var CodeMirrorConfig=window.CodeMirrorConfig||{},CodeMirror=function(){function h(f,e){for(var b in e)f.hasOwnProperty(b)||(f[b]=e[b])}function o(f,e){for(var b=0;b<f.length;b++)e(f[b])}function l(f){var e=document.createElement("DIV"),b=document.createElement("DIV");e.style.position="absolute";e.style.height="100%";if(e.style.setExpression)try{e.style.setExpression("height","this.previousSibling.offsetHeight + 'px'")}catch(a){}e.style.top="0px";e.style.left="0px";e.style.overflow="hidden";f.appendChild(e);
b.className="CodeMirror-line-numbers";e.appendChild(b);b.innerHTML="<div>1</div>";return e}function q(f){if(typeof f.parserfile=="string")f.parserfile=[f.parserfile];if(typeof f.stylesheet=="string")f.stylesheet=[f.stylesheet];var e=['<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>'];e.push('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>');o(f.stylesheet,function(b){e.push('<link rel="stylesheet" type="text/css" href="'+
b+'"/>')});o(f.basefiles.concat(f.parserfile),function(b){/^https?:/.test(b)||(b=f.path+b);e.push('<script type="text/javascript" src="'+b+'"><\/script>')});e.push('</head><body style="border-width: 0;" class="editbox" spellcheck="'+(f.disableSpellcheck?"false":"true")+'"></body></html>');return e.join("")}function n(f,e){this.options=e=e||{};h(e,CodeMirrorConfig);if(e.dumbTabs)e.tabMode="spaces";else if(e.normalTab)e.tabMode="default";var b=this.frame=document.createElement("IFRAME");if(e.iframeClass)b.className=
e.iframeClass;b.frameBorder=0;b.style.border="0";b.style.width="100%";b.style.height="100%";b.style.display="block";var a=this.wrapping=document.createElement("DIV");a.style.position="relative";a.className="CodeMirror-wrapping";a.style.width=e.width;a.style.height=e.height=="dynamic"?e.minHeight+"px":e.height;var c=this.textareaHack=document.createElement("TEXTAREA");a.appendChild(c);c.style.position="absolute";c.style.left="-10000px";c.style.width="10px";b.CodeMirror=this;if(e.domain&&m){this.html=
q(e);b.src="javascript:(function(){document.open();"+(e.domain?'document.domain="'+e.domain+'";':"")+"document.write(window.frameElement.CodeMirror.html);document.close();})()"}else b.src="javascript:false";f.appendChild?f.appendChild(a):f(a);a.appendChild(b);if(e.lineNumbers)this.lineNumbers=l(a);this.win=b.contentWindow;if(!e.domain||!m){this.win.document.open();this.win.document.write(q(e));this.win.document.close()}}h(CodeMirrorConfig,{stylesheet:[],path:"",parserfile:[],basefiles:["util.js",
"stringstream.js","select.js","undo.js","editor.js","tokenize.js"],iframeClass:null,passDelay:200,passTime:50,lineNumberDelay:200,lineNumberTime:50,continuousScanning:false,saveFunction:null,onChange:null,undoDepth:50,undoDelay:800,disableSpellcheck:true,textWrapping:true,readOnly:false,width:"",height:"300px",minHeight:100,autoMatchParens:false,parserConfig:null,tabMode:"indent",reindentOnLoad:false,activeTokens:null,cursorActivity:null,lineNumbers:false,indentUnit:2,domain:null});var m=document.selection&&
window.ActiveXObject&&/MSIE/.test(navigator.userAgent);n.prototype={init:function(){this.options.initCallback&&this.options.initCallback(this);this.options.lineNumbers&&this.activateLineNumbers();this.options.reindentOnLoad&&this.reindent();this.options.height=="dynamic"&&this.setDynamicHeight()},getCode:function(){return this.editor.getCode()},setCode:function(f){this.editor.importCode(f)},selection:function(){this.focusIfIE();return this.editor.selectedText()},reindent:function(){this.editor.reindent()},
reindentSelection:function(){this.focusIfIE();this.editor.reindentSelection(null)},focusIfIE:function(){this.win.select.ie_selection&&this.focus()},focus:function(){this.win.focus();this.editor.selectionSnapshot&&this.win.select.setBookmark(this.win.document.body,this.editor.selectionSnapshot)},replaceSelection:function(f){this.focus();this.editor.replaceSelection(f);return true},replaceChars:function(f,e,b){this.editor.replaceChars(f,e,b)},getSearchCursor:function(f,e,b){return this.editor.getSearchCursor(f,
e,b)},undo:function(){this.editor.history.undo()},redo:function(){this.editor.history.redo()},historySize:function(){return this.editor.history.historySize()},clearHistory:function(){this.editor.history.clear()},grabKeys:function(f,e){this.editor.grabKeys(f,e)},ungrabKeys:function(){this.editor.ungrabKeys()},setParser:function(f,e){this.editor.setParser(f,e)},setSpellcheck:function(f){this.win.document.body.spellcheck=f},setStylesheet:function(f){if(typeof f==="string")f=[f];for(var e={},b={},a=this.win.document.getElementsByTagName("link"),
c=0,d;d=a[c];c++)if(d.rel.indexOf("stylesheet")!==-1)for(var g=0;g<f.length;g++){var j=f[g];if(d.href.substring(d.href.length-j.length)===j){e[d.href]=true;b[j]=true}}for(c=0;d=a[c];c++)if(d.rel.indexOf("stylesheet")!==-1)d.disabled=!(d.href in e);for(g=0;g<f.length;g++){j=f[g];if(!(j in b)){d=this.win.document.createElement("link");d.rel="stylesheet";d.type="text/css";d.href=j;this.win.document.getElementsByTagName("head")[0].appendChild(d)}}},setTextWrapping:function(f){if(f!=this.options.textWrapping){this.win.document.body.style.whiteSpace=
f?"":"nowrap";this.options.textWrapping=f;if(this.lineNumbers){this.setLineNumbers(false);this.setLineNumbers(true)}}},setIndentUnit:function(f){this.win.indentUnit=f},setUndoDepth:function(f){this.editor.history.maxDepth=f},setTabMode:function(f){this.options.tabMode=f},setLineNumbers:function(f){if(f&&!this.lineNumbers){this.lineNumbers=l(this.wrapping);this.activateLineNumbers()}else if(!f&&this.lineNumbers){this.wrapping.removeChild(this.lineNumbers);this.wrapping.style.marginLeft="";this.lineNumbers=
null}},cursorPosition:function(f){this.focusIfIE();return this.editor.cursorPosition(f)},firstLine:function(){return this.editor.firstLine()},lastLine:function(){return this.editor.lastLine()},nextLine:function(f){return this.editor.nextLine(f)},prevLine:function(f){return this.editor.prevLine(f)},lineContent:function(f){return this.editor.lineContent(f)},setLineContent:function(f,e){this.editor.setLineContent(f,e)},removeLine:function(f){this.editor.removeLine(f)},insertIntoLine:function(f,e,b){this.editor.insertIntoLine(f,
e,b)},selectLines:function(f,e,b,a){this.win.focus();this.editor.selectLines(f,e,b,a)},nthLine:function(f){for(var e=this.firstLine();f>1&&e!==false;f--)e=this.nextLine(e);return e},lineNumber:function(f){for(var e=0;f!==false;){e++;f=this.prevLine(f)}return e},jumpToLine:function(f){if(typeof f=="number")f=this.nthLine(f);this.selectLines(f,0);this.win.focus()},currentLine:function(){return this.lineNumber(this.cursorLine())},cursorLine:function(){return this.cursorPosition().line},cursorCoords:function(f){return this.editor.cursorCoords(f)},
activateLineNumbers:function(){function f(){if(d.offsetWidth!=0){for(var x=d;x.parentNode;x=x.parentNode);if(!k.parentNode||x!=document||!g.Editor){try{v()}catch(z){}clearInterval(w)}else if(k.offsetWidth!=t){t=k.offsetWidth;d.parentNode.style.paddingLeft=t+"px"}}}function e(){k.scrollTop=i.scrollTop||j.documentElement.scrollTop||0}function b(x){var z=p.firstChild.offsetHeight;if(z!=0){z=Math.ceil((50+Math.max(i.offsetHeight,Math.max(d.offsetHeight,i.scrollHeight||0)))/z);for(var u=p.childNodes.length;u<=
z;u++){var y=document.createElement("DIV");y.appendChild(document.createTextNode(x?String(u+1):"\u00a0"));p.appendChild(y)}}}function a(){function x(){b(true);e()}r.updateNumbers=x;var z=g.addEventHandler(g,"scroll",e,true),u=g.addEventHandler(g,"resize",x,true);v=function(){z();u();if(r.updateNumbers==x)r.updateNumbers=null};x()}function c(){function x(F,J){C||(C=p.appendChild(document.createElement("DIV")));D&&D(C,J,F);B.push(C);B.push(F);L=C.offsetHeight+C.offsetTop;C=C.nextSibling}function z(){for(var F=
0;F<B.length;F+=2)B[F].innerHTML=B[F+1];B=[]}function u(){if(!(!p.parentNode||p.parentNode!=r.lineNumbers)){for(var F=(new Date).getTime()+r.options.lineNumberTime;E;){for(x(M++,E.previousSibling);E&&!g.isBR(E);E=E.nextSibling)for(var J=E.offsetTop+E.offsetHeight;p.offsetHeight&&J-3>L;)x("&nbsp;");if(E)E=E.nextSibling;if((new Date).getTime()>F){z();G=setTimeout(u,r.options.lineNumberDelay);return}}for(;C;)x(M++);z();e()}}function y(F){e();b(F);E=i.firstChild;C=p.firstChild;L=0;M=1;u()}function H(){G&&
clearTimeout(G);if(r.editor.allClean())y();else G=setTimeout(H,200)}var E,C,M,L,B=[],D=r.options.styleNumbers;y(true);var G=null;r.updateNumbers=H;var I=g.addEventHandler(g,"scroll",e,true),K=g.addEventHandler(g,"resize",H,true);v=function(){G&&clearTimeout(G);if(r.updateNumbers==H)r.updateNumbers=null;I();K()}}var d=this.frame,g=d.contentWindow,j=g.document,i=j.body,k=this.lineNumbers,p=k.firstChild,r=this,t=null,v=function(){};f();var w=setInterval(f,500);(this.options.textWrapping||this.options.styleNumbers?
c:a)()},setDynamicHeight:function(){function f(){for(var i=c.firstChild;i;i=i.nextSibling)if(a.isSpan(i)&&i.offsetHeight){d=i.offsetHeight;j=2*(e.frame.offsetTop+i.offsetTop+c.offsetTop+(m?10:0));break}if(d)e.wrapping.style.height=Math.max(j+d*(c.getElementsByTagName("BR").length+1),e.options.minHeight)+"px"}var e=this,b=e.options.cursorActivity,a=e.win,c=a.document.body,d=null,g=null,j=2*e.frame.offsetTop;c.style.overflowY="hidden";a.document.documentElement.style.overflowY="hidden";this.frame.scrolling=
"no";setTimeout(f,100);e.options.cursorActivity=function(i){b&&b(i);clearTimeout(g);g=setTimeout(f,200)}}};n.InvalidLineHandle={toString:function(){return"CodeMirror.InvalidLineHandle"}};n.replace=function(f){if(typeof f=="string")f=document.getElementById(f);return function(e){f.parentNode.replaceChild(e,f)}};n.fromTextArea=function(f,e){if(typeof f=="string")f=document.getElementById(f);e=e||{};if(f.style.width&&e.width==null)e.width=f.style.width;if(f.style.height&&e.height==null)e.height=f.style.height;
if(e.content==null)e.content=f.value;if(f.form){var b=function(){f.value=d.getCode()};typeof f.form.addEventListener=="function"?f.form.addEventListener("submit",b,false):f.form.attachEvent("onsubmit",b);var a=f.form.submit,c=function(){b();f.form.submit=a;f.form.submit();f.form.submit=c};f.form.submit=c}f.style.display="none";var d=new n(function(g){f.nextSibling?f.parentNode.insertBefore(g,f.nextSibling):f.parentNode.appendChild(g)},e);d.toTextArea=function(){f.parentNode.removeChild(d.wrapping);
f.style.display="";if(f.form){f.form.submit=a;typeof f.form.removeEventListener=="function"?f.form.removeEventListener("submit",b,false):f.form.detachEvent("onsubmit",b)}};return d};n.isProbablySupported=function(){var f;return window.opera?Number(window.opera.version())>=9.52:/Apple Computers, Inc/.test(navigator.vendor)&&(f=navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./))?Number(f[1])>=3:document.selection&&window.ActiveXObject&&(f=navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/))?Number(f[1])>=
6:(f=navigator.userAgent.match(/gecko\/(\d{8})/i))?Number(f[1])>=20050901:(f=navigator.userAgent.match(/AppleWebKit\/(\d+)/))?Number(f[1])>=525:null};return n}();function method(h,o){return function(){h[o].apply(h,arguments)}}var StopIteration={toString:function(){return"StopIteration"}};function forEach(h,o){if(h.next)try{for(;;)o(h.next())}catch(l){if(l!=StopIteration)throw l;}else for(var q=0;q<h.length;q++)o(h[q])}function map(h,o){var l=[];forEach(h,function(q){l.push(o(q))});return l}function matcher(h){return function(o){return h.test(o)}}function hasClass(h,o){var l=h.className;return l&&RegExp("(^| )"+o+"($| )").test(l)}
function insertAfter(h,o){o.parentNode.insertBefore(h,o.nextSibling);return h}function removeElement(h){h.parentNode&&h.parentNode.removeChild(h)}function clearElement(h){for(;h.firstChild;)h.removeChild(h.firstChild)}function isAncestor(h,o){for(;o=o.parentNode;)if(h==o)return true;return false}var nbsp="\u00a0",matching={"{":"}","[":"]","(":")","}":"{","]":"[",")":"("};
function normalizeEvent(h){if(!h.stopPropagation){h.stopPropagation=function(){this.cancelBubble=true};h.preventDefault=function(){this.returnValue=false}}if(!h.stop)h.stop=function(){this.stopPropagation();this.preventDefault()};if(h.type=="keypress"){h.code=h.charCode==null?h.keyCode:h.charCode;h.character=String.fromCharCode(h.code)}return h}
function addEventHandler(h,o,l,q){function n(m){l(normalizeEvent(m||window.event))}if(typeof h.addEventListener=="function"){h.addEventListener(o,n,false);if(q)return function(){h.removeEventListener(o,n,false)}}else{h.attachEvent("on"+o,n);if(q)return function(){h.detachEvent("on"+o,n)}}}function nodeText(h){return h.textContent||h.innerText||h.nodeValue||""}function nodeTop(h){for(var o=0;h.offsetParent;){o+=h.offsetTop;h=h.offsetParent}return o}
function isBR(h){h=h.nodeName;return h=="BR"||h=="br"}function isSpan(h){h=h.nodeName;return h=="SPAN"||h=="span"};var stringStream=function(h){function o(){for(;q==l.length;){n+=l;l="";q=0;try{l=h.next()}catch(m){if(m!=StopIteration)throw m;else return false}}return true}var l="",q=0,n="";return{peek:function(){if(!o())return null;return l.charAt(q)},next:function(){if(!o())if(n.length>0)throw"End of stringstream reached without emptying buffer ('"+n+"').";else throw StopIteration;return l.charAt(q++)},get:function(){var m=n;n="";if(q>0){m+=l.slice(0,q);l=l.slice(q);q=0}return m},push:function(m){l=l.slice(0,
q)+m+l.slice(q)},lookAhead:function(m,f,e,b){function a(k){return b?k.toLowerCase():k}m=a(m);var c=false,d=n,g=q;for(e&&this.nextWhileMatches(/[\s\u00a0]/);;){e=q+m.length;var j=l.length-q;if(e<=l.length){c=m==a(l.slice(q,e));q=e;break}else if(m.slice(0,j)==a(l.slice(q))){n+=l;l="";try{l=h.next()}catch(i){break}q=0;m=m.slice(j)}else break}if(!(c&&f)){l=n.slice(d.length)+l;q=g;n=d}return c},more:function(){return this.peek()!==null},applies:function(m){var f=this.peek();return f!==null&&m(f)},nextWhile:function(m){for(var f;(f=
this.peek())!==null&&m(f);)this.next()},matches:function(m){var f=this.peek();return f!==null&&m.test(f)},nextWhileMatches:function(m){for(var f;(f=this.peek())!==null&&m.test(f);)this.next()},equals:function(m){return m===this.peek()},endOfLine:function(){var m=this.peek();return m==null||m=="\n"}}};var select={};
(function(){function h(a,c){for(;a&&a.parentNode!=c;)a=a.parentNode;return a}function o(a,c){for(;!a.previousSibling&&a.parentNode!=c;)a=a.parentNode;return h(a.previousSibling,c)}select.ie_selection=document.selection&&document.selection.createRangeCollection;select.scrollToNode=function(a,c){if(a){var d=a,g=d.ownerDocument,j=g.body,i=g.defaultView||g.parentWindow;g=g.documentElement;for(var k=!d.nextSibling||!d.nextSibling.nextSibling||!d.nextSibling.nextSibling.nextSibling,p=0;d&&!d.offsetTop;){p++;
d=d.previousSibling}if(p==0)k=false;if(!(webkit&&d&&d.offsetTop==5&&d.offsetLeft==5)){p=p*(d?d.offsetHeight:0);var r=0,t=a?a.offsetWidth:0;for(d=d;d&&d.offsetParent;){p+=d.offsetTop;isBR(d)||(r+=d.offsetLeft);d=d.offsetParent}d=j.scrollLeft||g.scrollLeft||0;j=j.scrollTop||g.scrollTop||0;var v=false,w=i.innerWidth||g.clientWidth||0;if(c||t<w){if(c){var x=select.offsetInNode(i,a),z=nodeText(a).length;if(z)r+=t*(x/z)}t=r-d;if(t<0||t>w){d=r;v=true}}r=p-j;if(r<0||k||r>(i.innerHeight||g.clientHeight||0)-
50){j=k?1E6:p;v=true}v&&i.scrollTo(d,j)}}};select.scrollToCursor=function(a){select.scrollToNode(select.selectionTopNode(a,true)||a.firstChild,true)};var l=null;select.snapshotChanged=function(){if(l)l.changed=true};select.snapshotReplaceNode=function(a,c,d,g){function j(i){if(a==i.node){l.changed=true;if(d&&i.offset>d)i.offset-=d;else{i.node=c;i.offset+=g||0}}}if(l){j(l.start);j(l.end)}};select.snapshotMove=function(a,c,d,g,j){function i(k){if(a==k.node&&(!j||k.offset==0)){l.changed=true;k.node=
c;k.offset=g?Math.max(0,k.offset+d):d}}if(l){i(l.start);i(l.end)}};if(select.ie_selection){var q=function(a,c){function d(v){for(var w=null;!w&&v;){w=v.nextSibling;v=v.parentNode}return g(w)}function g(v){for(;v&&v.firstChild;)v=v.firstChild;return{node:v,offset:0}}var j=a.document.selection.createRange();j.collapse(c);var i=j.parentElement();if(!isAncestor(a.document.body,i))return null;if(!i.firstChild)return g(i);var k=j.duplicate();k.moveToElementText(i);k.collapse(true);for(var p=i.firstChild;p;p=
p.nextSibling){if(p.nodeType==3){var r=p.nodeValue.length;k.move("character",r)}else{k.moveToElementText(p);k.collapse(false)}var t=j.compareEndPoints("StartToStart",k);if(t==0)return d(p);if(t!=1){if(p.nodeType!=3)return g(p);k.setEndPoint("StartToEnd",j);return{node:p,offset:r-k.text.length}}}return d(i)};select.markSelection=function(a){l=null;if(a.document.selection){var c=q(a,true),d=q(a,false);if(c&&d)l={start:c,end:d,window:a,changed:false}}};select.selectMarked=function(){function a(j){var i=
c.body.createTextRange(),k=j.node;if(k)if(k.nodeType==3){i.moveToElementText(k.parentNode);for(j=j.offset;k.previousSibling;){k=k.previousSibling;j+=(k.innerText||"").length}i.move("character",j)}else{i.moveToElementText(k);i.collapse(true)}else{i.moveToElementText(l.window.document.body);i.collapse(false)}return i}if(l&&l.changed){var c=l.window.document,d=a(l.start),g=a(l.end);d.setEndPoint("StartToEnd",g);d.select()}};select.offsetInNode=function(a,c){var d=a.document.selection;if(!d)return 0;
d=d.createRange();var g=d.duplicate();try{g.moveToElementText(c)}catch(j){return 0}d.setEndPoint("StartToStart",g);return d.text.length};select.selectionTopNode=function(a,c){function d(r,t){if(t.nodeType==3){for(var v=0,w=t.previousSibling;w&&w.nodeType==3;){v+=w.nodeValue.length;w=w.previousSibling}if(w){try{r.moveToElementText(w)}catch(x){return false}r.collapse(false)}else r.moveToElementText(t.parentNode);v&&r.move("character",v)}else try{r.moveToElementText(t)}catch(z){return false}return true}
var g=a.ownerDocument.selection;if(!g)return false;g=g.createRange();var j=g.duplicate();g.collapse(c);var i=g.parentElement();if(i&&isAncestor(a,i)){j.moveToElementText(i);if(g.compareEndPoints("StartToStart",j)==1)return h(i,a)}c=0;for(i=a.childNodes.length-1;c<i;){var k=Math.ceil((i+c)/2),p=a.childNodes[k];if(!p)return false;if(!d(j,p))return false;if(g.compareEndPoints("StartToStart",j)==1)c=k;else i=k-1}return a.childNodes[c]||null};select.focusAfterNode=function(a,c){var d=c.ownerDocument.body.createTextRange();
d.moveToElementText(a||c);d.collapse(!a);d.select()};select.somethingSelected=function(a){return(a=a.document.selection)&&a.createRange().text!=""};var n=function(a,c){var d=a.document.selection;if(d){d=d.createRange();d.pasteHTML(c);d.collapse(false);d.select()}};select.insertNewlineAtCursor=function(a){n(a,"<br>")};select.insertTabAtCursor=function(a){n(a,"\u00a0\u00a0\u00a0\u00a0")};select.cursorPos=function(a,c){var d=a.ownerDocument.selection;if(!d)return null;for(var g=select.selectionTopNode(a,
c);g&&!isBR(g);)g=g.previousSibling;d=d.createRange();var j=d.duplicate();d.collapse(c);if(g){j.moveToElementText(g);j.collapse(false)}else{try{j.moveToElementText(a)}catch(i){return null}j.collapse(true)}d.setEndPoint("StartToStart",j);return{node:g,offset:d.text.length}};select.setCursorPos=function(a,c,d){function g(i){var k=a.ownerDocument.body.createTextRange();if(i.node){k.moveToElementText(i.node);k.collapse(false)}else{k.moveToElementText(a);k.collapse(true)}k.move("character",i.offset);return k}
var j=g(c);d&&d!=c&&j.setEndPoint("EndToEnd",g(d));j.select()};select.getBookmark=function(a){var c=select.cursorPos(a,true);a=select.cursorPos(a,false);if(c&&a)return{from:c,to:a}};select.setBookmark=function(a,c){c&&select.setCursorPos(a,c.from,c.to)}}else{var m=function(a,c){for(;a.nodeType!=3&&!isBR(a);){var d=a.childNodes[c]||a.nextSibling;for(c=0;!d&&a.parentNode;){a=a.parentNode;d=a.nextSibling}a=d;if(!d)break}return{node:a,offset:c}};select.markSelection=function(a){var c=a.getSelection();
if(!c||c.rangeCount==0)return l=null;c=c.getRangeAt(0);l={start:m(c.startContainer,c.startOffset),end:m(c.endContainer,c.endOffset),window:a,changed:false}};select.selectMarked=function(){function a(){if(d.start.node==d.end.node&&d.start.offset==d.end.offset){var i=d.window.getSelection();if(!i||i.rangeCount==0)return true;i=i.getRangeAt(0);i=m(i.startContainer,i.startOffset);return d.start.node!=i.node||d.start.offset!=i.offset}}function c(i,k){if(i.node)i.offset==0?j["set"+k+"Before"](i.node):j["set"+
k](i.node,i.offset);else j.setStartAfter(g.document.body.lastChild||g.document.body)}var d=l;if(d&&(d.changed||webkit&&a())){var g=d.window,j=g.document.createRange();c(d.end,"End");c(d.start,"Start");f(j,g)}};var f=function(a,c){var d=c.getSelection();if(d){d.removeAllRanges();d.addRange(a)}},e=function(a){a=a.getSelection();return!a||a.rangeCount==0?false:a.getRangeAt(0)};select.selectionTopNode=function(a,c){var d=e(a.ownerDocument.defaultView);if(!d)return false;var g=c?d.startContainer:d.endContainer,
j=c?d.startOffset:d.endOffset;window.opera&&!c&&d.endContainer==a&&d.endOffset==d.startOffset+1&&a.childNodes[d.startOffset]&&isBR(a.childNodes[d.startOffset])&&j--;return g.nodeType==3?j>0?h(g,a):o(g,a):g.nodeName.toUpperCase()=="HTML"?j==1?null:a.lastChild:g==a?j==0?null:g.childNodes[j-1]:j==g.childNodes.length?h(g,a):j==0?o(g,a):h(g.childNodes[j-1],a)};select.focusAfterNode=function(a,c){var d=c.ownerDocument.defaultView,g=d.document.createRange();g.setStartBefore(c.firstChild||c);if(a&&!a.firstChild)g.setEndAfter(a);
else a?g.setEnd(a,a.childNodes.length):g.setEndBefore(c.firstChild||c);g.collapse(false);f(g,d)};select.somethingSelected=function(a){return(a=e(a))&&!a.collapsed};select.offsetInNode=function(a,c){var d=e(a);if(!d)return 0;d=d.cloneRange();d.setStartBefore(c);return d.toString().length};var b=function(a,c){var d=e(a);if(d){d.deleteContents();d.insertNode(c);if(a.opera&&isBR(c)&&isSpan(c.parentNode)){d=c.nextSibling;var g=c.parentNode,j=g.parentNode;j.insertBefore(c,g.nextSibling);for(g="";d&&d.nodeType==
3;d=d.nextSibling){g+=d.nodeValue;removeElement(d)}j.insertBefore(makePartSpan(g,a.document),c.nextSibling)}d=a.document.createRange();d.selectNode(c);d.collapse(false);f(d,a)}};select.insertNewlineAtCursor=function(a){webkit?document.execCommand("insertLineBreak"):b(a,a.document.createElement("BR"))};select.insertTabAtCursor=function(a){b(a,a.document.createTextNode("\u00a0\u00a0\u00a0\u00a0"))};select.cursorPos=function(a,c){var d=e(window);if(d){for(var g=select.selectionTopNode(a,c);g&&!isBR(g);)g=
g.previousSibling;d=d.cloneRange();d.collapse(c);g?d.setStartAfter(g):d.setStartBefore(a);return{node:g,offset:d.toString().length}}};select.setCursorPos=function(a,c,d){function g(k,p,r){function t(z){z.nodeType==3?v.push(z):forEach(z.childNodes,t)}if(p==0&&k&&!k.nextSibling){i["set"+r+"After"](k);return true}if(k=k?k.nextSibling:a.firstChild){if(p==0){i["set"+r+"Before"](k);return true}for(var v=[];;){for(;k&&!v.length;){t(k);k=k.nextSibling}var w=v.shift();if(!w)return false;var x=w.nodeValue.length;
if(x>=p){i["set"+r](w,p);return true}p-=x}}}var j=a.ownerDocument.defaultView,i=j.document.createRange();d=d||c;g(d.node,d.offset,"End")&&g(c.node,c.offset,"Start")&&f(i,j)}}})();function UndoHistory(h,o,l,q){this.container=h;this.maxDepth=o;this.commitDelay=l;this.editor=q;this.parent=q.parent;this.last=this.first=h={text:"",from:null,to:null};this.firstTouched=false;this.history=[];this.redoHistory=[];this.touched=[]}
UndoHistory.prototype={scheduleCommit:function(){var h=this;this.parent.clearTimeout(this.commitTimeout);this.commitTimeout=this.parent.setTimeout(function(){h.tryCommit()},this.commitDelay)},touch:function(h){this.setTouched(h);this.scheduleCommit()},undo:function(){this.commit();if(this.history.length){var h=this.history.pop();this.redoHistory.push(this.updateTo(h,"applyChain"));this.notifyEnvironment();return this.chainNode(h)}},redo:function(){this.commit();if(this.redoHistory.length){var h=this.redoHistory.pop();
this.addUndoLevel(this.updateTo(h,"applyChain"));this.notifyEnvironment();return this.chainNode(h)}},clear:function(){this.history=[];this.redoHistory=[]},historySize:function(){return{undo:this.history.length,redo:this.redoHistory.length}},push:function(h,o,l){for(var q=[],n=0;n<l.length;n++){var m=n==l.length-1?o:this.container.ownerDocument.createElement("BR");q.push({from:h,to:m,text:cleanText(l[n])});h=m}this.pushChains([q],h==null&&o==null);this.notifyEnvironment()},pushChains:function(h,o){this.commit(o);
this.addUndoLevel(this.updateTo(h,"applyChain"));this.redoHistory=[]},chainNode:function(h){for(var o=0;o<h.length;o++){var l=h[o][0];if(l=l&&(l.from||l.to))return l}},reset:function(){this.history=[];this.redoHistory=[]},textAfter:function(h){return this.after(h).text},nodeAfter:function(h){return this.after(h).to},nodeBefore:function(h){return this.before(h).from},tryCommit:function(){if(window.UndoHistory)this.editor.highlightDirty()?this.commit(true):this.scheduleCommit()},commit:function(h){this.parent.clearTimeout(this.commitTimeout);
h||this.editor.highlightDirty(true);h=this.touchedChains();if(h.length){this.addUndoLevel(this.updateTo(h,"linkChain"));this.redoHistory=[];this.notifyEnvironment()}},updateTo:function(h,o){for(var l=[],q=[],n=0;n<h.length;n++){l.push(this.shadowChain(h[n]));q.push(this[o](h[n]))}o=="applyChain"&&this.notifyDirty(q);return l},notifyDirty:function(h){forEach(h,method(this.editor,"addDirtyNode"));this.editor.scheduleHighlight()},notifyEnvironment:function(){this.onChange&&this.onChange();window.frameElement&&
window.frameElement.CodeMirror.updateNumbers&&window.frameElement.CodeMirror.updateNumbers()},linkChain:function(h){for(var o=0;o<h.length;o++){var l=h[o];if(l.from)l.from.historyAfter=l;else this.first=l;if(l.to)l.to.historyBefore=l;else this.last=l}},after:function(h){return h?h.historyAfter:this.first},before:function(h){return h?h.historyBefore:this.last},setTouched:function(h){if(h){if(!h.historyTouched){this.touched.push(h);h.historyTouched=true}}else this.firstTouched=true},addUndoLevel:function(h){this.history.push(h);
this.history.length>this.maxDepth&&this.history.shift()},touchedChains:function(){function h(e,b){if(e)e.historyTemp=b;else n=b}function o(e){for(var b=[],a=e?e.nextSibling:q.container.firstChild;a&&!isBR(a);a=a.nextSibling)a.currentText&&b.push(a.currentText);return{from:e,to:a,text:cleanText(b.join(""))}}function l(e,b){for(var a=b+"Sibling",c=e[a];c&&!isBR(c);)c=c[a];return c}var q=this,n=null,m=[];q.firstTouched&&q.touched.push(null);forEach(q.touched,function(e){if(!(e&&e.parentNode!=q.container)){if(e)e.historyTouched=
false;else q.firstTouched=false;var b=o(e),a=q.after(e);if(!a||a.text!=b.text||a.to!=b.to){m.push(b);h(e,b)}}});var f=[];q.touched=[];forEach(m,function(e){if(e.from?e.from.historyTemp:n){for(var b=[],a=e.from,c=true;;){var d=a?a.historyTemp:n;if(!d)if(c)break;else d=o(a);b.unshift(d);h(a,null);if(!a)break;c=q.after(a);a=l(a,"previous")}a=e.to;for(c=q.before(e.from);;){if(!a)break;d=a?a.historyTemp:n;if(!d)if(c)break;else d=o(a);b.push(d);h(a,null);c=q.before(a);a=l(a,"next")}f.push(b)}});return f},
shadowChain:function(h){var o=[],l=this.after(h[0].from);for(h=h[h.length-1].to;;){o.push(l);l=l.to;if(!l||l==h)break;else l=l.historyAfter||this.before(h)}return o},applyChain:function(h){var o=select.cursorPos(this.container,false),l=this,q=h[0].from,n=h[h.length-1].to;(function(c,d){for(var g=c?c.nextSibling:l.container.firstChild;g!=d;){var j=g.nextSibling;removeElement(g);g=j}})(q,n);for(var m=0;m<h.length;m++){var f=h[m];m>0&&l.container.insertBefore(f.from,n);var e=makePartSpan(fixSpaces(f.text),
this.container.ownerDocument);l.container.insertBefore(e,n);if(o&&o.node==f.from){e=0;var b=this.after(f.from);if(b&&m==h.length-1){for(var a=0;a<o.offset&&f.text.charAt(a)==b.text.charAt(a);a++);if(o.offset>a)e=f.text.length-b.text.length}select.setCursorPos(this.container,{node:f.from,offset:Math.max(0,o.offset+e)})}else o&&m==h.length-1&&o.node&&o.node.parentNode!=this.container&&select.setCursorPos(this.container,{node:f.from,offset:f.text.length})}this.linkChain(h);return q}};var internetExplorer=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent),webkit=/AppleWebKit/.test(navigator.userAgent),safari=/Apple Computers, Inc/.test(navigator.vendor),gecko=/gecko\/(\d{8})/i.test(navigator.userAgent),brokenOpera=window.opera&&/Version\/10.[56]/.test(navigator.userAgent);function makeWhiteSpace(h){for(var o=[],l=true;h>0;h--){o.push(l||h==1?nbsp:" ");l^=true}return o.join("")}
function fixSpaces(h){if(h.charAt(0)==" ")h=nbsp+h.slice(1);return h.replace(/\t/g,function(){return makeWhiteSpace(indentUnit)}).replace(/[ \u00a0]{2,}/g,function(o){return makeWhiteSpace(o.length)})}function cleanText(h){return h.replace(/\u00a0/g," ")}function makePartSpan(h,o){var l=h;if(h.nodeType==3)l=h.nodeValue;else h=o.createTextNode(l);var q=o.createElement("SPAN");q.isPart=true;q.appendChild(h);q.currentText=l;return q}
var Editor=function(){function h(b){var a=makeWhiteSpace(indentUnit);return map(b.replace(/\t/g,a).replace(/\u00a0/g," ").replace(/\r\n?/g,"\n").split("\n"),fixSpaces)}function o(b,a){function c(i,k){if(i.nodeType==3){if((i.nodeValue=fixSpaces(i.nodeValue.replace(/\r/g,"").replace(/\n/g," "))).length)j=false;g.push(i)}else if(isBR(i)&&i.childNodes.length==0){j=true;g.push(i)}else{for(var p=i.firstChild;p;p=p.nextSibling)c(p);if(!j&&e.hasOwnProperty(i.nodeName.toUpperCase())){j=true;if(!a||!k)g.push(d.createElement("BR"))}}}
var d=b.ownerDocument,g=[],j=true;c(b,true);return g}function l(b){function a(i){var k=i.parentNode,p=i.nextSibling;return function(r){k.insertBefore(r,p)}}var c=b.ownerDocument,d=[],g=null,j=true;return{next:function(){if(!b)throw StopIteration;var i=b;b=i.nextSibling;var k;if(i.isPart&&i.childNodes.length==1&&i.firstChild.nodeType==3){i.currentText=i.firstChild.nodeValue;k=!/[\n\t\r]/.test(i.currentText)}else k=false;if(k){d.push(i);j=false;return i.currentText}else if(isBR(i)){j&&window.opera&&
i.parentNode.insertBefore(makePartSpan("",c),i);d.push(i);j=true;return"\n"}else{k=!i.nextSibling;g=a(i);removeElement(i);i=o(i,k);for(k=0;k<i.length;k++){var p=i,r=k,t=i[k],v="\n";if(t.nodeType==3){select.snapshotChanged();t=makePartSpan(t,c);v=t.currentText;j=false}else{j&&window.opera&&g(makePartSpan("",c));j=true}t.dirty=true;d.push(t);g(t);p[r]=v}return i.join("")}},nodes:d}}function q(b){for(;b&&!isBR(b);)b=b.previousSibling;return b}function n(b,a){if(b){if(isBR(b))b=b.nextSibling}else b=a.firstChild;
for(;b&&!isBR(b);)b=b.nextSibling;return b}function m(b,a,c,d){this.editor=b;if(d==undefined)d=a==a.toLowerCase();if(this.caseFold=d)a=a.toLowerCase();this.history=b.history;this.history.commit();this.atOccurrence=false;this.fallbackSize=15;var g;if(c&&(g=select.cursorPos(this.editor.container))){this.line=g.node;this.offset=g.offset}else{this.line=null;this.offset=0}this.valid=!!a;var j=a.split("\n"),i=this;this.matches=j.length==1?function(){var k=cleanText(i.history.textAfter(i.line).slice(i.offset));
k=(i.caseFold?k.toLowerCase():k).indexOf(a);if(k>-1)return{from:{node:i.line,offset:i.offset+k},to:{node:i.line,offset:i.offset+k+a.length}}}:function(){var k=cleanText(i.history.textAfter(i.line).slice(i.offset)),p=(i.caseFold?k.toLowerCase():k).lastIndexOf(j[0]);if(p==-1||p!=k.length-j[0].length)return false;k=i.offset+p;p=i.history.nodeAfter(i.line);for(var r=1;r<j.length-1;r++){var t=cleanText(i.history.textAfter(p));if((i.caseFold?t.toLowerCase():t)!=j[r])return false;p=i.history.nodeAfter(p)}r=
cleanText(i.history.textAfter(p));if((i.caseFold?r.toLowerCase():r).indexOf(j[j.length-1])!=0)return false;return{from:{node:i.line,offset:k},to:{node:p,offset:j[j.length-1].length}}}}function f(b){this.options=b;window.indentUnit=b.indentUnit;this.parent=parent;this.doc=document;var a=this.container=this.doc.body;this.win=window;this.history=new UndoHistory(a,b.undoDepth,b.undoDelay,this);var c=this;if(!f.Parser)throw"No parser loaded.";b.parserConfig&&f.Parser.configure&&f.Parser.configure(b.parserConfig);
b.readOnly||select.setCursorPos(a,{node:null,offset:0});this.dirty=[];this.importCode(b.content||"");this.history.onChange=b.onChange;if(b.readOnly){if(!b.textWrapping)a.style.whiteSpace="nowrap"}else{if(b.continuousScanning!==false){this.scanner=this.documentScanner(b.passTime);this.delayScanning()}var d=function(){if(document.body.contentEditable!=undefined&&internetExplorer)document.body.contentEditable="true";else document.designMode="on";document.documentElement.style.borderWidth="0";if(!b.textWrapping)a.style.whiteSpace=
"nowrap"};try{d()}catch(g){var j=addEventHandler(document,"focus",function(){j();d()},true)}addEventHandler(document,"keydown",method(this,"keyDown"));addEventHandler(document,"keypress",method(this,"keyPress"));addEventHandler(document,"keyup",method(this,"keyUp"));var i=function(){c.cursorActivity(false)};addEventHandler(document.body,"mouseup",i);addEventHandler(document.body,"cut",i);gecko&&addEventHandler(this.win,"pagehide",function(){c.unloaded=true});addEventHandler(document.body,"paste",
function(k){i();var p=null;try{var r=k.clipboardData||window.clipboardData;if(r)p=r.getData("Text")}catch(t){}if(p!==null){k.stop();c.replaceSelection(p);select.scrollToCursor(c.container)}});this.options.autoMatchParens&&addEventHandler(document.body,"click",method(this,"scheduleParenHighlight"))}}var e={P:true,DIV:true,LI:true};m.prototype={findNext:function(){function b(d){if(a.history.textAfter(d.node).length>d.offset){a.line=d.node;a.offset=d.offset+1}else{a.line=a.history.nodeAfter(d.node);
a.offset=0}}if(!this.valid)return false;this.atOccurrence=false;var a=this;if(this.line&&!this.line.parentNode){this.line=null;this.offset=0}for(;;){var c=this.matches();if(c){this.atOccurrence=c;b(c.from);return true}this.line=this.history.nodeAfter(this.line);this.offset=0;if(!this.line)return this.valid=false}},select:function(){if(this.atOccurrence){select.setCursorPos(this.editor.container,this.atOccurrence.from,this.atOccurrence.to);select.scrollToCursor(this.editor.container)}},replace:function(b){if(this.atOccurrence){b=
this.editor.replaceRange(this.atOccurrence.from,this.atOccurrence.to,b);this.line=b.node;this.offset=b.offset;this.atOccurrence=false}}};f.prototype={importCode:function(b){this.history.push(null,null,h(b));this.history.reset()},getCode:function(){if(!this.container.firstChild)return"";var b=[];select.markSelection(this.win);forEach(l(this.container.firstChild),method(b,"push"));select.selectMarked();return cleanText(b.join(""))},checkLine:function(b){if(b===false||!(b==null||b.parentNode==this.container))throw parent.CodeMirror.InvalidLineHandle;
},cursorPosition:function(b){if(b==null)b=true;return(b=select.cursorPos(this.container,b))?{line:b.node,character:b.offset}:{line:null,character:0}},firstLine:function(){return null},lastLine:function(){return this.container.lastChild?q(this.container.lastChild):null},nextLine:function(b){this.checkLine(b);return n(b,this.container)||false},prevLine:function(b){this.checkLine(b);if(b==null)return false;return q(b.previousSibling)},visibleLineCount:function(){for(var b=this.container.firstChild;b&&
isBR(b);)b=b.nextSibling;if(!b)return false;return Math.floor((window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)/b.offsetHeight)},selectLines:function(b,a,c,d){this.checkLine(b);b={node:b,offset:a};a=null;if(d!==undefined){this.checkLine(c);a={node:c,offset:d}}select.setCursorPos(this.container,b,a);select.scrollToCursor(this.container)},lineContent:function(b){var a=[];for(b=b?b.nextSibling:this.container.firstChild;b&&!isBR(b);b=b.nextSibling)a.push(nodeText(b));
return cleanText(a.join(""))},setLineContent:function(b,a){this.history.commit();this.replaceRange({node:b,offset:0},{node:b,offset:this.history.textAfter(b).length},a);this.addDirtyNode(b);this.scheduleHighlight()},removeLine:function(b){for(var a=b?b.nextSibling:this.container.firstChild;a;){var c=a.nextSibling;removeElement(a);if(isBR(a))break;a=c}this.addDirtyNode(b);this.scheduleHighlight()},insertIntoLine:function(b,a,c){var d=null;if(a=="end")d=n(b,this.container);else for(var g=b?b.nextSibling:
this.container.firstChild;g;g=g.nextSibling){if(a==0){d=g;break}var j=nodeText(g);if(j.length>a){d=g.nextSibling;c=j.slice(0,a)+c+j.slice(a);removeElement(g);break}a-=j.length}a=h(c);c=this.container.ownerDocument;for(g=0;g<a.length;g++){g>0&&this.container.insertBefore(c.createElement("BR"),d);this.container.insertBefore(makePartSpan(a[g],c),d)}this.addDirtyNode(b);this.scheduleHighlight()},selectedText:function(){var b=this.history;b.commit();var a=select.cursorPos(this.container,true),c=select.cursorPos(this.container,
false);if(!a||!c)return"";if(a.node==c.node)return b.textAfter(a.node).slice(a.offset,c.offset);var d=[b.textAfter(a.node).slice(a.offset)];for(a=b.nodeAfter(a.node);a!=c.node;a=b.nodeAfter(a))d.push(b.textAfter(a));d.push(b.textAfter(c.node).slice(0,c.offset));return cleanText(d.join("\n"))},replaceSelection:function(b){this.history.commit();var a=select.cursorPos(this.container,true),c=select.cursorPos(this.container,false);if(a&&c){c=this.replaceRange(a,c,b);select.setCursorPos(this.container,
c)}},cursorCoords:function(b){function a(k,p){var r=-(i.win.document.body.scrollTop||i.win.document.documentElement.scrollTop||0),t=-(i.win.document.body.scrollLeft||i.win.document.documentElement.scrollLeft||0)+p;forEach([k,i.win.frameElement],function(v){for(;v;){t+=v.offsetLeft;r+=v.offsetTop;v=v.offsetParent}});return{x:t,y:r,yBot:r+k.offsetHeight}}function c(k,p){var r=j.createElement("SPAN");r.appendChild(j.createTextNode(k));try{return p(r)}finally{r.parentNode&&r.parentNode.removeChild(r)}}
var d=select.cursorPos(this.container,b);if(!d)return null;b=d.offset;for(var g=d.node,j=this.win.document,i=this;b;){g=g?g.nextSibling:this.container.firstChild;d=nodeText(g);if(b<d.length)return c(d.substr(0,b),function(k){k.style.position="absolute";k.style.visibility="hidden";k.className=g.className;i.container.appendChild(k);return a(g,k.offsetWidth)});b-=d.length}return g&&isSpan(g)?a(g,g.offsetWidth):g&&g.nextSibling&&isSpan(g.nextSibling)?a(g.nextSibling,0):c("\u200b",function(k){g?g.parentNode.insertBefore(k,
g.nextSibling):i.container.insertBefore(k,i.container.firstChild);return a(k,0)})},reroutePasteEvent:function(){if(!(this.capturingPaste||window.opera)){this.capturingPaste=true;var b=window.frameElement.CodeMirror.textareaHack;parent.focus();b.value="";b.focus();var a=this;this.parent.setTimeout(function(){a.capturingPaste=false;a.win.focus();a.selectionSnapshot&&a.win.select.setBookmark(a.container,a.selectionSnapshot);var c=b.value;if(c){a.replaceSelection(c);select.scrollToCursor(a.container)}},
10)}},replaceRange:function(b,a,c){c=h(c);c[0]=this.history.textAfter(b.node).slice(0,b.offset)+c[0];var d=c[c.length-1];c[c.length-1]=d+this.history.textAfter(a.node).slice(a.offset);a=this.history.nodeAfter(a.node);this.history.push(b.node,a,c);return{node:this.history.nodeBefore(a),offset:d.length}},getSearchCursor:function(b,a,c){return new m(this,b,a,c)},reindent:function(){this.container.firstChild&&this.indentRegion(null,this.container.lastChild)},reindentSelection:function(b){if(select.somethingSelected(this.win)){var a=
select.selectionTopNode(this.container,true),c=select.selectionTopNode(this.container,false);a===false||c===false||this.indentRegion(a,c,b)}else this.indentAtCursor(b)},grabKeys:function(b,a){this.frozen=b;this.keyFilter=a},ungrabKeys:function(){this.frozen="leave"},setParser:function(b,a){f.Parser=window[b];(a=a||this.options.parserConfig)&&f.Parser.configure&&f.Parser.configure(a);if(this.container.firstChild){forEach(this.container.childNodes,function(c){if(c.nodeType!=3)c.dirty=true});this.addDirtyNode(this.firstChild);
this.scheduleHighlight()}},keyDown:function(b){if(this.frozen=="leave")this.keyFilter=this.frozen=null;if(this.frozen&&(!this.keyFilter||this.keyFilter(b.keyCode,b))){b.stop();this.frozen(b)}else{var a=this.lastKeyDownCode=b.keyCode;this.delayScanning();this.options.autoMatchParens&&this.scheduleParenHighlight();if(a==13){if(b.ctrlKey&&!b.altKey)this.reparseBuffer();else{select.insertNewlineAtCursor(this.win);this.indentAtCursor();select.scrollToCursor(this.container)}b.stop()}else if(a==9&&this.options.tabMode!=
"default"&&!b.ctrlKey){this.handleTab(!b.shiftKey);b.stop()}else if(a==32&&b.shiftKey&&this.options.tabMode=="default"){this.handleTab(true);b.stop()}else if(a==36&&!b.shiftKey&&!b.ctrlKey)this.home()&&b.stop();else if(a==35&&!b.shiftKey&&!b.ctrlKey)this.end()&&b.stop();else if(a==33&&!b.shiftKey&&!b.ctrlKey&&!gecko)this.pageUp()&&b.stop();else if(a==34&&!b.shiftKey&&!b.ctrlKey&&!gecko)this.pageDown()&&b.stop();else if((a==219||a==221)&&b.ctrlKey&&!b.altKey){this.highlightParens(b.shiftKey,true);
b.stop()}else if(b.metaKey&&!b.shiftKey&&(a==37||a==39)){var c=select.selectionTopNode(this.container);if(c!==false&&this.container.firstChild){if(a==37)select.focusAfterNode(q(c),this.container);else{a=n(c,this.container);select.focusAfterNode(a?a.previousSibling:this.container.lastChild,this.container)}b.stop()}}else if((b.ctrlKey||b.metaKey)&&!b.altKey)if(b.shiftKey&&a==90||a==89){select.scrollToNode(this.history.redo());b.stop()}else if(a==90||safari&&a==8){select.scrollToNode(this.history.undo());
b.stop()}else if(a==83&&this.options.saveFunction){this.options.saveFunction();b.stop()}else internetExplorer&&a==86&&this.reroutePasteEvent();this.keyUpOrPressAfterLastKeyDown=false}},keyPress:function(b){this.keyUpOrPressAfterLastKeyDown=true;var a=f.Parser.electricChars,c=this;if(this.frozen&&(!this.keyFilter||this.keyFilter(b.keyCode||b.code,b))||b.code==13||b.code==9&&this.options.tabMode!="default"||b.code==32&&b.shiftKey&&this.options.tabMode=="default")b.stop();else if(a&&a.indexOf(b.character)!=
-1)this.parent.setTimeout(function(){c.indentAtCursor(null)},0);else if((b.character=="v"||b.character=="V")&&(b.ctrlKey||b.metaKey)&&!b.altKey)this.reroutePasteEvent();else if(brokenOpera&&b.code==8){b=select.selectionTopNode(this.container);c=this;var d=b?b.nextSibling:this.container.firstChild;b!==false&&d&&isBR(d)&&this.parent.setTimeout(function(){select.selectionTopNode(c.container)==d&&select.focusAfterNode(d.previousSibling,c.container)},20)}},keyUp:function(b){this.keyUpOrPressAfterLastKeyDown=
true;this.cursorActivity(b.keyCode>=16&&b.keyCode<=18||b.keyCode>=33&&b.keyCode<=40)},indentLineAfter:function(b,a){var c=b?b.nextSibling:this.container.firstChild;if(c&&!hasClass(c,"whitespace"))c=null;var d=c?c.nextSibling:b?b.nextSibling:this.container.firstChild,g=b&&d&&d.currentText?d.currentText:"",j=0,i=c?c.currentText.length:0;if(a!=null&&this.options.tabMode=="shift")j=a?i+indentUnit:Math.max(0,i-indentUnit);else if(b)j=b.indentation(g,i,a);else if(f.Parser.firstIndentation)j=f.Parser.firstIndentation(g,
i,a);g=j-i;if(g<0)if(j==0){d&&select.snapshotMove(c.firstChild,d.firstChild,0);removeElement(c)}else{select.snapshotMove(c.firstChild,c.firstChild,g,true);c.currentText=makeWhiteSpace(j);c.firstChild.nodeValue=c.currentText}else if(g>0)if(c){c.currentText=makeWhiteSpace(j);c.firstChild.nodeValue=c.currentText;select.snapshotMove(c.firstChild,c.firstChild,g,true)}else{c=makePartSpan(makeWhiteSpace(j),this.doc);c.className="whitespace";b?insertAfter(c,b):this.container.insertBefore(c,this.container.firstChild);
select.snapshotMove(d&&(d.firstChild||d),c.firstChild,j,false,true)}g!=0&&this.addDirtyNode(b)},highlightAtCursor:function(){var b=select.selectionTopNode(this.container,true),a=select.selectionTopNode(this.container,false);if(b===false||a===false)return false;select.markSelection(this.win);if(this.highlight(b,n(a,this.container),true,20)===false)return false;select.selectMarked();return true},handleTab:function(b){this.options.tabMode=="spaces"?select.insertTabAtCursor(this.win):this.reindentSelection(b)},
home:function(){var b=select.selectionTopNode(this.container,true),a=b;if(b===false||!(!b||b.isPart||isBR(b))||!this.container.firstChild)return false;for(;b&&!isBR(b);)b=b.previousSibling;var c=b?b.nextSibling:this.container.firstChild;c&&c!=a&&c.isPart&&hasClass(c,"whitespace")?select.focusAfterNode(c,this.container):select.focusAfterNode(b,this.container);select.scrollToCursor(this.container);return true},end:function(){var b=select.selectionTopNode(this.container,true);if(b===false)return false;
b=n(b,this.container);if(!b)return false;select.focusAfterNode(b.previousSibling,this.container);select.scrollToCursor(this.container);return true},pageUp:function(){var b=this.cursorPosition().line,a=this.visibleLineCount();if(b===false||a===false)return false;a-=2;for(var c=0;c<a;c++){b=this.prevLine(b);if(b===false)break}if(c==0)return false;select.setCursorPos(this.container,{node:b,offset:0});select.scrollToCursor(this.container);return true},pageDown:function(){var b=this.cursorPosition().line,
a=this.visibleLineCount();if(b===false||a===false)return false;a-=2;for(var c=0;c<a;c++){var d=this.nextLine(b);if(d===false)break;b=d}if(c==0)return false;select.setCursorPos(this.container,{node:b,offset:0});select.scrollToCursor(this.container);return true},scheduleParenHighlight:function(){this.parenEvent&&this.parent.clearTimeout(this.parenEvent);var b=this;this.parenEvent=this.parent.setTimeout(function(){b.highlightParens()},300)},highlightParens:function(b,a){function c(w,x){if(w)if(i.options.markParen)i.options.markParen(w,
x);else{w.style.fontWeight="bold";w.style.color=x?"#8F8":"#F88"}}function d(w){if(w)if(i.options.unmarkParen)i.options.unmarkParen(w);else{w.style.fontWeight="";w.style.color=""}}function g(w){if(w.currentText)return(w=w.currentText.match(/^[\s\u00a0]*([\(\)\[\]{}])[\s\u00a0]*$/))&&w[1]}function j(){for(var w=[],x,z=true,u=p;u;u=t?u.nextSibling:u.previousSibling)if(u.className==r&&isSpan(u)&&(x=g(u))){if(/[\(\[\{]/.test(x)==t)w.push(x);else if(w.length){if(w.pop()!=matching[x])z=false}else z=false;
if(!w.length)break}else if(u.dirty||!isSpan(u)&&!isBR(u))return{node:u,status:"dirty"};return{node:u,status:u&&z}}var i=this;if(!a&&i.highlighted){d(i.highlighted[0]);d(i.highlighted[1])}if(window.select){this.parenEvent&&this.parent.clearTimeout(this.parenEvent);this.parenEvent=null;var k,p=select.selectionTopNode(this.container,true);if(p&&this.highlightAtCursor())if((p=select.selectionTopNode(this.container,true))&&((k=g(p))||(p=p.nextSibling)&&(k=g(p))))for(var r=p.className,t=/[\(\[\{]/.test(k);;){var v=
j();if(v.status=="dirty"){this.highlight(v.node,n(v.node));v.node.dirty=false}else{c(p,v.status);c(v.node,v.status);if(a)i.parent.setTimeout(function(){d(p);d(v.node)},500);else i.highlighted=[p,v.node];b&&v.node&&select.focusAfterNode(v.node.previousSibling,this.container);break}}}},indentAtCursor:function(b){if(this.container.firstChild)if(this.highlightAtCursor()){var a=select.selectionTopNode(this.container,false);if(a!==false){select.markSelection(this.win);this.indentLineAfter(q(a),b);select.selectMarked()}}},
indentRegion:function(b,a,c){var d=b=q(b),g=b&&q(b.previousSibling);isBR(a)||(a=n(a,this.container));this.addDirtyNode(b);do{var j=n(d,this.container);d&&this.highlight(g,j,true);this.indentLineAfter(d,c);g=d;d=j}while(d!=a);select.setCursorPos(this.container,{node:b,offset:0},{node:a,offset:0})},cursorActivity:function(b){if(this.unloaded){this.win.document.designMode="off";this.win.document.designMode="on";this.unloaded=false}if(internetExplorer){this.container.createTextRange().execCommand("unlink");
this.selectionSnapshot=select.getBookmark(this.container)}var a=this.options.cursorActivity;if(!b||a){var c=select.selectionTopNode(this.container,false);if(!(c===false||!this.container.firstChild)){c=c||this.container.firstChild;a&&a(c);if(!b){this.scheduleHighlight();this.addDirtyNode(c)}}}},reparseBuffer:function(){forEach(this.container.childNodes,function(b){b.dirty=true});this.container.firstChild&&this.addDirtyNode(this.container.firstChild)},addDirtyNode:function(b){if(b=b||this.container.firstChild){for(var a=
0;a<this.dirty.length;a++)if(this.dirty[a]==b)return;if(b.nodeType!=3)b.dirty=true;this.dirty.push(b)}},allClean:function(){return!this.dirty.length},scheduleHighlight:function(){var b=this;this.parent.clearTimeout(this.highlightTimeout);this.highlightTimeout=this.parent.setTimeout(function(){b.highlightDirty()},this.options.passDelay)},getDirtyNode:function(){for(;this.dirty.length>0;){var b=this.dirty.pop();try{for(;b&&b.parentNode!=this.container;)b=b.parentNode;if(b&&(b.dirty||b.nodeType==3))return b}catch(a){}}return null},
highlightDirty:function(b){if(!window.select)return false;this.options.readOnly||select.markSelection(this.win);for(var a,c=b?null:(new Date).getTime()+this.options.passTime;((new Date).getTime()<c||b)&&(a=this.getDirtyNode());){var d=this.highlight(a,c);d&&d.node&&d.dirty&&this.addDirtyNode(d.node)}this.options.readOnly||select.selectMarked();a&&this.scheduleHighlight();return this.dirty.length==0},documentScanner:function(b){var a=this,c=null;return function(){if(window.select){if(c&&c.parentNode!=
a.container)c=null;select.markSelection(a.win);var d=a.highlight(c,(new Date).getTime()+b,true);select.selectMarked();d=d?d.node&&d.node.nextSibling:null;c=c==d?null:d;a.delayScanning()}}},delayScanning:function(){if(this.scanner){this.parent.clearTimeout(this.documentScan);this.documentScan=this.parent.setTimeout(this.scanner,this.options.continuousScanning)}},isIMEOn:function(){return this.lastKeyDownCode==229||this.keyUpOrPressAfterLastKeyDown===false},highlight:function(b,a,c,d){function g(u){if(u){var y=
u.oldNextSibling;if(w||y===undefined||u.nextSibling!=y)i.history.touch(u);u.oldNextSibling=u.nextSibling}else{y=i.container.oldFirstChild;if(w||y===undefined||i.container.firstChild!=y)i.history.touch(null);i.container.oldFirstChild=i.container.firstChild}}var j=this.container,i=this,k=this.options.activeTokens,p=typeof a=="number"?a:null;if(!j.firstChild||this.isIMEOn())return false;for(;b&&(!b.parserFromHere||b.dirty);){if(d!=null&&isBR(b)&&--d<0)return false;b=b.previousSibling}if(b&&!b.nextSibling)return false;
var r=l(b?b.nextSibling:j.firstChild);d=stringStream(r);var t=b?b.parserFromHere(d):f.Parser.make(d),v={current:null,get:function(){if(!this.current)this.current=r.nodes.shift();return this.current},next:function(){this.current=null},remove:function(){j.removeChild(this.get());this.current=null},getNonEmpty:function(){for(var u=this.get();u&&isSpan(u)&&u.currentText=="";)if(window.opera&&(u.previousSibling==null||isBR(u.previousSibling))&&(u.nextSibling==null||isBR(u.nextSibling))){this.next();u=
this.get()}else{var y=u;this.remove();u=this.get();select.snapshotMove(y.firstChild,u&&(u.firstChild||u),0)}return u}},w=false,x=true,z=0;forEach(t,function(u){var y=v.getNonEmpty();if(u.value=="\n"){if(!isBR(y))throw"Parser out of sync. Expected BR.";if(y.dirty||!y.indentation)w=true;g(b);b=y;y.parserFromHere=t.copy();y.indentation=u.indentation;y.dirty=false;if(p==null&&y==a)throw StopIteration;if(p!=null&&(new Date).getTime()>=p||!w&&!x&&z>1&&!c)throw StopIteration;x=w;w=false;z=0;v.next()}else{if(!isSpan(y))throw"Parser out of sync. Expected SPAN.";
if(y.dirty)w=true;z++;if(!y.reduced&&y.currentText==u.value&&y.className==u.style){y.dirty=false;v.next()}else{w=true;var H=makePartSpan(u.value,i.doc);H.className=u.style;j.insertBefore(H,y);k&&k(H,u,i);u=u.value.length;for(var E=0;u>0;){y=v.get();var C=y.currentText.length;select.snapshotReplaceNode(y.firstChild,H.firstChild,u,E);if(C>u){y=y;y.currentText=y.currentText.substring(u);y.reduced=true;u=0}else{u-=C;E+=C;v.remove()}}}}});g(b);return{node:v.getNonEmpty(),dirty:w}}};return f}();
addEventHandler(window,"load",function(){var h=window.frameElement.CodeMirror;h.editor=new Editor(h.options);this.parent.setTimeout(method(h,"init"),0)});function tokenizer(h,o){function l(n){return n!="\n"&&/^[\s\u00a0]*$/.test(n)}var q={state:o,take:function(n){if(typeof n=="string")n={style:n,type:n};n.content=(n.content||"")+h.get();/\n$/.test(n.content)||h.nextWhile(l);n.value=n.content+h.get();return n},next:function(){if(!h.more())throw StopIteration;var n;if(h.equals("\n")){h.next();return this.take("whitespace")}if(h.applies(l))n="whitespace";else for(;!n;)n=this.state(h,function(m){q.state=m});return this.take(n)}};return q};var tokenizeJavaScript=function(){function h(e,b){for(var a=false;!e.endOfLine();){var c=e.next();if(c==b&&!a)return false;a=!a&&c=="\\"}return a}function o(e,b){return function(a,c){var d=e,g=l(e,b,a,function(i){d=i}),j=g.type=="operator"||g.type=="keyword c"||g.type.match(/^[\[{}\(,;:]$/);if(j!=b||d!=e)c(o(d,j));return g}}function l(e,b,a,c){function d(){a.nextWhileMatches(f);var p=a.get(),r=q.hasOwnProperty(p)&&q.propertyIsEnumerable(p)&&q[p];return r?{type:r.type,style:r.style,content:p}:{type:"variable",
style:"js-variable",content:p}}function g(p){var r="/*";for(p=p=="*";;){if(a.endOfLine())break;var t=a.next();if(t=="/"&&p){r=null;break}p=t=="*"}c(r);return{type:"comment",style:"js-comment"}}function j(){a.nextWhileMatches(n);return{type:"operator",style:"js-operator"}}function i(p){var r=h(a,p);c(r?p:null);return{type:"string",style:"js-string"}}if(e=='"'||e=="'")return i(e);var k=a.next();if(e=="/*")return g(k);else if(k=='"'||k=="'")return i(k);else if(/[\[\]{}\(\),;\:\.]/.test(k))return{type:k,
style:"js-punctuation"};else if(k=="0"&&(a.equals("x")||a.equals("X"))){a.next();a.nextWhileMatches(m);return{type:"number",style:"js-atom"}}else if(/[0-9]/.test(k)){a.nextWhileMatches(/[0-9]/);if(a.equals(".")){a.next();a.nextWhileMatches(/[0-9]/)}if(a.equals("e")||a.equals("E")){a.next();a.equals("-")&&a.next();a.nextWhileMatches(/[0-9]/)}return{type:"number",style:"js-atom"}}else if(k=="/")if(a.equals("*")){a.next();return g(k)}else if(a.equals("/")){h(a,null);return{type:"comment",style:"js-comment"}}else{if(b){h(a,
"/");a.nextWhileMatches(/[gi]/);e={type:"regexp",style:"js-string"}}else e=j();return e}else return n.test(k)?j():d()}var q=function(){function e(j,i){return{type:j,style:"js-"+i}}var b=e("keyword a","keyword"),a=e("keyword b","keyword"),c=e("keyword c","keyword"),d=e("operator","keyword"),g=e("atom","atom");return{"if":b,"while":b,"with":b,"else":a,"do":a,"try":a,"finally":a,"return":c,"break":c,"continue":c,"new":c,"delete":c,"throw":c,"in":d,"typeof":d,"instanceof":d,"var":e("var","keyword"),"function":e("function",
"keyword"),"catch":e("catch","keyword"),"for":e("for","keyword"),"switch":e("switch","keyword"),"case":e("case","keyword"),"default":e("default","keyword"),"true":g,"false":g,"null":g,undefined:g,NaN:g,Infinity:g}}(),n=/[+\-*&%=<>!?|]/,m=/[0-9A-Fa-f]/,f=/[\w\$_]/;return function(e,b){return tokenizer(e,b||o(false,true))}}();var JSParser=Editor.Parser=function(){function h(n,m,f,e,b,a){this.indented=n;this.column=m;this.type=f;if(e!=null)this.align=e;this.prev=b;this.info=a}function o(n){return function(m){var f=m&&m.charAt(0),e=n.type,b=f==e;return e=="vardef"?n.indented+4:e=="form"&&f=="{"?n.indented:e=="stat"||e=="form"?n.indented+indentUnit:n.info=="switch"&&!b?n.indented+(/^(?:case|default)\b/.test(m)?indentUnit:2*indentUnit):n.align?n.column-(b?1:0):n.indented+(b?0:indentUnit)}}var l={atom:true,number:true,variable:true,
string:true,regexp:true},q=false;return{make:function(n,m){function f(s){for(var A=s.length-1;A>=0;A--)K.push(s[A])}function e(){f(arguments);S=true}function b(){f(arguments);S=false}function a(){F={prev:F,vars:{"this":true,arguments:true}}}function c(){F=F.prev}function d(s){if(F){O="js-variabledef";F.vars[s]=true}}function g(s,A){var N=function(){J=new h(R,Q,s,null,J,A)};N.lex=true;return N}function j(){J=J.prev}function i(s){return function(A){A==s?e():e(arguments.callee)}}function k(){return b(r,
k)}function p(){return b(t,p)}function r(s){if(s=="var")e(g("vardef"),H,i(";"),j);else if(s=="keyword a")e(g("form"),t,r,j);else if(s=="keyword b")e(g("form"),r,j);else if(s=="{")e(g("}"),y,j);else if(s=="function")e(D);else if(s=="for")e(g("form"),i("("),g(")"),C,i(")"),j,r,j);else if(s=="variable")e(g("stat"),w);else if(s=="switch")e(g("form"),t,g("}","switch"),i("{"),y,j,j);else if(s=="case")e(t,i(":"));else if(s=="default")e(i(":"));else s=="catch"?e(g("form"),a,i("("),G,i(")"),r,j,c):b(g("stat"),
t,i(";"),j)}function t(s){if(l.hasOwnProperty(s))e(v);else if(s=="function")e(D);else if(s=="keyword c")e(t);else if(s=="(")e(g(")"),t,i(")"),j,v);else if(s=="operator")e(t);else if(s=="[")e(g("]"),u(t,"]"),j,v);else s=="{"?e(g("}"),u(z,"}"),j,v):e()}function v(s){if(s=="operator")e(t);else if(s=="(")e(g(")"),u(t,")"),j,v);else if(s==".")e(x,v);else s=="["&&e(g("]"),t,i("]"),j,v)}function w(s){s==":"?e(j,r):b(v,i(";"),j)}function x(s){if(s=="variable"){O="js-property";e()}}function z(s){if(s=="variable")O=
"js-property";l.hasOwnProperty(s)&&e(i(":"),t)}function u(s,A){function N(P){if(P==",")e(s,N);else P==A?e():e(i(A))}return function(P){P==A?e():b(s,N)}}function y(s){s=="}"?e():b(r,y)}function H(s,A){if(s=="variable"){d(A);e(E)}else e()}function E(s,A){if(A=="=")e(t,E);else s==","&&e(H)}function C(s){if(s=="var")e(H,L);else if(s==";")b(L);else s=="variable"?e(M):b(L)}function M(s,A){A=="in"?e(t):e(v,L)}function L(s,A){if(s==";")e(B);else A=="in"?e(t):e(t,i(";"),B)}function B(s){s==")"?b():e(t)}function D(s,
A){if(s=="variable"){d(A);e(D)}else s=="("&&e(a,u(G,")"),r,c)}function G(s,A){if(s=="variable"){d(A);e()}}var I=tokenizeJavaScript(n),K=[q?p:k],F=null,J=new h((m||0)-indentUnit,0,"block",false),Q=0,R=0,S,O,T={next:function(){for(;K[K.length-1].lex;)K.pop()();var s=I.next();if(s.type=="whitespace"&&Q==0)R=s.value.length;Q+=s.value.length;if(s.content=="\n"){R=Q=0;if(!("align"in J))J.align=false;s.indentation=o(J)}if(s.type=="whitespace"||s.type=="comment")return s;if(!("align"in J))J.align=true;for(;;){S=
O=false;K.pop()(s.type,s.content);if(S){if(O)s.style=O;else{var A;if(A=s.type=="variable")a:{for(A=F;A;){if(A.vars[s.content]){A=true;break a}A=A.prev}A=false}if(A)s.style="js-localvariable"}return s}}},copy:function(){var s=F,A=J,N=K.concat([]),P=I.state;return function(U){F=s;J=A;K=N.concat([]);Q=R=0;I=tokenizeJavaScript(U,P);return T}}};j.lex=true;return T},electricChars:"{}:",configure:function(n){if(n.json!=null)q=n.json}}}();var XMLParser=Editor.Parser=function(){var h={autoSelfClosers:{br:true,img:true,hr:true,link:true,input:true,meta:true,col:true,frame:true,base:true,area:true},doNotIndent:{pre:true,"!cdata":true}},o={autoSelfClosers:{},doNotIndent:{"!cdata":true}},l=h,q=false,n=function(){function m(a,c){var d=a.next();if(d=="<")if(a.equals("!")){a.next();if(a.equals("["))if(a.lookAhead("[CDATA[",true)){c(b("xml-cdata","]]\>"));return null}else return"xml-text";else if(a.lookAhead("--",true)){c(b("xml-comment","--\>"));
return null}else return"xml-text"}else if(a.equals("?")){a.next();a.nextWhileMatches(/[\w\._\-]/);c(b("xml-processing","?>"));return"xml-processing"}else{a.equals("/")&&a.next();c(f);return"xml-punctuation"}else if(d=="&"){for(;!a.endOfLine();)if(a.next()==";")break;return"xml-entity"}else{a.nextWhileMatches(/[^&<\n]/);return"xml-text"}}function f(a,c){var d=a.next();if(d==">"){c(m);return"xml-punctuation"}else if(/[?\/]/.test(d)&&a.equals(">")){a.next();c(m);return"xml-punctuation"}else if(d=="=")return"xml-punctuation";
else if(/[\'\"]/.test(d)){c(e(d));return null}else{a.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}}function e(a){return function(c,d){for(;!c.endOfLine();)if(c.next()==a){d(f);break}return"xml-attribute"}}function b(a,c){return function(d,g){for(;!d.endOfLine();){if(d.lookAhead(c,true)){g(m);break}d.next()}return a}}return function(a,c){return tokenizer(a,c||m)}}();return{make:function(m){function f(B){for(var D=B.length-1;D>=0;D--)u.push(B[D])}function e(){f(arguments);M=true}function b(){f(arguments);
M=false}function a(){z.style+=" xml-error"}function c(B){return function(D,G){if(G==B)e();else{a();e(arguments.callee)}}}function d(B,D){var G=l.doNotIndent.hasOwnProperty(B)||C&&C.noIndent;C={prev:C,name:B,indent:H,startOfLine:D,noIndent:G}}function g(B){return function(D,G){var I=B;if(I&&I.noIndent)return G;if(q&&/<!\[CDATA\[/.test(D))return 0;if(I&&/^<\//.test(D))I=I.prev;for(;I&&!I.startOfLine;)I=I.prev;return I?I.indent+indentUnit:0}}function j(){return b(i,j)}function i(B,D){if(D=="<")e(k,t,
r(y==1));else if(D=="</")e(p,c(">"));else{if(B=="xml-cdata"){if(!C||C.name!="!cdata")d("!cdata");if(/\]\]>$/.test(D))C=C.prev}else L.hasOwnProperty(B)||a();e()}}function k(B,D){if(B=="xml-name"){E=D.toLowerCase();z.style="xml-tagname";e()}else{E=null;b()}}function p(B,D){if(B=="xml-name"){z.style="xml-tagname";if(C&&D.toLowerCase()==C.name)C=C.prev;else a()}e()}function r(B){return function(D,G){if(G=="/>"||G==">"&&l.autoSelfClosers.hasOwnProperty(E))e();else if(G==">"){d(E,B);e()}else{a();e(arguments.callee)}}}
function t(B){if(B=="xml-name"){z.style="xml-attname";e(v,t)}else b()}function v(B,D){if(D=="=")e(w);else D==">"||D=="/>"?b(r):b()}function w(B){B=="xml-attribute"?e(w):b()}var x=n(m),z,u=[j],y=0,H=0,E=null,C=null,M,L={"xml-text":true,"xml-entity":true,"xml-comment":true,"xml-processing":true};return{indentation:function(){return H},next:function(){z=x.next();if(z.style=="whitespace"&&y==0)H=z.value.length;else y++;if(z.content=="\n"){H=y=0;z.indentation=g(C)}if(z.style=="whitespace"||z.type=="xml-comment")return z;
for(;;){M=false;u.pop()(z.style,z.content);if(M)return z}},copy:function(){var B=u.concat([]),D=x.state,G=C,I=this;return function(K){u=B.concat([]);y=H=0;C=G;x=n(K,D);return I}}}},electricChars:"/",configure:function(m){if(m.useHTMLKludges!=null)l=m.useHTMLKludges?h:o;if(m.alignCDATA)q=m.alignCDATA}}}();var CSSParser=Editor.Parser=function(){function h(l,q,n){return function(m){return!l||/^\}/.test(m)?n:q?n+indentUnit*2:n+indentUnit}}var o=function(){function l(f,e){var b=f.next();if(b=="@"){f.nextWhileMatches(/\w/);return"css-at"}else if(b=="/"&&f.equals("*")){e(q);return null}else if(b=="<"&&f.equals("!")){e(n);return null}else if(b=="=")return"css-compare";else if(f.equals("=")&&(b=="~"||b=="|")){f.next();return"css-compare"}else if(b=='"'||b=="'"){e(m(b));return null}else if(b=="#"){f.nextWhileMatches(/\w/);
return"css-hash"}else if(b=="!"){f.nextWhileMatches(/[ \t]/);f.nextWhileMatches(/\w/);return"css-important"}else if(/\d/.test(b)){f.nextWhileMatches(/[\w.%]/);return"css-unit"}else if(/[,.+>*\/]/.test(b))return"css-select-op";else if(/[;{}:\[\]]/.test(b))return"css-punctuation";else{f.nextWhileMatches(/[\w\\\-_]/);return"css-identifier"}}function q(f,e){for(var b=false;!f.endOfLine();){var a=f.next();if(b&&a=="/"){e(l);break}b=a=="*"}return"css-comment"}function n(f,e){for(var b=0;!f.endOfLine();){var a=
f.next();if(b>=2&&a==">"){e(l);break}b=a=="-"?b+1:0}return"css-comment"}function m(f){return function(e,b){for(var a=false;!e.endOfLine();){var c=e.next();if(c==f&&!a)break;a=!a&&c=="\\"}a||b(l);return"css-string"}}return function(f,e){return tokenizer(f,e||l)}}();return{make:function(l,q){q=q||0;var n=o(l),m=false,f=false,e=false,b={next:function(){var a=n.next(),c=a.style,d=a.content;if(c=="css-hash")c=a.style=f?"css-colorcode":"css-identifier";if(c=="css-identifier")if(f)a.style="css-value";else if(!m&&
!e)a.style="css-selector";if(d=="\n")a.indentation=h(m,f,q);if(d=="{")m=true;else if(d=="}")m=f=e=false;else if(d==";")f=e=false;else if(m&&c!="css-comment"&&c!="whitespace")f=true;else if(!m&&c=="css-at")e=true;return a},copy:function(){var a=m,c=f,d=n.state;return function(g){n=o(g,d);m=a;f=c;return b}}};return b},electricChars:"}"}}();var SparqlParser=Editor.Parser=function(){function h(m){return function(f){f=f&&f.charAt(0);if(/[\]\}]/.test(f))for(;m&&m.type=="pattern";)m=m.prev;f=m&&f==matching[m.type];return m?m.type=="pattern"?m.col:m.align?m.col-(f?m.width:0):m.indent+(f?0:indentUnit):0}}var o=/^(?:str|lang|langmatches|datatype|bound|sameterm|isiri|isuri|isblank|isliteral|union|a)$/i,l=RegExp("^(?:base|prefix|select|distinct|reduced|construct|describe|ask|from|named|where|order|limit|offset|filter|optional|graph|by|asc|desc)$",
"i"),q=/[*+\-<>=&|]/,n=function(){function m(e,b){var a=e.next();if(a=="$"||a=="?"){e.nextWhileMatches(/[\w\d]/);return"sp-var"}else if(a=="<"&&!e.matches(/[\s\u00a0=]/)){e.nextWhileMatches(/[^\s\u00a0>]/);e.equals(">")&&e.next();return"sp-uri"}else if(a=='"'||a=="'"){b(f(a));return null}else if(/[{}\(\),\.;\[\]]/.test(a))return"sp-punc";else if(a=="#"){for(;!e.endOfLine();)e.next();return"sp-comment"}else if(q.test(a)){e.nextWhileMatches(q);return"sp-operator"}else if(a==":"){e.nextWhileMatches(/[\w\d\._\-]/);
return"sp-prefixed"}else{e.nextWhileMatches(/[_\w\d]/);if(e.equals(":")){e.next();e.nextWhileMatches(/[\w\d_\-]/);return"sp-prefixed"}a=e.get();return{style:o.test(a)?"sp-operator":l.test(a)?"sp-keyword":"sp-word",content:a}}}function f(e){return function(b,a){for(var c=false;!b.endOfLine();){var d=b.next();if(d==e&&!c){a(m);break}c=!c&&d=="\\"}return"sp-literal"}}return function(e,b){return tokenizer(e,b||m)}}();return{make:function(m){function f(g,j){b={prev:b,indent:a,col:c,type:g,width:j}}var e=
n(m),b=null,a=0,c=0,d={next:function(){var g=e.next(),j=g.style,i=g.content,k=g.value.length;if(i=="\n"){g.indentation=h(b);a=c=0;if(b&&b.align==null)b.align=false}else if(j=="whitespace"&&c==0)a=k;else if(j!="sp-comment"&&b&&b.align==null)b.align=true;if(i!="\n")c+=k;if(/[\[\{\(]/.test(i))f(i,k);else if(/[\]\}\)]/.test(i)){for(;b&&b.type=="pattern";)b=b.prev;if(b&&i==matching[b.type])b=b.prev}else if(i=="."&&b&&b.type=="pattern")b=b.prev;else if((j=="sp-word"||j=="sp-prefixed"||j=="sp-uri"||j=="sp-var"||
j=="sp-literal")&&b&&/[\{\[]/.test(b.type))f("pattern",k);return g},copy:function(){var g=b,j=a,i=c,k=e.state;return function(p){e=n(p,k);b=g;a=j;c=i;return d}}};return d},electricChars:"}]"}}();var HTMLMixedParser=Editor.Parser=function(){if(!(CSSParser&&JSParser&&XMLParser))throw Error("CSS, JS, and XML parsers must be loaded for HTML mixed mode to work.");XMLParser.configure({useHTMLKludges:true});return{make:function(h){function o(){var e=q.next();if(e.content=="<")m=true;else if(e.style=="xml-tagname"&&m===true)m=e.content.toLowerCase();else if(e.content==">"){if(m=="script")f.next=l(JSParser,"<\/script");else if(m=="style")f.next=l(CSSParser,"</style");m=false}return e}function l(e,
b){var a=q.indentation();n=e.make(h,a+indentUnit);return function(){if(h.lookAhead(b,false,false,true)){n=null;f.next=o;return o()}var c=n.next(),d=c.value.lastIndexOf("<"),g=Math.min(c.value.length-d,b.length);if(d!=-1&&c.value.slice(d,d+g).toLowerCase()==b.slice(0,g)&&h.lookAhead(b.slice(g),false,false,true)){h.push(c.value.slice(d));c.value=c.value.slice(0,d)}if(c.indentation){var j=c.indentation;c.indentation=function(i){return i=="</"?a:j(i)}}return c}}var q=XMLParser.make(h),n=null,m=false,
f={next:o,copy:function(){var e=q.copy(),b=n&&n.copy(),a=f.next,c=m;return function(d){h=d;q=e(d);n=b&&b(d);f.next=a;m=c;return f}}};return f},electricChars:"{}/:"}}();var DummyParser=Editor.Parser=function(){function h(o){for(;!o.endOfLine();)o.next();return"text"}return{make:function(o){function l(m){return function(){return m}}o=tokenizer(o,h);var q=0,n={next:function(){var m=o.next();if(m.type=="whitespace")if(m.value=="\n")m.indentation=l(q);else q=m.value.length;return m},copy:function(){var m=q;return function(f){q=m;o=tokenizer(f,h);return n}}};return n}}}();CodeMirrorConfig=window.CodeMirrorConfig||{};
CodeMirror=function(){function h(f,e){for(var b in e)f.hasOwnProperty(b)||(f[b]=e[b])}function o(f,e){for(var b=0;b<f.length;b++)e(f[b])}function l(f,e){var b=document.createElement("DIV"),a=document.createElement("DIV");b.style.position="absolute";b.style.height="100%";if(b.style.setExpression)try{b.style.setExpression("height","this.previousSibling.offsetHeight + 'px'")}catch(c){}b.style.top="0px";b.style.left="0px";b.style.overflow="hidden";f.appendChild(b);a.className="CodeMirror-line-numbers";
b.appendChild(a);a.innerHTML="<div>"+e+"</div>";return b}function q(f){if(typeof f.parserfile=="string")f.parserfile=[f.parserfile];if(typeof f.basefiles=="string")f.basefiles=[f.basefiles];if(typeof f.stylesheet=="string")f.stylesheet=[f.stylesheet];var e=['<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>'];e.push('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>');o(f.stylesheet,function(b){e.push('<link rel="stylesheet" type="text/css" href="'+
b+'"/>')});o(f.basefiles.concat(f.parserfile),function(b){/^https?:/.test(b)||(b=f.path+b);e.push('<script type="text/javascript" src="'+b+'"><\/script>')});e.push('</head><body style="border-width: 0;" class="editbox" spellcheck="'+(f.disableSpellcheck?"false":"true")+'"></body></html>');return e.join("")}function n(f,e){this.options=e=e||{};h(e,CodeMirrorConfig);if(e.dumbTabs)e.tabMode="spaces";else if(e.normalTab)e.tabMode="default";var b=this.frame=document.createElement("IFRAME");if(e.iframeClass)b.className=
e.iframeClass;b.frameBorder=0;b.style.border="0";b.style.width="100%";b.style.height="100%";b.style.display="block";var a=this.wrapping=document.createElement("DIV");a.style.position="relative";a.className="CodeMirror-wrapping";a.style.width=e.width;a.style.height=e.height=="dynamic"?e.minHeight+"px":e.height;var c=this.textareaHack=document.createElement("TEXTAREA");a.appendChild(c);c.style.position="absolute";c.style.left="-10000px";c.style.width="10px";b.CodeMirror=this;if(e.domain&&m){this.html=
q(e);b.src="javascript:(function(){document.open();"+(e.domain?'document.domain="'+e.domain+'";':"")+"document.write(window.frameElement.CodeMirror.html);document.close();})()"}else b.src="javascript:;";f.appendChild?f.appendChild(a):f(a);a.appendChild(b);if(e.lineNumbers)this.lineNumbers=l(a,e.firstLineNumber);this.win=b.contentWindow;if(!e.domain||!m){this.win.document.open();this.win.document.write(q(e));this.win.document.close()}}h(CodeMirrorConfig,{stylesheet:[],path:"",parserfile:[],basefiles:["util.js",
"stringstream.js","select.js","undo.js","editor.js","tokenize.js"],iframeClass:null,passDelay:200,passTime:50,lineNumberDelay:200,lineNumberTime:50,continuousScanning:false,saveFunction:null,onChange:null,undoDepth:50,undoDelay:800,disableSpellcheck:true,textWrapping:true,readOnly:false,width:"",height:"300px",minHeight:100,autoMatchParens:false,parserConfig:null,tabMode:"indent",enterMode:"indent",electricChars:true,reindentOnLoad:false,activeTokens:null,cursorActivity:null,lineNumbers:false,firstLineNumber:1,
indentUnit:2,domain:null});var m=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent);n.prototype={init:function(){this.options.initCallback&&this.options.initCallback(this);this.options.lineNumbers&&this.activateLineNumbers();this.options.reindentOnLoad&&this.reindent();this.options.height=="dynamic"&&this.setDynamicHeight()},getCode:function(){return this.editor.getCode()},setCode:function(f){this.editor.importCode(f)},selection:function(){this.focusIfIE();return this.editor.selectedText()},
reindent:function(){this.editor.reindent()},reindentSelection:function(){this.focusIfIE();this.editor.reindentSelection(null)},focusIfIE:function(){this.win.select.ie_selection&&this.focus()},focus:function(){this.win.focus();this.editor.selectionSnapshot&&this.win.select.setBookmark(this.win.document.body,this.editor.selectionSnapshot)},replaceSelection:function(f){this.focus();this.editor.replaceSelection(f);return true},replaceChars:function(f,e,b){this.editor.replaceChars(f,e,b)},getSearchCursor:function(f,
e,b){return this.editor.getSearchCursor(f,e,b)},undo:function(){this.editor.history.undo()},redo:function(){this.editor.history.redo()},historySize:function(){return this.editor.history.historySize()},clearHistory:function(){this.editor.history.clear()},grabKeys:function(f,e){this.editor.grabKeys(f,e)},ungrabKeys:function(){this.editor.ungrabKeys()},setParser:function(f,e){this.editor.setParser(f,e)},setSpellcheck:function(f){this.win.document.body.spellcheck=f},setStylesheet:function(f){if(typeof f===
"string")f=[f];for(var e={},b={},a=this.win.document.getElementsByTagName("link"),c=0,d;d=a[c];c++)if(d.rel.indexOf("stylesheet")!==-1)for(var g=0;g<f.length;g++){var j=f[g];if(d.href.substring(d.href.length-j.length)===j){e[d.href]=true;b[j]=true}}for(c=0;d=a[c];c++)if(d.rel.indexOf("stylesheet")!==-1)d.disabled=!(d.href in e);for(g=0;g<f.length;g++){j=f[g];if(!(j in b)){d=this.win.document.createElement("link");d.rel="stylesheet";d.type="text/css";d.href=j;this.win.document.getElementsByTagName("head")[0].appendChild(d)}}},
setTextWrapping:function(f){if(f!=this.options.textWrapping){this.win.document.body.style.whiteSpace=f?"":"nowrap";this.options.textWrapping=f;if(this.lineNumbers){this.setLineNumbers(false);this.setLineNumbers(true)}}},setIndentUnit:function(f){this.win.indentUnit=f},setUndoDepth:function(f){this.editor.history.maxDepth=f},setTabMode:function(f){this.options.tabMode=f},setEnterMode:function(f){this.options.enterMode=f},setLineNumbers:function(f){if(f&&!this.lineNumbers){this.lineNumbers=l(this.wrapping);
this.activateLineNumbers()}else if(!f&&this.lineNumbers){this.wrapping.removeChild(this.lineNumbers);this.wrapping.style.marginLeft="";this.lineNumbers=null}},cursorPosition:function(f){this.focusIfIE();return this.editor.cursorPosition(f)},firstLine:function(){return this.editor.firstLine()},lastLine:function(){return this.editor.lastLine()},nextLine:function(f){return this.editor.nextLine(f)},prevLine:function(f){return this.editor.prevLine(f)},lineContent:function(f){return this.editor.lineContent(f)},
setLineContent:function(f,e){this.editor.setLineContent(f,e)},removeLine:function(f){this.editor.removeLine(f)},insertIntoLine:function(f,e,b){this.editor.insertIntoLine(f,e,b)},selectLines:function(f,e,b,a){this.win.focus();this.editor.selectLines(f,e,b,a)},nthLine:function(f){for(var e=this.firstLine();f>1&&e!==false;f--)e=this.nextLine(e);return e},lineNumber:function(f){for(var e=0;f!==false;){e++;f=this.prevLine(f)}return e},jumpToLine:function(f){if(typeof f=="number")f=this.nthLine(f);this.selectLines(f,
0);this.win.focus()},currentLine:function(){return this.lineNumber(this.cursorLine())},cursorLine:function(){return this.cursorPosition().line},cursorCoords:function(f){return this.editor.cursorCoords(f)},activateLineNumbers:function(){function f(){if(d.offsetWidth!=0){for(var x=d;x.parentNode;x=x.parentNode);if(!k.parentNode||x!=document||!g.Editor){try{v()}catch(z){}clearInterval(w)}else if(k.offsetWidth!=t){t=k.offsetWidth;d.parentNode.style.paddingLeft=t+"px"}}}function e(){k.scrollTop=i.scrollTop||
j.documentElement.scrollTop||0}function b(x){var z=p.firstChild.offsetHeight;if(z!=0){z=Math.ceil((50+Math.max(i.offsetHeight,Math.max(d.offsetHeight,i.scrollHeight||0)))/z);for(var u=p.childNodes.length;u<=z;u++){var y=document.createElement("DIV");y.appendChild(document.createTextNode(x?String(u+r.options.firstLineNumber):"\u00a0"));p.appendChild(y)}}}function a(){function x(){b(true);e()}r.updateNumbers=x;var z=g.addEventHandler(g,"scroll",e,true),u=g.addEventHandler(g,"resize",x,true);v=function(){z();
u();if(r.updateNumbers==x)r.updateNumbers=null};x()}function c(){function x(F,J){C||(C=p.appendChild(document.createElement("DIV")));D&&D(C,J,F);B.push(C);B.push(F);L=C.offsetHeight+C.offsetTop;C=C.nextSibling}function z(){for(var F=0;F<B.length;F+=2)B[F].innerHTML=B[F+1];B=[]}function u(){if(!(!p.parentNode||p.parentNode!=r.lineNumbers)){for(var F=(new Date).getTime()+r.options.lineNumberTime;E;){for(x(M++,E.previousSibling);E&&!g.isBR(E);E=E.nextSibling)for(var J=E.offsetTop+E.offsetHeight;p.offsetHeight&&
J-3>L;)x("&nbsp;");if(E)E=E.nextSibling;if((new Date).getTime()>F){z();G=setTimeout(u,r.options.lineNumberDelay);return}}for(;C;)x(M++);z();e()}}function y(F){e();b(F);E=i.firstChild;C=p.firstChild;L=0;M=r.options.firstLineNumber;u()}function H(){G&&clearTimeout(G);if(r.editor.allClean())y();else G=setTimeout(H,200)}var E,C,M,L,B=[],D=r.options.styleNumbers;y(true);var G=null;r.updateNumbers=H;var I=g.addEventHandler(g,"scroll",e,true),K=g.addEventHandler(g,"resize",H,true);v=function(){G&&clearTimeout(G);
if(r.updateNumbers==H)r.updateNumbers=null;I();K()}}var d=this.frame,g=d.contentWindow,j=g.document,i=j.body,k=this.lineNumbers,p=k.firstChild,r=this,t=null,v=function(){};f();var w=setInterval(f,500);(this.options.textWrapping||this.options.styleNumbers?c:a)()},setDynamicHeight:function(){function f(){for(var i=0,k=c.lastChild,p;k&&a.isBR(k);){k.hackBR||i++;k=k.previousSibling}if(k){d=k.offsetHeight;p=k.offsetTop+(1+i)*d}else if(d)p=i*d;if(p)e.wrapping.style.height=Math.max(j+p,e.options.minHeight)+
"px"}var e=this,b=e.options.cursorActivity,a=e.win,c=a.document.body,d=null,g=null,j=2*e.frame.offsetTop;c.style.overflowY="hidden";a.document.documentElement.style.overflowY="hidden";this.frame.scrolling="no";setTimeout(f,300);e.options.cursorActivity=function(i){b&&b(i);clearTimeout(g);g=setTimeout(f,100)}}};n.InvalidLineHandle={toString:function(){return"CodeMirror.InvalidLineHandle"}};n.replace=function(f){if(typeof f=="string")f=document.getElementById(f);return function(e){f.parentNode.replaceChild(e,
f)}};n.fromTextArea=function(f,e){if(typeof f=="string")f=document.getElementById(f);e=e||{};if(f.style.width&&e.width==null)e.width=f.style.width;if(f.style.height&&e.height==null)e.height=f.style.height;if(e.content==null)e.content=f.value;if(f.form){var b=function(){f.value=d.getCode()};typeof f.form.addEventListener=="function"?f.form.addEventListener("submit",b,false):f.form.attachEvent("onsubmit",b);var a=f.form.submit,c=function(){b();f.form.submit=a;f.form.submit();f.form.submit=c};f.form.submit=
c}f.style.display="none";var d=new n(function(g){f.nextSibling?f.parentNode.insertBefore(g,f.nextSibling):f.parentNode.appendChild(g)},e);d.toTextArea=function(){f.parentNode.removeChild(d.wrapping);f.style.display="";if(f.form){f.form.submit=a;typeof f.form.removeEventListener=="function"?f.form.removeEventListener("submit",b,false):f.form.detachEvent("onsubmit",b)}};return d};n.isProbablySupported=function(){var f;return window.opera?Number(window.opera.version())>=9.52:/Apple Computers, Inc/.test(navigator.vendor)&&
(f=navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./))?Number(f[1])>=3:document.selection&&window.ActiveXObject&&(f=navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/))?Number(f[1])>=6:(f=navigator.userAgent.match(/gecko\/(\d{8})/i))?Number(f[1])>=20050901:(f=navigator.userAgent.match(/AppleWebKit\/(\d+)/))?Number(f[1])>=525:null};return n}();function method(h,o){return function(){h[o].apply(h,arguments)}}StopIteration={toString:function(){return"StopIteration"}};
function forEach(h,o){if(h.next)try{for(;;)o(h.next())}catch(l){if(l!=StopIteration)throw l;}else for(var q=0;q<h.length;q++)o(h[q])}function map(h,o){var l=[];forEach(h,function(q){l.push(o(q))});return l}function matcher(h){return function(o){return h.test(o)}}function hasClass(h,o){var l=h.className;return l&&RegExp("(^| )"+o+"($| )").test(l)}function insertAfter(h,o){o.parentNode.insertBefore(h,o.nextSibling);return h}function removeElement(h){h.parentNode&&h.parentNode.removeChild(h)}
function clearElement(h){for(;h.firstChild;)h.removeChild(h.firstChild)}function isAncestor(h,o){for(;o=o.parentNode;)if(h==o)return true;return false}nbsp="\u00a0";matching={"{":"}","[":"]","(":")","}":"{","]":"[",")":"("};
function normalizeEvent(h){if(!h.stopPropagation){h.stopPropagation=function(){this.cancelBubble=true};h.preventDefault=function(){this.returnValue=false}}if(!h.stop)h.stop=function(){this.stopPropagation();this.preventDefault()};if(h.type=="keypress"){h.code=h.charCode==null?h.keyCode:h.charCode;h.character=String.fromCharCode(h.code)}return h}
function addEventHandler(h,o,l,q){function n(m){l(normalizeEvent(m||window.event))}if(typeof h.addEventListener=="function"){h.addEventListener(o,n,false);if(q)return function(){h.removeEventListener(o,n,false)}}else{h.attachEvent("on"+o,n);if(q)return function(){h.detachEvent("on"+o,n)}}}function nodeText(h){return h.textContent||h.innerText||h.nodeValue||""}function nodeTop(h){for(var o=0;h.offsetParent;){o+=h.offsetTop;h=h.offsetParent}return o}
function isBR(h){h=h.nodeName;return h=="BR"||h=="br"}function isSpan(h){h=h.nodeName;return h=="SPAN"||h=="span"}
stringStream=function(h){function o(){for(;q==l.length;){n+=l;l="";q=0;try{l=h.next()}catch(m){if(m!=StopIteration)throw m;else return false}}return true}var l="",q=0,n="";return{peek:function(){if(!o())return null;return l.charAt(q)},next:function(){if(!o())if(n.length>0)throw"End of stringstream reached without emptying buffer ('"+n+"').";else throw StopIteration;return l.charAt(q++)},get:function(){var m=n;n="";if(q>0){m+=l.slice(0,q);l=l.slice(q);q=0}return m},push:function(m){l=l.slice(0,q)+
m+l.slice(q)},lookAhead:function(m,f,e,b){function a(k){return b?k.toLowerCase():k}m=a(m);var c=false,d=n,g=q;for(e&&this.nextWhileMatches(/[\s\u00a0]/);;){e=q+m.length;var j=l.length-q;if(e<=l.length){c=m==a(l.slice(q,e));q=e;break}else if(m.slice(0,j)==a(l.slice(q))){n+=l;l="";try{l=h.next()}catch(i){break}q=0;m=m.slice(j)}else break}if(!(c&&f)){l=n.slice(d.length)+l;q=g;n=d}return c},more:function(){return this.peek()!==null},applies:function(m){var f=this.peek();return f!==null&&m(f)},nextWhile:function(m){for(var f;(f=
this.peek())!==null&&m(f);)this.next()},matches:function(m){var f=this.peek();return f!==null&&m.test(f)},nextWhileMatches:function(m){for(var f;(f=this.peek())!==null&&m.test(f);)this.next()},equals:function(m){return m===this.peek()},endOfLine:function(){var m=this.peek();return m==null||m=="\n"}}};select={};
(function(){function h(a,c){for(;a&&a.parentNode!=c;)a=a.parentNode;return a}function o(a,c){for(;!a.previousSibling&&a.parentNode!=c;)a=a.parentNode;return h(a.previousSibling,c)}select.ie_selection=document.selection&&document.selection.createRangeCollection;select.scrollToNode=function(a,c){if(a){for(var d=a,g=document.body,j=document.documentElement,i=!d.nextSibling||!d.nextSibling.nextSibling||!d.nextSibling.nextSibling.nextSibling,k=0;d&&!d.offsetTop;){k++;d=d.previousSibling}if(k==0)i=false;
if(!(webkit&&d&&d.offsetTop==5&&d.offsetLeft==5)){k*=d?d.offsetHeight:0;for(var p=0,r=a?a.offsetWidth:0;d&&d.offsetParent;){k+=d.offsetTop;isBR(d)||(p+=d.offsetLeft);d=d.offsetParent}d=g.scrollLeft||j.scrollLeft||0;g=g.scrollTop||j.scrollTop||0;var t=false,v=window.innerWidth||j.clientWidth||0;if(c||r<v){if(c){var w=select.offsetInNode(a),x=nodeText(a).length;if(x)p+=r*(w/x)}r=p-d;if(r<0||r>v){d=p;t=true}}p=k-g;if(p<0||i||p>(window.innerHeight||j.clientHeight||0)-50){g=i?1E6:k;t=true}t&&window.scrollTo(d,
g)}}};select.scrollToCursor=function(a){select.scrollToNode(select.selectionTopNode(a,true)||a.firstChild,true)};var l=null;select.snapshotChanged=function(){if(l)l.changed=true};select.snapshotReplaceNode=function(a,c,d,g){function j(i){if(a==i.node){l.changed=true;if(d&&i.offset>d)i.offset-=d;else{i.node=c;i.offset+=g||0}}}if(l){j(l.start);j(l.end)}};select.snapshotMove=function(a,c,d,g,j){function i(k){if(a==k.node&&(!j||k.offset==0)){l.changed=true;k.node=c;k.offset=g?Math.max(0,k.offset+d):d}}
if(l){i(l.start);i(l.end)}};if(select.ie_selection){var q=function(a){function c(r){for(var t=null;!t&&r;){t=r.nextSibling;r=r.parentNode}return d(t)}function d(r){for(;r&&r.firstChild;)r=r.firstChild;return{node:r,offset:0}}var g=document.selection.createRange();g.collapse(a);a=g.parentElement();if(!isAncestor(document.body,a))return null;if(!a.firstChild)return d(a);var j=g.duplicate();j.moveToElementText(a);j.collapse(true);for(var i=a.firstChild;i;i=i.nextSibling){if(i.nodeType==3){var k=i.nodeValue.length;
j.move("character",k)}else{j.moveToElementText(i);j.collapse(false)}var p=g.compareEndPoints("StartToStart",j);if(p==0)return c(i);if(p!=1){if(i.nodeType!=3)return d(i);j.setEndPoint("StartToEnd",g);return{node:i,offset:k-j.text.length}}}return c(a)};select.markSelection=function(){l=null;if(document.selection){var a=q(true),c=q(false);if(a&&c)l={start:a,end:c,changed:false}}};select.selectMarked=function(){function a(g){var j=document.body.createTextRange(),i=g.node;if(i)if(i.nodeType==3){j.moveToElementText(i.parentNode);
for(g=g.offset;i.previousSibling;){i=i.previousSibling;g+=(i.innerText||"").length}j.move("character",g)}else{j.moveToElementText(i);j.collapse(true)}else{j.moveToElementText(document.body);j.collapse(false)}return j}if(l&&l.changed){var c=a(l.start),d=a(l.end);c.setEndPoint("StartToEnd",d);c.select()}};select.offsetInNode=function(a){var c=document.selection;if(!c)return 0;c=c.createRange();var d=c.duplicate();try{d.moveToElementText(a)}catch(g){return 0}c.setEndPoint("StartToStart",d);return c.text.length};
select.selectionTopNode=function(a,c){function d(t,v){if(v.nodeType==3){for(var w=0,x=v.previousSibling;x&&x.nodeType==3;){w+=x.nodeValue.length;x=x.previousSibling}if(x){try{t.moveToElementText(x)}catch(z){return false}t.collapse(false)}else t.moveToElementText(v.parentNode);w&&t.move("character",w)}else try{t.moveToElementText(v)}catch(u){return false}return true}var g=document.selection;if(!g)return false;var j=g.createRange(),i=j.duplicate();j.collapse(c);var k=j.parentElement();if(k&&isAncestor(a,
k)){i.moveToElementText(k);if(j.compareEndPoints("StartToStart",i)==1)return h(k,a)}c=0;for(k=a.childNodes.length-1;c<k;){var p=Math.ceil((k+c)/2),r=a.childNodes[p];if(!r)return false;if(!d(i,r))return false;if(j.compareEndPoints("StartToStart",i)==1)c=p;else k=p-1}if(c==0){g=g.createRange();j=g.duplicate();j.moveToElementText(a);if(g.compareEndPoints("StartToStart",j)==0)return null}return a.childNodes[c]||null};select.focusAfterNode=function(a,c){var d=document.body.createTextRange();d.moveToElementText(a||
c);d.collapse(!a);d.select()};select.somethingSelected=function(){var a=document.selection;return a&&a.createRange().text!=""};var n=function(a){var c=document.selection;if(c){c=c.createRange();c.pasteHTML(a);c.collapse(false);c.select()}};select.insertNewlineAtCursor=function(){n("<br>")};select.insertTabAtCursor=function(){n("\u00a0\u00a0\u00a0\u00a0")};select.cursorPos=function(a,c){var d=document.selection;if(!d)return null;for(var g=select.selectionTopNode(a,c);g&&!isBR(g);)g=g.previousSibling;
d=d.createRange();var j=d.duplicate();d.collapse(c);if(g){j.moveToElementText(g);j.collapse(false)}else{try{j.moveToElementText(a)}catch(i){return null}j.collapse(true)}d.setEndPoint("StartToStart",j);return{node:g,offset:d.text.length}};select.setCursorPos=function(a,c,d){function g(i){var k=document.body.createTextRange();if(i.node){k.moveToElementText(i.node);k.collapse(false)}else{k.moveToElementText(a);k.collapse(true)}k.move("character",i.offset);return k}var j=g(c);d&&d!=c&&j.setEndPoint("EndToEnd",
g(d));j.select()};select.getBookmark=function(a){var c=select.cursorPos(a,true);a=select.cursorPos(a,false);if(c&&a)return{from:c,to:a}};select.setBookmark=function(a,c){c&&select.setCursorPos(a,c.from,c.to)}}else{var m=function(a,c){for(;a.nodeType!=3&&!isBR(a);){var d=a.childNodes[c]||a.nextSibling;for(c=0;!d&&a.parentNode;){a=a.parentNode;d=a.nextSibling}a=d;if(!d)break}return{node:a,offset:c}};select.markSelection=function(){var a=window.getSelection();if(!a||a.rangeCount==0)return l=null;a=a.getRangeAt(0);
l={start:m(a.startContainer,a.startOffset),end:m(a.endContainer,a.endOffset),changed:false}};select.selectMarked=function(){function a(){if(d.start.node==d.end.node&&d.start.offset==d.end.offset){var j=window.getSelection();if(!j||j.rangeCount==0)return true;j=j.getRangeAt(0);j=m(j.startContainer,j.startOffset);return d.start.node!=j.node||d.start.offset!=j.offset}}function c(j,i){if(j.node)j.offset==0?g["set"+i+"Before"](j.node):g["set"+i](j.node,j.offset);else g.setStartAfter(document.body.lastChild||
document.body)}var d=l;if(d&&(d.changed||webkit&&a())){var g=document.createRange();c(d.end,"End");c(d.start,"Start");f(g)}};var f=function(a){var c=window.getSelection();if(c){c.removeAllRanges();c.addRange(a)}},e=function(){var a=window.getSelection();return!a||a.rangeCount==0?false:a.getRangeAt(0)};select.selectionTopNode=function(a,c){var d=e();if(!d)return false;var g=c?d.startContainer:d.endContainer,j=c?d.startOffset:d.endOffset;window.opera&&!c&&d.endContainer==a&&d.endOffset==d.startOffset+
1&&a.childNodes[d.startOffset]&&isBR(a.childNodes[d.startOffset])&&j--;return g.nodeType==3?j>0?h(g,a):o(g,a):g.nodeName.toUpperCase()=="HTML"?j==1?null:a.lastChild:g==a?j==0?null:g.childNodes[j-1]:j==g.childNodes.length?h(g,a):j==0?o(g,a):h(g.childNodes[j-1],a)};select.focusAfterNode=function(a,c){var d=document.createRange();d.setStartBefore(c.firstChild||c);if(a&&!a.firstChild)d.setEndAfter(a);else a?d.setEnd(a,a.childNodes.length):d.setEndBefore(c.firstChild||c);d.collapse(false);f(d)};select.somethingSelected=
function(){var a=e();return a&&!a.collapsed};select.offsetInNode=function(a){var c=e();if(!c)return 0;c=c.cloneRange();c.setStartBefore(a);return c.toString().length};var b=function(a){var c=e();if(c){c.deleteContents();c.insertNode(a);webkitLastLineHack(document.body);if(window.opera&&isBR(a)&&isSpan(a.parentNode)){c=a.nextSibling;var d=a.parentNode,g=d.parentNode;g.insertBefore(a,d.nextSibling);for(d="";c&&c.nodeType==3;c=c.nextSibling){d+=c.nodeValue;removeElement(c)}g.insertBefore(makePartSpan(d,
document),a.nextSibling)}c=document.createRange();c.selectNode(a);c.collapse(false);f(c)}};select.insertNewlineAtCursor=function(){b(document.createElement("BR"))};select.insertTabAtCursor=function(){b(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"))};select.cursorPos=function(a,c){var d=e();if(d){for(var g=select.selectionTopNode(a,c);g&&!isBR(g);)g=g.previousSibling;d=d.cloneRange();d.collapse(c);g?d.setStartAfter(g):d.setStartBefore(a);d=d.toString();return{node:g,offset:d.length}}};select.setCursorPos=
function(a,c,d){function g(i,k,p){function r(x){x.nodeType==3?t.push(x):forEach(x.childNodes,r)}if(k==0&&i&&!i.nextSibling){j["set"+p+"After"](i);return true}if(i=i?i.nextSibling:a.firstChild){if(k==0){j["set"+p+"Before"](i);return true}for(var t=[];;){for(;i&&!t.length;){r(i);i=i.nextSibling}var v=t.shift();if(!v)return false;var w=v.nodeValue.length;if(w>=k){j["set"+p](v,k);return true}k-=w}}}var j=document.createRange();d=d||c;g(d.node,d.offset,"End")&&g(c.node,c.offset,"Start")&&f(j)}}})();
function UndoHistory(h,o,l,q){this.container=h;this.maxDepth=o;this.commitDelay=l;this.editor=q;this.parent=q.parent;this.last=this.first={text:"",from:null,to:null};this.firstTouched=false;this.history=[];this.redoHistory=[];this.touched=[]}
UndoHistory.prototype={scheduleCommit:function(){var h=this;this.parent.clearTimeout(this.commitTimeout);this.commitTimeout=this.parent.setTimeout(function(){h.tryCommit()},this.commitDelay)},touch:function(h){this.setTouched(h);this.scheduleCommit()},undo:function(){this.commit();if(this.history.length){var h=this.history.pop();this.redoHistory.push(this.updateTo(h,"applyChain"));this.notifyEnvironment();return this.chainNode(h)}},redo:function(){this.commit();if(this.redoHistory.length){var h=this.redoHistory.pop();
this.addUndoLevel(this.updateTo(h,"applyChain"));this.notifyEnvironment();return this.chainNode(h)}},clear:function(){this.history=[];this.redoHistory=[]},historySize:function(){return{undo:this.history.length,redo:this.redoHistory.length}},push:function(h,o,l){for(var q=[],n=0;n<l.length;n++){var m=n==l.length-1?o:this.container.ownerDocument.createElement("BR");q.push({from:h,to:m,text:cleanText(l[n])});h=m}this.pushChains([q],h==null&&o==null);this.notifyEnvironment()},pushChains:function(h,o){this.commit(o);
this.addUndoLevel(this.updateTo(h,"applyChain"));this.redoHistory=[]},chainNode:function(h){for(var o=0;o<h.length;o++){var l=h[o][0];if(l=l&&(l.from||l.to))return l}},reset:function(){this.history=[];this.redoHistory=[]},textAfter:function(h){return this.after(h).text},nodeAfter:function(h){return this.after(h).to},nodeBefore:function(h){return this.before(h).from},tryCommit:function(){if(window.parent&&window.UndoHistory)this.editor.highlightDirty()?this.commit(true):this.scheduleCommit()},commit:function(h){this.parent.clearTimeout(this.commitTimeout);
h||this.editor.highlightDirty(true);h=this.touchedChains();if(h.length){this.addUndoLevel(this.updateTo(h,"linkChain"));this.redoHistory=[];this.notifyEnvironment()}},updateTo:function(h,o){for(var l=[],q=[],n=0;n<h.length;n++){l.push(this.shadowChain(h[n]));q.push(this[o](h[n]))}o=="applyChain"&&this.notifyDirty(q);return l},notifyDirty:function(h){forEach(h,method(this.editor,"addDirtyNode"));this.editor.scheduleHighlight()},notifyEnvironment:function(){this.onChange&&this.onChange();window.frameElement&&
window.frameElement.CodeMirror.updateNumbers&&window.frameElement.CodeMirror.updateNumbers()},linkChain:function(h){for(var o=0;o<h.length;o++){var l=h[o];if(l.from)l.from.historyAfter=l;else this.first=l;if(l.to)l.to.historyBefore=l;else this.last=l}},after:function(h){return h?h.historyAfter:this.first},before:function(h){return h?h.historyBefore:this.last},setTouched:function(h){if(h){if(!h.historyTouched){this.touched.push(h);h.historyTouched=true}}else this.firstTouched=true},addUndoLevel:function(h){this.history.push(h);
this.history.length>this.maxDepth&&this.history.shift()},touchedChains:function(){function h(e,b){if(e)e.historyTemp=b;else n=b}function o(e){for(var b=[],a=e?e.nextSibling:q.container.firstChild;a&&!isBR(a);a=a.nextSibling)a.currentText&&b.push(a.currentText);return{from:e,to:a,text:cleanText(b.join(""))}}function l(e,b){for(var a=b+"Sibling",c=e[a];c&&!isBR(c);)c=c[a];return c}var q=this,n=null,m=[];q.firstTouched&&q.touched.push(null);forEach(q.touched,function(e){if(!(e&&e.parentNode!=q.container)){if(e)e.historyTouched=
false;else q.firstTouched=false;var b=o(e),a=q.after(e);if(!a||a.text!=b.text||a.to!=b.to){m.push(b);h(e,b)}}});var f=[];q.touched=[];forEach(m,function(e){if(e.from?e.from.historyTemp:n){for(var b=[],a=e.from,c=true;;){var d=a?a.historyTemp:n;if(!d)if(c)break;else d=o(a);b.unshift(d);h(a,null);if(!a)break;c=q.after(a);a=l(a,"previous")}a=e.to;for(c=q.before(e.from);;){if(!a)break;d=a?a.historyTemp:n;if(!d)if(c)break;else d=o(a);b.push(d);h(a,null);c=q.before(a);a=l(a,"next")}f.push(b)}});return f},
shadowChain:function(h){var o=[],l=this.after(h[0].from);for(h=h[h.length-1].to;;){o.push(l);l=l.to;if(!l||l==h)break;else l=l.historyAfter||this.before(h)}return o},applyChain:function(h){var o=select.cursorPos(this.container,false),l=this,q=h[0].from,n=h[h.length-1].to;(function(c,d){for(var g=c?c.nextSibling:l.container.firstChild;g!=d;){var j=g.nextSibling;removeElement(g);g=j}})(q,n);for(var m=0;m<h.length;m++){var f=h[m];m>0&&l.container.insertBefore(f.from,n);var e=makePartSpan(fixSpaces(f.text));
l.container.insertBefore(e,n);if(o&&o.node==f.from){e=0;var b=this.after(f.from);if(b&&m==h.length-1){for(var a=0;a<o.offset&&f.text.charAt(a)==b.text.charAt(a);a++);if(o.offset>a)e=f.text.length-b.text.length}select.setCursorPos(this.container,{node:f.from,offset:Math.max(0,o.offset+e)})}else o&&m==h.length-1&&o.node&&o.node.parentNode!=this.container&&select.setCursorPos(this.container,{node:f.from,offset:f.text.length})}this.linkChain(h);return q}};
internetExplorer=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent);webkit=/AppleWebKit/.test(navigator.userAgent);safari=/Apple Computers, Inc/.test(navigator.vendor);gecko=/gecko\/(\d{8})/i.test(navigator.userAgent);var mac=/Mac/.test(navigator.platform);brokenOpera=window.opera&&/Version\/10.[56]/.test(navigator.userAgent);function makeWhiteSpace(h){for(var o=[],l=true;h>0;h--){o.push(l||h==1?nbsp:" ");l^=true}return o.join("")}
function fixSpaces(h){if(h.charAt(0)==" ")h=nbsp+h.slice(1);return h.replace(/\t/g,function(){return makeWhiteSpace(indentUnit)}).replace(/[ \u00a0]{2,}/g,function(o){return makeWhiteSpace(o.length)})}function cleanText(h){return h.replace(/\u00a0/g," ")}function makePartSpan(h){var o=h;if(h.nodeType==3)o=h.nodeValue;else h=document.createTextNode(o);var l=document.createElement("SPAN");l.isPart=true;l.appendChild(h);l.currentText=o;return l}
var webkitLastLineHack=webkit?function(h){var o=h.lastChild;if(!o||!o.hackBR){o=document.createElement("BR");o.hackBR=true;h.appendChild(o)}}:function(){};
Editor=function(){function h(b){var a=makeWhiteSpace(indentUnit);return map(b.replace(/\t/g,a).replace(/\u00a0/g," ").replace(/\r\n?/g,"\n").split("\n"),fixSpaces)}function o(b,a){function c(j,i){if(j.nodeType==3){if((j.nodeValue=fixSpaces(j.nodeValue.replace(/\r/g,"").replace(/\n/g," "))).length)g=false;d.push(j)}else if(isBR(j)&&j.childNodes.length==0){g=true;d.push(j)}else{for(var k=j.firstChild;k;k=k.nextSibling)c(k);if(!g&&e.hasOwnProperty(j.nodeName.toUpperCase())){g=true;if(!a||!i)d.push(document.createElement("BR"))}}}
var d=[],g=true;c(b,true);return d}function l(b){function a(j){var i=j.parentNode,k=j.nextSibling;return function(p){i.insertBefore(p,k)}}var c=[],d=null,g=true;return{next:function(){if(!b)throw StopIteration;var j=b;b=j.nextSibling;var i;if(j.isPart&&j.childNodes.length==1&&j.firstChild.nodeType==3){j.currentText=j.firstChild.nodeValue;i=!/[\n\t\r]/.test(j.currentText)}else i=false;if(i){c.push(j);g=false;return j.currentText}else if(isBR(j)){g&&window.opera&&j.parentNode.insertBefore(makePartSpan(""),
j);c.push(j);g=true;return"\n"}else{i=!j.nextSibling;d=a(j);removeElement(j);j=o(j,i);for(i=0;i<j.length;i++){var k=j,p=i,r=j[i],t="\n";if(r.nodeType==3){select.snapshotChanged();r=makePartSpan(r);t=r.currentText;g=false}else{g&&window.opera&&d(makePartSpan(""));g=true}r.dirty=true;c.push(r);d(r);k[p]=t}return j.join("")}},nodes:c}}function q(b){for(;b&&!isBR(b);)b=b.previousSibling;return b}function n(b,a){if(b){if(isBR(b))b=b.nextSibling}else b=a.firstChild;for(;b&&!isBR(b);)b=b.nextSibling;return b}
function m(b,a,c,d){function g(k){k=cleanText(b.history.textAfter(k));return d?k.toLowerCase():k}this.editor=b;this.history=b.history;this.history.commit();this.valid=!!a;this.atOccurrence=false;if(d==undefined)d=a==a.toLowerCase();var j={node:null,offset:0};if(c&&typeof c=="object"&&typeof c.character=="number"){b.checkLine(c.line);c={node:c.line,offset:c.character};this.pos={from:c,to:c}}else this.pos=c?{from:select.cursorPos(b.container,true)||j,to:select.cursorPos(b.container,false)||j}:{from:j,
to:j};var i=(this.caseFold?a.toLowerCase():a).split("\n");this.matches=i.length==1?function(k,p,r){var t=g(p),v=a.length,w;if(k?r>=v&&(w=t.lastIndexOf(a,r-v))!=-1:(w=t.indexOf(a,r))!=-1)return{from:{node:p,offset:w},to:{node:p,offset:w+v}}}:function(k,p,r){var t=k?i.length-1:0,v=i[t],w=g(p),x=k?w.indexOf(v)+v.length:w.lastIndexOf(v);if(!(k?x>=r||x!=v.length:x<=r||x!=w.length-v.length))for(r=p;;){if(k&&!r)break;r=k?this.history.nodeBefore(r):this.history.nodeAfter(r);if(!k&&!r)break;w=g(r);v=i[k?--t:
++t];if(t>0&&t<i.length-1)if(w!=v)break;else continue;t=k?w.lastIndexOf(v):w.indexOf(v)+v.length;if(k?t!=w.length-v.length:t!=v.length)break;return{from:{node:k?r:p,offset:k?t:x},to:{node:k?p:r,offset:k?x:t}}}}}function f(b){this.options=b;window.indentUnit=b.indentUnit;this.parent=parent;var a=this.container=document.body;this.history=new UndoHistory(a,b.undoDepth,b.undoDelay,this);var c=this;if(!f.Parser)throw"No parser loaded.";b.parserConfig&&f.Parser.configure&&f.Parser.configure(b.parserConfig);
b.readOnly||select.setCursorPos(a,{node:null,offset:0});this.dirty=[];this.importCode(b.content||"");this.history.onChange=b.onChange;if(b.readOnly){if(!b.textWrapping)a.style.whiteSpace="nowrap"}else{if(b.continuousScanning!==false){this.scanner=this.documentScanner(b.passTime);this.delayScanning()}var d=function(){if(document.body.contentEditable!=undefined&&internetExplorer)document.body.contentEditable="true";else document.designMode="on";if(internetExplorer&&b.height!="dynamic")document.body.style.minHeight=
frameElement.clientHeight-2*document.body.offsetTop-5+"px";document.documentElement.style.borderWidth="0";if(!b.textWrapping)a.style.whiteSpace="nowrap"};try{d()}catch(g){var j=addEventHandler(document,"focus",function(){j();d()},true)}addEventHandler(document,"keydown",method(this,"keyDown"));addEventHandler(document,"keypress",method(this,"keyPress"));addEventHandler(document,"keyup",method(this,"keyUp"));var i=function(){c.cursorActivity(false)};addEventHandler(document.body,"mouseup",i);addEventHandler(document.body,
"cut",i);gecko&&addEventHandler(window,"pagehide",function(){c.unloaded=true});addEventHandler(document.body,"paste",function(k){i();var p=null;try{var r=k.clipboardData||window.clipboardData;if(r)p=r.getData("Text")}catch(t){}if(p!==null){k.stop();c.replaceSelection(p);select.scrollToCursor(c.container)}});this.options.autoMatchParens&&addEventHandler(document.body,"click",method(this,"scheduleParenHighlight"))}}var e={P:true,DIV:true,LI:true};m.prototype={findNext:function(){return this.find(false)},
findPrevious:function(){return this.find(true)},find:function(b){function a(){var i={node:g,offset:j};c.pos={from:i,to:i};return c.atOccurrence=false}if(!this.valid)return false;var c=this,d=b?this.pos.from:this.pos.to,g=d.node,j=d.offset;if(g&&!g.parentNode){g=null;j=0}for(;;){if(this.pos=this.matches(b,g,j))return this.atOccurrence=true;if(b){if(!g)return a();g=this.history.nodeBefore(g);j=this.history.textAfter(g).length}else{d=this.history.nodeAfter(g);if(!d){j=this.history.textAfter(g).length;
return a()}g=d;j=0}}},select:function(){if(this.atOccurrence){select.setCursorPos(this.editor.container,this.pos.from,this.pos.to);select.scrollToCursor(this.editor.container)}},replace:function(b){if(this.atOccurrence){this.pos.to=this.editor.replaceRange(this.pos.from,this.pos.to,b);this.atOccurrence=false}},position:function(){if(this.atOccurrence)return{line:this.pos.from.node,character:this.pos.from.offset}}};f.prototype={importCode:function(b){this.history.push(null,null,h(b));this.history.reset()},
getCode:function(){if(!this.container.firstChild)return"";var b=[];select.markSelection();forEach(l(this.container.firstChild),method(b,"push"));webkitLastLineHack(this.container);select.selectMarked();webkit&&this.container.lastChild.hackBR&&b.pop();return cleanText(b.join(""))},checkLine:function(b){if(b===false||!(b==null||b.parentNode==this.container))throw parent.CodeMirror.InvalidLineHandle;},cursorPosition:function(b){if(b==null)b=true;return(b=select.cursorPos(this.container,b))?{line:b.node,
character:b.offset}:{line:null,character:0}},firstLine:function(){return null},lastLine:function(){return this.container.lastChild?q(this.container.lastChild):null},nextLine:function(b){this.checkLine(b);return n(b,this.container)||false},prevLine:function(b){this.checkLine(b);if(b==null)return false;return q(b.previousSibling)},visibleLineCount:function(){for(var b=this.container.firstChild;b&&isBR(b);)b=b.nextSibling;if(!b)return false;return Math.floor((window.innerHeight||document.documentElement.clientHeight||
document.body.clientHeight)/b.offsetHeight)},selectLines:function(b,a,c,d){this.checkLine(b);b={node:b,offset:a};a=null;if(d!==undefined){this.checkLine(c);a={node:c,offset:d}}select.setCursorPos(this.container,b,a);select.scrollToCursor(this.container)},lineContent:function(b){var a=[];for(b=b?b.nextSibling:this.container.firstChild;b&&!isBR(b);b=b.nextSibling)a.push(nodeText(b));return cleanText(a.join(""))},setLineContent:function(b,a){this.history.commit();this.replaceRange({node:b,offset:0},
{node:b,offset:this.history.textAfter(b).length},a);this.addDirtyNode(b);this.scheduleHighlight()},removeLine:function(b){for(var a=b?b.nextSibling:this.container.firstChild;a;){var c=a.nextSibling;removeElement(a);if(isBR(a))break;a=c}this.addDirtyNode(b);this.scheduleHighlight()},insertIntoLine:function(b,a,c){var d=null;if(a=="end")d=n(b,this.container);else for(var g=b?b.nextSibling:this.container.firstChild;g;g=g.nextSibling){if(a==0){d=g;break}var j=nodeText(g);if(j.length>a){d=g.nextSibling;
c=j.slice(0,a)+c+j.slice(a);removeElement(g);break}a-=j.length}a=h(c);for(c=0;c<a.length;c++){c>0&&this.container.insertBefore(document.createElement("BR"),d);this.container.insertBefore(makePartSpan(a[c]),d)}this.addDirtyNode(b);this.scheduleHighlight()},selectedText:function(){var b=this.history;b.commit();var a=select.cursorPos(this.container,true),c=select.cursorPos(this.container,false);if(!a||!c)return"";if(a.node==c.node)return b.textAfter(a.node).slice(a.offset,c.offset);var d=[b.textAfter(a.node).slice(a.offset)];
for(a=b.nodeAfter(a.node);a!=c.node;a=b.nodeAfter(a))d.push(b.textAfter(a));d.push(b.textAfter(c.node).slice(0,c.offset));return cleanText(d.join("\n"))},replaceSelection:function(b){this.history.commit();var a=select.cursorPos(this.container,true),c=select.cursorPos(this.container,false);if(a&&c){c=this.replaceRange(a,c,b);select.setCursorPos(this.container,c);webkitLastLineHack(this.container)}},cursorCoords:function(b){function a(i,k){var p=-(document.body.scrollTop||document.documentElement.scrollTop||
0),r=-(document.body.scrollLeft||document.documentElement.scrollLeft||0)+k;forEach([i,window.frameElement],function(t){for(;t;){r+=t.offsetLeft;p+=t.offsetTop;t=t.offsetParent}});return{x:r,y:p,yBot:p+i.offsetHeight}}function c(i,k){var p=document.createElement("SPAN");p.appendChild(document.createTextNode(i));try{return k(p)}finally{p.parentNode&&p.parentNode.removeChild(p)}}var d=select.cursorPos(this.container,b);if(!d)return null;b=d.offset;for(var g=d.node,j=this;b;){g=g?g.nextSibling:this.container.firstChild;
d=nodeText(g);if(b<d.length)return c(d.substr(0,b),function(i){i.style.position="absolute";i.style.visibility="hidden";i.className=g.className;j.container.appendChild(i);return a(g,i.offsetWidth)});b-=d.length}return g&&isSpan(g)?a(g,g.offsetWidth):g&&g.nextSibling&&isSpan(g.nextSibling)?a(g.nextSibling,0):c("\u200b",function(i){g?g.parentNode.insertBefore(i,g.nextSibling):j.container.insertBefore(i,j.container.firstChild);return a(i,0)})},reroutePasteEvent:function(){if(!(this.capturingPaste||window.opera)){this.capturingPaste=
true;var b=window.frameElement.CodeMirror.textareaHack;parent.focus();b.value="";b.focus();var a=this;this.parent.setTimeout(function(){a.capturingPaste=false;window.focus();a.selectionSnapshot&&window.select.setBookmark(a.container,a.selectionSnapshot);var c=b.value;if(c){a.replaceSelection(c);select.scrollToCursor(a.container)}},10)}},replaceRange:function(b,a,c){c=h(c);c[0]=this.history.textAfter(b.node).slice(0,b.offset)+c[0];var d=c[c.length-1];c[c.length-1]=d+this.history.textAfter(a.node).slice(a.offset);
a=this.history.nodeAfter(a.node);this.history.push(b.node,a,c);return{node:this.history.nodeBefore(a),offset:d.length}},getSearchCursor:function(b,a,c){return new m(this,b,a,c)},reindent:function(){this.container.firstChild&&this.indentRegion(null,this.container.lastChild)},reindentSelection:function(b){if(select.somethingSelected()){var a=select.selectionTopNode(this.container,true),c=select.selectionTopNode(this.container,false);a===false||c===false||this.indentRegion(a,c,b)}else this.indentAtCursor(b)},
grabKeys:function(b,a){this.frozen=b;this.keyFilter=a},ungrabKeys:function(){this.frozen="leave"},setParser:function(b,a){f.Parser=window[b];(a=a||this.options.parserConfig)&&f.Parser.configure&&f.Parser.configure(a);if(this.container.firstChild){forEach(this.container.childNodes,function(c){if(c.nodeType!=3)c.dirty=true});this.addDirtyNode(this.firstChild);this.scheduleHighlight()}},keyDown:function(b){if(this.frozen=="leave")this.keyFilter=this.frozen=null;if(this.frozen&&(!this.keyFilter||this.keyFilter(b.keyCode,
b))){b.stop();this.frozen(b)}else{var a=b.keyCode;this.delayScanning();this.options.autoMatchParens&&this.scheduleParenHighlight();if(a==13){if(b.ctrlKey&&!b.altKey)this.reparseBuffer();else{select.insertNewlineAtCursor();a=this.options.enterMode;if(a!="flat")this.indentAtCursor(a=="keep"?"keep":undefined);select.scrollToCursor(this.container)}b.stop()}else if(a==9&&this.options.tabMode!="default"&&!b.ctrlKey){this.handleTab(!b.shiftKey);b.stop()}else if(a==32&&b.shiftKey&&this.options.tabMode=="default"){this.handleTab(true);
b.stop()}else if(a==36&&!b.shiftKey&&!b.ctrlKey)this.home()&&b.stop();else if(a==35&&!b.shiftKey&&!b.ctrlKey)this.end()&&b.stop();else if(a==33&&!b.shiftKey&&!b.ctrlKey&&!gecko)this.pageUp()&&b.stop();else if(a==34&&!b.shiftKey&&!b.ctrlKey&&!gecko)this.pageDown()&&b.stop();else if((a==219||a==221)&&b.ctrlKey&&!b.altKey){this.highlightParens(b.shiftKey,true);b.stop()}else if(b.metaKey&&!b.shiftKey&&(a==37||a==39)){var c=select.selectionTopNode(this.container);if(!(c===false||!this.container.firstChild)){if(a==
37)select.focusAfterNode(q(c),this.container);else{a=n(c,this.container);select.focusAfterNode(a?a.previousSibling:this.container.lastChild,this.container)}b.stop()}}else if((b.ctrlKey||b.metaKey)&&!b.altKey)if(b.shiftKey&&a==90||a==89){select.scrollToNode(this.history.redo());b.stop()}else if(a==90||safari&&a==8){select.scrollToNode(this.history.undo());b.stop()}else if(a==83&&this.options.saveFunction){this.options.saveFunction();b.stop()}else a==86&&!mac&&this.reroutePasteEvent()}},keyPress:function(b){var a=
this.options.electricChars&&f.Parser.electricChars,c=this;if(this.frozen&&(!this.keyFilter||this.keyFilter(b.keyCode||b.code,b))||b.code==13||b.code==9&&this.options.tabMode!="default"||b.code==32&&b.shiftKey&&this.options.tabMode=="default")b.stop();else if(mac&&(b.ctrlKey||b.metaKey)&&b.character=="v")this.reroutePasteEvent();else if(a&&a.indexOf(b.character)!=-1)this.parent.setTimeout(function(){c.indentAtCursor(null)},0);else if(brokenOpera)if(b.code==8){var d=select.selectionTopNode(this.container);
c=this;var g=d?d.nextSibling:this.container.firstChild;d!==false&&g&&isBR(g)&&this.parent.setTimeout(function(){select.selectionTopNode(c.container)==g&&select.focusAfterNode(g.previousSibling,c.container)},20)}else if(b.code==46){d=select.selectionTopNode(this.container);c=this;d&&isBR(d)&&this.parent.setTimeout(function(){select.selectionTopNode(c.container)!=d&&select.focusAfterNode(d,c.container)},20)}},keyUp:function(b){this.cursorActivity(b.keyCode>=16&&b.keyCode<=18||b.keyCode>=33&&b.keyCode<=
40)},indentLineAfter:function(b,a){function c(r){r=r?r.nextSibling:d.container.firstChild;if(!r||!hasClass(r,"whitespace"))return null;return r}var d=this,g=c(b),j=0,i=g?g.currentText.length:0;if(a=="keep"){if(b){var k=c(q(b.previousSibling));if(k)j=k.currentText.length}}else{var p=g?g.nextSibling:b?b.nextSibling:this.container.firstChild;k=b&&p&&p.currentText?p.currentText:"";if(a!=null&&this.options.tabMode=="shift")j=a?i+indentUnit:Math.max(0,i-indentUnit);else if(b)j=b.indentation(k,i,a);else if(f.Parser.firstIndentation)j=
f.Parser.firstIndentation(k,i,a)}i=j-i;if(i<0)if(j==0){if(p)select.snapshotMove(g.firstChild,p.firstChild||p,0);removeElement(g);g=null}else{select.snapshotMove(g.firstChild,g.firstChild,i,true);g.currentText=makeWhiteSpace(j);g.firstChild.nodeValue=g.currentText}else if(i>0)if(g){g.currentText=makeWhiteSpace(j);g.firstChild.nodeValue=g.currentText;select.snapshotMove(g.firstChild,g.firstChild,i,true)}else{g=makePartSpan(makeWhiteSpace(j));g.className="whitespace";b?insertAfter(g,b):this.container.insertBefore(g,
this.container.firstChild);select.snapshotMove(p&&(p.firstChild||p),g.firstChild,j,false,true)}else g&&select.snapshotMove(g.firstChild,g.firstChild,j,false);i!=0&&this.addDirtyNode(b)},highlightAtCursor:function(){var b=select.selectionTopNode(this.container,true),a=select.selectionTopNode(this.container,false);if(b===false||a===false)return false;select.markSelection();if(this.highlight(b,n(a,this.container),true,20)===false)return false;select.selectMarked();return true},handleTab:function(b){this.options.tabMode==
"spaces"?select.insertTabAtCursor():this.reindentSelection(b)},home:function(){var b=select.selectionTopNode(this.container,true),a=b;if(b===false||!(!b||b.isPart||isBR(b))||!this.container.firstChild)return false;for(;b&&!isBR(b);)b=b.previousSibling;var c=b?b.nextSibling:this.container.firstChild;c&&c!=a&&c.isPart&&hasClass(c,"whitespace")?select.focusAfterNode(c,this.container):select.focusAfterNode(b,this.container);select.scrollToCursor(this.container);return true},end:function(){var b=select.selectionTopNode(this.container,
true);if(b===false)return false;b=n(b,this.container);if(!b)return false;select.focusAfterNode(b.previousSibling,this.container);select.scrollToCursor(this.container);return true},pageUp:function(){var b=this.cursorPosition().line,a=this.visibleLineCount();if(b===false||a===false)return false;a-=2;for(var c=0;c<a;c++){b=this.prevLine(b);if(b===false)break}if(c==0)return false;select.setCursorPos(this.container,{node:b,offset:0});select.scrollToCursor(this.container);return true},pageDown:function(){var b=
this.cursorPosition().line,a=this.visibleLineCount();if(b===false||a===false)return false;a-=2;for(var c=0;c<a;c++){var d=this.nextLine(b);if(d===false)break;b=d}if(c==0)return false;select.setCursorPos(this.container,{node:b,offset:0});select.scrollToCursor(this.container);return true},scheduleParenHighlight:function(){this.parenEvent&&this.parent.clearTimeout(this.parenEvent);var b=this;this.parenEvent=this.parent.setTimeout(function(){b.highlightParens()},300)},highlightParens:function(b,a){function c(w,
x){if(w)if(i.options.markParen)i.options.markParen(w,x);else{w.style.fontWeight="bold";w.style.color=x?"#8F8":"#F88"}}function d(w){if(w)if(i.options.unmarkParen)i.options.unmarkParen(w);else{w.style.fontWeight="";w.style.color=""}}function g(w){if(w.currentText)return(w=w.currentText.match(/^[\s\u00a0]*([\(\)\[\]{}])[\s\u00a0]*$/))&&w[1]}function j(){for(var w=[],x,z=true,u=p;u;u=t?u.nextSibling:u.previousSibling)if(u.className==r&&isSpan(u)&&(x=g(u))){if(/[\(\[\{]/.test(x)==t)w.push(x);else if(w.length){if(w.pop()!=
matching[x])z=false}else z=false;if(!w.length)break}else if(u.dirty||!isSpan(u)&&!isBR(u))return{node:u,status:"dirty"};return{node:u,status:u&&z}}var i=this;if(!a&&i.highlighted){d(i.highlighted[0]);d(i.highlighted[1])}if(window.parent&&window.select){this.parenEvent&&this.parent.clearTimeout(this.parenEvent);this.parenEvent=null;var k,p=select.selectionTopNode(this.container,true);if(p&&this.highlightAtCursor())if((p=select.selectionTopNode(this.container,true))&&((k=g(p))||(p=p.nextSibling)&&(k=
g(p))))for(var r=p.className,t=/[\(\[\{]/.test(k);;){var v=j();if(v.status=="dirty"){this.highlight(v.node,n(v.node));v.node.dirty=false}else{c(p,v.status);c(v.node,v.status);if(a)i.parent.setTimeout(function(){d(p);d(v.node)},500);else i.highlighted=[p,v.node];b&&v.node&&select.focusAfterNode(v.node.previousSibling,this.container);break}}}},indentAtCursor:function(b){if(this.container.firstChild)if(this.highlightAtCursor()){var a=select.selectionTopNode(this.container,false);if(a!==false){select.markSelection();
this.indentLineAfter(q(a),b);select.selectMarked()}}},indentRegion:function(b,a,c){var d=b=q(b),g=b&&q(b.previousSibling);isBR(a)||(a=n(a,this.container));this.addDirtyNode(b);do{var j=n(d,this.container);d&&this.highlight(g,j,true);this.indentLineAfter(d,c);g=d;d=j}while(d!=a);select.setCursorPos(this.container,{node:b,offset:0},{node:a,offset:0})},cursorActivity:function(b){if(this.unloaded){window.document.designMode="off";window.document.designMode="on";this.unloaded=false}if(internetExplorer){this.container.createTextRange().execCommand("unlink");
this.selectionSnapshot=select.getBookmark(this.container)}var a=this.options.cursorActivity;if(!b||a){var c=select.selectionTopNode(this.container,false);if(!(c===false||!this.container.firstChild)){c=c||this.container.firstChild;a&&a(c);if(!b){this.scheduleHighlight();this.addDirtyNode(c)}}}},reparseBuffer:function(){forEach(this.container.childNodes,function(b){b.dirty=true});this.container.firstChild&&this.addDirtyNode(this.container.firstChild)},addDirtyNode:function(b){if(b=b||this.container.firstChild){for(var a=
0;a<this.dirty.length;a++)if(this.dirty[a]==b)return;if(b.nodeType!=3)b.dirty=true;this.dirty.push(b)}},allClean:function(){return!this.dirty.length},scheduleHighlight:function(){var b=this;this.parent.clearTimeout(this.highlightTimeout);this.highlightTimeout=this.parent.setTimeout(function(){b.highlightDirty()},this.options.passDelay)},getDirtyNode:function(){for(;this.dirty.length>0;){var b=this.dirty.pop();try{for(;b&&b.parentNode!=this.container;)b=b.parentNode;if(b&&(b.dirty||b.nodeType==3))return b}catch(a){}}return null},
highlightDirty:function(b){if(!window.parent||!window.select)return false;this.options.readOnly||select.markSelection();for(var a,c=b?null:(new Date).getTime()+this.options.passTime;((new Date).getTime()<c||b)&&(a=this.getDirtyNode());){var d=this.highlight(a,c);d&&d.node&&d.dirty&&this.addDirtyNode(d.node.nextSibling)}this.options.readOnly||select.selectMarked();a&&this.scheduleHighlight();return this.dirty.length==0},documentScanner:function(b){var a=this,c=null;return function(){if(window.parent&&
window.select){if(c&&c.parentNode!=a.container)c=null;select.markSelection();var d=a.highlight(c,(new Date).getTime()+b,true);select.selectMarked();d=d?d.node&&d.node.nextSibling:null;c=c==d?null:d;a.delayScanning()}}},delayScanning:function(){if(this.scanner){this.parent.clearTimeout(this.documentScan);this.documentScan=this.parent.setTimeout(this.scanner,this.options.continuousScanning)}},highlight:function(b,a,c,d){function g(u){if(u){var y=u.oldNextSibling;if(w||y===undefined||u.nextSibling!=
y)i.history.touch(u);u.oldNextSibling=u.nextSibling}else{y=i.container.oldFirstChild;if(w||y===undefined||i.container.firstChild!=y)i.history.touch(null);i.container.oldFirstChild=i.container.firstChild}}var j=this.container,i=this,k=this.options.activeTokens,p=typeof a=="number"?a:null;if(!j.firstChild)return false;for(;b&&(!b.parserFromHere||b.dirty);){if(d!=null&&isBR(b)&&--d<0)return false;b=b.previousSibling}if(b&&!b.nextSibling)return false;var r=l(b?b.nextSibling:j.firstChild);d=stringStream(r);
var t=b?b.parserFromHere(d):f.Parser.make(d),v={current:null,get:function(){if(!this.current)this.current=r.nodes.shift();return this.current},next:function(){this.current=null},remove:function(){j.removeChild(this.get());this.current=null},getNonEmpty:function(){for(var u=this.get();u&&isSpan(u)&&u.currentText=="";)if(window.opera&&(u.previousSibling==null||isBR(u.previousSibling))&&(u.nextSibling==null||isBR(u.nextSibling))){this.next();u=this.get()}else{var y=u;this.remove();u=this.get();select.snapshotMove(y.firstChild,
u&&(u.firstChild||u),0)}return u}},w=false,x=true,z=0;forEach(t,function(u){var y=v.getNonEmpty();if(u.value=="\n"){if(!isBR(y))throw"Parser out of sync. Expected BR.";if(y.dirty||!y.indentation)w=true;g(b);b=y;y.parserFromHere=t.copy();y.indentation=u.indentation;y.dirty=false;if(p==null&&y==a)throw StopIteration;if(p!=null&&(new Date).getTime()>=p||!w&&!x&&z>1&&!c)throw StopIteration;x=w;w=false;z=0;v.next()}else{if(!isSpan(y))throw"Parser out of sync. Expected SPAN.";if(y.dirty)w=true;z++;if(!y.reduced&&
y.currentText==u.value&&y.className==u.style){y.dirty=false;v.next()}else{w=true;var H=makePartSpan(u.value);H.className=u.style;j.insertBefore(H,y);k&&k(H,u,i);u=u.value.length;for(var E=0;u>0;){y=v.get();var C=y.currentText.length;select.snapshotReplaceNode(y.firstChild,H.firstChild,u,E);if(C>u){y.currentText=y.currentText.substring(u);y.reduced=true;u=0}else{u-=C;E+=C;v.remove()}}}}});g(b);webkitLastLineHack(this.container);return{node:v.getNonEmpty(),dirty:w}}};return f}();
addEventHandler(window,"load",function(){var h=window.frameElement.CodeMirror;h.editor=new Editor(h.options);this.parent.setTimeout(method(h,"init"),0)});
function tokenizer(h,o){function l(n){return n!="\n"&&/^[\s\u00a0]*$/.test(n)}var q={state:o,take:function(n){if(typeof n=="string")n={style:n,type:n};n.content=(n.content||"")+h.get();/\n$/.test(n.content)||h.nextWhile(l);n.value=n.content+h.get();return n},next:function(){if(!h.more())throw StopIteration;var n;if(h.equals("\n")){h.next();return this.take("whitespace")}if(h.applies(l))n="whitespace";else for(;!n;)n=this.state(h,function(m){q.state=m});return this.take(n)}};return q}
tokenizeJavaScript=function(){function h(e,b){for(var a=false;!e.endOfLine();){var c=e.next();if(c==b&&!a)return false;a=!a&&c=="\\"}return a}function o(e,b){return function(a,c){var d=e,g=l(e,b,a,function(i){d=i}),j=g.type=="operator"||g.type=="keyword c"||g.type.match(/^[\[{}\(,;:]$/);if(j!=b||d!=e)c(o(d,j));return g}}function l(e,b,a,c){function d(){a.nextWhileMatches(f);var p=a.get(),r=q.hasOwnProperty(p)&&q.propertyIsEnumerable(p)&&q[p];return r?{type:r.type,style:r.style,content:p}:{type:"variable",
style:"js-variable",content:p}}function g(p){var r="/*";for(p=p=="*";;){if(a.endOfLine())break;var t=a.next();if(t=="/"&&p){r=null;break}p=t=="*"}c(r);return{type:"comment",style:"js-comment"}}function j(){a.nextWhileMatches(n);return{type:"operator",style:"js-operator"}}function i(p){var r=h(a,p);c(r?p:null);return{type:"string",style:"js-string"}}if(e=='"'||e=="'")return i(e);var k=a.next();if(e=="/*")return g(k);else if(k=='"'||k=="'")return i(k);else if(/[\[\]{}\(\),;\:\.]/.test(k))return{type:k,
style:"js-punctuation"};else if(k=="0"&&(a.equals("x")||a.equals("X"))){a.next();a.nextWhileMatches(m);return{type:"number",style:"js-atom"}}else if(/[0-9]/.test(k)){a.nextWhileMatches(/[0-9]/);if(a.equals(".")){a.next();a.nextWhileMatches(/[0-9]/)}if(a.equals("e")||a.equals("E")){a.next();a.equals("-")&&a.next();a.nextWhileMatches(/[0-9]/)}return{type:"number",style:"js-atom"}}else if(k=="/")if(a.equals("*")){a.next();return g(k)}else if(a.equals("/")){h(a,null);return{type:"comment",style:"js-comment"}}else{if(b){h(a,
"/");a.nextWhileMatches(/[gi]/);e={type:"regexp",style:"js-string"}}else e=j();return e}else return n.test(k)?j():d()}var q=function(){function e(j,i){return{type:j,style:"js-"+i}}var b=e("keyword a","keyword"),a=e("keyword b","keyword"),c=e("keyword c","keyword"),d=e("operator","keyword"),g=e("atom","atom");return{"if":b,"while":b,"with":b,"else":a,"do":a,"try":a,"finally":a,"return":c,"break":c,"continue":c,"new":c,"delete":c,"throw":c,"in":d,"typeof":d,"instanceof":d,"var":e("var","keyword"),"function":e("function",
"keyword"),"catch":e("catch","keyword"),"for":e("for","keyword"),"switch":e("switch","keyword"),"case":e("case","keyword"),"default":e("default","keyword"),"true":g,"false":g,"null":g,undefined:g,NaN:g,Infinity:g}}(),n=/[+\-*&%=<>!?|]/,m=/[0-9A-Fa-f]/,f=/[\w\$_]/;return function(e,b){return tokenizer(e,b||o(false,true))}}();
JSParser=Editor.Parser=function(){function h(n,m,f,e,b,a){this.indented=n;this.column=m;this.type=f;if(e!=null)this.align=e;this.prev=b;this.info=a}function o(n){return function(m){var f=m&&m.charAt(0),e=n.type,b=f==e;return e=="vardef"?n.indented+4:e=="form"&&f=="{"?n.indented:e=="stat"||e=="form"?n.indented+indentUnit:n.info=="switch"&&!b?n.indented+(/^(?:case|default)\b/.test(m)?indentUnit:2*indentUnit):n.align?n.column-(b?1:0):n.indented+(b?0:indentUnit)}}var l={atom:true,number:true,variable:true,
string:true,regexp:true},q=false;return{make:function(n,m){function f(s){for(var A=s.length-1;A>=0;A--)K.push(s[A])}function e(){f(arguments);S=true}function b(){f(arguments);S=false}function a(){F={prev:F,vars:{"this":true,arguments:true}}}function c(){F=F.prev}function d(s){if(F){O="js-variabledef";F.vars[s]=true}}function g(s,A){var N=function(){J=new h(R,Q,s,null,J,A)};N.lex=true;return N}function j(){if(J.type==")")R=J.indented;J=J.prev}function i(s){return function(A){if(A==s)e();else s==";"?
b():e(arguments.callee)}}function k(){return b(r,k)}function p(){return b(t,p)}function r(s){if(s=="var")e(g("vardef"),H,i(";"),j);else if(s=="keyword a")e(g("form"),t,r,j);else if(s=="keyword b")e(g("form"),r,j);else if(s=="{")e(g("}"),y,j);else if(s==";")e();else if(s=="function")e(D);else if(s=="for")e(g("form"),i("("),g(")"),C,i(")"),j,r,j);else if(s=="variable")e(g("stat"),w);else if(s=="switch")e(g("form"),t,g("}","switch"),i("{"),y,j,j);else if(s=="case")e(t,i(":"));else if(s=="default")e(i(":"));
else s=="catch"?e(g("form"),a,i("("),G,i(")"),r,j,c):b(g("stat"),t,i(";"),j)}function t(s){if(l.hasOwnProperty(s))e(v);else if(s=="function")e(D);else if(s=="keyword c")e(t);else if(s=="(")e(g(")"),t,i(")"),j,v);else if(s=="operator")e(t);else if(s=="[")e(g("]"),u(t,"]"),j,v);else s=="{"?e(g("}"),u(z,"}"),j,v):e()}function v(s,A){if(s=="operator"&&/\+\+|--/.test(A))e(v);else if(s=="operator")e(t);else if(s==";")b();else if(s=="(")e(g(")"),u(t,")"),j,v);else if(s==".")e(x,v);else s=="["&&e(g("]"),
t,i("]"),j,v)}function w(s){s==":"?e(j,r):b(v,i(";"),j)}function x(s){if(s=="variable"){O="js-property";e()}}function z(s){if(s=="variable")O="js-property";l.hasOwnProperty(s)&&e(i(":"),t)}function u(s,A){function N(P){if(P==",")e(s,N);else P==A?e():e(i(A))}return function(P){P==A?e():b(s,N)}}function y(s){s=="}"?e():b(r,y)}function H(s,A){if(s=="variable"){d(A);e(E)}else e()}function E(s,A){if(A=="=")e(t,E);else s==","&&e(H)}function C(s){if(s=="var")e(H,L);else if(s==";")b(L);else s=="variable"?
e(M):b(L)}function M(s,A){A=="in"?e(t):e(v,L)}function L(s,A){if(s==";")e(B);else A=="in"?e(t):e(t,i(";"),B)}function B(s){s==")"?b():e(t)}function D(s,A){if(s=="variable"){d(A);e(D)}else s=="("&&e(a,u(G,")"),r,c)}function G(s,A){if(s=="variable"){d(A);e()}}var I=tokenizeJavaScript(n),K=[q?p:k],F=null,J=new h((m||0)-indentUnit,0,"block",false),Q=0,R=0,S,O,T={next:function(){for(;K[K.length-1].lex;)K.pop()();var s=I.next();if(s.type=="whitespace"&&Q==0)R=s.value.length;Q+=s.value.length;if(s.content==
"\n"){R=Q=0;if(!("align"in J))J.align=false;s.indentation=o(J)}if(s.type=="whitespace"||s.type=="comment")return s;if(!("align"in J))J.align=true;for(;;){S=O=false;K.pop()(s.type,s.content);if(S){if(O)s.style=O;else{var A;if(A=s.type=="variable")a:{for(A=F;A;){if(A.vars[s.content]){A=true;break a}A=A.prev}A=false}if(A)s.style="js-localvariable"}return s}}},copy:function(){var s=F,A=J,N=K.concat([]),P=I.state;return function(U){F=s;J=A;K=N.concat([]);Q=R=0;I=tokenizeJavaScript(U,P);return T}}};j.lex=
true;return T},electricChars:"{}:",configure:function(n){if(n.json!=null)q=n.json}}}();
XMLParser=Editor.Parser=function(){var h={autoSelfClosers:{br:true,img:true,hr:true,link:true,input:true,meta:true,col:true,frame:true,base:true,area:true},doNotIndent:{pre:true,"!cdata":true}},o={autoSelfClosers:{},doNotIndent:{"!cdata":true}},l=h,q=false,n=function(){function m(a,c){var d=a.next();if(d=="<")if(a.equals("!")){a.next();if(a.equals("["))if(a.lookAhead("[CDATA[",true)){c(b("xml-cdata","]]\>"));return null}else return"xml-text";else if(a.lookAhead("--",true)){c(b("xml-comment","--\>"));
return null}else return"xml-text"}else if(a.equals("?")){a.next();a.nextWhileMatches(/[\w\._\-]/);c(b("xml-processing","?>"));return"xml-processing"}else{a.equals("/")&&a.next();c(f);return"xml-punctuation"}else if(d=="&"){for(;!a.endOfLine();)if(a.next()==";")break;return"xml-entity"}else{a.nextWhileMatches(/[^&<\n]/);return"xml-text"}}function f(a,c){var d=a.next();if(d==">"){c(m);return"xml-punctuation"}else if(/[?\/]/.test(d)&&a.equals(">")){a.next();c(m);return"xml-punctuation"}else if(d=="=")return"xml-punctuation";
else if(/[\'\"]/.test(d)){c(e(d));return null}else{a.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}}function e(a){return function(c,d){for(;!c.endOfLine();)if(c.next()==a){d(f);break}return"xml-attribute"}}function b(a,c){return function(d,g){for(;!d.endOfLine();){if(d.lookAhead(c,true)){g(m);break}d.next()}return a}}return function(a,c){return tokenizer(a,c||m)}}();return{make:function(m){function f(B){for(var D=B.length-1;D>=0;D--)u.push(B[D])}function e(){f(arguments);M=true}function b(){f(arguments);
M=false}function a(){z.style+=" xml-error"}function c(B){return function(D,G){if(G==B)e();else{a();e(arguments.callee)}}}function d(B,D){var G=l.doNotIndent.hasOwnProperty(B)||C&&C.noIndent;C={prev:C,name:B,indent:H,startOfLine:D,noIndent:G}}function g(B){return function(D,G){var I=B;if(I&&I.noIndent)return G;if(q&&/<!\[CDATA\[/.test(D))return 0;if(I&&/^<\//.test(D))I=I.prev;for(;I&&!I.startOfLine;)I=I.prev;return I?I.indent+indentUnit:0}}function j(){return b(i,j)}function i(B,D){if(D=="<")e(k,t,
r(y==1));else if(D=="</")e(p,c(">"));else{if(B=="xml-cdata"){if(!C||C.name!="!cdata")d("!cdata");if(/\]\]>$/.test(D))C=C.prev}else L.hasOwnProperty(B)||a();e()}}function k(B,D){if(B=="xml-name"){E=D.toLowerCase();z.style="xml-tagname";e()}else{E=null;b()}}function p(B,D){if(B=="xml-name"){z.style="xml-tagname";if(C&&D.toLowerCase()==C.name)C=C.prev;else a()}e()}function r(B){return function(D,G){if(G=="/>"||G==">"&&l.autoSelfClosers.hasOwnProperty(E))e();else if(G==">"){d(E,B);e()}else{a();e(arguments.callee)}}}
function t(B){if(B=="xml-name"){z.style="xml-attname";e(v,t)}else b()}function v(B,D){if(D=="=")e(w);else D==">"||D=="/>"?b(r):b()}function w(B){B=="xml-attribute"?e(w):b()}var x=n(m),z,u=[j],y=0,H=0,E=null,C=null,M,L={"xml-text":true,"xml-entity":true,"xml-comment":true,"xml-processing":true};return{indentation:function(){return H},next:function(){z=x.next();if(z.style=="whitespace"&&y==0)H=z.value.length;else y++;if(z.content=="\n"){H=y=0;z.indentation=g(C)}if(z.style=="whitespace"||z.type=="xml-comment")return z;
for(;;){M=false;u.pop()(z.style,z.content);if(M)return z}},copy:function(){var B=u.concat([]),D=x.state,G=C,I=this;return function(K){u=B.concat([]);y=H=0;C=G;x=n(K,D);return I}}}},electricChars:"/",configure:function(m){if(m.useHTMLKludges!=null)l=m.useHTMLKludges?h:o;if(m.alignCDATA)q=m.alignCDATA}}}();
CSSParser=Editor.Parser=function(){function h(l,q,n){return function(m){return!l||/^\}/.test(m)?n:q?n+indentUnit*2:n+indentUnit}}var o=function(){function l(f,e){var b=f.next();if(b=="@"){f.nextWhileMatches(/\w/);return"css-at"}else if(b=="/"&&f.equals("*")){e(q);return null}else if(b=="<"&&f.equals("!")){e(n);return null}else if(b=="=")return"css-compare";else if(f.equals("=")&&(b=="~"||b=="|")){f.next();return"css-compare"}else if(b=='"'||b=="'"){e(m(b));return null}else if(b=="#"){f.nextWhileMatches(/\w/);
return"css-hash"}else if(b=="!"){f.nextWhileMatches(/[ \t]/);f.nextWhileMatches(/\w/);return"css-important"}else if(/\d/.test(b)){f.nextWhileMatches(/[\w.%]/);return"css-unit"}else if(/[,.+>*\/]/.test(b))return"css-select-op";else if(/[;{}:\[\]]/.test(b))return"css-punctuation";else{f.nextWhileMatches(/[\w\\\-_]/);return"css-identifier"}}function q(f,e){for(var b=false;!f.endOfLine();){var a=f.next();if(b&&a=="/"){e(l);break}b=a=="*"}return"css-comment"}function n(f,e){for(var b=0;!f.endOfLine();){var a=
f.next();if(b>=2&&a==">"){e(l);break}b=a=="-"?b+1:0}return"css-comment"}function m(f){return function(e,b){for(var a=false;!e.endOfLine();){var c=e.next();if(c==f&&!a)break;a=!a&&c=="\\"}a||b(l);return"css-string"}}return function(f,e){return tokenizer(f,e||l)}}();return{make:function(l,q){q=q||0;var n=o(l),m=false,f=false,e=false,b={next:function(){var a=n.next(),c=a.style,d=a.content;if(c=="css-hash")c=a.style=f?"css-colorcode":"css-identifier";if(c=="css-identifier")if(f)a.style="css-value";else if(!m&&
!e)a.style="css-selector";if(d=="\n")a.indentation=h(m,f,q);if(d=="{")m=true;else if(d=="}")m=f=e=false;else if(d==";")f=e=false;else if(m&&c!="css-comment"&&c!="whitespace")f=true;else if(!m&&c=="css-at"&&d!="@media")e=true;return a},copy:function(){var a=m,c=f,d=n.state;return function(g){n=o(g,d);m=a;f=c;return b}}};return b},electricChars:"}"}}();
SparqlParser=Editor.Parser=function(){function h(m){return function(f){f=f&&f.charAt(0);if(/[\]\}]/.test(f))for(;m&&m.type=="pattern";)m=m.prev;f=m&&f==matching[m.type];return m?m.type=="pattern"?m.col:m.align?m.col-(f?m.width:0):m.indent+(f?0:indentUnit):0}}var o=/^(?:str|lang|langmatches|datatype|bound|sameterm|isiri|isuri|isblank|isliteral|union|a)$/i,l=RegExp("^(?:base|prefix|select|distinct|reduced|construct|describe|ask|from|named|where|order|limit|offset|filter|optional|graph|by|asc|desc)$",
"i"),q=/[*+\-<>=&|]/,n=function(){function m(e,b){var a=e.next();if(a=="$"||a=="?"){e.nextWhileMatches(/[\w\d]/);return"sp-var"}else if(a=="<"&&!e.matches(/[\s\u00a0=]/)){e.nextWhileMatches(/[^\s\u00a0>]/);e.equals(">")&&e.next();return"sp-uri"}else if(a=='"'||a=="'"){b(f(a));return null}else if(/[{}\(\),\.;\[\]]/.test(a))return"sp-punc";else if(a=="#"){for(;!e.endOfLine();)e.next();return"sp-comment"}else if(q.test(a)){e.nextWhileMatches(q);return"sp-operator"}else if(a==":"){e.nextWhileMatches(/[\w\d\._\-]/);
return"sp-prefixed"}else{e.nextWhileMatches(/[_\w\d]/);if(e.equals(":")){e.next();e.nextWhileMatches(/[\w\d_\-]/);return"sp-prefixed"}a=e.get();return{style:o.test(a)?"sp-operator":l.test(a)?"sp-keyword":"sp-word",content:a}}}function f(e){return function(b,a){for(var c=false;!b.endOfLine();){var d=b.next();if(d==e&&!c){a(m);break}c=!c&&d=="\\"}return"sp-literal"}}return function(e,b){return tokenizer(e,b||m)}}();return{make:function(m){function f(g,j){b={prev:b,indent:a,col:c,type:g,width:j}}var e=
n(m),b=null,a=0,c=0,d={next:function(){var g=e.next(),j=g.style,i=g.content,k=g.value.length;if(i=="\n"){g.indentation=h(b);a=c=0;if(b&&b.align==null)b.align=false}else if(j=="whitespace"&&c==0)a=k;else if(j!="sp-comment"&&b&&b.align==null)b.align=true;if(i!="\n")c+=k;if(/[\[\{\(]/.test(i))f(i,k);else if(/[\]\}\)]/.test(i)){for(;b&&b.type=="pattern";)b=b.prev;if(b&&i==matching[b.type])b=b.prev}else if(i=="."&&b&&b.type=="pattern")b=b.prev;else if((j=="sp-word"||j=="sp-prefixed"||j=="sp-uri"||j=="sp-var"||
j=="sp-literal")&&b&&/[\{\[]/.test(b.type))f("pattern",k);return g},copy:function(){var g=b,j=a,i=c,k=e.state;return function(p){e=n(p,k);b=g;a=j;c=i;return d}}};return d},electricChars:"}]"}}();
HTMLMixedParser=Editor.Parser=function(){if(!(CSSParser&&JSParser&&XMLParser))throw Error("CSS, JS, and XML parsers must be loaded for HTML mixed mode to work.");XMLParser.configure({useHTMLKludges:true});return{make:function(h){function o(){var e=q.next();if(e.content=="<")m=true;else if(e.style=="xml-tagname"&&m===true)m=e.content.toLowerCase();else if(e.content==">"){if(m=="script")f.next=l(JSParser,"<\/script");else if(m=="style")f.next=l(CSSParser,"</style");m=false}return e}function l(e,b){var a=
q.indentation();n=e.make(h,a+indentUnit);return function(){if(h.lookAhead(b,false,false,true)){n=null;f.next=o;return o()}var c=n.next(),d=c.value.lastIndexOf("<"),g=Math.min(c.value.length-d,b.length);if(d!=-1&&c.value.slice(d,d+g).toLowerCase()==b.slice(0,g)&&h.lookAhead(b.slice(g),false,false,true)){h.push(c.value.slice(d));c.value=c.value.slice(0,d)}if(c.indentation){var j=c.indentation;c.indentation=function(i){return i=="</"?a:j(i)}}return c}}var q=XMLParser.make(h),n=null,m=false,f={next:o,
copy:function(){var e=q.copy(),b=n&&n.copy(),a=f.next,c=m;return function(d){h=d;q=e(d);n=b&&b(d);f.next=a;m=c;return f}}};return f},electricChars:"{}/:"}}();
DummyParser=Editor.Parser=function(){function h(o){for(;!o.endOfLine();)o.next();return"text"}return{make:function(o){function l(m){return function(){return m}}o=tokenizer(o,h);var q=0,n={next:function(){var m=o.next();if(m.type=="whitespace")if(m.value=="\n")m.indentation=l(q);else q=m.value.length;return m},copy:function(){var m=q;return function(f){q=m;o=tokenizer(f,h);return n}}};return n}}}();
