!function(e){function t(t){for(var n,s,i=t[0],r=t[1],a=0,l=[];a{const n=this.decodeKey(t);null!=n&&e.push(n)}))}}function c(e){return new storage_Storage(e.engine,e.prefix)}const[l,p]=Object(r.createGetterSetter)("storage"),d=Object.freeze({fontSize:14,polling:!0,pollInterval:6e4,tripleQuotes:!0,wrapMode:!0,autocomplete:Object.freeze({fields:!0,indices:!0,templates:!0,dataStreams:!0}),isHistoryEnabled:!0,isKeyboardShortcutsEnabled:!0,isAccessibilityOverlayEnabled:!0});var u;!function(e){e.FONT_SIZE="font_size",e.WRAP_MODE="wrap_mode",e.TRIPLE_QUOTES="triple_quotes",e.AUTOCOMPLETE_SETTINGS="autocomplete_settings",e.CONSOLE_POLLING="console_polling",e.POLL_INTERVAL="poll_interval",e.IS_HISTORY_ENABLED="is_history_enabled",e.IS_KEYBOARD_SHORTCUTS_ENABLED="is_keyboard_shortcuts_enabled",e.IS_ACCESSIBILITY_OVERLAY_ENABLED="is_accessibility_overlay_enabled"}(u||(u={}));class Settings{constructor(e){this.storage=e,this.addMigrationRule("is_history_disabled",u.IS_HISTORY_ENABLED,(e=>!e)),this.addMigrationRule("is_keyboard_shortcuts_disabled",u.IS_KEYBOARD_SHORTCUTS_ENABLED,(e=>!e))}addMigrationRule(e,t,n){const o=this.storage.get(e);void 0!==o&&(this.storage.set(t,n(o)),this.storage.delete(e))}getFontSize(){return this.storage.get(u.FONT_SIZE,d.fontSize)}setFontSize(e){return this.storage.set(u.FONT_SIZE,e),!0}getWrapMode(){return this.storage.get(u.WRAP_MODE,d.wrapMode)}setWrapMode(e){return this.storage.set(u.WRAP_MODE,e),!0}setTripleQuotes(e){return this.storage.set(u.TRIPLE_QUOTES,e),!0}getTripleQuotes(){return this.storage.get(u.TRIPLE_QUOTES,d.tripleQuotes)}getAutocomplete(){return this.storage.get(u.AUTOCOMPLETE_SETTINGS,d.autocomplete)}setAutocomplete(e){return this.storage.set(u.AUTOCOMPLETE_SETTINGS,e),!0}getPolling(){return this.storage.get(u.CONSOLE_POLLING,d.polling)}setPolling(e){return this.storage.set(u.CONSOLE_POLLING,e),!0}setIsHistoryEnabled(e){return this.storage.set(u.IS_HISTORY_ENABLED,e),!0}getIsHistoryEnabled(){return this.storage.get(u.IS_HISTORY_ENABLED,d.isHistoryEnabled)}setPollInterval(e){this.storage.set(u.POLL_INTERVAL,e)}getPollInterval(){return this.storage.get(u.POLL_INTERVAL,d.pollInterval)}setIsKeyboardShortcutsEnabled(e){return this.storage.set(u.IS_KEYBOARD_SHORTCUTS_ENABLED,e),!0}setIsAccessibilityOverlayEnabled(e){return this.storage.set(u.IS_ACCESSIBILITY_OVERLAY_ENABLED,e),!0}getIsKeyboardShortcutsDisabled(){return this.storage.get(u.IS_KEYBOARD_SHORTCUTS_ENABLED,d.isKeyboardShortcutsEnabled)}getIsAccessibilityOverlayEnabled(){return this.storage.get(u.IS_ACCESSIBILITY_OVERLAY_ENABLED,d.isAccessibilityOverlayEnabled)}toJSON(){return{autocomplete:this.getAutocomplete(),wrapMode:this.getWrapMode(),tripleQuotes:this.getTripleQuotes(),fontSize:parseFloat(this.getFontSize()),polling:Boolean(this.getPolling()),pollInterval:this.getPollInterval(),isHistoryEnabled:Boolean(this.getIsHistoryEnabled()),isKeyboardShortcutsEnabled:Boolean(this.getIsKeyboardShortcutsDisabled()),isAccessibilityOverlayEnabled:Boolean(this.getIsAccessibilityOverlayEnabled())}}updateSettings({fontSize:e,wrapMode:t,tripleQuotes:n,autocomplete:o,polling:s,pollInterval:i,isHistoryEnabled:r,isKeyboardShortcutsEnabled:a,isAccessibilityOverlayEnabled:c}){this.setFontSize(e),this.setWrapMode(t),this.setTripleQuotes(n),this.setAutocomplete(o),this.setPolling(s),this.setPollInterval(i),this.setIsHistoryEnabled(r),this.setIsKeyboardShortcutsEnabled(a),this.setIsAccessibilityOverlayEnabled(c)}}function _({storage:e}){return new Settings(e)}var h=n(0),g=n.n(h),f=n(4);class alias_Alias{constructor(){g()(this,"perAliasIndexes",{}),g()(this,"getIndices",((e,t)=>{const n=[],o=t.perIndexTypes;return Object.keys(o).forEach((e=>{e.startsWith(".ds")||n.push(e)})),(void 0===e||e)&&Object.keys(this.perAliasIndexes).forEach((e=>{n.push(e)})),n})),g()(this,"loadAliases",((e,t)=>{this.perAliasIndexes={};const n=t.perIndexTypes;Object.entries(e).forEach((([e,t])=>{n[e]=n[e]||{},Object.keys(t.aliases||{}).forEach((t=>{if(t===e)return;let n=this.perAliasIndexes[t];n||(n=[],this.perAliasIndexes[t]=n),n.push(e)}))})),this.perAliasIndexes._all=this.getIndices(!1,t)})),g()(this,"clearAliases",(()=>{this.perAliasIndexes={}}))}}var m=n(6);function b(e={}){const t=Object.entries(e).flatMap((([e,t])=>y(e,t)));return i.a.uniqBy(t,(function(e){return e.name+":"+e.type}))}function y(e,t){if(!1===t.enabled)return[];let n;function o(n){return"full"===(t.path||"full")?n.map((t=>(t.name=e+"."+t.name,t))):n}if(t.properties)return n=b(t.properties),o(n);const s=t.type,i={name:e,type:s};return t.index_name&&(i.name=t.index_name),t.fields?(n=Object.entries(t.fields).flatMap((([e,t])=>y(e,t))),n=o(n),n.unshift(i),n):[i]}class mapping_Mapping{constructor(){g()(this,"http",void 0),g()(this,"settings",void 0),g()(this,"perIndexTypes",{}),g()(this,"perWildcardIndices",{}),g()(this,"_isLoading$",new m.BehaviorSubject(!1)),g()(this,"isLoading$",this._isLoading$.asObservable()),g()(this,"loadingState",{}),g()(this,"getMappings",((e,t,n)=>{let o=[];if(!this.settings.getAutocomplete().fields)return o;if(e=function(e){const t=S().alias.perAliasIndexes,n=S().dataStream.perDataStreamIndices,o=S().mapping.perWildcardIndices;if(!e)return e;"string"==typeof e&&(e=[e]),e=e.flatMap((e=>t[e]?t[e]:n[e]?n[e]:o[e]?o[e]:[e]));let s=[].concat.apply([],e);return s.sort(),s=s.reduce(((e,t,n,o)=>(o[n-1]!==t&&e.push(t),e)),[]),s.length>1?s:s[0]}(e),"string"==typeof e){const s=this.perIndexTypes[e];if(!s||0===Object.keys(s).length)return n?this.loadingState[e]?o:(this.loadingState[e]=!0,n.asyncResultsState||(n.asyncResultsState={}),n.asyncResultsState.isLoading=!0,n.asyncResultsState.results=new Promise(((o,s)=>{this._isLoading$.next(!0),this.fetchMappings(e).then((s=>{this._isLoading$.next(!1),n.asyncResultsState.isLoading=!1,n.asyncResultsState.lastFetched=Date.now();const i=Object.keys(s);(i.length>1||i[0]&&i[0]!==e)&&(this.perWildcardIndices[e]=Object.keys(s)),this.loadMappings(s);const r=this.getMappings(e,t,n);delete this.loadingState[e],o(r)})).catch((t=>{console.error(t),this._isLoading$.next(!1),delete this.loadingState[e]}))})),[]):o;if("string"==typeof t){const e=s[t];Array.isArray(e)&&(o=e)}else Object.entries(s).forEach((([e,n])=>{t&&0!==t.length&&!t.includes(e)||o.push(n)})),o=[].concat.apply([],o)}else Object.keys(this.perIndexTypes).forEach((s=>{e&&0!==e.length&&!e.includes(s)||o.push(this.getMappings(s,t,n))})),o=[].concat.apply([],o);return i.a.uniqBy(o,(function(e){return e.name+":"+e.type}))})),g()(this,"loadMappings",(e=>{Object.entries(e).forEach((([e,t])=>{const n={};let o=t;t.mappings&&1===Object.keys(t).length&&(o=t.mappings),Object.entries(o).forEach((([e,t])=>{if("properties"===e){const o=b(t);n[e]=o}else n[e]=[]})),this.perIndexTypes[e]=n}))})),g()(this,"clearMappings",(()=>{this.perIndexTypes={}}))}setup(e,t){this.http=e,this.settings=t}async fetchMappings(e){return(await this.http.get(`${f.a}/autocomplete_entities`,{query:{fields:!0,fieldsIndices:e}})).mappings}}class data_stream_DataStream{constructor(){g()(this,"dataStreams",[]),g()(this,"perDataStreamIndices",{}),g()(this,"getDataStreams",(()=>[...this.dataStreams])),g()(this,"loadDataStreams",(e=>{var t;this.dataStreams=(null!==(t=e.data_streams)&&void 0!==t?t:[]).map((({name:e})=>e)).sort(),this.perDataStreamIndices=e.data_streams.reduce(((e,{name:t,indices:n})=>(e[t]=n.map((e=>e.index_name)),e)),{})})),g()(this,"clearDataStreams",(()=>{this.dataStreams=[]}))}}class base_template_BaseTemplate{constructor(){g()(this,"templates",[]),g()(this,"getTemplates",(()=>[...this.templates])),g()(this,"clearTemplates",(()=>{this.templates=[]}))}}class legacy_template_LegacyTemplate extends base_template_BaseTemplate{constructor(...e){super(...e),g()(this,"loadTemplates",(e=>{this.templates=Object.keys(e).sort()}))}}class index_template_IndexTemplate extends base_template_BaseTemplate{constructor(...e){super(...e),g()(this,"loadTemplates",(e=>{var t;this.templates=(null!==(t=e.index_templates)&&void 0!==t?t:[]).map((({name:e})=>e)).sort()}))}}class component_template_ComponentTemplate extends base_template_BaseTemplate{constructor(...e){super(...e),g()(this,"loadTemplates",(e=>{var t;this.templates=(null!==(t=e.component_templates)&&void 0!==t?t:[]).map((({name:e})=>e)).sort()}))}}let x;!function(e){e.INDICES="indices",e.FIELDS="fields",e.INDEX_TEMPLATES="indexTemplates",e.COMPONENT_TEMPLATES="componentTemplates",e.LEGACY_TEMPLATES="legacyTemplates",e.DATA_STREAMS="dataStreams"}(x||(x={}));class autocomplete_AutocompleteInfo{constructor(){g()(this,"alias",new alias_Alias),g()(this,"mapping",new mapping_Mapping),g()(this,"dataStream",new data_stream_DataStream),g()(this,"legacyTemplate",new legacy_template_LegacyTemplate),g()(this,"indexTemplate",new index_template_IndexTemplate),g()(this,"componentTemplate",new component_template_ComponentTemplate),g()(this,"http",void 0),g()(this,"pollTimeoutId",void 0)}setup(e){this.http=e}getEntityProvider(e,t={indices:[],types:[]}){switch(e){case x.INDICES:const n=!0,o=this.mapping;return()=>this.alias.getIndices(n,o);case x.FIELDS:return this.mapping.getMappings(t.indices,t.types,Object.getPrototypeOf(t));case x.INDEX_TEMPLATES:return()=>this.indexTemplate.getTemplates();case x.COMPONENT_TEMPLATES:return()=>this.componentTemplate.getTemplates();case x.LEGACY_TEMPLATES:return()=>this.legacyTemplate.getTemplates();case x.DATA_STREAMS:return()=>this.dataStream.getDataStreams();default:throw new Error(`Unsupported type: ${e}`)}}retrieve(e,t){this.clearSubscriptions(),this.http.get(`${f.a}/autocomplete_entities`,{query:{...t}}).then((t=>{this.load(t),this.pollTimeoutId=setTimeout((()=>{e.getPolling()&&this.retrieve(e,e.getAutocomplete())}),e.getPollInterval())}))}clearSubscriptions(){this.pollTimeoutId&&clearTimeout(this.pollTimeoutId)}load(e){const t=this.mapping;this.alias.loadAliases(e.aliases,t),this.indexTemplate.loadTemplates(e.indexTemplates),this.componentTemplate.loadTemplates(e.componentTemplates),this.legacyTemplate.loadTemplates(e.legacyTemplates),this.dataStream.loadDataStreams(e.dataStreams)}clear(){this.alias.clearAliases(),this.mapping.clearMappings(),this.dataStream.clearDataStreams(),this.legacyTemplate.clearTemplates(),this.indexTemplate.clearTemplates(),this.componentTemplate.clearTemplates()}}const[S,A]=Object(r.createGetterSetter)("AutocompleteInfo")},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return a}));var o=n(0),s=n.n(o),i=n(6);const r=e=>"QuotaExceededError"===e.name;class History{constructor(e){s()(this,"changeEmitter",void 0),this.storage=e,this.changeEmitter=new i.BehaviorSubject(this.getHistory()||[])}getHistoryKeys(){return this.storage.keys().filter((e=>0===e.indexOf("hist_elem"))).sort().reverse()}getHistory(){return this.getHistoryKeys().map((e=>this.storage.get(e)))}change(e){const t=this.changeEmitter.subscribe(e);return()=>t.unsubscribe()}addToHistory(e,t,n){const o=this.getHistoryKeys();o.splice(0,100),o.forEach((e=>{this.storage.delete(e)}));const s=(new Date).getTime(),i="hist_elem_"+s;this.storage.set(i,{time:s,endpoint:e,method:t,data:n}),this.changeEmitter.next(this.getHistory())}updateCurrentState(e){const t=(new Date).getTime();this.storage.set("editor_state",{time:t,content:e})}getLegacySavedEditorState(){const e=this.storage.get("editor_state");if(!e)return;const{time:t,content:n}=e;return{time:t,content:n}}deleteLegacySavedEditorState(){this.storage.delete("editor_state")}clearHistory(){this.getHistoryKeys().forEach((e=>this.storage.delete(e)))}}function a(e){return new History(e.storage)}},function(e,t){e.exports=__kbnSharedDeps__.Uuid},function(e,t){e.exports=__kbnSharedDeps_npm__},function(e,t,n){"use strict";var o,s=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),i=[];function r(e){for(var t=-1,n=0;nul{margin-bottom:0}.conHistory__body__spacer{flex:0 0 1%}.conHistory__reqs,.conHistory__viewer{flex:0 0 49.5%}.conHistory__reqs{overflow:auto}.conHistory__req{display:flex;justify-content:space-between}.conHistory__req-selected{background-color:#25262e}.conHistory__reqIcon{color:#535966}',""]),e.exports=t},function(e,t,n){var o=n(11),s=n(20);"string"==typeof(s=s.__esModule?s.default:s)&&(s=[[e.i,s,""]]);o(s,{insert:"head",singleton:!1}),e.exports=s.locals||{}},function(e,t,n){(t=n(12)(!1)).push([e.i,'#consoleRoot{display:flex;flex:1 1 auto;overflow:hidden}.consoleContainer{padding:8px}.conApp{display:flex;flex:1 1 auto}.conApp__editor{display:flex;flex:0 0 auto;position:relative;width:100%}.conApp__editor__spinner{width:100%}.conApp__output,.conApp_example{display:flex;flex:1 1 1px}.conApp__output .ace_badge,.conApp_example .ace_badge{border-radius:3px;cursor:default;display:inline-block;font-family:Inter UI,-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-size:12px;font-weight:500;line-height:1.5;max-width:100%;padding:0 8px;text-decoration:none;vertical-align:middle;white-space:nowrap}.conApp__output .ace_badge--success,.conApp_example .ace_badge--success{background-color:#6dccb1;color:#000}.conApp__output .ace_badge--warning,.conApp_example .ace_badge--warning{background-color:#f1d86f;color:#000}.conApp__output .ace_badge--primary,.conApp_example .ace_badge--primary{background-color:#79aad9;color:#000}.conApp__output .ace_badge--default,.conApp_example .ace_badge--default{background-color:#d3dae6;color:#000}.conApp__output .ace_badge--danger,.conApp_example .ace_badge--danger{background-color:#ff7e62;color:#000}.conApp__editorContent,.conApp__outputContent{flex:1 1 1px;height:100%}.conApp__editorActions{line-height:1;min-width:40px;position:absolute;right:16px;top:0;z-index:1000}.conApp__editorActions button{line-height:inherit}.conApp__resizer{align-items:center;background-color:#fafbfd;display:flex;flex:0 0 14px;justify-content:center;margin:0;position:relative;-webkit-user-select:none;user-select:none;width:14px;z-index:1000}.conApp__resizer:hover{background-color:#cce4f5}.conApp__resizer.active,.conApp__resizer:focus{background-color:#07c;color:#fff}.conApp__resizer:after{content:"";cursor:ew-resize;height:100%;left:0;position:absolute;top:0;width:100%}.conApp__autoComplete{left:-1000px;margin-top:22px;position:absolute;visibility:hidden;z-index:1002}.conApp__settingsModal{min-width:460px}.conApp__requestProgressBarContainer{position:relative;z-index:2000}.conApp__tabsExtension{border-bottom:1px solid #d3dae6}.conHistory{box-shadow:0 1px 5px #0000001a,0 3.6px 13px #00000012,0 8.4px 23px #0000000f,0 23px 35px #0000000d;padding:12px}.conHistory__body{display:flex;height:320px}.conHistory__body>ul{margin-bottom:0}.conHistory__body__spacer{flex:0 0 1%}.conHistory__reqs,.conHistory__viewer{flex:0 0 49.5%}.conHistory__reqs{overflow:auto}.conHistory__req{display:flex;justify-content:space-between}.conHistory__req-selected{background-color:#f5f7fa}.conHistory__reqIcon{color:#98a2b3}',""]),e.exports=t},function(e,t,n){"use strict";n.r(t),n.d(t,"Plugin",(function(){return plugin_ConsoleUIPlugin})),n.d(t,"plugin",(function(){return a})),n(16);var o=n(0),s=n.n(o),i=n(3),r=n(7);class plugin_ConsoleUIPlugin{constructor(e){s()(this,"autocompleteInfo",new r.a),this.ctx=e}setup({notifications:e,getStartServices:t,http:o},{devTools:s,home:a,share:c,usageCollection:l}){const{ui:{enabled:p}}=this.ctx.config.get();return this.autocompleteInfo.setup(o),Object(r.j)(this.autocompleteInfo),p?(a&&a.featureCatalogue.register({id:"console",title:i.i18n.translate("console.devToolsTitle",{defaultMessage:"Interact with the Elasticsearch API"}),description:i.i18n.translate("console.devToolsDescription",{defaultMessage:"Skip cURL and use a JSON interface to work with your data in Console."}),icon:"consoleApp",path:"/app/dev_tools#/console",showOnHomePage:!1,category:"admin"}),s.register({id:"console",order:1,title:i.i18n.translate("console.consoleDisplayName",{defaultMessage:"Console"}),enableRouting:!1,mount:async({element:s,theme$:i})=>{const[r]=await t(),{i18n:{Context:a},docLinks:{DOC_LINK_VERSION:c,links:p}}=r,{renderApp:d}=await n.e(1).then(n.bind(null,66));return d({http:o,docLinkVersion:c,docLinks:p,I18nContext:a,notifications:e,usageCollection:l,element:s,theme$:i,autocompleteInfo:this.autocompleteInfo})}}),{locator:c.url.locators.create({id:"CONSOLE_APP_LOCATOR",getLocation:async({loadFrom:e})=>({app:"dev_tools",path:"#/console"+(e?`?load_from=${e}`:""),state:{loadFrom:e}})})}):{}}start(){}}function a(e){return new plugin_ConsoleUIPlugin(e)}},function(e,t){e.exports=__kbnSharedDeps__.React},function(e,t){e.exports=__kbnSharedDeps__.EmotionReact},function(e,t){e.exports=__kbnSharedDeps__.ElasticEui},function(e,t){e.exports=__kbnSharedDeps__.KbnI18nReact},function(e,t,n){n.r(t);var o=__kbnBundles__.get("plugin/esUiShared/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(o))},function(e,t,n){n.r(t);var o=__kbnBundles__.get("plugin/kibanaReact/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(o))},function(e,t){e.exports=__kbnSharedDeps__.Jquery},function(e,t){e.exports=__kbnSharedDeps__.ReactDom},function(e,t){e.exports=__kbnSharedDeps__.KbnAnalytics},function(e,t){e.exports=__kbnSharedDeps__.Moment}]);