!function(e){function t(t){for(var r,n,o=t[0],a=t[1],i=0,h=[];i",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(h),u=["%","/","?",";","#"].concat(l),p=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=r(27);function y(e,t,r){if(e&&n.isObject(e)&&e instanceof o)return e;var s=new o;return s.parse(e,t,r),s}o.prototype.parse=function(e,t,r){if(!n.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),i=-1!==o&&o127?T+="x":T+=R[L];if(!T.match(d)){var k=M.slice(0,E),F=M.slice(E+1),N=R.match(f);N&&(k.push(N[1]),F.unshift(N[2])),F.length&&(y="/"+F.join(".")+y),this.hostname=k.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=s.toASCII(this.hostname));var B=this.port?":"+this.port:"",D=this.hostname||"";this.host=D+B,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==y[0]&&(y="/"+y))}if(!m[U])for(E=0,A=l.length;E0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())),r.search=e.search,r.query=e.query,n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!j.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var O=j.slice(-1)[0],x=(r.host||e.host||j.length>1)&&("."===O||".."===O)||""===O,E=0,P=j.length;P>=0;P--)"."===(O=j[P])?j.splice(P,1):".."===O?(j.splice(P,1),E++):E&&(j.splice(P,1),E--);if(!S&&!U)for(;E--;E)j.unshift("..");!S||""===j[0]||j[0]&&"/"===j[0].charAt(0)||j.unshift(""),x&&"/"!==j.join("/").substr(-1)&&j.push("");var C,M=""===j[0]||j[0]&&"/"===j[0].charAt(0);return _&&(r.hostname=r.host=M?"":j.length?j.shift():"",(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())),(S=S||r.host&&j.length)&&!M&&j.unshift(""),j.length?r.pathname=j.join("/"):(r.pathname=null,r.path=null),n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=i.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,r){var s,n=function(){var e=String.fromCharCode,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function n(e,t){if(!s[e]){s[e]={};for(var r=0;r>>8,r[2*s+1]=a%256}return r},decompressFromUint8Array:function(t){if(null==t)return o.decompress(t);for(var r=new Array(t.length/2),s=0,n=r.length;s>=1}else{for(n=1,s=0;s>=1}0==--u&&(u=Math.pow(2,d),d++),delete i[l]}else for(n=a[l],s=0;s>=1;0==--u&&(u=Math.pow(2,d),d++),a[h]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(i,l)){if(l.charCodeAt(0)<256){for(s=0;s>=1}else{for(n=1,s=0;s>=1}0==--u&&(u=Math.pow(2,d),d++),delete i[l]}else for(n=a[l],s=0;s>=1;0==--u&&(u=Math.pow(2,d),d++)}for(n=2,s=0;s>=1;for(;;){if(m<<=1,g==t-1){f.push(r(m));break}g++}return f.join("")},decompress:function(e){return null==e?"":""==e?null:o._decompress(e.length,32768,(function(t){return e.charCodeAt(t)}))},_decompress:function(t,r,s){var n,o,a,i,c,h,l,u=[],p=4,d=4,f=3,m="",g=[],b={val:s(0),position:r,index:1};for(n=0;n<3;n+=1)u[n]=n;for(a=0,c=Math.pow(2,2),h=1;h!=c;)i=b.val&b.position,b.position>>=1,0==b.position&&(b.position=r,b.val=s(b.index++)),a|=(i>0?1:0)*h,h<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),h=1;h!=c;)i=b.val&b.position,b.position>>=1,0==b.position&&(b.position=r,b.val=s(b.index++)),a|=(i>0?1:0)*h,h<<=1;l=e(a);break;case 1:for(a=0,c=Math.pow(2,16),h=1;h!=c;)i=b.val&b.position,b.position>>=1,0==b.position&&(b.position=r,b.val=s(b.index++)),a|=(i>0?1:0)*h,h<<=1;l=e(a);break;case 2:return""}for(u[3]=l,o=l,g.push(l);;){if(b.index>t)return"";for(a=0,c=Math.pow(2,f),h=1;h!=c;)i=b.val&b.position,b.position>>=1,0==b.position&&(b.position=r,b.val=s(b.index++)),a|=(i>0?1:0)*h,h<<=1;switch(l=a){case 0:for(a=0,c=Math.pow(2,8),h=1;h!=c;)i=b.val&b.position,b.position>>=1,0==b.position&&(b.position=r,b.val=s(b.index++)),a|=(i>0?1:0)*h,h<<=1;u[d++]=e(a),l=d-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),h=1;h!=c;)i=b.val&b.position,b.position>>=1,0==b.position&&(b.position=r,b.val=s(b.index++)),a|=(i>0?1:0)*h,h<<=1;u[d++]=e(a),l=d-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,f),f++),u[l])m=u[l];else{if(l!==d)return null;m=o+o.charAt(0)}g.push(m),u[d++]=o+m.charAt(0),o=m,0==--p&&(p=Math.pow(2,f),f++)}}};return o}();void 0===(s=function(){return n}.call(t,r,t,e))||(e.exports=s)},function(e,t){e.exports=__kbnSharedDeps_npm__},function(e,t){e.exports=__kbnSharedDeps__.ReactDom},function(e,t,r){"use strict";var s,n=function(){var e={};return function(t){if(void 0===e[t]){var r=document.querySelector(t);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}e[t]=r}return e[t]}}(),o=[];function a(e){for(var t=-1,r=0;rnew Promise(((o,a)=>{if("function"!=typeof t)throw new TypeError("Mapper function is required");if(!Number.isSafeInteger(r)&&r!==1/0||!(r>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);const i=[],c=[],h=e[Symbol.iterator]();let l=!1,u=!1,p=0,d=0;const f=()=>{if(l)return;const e=h.next(),r=d;if(d++,e.done)return u=!0,void(0===p&&(n||0===c.length?o(i):a(new s(c))));p++,(async()=>{try{const s=await e.value;i[r]=await t(s,r),p--,f()}catch(e){n?(l=!0,a(e)):(c.push(e),p--,f())}})()};for(let e=0;e0&&h>c&&(h=c);for(var l=0;l=0?(u=m.substr(0,g),p=m.substr(g+1)):(u=m,p=""),d=decodeURIComponent(u),f=decodeURIComponent(p),s(a,d)?n(a[d])?a[d].push(f):a[d]=[a[d],f]:a[d]=f}return a};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";var s=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,i){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),(function(a){var i=encodeURIComponent(s(a))+r;return n(e[a])?o(e[a],(function(e){return i+encodeURIComponent(s(e))})).join(t):i+encodeURIComponent(s(e[a]))})).join(t):i?encodeURIComponent(s(i))+r+encodeURIComponent(s(e)):""};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],s=0;se instanceof Error?e:null!==e&&"object"==typeof e?Object.assign(new Error(e.message),e):new Error(e)))).map((e=>"string"==typeof e.stack?n(e.stack).replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""):String(e))).join("\n");t="\n"+s(t,4),super(t),this.name="AggregateError",Object.defineProperty(this,"_errors",{value:e})}*[Symbol.iterator](){for(const e of this._errors)yield e}}e.exports=AggregateError},function(e,t,r){"use strict";e.exports=(e,t=1,r)=>{if(r={indent:" ",includeEmptyLines:!1,...r},"string"!=typeof e)throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if("number"!=typeof t)throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if("string"!=typeof r.indent)throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r.indent}\``);if(0===t)return e;const s=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return e.replace(s,r.indent.repeat(t))}},function(e,t,r){"use strict";const s=r(35),n=/\s+at.*(?:\(|\s)(.*)\)?/,o=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,a=void 0===s.homedir?"":s.homedir();e.exports=(e,t)=>(t=Object.assign({pretty:!1},t),e.replace(/\\/g,"/").split("\n").filter((e=>{const t=e.match(n);if(null===t||!t[1])return!0;const r=t[1];return!r.includes(".app/Contents/Resources/electron.asar")&&!r.includes(".app/Contents/Resources/default_app.asar")&&!o.test(r)})).filter((e=>""!==e.trim())).map((e=>t.pretty?e.replace(n,((e,t)=>e.replace(t,t.replace(a,"~")))):e)).join("\n"))},function(e,t){},function(e,t,r){"use strict";r.r(t),r.d(t,"CSV_QUOTE_VALUES_SETTING",(function(){return n})),r.d(t,"CSV_SEPARATOR_SETTING",(function(){return s})),r.d(t,"useLocatorUrl",(function(){return h})),r.d(t,"downloadMultipleAs",(function(){return A})),r.d(t,"downloadFileAs",(function(){return M})),r.d(t,"plugin",(function(){return R}));const s="csv:separator",n="csv:quoteValues";var o=r(5),a=r.n(o),i=r(12),c=r.n(i);const h=(e,t,r,s=[])=>{const[n,a]=Object(o.useState)(""),i=c()();return Object(o.useEffect)((()=>{e?e.getUrl(t,r).then((e=>{i()&&a(e)})).catch((e=>{i()&&(console.error("useLocatorUrl",e),a(""))})):a("")}),[e,...s]),n};var l=r(0),u=r.n(l);r(20);class share_menu_registry_ShareMenuRegistry{constructor(){u()(this,"shareMenuProviders",new Map)}setup(){return{register:e=>{if(this.shareMenuProviders.has(e.id))throw new Error(`Share menu provider with id [${e.id}] has already been registered. Use a unique id.`);this.shareMenuProviders.set(e.id,e)}}}start(){return{getShareMenuItems:e=>Array.from(this.shareMenuProviders.values()).flatMap((t=>t.getShareMenuItems(e)))}}}var p=r(9),d=r.n(p),f=r(3),m=r(2),g=r(13),b=r(4),v=r(6),y=r(1);let w;!function(e){e.EXPORT_URL_AS_SAVED_OBJECT="savedObject",e.EXPORT_URL_AS_SNAPSHOT="snapshot"}(w||(w={}));class url_panel_content_UrlPanelContent extends o.Component{constructor(e){super(e),u()(this,"mounted",void 0),u()(this,"shortUrlCache",void 0),u()(this,"isNotSaved",(()=>void 0===this.props.objectId||""===this.props.objectId)),u()(this,"resetUrl",(()=>{this.mounted&&(this.shortUrlCache=void 0,this.setState({useShortUrl:!1},this.setUrl))})),u()(this,"updateUrlParams",(e=>(e=this.props.isEmbedded?this.makeUrlEmbeddable(e):e,this.state.urlParams?this.getUrlParamExtensions(e):e))),u()(this,"getSavedObjectUrl",(()=>{if(this.isNotSaved())return;const e=this.getSnapshotUrl(!0),t=Object(v.parse)(e);if(!t||!t.hash)return;const r=Object(v.parse)(t.hash.slice(1),!0),s=Object(v.format)({protocol:t.protocol,auth:t.auth,host:t.host,pathname:t.pathname,hash:Object(v.format)({pathname:r.pathname,query:{_g:r.query._g}})});return this.updateUrlParams(s)})),u()(this,"getSnapshotUrl",(e=>{let t="";return e&&this.props.shareableUrlForSavedObject&&(t=this.props.shareableUrlForSavedObject),t||(t=this.props.shareableUrl||window.location.href),this.updateUrlParams(t)})),u()(this,"makeUrlEmbeddable",(e=>{const t="?embed=true";return-1!==e.indexOf("?")?e.replace("?",`${t}&`):`${e}${t}`})),u()(this,"addUrlAnonymousAccessParameters",(e=>{if(!this.state.anonymousAccessParameters||!this.state.usePublicUrl)return e;const t=new URL(e);for(const[e,r]of Object.entries(this.state.anonymousAccessParameters))t.searchParams.set(e,r);return t.toString()})),u()(this,"getUrlParamExtensions",(e=>{const{urlParams:t}=this.state;return t?Object.keys(t).reduce(((e,r)=>{const s=t[r];return s?Object.keys(s).reduce(((e,t)=>s[t]?e+`&${t}=true`:e),e):e}),e):e})),u()(this,"makeIframeTag",(e=>{if(e)return``})),u()(this,"setUrl",(()=>{let e;e=this.state.exportUrlAs===w.EXPORT_URL_AS_SAVED_OBJECT?this.getSavedObjectUrl():this.state.useShortUrl?this.shortUrlCache:this.getSnapshotUrl(),e&&(e=this.addUrlAnonymousAccessParameters(e)),this.props.isEmbedded&&(e=this.makeIframeTag(e)),this.setState({url:e})})),u()(this,"handleExportUrlAs",(e=>{this.setState({showWarningButton:Boolean(this.props.snapshotShareWarning)&&e===w.EXPORT_URL_AS_SNAPSHOT,exportUrlAs:e},this.setUrl)})),u()(this,"handleShortUrlChange",(async e=>{const t=e.target.checked;t&&void 0===this.shortUrlCache?this.createShortUrl():this.setState({useShortUrl:t},this.setUrl)})),u()(this,"handlePublicUrlChange",(()=>{this.setState((({usePublicUrl:e})=>({usePublicUrl:!e})),this.setUrl)})),u()(this,"createShortUrl",(async()=>{this.setState({isCreatingShortUrl:!0,shortUrlErrorMsg:void 0});try{const{shareableUrlLocatorParams:e}=this.props;if(e){const t=this.props.urlService.shortUrls.get(null),r=await t.createWithLocator(e);this.shortUrlCache=await r.locator.getUrl(r.params,{absolute:!0})}else{const e=this.getSnapshotUrl(),t=await this.props.urlService.shortUrls.get(null).createFromLongUrl(e);this.shortUrlCache=t.url}if(!this.mounted)return;this.setState({isCreatingShortUrl:!1,useShortUrl:!0},this.setUrl)}catch(e){if(!this.mounted)return;this.shortUrlCache=void 0,this.setState({useShortUrl:!1,isCreatingShortUrl:!1,shortUrlErrorMsg:b.i18n.translate("share.urlPanel.unableCreateShortUrlErrorMessage",{defaultMessage:"Unable to create short URL. Error: {errorMessage}",values:{errorMessage:e.message}})},this.setUrl)}})),u()(this,"renderCopyButton",(()=>Object(y.jsx)(m.EuiCopy,{beforeMessage:this.state.showWarningButton?this.props.snapshotShareWarning:void 0,textToCopy:this.state.url||"",anchorClassName:"eui-displayBlock"},(e=>Object(y.jsx)(m.EuiButton,{fill:!0,fullWidth:!0,onClick:e,disabled:this.state.isCreatingShortUrl||""===this.state.url,"data-share-url":this.state.url,"data-test-subj":"copyShareUrlButton",size:"s",iconType:this.state.showWarningButton?"warning":void 0,color:this.state.showWarningButton?"warning":"primary"},this.props.isEmbedded?Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.copyIframeCodeButtonLabel",defaultMessage:"Copy iFrame code"}):Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.copyLinkButtonLabel",defaultMessage:"Copy link"})))))),u()(this,"renderExportUrlAsOptions",(()=>{const e=Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.snapshotLabel",defaultMessage:"Snapshot"});return[{id:w.EXPORT_URL_AS_SNAPSHOT,label:Object(y.jsx)(a.a.Fragment,null,this.renderWithIconTip(e,Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.snapshotDescription",defaultMessage:"Snapshot URLs encode the current state of the {objectType} in the URL itself. Edits to the saved {objectType} won't be visible via this URL.",values:{objectType:this.props.objectType}}))),"data-test-subj":"exportAsSnapshot"},{id:w.EXPORT_URL_AS_SAVED_OBJECT,disabled:this.isNotSaved(),label:this.renderWithIconTip(Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.savedObjectLabel",defaultMessage:"Saved object"}),Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.savedObjectDescription",defaultMessage:"You can share this URL with people to let them load the most recent saved version of this {objectType}.",values:{objectType:this.props.objectType}})),"data-test-subj":"exportAsSavedObject"}]})),u()(this,"renderWithIconTip",((e,t)=>Object(y.jsx)(m.EuiFlexGroup,{gutterSize:"none",responsive:!1},Object(y.jsx)(m.EuiFlexItem,{grow:!1},e),Object(y.jsx)(m.EuiFlexItem,{grow:!1},Object(y.jsx)(m.EuiIconTip,{content:t,position:"bottom"}))))),u()(this,"renderExportAsRadioGroup",(()=>{const e=this.isNotSaved()?Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.canNotShareAsSavedObjectHelpText",defaultMessage:"To share as a saved object, save the {objectType}.",values:{objectType:this.props.objectType}}):void 0;return Object(y.jsx)(m.EuiFormRow,{helpText:e},Object(y.jsx)(m.EuiRadioGroup,{options:this.renderExportUrlAsOptions(),idSelected:this.state.exportUrlAs,onChange:this.handleExportUrlAs,legend:{children:Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.generateLinkAsLabel",defaultMessage:"Generate the link as"})}}))})),u()(this,"renderShortUrlSwitch",(()=>{if(this.state.exportUrlAs===w.EXPORT_URL_AS_SAVED_OBJECT||!this.props.allowShortUrl)return null;const e=Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.shortUrlLabel",defaultMessage:"Short URL"}),t=this.state.isCreatingShortUrl?Object(y.jsx)("span",null,Object(y.jsx)(m.EuiLoadingSpinner,{size:"s"})," ",e):e,r=Object(y.jsx)(m.EuiSwitch,{label:t,checked:this.state.useShortUrl,onChange:this.handleShortUrlChange,"data-test-subj":"useShortUrl"}),s=Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.shortUrlHelpText",defaultMessage:"We recommend sharing shortened snapshot URLs for maximum compatibility. Internet Explorer has URL length restrictions, and some wiki and markup parsers don't do well with the full-length version of the snapshot URL, but the short URL should work great."});return Object(y.jsx)(m.EuiFormRow,{helpText:this.state.shortUrlErrorMsg,"data-test-subj":"createShortUrl"},this.renderWithIconTip(r,s))})),u()(this,"renderPublicUrlSwitch",(()=>{if(!this.state.anonymousAccessParameters||!this.state.showPublicUrlSwitch)return null;const e=Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.publicUrlLabel",defaultMessage:"Public URL"}),t=Object(y.jsx)(m.EuiSwitch,{label:e,checked:this.state.usePublicUrl,onChange:this.handlePublicUrlChange,"data-test-subj":"usePublicUrl"}),r=Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.publicUrlHelpText",defaultMessage:"Use public URL to share with anyone. It enables one-step anonymous access by removing the login prompt."});return Object(y.jsx)(m.EuiFormRow,{"data-test-subj":"createPublicUrl"},this.renderWithIconTip(t,r))})),u()(this,"renderUrlParamExtensions",(()=>{if(!this.props.urlParamExtensions)return;const e=e=>(t={})=>{const r={urlParams:{...this.state.urlParams,[e]:{...t}}};this.setState(r,this.state.useShortUrl?this.createShortUrl:this.setUrl)};return Object(y.jsx)(a.a.Fragment,null,this.props.urlParamExtensions.map((({paramName:t,component:r})=>Object(y.jsx)(m.EuiFormRow,{key:t},Object(y.jsx)(r,{setParamValue:e(t)})))))})),this.shortUrlCache=void 0,this.state={exportUrlAs:w.EXPORT_URL_AS_SNAPSHOT,useShortUrl:!1,usePublicUrl:!1,isCreatingShortUrl:!1,url:"",anonymousAccessParameters:null,showPublicUrlSwitch:!1,showWarningButton:Boolean(this.props.snapshotShareWarning)}}componentWillUnmount(){window.removeEventListener("hashchange",this.resetUrl),this.mounted=!1}componentDidMount(){this.mounted=!0,this.setUrl(),window.addEventListener("hashchange",this.resetUrl,!1),this.props.anonymousAccess&&(async()=>{const{accessURLParameters:e}=await this.props.anonymousAccess.getState();if(!this.mounted)return;if(!e)return;let t=!1;if(this.props.showPublicUrlSwitch){const e=await this.props.anonymousAccess.getCapabilities();if(!this.mounted)return;try{t=this.props.showPublicUrlSwitch(e)}catch{t=!1}}this.setState({anonymousAccessParameters:e,showPublicUrlSwitch:t})})()}render(){const e=this.renderShortUrlSwitch(),t=this.renderPublicUrlSwitch(),r=this.renderCopyButton(),s=(!!e||!!t)&&Object(y.jsx)(m.EuiFormRow,{label:Object(y.jsx)(f.FormattedMessage,{id:"share.urlPanel.urlGroupTitle",defaultMessage:"URL"})},Object(y.jsx)(a.a.Fragment,null,Object(y.jsx)(m.EuiSpacer,{size:"s"}),e,t));return Object(y.jsx)(f.I18nProvider,null,Object(y.jsx)(m.EuiForm,{className:"kbnShareContextMenu__finalPanel","data-test-subj":"shareUrlForm"},this.renderExportAsRadioGroup(),this.renderUrlParamExtensions(),s,Object(y.jsx)(m.EuiSpacer,{size:"m"}),r))}}class share_context_menu_ShareContextMenu extends o.Component{constructor(...e){super(...e),u()(this,"getPanels",(()=>{const e=[],t=[],r={id:e.length+1,title:b.i18n.translate("share.contextMenu.permalinkPanelTitle",{defaultMessage:"Get link"}),content:Object(y.jsx)(url_panel_content_UrlPanelContent,{allowShortUrl:this.props.allowShortUrl,objectId:this.props.objectId,objectType:this.props.objectType,shareableUrl:this.props.shareableUrl,shareableUrlForSavedObject:this.props.shareableUrlForSavedObject,shareableUrlLocatorParams:this.props.shareableUrlLocatorParams,anonymousAccess:this.props.anonymousAccess,showPublicUrlSwitch:this.props.showPublicUrlSwitch,urlService:this.props.urlService,snapshotShareWarning:this.props.snapshotShareWarning})};if(t.push({name:b.i18n.translate("share.contextMenu.permalinksLabel",{defaultMessage:"Get links"}),icon:"link",panel:r.id,sortOrder:0,disabled:Boolean(this.props.disabledShareUrl),"data-test-subj":"Permalinks"}),e.push(r),this.props.allowEmbed){const r={id:e.length+1,title:b.i18n.translate("share.contextMenu.embedCodePanelTitle",{defaultMessage:"Embed Code"}),content:Object(y.jsx)(url_panel_content_UrlPanelContent,{allowShortUrl:this.props.allowShortUrl,isEmbedded:!0,objectId:this.props.objectId,objectType:this.props.objectType,shareableUrl:this.props.shareableUrl,shareableUrlForSavedObject:this.props.shareableUrlForSavedObject,shareableUrlLocatorParams:this.props.shareableUrlLocatorParams,urlParamExtensions:this.props.embedUrlParamExtensions,anonymousAccess:this.props.anonymousAccess,showPublicUrlSwitch:this.props.showPublicUrlSwitch,urlService:this.props.urlService,snapshotShareWarning:this.props.snapshotShareWarning})};e.push(r),t.push({name:b.i18n.translate("share.contextMenu.embedCodeLabel",{defaultMessage:"Embed code"}),icon:"console",panel:r.id,sortOrder:0})}if(this.props.shareMenuItems.forEach((({shareMenuItem:r,panel:s})=>{const n=e.length+1;e.push({...s,id:n}),t.push({...r,panel:n})})),t.length>1){const r={id:e.length+1,title:b.i18n.translate("share.contextMenuTitle",{defaultMessage:"Share this {objectType}",values:{objectType:this.props.objectTypeTitle||this.props.objectType}}),items:t.sort(((e,t)=>{const r=e.sortOrder||0,s=t.sortOrder||0;return r>s?1:r0?1:-1})).map((e=>{var t;return e["data-test-subj"]=`sharePanel-${null!==(t=e["data-test-subj"])&&void 0!==t?t:e.name.replace(" ","")}`,delete e.sortOrder,e}))};e.push(r)}const s=e.length-1,n=e[s].id;return{panels:e,initialPanelId:n}}))}render(){const{panels:e,initialPanelId:t}=this.getPanels();return Object(y.jsx)(f.I18nProvider,null,Object(y.jsx)(m.EuiContextMenu,{initialPanelId:t,panels:e,"data-test-subj":"shareContextMenu"}))}}class share_menu_manager_ShareMenuManager{constructor(){u()(this,"isOpen",!1),u()(this,"container",document.createElement("div")),u()(this,"onClose",(()=>{d.a.unmountComponentAtNode(this.container),this.isOpen=!1}))}start(e,t,r,s,n){return{toggleShareContextMenu:o=>{const a=()=>{var e;this.onClose(),null===(e=o.onClose)||void 0===e||e.call(o)},i=r.getShareMenuItems({...o,onClose:a}),c=null==n?void 0:n();this.toggleShareContextMenu({...o,allowEmbed:!s&&o.allowEmbed,onClose:a,menuItems:i,urlService:t,anonymousAccess:c,theme:e.theme})}}}toggleShareContextMenu({anchorElement:e,allowEmbed:t,allowShortUrl:r,objectId:s,objectType:n,sharingData:o,menuItems:a,shareableUrl:i,shareableUrlForSavedObject:c,shareableUrlLocatorParams:h,embedUrlParamExtensions:l,theme:u,showPublicUrlSwitch:p,urlService:b,anonymousAccess:v,snapshotShareWarning:w,onClose:S,objectTypeTitle:U,disabledShareUrl:j}){if(this.isOpen)return void S();this.isOpen=!0,document.body.appendChild(this.container);const _=Object(y.jsx)(f.I18nProvider,null,Object(y.jsx)(g.KibanaThemeProvider,{theme$:u.theme$},Object(y.jsx)(m.EuiWrappingPopover,{id:"sharePopover",button:e,isOpen:!0,closePopover:S,panelPaddingSize:"none",anchorPosition:"downLeft"},Object(y.jsx)(share_context_menu_ShareContextMenu,{allowEmbed:t,allowShortUrl:r,objectId:s,objectType:n,objectTypeTitle:U,shareMenuItems:a,sharingData:o,shareableUrl:i,shareableUrlForSavedObject:c,shareableUrlLocatorParams:h,onClose:S,embedUrlParamExtensions:l,anonymousAccess:v,showPublicUrlSwitch:p,urlService:b,snapshotShareWarning:w,disabledShareUrl:j}))));d.a.render(_,this.container)}}var S=r(7);class locator_Locator{constructor(e,t){u()(this,"id",void 0),u()(this,"migrations",void 0),u()(this,"telemetry",((e,t)=>this.definition.telemetry?this.definition.telemetry(e,t):t)),u()(this,"inject",((e,t)=>this.definition.inject?this.definition.inject(e,t):e)),u()(this,"extract",(e=>this.definition.extract?this.definition.extract(e):{state:e,references:[]})),u()(this,"useUrl",((e,t,r=[])=>h(this,e,t,r))),this.definition=e,this.deps=t,this.id=e.id,this.migrations=e.migrations||{}}async getLocation(e){return await this.definition.getLocation(e)}async getUrl(e,{absolute:t=!1}={}){const r=await this.getLocation(e);return this.deps.getUrl(r,{absolute:t})}getRedirectUrl(e,t={}){var r;const{baseUrl:s="",version:n="0.0.0"}=this.deps;return s+"/app/r?"+function(e,{lzCompress:t}={}){const r=new URLSearchParams;r.set("l",e.id),r.set("v",e.version);const s=JSON.stringify(e.params);if(t){const e=Object(S.compressToBase64)(s);r.set("lz",e)}else r.set("p",JSON.stringify(e.params));return r}({id:this.definition.id,version:n,params:e},{...t,lzCompress:null===(r=t.lzCompress)||void 0===r||r}).toString()}async navigate(e,{replace:t=!1}={}){const r=await this.getLocation(e);await this.deps.navigate(r,{replace:t})}navigateSync(e,t={}){this.navigate(e,t).catch((r=>{console.log(`Failed to navigate [locator = ${this.id}].`,e,t),console.error(r)}))}}class locator_client_LocatorClient{constructor(e){u()(this,"locators",new Map),u()(this,"getAllMigrations",(()=>{const e=this.migrations(),t={},r=new Set;for(const t of Object.values(e))for(const e of Object.keys(t))r.add(e);for(const s of r.values()){const r=t=>{const r=e[t.id];if(!r)return t;const n=r[s];return n?{...t,version:s,state:n(t.state)}:t};t[s]=r}return t})),this.deps=e}create(e){const t=new locator_Locator(e,this.deps);return this.locators.set(e.id,t),t}get(e){return this.locators.get(e)}getOrThrow(e){const t=this.locators.get(e);if(!t)throw new Error(`Locator [ID = "${e}"] is not registered.`);return t}migrations(){const e={};for(const t of this.locators.values())e[t.id]="function"==typeof t.migrations?t.migrations():t.migrations;return e}telemetry(e,t){for(const r of this.locators.values())t=r.telemetry(e.state,t);return t}inject(e,t){const r=this.getOrThrow(e.id),s=t.filter((e=>e.name.startsWith("params:"))).map((e=>({...e,name:e.name.substr("params:".length)})));return{...e,state:r.inject(e.state,s)}}extract(e){const t=this.getOrThrow(e.id).extract(e.state);return{state:{...e,state:t.state},references:t.references.map((e=>({...e,name:"params:"+e.name})))}}}class url_service_UrlService{constructor(e){u()(this,"locators",void 0),u()(this,"shortUrls",void 0),this.deps=e,this.locators=new locator_client_LocatorClient(e),this.shortUrls=e.shortUrls({locators:this.locators})}}var U=r(14),j=r(15);const _=/^\/app\/[^/]+.+$/,O="LEGACY_SHORT_URL_LOCATOR";class legacy_short_url_locator_LegacyShortUrlLocatorDefinition{constructor(){u()(this,"id",O)}async getLocation(e){const{url:t}=e;!function(e){if(!_.test(e)||e.includes("/../"))throw new Error(`Invalid short URL: ${e}`)}(t);const r=t.match(/^.*\/app\/([^\/#]+)(.+)$/);if(!r)throw new Error("Unexpected URL path.");const[,s,n]=r;if(!s||!n)throw new Error("Could not parse URL path.");return{app:s,path:n,state:{}}}}class redirect_manager_RedirectManager{constructor(e){u()(this,"error$",new U.BehaviorSubject(null)),this.deps=e}registerLocatorRedirectApp(e){e.application.register({id:"r",title:"Redirect endpoint",chromeless:!0,mount:async t=>{const{render:s}=await r.e(1).then(r.bind(null,46)),n=s(t.element,{manager:this,theme:e.theme,customBranding:e.customBranding});return this.onMount(t.history.location),()=>{n()}}})}registerLegacyShortUrlRedirectApp(e){e.application.register({id:"short_url_redirect",appRoute:"/goto",title:"Short URL Redirect",chromeless:!0,mount:async()=>{var t;const s=null===(t=location.pathname.match(new RegExp("/goto/(.*)$")))||void 0===t?void 0:t[1];if(!s)throw new Error("Url id not present in path");const n=this.deps.url,o=n.shortUrls.get(null),a=await o.get(s),i=a.data.locator.id,c=n.locators.get(i);if(!c)throw new Error(`Locator [id = ${i}] not found.`);const h=a.data.locator.state;if(a.data.locator.id!==O)return await c.navigate(h,{replace:!0}),()=>{};let l=h.url;if(e.uiSettings.get("state:storeInSessionStorage")){const{hashUrl:e}=await Promise.resolve().then(r.t.bind(null,39,7));l=e(l)}const u=e.http.basePath.prepend(l);return location.href=u,()=>{}}})}onMount(e){const t=e.pathname;if(t.startsWith("/s/"))return void this.navigateToShortUrlBySlug(t.substring("/s/".length));const r=e.search,s=this.parseSearchParams(r);this.navigate(s)}navigateToShortUrlBySlug(e){(async()=>{const t=this.deps.url,r=t.shortUrls.get(null),s=await r.resolve(e),n=s.data.locator.id,o=t.locators.get(n);if(!o)throw new Error(`Locator "${n}" not found.`);const a=s.data.locator.state;await o.navigate(a,{replace:!0})})().catch((e=>{this.error$.next(e),console.error(e)}))}navigate(e){const t=this.deps.url.locators.get(e.id);if(!t){const t=b.i18n.translate("share.urlService.redirect.RedirectManager.locatorNotFound",{defaultMessage:"Locator [ID = {id}] does not exist.",values:{id:e.id},description:"Error displayed to user in redirect endpoint when redirection cannot be performed successfully, because locator does not exist."}),r=new Error(t);throw this.error$.next(r),r}const r="function"==typeof t.migrations?t.migrations():t.migrations,s=Object(j.migrateToLatest)(r,{state:e.params,version:e.version});t.navigate(s,{replace:!0}).then().catch((e=>{console.log("Redirect endpoint failed to execute locator redirect."),console.error(e)}))}parseSearchParams(e){try{return function(e){const t=new URLSearchParams(e),r=t.get("l"),s=t.get("v"),n=t.get("lz"),o=n?Object(S.decompressFromBase64)(n):t.get("p");if(!r){const e=b.i18n.translate("share.urlService.redirect.RedirectManager.missingParamLocator",{defaultMessage:'Locator ID not specified. Specify "l" search parameter in the URL, which should be an existing locator ID.',description:"Error displayed to user in redirect endpoint when redirection cannot be performed successfully, because of missing locator ID."});throw new Error(e)}if(!s){const e=b.i18n.translate("share.urlService.redirect.RedirectManager.missingParamVersion",{defaultMessage:'Locator params version not specified. Specify "v" search parameter in the URL, which should be the release version of Kibana when locator params were generated.',description:"Error displayed to user in redirect endpoint when redirection cannot be performed successfully, because of missing version parameter."});throw new Error(e)}if(!o){const e=b.i18n.translate("share.urlService.redirect.RedirectManager.missingParamParams",{defaultMessage:'Locator params not specified. Specify "p" search parameter in the URL, which should be JSON serialized object of locator params.',description:"Error displayed to user in redirect endpoint when redirection cannot be performed successfully, because of missing params parameter."});throw new Error(e)}let a;try{a=JSON.parse(o)}catch{const e=b.i18n.translate("share.urlService.redirect.RedirectManager.invalidParamParams",{defaultMessage:'Could not parse locator params. Locator params must be serialized as JSON and set at "p" URL search parameter.',description:"Error displayed to user in redirect endpoint when redirection cannot be performed successfully, because locator parameters could not be parsed as JSON."});throw new Error(e)}return{id:r,version:s,params:a}}(e)}catch(e){throw this.error$.next(e),e}}}const x="SHORT_URL_REDIRECT_LOCATOR";class short_url_redirect_locator_ShortUrlRedirectLocatorDefinition{constructor(){u()(this,"id",x)}async getLocation(e){const{slug:t}=e;return{app:"r",path:"s/"+t,state:{}}}}class short_url_client_BrowserShortUrlClient{constructor(e){this.dependencies=e}async create({locator:e,params:t,slug:r}){const{http:s}=this.dependencies;return{data:await s.fetch("/api/short_url",{method:"POST",body:JSON.stringify({locatorId:e.id,slug:r,params:t})})}}async createWithLocator(e){const t=await this.create(e),r=this.dependencies.locators.get(x),s={slug:t.data.slug};return{...t,locator:r,params:s}}async createFromLongUrl(e){const t=Object(v.parse)(e);if(!t||!t.path)throw new Error(`Invalid URL: ${e}`);const r=t.path.replace(this.dependencies.http.basePath.get(),"")+(t.hash?t.hash:""),s=this.dependencies.locators.get(O);if(!s)throw new Error(`Locator "${O}" not found`);const n=await this.createWithLocator({locator:s,params:{url:r}}),o=await n.locator.getUrl(n.params,{absolute:!0});return{...n,url:o}}async get(e){const{http:t}=this.dependencies;return{data:await t.fetch("/api/short_url/"+e,{method:"GET"})}}async resolve(e){const{http:t}=this.dependencies;return{data:await t.fetch("/api/short_url/_slug/"+e,{method:"GET"})}}async delete(e){const{http:t}=this.dependencies;await t.fetch("/api/short_url/"+e,{method:"DELETE"})}}class short_url_client_factory_BrowserShortUrlClientFactory{constructor(e){this.dependencies=e}get(e){return new short_url_client_BrowserShortUrlClient(this.dependencies)}}class plugin_SharePlugin{constructor(e){u()(this,"shareMenuRegistry",new share_menu_registry_ShareMenuRegistry),u()(this,"shareContextMenu",new share_menu_manager_ShareMenuManager),u()(this,"redirectManager",void 0),u()(this,"url",void 0),u()(this,"anonymousAccessServiceProvider",void 0),this.initializerContext=e}setup(e){const{http:t}=e,{basePath:r}=t;return this.url=new url_service_UrlService({baseUrl:r.get(),version:this.initializerContext.env.packageInfo.version,navigate:async({app:t,path:r,state:s},{replace:n=!1}={})=>{const[o]=await e.getStartServices();await o.application.navigateToApp(t,{path:r,state:s,replace:n})},getUrl:async({app:t,path:r},{absolute:s})=>(await e.getStartServices())[0].application.getUrlForApp(t,{path:r,absolute:s}),shortUrls:({locators:e})=>new short_url_client_factory_BrowserShortUrlClientFactory({http:t,locators:e})}),this.url.locators.create(new legacy_short_url_locator_LegacyShortUrlLocatorDefinition),this.url.locators.create(new short_url_redirect_locator_ShortUrlRedirectLocatorDefinition),this.redirectManager=new redirect_manager_RedirectManager({url:this.url}),this.redirectManager.registerLocatorRedirectApp(e),this.redirectManager.registerLegacyShortUrlRedirectApp(e),{...this.shareMenuRegistry.setup(),url:this.url,navigate:e=>this.redirectManager.navigate(e),setAnonymousAccessServiceProvider:e=>{if(this.anonymousAccessServiceProvider)throw new Error("Anonymous Access service provider is already set.");this.anonymousAccessServiceProvider=e}}}start(e){const t="serverless"===this.initializerContext.env.packageInfo.buildFlavor;return{...this.shareContextMenu.start(e,this.url,this.shareMenuRegistry.start(),t,this.anonymousAccessServiceProvider),url:this.url,navigate:e=>this.redirectManager.navigate(e)}}}var E=r(16),P=r(17),C=r.n(P);function M(e,t){return A({[e]:t})}async function A(e){const t=Object.keys(e).map(((t,r)=>{const s=e[t],n=s instanceof Blob?s:new Blob([s.content],{type:s.type});return()=>Promise.resolve().then((()=>Object(E.saveAs)(n,t)))}));await C()(t,(e=>Promise.all([e(),(50,new Promise((e=>setTimeout(e,50))))])),{concurrency:1})}function R(e){return new plugin_SharePlugin(e)}},function(e,t){e.exports=__kbnSharedDeps__.EmotionCache},function(e,t){e.exports=__kbnSharedDeps__.TsLib},function(e,t,r){r.r(t);var s=__kbnBundles__.get("plugin/kibanaUtils/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(s))}]);