/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */!function(e){function t(t){for(var r,i,o=t[0],a=t[1],s=0,l=[];s"/app/reportingRedirect";let P;!function(e){e.PENDING="pending",e.PROCESSING="processing",e.COMPLETED="completed",e.FAILED="failed",e.WARNINGS="completed_with_warnings"}(P||(P={}));const R="reportJobListing",T="reportJobRow"},function(e,t){e.exports=__kbnSharedDeps__.React},function(e,t){e.exports=__kbnSharedDeps__.KbnI18nReact},function(e,t){e.exports=__kbnSharedDeps__.ElasticEui},function(e,t,r){r.r(t);var n=__kbnBundles__.get("plugin/kibanaReact/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(n))},function(e,t){e.exports=__kbnSharedDeps__.Rxjs},function(e,t){e.exports=__kbnSharedDeps__.RxjsOperators},function(e,t){e.exports=__kbnSharedDeps__.Moment},function(e,t,r){"use strict";r.d(t,"c",(function(){return a}));var n=r(22);r.d(t,"a",(function(){return n.AppNavLinkStatus}));var i=r(23);r.d(t,"d",(function(){return i.useRequest}));var o=r(7);r.d(t,"b",(function(){return o.KibanaContextProvider}));const a=()=>Object(o.useKibana)()},function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));const n=e=>{switch(e.state){case"valid":default:return{showLinks:!0,enableLinks:!0,message:""};case"invalid":return{showLinks:!1,enableLinks:!1,message:"Your license does not support Reporting. Please upgrade your license."};case"unavailable":return{showLinks:!0,enableLinks:!1,message:"You cannot use Reporting because license information is not available at this time."};case"expired":return{showLinks:!0,enableLinks:!1,message:"You cannot use Reporting because your license has expired."}}}},function(e,t,r){"use strict";r.d(t,"a",(function(){return VisualReportingSoftDisabledError}));var n=r(1),i=r.n(n),o=r(2);class ReportingError extends Error{constructor(e){super(),this.details=e}get message(){const e="ReportingError";return this.details?`${e}(code: ${this.code}) "${this.details}"`:`${e}(code: ${this.code})`}toString(){return this.message}}class InvalidLayoutParametersError extends ReportingError{get code(){return InvalidLayoutParametersError.code}}i()(InvalidLayoutParametersError,"code","invalid_layout_parameters_error");class DisallowedOutgoingUrl extends ReportingError{get code(){return DisallowedOutgoingUrl.code}}i()(DisallowedOutgoingUrl,"code","disallowed_outgoing_url_error");class AuthenticationExpiredError extends ReportingError{get code(){return AuthenticationExpiredError.code}}i()(AuthenticationExpiredError,"code","authentication_expired_error");class QueueTimeoutError extends ReportingError{get code(){return QueueTimeoutError.code}}i()(QueueTimeoutError,"code","queue_timeout_error");class UnknownError extends ReportingError{get code(){return UnknownError.code}}i()(UnknownError,"code","unknown_error");class PdfWorkerOutOfMemoryError extends ReportingError{get code(){return PdfWorkerOutOfMemoryError.code}humanFriendlyMessage(){return o.i18n.translate("reporting.common.pdfWorkerOutOfMemoryErrorMessage",{defaultMessage:"Can't generate a PDF due to insufficient memory. Try making a smaller PDF and retrying this report."})}}i()(PdfWorkerOutOfMemoryError,"code","pdf_worker_out_of_memory_error");class BrowserCouldNotLaunchError extends ReportingError{get code(){return BrowserCouldNotLaunchError.code}humanFriendlyMessage(){return o.i18n.translate("reporting.common.browserCouldNotLaunchErrorMessage",{defaultMessage:"Can't generate screenshots because the browser did not launch. See the server logs for more information."})}}i()(BrowserCouldNotLaunchError,"code","browser_could_not_launch_error");class BrowserUnexpectedlyClosedError extends ReportingError{get code(){return BrowserUnexpectedlyClosedError.code}}i()(BrowserUnexpectedlyClosedError,"code","browser_unexpectedly_closed_error");class BrowserScreenshotError extends ReportingError{get code(){return BrowserScreenshotError.code}}i()(BrowserScreenshotError,"code","browser_screenshot_error");class KibanaShuttingDownError extends ReportingError{get code(){return KibanaShuttingDownError.code}}i()(KibanaShuttingDownError,"code","kibana_shutting_down_error");class VisualReportingSoftDisabledError extends ReportingError{get code(){return VisualReportingSoftDisabledError.code}humanFriendlyMessage(){return o.i18n.translate("reporting.common.cloud.insufficientSystemMemoryError",{defaultMessage:"Can't generate this report due to insufficient memory."})}}i()(VisualReportingSoftDisabledError,"code","visual_reporting_soft_disabled_error")},function(e,t,r){e.exports=r(20)(1466)},function(e,t,r){r.r(t);var n=__kbnBundles__.get("plugin/embeddable/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(n))},function(e,t,r){"use strict";const n=r(31),i=r(32),o=r(33);function a(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function s(e,t){return t.encode?t.strict?n(e):encodeURIComponent(e):e}function c(e,t){return t.decode?i(e):e}function l(e){return Array.isArray(e)?e.sort():"object"==typeof e?l(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function u(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function p(e){const t=(e=u(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function d(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function g(e,t){a((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,n)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"comma":case"separator":return(t,r,n)=>{const i="string"==typeof r&&r.split("").indexOf(e.arrayFormatSeparator)>-1?r.split(e.arrayFormatSeparator).map((t=>c(t,e))):null===r?r:c(r,e);n[t]=i};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t),n=Object.create(null);if("string"!=typeof e)return n;if(!(e=e.trim().replace(/^[?#&]/,"")))return n;for(const i of e.split("&")){let[e,a]=o(t.decode?i.replace(/\+/g," "):i,"=");a=void 0===a?null:["comma","separator"].includes(t.arrayFormat)?a:c(a,t),r(c(e,t),a,n)}for(const e of Object.keys(n)){const r=n[e];if("object"==typeof r&&null!==r)for(const e of Object.keys(r))r[e]=d(r[e],t);else n[e]=d(r,t)}return!1===t.sort?n:(!0===t.sort?Object.keys(n).sort():Object.keys(n).sort(t.sort)).reduce(((e,t)=>{const r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=l(r):e[t]=r,e}),Object.create(null))}t.extract=p,t.parse=g,t.stringify=(e,t)=>{if(!e)return"";a((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],n=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const i=r.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[s(t,e),"[",i,"]"].join("")]:[...r,[s(t,e),"[",s(i,e),"]=",s(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[s(t,e),"[]"].join("")]:[...r,[s(t,e),"[]=",s(n,e)].join("")];case"comma":case"separator":return t=>(r,n)=>null==n||0===n.length?r:0===r.length?[[s(t,e),"=",s(n,e)].join("")]:[[r,s(n,e)].join(e.arrayFormatSeparator)];default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,s(t,e)]:[...r,[s(t,e),"=",s(n,e)].join("")]}}(t),i={};for(const t of Object.keys(e))r(t)||(i[t]=e[t]);const o=Object.keys(i);return!1!==t.sort&&o.sort(t.sort),o.map((r=>{const i=e[r];return void 0===i?"":null===i?s(r,t):Array.isArray(i)?i.reduce(n(r),[]).join("&"):s(r,t)+"="+s(i,t)})).filter((e=>e.length>0)).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[r,n]=o(e,"#");return Object.assign({url:r.split("?")[0]||"",query:g(p(e),t)},t&&t.parseFragmentIdentifier&&n?{fragmentIdentifier:c(n,t)}:{})},t.stringifyUrl=(e,r)=>{r=Object.assign({encode:!0,strict:!0},r);const n=u(e.url).split("?")[0]||"",i=t.extract(e.url),o=t.parse(i,{sort:!1}),a=Object.assign(o,e.query);let c=t.stringify(a,r);c&&(c=`?${c}`);let l=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(e.url);return e.fragmentIdentifier&&(l=`#${s(e.fragmentIdentifier,r)}`),`${n}${c}${l}`}},function(e,t){e.exports=__kbnSharedDeps__.KbnRison},function(e,t,r){r.r(t);var n=__kbnBundles__.get("plugin/discover/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(n))},function(e,t,r){"use strict";r.d(t,"a",(function(){return c})),r.d(t,"d",(function(){return l})),r.d(t,"c",(function(){return p})),r.d(t,"b",(function(){return reporting_api_client_ReportingAPIClient}));var n=r(4),i=r.n(n),o=r(11),a=r(0);const s=Object(n.createContext)(void 0),c=({apiClient:e,children:t})=>{const{services:{http:r}}=Object(o.c)();return Object(a.jsx)(s.Provider,{value:{http:r,apiClient:e}},t)},l=()=>{const e=Object(n.useContext)(s);if(!e)throw new Error('"useInternalApiClient" can only be used inside of "InternalApiClientContext"');return e};var u=r(3);const p=()=>{const{services:{http:e}}=Object(o.c)();return Object(o.d)(e,{path:u.e.MIGRATE.GET_ILM_POLICY_STATUS,method:"get"})};var d=r(1),g=r.n(d),h=r(2),b=r(17),f=r.n(b),m=r(10),j=r.n(m),_=r(16);var y=r(6);const{COMPLETED:v,FAILED:O,PENDING:x,PROCESSING:S,WARNINGS:w}=u.g;class job_Job{constructor(e){var t,r,n,i,o,a;g()(this,"id",void 0),g()(this,"index",void 0),g()(this,"objectType",void 0),g()(this,"title",void 0),g()(this,"isDeprecated",void 0),g()(this,"spaceId",void 0),g()(this,"browserTimezone",void 0),g()(this,"layout",void 0),g()(this,"version",void 0),g()(this,"jobtype",void 0),g()(this,"created_by",void 0),g()(this,"created_at",void 0),g()(this,"started_at",void 0),g()(this,"completed_at",void 0),g()(this,"status",void 0),g()(this,"attempts",void 0),g()(this,"max_attempts",void 0),g()(this,"timeout",void 0),g()(this,"kibana_name",void 0),g()(this,"kibana_id",void 0),g()(this,"size",void 0),g()(this,"content_type",void 0),g()(this,"csv_contains_formulas",void 0),g()(this,"max_size_reached",void 0),g()(this,"metrics",void 0),g()(this,"warnings",void 0),g()(this,"error_code",void 0),g()(this,"locatorParams",void 0),g()(this,"queue_time_ms",void 0),g()(this,"execution_time_ms",void 0),this.id=e.id,this.index=e.index,this.jobtype=e.jobtype,this.objectType=e.payload.objectType,this.title=e.payload.title,this.layout=e.payload.layout,this.version=e.payload.version,this.created_by=e.created_by,this.created_at=e.created_at,this.started_at=e.started_at,this.completed_at=e.completed_at,this.status=e.status,this.attempts=e.attempts,this.max_attempts=e.max_attempts,this.timeout=e.timeout,this.kibana_name=e.kibana_name,this.kibana_id=e.kibana_id,this.browserTimezone=e.payload.browserTimezone,this.size=null===(t=e.output)||void 0===t?void 0:t.size,this.content_type=null===(r=e.output)||void 0===r?void 0:r.content_type,this.isDeprecated=e.payload.isDeprecated||!1,this.spaceId=e.payload.spaceId,this.csv_contains_formulas=null===(n=e.output)||void 0===n?void 0:n.csv_contains_formulas,this.max_size_reached=null===(i=e.output)||void 0===i?void 0:i.max_size_reached,this.warnings=null===(o=e.output)||void 0===o?void 0:o.warnings,this.error_code=null===(a=e.output)||void 0===a?void 0:a.error_code,this.locatorParams=e.payload.locatorParams,this.metrics=e.metrics,this.queue_time_ms=e.queue_time_ms,this.execution_time_ms=e.execution_time_ms}getStatusMessage(){const e=this.status;let t,r;return e===x?t=h.i18n.translate("xpack.reporting.jobStatusDetail.pendingStatusReachedText",{defaultMessage:"Waiting for job to process."}):e===S?t=h.i18n.translate("xpack.reporting.jobStatusDetail.attemptXofY",{defaultMessage:"Attempt {attempts} of {max_attempts}.",values:{attempts:this.attempts,max_attempts:this.max_attempts}}):this.getWarnings()?t=h.i18n.translate("xpack.reporting.jobStatusDetail.warningsText",{defaultMessage:"See report info for warnings."}):this.getError()&&(t=h.i18n.translate("xpack.reporting.jobStatusDetail.errorText",{defaultMessage:"See report info for error details."})),this.isDeprecated&&(r=Object(a.jsx)(y.EuiText,{size:"s"}," ",Object(a.jsx)(y.EuiTextColor,{color:"warning"},h.i18n.translate("xpack.reporting.jobStatusDetail.deprecatedText",{defaultMessage:"This is a deprecated export type. Automation of this report will need to be re-created for compatibility with future versions of Kibana."})))),t?Object(a.jsx)(i.a.Fragment,null,Object(a.jsx)(y.EuiText,{size:"s"},Object(a.jsx)(y.EuiTextColor,{color:"subdued"},t)),r||null):null}get prettyStatus(){var e;return null!==(e=E.get(this.status))&&void 0!==e?e:h.i18n.translate("xpack.reporting.jobStatusDetail.unknownText",{defaultMessage:"Unknown"})}get canLinkToKibanaApp(){return Boolean(this.locatorParams)}get isDownloadReady(){return this.status===u.g.COMPLETED||this.status===u.g.WARNINGS}get prettyJobTypeName(){switch(this.jobtype){case"printable_pdf":case"printable_pdf_v2":return h.i18n.translate("xpack.reporting.jobType.pdfOutputName",{defaultMessage:"PDF"});case"PNG":case"PNGV2":return h.i18n.translate("xpack.reporting.jobType.pngOutputName",{defaultMessage:"PNG"});case"csv_searchsource":return h.i18n.translate("xpack.reporting.jobType.csvOutputName",{defaultMessage:"CSV"});default:return}}get prettyTimeout(){if(null==this.timeout)return h.i18n.translate("xpack.reporting.jobStatusDetail.timeoutSecondsUnknown",{defaultMessage:"Unknown"});const e=this.timeout/1e3;return h.i18n.translate("xpack.reporting.jobStatusDetail.timeoutSeconds",{defaultMessage:"{timeout} seconds",values:{timeout:e}})}getCreatedAtDate(){return this.formatDate(this.created_at)}getCreatedBy(){return this.created_by||h.i18n.translate("xpack.reporting.jobCreatedBy.unknownUserPlaceholderText",{defaultMessage:"Unknown"})}getCreatedAtLabel(){return this.created_by?Object(a.jsx)(i.a.Fragment,null,Object(a.jsx)("div",null,this.formatDate(this.created_at)),Object(a.jsx)("span",null,this.created_by)):this.formatDate(this.created_at)}getError(){if(this.status===O)return this.warnings}getDeprecatedMessage(){if(this.isDeprecated)return h.i18n.translate("xpack.reporting.jobWarning.exportTypeDeprecated",{defaultMessage:"This is a deprecated export type. Automation of this report will need to be re-created for compatibility with future versions of Kibana."})}getWarnings(){var e;const t=[],r=this.getDeprecatedMessage();if(r&&t.push(r),this.csv_contains_formulas&&t.push(h.i18n.translate("xpack.reporting.jobWarning.csvContainsFormulas",{defaultMessage:"Your CSV contains characters that spreadsheet applications might interpret as formulas."})),this.max_size_reached&&t.push(h.i18n.translate("xpack.reporting.jobWarning.maxSizeReachedTooltip",{defaultMessage:"Your search reached the max size and contains partial data."})),this.status!==O&&null!==(e=this.warnings)&&void 0!==e&&e.length&&t.push(...this.warnings),t.length)return Object(a.jsx)("ul",null,t.map(((e,t)=>Object(a.jsx)("li",{key:`warning-key-${t}`},e))))}getPrettyStatusTimestamp(){return this.formatDate(this.getStatusTimestamp())}formatDate(e){try{return j()(e).format("YYYY-MM-DD @ hh:mm A")}catch(t){return e}}getStatusTimestamp(){const e=this.status;return e===S&&this.started_at?this.started_at:this.completed_at&&[v,O,w].includes(e)?this.completed_at:this.created_at}}const E=new Map([[x,h.i18n.translate("xpack.reporting.jobStatuses.pendingText",{defaultMessage:"Pending"})],[S,h.i18n.translate("xpack.reporting.jobStatuses.processingText",{defaultMessage:"Processing"})],[v,h.i18n.translate("xpack.reporting.jobStatuses.completedText",{defaultMessage:"Completed"})],[w,h.i18n.translate("xpack.reporting.jobStatuses.warningText",{defaultMessage:"Completed"})],[O,h.i18n.translate("xpack.reporting.jobStatuses.failedText",{defaultMessage:"Failed"})]]);class reporting_api_client_ReportingAPIClient{constructor(e,t,r){g()(this,"http",void 0),g()(this,"getManagementLink",(()=>this.http.basePath.prepend(u.q))),g()(this,"getDownloadLink",(e=>this.http.basePath.prepend(`${u.e.JOBS.DOWNLOAD_PREFIX}/${e}`))),g()(this,"getServerBasePath",(()=>this.http.basePath.serverBasePath)),this.uiSettings=t,this.kibanaVersion=r,this.http=e}getKibanaAppHref(e){const t=Object(_.stringify)({jobId:e.id});return`${(({basePath:e,appPath:t,spaceId:r})=>void 0===r||"default"===r.toLowerCase()?`${e}${t}`:`${e}/s/${r}${t}`)({basePath:this.http.basePath.serverBasePath,spaceId:e.spaceId,appPath:Object(u.v)()})}?${t}`}getReportURL(e){return this.http.basePath.prepend(`${u.e.JOBS.DOWNLOAD_PREFIX}/${e}`)}downloadReport(e){const t=this.getReportURL(e);window.open(t)}async deleteReport(e){return await this.http.delete(`${u.e.JOBS.DELETE_PREFIX}/${e}`)}async list(e=0,t=[]){const r={page:e};return t.length>0&&(r.ids=t.slice(0,10).join(",")),(await this.http.get(u.e.JOBS.LIST,{query:r,asSystemRequest:!0})).map((e=>new job_Job(e)))}async total(){return await this.http.get(u.e.JOBS.COUNT,{asSystemRequest:!0})}async getError(e){var t;const r=await this.getInfo(e);return null!==(t=r.warnings)&&void 0!==t&&t[0]?r.warnings[0]:h.i18n.translate("xpack.reporting.apiClient.unknownError",{defaultMessage:"Report job {job} failed. Error unknown.",values:{job:e}})}async getInfo(e){const t=await this.http.get(`${u.e.JOBS.INFO_PREFIX}/${e}`);return new job_Job(t)}async findForJobIds(e){return(await this.http.fetch(u.e.JOBS.LIST,{query:{page:0,ids:e.join(",")},method:"GET"})).map((e=>new job_Job(e)))}getReportingPublicJobPath(e,t){const r=Object(_.stringify)({jobParams:f.a.encode(t)});return`${this.http.basePath.prepend(u.p.GENERATE_PREFIX)}/${e}?${r}`}async createReportingJob(e,t){const r=f.a.encode(t),n=await this.http.post(`${u.e.GENERATE_PREFIX}/${e}`,{method:"POST",body:JSON.stringify({jobParams:r})});return(e=>{const t=(()=>{const e=sessionStorage.getItem(u.f);return e?JSON.parse(e):[]})();t.push(e),(e=>{sessionStorage.setItem(u.f,JSON.stringify(e))})(t)})(n.job.id),new job_Job(n.job)}async createImmediateReport(e){const{objectType:t,...r}=e;return this.http.post(u.e.DOWNLOAD_CSV,{asResponse:!0,body:JSON.stringify(r)})}getDecoratedJobParams(e){return{browserTimezone:"Browser"===this.uiSettings.get("dateFormat:tz")?j.a.tz.guess():this.uiSettings.get("dateFormat:tz"),version:this.kibanaVersion,...e}}verifyBrowser(){return this.http.post(u.e.DIAGNOSE.BROWSER)}verifyScreenCapture(){return this.http.post(u.e.DIAGNOSE.SCREENSHOT)}migrateReportingIndicesIlmPolicy(){return this.http.put(u.e.MIGRATE.MIGRATE_ILM_POLICY)}}},function(e,t){e.exports=__kbnSharedDeps_npm__},function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r(10);const n=e=>"number"==typeof e?e:e.asMilliseconds()},function(e,t,r){r.r(t);var n=__kbnBundles__.get("entry/core/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(n))},function(e,t,r){r.r(t);var n=__kbnBundles__.get("plugin/esUiShared/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(n))},function(e,t,r){"use strict";r.d(t,"a",(function(){return s})),r(4);var n=r(2),i=r(5),o=r(6),a=r(0);const s={cloud:{insufficientMemoryError:e=>Object(a.jsx)(i.FormattedMessage,{id:"xpack.reporting.listing.infoPanel.callout.cloud.insufficientMemoryError",defaultMessage:"Kibana needs more memory to generate this report. Check {link}.",values:{link:Object(a.jsx)(o.EuiLink,{href:e},n.i18n.translate("xpack.reporting.listing.infoPanel.callout.cloud.insufficientMemoryError.urlLink",{defaultMessage:"RAM requirements"}))}})}}},function(e,t){e.exports=__kbnSharedDeps__.Lodash},function(e,t,r){"use strict";r.d(t,"a",(function(){return i})),r.d(t,"b",(function(){return o}));var n=r(3);const i=({sharingData:e})=>null!=e.locatorParams,o=e=>{switch(e){case n.h:case n.i:return"PDF";case n.a:case n.b:return"CSV";case n.l:case n.m:return"PNG";default:return e}}},function(e,t,r){"use strict";r.d(t,"b",(function(){return n.a})),r.d(t,"a",(function(){return i})),r(1),r(25);var n=r(13);const i="downloadCsvReport";r(10)},function(e,t,r){r.r(t);var n=__kbnBundles__.get("plugin/uiActions/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(n))},function(e,t,r){r(30),__kbnBundles__.define("plugin/reporting/public",r,34)},function(e,t,r){r.p=window.__kbnPublicPath__.reporting},function(e,t,r){"use strict";e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`))},function(e,t,r){"use strict";var n="%[a-f0-9]{2}",i=new RegExp("("+n+")|([^%]+?)","gi"),o=new RegExp("("+n+")+","gi");function a(e,t){try{return[decodeURIComponent(e.join(""))]}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],a(r),a(n))}function s(e){try{return decodeURIComponent(e)}catch(n){for(var t=e.match(i)||[],r=1;r{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]}},function(e,t,r){"use strict";r.r(t),r.d(t,"plugin",(function(){return V}));var n=r(1),i=r.n(n),o=r(2),a=r(8),s=r(9),c=r(15),l=r(21),u=r(19),p=r(3),d=r(6),g=r(5),h=r(4),b=r.n(h),f=r(7),m=r(13),j=r(24),_=r(0);const y=(e,t,r,n,i)=>({title:Object(f.toMountPoint)(Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.error.couldNotCreateReportTitle",defaultMessage:"Cannot create {reportType} report for '{reportObjectTitle}'.",values:{reportType:t.jobtype,reportObjectTitle:t.title}}),{theme$:n.theme$}),text:Object(f.toMountPoint)(Object(_.jsx)(b.a.Fragment,null,Object(_.jsx)(d.EuiCallOut,{size:"m",color:"danger","data-test-errorText":e},t.errorCode===m.a.code?j.a.cloud.insufficientMemoryError(i.links.reporting.cloudMinimumRequirements):e),Object(_.jsx)(d.EuiSpacer,null),Object(_.jsx)("p",null,Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.error.checkManagement",defaultMessage:"Go to {path} for details.",values:{path:Object(_.jsx)("a",{href:r()},Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.error.reportingSectionUrlLinkLabel",defaultMessage:"Stack Management > Kibana > Reporting"}))}}))),{theme$:n.theme$}),iconType:void 0,"data-test-subj":"completeReportFailure"}),v=(e,t,r)=>({text:Object(f.toMountPoint)(Object(_.jsx)(b.a.Fragment,null,Object(_.jsx)(d.EuiCallOut,{title:e,color:"danger",iconType:"warning"},t.toString()),Object(_.jsx)(d.EuiSpacer,null),Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.error.tryRefresh",defaultMessage:"Try refreshing the page."})),{theme$:r.theme$}),iconType:void 0}),O=({getUrl:e,job:t})=>Object(_.jsx)(d.EuiButton,{size:"s","data-test-subj":"downloadCompletedReportButton",href:e(t.id),target:"_blank"},Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.downloadReportButtonLabel",defaultMessage:"Download report"})),x=({getUrl:e})=>Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.reportLinkDescription",defaultMessage:"Download it now, or get it later in {path}.",values:{path:Object(_.jsx)("a",{href:e()},Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.reportLink.reportingSectionUrlLinkLabel",defaultMessage:"Stack Management > Reporting"}))}}),S=(e,t,r,n)=>({title:Object(f.toMountPoint)(Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.successfullyCreatedReportNotificationTitle",defaultMessage:"{reportType} created for '{reportObjectTitle}'",values:{reportType:e.jobtype,reportObjectTitle:e.title}}),{theme$:n.theme$}),color:"success",text:Object(f.toMountPoint)(Object(_.jsx)(b.a.Fragment,null,Object(_.jsx)("p",null,Object(_.jsx)(x,{getUrl:t})),Object(_.jsx)(O,{getUrl:r,job:e})),{theme$:n.theme$}),"data-test-subj":"completeReportSuccess"}),w=(e,t,r,n)=>({title:Object(f.toMountPoint)(Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportTitle",defaultMessage:"{reportType} may contain formulas",values:{reportType:e.jobtype}}),{theme$:n.theme$}),text:Object(f.toMountPoint)(Object(_.jsx)(b.a.Fragment,null,Object(_.jsx)("p",null,Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.csvContainsFormulas.formulaReportMessage",defaultMessage:"The report '{reportObjectTitle}' contains characters which spreadsheet applications can interpret as formulas.",values:{reportObjectTitle:e.title}})),Object(_.jsx)("p",null,Object(_.jsx)(x,{getUrl:t})),Object(_.jsx)(O,{getUrl:r,job:e})),{theme$:n.theme$}),"data-test-subj":"completeReportCsvFormulasWarning"}),E=(e,t,r,n)=>({title:Object(f.toMountPoint)(Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.maxSizeReached.partialReportTitle",defaultMessage:"Created partial {reportType} for '{reportObjectTitle}'",values:{reportType:e.jobtype,reportObjectTitle:e.title}}),{theme$:n.theme$}),text:Object(f.toMountPoint)(Object(_.jsx)(b.a.Fragment,null,Object(_.jsx)("p",null,Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.maxSizeReached.partialReportDescription",defaultMessage:"The report reached the max size and contains partial data."})),Object(_.jsx)("p",null,Object(_.jsx)(x,{getUrl:t})),Object(_.jsx)(O,{getUrl:r,job:e})),{theme$:n.theme$}),"data-test-subj":"completeReportMaxSizeWarning"}),C=(e,t,r,n)=>({title:Object(f.toMountPoint)(Object(_.jsx)(g.FormattedMessage,{id:"xpack.reporting.publicNotifier.warning.title",defaultMessage:"{reportType} completed with issues",values:{reportType:e.jobtype}}),{theme$:n.theme$}),text:Object(f.toMountPoint)(Object(_.jsx)(b.a.Fragment,null,Object(_.jsx)("p",null,Object(_.jsx)(x,{getUrl:t})),Object(_.jsx)(O,{getUrl:r,job:e})),{theme$:n.theme$}),"data-test-subj":"completeReportWarning"});function k(e){var t;return{id:e.id,status:e.status,title:e.title,jobtype:null!==(t=e.prettyJobTypeName)&&void 0!==t?t:e.jobtype,maxSizeReached:e.max_size_reached,csvContainsFormulas:e.csv_contains_formulas,errorCode:e.error_code}}class stream_handler_ReportingNotifierStreamHandler{constructor(e,t,r,n){this.notifications=e,this.apiClient=t,this.theme=r,this.docLinks=n}showNotifications({completed:e,failed:t}){return a.from((async()=>{const r={toastLifeTimeMs:864e5};for(const t of e)t.csvContainsFormulas?this.notifications.toasts.addWarning(w(t,this.apiClient.getManagementLink,this.apiClient.getDownloadLink,this.theme),r):t.maxSizeReached?this.notifications.toasts.addWarning(E(t,this.apiClient.getManagementLink,this.apiClient.getDownloadLink,this.theme),r):t.status===p.g.WARNINGS?this.notifications.toasts.addWarning(C(t,this.apiClient.getManagementLink,this.apiClient.getDownloadLink,this.theme),r):this.notifications.toasts.addSuccess(S(t,this.apiClient.getManagementLink,this.apiClient.getDownloadLink,this.theme),r);for(const e of t){const t=await this.apiClient.getError(e.id);this.notifications.toasts.addDanger(y(t,e,this.apiClient.getManagementLink,this.theme,this.docLinks))}return{completed:e,failed:t}})())}findChangedStatusJobs(e){return a.from(this.apiClient.findForJobIds(e)).pipe(Object(s.map)((t=>{const r=[],n=[],i=[];for(const o of t){const{id:t,status:a}=o;e.includes(t)&&(a===p.g.COMPLETED||a===p.g.WARNINGS?r.push(k(o)):a===p.g.FAILED?n.push(k(o)):i.push(t))}var o;return o=i,sessionStorage.setItem(p.f,JSON.stringify(o)),{completed:r,failed:n}})),Object(s.catchError)((e=>(this.notifications.toasts.addDanger(v(o.i18n.translate("xpack.reporting.publicNotifier.httpErrorMessage",{defaultMessage:"Could not check Reporting job status!"}),e,this.theme)),window.console.error(e),a.of({completed:[],failed:[]})))))}}var P=r(18),R=r(28),T=r(27),M=r(12);class get_csv_panel_action_ReportingCsvPanelAction{constructor({core:e,apiClient:t,startServices$:r,usesUiCapabilities:n}){i()(this,"isDownloading",void 0),i()(this,"type",""),i()(this,"id",T.a),i()(this,"licenseHasDownloadCsv",!1),i()(this,"capabilityHasDownloadCsv",!1),i()(this,"notifications",void 0),i()(this,"apiClient",void 0),i()(this,"startServices$",void 0),i()(this,"usesUiCapabilities",void 0),i()(this,"isCompatible",(async e=>{if(await new Promise((e=>{this.startServices$.subscribe((([{application:t},{licensing:r}])=>{var n;r.license$.subscribe((e=>{const t=e.check("reporting","basic"),{showLinks:r}=Object(M.a)(t);this.licenseHasDownloadCsv=r})),this.usesUiCapabilities?this.capabilityHasDownloadCsv=!0===(null===(n=t.capabilities.dashboard)||void 0===n?void 0:n.downloadCsv):this.capabilityHasDownloadCsv=!0,e()}))})),!this.licenseHasDownloadCsv||!this.capabilityHasDownloadCsv)return!1;const{embeddable:t}=e;if("search"!==t.type)return!1;const r=t.getSavedSearch().searchSource.getField("query");return!(r&&Boolean(r&&"sql"in r)||t.getInput().viewMode===c.ViewMode.EDIT)})),i()(this,"execute",(async e=>{const{embeddable:t}=e;if(!function(e){return e.type===P.SEARCH_EMBEDDABLE_TYPE}(t)||!await this.isCompatible(e))throw new R.IncompatibleActionError;if(this.isDownloading)return;const r=t.getSavedSearch(),{columns:n,getSearchSource:i}=await this.getSharingData(r),a=this.apiClient.getDecoratedJobParams({searchSource:i({addGlobalTimeFilter:!t.hasTimeRange(),absoluteTime:!0}),columns:n,title:r.title||"",objectType:"downloadCsv"});this.isDownloading=!0,this.notifications.toasts.addSuccess({title:o.i18n.translate("xpack.reporting.dashboard.csvDownloadStartedTitle",{defaultMessage:"CSV Download Started"}),text:o.i18n.translate("xpack.reporting.dashboard.csvDownloadStartedMessage",{defaultMessage:"Your CSV will download momentarily."}),"data-test-subj":"csvDownloadStarted"}),await this.apiClient.createImmediateReport(a).then((({body:e,response:t})=>{this.isDownloading=!1;const n=`${r.title}.csv`,i=new Blob([e],{type:(null==t?void 0:t.headers.get("content-type"))||void 0});if(window.navigator.msSaveOrOpenBlob)return window.navigator.msSaveOrOpenBlob(i,n);const o=window.document.createElement("a"),a=window.URL.createObjectURL(i);o.href=a,o.download=n,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(a),document.body.removeChild(o)})).catch(this.onGenerationFail.bind(this))})),this.isDownloading=!1,this.notifications=e.notifications,this.apiClient=t,this.startServices$=r,this.usesUiCapabilities=n}getIconType(){return"document"}getDisplayName(){return o.i18n.translate("xpack.reporting.dashboard.downloadCsvPanelTitle",{defaultMessage:"Download CSV"})}async getSharingData(e){const[{uiSettings:t},{data:r}]=await a.firstValueFrom(this.startServices$),{getSharingData:n}=await Object(P.loadSharingDataHelpers)();return await n(e.searchSource,e,{uiSettings:t,data:r})}onGenerationFail(e){this.isDownloading=!1,this.notifications.toasts.addDanger({title:o.i18n.translate("xpack.reporting.dashboard.failedCsvDownloadTitle",{defaultMessage:"CSV download failed"}),text:o.i18n.translate("xpack.reporting.dashboard.failedCsvDownloadMessage",{defaultMessage:"We couldn't generate your CSV at this time."}),"data-test-subj":"downloadCsvFail"})}}var D=r(14),I=r.n(D);const N=e=>Object(_.jsx)(h.Fragment,null,Object(_.jsx)(d.EuiSpacer,null),Object(_.jsx)(d.EuiFlexGroup,{justifyContent:"spaceAround"},Object(_.jsx)(d.EuiFlexItem,{grow:!1},Object(_.jsx)(d.EuiLoadingSpinner,{size:"l"}))),Object(_.jsx)(d.EuiSpacer,null)),F=Object(h.lazy)((()=>Promise.all([r.e(0),r.e(4)]).then(r.bind(null,56)).then((({ScreenCapturePanelContent:e})=>({default:e}))))),L=e=>Object(_.jsx)(h.Suspense,{fallback:Object(_.jsx)(N,null)},Object(_.jsx)(F,e));function A(e,t){return{ReportingPanelPDF:r=>Object(_.jsx)(L,I()({requiresSavedState:!1,reportType:p.j,apiClient:t,toasts:e.notifications.toasts,uiSettings:e.uiSettings,theme:e.theme},r)),ReportingPanelPDFV2:r=>Object(_.jsx)(L,I()({requiresSavedState:!1,reportType:p.k,apiClient:t,toasts:e.notifications.toasts,uiSettings:e.uiSettings,theme:e.theme},r)),ReportingPanelPNGV2:r=>Object(_.jsx)(L,I()({requiresSavedState:!1,reportType:p.o,apiClient:t,toasts:e.notifications.toasts,uiSettings:e.uiSettings,theme:e.theme},r))}}var $=r(11);const U=Object(h.lazy)((()=>r.e(0).then(r.bind(null,55)).then((({ReportingPanelContent:e})=>({default:e}))))),B=e=>Object(_.jsx)(h.Suspense,{fallback:Object(_.jsx)(N,null)},Object(_.jsx)(U,e));var G=r(26);const J=(e,t,r)=>()=>{const{objectType:n,sharingData:{title:i,layout:o,locatorParams:a}}=t,s={objectType:n,layout:o,title:i};if("printablePdfV2"===r)return{...s,locatorParams:[a]};if("pngV2"===r)return{...s,locatorParams:a};const c=t.shareableUrl.replace(window.location.origin+e.getServerBasePath(),"");return"printablePdf"===r?{...s,relativeUrls:[c]}:{...s,relativeUrl:c}};class plugin_ReportingPublicPlugin{constructor(e){i()(this,"kibanaVersion",void 0),i()(this,"apiClient",void 0),i()(this,"stop$",new a.ReplaySubject(1)),i()(this,"title",o.i18n.translate("xpack.reporting.management.reportingTitle",{defaultMessage:"Reporting"})),i()(this,"breadcrumbText",o.i18n.translate("xpack.reporting.breadcrumb",{defaultMessage:"Reporting"})),i()(this,"config",void 0),i()(this,"contract",void 0),this.config=e.config.get(),this.kibanaVersion=e.env.packageInfo.version}getApiClient(e,t){return this.apiClient||(this.apiClient=new u.b(e,t,this.kibanaVersion)),this.apiClient}getContract(e){if(e&&(this.contract={usesUiCapabilities:()=>{var e;return!1===(null===(e=this.config.roles)||void 0===e?void 0:e.enabled)},components:A(e,this.getApiClient(e.http,e.uiSettings))}),!this.contract)throw new Error("Setup error in Reporting plugin!");return this.contract}setup(e,t){const{getStartServices:n,uiSettings:i}=e,{home:s,management:l,screenshotMode:u,share:d,uiActions:g}=t,h=a.from(n()),b=!this.config.roles.enabled,f=this.getApiClient(e.http,e.uiSettings);s.featureCatalogue.register({id:"reporting",title:o.i18n.translate("xpack.reporting.registerFeature.reportingTitle",{defaultMessage:"Reporting"}),description:o.i18n.translate("xpack.reporting.registerFeature.reportingDescription",{defaultMessage:"Manage your reports generated from Discover, Visualize, and Dashboard."}),icon:"reportingApp",path:"/app/management/insightsAndAlerting/reporting",showOnHomePage:!1,category:"admin"}),l.sections.section.insightsAndAlerting.registerApp({id:"reporting",title:this.title,order:3,mount:async t=>{t.setBreadcrumbs([{text:this.breadcrumbText}]);const[[i,o],{mountManagementSection:a}]=await Promise.all([n(),r.e(2).then(r.bind(null,57))]),{docTitle:s}=i.chrome;s.change(this.title);const{license$:c}=o.licensing,l=await a(e,i,c,this.config.poll,f,d.url,t);return()=>{s.reset(),l()}}}),e.application.register({id:"reportingRedirect",mount:async e=>{const{mountRedirectApp:t}=await r.e(3).then(r.bind(null,58));return t({...e,apiClient:f,screenshotMode:u,share:d})},title:"Reporting redirect app",searchable:!1,chromeless:!0,exactRoute:!0,navLinkStatus:$.a.hidden}),g.addTriggerAction(c.CONTEXT_MENU_TRIGGER,new get_csv_panel_action_ReportingCsvPanelAction({core:e,apiClient:f,startServices$:h,usesUiCapabilities:b}));const m=this.getContract(e),{toasts:j}=e.notifications;return h.subscribe((([{application:t},{licensing:r}])=>{r.license$.subscribe((r=>{d.register((({apiClient:e,toasts:t,uiSettings:r,application:n,license:i,usesUiCapabilities:a,theme:s})=>({id:"csvReports",getShareMenuItems:({objectType:c,objectId:l,sharingData:u,onClose:d})=>{if("search"!==c)return[];const g=u.getSearchSource,h={title:u.title,objectType:c,columns:u.columns},b=e=>({...h,searchSource:g({addGlobalTimeFilter:!0,absoluteTime:!e})}),f=[],m=Object(M.a)(i.check("reporting","basic")),j=m.message,y=m.showLinks,v=!m.enableLinks;let O=!1;var x;if(O=!a||!0===(null===(x=n.capabilities.discover)||void 0===x?void 0:x.generateCsv),y&&O){const n=o.i18n.translate("xpack.reporting.shareContextMenu.csvReportsButtonLabel",{defaultMessage:"CSV Reports"});f.push({shareMenuItem:{name:n,icon:"document",toolTipContent:j,disabled:v,"data-test-subj":"CSVReports",sortOrder:1},panel:{id:"csvReportingPanel",title:n,content:Object(_.jsx)(B,{requiresSavedState:!1,apiClient:e,toasts:t,uiSettings:r,reportType:p.a,layoutId:void 0,objectId:l,getJobParams:b,onClose:d,theme:s})}})}return f}}))({apiClient:f,toasts:j,uiSettings:i,license:r,application:t,usesUiCapabilities:b,theme:e.theme})),(this.config.export_types.pdf.enabled||this.config.export_types.png.enabled)&&d.register((({apiClient:e,toasts:t,uiSettings:r,license:n,application:i,usesUiCapabilities:a,theme:s})=>({id:"screenCaptureReports",getShareMenuItems:({objectType:c,objectId:l,isDirty:u,onClose:p,shareableUrl:d,shareableUrlForSavedObject:g,...h})=>{const{enableLinks:b,showLinks:f,message:m}=Object(M.a)(n.check("reporting","gold")),j=m,y=f,v=!b;let O=!1,x=!1;var S,w;if(a?(O=!0===(null===(S=i.capabilities.dashboard)||void 0===S?void 0:S.generateScreenshot),x=!0===(null===(w=i.capabilities.visualize)||void 0===w?void 0:w.generateScreenshot)):(O=!0,x=!0),!y)return[];const E=["dashboard","visualization","lens"].includes(c);if(!E)return[];if("dashboard"===c&&!O)return[];if(E&&!x&&!O)return[];const{sharingData:C}=h,k=[],P=o.i18n.translate("xpack.reporting.shareContextMenu.pngReportsButtonLabel",{defaultMessage:"PNG Reports"}),R={shareableUrl:u?d:null!=g?g:d,objectType:c,sharingData:C},T=Object(G.a)(R),D=!T,I=T?"pngV2":"png",N={shareMenuItem:{name:P,icon:"document",toolTipContent:j,disabled:v||C.reportingDisabled,"data-test-subj":"PNGReports",sortOrder:10},panel:{id:"reportingPngPanel",title:P,content:Object(_.jsx)(L,{apiClient:e,toasts:t,uiSettings:r,reportType:I,objectId:l,requiresSavedState:D,getJobParams:J(e,R,I),isDirty:u,onClose:p,theme:s})}},F=o.i18n.translate("xpack.reporting.shareContextMenu.pdfReportsButtonLabel",{defaultMessage:"PDF Reports"}),A=T?"printablePdfV2":"printablePdf",$={shareMenuItem:{name:F,icon:"document",toolTipContent:j,disabled:v||C.reportingDisabled,"data-test-subj":"PDFReports",sortOrder:10},panel:{id:"reportingPdfPanel",title:F,content:Object(_.jsx)(L,{apiClient:e,toasts:t,uiSettings:r,reportType:A,objectId:l,requiresSavedState:D,layoutOption:"dashboard"===c?"print":void 0,getJobParams:J(e,R,A),isDirty:u,onClose:p,theme:s})}};return k.push(N),k.push($),k}}))({apiClient:f,toasts:j,uiSettings:i,license:r,application:t,usesUiCapabilities:b,theme:e.theme}))}))})),m}start(e){const{notifications:t,docLinks:r}=e,n=this.getApiClient(e.http,e.uiSettings),i=new stream_handler_ReportingNotifierStreamHandler(t,n,e.theme,r),c=Object(l.a)(this.config.poll.jobsRefresh.interval);return a.timer(0,c).pipe(Object(s.takeUntil)(this.stop$),Object(s.map)((()=>function(){const e=sessionStorage.getItem(p.f);return e?JSON.parse(e):[]}())),Object(s.filter)((e=>e.length>0)),Object(s.mergeMap)((e=>i.findChangedStatusJobs(e))),Object(s.mergeMap)((({completed:e,failed:t})=>i.showNotifications({completed:e,failed:t}))),Object(s.catchError)((r=>function(e,t,r){return e.toasts.addDanger(v(o.i18n.translate("xpack.reporting.publicNotifier.pollingErrorMessage",{defaultMessage:"Reporting notifier error!"}),t,r)),window.console.error(t),a.of({completed:[],failed:[]})}(t,r,e.theme)))).subscribe(),this.getContract()}stop(){this.stop$.next()}}function V(e){return new plugin_ReportingPublicPlugin(e)}},function(e,t){e.exports=__kbnSharedDeps__.ReactDom}]);