/*! 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.aiops_bundle_jsonpfunction=window.aiops_bundle_jsonpfunction||[]).push([[5],{168:function(e,t,a){"use strict";a.r(t),a.d(t,"categorizeFieldAction",(function(){return Pe}));var s=a(1),o=a.n(s),n=a(12),i=a(51),l=a(44),r=a(21),c=a(42),u=a(16),d=a(40),g=a(50),b=a(38),p=a(2),m=a(11),j=a(13),O=a(76),f=a(68),x=a(69),y=a(94),h=a(67),S=a(18),v=a(58),C=a.n(v),E=a(52);function k(e,t=2){if(void 0===e)return"";if(e%1==0)return e;if(Math.abs(e)100*e)),L=1e-5,_=.001,z={ON_AUTOMATIC:"on_automatic",ON_MANUAL:"on_manual",OFF:"off"},A=[{"data-test-subj":"aiopsRandomSamplerOptionOnAutomatic",value:z.ON_AUTOMATIC,text:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerPreference.onAutomaticLabel",{defaultMessage:"On - automatic"})},{"data-test-subj":"aiopsRandomSamplerOptionOnManual",value:z.ON_MANUAL,text:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerPreference.onManualLabel",{defaultMessage:"On - manual"})},{"data-test-subj":"aiopsRandomSamplerOptionOff",value:z.OFF,text:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerPreference.offLabel",{defaultMessage:"Off"})}];class random_sampler_RandomSampler{constructor(e,t,a,s){M()(this,"docCount$",new I.BehaviorSubject(0)),M()(this,"mode$",new I.BehaviorSubject(z.ON_AUTOMATIC)),M()(this,"probability$",new I.BehaviorSubject(_)),M()(this,"setRandomSamplerModeInStorage",void 0),M()(this,"setRandomSamplerProbabilityInStorage",void 0),this.mode$.next(e),this.setRandomSamplerModeInStorage=t,this.probability$.next(a),this.setRandomSamplerProbabilityInStorage=s}setDocCount(e){return this.docCount$.next(e)}getDocCount(){return this.docCount$.getValue()}setMode(e){return this.setRandomSamplerModeInStorage(e),this.mode$.next(e)}getMode$(){return this.mode$.asObservable()}getMode(){return this.mode$.getValue()}setProbability(e){return this.setRandomSamplerProbabilityInStorage(e),this.probability$.next(e)}getProbability$(){return this.probability$.asObservable()}getProbability(){return this.probability$.getValue()}createRandomSamplerWrapper(){const e=this.getMode(),t=this.getProbability();let a={};e===z.ON_MANUAL?a={probability:t}:e===z.OFF&&(a={probability:1});const s=Object(P.a)({...a,totalNumDocs:this.getDocCount()});return this.setProbability(s.probability),s}}var T=a(0);const N=({samplingProbability:e,setSamplingProbability:t})=>{const[a,o]=Object(s.useState)(e),n=!Object(E.a)(a)||isNaN(a)||a.5,i=100*(null!=a?a:L);return Object(T.jsx)(p.EuiFlexItem,{grow:!0},Object(T.jsx)(p.EuiSpacer,{size:"m"}),Object(T.jsx)(p.EuiFormRow,{fullWidth:!0,label:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.randomSamplerPercentageRowLabel",{defaultMessage:"Sampling percentage"}),helpText:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.randomSamplerPercentageRowHelpText",{defaultMessage:"Choose a value between 0.001% and 50% to randomly sample data."})},Object(T.jsx)(p.EuiRange,{fullWidth:!0,showValue:!0,showRange:!0,showLabels:!0,showInput:"inputWithPopover",min:.001,max:50,value:k(i,i>=1?0:3),ticks:w.map((e=>({value:e,label:.001===e||e>=5?`${e}`:""}))),isInvalid:n,onChange:e=>{const t=parseFloat(e.target.value),s=a?100*a:t;if(t>0&&t<=1)o(t/100);else{const e=t>s?Math.ceil(t):Math.floor(t);o(e/100)}},step:.001,"data-test-subj":"dvRandomSamplerProbabilityRange",append:Object(T.jsx)(p.EuiButton,{disabled:n,onClick:()=>{t&&Object(E.a)(a)&&t(a)}},Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.randomSamplerSettingsPopUp.randomSamplerPercentageApply",defaultMessage:"Apply"}))})))},R=({randomSampler:e,reload:t})=>{const[a,o]=Object(s.useState)(!1),n=C()(e.getProbability$(),e.getProbability()),i=Object(s.useCallback)((a=>{e.setProbability(a),t()}),[t,e]),l=C()(e.getMode$(),e.getMode()),r=Object(s.useCallback)((a=>{e.setMode(a),t()}),[e,t]),{calloutInfoMessage:c,buttonText:u}=Object(s.useMemo)((()=>{switch(l){case z.OFF:return{calloutInfoMessage:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.offCallout.message",{defaultMessage:"Random sampling can be turned on to increase the speed of analysis, although some accuracy will be lost."}),buttonText:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.offCallout.button",{defaultMessage:"No sampling"})};case z.ON_AUTOMATIC:return{calloutInfoMessage:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.onAutomaticCallout.message",{defaultMessage:"The pattern analysis will use random sampler aggregations. The probability is automatically set to balance accuracy and speed."}),buttonText:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.onAutomaticCallout.button",{defaultMessage:"Auto sampling"})};case z.ON_MANUAL:default:return{calloutInfoMessage:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.onManualCallout.message",{defaultMessage:"The pattern analysis will use random sampler aggregations. A lower percentage probability increases performance, but some accuracy is lost."}),buttonText:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.onManualCallout.button",{defaultMessage:"Manual sampling"})}}}),[l]);return Object(T.jsx)(p.EuiPopover,{"data-test-subj":"aiopsRandomSamplerOptionsPopover",id:"aiopsSamplingOptions",button:Object(T.jsx)(p.EuiButtonEmpty,{onClick:()=>o(!a),iconSide:"right",iconType:"arrowDown"},u),isOpen:a,closePopover:()=>o(!1),panelPaddingSize:"none",anchorPosition:"downLeft"},Object(T.jsx)(p.EuiPanel,{style:{maxWidth:400}},Object(T.jsx)(p.EuiFlexItem,{grow:!0},Object(T.jsx)(p.EuiCallOut,{size:"s",color:"primary",title:c})),Object(T.jsx)(p.EuiSpacer,{size:"m"}),Object(T.jsx)(p.EuiFormRow,{"data-test-subj":"aiopsRandomSamplerOptionsFormRow",label:m.i18n.translate("xpack.aiops.logCategorization.randomSamplerSettingsPopUp.randomSamplerRowLabel",{defaultMessage:"Random sampling"})},Object(T.jsx)(p.EuiSelect,{"data-test-subj":"aiopsRandomSamplerOptionsSelect",options:A,value:l,onChange:e=>r(e.target.value)})),l===z.ON_MANUAL?Object(T.jsx)(N,{samplingProbability:n,setSamplingProbability:i}):null,l===z.ON_AUTOMATIC?Object(T.jsx)(q,{samplingProbability:n}):null))},q=({samplingProbability:e})=>null!==e?Object(T.jsx)("div",{"data-test-subj":"aiopsRandomSamplerProbabilityUsedMsg"},Object(T.jsx)(p.EuiSpacer,{size:"m"}),Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.randomSamplerSettingsPopUp.probabilityLabel",defaultMessage:"Probability used: {samplingProbability}%",values:{samplingProbability:100*e}})):null,U=1e3,D=1;function V(){const[e,t]=Object(i.b)(g.b,z.ON_AUTOMATIC),[a,o]=Object(i.b)(g.c,_),{data:l}=Object(b.b)(),r=Object(s.useRef)(new AbortController),c=Object(s.useMemo)((()=>new random_sampler_RandomSampler(e,t,a,o)),[]);return{runCategorizeRequest:Object(s.useCallback)(((e,t,a,s,o,i,u)=>{const{wrap:d,unwrap:g}=c.createRandomSamplerWrapper();return new Promise(((c,b)=>{l.search.search(function(e,t,a,s,o,n,i,l){return{params:{index:e,size:0,body:{query:B(n,a,s,o),aggs:i({categories:{categorize_text:{field:t,size:U},aggs:{hit:{top_hits:{size:D,sort:[a],_source:t}},...l?{sparkline:{date_histogram:{field:a,fixed_interval:`${l}ms`}}}:{}}}})}}}}(e,t,a,s,o,i,d,u),{abortSignal:r.current.signal}).subscribe({next:e=>{Object(S.isCompleteResponse)(e)?c(function(e,t,a){const s={},{aggregations:o}=e.rawResponse;if(void 0===o)throw new Error("processCategoryResults failed, did not return aggregations.");const{categories:{buckets:i}}=a(o);return{categories:i.map((e=>(s[e.key]=void 0===e.sparkline?{}:e.sparkline.buckets.reduce(((e,t)=>(e[t.key]=t.doc_count,e)),{}),{key:e.key,count:e.doc_count,examples:e.hit.hits.hits.map((e=>Object(n.get)(e._source,t)))}))),sparkLinesPerCategory:s}}(e,t,g)):Object(S.isErrorResponse)(e)&&b(e)},error:e=>{if("AbortError"===e.name)return c({categories:[],sparkLinesPerCategory:{}});b(e)}})}))}),[l.search,c]),cancelRequest:Object(s.useCallback)((()=>{r.current.abort(),r.current=new AbortController}),[]),randomSampler:c}}function B(e,t,a,s){const o=Object(n.cloneDeep)(e);return void 0===o.bool&&(o.bool={}),void 0===o.bool.must&&(o.bool.must=[],void 0!==o.match_all&&(o.bool.must.push({match_all:o.match_all}),delete o.match_all)),void 0!==o.multi_match&&(o.bool.should={multi_match:o.multi_match},delete o.multi_match),o.bool.must.push({range:{[t]:{gte:a,lte:s,format:"epoch_millis"}}}),o}var Q=a(26),G=a.n(Q),$=a(14),K=a.n($);const W="should",H="must_not";function Y(e,t,a,s,o){return{query:{bool:{[s]:(void 0===o?a:[o]).map((({key:e})=>({match:{[t]:{auto_generate_synonyms_phrase_query:!1,fuzziness:0,operator:"and",query:e}}})))}},meta:{alias:m.i18n.translate("xpack.aiops.logCategorization.filterAliasLabel",{defaultMessage:"Categorization - {field}",values:{field:t}}),index:e,disabled:!1}}}var Z=a(95),J=a(66);const X=({categoriesCount:e,selectedCategoriesCount:t,labels:a,openInDiscover:s})=>{const n=Object(J.a)();return Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(p.EuiFlexGroup,{gutterSize:"none",alignItems:"center",css:Object(T.css)({minHeight:n.euiSizeXL},"","")},Object(T.jsx)(p.EuiFlexItem,null,Object(T.jsx)(p.EuiText,{size:"s","data-test-subj":"aiopsLogPatternsFoundCount"},Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.counts",defaultMessage:"{count} {count, plural, one {pattern} other {patterns}} found",values:{count:e}}),t>0?Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.selectedCounts",defaultMessage:" | {count} selected",values:{count:t}})):null)),t>0?Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(p.EuiFlexItem,{grow:!1},Object(T.jsx)(p.EuiButtonEmpty,{size:"s",onClick:()=>s(W),iconType:"plusInCircle",iconSide:"left"},a.multiSelect.in)),Object(T.jsx)(p.EuiFlexItem,{grow:!1},Object(T.jsx)(p.EuiButtonEmpty,{size:"s",onClick:()=>s(H),iconType:"minusInCircle",iconSide:"left"},a.multiSelect.out))):null))};var ee={name:"fa61i",styles:"padding-inline:0px"};const te=({categories:e,sparkLines:t,eventRate:a,dataViewId:n,selectedField:i,timefilter:l,aiopsListState:r,pinnedCategory:c,setPinnedCategory:u,selectedCategory:d,setSelectedCategory:g,onAddFilter:j,onClose:O=(()=>{}),enableRowActions:f=!0})=>{const x=Object(J.a)(),y=Object(p.useEuiBackgroundColor)("primary"),{openInDiscoverWithFilter:h}=function(){const{http:{basePath:e}}=Object(b.b)();return{openInDiscoverWithFilter:(t,a,s,o,n,i,l)=>{var r,c;const u=G.a.encode({time:{from:K()(null===(r=n.min)||void 0===r?void 0:r.valueOf()).toISOString(),to:K()(null===(c=n.max)||void 0===c?void 0:c.valueOf()).toISOString()}}),d=G.a.encode({filters:[...o.filters,Y(t,a,s,i,l)],index:t,interval:"auto",query:{language:o.searchQueryLanguage,query:o.searchString}});let g=e.get();g+="/app/discover#/",g+="?_g="+u,g+="&_a="+encodeURIComponent(d),window.open(g,"_blank")}}}(),[S,v]=Object(s.useState)([]),{onTableChange:C,pagination:E,sorting:k}=function(e,t,a="asc"){const[o,n]=Object(s.useState)(0),[i,l]=Object(s.useState)(10),[r,c]=Object(s.useState)(t),[u,d]=Object(s.useState)(a);return{onTableChange:({page:e={index:0,size:10},sort:t={field:r,direction:u}})=>{const{index:a,size:s}=e;n(a),l(s);const{field:o,direction:i}=t;c(o),d(i)},pagination:{pageIndex:o,pageSize:i,totalItemCount:(null!=e?e:[]).length,pageSizeOptions:[10,20,50],showPerPageOptions:!0},sorting:{sort:{field:r,direction:u}},setPageIndex:n}}(null!=e?e:[],"key"),F=Object(s.useMemo)((()=>function(e){const t=e=>m.i18n.translate("xpack.aiops.logCategorization.flyout.filterIn",{defaultMessage:"Filter for {values, plural, one {pattern} other {patterns}}",values:{values:e?1:2}}),a=e=>m.i18n.translate("xpack.aiops.logCategorization.flyout.filterOut",{defaultMessage:"Filter out {values, plural, one {pattern} other {patterns}}",values:{values:e?1:2}}),s=e=>m.i18n.translate("xpack.aiops.logCategorization.filterIn",{defaultMessage:"Filter for {values, plural, one {pattern} other {patterns}} in Discover",values:{values:e?1:2}}),o=e=>m.i18n.translate("xpack.aiops.logCategorization.filterOut",{defaultMessage:"Filter out {values, plural, one {pattern} other {patterns}} in Discover",values:{values:e?1:2}});return e?{multiSelect:{in:t(!1),out:a(!1)},singleSelect:{in:t(!0),out:a(!0)}}:{multiSelect:{in:s(!1),out:o(!1)},singleSelect:{in:s(!0),out:o(!0)}}}(void 0!==j&&void 0!==O)),[j,O]),M=(e,t)=>{if(void 0!==j&&void 0!==i&&"string"!=typeof i)return j(Y("",i.name,S,e,t),`Patterns - ${i.name}`),void O();const a=l.getActiveBounds();void 0!==a&&void 0!==i&&h(n,"string"==typeof i?i:i.name,S,r,a,e,t)},I=[{field:"count",name:m.i18n.translate("xpack.aiops.logCategorization.column.count",{defaultMessage:"Count"}),sortable:!0,width:"80px"},{field:"count",name:m.i18n.translate("xpack.aiops.logCategorization.column.logRate",{defaultMessage:"Log rate"}),sortable:!1,width:"100px",render:(s,{key:o})=>{const n=t[o];if(void 0===n)return null;const i=a.map((e=>({doc_count_overall:e.docCount,doc_count_significant_term:n[e.key],key:e.key,key_as_string:`${e.key}`})));return Object(T.jsx)(Z.a,{chartData:i,isLoading:null===e&&void 0===i,label:""})}},{field:"examples",name:m.i18n.translate("xpack.aiops.logCategorization.column.examples",{defaultMessage:"Examples"}),sortable:!0,render:e=>Object(T.jsx)(o.a.Fragment,null,e.map((e=>Object(T.jsx)(p.EuiText,{size:"s",key:e},Object(T.jsx)(p.EuiCode,{language:"log",transparentBackground:!0,css:ee},e)))))},{name:m.i18n.translate("xpack.aiops.logCategorization.column.actions",{defaultMessage:"Actions"}),sortable:!1,width:"60px",actions:[{name:F.singleSelect.in,description:F.singleSelect.in,icon:"plusInCircle",type:"icon","data-test-subj":"aiopsLogPatternsActionFilterInButton",onClick:e=>M(W,e)},{name:F.singleSelect.out,description:F.singleSelect.out,icon:"minusInCircle",type:"icon","data-test-subj":"aiopsLogPatternsActionFilterOutButton",onClick:e=>M(H,e)}]}],P={selectable:()=>!0,onSelectionChange:e=>v(e)},w=e=>c&&c.key===e.key&&c.key===e.key?{backgroundColor:y}:d&&d.key===e.key?{backgroundColor:x.euiColorLightestShade}:{backgroundColor:x.euiColorEmptyShade};return Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(X,{categoriesCount:e.length,selectedCategoriesCount:S.length,labels:F,openInDiscover:e=>M(e)}),Object(T.jsx)(p.EuiSpacer,{size:"xs"}),Object(T.jsx)(p.EuiHorizontalRule,{margin:"none"}),Object(T.jsx)(p.EuiInMemoryTable,{compressed:!0,items:e,columns:I,isSelectable:!0,selection:P,itemId:"key",onTableChange:C,pagination:E,sorting:k,"data-test-subj":"aiopsLogPatternsTable",rowProps:e=>f?{onClick:()=>{e.key===(null==c?void 0:c.key)?u(null):u(e)},onMouseEnter:()=>{g(e)},onMouseLeave:()=>{g(null)},style:w(e)}:void 0}))};var ae=a(93),se=a(111);const oe=({eventRate:e,sparkLines:t,totalCount:a,pinnedCategory:n,selectedCategory:i,documentCountStats:l})=>{const{data:r,uiSettings:c,fieldFormats:u,charts:d}=Object(b.b)(),g=m.i18n.translate("xpack.aiops.logCategorization.chartPointsSplitLabel",{defaultMessage:"Selected pattern"}),p=Object(s.useMemo)((()=>{var a;const s=null!==(a=null!=i?i:n)&&void 0!==a?a:null;return e.map((({key:e,docCount:a})=>{let o=a;return s&&t[s.key]&&t[s.key][e]&&(o-=t[s.key][e]),{time:e,value:o}}))}),[e,n,i,t]),j=Object(s.useMemo)((()=>{var a;const s=null!==(a=null!=i?i:n)&&void 0!==a?a:null;return null!==s?e.map((({key:e})=>({time:e,value:t&&t[s.key]&&t[s.key][e]?t[s.key][e]:0}))):void 0}),[e,n,i,t]);return void 0===(null==l?void 0:l.interval)?null:Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(se.a,{totalCount:a}),Object(T.jsx)(ae.a,{dependencies:{data:r,uiSettings:c,fieldFormats:u,charts:d},chartPoints:p,chartPointsSplit:j,timeRangeEarliest:e[0].key,timeRangeLatest:e[e.length-1].key,interval:l.interval,chartPointsSplitLabel:g,isBrushCleared:!1}))},ne=({eventRateLength:e,fieldSelected:t,categoriesLength:a,loading:s})=>!0===s?null:Object(T.jsx)(o.a.Fragment,null,0===e?Object(T.jsx)(p.EuiEmptyPrompt,{title:Object(T.jsx)("h2",null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.noDocsTitle",defaultMessage:"No documents found"})),titleSize:"xs",body:Object(T.jsx)("p",null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.noDocsBody",defaultMessage:"Ensure the selected time range contains documents."})),"data-test-subj":"aiopsNoWindowParametersEmptyPrompt"}):null,e>0&&null===a?Object(T.jsx)(p.EuiEmptyPrompt,{title:Object(T.jsx)("h2",null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.emptyPromptTitle",defaultMessage:"Select a text field and click run pattern analysis to start analysis"})),titleSize:"xs",body:Object(T.jsx)("p",null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.emptyPromptBody",defaultMessage:"Log pattern analysis groups messages into common patterns."})),"data-test-subj":"aiopsNoWindowParametersEmptyPrompt"}):null,e>0&&null!==a&&0===a?Object(T.jsx)(p.EuiEmptyPrompt,{title:Object(T.jsx)("h2",null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.noCategoriesTitle",defaultMessage:"No patterns found"})),titleSize:"xs",body:Object(T.jsx)("p",null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.noCategoriesBody",defaultMessage:"Ensure the selected field is populated in the selected time range."})),"data-test-subj":"aiopsNoWindowParametersEmptyPrompt"}):null),ie={LOG_RATE_ANALYSIS:"/internal/aiops/log_rate_analysis",CATEGORIZATION_FIELD_VALIDATION:"/internal/aiops/categorization_field_validation"};function le(){const{http:e}=Object(b.b)(),t=Object(s.useRef)(new AbortController);return{runValidateFieldRequest:Object(s.useCallback)((async(t,a,s,o,n,i)=>{const l=B(i,s,o,n);return await e.post(ie.CATEGORIZATION_FIELD_VALIDATION,{body:JSON.stringify({indexPatternTitle:t,query:l,size:5,field:a,timeField:s,start:o,end:n,runtimeMappings:void 0,indicesOptions:void 0,includeExamples:!1}),version:"1"})}),[e]),cancelRequest:Object(s.useCallback)((()=>{t.current.abort(),t.current=new AbortController}),[])}}let re,ce;!function(e){e.VALID="valid",e.PARTIALLY_VALID="partially_valid",e.INVALID="invalid"}(re||(re={})),function(e){e[e.NO_EXAMPLES=0]="NO_EXAMPLES",e[e.FAILED_TO_TOKENIZE=1]="FAILED_TO_TOKENIZE",e[e.TOO_MANY_TOKENS=2]="TOO_MANY_TOKENS",e[e.TOKEN_COUNT=3]="TOKEN_COUNT",e[e.MEDIAN_LINE_LENGTH=4]="MEDIAN_LINE_LENGTH",e[e.NULL_VALUES=5]="NULL_VALUES",e[e.INSUFFICIENT_PRIVILEGES=6]="INSUFFICIENT_PRIVILEGES"}(ce||(ce={})),ce.NO_EXAMPLES,m.i18n.translate("xpack.ml.models.jobService.categorization.messages.validNoDataFound",{defaultMessage:"Examples were successfully loaded."}),ce.FAILED_TO_TOKENIZE,m.i18n.translate("xpack.ml.models.jobService.categorization.messages.validFailureToGetTokens",{defaultMessage:"The loaded examples were tokenized successfully."}),ce.TOKEN_COUNT,m.i18n.translate("xpack.ml.models.jobService.categorization.messages.validTokenLength",{defaultMessage:"More than {tokenCount} tokens per example were found in over {percentage}% of the loaded examples.",values:{percentage:Math.floor(75),tokenCount:3}}),ce.MEDIAN_LINE_LENGTH,m.i18n.translate("xpack.ml.models.jobService.categorization.messages.validMedianLineLength",{defaultMessage:"The median line length of the loaded examples was less than {medianCharCount} characters.",values:{medianCharCount:400}}),ce.NULL_VALUES,m.i18n.translate("xpack.ml.models.jobService.categorization.messages.validNullValues",{defaultMessage:"Less than {percentage}% of the loaded examples were null.",values:{percentage:Math.floor(25)}}),ce.TOO_MANY_TOKENS,m.i18n.translate("xpack.ml.models.jobService.categorization.messages.validTooManyTokens",{defaultMessage:"Less than 10000 tokens were found in total in the loaded examples."}),ce.INSUFFICIENT_PRIVILEGES,m.i18n.translate("xpack.ml.models.jobService.categorization.messages.validUserPrivileges",{defaultMessage:"The user has sufficient privileges to perform the checks."});const ue=({validationResults:e})=>null===e||e.overallValidStatus===re.VALID?null:Object(T.jsx)(p.EuiCallOut,{color:"warning",title:m.i18n.translate("xpack.aiops.logCategorization.fieldValidationTitle",{defaultMessage:"The selected field is possibly not suitable for pattern analysis"})},e.validationChecks.filter((e=>e.valid!==re.VALID)).map((e=>Object(T.jsx)("div",{key:e.id},e.message)))),de="message";var ge={name:"1qw7xfh",styles:"min-width:410px"},be={name:"xdvdnl",styles:"margin-top:auto"},pe={name:"xdvdnl",styles:"margin-top:auto"};const me=()=>{var e,t,a;const{notifications:{toasts:n}}=Object(b.b)(),{dataView:i,savedSearch:r}=Object(d.c)(),{runCategorizeRequest:c,cancelRequest:u,randomSampler:g}=V(),{runValidateFieldRequest:S,cancelRequest:v}=le(),[C,E]=Object(l.b)("logCategorization",Object(x.b)()),[k,F]=Object(l.c)("_g"),[M,I]=Object(s.useState)(),[P,w]=Object(s.useState)(null),[L,_]=Object(s.useState)(r),[z,A]=Object(s.useState)(!1),[N,q]=Object(s.useState)(0),[U,D]=Object(s.useState)([]),[B,Q]=Object(s.useState)(null),[G,$]=Object(s.useState)(null),[K,W]=Object(s.useState)(null),H=Object(s.useCallback)((()=>{v(),u()}),[u,v]);Object(s.useEffect)((()=>{r&&_(r)}),[r]),Object(s.useEffect)((function(){return()=>{H()}}),[H]);const Y=Object(s.useCallback)((e=>{null!==L&&_(null),E({...C,searchQuery:e.searchQuery,searchString:e.searchString,searchQueryLanguage:e.queryLanguage,filters:e.filters})}),[L,C,E]),{searchQueryLanguage:Z,searchString:J,searchQuery:X}=Object(f.a)({dataView:i,savedSearch:L},C),{documentStats:ee,timefilter:ae,earliest:se,latest:ie,intervalMs:re}=Object(O.a)(i,"log_categorization",X,F,void 0,void 0,20);Object(s.useEffect)((()=>{void 0!==(null==k?void 0:k.time)&&ae.setTime({from:k.time.from,to:k.time.to})}),[JSON.stringify(null==k?void 0:k.time),ae]);const ce=Object(s.useMemo)((()=>i.fields.filter((({displayName:e,esTypes:t,count:a})=>t&&t.includes("text")&&!["_id","_index"].includes(e))).map((({displayName:e})=>({label:e})))),[i]);Object(s.useEffect)((()=>{var e;null!==(e=ee.documentCountStats)&&void 0!==e&&e.buckets&&(g.setDocCount(ee.totalCount),D(Object.entries(ee.documentCountStats.buckets).map((([e,t])=>({key:+e,docCount:t})))),$(null),W(null),q(ee.totalCount))}),[ee,se,ie,Z,J,X,g]);const me=Object(s.useCallback)((async()=>{A(!0),$(null),W(null);const{getIndexPattern:e,timeFieldName:t}=i,a=e();if(void 0!==M&&void 0!==t){H();try{const[e,s]=await Promise.all([S(a,M,t,se,ie,X),c(a,M,t,se,ie,X,re)]);W(e),$({categories:s.categories,sparkLines:s.sparkLinesPerCategory})}catch(e){n.addError(e,{title:m.i18n.translate("xpack.aiops.logCategorization.errorLoadingCategories",{defaultMessage:"Error loading categories"})})}A(!1)}else A(!1)}),[i,M,H,S,se,ie,X,c,re,n]);return Object(s.useEffect)((function(){if(void 0!==M)return;const e=C.field;void 0!==e&&ce.find((t=>t.label===e))?I(e):1===ce.length?I(ce[0].label):ce.find((e=>e.label===de))&&I(de)}),[ce,me,M,C.field]),Object(T.jsx)(p.EuiPageBody,{"data-test-subj":"aiopsLogPatternAnalysisPage",paddingSize:"none",panelled:!1},Object(T.jsx)(h.a,null),Object(T.jsx)(p.EuiSpacer,null),Object(T.jsx)(p.EuiFlexGroup,{gutterSize:"none"},Object(T.jsx)(p.EuiFlexItem,null,Object(T.jsx)(y.a,{dataView:i,searchString:null!=J?J:"",searchQuery:X,searchQueryLanguage:Z,setSearchParams:Y}))),Object(T.jsx)(p.EuiSpacer,{size:"m"}),Object(T.jsx)(p.EuiFlexGroup,{gutterSize:"none"},Object(T.jsx)(p.EuiFlexItem,{grow:!1,css:ge},Object(T.jsx)(p.EuiFormRow,{label:m.i18n.translate("xpack.aiops.logCategorization.categoryFieldSelect",{defaultMessage:"Category field"})},Object(T.jsx)(p.EuiComboBox,{isDisabled:!0===z,options:ce,onChange:e=>{$(null),W(null);const t=e&&e.length?e[0].label:void 0;I(t),E({field:t})},selectedOptions:void 0===M?void 0:[{label:M}],singleSelection:{asPlainText:!0},"data-test-subj":"aiopsLogPatternAnalysisCategoryField"}))),Object(T.jsx)(p.EuiFlexItem,{grow:!1,css:be},!1===z?Object(T.jsx)(p.EuiButton,{disabled:void 0===M,onClick:()=>{me()},"data-test-subj":"aiopsLogPatternAnalysisRunButton"},Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.logCategorization.runButton",defaultMessage:"Run pattern analysis"})):Object(T.jsx)(p.EuiButton,{onClick:()=>H()},"Cancel")),Object(T.jsx)(p.EuiFlexItem,null),Object(T.jsx)(p.EuiFlexItem,{grow:!1,css:pe},Object(T.jsx)(R,{randomSampler:g,reload:()=>me()}))),U.length?Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(p.EuiSpacer,null),Object(T.jsx)(oe,{eventRate:U,pinnedCategory:B,selectedCategory:P,sparkLines:null!==(e=null==G?void 0:G.sparkLines)&&void 0!==e?e:{},totalCount:N,documentCountStats:ee.documentCountStats}),Object(T.jsx)(p.EuiSpacer,null)):null,Object(T.jsx)(ue,{validationResults:K}),!0===z?Object(T.jsx)(p.EuiSkeletonText,{lines:10}):null,Object(T.jsx)(ne,{loading:z,categoriesLength:null!==(t=null==G||null===(a=G.categories)||void 0===a?void 0:a.length)&&void 0!==t?t:null,eventRateLength:U.length,fieldSelected:null!==M}),void 0!==M&&null!==G&&G.categories.length>0?Object(T.jsx)(te,{categories:G.categories,aiopsListState:C,dataViewId:i.id,eventRate:U,sparkLines:G.sparkLines,selectedField:M,pinnedCategory:B,setPinnedCategory:Q,selectedCategory:P,setSelectedCategory:w,timefilter:ae}):null)};var je=a(63);const Oe=new r.Storage(window.localStorage);var fe=a(31),xe=a(19),ye=a(24),he=a(74),Se=a(17),ve=a(45);const Ce=()=>Object(T.jsx)(p.EuiBetaBadge,{label:m.i18n.translate("xpack.aiops.techPreviewBadge.label",{defaultMessage:"Technical preview"}),size:"m",color:"hollow",tooltipContent:m.i18n.translate("xpack.aiops.techPreviewBadge.tooltip",{defaultMessage:"This functionality is in technical preview and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but features in technical preview are not subject to the support SLA of official GA features."}),tooltipPosition:"right"});var Ee={name:"1azakc",styles:"text-align:center"},ke={name:"1azakc",styles:"text-align:center"};const Fe=({onClose:e})=>Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(p.EuiSpacer,{size:"l"}),Object(T.jsx)(p.EuiFlexGroup,{justifyContent:"spaceAround"},Object(T.jsx)(p.EuiFlexItem,{grow:!1,css:Ee},Object(T.jsx)(p.EuiFlexGrid,{columns:1},Object(T.jsx)(p.EuiFlexItem,null,Object(T.jsx)(p.EuiLoadingElastic,{size:"xxl"})),Object(T.jsx)(p.EuiFlexItem,null,Object(T.jsx)(p.EuiText,null,Object(T.jsx)("h2",null,Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.categorizeFlyout.loading.title",defaultMessage:"Loading pattern analysis"})))),Object(T.jsx)(p.EuiFlexItem,null,Object(T.jsx)(p.EuiFlexGroup,{justifyContent:"spaceAround"},Object(T.jsx)(p.EuiFlexItem,{grow:!1,css:ke},Object(T.jsx)(p.EuiButton,{onClick:()=>e()},"Cancel")))))))),Me=({dataView:e,savedSearch:t,selectedField:a,onClose:n})=>{var i,r;const{notifications:{toasts:c},data:{query:{getState:u,filterManager:d}},uiSettings:g}=Object(b.b)(),{runValidateFieldRequest:y,cancelRequest:h}=le(),{euiTheme:S}=Object(p.useEuiTheme)(),{filters:v,query:C}=Object(s.useMemo)((()=>u()),[u]),E=Object(s.useRef)(!1),{runCategorizeRequest:k,cancelRequest:F,randomSampler:M}=V(),[I]=Object(l.b)("logCategorization",Object(x.b)({searchQuery:Object(ve.a)(C,v,e,g)})),[P,w]=Object(s.useState)(null),[L]=Object(s.useState)(t),[_,z]=Object(s.useState)(!0),[A,N]=Object(s.useState)([]),[q,U]=Object(s.useState)(null),[D,B]=Object(s.useState)(null),[Q,G]=Object(s.useState)(null),$=Object(s.useCallback)((()=>{h(),F()}),[F,h]);Object(s.useEffect)((function(){return E.current=!0,()=>{E.current=!1,$()}}),[$,E]);const{searchQueryLanguage:K,searchString:W,searchQuery:H}=Object(f.a)({dataView:e,savedSearch:L},I,!0),{documentStats:Y,timefilter:Z,earliest:J,latest:X,intervalMs:ee,forceRefresh:ae}=Object(O.a)(e,"log_categorization",H,void 0,void 0,void 0,20),se=Object(s.useCallback)((async()=>{const{getIndexPattern:t,timeFieldName:s}=e,o=t();if(void 0!==a&&void 0!==s){$(),z(!0),B(null),G(null);try{const[e,t]=await Promise.all([y(o,a.name,s,J,X,H),k(o,a.name,s,J,X,H,ee)]);!0===E.current&&(G(e),B({categories:t.categories,sparkLines:t.sparkLinesPerCategory}))}catch(e){c.addError(e,{title:m.i18n.translate("xpack.aiops.logCategorization.errorLoadingCategories",{defaultMessage:"Error loading categories"})})}!0===E.current&&z(!1)}}),[e,a,$,y,J,X,H,k,ee,c]),oe=Object(s.useCallback)(((t,a)=>{const s=Object(Se.buildEmptyFilter)(!1,e.id);a&&(s.meta.alias=a),s.query=t.query,d.addFilters([s])}),[e,d]);return Object(s.useEffect)((()=>{var e;null!==(e=Y.documentCountStats)&&void 0!==e&&e.buckets&&(M.setDocCount(Y.totalCount),N(Object.entries(Y.documentCountStats.buckets).map((([e,t])=>({key:+e,docCount:t})))),B(null),se())}),[Y,J,X,K,W,H,se,M]),Object(T.jsx)(o.a.Fragment,null,Object(T.jsx)(p.EuiFlyoutHeader,{hasBorder:!0},Object(T.jsx)(p.EuiFlexGroup,{gutterSize:"s",alignItems:"center"},Object(T.jsx)(p.EuiFlexItem,{grow:!1},Object(T.jsx)(p.EuiTitle,{size:"m"},Object(T.jsx)("h2",{id:"flyoutTitle","data-test-subj":"mlJobSelectorFlyoutTitle"},Object(T.jsx)(j.FormattedMessage,{id:"xpack.aiops.categorizeFlyout.title",defaultMessage:"Pattern analysis of {name}",values:{name:a.name}})))),Object(T.jsx)(p.EuiFlexItem,{grow:!1,css:Object(T.css)({marginTop:S.size.xs},"","")},Object(T.jsx)(Ce,null)),Object(T.jsx)(p.EuiFlexItem,null),Object(T.jsx)(p.EuiFlexItem,{grow:!1},Object(T.jsx)(R,{randomSampler:M,reload:()=>ae()})))),Object(T.jsx)(p.EuiFlyoutBody,{"data-test-subj":"mlJobSelectorFlyoutBody"},Object(T.jsx)(ue,{validationResults:Q}),!0===_?Object(T.jsx)(Fe,{onClose:n}):null,Object(T.jsx)(ne,{loading:_,categoriesLength:null!==(i=null==D||null===(r=D.categories)||void 0===r?void 0:r.length)&&void 0!==i?i:null,eventRateLength:A.length,fieldSelected:null!==a}),!1===_&&null!==D&&D.categories.length>0?Object(T.jsx)(te,{categories:D.categories,aiopsListState:I,dataViewId:e.id,eventRate:A,sparkLines:D.sparkLines,selectedField:a,pinnedCategory:q,setPinnedCategory:U,selectedCategory:P,setSelectedCategory:w,timefilter:Z,onAddFilter:oe,onClose:n,enableRowActions:!1}):null))},Ie=new r.Storage(window.localStorage),Pe=(e,t)=>Object(fe.createAction)({type:fe.ACTION_CATEGORIZE_FIELD,id:fe.ACTION_CATEGORIZE_FIELD,getDisplayName:()=>m.i18n.translate("xpack.aiops.categorizeFieldAction.displayName",{defaultMessage:"Categorize field"}),isCompatible:async({field:e})=>{var t;return!0===(null===(t=e.esTypes)||void 0===t?void 0:t.includes("text"))},execute:async a=>{const{field:s,dataView:o}=a;!async function(e,t,a,s){const{http:o,theme:l,overlays:r,application:u,notifications:d,uiSettings:p,i18n:m}=a;new Promise((async(j,O)=>{try{const O=()=>{y.close(),j()},f={notifications:d,uiSettings:p,http:o,theme:l,application:u,i18n:m,...s},x={...Object(n.pick)(f,["data","http","notifications","theme","uiSettings"]),i18n:m,uiSettingsKeys:S.UI_SETTINGS},y=r.openFlyout(Object(he.a)(Object(T.jsx)(ye.KibanaContextProvider,{services:{...a}},Object(T.jsx)(b.a.Provider,{value:f},Object(T.jsx)(c.a,x,Object(T.jsx)(i.a,{storage:Ie,storageKeys:g.d},Object(T.jsx)(Me,{dataView:t,savedSearch:null,selectedField:e,onClose:O}))))),{theme:l,i18n:m}),{"data-test-subj":"aiopsCategorizeFlyout",ownFocus:!0,closeButtonProps:{"aria-label":"aiopsCategorizeFlyout"},onClose:O,size:"l"});u.currentAppId$.pipe(Object(xe.skip)(1),Object(xe.takeUntil)(Object(I.from)(y.onClose)),Object(xe.distinctUntilChanged)()).subscribe((()=>{y.close()}))}catch(e){O(e)}}))}(s,o,e,t)}});t.default=({dataView:e,savedSearch:t,appDependencies:a})=>{if(!e)return null;const s=Object(je.a)(e,"log_categorization");if(null!==s)return Object(T.jsx)(o.a.Fragment,null,s);const r={...Object(n.pick)(a,["data","http","notifications","theme","uiSettings","i18n"]),uiSettingsKeys:u.UI_SETTINGS};return Object(T.jsx)(b.a.Provider,{value:a},Object(T.jsx)(l.a,null,Object(T.jsx)(d.a.Provider,{value:{dataView:e,savedSearch:t}},Object(T.jsx)(i.a,{storage:Oe,storageKeys:g.d},Object(T.jsx)(c.a,r,Object(T.jsx)(me,null))))))}},45:function(e,t,a){"use strict";a.d(t,"a",(function(){return r})),a.d(t,"b",(function(){return c}));var s=a(12),o=a(16),n=a(18),i=a(17),l=(a(39),a(46));function r(e,t,a,s){let r=Object(l.d)();if(Object(n.isQuery)(e)&&e.language===l.a.KUERY){const s=Object(i.fromKueryExpression)(e.query);if(""!==e.query&&(r=Object(i.toElasticsearchQuery)(s,a)),void 0!==r.bool){const e=Object(i.buildQueryFromFilters)(t,a);Array.isArray(r.bool.filter)||(r.bool.filter=void 0===r.bool.filter?[]:[r.bool.filter]),Array.isArray(r.bool.must_not)||(r.bool.must_not=void 0===r.bool.must_not?[]:[r.bool.must_not]),r.bool.filter=[...r.bool.filter,...e.filter],r.bool.must_not=[...r.bool.must_not,...e.must_not]}}else r=Object(i.buildEsQuery)(a,e?[e]:[],t||[],s?Object(o.getEsQueryConfig)(s):void 0);return r}function c({dataView:e,uiSettings:t,savedSearch:a,query:i,filters:c,filterManager:u}){if(!e||!a)return;const d=i,g=c,b=function(e){return e&&"searchSource"in e&&(null==e?void 0:e.searchSource)instanceof o.SearchSource?e.searchSource:void 0}(a);if(b&&void 0!==b.getParent()&&d){var p,m,j;const e=null!==(p=Object(s.cloneDeep)(null===(m=a.searchSource.getSearchRequestBody())||void 0===m?void 0:m.query))&&void 0!==p?p:Object(l.d)(),t=null===(j=a.searchSource.getField("index"))||void 0===j?void 0:j.timeFieldName;return Array.isArray(e.bool.filter)&&void 0!==t&&(e.bool.filter=e.bool.filter.filter((e=>{var a;return!(e.hasOwnProperty("range")&&null!==(a=e.range)&&void 0!==a&&a.hasOwnProperty(t))}))),{searchQuery:e,searchString:d.query,queryLanguage:d.language}}if(!a&&d)return u&&g&&u.addFilters(g),{searchQuery:r(d,Array.isArray(g)?g:[],e,t),searchString:d.query,queryLanguage:d.language};if(b){const a=null==u?void 0:u.getGlobalFilters(),s=null!=d?d:b.getField("query"),o=null!=g?g:Object(n.mapAndFlattenFilters)(b.getField("filter"));return u&&u.setFilters(o),a&&(null==u||u.addFilters(a)),{searchQuery:r(s,u?null==u?void 0:u.getFilters():o,e,t),searchString:s.query,queryLanguage:s.language}}}},67:function(e,t,a){"use strict";a.d(t,"a",(function(){return p}));var s=a(0),o=a(1),n=a(2),i=a(44),l=a(51),r=a(42),c=a(14),u=a.n(c),d=a(40),g=a(50);const b={name:"1v0pok0",styles:"min-width:300px"},p=()=>{const[,e]=Object(i.c)("_g"),{dataView:t}=Object(d.c)(),[a,c]=Object(l.b)(g.a,r.c.EXCLUDE),p=Object(r.g)({timeRangeSelector:void 0!==t.timeFieldName,autoRefreshSelector:!0}),m=Object(o.useCallback)((t=>{e({time:{from:u()(t.start.epoch).toISOString(),to:u()(t.end.epoch).toISOString()}})}),[e]),j=Object(o.useMemo)((()=>void 0!==t.timeFieldName&&""!==t.timeFieldName),[t.timeFieldName]);return Object(s.jsx)(n.EuiPageHeader,{pageTitle:Object(s.jsx)("div",{css:b},t.getName()),rightSideItems:[Object(s.jsx)(n.EuiFlexGroup,{gutterSize:"s","data-test-subj":"aiopsTimeRangeSelectorSection"},j?Object(s.jsx)(n.EuiFlexItem,{grow:!1},Object(s.jsx)(r.d,{frozenDataPreference:a,setFrozenDataPreference:c,dataView:t,query:void 0,disabled:!1,timefilter:p,callback:m})):null,Object(s.jsx)(r.b,{isAutoRefreshOnly:!j,showRefresh:!j,width:"full",flexGroup:!1}))]})}},68:function(e,t,a){"use strict";a.d(t,"a",(function(){return i}));var s=a(1),o=a(45),n=a(38);const i=({dataView:e,savedSearch:t},a,i=!1)=>{const{uiSettings:l,data:{query:{filterManager:r}}}=Object(n.b)(),c=Object(s.useMemo)((()=>Object(o.b)({dataView:e,uiSettings:l,savedSearch:t,filterManager:r})),[e,l,t,r]);if(void 0===c||a&&""!==a.searchString){if(null!=a&&a.filters&&!1===i){const e=null==r?void 0:r.getGlobalFilters();r&&r.setFilters(a.filters),e&&(null==r||r.addFilters(e))}return{searchQuery:null==a?void 0:a.searchQuery,searchString:null==a?void 0:a.searchString,searchQueryLanguage:null==a?void 0:a.searchQueryLanguage}}return{searchQuery:c.searchQuery,searchString:c.searchString,searchQueryLanguage:c.queryLanguage}}},69:function(e,t,a){"use strict";a.d(t,"a",(function(){return n})),a.d(t,"b",(function(){return i}));var s=a(46);const o={match_all:{}},n=e=>({searchString:"",searchQuery:o,searchQueryLanguage:s.a.KUERY,filters:[],...e}),i=e=>({field:void 0,...n(e)})},94:function(e,t,a){"use strict";a.d(t,"a",(function(){return c}));var s=a(1),o=a(2),n=a(11),i=a(38),l=a(45),r=a(0);const c=({dataView:e,searchString:t,searchQueryLanguage:a,setSearchParams:c})=>{const{uiSettings:u,unifiedSearch:{ui:{SearchBar:d}},notifications:{toasts:g},data:{query:b}}=Object(i.b)(),[p,m]=Object(s.useState)({query:t||"",language:a});Object(s.useEffect)((()=>{m({query:t||"",language:a})}),[a,t,b.filterManager]);const j=({query:t,filters:a})=>{const s=null!=t?t:p,o=null!=a?a:b.filterManager.getFilters();try{var i;o&&b.filterManager.setFilters(o);const t=Object(l.a)(s,null!==(i=b.filterManager.getFilters())&&void 0!==i?i:[],e,u);c({searchQuery:t,searchString:s.query,queryLanguage:s.language,filters:o})}catch(e){console.log("Invalid syntax",JSON.stringify(e,null,2)),g.addError(e,{title:n.i18n.translate("xpack.aiops.searchPanel.invalidSyntax",{defaultMessage:"Invalid syntax"})})}};return Object(r.jsx)(o.EuiFlexGroup,{gutterSize:"s","data-test-subj":"aiopsSearchPanel",responsive:!1},Object(r.jsx)(o.EuiFlexItem,{grow:9},Object(r.jsx)(d,{dataTestSubj:"aiopsQueryInput",appName:"aiops",showFilterBar:!0,showDatePicker:!1,showQueryInput:!0,query:p,onQuerySubmit:e=>j({query:e.query}),indexPatterns:[e],placeholder:n.i18n.translate("xpack.aiops.searchPanel.queryBarPlaceholderText",{defaultMessage:'Search… (e.g. status:200 AND extension:"PHP")'}),displayStyle:"inPage",isClearable:!0,showSubmitButton:!1,onFiltersUpdated:e=>j({filters:e})})))}}}]);