!function(e){function t(t){for(var n,s,i=t[0],o=t[1],a=0,c=[];ae,i=e=>({serialize:t=>(e[Object(r.a)(t)].serialize||s)(t),deserialize:t=>(e[Object(r.a)(t)].deserialize||s)(t)});var o=n(15),a=n(16);function u({type:e,...t}){return t}},function(e,t){e.exports=__kbnSharedDeps__.React},function(e,t,n){"use strict";n.r(t),n.d(t,"americanTypewriter",(function(){return r})),n.d(t,"arial",(function(){return s})),n.d(t,"baskerville",(function(){return i})),n.d(t,"bookAntiqua",(function(){return o})),n.d(t,"brushScript",(function(){return a})),n.d(t,"chalkboard",(function(){return u})),n.d(t,"didot",(function(){return c})),n.d(t,"futura",(function(){return l})),n.d(t,"gillSans",(function(){return d})),n.d(t,"helveticaNeue",(function(){return p})),n.d(t,"hoeflerText",(function(){return f})),n.d(t,"inter",(function(){return h})),n.d(t,"lucidaGrande",(function(){return m})),n.d(t,"myriad",(function(){return g})),n.d(t,"openSans",(function(){return v})),n.d(t,"optima",(function(){return b})),n.d(t,"palatino",(function(){return x})),n.d(t,"fonts",(function(){return y}));const r={label:"American Typewriter",value:"'American Typewriter', 'Courier New', Courier, Monaco, mono"},s={label:"Arial",value:"Arial, sans-serif"},i={label:"Baskerville",value:"Baskerville, Georgia, Garamond, 'Times New Roman', Times, serif"},o={label:"Book Antiqua",value:"'Book Antiqua', Georgia, Garamond, 'Times New Roman', Times, serif"},a={label:"Brush Script",value:"'Brush Script MT', 'Comic Sans', sans-serif"},u={label:"Chalkboard",value:"Chalkboard, 'Comic Sans', sans-serif"},c={label:"Didot",value:"Didot, Georgia, Garamond, 'Times New Roman', Times, serif"},l={label:"Futura",value:"Futura, Impact, Helvetica, Arial, sans-serif"},d={label:"Gill Sans",value:"'Gill Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Helvetica, Arial, sans-serif"},p={label:"Helvetica Neue",value:"'Helvetica Neue', Helvetica, Arial, sans-serif"},f={label:"Hoefler Text",value:"'Hoefler Text', Garamond, Georgia, 'Times New Roman', Times, serif"},h={label:"Inter",value:"'Inter', 'Inter UI', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'"},m={label:"Lucida Grande",value:"'Lucida Grande', 'Lucida Sans Unicode', Lucida, Verdana, Helvetica, Arial, sans-serif"},g={label:"Myriad",value:"Myriad, Helvetica, Arial, sans-serif"},v={label:"Open Sans",value:"'Open Sans', Helvetica, Arial, sans-serif"},b={label:"Optima",value:"Optima, 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Helvetica, Arial, sans-serif"},x={label:"Palatino",value:"Palatino, 'Book Antiqua', Georgia, Garamond, 'Times New Roman', Times, serif"},y=[r,s,i,o,a,u,c,l,d,p,f,h,m,g,v,b,x]},function(e,t,n){"use strict";let r,s,i,o,a,u,c,l;n.r(t),n.d(t,"BackgroundRepeat",(function(){return r})),n.d(t,"BackgroundSize",(function(){return s})),n.d(t,"Overflow",(function(){return a})),n.d(t,"FontStyle",(function(){return i})),n.d(t,"FontWeight",(function(){return o})),n.d(t,"FontSizeUnit",(function(){return l})),n.d(t,"TextDecoration",(function(){return c})),n.d(t,"TextAlignment",(function(){return u})),n.d(t,"buildExpression",(function(){return x})),n.d(t,"buildExpressionFunction",(function(){return f})),n.d(t,"formatExpression",(function(){return y})),n.d(t,"isExpressionAstBuilder",(function(){return g})),n.d(t,"parseExpression",(function(){return E})),n.d(t,"parse",(function(){return m})),n.d(t,"isExpressionAst",(function(){return v})),n.d(t,"format",(function(){return p})),n.d(t,"americanTypewriter",(function(){return w.americanTypewriter})),n.d(t,"inter",(function(){return w.inter})),n.d(t,"arial",(function(){return w.arial})),n.d(t,"fonts",(function(){return w.fonts})),n.d(t,"bookAntiqua",(function(){return w.bookAntiqua})),n.d(t,"brushScript",(function(){return w.brushScript})),n.d(t,"didot",(function(){return w.didot})),n.d(t,"futura",(function(){return w.futura})),n.d(t,"chalkboard",(function(){return w.chalkboard})),n.d(t,"gillSans",(function(){return w.gillSans})),n.d(t,"openSans",(function(){return w.openSans})),n.d(t,"helveticaNeue",(function(){return w.helveticaNeue})),n.d(t,"hoeflerText",(function(){return w.hoeflerText})),n.d(t,"lucidaGrande",(function(){return w.lucidaGrande})),n.d(t,"myriad",(function(){return w.myriad})),n.d(t,"optima",(function(){return w.optima})),n.d(t,"palatino",(function(){return w.palatino})),n.d(t,"baskerville",(function(){return w.baskerville})),n.d(t,"num",(function(){return j.l})),n.d(t,"filter",(function(){return j.f})),n.d(t,"error",(function(){return j.e})),n.d(t,"image",(function(){return j.h})),n.d(t,"render",(function(){return j.p})),n.d(t,"number",(function(){return j.m})),n.d(t,"datatable",(function(){return j.d})),n.d(t,"nullType",(function(){return j.k})),n.d(t,"range",(function(){return j.o})),n.d(t,"pointseries",(function(){return j.n})),n.d(t,"serializeProvider",(function(){return j.q})),n.d(t,"typeSpecs",(function(){return j.u})),n.d(t,"string",(function(){return j.s})),n.d(t,"shape",(function(){return j.r})),n.d(t,"style",(function(){return j.t})),n.d(t,"uiSetting",(function(){return j.v})),n.d(t,"boolean",(function(){return j.c})),n.d(t,"isExpressionValueError",(function(){return j.j})),n.d(t,"getType",(function(){return j.g})),n.d(t,"unboxExpressionValue",(function(){return j.w})),n.d(t,"isDatatable",(function(){return j.i})),n.d(t,"ExpressionType",(function(){return j.a})),n.d(t,"PointSeriesColumnNames",(function(){return j.b})),n.d(t,"derivative",(function(){return $})),n.d(t,"movingAverage",(function(){return I})),n.d(t,"mapColumn",(function(){return D})),n.d(t,"math",(function(){return U})),n.d(t,"mathColumn",(function(){return B})),n.d(t,"clog",(function(){return C})),n.d(t,"createTable",(function(){return A})),n.d(t,"font",(function(){return M})),n.d(t,"variableSet",(function(){return R})),n.d(t,"variable",(function(){return F})),n.d(t,"theme",(function(){return N})),n.d(t,"cumulativeSum",(function(){return k})),n.d(t,"overallMetric",(function(){return L})),n.d(t,"getUiSettingFn",(function(){return H})),n.d(t,"buildResultColumns",(function(){return G.a})),n.d(t,"getBucketIdentifier",(function(){return G.b})),n.d(t,"ExpressionFunction",(function(){return expression_function_ExpressionFunction})),n.d(t,"ExpressionRenderer",(function(){return expression_renderer_ExpressionRenderer})),n.d(t,"createExecutorContainer",(function(){return K})),n.d(t,"pureSelectors",(function(){return J})),n.d(t,"pureTransitions",(function(){return Y})),n.d(t,"defaultState",(function(){return W})),n.d(t,"createExecutionContainer",(function(){return ne})),n.d(t,"executionPureTransitions",(function(){return ee})),n.d(t,"ExpressionsService",(function(){return expressions_services_ExpressionsService})),n.d(t,"createDefaultInspectorAdapters",(function(){return ce})),n.d(t,"createMockContext",(function(){return ae})),n.d(t,"createError",(function(){return re})),n.d(t,"getByAlias",(function(){return ie})),n.d(t,"ExpressionsInspectorAdapter",(function(){return expressions_inspector_adapter_ExpressionsInspectorAdapter})),n.d(t,"TablesAdapter",(function(){return tables_adapter_TablesAdapter})),function(e){e.REPEAT="repeat",e.REPEAT_NO="no-repeat",e.REPEAT_X="repeat-x",e.REPEAT_Y="repeat-y",e.ROUND="round",e.SPACE="space"}(r||(r={})),function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(s||(s={})),function(e){e.ITALIC="italic",e.NORMAL="normal"}(i||(i={})),function(e){e.NORMAL="normal",e.BOLD="bold",e.BOLDER="bolder",e.LIGHTER="lighter",e.ONE="100",e.TWO="200",e.THREE="300",e.FOUR="400",e.FIVE="500",e.SIX="600",e.SEVEN="700",e.EIGHT="800",e.NINE="900"}(o||(o={})),function(e){e.AUTO="auto",e.HIDDEN="hidden",e.SCROLL="scroll",e.VISIBLE="visible"}(a||(a={})),function(e){e.CENTER="center",e.JUSTIFY="justify",e.LEFT="left",e.RIGHT="right"}(u||(u={})),function(e){e.NONE="none",e.UNDERLINE="underline"}(c||(c={})),function(e){e.PX="px",e.PT="pt"}(l||(l={}));const{toExpression:d}=n(26);function p(e,t){return d(e,t)}function f(e,t){const n=Object.entries(t).reduce(((e,[t,n])=>(Array.isArray(n)?e[t]=n.map((e=>v(e)?x(e):e)):void 0!==n?e[t]=v(n)?[x(n)]:[n]:delete e[t],e)),{...t});return{type:"expression_function_builder",name:e,arguments:n,addArgument(e,t){return void 0!==t&&(n.hasOwnProperty(e)||(n[e]=[]),n[e].push(t)),this},getArgument(e){if(n.hasOwnProperty(e))return n[e]},replaceArgument(e,t){if(!n.hasOwnProperty(e))throw new Error("Argument to replace does not exist on this function");return n[e]=t,this},removeArgument(e){return delete n[e],this},toAst:()=>({type:"function",function:e,arguments:Object.entries(n).reduce(((e,[t,n])=>(e[t]=n.map((e=>g(e)?e.toAst():e)),e)),{})}),toString(){return p({type:"expression",chain:[this.toAst()]},"expression")}}}const{parse:h}=n(26);function m(e,t){try{return h(String(e),{startRule:t})}catch(e){throw new Error(`Unable to parse expression: ${e.message}`)}}function g(e){return"expression_builder"===(null==e?void 0:e.type)}function v(e){return"expression"===(null==e?void 0:e.type)}const b=e=>({type:"expression",chain:e.map((e=>e.toAst()))});function x(e){const t=e=>e.map((e=>f(e.function,e.arguments))),n=e?"string"==typeof(r=e)?t(m(r,"expression").chain):Array.isArray(r)?r:t(r.chain):[];var r;return{type:"expression_builder",functions:n,findFunction:e=>n.reduce(((t,n)=>(Object.values(n.arguments).forEach((n=>{n.forEach((n=>{g(n)&&(t=t.concat(n.findFunction(e)))}))})),n.name===e&&t.push(n),t)),[]),toAst(){if(n.length<1)throw new Error("Functions have not been added to the expression builder");return b(n)},toString(){if(n.length<1)throw new Error("Functions have not been added to the expression builder");return p(b(n),"expression")}}}function y(e){return p(e,"expression")}function E(e){return m(e,"expression")}var w=n(7),j=n(5),O=n(0),_=n.n(O);class expression_function_parameter_ExpressionFunctionParameter{constructor(e,t){_()(this,"name",void 0),_()(this,"required",void 0),_()(this,"help",void 0),_()(this,"types",void 0),_()(this,"default",void 0),_()(this,"aliases",void 0),_()(this,"deprecated",void 0),_()(this,"multi",void 0),_()(this,"resolve",void 0),_()(this,"strict",void 0),_()(this,"options",void 0);const{required:n,help:r,types:s,aliases:i,deprecated:o,multi:a,options:u,resolve:c,strict:l}=t;if("_"===e)throw Error("Arg names must not be _. Use it in aliases instead.");this.name=e,this.required=!!n,this.help=r||"",this.types=s||[],this.default=t.default,this.aliases=i||[],this.deprecated=!!o,this.multi=!!a,this.options=u||[],this.resolve=null==c||c,this.strict=l}accepts(e){var t;return!(null!==(t=this.types)&&void 0!==t&&t.length)||this.types.includes(e)}}var T=n(3);class expression_function_ExpressionFunction{constructor(e){_()(this,"name",void 0),_()(this,"namespace",void 0),_()(this,"aliases",void 0),_()(this,"type",void 0),_()(this,"fn",void 0),_()(this,"help",void 0),_()(this,"args",{}),_()(this,"inputTypes",void 0),_()(this,"disabled",void 0),_()(this,"deprecated",void 0),_()(this,"telemetry",void 0),_()(this,"extract",void 0),_()(this,"inject",void 0),_()(this,"migrations",void 0),_()(this,"accepts",(e=>{var t,n;return null===(t=null===(n=this.inputTypes)||void 0===n?void 0:n.includes(e))||void 0===t||t}));const{name:t,type:n,aliases:r,fn:s,help:i,args:o,inputTypes:a,context:u,disabled:c,deprecated:l,telemetry:d,inject:p,extract:f,migrations:h,namespace:m}=e;this.name=t,this.namespace=m,this.type=n,this.aliases=r||[],this.fn=s,this.help=i||"",this.inputTypes=a||(null==u?void 0:u.types),this.disabled=c||!1,this.deprecated=!!l,this.telemetry=d||((e,t)=>t),this.inject=p||T.identity,this.extract=f||(e=>({state:e,references:[]})),this.migrations=h||{};for(const[e,t]of Object.entries(o||{}))this.args[e]=new expression_function_parameter_ExpressionFunctionParameter(e,t)}}const C={name:"clog",args:{},help:"Outputs the _input_ in the console. This function is for debug purposes",fn:e=>(console.log(e),e)};var S=n(1);const A={name:"createTable",type:"datatable",inputTypes:["null"],help:S.i18n.translate("expressions.functions.createTableHelpText",{defaultMessage:"Creates a datatable with a list of columns, and 1 or more empty rows. To populate the rows, use {mapColumnFn} or {mathColumnFn}.",values:{mathColumnFn:"`mathColumn`",mapColumnFn:"`mapColumn`"}}),args:{ids:{types:["string"],help:S.i18n.translate("expressions.functions.createTable.args.idsHelpText",{defaultMessage:"Column ids to generate in positional order. ID represents the key in the row."}),required:!1,multi:!0},names:{types:["string"],help:S.i18n.translate("expressions.functions.createTable.args.nameHelpText",{defaultMessage:"Column names to generate in positional order. Names are not required to be unique, and default to the ID if not provided."}),required:!1,multi:!0},rowCount:{types:["number"],help:S.i18n.translate("expressions.functions.createTable.args.rowCountText",{defaultMessage:"The number of empty rows to add to the table, to be assigned a value later"}),default:1,required:!1}},fn(e,t){var n;const r=[];return(null!==(n=t.ids)&&void 0!==n?n:[]).map(((e,n)=>{var s,i;r.push({id:e,name:null!==(s=null===(i=t.names)||void 0===i?void 0:i[n])&&void 0!==s?s:e,meta:{type:"null"}})})),{columns:r,rows:[...Array(t.rowCount)].map((()=>({}))),type:"datatable"}}},M={name:"font",aliases:[],type:"style",help:S.i18n.translate("expressions.functions.fontHelpText",{defaultMessage:"Create a font style."}),inputTypes:["null"],args:{align:{default:'{ theme "font.align" default="left" }',help:S.i18n.translate("expressions.functions.font.args.alignHelpText",{defaultMessage:"The horizontal text alignment."}),options:Object.values(u),types:["string"]},color:{default:'{ theme "font.color" }',help:S.i18n.translate("expressions.functions.font.args.colorHelpText",{defaultMessage:"The text color."}),types:["string"]},family:{default:`{ theme "font.family" default="${w.openSans.value}" }`,help:S.i18n.translate("expressions.functions.font.args.familyHelpText",{defaultMessage:"An acceptable {css} web font string",values:{css:"CSS"}}),types:["string"]},italic:{default:'{ theme "font.italic" default=false }',help:S.i18n.translate("expressions.functions.font.args.italicHelpText",{defaultMessage:"Italicize the text?"}),options:[!0,!1],types:["boolean"]},lHeight:{default:'{ theme "font.lHeight" }',aliases:["lineHeight"],help:S.i18n.translate("expressions.functions.font.args.lHeightHelpText",{defaultMessage:"The line height in pixels"}),types:["number","null"]},size:{default:'{ theme "font.size" default=14 }',help:S.i18n.translate("expressions.functions.font.args.sizeHelpText",{defaultMessage:"The font size"}),types:["number"]},sizeUnit:{default:"px",help:S.i18n.translate("expressions.functions.font.args.sizeUnitHelpText",{defaultMessage:"The font size unit"}),types:["string"],options:["px","pt"]},underline:{default:'{ theme "font.underline" default=false }',help:S.i18n.translate("expressions.functions.font.args.underlineHelpText",{defaultMessage:"Underline the text?"}),options:[!0,!1],types:["boolean"]},weight:{default:'{ theme "font.weight" default="normal" }',help:S.i18n.translate("expressions.functions.font.args.weightHelpText",{defaultMessage:"The font weight. For example, {list}, or {end}.",values:{list:Object.values(o).slice(0,-1).map((e=>`\`"${e}"\``)).join(", "),end:`\`"${Object.values(o).slice(-1)[0]}"\``}}),options:Object.values(o),types:["string"]}},fn:(e,t)=>{if(!Object.values(o).includes(t.weight))throw new Error(S.i18n.translate("expressions.functions.font.invalidFontWeightErrorMessage",{defaultMessage:"Invalid font weight: '{weight}'",values:{weight:t.weight}}));if(!Object.values(u).includes(t.align))throw new Error(S.i18n.translate("expressions.functions.font.invalidTextAlignmentErrorMessage",{defaultMessage:"Invalid text alignment: '{align}'",values:{align:t.align}}));const n=null!=t.lHeight?`${t.lHeight}px`:"1",r=[l.PX,l.PT];if(t.sizeUnit&&!r.includes(t.sizeUnit))throw new Error(S.i18n.translate("expressions.functions.font.invalidSizeUnitErrorMessage",{defaultMessage:"Invalid size unit: '{sizeUnit}'",values:{sizeUnit:t.sizeUnit}}));const s={fontFamily:t.family,fontWeight:t.weight,fontStyle:t.italic?i.ITALIC:i.NORMAL,textDecoration:t.underline?c.UNDERLINE:c.NONE,textAlign:t.align,fontSize:`${t.size}${t.sizeUnit}`,lineHeight:n};return t.color&&(s.color=t.color),{type:"style",spec:s,css:(a=s,a?Object.keys(a).map((e=>e.trim().replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\W/g,(e=>/[À-ž]/.test(e)?e:"-")).replace(/^-+|-+$/g,"").toLowerCase().concat(":").concat(String(a[e])))).join(";"):"")};var a}},R={name:"var_set",help:S.i18n.translate("expressions.functions.varset.help",{defaultMessage:"Updates the Kibana global context."}),args:{name:{types:["string"],aliases:["_"],required:!0,multi:!0,help:S.i18n.translate("expressions.functions.varset.name.help",{defaultMessage:"Specify the name of the variable."})},value:{aliases:["val"],multi:!0,help:S.i18n.translate("expressions.functions.varset.val.help",{defaultMessage:"Specify the value for the variable. When unspecified, the input context is used."})}},fn(e,t,n){const{variables:r}=n;return t.name.forEach(((n,s)=>{var i;r[n]=void 0===(null===(i=t.value)||void 0===i?void 0:i[s])?e:t.value[s]})),e}},F={name:"var",help:S.i18n.translate("expressions.functions.var.help",{defaultMessage:"Updates the Kibana global context."}),args:{name:{types:["string"],aliases:["_"],required:!0,help:S.i18n.translate("expressions.functions.var.name.help",{defaultMessage:"Specify the name of the variable."})}},fn(e,t,n){const{variables:r}=n;return r[t.name]}},N={name:"theme",aliases:[],help:S.i18n.translate("expressions.functions.themeHelpText",{defaultMessage:"Reads a theme setting."}),inputTypes:["null"],args:{variable:{aliases:["_"],help:S.i18n.translate("expressions.functions.theme.args.variableHelpText",{defaultMessage:"Name of the theme variable to read."}),required:!0,types:["string"]},default:{help:S.i18n.translate("expressions.functions.theme.args.defaultHelpText",{defaultMessage:"default value in case theming info is not available."})}},fn:(e,t,n)=>{const r=n.variables.theme||{};return Object(T.get)(r,t.variable,t.default)}},k={name:"cumulative_sum",type:"datatable",inputTypes:["datatable"],help:S.i18n.translate("expressions.functions.cumulativeSum.help",{defaultMessage:"Calculates the cumulative sum of a column in a data table"}),args:{by:{help:S.i18n.translate("expressions.functions.cumulativeSum.args.byHelpText",{defaultMessage:"Column to split the cumulative sum calculation by"}),multi:!0,types:["string"],required:!1},inputColumnId:{help:S.i18n.translate("expressions.functions.cumulativeSum.args.inputColumnIdHelpText",{defaultMessage:"Column to calculate the cumulative sum of"}),types:["string"],required:!0},outputColumnId:{help:S.i18n.translate("expressions.functions.cumulativeSum.args.outputColumnIdHelpText",{defaultMessage:"Column to store the resulting cumulative sum in"}),types:["string"],required:!0},outputColumnName:{help:S.i18n.translate("expressions.functions.cumulativeSum.args.outputColumnNameHelpText",{defaultMessage:"Name of the column to store the resulting cumulative sum in"}),types:["string"],required:!1}},async fn(e,t){const{cumulativeSumFn:r}=await n.e(2).then(n.bind(null,94));return r(e,t)}},L={name:"overall_metric",type:"datatable",inputTypes:["datatable"],help:S.i18n.translate("expressions.functions.overallMetric.help",{defaultMessage:"Calculates the overall sum, min, max or average of a column in a data table"}),args:{by:{help:S.i18n.translate("expressions.functions.overallMetric.args.byHelpText",{defaultMessage:"Column to split the overall calculation by"}),multi:!0,types:["string"],required:!1},metric:{help:S.i18n.translate("expressions.functions.overallMetric.metricHelpText",{defaultMessage:"Metric to calculate"}),types:["string"],options:["sum","min","max","average"]},inputColumnId:{help:S.i18n.translate("expressions.functions.overallMetric.args.inputColumnIdHelpText",{defaultMessage:"Column to calculate the overall metric of"}),types:["string"],required:!0},outputColumnId:{help:S.i18n.translate("expressions.functions.overallMetric.args.outputColumnIdHelpText",{defaultMessage:"Column to store the resulting overall metric in"}),types:["string"],required:!0},outputColumnName:{help:S.i18n.translate("expressions.functions.overallMetric.args.outputColumnNameHelpText",{defaultMessage:"Name of the column to store the resulting overall metric in"}),types:["string"],required:!1}},async fn(e,t){const{overallMetricFn:r}=await n.e(5).then(n.bind(null,95));return r(e,t)}},$={name:"derivative",type:"datatable",inputTypes:["datatable"],help:S.i18n.translate("expressions.functions.derivative.help",{defaultMessage:"Calculates the derivative of a column in a data table"}),args:{by:{help:S.i18n.translate("expressions.functions.derivative.args.byHelpText",{defaultMessage:"Column to split the derivative calculation by"}),multi:!0,types:["string"],required:!1},inputColumnId:{help:S.i18n.translate("expressions.functions.derivative.args.inputColumnIdHelpText",{defaultMessage:"Column to calculate the derivative of"}),types:["string"],required:!0},outputColumnId:{help:S.i18n.translate("expressions.functions.derivative.args.outputColumnIdHelpText",{defaultMessage:"Column to store the resulting derivative in"}),types:["string"],required:!0},outputColumnName:{help:S.i18n.translate("expressions.functions.derivative.args.outputColumnNameHelpText",{defaultMessage:"Name of the column to store the resulting derivative in"}),types:["string"],required:!1}},async fn(e,t){const{derivativeFn:r}=await n.e(3).then(n.bind(null,96));return r(e,t)}},I={name:"moving_average",type:"datatable",inputTypes:["datatable"],help:S.i18n.translate("expressions.functions.movingAverage.help",{defaultMessage:"Calculates the moving average of a column in a data table"}),args:{by:{help:S.i18n.translate("expressions.functions.movingAverage.args.byHelpText",{defaultMessage:"Column to split the moving average calculation by"}),multi:!0,types:["string"],required:!1},inputColumnId:{help:S.i18n.translate("expressions.functions.movingAverage.args.inputColumnIdHelpText",{defaultMessage:"Column to calculate the moving average of"}),types:["string"],required:!0},outputColumnId:{help:S.i18n.translate("expressions.functions.movingAverage.args.outputColumnIdHelpText",{defaultMessage:"Column to store the resulting moving average in"}),types:["string"],required:!0},outputColumnName:{help:S.i18n.translate("expressions.functions.movingAverage.args.outputColumnNameHelpText",{defaultMessage:"Name of the column to store the resulting moving average in"}),types:["string"],required:!1},window:{help:S.i18n.translate("expressions.functions.movingAverage.args.windowHelpText",{defaultMessage:'The size of window to "slide" across the histogram.'}),types:["number"],default:5}},async fn(e,t){const{movingAverageFn:r}=await n.e(4).then(n.bind(null,97));return r(e,t)}};function H({getStartDependencies:e}){return{name:"uiSetting",help:S.i18n.translate("expressions.functions.uiSetting.help",{defaultMessage:"Returns a UI settings parameter value."}),args:{default:{help:S.i18n.translate("expressions.functions.uiSetting.args.default",{defaultMessage:"A default value in case of the parameter is not set."})},parameter:{aliases:["_"],help:S.i18n.translate("expressions.functions.uiSetting.args.parameter",{defaultMessage:"The parameter name."}),required:!0,types:["string"]}},async fn(t,{default:n,parameter:r},{getKibanaRequest:s}){const{uiSettings:i}=await e((()=>{const e=null==s?void 0:s();if(!e)throw new Error(S.i18n.translate("expressions.functions.uiSetting.error.kibanaRequest",{defaultMessage:"A KibanaRequest is required to get UI settings on the server. Please provide a request object to the expression execution params."}));return e}));try{return{type:"ui_setting",key:r,value:await i.get(r,n)}}catch{throw new Error(S.i18n.translate("expressions.functions.uiSetting.error.parameter",{defaultMessage:'Invalid parameter "{parameter}".',values:{parameter:r}}))}}}}var P=n(2),q=n(4);const D={name:"mapColumn",aliases:["mc"],type:"datatable",inputTypes:["datatable"],help:S.i18n.translate("expressions.functions.mapColumnHelpText",{defaultMessage:"Adds a column calculated as the result of other columns. Changes are made only when you provide arguments.See also {alterColumnFn} and {staticColumnFn}.",values:{alterColumnFn:"`alterColumn`",staticColumnFn:"`staticColumn`"}}),args:{id:{types:["string","null"],help:S.i18n.translate("expressions.functions.mapColumn.args.idHelpText",{defaultMessage:"An optional id of the resulting column. When no id is provided, the id will be looked up from the existing column by the provided name argument. If no column with this name exists yet, a new column with this name and an identical id will be added to the table."}),required:!1,default:null},name:{types:["string"],aliases:["_","column"],help:S.i18n.translate("expressions.functions.mapColumn.args.nameHelpText",{defaultMessage:"The name of the resulting column. Names are not required to be unique."}),required:!0},expression:{types:["boolean","number","string","null"],resolve:!1,aliases:["exp","fn","function"],help:S.i18n.translate("expressions.functions.mapColumn.args.expressionHelpText",{defaultMessage:"An expression that is executed on every row, provided with a single-row {DATATABLE} context and returning the cell value.",values:{DATATABLE:"`datatable`"}}),required:!0},copyMetaFrom:{types:["string","null"],help:S.i18n.translate("expressions.functions.mapColumn.args.copyMetaFromHelpText",{defaultMessage:"If set, the meta object from the specified column id is copied over to the specified target column. If the column doesn't exist it silently fails."}),required:!1,default:null}},fn(e,t){var n,r,s;const i=t.copyMetaFrom?e.columns.find((({id:e})=>e===t.copyMetaFrom)):void 0,o=e.columns.findIndex((({id:e,name:n})=>t.id?e===t.id:n===t.name)),a=-1===o?e.columns.length:o,u=null!==(n=null!==(r=null===(s=e.columns[a])||void 0===s?void 0:s.id)&&void 0!==r?r:t.id)&&void 0!==n?n:t.name;return Object(P.defer)((()=>Object(P.combineLatest)(e.rows.map((n=>t.expression({...e,columns:[...e.columns],rows:[n]}).pipe(Object(q.map)((e=>({...n,[u]:e}))),Object(q.defaultIfEmpty)(n))))))).pipe(Object(q.defaultIfEmpty)([]),Object(q.map)((n=>{var r;let s="null";for(const e of n){const t=Object(j.g)(e[u]);if("null"!==t){s=t;break}}const o=[...e.columns];return o[a]={id:u,name:t.name,meta:{type:s,params:{id:s},...null!==(r=null==i?void 0:i.meta)&&void 0!==r?r:{}}},{...e,columns:o,rows:n}})))}},z="`TinyMath`",U={name:"math",type:void 0,inputTypes:["number","datatable"],help:S.i18n.translate("expressions.functions.mathHelpText",{defaultMessage:"Interprets a {TINYMATH} math expression using a {TYPE_NUMBER} or {DATATABLE} as {CONTEXT}. The {DATATABLE} columns are available by their column name. If the {CONTEXT} is a number it is available as {value}.",values:{TINYMATH:z,CONTEXT:"_context_",DATATABLE:"`datatable`",value:"`value`",TYPE_NUMBER:"`number`"}}),args:{expression:{aliases:["_"],types:["string"],help:S.i18n.translate("expressions.functions.math.args.expressionHelpText",{defaultMessage:"An evaluated {TINYMATH} expression. See {TINYMATH_URL}.",values:{TINYMATH:z,TINYMATH_URL:"https://www.elastic.co/guide/en/kibana/current/canvas-tinymath-functions.html"}})},onError:{types:["string"],options:["throw","false","zero","null"],help:S.i18n.translate("expressions.functions.math.args.onErrorHelpText",{defaultMessage:"In case the {TINYMATH} evaluation fails or returns NaN, the return value is specified by onError. When `'throw'`, it will throw an exception, terminating expression execution (default).",values:{TINYMATH:z}})}},fn:async(e,t)=>{const{mathFn:r}=await n.e(1).then(n.bind(null,98));return r(e,t)}},B={name:"mathColumn",type:"datatable",inputTypes:["datatable"],help:S.i18n.translate("expressions.functions.mathColumnHelpText",{defaultMessage:"Adds a column by evaluating {tinymath} on each row. This function is optimized for math and performs better than using a math expression in {mapColumnFn}.",values:{mapColumnFn:"`mapColumn`",tinymath:"`TinyMath`"}}),args:{...U.args,id:{types:["string"],help:S.i18n.translate("expressions.functions.mathColumn.args.idHelpText",{defaultMessage:"id of the resulting column. Must be unique."}),required:!0},name:{types:["string"],aliases:["_","column"],help:S.i18n.translate("expressions.functions.mathColumn.args.nameHelpText",{defaultMessage:"The name of the resulting column. Names are not required to be unique."}),required:!0},castColumns:{types:["string"],multi:!0,help:S.i18n.translate("expressions.functions.mathColumn.args.castColumnsHelpText",{defaultMessage:"The ids of columns to cast to numbers before applying the formula"}),required:!1},copyMetaFrom:{types:["string","null"],help:S.i18n.translate("expressions.functions.mathColumn.args.copyMetaFromHelpText",{defaultMessage:"If set, the meta object from the specified column id is copied over to the specified target column. If the column doesn't exist it silently fails."}),required:!1,default:null}},fn:async(e,t,n)=>{var r;const s=[...e.columns];if(s.findIndex((({id:e})=>e===t.id))>-1)throw new Error(S.i18n.translate("expressions.functions.mathColumn.uniqueIdError",{defaultMessage:"ID must be unique"}));const i=await Promise.all(e.rows.map((async r=>{let s=r;t.castColumns&&(s={...r},t.castColumns.forEach((e=>{switch(typeof r[e]){case"string":const t=Number(new Date(s[e]));return isNaN(t)?void(s[e]=Number(s[e])):void(s[e]=t);case"boolean":return void(s[e]=Number(s[e]))}})));const i=await U.fn({...e,columns:e.columns,rows:[s]},{expression:t.expression,onError:t.onError},n);if(Array.isArray(i)){if(1===i.length)return{...r,[t.id]:i[0]};throw new Error(S.i18n.translate("expressions.functions.mathColumn.arrayValueError",{defaultMessage:"Cannot perform math on array values at {name}",values:{name:t.name}}))}return{...r,[t.id]:i}})));let o="null";if(i.length)for(const e of i){const n=Object(j.g)(e[t.id]);if("null"!==n){o=n;break}}const a={id:t.id,name:null!==(r=t.name)&&void 0!==r?r:t.id,meta:{type:o,params:{id:o}}};if(t.copyMetaFrom){const e=s.find((({id:e})=>e===t.copyMetaFrom));a.meta={...a.meta,...(null==e?void 0:e.meta)||{}}}return s.push(a),{...e,columns:s,rows:i}}};var G=n(22);class expression_renderer_ExpressionRenderer{constructor(e){_()(this,"name",void 0),_()(this,"namespace",void 0),_()(this,"displayName",void 0),_()(this,"help",void 0),_()(this,"validate",void 0),_()(this,"reuseDomNode",void 0),_()(this,"render",void 0);const{name:t,displayName:n,help:r,validate:s,reuseDomNode:i,render:o,namespace:a}=e;this.name=t,this.namespace=a,this.displayName=n||t,this.help=r||"",this.validate=s||(()=>{}),this.reuseDomNode=Boolean(i),this.render=o}}class expression_renderer_registry_ExpressionRendererRegistry{constructor(){_()(this,"renderers",new Map)}register(e){"function"==typeof e&&(e=e());const t=new expression_renderer_ExpressionRenderer(e);this.renderers.set(t.name,t)}get(e){return this.renderers.get(e)||null}toJS(){return this.toArray().reduce(((e,t)=>(e[t.name]=t,e)),{})}toArray(){return[...this.renderers.values()]}}var V=n(17);const W={functions:{},types:{},context:{}},Y={addFunction:e=>t=>({...e,functions:{...e.functions,[t.name]:t}}),addType:e=>t=>({...e,types:{...e.types,[t.name]:t}})},J={getFunction:e=>t=>e.functions[t]||null,getType:e=>t=>e.types[t]||null,getContext:({context:e})=>()=>e},K=(e=W)=>Object(V.createStateContainer)(e,Y,J);var X=n(13),Z=n(21);const Q={...W,state:"not-started",ast:{type:"expression",chain:[]}},ee={start:e=>()=>({...e,state:"pending"}),setResult:e=>t=>({...e,state:"result",result:t}),setError:e=>t=>({...e,state:"error",error:t})},te=e=>e,ne=(e=Q)=>Object(V.createStateContainer)(e,ee,{},{freeze:te}),re=e=>({type:"error",error:{stack:void 0,message:"string"==typeof e?e:String(e.message),name:"object"==typeof e&&e.name||"Error",original:e instanceof Error?e:"object"==typeof e&&"original"in e&&e.original instanceof Error?e.original:void 0}}),se="*";function ie(e,t,n){const r=t.toLowerCase();return Object.values(e).find((({name:e,aliases:t,namespace:s})=>!!e&&(!(e.toLowerCase()!==r||s&&n!==se&&s!==n)||(t||[]).some((e=>e.toLowerCase()===r&&(!s||n===se||s===n))))))}var oe=n(18);class tables_adapter_TablesAdapter extends oe.EventEmitter{constructor(...e){super(...e),_()(this,"_tables",{})}logDatatable(e,t){this._tables[e]=t,this.emit("change",this.tables)}reset(){this._tables={},this.emit("change",this.tables)}get tables(){return this._tables}}class expressions_inspector_adapter_ExpressionsInspectorAdapter extends oe.EventEmitter{constructor(...e){super(...e),_()(this,"_ast",{})}logAST(e){this._ast=e,this.emit("change",this._ast)}get ast(){return this._ast}}const ae=()=>({getSearchContext:()=>({}),getSearchSessionId:()=>{},types:{},variables:{},abortSignal:{},inspectorAdapters:{}});var ue=n(28);const ce=()=>({requests:new ue.RequestAdapter,tables:new tables_adapter_TablesAdapter,expression:new expressions_inspector_adapter_ExpressionsInspectorAdapter});var le=n(11);class execution_contract_ExecutionContract{get isPending(){const{state:e,result:t}=this.execution.state.get();return!("error"===e||"result"===e&&(null==t||!t.partial))}constructor(e){_()(this,"execution",void 0),_()(this,"cancel",(()=>{this.execution.cancel()})),_()(this,"getData",(()=>this.execution.result.pipe(Object(q.catchError)((({name:e,message:t,stack:n})=>Object(P.of)({partial:!1,result:{type:"error",error:{name:e,message:t,stack:n}}})))))),_()(this,"getExpression",(()=>this.execution.expression)),_()(this,"getAst",(()=>this.execution.state.get().ast)),_()(this,"inspect",(()=>this.execution.inspectorAdapters)),this.execution=e}}class execution_Execution{get inspectorAdapters(){return this.context.inspectorAdapters}constructor(e,t){_()(this,"state",void 0),_()(this,"input",null),_()(this,"input$",new P.ReplaySubject(1)),_()(this,"context",void 0),_()(this,"abortController",new AbortController),_()(this,"hasStarted",!1),_()(this,"result",void 0),_()(this,"childExecutions",[]),_()(this,"contract",void 0),_()(this,"expression",void 0),this.execution=e,this.logger=t;const{executor:n}=e;if(this.contract=new execution_contract_ExecutionContract(this),!e.ast&&!e.expression)throw new TypeError("Execution params should contain at least .ast or .expression key.");if(e.ast&&e.expression)throw new TypeError("Execution params cannot contain both .ast and .expression key.");this.expression=e.expression||y(e.ast);const r=e.ast||E(this.expression);this.state=ne({...n.state,state:"not-started",ast:r});const s=e.params.inspectorAdapters||ce();this.context={getSearchContext:()=>this.execution.params.searchContext||{},getSearchSessionId:()=>e.params.searchSessionId,getKibanaRequest:e.params.kibanaRequest?()=>e.params.kibanaRequest:void 0,variables:e.params.variables||{},types:n.getTypes(),abortSignal:this.abortController.signal,inspectorAdapters:s,logDatatable:(e,t)=>{s.tables[e]=t},isSyncColorsEnabled:()=>e.params.syncColors,isSyncCursorEnabled:()=>e.params.syncCursor,isSyncTooltipsEnabled:()=>e.params.syncTooltips,...e.executor.context,getExecutionContext:()=>e.params.executionContext},this.result=this.input$.pipe(Object(q.switchMap)((e=>{return this.invokeChain(this.state.get().ast.chain,e).pipe((n=this.abortController.signal,e=>new P.Observable((t=>{const r=()=>{t.error(new X.AbortError)};t.add(e.subscribe(t)),t.add((()=>n.removeEventListener("abort",r))),n.addEventListener("abort",r),n.aborted&&r()}))),(e=>new P.Observable((t=>{let n;t.add(e.subscribe({next:e=>{n={result:e,partial:!0},t.next(n)},error:e=>t.error(e),complete:()=>{n&&(n.partial=!1),t.complete()}})),t.add((()=>{n=void 0}))}))),this.execution.params.partial&&this.execution.params.throttle?(t=this.execution.params.throttle,e=>new P.Observable((n=>{let r,s=!1;const i=()=>{s&&(n.next(r),s=!1,r=void 0)};let o;const a=Object(P.timer)(0,t).pipe(Object(P.takeWhile)((()=>s)),Object(q.finalize)((()=>{n.remove(o),o=void 0})));n.add(e.subscribe({next:e=>{r=e,s=!0,o||(o=a.subscribe(i),n.add(o))},error:e=>n.error(e),complete:()=>{i(),n.complete()}})),n.add((()=>{s=!1,r=void 0}))}))):P.identity);var t,n})),Object(q.catchError)((e=>this.abortController.signal.aborted?(this.childExecutions.forEach((e=>e.cancel())),Object(P.of)({result:re({message:"The expression was aborted.",name:"AbortError"}),partial:!1})):Object(P.throwError)(e))),Object(q.tap)({next:e=>{var t;null===(t=this.context.inspectorAdapters.expression)||void 0===t||t.logAST(this.state.get().ast),this.state.transitions.setResult(e)},error:e=>this.state.transitions.setError(e)}),Object(q.shareReplay)(1))}cancel(){this.abortController.abort()}start(e=null,t){if(this.hasStarted)throw new Error("Execution already started.");var n;return this.hasStarted=!0,this.input=e,this.state.transitions.start(),t||null===(n=this.context.inspectorAdapters.requests)||void 0===n||n.reset(),Object(P.isObservable)(e)?e.subscribe(this.input$):Object(Z.isPromise)(e)?Object(P.from)(e).subscribe(this.input$):Object(P.of)(e).subscribe(this.input$),this.result}invokeChain([e,...t],n){return e?Object(P.defer)((()=>{const{function:r,arguments:s}=e,i=ie(this.state.get().functions,r,this.execution.params.namespace);if(!i)throw re({name:"fn not found",message:S.i18n.translate("expressions.execution.functionNotFound",{defaultMessage:"Function {fnName} could not be found.",values:{fnName:r}})});if(i.disabled)throw re({name:"fn is disabled",message:S.i18n.translate("expressions.execution.functionDisabled",{defaultMessage:"Function {fnName} is disabled.",values:{fnName:r}})});var o;i.deprecated&&(null===(o=this.logger)||void 0===o||o.warn(`Function '${r}' is deprecated`)),this.execution.params.debug&&(e.debug={input:n,args:{},duration:0,fn:i.name,success:!0});const a=this.execution.params.debug?Object(X.now)():0;return this.resolveArgs(i,n,s).pipe(Object(q.switchMap)((s=>(Object(le.b)(s)?Object(P.throwError)(s.error):Object(P.of)(s)).pipe(Object(q.tap)((t=>{var n;return this.execution.params.debug&&Object.assign(null!==(n=e.debug)&&void 0!==n?n:{},{args:t})})),Object(q.switchMap)((e=>this.invokeFunction(i,n,e))),this.execution.params.partial?P.identity:Object(P.last)(),Object(q.switchMap)((e=>"error"===Object(j.g)(e)?Object(P.throwError)(e):Object(P.of)(e))),Object(q.tap)((t=>{var n;return this.execution.params.debug&&Object.assign(null!==(n=e.debug)&&void 0!==n?n:{},{output:t})})),Object(q.switchMap)((e=>this.invokeChain(t,e))),Object(q.catchError)((t=>{const n=re(t);var s;return n.error.message=`[${r}] > ${n.error.message}`,this.execution.params.debug&&Object.assign(null!==(s=e.debug)&&void 0!==s?s:{},{error:n,rawError:t,success:!1}),Object(P.of)(n)}))))),Object(q.finalize)((()=>{var t;this.execution.params.debug&&Object.assign(null!==(t=e.debug)&&void 0!==t?t:{},{duration:Object(X.now)()-a})})))})).pipe(Object(q.catchError)((e=>Object(P.of)(e)))):Object(P.of)(n)}invokeFunction(e,t,n){return Object(P.of)(t).pipe(Object(q.map)((t=>this.cast(t,e.inputTypes))),Object(q.switchMap)((t=>Object(P.of)(e.fn(t,n,this.context)))),Object(q.switchMap)((e=>Object(P.isObservable)(e)?e:Object(P.from)(Object(Z.isPromise)(e)?e:[e]))),Object(q.map)((t=>{const n=Object(j.g)(t),r=e.type;if(r&&n!==r)throw new Error(`Function '${e.name}' should return '${r}', actually returned '${n}'`);const s=this.context.types[e.type];if(s&&s.validate)try{s.validate(t)}catch(t){throw new Error(`Output of '${e.name}' is not a valid type '${e.type}': ${t}`)}return t})))}cast(e,t){if(null==t||!t.length)return e;const n=Object(j.g)(e);if(t.includes(n))return e;const{types:r}=this.state.get(),s=r[n];for(const i of t){if(null!=s&&s.castsTo(i))return s.to(e,i,r);const t=r[i];if(null!=t&&t.castsFrom(n))return t.from(e,r)}throw re({name:"invalid value",message:`Can not cast '${n}' to any of '${t.join(", ")}'`})}validate(e,t){var n;if(null!==(n=t.options)&&void 0!==n&&n.length&&!t.options.includes(e)){var r;const n=`Value '${e}' is not among the allowed options for argument '${t.name}': '${t.options.join("', '")}'`;if(t.strict)throw re({message:n,name:"invalid argument"});null===(r=this.logger)||void 0===r||r.warn(n)}}resolveArgs(e,t,n){return Object(P.defer)((()=>{const{args:r}=e,s=Object(T.reduce)(n,((t,n,s)=>{const i=ie(r,s);if(!i)throw re({name:"unknown argument",message:`Unknown argument '${s}' passed to function '${e.name}'`});var o;return i.deprecated&&!t[i.name]&&(null===(o=this.logger)||void 0===o||o.warn(`Argument '${s}' is deprecated in function '${e.name}'`)),t[i.name]=(t[i.name]||[]).concat(n),t}),{});for(const{default:t,name:n,required:i}of Object.values(r))if(n in s||void 0===t||(s[n]=[m(t,"argument")]),i&&!(n in s))throw re({name:"missing argument",message:`${e.name} requires the "${n}" argument`});const i=Object(T.mapValues)(s,((e,n)=>e.map((e=>(s=t)=>this.interpret(e,s).pipe(Object(q.pluck)("result"),Object(q.switchMap)((e=>Object(le.b)(e)?Object(P.of)(e):Object(P.of)(e).pipe(Object(q.map)((e=>this.cast(e,r[n].types))),Object(q.tap)((e=>this.validate(e,r[n]))),Object(q.catchError)((e=>Object(P.of)(e))))))))))),o=Object(T.keys)(i);return o.length?Object(P.combineLatest)(o.map((e=>{const t=i[e];return t.length?r[e].resolve?Object(P.combineLatest)(t.map((e=>e()))).pipe(Object(q.map)((e=>{var t;return null!==(t=e.find(le.b))&&void 0!==t?t:e}))):Object(P.of)(t):Object(P.of)([])}))).pipe(Object(q.map)((e=>{var t;return null!==(t=e.find(le.b))&&void 0!==t?t:Object(T.mapValues)(Object(T.zipObject)(o,e),((e,t)=>r[t].multi?e:Object(T.last)(e)))}))):Object(P.from)([{}])})).pipe(Object(q.catchError)((e=>Object(P.of)(e))))}interpret(e,t){switch(Object(j.g)(e)){case"expression":const n=this.execution.executor.createExecution(e,{...this.execution.params,variables:this.context.variables});return this.childExecutions.push(n),n.start(t,!0);case"string":case"number":case"null":case"boolean":return Object(P.of)({result:e,partial:!1});default:return Object(P.throwError)(new Error(`Unknown AST object: ${JSON.stringify(e)}`))}}}var de=n(15),pe=n(16);class TypesRegistry{constructor(e){this.executor=e}register(e){this.executor.registerType(e)}get(e){var t;return null!==(t=this.executor.getType(e))&&void 0!==t?t:null}toJS(){return this.executor.getTypes()}toArray(){return Object.values(this.toJS())}}class FunctionsRegistry{constructor(e){this.executor=e}register(e){this.executor.registerFunction(e)}get(e){var t;return null!==(t=this.executor.getFunction(e))&&void 0!==t?t:null}toJS(){return this.executor.getFunctions()}toArray(){return Object.values(this.toJS())}}class executor_Executor{static createWithDefaults(e,t){const n=new executor_Executor(e,t);for(const e of pe.r)n.registerType(e);return n}constructor(e,t){_()(this,"container",void 0),_()(this,"functions",void 0),_()(this,"types",void 0),this.logger=e,this.functions=new FunctionsRegistry(this),this.types=new TypesRegistry(this),this.container=K(t)}get state(){return this.container.get()}registerFunction(e){const t=new expression_function_ExpressionFunction("object"==typeof e?e:e());this.container.transitions.addFunction(t)}getFunction(e,t){const n=this.container.get().functions[e];if(null==n||!n.namespace||n.namespace===t)return n}getFunctions(e){const t=Object.entries(this.container.get().functions).filter((([t,n])=>!n.namespace||n.namespace===e));return Object.fromEntries(t)}registerType(e){const t=new de.a("object"==typeof e?e:e());this.container.transitions.addType(t)}getType(e){return this.container.get().types[e]}getTypes(){return this.container.get().types}get context(){return this.container.selectors.getContext()}run(e,t,n={}){return this.createExecution(e,n).start(t)}createExecution(e,t={}){const n={params:t,executor:this};return"string"==typeof e?n.expression=e:n.ast=e,new execution_Execution(n,this.logger)}walkAst(e,t){const n=this.container.get().functions;for(const r of e.chain){const{function:e,arguments:s}=r,i=ie(n,e,se);i&&(r.arguments=Object(T.mapValues)(s,(e=>e.map((e=>null!=e&&"object"==typeof e?this.walkAst(e,t):e)))),t(i,r))}return e}walkAstAndTransform(e,t){var n;let r=0;const s=this.container.get().functions;return null!==(n=e.chain.reduce(((e,n,i)=>{const o=i+r,{function:a,arguments:u}=n,c=ie(s,a,se);if(!c)return e;n.arguments=Object(T.mapValues)(u,(e=>e.map((e=>null!=e&&"object"==typeof e?this.walkAstAndTransform(e,t):e))));const l=t(c,n);if("function"===l.type){const t=o>0?e.chain.slice(0,o):[],n=e.chain.slice(o+1);return{...e,chain:[...t,l,...n]}}if("expression"===l.type){const{chain:t}=l,n=o>0?e.chain.slice(0,o):[],s=e.chain.slice(o+1);return r+=t.length-1,{...e,chain:[...n,...t,...s]}}return e}),e))&&void 0!==n?n:e}inject(e,t){let n=0;return this.walkAst(Object(T.cloneDeep)(e),((e,r)=>{r.arguments=e.inject(r.arguments,t.filter((e=>e.name.includes(`l${n}_`))).map((e=>({...e,name:e.name.replace(`l${n}_`,"")})))),n++}))}extract(e){let t=0;const n=[];return{state:this.walkAst(Object(T.cloneDeep)(e),((e,r)=>{const{state:s,references:i}=e.extract(r.arguments);r.arguments=s,n.push(...i.map((e=>({...e,name:`l${t}_${e.name}`})))),t+=1})),references:n}}telemetry(e,t){return this.walkAst(Object(T.cloneDeep)(e),((e,n)=>{t=e.telemetry(n.arguments,t)})),t}getAllMigrations(){const e=new Set(Object.values(this.container.get().functions).map((e=>{const t="function"==typeof e.migrations?e.migrations():e.migrations||{};return Object.keys(t)})).flat(1)),t={};return e.forEach((e=>{t[e]=t=>({...this.migrate(t,e)})})),t}migrateToLatest(e){return Object(X.migrateToLatest)(this.getAllMigrations(),e)}migrate(e,t){return this.walkAstAndTransform(Object(T.cloneDeep)(e),((e,n)=>{const r="function"==typeof e.migrations?e.migrations():e.migrations||{};return r[t]?r[t](n):n}))}}class ExpressionsServiceFork{constructor(e,t){this.namespace=e,this.expressionsService=t,this.registerFunction=this.registerFunction.bind(this),this.registerRenderer=this.registerRenderer.bind(this),this.registerType=this.registerType.bind(this),this.run=this.run.bind(this),this.execute=this.execute.bind(this),this.getFunction=this.getFunction.bind(this),this.getFunctions=this.getFunctions.bind(this)}registerFunction(e){return"function"==typeof e&&(e=e()),this.expressionsService.registerFunction({...e,namespace:this.namespace})}registerRenderer(e){return"function"==typeof e&&(e=e()),this.expressionsService.registerRenderer({...e,namespace:this.namespace})}registerType(e){return"function"==typeof e&&(e=e()),this.expressionsService.registerType({...e,namespace:this.namespace})}run(e,t,n){return this.expressionsService.run(e,t,{...n,namespace:this.namespace})}execute(e,t,n){return this.expressionsService.execute(e,t,{...n,namespace:this.namespace})}getFunction(e){return this.expressionsService.getFunction(e,this.namespace)}getFunctions(){return this.expressionsService.getFunctions(this.namespace)}setup(){return{...this.expressionsService,registerFunction:this.registerFunction,registerRenderer:this.registerRenderer,registerType:this.registerType}}start(){return{...this.expressionsService,run:this.run,execute:this.execute,getFunction:this.getFunction,getFunctions:this.getFunctions}}}class expressions_services_ExpressionsService{constructor({logger:e,executor:t=executor_Executor.createWithDefaults(e),renderers:n=new expression_renderer_registry_ExpressionRendererRegistry}={}){_()(this,"executor",void 0),_()(this,"renderers",void 0),_()(this,"getFunction",((e,t)=>this.executor.getFunction(e,t))),_()(this,"getFunctions",(e=>this.executor.getFunctions(e))),_()(this,"getRenderer",(e=>(this.assertStart(),this.renderers.get(e)))),_()(this,"getRenderers",(()=>(this.assertStart(),this.renderers.toJS()))),_()(this,"getType",(e=>(this.assertStart(),this.executor.getType(e)))),_()(this,"getTypes",(()=>this.executor.getTypes())),_()(this,"registerFunction",(e=>this.executor.registerFunction(e))),_()(this,"registerType",(e=>this.executor.registerType(e))),_()(this,"registerRenderer",(e=>this.renderers.register(e))),_()(this,"fork",(e=>(this.assertSetup(),new ExpressionsServiceFork(e,this)))),_()(this,"execute",((e,t,n)=>{this.assertStart();const r=this.executor.createExecution(e,n);return r.start(t),r.contract})),_()(this,"run",((e,t,n)=>(this.assertStart(),this.executor.run(e,t,n)))),_()(this,"telemetry",((e,t={})=>this.executor.telemetry(e,t))),_()(this,"extract",(e=>this.executor.extract(e))),_()(this,"inject",((e,t)=>this.executor.inject(e,t))),_()(this,"getAllMigrations",(()=>this.executor.getAllMigrations())),_()(this,"migrateToLatest",(e=>this.executor.migrateToLatest(e))),this.executor=t,this.renderers=n}isStarted(){return expressions_services_ExpressionsService.started.has(this)}assertSetup(){if(this.isStarted())throw new Error("The expression service is already started and can no longer be configured.")}assertStart(){if(!this.isStarted())throw new Error("The expressions service has not started yet.")}setup(...e){for(const e of[C,A,M,R,F,N,k,$,I,L,D,U,B])this.registerFunction(e);return this}start(...e){return expressions_services_ExpressionsService.started.add(this),this}stop(){expressions_services_ExpressionsService.started.delete(this)}}_()(expressions_services_ExpressionsService,"started",new WeakSet)},function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"f",(function(){return o})),n.d(t,"d",(function(){return a})),n.d(t,"g",(function(){return u})),n.d(t,"b",(function(){return c})),n.d(t,"e",(function(){return l})),n.d(t,"a",(function(){return expressions_services_ExpressionsService}));var r=n(20),s=n(8);class expressions_services_ExpressionsService extends s.ExpressionsService{setup({getStartServices:e}){return this.registerFunction(function({getStartServices:e}){return Object(s.getUiSettingFn)({async getStartDependencies(){const[{uiSettings:t}]=await e();return{uiSettings:t}}})}({getStartServices:e})),super.setup()}}const[i,o]=Object(r.createGetterSetter)("Notifications"),[a,u]=Object(r.createGetterSetter)("Renderers registry"),[c,l]=Object(r.createGetterSetter)("ExpressionsService")},function(e,t,n){"use strict";function r(e){if(null==e)return"null";if(Array.isArray(e))throw new Error("Unexpected array value encountered.");if("object"!=typeof e)return typeof e;const{type:t}=e;if(!t)throw new Error("Objects must have a type property");return t}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return o}));var r=n(10);const s="error",i=e=>{try{return"error"===Object(r.a)(e)}catch(e){}return!1},o={name:s,to:{render:e=>({type:"render",as:s,value:{error:e.error,info:e.info}})}}},function(e,t){e.exports=__kbnSharedDeps__.EmotionReact},function(e,t,n){n.r(t);var r=__kbnBundles__.get("plugin/kibanaUtils/common");Object.defineProperties(t,Object.getOwnPropertyDescriptors(r))},function(e,t){e.exports=__kbnSharedDeps__.ElasticEui},function(e,t,n){"use strict";n.d(t,"a",(function(){return ExpressionType}));var r=n(0),s=n.n(r),i=n(10);class ExpressionType{constructor(e){s()(this,"name",void 0),s()(this,"namespace",void 0),s()(this,"help",void 0),s()(this,"validate",void 0),s()(this,"create",void 0),s()(this,"serialize",void 0),s()(this,"deserialize",void 0),s()(this,"definition",void 0),s()(this,"getToFn",(e=>this.definition.to?this.definition.to[e]||this.definition.to["*"]:void 0)),s()(this,"getFromFn",(e=>this.definition.from?this.definition.from[e]||this.definition.from["*"]:void 0)),s()(this,"castsTo",(e=>"function"==typeof this.getToFn(e))),s()(this,"castsFrom",(e=>"function"==typeof this.getFromFn(e))),s()(this,"to",((e,t,n)=>{const r=Object(i.a)(e);if(r!==this.name)throw new Error(`Can not cast object of type '${r}' using '${this.name}'`);if(!this.castsTo(t))throw new Error(`Can not cast '${r}' to '${t}'`);return this.getToFn(t)(e,n)})),s()(this,"from",((e,t)=>{const n=Object(i.a)(e);if(!this.castsFrom(n))throw new Error(`Can not cast '${this.name}' from ${n}`);return this.getFromFn(n)(e,t)}));const{name:t,help:n,deserialize:r,serialize:o,validate:a,namespace:u}=e;this.name=t,this.namespace=u,this.help=n||"",this.validate=a||(()=>{}),this.create=e.create,this.serialize=o,this.deserialize=r,this.definition=e}}},function(e,t,n){"use strict";n.d(t,"r",(function(){return C})),n.d(t,"b",(function(){return s})),n.d(t,"g",(function(){return a})),n.d(t,"c",(function(){return u})),n.d(t,"h",(function(){return c.b})),n.d(t,"d",(function(){return c.a})),n.d(t,"e",(function(){return l})),n.d(t,"f",(function(){return d})),n.d(t,"i",(function(){return p})),n.d(t,"j",(function(){return h})),n.d(t,"k",(function(){return m})),n.d(t,"a",(function(){return v})),n.d(t,"l",(function(){return b})),n.d(t,"m",(function(){return x})),n.d(t,"n",(function(){return E})),n.d(t,"o",(function(){return w})),n.d(t,"p",(function(){return j})),n.d(t,"q",(function(){return O})),n.d(t,"s",(function(){return T}));const r="boolean",s={name:r,from:{null:()=>!1,number:e=>Boolean(e),string:e=>Boolean(e)},to:{render:e=>({type:"render",as:"text",value:{text:`${e}`}}),datatable:e=>({type:"datatable",columns:[{id:"value",name:"value",meta:{type:r}}],rows:[{value:e}]})}};var i=n(3);const o="datatable",a=e=>"datatable"===(null==e?void 0:e.type),u={name:o,validate:e=>{if(!e.columns)throw new Error("datatable must have a columns array, even if it is empty");if(!e.rows)throw new Error("datatable must have a rows array, even if it is empty")},serialize:e=>{const{columns:t,rows:n}=e;return{...e,rows:n.map((e=>t.map((t=>e[t.name]))))}},deserialize:e=>{const{columns:t,rows:n}=e;return{...e,rows:n.map((e=>Object(i.zipObject)(Object(i.map)(t,"name"),e)))}},from:{null:()=>({type:o,meta:{},rows:[],columns:[]}),pointseries:e=>({type:o,meta:{},rows:e.rows,columns:Object(i.map)(e.columns,((e,t)=>({id:t,name:e.expression,meta:{type:e.type}})))})},to:{render:e=>({type:"render",as:"table",value:{datatable:e,paginate:!0,perPage:10,showHeader:!0}}),pointseries:e=>{const t=["x","y","color","size","text"],n=e.columns.filter((e=>t.includes(e.id))),r=e.rows.map((e=>Object(i.pick)(e,t)));return{type:"pointseries",columns:n.reduce(((e,t)=>(e[t.name]={type:t.meta.type,expression:t.name,role:"dimension"},e)),{}),rows:r}}}};var c=n(11);const l={name:"filter",from:{null:()=>({type:"filter",filterType:"filter",meta:{},and:[]})}},d={name:"image",to:{render:e=>({type:"render",as:"image",value:e})}},p={name:"null",from:{"*":()=>null}};var f=n(1);const h={name:"num",from:{null:()=>({type:"num",value:0}),boolean:e=>({type:"num",value:Number(e)}),string:e=>{const t=Number(e);if(Number.isNaN(t))throw new Error(f.i18n.translate("expressions.types.number.fromStringConversionErrorMessage",{defaultMessage:'Can\'t typecast "{string}" string to number',values:{string:e}}));return{type:"num",value:t}},"*":e=>({type:"num",value:Number(e)})},to:{render:({value:e})=>({type:"render",as:"text",value:{text:`${e}`}}),datatable:({value:e})=>({type:"datatable",columns:[{id:"value",name:"value",meta:{type:"number"}}],rows:[{value:e}]})}},m={name:"number",from:{null:()=>0,boolean:e=>Number(e),string:e=>{const t=Number(e);if(Number.isNaN(t))throw new Error(f.i18n.translate("expressions.types.number.fromStringConversionErrorMessage",{defaultMessage:'Can\'t typecast "{string}" string to number',values:{string:e}}));return t}},to:{render:e=>({type:"render",as:"text",value:{text:`${e}`}}),datatable:e=>({type:"datatable",columns:[{id:"value",name:"value",meta:{type:"number"}}],rows:[{value:e}]})}},g="pointseries",v={X:"x",Y:"y",COLOR:"color",SIZE:"size",TEXT:"text"},b={name:g,from:{null:()=>({type:g,rows:[],columns:{}})},to:{render:(e,t)=>({type:"render",as:"table",value:{datatable:t.datatable.from(e,t),showHeader:!0}})}},x={name:"range",from:{null:()=>({type:"range",from:0,to:0})},to:{render:e=>({type:"render",as:"text",value:{text:(null==e?void 0:e.label)||`from ${e.from} to ${e.to}`}})}},y="render",E={name:y,from:{"*":e=>({type:y,as:"debug",value:e})}},w={name:"shape",to:{render:e=>({type:"render",as:"shape",value:e})}},j={name:"string",from:{null:()=>"",boolean:e=>String(e),number:e=>String(e)},to:{render:e=>({type:"render",as:"text",value:{text:e}}),datatable:e=>({type:"datatable",columns:[{id:"value",name:"value",meta:{type:"string"}}],rows:[{value:e}]})}},O={name:"style",from:{null:()=>({type:"style",spec:{},css:""})}};function _(e){return null==e?"null":Array.isArray(e)?e.length?_(e[0]):"unknown":["boolean","number","object","string"].includes(typeof e)?typeof e:"unknown"}const T={name:"ui_setting",to:{boolean:({value:e})=>Boolean(e),number:({value:e})=>Number(e),string:({value:e})=>String(null!=e?e:""),render:({value:e})=>({type:"render",as:"text",value:{text:"object"==typeof e&&null!==e?JSON.stringify(e):String(null!=e?e:"")}}),datatable:({key:e,value:t})=>({type:"datatable",columns:[{id:e,name:e,meta:{type:_(t)}}],rows:(Array.isArray(t)?t:[t]).map((t=>({[e]:t})))})}},C=[s,u,c.a,l,d,p,h,m,b,x,E,w,j,O,T]},function(e,t,n){n.r(t);var r=__kbnBundles__.get("plugin/kibanaUtils/common/state_containers");Object.defineProperties(t,Object.getOwnPropertyDescriptors(r))},function(e,t,n){"use strict";var r,s="object"==typeof Reflect?Reflect:null,i=s&&"function"==typeof s.apply?s.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(n,r){function s(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",s),n([].slice.call(arguments))}v(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&v(e,"error",t,{once:!0})}(e,s)}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var u=10;function c(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function d(e,t,n,r){var s,i,o,a;if(c(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),o=i[t]),void 0===o)o=i[t]=n,++e._eventsCount;else if("function"==typeof o?o=i[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(s=l(e))>0&&o.length>s&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,a=u,console&&console.warn&&console.warn(a)}return e}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},s=p.bind(r);return s.listener=n,r.wrapFn=s,s}function h(e,t,n){var r=e._events;if(void 0===r)return[];var s=r[t];return void 0===s?[]:"function"==typeof s?n?[s.listener||s]:[s]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=s[e];if(void 0===u)return!1;if("function"==typeof u)i(u,this,t);else{var c=u.length,l=g(u,c);for(n=0;n=0;i--)if(n[i]===t||n[i].listener===t){o=n[i].listener,s=i;break}if(s<0)return this;0===s?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(6),s=n(41);t.default=function(e,t){var n=s.useFirstMountState();r.useEffect((function(){if(!n)return e()}),t)}},function(e,t,n){n.r(t);var r=__kbnBundles__.get("plugin/kibanaUtils/public");Object.defineProperties(t,Object.getOwnPropertyDescriptors(r))},function(e,t){e.exports=__kbnSharedDeps__.KbnStd},function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return i}));var r=n(1);function s(e,t){return(t||[]).map((t=>null==e[t]?"":String(e[t]))).join("|")}function i(e,t,n,s,i={allowColumnOverwrite:!1}){if(!i.allowColumnOverwrite&&e.columns.some((e=>e.id===t)))throw new Error(r.i18n.translate("expressions.functions.seriesCalculations.columnConflictMessage",{defaultMessage:"Specified outputColumnId {columnId} already exists. Please pick another column id.",values:{columnId:t}}));const o=e.columns.find((e=>e.id===n));if(!o)return;const a={...o,id:t,name:s||t},u=[...e.columns],c=n===t?0:1,l=n===t?1:0;return u.splice(u.indexOf(o)+c,l,a),u}},function(e,t,n){"use strict";var r,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 o(e){for(var t=-1,n=0;nt?e:(t-=e.length,e+(n+=n.repeat(t)).slice(0,t))}n.r(t),n.d(t,"fromExpression",(function(){return u})),n.d(t,"isAst",(function(){return s})),n.d(t,"isAstWithMeta",(function(){return r})),n.d(t,"toExpression",(function(){return v})),n.d(t,"safeElementFromExpression",(function(){return c})),n.d(t,"Fn",(function(){return x})),n.d(t,"getType",(function(){return l})),n.d(t,"castProvider",(function(){return y})),n.d(t,"parse",(function(){return a})),n.d(t,"getByAlias",(function(){return E})),n.d(t,"Registry",(function(){return registry_Registry})),n.d(t,"addRegistries",(function(){return O})),n.d(t,"register",(function(){return _})),n.d(t,"registryFactory",(function(){return T})),function(e,t){function n(){this.constructor=e}n.prototype=t.prototype,e.prototype=new n}(i,Error),i.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var n,r=null;for(n=0;n0){for(t=1,n=1;t[\]$`|= \t\n\r]/,j=/^[^"'(){}<>[\]$`|= \t\n\r]/,O=/^[^"]/,_=/^[^']/,T=he("|",!1),C=ge("function"),S=he("=",!1),A=he("$",!1),M=he("{",!1),R=he("}",!1),F=me([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),N=ge("literal"),k=he('"',!1),L=he("'",!1),$=me([" ","\t","\r","\n"],!1,!1),I=he("//",!1),H=me(["\n"],!0,!1),P=he("/*",!1),q=he("*/",!1),D={type:"any"},z=he("\\",!1),U=me(['"',"'","(",")","{","}","<",">","[","]","$","`","|","="," ","\t","\n","\r"],!1,!1),B=me(['"',"'","(",")","{","}","<",">","[","]","$","`","|","="," ","\t","\n","\r"],!0,!1),G=me(['"'],!0,!1),V=me(["'"],!0,!1),W=function(e,t){return t},Y=function(e,t){return Re({type:"expression",chain:e?[e].concat(t):[]},pe(),fe())},J=function(e,t){return Re({type:"function",function:e,arguments:t},pe(),fe())},K=function(e,t){return{name:e,value:t}},X=function(e){return{name:"_",value:e}},Z=function(e){return e},Q=function(e){return Re(e,pe(),fe())},ee=function(e){return e},te=function(e){return e.reduce(((e,{name:t,value:n})=>({...e,[t]:(e[t]||[]).concat(n)})),{})},ne=function(e){return e.join("")},re=function(e){return e.join("")},se=function(e){var t=e.join("");return"null"===t?null:"true"===t||"false"!==t&&(isNaN(Number(t))?t:Number(t))},ie=function(e){return e},oe=0,ae=0,ue=[{line:1,column:1}],ce=0,le=[],de=0;if("startRule"in t){if(!(t.startRule in o))throw new Error("Can't start parsing from rule \""+t.startRule+'".');a=o[t.startRule]}function pe(){return e.substring(ae,oe)}function fe(){return be(ae,oe)}function he(e,t){return{type:"literal",text:e,ignoreCase:t}}function me(e,t,n){return{type:"class",parts:e,inverted:t,ignoreCase:n}}function ge(e){return{type:"other",description:e}}function ve(t){var n,r=ue[t];if(r)return r;for(n=t-1;!ue[n];)n--;for(r={line:(r=ue[n]).line,column:r.column};nce&&(ce=oe,le=[]),le.push(e))}function ye(){var t,n,s,i,o,a;for(t=oe,_e(),(n=Ee())===r&&(n=null),s=[],i=oe,124===e.charCodeAt(oe)?(o=u,oe++):(o=r,0===de&&xe(T)),o!==r?(_e(),(a=Ee())!==r?(ae=i,i=W(n,a)):(oe=i,i=r)):(oe=i,i=r);i!==r;)s.push(i),i=oe,124===e.charCodeAt(oe)?(o=u,oe++):(o=r,0===de&&xe(T)),o!==r?(_e(),(a=Ee())!==r?(ae=i,i=W(n,a)):(oe=i,i=r)):(oe=i,i=r);return ae=t,Y(n,s)}function Ee(){var e,t,n;return de++,e=oe,(t=Oe())!==r?(n=function(){var e,t,n,s;for(e=oe,t=[],n=oe,_e()!==r&&(s=we())!==r?(ae=n,n=ee(s)):(oe=n,n=r);n!==r;)t.push(n),n=oe,_e()!==r&&(s=we())!==r?(ae=n,n=ee(s)):(oe=n,n=r);return(n=_e())===r&&(n=null),ae=e,e=te(t)}(),ae=e,e=J(t,n)):(oe=e,e=r),de--,e===r&&(t=r,0===de&&xe(C)),e}function we(){var t,n,s,i;return t=oe,(n=Oe())!==r?(_e(),61===e.charCodeAt(oe)?(s=c,oe++):(s=r,0===de&&xe(S)),s!==r?(_e(),(i=je())!==r?(ae=t,t=K(n,i)):(oe=t,t=r)):(oe=t,t=r)):(oe=t,t=r),t===r&&(t=oe,(n=je())!==r&&(ae=t,n=X(n)),t=n),t}function je(){var t,n,s,i,o;return t=oe,36===e.charCodeAt(oe)?(n=l,oe++):(n=r,0===de&&xe(A)),n===r&&(n=null),123===e.charCodeAt(oe)?(s=d,oe++):(s=r,0===de&&xe(M)),s!==r&&(i=ye())!==r?(125===e.charCodeAt(oe)?(o=p,oe++):(o=r,0===de&&xe(R)),o!==r?(ae=t,t=Z(i)):(oe=t,t=r)):(oe=t,t=r),t===r&&(t=oe,n=function(){var t;return de++,t=function(){var t,n,s,i;if(t=oe,34===e.charCodeAt(oe)?(n=f,oe++):(n=r,0===de&&xe(k)),n!==r){for(s=[],i=Ae();i!==r;)s.push(i),i=Ae();34===e.charCodeAt(oe)?(i=f,oe++):(i=r,0===de&&xe(k)),i!==r?(ae=t,t=re(s)):(oe=t,t=r)}else oe=t,t=r;if(t===r)if(t=oe,39===e.charCodeAt(oe)?(n=h,oe++):(n=r,0===de&&xe(L)),n!==r){for(s=[],i=Me();i!==r;)s.push(i),i=Me();39===e.charCodeAt(oe)?(i=h,oe++):(i=r,0===de&&xe(L)),i!==r?(ae=t,t=re(s)):(oe=t,t=r)}else oe=t,t=r;return t}(),t===r&&(t=function(){var e,t,n,s;if(e=oe,t=oe,de++,n=Ce(),de--,n===r?t=void 0:(oe=t,t=r),t!==r){if(n=[],(s=Se())!==r)for(;s!==r;)n.push(s),s=Se();else n=r;n!==r?(ae=e,e=se(n)):(oe=e,e=r)}else oe=e,e=r;return e}()),de--,t===r&&0===de&&xe(N),t}(),n!==r&&(ae=t,n=Q(n)),t=n),t}function Oe(){var t,n,s;if(t=oe,n=[],x.test(e.charAt(oe))?(s=e.charAt(oe),oe++):(s=r,0===de&&xe(F)),s!==r)for(;s!==r;)n.push(s),x.test(e.charAt(oe))?(s=e.charAt(oe),oe++):(s=r,0===de&&xe(F));else n=r;return n!==r&&(ae=t,n=ne(n)),n}function _e(){var e,t;if(e=[],(t=Te())===r&&(t=Ce()),t!==r)for(;t!==r;)e.push(t),(t=Te())===r&&(t=Ce());else e=r;return e}function Te(){var t;return y.test(e.charAt(oe))?(t=e.charAt(oe),oe++):(t=r,0===de&&xe($)),t}function Ce(){var t;return(t=function(){var t,n,s,i;if(t=oe,e.substr(oe,2)===m?(n=m,oe+=2):(n=r,0===de&&xe(I)),n!==r){for(s=[],E.test(e.charAt(oe))?(i=e.charAt(oe),oe++):(i=r,0===de&&xe(H));i!==r;)s.push(i),E.test(e.charAt(oe))?(i=e.charAt(oe),oe++):(i=r,0===de&&xe(H));t=n=[n,s]}else oe=t,t=r;return t}())===r&&(t=function(){var t,n,s,i,o,a;if(t=oe,e.substr(oe,2)===g?(n=g,oe+=2):(n=r,0===de&&xe(P)),n!==r){for(s=[],i=oe,o=oe,de++,e.substr(oe,2)===v?(a=v,oe+=2):(a=r,0===de&&xe(q)),de--,a===r?o=void 0:(oe=o,o=r),o!==r?(e.length>oe?(a=e.charAt(oe),oe++):(a=r,0===de&&xe(D)),a!==r?i=o=[o,a]:(oe=i,i=r)):(oe=i,i=r);i!==r;)s.push(i),i=oe,o=oe,de++,e.substr(oe,2)===v?(a=v,oe+=2):(a=r,0===de&&xe(q)),de--,a===r?o=void 0:(oe=o,o=r),o!==r?(e.length>oe?(a=e.charAt(oe),oe++):(a=r,0===de&&xe(D)),a!==r?i=o=[o,a]:(oe=i,i=r)):(oe=i,i=r);e.substr(oe,2)===v?(i=v,oe+=2):(i=r,0===de&&xe(q)),i===r&&(i=null),t=n=[n,s,i]}else oe=t,t=r;return t}()),t}function Se(){var t,n,s;return t=oe,92===e.charCodeAt(oe)?(n=b,oe++):(n=r,0===de&&xe(z)),n!==r?(w.test(e.charAt(oe))?(s=e.charAt(oe),oe++):(s=r,0===de&&xe(U)),s===r&&(92===e.charCodeAt(oe)?(s=b,oe++):(s=r,0===de&&xe(z))),s!==r?(ae=t,t=ie(s)):(oe=t,t=r)):(oe=t,t=r),t===r&&(j.test(e.charAt(oe))?(t=e.charAt(oe),oe++):(t=r,0===de&&xe(B))),t}function Ae(){var t,n,s;return t=oe,92===e.charCodeAt(oe)?(n=b,oe++):(n=r,0===de&&xe(z)),n!==r?(34===e.charCodeAt(oe)?(s=f,oe++):(s=r,0===de&&xe(k)),s===r&&(92===e.charCodeAt(oe)?(s=b,oe++):(s=r,0===de&&xe(z))),s!==r?(ae=t,t=ie(s)):(oe=t,t=r)):(oe=t,t=r),t===r&&(O.test(e.charAt(oe))?(t=e.charAt(oe),oe++):(t=r,0===de&&xe(G))),t}function Me(){var t,n,s;return t=oe,92===e.charCodeAt(oe)?(n=b,oe++):(n=r,0===de&&xe(z)),n!==r?(39===e.charCodeAt(oe)?(s=h,oe++):(s=r,0===de&&xe(L)),s===r&&(92===e.charCodeAt(oe)?(s=b,oe++):(s=r,0===de&&xe(z))),s!==r?(ae=t,t=ie(s)):(oe=t,t=r)):(oe=t,t=r),t===r&&(_.test(e.charAt(oe))?(t=e.charAt(oe),oe++):(t=r,0===de&&xe(V))),t}function Re(e,n,{start:{offset:r},end:{offset:s}}){return t.addMeta?{node:e,text:n,start:r,end:s}:e}if((n=a())!==r&&oe===e.length)return n;throw n!==r&&oe{if(!e||!t||(null==e?void 0:e.node.function)!==(null==t?void 0:t.function))throw Error("Expression changes are not supported.");!function(e,t){if(Object(d.xor)(Object.keys(e.node.arguments),Object.keys(t.arguments)).length)throw Error("Function changes are not supported.");Object(d.forEach)(e.node.arguments,((e,n)=>{!function(e,t){if(e.length!==t.length)throw Error("Arguments changes are not supported.");Object(d.zip)(e,t).forEach((([e,t])=>function(e,t){r(e)&&s(t)?o(e,t):e.node!==t&&i.push({type:"value",source:e,target:t})}(e,t)))}(e,t.arguments[n])}))}(e,t)}))}for(;n.length;)o(...n.shift());return i}(e,t).sort((({source:e},{source:t})=>e.start-t.start)).forEach((function(t){var s;if("value"!==(null==(s=t)?void 0:s.type))throw new Error("Cannot apply patch for the change.");!function(t){if(r(t.source))throw new Error("Patching sub-expressions is not supported.");n+=`${e.substring(i,t.source.start)}${v(t.target,"argument")}`,i=t.source.end}(t)})),n+=e.substring(i),n}function f(e,t,n=0){const r=l(e);function s(e,t){return null==e||"_"===e?t:`${e}=${t}`}if("string"===r)return s(t,`"${e.replace(/[\\"]/g,"\\$&")}"`);if("boolean"===r||"null"===r||"number"===r)return s(t,`${e}`);if("expression"===r)return s(t,`{${g(e.chain,n+1)}}`);throw new Error(`Invalid argument type in AST: ${r}`)}function h({arguments:e},t=0){if(null==e||"object"!=typeof e||Array.isArray(e))throw new Error("Arguments can only be an object");return Object.keys(e).map((n=>e[n].reduce(((e,r)=>{const s=f(r,n,t),i=e.split("\n").pop().length;return 0===t&&i+s.length>80?`${e}\n ${s}`:i>0?`${e} ${s}`:s}),"")))}function m(e,t){var n;return`${e} ${null!==(n=null==t?void 0:t.join(" "))&&void 0!==n?n:""}`.trim()}function g(e,t=0){if(!e)throw new Error("Expressions must contain a chain");const n=t>0?" | ":"\n| ";return e.map((e=>{if("function"!==l(e))return;const{function:n}=e;if(!n)throw new Error("Functions must have a function name");return m(n,h(e,t))})).join(n)}function v(e,t="expression"){const{type:n,source:r}="string"==typeof t?{type:t}:t;if(r&&s(e))return p(r,e);if("argument"===n)return f(e);const i=l(e);if("expression"===i){const{chain:t}=e;if(!Array.isArray(t))throw new Error("Expressions must contain a chain");return g(t)}if("function"===i){const{function:t}=e;return m(t,h(e))}throw new Error("Expression must be an expression or argument function")}function b(e){if("_"===e.name)throw Error("Arg names must not be _. Use it in aliases instead.");this.name=e.name,this.required=e.required||!1,this.help=e.help||"",this.types=e.types||[],this.default=e.default,this.aliases=e.aliases||[],this.multi=null!=e.multi&&e.multi,this.resolve=null==e.resolve||e.resolve,this.options=e.options||[],this.accepts=t=>!this.types.length||Object(d.includes)(e.types,t)}function x(e){this.name=e.name,this.type=e.type,this.aliases=e.aliases||[],this.fn=(...t)=>Promise.resolve(e.fn(...t)),this.help=e.help||"",this.args=Object(d.mapValues)(e.args||{},((e,t)=>new b({name:t,...e}))),this.context=e.context||{},this.accepts=e=>!this.context.types||Object(d.includes)(this.context.types,e)}function y(e){return function(t,n){if(!n||0===n.length)return t;const r=l(t);if(n.includes(r))return t;const s=e[r];for(let i=0;ie.toLowerCase()===n||(t||[]).some((e=>e.toLowerCase()===n))))}var w=n(0),j=n.n(w);class registry_Registry{constructor(e="name"){if(j()(this,"_prop",void 0),j()(this,"_indexed",void 0),"string"!=typeof e)throw new Error("Registry property name must be a string");this._prop=e,this._indexed=new Object}wrapper(e){return e}register(e){const t="function"==typeof e?e():e;if("object"!=typeof t||!t[this._prop])throw new Error(`Registered functions must return an object with a ${this._prop} property`);this._indexed[t[this._prop].toLowerCase()]=this.wrapper(t)}toJS(){return Object.keys(this._indexed).reduce(((e,t)=>(e[t]=this.get(t),e)),{})}toArray(){return Object.keys(this._indexed).map((e=>this.get(e)))}get(e){if(void 0===e)return null;const t=e.toLowerCase();return this._indexed[t]?Object(d.clone)(this._indexed[t]):null}getProp(){return this._prop}reset(){this._indexed=new Object}}function O(e,t){return Object.keys(t).forEach((n=>{if(e[n])throw new Error(`There is already a registry named "${n}".`);e[n]=t[n]})),e}function _(e,t){return Object.keys(t).forEach((n=>{if(!e[n])throw new Error(`There is no registry named "${n}".`);if(!e[n].register)throw new Error(`Registry "${n}" must have a register function.`);t[n].forEach((t=>e[n].register(t)))})),e}function T(e){return{registries:()=>e,register:t=>_(e,t)}}},function(e,t,n){"use strict";n.r(t),n.d(t,"ReactExpressionRenderer",(function(){return y})),n.d(t,"useExpressionRenderer",(function(){return b}));var r=n(29),s=n.n(r),i=n(6),o=n(30),a=n.n(o),u=n(14),c=n(4),l=n(19),d=n.n(l),p=n(8),f=n(31),h=n(3),m=n(32),g=n.n(m);function v(e){const t=Object(i.useRef)(e);return g()(t.current,e)||(t.current=e),t.current}function b(e,{debounce:t,expression:n,hasCustomErrorRenderer:r,onData$:s,onEvent:o,onRender$:a,reload$:u,...l}){const[{error:m,isEmpty:g,isLoading:b},x]=Object(i.useReducer)(((e,t)=>({...e,...t})),{isEmpty:!0,isLoading:!1,error:null}),y=v({expression:n,params:v(l)}),[{expression:E,params:w},j]=function(e,t){const[n,r]=Object(i.useState)(e),[s,o]=Object(i.useState)(!1),a=Object(i.useCallback)((e=>{r(e),o(!1)}),[r,o]),u=Object(i.useMemo)((()=>t?Object(h.debounce)(a,t):a),[a,t]);return Object(i.useEffect)((()=>()=>{var e;return null===(e=u.cancel)||void 0===e?void 0:e.call(u)}),[u]),d()((()=>(o(!0),u(e),()=>{var e;return null===(e=u.cancel)||void 0===e?void 0:e.call(u)})),[e]),[n,s]}(y,t),O=Object(i.useRef)(null),_=Object(i.useRef)(!1),T=Object(i.useRef)(null);return Object(i.useEffect)((()=>{var t;O.current=e.current&&new f.ExpressionLoader(e.current,E,{...w,onRenderError:(e,t,n)=>{var r;return T.current=n,x({error:t,isEmpty:!1,isLoading:!1}),null===(r=w.onRenderError)||void 0===r?void 0:r.call(w,e,t,n)}});const n=null===(t=O.current)||void 0===t?void 0:t.loading$.subscribe((()=>{_.current=!1,x({isLoading:!0})}));return()=>{var e;null==n||n.unsubscribe(),null===(e=O.current)||void 0===e||e.destroy(),O.current=null,T.current=null}}),[w.onRenderError,w.interactive,w.renderMode,w.syncColors,w.syncTooltips,w.syncCursor]),Object(i.useEffect)((()=>{var e;const t=o&&(null===(e=O.current)||void 0===e?void 0:e.events$.subscribe(o));return()=>null==t?void 0:t.unsubscribe()}),[O.current,o]),Object(i.useEffect)((()=>{var e;const t=null===(e=O.current)||void 0===e?void 0:e.data$.subscribe((({partial:e,result:t})=>{var n;x({isEmpty:!1,...Object(p.isExpressionValueError)(t)?{}:{error:null}}),null==s||s(t,null===(n=O.current)||void 0===n?void 0:n.inspect(),e)}));return()=>null==t?void 0:t.unsubscribe()}),[O.current,s]),Object(i.useEffect)((()=>{var e;const t=null===(e=O.current)||void 0===e?void 0:e.render$.pipe(Object(c.filter)((()=>!_.current))).subscribe((e=>{x({error:null,isEmpty:!1,isLoading:!1}),null==a||a(e)}));return()=>{null==t||t.unsubscribe()}}),[O.current,a]),Object(i.useEffect)((()=>{const e=null==u?void 0:u.subscribe((()=>{var e;null===(e=O.current)||void 0===e||e.update(E,w)}));return()=>null==e?void 0:e.unsubscribe()}),[u,E,w]),d()((()=>{var e;null===(e=O.current)||void 0===e||e.update(E,w)}),[E,w]),Object(i.useLayoutEffect)((()=>{var e;m&&r&&(_.current=!0,null===(e=T.current)||void 0===e||e.done()),T.current=null}),[m,r]),{error:m,isEmpty:g,isLoading:b||j}}var x=n(12);function y({className:e,dataAttrs:t,padding:n,renderError:r,...o}){const c=Object(i.useRef)(null),{euiTheme:l}=Object(u.useEuiTheme)(),{error:d,isEmpty:p,isLoading:f}=b(c,{...o,hasCustomErrorRenderer:!!r}),h=a()("expExpressionRenderer",e,{"expExpressionRenderer-isEmpty":p,"expExpressionRenderer-hasError":!!d}),m={};return n&&(m.padding=l.size[n]),Object(x.jsx)("div",s()({},t,{className:h}),p&&Object(x.jsx)(u.EuiLoadingChart,{mono:!0,size:"l"}),f&&Object(x.jsx)(u.EuiProgress,{size:"xs",color:"accent",position:"absolute",style:{zIndex:1}}),!f&&d&&(null==r?void 0:r(d.message,d)),Object(x.jsx)("div",{className:"expExpressionRenderer__expression",style:m,ref:c}))}},function(e,t,n){n.r(t);var r=__kbnBundles__.get("plugin/inspector/common");Object.defineProperties(t,Object.getOwnPropertyDescriptors(r))},function(e,t,n){e.exports=n(25)(1466)},function(e,t){e.exports=__kbnSharedDeps__.Classnames},function(e,t,n){"use strict";n.r(t),n.d(t,"ExpressionLoader",(function(){return ExpressionLoader})),n.d(t,"loader",(function(){return l}));var r=n(0),s=n.n(r),i=n(2),o=n(4),a=n(3),u=n(33),c=n(9);class ExpressionLoader{constructor(e,t,n){s()(this,"data$",void 0),s()(this,"update$",void 0),s()(this,"render$",void 0),s()(this,"events$",void 0),s()(this,"loading$",void 0),s()(this,"execution",void 0),s()(this,"renderHandler",void 0),s()(this,"dataSubject",void 0),s()(this,"loadingSubject",void 0),s()(this,"data",void 0),s()(this,"params",{}),s()(this,"subscription",void 0),s()(this,"loadData",((e,t)=>{var n;null===(n=this.subscription)||void 0===n||n.unsubscribe(),this.execution&&this.execution.isPending&&this.execution.cancel(),this.setParams(t),this.execution=Object(c.b)().execute(e,t.context,{searchContext:t.searchContext,variables:t.variables||{},inspectorAdapters:t.inspectorAdapters,searchSessionId:t.searchSessionId,debug:t.debug,syncColors:t.syncColors,syncCursor:null==t?void 0:t.syncCursor,syncTooltips:t.syncTooltips,executionContext:t.executionContext,partial:t.partial,throttle:t.throttle}),this.subscription=this.execution.getData().pipe(Object(o.delay)(0)).subscribe((e=>this.dataSubject.next(e)))})),this.dataSubject=new i.Subject,this.data$=this.dataSubject.asObservable(),this.loadingSubject=new i.BehaviorSubject(!1),this.loading$=this.loadingSubject.asObservable().pipe(Object(o.shareReplay)(1),Object(o.filter)((e=>!0===e)),Object(o.map)((()=>{}))),this.renderHandler=new u.ExpressionRenderHandler(e,{interactive:null==n?void 0:n.interactive,onRenderError:n&&n.onRenderError,renderMode:null==n?void 0:n.renderMode,syncColors:null==n?void 0:n.syncColors,syncTooltips:null==n?void 0:n.syncTooltips,syncCursor:null==n?void 0:n.syncCursor,hasCompatibleActions:null==n?void 0:n.hasCompatibleActions,getCompatibleCellValueActions:null==n?void 0:n.getCompatibleCellValueActions,executionContext:null==n?void 0:n.executionContext}),this.render$=this.renderHandler.render$,this.update$=this.renderHandler.update$,this.events$=this.renderHandler.events$,this.update$.subscribe((e=>{if(e){const{newExpression:t,newParams:n}=e;this.update(t,n)}})),this.data$.subscribe((({result:e})=>{this.render(e)})),this.render$.subscribe((()=>{this.loadingSubject.next(!1)})),this.setParams(n),t&&(this.loadingSubject.next(!0),this.loadData(t,this.params))}destroy(){var e;this.dataSubject.complete(),this.loadingSubject.complete(),this.renderHandler.destroy(),this.cancel(),null===(e=this.subscription)||void 0===e||e.unsubscribe()}cancel(){var e;null===(e=this.execution)||void 0===e||e.cancel()}getExpression(){var e;return null===(e=this.execution)||void 0===e?void 0:e.getExpression()}getAst(){var e;return null===(e=this.execution)||void 0===e?void 0:e.getAst()}getElement(){return this.renderHandler.getElement()}inspect(){var e;return null===(e=this.execution)||void 0===e?void 0:e.inspect()}update(e,t){this.setParams(t),this.loadingSubject.next(!0),e?this.loadData(e,this.params):this.data&&this.render(this.data)}render(e){this.renderHandler.render(e,this.params.uiState)}setParams(e){var t,n;e&&Object.keys(e).length&&(e.searchContext&&(this.params.searchContext=Object(a.defaults)({},e.searchContext,this.params.searchContext||{})),e.uiState&&this.params&&(this.params.uiState=e.uiState),e.variables&&this.params&&(this.params.variables=e.variables),e.searchSessionId&&this.params&&(this.params.searchSessionId=e.searchSessionId),this.params.syncColors=e.syncColors,this.params.syncCursor=e.syncCursor,this.params.syncTooltips=e.syncTooltips,this.params.debug=Boolean(e.debug),this.params.partial=Boolean(e.partial),this.params.throttle=Number(null!==(t=e.throttle)&&void 0!==t?t:1e3),this.params.inspectorAdapters=e.inspectorAdapters||(null===(n=this.execution)||void 0===n?void 0:n.inspect()),this.params.executionContext=e.executionContext)}}const l=async(e,t,n)=>new ExpressionLoader(e,t,n)},function(e,t,n){"use strict";function r(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}t.__esModule=!0,t.default=function(e,t){if(r(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(var i=0;i{"AbortError"!==t.name?(Object(c.c)().toasts.addError(t,{title:u.i18n.translate("expressions.defaultErrorRenderer.errorTitle",{defaultMessage:"Error in visualisation"}),toastMessage:t.message}),n.done()):n.done()};class render_ExpressionRenderHandler{constructor(e,{onRenderError:t,renderMode:n,syncColors:r,syncTooltips:u,syncCursor:d,interactive:p,hasCompatibleActions:f=(async()=>!1),getCompatibleCellValueActions:h=(async()=>[]),executionContext:m}={}){s()(this,"render$",void 0),s()(this,"update$",void 0),s()(this,"events$",void 0),s()(this,"element",void 0),s()(this,"destroyFn",void 0),s()(this,"renderCount",0),s()(this,"renderSubject",void 0),s()(this,"eventsSubject",void 0),s()(this,"updateSubject",void 0),s()(this,"handlers",void 0),s()(this,"onRenderError",void 0),s()(this,"render",(async(e,t)=>{if(!e||"object"!=typeof e)return this.handleRenderError(new Error("invalid data provided to the expression renderer"));if("render"!==e.type||!e.as)return"error"===e.type?this.handleRenderError(e.error):this.handleRenderError(new Error("invalid data provided to the expression renderer"));if(!Object(c.d)().get(e.as))return this.handleRenderError(new Error(`invalid renderer id '${e.as}'`));try{await Object(c.d)().get(e.as).render(this.element,e.value,{...this.handlers,uiState:t})}catch(e){return this.handleRenderError(e)}})),s()(this,"destroy",(()=>{this.renderSubject.complete(),this.eventsSubject.complete(),this.updateSubject.complete(),this.destroyFn&&this.destroyFn()})),s()(this,"getElement",(()=>this.element)),s()(this,"handleRenderError",(e=>{this.onRenderError(this.element,e,this.handlers)})),this.element=e,this.eventsSubject=new i.Subject,this.events$=this.eventsSubject.asObservable(),this.onRenderError=t||l,this.renderSubject=new i.BehaviorSubject(null),this.render$=this.renderSubject.asObservable().pipe(Object(o.filter)(a.isNumber)),this.updateSubject=new i.Subject,this.update$=this.updateSubject.asObservable(),this.handlers={onDestroy:e=>{this.destroyFn=e},done:()=>{this.renderCount++,this.renderSubject.next(this.renderCount)},reload:()=>{this.updateSubject.next(null)},getExecutionContext:()=>m,update:e=>{this.updateSubject.next(e)},event:e=>{this.eventsSubject.next(e)},getRenderMode:()=>n||"view",isSyncColorsEnabled:()=>r||!1,isSyncTooltipsEnabled:()=>u||!1,isSyncCursorEnabled:()=>d||!0,isInteractive:()=>null==p||p,hasCompatibleActions:f,getCompatibleCellValueActions:h}}}const d=async(e,t,n)=>{const r=new render_ExpressionRenderHandler(e,n);return r.render(t),r}},function(e,t,n){n(35),__kbnBundles__.define("plugin/expressions/public",n,42),__kbnBundles__.define("plugin/expressions/common",n,8),__kbnBundles__.define("plugin/expressions/common/fonts",n,7)},function(e,t,n){n.p=window.__kbnPublicPath__.expressions},function(e,t,n){switch(window.__kbnThemeTag__){case"v8dark":return n(37);case"v8light":return n(39)}},function(e,t,n){var r=n(23),s=n(38);"string"==typeof(s=s.__esModule?s.default:s)&&(s=[[e.i,s,""]]);r(s,{insert:"head",singleton:!1}),e.exports=s.locals||{}},function(e,t,n){(t=n(24)(!1)).push([e.i,".expExpressionRenderer{align-items:center;display:flex;height:100%;justify-content:center;position:relative;width:100%}.expExpressionRenderer__expression{height:100%;width:100%}.expExpressionRenderer-hasError .expExpressionRenderer__expression,.expExpressionRenderer-isEmpty .expExpressionRenderer__expression{display:none}",""]),e.exports=t},function(e,t,n){var r=n(23),s=n(40);"string"==typeof(s=s.__esModule?s.default:s)&&(s=[[e.i,s,""]]);r(s,{insert:"head",singleton:!1}),e.exports=s.locals||{}},function(e,t,n){(t=n(24)(!1)).push([e.i,".expExpressionRenderer{align-items:center;display:flex;height:100%;justify-content:center;position:relative;width:100%}.expExpressionRenderer__expression{height:100%;width:100%}.expExpressionRenderer-hasError .expExpressionRenderer__expression,.expExpressionRenderer-isEmpty .expExpressionRenderer__expression{display:none}",""]),e.exports=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useFirstMountState=void 0;var r=n(6);t.useFirstMountState=function(){var e=r.useRef(!0);return e.current?(e.current=!1,!0):e.current}},function(e,t,n){"use strict";n.r(t),n.d(t,"Plugin",(function(){return plugin_ExpressionsPublicPlugin})),n.d(t,"plugin",(function(){return h})),n.d(t,"useExpressionRenderer",(function(){return p.useExpressionRenderer})),n.d(t,"buildExpression",(function(){return f.buildExpression})),n.d(t,"buildExpressionFunction",(function(){return f.buildExpressionFunction})),n.d(t,"formatExpression",(function(){return f.formatExpression})),n.d(t,"isExpressionAstBuilder",(function(){return f.isExpressionAstBuilder})),n.d(t,"parseExpression",(function(){return f.parseExpression})),n.d(t,"createDefaultInspectorAdapters",(function(){return f.createDefaultInspectorAdapters})),n(36);var r=n(0),s=n.n(r),i=n(3),o=n(9),a=n(6),u=n(14),c=n(12);const l=Object(a.lazy)((async()=>{const{ReactExpressionRenderer:e}=await Promise.resolve().then(n.bind(null,27));return{default:e}})),d=e=>Object(c.jsx)(a.Suspense,{fallback:Object(c.jsx)(u.EuiLoadingSpinner,null)},Object(c.jsx)(l,e));class plugin_ExpressionsPublicPlugin{constructor(e){s()(this,"expressions",new o.a({logger:plugin_ExpressionsPublicPlugin.logger}))}setup(e){const{expressions:t}=this,{renderers:n}=t;Object(o.g)(n),Object(o.e)(t);const r=t.setup(Object(i.pick)(e,"getStartServices"));return Object.freeze(r)}start(e){Object(o.f)(e.notifications);const{expressions:t}=this,r={...t.start(),loader:async(e,t,r)=>{const{ExpressionLoader:s}=await Promise.resolve().then(n.bind(null,31));return new s(e,t,r)},render:async(e,t,r)=>{const{ExpressionRenderHandler:s}=await Promise.resolve().then(n.bind(null,33)),i=new s(e,r);return i.render(t),i},ReactExpressionRenderer:d};return Object.freeze(r)}stop(){this.expressions.stop()}}s()(plugin_ExpressionsPublicPlugin,"logger",{...console,fatal:console.error,get(){return this},isLevelEnabled:()=>!0});var p=n(27),f=n(8);function h(e){return new plugin_ExpressionsPublicPlugin(e)}}]);