/*! 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.lens_bundle_jsonpfunction=window.lens_bundle_jsonpfunction||[]).push([[7,16],{108:function(e,t,a){"use strict";a.d(t,"a",(function(){return n})),a.d(t,"c",(function(){return l})),a.d(t,"b",(function(){return o}));var s=a(25);const i=["_type","_source"];const n=e=>"_score"!==e.name&&["string","text","keyword","version","ip","number","geo_point","geo_shape"].includes(e.type),l=e=>!e.aggregatable&&n(e)||"geo_point"===e.type||"geo_shape"===e.type;function o(e,t){if(e=Object(s.defaults)(e,{count:5}),!n(e.field))throw new Error(`Analysis is not available this field type: "${e.field.type}". Field name: "${e.field.name}"`);const a=(l=e.hits,o=e.field,u=e.dataView,Object(s.map)(l,(function(e){return function(e,t,a){var n;const l={};function o(e,i=""){for(const[n,u]of Object.entries(e)){const e=i+n,r=null==t?void 0:t.fields.getByName(e);if(!1===(null==a?void 0:a.shallow)){const t="nested"===(null==r?void 0:r.type);if(Array.isArray(u)&&!t){u.forEach((t=>Object(s.isPlainObject)(t)&&o(t,e+".")));continue}}else if(void 0!==l[e])continue;const c=r&&"conflict"!==r.type,d=!Object(s.isPlainObject)(u);c||d?l[e]?Array.isArray(l[e])?l[e].push(u):l[e]=[l[e],u]:l[e]=u:o(u,e+".")}}return o(e.fields||{}),!1!==(null==a?void 0:a.source)&&e._source?o(e._source):null!=a&&a.includeIgnoredValues&&e.ignored_field_values&&Object.entries(e.ignored_field_values).forEach((([e,t])=>{l[e]?Array.isArray(l[e])?l[e]=[...l[e],...t]:l[e]=[l[e],...t]:l[e]=t})),null==t||null===(n=t.metaFields)||void 0===n||n.forEach((t=>{i.includes(t)||"_"!==t.charAt(0)||(l[t]=e[t])})),new Proxy(l,{ownKeys:e=>Reflect.ownKeys(e).sort(((e,a)=>{var s,i;const n=null==t||null===(s=t.metaFields)||void 0===s?void 0:s.includes(String(e)),l=null==t||null===(i=t.metaFields)||void 0===i?void 0:i.includes(String(a));return n&&l?String(e).localeCompare(String(a)):n?1:l?-1:String(e).localeCompare(String(a))}))})}(e,u,{includeIgnoredValues:!0})[o.name]})));var l,o,u;const{groups:r,sampledValues:c}=function(e,t){const a={};let i=0;return e.forEach((function(e){if(Object(s.isObject)(e)&&!Array.isArray(e))throw new Error("Analysis is not available for object fields.");let n,l=0;const o={};n=Array.isArray(e)?e:null==e?[]:[e],n.forEach((e=>{const s=t?t.convert(e):e;o[s]||(a.hasOwnProperty(s)?a[s].count++:a[s]={key:s,count:1,order:l++},o[s]=!0,i++)}))})),{groups:a,sampledValues:i}}(a,t);return{buckets:Object(s.sortBy)(r,["count","order"]).reverse().slice(0,e.count).map((e=>Object(s.pick)(e,["key","count"]))),sampledValues:c,sampledDocuments:e.hits.length}}},136:function(e,t,a){"use strict";a.d(t,"a",(function(){return r})),a.d(t,"d",(function(){return c})),a.d(t,"c",(function(){return m})),a.d(t,"b",(function(){return g}));var s=a(47),i=a.n(s),n=a(108);const l=5e3,o=10,u=100;function r({dataViewPattern:e,timeFieldName:t,fromDate:a,toDate:s,dslQuery:i,runtimeMappings:n,aggs:l,fields:o,size:u}){const r=t?[{range:{[t]:{gte:a,lte:s,format:"strict_date_optional_time"}}},i]:[i];return 1===(null==o?void 0:o.length)&&r.push({exists:o[0]}),{index:e,body:{query:{bool:{filter:r}},aggs:l,fields:o,runtime_mappings:n,_source:(null==o||!o.length)&&void 0},track_total_hits:!0,size:null!=u?u:0}}async function c({searchHandler:e,dataView:t,field:a,fromDate:s,toDate:u,size:r}){return a.aggregatable?"geo_point"===a.type||"geo_shape"===a.type?await async function(e,t,a){try{const s=a.getFormatterForField(t);return await p(e,t,a,s)}catch(e){return console.error(e),{}}}(e,a,t):d(a)?"histogram"===a.type?await b(e,a,!1):g(a)?await async function(e,t){const a={sample:{sampler:{shard_size:l},aggs:{min_max_summary:{filter:{exists:{field:t.name}},aggs:{min:{min:{field:t.name}},max:{max:{field:t.name}}}}}}},s=await e({aggs:a}),i=s.aggregations.sample.min_max_summary.min.value,n=s.aggregations.sample.min_max_summary.max.value,o=s.aggregations.sample.doc_count;return{totalDocuments:j(s),sampledDocuments:o,sampledValues:o,numberSummary:{minValue:i,maxValue:n}}}(e,a):"number"===a.type?await b(e,a):"date"===a.type?await async function(e,t,a){const s=i.a.parse(a.fromDate),n=i.a.parse(a.toDate);if(!s)throw Error("Invalid fromDate value");if(!n)throw Error("Invalid toDate value");const l=Math.round((n.valueOf()-s.valueOf())/10);if(l<1)return{totalDocuments:0,histogram:{buckets:[]}};const o=`${l}ms`,u={histo:{date_histogram:{...f(t),fixed_interval:o}}},r=await e({aggs:u});return{totalDocuments:j(r),histogram:{buckets:r.aggregations.histo.buckets.map((e=>({count:e.doc_count,key:e.key})))}}}(e,a,{fromDate:s,toDate:u}):await async function(e,t,a=o){const s=f(t),i={sample:{sampler:{shard_size:l},aggs:{sample_count:{value_count:{...s}},top_values:{terms:{...s,size:a,shard_size:a<=10?25:void 0}}}}},n=await e({aggs:i}),u={buckets:n.aggregations.sample.top_values.buckets.map((e=>({count:e.doc_count,key:e.key})))};return{totalDocuments:j(n),sampledDocuments:n.aggregations.sample.doc_count,sampledValues:v(u,n.aggregations.sample.top_values.sum_other_doc_count)||n.aggregations.sample.sample_count.value,topValues:u}}(e,a,r):{}:Object(n.a)(a)?await p(e,a,t):{}}function d(e){return!("document"===e.type||e.type.includes("range")||"geo_point"===e.type||"geo_shape"===e.type||"murmur3"===e.type||"attachment"===e.type)}function m(e){return e.aggregatable&&d(e)||Object(n.c)(e)}function g(e){return"counter"===e.timeSeriesMetric}async function b(e,t,a=!0){const s=f(t),i={min_value:{min:{field:t.name}},max_value:{max:{field:t.name}},sample_count:{value_count:{...s}}},n={sample:{sampler:{shard_size:l},aggs:{...i}}},u={sample:{sampler:{shard_size:l},aggs:{...i,top_values:{terms:{...s,size:o}}}}},r=await e({aggs:a?u:n}),c=r.aggregations.sample.min_value.value,d=r.aggregations.sample.max_value.value,m="top_values"in r.aggregations.sample?r.aggregations.sample.top_values:{buckets:[],sum_other_doc_count:0},g={buckets:m.buckets.map((e=>({count:e.doc_count,key:e.key})))};let b=(d-c)/10;if(Number.isInteger(c)&&Number.isInteger(d)&&(b=Math.ceil(b)),0===b)return{totalDocuments:j(r),sampledValues:v(g,m.sum_other_doc_count)||r.aggregations.sample.sample_count.value,sampledDocuments:r.aggregations.sample.doc_count,topValues:g,histogram:a?{buckets:[]}:{buckets:[{count:r.aggregations.sample.doc_count,key:c}]}};const p={sample:{sampler:{shard_size:l},aggs:{histo:{histogram:{field:t.name,interval:b}}}}},x=await e({aggs:p});return{totalDocuments:j(r),sampledDocuments:r.aggregations.sample.doc_count,sampledValues:v(g,m.sum_other_doc_count)||r.aggregations.sample.sample_count.value,histogram:{buckets:x.aggregations.sample.histo.buckets.map((e=>({count:e.doc_count,key:e.key})))},topValues:g}}async function p(e,t,a,s){try{const i=f(t),l={size:u,fields:[i]},r=await e(l),c=Object(n.b)({hits:r.hits.hits,field:t,dataView:a,count:o},s);return{totalDocuments:j(r),sampledDocuments:c.sampledDocuments,sampledValues:c.sampledValues,topValues:{buckets:c.buckets}}}catch(e){return console.error(e),{}}}function f(e){return e.scripted?{script:{lang:e.lang,source:e.script}}:{field:e.name}}const j=e=>{var t,a;return null!==(t=null!==(a=e.hits.total.value)&&void 0!==a?a:e.hits.total)&&void 0!==t?t:0};function v(e,t){var a;return((null==e||null===(a=e.buckets)||void 0===a?void 0:a.reduce(((e,t)=>t.count+e),0))||0)+(t||0)}},187:function(e,t,a){"use strict";a.r(t);var s=a(14),i=a.n(s),n=(a(7),a(6)),l=a(0),o=a(2),u={name:"5iz1wr",styles:"width:48px"},r={name:"ovk77c",styles:"min-width:0"};t.default=({"data-test-subj":e,onAddFilter:t,overrideFieldTopValueBar:a,...s})=>{var c,d,m,g;const b=a?a(s):{},{field:p,type:f,fieldValue:j,formattedFieldValue:v,formattedPercentage:x,progressValue:h,count:y,color:O,textProps:F={}}={...s,...b},S=null!==(c=null==p||null===(d=p.subType)||void 0===d||null===(m=d.multi)||void 0===m?void 0:m.parent)&&void 0!==c?c:p.name;return Object(o.jsx)(n.EuiFlexGroup,{alignItems:"stretch",gutterSize:"s",responsive:!1,"data-test-subj":`${e}-topValues-bucket`},Object(o.jsx)(n.EuiFlexItem,{grow:1,css:r},Object(o.jsx)(n.EuiFlexGroup,{alignItems:"stretch",gutterSize:"s",responsive:!1},Object(o.jsx)(n.EuiFlexItem,{grow:!0,className:"eui-textTruncate","data-test-subj":`${e}-topValues-formattedFieldValue`},(null!==(g=null==v?void 0:v.length)&&void 0!==g?g:0)>0?Object(o.jsx)(n.EuiToolTip,{content:v,delay:"long"},Object(o.jsx)(n.EuiText,i()({size:"xs",className:"eui-textTruncate",color:"subdued"},F),v)):Object(o.jsx)(n.EuiText,{size:"xs"},"other"===f?l.i18n.translate("unifiedFieldList.fieldStats.otherDocsLabel",{defaultMessage:"Other"}):""===v?l.i18n.translate("unifiedFieldList.fieldStats.emptyStringValueLabel",{defaultMessage:"(empty)"}):"-")),Object(o.jsx)(n.EuiFlexItem,{grow:!1,"data-test-subj":`${e}-topValues-formattedPercentage`},Object(o.jsx)(n.EuiToolTip,{content:l.i18n.translate("unifiedFieldList.fieldStats.bucketPercentageTooltip",{defaultMessage:"{formattedPercentage} ({count, plural, one {# record} other {# records}})",values:{formattedPercentage:x,count:y}}),delay:"long"},Object(o.jsx)(n.EuiText,{size:"xs",textAlign:"left",color:O},x)))),Object(o.jsx)(n.EuiProgress,{value:h,max:1,size:"s",color:"other"===f?"subdued":O,"aria-label":`${v} (${x})`})),t&&p.filterable&&Object(o.jsx)(n.EuiFlexItem,{grow:!1},"other"===f?Object(o.jsx)("div",{css:u}):Object(o.jsx)("div",null,Object(o.jsx)(n.EuiButtonIcon,{iconSize:"s",iconType:"plusInCircle",onClick:()=>t(p,j,"+"),"aria-label":l.i18n.translate("unifiedFieldList.fieldStats.filterValueButtonAriaLabel",{defaultMessage:'Filter for {field}: "{value}"',values:{value:v,field:S}}),"data-test-subj":`plus-${S}-${j}`,style:{minHeight:"auto",minWidth:"auto",paddingRight:2,paddingLeft:2,paddingTop:0,paddingBottom:0}}),Object(o.jsx)(n.EuiButtonIcon,{iconSize:"s",iconType:"minusInCircle",onClick:()=>t(p,j,"-"),"aria-label":l.i18n.translate("unifiedFieldList.fieldStats.filterOutValueButtonAriaLabel",{defaultMessage:'Filter out {field}: "{value}"',values:{value:v,field:S}}),"data-test-subj":`minus-${S}-${j}`,style:{minHeight:"auto",minWidth:"auto",paddingTop:0,paddingBottom:0,paddingRight:2,paddingLeft:2}}))))}},582:function(e,t,a){"use strict";a.r(t);var s=a(7),i=a.n(s),n=a(91),l=a(564),o=a(47),u=a.n(o),r=a(6),c=a(26),d=a(32),m=a(0),g=a(21),b=a(108),p=a(136),f=a(181),j=a(187),v=a(2);const x=({areExamples:e,buckets:t,dataView:a,field:n,sampledValuesCount:l,color:o=h(),"data-test-subj":u,onAddFilter:c,overrideFieldTopValueBar:d})=>{if(null==t||!t.length)return null;const m=a.getFormatterForField(n),g=S(F(t),l),b=t.some((e=>!Number.isInteger(e.count/l)));return Object(v.jsx)("div",{"data-test-subj":e?"unifiedFieldStats-exampleValueBuckets":"unifiedFieldStats-topValueBuckets"},Object(v.jsx)("div",{"data-test-subj":`${u}-topValues`},t.map(((e,t)=>{const a=e.key,i=m.convert(a);return Object(v.jsx)(s.Fragment,{key:a},t>0&&Object(v.jsx)(r.EuiSpacer,{size:"s"}),Object(v.jsx)(j.default,{field:n,fieldValue:a,formattedFieldValue:i,formattedPercentage:y(e.count,l,b),progressValue:O(e.count,l),count:e.count,color:o,"data-test-subj":u,onAddFilter:c,overrideFieldTopValueBar:d}))})),g>0&&Object(v.jsx)(i.a.Fragment,null,Object(v.jsx)(r.EuiSpacer,{size:"s"}),Object(v.jsx)(j.default,{type:"other",field:n,fieldValue:void 0,formattedPercentage:y(g,l,b),progressValue:O(g,l),count:g,color:o,"data-test-subj":u,onAddFilter:c,overrideFieldTopValueBar:d}))))},h=()=>Object(r.euiPaletteColorBlind)()[1],y=(e,t,a)=>t>0?`${(Math.round(e/t*1e3)/10).toFixed(a?1:0)}%`:"",O=(e,t)=>t>0?e/t:0,F=e=>(null==e?void 0:e.reduce(((e,t)=>t.count+e),0))||0,S=(e,t)=>t&&e?t-e:0,_=({message:e})=>Object(v.jsx)(r.EuiText,{size:"s"},e),T=({dataView:e,field:t,numberSummary:a,"data-test-subj":s})=>{if(!a||!V(a))return null;const i=e.getFormatterForField(t),n=[{key:"min",label:m.i18n.translate("unifiedFieldList.fieldStats.numberSummary.minLabel",{defaultMessage:"min"}),value:i.convert(a.minValue,"text")},{key:"max",label:m.i18n.translate("unifiedFieldList.fieldStats.numberSummary.maxLabel",{defaultMessage:"max"}),value:i.convert(a.maxValue,"text")}],l=[{field:"label",name:"",align:r.LEFT_ALIGNMENT},{field:"value",name:"",render:e=>Object(v.jsx)("strong",null,e),align:r.RIGHT_ALIGNMENT}],o=m.i18n.translate("unifiedFieldList.fieldStats.numberSummary.summaryTableTitle",{defaultMessage:"Summary"});return Object(v.jsx)(r.EuiBasicTable,{compressed:!0,items:n,columns:l,tableCaption:o,"data-test-subj":`${s}-numberSummary`,responsive:!1,css:Object(v.css)("& .euiTableHeaderCell{",Object(r.euiScreenReaderOnly)(),";}& .euiTableRowCell{border-top:none;}","")})};function V(e){return"number"==typeof(null==e?void 0:e.minValue)&&"number"==typeof(null==e?void 0:e.maxValue)}var k=a(570);const D=({services:e,query:t,dslQuery:a,filters:o,fromDate:j,toDate:y,dataViewOrDataViewId:O,field:k,color:D=h(),"data-test-subj":w="fieldStats",overrideMissingContent:E,overrideFooter:L,onAddFilter:M,overrideFieldTopValueBar:z,onStateChange:A})=>{const{fieldFormats:I,uiSettings:B,charts:C,dataViews:N,data:$}=e,[P,R]=Object(s.useState)({isLoading:!1}),[G,H]=Object(s.useState)(null),Q=Object(s.useRef)(null),U=Object(s.useRef)(!1),W=Object(s.useCallback)((e=>{U.current||R(e)}),[R,U]);Object(s.useEffect)((function(){A&&A(P)}),[A,P]);const q=Object(s.useCallback)((e=>{U.current||H(e)}),[H,U]);Object(s.useEffect)((()=>{!async function(){if(!U.current)try{var e;const s="string"==typeof O?await N.get(O):O;if(q(s),P.isLoading)return;W((e=>({...e,isLoading:!0}))),null===(e=Q.current)||void 0===e||e.abort(),Q.current=new AbortController;const i=await Object(f.a)({services:{data:$},dataView:s,field:k,fromDate:j,toDate:y,dslQuery:null!=a?a:Object(g.buildEsQuery)(s,null!=t?t:[],null!=o?o:[],Object(l.a)(B)),abortController:Q.current});Q.current=null,W((e=>({...e,isLoading:!1,totalDocuments:i.totalDocuments,sampledDocuments:i.sampledDocuments,sampledValues:i.sampledValues,histogram:i.histogram,topValues:i.topValues,numberSummary:i.numberSummary})))}catch(e){W((e=>({...e,isLoading:!1})))}}()}),[O,k,a,t,o,j,y,e]),Object(s.useEffect)((()=>()=>{var e;U.current=!0,null===(e=Q.current)||void 0===e||e.abort()}),[]);const K=C.theme.useChartsTheme(),Z=C.theme.useChartsBaseTheme(),J=Object(s.useMemo)((()=>{var e;return D?{...K,barSeriesStyle:{...K.barSeriesStyle,rect:{...(null===(e=K.barSeriesStyle)||void 0===e?void 0:e.rect)||{},fill:D}}}:K}),[K,D]),{isLoading:X,histogram:Y,topValues:ee,numberSummary:te,sampledValues:ae,sampledDocuments:se,totalDocuments:ie}=P;let ne=!!P.histogram;const le=u.a.parse(j),oe=u.a.parse(y),ue=F(null==ee?void 0:ee.buckets),re=S(ue,ae);ue&&Y&&Y.buckets.length&&ee&&ee.buckets.length&&(ne=re/ue>.9);const[ce,de]=Object(s.useState)(ne);if(X)return Object(v.jsx)(r.EuiLoadingSpinner,null);if(!G)return null;const me=G.getFormatterForField(k);let ge=Object(v.jsx)(i.a.Fragment,null);function be(e){const t="unifiedFieldStats-statsFooter-docsCount",a=ie?Object(v.jsx)(r.EuiText,{color:"subdued",size:"xs","data-test-subj":`${w}-statsFooter`},se&&se{de("histogram"===e)},idSelected:ce?"histogram":"topValues"}),Object(v.jsx)(r.EuiSpacer,{size:"xs"})):"date"===k.type?ge=Object(v.jsx)(r.EuiTitle,{size:"xxxs"},Object(v.jsx)("h6",null,m.i18n.translate("unifiedFieldList.fieldStats.fieldTimeDistributionLabel",{defaultMessage:"Time distribution"}))):ee&&ee.buckets.length&&(ge=Object(v.jsx)(r.EuiTitle,{size:"xxxs"},Object(v.jsx)("h6",null,Object(b.c)(k)?m.i18n.translate("unifiedFieldList.fieldStats.examplesLabel",{defaultMessage:"Examples"}):m.i18n.translate("unifiedFieldList.fieldStats.topValuesLabel",{defaultMessage:"Top values"})))),Y&&Y.buckets.length){const e=m.i18n.translate("unifiedFieldList.fieldStats.countLabel",{defaultMessage:"Count"});if("date"===k.type)return be(Object(v.jsx)("div",{"data-test-subj":"unifiedFieldStats-timeDistribution"},Object(v.jsx)("div",{"data-test-subj":`${w}-histogram`},Object(v.jsx)(d.Chart,{size:{height:200,width:268}},Object(v.jsx)(d.Tooltip,{type:d.TooltipType.None}),Object(v.jsx)(d.Settings,{theme:J,baseTheme:Z,xDomain:le&&oe?{min:le.valueOf(),max:oe.valueOf(),minInterval:Math.round((oe.valueOf()-le.valueOf())/10)}:void 0}),Object(v.jsx)(d.Axis,{id:"key",position:d.Position.Bottom,tickFormat:le&&oe?Object(d.niceTimeFormatter)([le.valueOf(),oe.valueOf()]):void 0,showOverlappingTicks:!0}),Object(v.jsx)(d.HistogramBarSeries,{data:Y.buckets,id:e,xAccessor:"key",yAccessors:["count"],xScaleType:d.ScaleType.Time,yScaleType:d.ScaleType.Linear,timeZone:"local"})))));if(ce||!ee||!ee.buckets.length)return be(Object(v.jsx)("div",{"data-test-subj":"unifiedFieldStats-histogram"},Object(v.jsx)(d.Chart,{"data-test-subj":`${w}-histogram`,size:{height:200,width:"100%"}},Object(v.jsx)(d.Tooltip,{type:d.TooltipType.None}),Object(v.jsx)(d.Settings,{rotation:90,theme:J,baseTheme:Z}),Object(v.jsx)(d.Axis,{id:"key",position:d.Position.Left,showOverlappingTicks:!0,tickFormat:e=>me.convert(e)}),Object(v.jsx)(d.HistogramBarSeries,{data:Y.buckets,id:e,xAccessor:"key",yAccessors:["count"],xScaleType:d.ScaleType.Linear,yScaleType:d.ScaleType.Linear}))))}return ee&&ee.buckets.length?be(Object(v.jsx)(x,{areExamples:Object(b.c)(k),buckets:ee.buckets,dataView:G,field:k,sampledValuesCount:ae,color:D,"data-test-subj":w,onAddFilter:M,overrideFieldTopValueBar:z})):null};t.default=e=>Object(v.jsx)(k.a,null,Object(v.jsx)(D,e))}}]);