(window.visDefaultEditor_bundle_jsonpfunction=window.visDefaultEditor_bundle_jsonpfunction||[]).push([[1],{28:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=i(21).__importDefault(i(31));t.default=function(e){a.default((function(){e()}))}},29:function(e,t,i){"use strict";var a,n=function(){var e={};return function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}e[t]=i}return e[t]}}(),r=[];function s(e){for(var t=-1,i=0;i*{flex-shrink:0}.visEditorSidebar__config{padding:8px}.visEditorSidebar__config>*{flex-grow:0}@media only screen and (min-width:992px) and (max-width:1199px){.visEditorSidebar__config{display:flex;flex:1 1 1px;flex-direction:column;overflow:auto;scrollbar-color:#98a2b380 #0000;scrollbar-width:thin}.visEditorSidebar__config>*{flex-shrink:0}.visEditorSidebar__config::-webkit-scrollbar{height:16px;width:16px}.visEditorSidebar__config::-webkit-scrollbar-thumb{background-clip:content-box;background-color:#98a2b380;border:6px solid #0000;border-radius:16px}.visEditorSidebar__config::-webkit-scrollbar-corner,.visEditorSidebar__config::-webkit-scrollbar-track{background-color:#0000}}@media only screen and (min-width:1200px){.visEditorSidebar__config{display:flex;flex:1 1 1px;flex-direction:column;overflow:auto;scrollbar-color:#98a2b380 #0000;scrollbar-width:thin}.visEditorSidebar__config>*{flex-shrink:0}.visEditorSidebar__config::-webkit-scrollbar{height:16px;width:16px}.visEditorSidebar__config::-webkit-scrollbar-thumb{background-clip:content-box;background-color:#98a2b380;border:6px solid #0000;border-radius:16px}.visEditorSidebar__config::-webkit-scrollbar-corner,.visEditorSidebar__config::-webkit-scrollbar-track{background-color:#0000}}.visEditorSidebar__config-isHidden{display:none}.visEditorSidebar__titleContainer{padding:8px 32px 8px 8px}.visEditorSidebar__indexPatternPlaceholder{border-bottom:1px solid #343741;min-height:40px}.visEditorSidebar__linkedSearch,.visEditorSidebar__nav{flex-grow:0}.visEditorSidebar__section{background-color:#1d1e24;border-radius:6px;padding:8px}.visEditorSidebar__section+.visEditorSidebar__section{margin-top:8px}.visEditorSidebar__collapsible{background-color:#25262e}.visEditorSidebar__collapsible--marginBottom{margin-bottom:12px}.visEditorSidebar__formRow{align-items:center;display:flex;margin-top:12px}.visEditorSidebar__formLabel{align-items:center;display:flex;flex:1 1 40%;padding-right:4px}.visEditorSidebar__formControl{align-items:center;display:flex;flex:1 1 60%}.visEditorSidebar__aggGroupAccordionButtonContent{font-size:14px}.visEditorSidebar__aggGroupAccordionButtonContent span{color:#98a2b3}.visEditorSidebar__controls{align-items:center;border-top:1px solid #343741;display:flex;justify-content:flex-end;padding:8px}.visEditorSidebar__controls .visEditorSidebar__autoApplyButton{margin-left:12px}.visEditorAgg__subAgg{background-color:initial;border:2px solid #343741;border-radius:6px;padding:8px}.visEditorAgg__subAgg+.visEditorAggParam__string{margin-top:16px}.visEditorAggParam--half{display:inline-block;margin:16px 0;width:calc(50% - 4px)}.visEditorAggParam--half-size{margin-left:8px}",""]),e.exports=t},35:function(e,t,i){var a=i(29),n=i(36);"string"==typeof(n=n.__esModule?n.default:n)&&(n=[[e.i,n,""]]);a(n,{insert:"head",singleton:!1}),e.exports=n.locals||{}},36:function(e,t,i){(t=i(30)(!1)).push([e.i,".visEditor--default{display:flex;flex:1 1 auto}.visEditor__collapsibleSidebar{flex-grow:1}.visEditor__collapsibleSidebar-isClosed{min-width:0;width:32px!important}.visEditor__collapsibleSidebar-isClosed .visEditorSidebar{display:none;padding-left:0}.visEditor__collapsibleSidebarButton{position:absolute;right:4px;top:8px}.visEditor__resizer-isHidden{display:none}.visEditor__visualization__wrapper-expanded{width:100%!important}.visEditor__visualization{display:flex;flex:1 1 auto;overflow:hidden}.visEditor__canvas{background-color:#fff;display:flex;flex-direction:row;overflow:auto}.visEditor__canvas,.visEditor__canvas.embedded{flex-basis:100%;flex-shrink:1}.visEditor__canvas .visChart{position:relative}@media only screen and (max-width:574px){.visEditor--default{flex-direction:column}.visEditor__collapsibleSidebar{flex-grow:0;width:100%!important}.visEditor__collapsibleSidebar-isClosed{height:40px!important}.visEditor__resizer{display:none}.visEditor__visualization__wrapper{display:flex;flex:1;flex-direction:column;width:100%!important}}@media only screen and (min-width:575px) and (max-width:767px){.visEditor--default{flex-direction:column}.visEditor__collapsibleSidebar{flex-grow:0;width:100%!important}.visEditor__collapsibleSidebar-isClosed{height:40px!important}.visEditor__resizer{display:none}.visEditor__visualization__wrapper{display:flex;flex:1;flex-direction:column;width:100%!important}}@media only screen and (min-width:768px) and (max-width:991px){.visEditor--default{flex-direction:column}.visEditor__collapsibleSidebar{flex-grow:0;width:100%!important}.visEditor__collapsibleSidebar-isClosed{height:40px!important}.visEditor__resizer{display:none}.visEditor__visualization__wrapper{display:flex;flex:1;flex-direction:column;width:100%!important}}.visEditorSidebar{height:100%;padding-left:8px}@media only screen and (max-width:574px){.visEditorSidebar{padding-left:0}}@media only screen and (min-width:575px) and (max-width:767px){.visEditorSidebar{padding-left:0}}@media only screen and (min-width:768px) and (max-width:991px){.visEditorSidebar{padding-left:0}}.visEditorSidebar__form{display:flex;flex:1 1 auto;flex-direction:column;max-width:100%}.visEditorSidebar__form>*{flex-shrink:0}.visEditorSidebar__config{padding:8px}.visEditorSidebar__config>*{flex-grow:0}@media only screen and (min-width:992px) and (max-width:1199px){.visEditorSidebar__config{display:flex;flex:1 1 1px;flex-direction:column;overflow:auto;scrollbar-color:#69707d80 #0000;scrollbar-width:thin}.visEditorSidebar__config>*{flex-shrink:0}.visEditorSidebar__config::-webkit-scrollbar{height:16px;width:16px}.visEditorSidebar__config::-webkit-scrollbar-thumb{background-clip:content-box;background-color:#69707d80;border:6px solid #0000;border-radius:16px}.visEditorSidebar__config::-webkit-scrollbar-corner,.visEditorSidebar__config::-webkit-scrollbar-track{background-color:#0000}}@media only screen and (min-width:1200px){.visEditorSidebar__config{display:flex;flex:1 1 1px;flex-direction:column;overflow:auto;scrollbar-color:#69707d80 #0000;scrollbar-width:thin}.visEditorSidebar__config>*{flex-shrink:0}.visEditorSidebar__config::-webkit-scrollbar{height:16px;width:16px}.visEditorSidebar__config::-webkit-scrollbar-thumb{background-clip:content-box;background-color:#69707d80;border:6px solid #0000;border-radius:16px}.visEditorSidebar__config::-webkit-scrollbar-corner,.visEditorSidebar__config::-webkit-scrollbar-track{background-color:#0000}}.visEditorSidebar__config-isHidden{display:none}.visEditorSidebar__titleContainer{padding:8px 32px 8px 8px}.visEditorSidebar__indexPatternPlaceholder{border-bottom:1px solid #d3dae6;min-height:40px}.visEditorSidebar__linkedSearch,.visEditorSidebar__nav{flex-grow:0}.visEditorSidebar__section{background-color:#fff;border-radius:6px;padding:8px}.visEditorSidebar__section+.visEditorSidebar__section{margin-top:8px}.visEditorSidebar__collapsible{background-color:#fafbfd}.visEditorSidebar__collapsible--marginBottom{margin-bottom:12px}.visEditorSidebar__formRow{align-items:center;display:flex;margin-top:12px}.visEditorSidebar__formLabel{align-items:center;display:flex;flex:1 1 40%;padding-right:4px}.visEditorSidebar__formControl{align-items:center;display:flex;flex:1 1 60%}.visEditorSidebar__aggGroupAccordionButtonContent{font-size:14px}.visEditorSidebar__aggGroupAccordionButtonContent span{color:#69707d}.visEditorSidebar__controls{align-items:center;border-top:1px solid #d3dae6;display:flex;justify-content:flex-end;padding:8px}.visEditorSidebar__controls .visEditorSidebar__autoApplyButton{margin-left:12px}.visEditorAgg__subAgg{background-color:initial;border:2px solid #d3dae6;border-radius:6px;padding:8px}.visEditorAgg__subAgg+.visEditorAggParam__string{margin-top:16px}.visEditorAggParam--half{display:inline-block;margin:16px 0;width:calc(50% - 4px)}.visEditorAggParam--half-size{margin-left:8px}",""]),e.exports=t},37:function(e,t,i){ace.define("ace/mode/json_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],(function(e,t,i){"use strict";var a=e("../lib/oop"),n=e("./text_highlight_rules").TextHighlightRules,r=function(){this.$rules={start:[{token:"variable",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'},{token:"string",regex:'"',next:"string"},{token:"constant.numeric",regex:"0[xX][0-9a-fA-F]+\\b"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"constant.language.boolean",regex:"(?:true|false)\\b"},{token:"text",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"comment",regex:"\\/\\/.*$"},{token:"comment.start",regex:"\\/\\*",next:"comment"},{token:"paren.lparen",regex:"[[({]"},{token:"paren.rparen",regex:"[\\])}]"},{token:"text",regex:"\\s+"}],string:[{token:"constant.language.escape",regex:/\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/},{token:"string",regex:'"|$',next:"start"},{defaultToken:"string"}],comment:[{token:"comment.end",regex:"\\*\\/",next:"start"},{defaultToken:"comment"}]}};a.inherits(r,n),t.JsonHighlightRules=r})),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],(function(e,t,i){"use strict";var a=e("../range").Range,n=function(){};(function(){this.checkOutdent=function(e,t){return!!/^\s+$/.test(e)&&/^\s*\}/.test(t)},this.autoOutdent=function(e,t){var i=e.getLine(t).match(/^(\s*\})/);if(!i)return 0;var n=i[1].length,r=e.findMatchingBracket({row:t,column:n});if(!r||r.row==t)return 0;var s=this.$getIndent(e.getLine(r.row));e.replace(new a(t,0,t,n-1),s)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(n.prototype),t.MatchingBraceOutdent=n})),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],(function(e,t,i){"use strict";var a=e("../../lib/oop"),n=e("../../range").Range,r=e("./fold_mode").FoldMode,s=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};a.inherits(s,r),function(){this.foldingStartMarker=/([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,i){var a=e.getLine(i);if(this.singleLineBlockCommentRe.test(a)&&!this.startRegionRe.test(a)&&!this.tripleStarBlockCommentRe.test(a))return"";var n=this._getFoldWidgetBase(e,t,i);return!n&&this.startRegionRe.test(a)?"start":n},this.getFoldWidgetRange=function(e,t,i,a){var n,r=e.getLine(i);if(this.startRegionRe.test(r))return this.getCommentRegionBlock(e,r,i);if(n=r.match(this.foldingStartMarker)){var s=n.index;if(n[1])return this.openingBracketBlock(e,n[1],i,s);var o=e.getCommentFoldRange(i,s+n[0].length,1);return o&&!o.isMultiLine()&&(a?o=this.getSectionRange(e,i):"all"!=t&&(o=null)),o}return"markbegin"!==t&&(n=r.match(this.foldingStopMarker))?(s=n.index+n[0].length,n[1]?this.closingBracketBlock(e,n[1],i,s):e.getCommentFoldRange(i,s,-1)):void 0},this.getSectionRange=function(e,t){for(var i=e.getLine(t),a=i.search(/\S/),r=t,s=i.length,o=t+=1,l=e.getLength();++tc)break;var d=this.getFoldWidgetRange(e,"all",t);if(d){if(d.start.row<=r)break;if(d.isMultiLine())t=d.end.row;else if(a==c)break}o=t}}return new n(r,s,o,e.getLine(o).length)},this.getCommentRegionBlock=function(e,t,i){for(var a=t.search(/\s*$/),r=e.getLength(),s=i,o=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,l=1;++is)return new n(s,a,i,t.length)}}.call(s.prototype)})),ace.define("ace/mode/json",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/json_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle","ace/worker/worker_client"],(function(e,t,a){"use strict";var n=e("../lib/oop"),r=e("./text").Mode,s=e("./json_highlight_rules").JsonHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,l=e("./behaviour/cstyle").CstyleBehaviour,c=e("./folding/cstyle").FoldMode,d=e("../worker/worker_client").WorkerClient,u=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new l,this.foldingRules=new c};n.inherits(u,r),function(){this.getNextLineIndent=function(e,t,i){var a=this.$getIndent(t);return"start"==e&&t.match(/^.*[\{\(\[]\s*$/)&&(a+=i),a},this.checkOutdent=function(e,t,i){return this.$outdent.checkOutdent(t,i)},this.autoOutdent=function(e,t,i){this.$outdent.autoOutdent(t,i)},this.createWorker=function(e){var t=new d(["ace"],i(38),"JsonWorker");return t.attachToDocument(e.getDocument()),t.on("annotate",(function(t){e.setAnnotations(t.data)})),t.on("terminate",(function(){e.clearAnnotations()})),t},this.$id="ace/mode/json"}.call(u.prototype),t.Mode=u}))},38:function(e,t){e.exports.id="ace/mode/json_worker",e.exports.src='"no use strict";!function(window){function resolveModuleId(id,paths){for(var testPath=id,tail="";testPath;){var alias=paths[testPath];if("string"==typeof alias)return alias+tail;if(alias)return alias.location.replace(/\\/*$/,"/")+(tail||alias.main||alias.name);if(alias===!1)return"";var i=testPath.lastIndexOf("/");if(-1===i)break;tail=testPath.substr(i)+tail,testPath=testPath.slice(0,i)}return id}if(!(void 0!==window.window&&window.document||window.acequire&&window.define)){window.console||(window.console=function(){var msgs=Array.prototype.slice.call(arguments,0);postMessage({type:"log",data:msgs})},window.console.error=window.console.warn=window.console.log=window.console.trace=window.console),window.window=window,window.ace=window,window.onerror=function(message,file,line,col,err){postMessage({type:"error",data:{message:message,data:err.data,file:file,line:line,col:col,stack:err.stack}})},window.normalizeModule=function(parentId,moduleName){if(-1!==moduleName.indexOf("!")){var chunks=moduleName.split("!");return window.normalizeModule(parentId,chunks[0])+"!"+window.normalizeModule(parentId,chunks[1])}if("."==moduleName.charAt(0)){var base=parentId.split("/").slice(0,-1).join("/");for(moduleName=(base?base+"/":"")+moduleName;-1!==moduleName.indexOf(".")&&previous!=moduleName;){var previous=moduleName;moduleName=moduleName.replace(/^\\.\\//,"").replace(/\\/\\.\\//,"/").replace(/[^\\/]+\\/\\.\\.\\//,"")}}return moduleName},window.acequire=function acequire(parentId,id){if(id||(id=parentId,parentId=null),!id.charAt)throw Error("worker.js acequire() accepts only (parentId, id) as arguments");id=window.normalizeModule(parentId,id);var module=window.acequire.modules[id];if(module)return module.initialized||(module.initialized=!0,module.exports=module.factory().exports),module.exports;if(!window.acequire.tlns)return console.log("unable to load "+id);var path=resolveModuleId(id,window.acequire.tlns);return".js"!=path.slice(-3)&&(path+=".js"),window.acequire.id=id,window.acequire.modules[id]={},importScripts(path),window.acequire(parentId,id)},window.acequire.modules={},window.acequire.tlns={},window.define=function(id,deps,factory){if(2==arguments.length?(factory=deps,"string"!=typeof id&&(deps=id,id=window.acequire.id)):1==arguments.length&&(factory=id,deps=[],id=window.acequire.id),"function"!=typeof factory)return window.acequire.modules[id]={exports:factory,initialized:!0},void 0;deps.length||(deps=["require","exports","module"]);var req=function(childId){return window.acequire(id,childId)};window.acequire.modules[id]={exports:{},factory:function(){var module=this,returnExports=factory.apply(this,deps.map(function(dep){switch(dep){case"require":return req;case"exports":return module.exports;case"module":return module;default:return req(dep)}}));return returnExports&&(module.exports=returnExports),module}}},window.define.amd={},acequire.tlns={},window.initBaseUrls=function(topLevelNamespaces){for(var i in topLevelNamespaces)acequire.tlns[i]=topLevelNamespaces[i]},window.initSender=function(){var EventEmitter=window.acequire("ace/lib/event_emitter").EventEmitter,oop=window.acequire("ace/lib/oop"),Sender=function(){};return function(){oop.implement(this,EventEmitter),this.callback=function(data,callbackId){postMessage({type:"call",id:callbackId,data:data})},this.emit=function(name,data){postMessage({type:"event",name:name,data:data})}}.call(Sender.prototype),new Sender};var main=window.main=null,sender=window.sender=null;window.onmessage=function(e){var msg=e.data;if(msg.event&&sender)sender._signal(msg.event,msg.data);else if(msg.command)if(main[msg.command])main[msg.command].apply(main,msg.args);else{if(!window[msg.command])throw Error("Unknown command:"+msg.command);window[msg.command].apply(window,msg.args)}else if(msg.init){window.initBaseUrls(msg.tlns),acequire("ace/lib/es5-shim"),sender=window.sender=window.initSender();var clazz=acequire(msg.module)[msg.classname];main=window.main=new clazz(sender)}}}}(this),ace.define("ace/lib/oop",["require","exports","module"],function(acequire,exports){"use strict";exports.inherits=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})},exports.mixin=function(obj,mixin){for(var key in mixin)obj[key]=mixin[key];return obj},exports.implement=function(proto,mixin){exports.mixin(proto,mixin)}}),ace.define("ace/range",["require","exports","module"],function(acequire,exports){"use strict";var comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},Range=function(startRow,startColumn,endRow,endColumn){this.start={row:startRow,column:startColumn},this.end={row:endRow,column:endColumn}};(function(){this.isEqual=function(range){return this.start.row===range.start.row&&this.end.row===range.end.row&&this.start.column===range.start.column&&this.end.column===range.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(row,column){return 0==this.compare(row,column)},this.compareRange=function(range){var cmp,end=range.end,start=range.start;return cmp=this.compare(end.row,end.column),1==cmp?(cmp=this.compare(start.row,start.column),1==cmp?2:0==cmp?1:0):-1==cmp?-2:(cmp=this.compare(start.row,start.column),-1==cmp?-1:1==cmp?42:0)},this.comparePoint=function(p){return this.compare(p.row,p.column)},this.containsRange=function(range){return 0==this.comparePoint(range.start)&&0==this.comparePoint(range.end)},this.intersects=function(range){var cmp=this.compareRange(range);return-1==cmp||0==cmp||1==cmp},this.isEnd=function(row,column){return this.end.row==row&&this.end.column==column},this.isStart=function(row,column){return this.start.row==row&&this.start.column==column},this.setStart=function(row,column){"object"==typeof row?(this.start.column=row.column,this.start.row=row.row):(this.start.row=row,this.start.column=column)},this.setEnd=function(row,column){"object"==typeof row?(this.end.column=row.column,this.end.row=row.row):(this.end.row=row,this.end.column=column)},this.inside=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)||this.isStart(row,column)?!1:!0:!1},this.insideStart=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)?!1:!0:!1},this.insideEnd=function(row,column){return 0==this.compare(row,column)?this.isStart(row,column)?!1:!0:!1},this.compare=function(row,column){return this.isMultiLine()||row!==this.start.row?this.start.row>row?-1:row>this.end.row?1:this.start.row===row?column>=this.start.column?0:-1:this.end.row===row?this.end.column>=column?0:1:0:this.start.column>column?-1:column>this.end.column?1:0},this.compareStart=function(row,column){return this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.compareEnd=function(row,column){return this.end.row==row&&this.end.column==column?1:this.compare(row,column)},this.compareInside=function(row,column){return this.end.row==row&&this.end.column==column?1:this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.clipRows=function(firstRow,lastRow){if(this.end.row>lastRow)var end={row:lastRow+1,column:0};else if(firstRow>this.end.row)var end={row:firstRow,column:0};if(this.start.row>lastRow)var start={row:lastRow+1,column:0};else if(firstRow>this.start.row)var start={row:firstRow,column:0};return Range.fromPoints(start||this.start,end||this.end)},this.extend=function(row,column){var cmp=this.compare(row,column);if(0==cmp)return this;if(-1==cmp)var start={row:row,column:column};else var end={row:row,column:column};return Range.fromPoints(start||this.start,end||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return Range.fromPoints(this.start,this.end)},this.collapseRows=function(){return 0==this.end.column?new Range(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new Range(this.start.row,0,this.end.row,0)},this.toScreenRange=function(session){var screenPosStart=session.documentToScreenPosition(this.start),screenPosEnd=session.documentToScreenPosition(this.end);return new Range(screenPosStart.row,screenPosStart.column,screenPosEnd.row,screenPosEnd.column)},this.moveBy=function(row,column){this.start.row+=row,this.start.column+=column,this.end.row+=row,this.end.column+=column}}).call(Range.prototype),Range.fromPoints=function(start,end){return new Range(start.row,start.column,end.row,end.column)},Range.comparePoints=comparePoints,Range.comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},exports.Range=Range}),ace.define("ace/apply_delta",["require","exports","module"],function(acequire,exports){"use strict";exports.applyDelta=function(docLines,delta){var row=delta.start.row,startColumn=delta.start.column,line=docLines[row]||"";switch(delta.action){case"insert":var lines=delta.lines;if(1===lines.length)docLines[row]=line.substring(0,startColumn)+delta.lines[0]+line.substring(startColumn);else{var args=[row,1].concat(delta.lines);docLines.splice.apply(docLines,args),docLines[row]=line.substring(0,startColumn)+docLines[row],docLines[row+delta.lines.length-1]+=line.substring(startColumn)}break;case"remove":var endColumn=delta.end.column,endRow=delta.end.row;row===endRow?docLines[row]=line.substring(0,startColumn)+line.substring(endColumn):docLines.splice(row,endRow-row+1,line.substring(0,startColumn)+docLines[endRow].substring(endColumn))}}}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(acequire,exports){"use strict";var EventEmitter={},stopPropagation=function(){this.propagationStopped=!0},preventDefault=function(){this.defaultPrevented=!0};EventEmitter._emit=EventEmitter._dispatchEvent=function(eventName,e){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var listeners=this._eventRegistry[eventName]||[],defaultHandler=this._defaultHandlers[eventName];if(listeners.length||defaultHandler){"object"==typeof e&&e||(e={}),e.type||(e.type=eventName),e.stopPropagation||(e.stopPropagation=stopPropagation),e.preventDefault||(e.preventDefault=preventDefault),listeners=listeners.slice();for(var i=0;listeners.length>i&&(listeners[i](e,this),!e.propagationStopped);i++);return defaultHandler&&!e.defaultPrevented?defaultHandler(e,this):void 0}},EventEmitter._signal=function(eventName,e){var listeners=(this._eventRegistry||{})[eventName];if(listeners){listeners=listeners.slice();for(var i=0;listeners.length>i;i++)listeners[i](e,this)}},EventEmitter.once=function(eventName,callback){var _self=this;callback&&this.addEventListener(eventName,function newCallback(){_self.removeEventListener(eventName,newCallback),callback.apply(null,arguments)})},EventEmitter.setDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers||(handlers=this._defaultHandlers={_disabled_:{}}),handlers[eventName]){var old=handlers[eventName],disabled=handlers._disabled_[eventName];disabled||(handlers._disabled_[eventName]=disabled=[]),disabled.push(old);var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}handlers[eventName]=callback},EventEmitter.removeDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers){var disabled=handlers._disabled_[eventName];if(handlers[eventName]==callback)handlers[eventName],disabled&&this.setDefaultHandler(eventName,disabled.pop());else if(disabled){var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}}},EventEmitter.on=EventEmitter.addEventListener=function(eventName,callback,capturing){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];return listeners||(listeners=this._eventRegistry[eventName]=[]),-1==listeners.indexOf(callback)&&listeners[capturing?"unshift":"push"](callback),callback},EventEmitter.off=EventEmitter.removeListener=EventEmitter.removeEventListener=function(eventName,callback){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];if(listeners){var index=listeners.indexOf(callback);-1!==index&&listeners.splice(index,1)}},EventEmitter.removeAllListeners=function(eventName){this._eventRegistry&&(this._eventRegistry[eventName]=[])},exports.EventEmitter=EventEmitter}),ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(acequire,exports){"use strict";var oop=acequire("./lib/oop"),EventEmitter=acequire("./lib/event_emitter").EventEmitter,Anchor=exports.Anchor=function(doc,row,column){this.$onChange=this.onChange.bind(this),this.attach(doc),column===void 0?this.setPosition(row.row,row.column):this.setPosition(row,column)};(function(){function $pointsInOrder(point1,point2,equalPointsInOrder){var bColIsAfter=equalPointsInOrder?point1.column<=point2.column:point1.columnthis.row)){var point=$getTransformedPoint(delta,{row:this.row,column:this.column},this.$insertRight);this.setPosition(point.row,point.column,!0)}},this.setPosition=function(row,column,noClip){var pos;if(pos=noClip?{row:row,column:column}:this.$clipPositionToDocument(row,column),this.row!=pos.row||this.column!=pos.column){var old={row:this.row,column:this.column};this.row=pos.row,this.column=pos.column,this._signal("change",{old:old,value:pos})}},this.detach=function(){this.document.removeEventListener("change",this.$onChange)},this.attach=function(doc){this.document=doc||this.document,this.document.on("change",this.$onChange)},this.$clipPositionToDocument=function(row,column){var pos={};return row>=this.document.getLength()?(pos.row=Math.max(0,this.document.getLength()-1),pos.column=this.document.getLine(pos.row).length):0>row?(pos.row=0,pos.column=0):(pos.row=row,pos.column=Math.min(this.document.getLine(pos.row).length,Math.max(0,column))),0>column&&(pos.column=0),pos}}).call(Anchor.prototype)}),ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"],function(acequire,exports){"use strict";var oop=acequire("./lib/oop"),applyDelta=acequire("./apply_delta").applyDelta,EventEmitter=acequire("./lib/event_emitter").EventEmitter,Range=acequire("./range").Range,Anchor=acequire("./anchor").Anchor,Document=function(textOrLines){this.$lines=[""],0===textOrLines.length?this.$lines=[""]:Array.isArray(textOrLines)?this.insertMergedLines({row:0,column:0},textOrLines):this.insert({row:0,column:0},textOrLines)};(function(){oop.implement(this,EventEmitter),this.setValue=function(text){var len=this.getLength()-1;this.remove(new Range(0,0,len,this.getLine(len).length)),this.insert({row:0,column:0},text)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(row,column){return new Anchor(this,row,column)},this.$split=0==="aaa".split(/a/).length?function(text){return text.replace(/\\r\\n|\\r/g,"\\n").split("\\n")}:function(text){return text.split(/\\r\\n|\\r|\\n/)},this.$detectNewLine=function(text){var match=text.match(/^.*?(\\r\\n|\\r|\\n)/m);this.$autoNewLine=match?match[1]:"\\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\\r\\n";case"unix":return"\\n";default:return this.$autoNewLine||"\\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(newLineMode){this.$newLineMode!==newLineMode&&(this.$newLineMode=newLineMode,this._signal("changeNewLineMode"))},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(text){return"\\r\\n"==text||"\\r"==text||"\\n"==text},this.getLine=function(row){return this.$lines[row]||""},this.getLines=function(firstRow,lastRow){return this.$lines.slice(firstRow,lastRow+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(range){return this.getLinesForRange(range).join(this.getNewLineCharacter())},this.getLinesForRange=function(range){var lines;if(range.start.row===range.end.row)lines=[this.getLine(range.start.row).substring(range.start.column,range.end.column)];else{lines=this.getLines(range.start.row,range.end.row),lines[0]=(lines[0]||"").substring(range.start.column);var l=lines.length-1;range.end.row-range.start.row==l&&(lines[l]=lines[l].substring(0,range.end.column))}return lines},this.insertLines=function(row,lines){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(row,lines)},this.removeLines=function(firstRow,lastRow){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(firstRow,lastRow)},this.insertNewLine=function(position){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead."),this.insertMergedLines(position,["",""])},this.insert=function(position,text){return 1>=this.getLength()&&this.$detectNewLine(text),this.insertMergedLines(position,this.$split(text))},this.insertInLine=function(position,text){var start=this.clippedPos(position.row,position.column),end=this.pos(position.row,position.column+text.length);return this.applyDelta({start:start,end:end,action:"insert",lines:[text]},!0),this.clonePos(end)},this.clippedPos=function(row,column){var length=this.getLength();void 0===row?row=length:0>row?row=0:row>=length&&(row=length-1,column=void 0);var line=this.getLine(row);return void 0==column&&(column=line.length),column=Math.min(Math.max(column,0),line.length),{row:row,column:column}},this.clonePos=function(pos){return{row:pos.row,column:pos.column}},this.pos=function(row,column){return{row:row,column:column}},this.$clipPosition=function(position){var length=this.getLength();return position.row>=length?(position.row=Math.max(0,length-1),position.column=this.getLine(length-1).length):(position.row=Math.max(0,position.row),position.column=Math.min(Math.max(position.column,0),this.getLine(position.row).length)),position},this.insertFullLines=function(row,lines){row=Math.min(Math.max(row,0),this.getLength());var column=0;this.getLength()>row?(lines=lines.concat([""]),column=0):(lines=[""].concat(lines),row--,column=this.$lines[row].length),this.insertMergedLines({row:row,column:column},lines)},this.insertMergedLines=function(position,lines){var start=this.clippedPos(position.row,position.column),end={row:start.row+lines.length-1,column:(1==lines.length?start.column:0)+lines[lines.length-1].length};return this.applyDelta({start:start,end:end,action:"insert",lines:lines}),this.clonePos(end)},this.remove=function(range){var start=this.clippedPos(range.start.row,range.start.column),end=this.clippedPos(range.end.row,range.end.column);return this.applyDelta({start:start,end:end,action:"remove",lines:this.getLinesForRange({start:start,end:end})}),this.clonePos(start)},this.removeInLine=function(row,startColumn,endColumn){var start=this.clippedPos(row,startColumn),end=this.clippedPos(row,endColumn);return this.applyDelta({start:start,end:end,action:"remove",lines:this.getLinesForRange({start:start,end:end})},!0),this.clonePos(start)},this.removeFullLines=function(firstRow,lastRow){firstRow=Math.min(Math.max(0,firstRow),this.getLength()-1),lastRow=Math.min(Math.max(0,lastRow),this.getLength()-1);var deleteFirstNewLine=lastRow==this.getLength()-1&&firstRow>0,deleteLastNewLine=this.getLength()-1>lastRow,startRow=deleteFirstNewLine?firstRow-1:firstRow,startCol=deleteFirstNewLine?this.getLine(startRow).length:0,endRow=deleteLastNewLine?lastRow+1:lastRow,endCol=deleteLastNewLine?0:this.getLine(endRow).length,range=new Range(startRow,startCol,endRow,endCol),deletedLines=this.$lines.slice(firstRow,lastRow+1);return this.applyDelta({start:range.start,end:range.end,action:"remove",lines:this.getLinesForRange(range)}),deletedLines},this.removeNewLine=function(row){this.getLength()-1>row&&row>=0&&this.applyDelta({start:this.pos(row,this.getLine(row).length),end:this.pos(row+1,0),action:"remove",lines:["",""]})},this.replace=function(range,text){if(range instanceof Range||(range=Range.fromPoints(range.start,range.end)),0===text.length&&range.isEmpty())return range.start;if(text==this.getTextRange(range))return range.end;this.remove(range);var end;return end=text?this.insert(range.start,text):range.start},this.applyDeltas=function(deltas){for(var i=0;deltas.length>i;i++)this.applyDelta(deltas[i])},this.revertDeltas=function(deltas){for(var i=deltas.length-1;i>=0;i--)this.revertDelta(deltas[i])},this.applyDelta=function(delta,doNotValidate){var isInsert="insert"==delta.action;(isInsert?1>=delta.lines.length&&!delta.lines[0]:!Range.comparePoints(delta.start,delta.end))||(isInsert&&delta.lines.length>2e4&&this.$splitAndapplyLargeDelta(delta,2e4),applyDelta(this.$lines,delta,doNotValidate),this._signal("change",delta))},this.$splitAndapplyLargeDelta=function(delta,MAX){for(var lines=delta.lines,l=lines.length,row=delta.start.row,column=delta.start.column,from=0,to=0;;){from=to,to+=MAX-1;var chunk=lines.slice(from,to);if(to>l){delta.lines=chunk,delta.start.row=row+from,delta.start.column=column;break}chunk.push(""),this.applyDelta({start:this.pos(row+from,column),end:this.pos(row+to,column=0),action:delta.action,lines:chunk},!0)}},this.revertDelta=function(delta){this.applyDelta({start:this.clonePos(delta.start),end:this.clonePos(delta.end),action:"insert"==delta.action?"remove":"insert",lines:delta.lines.slice()})},this.indexToPosition=function(index,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,i=startRow||0,l=lines.length;l>i;i++)if(index-=lines[i].length+newlineLength,0>index)return{row:i,column:index+lines[i].length+newlineLength};return{row:l-1,column:lines[l-1].length}},this.positionToIndex=function(pos,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,index=0,row=Math.min(pos.row,lines.length),i=startRow||0;row>i;++i)index+=lines[i].length+newlineLength;return index+pos.column}}).call(Document.prototype),exports.Document=Document}),ace.define("ace/lib/lang",["require","exports","module"],function(acequire,exports){"use strict";exports.last=function(a){return a[a.length-1]},exports.stringReverse=function(string){return string.split("").reverse().join("")},exports.stringRepeat=function(string,count){for(var result="";count>0;)1&count&&(result+=string),(count>>=1)&&(string+=string);return result};var trimBeginRegexp=/^\\s\\s*/,trimEndRegexp=/\\s\\s*$/;exports.stringTrimLeft=function(string){return string.replace(trimBeginRegexp,"")},exports.stringTrimRight=function(string){return string.replace(trimEndRegexp,"")},exports.copyObject=function(obj){var copy={};for(var key in obj)copy[key]=obj[key];return copy},exports.copyArray=function(array){for(var copy=[],i=0,l=array.length;l>i;i++)copy[i]=array[i]&&"object"==typeof array[i]?this.copyObject(array[i]):array[i];return copy},exports.deepCopy=function deepCopy(obj){if("object"!=typeof obj||!obj)return obj;var copy;if(Array.isArray(obj)){copy=[];for(var key=0;obj.length>key;key++)copy[key]=deepCopy(obj[key]);return copy}if("[object Object]"!==Object.prototype.toString.call(obj))return obj;copy={};for(var key in obj)copy[key]=deepCopy(obj[key]);return copy},exports.arrayToMap=function(arr){for(var map={},i=0;arr.length>i;i++)map[arr[i]]=1;return map},exports.createMap=function(props){var map=Object.create(null);for(var i in props)map[i]=props[i];return map},exports.arrayRemove=function(array,value){for(var i=0;array.length>=i;i++)value===array[i]&&array.splice(i,1)},exports.escapeRegExp=function(str){return str.replace(/([.*+?^${}()|[\\]\\/\\\\])/g,"\\\\$1")},exports.escapeHTML=function(str){return str.replace(/&/g,"&").replace(/"/g,""").replace(/\'/g,"'").replace(/i;i+=2){if(Array.isArray(data[i+1]))var d={action:"insert",start:data[i],lines:data[i+1]};else var d={action:"remove",start:data[i],end:data[i+1]};doc.applyDelta(d,!0)}return _self.$timeout?deferredUpdate.schedule(_self.$timeout):(_self.onUpdate(),void 0)})};(function(){this.$timeout=500,this.setTimeout=function(timeout){this.$timeout=timeout},this.setValue=function(value){this.doc.setValue(value),this.deferredUpdate.schedule(this.$timeout)},this.getValue=function(callbackId){this.sender.callback(this.doc.getValue(),callbackId)},this.onUpdate=function(){},this.isPending=function(){return this.deferredUpdate.isPending()}}).call(Mirror.prototype)}),ace.define("ace/mode/json/json_parse",["require","exports","module"],function(){"use strict";var at,ch,text,value,escapee={\'"\':\'"\',"\\\\":"\\\\","/":"/",b:"\\b",f:"\\f",n:"\\n",r:"\\r",t:"\t"},error=function(m){throw{name:"SyntaxError",message:m,at:at,text:text}},next=function(c){return c&&c!==ch&&error("Expected \'"+c+"\' instead of \'"+ch+"\'"),ch=text.charAt(at),at+=1,ch},number=function(){var number,string="";for("-"===ch&&(string="-",next("-"));ch>="0"&&"9">=ch;)string+=ch,next();if("."===ch)for(string+=".";next()&&ch>="0"&&"9">=ch;)string+=ch;if("e"===ch||"E"===ch)for(string+=ch,next(),("-"===ch||"+"===ch)&&(string+=ch,next());ch>="0"&&"9">=ch;)string+=ch,next();return number=+string,isNaN(number)?(error("Bad number"),void 0):number},string=function(){var hex,i,uffff,string="";if(\'"\'===ch)for(;next();){if(\'"\'===ch)return next(),string;if("\\\\"===ch)if(next(),"u"===ch){for(uffff=0,i=0;4>i&&(hex=parseInt(next(),16),isFinite(hex));i+=1)uffff=16*uffff+hex;string+=String.fromCharCode(uffff)}else{if("string"!=typeof escapee[ch])break;string+=escapee[ch]}else string+=ch}error("Bad string")},white=function(){for(;ch&&" ">=ch;)next()},word=function(){switch(ch){case"t":return next("t"),next("r"),next("u"),next("e"),!0;case"f":return next("f"),next("a"),next("l"),next("s"),next("e"),!1;case"n":return next("n"),next("u"),next("l"),next("l"),null}error("Unexpected \'"+ch+"\'")},array=function(){var array=[];if("["===ch){if(next("["),white(),"]"===ch)return next("]"),array;for(;ch;){if(array.push(value()),white(),"]"===ch)return next("]"),array;next(","),white()}}error("Bad array")},object=function(){var key,object={};if("{"===ch){if(next("{"),white(),"}"===ch)return next("}"),object;for(;ch;){if(key=string(),white(),next(":"),Object.hasOwnProperty.call(object,key)&&error(\'Duplicate key "\'+key+\'"\'),object[key]=value(),white(),"}"===ch)return next("}"),object;next(","),white()}}error("Bad object")};return value=function(){switch(white(),ch){case"{":return object();case"[":return array();case\'"\':return string();case"-":return number();default:return ch>="0"&&"9">=ch?number():word()}},function(source,reviver){var result;return text=source,at=0,ch=" ",result=value(),white(),ch&&error("Syntax error"),"function"==typeof reviver?function walk(holder,key){var k,v,value=holder[key];if(value&&"object"==typeof value)for(k in value)Object.hasOwnProperty.call(value,k)&&(v=walk(value,k),void 0!==v?value[k]=v:delete value[k]);return reviver.call(holder,key,value)}({"":result},""):result}}),ace.define("ace/mode/json_worker",["require","exports","module","ace/lib/oop","ace/worker/mirror","ace/mode/json/json_parse"],function(acequire,exports){"use strict";var oop=acequire("../lib/oop"),Mirror=acequire("../worker/mirror").Mirror,parse=acequire("./json/json_parse"),JsonWorker=exports.JsonWorker=function(sender){Mirror.call(this,sender),this.setTimeout(200)};oop.inherits(JsonWorker,Mirror),function(){this.onUpdate=function(){var value=this.doc.getValue(),errors=[];try{value&&parse(value)}catch(e){var pos=this.doc.indexToPosition(e.at-1);errors.push({row:pos.row,column:pos.column,text:e.message,type:"error"})}this.sender.emit("annotate",errors)}}.call(JsonWorker.prototype)}),ace.define("ace/lib/es5-shim",["require","exports","module"],function(){function Empty(){}function doesDefinePropertyWork(object){try{return Object.defineProperty(object,"sentinel",{}),"sentinel"in object}catch(exception){}}function toInteger(n){return n=+n,n!==n?n=0:0!==n&&n!==1/0&&n!==-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n))),n}Function.prototype.bind||(Function.prototype.bind=function(that){var target=this;if("function"!=typeof target)throw new TypeError("Function.prototype.bind called on incompatible "+target);var args=slice.call(arguments,1),bound=function(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));return Object(result)===result?result:this}return target.apply(that,args.concat(slice.call(arguments)))};return target.prototype&&(Empty.prototype=target.prototype,bound.prototype=new Empty,Empty.prototype=null),bound});var defineGetter,defineSetter,lookupGetter,lookupSetter,supportsAccessors,call=Function.prototype.call,prototypeOfArray=Array.prototype,prototypeOfObject=Object.prototype,slice=prototypeOfArray.slice,_toString=call.bind(prototypeOfObject.toString),owns=call.bind(prototypeOfObject.hasOwnProperty);if((supportsAccessors=owns(prototypeOfObject,"__defineGetter__"))&&(defineGetter=call.bind(prototypeOfObject.__defineGetter__),defineSetter=call.bind(prototypeOfObject.__defineSetter__),lookupGetter=call.bind(prototypeOfObject.__lookupGetter__),lookupSetter=call.bind(prototypeOfObject.__lookupSetter__)),2!=[1,2].splice(0).length)if(function(){function makeArray(l){var a=Array(l+2);return a[0]=a[1]=0,a}var lengthBefore,array=[];return array.splice.apply(array,makeArray(20)),array.splice.apply(array,makeArray(26)),lengthBefore=array.length,array.splice(5,0,"XXX"),lengthBefore+1==array.length,lengthBefore+1==array.length?!0:void 0\n}()){var array_splice=Array.prototype.splice;Array.prototype.splice=function(start,deleteCount){return arguments.length?array_splice.apply(this,[void 0===start?0:start,void 0===deleteCount?this.length-start:deleteCount].concat(slice.call(arguments,2))):[]}}else Array.prototype.splice=function(pos,removeCount){var length=this.length;pos>0?pos>length&&(pos=length):void 0==pos?pos=0:0>pos&&(pos=Math.max(length+pos,0)),length>pos+removeCount||(removeCount=length-pos);var removed=this.slice(pos,pos+removeCount),insert=slice.call(arguments,2),add=insert.length;if(pos===length)add&&this.push.apply(this,insert);else{var remove=Math.min(removeCount,length-pos),tailOldPos=pos+remove,tailNewPos=tailOldPos+add-remove,tailCount=length-tailOldPos,lengthAfterRemove=length-remove;if(tailOldPos>tailNewPos)for(var i=0;tailCount>i;++i)this[tailNewPos+i]=this[tailOldPos+i];else if(tailNewPos>tailOldPos)for(i=tailCount;i--;)this[tailNewPos+i]=this[tailOldPos+i];if(add&&pos===lengthAfterRemove)this.length=lengthAfterRemove,this.push.apply(this,insert);else for(this.length=lengthAfterRemove+add,i=0;add>i;++i)this[pos+i]=insert[i]}return removed};Array.isArray||(Array.isArray=function(obj){return"[object Array]"==_toString(obj)});var boxedString=Object("a"),splitString="a"!=boxedString[0]||!(0 in boxedString);if(Array.prototype.forEach||(Array.prototype.forEach=function(fun){var object=toObject(this),self=splitString&&"[object String]"==_toString(this)?this.split(""):object,thisp=arguments[1],i=-1,length=self.length>>>0;if("[object Function]"!=_toString(fun))throw new TypeError;for(;length>++i;)i in self&&fun.call(thisp,self[i],i,object)}),Array.prototype.map||(Array.prototype.map=function(fun){var object=toObject(this),self=splitString&&"[object String]"==_toString(this)?this.split(""):object,length=self.length>>>0,result=Array(length),thisp=arguments[1];if("[object Function]"!=_toString(fun))throw new TypeError(fun+" is not a function");for(var i=0;length>i;i++)i in self&&(result[i]=fun.call(thisp,self[i],i,object));return result}),Array.prototype.filter||(Array.prototype.filter=function(fun){var value,object=toObject(this),self=splitString&&"[object String]"==_toString(this)?this.split(""):object,length=self.length>>>0,result=[],thisp=arguments[1];if("[object Function]"!=_toString(fun))throw new TypeError(fun+" is not a function");for(var i=0;length>i;i++)i in self&&(value=self[i],fun.call(thisp,value,i,object)&&result.push(value));return result}),Array.prototype.every||(Array.prototype.every=function(fun){var object=toObject(this),self=splitString&&"[object String]"==_toString(this)?this.split(""):object,length=self.length>>>0,thisp=arguments[1];if("[object Function]"!=_toString(fun))throw new TypeError(fun+" is not a function");for(var i=0;length>i;i++)if(i in self&&!fun.call(thisp,self[i],i,object))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(fun){var object=toObject(this),self=splitString&&"[object String]"==_toString(this)?this.split(""):object,length=self.length>>>0,thisp=arguments[1];if("[object Function]"!=_toString(fun))throw new TypeError(fun+" is not a function");for(var i=0;length>i;i++)if(i in self&&fun.call(thisp,self[i],i,object))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(fun){var object=toObject(this),self=splitString&&"[object String]"==_toString(this)?this.split(""):object,length=self.length>>>0;if("[object Function]"!=_toString(fun))throw new TypeError(fun+" is not a function");if(!length&&1==arguments.length)throw new TypeError("reduce of empty array with no initial value");var result,i=0;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i++];break}if(++i>=length)throw new TypeError("reduce of empty array with no initial value")}for(;length>i;i++)i in self&&(result=fun.call(void 0,result,self[i],i,object));return result}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(fun){var object=toObject(this),self=splitString&&"[object String]"==_toString(this)?this.split(""):object,length=self.length>>>0;if("[object Function]"!=_toString(fun))throw new TypeError(fun+" is not a function");if(!length&&1==arguments.length)throw new TypeError("reduceRight of empty array with no initial value");var result,i=length-1;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i--];break}if(0>--i)throw new TypeError("reduceRight of empty array with no initial value")}do i in this&&(result=fun.call(void 0,result,self[i],i,object));while(i--);return result}),Array.prototype.indexOf&&-1==[0,1].indexOf(1,2)||(Array.prototype.indexOf=function(sought){var self=splitString&&"[object String]"==_toString(this)?this.split(""):toObject(this),length=self.length>>>0;if(!length)return-1;var i=0;for(arguments.length>1&&(i=toInteger(arguments[1])),i=i>=0?i:Math.max(0,length+i);length>i;i++)if(i in self&&self[i]===sought)return i;return-1}),Array.prototype.lastIndexOf&&-1==[0,1].lastIndexOf(0,-3)||(Array.prototype.lastIndexOf=function(sought){var self=splitString&&"[object String]"==_toString(this)?this.split(""):toObject(this),length=self.length>>>0;if(!length)return-1;var i=length-1;for(arguments.length>1&&(i=Math.min(i,toInteger(arguments[1]))),i=i>=0?i:length-Math.abs(i);i>=0;i--)if(i in self&&sought===self[i])return i;return-1}),Object.getPrototypeOf||(Object.getPrototypeOf=function(object){return object.__proto__||(object.constructor?object.constructor.prototype:prototypeOfObject)}),!Object.getOwnPropertyDescriptor){var ERR_NON_OBJECT="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function(object,property){if("object"!=typeof object&&"function"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT+object);if(owns(object,property)){var descriptor,getter,setter;if(descriptor={enumerable:!0,configurable:!0},supportsAccessors){var prototype=object.__proto__;object.__proto__=prototypeOfObject;var getter=lookupGetter(object,property),setter=lookupSetter(object,property);if(object.__proto__=prototype,getter||setter)return getter&&(descriptor.get=getter),setter&&(descriptor.set=setter),descriptor}return descriptor.value=object[property],descriptor}}}if(Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(object){return Object.keys(object)}),!Object.create){var createEmpty;createEmpty=null===Object.prototype.__proto__?function(){return{__proto__:null}}:function(){var empty={};for(var i in empty)empty[i]=null;return empty.constructor=empty.hasOwnProperty=empty.propertyIsEnumerable=empty.isPrototypeOf=empty.toLocaleString=empty.toString=empty.valueOf=empty.__proto__=null,empty},Object.create=function(prototype,properties){var object;if(null===prototype)object=createEmpty();else{if("object"!=typeof prototype)throw new TypeError("typeof prototype["+typeof prototype+"] != \'object\'");var Type=function(){};Type.prototype=prototype,object=new Type,object.__proto__=prototype}return void 0!==properties&&Object.defineProperties(object,properties),object}}if(Object.defineProperty){var definePropertyWorksOnObject=doesDefinePropertyWork({}),definePropertyWorksOnDom="undefined"==typeof document||doesDefinePropertyWork(document.createElement("div"));if(!definePropertyWorksOnObject||!definePropertyWorksOnDom)var definePropertyFallback=Object.defineProperty}if(!Object.defineProperty||definePropertyFallback){var ERR_NON_OBJECT_DESCRIPTOR="Property description must be an object: ",ERR_NON_OBJECT_TARGET="Object.defineProperty called on non-object: ",ERR_ACCESSORS_NOT_SUPPORTED="getters & setters can not be defined on this javascript engine";Object.defineProperty=function(object,property,descriptor){if("object"!=typeof object&&"function"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT_TARGET+object);if("object"!=typeof descriptor&&"function"!=typeof descriptor||null===descriptor)throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR+descriptor);if(definePropertyFallback)try{return definePropertyFallback.call(Object,object,property,descriptor)}catch(exception){}if(owns(descriptor,"value"))if(supportsAccessors&&(lookupGetter(object,property)||lookupSetter(object,property))){var prototype=object.__proto__;object.__proto__=prototypeOfObject,delete object[property],object[property]=descriptor.value,object.__proto__=prototype}else object[property]=descriptor.value;else{if(!supportsAccessors)throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);owns(descriptor,"get")&&defineGetter(object,property,descriptor.get),owns(descriptor,"set")&&defineSetter(object,property,descriptor.set)}return object}}Object.defineProperties||(Object.defineProperties=function(object,properties){for(var property in properties)owns(properties,property)&&Object.defineProperty(object,property,properties[property]);return object}),Object.seal||(Object.seal=function(object){return object}),Object.freeze||(Object.freeze=function(object){return object});try{Object.freeze(function(){})}catch(exception){Object.freeze=function(freezeObject){return function(object){return"function"==typeof object?object:freezeObject(object)}}(Object.freeze)}if(Object.preventExtensions||(Object.preventExtensions=function(object){return object}),Object.isSealed||(Object.isSealed=function(){return!1}),Object.isFrozen||(Object.isFrozen=function(){return!1}),Object.isExtensible||(Object.isExtensible=function(object){if(Object(object)===object)throw new TypeError;for(var name="";owns(object,name);)name+="?";object[name]=!0;var returnValue=owns(object,name);return delete object[name],returnValue}),!Object.keys){var hasDontEnumBug=!0,dontEnums=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],dontEnumsLength=dontEnums.length;for(var key in{toString:null})hasDontEnumBug=!1;Object.keys=function(object){if("object"!=typeof object&&"function"!=typeof object||null===object)throw new TypeError("Object.keys called on a non-object");var keys=[];for(var name in object)owns(object,name)&&keys.push(name);if(hasDontEnumBug)for(var i=0,ii=dontEnumsLength;ii>i;i++){var dontEnum=dontEnums[i];owns(object,dontEnum)&&keys.push(dontEnum)}return keys}}Date.now||(Date.now=function(){return(new Date).getTime()});var ws="\t\\n\v\\f\\r   ᠎              \\u2028\\u2029\ufeff";if(!String.prototype.trim||ws.trim()){ws="["+ws+"]";var trimBeginRegexp=RegExp("^"+ws+ws+"*"),trimEndRegexp=RegExp(ws+ws+"*$");String.prototype.trim=function(){return(this+"").replace(trimBeginRegexp,"").replace(trimEndRegexp,"")}}var toObject=function(o){if(null==o)throw new TypeError("can\'t convert "+o+" to object");return Object(o)}});'},39:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=i(21),n=i(2),r=a.__importDefault(i(40));t.default=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=[]);var a=r.default(e,t),s=a[0],o=a[1],l=a[2];return n.useEffect(l,i),[s,o]}},40:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=i(2);t.default=function(e,t){void 0===t&&(t=0);var i=a.useRef(!1),n=a.useRef(),r=a.useRef(e),s=a.useCallback((function(){return i.current}),[]),o=a.useCallback((function(){i.current=!1,n.current&&clearTimeout(n.current),n.current=setTimeout((function(){i.current=!0,r.current()}),t)}),[t]),l=a.useCallback((function(){i.current=null,n.current&&clearTimeout(n.current)}),[]);return a.useEffect((function(){r.current=e}),[e]),a.useEffect((function(){return o(),l}),[t]),[s,l,o]}},41:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=i(21),n=i(2),r=a.__importDefault(i(31));t.default=function(e){var t=n.useRef(e);t.current=e,r.default((function(){return function(){return t.current()}}))}},42:function(e,t,i){"use strict";i.r(t),i.d(t,"default",(function(){return Gt})),i(32),i(37);var a=i(2),n=i.n(a),r=i(1),s=i(7),o=i(22),l=i(10),c=i.n(l),d=i(6),u=i(3),g=i(0);function p({setSelectedTab:e,optionTabs:t}){return Object(g.jsx)(r.EuiTabs,{className:"visEditorSidebar__nav",size:"s"},t.map((({name:t,title:i,isSelected:a=!1})=>Object(g.jsx)(r.EuiTab,{key:t,isSelected:a,"data-test-subj":`visEditorTab__${t}`,onClick:()=>e(t)},i))))}var m=i(4),f=i(39),b=i.n(f),h=i(20);let v;!function(e){e.ADD_NEW_AGG="ADD_NEW_AGG",e.DISCARD_CHANGES="DISCARD_CHANGES",e.CHANGE_AGG_TYPE="CHANGE_AGG_TYPE",e.SET_AGG_PARAM_VALUE="SET_AGG_PARAM_VALUE",e.SET_STATE_PARAM_VALUE="SET_STATE_PARAM_VALUE",e.TOGGLE_ENABLED_AGG="TOGGLE_ENABLED_AGG",e.REMOVE_AGG="REMOVE_AGG",e.REORDER_AGGS="REORDER_AGGS",e.UPDATE_STATE_PARAMS="UPDATE_STATE_PARAMS"}(v||(v={}));const j=(e,t)=>e.find((e=>e.name===t))||{},x=(e,t,i)=>{const a=j(i,e.schema);return t.reduce(((t,i)=>i.schema===e.schema?++t:t),0)>a.min},E=e=>e.reduce(((e,t)=>"metric"===t.schema&&t.enabled?++e:e),0),y=(e,t,i,a)=>{if(!j(a,e.schema).mustBeFirst)return!1;const n=Object(d.findIndex)(i,(t=>t.schema!==e.schema));return-1!==n&&t>n};function w(e){return{...e.clone()}}const O=({aggs:{createAggConfigs:e}})=>(t,i)=>{switch(i.type){case v.ADD_NEW_AGG:{const{schema:a}=i.payload,n=!t.data.aggs.aggs.find((e=>e.schema===a.name))&&a.defaults?a.defaults.slice(0,a.max):{schema:a.name},r=t.data.aggs.createAggConfig(n,{addToAggConfigs:!1});r.brandNew=!0;const s=[...t.data.aggs.aggs,r];return{...t,data:{...t.data,aggs:e(t.data.indexPattern,s)}}}case v.DISCARD_CHANGES:return w(i.payload.vis);case v.CHANGE_AGG_TYPE:{const{aggId:a,value:n}=i.payload,r=t.data.aggs.aggs.map((e=>e.id===a?(e.type=n,e.serialize()):e));return{...t,data:{...t.data,aggs:e(t.data.indexPattern,r)}}}case v.SET_AGG_PARAM_VALUE:{const{aggId:a,paramName:n,value:r}=i.payload,s=t.data.aggs.aggs.map((e=>{if(e.id===a){const t=e.serialize();return{...t,params:{...t.params,[n]:r}}}return e}));return{...t,data:{...t.data,aggs:e(t.data.indexPattern,s)}}}case v.SET_STATE_PARAM_VALUE:{const{paramName:e,value:a}=i.payload;return{...t,params:{...t.params,[e]:a}}}case v.REMOVE_AGG:{let a=!1;const n=t.data.aggs.aggs.filter((({id:e,schema:t})=>{if(e===i.payload.aggId){const e=i.payload.schemas.find((e=>e.name===t));return e&&e.group===h.AggGroupNames.Metrics&&(a=!0),!1}return!0}));if(a&&0===E(n)){const e=n.find((e=>"metric"===e.schema));e&&(e.enabled=!0)}return{...t,data:{...t.data,aggs:e(t.data.indexPattern,n)}}}case v.REORDER_AGGS:{const{sourceAgg:a,destinationAgg:n}=i.payload,r=t.data.aggs.aggs.indexOf(n),s=[...t.data.aggs.aggs];return s.splice(r,0,s.splice(t.data.aggs.aggs.indexOf(a),1)[0]),{...t,data:{...t.data,aggs:e(t.data.indexPattern,s)}}}case v.TOGGLE_ENABLED_AGG:{const{aggId:a,enabled:n}=i.payload,r=t.data.aggs.aggs.map((e=>e.id===a?{...e.serialize(),enabled:n}:e));return{...t,data:{...t.data,aggs:e(t.data.indexPattern,r)}}}case v.UPDATE_STATE_PARAMS:{const{params:e}=i.payload;return{...t,params:Object(d.cloneDeep)(e)}}}},_={validity:{},touched:!1,invalid:!1},S=e=>({type:v.ADD_NEW_AGG,payload:{schema:e}}),T=e=>({type:v.DISCARD_CHANGES,payload:{vis:e}}),k=(e,t)=>({type:v.CHANGE_AGG_TYPE,payload:{aggId:e,value:t}}),A=(e,t,i)=>({type:v.SET_AGG_PARAM_VALUE,payload:{aggId:e,paramName:t,value:i}}),C=(e,t)=>({type:v.SET_STATE_PARAM_VALUE,payload:{paramName:e,value:t}}),M=(e,t)=>({type:v.REMOVE_AGG,payload:{aggId:e,schemas:t}}),I=(e,t)=>({type:v.REORDER_AGGS,payload:{sourceAgg:e,destinationAgg:t}}),R=(e,t)=>({type:v.TOGGLE_ENABLED_AGG,payload:{aggId:e,enabled:t}});function L({applyChanges:e,isDirty:t,isInvalid:i,isTouched:n,dispatch:s,vis:o}){const{enableAutoApply:l}=o.type.editorConfig,[c,d]=Object(a.useState)(!1),p=Object(a.useCallback)((e=>d(e)),[]),f=Object(a.useCallback)((()=>s(T(o))),[s,o]);return b()((()=>{c&&t&&e()}),300,[t,c,e]),Object(g.jsx)("div",{className:"visEditorSidebar__controls"},!c&&Object(g.jsx)(r.EuiFlexGroup,{justifyContent:"spaceBetween",gutterSize:"none",responsive:!1},Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiButtonEmpty,{"data-test-subj":"visualizeEditorResetButton",disabled:!t,iconType:"cross",onClick:f,size:"s"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.sidebar.discardChangesButtonLabel",defaultMessage:"Discard"}))),Object(g.jsx)(r.EuiFlexItem,{grow:!1},i&&n?Object(g.jsx)(r.EuiToolTip,{content:u.i18n.translate("visDefaultEditor.sidebar.errorButtonTooltip",{defaultMessage:"Errors in the highlighted fields need to be resolved."})},Object(g.jsx)(r.EuiButton,{color:"danger",iconType:"warning",size:"s",disabled:!0},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.sidebar.updateChartButtonLabel",defaultMessage:"Update"}))):Object(g.jsx)(r.EuiFlexGroup,{alignItems:"center",gutterSize:"s",responsive:!1},Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiIconTip,{content:u.i18n.translate("visDefaultEditor.sidebar.updateInfoTooltip",{defaultMessage:"CTRL + Enter is a shortcut for Update."}),type:"keyboard",color:"subdued"})),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiButton,{"data-test-subj":"visualizeEditorRenderButton",disabled:!t,fill:!0,iconType:"play",onClick:e,size:"s"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.sidebar.updateChartButtonLabel",defaultMessage:"Update"})))))),l&&Object(g.jsx)(r.EuiToolTip,{title:c?u.i18n.translate("visDefaultEditor.sidebar.autoApplyChangesOnLabel",{defaultMessage:"Auto apply is on"}):u.i18n.translate("visDefaultEditor.sidebar.autoApplyChangesOffLabel",{defaultMessage:"Auto apply is off"}),content:u.i18n.translate("visDefaultEditor.sidebar.autoApplyChangesTooltip",{defaultMessage:"Auto updates the visualization on every change."})},Object(g.jsx)(r.EuiButton,{className:"visEditorSidebar__autoApplyButton","data-test-subj":"visualizeEditorAutoButton",iconType:"refresh",color:c?"primary":"text",fill:!0,onClick:()=>p(!c),size:"s",minWidth:80,"aria-label":c?u.i18n.translate("visDefaultEditor.sidebar.autoApplyChangesLabelOn",{defaultMessage:"Auto apply is on"}):u.i18n.translate("visDefaultEditor.sidebar.autoApplyChangesLabelOff",{defaultMessage:"Auto apply is off"})},c?u.i18n.translate("visDefaultEditor.sidebar.autoApplyChangesOn",{defaultMessage:"On"}):u.i18n.translate("visDefaultEditor.sidebar.autoApplyChangesOff",{defaultMessage:"Off"}))))}var P=i(23);function D({savedSearch:e,eventEmitter:t}){const[i,n]=Object(a.useState)(!1),{services:{application:o}}=Object(s.useKibana)(),l=Object(a.useCallback)((()=>n(!1)),[]),c=Object(a.useCallback)((()=>n((e=>!e))),[]),d=Object(a.useCallback)((()=>{n(!1),t.emit("unlinkFromSavedSearch")}),[t]),p=Object(a.useCallback)((()=>{o.navigateToApp("discover",{path:Object(P.getSavedSearchUrl)(e.id)})}),[o,e.id]),f=u.i18n.translate("visDefaultEditor.sidebar.savedSearch.linkButtonAriaLabel",{defaultMessage:"Link to saved search. Click to learn more or break link."});return Object(g.jsx)(r.EuiFlexGroup,{alignItems:"center",className:"visEditorSidebar__titleContainer visEditorSidebar__linkedSearch",gutterSize:"xs",responsive:!1},Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiIcon,{type:"search"})),Object(g.jsx)(r.EuiFlexItem,{grow:!1,className:"eui-textTruncate"},Object(g.jsx)(r.EuiTitle,{size:"xs",className:"eui-textTruncate"},Object(g.jsx)("h2",{title:u.i18n.translate("visDefaultEditor.sidebar.savedSearch.titleAriaLabel",{defaultMessage:"Saved search: {title}",values:{title:e.title}})},e.title))),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiPopover,{anchorPosition:"downRight",button:Object(g.jsx)(r.EuiToolTip,{content:f},Object(g.jsx)(r.EuiButtonIcon,{"aria-label":f,"data-test-subj":"showUnlinkSavedSearchPopover",iconType:"link",onClick:c})),isOpen:i,closePopover:l,panelPaddingSize:"s"},Object(g.jsx)(r.EuiPopoverTitle,null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.sidebar.savedSearch.popoverTitle",defaultMessage:"Linked to saved search"})),Object(g.jsx)("div",{style:{width:260}},Object(g.jsx)(r.EuiText,{size:"s"},Object(g.jsx)("p",null,Object(g.jsx)(r.EuiButtonEmpty,{"data-test-subj":"viewSavedSearch",flush:"left",onClick:p,size:"xs"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.sidebar.savedSearch.goToDiscoverButtonText",defaultMessage:"View this search in Discover"}))),Object(g.jsx)("p",null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.sidebar.savedSearch.popoverHelpText",defaultMessage:"Subsequent modifications to this saved search are reflected in the visualization. To disable automatic updates, remove the link."})),Object(g.jsx)("p",null,Object(g.jsx)(r.EuiButton,{color:"danger","data-test-subj":"unlinkSavedSearch",fullWidth:!0,onClick:d,size:"s"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.sidebar.savedSearch.unlinkSavedSearchButtonText",defaultMessage:"Remove link to saved search"}))))))))}function F({savedSearch:e,vis:t,isLinkedSearch:i,eventEmitter:a}){var n,s,o,l;return i&&e?Object(g.jsx)(D,{savedSearch:e,eventEmitter:a}):t.type.options.showIndexSelection?Object(g.jsx)(r.EuiTitle,{size:"xs",className:"visEditorSidebar__titleContainer eui-textTruncate"},Object(g.jsx)("h2",{title:u.i18n.translate("visDefaultEditor.sidebar.indexPatternAriaLabel",{defaultMessage:"Index pattern: {title}",values:{title:null===(n=t.data)||void 0===n||null===(s=n.indexPattern)||void 0===s?void 0:s.getName()}})},null===(o=t.data)||void 0===o||null===(l=o.indexPattern)||void 0===l?void 0:l.getName())):Object(g.jsx)("div",{className:"visEditorSidebar__indexPatternPlaceholder"})}var N=i(41),B=i.n(N);let V,z;function G(e,t){switch(t.type){case V.TOUCHED:return{...e,touched:t.payload};case V.VALID:return{...e,valid:t.payload};default:throw new Error}}function $(e,{type:t,paramName:i="",payload:a}){const n=e[i]||{valid:!0,touched:!1};switch(t){case z.TOUCHED:return{...e,[i]:{...n,touched:a}};case z.VALID:return{...e,[i]:{...n,valid:a}};case z.RESET:return{};default:throw new Error}}function q(e){return e.reduce(((e,t)=>(e[t.aggParam.name]={valid:!0,touched:!1},e)),{})}function W({aggError:e,id:t,indexPattern:i,value:n,setValue:o,aggTypeOptions:l,showValidation:c,isSubAggregation:p,onChangeAggType:f}){const[b,h]=Object(a.useState)(!1),{services:v}=Object(s.useKibana)(),j=n?[{label:n.title,target:n}]:[],x=p?Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.aggSelect.subAggregationLabel",defaultMessage:"Sub aggregation"}):Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.aggSelect.aggregationLabel",defaultMessage:"Aggregation"});let E;Object(d.has)(n,"name")&&(E=v.docLinks.links.aggs[n.name]);const y=n&&E&&Object(g.jsx)(r.EuiText,{size:"xs"},Object(g.jsx)(r.EuiLink,{href:E,target:"_blank",rel:"noopener"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.aggSelect.helpLinkLabel",defaultMessage:"{aggTitle} help",values:{aggTitle:n?n.title:""}}))),w=e?[e]:[];l.length||w.push(u.i18n.translate("visDefaultEditor.aggSelect.noCompatibleAggsDescription",{defaultMessage:"The index pattern {indexPatternTitle} does not have any aggregatable fields.",values:{indexPatternTitle:i&&i.title}}));const O=!!n&&!w.length&&!b,_=Object(a.useCallback)((e=>{const t=Object(d.get)(e,"0.target");t&&o(t)}),[o]),S=Object(a.useCallback)((e=>h(Boolean(e))),[]),T=Object(a.useCallback)((()=>f({type:V.TOUCHED,payload:!0})),[f]),k=Object(a.useCallback)((e=>f({type:V.VALID,payload:e})),[f]);return Object(a.useEffect)((()=>{k(O)}),[O,k]),Object(a.useEffect)((()=>{w.length&&T()}),[w.length,T]),Object(g.jsx)(r.EuiFormRow,{label:x,labelAppend:y,error:w,isInvalid:!!c&&!O,fullWidth:!0,display:"rowCompressed"},Object(g.jsx)(r.EuiComboBox,{placeholder:u.i18n.translate("visDefaultEditor.aggSelect.selectAggPlaceholder",{defaultMessage:"Select an aggregation"}),id:`visDefaultEditorAggSelect${t}`,isDisabled:!l.length,options:l,selectedOptions:j,singleSelection:{asPlainText:!0},onBlur:T,onChange:_,onSearchChange:S,"data-test-subj":"defaultEditorAggSelect",isClearable:!1,isInvalid:!!c&&!O,fullWidth:!0,sortMatchesBy:"startsWith",compressed:!0}))}function U(e){const{agg:t,aggParam:i,paramEditor:n,setAggParamValue:r,onChangeParamsState:s,...o}=e,l=Object(a.useCallback)((e=>{s({type:z.VALID,paramName:i.name,payload:e})}),[s,i.name]),d=Object(a.useCallback)(((e=!0)=>{s({type:z.TOUCHED,paramName:i.name,payload:e})}),[s,i.name]),u=Object(a.useCallback)((a=>{e.value!==a&&r(t.id,i.name,a)}),[r,t.id,i.name,e.value]);return Object(a.useEffect)((()=>{i.shouldShow&&!i.shouldShow(t)&&l(!0)}),[t,t.params.field,i,l]),i.shouldShow&&!i.shouldShow(t)?null:Object(g.jsx)(n,c()({agg:t,aggParam:i,setValidity:l,setTouched:d,setValue:u},o))}!function(e){e.TOUCHED="aggTypeTouched",e.VALID="aggTypeValid"}(V||(V={})),function(e){e.TOUCHED="aggParamsTouched",e.VALID="aggParamsValid",e.RESET="aggParamsReset"}(z||(z={}));const{propFilter:H}=h.search.aggs,K=H("name"),J=[(e,t,i,a)=>0!==K([e],a).length,(e,t,i,a)=>{const n=t.getAggregationRestrictions();if(!n)return!0;const r=e.name;return"count"===r||!!n&&Object.keys(n).includes(r)||!1}],Y=[(e,t)=>{const i=t.getIndexPattern().getAggregationRestrictions();if(!i)return!0;const a=i[t.type&&t.type.name];return!!a&&!!a[e.name]}];var X=i(12),Q=i(24),Z=i.n(Q),ee=i(28),te=i.n(ee);const ie=Object(r.htmlIdGenerator)(),ae=(e="")=>{if(!e)return!0;const t=Z.a.parse(e);return t&&t.isValid()};function ne({value:e=!1,setValue:t,dataTestSubj:i,displayToolTip:a,displayLabel:n,disabled:s}){return Object(g.jsx)(r.EuiFormRow,{fullWidth:!0},Object(g.jsx)(r.EuiToolTip,{content:a,delay:"long",position:"right"},Object(g.jsx)(r.EuiSwitch,{compressed:!0,label:n,checked:e,disabled:s,"data-test-subj":i,onChange:e=>t(e.target.checked)})))}var re=i(11);const se=u.i18n.translate("visDefaultEditor.controls.field.fieldLabel",{defaultMessage:"Field"});function oe({agg:e,aggParam:t,customError:i,customLabel:n,indexedFields:s=[],showValidation:o,value:l,setTouched:c,setValidity:p,setValue:m}){const[f,b]=Object(a.useState)(!1),v=l?[{label:l.displayName,target:l,key:l.name}]:[],j=i?[i]:[];let x=!1;s.length||j.push(u.i18n.translate("visDefaultEditor.controls.field.noCompatibleFieldsDescription",{defaultMessage:"The index pattern {indexPatternTitle} does not contain any of the following compatible field types: {fieldTypes}",values:{indexPatternTitle:e.getIndexPattern&&e.getIndexPattern().title,fieldTypes:le(e)}})),l&&l.type===h.KBN_FIELD_TYPES.MISSING?(j.push(u.i18n.translate("visDefaultEditor.controls.field.fieldIsNotExists",{defaultMessage:'The field "{fieldParameter}" associated with this object no longer exists in the index pattern. Please use another field.',values:{fieldParameter:l.name}})),x=!0):l&&!ce(e).find((e=>e===l.type||"*"===e))&&(j.push(u.i18n.translate("visDefaultEditor.controls.field.invalidFieldForAggregation",{defaultMessage:'Saved field "{fieldParameter}" of index pattern "{indexPatternTitle}" is invalid for use with this aggregation. Please select a new field.',values:{fieldParameter:null==l?void 0:l.name,indexPatternTitle:e.getIndexPattern&&e.getIndexPattern().title}})),x=!0);const E=!!l&&!j.length&&!f,y=(o||!s.length||x)&&!E;Object(re.g)(p,E),te()((()=>{if(1!==s.length)return;const e=s[0];"options"in e?1===e.options.length&&m(e.options[0].target):m(e.target)}));const w=Object(a.useCallback)((e=>b(Boolean(e))),[]);return Object(g.jsx)(r.EuiFormRow,{label:n||se,isInvalid:y,fullWidth:!0,error:j,display:"rowCompressed"},Object(g.jsx)(r.EuiComboBox,{compressed:!0,placeholder:u.i18n.translate("visDefaultEditor.controls.field.selectFieldPlaceholder",{defaultMessage:"Select a field"}),options:s,isDisabled:!s.length,selectedOptions:v,singleSelection:{asPlainText:!0},isClearable:!1,isInvalid:y,onChange:i=>{const a=Object(d.get)(i,"0.target");t.required&&!a||m(a),t.onChange&&t.onChange(e)},onBlur:c,onSearchChange:w,sortMatchesBy:"startsWith","data-test-subj":"visDefaultEditorField",fullWidth:!0}))}function le(e){return Object(re.a)(ce(e),{inclusive:!1})}function ce(e){const t=Object(d.get)(e,"type.params",[]).find((e=>"field"===e.name))||{};return Object(re.c)(t.filterFieldTypes||[])}var de=i(25);function ue({id:e,arrayIndex:t,customLabel:i,value:n,autoFocus:o,disableRemove:l,dataTestSubj:c,agg:d,onChangeValue:p,onRemoveFilter:m}){const{services:f}=Object(s.useKibana)(),{data:b,dataViews:h,unifiedSearch:v,usageCollection:j,storage:x,notifications:E,http:y,docLinks:w,uiSettings:O,appName:_}=f,[S,T]=Object(a.useState)(!1),k=u.i18n.translate("visDefaultEditor.controls.filters.filterLabel",{defaultMessage:"Filter {index}",values:{index:t+1}}),A=Object(g.jsx)("div",null,Object(g.jsx)(r.EuiButtonIcon,{iconType:"tag","aria-label":u.i18n.translate("visDefaultEditor.controls.filters.toggleFilterButtonAriaLabel",{defaultMessage:"Toggle filter label"}),"aria-expanded":S,"aria-controls":`visEditorFilterLabel${t}`,onClick:()=>T(!S)}),Object(g.jsx)(r.EuiButtonIcon,{iconType:"trash",color:"danger",disabled:l,"aria-label":u.i18n.translate("visDefaultEditor.controls.filters.removeFilterButtonAriaLabel",{defaultMessage:"Remove this filter"}),onClick:()=>m(e)}));return Object(g.jsx)(r.EuiForm,null,Object(g.jsx)(r.EuiFormRow,{label:`${k}${i?` - ${i}`:""}`,labelAppend:A,fullWidth:!0},Object(g.jsx)(de.QueryStringInput,{query:n,indexPatterns:[d.getIndexPattern()],onChange:t=>p(e,t,i),onBlur:()=>{n.query.length>0&&b.query.addToQueryLog(_,n)},disableAutoFocus:!o,dataTestSubj:c,bubbleSubmitEvent:!0,languageSwitcherPopoverAnchorPosition:"leftDown",size:"s",deps:{data:b,dataViews:h,unifiedSearch:v,usageCollection:j,storage:x,notifications:E,http:y,docLinks:w,uiSettings:O},appName:_})),S?Object(g.jsx)(r.EuiFormRow,{id:`visEditorFilterLabel${t}`,label:u.i18n.translate("visDefaultEditor.controls.filters.definiteFilterLabel",{defaultMessage:"Filter {index} label",description:"'Filter {index}' represents the name of the filter as a noun, similar to 'label for filter 1'.",values:{index:t+1}}),fullWidth:!0,display:"rowCompressed"},Object(g.jsx)(r.EuiFieldText,{value:i,placeholder:u.i18n.translate("visDefaultEditor.controls.filters.labelPlaceholder",{defaultMessage:"Label"}),onChange:t=>p(e,n,t.target.value),fullWidth:!0,compressed:!0})):null,Object(g.jsx)(r.EuiSpacer,{size:"m"}))}const ge=Object(r.htmlIdGenerator)(),{isType:pe}=h.search.aggs;function me({agg:e,aggParam:t,showValidation:i,value:n,setValidity:s,setValue:o,setTouched:l}){const c=!t.required||!!n;Object(a.useEffect)((()=>{s(c)}),[c,s]);const d=Object(a.useCallback)((e=>o(e.target.value)),[o]);return Object(g.jsx)(r.EuiFormRow,{className:"visEditorAggParam__string",label:t.displayName||t.name,fullWidth:!0,display:"rowCompressed",isInvalid:!!i&&!c},Object(g.jsx)(r.EuiFieldText,{value:n||"","data-test-subj":`visEditorStringInput${e.id}${t.name}`,onChange:d,fullWidth:!0,compressed:!0,onBlur:l,isInvalid:!!i&&!c}))}const fe="(\\-?(?:\\d+(?:\\.\\d+)?|Infinity))",be=new RegExp("^\\s*([\\[|\\(])\\s*"+fe+"\\s*,\\s*"+fe+"\\s*([\\]|\\)])\\s*$");class NumberListRange{constructor(e,t,i,a){this.minInclusive=e,this.min=t,this.max=i,this.maxInclusive=a}within(e){return!(this.min===e&&!this.minInclusive||this.min>e||this.max===e&&!this.maxInclusive||this.maxi[2]&&i.reverse();const[a,n,r,s]=i;return new NumberListRange(a,n,r,s)}const ve="",je=he("[0,Infinity)"),xe=Object(r.htmlIdGenerator)(),Ee={value:0,id:xe(),isInvalid:!1};function ye(e){const t=parseFloat(e);return isNaN(t)?ve:t}function we(e){try{return e?he(e):je}catch(e){throw new TypeError("Unable to parse range: "+e.message)}}function Oe(e,t){const i=Object(d.last)(e).value;let a=Number(i)?Number(i)+1:1;return a>=t.max&&(a=t.max-1),{id:xe(),value:a,isInvalid:!1}}function _e(e){return e.length?e.map((e=>({value:void 0===e?ve:e,id:xe(),isInvalid:!1}))):[Ee]}function Se({autoFocus:e,disableDelete:t,model:i,isInvalid:n,labelledbyId:s,range:o,onBlur:l,onDelete:c,onChange:d}){const p=u.i18n.translate("visDefaultEditor.controls.numberList.removeUnitButtonAriaLabel",{defaultMessage:"Remove the rank value of {value}",values:{value:i.value}}),m=Object(a.useCallback)((e=>d({value:e.target.value,id:i.id})),[d,i.id]),f=Object(a.useCallback)((()=>c(i.id)),[c,i.id]);return Object(g.jsx)(r.EuiFlexGroup,{responsive:!1,alignItems:"center",gutterSize:"s"},Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldNumber,{"aria-labelledby":s,autoFocus:e,compressed:!0,isInvalid:n,placeholder:u.i18n.translate("visDefaultEditor.controls.numberList.enterValuePlaceholder",{defaultMessage:"Enter a value"}),onChange:m,value:i.value,fullWidth:!0,min:o.min,max:o.max,onBlur:l})),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiButtonIcon,{"aria-label":p,title:p,color:"danger",iconType:"trash",onClick:f,disabled:t})))}const Te=Object(r.htmlIdGenerator)();function ke({agg:e,aggParam:t,value:i,setValue:s,setTouched:o}){const[l,c]=Object(a.useState)(_e(i&&Object(d.isArray)(i)?i:[ve])),u=Object(a.useMemo)((()=>we("[-Infinity,Infinity]")),[]);Object(a.useEffect)((()=>{!Object(d.isArray)(i)||i.length===l.length&&i.every(((e,t)=>e===l[t].value))||c(i.map((e=>({id:Te(),value:e,isInvalid:!1}))))}),[l,i]);const p=Object(a.useCallback)((e=>{c(e),s(e.map((({value:e})=>e)))}),[s]),f=Object(a.useCallback)((e=>{p(l.map((t=>t.id===e.id?{id:e.id,value:ye(e.value),isInvalid:!1}:t)))}),[l,p]),b=Object(a.useCallback)((()=>{const e=[...l,{id:Te(),value:ve,isInvalid:!1}];p(e)}),[l,p]),h=Object(a.useCallback)((e=>p(l.filter((t=>t.id!==e)))),[l,p]);return Object(g.jsx)(r.EuiFormRow,{id:`${t.name}-${e.id}}`,label:t.displayName||t.name,fullWidth:!0,display:"rowCompressed"},Object(g.jsx)(n.a.Fragment,null,l.map(((i,n)=>Object(g.jsx)(a.Fragment,{key:i.id},Object(g.jsx)(Se,{isInvalid:i.isInvalid,disableDelete:1===l.length,model:i,labelledbyId:`${t.name}-${e.id}-legend`,range:u,onDelete:h,onChange:f,onBlur:o,autoFocus:1!==l.length&&n===l.length-1}),l.length-1!==n&&Object(g.jsx)(r.EuiSpacer,{size:"s"})))),Object(g.jsx)(r.EuiSpacer,{size:"s"}),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiButtonEmpty,{iconType:"plusInCircleFilled",onClick:b,size:"xs"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.includeExclude.addUnitButtonLabel",defaultMessage:"Add value"})))))}const{isNumberType:Ae}=h.search.aggs;function Ce(e){const{agg:t,value:i,setValue:n}=e,r=Ae(t);return Object(a.useEffect)((()=>{if(r&&!Array.isArray(i)&&void 0!==i){const e=i.split("|").map((e=>parseFloat(e))).filter((e=>Number.isFinite(e)));n(e.length?e:[""])}else!r&&Array.isArray(i)&&void 0!==i&&n(i.filter((e=>""!==e)).join("|"))}),[r,n,i]),r?Object(g.jsx)(ke,c()({},e,{value:i})):Object(g.jsx)(me,c()({},e,{value:i}))}const Me=Object(r.htmlIdGenerator)(),Ie=(e,t)=>{const i={model:e||"",isInvalid:!1};if(!e)return i.isInvalid=!1,i;try{return i.model=new t(e).toString(),i.isInvalid=!1,i}catch(e){return i.isInvalid=!0,i}};function Re({config:e,list:t,onChange:i,setValidity:s}){const{defaultValue:o,getModelValue:l,modelNames:c,onChangeFn:u,validateClass:p}=e,[f,b]=Object(a.useState)((()=>t.map((e=>({id:Me(),...l(e)}))))),h=f.some(e.hasInvalidValuesFn),v=Object(a.useCallback)((e=>{b(e),i(e.map(u))}),[u,i]),j=Object(a.useCallback)(((e,t,i)=>{const{model:a,isInvalid:n}=Ie(t,p);v(f.map(((r,s)=>s===e?{...r,[i]:{value:t,model:a,isInvalid:n}}:r)))}),[f,v,p]),x=Object(a.useCallback)((e=>v(f.filter((t=>t.id!==e)))),[f,v]),E=Object(a.useCallback)((()=>v([...f,{id:Me(),...l()}])),[l,f,v]);return Object(a.useEffect)((()=>{t.length||v([{id:Me(),...o}])}),[o,t.length,v]),Object(a.useEffect)((()=>{s(!h)}),[h,s]),Object(a.useEffect)((()=>{(t.length!==f.length||t.some(((e,t)=>{const i=Object(d.mapValues)(Object(d.pick)(f[t],c),"model");return!Object(d.isEqual)(e,Object(d.omitBy)(i,d.isEmpty))})))&&b(t.map((e=>({id:Me(),...l(e)}))))}),[l,t,c,f]),Object(g.jsx)(n.a.Fragment,null,f.map(((t,i)=>Object(g.jsx)(a.Fragment,{key:t.id},Object(g.jsx)(r.EuiFlexGroup,{gutterSize:"xs",alignItems:"center",responsive:!1},e.renderInputRow(t,i,j),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiButtonIcon,{"aria-label":e.getRemoveBtnAriaLabel(t),title:e.getRemoveBtnAriaLabel(t),disabled:1===f.length,color:"danger",iconType:"trash",onClick:()=>x(t.id)}))),Object(g.jsx)(r.EuiSpacer,{size:"xs"})))),Object(g.jsx)(r.EuiSpacer,{size:"s"}),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiButtonEmpty,{iconType:"plusInCircleFilled",onClick:E,size:"xs"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.ipRanges.addRangeButtonLabel",defaultMessage:"Add range"}))))}const Le={defaultValue:{from:{value:"0.0.0.0",model:"0.0.0.0",isInvalid:!1},to:{value:"255.255.255.255",model:"255.255.255.255",isInvalid:!1}},validateClass:h.search.aggs.IpAddress,getModelValue:(e={})=>({from:{value:e.from||"",model:e.from||"",isInvalid:!1},to:{value:e.to||"",model:e.to||"",isInvalid:!1}}),getRemoveBtnAriaLabel:e=>u.i18n.translate("visDefaultEditor.controls.ipRanges.removeRangeAriaLabel",{defaultMessage:"Remove the range of {from} to {to}",values:{from:e.from.value||"*",to:e.to.value||"*"}}),onChangeFn:({from:e,to:t})=>{const i={};return e.model&&(i.from=e.model),t.model&&(i.to=t.model),i},hasInvalidValuesFn:({from:e,to:t})=>e.isInvalid||t.isInvalid,modelNames:["from","to"]};function Pe({showValidation:e,onBlur:t,...i}){const s=Object(a.useCallback)(((i,a,s)=>Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldText,{"aria-label":u.i18n.translate("visDefaultEditor.controls.ipRanges.ipRangeFromAriaLabel",{defaultMessage:"IP range from: {value}",values:{value:i.from.value||"*"}}),compressed:!0,isInvalid:!!e&&i.from.isInvalid,placeholder:"*",onChange:e=>{s(a,e.target.value,"from")},value:i.from.value,onBlur:t})),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiIcon,{type:"sortRight",color:"subdued"})),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldText,{"aria-label":u.i18n.translate("visDefaultEditor.controls.ipRanges.ipRangeToAriaLabel",{defaultMessage:"IP range to: {value}",values:{value:i.to.value||"*"}}),compressed:!0,isInvalid:!!e&&i.to.isInvalid,placeholder:"*",onChange:e=>{s(a,e.target.value,"to")},value:i.to.value,onBlur:t})))),[t,e]),o={...Le,renderInputRow:s};return Object(g.jsx)(Re,c()({config:o},i))}const De={defaultValue:{mask:{model:"0.0.0.0/1",value:"0.0.0.0/1",isInvalid:!1}},validateClass:h.search.aggs.CidrMask,getModelValue:(e={})=>({mask:{model:e.mask||"",value:e.mask||"",isInvalid:!1}}),getRemoveBtnAriaLabel:e=>e.mask.value?u.i18n.translate("visDefaultEditor.controls.ipRanges.removeCidrMaskButtonAriaLabel",{defaultMessage:"Remove the CIDR mask value of {mask}",values:{mask:e.mask.value}}):u.i18n.translate("visDefaultEditor.controls.ipRanges.removeEmptyCidrMaskButtonAriaLabel",{defaultMessage:"Remove the CIDR mask default value"}),onChangeFn:({mask:e})=>e.model?{mask:e.model}:{},hasInvalidValuesFn:({mask:e})=>e.isInvalid,modelNames:"mask"};function Fe({showValidation:e,onBlur:t,...i}){const n=Object(a.useCallback)((({mask:i},a,n)=>Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldText,{"aria-label":u.i18n.translate("visDefaultEditor.controls.ipRanges.cidrMaskAriaLabel",{defaultMessage:"CIDR mask: {mask}",values:{mask:i.value||"*"}}),compressed:!0,fullWidth:!0,isInvalid:!!e&&i.isInvalid,placeholder:"*",onChange:e=>{n(a,e.target.value,"mask")},value:i.value,onBlur:t}))),[t,e]),s={...De,renderInputRow:n};return Object(g.jsx)(Re,c()({config:s},i))}var Ne;!function(e){e.MASK="mask",e.FROM_TO="fromTo"}(Ne||(Ne={}));const Be=["!top_hits","!top_metrics","!percentiles","!percentile_ranks","!median","!std_dev"],Ve="EMPTY_VALUE",ze=[{text:"",value:Ve,hidden:!0}],Ge=Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.numberInterval.minimumIntervalLabel",defaultMessage:"Minimum interval"})," ",Object(g.jsx)(r.EuiIconTip,{position:"right",content:Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.numberInterval.minimumIntervalTooltip",defaultMessage:"Interval will be automatically scaled in the event that the provided value creates more buckets than specified by Advanced Setting's {histogramMaxBars}",values:{histogramMaxBars:h.UI_SETTINGS.HISTOGRAM_MAX_BARS}}),type:"questionInCircle"})),$e="auto",qe=u.i18n.translate("visDefaultEditor.controls.numberInterval.selectIntervalPlaceholder",{defaultMessage:"Enter an interval"}),We=u.i18n.translate("visDefaultEditor.controls.numberInterval.autoInteralIsUsed",{defaultMessage:"Auto interval is used"}),Ue=u.i18n.translate("visDefaultEditor.controls.useAutoInterval",{defaultMessage:"Use auto interval"}),{termsAggFilter:He}=h.search.aggs,Ke="_key",Je=[{text:u.i18n.translate("visDefaultEditor.controls.orderAgg.alphabeticalLabel",{defaultMessage:"Alphabetical"}),value:Ke}],Ye=Object(re.b)(He);function Xe({labelledbyId:e,numberArray:t,range:i,showValidation:s,unitName:o,validateAscendingOrder:l=!1,disallowDuplicates:c=!1,onChange:d,setTouched:p,setValidity:f}){const b=Object(a.useMemo)((()=>we(i)),[i]),[h,v]=Object(a.useState)(_e(t));Object(a.useEffect)((()=>{v((e=>function(e,t,i,a=!1,n=!1){return e.length?e.map(((r,s)=>{const o=t[s]||{id:xe()},l=void 0===r?ve:r,c=i?function(e,t){const i={isInvalid:!1};return e===ve?(i.isInvalid=!0,i.error=ve):t.within(e)||(i.isInvalid=!0,i.error=u.i18n.translate("visDefaultEditor.controls.numberList.invalidRangeErrorMessage",{defaultMessage:"The value should be in the range of {min} to {max}.",values:{min:t.min,max:t.max}})),i}(l,i):{isInvalid:!1},d=a?function(e,t,i){const a={isInvalidOrder:!1},n=i[t-1];return void 0!==n&&void 0!==e&&e<=n&&(a.isInvalidOrder=!0,a.error=u.i18n.translate("visDefaultEditor.controls.numberList.invalidAscOrderErrorMessage",{defaultMessage:"Value is not in ascending order."})),a}(l,s,e):{isInvalidOrder:!1},g=n?function(e,t,i){const a={isDuplicate:!1};return e!==ve&&i.indexOf(e)!==t&&(a.isDuplicate=!0,a.error=u.i18n.translate("visDefaultEditor.controls.numberList.duplicateValueErrorMessage",{defaultMessage:"Duplicate value."})),a}(l,s,e):{isDuplicate:!1},p=[c.error,d.error,g.error].filter(Boolean).join(" ");return{...o,value:l,isInvalid:c.isInvalid||d.isInvalidOrder||g.isDuplicate,error:p===ve?void 0:p}})):[Ee]}(t,e,b,l,c)))}),[t,b,l,c]),Object(a.useEffect)((()=>{t.length||d([h[0].value])}),[h,t.length,d]);const j=!h.find((({isInvalid:e})=>e));Object(re.g)(f,j);const x=Object(a.useCallback)((e=>{v(e),d(e.map((({value:e})=>e===ve?void 0:e)))}),[d]),E=Object(a.useCallback)((({id:e,value:t})=>{const i=ye(t);x(h.map((t=>t.id===e?{id:e,value:i,isInvalid:!1}:t)))}),[h,x]),y=Object(a.useCallback)((()=>{const e=[...h,Oe(h,b)];x(e)}),[h,b,x]),w=Object(a.useCallback)((e=>{const t=h.filter((t=>t.id!==e));x(t)}),[h,x]);return Object(g.jsx)(n.a.Fragment,null,h.map(((t,i)=>Object(g.jsx)(a.Fragment,{key:t.id},Object(g.jsx)(Se,{isInvalid:!!s&&t.isInvalid,disableDelete:1===h.length,model:t,labelledbyId:e,range:b,onDelete:w,onChange:E,onBlur:p,autoFocus:1!==h.length&&i===h.length-1}),s&&t.isInvalid&&t.error&&Object(g.jsx)(r.EuiFormErrorText,null,t.error),h.length-1!==i&&Object(g.jsx)(r.EuiSpacer,{size:"s"})))),Object(g.jsx)(r.EuiSpacer,{size:"s"}),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiButtonEmpty,{iconType:"plusInCircleFilled",onClick:y,size:"xs"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.numberList.addUnitButtonLabel",defaultMessage:"Add {unitName}",values:{unitName:o}}))))}var Qe=i(8),Ze=i(26),et=i(27);function tt({disabled:e,iconTip:t,value:i,setValue:s,showValidation:o,setValidity:l,setTouched:c}){const u=Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.sizeLabel",defaultMessage:"Size"}),t),p=e||Number(i)>0;return Object(a.useEffect)((()=>{l(p)}),[p,l]),Object(g.jsx)(r.EuiFormRow,{label:u,fullWidth:!0,isInvalid:!!o&&!p,display:"rowCompressed"},Object(g.jsx)(r.EuiFieldNumber,{value:Object(d.isUndefined)(i)?"":i,onChange:e=>s(""===e.target.value?"":parseFloat(e.target.value)),fullWidth:!0,compressed:!0,isInvalid:!!o&&!p,onBlur:c,min:1,disabled:e,"data-test-subj":"sizeParamEditor"}))}function it({agg:e,aggParam:t,formIsTouched:i,metricAggs:a,state:s,setValue:o,setValidity:l,setTouched:c,schemas:d}){const p=u.i18n.translate("visDefaultEditor.controls.metrics.metricTitle",{defaultMessage:"Metric"}),m=u.i18n.translate("visDefaultEditor.controls.metrics.bucketTitle",{defaultMessage:"Bucket"}),f=t.name,b="customMetric"===f,v=b?p:m,j=b?h.AggGroupNames.Metrics:h.AggGroupNames.Buckets;te()((()=>{e.params[f]?o(e.params[f]):o(t.makeAgg(e))}));const{onAggTypeChange:x,setAggParamValue:E}=Object(re.f)(e,t,e.params[f],o);return e.params[f]?Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiSpacer,{size:"m"}),Object(g.jsx)(r.EuiFormLabel,null,v),Object(g.jsx)(r.EuiSpacer,{size:"s"}),Object(g.jsx)(Ot,{agg:e.params[f],allowedAggs:t.allowedAggs,groupName:j,className:"visEditorAgg__subAgg",formIsTouched:i,indexPattern:e.getIndexPattern(),metricAggs:a,state:s,setAggParamValue:E,onAggTypeChange:x,setValidity:l,setTouched:c,schemas:d,hideCustomLabel:!b})):null}const{parseEsInterval:at,InvalidEsCalendarIntervalError:nt}=h.search.aggs;function rt(e){if("0ms"===e)return{isValidCalendarValue:!0};try{return at(e),{isValidCalendarValue:!0}}catch(e){return e instanceof nt?{isValidCalendarValue:!1,error:e.message}:{isValidCalendarValue:!0}}}const st=u.i18n.translate("visDefaultEditor.controls.timeInterval.invalidFormatErrorMessage",{defaultMessage:"Invalid interval format."}),ot="auto",lt=Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.timeInterval.createsTooManyBucketsTooltip",defaultMessage:"This interval creates too many buckets to show in the selected time range, so it has been scaled up."}),ct=Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.timeInterval.createsTooLargeBucketsTooltip",defaultMessage:"This interval creates buckets that are too large to show in the selected time range, so it has been scaled down."}),dt=Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.timeInterval.selectOptionHelpText",defaultMessage:"Select an option or create a custom value. Examples: 30s, 20m, 24h, 2d, 1w, 1M"});function ut(e){const{options:t=[]}=e.getAggParams().find((({name:e})=>"aggregate"===e));return t.filter((t=>t.isCompatible(e)))}function gt(e){const t=u.i18n.translate("visDefaultEditor.controls.sortOnLabel",{defaultMessage:"Sort on"});return Object(g.jsx)(oe,c()({},e,{customLabel:t}))}function pt({aggParam:e,value:t,showValidation:i,setValue:n,setValidity:s,setTouched:o}){const l=u.i18n.translate("visDefaultEditor.controls.orderLabel",{defaultMessage:"Order"}),c=!!t;return Object(a.useEffect)((()=>{s(c)}),[c,s]),Object(g.jsx)(r.EuiFormRow,{label:l,fullWidth:!0,isInvalid:!!i&&!c,display:"rowCompressed"},Object(g.jsx)(r.EuiSelect,{options:e.options,value:t&&t.value,onChange:t=>n(e.options.find((e=>e.value===t.target.value))),fullWidth:!0,compressed:!0,isInvalid:!!i&&!c,onBlur:o}))}const mt=u.i18n.translate("visDefaultEditor.controls.maxBars.autoPlaceholder",{defaultMessage:"Auto"}),ft=Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.maxBars.maxBarsLabel",defaultMessage:"Max bars"})," ",Object(g.jsx)(r.EuiIconTip,{position:"right",content:Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.maxBars.maxBarsHelpText",defaultMessage:"Intervals will be selected automatically based on the available data. The maximum number of bars can never be greater than the Advanced Setting's {histogramMaxBars}",values:{histogramMaxBars:h.UI_SETTINGS.HISTOGRAM_MAX_BARS}}),type:"questionInCircle"})),{siblingPipelineType:bt,parentPipelineType:ht}=h.search.aggs,vt={[h.BUCKET_TYPES.DATE_HISTOGRAM]:{scaleMetricValues:function(e){return Object(g.jsx)(ne,c()({dataTestSubj:"scaleMetricsSwitch",displayLabel:u.i18n.translate("visDefaultEditor.controls.scaleMetricsLabel",{defaultMessage:"Scale metric values (deprecated)"}),displayToolTip:u.i18n.translate("visDefaultEditor.controls.scaleMetricsTooltip",{defaultMessage:"If you select a manual minimum interval and a larger interval will be used, enabling this will cause count and sum metrics to be scaled to the manual selected interval."})},e))},interval:function({agg:e,aggParam:t,editorConfig:i,value:s,setValue:o,showValidation:l,setTouched:c,setValidity:p}){const f=Object(d.get)(i,"interval.timeBase"),b=f?[]:(t.options||[]).reduce(((t,i)=>(i.enabled&&!i.enabled(e)||t.push({label:i.display,key:i.val}),t)),[]);let v,j=[];s&&(v=Object(d.find)(b,{key:s}),j=v?[v]:s===ot?[]:[{label:s,key:"custom"}]);const{isValid:x,error:E,interval:y}=function(e,t,i,a){var n,r;if(i)return{isValid:!0,interval:null===(r=e.buckets)||void 0===r?void 0:r.getInterval()};if(!t||t===ot&&!i)return{isValid:!1};if(!a){const{isValidCalendarValue:e,error:i}=rt(t);if(!e)return{isValid:!1,error:i}}const s=h.search.aggs.isValidInterval(t,a);if(!s)return{isValid:!1,error:st};const o=null===(n=e.buckets)||void 0===n?void 0:n.getInterval(),{isValidCalendarValue:l,error:c}=rt(o.expression);return l?{isValid:s,interval:o}:{isValid:!1,error:c}}(e,s,v,f),w=y&&y.scaled?Object(g.jsx)("strong",{"data-test-subj":"currentlyScaledText",className:"eui-displayBlock"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.timeInterval.scaledHelpText",defaultMessage:"Currently scaled to {bucketDescription}",values:{bucketDescription:Object(d.get)(y,"description")||""}})," ",Object(g.jsx)(r.EuiIconTip,{position:"right",type:"questionInCircle",content:y.scale<=1?lt:ct})):null,O=Object(g.jsx)(n.a.Fragment,null,w,Object(d.get)(i,"interval.help")||dt);return Object(a.useEffect)((()=>{p(x)}),[x,p]),Object(g.jsx)(r.EuiFormRow,{display:"rowCompressed",error:E,fullWidth:!0,helpText:O,isInvalid:l&&!x,label:u.i18n.translate("visDefaultEditor.controls.timeInterval.minimumIntervalLabel",{defaultMessage:"Minimum interval"})},Object(g.jsx)(r.EuiComboBox,{compressed:!0,fullWidth:!0,"data-test-subj":"visEditorInterval",isInvalid:l&&!x,noSuggestions:!!f,onChange:e=>{const t=Object(d.get)(e,"0");o(t?t.key:"")},onCreateOption:e=>o(e.trim()),options:b,selectedOptions:j,singleSelection:{asPlainText:!0},placeholder:u.i18n.translate("visDefaultEditor.controls.timeInterval.selectIntervalPlaceholder",{defaultMessage:"Select an interval"}),onBlur:c}))},drop_partials:function(e){return Object(g.jsx)(ne,c()({dataTestSubj:"dropPartialBucketsCheckbox",displayLabel:u.i18n.translate("visDefaultEditor.controls.dropPartialBucketsLabel",{defaultMessage:"Drop partial buckets"}),displayToolTip:u.i18n.translate("visDefaultEditor.controls.dropPartialBucketsTooltip",{defaultMessage:"Remove buckets that span time outside the time range so the histogram doesn't start and end with incomplete buckets."})},e))}},[h.BUCKET_TYPES.DATE_RANGE]:{ranges:function({value:e=[],setValue:t,setValidity:i}){const{services:o}=Object(s.useKibana)(),[l,c]=Object(a.useState)((()=>e.map((e=>({...e,id:ie()}))))),p=e.some((({from:e,to:t})=>!e&&!t||!ae(e)||!ae(t))),f=Object(a.useCallback)((e=>{t(e.map((e=>Object(d.omit)(e,"id")))),c(e)}),[t]),b=Object(a.useCallback)((()=>f([...l,{id:ie()}])),[l,f]);te()((()=>{e.length||b()})),Object(a.useEffect)((()=>{(e.length!==l.length||e.some(((e,t)=>!Object(d.isEqual)(e,Object(d.omit)(l[t],"id")))))&&c(e.map((e=>({...e,id:ie()}))))}),[l,e]),Object(a.useEffect)((()=>{i(!p)}),[p,i]);const h=(e,t,i)=>f(l.map((a=>a.id===e?{...a,[t]:""===i?void 0:i}:a)));return Object(g.jsx)(r.EuiFormRow,{display:"rowCompressed",fullWidth:!0},Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiText,{size:"xs"},Object(g.jsx)(r.EuiLink,{href:o.docLinks.links.date.dateMath,target:"_blank"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.dateRanges.acceptedDateFormatsLinkText",defaultMessage:"Acceptable date formats"}))),Object(g.jsx)(r.EuiSpacer,{size:"s"}),l.map((({from:t,to:i,id:n},s)=>{const o=u.i18n.translate("visDefaultEditor.controls.dateRanges.removeRangeButtonAriaLabel",{defaultMessage:"Remove the range of {from} to {to}",values:{from:t||"−∞",to:i||"+∞"}}),c=!t&&!i;return Object(g.jsx)(a.Fragment,{key:n},Object(g.jsx)(r.EuiFlexGroup,{responsive:!1,gutterSize:"s",alignItems:"center"},Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldText,{"aria-label":u.i18n.translate("visDefaultEditor.controls.dateRanges.fromColumnLabel",{defaultMessage:"From",description:"Beginning of a date range, e.g. *From* 2018-02-26 To 2018-02-28"}),compressed:!0,fullWidth:!0,isInvalid:c||!ae(t),placeholder:"−∞",value:t||"",onChange:e=>h(n,"from",e.target.value),"data-test-subj":`visEditorDateRange${s}__from`})),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiIcon,{type:"sortRight",color:"subdued"})),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldText,{"aria-label":u.i18n.translate("visDefaultEditor.controls.dateRanges.toColumnLabel",{defaultMessage:"To",description:"End of a date range, e.g. From 2018-02-26 *To* 2018-02-28"}),"data-test-subj":`visEditorDateRange${s}__to`,compressed:!0,fullWidth:!0,isInvalid:c||!ae(i),placeholder:"+∞",value:i||"",onChange:e=>h(n,"to",e.target.value)})),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiButtonIcon,{title:o,"aria-label":o,disabled:1===e.length,color:"danger",iconType:"trash",onClick:()=>(e=>f(l.filter((t=>t.id!==e))))(n)}))),Object(g.jsx)(r.EuiSpacer,{size:"xs"}))})),p&&Object(g.jsx)(r.EuiFormErrorText,null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.dateRanges.errorMessage",defaultMessage:"Each range should have at least one valid date."})),Object(g.jsx)(r.EuiSpacer,{size:"s"}),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiButtonEmpty,{iconType:"plusInCircleFilled",onClick:b,size:"xs","data-test-subj":"visEditorAddDateRange"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.dateRanges.addRangeButtonLabel",defaultMessage:"Add range"})))))}},[h.BUCKET_TYPES.FILTERS]:{filters:function({agg:e,value:t=[],setValue:i}){const[o,l]=Object(a.useState)((()=>t.map((e=>({...e,id:ge()})))));te()((()=>{i(o.map((e=>Object(d.omit)({...e,input:e.input},"id"))))})),Object(a.useEffect)((()=>{(t.length!==o.length||t.some(((e,t)=>!Object(d.isEqual)(e,Object(d.omit)(o[t],"id")))))&&l(t.map((e=>({...e,id:ge()}))))}),[o,t]);const c=e=>{i(e.map((e=>Object(d.omit)(e,"id")))),l(e)},{services:u}=Object(s.useKibana)(),p=e=>c(o.filter((t=>t.id!==e))),f=(e,t,i)=>c(o.map((a=>a.id===e?{...a,input:t,label:i}:a)));return Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiSpacer,{size:"m"}),o.map((({input:t,label:i,id:a},n)=>Object(g.jsx)(ue,{key:a,id:a,arrayIndex:n,customLabel:i,value:t,autoFocus:n===o.length-1,disableRemove:0===n&&1===o.length,dataTestSubj:`visEditorFilterInput_${e.id}_${n}`,agg:e,onChangeValue:f,onRemoveFilter:p}))),Object(g.jsx)(r.EuiButton,{iconType:"plusInCircle",fill:!0,fullWidth:!0,onClick:()=>c([...o,{input:u.data.query.queryString.getDefaultQuery(),label:"",id:ge()}]),size:"s","data-test-subj":"visEditorAddFilterButton"},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.filters.addFilterButtonLabel",defaultMessage:"Add filter"})),Object(g.jsx)(r.EuiSpacer,{size:"m"}))}},[h.BUCKET_TYPES.HISTOGRAM]:{interval:function({agg:e,editorConfig:t,showValidation:i,value:n,setTouched:s,setValidity:o,setValue:l}){const c=e.getField(),u=!c||"number"===c.type,p=u&&(e=>e===$e)(n),m=Object(d.get)(t,"interval.base"),f=m||0,b=""!==n&&void 0!==n&&(p||Number(n)>=f);Object(a.useEffect)((()=>{o(b)}),[b,o]);const h=Object(a.useCallback)((({target:e})=>l(isNaN(e.valueAsNumber)?"":e.valueAsNumber)),[l]),v=Object(a.useCallback)((e=>{const t=e.target.checked;l(t?$e:"")}),[l]);return Object(g.jsx)(r.EuiFormRow,{display:"rowCompressed",label:Ge,fullWidth:!0,isInvalid:i&&!b,helpText:Object(d.get)(t,"interval.help")},Object(g.jsx)(r.EuiFlexGroup,{gutterSize:"s",responsive:!1,direction:"column"},Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiSwitch,{label:Ue,onChange:v,checked:p,compressed:!0,disabled:!u,"data-test-subj":`visEditorIntervalSwitch${e.id}`})),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldNumber,{value:p?"":n,min:f,step:m||"any","data-test-subj":`visEditorInterval${e.id}`,isInvalid:i&&!b,onChange:h,onBlur:s,disabled:p,fullWidth:!0,compressed:!0,placeholder:p?We:qe}))))},maxBars:function({disabled:e,iconTip:t,value:i,setValue:n,showValidation:o,setValidity:l,setTouched:c}){var d;const{services:u}=Object(s.useKibana)(),p=null===(d=u.uiSettings)||void 0===d?void 0:d.get(h.UI_SETTINGS.HISTOGRAM_MAX_BARS),m=e||void 0===i||""===i||Number(i)>0||i{l(m)}),[m,l]);const f=Object(a.useCallback)((e=>n(""===e.target.value?"":parseFloat(e.target.value))),[n]);return Object(g.jsx)(r.EuiFormRow,{label:ft,fullWidth:!0,isInvalid:!!o&&!m,display:"rowCompressed"},Object(g.jsx)(r.EuiFieldNumber,{value:i||"",placeholder:mt,onChange:f,min:1,fullWidth:!0,compressed:!0,max:p,isInvalid:!!o&&!m,onBlur:c,disabled:e,"data-test-subj":"maxBarsParamEditor"}))},min_doc_count:function(e){return Object(g.jsx)(ne,c()({displayLabel:u.i18n.translate("visDefaultEditor.controls.showEmptyBucketsLabel",{defaultMessage:"Show empty buckets"}),displayToolTip:u.i18n.translate("visDefaultEditor.controls.showEmptyBucketsTooltip",{defaultMessage:"Show all buckets, not only the buckets with results"})},e))},has_extended_bounds:function(e){const{agg:t,setValue:i,value:n}=e,r=Object(a.useRef)(t.params.min_doc_count);return Object(a.useEffect)((()=>{r.current!==t.params.min_doc_count&&(r.current=t.params.min_doc_count,i(n&&t.params.min_doc_count))}),[t.params.min_doc_count,i,n]),Object(g.jsx)(ne,c()({},e,{displayLabel:u.i18n.translate("visDefaultEditor.controls.extendedBoundsLabel",{defaultMessage:"Extend bounds"}),displayToolTip:u.i18n.translate("visDefaultEditor.controls.extendedBoundsTooltip",{defaultMessage:"Min and Max do not filter the results, but rather extend the bounds of the result set."}),disabled:!e.agg.params.min_doc_count||!(pe("number")(e.agg)||pe("date")(e.agg))}))},extended_bounds:function({value:e={},setValue:t,setValidity:i,showValidation:a,setTouched:n}){const s=u.i18n.translate("visDefaultEditor.controls.extendedBounds.minLabel",{defaultMessage:"Min"}),o=u.i18n.translate("visDefaultEditor.controls.extendedBounds.maxLabel",{defaultMessage:"Max"}),l=function({min:e,max:t}){return""!==e&&""!==t&&t>=e}(e);let c;l||(c=u.i18n.translate("visDefaultEditor.controls.extendedBounds.errorMessage",{defaultMessage:"Min should be less than or equal to Max."})),Object(re.g)(i,l);const p=(i,a)=>{t({...e,[a]:""===i.target.value?"":parseFloat(i.target.value)})};return Object(g.jsx)(r.EuiFormRow,{fullWidth:!0,isInvalid:!!a&&!l,error:c},Object(g.jsx)(r.EuiFlexGroup,{gutterSize:"s",responsive:!1},Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldNumber,{value:Object(d.isUndefined)(e.min)?"":e.min,onChange:e=>p(e,"min"),onBlur:n,fullWidth:!0,isInvalid:!!a&&!l,"aria-label":s,prepend:s,compressed:!0})),Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)(r.EuiFieldNumber,{value:Object(d.isUndefined)(e.max)?"":e.max,onChange:e=>p(e,"max"),onBlur:n,fullWidth:!0,isInvalid:!!a&&!l,"aria-label":o,prepend:o,compressed:!0}))))}},[h.BUCKET_TYPES.IP_RANGE]:{ipRangeType:function({agg:e,value:t,setValue:i}){const a=[{id:`visEditorIpRangeFromToLabel${e.id}`,label:u.i18n.translate("visDefaultEditor.controls.ipRanges.fromToButtonLabel",{defaultMessage:"From/to"})},{id:`visEditorIpRangeCidrLabel${e.id}`,label:u.i18n.translate("visDefaultEditor.controls.ipRanges.cidrMasksButtonLabel",{defaultMessage:"CIDR masks"})}];return Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiSpacer,{size:"m"}),Object(g.jsx)(r.EuiButtonGroup,{isFullWidth:!0,onChange:e=>{i(e===a[0].id?Ne.FROM_TO:Ne.MASK)},idSelected:t===Ne.FROM_TO?a[0].id:a[1].id,options:a,legend:u.i18n.translate("visDefaultEditor.controls.ipRangesAriaLabel",{defaultMessage:"IP ranges"})}),Object(g.jsx)(r.EuiSpacer,{size:"s"}))},ranges:function({agg:e,value:t={fromTo:[],mask:[]},setTouched:i,setValue:n,setValidity:s,showValidation:o}){const l=Object(a.useCallback)((e=>n({...t,[Ne.MASK]:e})),[n,t]),c=Object(a.useCallback)((e=>n({...t,[Ne.FROM_TO]:e})),[n,t]);return Object(g.jsx)(r.EuiFormRow,{fullWidth:!0,id:`visEditorIpRange${e.id}`,display:"rowCompressed"},e.params.ipRangeType===Ne.MASK?Object(g.jsx)(Fe,{list:t.mask,showValidation:o,onBlur:i,onChange:l,setValidity:s}):Object(g.jsx)(Pe,{list:t.fromTo,showValidation:o,onBlur:i,onChange:c,setValidity:s}))}},[h.BUCKET_TYPES.RANGE]:{ranges:e=>Object(g.jsx)(Qe.a,{value:e.value,setValue:e.setValue})},[h.BUCKET_TYPES.SIGNIFICANT_TERMS]:{size:tt},[h.BUCKET_TYPES.TERMS]:{include:Ce,exclude:Ce,orderBy:function({agg:e,value:t,showValidation:i,setValue:a,setValidity:n,setTouched:s,metricAggs:o}){const l=u.i18n.translate("visDefaultEditor.controls.orderAgg.orderByLabel",{defaultMessage:"Order by"}),c=!!t;Object(re.g)(n,c),te()((()=>{if(!t){let e={id:Ke};o&&(e=o.filter(Ye)[0]||e),a(e.id)}})),Object(re.e)(a,He,o,t,Ke);const d=Object(re.d)(He,o,Je);return Object(g.jsx)(r.EuiFormRow,{label:l,fullWidth:!0,isInvalid:i&&!c,display:"rowCompressed"},Object(g.jsx)(r.EuiSelect,{options:d,value:t,onChange:e=>a(e.target.value),fullWidth:!0,compressed:!0,isInvalid:i&&!c,onBlur:s,"data-test-subj":`visEditorOrderBy${e.id}`}))},orderAgg:function({agg:e,aggParam:t,formIsTouched:i,value:s,metricAggs:o,state:l,setValue:c,setValidity:d,setTouched:u,schemas:p}){const m=e.params.orderBy;Object(a.useEffect)((()=>{"custom"!==m||s||c(t.makeAgg(e)),"custom"!==m&&s&&c(void 0)}),[e,t,m,c,s]);const{onAggTypeChange:f,setAggParamValue:b}=Object(re.f)(e,t,s,c);return e.params.orderAgg?Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiSpacer,{size:"m"}),Object(g.jsx)(Ot,{agg:s,allowedAggs:t.allowedAggs,hideCustomLabel:!0,groupName:h.AggGroupNames.Metrics,className:"visEditorAgg__subAgg",formIsTouched:i,indexPattern:e.getIndexPattern(),metricAggs:o,state:l,setAggParamValue:b,onAggTypeChange:f,setValidity:d,setTouched:u,schemas:p})):null},order:Object(re.h)(pt),size:Object(re.h)(tt),otherBucket:function(e){return Object(g.jsx)(ne,c()({dataTestSubj:"otherBucketSwitch",displayLabel:u.i18n.translate("visDefaultEditor.controls.otherBucket.groupValuesLabel",{defaultMessage:"Group other values in separate bucket"}),displayToolTip:u.i18n.translate("visDefaultEditor.controls.otherBucket.groupValuesTooltip",{defaultMessage:"Values not in the top N are grouped in this bucket. To include documents with missing values, enable 'Show missing values'."})},e))},missingBucket:function(e){const t=!h.search.aggs.isStringType(e.agg),{setValue:i}=e;return Object(a.useEffect)((()=>{t&&i(!1)}),[t,i]),Object(g.jsx)(ne,c()({},e,{dataTestSubj:"missingBucketSwitch",displayLabel:u.i18n.translate("visDefaultEditor.controls.otherBucket.showMissingValuesLabel",{defaultMessage:"Show missing values"}),displayToolTip:u.i18n.translate("visDefaultEditor.controls.otherBucket.showMissingValuesTooltip",{defaultMessage:'Only works for fields of type "string". When enabled, include documents with missing values in the search. If this bucket is in the top N, it appears in the chart. If not in the top N, and you enable "Group other values in separate bucket", Elasticsearch adds the missing values to the "other" bucket.'}),disabled:t}))}}},jt={[h.METRIC_TYPES.TOP_HITS]:{field:function(e){const t=ut(e.agg);let i;return e.value&&!t.length&&(i=u.i18n.translate("visDefaultEditor.controls.aggregateWith.noAggsErrorTooltip",{defaultMessage:"The chosen field has no compatible aggregations."})),Object(g.jsx)(oe,c()({},e,{customError:i}))},aggregate:Object(re.h)((function({agg:e,aggParam:t,value:i,showValidation:s,setValue:o,setValidity:l,setTouched:c}){const d=Object(a.useRef)(!0),p=e.params.field&&e.params.field.type,f={text:"",value:"EMPTY_VALUE",disabled:!0,hidden:!0},b=ut(e).map((({text:e,value:t})=>({text:e,value:t}))).sort(((e,t)=>e.text.toLowerCase().localeCompare(t.text.toLowerCase()))),h=[f,...b],v=p&&!b.length,j=v||!!i,x=Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.aggregateWithLabel",defaultMessage:"Aggregate with"})," ",Object(g.jsx)(r.EuiIconTip,{position:"right",type:"questionInCircle",content:u.i18n.translate("visDefaultEditor.controls.aggregateWithTooltip",{defaultMessage:"Choose a strategy for combining multiple hits or a multi-valued field into a single metric."})}));return Object(a.useEffect)((()=>{l(j)}),[j,l]),Object(a.useEffect)((()=>{if(d.current)d.current=!1;else{if(i){if(t.options.find((e=>e.value===i.value)))return;o()}1===b.length&&o(t.options.find((e=>e.value===b[0].value)))}}),[t.options,p,b,o,i]),Object(g.jsx)(r.EuiFormRow,{label:x,fullWidth:!0,isInvalid:!!s&&!j,display:"rowCompressed"},Object(g.jsx)(r.EuiSelect,{options:h,value:i?i.value:f.value,onChange:e=>{e.target.value===f.value?o():o(t.options.find((t=>t.value===e.target.value)))},fullWidth:!0,compressed:!0,isInvalid:!!s&&!j,disabled:v,onBlur:c,"data-test-subj":"visDefaultEditorAggregateWith"}))})),size:Object(re.h)((function(e){const t=Object(g.jsx)(n.a.Fragment,null," ",Object(g.jsx)(r.EuiIconTip,{position:"right",content:u.i18n.translate("visDefaultEditor.controls.sizeTooltip",{defaultMessage:"Request top-K hits. Multiple hits will be combined via 'aggregate with'."}),type:"questionInCircle"})),i=e.agg.params.field&&e.agg.params.field.type&&!ut(e.agg).length;return Object(g.jsx)(tt,c()({},e,{iconTip:t,disabled:i}))})),sortField:gt,sortOrder:pt},[h.METRIC_TYPES.TOP_METRICS]:{field:oe,sortField:gt,sortOrder:pt},[h.METRIC_TYPES.PERCENTILES]:{percents:function({agg:e,showValidation:t,value:i=[],setTouched:n,setValidity:s,setValue:o}){const l=u.i18n.translate("visDefaultEditor.controls.percentiles.percentsLabel",{defaultMessage:"Percents"}),[c,d]=Object(a.useState)(!0),p=Object(a.useCallback)((e=>{d(e),s(e)}),[s]);return Object(g.jsx)(r.EuiFormRow,{label:l,labelType:"legend",fullWidth:!0,id:`visEditorPercentileLabel${e.id}`,isInvalid:!!t&&!c,display:"rowCompressed"},Object(g.jsx)(Xe,{labelledbyId:`visEditorPercentileLabel${e.id}-legend`,numberArray:i,range:"[0,100]",disallowDuplicates:!0,unitName:u.i18n.translate("visDefaultEditor.controls.percentileRanks.percentUnitNameText",{defaultMessage:"percent"}),showValidation:t,onChange:o,setTouched:n,setValidity:p}))}},[h.METRIC_TYPES.PERCENTILE_RANKS]:{values:function({agg:e,showValidation:t,value:i=[],setTouched:n,setValidity:s,setValue:o}){const l=u.i18n.translate("visDefaultEditor.controls.percentileRanks.valuesLabel",{defaultMessage:"Values"}),[c,d]=Object(a.useState)(!0),p=Object(a.useCallback)((e=>{d(e),s(e)}),[s]);return Object(g.jsx)(r.EuiFormRow,{label:l,labelType:"legend",fullWidth:!0,id:`visEditorPercentileRanksLabel${e.id}`,isInvalid:!!t&&!c,display:"rowCompressed","data-test-subj":"visEditorPercentileRanks"},Object(g.jsx)(Xe,{labelledbyId:`visEditorPercentileRanksLabel${e.id}-legend`,numberArray:i,range:"[-Infinity,Infinity]",unitName:u.i18n.translate("visDefaultEditor.controls.percentileRanks.valueUnitNameText",{defaultMessage:"value"}),validateAscendingOrder:!0,showValidation:t,onChange:o,setTouched:n,setValidity:p}))}}},xt={common:{string:me,json:function({showValidation:e,value:t="",setValidity:i,setValue:o,setTouched:l}){const[c,d]=Object(a.useState)(!0),p=Object(a.useMemo)((()=>u.i18n.translate("visDefaultEditor.controls.jsonInputTooltip",{defaultMessage:"Any JSON formatted properties you add here will be merged with the elasticsearch aggregation definition for this section. For example 'shard_size' on a terms aggregation."})),[]),m=Object(a.useMemo)((()=>u.i18n.translate("visDefaultEditor.controls.jsonInputLabel",{defaultMessage:"JSON input"})),[]),f=Object(a.useMemo)((()=>Object(g.jsx)(n.a.Fragment,null,m," ",Object(g.jsx)(r.EuiIconTip,{position:"right",content:p,type:"questionInCircle"}))),[m,p]),b=Object(a.useCallback)((e=>{o(e);let t=!0;try{e&&JSON.parse(et.XJson.collapseLiteralStrings(e))}catch(e){t=!1}d(t),i(t)}),[i,d,o]);return Object(g.jsx)(r.EuiFormRow,{label:f,isInvalid:!!e&&!c,fullWidth:!0,display:"rowCompressed",onBlur:l},Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(s.CodeEditor,{"aria-label":m,"aria-describedby":"jsonEditorDescription",languageId:Ze.XJsonLang.ID,languageConfiguration:{autoClosingPairs:[{open:"{",close:"}"}]},width:"100%",height:"250px",value:t,onChange:b,options:{renderValidationDecorations:t?"on":"off",lineNumbers:"on",fontSize:14,minimap:{enabled:!1},scrollBeyondLastLine:!1,folding:!0,wordWrap:"on",wrappingIndent:"indent",automaticLayout:!0}})))},field:oe},[bt]:{customBucket:it,customMetric:it},[ht]:{metricAgg:function({agg:e,value:t,showValidation:i,setValue:n,setValidity:s,setTouched:o,metricAggs:l=[]}){const c=u.i18n.translate("visDefaultEditor.controls.metricLabel",{defaultMessage:"Metric"}),d=!!t;Object(re.g)(s,d),Object(re.e)(n,Be,l,t);const p=Object(a.useMemo)((()=>l.filter((t=>t.type.name!==e.type.name))),[l,e.type.name]),m=Object(re.d)(Be,p,ze),f=Object(a.useCallback)((e=>n(e.target.value)),[n]);return Object(g.jsx)(r.EuiFormRow,{label:c,fullWidth:!0,isInvalid:i&&!d,display:"rowCompressed"},Object(g.jsx)(r.EuiSelect,{compressed:!0,fullWidth:!0,options:m,value:t||Ve,onChange:f,isInvalid:i&&!d,onBlur:o,"data-test-subj":`visEditorSubAggMetric${e.id}`}))},customMetric:function({agg:e,aggParam:t,formIsTouched:i,metricAggs:s,state:o,setValue:l,setValidity:c,setTouched:d,schemas:u}){Object(a.useEffect)((()=>{"custom"!==e.params.metricAgg?l(void 0):e.params.customMetric||l(t.makeAgg(e))}),[s,e,l,t]);const{onAggTypeChange:p,setAggParamValue:m}=Object(re.f)(e,t,e.params.customMetric,l);return"custom"===e.params.metricAgg&&e.params.customMetric?Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiSpacer,{size:"m"}),Object(g.jsx)(Ot,{agg:e.params.customMetric,allowedAggs:t.allowedAggs,groupName:h.AggGroupNames.Metrics,className:"visEditorAgg__subAgg",formIsTouched:i,indexPattern:e.getIndexPattern(),metricAggs:s,state:o,setAggParamValue:m,onAggTypeChange:p,setValidity:c,setTouched:d,schemas:u,hideCustomLabel:!0})):null}},[h.AggGroupNames.Buckets]:vt,[h.AggGroupNames.Metrics]:jt};function Et(e){let t="";if(e.type&&e.type.makeLabel)try{t=e.type.makeLabel(e)}catch(e){}return t}const yt="fixedValue",wt="default";function Ot({agg:e,aggError:t,aggIndex:i=0,aggIsTooLow:o=!1,className:l,disabledParams:p,groupName:m,formIsTouched:f,indexPattern:b,metricAggs:v,state:x,setAggParamValue:E,onAggTypeChange:y,setTouched:w,setValidity:O,schemas:_,allowedAggs:S=[],hideCustomLabel:T=!1}){var k,A,C;const M=Object(a.useMemo)((()=>j(_,e.schema)),[e.schema,_]),I=Object(a.useMemo)((()=>[...S,...M.aggFilter||[]]),[S,M.aggFilter]),{services:R}=Object(s.useKibana)(),L=Object(a.useMemo)((()=>R.data.search.aggs.types.getAll()),[R.data.search.aggs.types]),P=Object(a.useMemo)((()=>function(e,t,i,a,n){const r=function(e,t,i,a){return e.filter((e=>J.every((n=>n(e,t,i,a)))))}(e[a],i,t,n);return Object(X.a)(r,"subtype","title")}(L,e,b,m,I)),[L,e,b,m,I]),D=o?u.i18n.translate("visDefaultEditor.aggParams.errors.aggWrongRunOrderErrorMessage",{defaultMessage:'"{schema}" aggs must run before all other buckets!',values:{schema:M.title}}):"",F=null===(k=e.type)||void 0===k?void 0:k.name,N=null===(A=e.params)||void 0===A||null===(C=A.field)||void 0===C?void 0:C.name,V=Object(a.useMemo)((()=>function(e,t,i){const a=e.getAggregationRestrictions();if(!a||!t||!i)return{};if("terms"===t)return{otherBucket:{hidden:!0},missingBucket:{hidden:!0}};const n=a[t]&&a[t][i];if(!n)return{};if("histogram"===t){const e=n.interval;return e?{intervalBase:{fixedValue:e},interval:{base:e,help:u.i18n.translate("visDefaultEditor.editorConfig.histogram.interval.helpText",{defaultMessage:"Must be a multiple of configuration interval: {interval}",values:{interval:e}})}}:{}}if("date_histogram"===t){const e=n.calendar_interval||n.fixed_interval;return{useNormalizedEsInterval:{fixedValue:!1},interval:{default:e,timeBase:e,help:u.i18n.translate("visDefaultEditor.editorConfig.dateHistogram.customInterval.helpText",{defaultMessage:"Must be a multiple of configuration interval: {interval}",values:{interval:e}})}}}return{}}(b,F,N)),[b,F,N]),H=Object(a.useMemo)((()=>function({agg:e,editorConfig:t,metricAggs:i,state:a,schemas:n,hideCustomLabel:r}){const s={basic:[],advanced:[]},o=e.type&&e.type.params.filter((e=>!Object(d.get)(t,[e.name,"hidden"],!1)))||[],l=j(n,e.schema);return o.forEach(((o,c)=>{let u,g=[];if(r&&"customLabel"===o.name)return;if("timeShift"===o.name)return;if("field"===o.type){let t=o.getAvailableFields(e);if("top_hits"===e.type.name&&"field"===o.name&&(Object(d.get)(l,`aggSettings[${e.type.name}].allowStrings`,!1)||(t=t.filter((e=>"number"===e.type)))),u=function(e,t){return e.filter((e=>Y.every((i=>i(e,t)))))}(t,e),g=Object(X.a)(u,"type","displayName","name"),u&&!g.length&&c>0)return}const p=o.advanced?"advanced":"basic";let m;if(e.type.subtype&&xt[e.type.subtype])m=Object(d.get)(xt,[e.type.subtype,o.name]);else{const t=e.type.type,i=e.type.name,a=Object(d.get)(xt,[t,i],{});m=Object(d.get)(a,o.name)}m||(m=Object(d.get)(xt,["common",o.type])),m&&s[p].push({agg:e,aggParam:o,editorConfig:t,indexedFields:g,paramEditor:m,metricAggs:i,state:a,value:e.params[o.name],schemas:n,hideCustomLabel:r})})),s}({agg:e,editorConfig:V,metricAggs:v,state:x,schemas:_,hideCustomLabel:T})),[e,V,v,x,_,T]),K=[...H.basic,...H.advanced],[Q,Z]=Object(a.useReducer)($,K,q),[ee,te]=Object(a.useReducer)(G,{touched:!1,valid:!0}),ie=!D&&ee.valid&&Object.entries(Q).every((([,e])=>e.valid)),ae=!!D||function(e,t,i){if(!e)return t.touched;const a=Object.values(i).filter((e=>!e.valid));return!Object(d.isEmpty)(a)&&a.every((e=>e.touched))}(e.type,ee,Q),ne=Object(a.useCallback)((t=>{e.type!==t&&(y(e.id,t),Z({type:z.RESET}))}),[y,e]);return B()((()=>O(!0))),Object(a.useEffect)((()=>{Object.entries(V).forEach((([t,i])=>{const a=e.type.params.find((e=>e.name===t)),n=i.hasOwnProperty(yt),r=i.hasOwnProperty(wt);if(n||r){let n,s=yt,o=i;r&&(s=wt,o=i),n=a&&a.deserialize?a.deserialize(o[s]):o[s],e.params[t]!==n&&E(e.id,t,n)}}))}),[V]),Object(a.useEffect)((()=>{w(!1)}),[e.type,w]),Object(a.useEffect)((()=>{O(ie)}),[ie,e.type,O]),Object(a.useEffect)((()=>{w(ae)}),[ae,w]),Object(g.jsx)(r.EuiForm,{className:l,isInvalid:!!D,error:D,"data-test-subj":"visAggEditorParams"},Object(g.jsx)(W,{aggError:t,id:e.id,indexPattern:b,value:e.type,aggTypeOptions:P,isSubAggregation:i>=1&&m===h.AggGroupNames.Buckets,showValidation:f||ee.touched,setValue:ne,onChangeAggType:te}),H.basic.map((t=>{const i=Q[t.aggParam.name]||{touched:!1,valid:!0};return Object(g.jsx)(U,c()({key:`${t.aggParam.name}${e.type?e.type.name:""}`,disabled:p&&p.includes(t.aggParam.name),formIsTouched:f,showValidation:f||i.touched,setAggParamValue:E,onChangeParamsState:Z},t))})),H.advanced.length?Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiSpacer,{size:"m"}),Object(g.jsx)(r.EuiAccordion,{id:"advancedAccordion","data-test-subj":`advancedParams-${e.id}`,buttonContent:u.i18n.translate("visDefaultEditor.advancedToggle.advancedLinkLabel",{defaultMessage:"Advanced"})},Object(g.jsx)(r.EuiSpacer,{size:"s"}),H.advanced.map((t=>{const i=Q[t.aggParam.name]||{touched:!1,valid:!0};return Object(g.jsx)(U,c()({key:`${t.aggParam.name}${e.type?e.type.name:""}`,disabled:p&&p.includes(t.aggParam.name),formIsTouched:f,showValidation:f||i.touched,setAggParamValue:E,onChangeParamsState:Z},t))})))):null)}let _t;function St(e,t){const i=e[t.aggId]||{touched:!1,valid:!0};switch(t.type){case _t.TOUCHED:return{...e,[t.aggId]:{...i,touched:t.payload}};case _t.VALID:return{...e,[t.aggId]:{...i,valid:t.payload}};default:throw new Error}}function Tt(e){return e.reduce(((e,t)=>(e[t.id]={touched:!1,valid:!0},e)),{})}!function(e){e.TOUCHED="aggsTouched",e.VALID="aggsValid"}(_t||(_t={}));const kt={NAME:"row",ROWS:"visEditorSplitBy__true",COLUMNS:"visEditorSplitBy__false"};function At({editorStateParams:e,setStateParamValue:t}){void 0===e.row&&t(kt.NAME,!0);const i=`visEditorSplitBy__${e.row}`,s=[{id:kt.ROWS,label:u.i18n.translate("visDefaultEditor.controls.rowsLabel",{defaultMessage:"Rows"}),"data-test-subj":"visEditorSplitBy-Rows"},{id:kt.COLUMNS,label:u.i18n.translate("visDefaultEditor.controls.columnsLabel",{defaultMessage:"Columns"}),"data-test-subj":"visEditorSplitBy-Columns"}],o=Object(a.useCallback)((e=>t(kt.NAME,e===kt.ROWS)),[t]);return Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiFormRow,{display:"rowCompressed",fullWidth:!0},Object(g.jsx)(r.EuiButtonGroup,{"data-test-subj":"visEditorSplitBy",legend:u.i18n.translate("visDefaultEditor.controls.splitByLegend",{defaultMessage:"Split chart by rows or columns."}),options:s,isFullWidth:!0,idSelected:i,onChange:o})),Object(g.jsx)(r.EuiSpacer,{size:"m"}))}const Ct=50,Mt="radiusRatio";function It({editorStateParams:e,setStateParamValue:t}){const i=Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.controls.dotSizeRatioLabel",defaultMessage:"Dot size ratio"})," ",Object(g.jsx)(r.EuiIconTip,{content:u.i18n.translate("visDefaultEditor.controls.dotSizeRatioHelpText",{defaultMessage:"Change the ratio of the radius of the smallest point to the largest point."}),position:"right"}));te()((()=>{e.radiusRatio||t(Mt,Ct)}));const s=Object(a.useCallback)((e=>t(Mt,parseFloat(e.currentTarget.value))),[t]);return Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiFormRow,{fullWidth:!0,label:i,display:"rowCompressed"},Object(g.jsx)(r.EuiRange,{compressed:!0,fullWidth:!0,min:1,max:100,value:e.radiusRatio||Ct,onChange:s,showRange:!0,showValue:!0,valueAppend:"%"})),Object(g.jsx)(r.EuiSpacer,{size:"m"}))}function Rt({agg:e,aggIndex:t,aggIsTooLow:i,dragHandleProps:s,formIsTouched:o,groupName:l,isDisabled:d,isDraggable:p,isLastBucket:m,isRemovable:f,metricAggs:b,lastParentPipelineAggTitle:h,state:v,setAggParamValue:x,setStateParamValue:E,onAggTypeChange:y,onToggleEnableAgg:w,removeAgg:O,setAggsState:_,schemas:S,timeRange:T}){var k;const[A,C]=Object(a.useState)(e.brandNew),[M,I]=Object(a.useState)(!0),R=!A&&M,L=!A&&!M,P=null===(k=e.type)||void 0===k?void 0:k.name,D=j(S,e.schema).title;let F,N;const B=m&&h&&e.type;let V;"split"===e.schema&&(V=At),"radius"===e.schema&&(V=It),B&&(["date_histogram","histogram"].includes(P)?F=["min_doc_count"]:N=u.i18n.translate("visDefaultEditor.metrics.wrongLastBucketTypeErrorMessage",{defaultMessage:'Last bucket aggregation must be "Date Histogram" or "Histogram" when using "{type}" metric aggregation.',values:{type:h},description:"Date Histogram and Histogram should not be translated"}));const[z,G]=Object(a.useState)(Et(e));Object(a.useEffect)((()=>{T&&"date_histogram"===P&&e.aggConfigs.setTimeRange(T),G(Et(e))}),[e,P,T]),Object(a.useEffect)((()=>{B&&["date_histogram","histogram"].includes(P)&&x(e.id,"min_doc_count","histogram"===P||0)}),[P,B,e.id,x]);const $=Object(a.useCallback)((t=>{_({type:_t.TOUCHED,payload:t,aggId:e.id})}),[e.id,_]),q=Object(a.useCallback)((t=>{_({type:_t.VALID,payload:t,aggId:e.id}),I(t)}),[e.id,_]),W=Object(a.useCallback)((e=>{C(e),e||$(!0)}),[$]),U=Object(g.jsx)(n.a.Fragment,null,D||e.schema," ",R&&Object(g.jsx)("span",null,z));return Object(g.jsx)(r.EuiAccordion,{id:`visEditorAggAccordion${e.id}`,initialIsOpen:A,buttonContent:U,buttonClassName:"eui-textTruncate",buttonContentClassName:"visEditorSidebar__aggGroupAccordionButtonContent eui-textTruncate",className:"visEditorSidebar__section visEditorSidebar__collapsible visEditorSidebar__collapsible--marginBottom","aria-label":u.i18n.translate("visDefaultEditor.agg.toggleEditorButtonAriaLabel",{defaultMessage:"Toggle {schema} editor",values:{schema:D||e.schema}}),"data-test-subj":`visEditorAggAccordion${e.id}`,extraAction:(()=>{var t,i;const a=[],o=null===(t=e.type)||void 0===t||null===(i=t.title)||void 0===i?void 0:i.toLowerCase();return L&&a.push({id:"hasErrors",color:"danger",type:"error",tooltip:u.i18n.translate("visDefaultEditor.agg.errorsAriaLabel",{defaultMessage:"{schemaTitle} {aggTitle} aggregation has errors",values:{aggTitle:o,schemaTitle:D}}),dataTestSubj:"hasErrorsAggregationIcon"}),e.enabled&&f&&a.push({id:"disableAggregation",color:"text",disabled:d,type:"eye",onClick:()=>w(e.id,!1),tooltip:u.i18n.translate("visDefaultEditor.agg.disableAggButtonTooltip",{defaultMessage:"Disable {schemaTitle} {aggTitle} aggregation",values:{aggTitle:o,schemaTitle:D}}),dataTestSubj:"toggleDisableAggregationBtn disable"}),e.enabled||a.push({id:"enableAggregation",color:"text",type:"eyeClosed",onClick:()=>w(e.id,!0),tooltip:u.i18n.translate("visDefaultEditor.agg.enableAggButtonTooltip",{defaultMessage:"Enable {schemaTitle} {aggTitle} aggregation",values:{aggTitle:o,schemaTitle:D}}),dataTestSubj:"toggleDisableAggregationBtn enable"}),p&&a.push({id:"dragHandle",color:"text",type:"grab",tooltip:u.i18n.translate("visDefaultEditor.agg.modifyPriorityButtonTooltip",{defaultMessage:"Modify priority of {schemaTitle} {aggTitle} by dragging",values:{aggTitle:o,schemaTitle:D}}),dataTestSubj:"dragHandleBtn"}),f&&a.push({id:"removeDimension",color:"danger",type:"cross",onClick:()=>O(e.id),tooltip:u.i18n.translate("visDefaultEditor.agg.removeDimensionButtonTooltip",{defaultMessage:"Remove {schemaTitle} {aggTitle} aggregation",values:{aggTitle:o,schemaTitle:D}}),dataTestSubj:"removeDimensionBtn"}),a.length?Object(g.jsx)(n.a.Fragment,null,a.map((e=>Object(g.jsx)(r.EuiToolTip,{key:e.id,position:"bottom",content:e.tooltip},Object(g.jsx)(r.EuiButtonIcon,c()({disabled:e.disabled,iconType:e.type,color:e.color,onClick:e.onClick,"aria-label":e.tooltip,"data-test-subj":e.dataTestSubj},"dragHandle"===e.id?s:{})))))):null})(),onToggle:W},Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiSpacer,{size:"m"}),V&&Object(g.jsx)(V,{agg:e,editorStateParams:v.params,setAggParamValue:x,setStateParamValue:E}),Object(g.jsx)(Ot,{agg:e,aggError:N,aggIndex:t,aggIsTooLow:i,disabledParams:F,formIsTouched:o,groupName:l,indexPattern:e.getIndexPattern(),metricAggs:b,state:v,setAggParamValue:x,onAggTypeChange:y,setTouched:$,setValidity:q,schemas:S})))}function Lt({group:e=[],groupName:t,schemas:i,addSchema:n,stats:s}){const[o,l]=Object(a.useState)(!1),c=t===h.AggGroupNames.Buckets?u.i18n.translate("visDefaultEditor.aggAdd.bucketLabel",{defaultMessage:"bucket"}):u.i18n.translate("visDefaultEditor.aggAdd.metricLabel",{defaultMessage:"metric"}),d=Object(g.jsx)(r.EuiButtonEmpty,{size:"s",iconType:"plusInCircleFilled","data-test-subj":`visEditorAdd_${t}`,onClick:()=>l(!o),"aria-label":u.i18n.translate("visDefaultEditor.aggAdd.addGroupButtonLabel",{defaultMessage:"Add {groupNameLabel}",values:{groupNameLabel:c}})},Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.aggAdd.addButtonLabel",defaultMessage:"Add"})),p=(e,t)=>{var i;return null!==(i=e.disabled)&&void 0!==i?i:t},f=u.i18n.translate("visDefaultEditor.aggAdd.maxBuckets",{defaultMessage:"Max {groupNameLabel} count reached",values:{groupNameLabel:c}});return Object(g.jsx)(r.EuiFlexGroup,{justifyContent:"center",responsive:!1},Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(r.EuiPopover,{id:`addGroupButtonPopover_${t}`,button:d,isOpen:o,panelPaddingSize:"none",repositionOnScroll:!0,closePopover:()=>l(!1)},Object(g.jsx)(r.EuiPopoverTitle,{paddingSize:"s"},(t!==h.AggGroupNames.Buckets||!s.count)&&Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.aggAdd.addGroupButtonLabel",defaultMessage:"Add {groupNameLabel}",values:{groupNameLabel:c}}),t===h.AggGroupNames.Buckets&&s.count>0&&Object(g.jsx)(m.FormattedMessage,{id:"visDefaultEditor.aggAdd.addSubGroupButtonLabel",defaultMessage:"Add sub-{groupNameLabel}",values:{groupNameLabel:c}})),Object(g.jsx)(r.EuiContextMenuPanel,{items:i.map((i=>{var a;const s=(t=>e.filter((e=>e.schema===t.name)).length>=t.max)(i);return Object(g.jsx)(r.EuiContextMenuItem,{key:`${i.name}_${i.title}`,"data-test-subj":`visEditorAdd_${t}_${i.title}`,disabled:o&&p(i,s),onClick:()=>(e=>{l(!1),n(e)})(i),toolTipContent:null!==(a=i.tooltip)&&void 0!==a?a:s?f:void 0},i.title)}))}))))}function Pt({formIsTouched:e,groupName:t,lastParentPipelineAggTitle:i,metricAggs:s,state:o,schemas:l=[],addSchema:c,setAggParamValue:p,setStateParamValue:m,onAggTypeChange:f,onToggleEnableAgg:b,removeAgg:v,reorderAggs:j,setTouched:w,setValidity:O,timeRange:_}){const S=h.AggGroupLabels[t],T=l.map((e=>e.name)),k=Object(a.useMemo)((()=>{var e;return(null===(e=o.data.aggs)||void 0===e?void 0:e.aggs.filter((e=>e.schema&&T.includes(e.schema))))||[]}),[o.data.aggs,T]),A={max:0,count:k.length};l.forEach((e=>{A.max+=e.max}));const[C,M]=Object(a.useReducer)(St,k,Tt),I=i&&t===h.AggGroupNames.Buckets&&!k.length?u.i18n.translate("visDefaultEditor.buckets.mustHaveBucketErrorMessage",{defaultMessage:'Add a bucket with "Date Histogram" or "Histogram" aggregation.',description:"Date Histogram and Histogram should not be translated"}):void 0,R=!I&&Object.values(C).every((e=>e.valid)),L=function(e){const t=Object.values(e).filter((e=>!e.valid));return!Object(d.isEmpty)(t)&&t.every((e=>e.touched))}(C),P=Object(a.useMemo)((()=>t===h.AggGroupNames.Metrics&&1===E(k)),[t,k]);Object(a.useEffect)((()=>{w(L)}),[L,w]),Object(a.useEffect)((()=>{e&&!L&&Object.keys(C).map((([e])=>{M({type:_t.TOUCHED,payload:!0,aggId:e})}))}),[e]),Object(a.useEffect)((()=>{O(`aggGroup__${t}`,R)}),[t,R,O]);const D=Object(a.useCallback)((({source:e,destination:t})=>{e&&t&&j(k[e.index],k[t.index])}),[j,k]);return Object(g.jsx)(r.EuiDragDropContext,{onDragEnd:D},Object(g.jsx)(r.EuiPanel,{"data-test-subj":`${t}AggGroup`,paddingSize:"s"},Object(g.jsx)(r.EuiTitle,{size:"xs"},Object(g.jsx)("h3",null,S)),Object(g.jsx)(r.EuiSpacer,{size:"s"}),I&&Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiFormErrorText,{"data-test-subj":"bucketsError"},I),Object(g.jsx)(r.EuiSpacer,{size:"s"})),Object(g.jsx)(r.EuiDroppable,{droppableId:`agg_group_dnd_${t}`,className:"visEditorSidebar__collapsible--marginBottom"},Object(g.jsx)(n.a.Fragment,null,k.map(((e,a)=>Object(g.jsx)(r.EuiDraggable,{key:e.id,index:a,draggableId:`agg_group_dnd_${t}_${e.id}`,customDragHandle:!0,disableInteractiveElementBlocking:!0},(n=>Object(g.jsx)(Rt,{agg:e,aggIndex:a,aggIsTooLow:y(e,a,k,l),dragHandleProps:n.dragHandleProps||null,formIsTouched:!!C[e.id]&&C[e.id].touched,groupName:t,isDraggable:A.count>1,isLastBucket:t===h.AggGroupNames.Buckets&&a===k.length-1,isRemovable:x(e,k,l),isDisabled:"metric"===e.schema&&P,lastParentPipelineAggTitle:i,metricAggs:s,state:o,setAggParamValue:p,setStateParamValue:m,onAggTypeChange:f,onToggleEnableAgg:b,removeAgg:v,setAggsState:M,schemas:l,timeRange:_}))))))),A.max>A.count&&Object(g.jsx)(Lt,{group:k,groupName:t,schemas:l,stats:A,addSchema:c})))}function Dt({dispatch:e,formIsTouched:t,metricAggs:i,schemas:s,state:o,setTouched:l,setValidity:u,setStateValue:p,timeRange:m}){const f=Object(a.useMemo)((()=>Object(d.findLast)(i,(({type:e})=>e.subtype===h.search.aggs.parentPipelineType))),[i]),b=f&&f.type.title,v=Object(a.useCallback)((t=>e(S(t))),[e]),j=Object(a.useCallback)((t=>e(M(t,s.all||[]))),[e,s]),x=Object(a.useCallback)(((...t)=>e(I(...t))),[e]),E=Object(a.useCallback)(((...t)=>e(A(...t))),[e]),y=Object(a.useCallback)(((...t)=>e(k(...t))),[e]),w=Object(a.useCallback)(((...t)=>e(R(...t))),[e]),O={addSchema:v,formIsTouched:t,lastParentPipelineAggTitle:b,metricAggs:i,state:o,reorderAggs:x,setAggParamValue:E,setStateParamValue:p,onAggTypeChange:y,onToggleEnableAgg:w,setValidity:u,setTouched:l,removeAgg:j};return Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(Pt,c()({groupName:h.AggGroupNames.Metrics,schemas:s.metrics},O)),Object(g.jsx)(r.EuiSpacer,{size:"s"}),Object(g.jsx)(Pt,c()({groupName:h.AggGroupNames.Buckets,schemas:s.buckets,timeRange:m},O)))}const Ft=({type:e})=>{const[t,i]=Object(a.useState)((()=>{var t,i;const a=[...null!==(t=e.schemas.buckets)&&void 0!==t&&t.length||null!==(i=e.schemas.metrics)&&void 0!==i&&i.length?[{name:"data",title:u.i18n.translate("visDefaultEditor.sidebar.tabs.dataLabel",{defaultMessage:"Data"}),editor:Dt}]:[],...!e.editorConfig.optionTabs&&e.editorConfig.optionsTemplate?[{name:"options",title:u.i18n.translate("visDefaultEditor.sidebar.tabs.optionsLabel",{defaultMessage:"Options"}),editor:e.editorConfig.optionsTemplate}]:e.editorConfig.optionTabs];return a[0].isSelected=!0,a}));return[t,Object(a.useCallback)((e=>{i((t=>t.map((t=>({...t,isSelected:t.name===e})))))}),[])]};function Nt({embeddableHandler:e,isCollapsed:t,onClickCollapse:i,uiState:o,vis:l,isLinkedSearch:m,eventEmitter:f,savedSearch:b,timeRange:h}){const[j,x]=Object(a.useState)(!1),[E,y]=function(e,t){const{services:i}=Object(s.useKibana)(),[n,r]=Object(a.useReducer)(O(i.data.search),e,w);return[n,Object(a.useCallback)((e=>{r(e),t.emit("dirtyStateChange",{isDirty:e.type!==v.DISCARD_CHANGES})}),[t])]}(l,f),{formState:S,setTouched:k,setValidity:A,resetValidity:M}=function(){const[e,t]=Object(a.useState)(_),i=Object(a.useCallback)(((e,i)=>{t((t=>{const a={...t.validity,[e]:i};return{...t,validity:a,invalid:Object.values(a).some((e=>!e))}}))}),[]),n=Object(a.useCallback)((()=>{t(_)}),[]);return{formState:e,setValidity:i,setTouched:Object(a.useCallback)((e=>{t((t=>({...t,touched:e})))}),[]),resetValidity:n}}(),[I,R]=Ft(l),P=Object(a.useMemo)((()=>E.data.aggs?E.data.aggs.getResponseAggs():[]),[E.data.aggs]),D=(l.type.schemas.metrics||[]).map((e=>e.name)),N=Object(a.useMemo)((()=>P.filter((e=>e.schema&&D.includes(e.schema)))),[P,D]),B=Object(a.useMemo)((()=>P.some((e=>"histogram"===e.type.name))),[P]),V=Object(a.useCallback)((e=>{A("visOptions",e)}),[A]),z=Object(a.useCallback)(((e,t)=>{!Object(d.isEqual)(E.params[e],t)&&y(C(e,t))}),[y,E.params]),G=Object(a.useCallback)((()=>{!S.invalid&&j?(l.setState({...l.serialize(),params:E.params,data:{aggs:E.data.aggs?E.data.aggs.aggs.map((e=>e.serialize())):[]}}),e.reload(),f.emit("dirtyStateChange",{isDirty:!1}),k(!1)):k(!0)}),[l,E,S.invalid,k,j,f,e]),$=Object(a.useCallback)((e=>{e.ctrlKey&&e.key===r.keys.ENTER&&(e.preventDefault(),e.stopPropagation(),G())}),[G]);Object(a.useEffect)((()=>{const e=({isDirty:e})=>{x(e),e||M()};return f.on("dirtyStateChange",e),()=>{f.off("dirtyStateChange",e)}}),[M,f]),Object(a.useEffect)((()=>{const e=()=>y(T(l));return f.on("updateEditor",e),()=>{f.off("updateEditor",e)}}),[y,l,f]);const q={dispatch:y,formIsTouched:S.touched,metricAggs:N,state:E,schemas:l.type.schemas,setValidity:A,setTouched:k,setStateValue:z},W={aggs:E.data.aggs,hasHistogramAgg:B,stateParams:E.params,vis:l,uiState:o,setValue:z,setValidity:V,setTouched:k};return Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(r.EuiFlexGroup,{className:"visEditorSidebar",direction:"column",justifyContent:"spaceBetween",gutterSize:"none",responsive:!1},Object(g.jsx)(r.EuiFlexItem,null,Object(g.jsx)("form",{className:"visEditorSidebar__form",name:"visualizeEditor",onKeyDownCapture:$},l.type.requiresSearch&&Object(g.jsx)(F,{isLinkedSearch:m,savedSearch:b,vis:l,eventEmitter:f}),I.length>1&&Object(g.jsx)(p,{optionTabs:I,setSelectedTab:R}),I.map((({editor:e,name:t,isSelected:i=!1})=>Object(g.jsx)("div",{key:t,className:"visEditorSidebar__config "+(i?"":"visEditorSidebar__config-isHidden")},Object(g.jsx)(e,c()({isTabSelected:i},"data"===t?q:W,{timeRange:h}))))))),Object(g.jsx)(r.EuiFlexItem,{grow:!1},Object(g.jsx)(L,{applyChanges:G,dispatch:y,isDirty:j,isTouched:S.touched,isInvalid:S.invalid,vis:l}))),Object(g.jsx)(r.EuiButtonIcon,{"aria-expanded":!t,"aria-label":u.i18n.translate("visDefaultEditor.sidebar.collapseButtonAriaLabel",{defaultMessage:"Toggle sidebar"}),className:"visEditor__collapsibleSidebarButton","data-test-subj":"collapseSideBarButton",color:"text",iconType:t?"menuLeft":"menuRight",onClick:i}))}const Bt=Object(a.memo)(Nt);var Vt=i(13);const zt=new o.Storage(window.localStorage);function Gt({core:e,data:t,vis:i,uiState:o,timeRange:l,filters:c,query:d,embeddableHandler:u,eventEmitter:p,linked:m,savedSearch:f}){const b=Object(a.useRef)(null),[h,v]=Object(a.useState)(!1),j=Object(a.useCallback)((()=>{v((e=>!e))}),[]),x=Object(a.useCallback)((()=>{}),[]);Object(a.useEffect)((()=>{if(b.current)return u.render(b.current).then((()=>{setTimeout((async()=>{p.emit("embeddableRendered")}))})),()=>u.destroy()}),[u,p]),Object(a.useEffect)((()=>{u.updateInput({timeRange:l,filters:c,query:d})}),[u,l,c,d]);const E=Object(Vt.b)(i.type.editorConfig.defaultSize);return Object(g.jsx)(e.i18n.Context,null,Object(g.jsx)(s.KibanaContextProvider,{services:{appName:"vis_default_editor",storage:zt,data:t,...e}},Object(g.jsx)(r.EuiResizableContainer,{className:"visEditor--default",onMouseLeave:x},((e,t)=>Object(g.jsx)(n.a.Fragment,null,Object(g.jsx)(e,{className:"visEditor__visualization",initialSize:100-E,minSize:"25%",paddingSize:"none",wrapperProps:{className:"visEditor__visualization__wrapper "+(h?"visEditor__visualization__wrapper-expanded":"")}},Object(g.jsx)("div",{className:"visEditor__canvas",ref:b,"data-shared-items-container":!0})),Object(g.jsx)(t,{className:"visEditor__resizer "+(h?"visEditor__resizer-isHidden":"")}),Object(g.jsx)(e,{initialSize:E,minSize:h?"0":"350px",paddingSize:"none",wrapperProps:{className:"visEditor__collapsibleSidebar "+(h?"visEditor__collapsibleSidebar-isClosed":"")}},Object(g.jsx)(Bt,{embeddableHandler:u,isCollapsed:h,onClickCollapse:j,vis:i,uiState:o,isLinkedSearch:m,savedSearch:f,timeRange:l,eventEmitter:p})))))))}}}]);