engine/app/assets/javascripts/locomotive/plugins/codemirror/codemirror_base.min.js

118 lines
61 KiB
JavaScript

function method(g,p){return function(){g[p].apply(g,arguments)}}var StopIteration={toString:function(){return"StopIteration"}};function forEach(g,p){if(g.next)try{for(;;)p(g.next())}catch(k){if(k!=StopIteration)throw k;}else for(var m=0;m<g.length;m++)p(g[m])}function map(g,p){var k=[];forEach(g,function(m){k.push(p(m))});return k}function matcher(g){return function(p){return g.test(p)}}function hasClass(g,p){var k=g.className;return k&&RegExp("(^| )"+p+"($| )").test(k)}
function removeClass(g,p){g.className=g.className.replace(RegExp(" "+p+"\\b","g"),"");return g}function insertAfter(g,p){p.parentNode.insertBefore(g,p.nextSibling);return g}function removeElement(g){g.parentNode&&g.parentNode.removeChild(g)}function clearElement(g){for(;g.firstChild;)g.removeChild(g.firstChild)}function isAncestor(g,p){for(;p=p.parentNode;)if(g==p)return true;return false}var nbsp="\u00a0",matching={"{":"}","[":"]","(":")","}":"{","]":"[",")":"("};
function normalizeEvent(g){if(!g.stopPropagation){g.stopPropagation=function(){this.cancelBubble=true};g.preventDefault=function(){this.returnValue=false}}if(!g.stop)g.stop=function(){this.stopPropagation();this.preventDefault()};if(g.type=="keypress"){g.code=g.charCode==null?g.keyCode:g.charCode;g.character=String.fromCharCode(g.code)}return g}
function addEventHandler(g,p,k,m){function s(n){k(normalizeEvent(n||window.event))}if(typeof g.addEventListener=="function"){g.addEventListener(p,s,false);if(m)return function(){g.removeEventListener(p,s,false)}}else{g.attachEvent("on"+p,s);if(m)return function(){g.detachEvent("on"+p,s)}}}function nodeText(g){return g.textContent||g.innerText||g.nodeValue||""}function nodeTop(g){for(var p=0;g.offsetParent;){p+=g.offsetTop;g=g.offsetParent}return p}
function isBR(g){g=g.nodeName;return g=="BR"||g=="br"}function isSpan(g){g=g.nodeName;return g=="SPAN"||g=="span"};var stringStream=function(g){function p(){for(;m==k.length;){s+=k;k="";m=0;try{k=g.next()}catch(n){if(n!=StopIteration)throw n;else return false}}return true}var k="",m=0,s="";return{peek:function(){if(!p())return null;return k.charAt(m)},next:function(){if(!p())if(s.length>0)throw"End of stringstream reached without emptying buffer ('"+s+"').";else throw StopIteration;return k.charAt(m++)},get:function(){var n=s;s="";if(m>0){n+=k.slice(0,m);k=k.slice(m);m=0}return n},push:function(n){k=k.slice(0,
m)+n+k.slice(m)},lookAhead:function(n,t,a,d){function c(j){return d?j.toLowerCase():j}n=c(n);var b=false,e=s,f=m;for(a&&this.nextWhileMatches(/[\s\u00a0]/);;){a=m+n.length;var h=k.length-m;if(a<=k.length){b=n==c(k.slice(m,a));m=a;break}else if(n.slice(0,h)==c(k.slice(m))){s+=k;k="";try{k=g.next()}catch(i){if(i!=StopIteration)throw i;break}m=0;n=n.slice(h)}else break}if(!(b&&t)){k=s.slice(e.length)+k;m=f;s=e}return b},lookAheadRegex:function(n,t){if(n.source.charAt(0)!="^")throw Error("Regexps passed to lookAheadRegex must start with ^");
for(;k.indexOf("\n",m)==-1;)try{k+=g.next()}catch(a){if(a!=StopIteration)throw a;break}var d=k.slice(m).match(n);if(d&&t)m+=d[0].length;return d},more:function(){return this.peek()!==null},applies:function(n){var t=this.peek();return t!==null&&n(t)},nextWhile:function(n){for(var t;(t=this.peek())!==null&&n(t);)this.next()},matches:function(n){var t=this.peek();return t!==null&&n.test(t)},nextWhileMatches:function(n){for(var t;(t=this.peek())!==null&&n.test(t);)this.next()},equals:function(n){return n===
this.peek()},endOfLine:function(){var n=this.peek();return n==null||n=="\n"}}};var select={};
(function(){function g(b,e){for(;b&&b.parentNode!=e;)b=b.parentNode;return b}function p(b,e){for(;!b.previousSibling&&b.parentNode!=e;)b=b.parentNode;return g(b.previousSibling,e)}function k(b){var e=b.nextSibling;if(e){for(;e.firstChild;)e=e.firstChild;return e.nodeType==3||isBR(e)?e:k(e)}else{for(b=b.parentNode;b&&!b.nextSibling;)b=b.parentNode;return b&&k(b)}}select.ie_selection=document.selection&&document.selection.createRangeCollection;select.scrollToNode=function(b,e){if(b){for(var f=b,h=document.body,
i=document.documentElement,j=!f.nextSibling||!f.nextSibling.nextSibling||!f.nextSibling.nextSibling.nextSibling,q=0;f&&!f.offsetTop;){q++;f=f.previousSibling}if(q==0)j=false;if(!(webkit&&f&&f.offsetTop==5&&f.offsetLeft==5)){q=q*(f?f.offsetHeight:0);var l=0,r=b?b.offsetWidth:0;for(f=f;f&&f.offsetParent;){q+=f.offsetTop;isBR(f)||(l+=f.offsetLeft);f=f.offsetParent}f=h.scrollLeft||i.scrollLeft||0;h=h.scrollTop||i.scrollTop||0;var o=false,w=window.innerWidth||i.clientWidth||0;if(e||r<w){if(e){var A=select.offsetInNode(b),
v=nodeText(b).length;if(v)l+=r*(A/v)}r=l-f;if(r<0||r>w){f=l;o=true}}l=q-h;if(l<0||j||l>(window.innerHeight||i.clientHeight||0)-50){h=j?1E6:q;o=true}o&&window.scrollTo(f,h)}}};select.scrollToCursor=function(b){select.scrollToNode(select.selectionTopNode(b,true)||b.firstChild,true)};var m=null;select.snapshotChanged=function(){if(m)m.changed=true};select.snapshotReplaceNode=function(b,e,f,h){function i(j){if(b==j.node){m.changed=true;if(f&&j.offset>f)j.offset-=f;else{j.node=e;j.offset+=h||0}}else if(select.ie_selection&&
j.offset==0&&j.node==k(b))m.changed=true}if(m){i(m.start);i(m.end)}};select.snapshotMove=function(b,e,f,h,i){function j(q){if(b==q.node&&(!i||q.offset==0)){m.changed=true;q.node=e;q.offset=h?Math.max(0,q.offset+f):f}}if(m){j(m.start);j(m.end)}};if(select.ie_selection){var s=function(){var b=document.selection;return b&&(b.createRange||b.createTextRange)()},n=function(b){function e(r){for(var o=null;!o&&r;){o=r.nextSibling;r=r.parentNode}return f(o)}function f(r){for(;r&&r.firstChild;)r=r.firstChild;
return{node:r,offset:0}}var h=s();h.collapse(b);b=h.parentElement();if(!isAncestor(document.body,b))return null;if(!b.firstChild)return f(b);var i=h.duplicate();i.moveToElementText(b);i.collapse(true);for(var j=b.firstChild;j;j=j.nextSibling){if(j.nodeType==3){var q=j.nodeValue.length;i.move("character",q)}else{i.moveToElementText(j);i.collapse(false)}var l=h.compareEndPoints("StartToStart",i);if(l==0)return e(j);if(l!=1){if(j.nodeType!=3)return f(j);i.setEndPoint("StartToEnd",h);return{node:j,offset:q-
i.text.length}}}return e(b)};select.markSelection=function(){m=null;if(document.selection){var b=n(true),e=n(false);if(b&&e)m={start:b,end:e,changed:false}}};select.selectMarked=function(){function b(h){var i=document.body.createTextRange(),j=h.node;if(j)if(j.nodeType==3){i.moveToElementText(j.parentNode);for(h=h.offset;j.previousSibling;){j=j.previousSibling;h+=(j.innerText||"").length}i.move("character",h)}else{i.moveToElementText(j);i.collapse(true)}else{i.moveToElementText(document.body);i.collapse(false)}return i}
if(m&&m.changed){var e=b(m.start),f=b(m.end);e.setEndPoint("StartToEnd",f);e.select()}};select.offsetInNode=function(b){var e=s();if(!e)return 0;var f=e.duplicate();try{f.moveToElementText(b)}catch(h){return 0}e.setEndPoint("StartToStart",f);return e.text.length};select.selectionTopNode=function(b,e){function f(o,w){if(w.nodeType==3){for(var A=0,v=w.previousSibling;v&&v.nodeType==3;){A+=v.nodeValue.length;v=v.previousSibling}if(v){try{o.moveToElementText(v)}catch(x){return false}o.collapse(false)}else o.moveToElementText(w.parentNode);
A&&o.move("character",A)}else try{o.moveToElementText(w)}catch(H){return false}return true}var h=s();if(!h)return false;var i=h.duplicate();h.collapse(e);var j=h.parentElement();if(j&&isAncestor(b,j)){i.moveToElementText(j);if(h.compareEndPoints("StartToStart",i)==1)return g(j,b)}e=0;for(j=b.childNodes.length-1;e<j;){var q=Math.ceil((j+e)/2),l=b.childNodes[q];if(!l)return false;if(!f(i,l))return false;if(h.compareEndPoints("StartToStart",i)==1)e=q;else j=q-1}if(e==0){h=s();i=h.duplicate();try{i.moveToElementText(b)}catch(r){return null}if(h.compareEndPoints("StartToStart",
i)==0)return null}return b.childNodes[e]||null};select.focusAfterNode=function(b,e){var f=document.body.createTextRange();f.moveToElementText(b||e);f.collapse(!b);f.select()};select.somethingSelected=function(){var b=s();return b&&b.text!=""};var t=function(b){var e=s();if(e){e.pasteHTML(b);e.collapse(false);e.select()}};select.insertNewlineAtCursor=function(){t("<br>")};select.insertTabAtCursor=function(){t("\u00a0\u00a0\u00a0\u00a0")};select.cursorPos=function(b,e){var f=s();if(!f)return null;for(var h=
select.selectionTopNode(b,e);h&&!isBR(h);)h=h.previousSibling;var i=f.duplicate();f.collapse(e);if(h){i.moveToElementText(h);i.collapse(false)}else{try{i.moveToElementText(b)}catch(j){return null}i.collapse(true)}f.setEndPoint("StartToStart",i);return{node:h,offset:f.text.length}};select.setCursorPos=function(b,e,f){function h(j){var q=document.body.createTextRange();if(j.node){q.moveToElementText(j.node);q.collapse(false)}else{q.moveToElementText(b);q.collapse(true)}q.move("character",j.offset);
return q}var i=h(e);f&&f!=e&&i.setEndPoint("EndToEnd",h(f));i.select()};select.getBookmark=function(b){var e=select.cursorPos(b,true);b=select.cursorPos(b,false);if(e&&b)return{from:e,to:b}};select.setBookmark=function(b,e){e&&select.setCursorPos(b,e.from,e.to)}}else{var a=function(b,e){for(;b.nodeType!=3&&!isBR(b);){var f=b.childNodes[e]||b.nextSibling;for(e=0;!f&&b.parentNode;){b=b.parentNode;f=b.nextSibling}b=f;if(!f)break}return{node:b,offset:e}};select.markSelection=function(){var b=window.getSelection();
if(!b||b.rangeCount==0)return m=null;b=b.getRangeAt(0);m={start:a(b.startContainer,b.startOffset),end:a(b.endContainer,b.endOffset),changed:false}};select.selectMarked=function(){function b(){if(f.start.node==f.end.node&&f.start.offset==f.end.offset){var i=window.getSelection();if(!i||i.rangeCount==0)return true;i=i.getRangeAt(0);i=a(i.startContainer,i.startOffset);return f.start.node!=i.node||f.start.offset!=i.offset}}function e(i,j){if(i.node)i.offset==0?h["set"+j+"Before"](i.node):h["set"+j](i.node,
i.offset);else h.setStartAfter(document.body.lastChild||document.body)}var f=m;if(f&&(f.changed||webkit&&b())){var h=document.createRange();e(f.end,"End");e(f.start,"Start");d(h)}};var d=function(b){var e=window.getSelection();if(e){e.removeAllRanges();e.addRange(b)}},c=function(){var b=window.getSelection();return!b||b.rangeCount==0?false:b.getRangeAt(0)};select.selectionTopNode=function(b,e){var f=c();if(!f)return false;var h=e?f.startContainer:f.endContainer,i=e?f.startOffset:f.endOffset;window.opera&&
!e&&f.endContainer==b&&f.endOffset==f.startOffset+1&&b.childNodes[f.startOffset]&&isBR(b.childNodes[f.startOffset])&&i--;return h.nodeType==3?i>0?g(h,b):p(h,b):h.nodeName.toUpperCase()=="HTML"?i==1?null:b.lastChild:h==b?i==0?null:h.childNodes[i-1]:i==h.childNodes.length?g(h,b):i==0?p(h,b):g(h.childNodes[i-1],b)};select.focusAfterNode=function(b,e){var f=document.createRange();f.setStartBefore(e.firstChild||e);if(b&&!b.firstChild)f.setEndAfter(b);else b?f.setEnd(b,b.childNodes.length):f.setEndBefore(e.firstChild||
e);f.collapse(false);d(f)};select.somethingSelected=function(){var b=c();return b&&!b.collapsed};select.offsetInNode=function(b){var e=c();if(!e)return 0;e=e.cloneRange();e.setStartBefore(b);return e.toString().length};select.insertNodeAtCursor=function(b){var e=c();if(e){e.deleteContents();e.insertNode(b);webkitLastLineHack(document.body);if(window.opera&&isBR(b)&&isSpan(b.parentNode)){e=b.nextSibling;var f=b.parentNode,h=f.parentNode;h.insertBefore(b,f.nextSibling);for(f="";e&&e.nodeType==3;e=e.nextSibling){f+=
e.nodeValue;removeElement(e)}h.insertBefore(makePartSpan(f,document),b.nextSibling)}e=document.createRange();e.selectNode(b);e.collapse(false);d(e)}};select.insertNewlineAtCursor=function(){select.insertNodeAtCursor(document.createElement("BR"))};select.insertTabAtCursor=function(){select.insertNodeAtCursor(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"))};select.cursorPos=function(b,e){var f=c();if(f){for(var h=select.selectionTopNode(b,e);h&&!isBR(h);)h=h.previousSibling;f=f.cloneRange();f.collapse(e);
h?f.setStartAfter(h):f.setStartBefore(b);f=f.toString();return{node:h,offset:f.length}}};select.setCursorPos=function(b,e,f){function h(j,q,l){function r(v){v.nodeType==3?o.push(v):forEach(v.childNodes,r)}if(q==0&&j&&!j.nextSibling){i["set"+l+"After"](j);return true}if(j=j?j.nextSibling:b.firstChild){if(q==0){i["set"+l+"Before"](j);return true}for(var o=[];;){for(;j&&!o.length;){r(j);j=j.nextSibling}var w=o.shift();if(!w)return false;var A=w.nodeValue.length;if(A>=q){i["set"+l](w,q);return true}q-=
A}}}var i=document.createRange();f=f||e;h(f.node,f.offset,"End")&&h(e.node,e.offset,"Start")&&d(i)}}})();function UndoHistory(g,p,k,m){this.container=g;this.maxDepth=p;this.commitDelay=k;this.editor=m;this.last=this.first=g={text:"",from:null,to:null};this.firstTouched=false;this.history=[];this.redoHistory=[];this.touched=[]}
UndoHistory.prototype={scheduleCommit:function(){var g=this;parent.clearTimeout(this.commitTimeout);this.commitTimeout=parent.setTimeout(function(){g.tryCommit()},this.commitDelay)},touch:function(g){this.setTouched(g);this.scheduleCommit()},undo:function(){this.commit();if(this.history.length){var g=this.history.pop();this.redoHistory.push(this.updateTo(g,"applyChain"));this.notifyEnvironment();return this.chainNode(g)}},redo:function(){this.commit();if(this.redoHistory.length){var g=this.redoHistory.pop();
this.addUndoLevel(this.updateTo(g,"applyChain"));this.notifyEnvironment();return this.chainNode(g)}},clear:function(){this.history=[];this.redoHistory=[]},historySize:function(){return{undo:this.history.length,redo:this.redoHistory.length}},push:function(g,p,k){for(var m=[],s=0;s<k.length;s++){var n=s==k.length-1?p:document.createElement("br");m.push({from:g,to:n,text:cleanText(k[s])});g=n}this.pushChains([m],g==null&&p==null);this.notifyEnvironment()},pushChains:function(g,p){this.commit(p);this.addUndoLevel(this.updateTo(g,
"applyChain"));this.redoHistory=[]},chainNode:function(g){for(var p=0;p<g.length;p++){var k=g[p][0];if(k=k&&(k.from||k.to))return k}},reset:function(){this.history=[];this.redoHistory=[]},textAfter:function(g){return this.after(g).text},nodeAfter:function(g){return this.after(g).to},nodeBefore:function(g){return this.before(g).from},tryCommit:function(){!window||!window.parent||!window.UndoHistory||(this.editor.highlightDirty()?this.commit(true):this.scheduleCommit())},commit:function(g){parent.clearTimeout(this.commitTimeout);
g||this.editor.highlightDirty(true);g=this.touchedChains();if(g.length){this.addUndoLevel(this.updateTo(g,"linkChain"));this.redoHistory=[];this.notifyEnvironment()}},updateTo:function(g,p){for(var k=[],m=[],s=0;s<g.length;s++){k.push(this.shadowChain(g[s]));m.push(this[p](g[s]))}p=="applyChain"&&this.notifyDirty(m);return k},notifyDirty:function(g){forEach(g,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(g){for(var p=0;p<g.length;p++){var k=g[p];if(k.from)k.from.historyAfter=k;else this.first=k;if(k.to)k.to.historyBefore=k;else this.last=k}},after:function(g){return g?g.historyAfter:this.first},before:function(g){return g?g.historyBefore:this.last},setTouched:function(g){if(g){if(!g.historyTouched){this.touched.push(g);g.historyTouched=true}}else this.firstTouched=true},addUndoLevel:function(g){this.history.push(g);
this.history.length>this.maxDepth&&this.history.shift()},touchedChains:function(){function g(a,d){if(a)a.historyTemp=d;else s=d}function p(a){for(var d=[],c=a?a.nextSibling:m.container.firstChild;c&&(!isBR(c)||c.hackBR);c=c.nextSibling)!c.hackBR&&c.currentText&&d.push(c.currentText);return{from:a,to:c,text:cleanText(d.join(""))}}function k(a,d){for(var c=d+"Sibling",b=a[c];b&&!isBR(b);)b=b[c];return b}var m=this,s=null,n=[];m.firstTouched&&m.touched.push(null);forEach(m.touched,function(a){if(!(a&&
(a.parentNode!=m.container||a.hackBR))){if(a)a.historyTouched=false;else m.firstTouched=false;var d=p(a),c=m.after(a);if(!c||c.text!=d.text||c.to!=d.to){n.push(d);g(a,d)}}});var t=[];m.touched=[];forEach(n,function(a){if(a.from?a.from.historyTemp:s){for(var d=[],c=a.from,b=true;;){var e=c?c.historyTemp:s;if(!e)if(b)break;else e=p(c);d.unshift(e);g(c,null);if(!c)break;b=m.after(c);c=k(c,"previous")}c=a.to;for(b=m.before(a.from);;){if(!c)break;e=c?c.historyTemp:s;if(!e)if(b)break;else e=p(c);d.push(e);
g(c,null);b=m.before(c);c=k(c,"next")}t.push(d)}});return t},shadowChain:function(g){var p=[],k=this.after(g[0].from);for(g=g[g.length-1].to;;){p.push(k);k=k.to;if(!k||k==g)break;else k=k.historyAfter||this.before(g)}return p},applyChain:function(g){var p=select.cursorPos(this.container,false),k=this,m=g[0].from,s=g[g.length-1].to;(function(b,e){for(var f=b?b.nextSibling:k.container.firstChild;f!=e;){var h=f.nextSibling;removeElement(f);f=h}})(m,s);for(var n=0;n<g.length;n++){var t=g[n];n>0&&k.container.insertBefore(t.from,
s);var a=makePartSpan(fixSpaces(t.text));k.container.insertBefore(a,s);if(p&&p.node==t.from){a=0;var d=this.after(t.from);if(d&&n==g.length-1){for(var c=0;c<p.offset&&t.text.charAt(c)==d.text.charAt(c);c++);if(p.offset>c)a=t.text.length-d.text.length}select.setCursorPos(this.container,{node:t.from,offset:Math.max(0,p.offset+a)})}else p&&n==g.length-1&&p.node&&p.node.parentNode!=this.container&&select.setCursorPos(this.container,{node:t.from,offset:t.text.length})}this.linkChain(g);return m}};var internetExplorer=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent),webkit=/AppleWebKit/.test(navigator.userAgent),safari=/Apple Computer, Inc/.test(navigator.vendor),gecko=navigator.userAgent.match(/gecko\/(\d{8})/i);if(gecko)gecko=Number(gecko[1]);var mac=/Mac/.test(navigator.platform),brokenOpera=window.opera&&/Version\/10.[56]/.test(navigator.userAgent),slowWebkit=/AppleWebKit\/533/.test(navigator.userAgent);
function makeWhiteSpace(g){for(var p=[],k=true;g>0;g--){p.push(k||g==1?nbsp:" ");k^=true}return p.join("")}function fixSpaces(g){if(g.charAt(0)==" ")g=nbsp+g.slice(1);return g.replace(/\t/g,function(){return makeWhiteSpace(indentUnit)}).replace(/[ \u00a0]{2,}/g,function(p){return makeWhiteSpace(p.length)})}function cleanText(g){return g.replace(/\u00a0/g," ").replace(/\u200b/g,"")}
function makePartSpan(g){var p=g;if(g.nodeType==3)p=g.nodeValue;else g=document.createTextNode(p);var k=document.createElement("span");k.isPart=true;k.appendChild(g);k.currentText=p;return k}function alwaysZero(){return 0}var webkitLastLineHack=webkit?function(g){var p=g.lastChild;if(!p||!p.hackBR){p=document.createElement("br");p.hackBR=true;g.appendChild(p)}}:function(){};
function asEditorLines(g){var p=makeWhiteSpace(indentUnit);return map(g.replace(/\t/g,p).replace(/\u00a0/g," ").replace(/\r\n?/g,"\n").split("\n"),fixSpaces)}
var Editor=function(){function g(a,d){function c(f,h){if(f.nodeType==3){if((f.nodeValue=fixSpaces(f.nodeValue.replace(/[\r\u200b]/g,"").replace(/\n/g," "))).length)e=false;b.push(f)}else if(isBR(f)&&f.childNodes.length==0){e=true;b.push(f)}else{for(var i=f.firstChild;i;i=i.nextSibling)c(i);if(!e&&t.hasOwnProperty(f.nodeName.toUpperCase())){e=true;if(!d||!h)b.push(document.createElement("br"))}}}var b=[],e=true;c(a,true);return b}function p(a){function d(f){var h=f.parentNode,i=f.nextSibling;return function(j){h.insertBefore(j,
i)}}var c=[],b=null,e=true;return{next:function(){if(!a)throw StopIteration;var f=a;a=f.nextSibling;var h;if(f.isPart&&f.childNodes.length==1&&f.firstChild.nodeType==3){h=f.firstChild.nodeValue;f.dirty=f.dirty||h!=f.currentText;f.currentText=h;h=!/[\n\t\r]/.test(f.currentText)}else h=false;if(h){c.push(f);e=false;return f.currentText}else if(isBR(f)){e&&window.opera&&f.parentNode.insertBefore(makePartSpan(""),f);c.push(f);e=true;return"\n"}else{h=!f.nextSibling;b=d(f);removeElement(f);f=g(f,h);for(h=
0;h<f.length;h++){var i=f,j=h,q=f[h],l="\n";if(q.nodeType==3){select.snapshotChanged();q=makePartSpan(q);l=q.currentText;e=false}else{e&&window.opera&&b(makePartSpan(""));e=true}q.dirty=true;c.push(q);b(q);i[j]=l}return f.join("")}},nodes:c}}function k(a){for(;a&&!isBR(a);)a=a.previousSibling;return a}function m(a,d){if(a){if(isBR(a))a=a.nextSibling}else a=d.firstChild;for(;a&&!isBR(a);)a=a.nextSibling;return a}function s(a,d,c,b){function e(j){j=cleanText(a.history.textAfter(j));return b?j.toLowerCase():
j}this.editor=a;this.history=a.history;this.history.commit();this.valid=!!d;this.atOccurrence=false;if(b==undefined)b=typeof d=="string"&&d==d.toLowerCase();var f={node:null,offset:0},h=this;if(c&&typeof c=="object"&&typeof c.character=="number"){a.checkLine(c.line);c={node:c.line,offset:c.character};this.pos={from:c,to:c}}else this.pos=c?{from:select.cursorPos(a.container,true)||f,to:select.cursorPos(a.container,false)||f}:{from:f,to:f};if(typeof d!="string")this.matches=function(j,q,l){if(j){j=
e(q).slice(0,l);var r=j.match(d);for(l=0;r;){var o=j.indexOf(r[0]);l+=o;j=j.slice(o+1);if(o=j.match(d))r=o;else break}}else{j=e(q).slice(l);l=(r=j.match(d))&&l+j.indexOf(r[0])}if(r){h.currentMatch=r;return{from:{node:q,offset:l},to:{node:q,offset:l+r[0].length}}}};else{if(b)d=d.toLowerCase();var i=d.split("\n");this.matches=i.length==1?function(j,q,l){var r=e(q),o=d.length,w;if(j?l>=o&&(w=r.lastIndexOf(d,l-o))!=-1:(w=r.indexOf(d,l))!=-1)return{from:{node:q,offset:w},to:{node:q,offset:w+o}}}:function(j,
q,l){var r=j?i.length-1:0,o=i[r],w=e(q),A=j?w.indexOf(o)+o.length:w.lastIndexOf(o);if(!(j?A>=l||A!=o.length:A<=l||A!=w.length-o.length))for(l=q;;){if(j&&!l)break;l=j?this.history.nodeBefore(l):this.history.nodeAfter(l);if(!j&&!l)break;w=e(l);o=i[j?--r:++r];if(r>0&&r<i.length-1)if(w!=o)break;else continue;r=j?w.lastIndexOf(o):w.indexOf(o)+o.length;if(j?r!=w.length-o.length:r!=o.length)break;return{from:{node:j?l:q,offset:j?r:A},to:{node:j?q:l,offset:j?A:r}}}}}}function n(a){this.options=a;window.indentUnit=
a.indentUnit;var d=this.container=document.body;this.history=new UndoHistory(d,a.undoDepth,a.undoDelay,this);var c=this;if(!n.Parser)throw"No parser loaded.";a.parserConfig&&n.Parser.configure&&n.Parser.configure(a.parserConfig);!a.readOnly&&!internetExplorer&&select.setCursorPos(d,{node:null,offset:0});this.dirty=[];this.importCode(a.content||"");this.history.onChange=a.onChange;if(a.readOnly){if(!a.textWrapping)d.style.whiteSpace="nowrap"}else{if(a.continuousScanning!==false){this.scanner=this.documentScanner(a.passTime);
this.delayScanning()}var b=function(){if(document.body.contentEditable!=undefined&&internetExplorer)document.body.contentEditable="true";else document.designMode="on";if(internetExplorer&&a.height!="dynamic")document.body.style.minHeight=window.frameElement.clientHeight-2*document.body.offsetTop-5+"px";document.documentElement.style.borderWidth="0";if(!a.textWrapping)d.style.whiteSpace="nowrap"};try{b()}catch(e){var f=addEventHandler(document,"focus",function(){f();b()},true)}addEventHandler(document,
"keydown",method(this,"keyDown"));addEventHandler(document,"keypress",method(this,"keyPress"));addEventHandler(document,"keyup",method(this,"keyUp"));var h=function(){c.cursorActivity(false)};addEventHandler(internetExplorer?document.body:window,"mouseup",h);addEventHandler(document.body,"cut",h);gecko&&addEventHandler(window,"pagehide",function(){c.unloaded=true});addEventHandler(document.body,"paste",function(i){h();var j=null;try{var q=i.clipboardData||window.clipboardData;if(q)j=q.getData("Text")}catch(l){}if(j!==
null){i.stop();c.replaceSelection(j);select.scrollToCursor(c.container)}});this.options.autoMatchParens&&addEventHandler(document.body,"click",method(this,"scheduleParenHighlight"))}}var t={P:true,DIV:true,LI:true};s.prototype={findNext:function(){return this.find(false)},findPrevious:function(){return this.find(true)},find:function(a){function d(){var h={node:e,offset:f};c.pos={from:h,to:h};return c.atOccurrence=false}if(!this.valid)return false;var c=this,b=a?this.pos.from:this.pos.to,e=b.node,
f=b.offset;if(e&&!e.parentNode){e=null;f=0}for(;;){if(this.pos=this.matches(a,e,f))return this.atOccurrence=true;if(a){if(!e)return d();e=this.history.nodeBefore(e);f=this.history.textAfter(e).length}else{b=this.history.nodeAfter(e);if(!b){f=this.history.textAfter(e).length;return d()}e=b;f=0}}},select:function(){if(this.atOccurrence){select.setCursorPos(this.editor.container,this.pos.from,this.pos.to);select.scrollToCursor(this.editor.container)}},replace:function(a){if(this.atOccurrence){var d=
this.currentMatch;if(d)a=a.replace(/\\(\d)/,function(c,b){return d[b]});this.pos.to=this.editor.replaceRange(this.pos.from,this.pos.to,a);this.atOccurrence=false}},position:function(){if(this.atOccurrence)return{line:this.pos.from.node,character:this.pos.from.offset}}};n.prototype={importCode:function(a){var d=asEditorLines(a);if(!this.options.incrementalLoading||d.length<1E3){this.history.push(null,null,d);this.history.reset()}else{var c=0,b=this,e=function(){var f=d.slice(c,c+1E3);f.push("");b.history.push(b.history.nodeBefore(null),
null,f);b.history.reset();c+=1E3;c<d.length&&parent.setTimeout(e,1E3)};e()}},getCode:function(){if(!this.container.firstChild)return"";var a=[];select.markSelection();forEach(p(this.container.firstChild),method(a,"push"));select.selectMarked();webkit&&this.container.lastChild.hackBR&&a.pop();webkitLastLineHack(this.container);return cleanText(a.join(""))},checkLine:function(a){if(a===false||!(a==null||a.parentNode==this.container||a.hackBR))throw parent.CodeMirror.InvalidLineHandle;},cursorPosition:function(a){if(a==
null)a=true;return(a=select.cursorPos(this.container,a))?{line:a.node,character:a.offset}:{line:null,character:0}},firstLine:function(){return null},lastLine:function(){var a=this.container.lastChild;if(a)a=k(a);if(a&&a.hackBR)a=k(a.previousSibling);return a},nextLine:function(a){this.checkLine(a);a=m(a,this.container);return!a||a.hackBR?false:a},prevLine:function(a){this.checkLine(a);if(a==null)return false;return k(a.previousSibling)},visibleLineCount:function(){for(var a=this.container.firstChild;a&&
isBR(a);)a=a.nextSibling;if(!a)return false;return Math.floor((window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)/a.offsetHeight)},selectLines:function(a,d,c,b){this.checkLine(a);a={node:a,offset:d};d=null;if(b!==undefined){this.checkLine(c);d={node:c,offset:b}}select.setCursorPos(this.container,a,d);select.scrollToCursor(this.container)},lineContent:function(a){var d=[];for(a=a?a.nextSibling:this.container.firstChild;a&&!isBR(a);a=a.nextSibling)d.push(nodeText(a));
return cleanText(d.join(""))},setLineContent:function(a,d){this.history.commit();this.replaceRange({node:a,offset:0},{node:a,offset:this.history.textAfter(a).length},d);this.addDirtyNode(a);this.scheduleHighlight()},removeLine:function(a){for(var d=a?a.nextSibling:this.container.firstChild;d;){var c=d.nextSibling;removeElement(d);if(isBR(d))break;d=c}this.addDirtyNode(a);this.scheduleHighlight()},insertIntoLine:function(a,d,c){var b=null;if(d=="end")b=m(a,this.container);else for(var e=a?a.nextSibling:
this.container.firstChild;e;e=e.nextSibling){if(d==0){b=e;break}var f=nodeText(e);if(f.length>d){b=e.nextSibling;c=f.slice(0,d)+c+f.slice(d);removeElement(e);break}d-=f.length}d=asEditorLines(c);for(c=0;c<d.length;c++){c>0&&this.container.insertBefore(document.createElement("BR"),b);this.container.insertBefore(makePartSpan(d[c]),b)}this.addDirtyNode(a);this.scheduleHighlight()},selectedText:function(){var a=this.history;a.commit();var d=select.cursorPos(this.container,true),c=select.cursorPos(this.container,
false);if(!d||!c)return"";if(d.node==c.node)return a.textAfter(d.node).slice(d.offset,c.offset);var b=[a.textAfter(d.node).slice(d.offset)];for(d=a.nodeAfter(d.node);d!=c.node;d=a.nodeAfter(d))b.push(a.textAfter(d));b.push(a.textAfter(c.node).slice(0,c.offset));return cleanText(b.join("\n"))},replaceSelection:function(a){this.history.commit();var d=select.cursorPos(this.container,true),c=select.cursorPos(this.container,false);if(d&&c){c=this.replaceRange(d,c,a);select.setCursorPos(this.container,
c);webkitLastLineHack(this.container)}},cursorCoords:function(a,d){function c(j,q){var l=-(document.body.scrollTop||document.documentElement.scrollTop||0),r=-(document.body.scrollLeft||document.documentElement.scrollLeft||0)+q;forEach([j,d?null:window.frameElement],function(o){for(;o;){r+=o.offsetLeft;l+=o.offsetTop;o=o.offsetParent}});return{x:r,y:l,yBot:l+j.offsetHeight}}function b(j,q){var l=document.createElement("SPAN");l.appendChild(document.createTextNode(j));try{return q(l)}finally{l.parentNode&&
l.parentNode.removeChild(l)}}var e=select.cursorPos(this.container,a);if(!e)return null;for(var f=e.offset,h=e.node,i=this;f;){h=h?h.nextSibling:this.container.firstChild;e=nodeText(h);if(f<e.length)return b(e.substr(0,f),function(j){j.style.position="absolute";j.style.visibility="hidden";j.className=h.className;i.container.appendChild(j);return c(h,j.offsetWidth)});f-=e.length}return h&&isSpan(h)?c(h,h.offsetWidth):h&&h.nextSibling&&isSpan(h.nextSibling)?c(h.nextSibling,0):b("\u200b",function(j){h?
h.parentNode.insertBefore(j,h.nextSibling):i.container.insertBefore(j,i.container.firstChild);return c(j,0)})},reroutePasteEvent:function(){if(!(this.capturingPaste||window.opera||gecko&&gecko>=20101026)){this.capturingPaste=true;var a=window.frameElement.CodeMirror.textareaHack,d=this.cursorCoords(true,true);a.style.top=d.y+"px";if(internetExplorer)if(d=select.getBookmark(this.container))this.selectionSnapshot=d;parent.focus();a.value="";a.focus();var c=this;parent.setTimeout(function(){c.capturingPaste=
false;window.focus();c.selectionSnapshot&&window.select.setBookmark(c.container,c.selectionSnapshot);var b=a.value;if(b){c.replaceSelection(b);select.scrollToCursor(c.container)}},10)}},replaceRange:function(a,d,c){c=asEditorLines(c);c[0]=this.history.textAfter(a.node).slice(0,a.offset)+c[0];var b=c[c.length-1];c[c.length-1]=b+this.history.textAfter(d.node).slice(d.offset);d=this.history.nodeAfter(d.node);this.history.push(a.node,d,c);return{node:this.history.nodeBefore(d),offset:b.length}},getSearchCursor:function(a,
d,c){return new s(this,a,d,c)},reindent:function(){this.container.firstChild&&this.indentRegion(null,this.container.lastChild)},reindentSelection:function(a){if(select.somethingSelected()){var d=select.selectionTopNode(this.container,true),c=select.selectionTopNode(this.container,false);d===false||c===false||this.indentRegion(d,c,a)}else this.indentAtCursor(a)},grabKeys:function(a,d){this.frozen=a;this.keyFilter=d},ungrabKeys:function(){this.frozen="leave"},setParser:function(a,d){n.Parser=window[a];
(d=d||this.options.parserConfig)&&n.Parser.configure&&n.Parser.configure(d);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(a){if(this.frozen=="leave")this.keyFilter=this.frozen=null;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode,a))){a.stop();this.frozen(a)}else{var d=a.keyCode;this.delayScanning();this.options.autoMatchParens&&this.scheduleParenHighlight();
if(d==13){if(a.ctrlKey&&!a.altKey)this.reparseBuffer();else{select.insertNewlineAtCursor();d=this.options.enterMode;if(d!="flat")this.indentAtCursor(d=="keep"?"keep":undefined);select.scrollToCursor(this.container)}a.stop()}else if(d==9&&this.options.tabMode!="default"&&!a.ctrlKey){this.handleTab(!a.shiftKey);a.stop()}else if(d==32&&a.shiftKey&&this.options.tabMode=="default"){this.handleTab(true);a.stop()}else if(d==36&&!a.shiftKey&&!a.ctrlKey)this.home()&&a.stop();else if(d==35&&!a.shiftKey&&!a.ctrlKey)this.end()&&
a.stop();else if(d==33&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageUp()&&a.stop();else if(d==34&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageDown()&&a.stop();else if((d==219||d==221)&&a.ctrlKey&&!a.altKey){this.highlightParens(a.shiftKey,true);a.stop()}else if(a.metaKey&&!a.shiftKey&&(d==37||d==39)){var c=select.selectionTopNode(this.container);if(!(c===false||!this.container.firstChild)){if(d==37)select.focusAfterNode(k(c),this.container);else{d=m(c,this.container);select.focusAfterNode(d?d.previousSibling:
this.container.lastChild,this.container)}a.stop()}}else if((a.ctrlKey||a.metaKey)&&!a.altKey)if(a.shiftKey&&d==90||d==89){select.scrollToNode(this.history.redo());a.stop()}else if(d==90||safari&&d==8){select.scrollToNode(this.history.undo());a.stop()}else if(d==83&&this.options.saveFunction){this.options.saveFunction();a.stop()}else d==86&&!mac&&this.reroutePasteEvent()}},keyPress:function(a){var d=this.options.electricChars&&n.Parser.electricChars,c=this;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode||
a.code,a))||a.code==13||a.code==9&&this.options.tabMode!="default"||a.code==32&&a.shiftKey&&this.options.tabMode=="default")a.stop();else if(mac&&(a.ctrlKey||a.metaKey)&&a.character=="v")this.reroutePasteEvent();else if(d&&d.indexOf(a.character)!=-1)parent.setTimeout(function(){c.indentAtCursor(null)},0);else if(brokenOpera)if(a.code==8){var b=select.selectionTopNode(this.container);c=this;var e=b?b.nextSibling:this.container.firstChild;b!==false&&e&&isBR(e)&&parent.setTimeout(function(){select.selectionTopNode(c.container)==
e&&select.focusAfterNode(e.previousSibling,c.container)},20)}else{if(a.code==46){b=select.selectionTopNode(this.container);c=this;b&&isBR(b)&&parent.setTimeout(function(){select.selectionTopNode(c.container)!=b&&select.focusAfterNode(b,c.container)},20)}}else if(slowWebkit){e=(b=select.selectionTopNode(this.container))?b.nextSibling:this.container.firstChild;if(b&&e&&isBR(e)&&!isBR(b)){var f=document.createTextNode("\u200b");this.container.insertBefore(f,e);parent.setTimeout(function(){if(f.nodeValue==
"\u200b")removeElement(f);else f.nodeValue=f.nodeValue.replace("\u200b","")},20)}}webkit&&!this.options.textWrapping&&setTimeout(function(){var h=select.selectionTopNode(c.container,true);h&&h.nodeType==3&&h.previousSibling&&isBR(h.previousSibling)&&h.nextSibling&&isBR(h.nextSibling)&&h.parentNode.replaceChild(document.createElement("BR"),h.previousSibling)},50)},keyUp:function(a){this.cursorActivity(a.keyCode>=16&&a.keyCode<=18||a.keyCode>=33&&a.keyCode<=40)},indentLineAfter:function(a,d){function c(q){q=
q?q.nextSibling:b.container.firstChild;if(!q||!hasClass(q,"whitespace"))return null;return q}var b=this,e=c(a),f=0,h=e?e.currentText.length:0,i=e?e.nextSibling:a?a.nextSibling:this.container.firstChild;if(d=="keep"){if(a){var j=c(k(a.previousSibling));if(j)f=j.currentText.length}}else{j=a&&i&&i.currentText?i.currentText:"";if(d!=null&&this.options.tabMode=="shift")f=d?h+indentUnit:Math.max(0,h-indentUnit);else if(a)f=a.indentation(j,h,d,i);else if(n.Parser.firstIndentation)f=n.Parser.firstIndentation(j,
h,d,i)}h=f-h;if(h<0)if(f==0){if(i)select.snapshotMove(e.firstChild,i.firstChild||i,0);removeElement(e);e=null}else{select.snapshotMove(e.firstChild,e.firstChild,h,true);e.currentText=makeWhiteSpace(f);e.firstChild.nodeValue=e.currentText}else if(h>0)if(e){e.currentText=makeWhiteSpace(f);e.firstChild.nodeValue=e.currentText;select.snapshotMove(e.firstChild,e.firstChild,h,true)}else{e=makePartSpan(makeWhiteSpace(f));e.className="whitespace";a?insertAfter(e,a):this.container.insertBefore(e,this.container.firstChild);
select.snapshotMove(i&&(i.firstChild||i),e.firstChild,f,false,true)}else e&&select.snapshotMove(e.firstChild,e.firstChild,f,false);h!=0&&this.addDirtyNode(a)},highlightAtCursor:function(){var a=select.selectionTopNode(this.container,true),d=select.selectionTopNode(this.container,false);if(a===false||d===false)return false;select.markSelection();if(this.highlight(a,m(d,this.container),true,20)===false)return false;select.selectMarked();return true},handleTab:function(a){this.options.tabMode=="spaces"?
select.insertTabAtCursor():this.reindentSelection(a)},home:function(){var a=select.selectionTopNode(this.container,true),d=a;if(a===false||!(!a||a.isPart||isBR(a))||!this.container.firstChild)return false;for(;a&&!isBR(a);)a=a.previousSibling;var c=a?a.nextSibling:this.container.firstChild;c&&c!=d&&c.isPart&&hasClass(c,"whitespace")?select.focusAfterNode(c,this.container):select.focusAfterNode(a,this.container);select.scrollToCursor(this.container);return true},end:function(){var a=select.selectionTopNode(this.container,
true);if(a===false)return false;a=m(a,this.container);if(!a)return false;select.focusAfterNode(a.previousSibling,this.container);select.scrollToCursor(this.container);return true},pageUp:function(){var a=this.cursorPosition().line,d=this.visibleLineCount();if(a===false||d===false)return false;d-=2;for(var c=0;c<d;c++){a=this.prevLine(a);if(a===false)break}if(c==0)return false;select.setCursorPos(this.container,{node:a,offset:0});select.scrollToCursor(this.container);return true},pageDown:function(){var a=
this.cursorPosition().line,d=this.visibleLineCount();if(a===false||d===false)return false;d-=2;for(var c=0;c<d;c++){var b=this.nextLine(a);if(b===false)break;a=b}if(c==0)return false;select.setCursorPos(this.container,{node:a,offset:0});select.scrollToCursor(this.container);return true},scheduleParenHighlight:function(){this.parenEvent&&parent.clearTimeout(this.parenEvent);var a=this;this.parenEvent=parent.setTimeout(function(){a.highlightParens()},300)},highlightParens:function(a,d){function c(w,
A){if(w)if(i)if(i.call)i(w,A);else w.className+=" "+i[A?0:1];else{w.style.fontWeight="bold";w.style.color=A?"#8F8":"#F88"}}function b(w){if(w)if(i&&!i.call)removeClass(removeClass(w,i[0]),i[1]);else if(h.options.unmarkParen)h.options.unmarkParen(w);else{w.style.fontWeight="";w.style.color=""}}function e(w){if(w.currentText)return(w=w.currentText.match(/^[\s\u00a0]*([\(\)\[\]{}])[\s\u00a0]*$/))&&w[1]}function f(){for(var w=[],A,v=true,x=q;x;x=r?x.nextSibling:x.previousSibling)if(x.className==l&&isSpan(x)&&
(A=e(x))){if(/[\(\[\{]/.test(A)==r)w.push(A);else if(w.length){if(w.pop()!=matching[A])v=false}else v=false;if(!w.length)break}else if(x.dirty||!isSpan(x)&&!isBR(x))return{node:x,status:"dirty"};return{node:x,status:x&&v}}var h=this,i=this.options.markParen;if(typeof i=="string")i=[i,i];if(!d&&h.highlighted){b(h.highlighted[0]);b(h.highlighted[1])}if(!(!window||!window.parent||!window.select)){this.parenEvent&&parent.clearTimeout(this.parenEvent);this.parenEvent=null;var j,q=select.selectionTopNode(this.container,
true);if(q&&this.highlightAtCursor())if((q=select.selectionTopNode(this.container,true))&&((j=e(q))||(q=q.nextSibling)&&(j=e(q))))for(var l=q.className,r=/[\(\[\{]/.test(j);;){var o=f();if(o.status=="dirty"){this.highlight(o.node,m(o.node));o.node.dirty=false}else{c(q,o.status);c(o.node,o.status);if(d)parent.setTimeout(function(){b(q);b(o.node)},500);else h.highlighted=[q,o.node];a&&o.node&&select.focusAfterNode(o.node.previousSibling,this.container);break}}}},indentAtCursor:function(a){if(this.container.firstChild)if(this.highlightAtCursor()){var d=
select.selectionTopNode(this.container,false);if(d!==false){select.markSelection();this.indentLineAfter(k(d),a);select.selectMarked()}}},indentRegion:function(a,d,c){var b=a=k(a),e=a&&k(a.previousSibling);isBR(d)||(d=m(d,this.container));this.addDirtyNode(a);do{var f=m(b,this.container);b&&this.highlight(e,f,true);this.indentLineAfter(b,c);e=b;b=f}while(b!=d);select.setCursorPos(this.container,{node:a,offset:0},{node:d,offset:0})},cursorActivity:function(a){if(this.unloaded){window.document.designMode=
"off";window.document.designMode="on";this.unloaded=false}if(internetExplorer){this.container.createTextRange().execCommand("unlink");clearTimeout(this.saveSelectionSnapshot);var d=this;this.saveSelectionSnapshot=setTimeout(function(){var e=select.getBookmark(d.container);if(e)d.selectionSnapshot=e},200)}var c=this.options.onCursorActivity;if(!a||c){var b=select.selectionTopNode(this.container,false);if(!(b===false||!this.container.firstChild)){b=b||this.container.firstChild;c&&c(b);if(!a){this.scheduleHighlight();
this.addDirtyNode(b)}}}},reparseBuffer:function(){forEach(this.container.childNodes,function(a){a.dirty=true});this.container.firstChild&&this.addDirtyNode(this.container.firstChild)},addDirtyNode:function(a){if(a=a||this.container.firstChild){for(var d=0;d<this.dirty.length;d++)if(this.dirty[d]==a)return;if(a.nodeType!=3)a.dirty=true;this.dirty.push(a)}},allClean:function(){return!this.dirty.length},scheduleHighlight:function(){var a=this;parent.clearTimeout(this.highlightTimeout);this.highlightTimeout=
parent.setTimeout(function(){a.highlightDirty()},this.options.passDelay)},getDirtyNode:function(){for(;this.dirty.length>0;){var a=this.dirty.pop();try{for(;a&&a.parentNode!=this.container;)a=a.parentNode;if(a&&(a.dirty||a.nodeType==3))return a}catch(d){}}return null},highlightDirty:function(a){if(!window||!window.parent||!window.select)return false;this.options.readOnly||select.markSelection();for(var d,c=a?null:(new Date).getTime()+this.options.passTime;((new Date).getTime()<c||a)&&(d=this.getDirtyNode());){var b=
this.highlight(d,c);b&&b.node&&b.dirty&&this.addDirtyNode(b.node.nextSibling)}this.options.readOnly||select.selectMarked();d&&this.scheduleHighlight();return this.dirty.length==0},documentScanner:function(a){var d=this,c=null;return function(){if(!(!window||!window.parent||!window.select)){if(c&&c.parentNode!=d.container)c=null;select.markSelection();var b=d.highlight(c,(new Date).getTime()+a,true);select.selectMarked();b=b?b.node&&b.node.nextSibling:null;c=c==b?null:b;d.delayScanning()}}},delayScanning:function(){if(this.scanner){parent.clearTimeout(this.documentScan);
this.documentScan=parent.setTimeout(this.scanner,this.options.continuousScanning)}},highlight:function(a,d,c,b){function e(v){if(v){var x=v.oldNextSibling;if(o||x===undefined||v.nextSibling!=x)h.history.touch(v);v.oldNextSibling=v.nextSibling}else{x=h.container.oldFirstChild;if(o||x===undefined||h.container.firstChild!=x)h.history.touch(null);h.container.oldFirstChild=h.container.firstChild}}var f=this.container,h=this,i=this.options.activeTokens,j=typeof d=="number"?d:null;if(!f.firstChild)return false;
for(;a&&(!a.parserFromHere||a.dirty);){if(b!=null&&isBR(a)&&--b<0)return false;a=a.previousSibling}if(a&&!a.nextSibling)return false;var q=p(a?a.nextSibling:f.firstChild);b=stringStream(q);var l=a?a.parserFromHere(b):n.Parser.make(b),r={current:null,get:function(){if(!this.current)this.current=q.nodes.shift();return this.current},next:function(){this.current=null},remove:function(){f.removeChild(this.get());this.current=null},getNonEmpty:function(){for(var v=this.get();v&&isSpan(v)&&v.currentText==
"";)if(window.opera&&(v.previousSibling==null||isBR(v.previousSibling))&&(v.nextSibling==null||isBR(v.nextSibling))){this.next();v=this.get()}else{var x=v;this.remove();v=this.get();select.snapshotMove(x.firstChild,v&&(v.firstChild||v),0)}return v}},o=false,w=true,A=0;forEach(l,function(v){var x=r.getNonEmpty();if(v.value=="\n"){if(!isBR(x))throw"Parser out of sync. Expected BR.";if(x.dirty||!x.indentation)o=true;e(a);a=x;x.parserFromHere=l.copy();x.indentation=v.indentation||alwaysZero;x.dirty=false;
if(j==null&&x==d)throw StopIteration;if(j!=null&&(new Date).getTime()>=j||!o&&!w&&A>1&&!c)throw StopIteration;w=o;o=false;A=0;r.next()}else{if(!isSpan(x))throw"Parser out of sync. Expected SPAN.";if(x.dirty)o=true;A++;if(!x.reduced&&x.currentText==v.value&&x.className==v.style){i&&x.dirty&&i(x,v,h);x.dirty=false;r.next()}else{o=true;var H=makePartSpan(v.value);H.className=v.style;f.insertBefore(H,x);i&&i(H,v,h);v=v.value.length;for(var K=0;v>0;){x=r.get();var L=x.currentText.length;select.snapshotReplaceNode(x.firstChild,
H.firstChild,v,K);if(L>v){x=x;x.currentText=x.currentText.substring(v);x.reduced=true;v=0}else{v-=L;K+=L;r.remove()}}}}});e(a);webkitLastLineHack(this.container);return{node:r.getNonEmpty(),dirty:o}}};return n}();addEventHandler(window,"load",function(){var g=window.frameElement.CodeMirror;g.editor=new Editor(g.options);parent.setTimeout(method(g,"init"),0)});function tokenizer(g,p){function k(s){return s!="\n"&&/^[\s\u00a0]*$/.test(s)}var m={state:p,take:function(s){if(typeof s=="string")s={style:s,type:s};s.content=(s.content||"")+g.get();/\n$/.test(s.content)||g.nextWhile(k);s.value=s.content+g.get();return s},next:function(){if(!g.more())throw StopIteration;var s;if(g.equals("\n")){g.next();return this.take("whitespace")}if(g.applies(k))s="whitespace";else for(;!s;)s=this.state(g,function(n){m.state=n});return this.take(s)}};return m};var tokenizeJavaScript=function(){function g(a,d){for(var c=false;!a.endOfLine();){var b=a.next();if(b==d&&!c)return false;c=!c&&b=="\\"}return c}function p(a,d){return function(c,b){var e=a,f=k(a,d,c,function(i){e=i}),h=f.type=="operator"||f.type=="keyword c"||f.type.match(/^[\[{}\(,;:]$/);if(h!=d||e!=a)b(p(e,h));return f}}function k(a,d,c,b){function e(){c.nextWhileMatches(t);var q=c.get(),l=m.hasOwnProperty(q)&&m.propertyIsEnumerable(q)&&m[q];return l?{type:l.type,style:l.style,content:q}:{type:"variable",
style:"js-variable",content:q}}function f(q){var l="/*";for(q=q=="*";;){if(c.endOfLine())break;var r=c.next();if(r=="/"&&q){l=null;break}q=r=="*"}b(l);return{type:"comment",style:"js-comment"}}function h(){c.nextWhileMatches(s);return{type:"operator",style:"js-operator"}}function i(q){var l=g(c,q);b(l?q:null);return{type:"string",style:"js-string"}}if(a=='"'||a=="'")return i(a);var j=c.next();if(a=="/*")return f(j);else if(j=='"'||j=="'")return i(j);else if(/[\[\]{}\(\),;\:\.]/.test(j))return{type:j,
style:"js-punctuation"};else if(j=="0"&&(c.equals("x")||c.equals("X"))){c.next();c.nextWhileMatches(n);return{type:"number",style:"js-atom"}}else if(/[0-9]/.test(j)){c.nextWhileMatches(/[0-9]/);if(c.equals(".")){c.next();c.nextWhileMatches(/[0-9]/)}if(c.equals("e")||c.equals("E")){c.next();c.equals("-")&&c.next();c.nextWhileMatches(/[0-9]/)}return{type:"number",style:"js-atom"}}else if(j=="/")if(c.equals("*")){c.next();return f(j)}else if(c.equals("/")){g(c,null);return{type:"comment",style:"js-comment"}}else{if(d){g(c,
"/");c.nextWhileMatches(/[gimy]/);a={type:"regexp",style:"js-string"}}else a=h();return a}else return s.test(j)?h():e()}var m=function(){function a(h,i){return{type:h,style:"js-"+i}}var d=a("keyword a","keyword"),c=a("keyword b","keyword"),b=a("keyword c","keyword"),e=a("operator","keyword"),f=a("atom","atom");return{"if":d,"while":d,"with":d,"else":c,"do":c,"try":c,"finally":c,"return":b,"break":b,"continue":b,"new":b,"delete":b,"throw":b,"in":e,"typeof":e,"instanceof":e,"var":a("var","keyword"),
"function":a("function","keyword"),"catch":a("catch","keyword"),"for":a("for","keyword"),"switch":a("switch","keyword"),"case":a("case","keyword"),"default":a("default","keyword"),"true":f,"false":f,"null":f,undefined:f,NaN:f,Infinity:f}}(),s=/[+\-*&%=<>!?|]/,n=/[0-9A-Fa-f]/,t=/[\w\$_]/;return function(a,d){return tokenizer(a,d||p(false,true))}}();var JSParser=Editor.Parser=function(){function g(s,n,t,a,d,c){this.indented=s;this.column=n;this.type=t;if(a!=null)this.align=a;this.prev=d;this.info=c}function p(s){return function(n){var t=n&&n.charAt(0),a=s.type,d=t==a;return a=="vardef"?s.indented+4:a=="form"&&t=="{"?s.indented:a=="stat"||a=="form"?s.indented+indentUnit:s.info=="switch"&&!d?s.indented+(/^(?:case|default)\b/.test(n)?indentUnit:2*indentUnit):s.align?s.column-(d?1:0):s.indented+(d?0:indentUnit)}}var k={atom:true,number:true,variable:true,
string:true,regexp:true},m=false;return{make:function(s,n){function t(u){for(var B=u.length-1;B>=0;B--)y.push(u[B])}function a(){t(arguments);S=true}function d(){t(arguments);S=false}function c(){C={prev:C,vars:{"this":true,arguments:true}}}function b(){C=C.prev}function e(u){if(C){Q="js-variabledef";C.vars[u]=true}}function f(u,B){var P=function(){E=new g(O,I,u,null,E,B)};P.lex=true;return P}function h(){if(E.type==")")O=E.indented;E=E.prev}function i(u){return function(B){if(B==u)a();else u==";"?
d():a(arguments.callee)}}function j(){return d(l,j)}function q(){return d(r,q)}function l(u){if(u=="var")a(f("vardef"),K,i(";"),h);else if(u=="keyword a")a(f("form"),r,l,h);else if(u=="keyword b")a(f("form"),l,h);else if(u=="{")a(f("}"),H,h);else if(u==";")a();else if(u=="function")a(z);else if(u=="for")a(f("form"),i("("),f(")"),F,i(")"),h,l,h);else if(u=="variable")a(f("stat"),w);else if(u=="switch")a(f("form"),r,f("}","switch"),i("{"),H,h,h);else if(u=="case")a(r,i(":"));else if(u=="default")a(i(":"));
else u=="catch"?a(f("form"),c,i("("),M,i(")"),l,h,b):d(f("stat"),r,i(";"),h)}function r(u){if(k.hasOwnProperty(u))a(o);else if(u=="function")a(z);else if(u=="keyword c")a(r);else if(u=="(")a(f(")"),r,i(")"),h,o);else if(u=="operator")a(r);else if(u=="[")a(f("]"),x(r,"]"),h,o);else u=="{"?a(f("}"),x(v,"}"),h,o):a()}function o(u,B){if(u=="operator"&&/\+\+|--/.test(B))a(o);else if(u=="operator")a(r);else if(u==";")d();else if(u=="(")a(f(")"),x(r,")"),h,o);else if(u==".")a(A,o);else u=="["&&a(f("]"),
r,i("]"),h,o)}function w(u){u==":"?a(h,l):d(o,i(";"),h)}function A(u){if(u=="variable"){Q="js-property";a()}}function v(u){if(u=="variable")Q="js-property";k.hasOwnProperty(u)&&a(i(":"),r)}function x(u,B){function P(R){if(R==",")a(u,P);else R==B?a():a(i(B))}return function(R){R==B?a():d(u,P)}}function H(u){u=="}"?a():d(l,H)}function K(u,B){if(u=="variable"){e(B);a(L)}else a()}function L(u,B){if(B=="=")a(r,L);else u==","&&a(K)}function F(u){if(u=="var")a(K,G);else if(u==";")d(G);else u=="variable"?
a(N):d(G)}function N(u,B){B=="in"?a(r):a(o,G)}function G(u,B){if(u==";")a(D);else B=="in"?a(r):a(r,i(";"),D)}function D(u){u==")"?d():a(r)}function z(u,B){if(u=="variable"){e(B);a(z)}else u=="("&&a(c,x(M,")"),l,b)}function M(u,B){if(u=="variable"){e(B);a()}}var J=tokenizeJavaScript(s),y=[m?q:j],C=null,E=new g((n||0)-indentUnit,0,"block",false),I=0,O=0,S,Q,T={next:function(){for(;y[y.length-1].lex;)y.pop()();var u=J.next();if(u.type=="whitespace"&&I==0)O=u.value.length;I+=u.value.length;if(u.content==
"\n"){O=I=0;if(!("align"in E))E.align=false;u.indentation=p(E)}if(u.type=="whitespace"||u.type=="comment")return u;if(!("align"in E))E.align=true;for(;;){S=Q=false;y.pop()(u.type,u.content);if(S){if(Q)u.style=Q;else{var B;if(B=u.type=="variable")a:{for(B=C;B;){if(B.vars[u.content]){B=true;break a}B=B.prev}B=false}if(B)u.style="js-localvariable"}return u}}},copy:function(){var u=C,B=E,P=y.concat([]),R=J.state;return function(U){C=u;E=B;y=P.concat([]);I=O=0;J=tokenizeJavaScript(U,R);return T}}};h.lex=
true;return T},electricChars:"{}:",configure:function(s){if(s.json!=null)m=s.json}}}();var XMLParser=Editor.Parser=function(){var g={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}},p={autoSelfClosers:{},doNotIndent:{"!cdata":true}},k=g,m=false,s=function(){function n(c,b){var e=c.next();if(e=="<")if(c.equals("!")){c.next();if(c.equals("["))if(c.lookAhead("[CDATA[",true)){b(d("xml-cdata","]]\>"));return null}else return"xml-text";else if(c.lookAhead("--",true)){b(d("xml-comment","--\>"));
return null}else if(c.lookAhead("DOCTYPE",true)){c.nextWhileMatches(/[\w\._\-]/);b(d("xml-doctype",">"));return"xml-doctype"}else return"xml-text"}else if(c.equals("?")){c.next();c.nextWhileMatches(/[\w\._\-]/);b(d("xml-processing","?>"));return"xml-processing"}else{c.equals("/")&&c.next();b(t);return"xml-punctuation"}else if(e=="&"){for(;!c.endOfLine();)if(c.next()==";")break;return"xml-entity"}else{c.nextWhileMatches(/[^&<\n]/);return"xml-text"}}function t(c,b){var e=c.next();if(e==">"){b(n);return"xml-punctuation"}else if(/[?\/]/.test(e)&&
c.equals(">")){c.next();b(n);return"xml-punctuation"}else if(e=="=")return"xml-punctuation";else if(/[\'\"]/.test(e)){b(a(e));return null}else{c.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}}function a(c){return function(b,e){for(;!b.endOfLine();)if(b.next()==c){e(t);break}return"xml-attribute"}}function d(c,b){return function(e,f){for(;!e.endOfLine();){if(e.lookAhead(b,true)){f(n);break}e.next()}return c}}return function(c,b){return tokenizer(c,b||n)}}();return{make:function(n){function t(D){for(var z=
D.length-1;z>=0;z--)x.push(D[z])}function a(){t(arguments);N=true}function d(){t(arguments);N=false}function c(){v.style+=" xml-error"}function b(D){return function(z,M){if(M==D)a();else{c();a(arguments.callee)}}}function e(D,z){var M=k.doNotIndent.hasOwnProperty(D)||F&&F.noIndent;F={prev:F,name:D,indent:K,startOfLine:z,noIndent:M}}function f(D){return function(z,M){var J=D;if(J&&J.noIndent)return M;if(m&&/<!\[CDATA\[/.test(z))return 0;if(J&&/^<\//.test(z))J=J.prev;for(;J&&!J.startOfLine;)J=J.prev;
return J?J.indent+indentUnit:0}}function h(){return d(i,h)}function i(D,z){if(z=="<")a(j,r,l(H==1));else if(z=="</")a(q,b(">"));else{if(D=="xml-cdata"){if(!F||F.name!="!cdata")e("!cdata");if(/\]\]>$/.test(z))F=F.prev}else G.hasOwnProperty(D)||c();a()}}function j(D,z){if(D=="xml-name"){L=z.toLowerCase();v.style="xml-tagname";a()}else{L=null;d()}}function q(D,z){if(D=="xml-name"){v.style="xml-tagname";if(F&&z.toLowerCase()==F.name)F=F.prev;else c()}a()}function l(D){return function(z,M){if(M=="/>"||
M==">"&&k.autoSelfClosers.hasOwnProperty(L))a();else if(M==">"){e(L,D);a()}else{c();a(arguments.callee)}}}function r(D){if(D=="xml-name"){v.style="xml-attname";a(o,r)}else d()}function o(D,z){if(z=="=")a(w);else z==">"||z=="/>"?d(l):d()}function w(D){D=="xml-attribute"?a(w):d()}var A=s(n),v,x=[h],H=0,K=0,L=null,F=null,N,G={"xml-text":true,"xml-entity":true,"xml-comment":true,"xml-processing":true,"xml-doctype":true};return{indentation:function(){return K},next:function(){v=A.next();if(v.style=="whitespace"&&
H==0)K=v.value.length;else H++;if(v.content=="\n"){K=H=0;v.indentation=f(F)}if(v.style=="whitespace"||v.type=="xml-comment")return v;for(;;){N=false;x.pop()(v.style,v.content);if(N)return v}},copy:function(){var D=x.concat([]),z=A.state,M=F,J=this;return function(y){x=D.concat([]);H=K=0;F=M;A=s(y,z);return J}}}},electricChars:"/",configure:function(n){if(n.useHTMLKludges!=null)k=n.useHTMLKludges?g:p;if(n.alignCDATA)m=n.alignCDATA}}}();var CSSParser=Editor.Parser=function(){function g(k,m,s){return function(n){return!k||/^\}/.test(n)?s:m?s+indentUnit*2:s+indentUnit}}var p=function(){function k(t,a){var d=t.next();if(d=="@"){t.nextWhileMatches(/\w/);return"css-at"}else if(d=="/"&&t.equals("*")){a(m);return null}else if(d=="<"&&t.equals("!")){a(s);return null}else if(d=="=")return"css-compare";else if(t.equals("=")&&(d=="~"||d=="|")){t.next();return"css-compare"}else if(d=='"'||d=="'"){a(n(d));return null}else if(d=="#"){t.nextWhileMatches(/\w/);
return"css-hash"}else if(d=="!"){t.nextWhileMatches(/[ \t]/);t.nextWhileMatches(/\w/);return"css-important"}else if(/\d/.test(d)){t.nextWhileMatches(/[\w.%]/);return"css-unit"}else if(/[,.+>*\/]/.test(d))return"css-select-op";else if(/[;{}:\[\]]/.test(d))return"css-punctuation";else{t.nextWhileMatches(/[\w\\\-_]/);return"css-identifier"}}function m(t,a){for(var d=false;!t.endOfLine();){var c=t.next();if(d&&c=="/"){a(k);break}d=c=="*"}return"css-comment"}function s(t,a){for(var d=0;!t.endOfLine();){var c=
t.next();if(d>=2&&c==">"){a(k);break}d=c=="-"?d+1:0}return"css-comment"}function n(t){return function(a,d){for(var c=false;!a.endOfLine();){var b=a.next();if(b==t&&!c)break;c=!c&&b=="\\"}c||d(k);return"css-string"}}return function(t,a){return tokenizer(t,a||k)}}();return{make:function(k,m){m=m||0;var s=p(k),n=false,t=false,a=false,d={next:function(){var c=s.next(),b=c.style,e=c.content;if(b=="css-hash")b=c.style=t?"css-colorcode":"css-identifier";if(b=="css-identifier")if(t)c.style="css-value";else if(!n&&
!a)c.style="css-selector";if(e=="\n")c.indentation=g(n,t,m);if(e=="{"&&a=="@media")a=false;else if(e=="{")n=true;else if(e=="}")n=t=a=false;else if(e==";")t=a=false;else if(n&&b!="css-comment"&&b!="whitespace")t=true;else if(!n&&b=="css-at")a=e;return c},copy:function(){var c=n,b=t,e=s.state;return function(f){s=p(f,e);n=c;t=b;return d}}};return d},electricChars:"}"}}();var HTMLMixedParser=Editor.Parser=function(){function g(){var k=["XMLParser"],m;for(m in p)k.push(p[m]);for(var s in k)if(!window[k[s]])throw Error(k[s]+" parser must be loaded for HTML mixed mode to work.");XMLParser.configure({useHTMLKludges:true})}var p={script:"JSParser",style:"CSSParser"};return{make:function(k){function m(){var c=n.next();if(c.content=="<")a=true;else if(c.style=="xml-tagname"&&a===true)a=c.content.toLowerCase();else if(c.content==">"){if(p[a])d.next=s(window[p[a]],"</"+a);
a=false}return c}function s(c,b){var e=n.indentation();t=c.make(k,e+indentUnit);return function(){if(k.lookAhead(b,false,false,true)){t=null;d.next=m;return m()}var f=t.next(),h=f.value.lastIndexOf("<"),i=Math.min(f.value.length-h,b.length);if(h!=-1&&f.value.slice(h,h+i).toLowerCase()==b.slice(0,i)&&k.lookAhead(b.slice(i),false,false,true)){k.push(f.value.slice(h));f.value=f.value.slice(0,h)}if(f.indentation){var j=f.indentation;f.indentation=function(q){return q=="</"?e:j(q)}}return f}}g();var n=
XMLParser.make(k),t=null,a=false,d={next:m,copy:function(){var c=n.copy(),b=t&&t.copy(),e=d.next,f=a;return function(h){k=h;n=c(h);t=b&&b(h);d.next=e;a=f;return d}}};return d},electricChars:"{}/:",configure:function(k){if(k.triggers)p=k.triggers}}}();var DummyParser=Editor.Parser=function(){function g(p){for(;!p.endOfLine();)p.next();return"text"}return{make:function(p){function k(n){return function(){return n}}p=tokenizer(p,g);var m=0,s={next:function(){var n=p.next();if(n.type=="whitespace")if(n.value=="\n")n.indentation=k(m);else m=n.value.length;return n},copy:function(){var n=m;return function(t){m=n;p=tokenizer(t,g);return s}}};return s}}}();var LiquidParser=Editor.Parser=function(){var g={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}},p={autoSelfClosers:{},doNotIndent:{"!cdata":true}},k=g,m=false,s=/[\'\"]/,n=/[\w\_]/,t=/[\.\|\=\:]/,a={};["in"].forEach(function(c){a[c]=true});var d=function(){function c(l,r){var o=l.next();if(o=="<")if(l.equals("!")){l.next();if(l.equals("["))if(l.lookAhead("[CDATA[",true)){r(q("xml-cdata","]]\>"));
return null}else return"xml-text";else if(l.lookAhead("--",true)){r(q("xml-comment","--\>"));return null}else return"xml-text"}else if(l.equals("?")){l.next();l.nextWhileMatches(/[\w\._\-]/);r(q("xml-processing","?>"));return"xml-processing"}else{l.equals("/")&&l.next();r(b);return"xml-punctuation"}else if(o=="{"){if(l.equals("{")){l.next();r(e);return"liquid-punctuation"}if(l.equals("%")){l.next();r(f);return"liquid-punctuation"}else return"xml-text"}else if(o=="&"){for(;!l.endOfLine();)if(l.next()==
";")break;return"xml-entity"}else{l.nextWhileMatches(/[^{&<\n]/);return"xml-text"}}function b(l,r){var o=l.next();if(o==">"){r(c);return"xml-punctuation"}else if(/[?\/]/.test(o)&&l.equals(">")){l.next();r(c);return"xml-punctuation"}else if(o=="=")return"xml-punctuation";else if(/[\'\"]/.test(o)){r(j(o));return null}else{l.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}}function e(l,r){var o=l.next();if(o=="}")if(l.equals("}")){l.next();r(c);return"liquid-punctuation"}else{r(c);return"liquid-bad-punctuation"}else if(s.test(o)){r(i(o,
e));return null}else if(t.test(o))return"liquid-punctuation";return"liquid-text"}function f(l,r){l.nextWhileMatches(n);r(h);return"liquid-tag-name"}function h(l,r){var o=l.next();if(o=="%")if(l.equals("}")){l.next();r(c);return"liquid-punctuation"}else{r(c);return"liquid-bad-punctuation"}else if(s.test(o)){r(i(o,h));return null}else{if(t.test(o))o="liquid-punctuation";else{o=a;l.nextWhileMatches(n);var w=l.get();o=o&&o.propertyIsEnumerable(w)?{type:"string",style:"liquid-keyword",content:w}:{type:"string",
style:"liquid-text",content:w}}return o}}function i(l,r){return function(o,w){for(;!o.endOfLine();)if(o.next()==l){w(r);break}return"liquid-string"}}function j(l){return function(r,o){for(;!r.endOfLine();)if(r.next()==l){o(b);break}return"xml-attribute"}}function q(l,r){return function(o,w){for(;!o.endOfLine();){if(o.lookAhead(r,true)){w(c);break}o.next()}return l}}return function(l,r){return tokenizer(l,r||c)}}();return{make:function(c){function b(y){for(var C=y.length-1;C>=0;C--)K.push(y[C])}function e(){b(arguments);
D=true}function f(){b(arguments);D=false}function h(y){return function(C,E){if(E==y)e();else{z="xml-error";e(arguments.callee)}}}function i(y,C){var E=k.doNotIndent.hasOwnProperty(y)||G&&G.noIndent;G={prev:G,name:y,indent:F,startOfLine:C,noIndent:E}}function j(y){return function(C,E){var I=y;if(I&&I.noIndent)return E;if(m&&/<!\[CDATA\[/.test(C))return 0;if(I&&/^<\//.test(C))I=I.prev;for(;I&&!I.startOfLine;)I=I.prev;return I?I.indent+indentUnit:0}}function q(){return f(l,q)}function l(y,C){if(C=="<")e(r,
A,w(L==1));else if(C=="</")e(o,h(">"));else{if(y=="xml-cdata"){if(!G||G.name!="!cdata")i("!cdata");if(/\]\]>$/.test(C))G=G.prev}else M.hasOwnProperty(y)||J.hasOwnProperty(y)||(z="xml-error");e()}}function r(y,C){if(y=="xml-name"){N=C.toLowerCase();z="xml-tagname";e()}else{N=null;f()}}function o(y,C){if(y=="xml-name"&&G&&C.toLowerCase()==G.name){G=G.prev;z="xml-tagname"}else z="xml-error";e()}function w(y){return function(C,E){if(E=="/>"||E==">"&&k.autoSelfClosers.hasOwnProperty(N))e();else if(E==
">")i(N,y)||e();else{z="xml-error";e(arguments.callee)}}}function A(y){if(y=="xml-name"){z="xml-attname";e(v,A)}else f()}function v(y,C){if(C=="=")e(x);else C==">"||C=="/>"?f(w):f()}function x(y){y=="xml-attribute"?e(x):f()}var H=d(c),K=[q],L=0,F=0,N=null,G=null,D,z,M={"xml-text":true,"xml-entity":true,"xml-comment":true,"xml-processing":true},J={"liquid-punctuation":true,"liquid-bad-punctuation":true,"liquid-keyword":true,"liquid-tag-name":true,"liquid-variable":true,"liquid-text":true,"liquid-string":true};
return{indentation:function(){return F},next:function(){var y=H.next();if(y.style=="whitespace"&&L==0)F=y.value.length;else L++;if(y.content=="\n"){F=L=0;y.indentation=j(G)}if(y.style=="whitespace"||y.type=="xml-comment")return y;for(;;){D=z=false;K.pop()(y.style,y.content);if(D){if(z)y.style=z;return y}}},copy:function(){var y=K.concat([]),C=H.state,E=G,I=this;return function(O){K=y.concat([]);L=F=0;G=E;H=d(O,C);return I}}}},electricChars:"/",configure:function(c){if(c.useHTMLKludges!=null)k=c.useHTMLKludges?
g:p;if(c.alignCDATA)m=c.alignCDATA}}}();