/*! 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. */ (window.maps_bundle_jsonpfunction=window.maps_bundle_jsonpfunction||[]).push([[23],{520:function(e,t,s){var r,o=function(){var e=String.fromCharCode,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",r={};function o(e,t){if(!r[e]){r[e]={};for(var s=0;s>>8,s[2*r+1]=i%256}return s},decompressFromUint8Array:function(t){if(null==t)return n.decompress(t);for(var s=new Array(t.length/2),r=0,o=s.length;r>=1}else{for(o=1,r=0;r>=1}0==--d&&(d=Math.pow(2,h),h++),delete l[c]}else for(o=i[c],r=0;r>=1;0==--d&&(d=Math.pow(2,h),h++),i[u]=p++,c=String(a)}if(""!==c){if(Object.prototype.hasOwnProperty.call(l,c)){if(c.charCodeAt(0)<256){for(r=0;r>=1}else{for(o=1,r=0;r>=1}0==--d&&(d=Math.pow(2,h),h++),delete l[c]}else for(o=i[c],r=0;r>=1;0==--d&&(d=Math.pow(2,h),h++)}for(o=2,r=0;r>=1;for(;;){if(m<<=1,g==t-1){f.push(s(m));break}g++}return f.join("")},decompress:function(e){return null==e?"":""==e?null:n._decompress(e.length,32768,(function(t){return e.charCodeAt(t)}))},_decompress:function(t,s,r){var o,n,i,l,a,u,c,d=[],p=4,h=4,f=3,m="",g=[],y={val:r(0),position:s,index:1};for(o=0;o<3;o+=1)d[o]=o;for(i=0,a=Math.pow(2,2),u=1;u!=a;)l=y.val&y.position,y.position>>=1,0==y.position&&(y.position=s,y.val=r(y.index++)),i|=(l>0?1:0)*u,u<<=1;switch(i){case 0:for(i=0,a=Math.pow(2,8),u=1;u!=a;)l=y.val&y.position,y.position>>=1,0==y.position&&(y.position=s,y.val=r(y.index++)),i|=(l>0?1:0)*u,u<<=1;c=e(i);break;case 1:for(i=0,a=Math.pow(2,16),u=1;u!=a;)l=y.val&y.position,y.position>>=1,0==y.position&&(y.position=s,y.val=r(y.index++)),i|=(l>0?1:0)*u,u<<=1;c=e(i);break;case 2:return""}for(d[3]=c,n=c,g.push(c);;){if(y.index>t)return"";for(i=0,a=Math.pow(2,f),u=1;u!=a;)l=y.val&y.position,y.position>>=1,0==y.position&&(y.position=s,y.val=r(y.index++)),i|=(l>0?1:0)*u,u<<=1;switch(c=i){case 0:for(i=0,a=Math.pow(2,8),u=1;u!=a;)l=y.val&y.position,y.position>>=1,0==y.position&&(y.position=s,y.val=r(y.index++)),i|=(l>0?1:0)*u,u<<=1;d[h++]=e(i),c=h-1,p--;break;case 1:for(i=0,a=Math.pow(2,16),u=1;u!=a;)l=y.val&y.position,y.position>>=1,0==y.position&&(y.position=s,y.val=r(y.index++)),i|=(l>0?1:0)*u,u<<=1;d[h++]=e(i),c=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,f),f++),d[c])m=d[c];else{if(c!==h)return null;m=n+n.charAt(0)}g.push(m),d[h++]=n+m.charAt(0),n=m,0==--p&&(p=Math.pow(2,f),f++)}}};return n}();void 0===(r=function(){return o}.call(t,s,t,e))||(e.exports=r)},68:function(e,t,s){"use strict";s.r(t);var r=s(2),o=s.n(r),n=s(39),i=s.n(n),l=s(4),a=s.n(l),u=s(1),c=s(14),d=s(40),p=s(3);function h(){return Object(p.jsx)(c.EuiEmptyPrompt,{title:Object(p.jsx)("h2",null,Object(p.jsx)(d.FormattedMessage,{id:"xpack.maps.inspector.vectorTile.noRequestsLoggedTitle",defaultMessage:"No requests logged for vector tiles"})),body:Object(p.jsx)(a.a.Fragment,null,Object(p.jsx)("p",null,Object(p.jsx)(d.FormattedMessage,{id:"xpack.maps.inspector.vectorTile.noRequestsLoggedDescription.mapHasNotLoggedAnyRequestsText",defaultMessage:"This map does not have any vector tile search results."})))})}var f=s(66),m=s(43),g=s(520),y=s(5),b=s(0),v=s(49),x=s.n(v);function j(e){try{const{path:s,body:r}=function(e){const t=function(e){const t=e.split("?"),s=t.length<=1?"":t[1];return new URLSearchParams(s)}(e.tileUrl),s=t.has("requestBody")?t.get("requestBody"):"()";if(!t.has("index"))throw new Error("Required query parameter 'index' not provided.");const r=t.get("index");if(!t.has("geometryFieldName"))throw new Error("Required query parameter 'geometryFieldName' not provided.");const o=t.get("geometryFieldName"),n=!!t.has("hasLabels")&&"true"===t.get("hasLabels");if(!t.has("buffer"))throw new Error("Required query parameter 'buffer' not provided.");const i=parseInt(t.get("buffer"),10);if(e.tileUrl.includes(b.nb))return function({buffer:e,risonRequestBody:t,geometryFieldName:s,gridPrecision:r,hasLabels:o,index:n,renderAs:i=b.tb.POINT,x:l,y:a,z:u}){const c=x.a.decode(t);if(!c)throw new Error("Required requestBody parameter not provided");return{path:`/${encodeURIComponent(n)}/_mvt/${encodeURIComponent(s)}/${u}/${l}/${a}`,body:{buffer:e,size:0,grid_precision:r,exact_bounds:!1,extent:4096,query:c.query,grid_agg:i===b.tb.HEX?"geohex":"geotile",grid_type:i===b.tb.GRID||i===b.tb.HEX?"grid":"centroid",aggs:c.aggs,fields:c.fields?c.fields:[],runtime_mappings:c.runtime_mappings,with_labels:o}}}({buffer:i,risonRequestBody:s,geometryFieldName:o,gridPrecision:parseInt(t.get("gridPrecision"),10),hasLabels:n,index:r,renderAs:t.get("renderAs"),x:e.x,y:e.y,z:e.z});if(e.tileUrl.includes(b.ob))return function({buffer:e,risonRequestBody:t,geometryFieldName:s,hasLabels:r,index:o,x:n,y:i,z:l}){const a=x.a.decode(t);if(!a)throw new Error("Required requestBody parameter not provided");const u={buffer:e,grid_precision:0,exact_bounds:!0,extent:4096,query:a.query,runtime_mappings:a.runtime_mappings,track_total_hits:"number"==typeof a.size&&a.size+1,with_labels:r};return a.fields&&(u.fields=a.fields),a.sort&&(u.sort=a.sort),{path:`/${encodeURIComponent(o)}/_mvt/${encodeURIComponent(s)}/${l}/${n}/${i}`,body:u}}({buffer:i,risonRequestBody:s,geometryFieldName:o,hasLabels:n,index:r,x:e.x,y:e.y,z:e.z});throw new Error("Unexpected path")}(e.tileRequest),o=`POST ${s}\n${JSON.stringify(r,null,2)}`;let n;if(Object(y.j)().show){var t;const e=Object(g.compressToEncodedURIComponent)(o);n=null===(t=Object(y.L)().url.locators.get("CONSOLE_APP_LOCATOR"))||void 0===t?void 0:t.useUrl({loadFrom:`data:text/plain,${e}`})}return Object(p.jsx)(c.EuiFlexGroup,{direction:"column",gutterSize:"s",wrap:!1,responsive:!0,style:{height:"100%"}},Object(p.jsx)(c.EuiFlexItem,{grow:!1},Object(p.jsx)(c.EuiSpacer,{size:"s"}),Object(p.jsx)(c.EuiFlexGroup,{justifyContent:"flexEnd",gutterSize:"m",wrap:!0},Object(p.jsx)(c.EuiFlexItem,{grow:!1},Object(p.jsx)("div",null,Object(p.jsx)(c.EuiCopy,{textToCopy:o},(e=>Object(p.jsx)(c.EuiButtonEmpty,{size:"xs",flush:"right",iconType:"copyClipboard",onClick:e},u.i18n.translate("xpack.maps.inspector.vectorTileRequest.copyToClipboardLabel",{defaultMessage:"Copy to clipboard"})))))),void 0!==n&&Object(p.jsx)(c.EuiFlexItem,{grow:!1},Object(p.jsx)("div",null,Object(p.jsx)(c.EuiButtonEmpty,{size:"xs",flush:"right",onClick:()=>{Object(y.C)()(n)},iconType:"wrench"},u.i18n.translate("xpack.maps.inspector.vectorTileRequest.openInConsoleLabel",{defaultMessage:"Open in Console"})))))),Object(p.jsx)(c.EuiFlexItem,{grow:!0},Object(p.jsx)(m.CodeEditor,{languageId:f.XJsonLang.ID,value:o,options:{readOnly:!0,lineNumbers:"off",fontSize:12,minimap:{enabled:!1},folding:!0,scrollBeyondLastLine:!1,wordWrap:"on",wrappingIndent:"indent",automaticLayout:!0}})))}catch(t){return Object(p.jsx)(c.EuiCallOut,{title:u.i18n.translate("xpack.maps.inspector.vectorTileRequest.errorMessage",{defaultMessage:"Unable to create Elasticsearch vector tile search request"}),color:"warning",iconType:"help"},Object(p.jsx)("p",null,u.i18n.translate("xpack.maps.inspector.vectorTileRequest.errorTitle",{defaultMessage:"Could not convert tile request, '{tileUrl}', to Elasticesarch vector tile search request, error: {error}",values:{tileUrl:e.tileRequest.tileUrl,error:t.message}})))}}function q(){return Object(p.jsx)(c.EuiCallOut,{size:"s",title:u.i18n.translate("xpack.maps.inspector.vectorTile.requestsView",{defaultMessage:"You're viewing vector tile search requests. To view requests submitted to the search API, set View to Requests."}),iconType:"iInCircle"})}class vector_tile_inspector_VectorTileInspector extends l.Component{constructor(...e){super(...e),o()(this,"_isMounted",!1),o()(this,"state",{selectedLayer:null,selectedTileRequest:null,tileRequests:[],layerOptions:[]}),o()(this,"_onAdapterChange",(()=>{const e=this.props.adapters.vectorTiles.getLayerOptions();if(0===e.length)return void this.setState({selectedLayer:null,selectedTileRequest:null,tileRequests:[],layerOptions:[]});const t=this.state.selectedLayer&&e.some((e=>{var t;return(null===(t=this.state.selectedLayer)||void 0===t?void 0:t.value)===e.value}))?this.state.selectedLayer:e[0],s=this.props.adapters.vectorTiles.getTileRequests(t.value),r=this.state.selectedTileRequest&&s.some((e=>{var t,s,r,o;return(null===(t=this.state.selectedTileRequest)||void 0===t?void 0:t.layerId)===e.layerId&&(null===(s=this.state.selectedTileRequest)||void 0===s?void 0:s.x)===e.x&&(null===(r=this.state.selectedTileRequest)||void 0===r?void 0:r.y)===e.y&&(null===(o=this.state.selectedTileRequest)||void 0===o?void 0:o.z)===e.z}))?this.state.selectedTileRequest:s.length?s[0]:null;this.setState({selectedLayer:t,selectedTileRequest:r,tileRequests:s,layerOptions:e})})),o()(this,"_debouncedOnAdapterChange",i.a.debounce((()=>{this._isMounted&&this._onAdapterChange()}),256)),o()(this,"_onLayerSelect",(e=>{if(0===e.length)return void this.setState({selectedLayer:null,selectedTileRequest:null,tileRequests:[]});const t=e[0],s=this.props.adapters.vectorTiles.getTileRequests(t.value);this.setState({selectedLayer:t,selectedTileRequest:s.length?s[0]:null,tileRequests:s})}))}componentDidMount(){this._isMounted=!0,this._onAdapterChange(),this.props.adapters.vectorTiles.on("change",this._debouncedOnAdapterChange)}componentWillUnmount(){this._isMounted=!1,this.props.adapters.vectorTiles.removeListener("change",this._debouncedOnAdapterChange)}renderTabs(){return this.state.tileRequests.map((e=>{var t,s,r,o;const n=`${e.z}/${e.x}/${e.y}`;return Object(p.jsx)(c.EuiTab,{key:`${e.layerId}${n}`,onClick:()=>{this.setState({selectedTileRequest:e})},isSelected:e.layerId===(null===(t=this.state.selectedTileRequest)||void 0===t?void 0:t.layerId)&&e.x===(null===(s=this.state.selectedTileRequest)||void 0===s?void 0:s.x)&&e.y===(null===(r=this.state.selectedTileRequest)||void 0===r?void 0:r.y)&&e.z===(null===(o=this.state.selectedTileRequest)||void 0===o?void 0:o.z)},n)}))}render(){return 0===this.state.layerOptions.length?Object(p.jsx)(a.a.Fragment,null,Object(p.jsx)(q,null),Object(p.jsx)(h,null)):Object(p.jsx)(a.a.Fragment,null,Object(p.jsx)(q,null),Object(p.jsx)(c.EuiSpacer,null),Object(p.jsx)(c.EuiComboBox,{singleSelection:!0,options:this.state.layerOptions,selectedOptions:this.state.selectedLayer?[this.state.selectedLayer]:[],onChange:this._onLayerSelect,isClearable:!1,prepend:u.i18n.translate("xpack.maps.inspector.vectorTile.layerSelectPrepend",{defaultMessage:"Layer"})}),Object(p.jsx)(c.EuiSpacer,null),Object(p.jsx)(c.EuiTabs,{size:"s"},this.renderTabs()),Object(p.jsx)(c.EuiSpacer,{size:"s"}),this.state.selectedTileRequest&&Object(p.jsx)(j,{key:`${this.state.selectedTileRequest.layerId}${this.state.selectedTileRequest.x}${this.state.selectedTileRequest.y}${this.state.selectedTileRequest.z}`,tileRequest:this.state.selectedTileRequest}))}}t.default=vector_tile_inspector_VectorTileInspector}}]);