/*! 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.dataVisualizer_bundle_jsonpfunction=window.dataVisualizer_bundle_jsonpfunction||[]).push([[8],{175:function(e,t,a){"use strict";a.r(t),a.d(t,"FileDataVisualizer",(function(){return s.FileDataVisualizer})),a.d(t,"IndexDataVisualizer",(function(){return k})),a.d(t,"DataComparison",(function(){return z.a}));var s=a(40),i=(a(99),a(6)),r=a(0),n=a(11),c=a(4),o=a(8),d=a(3),l=a(44),u=a(30),h=a(82),S=a(18),b=a(65),j=a(31),v=a(15),f=a(5),g=a(77),O=a(56),I=a(19),p=a(80);const x=d.i18n.translate("xpack.dataVisualizer.chrome.help.appName",{defaultMessage:"Data Visualizer"});var y=a(79),w=a(2);const V=new l.Storage(window.localStorage),m=e=>{const t=Object(v.d)(e.urlSearchString);let a={dataViewId:t.index,searchSessionId:e.searchSessionId};if(e.savedSearchId&&(a.savedSearchId=e.savedSearchId),t){if(t._g){const{time:e,refreshInterval:s}=t._g;a.timeRange=e,a.refreshInterval=s}t._a&&t._a[p.a]&&(a={...a,...t._a[p.a]})}return a},E=({IndexDataVisualizerComponent:e,getAdditionalLinks:t})=>{const{services:a}=Object(O.a)(),{data:{dataViews:s,search:l},savedObjects:{client:u},notifications:{toasts:h},savedSearch:b}=a,j=Object(n.useHistory)(),{search:f}=Object(n.useLocation)(),[g,p]=Object(r.useState)(void 0),[y,V]=Object(r.useState)(null),[E,k]=Object(r.useState)(void 0);Object(r.useEffect)((()=>{const e=Object(v.d)(f);if(l.session&&l.session.enableStorage({getName:async()=>x,getLocatorData:async()=>({id:I.a,initialState:m({...a,urlSearchString:f,dataViewId:null==g?void 0:g.id,savedSearchId:null==y?void 0:y.id,shouldRestoreSearchSession:!1,searchSessionId:l.session.getSessionId()}),restoreState:m({...a,urlSearchString:f,dataViewId:null==g?void 0:g.id,savedSearchId:null==y?void 0:y.id,shouldRestoreSearchSession:!0,searchSessionId:l.session.getSessionId()})})}),void 0!==e.searchSessionId&&e.searchSessionId!==E){var t;null===(t=l.session)||void 0===t||t.restore(e.searchSessionId),k(e.searchSessionId)}else{var s;const e=null===(s=l.session)||void 0===s?void 0:s.start();k(e)}return()=>{l.session.clear()}}),[l.session,f]),Object(r.useEffect)((()=>{const e=f,t=Object(c.parse)(e,{sort:!1});(async()=>{if("string"==typeof(null==t?void 0:t.savedSearchId)){const e=t.savedSearchId;try{const t=await b.get(e),a=t.searchSource.getField("index");a||h.addDanger({title:d.i18n.translate("xpack.dataVisualizer.index.dataViewErrorMessage",{defaultMessage:"Error finding data view"})}),V(t),p(a)}catch(t){h.addError(t,{title:d.i18n.translate("xpack.dataVisualizer.index.savedSearchErrorMessage",{defaultMessage:"Error retrieving saved search {savedSearchId}",values:{savedSearchId:e}})})}}if("string"==typeof(null==t?void 0:t.index)){const e=await s.get(t.index);p(e)}})()}),[u,h,s,f,l,b]);const z=Object(r.useCallback)(((e,t,a,s)=>{const r=f,n=Object(v.d)(r),d=Object(c.parse)(r,{sort:!1});if(Object.prototype.hasOwnProperty.call(n,e)||(n[e]={}),"string"==typeof t){if(Object(i.isEqual)(Object(S.a)(n,`${e}.${t}`),a))return r;n[e][t]=a}else{const a=t;Object.keys(a).forEach((t=>{n[e][t]=a[t]}))}try{const e=Object(c.stringify)(d,{sort:!1,encode:!1});if(Object.keys(n).forEach((e=>{Object(v.c)(e)?d[e]=Object(o.encode)(n[e]):d[e]=n[e]})),e!==Object(c.stringify)(d,{sort:!1,encode:!1})){const e=Object(c.stringify)(d,{sort:!1});s?j.replace({search:e}):j.push({search:e})}}catch(e){console.error("Could not save url state",e)}}),[j,f]);return Object(w.jsx)(v.a,{value:{searchString:f,setUrlState:z}},g?Object(w.jsx)(e,{currentDataView:g,currentSavedSearch:y,currentSessionId:E,getAdditionalLinks:t}):Object(w.jsx)("div",null))},k=({getAdditionalLinks:e})=>{const t=Object(f.a)(),{data:a,maps:s,embeddable:r,discover:n,share:c,security:o,fileUpload:d,lens:l,dataViewFieldEditor:S,uiActions:v,charts:O,unifiedSearch:I}=Object(f.b)(),p={data:a,maps:s,embeddable:r,discover:n,share:c,security:o,fileUpload:d,lens:l,dataViewFieldEditor:S,uiActions:v,charts:O,unifiedSearch:I,...t},x={...Object(i.pick)(p,["data","http","notifications","theme","uiSettings","i18n"]),uiSettingsKeys:j.UI_SETTINGS};return Object(w.jsx)(u.KibanaThemeProvider,{theme$:t.theme.theme$,modify:{breakpoint:{xxl:1400}}},Object(w.jsx)(u.KibanaContextProvider,{services:{...p}},Object(w.jsx)(h.a,{storage:V,storageKeys:y.d},Object(w.jsx)(b.a,x,Object(w.jsx)(E,{IndexDataVisualizerComponent:g.a,getAdditionalLinks:e})))))};var z=a(16)}}]);