if(!Array.prototype.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a3){f.scrollTop+=h/3;e.animateTimeout=setTimeout(c,50)}};c()}};JSONEditor.History=function(a){this.editor=a;this.clear();this.actions={editField:{undo:function(b){b.params.node.updateField(b.params.oldValue)},redo:function(b){b.params.node.updateField(b.params.newValue)}},editValue:{undo:function(b){b.params.node.updateValue(b.params.oldValue)},redo:function(b){b.params.node.updateValue(b.params.newValue)}},appendNode:{undo:function(b){b.params.parent.removeChild(b.params.node)},redo:function(b){b.params.parent.appendChild(b.params.node)}},removeNode:{undo:function(d){var c=d.params.parent;var b=c.childs[d.params.index]||c.append;c.insertBefore(d.params.node,b)},redo:function(b){b.params.parent.removeChild(b.params.node)}},duplicateNode:{undo:function(b){b.params.parent.removeChild(b.params.clone)},redo:function(b){b.params.parent.insertBefore(b.params.clone,b.params.node)}},changeType:{undo:function(b){b.params.node.changeType(b.params.oldType)},redo:function(b){b.params.node.changeType(b.params.newType)}},moveNode:{undo:function(b){b.params.startParent.moveTo(b.params.node,b.params.startIndex)},redo:function(b){b.params.endParent.moveTo(b.params.node,b.params.endIndex)}}}};JSONEditor.History.prototype.onChange=function(){};JSONEditor.History.prototype.add=function(a,b){this.index++;this.history[this.index]={action:a,params:b,timestamp:new Date()};if(this.index=0)};JSONEditor.History.prototype.canRedo=function(){return(this.indexm+h){o=undefined}}if(o&&o.parent){o.parent.moveBefore(this,o)}}else{var l=(this.expanded&&this.append)?this.append.getDom():this.dom.tr;var e=l?l.nextSibling:undefined;if(e){var n=JSONEditor.getAbsoluteTop(e);var d=undefined;var j=e.nextSibling;var b=JSONEditor.getAbsoluteTop(j);var a=j?(b-n):0;while(j&&f>i+a){d=JSONEditor.getNodeFromTarget(j);j=j.nextSibling;b=JSONEditor.getAbsoluteTop(j);a=j?(b-n):0}if(d&&d.parent){d.parent.moveBefore(this,d)}}}JSONEditor.Events.preventDefault(c)};JSONEditor.Node.prototype._onDragEnd=function(a){a=a||window.event;var b={node:this,startParent:this.drag.startParent,startIndex:this.drag.startIndex,endParent:this.parent,endIndex:this.parent.childs.indexOf(this)};if((b.startParent!=b.endParent)||(b.startIndex!=b.endIndex)){this.getEditor().onAction("moveNode",b)}document.body.style.cursor=this.drag.oldCursor;delete JSONEditor.freezeHighlight;delete this.drag;this.setHighlight(false);if(this.mousemove){JSONEditor.Events.removeEventListener(document,"mousemove",this.mousemove);delete this.mousemove}if(this.mouseup){JSONEditor.Events.removeEventListener(document,"mouseup",this.mouseup);delete this.mouseup}JSONEditor.Events.preventDefault(a)};JSONEditor.Node.prototype._createDomDragArea=function(){if(!this.parent){return undefined}var a=document.createElement("button");a.className="jsoneditor-dragarea";a.title="Move field (drag and drop)";return a};JSONEditor.Node.prototype._createDomField=function(){return document.createElement("div")};JSONEditor.Node.prototype.setHighlight=function(a){if(JSONEditor.freezeHighlight){return}if(this.dom.tr){this.dom.tr.className="jsoneditor-tr"+(a?" jsoneditor-tr-highlight":"");if(this.append){this.append.setHighlight(a)}if(this.childs){this.childs.forEach(function(b){b.setHighlight(a)})}}};JSONEditor.Node.prototype.updateValue=function(a){this.value=a;this.updateDom()};JSONEditor.Node.prototype.updateField=function(a){this.field=a;this.updateDom()};JSONEditor.Node.prototype.updateDom=function(a){var f=this.dom.tree;if(f){f.style.marginLeft=this.getLevel()*24+"px"}var d=this.dom.field;if(d){if(this.fieldEditable==true){d.contentEditable="true";d.spellcheck=false;d.className="jsoneditor-field"}else{d.className="jsoneditor-readonly"}var e;if(this.index!=undefined){e=this.index}else{if(this.field!=undefined){e=this.field}else{if(this.type=="array"||this.type=="object"){e=this.type}else{e="field"}}}d.innerHTML=this._escapeHTML(e)}var c=this.dom.value;if(c){var b=this.childs?this.childs.length:0;if(this.type=="array"){c.innerHTML="["+b+"]";c.title=this.type+" containing "+b+" items"}else{if(this.type=="object"){c.innerHTML="{"+b+"}";c.title=this.type+" containing "+b+" items"}else{c.innerHTML=this._escapeHTML(this.value);delete c.title}}}this._updateDomField();this._updateDomValue();if(a&&a.updateIndexes==true){this._updateDomIndexes()}if(a&&a.recurse==true){if(this.childs){this.childs.forEach(function(g){g.updateDom(a)})}if(this.append){this.append.updateDom()}}};JSONEditor.Node.prototype._updateDomIndexes=function(){var a=this.dom.value;var b=this.childs;if(a&&b){if(this.type=="array"){b.forEach(function(e,c){e.index=c;var d=e.dom.field;if(d){d.innerHTML=c}})}else{if(this.type=="object"){b.forEach(function(c){if(c.index!=undefined){delete c.index;if(c.field==undefined){c.field="field"}}})}}}};JSONEditor.Node.prototype._createDomValue=function(){var a;if(this.type=="array"){a=document.createElement("div");a.className="jsoneditor-readonly";a.innerHTML="[...]"}else{if(this.type=="object"){a=document.createElement("div");a.className="jsoneditor-readonly";a.innerHTML="{...}"}else{if(this.type=="string"){a=document.createElement("div");a.contentEditable="true";a.spellcheck=false;a.className="jsoneditor-value";a.innerHTML=this._escapeHTML(this.value)}else{a=document.createElement("div");a.contentEditable="true";a.spellcheck=false;a.className="jsoneditor-value";a.innerHTML=this._escapeHTML(this.value)}}}return a};JSONEditor.Node.prototype._createDomExpandButton=function(){var b=document.createElement("button");var a=(this.type=="array"||this.type=="object");if(a){b.className=this.expanded?"jsoneditor-expanded":"jsoneditor-collapsed";b.title="Click to expand/collapse this field. \nCtrl+Click to expand/collapse including all childs."}else{b.className="jsoneditor-invisible";b.title=""}return b};JSONEditor.Node.prototype._createDomTree=function(f,d,e){var g=this.dom;var a=document.createElement("table");var j=document.createElement("tbody");a.style.borderCollapse="collapse";a.appendChild(j);var k=document.createElement("tr");j.appendChild(k);var h=document.createElement("td");h.className="jsoneditor-td-tree";k.appendChild(h);h.appendChild(f);g.tdExpand=h;var b=document.createElement("td");b.className="jsoneditor-td-tree";k.appendChild(b);b.appendChild(d);g.tdField=b;var i=document.createElement("td");i.className="jsoneditor-td-tree";k.appendChild(i);if(this.type!="object"&&this.type!="array"){i.appendChild(document.createTextNode(":"));i.className="jsoneditor-separator"}g.tdSeparator=i;var c=document.createElement("td");c.className="jsoneditor-td-tree";k.appendChild(c);c.appendChild(e);g.tdValue=c;return a};JSONEditor.Node.prototype.onEvent=function(b){var n=b.type;var l=b.target||b.srcElement;var j=this.dom;var g=this;var c=(this.type=="array"||this.type=="object");var i=j.value;if(l==i){switch(n){case"focus":JSONEditor.focusNode=this;break;case"blur":case"change":this._getDomValue(true);this._updateDomValue();if(this.value){i.innerHTML=this._escapeHTML(this.value)}break;case"keyup":this._getDomValue(true);this._updateDomValue();break;case"cut":case"paste":setTimeout(function(){g._getDomValue(true);g._updateDomValue()},1);break}}var f=j.field;if(l==f){switch(n){case"focus":JSONEditor.focusNode=this;break;case"change":case"blur":this._getDomField(true);this._updateDomField();if(this.field){f.innerHTML=this._escapeHTML(this.field)}break;case"keyup":this._getDomField(true);this._updateDomField();break;case"cut":case"paste":setTimeout(function(){g._getDomField(true);g._updateDomField()},1);break}}var k=j.drag;if(l==k){switch(n){case"mousedown":this._onDragStart(b);break;case"mouseover":this.setHighlight(true);break;case"mouseout":this.setHighlight(false);break}}var h=j.expand;if(l==h){if(n=="click"){if(c){this._onExpand(b)}}}var p=j.duplicate;if(l==p){switch(n){case"click":var m=this.parent._duplicate(this);this.getEditor().onAction("duplicateNode",{node:this,clone:m,parent:this.parent});break;case"mouseover":this.setHighlight(true);break;case"mouseout":this.setHighlight(false);break}}var d=j.remove;if(l==d){switch(n){case"click":this._onRemove();break;case"mouseover":this.setHighlight(true);break;case"mouseout":this.setHighlight(false);break}}var o=j.type;if(l==o){switch(n){case"click":this._onChangeType(b);break;case"mouseover":this.setHighlight(true);break;case"mouseout":this.setHighlight(false);break}}var a=j.tree;if(l==a.parentNode){switch(n){case"click":var e=(b.offsetX!=undefined)?(b.offsetX<(this.getLevel()+1)*24):(b.clientX"+k+"";g.appendChild(e);g.onmousedown=(function(l){return function(){c.callback(l)}})(f.value);b.appendChild(g)});document.body.appendChild(b);c.node.setHighlight(true);JSONEditor.freezeHighlight=true;var a=JSONEditor.Events.addEventListener(document,"mousedown",function(){JSONEditor.freezeHighlight=false;c.node.setHighlight(false);if(b&&b.parentNode){b.parentNode.removeChild(b)}JSONEditor.Events.removeEventListener(document,"mousedown",a)});var d=JSONEditor.Events.addEventListener(document,"mousewheel",function(){JSONEditor.freezeHighlight=false;c.node.setHighlight(false);if(b&&b.parentNode){b.parentNode.removeChild(b)}JSONEditor.Events.removeEventListener(document,"mousewheel",d)})};JSONEditor.Node.prototype.getAppend=function(){if(!this.append){this.append=new JSONEditor.AppendNode();this.append.setParent(this)}return this.append.getDom()};JSONEditor.Node.prototype._createDomRemoveButton=function(){if(this.parent&&(this.parent.type=="array"||this.parent.type=="object")){var a=document.createElement("button");a.className="jsoneditor-remove";a.title="Remove field (including all its childs)";return a}else{return undefined}};JSONEditor.Node.prototype._createDomDuplicateButton=function(){if(this.parent&&(this.parent.type=="array"||this.parent.type=="object")){var a=document.createElement("button");a.className="jsoneditor-duplicate";a.title="Duplicate field (including all childs)";return a}else{return undefined}};JSONEditor.Node.prototype._getType=function(a){if(a instanceof Array){return"array"}if(a instanceof Object){return"object"}if(typeof(a)=="string"&&typeof(this._stringCast(a))!="string"){return"string"}return"auto"};JSONEditor.Node.prototype._stringCast=function(d){var c=d.toLowerCase(),b=Number(d),a=parseFloat(d);if(d==""){return""}else{if(c=="null"){return null}else{if(c=="true"){return true}else{if(c=="false"){return false}else{if(!isNaN(b)&&!isNaN(a)){return b}else{return d}}}}}};JSONEditor.Node.prototype._escapeHTML=function(c){var a=String(c).replace(//g,">").replace(/ /g,"  ").replace(/^ /," ").replace(/ $/," ");var b=JSON.stringify(a);return b.substring(1,b.length-1)};JSONEditor.Node.prototype._unescapeHTML=function(c){var b='"'+this._escapeJSON(c)+'"';var a=JSON.parse(b);return a.replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")};JSONEditor.Node.prototype._escapeJSON=function(e){var d="";var b=0,a=e.length;while(bthis.results.length-1){a=0}this.setActiveResult(a)}};JSONEditor.SearchBox.prototype.previous=function(){if(this.results!=undefined){var a=this.results.length-1;var b=(this.resultIndex!=undefined)?this.resultIndex-1:a;if(b<0){b=a}this.setActiveResult(b)}};JSONEditor.SearchBox.prototype.setActiveResult=function(c){if(this.activeResult){var b=this.activeResult.node;var a=this.activeResult.elem;if(a=="field"){delete b.searchFieldActive}else{delete b.searchValueActive}b.updateDom()}if(!this.results||!this.results[c]){this.resultIndex=undefined;this.activeResult=undefined;return}this.resultIndex=c;var e=this.results[this.resultIndex].node;var d=this.results[this.resultIndex].elem;if(d=="field"){e.searchFieldActive=true}else{e.searchValueActive=true}this.activeResult=this.results[this.resultIndex];e.updateDom();e.scrollTo()};JSONEditor.SearchBox.prototype.focusActiveResult=function(){if(!this.activeResult){this.next()}if(this.activeResult){this.activeResult.node.focus(this.activeResult.elem)}};JSONEditor.SearchBox.prototype.clearDelay=function(){if(this.timeout!=undefined){clearTimeout(this.timeout);delete this.timeout}};JSONEditor.SearchBox.prototype.onDelayedSearch=function(a){this.clearDelay();var b=this;this.timeout=setTimeout(function(c){b.onSearch(c)},this.delay)};JSONEditor.SearchBox.prototype.onSearch=function(b,d){this.clearDelay();var c=this.dom.search.value;var e=(c.length>0)?c:undefined;if(e!=this.lastText||d){this.lastText=e;this.results=editor.search(e);this.setActiveResult(undefined);if(e!=undefined){var a=this.results.length;switch(a){case 0:this.dom.results.innerHTML="no results";break;case 1:this.dom.results.innerHTML="1 result";break;default:this.dom.results.innerHTML=a+" results";break}}else{this.dom.results.innerHTML=""}}};JSONEditor.SearchBox.prototype.onKeyDown=function(a){a=a||window.event;var b=a.which||a.keyCode;if(b==27){this.dom.search.value="";this.onSearch(a);JSONEditor.Events.preventDefault(a);JSONEditor.Events.stopPropagation(a)}else{if(b==13){if(a.ctrlKey){this.onSearch(a,true)}else{if(a.shiftKey){this.previous()}else{this.next()}}JSONEditor.Events.preventDefault(a);JSONEditor.Events.stopPropagation(a)}}};JSONEditor.SearchBox.prototype.onKeyUp=function(a){a=a||window.event;var b=a.which||a.keyCode;if(b!=27&&b!=13){this.onDelayedSearch(a)}};JSONEditor.Events={};JSONEditor.Events.addEventListener=function(b,e,d,a){if(b.addEventListener){if(a===undefined){a=false}if(e==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0){e="DOMMouseScroll"}b.addEventListener(e,d,a);return d}else{var c=function(){return d.call(b,window.event)};b.attachEvent("on"+e,c);return c}};JSONEditor.Events.removeEventListener=function(b,d,c,a){if(b.removeEventListener){if(a===undefined){a=false}if(d==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0){d="DOMMouseScroll"}b.removeEventListener(d,c,a)}else{b.detachEvent("on"+d,c)}};JSONEditor.Events.stopPropagation=function(a){if(!a){a=window.event}if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}};JSONEditor.Events.preventDefault=function(a){if(!a){a=window.event}if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}};JSONEditor.getAbsoluteLeft=function(b){var c=0;var a=document.body;while(b!=null&&b!=a){c+=b.offsetLeft;c-=b.scrollLeft;b=b.offsetParent}return c};JSONEditor.getAbsoluteTop=function(b){var c=0;var a=document.body;while(b!=null&&b!=a){c+=b.offsetTop;c-=b.scrollTop;b=b.offsetParent}return c};JSONEditor.addClassName=function(c,b){var a=c.className.split(" ");if(a.indexOf(b)==-1){a.push(b);c.className=a.join(" ")}};JSONEditor.removeClassName=function(d,c){var b=d.className.split(" ");var a=b.indexOf(c);if(a!=-1){b.splice(a,1);d.className=b.join(" ")}};JSONEditor.stripFormatting=function(b){var g=b.childNodes;for(var e=0,a=g.length;e=0;d--){var f=c[d];if(f.specified==true){h.removeAttribute(f.name)}}}JSONEditor.stripFormatting(h)}};JSONEditor.setEndOfContentEditable=function(b){var a,c;if(document.createRange){a=document.createRange();a.selectNodeContents(b);a.collapse(false);c=window.getSelection();c.removeAllRanges();c.addRange(a)}else{if(document.selection){a=document.body.createTextRange();a.moveToElementText(b);a.collapse(false);a.select()}}};JSONEditor.getInnerText=function(d,b){var f=(b==undefined);if(f){b={text:"",flush:function(){var i=this.text;this.text="";return i},set:function(i){this.text=i}}}if(d.nodeValue){return b.flush()+d.nodeValue}if(d.hasChildNodes()){var k=d.childNodes;var g="";for(var e=0,c=k.length;e