/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.security_bundle_jsonpfunction=window.security_bundle_jsonpfunction||[]).push([[8],{251:function(e,t,n){e.exports=n(28)(3825)},252:function(e,t,n){ace.define("ace/mode/json_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],(function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,o=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"}]}};r.inherits(o,i),t.JsonHighlightRules=o})),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],(function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return!!/^\s+$/.test(e)&&/^\s*\}/.test(t)},this.autoOutdent=function(e,t){var n=e.getLine(t).match(/^(\s*\})/);if(!n)return 0;var i=n[1].length,o=e.findMatchingBracket({row:t,column:i});if(!o||o.row==t)return 0;var s=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,i-1),s)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i})),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],(function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,o=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)))};r.inherits(s,o),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,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i,o=e.getLine(n);if(this.startRegionRe.test(o))return this.getCommentRegionBlock(e,o,n);if(i=o.match(this.foldingStartMarker)){var s=i.index;if(i[1])return this.openingBracketBlock(e,i[1],n,s);var a=e.getCommentFoldRange(n,s+i[0].length,1);return a&&!a.isMultiLine()&&(r?a=this.getSectionRange(e,n):"all"!=t&&(a=null)),a}return"markbegin"!==t&&(i=o.match(this.foldingStopMarker))?(s=i.index+i[0].length,i[1]?this.closingBracketBlock(e,i[1],n,s):e.getCommentFoldRange(n,s,-1)):void 0},this.getSectionRange=function(e,t){for(var n=e.getLine(t),r=n.search(/\S/),o=t,s=n.length,a=t+=1,l=e.getLength();++tc)break;var u=this.getFoldWidgetRange(e,"all",t);if(u){if(u.start.row<=o)break;if(u.isMultiLine())t=u.end.row;else if(r==c)break}a=t}}return new i(o,s,a,e.getLine(a).length)},this.getCommentRegionBlock=function(e,t,n){for(var r=t.search(/\s*$/),o=e.getLength(),s=n,a=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,l=1;++ns)return new i(s,r,n,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,r){"use strict";var i=e("../lib/oop"),o=e("./text").Mode,s=e("./json_highlight_rules").JsonHighlightRules,a=e("./matching_brace_outdent").MatchingBraceOutdent,l=e("./behaviour/cstyle").CstyleBehaviour,c=e("./folding/cstyle").FoldMode,u=e("../worker/worker_client").WorkerClient,p=function(){this.HighlightRules=s,this.$outdent=new a,this.$behaviour=new l,this.foldingRules=new c};i.inherits(p,o),function(){this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t);return"start"==e&&t.match(/^.*[\{\(\[]\s*$/)&&(r+=n),r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.createWorker=function(e){var t=new u(["ace"],n(253),"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(p.prototype),t.Mode=p}))},253: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)}});'},254:function(e,t){ace.define("ace/theme/github",["require","exports","module","ace/lib/dom"],(function(e,t,n){t.isDark=!1,t.cssClass="ace-github",t.cssText='.ace-github .ace_gutter {background: #e8e8e8;color: #AAA;}.ace-github {background: #fff;color: #000;}.ace-github .ace_keyword {font-weight: bold;}.ace-github .ace_string {color: #D14;}.ace-github .ace_variable.ace_class {color: teal;}.ace-github .ace_constant.ace_numeric {color: #099;}.ace-github .ace_constant.ace_buildin {color: #0086B3;}.ace-github .ace_support.ace_function {color: #0086B3;}.ace-github .ace_comment {color: #998;font-style: italic;}.ace-github .ace_variable.ace_language {color: #0086B3;}.ace-github .ace_paren {font-weight: bold;}.ace-github .ace_boolean {font-weight: bold;}.ace-github .ace_string.ace_regexp {color: #009926;font-weight: normal;}.ace-github .ace_variable.ace_instance {color: teal;}.ace-github .ace_constant.ace_language {font-weight: bold;}.ace-github .ace_cursor {color: black;}.ace-github.ace_focus .ace_marker-layer .ace_active-line {background: rgb(255, 255, 204);}.ace-github .ace_marker-layer .ace_active-line {background: rgb(245, 245, 245);}.ace-github .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-github.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;}.ace-github.ace_nobold .ace_line > span {font-weight: normal !important;}.ace-github .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-github .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-github .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-github .ace_gutter-active-line {background-color : rgba(0, 0, 0, 0.07);}.ace-github .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-github .ace_invisible {color: #BFBFBF}.ace-github .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-github .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}',e("../lib/dom").importCssString(t.cssText,t.cssClass)}))},255:function(e,t,n){switch(window.__kbnThemeTag__){case"v8dark":return n(256);case"v8light":return n(258)}},256:function(e,t,n){var r=n(58),i=n(257);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);r(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},257:function(e,t,n){(t=n(59)(!1)).push([e.i,".secRoleMapping__ruleEditorGroup--even{background-color:#25262e}.secRoleMapping__ruleEditorGroup--odd{background-color:#1d1e24}",""]),e.exports=t},258:function(e,t,n){var r=n(58),i=n(259);"string"==typeof(i=i.__esModule?i.default:i)&&(i=[[e.i,i,""]]);r(i,{insert:"head",singleton:!1}),e.exports=i.locals||{}},259:function(e,t,n){(t=n(59)(!1)).push([e.i,".secRoleMapping__ruleEditorGroup--even{background-color:#f5f7fa}.secRoleMapping__ruleEditorGroup--odd{background-color:#fff}",""]),e.exports=t},299:function(e,t,n){"use strict";n.r(t),n.d(t,"EditRoleMappingPage",(function(){return edit_role_mapping_page_EditRoleMappingPage}));var r=n(1),i=n.n(r),o=n(3),s=n(2),a=n.n(s),l=n(4),c=n(6),u=n(13),p=n.n(u),d=n(0);const g=e=>{if(!e.canUseStoredScripts&&!e.canUseInlineScripts)return Object(d.jsx)(o.EuiCallOut,{iconType:"warning",color:"danger",title:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleTemplatesUnavailableTitle",defaultMessage:"Role templates unavailable"})},Object(d.jsx)("p",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleTemplatesUnavailable",defaultMessage:"Role templates cannot be used when scripts are disabled in Elasticsearch."})));const t=Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.addRoleTemplate",defaultMessage:"Add template"});return e.canUseInlineScripts?Object(d.jsx)(o.EuiButtonEmpty,{iconType:"plusInCircle",onClick:()=>e.onClick("inline"),"data-test-subj":"addRoleTemplateButton"},t):Object(d.jsx)(o.EuiButtonEmpty,{iconType:"plusInCircle",onClick:()=>e.onClick("stored"),"data-test-subj":"addRoleTemplateButton"},t)};function h(e){return null!=e.template&&e.template.hasOwnProperty("id")&&"string"==typeof e.template.id}function m(e){return null!=e.template&&e.template.hasOwnProperty("source")&&"string"==typeof e.template.source}const f=[{id:"inline",label:l.i18n.translate("xpack.security.management.editRoleMapping.roleTemplate.inlineTypeLabel",{defaultMessage:"Role template"})},{id:"stored",label:l.i18n.translate("xpack.security.management.editRoleMapping.roleTemplate.storedTypeLabel",{defaultMessage:"Stored script"})}],b=e=>{void 0===e.readOnly&&(e.readOnly=!1);const t=f.filter((({id:t})=>"inline"===t&&e.canUseInlineScripts||"stored"===t&&e.canUseStoredScripts)),n=f.filter((({id:t})=>"inline"===t&&m(e.roleTemplate)||"stored"===t&&h(e.roleTemplate)));return Object(d.jsx)(o.EuiComboBox,{options:t,singleSelection:{asPlainText:!0},selectedOptions:n,"data-test-subj":"roleMappingsFormTemplateType",onChange:t=>{const[{id:n}]=t;"inline"===n?e.onChange({...e.roleTemplate,template:{source:""}}):e.onChange({...e.roleTemplate,template:{id:""}})},isClearable:!1,isDisabled:e.readOnly})},j=({roleTemplate:e,onChange:t,onDelete:n,canUseInlineScripts:r,canUseStoredScripts:i,readOnly:a=!1})=>Object(d.jsx)(o.EuiFlexGroup,{direction:"column",gutterSize:"s"},function(){const n=Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(o.EuiFormRow,{label:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleTemplateType",defaultMessage:"Template type"})},Object(d.jsx)(b,{roleTemplate:e,canUseStoredScripts:i,canUseInlineScripts:r,onChange:t,readOnly:a}))),s=Object(d.jsx)(o.EuiFlexItem,null,function(){const n=l.i18n.translate("xpack.security.management.editRoleMapping.roleTemplateReturnsJson",{defaultMessage:"Returns JSON"});return Object(d.jsx)(o.EuiFormRow,{label:n},Object(d.jsx)(o.EuiSwitch,{"data-test-subj":"roleTemplateFormatSwitch",checked:"json"===e.format,label:n,showLabel:!1,onChange:n=>{t({...e,format:n.target.checked?"json":"string"})},disabled:a}))}());return Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(o.EuiFlexGroup,{justifyContent:"spaceBetween"},n,s))}(),function(){if(m(e)){const n={};r||a||(n.isInvalid=!0,n.error=Object(d.jsx)(o.EuiText,{size:"xs",color:"danger","data-test-subj":"roleMappingInlineScriptsDisabled"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleTemplateInlineScriptsDisabled",defaultMessage:"Template uses inline scripts, which are disabled in Elasticsearch."})));const i="{{username}}_role";return Object(d.jsx)(s.Fragment,null,Object(d.jsx)(o.EuiFlexItem,{grow:1,style:{maxWidth:"400px"}},Object(d.jsx)(o.EuiFormRow,p()({label:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleTemplateLabel",defaultMessage:"Template"}),helpText:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleTemplateHelpText",defaultMessage:"Mustache templates are allowed. Example: {example}",values:{example:i}})},n),Object(d.jsx)(o.EuiFieldText,{"data-test-subj":"roleTemplateSourceEditor",value:e.template.source,onChange:n=>{t({...e,template:{source:n.target.value}})},disabled:a}))))}if(h(e)){const n={};return i||(n.isInvalid=!0,n.error=Object(d.jsx)(o.EuiText,{size:"xs",color:"danger","data-test-subj":"roleMappingStoredScriptsDisabled"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleTemplateStoredScriptsDisabled",defaultMessage:"Template uses stored scripts, which are disabled in Elasticsearch."}))),Object(d.jsx)(s.Fragment,null,Object(d.jsx)(o.EuiFlexItem,{grow:1,style:{maxWidth:"400px"}},Object(d.jsx)(o.EuiFormRow,p()({label:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.storedScriptLabel",defaultMessage:"Stored script ID"}),helpText:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.storedScriptHelpText",defaultMessage:"ID of a previously stored Painless or Mustache script."})},n),Object(d.jsx)(o.EuiFieldText,{"data-test-subj":"roleTemplateScriptIdEditor",value:e.template.id,onChange:n=>{t({...e,template:{id:n.target.value}})},disabled:a}))))}if(!h(n=e)&&!m(n))return Object(d.jsx)(o.EuiFlexItem,{grow:1,"data-test-subj":"roleMappingInvalidRoleTemplate"},Object(d.jsx)(o.EuiCallOut,{color:"warning",title:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.invalidRoleTemplateTitle",defaultMessage:"Invalid role template"})},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.invalidRoleTemplateMessage",defaultMessage:"Role template is invalid, and cannot be edited here. Please delete and recreate, or fix via the Role Mapping API."})));var n;throw new Error("Unable to determine role template type")}(),Object(d.jsx)(o.EuiFlexItem,{grow:!1},Object(d.jsx)(o.EuiSpacer,{size:"s"}),Object(d.jsx)(o.EuiFlexGroup,{justifyContent:"flexEnd"},Object(d.jsx)(o.EuiFlexItem,{grow:!1},a?null:Object(d.jsx)(o.EuiButtonEmpty,{iconType:"trash",color:"danger",size:"xs",onClick:()=>n(e),"data-test-subj":"deleteRoleTemplateButton"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.deleteRoleTemplateButton",defaultMessage:"Delete template"}))))));var x=n(22),y=n(97);class role_selector_RoleSelector extends a.a.Component{constructor(e){super(e),i()(this,"getRoleComboBox",(()=>{const{roles:e=[]}=this.props.roleMapping;return Object(d.jsx)(y.a,{"data-test-subj":"roleMappingFormRolesCombo",placeholder:l.i18n.translate("xpack.security.management.editRoleMapping.selectRolesPlaceholder",{defaultMessage:"Select one or more roles"}),isLoading:0===this.state.roles.length,availableRoles:this.state.roles,selectedRoleNames:e,onChange:e=>{this.props.onChange({...this.props.roleMapping,roles:e,role_templates:[]})},isDisabled:this.props.readOnly})})),i()(this,"getRoleTemplates",(()=>{const{role_templates:e=[]}=this.props.roleMapping;return Object(d.jsx)("div",null,e.map(((t,n)=>Object(d.jsx)(s.Fragment,{key:n},Object(d.jsx)(j,{"data-test-subj":"roleMappingFormRoleTemplateEditor",canUseStoredScripts:this.props.canUseStoredScripts,canUseInlineScripts:this.props.canUseInlineScripts,roleTemplate:t,onChange:e=>{const t=[...this.props.roleMapping.role_templates||[]];t.splice(n,1,e),this.props.onChange({...this.props.roleMapping,role_templates:t})},onDelete:()=>{const e=[...this.props.roleMapping.role_templates||[]];e.splice(n,1),this.props.onChange({...this.props.roleMapping,role_templates:e})},readOnly:this.props.readOnly}),n===e.length-1&&this.props.readOnly?null:Object(d.jsx)(o.EuiHorizontalRule,null)))),this.conditionallyRenderAddRoleTemplateButton())})),i()(this,"conditionallyRenderAddRoleTemplateButton",(()=>this.props.readOnly?null:Object(d.jsx)(g,{canUseStoredScripts:this.props.canUseStoredScripts,canUseInlineScripts:this.props.canUseInlineScripts,onClick:e=>{switch(e){case"inline":{const e=this.props.roleMapping.role_templates||[];this.props.onChange({...this.props.roleMapping,roles:[],role_templates:[...e,{template:{source:""}}]});break}case"stored":{const e=this.props.roleMapping.role_templates||[];this.props.onChange({...this.props.roleMapping,roles:[],role_templates:[...e,{template:{id:""}}]});break}default:throw new Error(`Unsupported template type: ${e}`)}}}))),i()(this,"getHelpText",(()=>{if("roles"===this.props.mode&&this.hasDeprecatedRolesAssigned())return Object(d.jsx)("span",{"data-test-subj":"deprecatedRolesAssigned"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.deprecatedRolesAssigned",defaultMessage:"This mapping is assigned a deprecated role. Please migrate to a supported role."}))})),i()(this,"hasDeprecatedRolesAssigned",(()=>{var e,t;return null!==(e=null===(t=this.props.roleMapping.roles)||void 0===t?void 0:t.some((e=>this.state.roles.some((t=>t.name===e&&Object(x.j)(t))))))&&void 0!==e&&e})),this.state={roles:[]}}async componentDidMount(){const e=await this.props.rolesAPIClient.getRoles();this.setState({roles:e})}render(){const{mode:e}=this.props;return Object(d.jsx)(o.EuiFormRow,{fullWidth:!0,helpText:this.getHelpText()},"roles"===e?this.getRoleComboBox():this.getRoleTemplates())}}i()(role_selector_RoleSelector,"defaultProps",{readOnly:!1});class Rule{}class rule_group_RuleGroup extends Rule{}class all_rule_AllRule extends rule_group_RuleGroup{constructor(e=[]){super(),this.rules=e}getRules(){return[...this.rules]}getDisplayTitle(){return l.i18n.translate("xpack.security.management.editRoleMapping.allRule.displayTitle",{defaultMessage:"All are true"})}replaceRule(e,t){this.rules.splice(e,1,t)}removeRule(e){this.rules.splice(e,1)}addRule(e){this.rules.push(e)}canContainRules(){return!0}clone(){return new all_rule_AllRule(this.rules.map((e=>e.clone())))}toRaw(){return{all:[...this.rules.map((e=>e.toRaw()))]}}}class except_all_rule_ExceptAllRule extends rule_group_RuleGroup{constructor(e=[]){super(),this.rules=e}getRules(){return[...this.rules]}getDisplayTitle(){return l.i18n.translate("xpack.security.management.editRoleMapping.exceptAllRule.displayTitle",{defaultMessage:"Any are false"})}replaceRule(e,t){this.rules.splice(e,1,t)}removeRule(e){this.rules.splice(e,1)}addRule(e){this.rules.push(e)}canContainRules(){return!0}clone(){return new except_all_rule_ExceptAllRule(this.rules.map((e=>e.clone())))}toRaw(){return{except:{all:[...this.rules.map((e=>e.toRaw()))]}}}}class except_any_rule_ExceptAnyRule extends rule_group_RuleGroup{constructor(e=[]){super(),this.rules=e}getRules(){return[...this.rules]}getDisplayTitle(){return l.i18n.translate("xpack.security.management.editRoleMapping.exceptAnyRule.displayTitle",{defaultMessage:"All are false"})}replaceRule(e,t){this.rules.splice(e,1,t)}removeRule(e){this.rules.splice(e,1)}addRule(e){this.rules.push(e)}canContainRules(e){const t=[except_all_rule_ExceptAllRule,except_any_rule_ExceptAnyRule];return e.every((e=>!t.some((t=>e instanceof t))))}clone(){return new except_any_rule_ExceptAnyRule(this.rules.map((e=>e.clone())))}toRaw(){return{except:{any:[...this.rules.map((e=>e.toRaw()))]}}}}class any_rule_AnyRule extends rule_group_RuleGroup{constructor(e=[]){super(),this.rules=e}getRules(){return[...this.rules]}getDisplayTitle(){return l.i18n.translate("xpack.security.management.editRoleMapping.anyRule.displayTitle",{defaultMessage:"Any are true"})}replaceRule(e,t){this.rules.splice(e,1,t)}removeRule(e){this.rules.splice(e,1)}addRule(e){this.rules.push(e)}canContainRules(e){const t=[except_all_rule_ExceptAllRule,except_any_rule_ExceptAnyRule];return e.every((e=>!t.some((t=>e instanceof t))))}clone(){return new any_rule_AnyRule(this.rules.map((e=>e.clone())))}toRaw(){return{any:[...this.rules.map((e=>e.toRaw()))]}}}class field_rule_FieldRule extends Rule{constructor(e,t){super(),this.field=e,this.value=t}getDisplayTitle(){return l.i18n.translate("xpack.security.management.editRoleMapping.fieldRule.displayTitle",{defaultMessage:"The following is true"})}clone(){return new field_rule_FieldRule(this.field,Array.isArray(this.value)?[...this.value]:this.value)}toRaw(){return{field:{[this.field]:Array.isArray(this.value)?[...this.value]:this.value}}}}class RuleBuilderError extends Error{constructor(e,t){super(e),this.ruleTrace=t,Object.setPrototypeOf(this,RuleBuilderError.prototype)}}function w(e={}){return v(e,null,[],0)}function v(e,t,n,r){const i=Object.entries(e);if(!i.length)return{rules:null,maxDepth:0};if(i.length>1)throw new RuleBuilderError(l.i18n.translate("xpack.security.management.editRoleMapping.ruleBuilder.expectSingleRule",{defaultMessage:"Expected a single rule definition, but found {numberOfRules}.",values:{numberOfRules:i.length}}),n);const o=i[0],[s,a]=o;return function(e,t,n,r=[],i){const o="except"===n,s=[...r,e];switch(e){case"field":{R(t,s);const e=Object.entries(t);if(1!==e.length)throw new RuleBuilderError(l.i18n.translate("xpack.security.management.editRoleMapping.ruleBuilder.expectedSingleFieldRule",{defaultMessage:"Expected a single field, but found {count}.",values:{count:e.length}}),s);const[n,r]=e[0];(Array.isArray(r)?r:[r]).forEach((e=>{const t=typeof e;if(null!==e&&!["string","number","boolean"].includes(t))throw new RuleBuilderError(l.i18n.translate("xpack.security.management.editRoleMapping.ruleBuilder.invalidFieldValueType",{defaultMessage:"Invalid value type for field. Expected one of null, string, number, or boolean, but found {valueType} ({value}).",values:{valueType:t,value:JSON.stringify(r)}}),s)}));const a=new field_rule_FieldRule(n,r);return{rules:o?new except_all_rule_ExceptAllRule([a]):a,maxDepth:i}}case"any":case"all":{if(null!=t&&!Array.isArray(t))throw new RuleBuilderError(l.i18n.translate("xpack.security.management.editRoleMapping.ruleBuilder.expectedArrayForGroupRule",{defaultMessage:"Expected an array of rules, but found {type}.",values:{type:typeof t}}),s);const n=(t||[]).map(((t,n)=>v(t,e,[...s,`[${n}]`],i))),{subRules:r,maxDepth:a}=n.reduce(((e,t)=>({subRules:[...e.subRules,t.rules],maxDepth:Math.max(e.maxDepth,t.maxDepth)})),{subRules:[],maxDepth:0});return"all"===e?{rules:o?new except_all_rule_ExceptAllRule(r):new all_rule_AllRule(r),maxDepth:a}:{rules:o?new except_any_rule_ExceptAnyRule(r):new any_rule_AnyRule(r),maxDepth:a}}case"except":if(R(t,s),"all"!==n)throw new RuleBuilderError(l.i18n.translate("xpack.security.management.editRoleMapping.ruleBuilder.exceptOnlyInAllRule",{defaultMessage:'"except" rule can only exist within an "all" rule.'}),s);return v(t||{},e,s,i-1);default:throw new RuleBuilderError(l.i18n.translate("xpack.security.management.editRoleMapping.ruleBuilder.unknownRuleType",{defaultMessage:"Unknown rule type: {ruleType}.",values:{ruleType:e}}),s)}}(s,a,t,n,r+1)}function R(e,t){let n=typeof e;if(Array.isArray(e)&&(n="array"),e&&"object"!==n)throw new RuleBuilderError(l.i18n.translate("xpack.security.management.editRoleMapping.ruleBuilder.expectedObjectError",{defaultMessage:"Expected an object, but found {type}.",values:{type:n}}),t)}function M({name:e}){return e?{isInvalid:!1}:k(l.i18n.translate("xpack.security.role_mappings.validation.invalidName",{defaultMessage:"Name is required."}))}function O({roles:e}){return e&&!e.length?k(l.i18n.translate("xpack.security.role_mappings.validation.invalidRoles",{defaultMessage:"At least one role is required."})):{isInvalid:!1}}function E({role_templates:e}){return e&&!e.length?k(l.i18n.translate("xpack.security.role_mappings.validation.invalidRoleTemplates",{defaultMessage:"At least one role template is required."})):{isInvalid:!1}}function _({rules:e}){try{const{rules:t}=w(e);if(!t)return k(l.i18n.translate("xpack.security.role_mappings.validation.invalidRoleRule",{defaultMessage:"At least one rule is required."}))}catch(e){return k(e.message)}return{isInvalid:!1}}function k(e){return{isInvalid:!0,error:e}}class mapping_info_panel_MappingInfoPanel extends s.Component{constructor(e){super(e),i()(this,"getRoleMappingName",(()=>Object(d.jsx)(o.EuiDescribedFormGroup,{title:Object(d.jsx)("h3",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingNameFormGroupTitle",defaultMessage:"Mapping name"})),description:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingNameFormGroupHelpText",defaultMessage:"A unique name used to identify this role mapping."}),fullWidth:!0},Object(d.jsx)(o.EuiFormRow,p()({label:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingNameFormRowTitle",defaultMessage:"Name"}),fullWidth:!0},this.props.validateForm&&M(this.props.roleMapping)),Object(d.jsx)(o.EuiFieldText,{name:"name",value:this.props.roleMapping.name||"",onChange:this.onNameChange,"data-test-subj":"roleMappingFormNameInput",disabled:"edit"===this.props.mode||"view"===this.props.mode}))))),i()(this,"getRolesOrRoleTemplatesSelector",(()=>"roles"===this.state.rolesMode?this.getRolesSelector():this.getRoleTemplatesSelector())),i()(this,"getRolesSelector",(()=>Object(d.jsx)(o.EuiDescribedFormGroup,{title:Object(d.jsx)("h3",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingRolesFormRowTitle",defaultMessage:"Roles"})),description:Object(d.jsx)(o.EuiText,{size:"s",color:"subdued"},Object(d.jsx)("span",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingRolesFormRowHelpText",defaultMessage:"Assign roles to your users."})),Object(d.jsx)(o.EuiSpacer,{size:"m"}),this.getSwitchToRoleTemplateButton()),fullWidth:!0},Object(d.jsx)(o.EuiFormRow,p()({fullWidth:!0},(()=>this.props.validateForm?O(this.props.roleMapping):{})()),Object(d.jsx)(role_selector_RoleSelector,{"data-test-subj":"roleMappingFormRoleSelector",rolesAPIClient:this.props.rolesAPIClient,roleMapping:this.props.roleMapping,mode:this.state.rolesMode,canUseInlineScripts:this.props.canUseInlineScripts,canUseStoredScripts:this.props.canUseStoredScripts,onChange:e=>this.props.onChange(e),readOnly:"view"===this.props.mode}))))),i()(this,"getSwitchToRoleTemplateButton",(()=>"view"!==this.props.mode?Object(d.jsx)(o.EuiLink,{"data-test-subj":"switchToRoleTemplatesButton",onClick:()=>{this.onRolesModeChange("templates")}},Object(d.jsx)(s.Fragment,null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.switchToRoleTemplates",defaultMessage:"Switch to role templates"})," ",Object(d.jsx)(o.EuiIcon,{size:"s",type:"inputOutput"}))):null)),i()(this,"getRoleTemplatesSelector",(()=>Object(d.jsx)(o.EuiDescribedFormGroup,{title:Object(d.jsx)("h3",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingRoleTemplatesFormRowTitle",defaultMessage:"Role templates"})),description:Object(d.jsx)(o.EuiText,{size:"s",color:"subdued"},Object(d.jsx)("span",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingRoleTemplatesFormRowHelpText",defaultMessage:"Create templates that describe the roles to assign to your users."})," ",Object(d.jsx)(o.EuiLink,{href:this.props.docLinks.links.apis.createRoleMappingTemplates,external:!0,target:"_blank"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingRoleTemplatesFormRowLearnMore",defaultMessage:"Learn about role templates"}))),Object(d.jsx)(o.EuiSpacer,{size:"m"}),this.getSwitchToRolesButton()),fullWidth:!0},Object(d.jsx)(o.EuiFormRow,p()({fullWidth:!0},(()=>this.props.validateForm?E(this.props.roleMapping):{})()),Object(d.jsx)(role_selector_RoleSelector,{"data-test-subj":"roleMappingFormTemplateSelector",rolesAPIClient:this.props.rolesAPIClient,roleMapping:this.props.roleMapping,mode:this.state.rolesMode,canUseInlineScripts:this.props.canUseInlineScripts,canUseStoredScripts:this.props.canUseStoredScripts,onChange:e=>this.props.onChange(e),readOnly:"view"===this.props.mode}))))),i()(this,"getSwitchToRolesButton",(()=>"view"!==this.props.mode?Object(d.jsx)(o.EuiLink,{onClick:()=>{this.onRolesModeChange("roles")},"data-test-subj":"switchToRolesButton"},Object(d.jsx)(s.Fragment,null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.switchToRoles",defaultMessage:"Switch to roles"})," ",Object(d.jsx)(o.EuiIcon,{size:"s",type:"inputOutput"}))):null)),i()(this,"getEnabledSwitch",(()=>Object(d.jsx)(o.EuiDescribedFormGroup,{title:Object(d.jsx)("h3",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingEnabledFormRowTitle",defaultMessage:"Enable mapping"})),description:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingEnabledFormRowHelpText",defaultMessage:"Map roles to users based on their username, groups, and other metadata. When false, ignore mappings."}),fullWidth:!0},Object(d.jsx)(o.EuiFormRow,{label:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingEnabledFormRowLabel",defaultMessage:"Enable mapping"}),fullWidth:!0},Object(d.jsx)(o.EuiSwitch,{name:"enabled",label:l.i18n.translate("xpack.security.management.editRoleMapping.roleMappingEnabledLabel",{defaultMessage:"Enable mapping"}),showLabel:!1,"data-test-subj":"roleMappingsEnabledSwitch",checked:this.props.roleMapping.enabled,onChange:e=>{this.props.onChange({...this.props.roleMapping,enabled:e.target.checked})},disabled:"view"===this.props.mode}))))),i()(this,"onNameChange",(e=>{const t=e.target.value;this.props.onChange({...this.props.roleMapping,name:t})})),i()(this,"onRolesModeChange",(e=>{const t=this.props.canUseInlineScripts||this.props.canUseStoredScripts;if("templates"===e&&t){const e=this.props.canUseInlineScripts?{template:{source:""}}:{template:{id:""}};this.props.onChange({...this.props.roleMapping,roles:[],role_templates:[e]})}this.setState({rolesMode:e})})),this.state={rolesMode:e.roleMapping.role_templates&&e.roleMapping.role_templates.length>0?"templates":"roles"}}render(){return Object(d.jsx)(o.EuiPanel,{hasShadow:!1,hasBorder:!0},Object(d.jsx)(o.EuiTitle,null,Object(d.jsx)("h2",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingTitle",defaultMessage:"Role mapping"}))),Object(d.jsx)(o.EuiSpacer,null),this.getRoleMappingName(),this.getEnabledSwitch(),this.getRolesOrRoleTemplatesSelector())}}n(251),n(252),n(254);var C=n(5),S=n(55);const F=e=>{const t=Object(C.useKibana)().services.docLinks,[n,r]=Object(s.useState)(JSON.stringify(e.rules?e.rules.toRaw():{},null,2)),[i,a]=Object(s.useState)(null);function u(){try{const e=JSON.parse(n);r(JSON.stringify(e,null,2))}catch(e){}}return Object(d.jsx)(o.EuiFormRow,{isInvalid:Boolean(i),error:i&&l.i18n.translate("xpack.security.management.editRoleMapping.JSONEditorRuleError",{defaultMessage:"Invalid rule definition at {ruleLocation}: {errorMessage}",values:{ruleLocation:i.ruleTrace.join("."),errorMessage:i.message}}),fullWidth:!0,"data-test-subj":"roleMappingsJSONEditor"},Object(d.jsx)(s.Fragment,null,Object(d.jsx)(C.CodeEditorField,{"aria-label":"",languageId:S.XJsonLang.ID,value:n,onChange:function(t){r(t);try{const n=JSON.parse(t);e.onChange(w(n).rules),e.onValidityChange(!0),a(null)}catch(t){a(t instanceof RuleBuilderError?t:null),e.onValidityChange(!1)}},fullWidth:!0,height:"300px",options:{accessibilitySupport:"off",lineNumbers:"on",fontSize:12,tabSize:2,automaticLayout:!0,minimap:{enabled:!1},overviewRulerBorder:!1,scrollbar:{alwaysConsumeMouseWheel:!1},scrollBeyondLastLine:!1,wordWrap:"on",wrappingIndent:"indent",readOnly:e.readOnly,domReadOnly:e.readOnly}}),Object(d.jsx)(o.EuiSpacer,{size:"s"}),function(){if(!e.readOnly)return Object(d.jsx)(o.EuiButton,{"data-test-subj":"roleMappingsJSONReformatButton",iconType:"broom",onClick:u,size:"s"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.autoFormatRuleText",defaultMessage:"Reformat"}))}(),Object(d.jsx)(o.EuiSpacer,{size:"s"}),Object(d.jsx)(o.EuiText,{size:"s"},Object(d.jsx)("p",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.JSONEditorHelpText",defaultMessage:"Specify your rules in JSON format consistent with the {roleMappingAPI}",values:{roleMappingAPI:Object(d.jsx)(o.EuiLink,{href:t.links.apis.createRoleMapping,external:!0,target:"_blank"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.JSONEditorEsApi",defaultMessage:"Elasticsearch role mapping API."}))}})))))},T=[{name:"username"},{name:"dn"},{name:"groups"},{name:"realm.name"}].map((e=>({label:e.name}))),A={text:{id:"text",defaultValue:"*"},number:{id:"number",defaultValue:0},null:{id:"null",defaultValue:null},boolean:{id:"boolean",defaultValue:!0}};class field_rule_editor_FieldRuleEditor extends s.Component{constructor(...e){super(...e),i()(this,"renderFieldRow",((e,t,n)=>{const r=0===n;let i=!0,s=t;Array.isArray(t)&&(i=t.length-1===n,s=t[n]);const a=this.getComparisonType(s);return Object(d.jsx)(o.EuiFlexGroup,{gutterSize:"s"},Object(d.jsx)(o.EuiFlexItem,{grow:1},r?Object(d.jsx)(o.EuiFormRow,{label:l.i18n.translate("xpack.security.management.editRoleMapping.fieldRuleEditor.userFieldLabel",{defaultMessage:"User field"})},Object(d.jsx)(o.EuiComboBox,{isClearable:!1,selectedOptions:[{label:e}],singleSelection:{asPlainText:!0},onChange:this.onFieldChange,onCreateOption:this.onAddField,options:T,"data-test-subj":`fieldRuleEditorField-${n} fieldRuleEditorField-${n}-combo`,isDisabled:this.props.readOnly})):Object(d.jsx)(o.EuiFormRow,{hasEmptyLabelSpace:!0},Object(d.jsx)(o.EuiExpression,{description:l.i18n.translate("xpack.security.management.editRoleMapping.fieldRuleEditor.orLabel",{defaultMessage:"or"}),value:e,"data-test-subj":`fieldRuleEditorField-${n} fieldRuleEditorField-${n}-expression`}))),Object(d.jsx)(o.EuiFlexItem,{grow:!1},this.renderFieldTypeInput(a.id,n)),Object(d.jsx)(o.EuiFlexItem,{grow:1},this.renderFieldValueInput(a.id,s,n)),this.conditionallyRenderAddButton(i),this.conditionallyRenderDeleteButton(n))})),i()(this,"conditionallyRenderAddButton",(e=>Object(d.jsx)(o.EuiFlexItem,{grow:!1},Object(d.jsx)(o.EuiFormRow,{hasEmptyLabelSpace:!0},!1===this.props.readOnly&&e?Object(d.jsx)(o.EuiButtonIcon,{iconSize:"s",iconType:"plusInCircle",onClick:this.onAddAlternateValue,color:"primary","data-test-subj":"addAlternateValueButton","aria-label":l.i18n.translate("xpack.security.management.editRoleMapping.fieldRuleEditor.addAlternateValueButton",{defaultMessage:"Add alternate value"})}):Object(d.jsx)(o.EuiIcon,{size:"s",type:"empty"}))))),i()(this,"conditionallyRenderDeleteButton",(e=>Object(d.jsx)(o.EuiFlexItem,{grow:1},Object(d.jsx)(o.EuiFormRow,{hasEmptyLabelSpace:!0},!1===this.props.readOnly?Object(d.jsx)(o.EuiButtonIcon,{iconType:"trash",color:"danger",iconSize:"s","data-test-subj":`fieldRuleEditorDeleteValue fieldRuleEditorDeleteValue-${e}`,"aria-label":l.i18n.translate("xpack.security.management.editRoleMapping.fieldRuleEditor.deleteValueLabel",{defaultMessage:"Delete value"}),onClick:()=>this.onRemoveAlternateValue(e)}):Object(d.jsx)(o.EuiIcon,{size:"s",type:"empty"}))))),i()(this,"renderFieldTypeInput",((e,t)=>Object(d.jsx)(o.EuiFormRow,{label:l.i18n.translate("xpack.security.management.editRoleMapping.fieldRuleEditor.typeFormRow",{defaultMessage:"Type"}),key:t},Object(d.jsx)(o.EuiSelect,{options:[{value:"text",text:"text"},{value:"number",text:"number"},{value:"null",text:"is null"},{value:"boolean",text:"boolean"}],"data-test-subj":`fieldRuleEditorValueType-${t}`,value:e,onChange:e=>this.onComparisonTypeChange(t,e.target.value),disabled:this.props.readOnly})))),i()(this,"renderFieldValueInput",((e,t,n)=>{const r=this.getInputFieldForType(e,t,n);return Object(d.jsx)(o.EuiFormRow,{label:l.i18n.translate("xpack.security.management.editRoleMapping.fieldRuleEditor.valueFormRow",{defaultMessage:"Value"}),key:n},r)})),i()(this,"getInputFieldForType",((e,t,n)=>{const r=null===t,i={"data-test-subj":`fieldRuleEditorValue-${n}`};switch(e){case"boolean":return Object(d.jsx)(o.EuiSelect,p()({},i,{value:null==t?void 0:t.toString(),onChange:this.onBooleanValueChange(n),options:[{value:"true",text:"true"},{value:"false",text:"false"}],disabled:this.props.readOnly}));case"text":case"null":return Object(d.jsx)(o.EuiFieldText,p()({},i,{value:r?"-- null --":t,onChange:this.onValueChange(n),disabled:r||this.props.readOnly}));case"number":return Object(d.jsx)(o.EuiFieldNumber,{"data-test-subj":`fieldRuleEditorValue-${n}`,value:t,onChange:this.onNumericValueChange(n),disabled:this.props.readOnly});default:throw new Error(`Unsupported input field type: ${e}`)}})),i()(this,"onAddAlternateValue",(()=>{const{field:e,value:t}=this.props.rule,n=Array.isArray(t)?[...t]:[t];n.push("*"),this.props.onChange(new field_rule_FieldRule(e,n))})),i()(this,"onRemoveAlternateValue",(e=>{const{field:t,value:n}=this.props.rule;if(!Array.isArray(n)||1===n.length)return void this.props.onDelete();const r=[...n];r.splice(e,1),this.props.onChange(new field_rule_FieldRule(t,r))})),i()(this,"onFieldChange",(([e])=>{if(!e)return;const{value:t}=this.props.rule;this.props.onChange(new field_rule_FieldRule(e.label,t))})),i()(this,"onAddField",(e=>{const{value:t}=this.props.rule;this.props.onChange(new field_rule_FieldRule(e,t))})),i()(this,"onValueChange",(e=>t=>{const{field:n,value:r}=this.props.rule;let i;Array.isArray(r)?(i=[...r],i.splice(e,1,t.target.value)):i=t.target.value,this.props.onChange(new field_rule_FieldRule(n,i))})),i()(this,"onNumericValueChange",(e=>t=>{const{field:n,value:r}=this.props.rule;let i;Array.isArray(r)?(i=[...r],i.splice(e,1,parseFloat(t.target.value))):i=parseFloat(t.target.value),this.props.onChange(new field_rule_FieldRule(n,i))})),i()(this,"onBooleanValueChange",(e=>t=>{const n="true"===t.target.value,{field:r,value:i}=this.props.rule;let o;Array.isArray(i)?(o=[...i],o.splice(e,1,n)):o=n,this.props.onChange(new field_rule_FieldRule(r,o))})),i()(this,"onComparisonTypeChange",((e,t)=>{const n=A[t];if(!n)throw new Error(`Unexpected comparison type: ${t}`);const{field:r,value:i}=this.props.rule;let o=i;Array.isArray(i)?(o=[...i],o.splice(e,1,n.defaultValue)):o=n.defaultValue,this.props.onChange(new field_rule_FieldRule(r,o))}))}render(){const{field:e,value:t}=this.props.rule,n=Array.isArray(t)?t.map(((n,r)=>this.renderFieldRow(e,t,r))):[this.renderFieldRow(e,t,0)];return Object(d.jsx)(o.EuiFlexGroup,{direction:"column"},n.map(((e,t)=>Object(d.jsx)(o.EuiFlexItem,{key:t},e))))}getComparisonType(e){const t=typeof e;if("string"===t||"undefined"===t)return A.text;if("number"===t)return A.number;if("boolean"===t)return A.boolean;if(null===e)return A.null;throw new Error(`Unable to detect comparison type for rule value [${e}]`)}}i()(field_rule_editor_FieldRuleEditor,"defaultProps",{readOnly:!1}),n(255);const L=e=>{const[t,n]=Object(s.useState)(!1),r=Object(d.jsx)(o.EuiButtonEmpty,{iconType:"plusInCircle","data-test-subj":"roleMappingsAddRuleButton",onClick:()=>{n(!t)}},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.addRuleButton",defaultMessage:"Add"})),i=[Object(d.jsx)(o.EuiContextMenuItem,{id:"addRuleOption",key:"rule",name:"Add rule",icon:"user",onClick:()=>{n(!1),e.onClick(new field_rule_FieldRule("username","*"))}},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.addRuleOption",defaultMessage:"Add rule"})),Object(d.jsx)(o.EuiContextMenuItem,{id:"addRuleGroupOption",key:"ruleGroup",name:"Add rule group",icon:"list",onClick:()=>{n(!1),e.onClick(new all_rule_AllRule([new field_rule_FieldRule("username","*")]))}},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.addRuleGroupOption",defaultMessage:"Add rule group"}))];return Object(d.jsx)(o.EuiPopover,{id:"addRuleContextMenu","data-test-subj":"addRuleContextMenu",button:r,isOpen:t,closePopover:()=>n(!1),panelPaddingSize:"none",anchorPosition:"downLeft"},Object(d.jsx)(o.EuiContextMenuPanel,{title:"Add rule",items:i}))},I=[new all_rule_AllRule,new any_rule_AnyRule],P=[new except_all_rule_ExceptAllRule,new except_any_rule_ExceptAnyRule],B=e=>{void 0===e.readOnly&&(e.readOnly=!1);const[t,n]=Object(s.useState)(!1),[r,i]=Object(s.useState)(!1),[a,l]=Object(s.useState)(null),u=e.parentRule&&e.parentRule.canContainRules(P),p=[...I,...u?P:[]],g=Object(d.jsx)(o.EuiLink,{disabled:e.readOnly,onClick:()=>n(!t),"data-test-subj":"ruleGroupTitle"},e.rule.getDisplayTitle(),!1===e.readOnly&&Object(d.jsx)(o.EuiIcon,{type:"arrowDown"})),h=Object(d.jsx)(o.EuiPopover,{button:g,isOpen:t,closePopover:()=>n(!1)},Object(d.jsx)(o.EuiContextMenuPanel,{items:p.map(((t,r)=>{const s=t.getDisplayTitle()===e.rule.getDisplayTitle()?"check":"empty";return Object(d.jsx)(o.EuiContextMenuItem,{key:r,icon:s,onClick:()=>(t=>{const r=e.rule.getRules();if(t.canContainRules(r)){const i=t.clone();r.forEach((e=>i.addRule(e))),e.onChange(i),n(!1)}else l(t),i(!0)})(t)},t.getDisplayTitle())}))})),m=r?Object(d.jsx)(o.EuiConfirmModal,{"data-test-subj":"confirmRuleChangeModal",title:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.confirmGroupChangePromptTitle",defaultMessage:"Change group type?"}),onCancel:()=>{i(!1),l(null)},onConfirm:()=>{i(!1),(t=>{const r=t.clone();0===r.getRules().length&&r.addRule(new field_rule_FieldRule("username","*")),e.onChange(r),n(!1)})(a),l(null)},cancelButtonText:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.confirmGroupChangeCancelButton",defaultMessage:"Cancel"}),confirmButtonText:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.confirmGroupChangeConfirmButton",defaultMessage:"Change anyway"})},Object(d.jsx)("p",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.switchWithIncompatibleRulesMessage",defaultMessage:"This group contains rules that are not compatible with the new type. If you change types, you will lose all rules within this group."}))):null;return Object(d.jsx)("h3",null,h,m)};function D(e){return!(e instanceof field_rule_FieldRule)}class rule_group_editor_RuleGroupEditor extends s.Component{constructor(...e){super(...e),i()(this,"renderSubRules",(()=>this.props.rule.getRules().map(((e,t,n)=>{const r=t===n.length-1?null:Object(d.jsx)(o.EuiFlexItem,{grow:!1},Object(d.jsx)(o.EuiHorizontalRule,{margin:"m"}));return D(e)?Object(d.jsx)(s.Fragment,{key:t},Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(rule_group_editor_RuleGroupEditor,{rule:e,parentRule:this.props.rule,allowAdd:this.props.allowAdd,ruleDepth:this.props.ruleDepth+1,onChange:e=>{const n=this.props.rule.clone();n.replaceRule(t,e),this.props.onChange(n)},onDelete:()=>{const e=this.props.rule.clone();e.removeRule(t),this.props.onChange(e)},readOnly:this.props.readOnly})),r):Object(d.jsx)(s.Fragment,{key:t},Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(field_rule_editor_FieldRuleEditor,{rule:e,onChange:e=>{const n=this.props.rule.clone();n.replaceRule(t,e),this.props.onChange(n)},onDelete:()=>{const e=this.props.rule.clone();e.removeRule(t),this.props.onChange(e)},readOnly:this.props.readOnly})),r)})))),i()(this,"onAddRuleClick",(e=>{const t=this.props.rule.clone();t.addRule(e),this.props.onChange(t)}))}render(){return Object(d.jsx)(o.EuiPanel,{className:"secRoleMapping__ruleEditorGroup--"+(this.props.ruleDepth%2?"odd":"even"),hasBorder:!0,hasShadow:!1},Object(d.jsx)(o.EuiFlexGroup,{direction:"column"},Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(o.EuiFlexGroup,{alignItems:"center"},Object(d.jsx)(o.EuiFlexItem,{grow:!0},Object(d.jsx)(B,{rule:this.props.rule,onChange:this.props.onChange,parentRule:this.props.parentRule,readOnly:this.props.readOnly})),Object(d.jsx)(o.EuiFlexItem,{grow:!1},!1===this.props.readOnly&&Object(d.jsx)(o.EuiButtonEmpty,{color:"danger",onClick:this.props.onDelete,size:"s",iconType:"trash","data-test-subj":"deleteRuleGroupButton"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.deleteRuleGroupButton",defaultMessage:"Delete"}))))),this.renderSubRules(),this.props.allowAdd&&!1===this.props.readOnly&&Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(L,{onClick:this.onAddRuleClick}))))}}i()(rule_group_editor_RuleGroupEditor,"defaultProps",{readOnly:!1});class visual_rule_editor_VisualRuleEditor extends s.Component{constructor(...e){super(...e),i()(this,"canUseVisualEditor",(()=>this.props.maxDepth<5)),i()(this,"getRuleDepthWarning",(()=>this.canUseVisualEditor()?null:Object(d.jsx)(s.Fragment,null,Object(d.jsx)(o.EuiCallOut,{iconType:"warning",title:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.visualRuleEditor.switchToJSONEditorTitle",defaultMessage:"Switch to JSON editor"}),"data-test-subj":"roleMappingsRulesTooComplex"},Object(d.jsx)("p",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.visualRuleEditor.switchToJSONEditorMessage",defaultMessage:"Role mapping rules are too complex for the visual editor. Switch to the JSON editor to continue editing this rule."})),Object(d.jsx)(o.EuiButton,{onClick:this.props.onSwitchEditorMode,size:"s"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.visualRuleEditor.switchToJSONEditorButton",defaultMessage:"Use JSON editor"}))),Object(d.jsx)(o.EuiSpacer,{size:"s"})))),i()(this,"onRuleChange",(e=>{this.props.onChange(e)})),i()(this,"onRuleDelete",(()=>{this.props.onChange(null)})),i()(this,"renderRule",((e,t)=>this.getEditorForRuleType(e,t)))}render(){if(this.props.rules){const e=this.renderRule(this.props.rules,this.onRuleChange);return Object(d.jsx)(s.Fragment,null,this.getRuleDepthWarning(),e)}return Object(d.jsx)(o.EuiEmptyPrompt,{title:Object(d.jsx)("h3",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.visualRuleEditor.noRulesDefinedTitle",defaultMessage:"No rules defined"})),titleSize:"s",body:Object(d.jsx)("div",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.visualRuleEditor.noRulesDefinedMessage",defaultMessage:"Rules control which users should be assigned roles."})),"data-test-subj":"roleMappingsNoRulesDefined",actions:!this.props.readOnly&&Object(d.jsx)(o.EuiButton,{color:"primary",iconType:"plusInCircle","data-test-subj":"roleMappingsAddRuleButton",onClick:()=>{this.props.onChange(new all_rule_AllRule([new field_rule_FieldRule("username","*")]))}},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.addFirstRuleButton",defaultMessage:"Add rules"}))})}getEditorForRuleType(e,t){return D(e)?Object(d.jsx)(rule_group_editor_RuleGroupEditor,{rule:e,ruleDepth:0,allowAdd:this.canUseVisualEditor(),onChange:e=>t(e),onDelete:this.onRuleDelete,readOnly:this.props.readOnly}):Object(d.jsx)(field_rule_editor_FieldRuleEditor,{rule:e,onChange:e=>t(e),onDelete:this.onRuleDelete,readOnly:this.props.readOnly})}}i()(visual_rule_editor_VisualRuleEditor,"defaultProps",{readOnly:!1});class rule_editor_panel_RuleEditorPanel extends s.Component{constructor(e){super(e),i()(this,"conditionallyRenderEditModeToggle",(()=>{if(!this.props.readOnly)return Object(d.jsx)(a.a.Fragment,null,this.getModeToggle(),Object(d.jsx)(o.EuiSpacer,{size:"m"}))})),i()(this,"initializeFromRawRules",(e=>{const{rules:t,maxDepth:n}=w(e);return{rules:t,mode:n>=5?"json":"visual",maxDepth:n}})),i()(this,"getConfirmModeChangePrompt",(()=>this.state.showConfirmModeChange?Object(d.jsx)(o.EuiConfirmModal,{title:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.confirmModeChangePromptTitle",defaultMessage:"Switch with invalid rules?"}),onCancel:()=>this.setState({showConfirmModeChange:!1}),onConfirm:()=>{this.setState({mode:"visual",showConfirmModeChange:!1}),this.onValidityChange(!0)},cancelButtonText:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.confirmModeChangePromptCancelButton",defaultMessage:"Cancel"}),confirmButtonText:Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.confirmModeChangePromptConfirmButton",defaultMessage:"Switch anyway"})},Object(d.jsx)("p",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.confirmModeChangePromptBody",defaultMessage:"The rules defined are not valid, and cannot be translated to the visual editor. You may lose some or all of your changes during the conversion. Do you wish to continue?"}))):null)),i()(this,"onRuleChange",(e=>{const t=e?e.toRaw():{};this.props.onChange(t),this.setState({...w(t)})})),i()(this,"onValidityChange",(e=>{this.setState({isRuleValid:e}),this.props.onValidityChange(e)})),i()(this,"trySwitchEditorMode",(e=>{switch(e){case"visual":this.state.isRuleValid?(this.setState({mode:e}),this.onValidityChange(!0)):this.setState({showConfirmModeChange:!0});break;case"json":this.setState({mode:e}),this.onValidityChange(!0);break;default:throw new Error(`Unexpected rule editor mode: ${this.state.mode}`)}})),this.state={...this.initializeFromRawRules(e.rawRules),isRuleValid:!0,showConfirmModeChange:!1,showVisualEditorDisabledAlert:!1}}render(){const e=this.props.validateForm&&_({rules:this.state.rules?this.state.rules.toRaw():{}});let t=null;return e&&e.error&&(t=Object(d.jsx)(s.Fragment,null,Object(d.jsx)(o.EuiCallOut,{color:"danger",title:e.error,size:"s"}))),Object(d.jsx)(o.EuiPanel,{hasShadow:!1,hasBorder:!0},Object(d.jsx)(o.EuiTitle,null,Object(d.jsx)("h2",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.mappingRulesPanelTitle",defaultMessage:"Mapping rules"}))),Object(d.jsx)(o.EuiFlexGroup,{direction:"column"},Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(o.EuiText,{size:"s",color:"subdued"},Object(d.jsx)("p",null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingRulesFormRowHelpText",defaultMessage:"Assign roles to users who match these rules. {learnMoreLink}",values:{learnMoreLink:Object(d.jsx)(o.EuiLink,{href:this.props.docLinks.links.security.mappingRolesFieldRules,target:"_blank",external:!0},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.fieldRuleEditor.fieldValueHelp",defaultMessage:"Learn about supported field values."}))}})))),Object(d.jsx)(o.EuiFlexItem,null,Object(d.jsx)(o.EuiFormRow,{fullWidth:!0,isInvalid:e&&e.isInvalid},Object(d.jsx)(o.EuiErrorBoundary,null,Object(d.jsx)(s.Fragment,null,t,this.conditionallyRenderEditModeToggle(),this.getEditor(),this.getConfirmModeChangePrompt()))))))}getModeToggle(){if("json"===this.state.mode&&this.state.maxDepth>5)return Object(d.jsx)(o.EuiCallOut,{size:"s",title:l.i18n.translate("xpack.security.management.editRoleMapping.visualEditorUnavailableTitle",{defaultMessage:"Visual editor unavailable"})},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.visualEditorUnavailableMessage",defaultMessage:"Rule definition is too complex for the visual editor."}));if("visual"===this.state.mode&&null===this.state.rules)return null;switch(this.state.mode){case"visual":return Object(d.jsx)(o.EuiLink,{"data-test-subj":"roleMappingsJSONRuleEditorButton",onClick:()=>{this.trySwitchEditorMode("json")}},Object(d.jsx)(s.Fragment,null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.switchToJSONEditorLink",defaultMessage:"Switch to JSON editor"})," ",Object(d.jsx)(o.EuiIcon,{type:"inputOutput",size:"s"})));case"json":return Object(d.jsx)(o.EuiLink,{"data-test-subj":"roleMappingsVisualRuleEditorButton",onClick:()=>{this.trySwitchEditorMode("visual")}},Object(d.jsx)(s.Fragment,null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.switchToVisualEditorLink",defaultMessage:"Switch to visual editor"})," ",Object(d.jsx)(o.EuiIcon,{type:"inputOutput",size:"s"})));default:throw new Error(`Unexpected rule editor mode: ${this.state.mode}`)}}getEditor(){switch(this.state.mode){case"visual":return Object(d.jsx)(visual_rule_editor_VisualRuleEditor,{"data-test-subj":"roleMappingsVisualRuleEditor",rules:this.state.rules,maxDepth:this.state.maxDepth,onChange:this.onRuleChange,onSwitchEditorMode:()=>this.trySwitchEditorMode("json"),readOnly:this.props.readOnly});case"json":return Object(d.jsx)(F,{"data-test-subj":"roleMappingsJSONRuleEditor",rules:this.state.rules,onChange:this.onRuleChange,onValidityChange:this.onValidityChange,readOnly:this.props.readOnly});default:throw new Error(`Unexpected rule editor mode: ${this.state.mode}`)}}}i()(rule_editor_panel_RuleEditorPanel,"defaultProps",{readOnly:!1});var N=n(93);class edit_role_mapping_page_EditRoleMappingPage extends s.Component{constructor(e){super(e),i()(this,"getInfoPanelMode",(()=>this.props.readOnly?"view":this.editingExistingRoleMapping()?"edit":"create")),i()(this,"getFormTitle",(()=>this.props.readOnly?Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.readOnlyRoleMappingTitle",defaultMessage:"Viewing role mapping"}):this.editingExistingRoleMapping()?Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.editRoleMappingTitle",defaultMessage:"Edit role mapping"}):Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.createRoleMappingTitle",defaultMessage:"Create role mapping"}))),i()(this,"getFormButtons",(()=>!0===this.props.readOnly?this.getReturnToRoleMappingListButton():Object(d.jsx)(o.EuiFlexGroup,null,Object(d.jsx)(o.EuiFlexItem,{grow:!1},this.getSaveButton()),Object(d.jsx)(o.EuiFlexItem,{grow:!1},this.getCancelButton()),Object(d.jsx)(o.EuiFlexItem,{grow:!0}),this.getDeleteButton()))),i()(this,"getReturnToRoleMappingListButton",(()=>Object(d.jsx)(o.EuiButton,{onClick:this.backToRoleMappingsList,iconType:"arrowLeft","data-test-subj":"roleMappingFormReturnButton"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.returnToRoleMappingListButton",defaultMessage:"Back to role mappings"})))),i()(this,"getSaveButton",(()=>Object(d.jsx)(o.EuiButton,{fill:!0,onClick:this.saveRoleMapping,isLoading:"saveInProgress"===this.state.loadState,disabled:!this.state.rulesValid||"saveInProgress"===this.state.loadState,"data-test-subj":"saveRoleMappingButton"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.saveRoleMappingButton",defaultMessage:"Save role mapping"})))),i()(this,"getCancelButton",(()=>Object(d.jsx)(o.EuiButton,{onClick:this.backToRoleMappingsList},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.cancelButton",defaultMessage:"Cancel"})))),i()(this,"getDeleteButton",(()=>this.editingExistingRoleMapping()&&!this.props.readOnly?Object(d.jsx)(o.EuiFlexItem,{grow:!1},Object(d.jsx)(N.a,{roleMappingsAPI:this.props.roleMappingsAPI,notifications:this.props.notifications},(e=>Object(d.jsx)(o.EuiButtonEmpty,{"data-test-subj":"deleteRoleMappingButton",onClick:()=>e([this.state.roleMapping],(()=>this.backToRoleMappingsList())),color:"danger"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.deleteRoleMappingButton",defaultMessage:"Delete role mapping"}))))):null)),i()(this,"onRuleValidityChange",(e=>{this.setState({rulesValid:e})})),i()(this,"saveRoleMapping",(()=>{if(!this.state.roleMapping)return;const{isInvalid:e}=function(e){const{isInvalid:t,error:n}=M(e),{isInvalid:r,error:i}=O(e),{isInvalid:o,error:s}=E(e),{isInvalid:a,error:l}=_(e);return t||r&&o||a?k(n||l||i||s):{isInvalid:!1}}(this.state.roleMapping);if(e)return void this.setState({validateForm:!0});const t=this.state.roleMapping.name;this.setState({loadState:"saveInProgress"}),this.props.roleMappingsAPI.saveRoleMapping(this.state.roleMapping).then((()=>{this.props.notifications.toasts.addSuccess({title:l.i18n.translate("xpack.security.management.editRoleMapping.saveSuccess",{defaultMessage:"Saved role mapping '{roleMappingName}'",values:{roleMappingName:t}}),"data-test-subj":"savedRoleMappingSuccessToast"}),this.backToRoleMappingsList()})).catch((e=>{var t;this.props.notifications.toasts.addError(e,{title:l.i18n.translate("xpack.security.management.editRoleMapping.saveError",{defaultMessage:"Error saving role mapping"}),toastMessage:null==e||null===(t=e.body)||void 0===t?void 0:t.message}),this.setState({loadState:"saveInProgress"})}))})),i()(this,"editingExistingRoleMapping",(()=>"string"==typeof this.props.name&&"edit"===this.props.action)),i()(this,"cloningExistingRoleMapping",(()=>"string"==typeof this.props.name&&"clone"===this.props.action)),i()(this,"backToRoleMappingsList",(()=>this.props.history.push("/"))),this.state={loadState:"loading",roleMapping:null,hasCompatibleRealms:!0,canUseStoredScripts:!0,canUseInlineScripts:!0,rulesValid:!0,validateForm:!1,formError:{isInvalid:!1}}}componentDidMount(){this.loadAppData()}async componentDidUpdate(e){e.name!==this.props.name&&await this.loadAppData()}render(){const{loadState:e}=this.state;return"permissionDenied"===e?Object(d.jsx)(N.c,null):"loading"===e?Object(d.jsx)(o.EuiPageSection,{alignment:"center",color:"subdued"},Object(d.jsx)(N.d,null)):Object(d.jsx)(a.a.Fragment,null,Object(d.jsx)(o.EuiPageHeader,{bottomBorder:!0,pageTitle:this.getFormTitle(),description:Object(d.jsx)(a.a.Fragment,null,Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.roleMappingDescription",defaultMessage:"Use role mappings to control which roles are assigned to your users. {learnMoreLink}",values:{learnMoreLink:Object(d.jsx)(o.EuiLink,{href:this.props.docLinks.links.security.mappingRoles,external:!0,target:"_blank"},Object(d.jsx)(c.FormattedMessage,{id:"xpack.security.management.editRoleMapping.learnMoreLinkText",defaultMessage:"Learn more about role mappings."}))}}),!this.state.hasCompatibleRealms&&Object(d.jsx)(a.a.Fragment,null,Object(d.jsx)(o.EuiSpacer,{size:"s"}),Object(d.jsx)(N.b,null)))}),Object(d.jsx)(o.EuiSpacer,{size:"l"}),Object(d.jsx)(o.EuiForm,{isInvalid:this.state.formError.isInvalid,error:this.state.formError.error},Object(d.jsx)(mapping_info_panel_MappingInfoPanel,{"data-test-subj":"roleMappingInfoPanel",roleMapping:this.state.roleMapping,onChange:e=>this.setState({roleMapping:e}),mode:this.getInfoPanelMode(),validateForm:this.state.validateForm,canUseInlineScripts:this.state.canUseInlineScripts,canUseStoredScripts:this.state.canUseStoredScripts,rolesAPIClient:this.props.rolesAPIClient,docLinks:this.props.docLinks}),Object(d.jsx)(o.EuiSpacer,null),Object(d.jsx)(rule_editor_panel_RuleEditorPanel,{"data-test-subj":"roleMappingRulePanel",rawRules:this.state.roleMapping.rules,validateForm:this.state.validateForm,onValidityChange:this.onRuleValidityChange,onChange:e=>this.setState({roleMapping:{...this.state.roleMapping,rules:e}}),docLinks:this.props.docLinks,readOnly:this.props.readOnly}),Object(d.jsx)(o.EuiSpacer,null),this.getFormButtons()))}async loadAppData(){try{const[e,t]=await Promise.all([this.props.roleMappingsAPI.checkRoleMappingFeatures(),this.editingExistingRoleMapping()||this.cloningExistingRoleMapping()?this.props.roleMappingsAPI.getRoleMapping(this.props.name):Promise.resolve({name:"",enabled:!0,metadata:{},role_templates:[],roles:[],rules:{}})]),{canManageRoleMappings:n,canUseStoredScripts:r,canUseInlineScripts:i,hasCompatibleRealms:o}=e,s=n||this.props.readOnly?"ready":"permissionDenied";this.setState({loadState:s,hasCompatibleRealms:o,canUseStoredScripts:r,canUseInlineScripts:i,roleMapping:{...t,name:this.cloningExistingRoleMapping()?"":t.name}})}catch(n){var e,t;this.props.notifications.toasts.addDanger({title:l.i18n.translate("xpack.security.management.editRoleMapping.table.fetchingRoleMappingsErrorMessage",{defaultMessage:"Error loading role mapping editor: {message}",values:{message:null!==(e=null==n||null===(t=n.body)||void 0===t?void 0:t.message)&&void 0!==e?e:""}}),"data-test-subj":"errorLoadingRoleMappingEditorToast"}),this.backToRoleMappingsList()}}}i()(edit_role_mapping_page_EditRoleMappingPage,"defaultProps",{readOnly:!1})},58:function(e,t,n){"use strict";var r,i=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),o=[];function s(e){for(var t=-1,n=0;n{const[a,l]=Object(i.useState)([]),[c,u]=Object(i.useState)(!1),[p,d]=Object(i.useState)(!1),g=Object(i.useRef)(null),h=Object(i.useRef)(null),m=()=>{u(!1),l([])},f=()=>{m(),h.current&&h.current()},b=async()=>{let t;d(!0);try{t=await e.deleteRoleMappings(a.map((e=>e.name)))}catch(e){return n.toasts.addError(e,{title:o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.unknownError",{defaultMessage:"Error deleting role mappings"})}),void d(!1)}d(!1),m();const r=t.filter((e=>e.success)),i=t.filter((e=>!e.success));if(r.length>0){const e=r.length>1?o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.successMultipleNotificationTitle",{defaultMessage:"Deleted {count} role mappings",values:{count:r.length}}):o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.successSingleNotificationTitle",{defaultMessage:"Deleted role mapping '{name}'",values:{name:r[0].name}});n.toasts.addSuccess({title:e,"data-test-subj":"deletedRoleMappingSuccessToast"}),g.current&&g.current(r.map((({name:e})=>e)))}if(i.length>0){const e=i.length>1?o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.errorMultipleNotificationTitle",{defaultMessage:"Error deleting {count} role mappings",values:{count:i.length}}):o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.errorSingleNotificationTitle",{defaultMessage:"Error deleting role mapping '{name}'",values:{name:i[0].name}});n.toasts.addDanger(e)}};return Object(s.jsx)(i.Fragment,null,t(((e,t=(()=>{}),n=(()=>{}))=>{if(!e||!e.length)throw new Error("No Role Mappings specified for delete");u(!0),l(e),g.current=t,h.current=n})),(()=>{if(!c)return null;const e=1===a.length;return Object(s.jsx)(r.EuiConfirmModal,{title:e?o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.confirmModal.deleteSingleTitle",{defaultMessage:"Delete role mapping '{name}'?",values:{name:a[0].name}}):o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.confirmModal.deleteMultipleTitle",{defaultMessage:"Delete {count} role mappings?",values:{count:a.length}}),onCancel:f,onConfirm:b,cancelButtonText:o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.confirmModal.cancelButtonLabel",{defaultMessage:"Cancel"}),confirmButtonText:o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.confirmModal.confirmButtonLabel",{defaultMessage:"Delete {count, plural, one {role mapping} other {role mappings}}",values:{count:a.length}}),confirmButtonDisabled:p,buttonColor:"danger","data-test-subj":"deleteRoleMappingConfirmationModal"},e?null:Object(s.jsx)(i.Fragment,null,Object(s.jsx)("p",null,o.i18n.translate("xpack.security.management.roleMappings.deleteRoleMapping.confirmModal.deleteMultipleListDescription",{defaultMessage:"You are about to delete these role mappings:"})),Object(s.jsx)("ul",null,a.map((({name:e})=>Object(s.jsx)("li",{key:e},e))))))})())};var l=n(6),c=n(5);const u=()=>{const e=Object(c.useKibana)().services.docLinks;return Object(s.jsx)(r.EuiCallOut,{title:Object(s.jsx)(l.FormattedMessage,{id:"xpack.security.management.roleMappings.noCompatibleRealmsErrorTitle",defaultMessage:"No compatible realms appear to be enabled in Elasticsearch"}),color:"warning",iconType:"warning"},Object(s.jsx)(l.FormattedMessage,{id:"xpack.security.management.roleMappings.noCompatibleRealmsErrorDescription",defaultMessage:"Role mappings may not be applied to users. Contact your system administrator and refer to the {link} for more information.",values:{link:Object(s.jsx)(r.EuiLink,{href:e.links.security.mappingRoles,external:!0,target:"_blank"},Object(s.jsx)(l.FormattedMessage,{id:"xpack.security.management.roleMappings.noCompatibleRealmsErrorLinkText",defaultMessage:"docs"}))}}))},p=()=>Object(s.jsx)(r.EuiPageSection,{alignment:"center",color:"subdued"},Object(s.jsx)(r.EuiEmptyPrompt,{iconType:"securityApp",title:Object(s.jsx)("h2",null,Object(s.jsx)(l.FormattedMessage,{id:"xpack.security.management.roleMappings.deniedPermissionTitle",defaultMessage:"You need permission to manage role mappings"})),body:Object(s.jsx)("p",{"data-test-subj":"permissionDeniedMessage"},Object(s.jsx)(l.FormattedMessage,{id:"xpack.security.management.roleMappings.deniedPermissionDescription",defaultMessage:"Contact your system administrator."}))})),d=e=>Object(s.jsx)(r.EuiEmptyPrompt,{title:Object(s.jsx)(r.EuiLoadingSpinner,{size:"xl"}),body:Object(s.jsx)(r.EuiText,{color:"subdued"},e.children||Object(s.jsx)(l.FormattedMessage,{id:"xpack.security.management.editRoleMapping.loadingRoleMappingDescription",defaultMessage:"Loading…"})),"data-test-subj":"sectionLoading"})},97:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(3),i=(n(2),n(4)),o=n(6),s=n(22),a=n(0);const l=e=>{var t,n,o,l,u;const p=t=>{var n,r,i,o,a;const l=e.availableRoles.find((e=>e.name===t)),c=null!==(n=l&&Object(s.m)(l))&&void 0!==n&&n,u=null!==(r=l&&Object(s.j)(l))&&void 0!==r&&r,p=null!==(i=l&&Object(s.n)(l))&&void 0!==i&&i,d=null!==(o=l&&Object(s.i)(l))&&void 0!==o&&o;return{color:u?"warning":c?"primary":void 0,"data-test-subj":`roleOption-${t}`,label:t,value:{isReserved:c,isDeprecated:u,isSystem:p,isAdmin:d,deprecatedReason:null==l||null===(a=l.metadata)||void 0===a?void 0:a._deprecated_reason}}},d=e.availableRoles.map((e=>p(e.name))),g=e.selectedRoleNames.map(p),h=d.reduce(((e,t)=>{var n,r,i,o;const s=null!==(n=t.value)&&void 0!==n&&n.isDeprecated?"deprecated":null!==(r=t.value)&&void 0!==r&&r.isSystem?"system":null!==(i=t.value)&&void 0!==i&&i.isAdmin?"admin":null!==(o=t.value)&&void 0!==o&&o.isReserved?"user":"custom";return e[s]||(e[s]=[]),e[s].push(t),e}),{});return Object(a.jsx)(r.EuiComboBox,{"data-test-subj":"rolesDropdown",id:e.id,placeholder:e.placeholder||i.i18n.translate("xpack.security.management.users.roleComboBox.placeholder",{defaultMessage:"Select roles"}),onChange:t=>{e.onChange(t.map((e=>e.label)))},isLoading:e.isLoading,isDisabled:e.isDisabled,options:[{label:i.i18n.translate("xpack.security.management.users.roleComboBox.customRoles",{defaultMessage:"Custom roles"}),options:null!==(t=h.custom)&&void 0!==t?t:[]},{label:i.i18n.translate("xpack.security.management.users.roleComboBox.userRoles",{defaultMessage:"User roles"}),options:null!==(n=h.user)&&void 0!==n?n:[]},{label:i.i18n.translate("xpack.security.management.users.roleComboBox.AdminRoles",{defaultMessage:"Admin roles"}),options:null!==(o=h.admin)&&void 0!==o?o:[]},{label:i.i18n.translate("xpack.security.management.users.roleComboBox.systemRoles",{defaultMessage:"System roles"}),options:null!==(l=h.system)&&void 0!==l?l:[]},{label:i.i18n.translate("xpack.security.management.users.roleComboBox.deprecatedRoles",{defaultMessage:"Deprecated roles"}),options:null!==(u=h.deprecated)&&void 0!==u?u:[]}],selectedOptions:g,renderOption:c})};function c(e){var t,n;return Object(a.jsx)(r.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center",responsive:!1},Object(a.jsx)(r.EuiFlexItem,null,e.label),null!==(t=e.value)&&void 0!==t&&t.isDeprecated?Object(a.jsx)(r.EuiFlexItem,{grow:!1},Object(a.jsx)(r.EuiBadge,{color:e.color},Object(a.jsx)(o.FormattedMessage,{id:"xpack.security.management.users.roleComboBox.deprecatedBadge",defaultMessage:"deprecated"}))):null!==(n=e.value)&&void 0!==n&&n.isReserved?Object(a.jsx)(r.EuiFlexItem,{grow:!1},Object(a.jsx)(r.EuiBadge,{color:e.color},Object(a.jsx)(o.FormattedMessage,{id:"xpack.security.management.users.roleComboBox.reservedBadge",defaultMessage:"built in"}))):void 0)}}}]);