text: ﻿window.CodeMirror=function(){function l(a,b){if(!(this instanceof l))return new l(a,b);this.options=b=b||{};for(var c in Hb)!b.hasOwnProperty(c)&&Hb.hasOwnProperty(c)&&(b[c]=Hb[c]);Ib(b);c=this.display=Fd(a,"string"==typeof b.value?0:b.value.first);c.wrapper.CodeMirror=this;Ac(this);b.autofocus&&!Jb&&G(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,draggingText:!1,highlight:new Kb};Bc(this);b.lineWrapping&&(this.display.wrapper.className+=
  " CodeMirror-wrap");var d=b.value;"string"==typeof d&&(d=new F(b.value,b.mode));p(this,Cc)(this,d);B&&setTimeout(K(W,this,!0),20);Gd(this);var e;try{e=document.activeElement==c.input}catch(f){}e||b.autofocus&&!Jb?setTimeout(K($,this),20):Lb(this);p(this,function(){for(var a in ia)if(ia.propertyIsEnumerable(a))ia[a](this,b[a],Dc);for(a=0;a<Mb.length;++a)Mb[a](this)})()}function Fd(a,b){var c={},d=c.input=n("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none; font-size: 4px;");
  L?d.style.width="1000px":d.setAttribute("wrap","off");Ba&&(d.style.border="1px solid black");d.setAttribute("autocorrect","off");d.setAttribute("autocapitalize","off");d.setAttribute("spellcheck","false");c.inputDiv=n("div",[d],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");c.scrollbarH=n("div",[n("div",null,null,"height: 1px")],"CodeMirror-hscrollbar");c.scrollbarV=n("div",[n("div",null,null,"width: 1px")],"CodeMirror-vscrollbar");c.scrollbarFiller=n("div",null,"CodeMirror-scrollbar-filler");
  c.gutterFiller=n("div",null,"CodeMirror-gutter-filler");c.lineDiv=n("div",null,"CodeMirror-code");c.selectionDiv=n("div",null,null,"position: relative; z-index: 1");c.cursor=n("div"," ","CodeMirror-cursor");c.otherCursor=n("div"," ","CodeMirror-cursor CodeMirror-secondarycursor");c.measure=n("div",null,"CodeMirror-measure");c.lineSpace=n("div",[c.measure,c.selectionDiv,c.lineDiv,c.cursor,c.otherCursor],null,"position: relative; outline: none");c.mover=n("div",[n("div",[c.lineSpace],"CodeMirror-lines")],
  null,"position: relative");c.sizer=n("div",[c.mover],"CodeMirror-sizer");c.heightForcer=n("div",null,null,"position: absolute; height: "+ja+"px; width: 1px;");c.gutters=n("div",null,"CodeMirror-gutters");c.lineGutter=null;c.scroller=n("div",[c.sizer,c.heightForcer,c.gutters],"CodeMirror-scroll");c.scroller.setAttribute("tabIndex","-1");c.wrapper=n("div",[c.inputDiv,c.scrollbarH,c.scrollbarV,c.scrollbarFiller,c.gutterFiller,c.scroller],"CodeMirror");ka&&(c.gutters.style.zIndex=-1,c.scroller.style.paddingRight=
  0);a.appendChild?a.appendChild(c.wrapper):a(c.wrapper);Ba&&(d.style.width="0px");L||(c.scroller.draggable=!0);Nb?(c.inputDiv.style.height="1px",c.inputDiv.style.position="absolute"):ka&&(c.scrollbarH.style.minWidth=c.scrollbarV.style.minWidth="18px");c.viewOffset=c.lastSizeC=0;c.showingFrom=c.showingTo=b;c.lineNumWidth=c.lineNumInnerWidth=c.lineNumChars=null;c.prevInput="";c.alignWidgets=!1;c.pollingFast=!1;c.poll=new Kb;c.cachedCharWidth=c.cachedTextHeight=null;c.measureLineCache=[];c.measureLineCachePos=
  0;c.inaccurateSelection=!1;c.maxLine=null;c.maxLineLength=0;c.maxLineChanged=!1;c.wheelDX=c.wheelDY=c.wheelStartX=c.wheelStartY=null;return c}function Ca(a){a.doc.mode=l.getMode(a.options,a.doc.modeOption);a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.frontier=a.doc.first;$a(a,100);a.state.modeGen++;a.curOp&&u(a)}function Ec(a){var b=Da(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/Fc(a.display)-3);return function(e){return aa(a.doc,
  e)?0:c?(Math.ceil(e.text.length/d)||1)*b:b}}function Gc(a){var b=a.doc,c=Ec(a);b.iter(function(a){var b=c(a);b!=a.height&&M(a,b)})}function Bc(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");la(a)}function Ea(a){Ac(a);u(a);setTimeout(function(){Ob(a)},20)}function Ac(a){var b=a.display.gutters,c=a.options.gutters;ab(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(n("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==
  e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none"}function bb(a,b){if(0==b.height)return 0;for(var c=b.text.length,d,e=b;d=ba(e,-1);)d=d.find(),e=q(a,d.from.line),c+=d.from.ch-d.to.ch;for(e=b;d=Fa(e);)d=d.find(),c-=e.text.length-d.from.ch,e=q(a,d.to.line),c+=e.text.length-d.to.ch;return c}function Pb(a){var b=a.display,c=a.doc;b.maxLine=q(c,c.first);b.maxLineLength=bb(c,b.maxLine);b.maxLineChanged=!0;c.iter(function(a){var e=bb(c,a);e>b.maxLineLength&&
  (b.maxLineLength=e,b.maxLine=a)})}function Ib(a){for(var b=!1,c=0;c<a.gutters.length;++c)"CodeMirror-linenumbers"==a.gutters[c]&&(a.lineNumbers?b=!0:a.gutters.splice(c--,1));!b&&a.lineNumbers&&a.gutters.push("CodeMirror-linenumbers")}function Qb(a){var b=a.display,c=a.doc.height+(b.mover.offsetHeight-b.lineSpace.offsetHeight);b.sizer.style.minHeight=b.heightForcer.style.top=c+"px";b.gutters.style.height=Math.max(c,b.scroller.clientHeight-ja)+"px";var c=Math.max(c,b.scroller.scrollHeight),d=b.scroller.scrollWidth>
  b.scroller.clientWidth,e=c>b.scroller.clientHeight;e?(b.scrollbarV.style.display="block",b.scrollbarV.style.bottom=d?Ga(b.measure)+"px":"0",b.scrollbarV.firstChild.style.height=c-b.scroller.clientHeight+b.scrollbarV.clientHeight+"px"):b.scrollbarV.style.display="";d?(b.scrollbarH.style.display="block",b.scrollbarH.style.right=e?Ga(b.measure)+"px":"0",b.scrollbarH.firstChild.style.width=b.scroller.scrollWidth-b.scroller.clientWidth+b.scrollbarH.clientWidth+"px"):b.scrollbarH.style.display="";d&&e?
  (b.scrollbarFiller.style.display="block",b.scrollbarFiller.style.height=b.scrollbarFiller.style.width=Ga(b.measure)+"px"):b.scrollbarFiller.style.display="";d&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(b.gutterFiller.style.display="block",b.gutterFiller.style.height=Ga(b.measure)+"px",b.gutterFiller.style.width=b.gutters.offsetWidth+"px"):b.gutterFiller.style.display="";Hd&&0===Ga(b.measure)&&(b.scrollbarV.style.minWidth=b.scrollbarH.style.minHeight=Id?"18px":"12px")}function Rb(a,
  b,c){var d=a.scroller.scrollTop,e=a.wrapper.clientHeight;"number"==typeof c?d=c:c&&(d=c.top,e=c.bottom-c.top);d=Math.floor(d-a.lineSpace.offsetTop);a=Math.ceil(d+e);return{from:cb(b,d),to:cb(b,a)}}function Ob(a){var b=a.display;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var c=Sb(b)-b.scroller.scrollLeft+a.doc.scrollLeft,d=b.gutters.offsetWidth,e=c+"px",f=b.lineDiv.firstChild;f;f=f.nextSibling)if(f.alignable)for(var g=0,h=f.alignable;g<h.length;++g)h[g].style.left=e;a.options.fixedGutter&&
  (b.gutters.style.left=c+d+"px")}}function Jd(a){if(!a.options.lineNumbers)return!1;var b=a.doc,b=""+a.options.lineNumberFormatter(b.first+b.size-1+a.options.firstLineNumber),a=a.display;if(b.length!=a.lineNumChars){var c=a.measure.appendChild(n("div",[n("div",b)],"CodeMirror-linenumber CodeMirror-gutter-elt")),d=c.firstChild.offsetWidth,c=c.offsetWidth-d;a.lineGutter.style.width="";a.lineNumInnerWidth=Math.max(d,a.lineGutter.offsetWidth-c);a.lineNumWidth=a.lineNumInnerWidth+c;a.lineNumChars=a.lineNumInnerWidth?
  b.length:-1;a.lineGutter.style.width=a.lineNumWidth+"px";return!0}return!1}function Sb(a){return y(a.scroller).left-y(a.sizer).left}function db(a,b,c){for(var d=a.display.showingFrom,e=a.display.showingTo,f,g=Rb(a.display,a.doc,c);Kd(a,b,g);){f=!0;Tb(a);Qb(a);c&&(c=Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,"number"==typeof c?c:c.top));g=Rb(a.display,a.doc,c);if(g.from>=a.display.showingFrom&&g.to<=a.display.showingTo)break;b=[]}f&&(O(a,"update",a),(a.display.showingFrom!=
  d||a.display.showingTo!=e)&&O(a,"viewportChange",a,a.display.showingFrom,a.display.showingTo));return f}function Kd(a,b,c){var d=a.display,e=a.doc;if(d.wrapper.clientWidth){if(!(0==b.length&&c.from>d.showingFrom&&c.to<d.showingTo)){Jd(a)&&(b=[{from:e.first,to:e.first+e.size}]);var f=d.sizer.style.marginLeft=d.gutters.offsetWidth+"px";d.scrollbarH.style.left=a.options.fixedGutter?f:"0";var g=Infinity;if(a.options.lineNumbers)for(f=0;f<b.length;++f)if(b[f].diff){g=b[f].from;break}var f=e.first+e.size,
  h=Math.max(c.from-a.options.viewportMargin,e.first),c=Math.min(f,c.to+a.options.viewportMargin);d.showingFrom<h&&20>h-d.showingFrom&&(h=Math.max(e.first,d.showingFrom));d.showingTo>c&&20>d.showingTo-c&&(c=Math.min(f,d.showingTo));if(Ha)for(h=H(ma(e,q(e,h)));c<f&&aa(e,q(e,c));)++c;var i=[{from:Math.max(d.showingFrom,e.first),to:Math.min(d.showingTo,f)}],i=i[0].from>=i[0].to?[]:Ld(i,b);if(Ha)for(f=0;f<i.length;++f)for(var b=i[f],j;j=Fa(q(e,b.to-1));)if(j=j.find().from.line,j>b.from)b.to=j;else{i.splice(f--,
  1);break}for(f=e=0;f<i.length;++f)b=i[f],b.from<h&&(b.from=h),b.to>c&&(b.to=c),b.from>=b.to?i.splice(f--,1):e+=b.to-b.from;if(e==c-h&&h==d.showingFrom&&c==d.showingTo)Hc(a);else{i.sort(function(a,b){return a.from-b.from});try{var k=document.activeElement}catch(m){}e<0.7*(c-h)&&(d.lineDiv.style.display="none");Md(a,h,c,i,g);d.lineDiv.style.display="";k&&(document.activeElement!=k&&k.offsetHeight)&&k.focus();if(h!=d.showingFrom||c!=d.showingTo||d.lastSizeC!=d.wrapper.clientHeight)d.lastSizeC=d.wrapper.clientHeight;
  d.showingFrom=h;d.showingTo=c;$a(a,100);k=d.lineDiv.offsetTop;for(e=d.lineDiv.firstChild;e;e=e.nextSibling)if(e.lineObj&&(ka?(g=e.offsetTop+e.offsetHeight,f=g-k,k=g):(f=y(e),f=f.bottom-f.top),g=e.lineObj.height-f,2>f&&(f=Da(d)),0.001<g||-0.001>g))if(M(e.lineObj,f),g=e.lineObj.widgets)for(f=0;f<g.length;++f)g[f].height=g[f].node.offsetHeight;Hc(a);return!0}}}else d.showingFrom=d.showingTo=e.first,d.viewOffset=0}function Hc(a){var b=a.display.viewOffset=na(a,q(a.doc,a.display.showingFrom));a.display.mover.style.top=
  b+"px"}function Ld(a,b){for(var c=0,d=b.length||0;c<d;++c){for(var e=b[c],f=[],g=e.diff||0,h=0,i=a.length;h<i;++h){var j=a[h];e.to<=j.from&&e.diff?f.push({from:j.from+g,to:j.to+g}):e.to<=j.from||e.from>=j.to?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g}))}a=f}return a}function Nd(a){for(var b=a.display,c={},d={},e=b.gutters.firstChild,f=0;e;e=e.nextSibling,++f)c[a.options.gutters[f]]=e.offsetLeft,d[a.options.gutters[f]]=e.offsetWidth;return{fixedPos:Sb(b),
  gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function Md(a,b,c,d,e){function f(b){var c=b.nextSibling;L&&oa&&a.display.currentWheelTarget==b?(b.style.display="none",b.lineObj=null):b.parentNode.removeChild(b);return c}var g=Nd(a),h=a.display,i=a.options.lineNumbers;!d.length&&(!L||!a.display.currentWheelTarget)&&ab(h.lineDiv);var j=h.lineDiv,k=j.firstChild,m=d.shift(),s=b;for(a.doc.iter(b,c,function(b){m&&m.to==s&&(m=d.shift());if(aa(a.doc,
  b)){if(0!=b.height&&M(b,0),b.widgets&&k.previousSibling)for(var c=0;c<b.widgets.length;++c)if(b.widgets[c].showIfHidden){var h=k.previousSibling;if(/pre/i.test(h.nodeName)){var l=n("div",null,null,"position: relative");h.parentNode.replaceChild(l,h);l.appendChild(h);h=l}l=h.appendChild(n("div",[b.widgets[c].node],"CodeMirror-linewidget"));Ub(b.widgets[c],l,h,g)}}else if(m&&m.from<=s&&m.to>s){for(;k.lineObj!=b;)k=f(k);i&&(e<=s&&k.lineNumber)&&Ic(k.lineNumber,""+a.options.lineNumberFormatter(s+a.options.firstLineNumber));
  k=k.nextSibling}else{if(b.widgets)for(var o=0,q=k;q&&20>o;++o,q=q.nextSibling)if(q.lineObj==b&&/div/i.test(q.nodeName)){c=q;break}var o=a,r=s,I=c,q=Vb(o,b),p=b.gutterMarkers,Od=o.display;if(!o.options.lineNumbers&&!p&&!b.bgClass&&!b.wrapClass&&!b.widgets)h=q;else{if(I){I.alignable=null;for(var t=!0,v=0,w=I.firstChild,x;w;w=x)if(x=w.nextSibling,/\bCodeMirror-linewidget\b/.test(w.className)){for(var y=0,B=!0;y<b.widgets.length;++y){var u=b.widgets[y],z=!1;u.above||(z=B,B=!1);if(u.node==w.firstChild){Ub(u,
  w,I,g);++v;z&&I.insertBefore(q,w);break}}if(y==b.widgets.length){t=!1;break}}else I.removeChild(w);t&&v==b.widgets.length&&(h=I,I.className=b.wrapClass||"")}h||(h=n("div",null,b.wrapClass,"position: relative"),h.appendChild(q));b.bgClass&&h.insertBefore(n("div",null,b.bgClass+" CodeMirror-linebackground"),h.firstChild);if(o.options.lineNumbers||p){l=h.insertBefore(n("div",null,null,"position: absolute; left: "+(o.options.fixedGutter?g.fixedPos:-g.gutterTotalWidth)+"px"),h.firstChild);o.options.fixedGutter&&
  (h.alignable||(h.alignable=[])).push(l);if(o.options.lineNumbers&&(!p||!p["CodeMirror-linenumbers"]))h.lineNumber=l.appendChild(n("div",""+o.options.lineNumberFormatter(r+o.options.firstLineNumber),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+g.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+Od.lineNumInnerWidth+"px"));if(p)for(y=0;y<o.options.gutters.length;++y)u=o.options.gutters[y],(r=p.hasOwnProperty(u)&&p[u])&&l.appendChild(n("div",[r],"CodeMirror-gutter-elt","left: "+g.gutterLeft[u]+
  "px; width: "+g.gutterWidth[u]+"px"))}ka&&(h.style.zIndex=2);if(b.widgets&&h!=I){y=0;for(I=b.widgets;y<I.length;++y)u=I[y],p=n("div",[u.node],"CodeMirror-linewidget"),Ub(u,p,h,g),u.above?h.insertBefore(p,o.options.lineNumbers&&0!=b.height?l:q):h.appendChild(p),O(u,"redraw")}}if(h!=c)j.insertBefore(h,k);else{for(;k!=c;)k=f(k);k=k.nextSibling}h.lineObj=b}++s});k;)k=f(k)}function Ub(a,b,c,d){a.noHScroll&&((c.alignable||(c.alignable=[])).push(b),c=d.wrapperWidth,b.style.left=d.fixedPos+"px",a.coverGutter||
  (c-=d.gutterTotalWidth,b.style.paddingLeft=d.gutterTotalWidth+"px"),b.style.width=c+"px");a.coverGutter&&(b.style.zIndex=5,b.style.position="relative",a.noHScroll||(b.style.marginLeft=-d.gutterTotalWidth+"px"))}function Tb(a){var b=a.display,c=w(a.doc.sel.from,a.doc.sel.to);if(c||a.options.showCursorWhenSelecting){var d=a.display,e=P(a,a.doc.sel.head,"div");d.cursor.style.left=e.left+"px";d.cursor.style.top=e.top+"px";d.cursor.style.height=Math.max(0,e.bottom-e.top)*a.options.cursorHeight+"px";d.cursor.style.display=
  "";e.other?(d.otherCursor.style.display="",d.otherCursor.style.left=e.other.left+"px",d.otherCursor.style.top=e.other.top+"px",d.otherCursor.style.height=0.85*(e.other.bottom-e.other.top)+"px"):d.otherCursor.style.display="none"}else b.cursor.style.display=b.otherCursor.style.display="none";c?b.selectionDiv.style.display="none":Pd(a);a.options.moveInputWithCursor&&(a=P(a,a.doc.sel.head,"div"),c=y(b.wrapper),d=y(b.lineDiv),b.inputDiv.style.top=Math.max(0,Math.min(b.wrapper.clientHeight-10,a.top+d.top-
  c.top))+"px",b.inputDiv.style.left=Math.max(0,Math.min(b.wrapper.clientWidth-10,a.left+d.left-c.left))+"px")}function Pd(a){function b(a,b,c,d){0>b&&(b=0);g.appendChild(n("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?h-a:c)+"px; height: "+(d-b)+"px"))}function c(c,d,f,g){var j=q(e,c),k=j.text.length,m=g?Infinity:-Infinity;Qd(Q(j),d||0,null==f?k:f,function(e,s,l){var q=eb(a,o(c,e),"div",j),n,p;e==s?(n=q,l=p=q.left):(n=eb(a,o(c,s-1),"div",j),"rtl"==
  l&&(l=q,q=n,n=l),l=q.left,p=n.right);3<n.top-q.top&&(b(l,q.top,null,q.bottom),l=i,q.bottom<n.top&&b(l,q.bottom,null,n.top));null==f&&s==k&&(p=h);null==d&&0==e&&(l=i);m=g?Math.min(n.top,m):Math.max(n.bottom,m);l<i+1&&(l=i);b(l,n.top,p-l,n.bottom)});return m}var d=a.display,e=a.doc,f=a.doc.sel,g=document.createDocumentFragment(),h=d.lineSpace.offsetWidth,i=R(a.display.measure,n("pre",null,null,"text-align: left")).appendChild(n("span","x")).offsetLeft;if(f.from.line==f.to.line)c(f.from.line,f.from.ch,
  f.to.ch);else{for(var j=q(e,f.from.line),k=j,m=[f.from.line,f.from.ch],s;k=Fa(k);){k=k.find();m.push(k.from.ch,k.to.line,k.to.ch);if(k.to.line==f.to.line){m.push(f.to.ch);s=!0;break}k=q(e,k.to.line)}if(s)for(f=0;f<m.length;f+=3)c(m[f],m[f+1],m[f+2]);else m=q(e,f.to.line),j=f.from.ch?c(f.from.line,f.from.ch,null,!1):na(a,j)-d.viewOffset,f=f.to.ch?c(f.to.line,ba(m,-1)?null:0,f.to.ch,!0):na(a,m)-d.viewOffset,j<f&&b(i,j,null,f)}R(d.selectionDiv,g);d.selectionDiv.style.display=""}function fb(a){if(a.state.focused){var b=
  a.display;clearInterval(b.blinker);var c=!0;b.cursor.style.visibility=b.otherCursor.style.visibility="";b.blinker=setInterval(function(){b.cursor.style.visibility=b.otherCursor.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate)}}function $a(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.showingTo&&a.state.highlight.set(b,K(Rd,a))}function Rd(a){var b=a.doc;b.frontier<b.first&&(b.frontier=b.first);if(!(b.frontier>=a.display.showingTo)){var c=+new Date+a.options.workTime,d=pa(b.mode,
  Ia(a,b.frontier)),e=[],f;b.iter(b.frontier,Math.min(b.first+b.size,a.display.showingTo+500),function(g){if(b.frontier>=a.display.showingFrom){var h=g.styles;g.styles=Lc(a,g,d);for(var i=!h||h.length!=g.styles.length,j=0;!i&&j<h.length;++j)i=h[j]!=g.styles[j];i&&(f&&f.end==b.frontier?f.end++:e.push(f={start:b.frontier,end:b.frontier+1}));g.stateAfter=pa(b.mode,d)}else{Mc(a,g,d);g.stateAfter=b.frontier%5==0?pa(b.mode,d):null}++b.frontier;if(+new Date>c){$a(a,a.options.workDelay);return true}});e.length&&
  p(a,function(){for(var a=0;a<e.length;++a)u(this,e[a].start,e[a].end)})()}}function Sd(a,b){for(var c,d,e=a.doc,f=b,g=b-100;f>g;--f){if(f<=e.first)return e.first;var h=q(e,f-1);if(h.stateAfter)return f;h=qa(h.text,null,a.options.tabSize);if(null==d||c>h)d=f-1,c=h}return d}function Ia(a,b){var c=a.doc,d=a.display;if(!c.mode.startState)return!0;var e=Sd(a,b),f=e>c.first&&q(c,e-1).stateAfter,f=f?pa(c.mode,f):Nc(c.mode);c.iter(e,b,function(g){Mc(a,g,f);g.stateAfter=e==b-1||0==e%5||e>=d.showingFrom&&e<
  d.showingTo?pa(c.mode,f):null;++e});return f}function Wb(a,b,c,d){for(var e=-1,d=d||Xb(a,b),a=c;;a+=e){var f=d[a];if(f)break;0>e&&0==a&&(e=1)}return{left:a<c?f.right:f.left,right:a>c?f.left:f.right,top:f.top,bottom:f.bottom}}function Yb(a,b){for(var c=a.display.measureLineCache,d=0;d<c.length;++d){var e=c[d];if(e.text==b.text&&e.markedSpans==b.markedSpans&&a.display.scroller.clientWidth==e.width&&e.classes==b.textClass+"|"+b.bgClass+"|"+b.wrapClass)return e}}function Td(a,b){var c=Yb(a,b);c&&(c.text=
  c.measure=c.markedSpans=null)}function Xb(a,b){var c=Yb(a,b);if(c)return c.measure;var d=a.display,e=Oc(b.text.length),f=Vb(a,b,e);if(B&&!ka&&!a.options.lineWrapping&&100<f.childNodes.length){for(var g=document.createDocumentFragment(),h=f.childNodes.length,c=0,i=Math.ceil(h/10);c<i;++c){for(var j=n("div",null,null,"display: inline-block"),k=0;10>k&&h;++k)j.appendChild(f.firstChild),--h;g.appendChild(j)}f.appendChild(g)}R(d.measure,f);i=y(d.lineDiv);h=[];g=Oc(b.text.length);j=f.offsetHeight;J&&d.measure.first!=
  f&&R(d.measure,f);for(c=0;c<e.length;++c)if(d=e[c]){for(var f=y(d),m=Math.max(0,f.top-i.top),s=Math.min(f.bottom-i.top,j),k=0;k<h.length;k+=2){var C=h[k],l=h[k+1];if(!(C>s||l<m))if(C<=m&&l>=s||m<=C&&s>=l||Math.min(s,l)-Math.max(m,C)>=s-m>>1){h[k]=Math.min(m,C);h[k+1]=Math.max(s,l);break}}k==h.length&&h.push(m,s);m=f.right;d.measureRight&&(m=y(d.measureRight).left);g[c]={left:f.left-i.left,right:m-i.left,top:k}}for(c=0;c<g.length;++c)if(d=g[c])e=d.top,d.top=h[e],d.bottom=h[e+1];c=a.display.measureLineCache;
  e={text:b.text,width:a.display.scroller.clientWidth,markedSpans:b.markedSpans,measure:g,classes:b.textClass+"|"+b.bgClass+"|"+b.wrapClass};16==c.length?c[++a.display.measureLineCachePos%16]=e:c.push(e);return g}function la(a){a.display.measureLineCache.length=a.display.measureLineCachePos=0;a.display.cachedCharWidth=a.display.cachedTextHeight=null;a.options.lineWrapping||(a.display.maxLineChanged=!0);a.display.lineNumChars=null}function Pc(a,b,c,d){if(b.widgets)for(var e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=
  gb(b.widgets[e]);c.top+=f;c.bottom+=f}if("line"==d)return c;d||(d="local");b=na(a,b);"local"!=d&&(b-=a.display.viewOffset);"page"==d&&(a=y(a.display.lineSpace),b+=a.top+(window.pageYOffset||(document.documentElement||document.body).scrollTop),a=a.left+(window.pageXOffset||(document.documentElement||document.body).scrollLeft),c.left+=a,c.right+=a);c.top+=b;c.bottom+=b;return c}function eb(a,b,c,d){d||(d=q(a.doc,b.line));return Pc(a,d,Wb(a,d,b.ch),c)}function P(a,b,c,d,e){function f(b,f){var g=Wb(a,
  d,b,e);f?g.left=g.right:g.right=g.left;return Pc(a,d,g,c)}function g(a,b){var c=h[b],d=c.level%2;a==(c.level%2?c.to:c.from)&&b&&c.level<h[b-1].level?(c=h[--b],a=Zb(c)-(c.level%2?0:1),d=!0):a==Zb(c)&&(b<h.length-1&&c.level<h[b+1].level)&&(c=h[++b],a=(c.level%2?c.to:c.from)-c.level%2,d=!1);return d&&a==c.to&&a>c.from?f(a-1):f(a,d)}d=d||q(a.doc,b.line);e||(e=Xb(a,d));var h=Q(d),b=b.ch;if(!h)return f(b);var i=$b(h,b),i=g(b,i);null!=ra&&(i.other=g(b,ra));return i}function hb(a,b,c){a=new o(a,b);c&&(a.outside=
  !0);return a}function ac(a,b,c){var d=a.doc,c=c+a.display.viewOffset;if(0>c)return hb(d.first,0,!0);var e=cb(d,c),f=d.first+d.size-1;if(e>f)return hb(d.first+d.size-1,q(d,f).text.length,!0);for(0>b&&(b=0);;){var f=q(d,e),e=Ud(a,f,e,b,c),g=(f=Fa(f))&&f.find();if(f&&e.ch>=g.from.ch)e=g.to.line;else return e}}function Ud(a,b,c,d,e){function f(d){d=P(a,o(c,d),"line",b,j);h=!0;if(g>d.bottom)return d.left-i;if(g<d.top)return d.left+i;h=!1;return d.left}var g=e-na(a,b),h=!1,i=2*a.display.wrapper.clientWidth,
  j=Xb(a,b),k=Q(b),m=b.text.length,s=ib(b),C=jb(b),l=f(s),e=h,q=f(C),n=h;if(d>q)return hb(c,C,n);for(;;){if(k?C==s||C==bc(b,s,1):1>=C-s){for(s=(d=d-l<q-d)?s:C;cc.test(b.text.charAt(s));)++s;e=hb(c,s,d?e:n);e.after=d;return e}var p=Math.ceil(m/2),r=s+p;if(k)for(var r=s,t=0;t<p;++t)r=bc(b,r,1);t=f(r);if(t>d){C=r;q=t;if(n=h)q+=1E3;m=p}else s=r,l=t,e=h,m-=p}}function Da(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==ca){ca=n("pre");for(var b=0;49>b;++b)ca.appendChild(document.createTextNode("x")),
  ca.appendChild(n("br"));ca.appendChild(document.createTextNode("x"))}R(a.measure,ca);b=ca.offsetHeight/50;3<b&&(a.cachedTextHeight=b);ab(a.measure);return b||1}function Fc(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=n("span","x"),c=n("pre",[b]);R(a.measure,c);b=b.offsetWidth;2<b&&(a.cachedCharWidth=b);return b||10}function sa(a){a.curOp={changes:[],updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,cursorActivity:!1,updateMaxLine:!1,updateScrollPos:!1,id:++Vd};
  kb++||(X=[])}function ta(a){var b=a.curOp,c=a.doc,d=a.display;a.curOp=null;b.updateMaxLine&&Pb(a);if(d.maxLineChanged&&!a.options.lineWrapping&&d.maxLine){var e;e=d.maxLine;var f=!1;if(e.markedSpans)for(var g=0;g<e.markedSpans;++g){var h=e.markedSpans[g];if(h.collapsed&&(null==h.to||h.to==e.text.length))f=!0}(f=!f&&Yb(a,e))?e=Wb(a,e,e.text.length,f.measure).right:(e=Vb(a,e),f=e.appendChild(lb(a.display.measure)),R(a.display.measure,e),e=y(f).right-y(a.display.lineDiv).left);d.sizer.style.minWidth=
  Math.max(0,e+3+ja)+"px";d.maxLineChanged=!1;e=Math.max(0,d.sizer.offsetLeft+d.sizer.offsetWidth-d.scroller.clientWidth);e<c.scrollLeft&&!b.updateScrollPos&&ua(a,Math.min(d.scroller.scrollLeft,e),!0)}var i,j;b.updateScrollPos?i=b.updateScrollPos:b.selectionChanged&&d.scroller.clientHeight&&(i=P(a,c.sel.head),i=mb(a,i.left,i.top,i.left,i.bottom));if(b.changes.length||i&&null!=i.scrollTop)j=db(a,b.changes,i&&i.scrollTop),a.display.scroller.offsetHeight&&(a.doc.scrollTop=a.display.scroller.scrollTop);
  !j&&b.selectionChanged&&Tb(a);if(b.updateScrollPos)d.scroller.scrollTop=d.scrollbarV.scrollTop=c.scrollTop=i.scrollTop,d.scroller.scrollLeft=d.scrollbarH.scrollLeft=c.scrollLeft=i.scrollLeft,Ob(a),b.scrollToPos&&Qc(a,r(a.doc,b.scrollToPos),b.scrollToPosMargin);else if(i&&(c=Qc(a,a.doc.sel.head,a.options.cursorScrollMargin),a.state.focused)){d=a.display;i=y(d.sizer);j=null;e=a.display.lineSpace.offsetTop;if(0>c.top+e+i.top)j=!0;else if(c.bottom+e+i.top>(window.innerHeight||document.documentElement.clientHeight))j=
  !1;if(null!=j&&!Wd){if(i="none"==d.cursor.style.display)d.cursor.style.display="",d.cursor.style.left=c.left+"px",d.cursor.style.top=c.top-d.viewOffset+"px";d.cursor.scrollIntoView(j);i&&(d.cursor.style.display="none")}}b.selectionChanged&&fb(a);a.state.focused&&b.updateInput&&W(a,b.userSelChange);c=b.maybeHiddenMarkers;d=b.maybeUnhiddenMarkers;if(c)for(j=0;j<c.length;++j)c[j].lines.length||D(c[j],"hide");if(d)for(j=0;j<d.length;++j)d[j].lines.length&&D(d[j],"unhide");var k;--kb||(k=X,X=null);b.textChanged&&
  D(a,"change",a,b.textChanged);b.cursorActivity&&D(a,"cursorActivity",a);if(k)for(j=0;j<k.length;++j)k[j]()}function p(a,b){return function(){var c=a||this,d=!c.curOp;d&&sa(c);try{var e=b.apply(c,arguments)}finally{d&&ta(c)}return e}}function Ja(a){return function(){var b=this.cm&&!this.cm.curOp,c;b&&sa(this.cm);try{c=a.apply(this,arguments)}finally{b&&ta(this.cm)}return c}}function dc(a,b){var c=!a.curOp,d;c&&sa(a);try{d=b()}finally{c&&ta(a)}return d}function u(a,b,c,d){null==b&&(b=a.doc.first);null==
  c&&(c=a.doc.first+a.doc.size);a.curOp.changes.push({from:b,to:c,diff:d})}function nb(a){a.display.pollingFast||a.display.poll.set(a.options.pollInterval,function(){ec(a);a.state.focused&&nb(a)})}function Ka(a){function b(){!ec(a)&&!c?(c=!0,a.display.poll.set(60,b)):(a.display.pollingFast=!1,nb(a))}var c=!1;a.display.pollingFast=!0;a.display.poll.set(20,b)}function ec(a){var b=a.display.input,c=a.display.prevInput,d=a.doc,e=d.sel;if(!a.state.focused||Xd(b)||La(a))return!1;var f=b.value;if(f==c&&w(e.from,
  e.to))return!1;if(B&&!J&&a.display.inputHasSelection===f)return W(a,!0),!1;var g=!a.curOp;g&&sa(a);e.shift=!1;for(var h=0,i=Math.min(c.length,f.length);h<i&&c.charCodeAt(h)==f.charCodeAt(h);)++h;i=e.from;e=e.to;h<c.length?i=o(i.line,i.ch-(c.length-h)):a.state.overwrite&&(w(i,e)&&!a.state.pasteIncoming)&&(e=o(e.line,Math.min(q(d,e.line).text.length,e.ch+(f.length-h))));c=a.curOp.updateInput;va(a.doc,{from:i,to:e,text:da(f.slice(h)),origin:a.state.pasteIncoming?"paste":"+input"},"end");a.curOp.updateInput=
  c;1E3<f.length||-1<f.indexOf("\n")?b.value=a.display.prevInput="":a.display.prevInput=f;g&&ta(a);a.state.pasteIncoming=!1;return!0}function W(a,b){var c,d,e=a.doc;w(e.sel.from,e.sel.to)?b&&(a.display.prevInput=a.display.input.value="",B&&!J&&(a.display.inputHasSelection=null)):(a.display.prevInput="",d=(c=Rc&&(100<e.sel.to.line-e.sel.from.line||1E3<(d=a.getSelection()).length))?"-":d||a.getSelection(),a.display.input.value=d,a.state.focused&&Sc(a.display.input),B&&!J&&(a.display.inputHasSelection=
  d));a.display.inaccurateSelection=c}function G(a){"nocursor"!=a.options.readOnly&&(!Jb||document.activeElement!=a.display.input)&&a.display.input.focus()}function La(a){return a.options.readOnly||a.doc.cantEdit}function Gd(a){function b(){a.state.focused&&setTimeout(K(G,a),0)}function c(){g.cachedCharWidth=g.cachedTextHeight=null;la(a);dc(a,K(u,a))}function d(){for(var a=g.wrapper.parentNode;a&&a!=document.body;a=a.parentNode);a?setTimeout(d,5E3):T(window,"resize",c)}function e(b){(!a.options.onDragEvent||
  !a.options.onDragEvent(a,Ma(b)))&&Na(b)}function f(){g.inaccurateSelection&&(g.prevInput="",g.inaccurateSelection=!1,g.input.value=a.getSelection(),Sc(g.input))}var g=a.display;t(g.scroller,"mousedown",p(a,Yd));B?t(g.scroller,"dblclick",p(a,function(b){var c=wa(a,b);c&&(!Tc(a,b)&&!ea(a.display,b))&&(z(b),b=fc(q(a.doc,c.line).text,c),A(a.doc,b.from,b.to))})):t(g.scroller,"dblclick",z);t(g.lineSpace,"selectstart",function(a){ea(g,a)||z(a)});gc||t(g.scroller,"contextmenu",function(b){Uc(a,b)});t(g.scroller,
  "scroll",function(){g.scroller.clientHeight&&(Oa(a,g.scroller.scrollTop),ua(a,g.scroller.scrollLeft,!0),D(a,"scroll",a))});t(g.scrollbarV,"scroll",function(){g.scroller.clientHeight&&Oa(a,g.scrollbarV.scrollTop)});t(g.scrollbarH,"scroll",function(){g.scroller.clientHeight&&ua(a,g.scrollbarH.scrollLeft)});t(g.scroller,"mousewheel",function(b){Vc(a,b)});t(g.scroller,"DOMMouseScroll",function(b){Vc(a,b)});t(g.scrollbarH,"mousedown",b);t(g.scrollbarV,"mousedown",b);t(g.wrapper,"scroll",function(){g.wrapper.scrollTop=
  g.wrapper.scrollLeft=0});t(window,"resize",c);setTimeout(d,5E3);t(g.input,"keyup",p(a,function(b){if((!a.options.onKeyEvent||!a.options.onKeyEvent(a,Ma(b)))&&16==b.keyCode)a.doc.sel.shift=!1}));t(g.input,"input",K(Ka,a));t(g.input,"keydown",p(a,Wc));t(g.input,"keypress",p(a,Zd));t(g.input,"focus",K($,a));t(g.input,"blur",K(Lb,a));a.options.dragDrop&&(t(g.scroller,"dragstart",function(b){var c=a;if(B&&!c.state.draggingText)Na(b);else if(!ea(c.display,b)){var d=c.getSelection();b.dataTransfer.setData("Text",
  d);b.dataTransfer.setDragImage&&(d=n("img",null,null,"position: fixed; left: 0; top: 0;"),S&&(d.width=d.height=1,c.display.wrapper.appendChild(d),d._top=d.offsetTop),hc&&(c.display.dragImg?d=c.display.dragImg:(c.display.dragImg=d,d.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",c.display.wrapper.appendChild(d))),b.dataTransfer.setDragImage(d,0,0),S&&d.parentNode.removeChild(d))}}),t(g.scroller,"dragenter",e),t(g.scroller,"dragover",e),t(g.scroller,"drop",p(a,$d)));
  t(g.scroller,"paste",function(b){if(!ea(g,b)){G(a);Ka(a)}});t(g.input,"paste",function(){a.state.pasteIncoming=true;Ka(a)});t(g.input,"cut",f);t(g.input,"copy",f);Nb&&t(g.sizer,"mouseup",function(){document.activeElement==g.input&&g.input.blur();G(a)})}function ea(a,b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(!c||/\bCodeMirror-(?:line)?widget\b/.test(c.className)||c.parentNode==a.sizer&&c!=a.mover)return!0}function wa(a,b,c){var d=a.display;if(!c&&(c=b.target||b.srcElement,
  c==d.scrollbarH||c==d.scrollbarH.firstChild||c==d.scrollbarV||c==d.scrollbarV.firstChild||c==d.scrollbarFiller||c==d.gutterFiller))return null;var e,f,d=y(d.lineSpace);try{e=b.clientX,f=b.clientY}catch(g){return null}return ac(a,e-d.left,f-d.top)}function Yd(a){function b(a){if(!w(n,a))if(n=a,"single"==k)A(e.doc,r(g,i),a);else if(C=r(g,C),l=r(g,l),"double"==k){var b=fc(q(g,a.line).text,a);x(a,C)?A(e.doc,b.from,l):A(e.doc,C,b.to)}else"triple"==k&&(x(a,C)?A(e.doc,l,r(g,o(a.line,0))):A(e.doc,C,r(g,o(a.line+
  1,0))))}function c(a){var d=++u,h=wa(e,a,!0);if(h)if(w(h,m)){var i=a.clientY<v.top?-20:a.clientY>v.bottom?20:0;i&&setTimeout(p(e,function(){u==d&&(f.scroller.scrollTop+=i,c(a))}),50)}else{e.state.focused||$(e);m=h;b(h);var j=Rb(f,g);(h.line>=j.to||h.line<j.from)&&setTimeout(p(e,function(){u==d&&c(a)}),150)}}function d(a){u=Infinity;var c=wa(e,a);c&&b(c);z(a);G(e);T(document,"mousemove",Jc);T(document,"mouseup",Kc)}var e=this,f=e.display,g=e.doc,h=g.sel;h.shift=a.shiftKey;if(ea(f,a))L||(f.scroller.draggable=
  !1,setTimeout(function(){f.scroller.draggable=!0},100));else if(!Tc(e,a)){var i=wa(e,a);switch(Xc(a)){case 3:gc&&Uc.call(e,e,a);return;case 2:i&&A(e.doc,i);setTimeout(K(G,e),20);z(a);return}if(i){e.state.focused||$(e);var j=+new Date,k="single";ob&&ob.time>j-400&&w(ob.pos,i)?(k="triple",z(a),setTimeout(K(G,e),20),ae(e,i.line)):pb&&pb.time>j-400&&w(pb.pos,i)?(k="double",ob={time:j,pos:i},z(a),j=fc(q(g,i.line).text,i),A(e.doc,j.from,j.to)):pb={time:j,pos:i};var m=i;if(e.options.dragDrop&&be&&!La(e)&&
  !w(h.from,h.to)&&!x(i,h.from)&&!x(h.to,i)&&"single"==k){var s=p(e,function(b){if(L)f.scroller.draggable=false;e.state.draggingText=false;T(document,"mouseup",s);T(f.scroller,"drop",s);if(Math.abs(a.clientX-b.clientX)+Math.abs(a.clientY-b.clientY)<10){z(b);A(e.doc,i);G(e)}});L&&(f.scroller.draggable=!0);e.state.draggingText=s;f.scroller.dragDrop&&f.scroller.dragDrop();t(document,"mouseup",s);t(f.scroller,"drop",s)}else{z(a);"single"==k&&A(e.doc,r(g,i));var C=h.from,l=h.to,n=i,v=y(f.wrapper),u=0,Jc=
  p(e,function(a){!B&&!Xc(a)?d(a):c(a)}),Kc=p(e,d);t(document,"mousemove",Jc);t(document,"mouseup",Kc)}}else(a.target||a.srcElement)==f.scroller&&z(a)}}function $d(a){var b=this;if(!(ea(b.display,a)||b.options.onDragEvent&&b.options.onDragEvent(b,Ma(a)))){z(a);var c=wa(b,a,!0),d=a.dataTransfer.files;if(c&&!La(b))if(d&&d.length&&window.FileReader&&window.File)for(var e=d.length,f=Array(e),g=0,a=function(a,d){var h=new FileReader;h.onload=function(){f[d]=h.result;++g==e&&(c=r(b.doc,c),va(b.doc,{from:c,
  to:c,text:da(f.join("\n")),origin:"paste"},"around"))};h.readAsText(a)},h=0;h<e;++h)a(d[h],h);else if(b.state.draggingText&&!x(c,b.doc.sel.from)&&!x(b.doc.sel.to,c))b.state.draggingText(a),setTimeout(K(G,b),20);else try{if(f=a.dataTransfer.getData("Text")){var h=b.doc.sel.from,i=b.doc.sel.to;Y(b.doc,c,c);b.state.draggingText&&Z(b.doc,"",h,i,"paste");b.replaceSelection(f,null,"paste");G(b);$(b)}}catch(j){}}}function Tc(a,b){var c=a.display;try{var d=b.clientX,e=b.clientY}catch(f){return!1}if(d>=Math.floor(y(c.gutters).right))return!1;
  z(b);if(!xa(a,"gutterClick"))return!0;var g=y(c.lineDiv);if(e>g.bottom)return!0;e-=g.top-c.viewOffset;for(g=0;g<a.options.gutters.length;++g){var h=c.gutters.childNodes[g];if(h&&y(h).right>=d){c=cb(a.doc,e);O(a,"gutterClick",a,c,a.options.gutters[g],b);break}}return!0}function Oa(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,ya||db(a,[],b),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbarV.scrollTop!=b&&(a.display.scrollbarV.scrollTop=b),ya&&db(a,[]))}
  function ua(a,b,c){if(!(c?b==a.doc.scrollLeft:2>Math.abs(a.doc.scrollLeft-b)))if(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,Ob(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbarH.scrollLeft!=b)a.display.scrollbarH.scrollLeft=b}function Vc(a,b){var c=b.wheelDeltaX,d=b.wheelDeltaY;null==c&&(b.detail&&b.axis==b.HORIZONTAL_AXIS)&&(c=b.detail);null==d&&b.detail&&b.axis==b.VERTICAL_AXIS?d=b.detail:null==d&&(d=b.wheelDelta);
  var e=a.display,f=e.scroller;if(c&&f.scrollWidth>f.clientWidth||d&&f.scrollHeight>f.clientHeight){if(d&&oa&&L)for(var g=b.target;g!=f;g=g.parentNode)if(g.lineObj){a.display.currentWheelTarget=g;break}if(c&&!ya&&!S&&null!=N)d&&Oa(a,Math.max(0,Math.min(f.scrollTop+d*N,f.scrollHeight-f.clientHeight))),ua(a,Math.max(0,Math.min(f.scrollLeft+c*N,f.scrollWidth-f.clientWidth))),z(b),e.wheelStartX=null;else{if(d&&null!=N){var g=d*N,h=a.doc.scrollTop,i=h+e.wrapper.clientHeight;0>g?h=Math.max(0,h+g-50):i=Math.min(a.doc.height,
  i+g+50);db(a,[],{top:h,bottom:i})}20>qb&&(null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=c,e.wheelDY=d,setTimeout(function(){if(e.wheelStartX!=null){var a=f.scrollLeft-e.wheelStartX,b=f.scrollTop-e.wheelStartY,a=b&&e.wheelDY&&b/e.wheelDY||a&&e.wheelDX&&a/e.wheelDX;e.wheelStartX=e.wheelStartY=null;if(a){N=(N*qb+a)/(qb+1);++qb}}},200)):(e.wheelDX+=c,e.wheelDY+=d))}}}function rb(a,b,c){if("string"==typeof b&&(b=ic[b],!b))return!1;a.display.pollingFast&&ec(a)&&(a.display.pollingFast=
  !1);var d=a.doc,e=d.sel.shift,f=!1;try{La(a)&&(a.state.suppressEdits=!0),c&&(d.sel.shift=!1),f=b(a)!=Yc}finally{d.sel.shift=e,a.state.suppressEdits=!1}return f}function Zc(a){var b=a.state.keyMaps.slice(0);a.options.extraKeys&&b.push(a.options.extraKeys);b.push(a.options.keyMap);return b}function $c(a,b){var c=jc(a.options.keyMap),d=c.auto;clearTimeout(ad);d&&!bd(b)&&(ad=setTimeout(function(){jc(a.options.keyMap)==c&&(a.options.keyMap=d.call?d.call(null,a):d)},50));var e=cd(b,!0),f=!1;if(!e)return!1;
  f=Zc(a);f=b.shiftKey?Pa("Shift-"+e,f,function(b){return rb(a,b,!0)})||Pa(e,f,function(b){if("string"==typeof b&&/^go[A-Z]/.test(b))return rb(a,b)}):Pa(e,f,function(b){return rb(a,b)});"stop"==f&&(f=!1);f&&(z(b),fb(a),J&&(b.oldKeyCode=b.keyCode,b.keyCode=0));return f}function ce(a,b,c){if(c=Pa("'"+c+"'",Zc(a),function(b){return rb(a,b,!0)}))z(b),fb(a);return c}function Wc(a){this.state.focused||$(this);B&&27==a.keyCode&&(a.returnValue=!1);if(!this.options.onKeyEvent||!this.options.onKeyEvent(this,
  Ma(a))){var b=a.keyCode;this.doc.sel.shift=16==b||a.shiftKey;var c=$c(this,a);S&&(kc=c?b:null,!c&&(88==b&&!Rc&&(oa?a.metaKey:a.ctrlKey))&&this.replaceSelection(""))}}function Zd(a){var b=this;if(!b.options.onKeyEvent||!b.options.onKeyEvent(b,Ma(a))){var c=a.keyCode,d=a.charCode;if(S&&c==kc)kc=null,z(a);else if(!(S&&(!a.which||10>a.which)||Nb)||!$c(b,a))c=String.fromCharCode(null==d?c:d),this.options.electricChars&&(this.doc.mode.electricChars&&this.options.smartIndent&&!La(this)&&-1<this.doc.mode.electricChars.indexOf(c))&&
  setTimeout(p(b,function(){sb(b,b.doc.sel.to.line,"smart")}),75),ce(b,a,c)||(B&&!J&&(b.display.inputHasSelection=null),Ka(b))}}function $(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(D(a,"focus",a),a.state.focused=!0,-1==a.display.wrapper.className.search(/\bCodeMirror-focused\b/)&&(a.display.wrapper.className+=" CodeMirror-focused"),W(a,!0)),nb(a),fb(a))}function Lb(a){a.state.focused&&(D(a,"blur",a),a.state.focused=!1,a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-focused",
  ""));clearInterval(a.display.blinker);setTimeout(function(){if(!a.state.focused)a.doc.sel.shift=false},150)}function Uc(a,b){function c(){if(null!=e.input.selectionStart){var a=e.input.value=" "+(w(f.from,f.to)?"":e.input.value);e.prevInput=" ";e.input.selectionStart=1;e.input.selectionEnd=a.length}}function d(){e.inputDiv.style.position="relative";e.input.style.cssText=i;J&&(e.scrollbarV.scrollTop=e.scroller.scrollTop=h);nb(a);if(null!=e.input.selectionStart){(!B||J)&&c();clearTimeout(lc);var b=
  0,d=function(){e.prevInput==" "&&e.input.selectionStart==0?p(a,ic.selectAll)(a):b++<10?lc=setTimeout(d,500):W(a)};lc=setTimeout(d,200)}}var e=a.display,f=a.doc.sel;if(!ea(e,b)){var g=wa(a,b),h=e.scroller.scrollTop;if(g&&!S){(w(f.from,f.to)||x(g,f.from)||!x(g,f.to))&&p(a,Y)(a.doc,g,g);var i=e.input.style.cssText;e.inputDiv.style.position="absolute";e.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(b.clientY-5)+"px; left: "+(b.clientX-5)+"px; z-index: 1000; background: white; outline: none;border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);";
  G(a);W(a,!0);w(f.from,f.to)&&(e.input.value=e.prevInput=" ");B&&!J&&c();if(gc){Na(b);var j=function(){T(window,"mouseup",j);setTimeout(d,20)};t(window,"mouseup",j)}else setTimeout(d,50)}}}function mc(a){return!a.text?a.to:o(a.from.line+a.text.length-1,E(a.text).length+(1==a.text.length?a.from.ch:0))}function dd(a,b,c){if(!x(b.from,c))return r(a,c);var d=b.text.length-1-(b.to.line-b.from.line);if(c.line>b.to.line+d)return b=c.line-d,d=a.first+a.size-1,b>d?o(d,q(a,d).text.length):tb(c,q(a,b).text.length);
  if(c.line==b.to.line+d)return tb(c,E(b.text).length+(1==b.text.length?b.from.ch:0)+q(a,b.to.line).text.length-b.to.ch);a=c.line-b.from.line;return tb(c,b.text[a].length+(a?0:b.from.ch))}function nc(a,b,c){if(c&&"object"==typeof c)return{anchor:dd(a,b,c.anchor),head:dd(a,b,c.head)};if("start"==c)return{anchor:b.from,head:b.from};var d=mc(b);if("around"==c)return{anchor:b.from,head:d};if("end"==c)return{anchor:d,head:d};c=function(a){if(x(a,b.from))return a;if(!x(b.to,a))return d;var c=a.line+b.text.length-
  (b.to.line-b.from.line)-1,g=a.ch;a.line==b.to.line&&(g+=d.ch-b.to.ch);return o(c,g)};return{anchor:c(a.sel.anchor),head:c(a.sel.head)}}function de(a,b){var c={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,update:function(b,c,f,g){b&&(this.from=r(a,b));c&&(this.to=r(a,c));f&&(this.text=f);void 0!==g&&(this.origin=g)},cancel:function(){this.canceled=!0}};D(a,"beforeChange",a,c);a.cm&&D(a.cm,"beforeChange",a.cm,c);return c.canceled?null:{from:c.from,to:c.to,text:c.text,origin:c.origin}}
  function va(a,b,c,d){if(a.cm){if(!a.cm.curOp)return p(a.cm,va)(a,b,c,d);if(a.cm.state.suppressEdits)return}if(xa(a,"beforeChange")||a.cm&&xa(a.cm,"beforeChange"))if(b=de(a,b),!b)return;if(d=ed&&!d&&ee(a,b.from,b.to)){for(var e=d.length-1;1<=e;--e)oc(a,{from:d[e].from,to:d[e].to,text:[""]});d.length&&oc(a,{from:d[0].from,to:d[0].to,text:b.text},c)}else oc(a,b,c)}function oc(a,b,c){c=nc(a,b,c);fd(a,b,c,a.cm?a.cm.curOp.id:NaN);Qa(a,b,c,pc(a,b));var d=[];za(a,function(a,c){!c&&-1==U(d,a.history)&&(gd(a.history,
  b),d.push(a.history));Qa(a,b,null,pc(a,b))})}function hd(a,b){if(!a.cm||!a.cm.state.suppressEdits){var c=a.history,d=("undo"==b?c.done:c.undone).pop();if(d){c.dirtyCounter+="undo"==b?-1:1;var e={changes:[],anchorBefore:d.anchorAfter,headBefore:d.headAfter,anchorAfter:d.anchorBefore,headAfter:d.headBefore};("undo"==b?c.undone:c.done).push(e);for(c=d.changes.length-1;0<=c;--c){var f=d.changes[c];f.origin=b;e.changes.push(qc(a,f));var g=c?nc(a,f,null):{anchor:d.anchorBefore,head:d.headBefore};Qa(a,f,
  g,id(a,f));var h=[];za(a,function(a,b){!b&&-1==U(h,a.history)&&(gd(a.history,f),h.push(a.history));Qa(a,f,null,id(a,f))})}}}}function jd(a,b){function c(a){return o(a.line+b,a.ch)}a.first+=b;a.cm&&u(a.cm,a.first,a.first,b);a.sel.head=c(a.sel.head);a.sel.anchor=c(a.sel.anchor);a.sel.from=c(a.sel.from);a.sel.to=c(a.sel.to)}function Qa(a,b,c,d){if(a.cm&&!a.cm.curOp)return p(a.cm,Qa)(a,b,c,d);if(b.to.line<a.first)jd(a,b.text.length-1-(b.to.line-b.from.line));else if(!(b.from.line>a.lastLine())){if(b.from.line<
  a.first){var e=b.text.length-1-(a.first-b.from.line);jd(a,e);b={from:o(a.first,0),to:o(b.to.line+e,b.to.ch),text:[E(b.text)],origin:b.origin}}e=a.lastLine();b.to.line>e&&(b={from:b.from,to:o(e,q(a,e).text.length),text:[b.text[0]],origin:b.origin});b.removed=rc(a,b.from,b.to);c||(c=nc(a,b,null));a.cm?fe(a.cm,b,d,c):sc(a,b,d,c)}}function fe(a,b,c,d){var e=a.doc,f=a.display,g=b.from,h=b.to,i=!1,j=g.line;a.options.lineWrapping||(j=H(ma(e,q(e,g.line))),e.iter(j,h.line+1,function(a){if(a==f.maxLine)return i=
  !0}));!x(e.sel.head,b.from)&&!x(b.to,e.sel.head)&&(a.curOp.cursorActivity=!0);sc(e,b,c,d,Ec(a));a.options.lineWrapping||(e.iter(j,g.line+b.text.length,function(a){var b=bb(e,a);if(b>f.maxLineLength){f.maxLine=a;f.maxLineLength=b;f.maxLineChanged=true;i=false}}),i&&(a.curOp.updateMaxLine=!0));e.frontier=Math.min(e.frontier,g.line);$a(a,400);u(a,g.line,h.line+1,b.text.length-(h.line-g.line)-1);if(xa(a,"change"))if(b={from:g,to:h,text:b.text,removed:b.removed,origin:b.origin},a.curOp.textChanged){for(a=
  a.curOp.textChanged;a.next;a=a.next);a.next=b}else a.curOp.textChanged=b}function Z(a,b,c,d,e){d||(d=c);if(x(d,c))var f=d,d=c,c=f;"string"==typeof b&&(b=da(b));va(a,{from:c,to:d,text:b,origin:e},null)}function o(a,b){if(!(this instanceof o))return new o(a,b);this.line=a;this.ch=b}function w(a,b){return a.line==b.line&&a.ch==b.ch}function x(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function fa(a){return o(a.line,a.ch)}function r(a,b){if(b.line<a.first)return o(a.first,0);var c=a.first+a.size-
  1;return b.line>c?o(c,q(a,c).text.length):tb(b,q(a,b.line).text.length)}function tb(a,b){var c=a.ch;return null==c||c>b?o(a.line,b):0>c?o(a.line,0):a}function Aa(a,b){return b>=a.first&&b<a.first+a.size}function A(a,b,c,d){if(a.sel.shift||a.sel.extend){var e=a.sel.anchor;if(c){var f=x(b,e);f!=x(c,e)?(e=b,b=c):f!=x(b,c)&&(b=c)}Y(a,e,b,d)}else Y(a,b,c||b,d);a.cm&&(a.cm.curOp.userSelChange=!0)}function Y(a,b,c,d,e){if(!e&&xa(a,"beforeSelectionChange")||a.cm&&xa(a.cm,"beforeSelectionChange"))b={anchor:b,
  head:c},D(a,"beforeSelectionChange",a,b),a.cm&&D(a.cm,"beforeSelectionChange",a.cm,b),b.anchor=r(a,b.anchor),b.head=r(a,b.head),c=b.head,b=b.anchor;var f=a.sel;f.goalColumn=null;if(e||!w(b,f.anchor))b=ub(a,b,d,"push"!=e);if(e||!w(c,f.head))c=ub(a,c,d,"push"!=e);if(!w(f.anchor,b)||!w(f.head,c))f.anchor=b,f.head=c,d=x(c,b),f.from=d?c:b,f.to=d?b:c,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=a.cm.curOp.cursorActivity=!0),O(a,"cursorActivity",a)}function kd(a){Y(a.doc,a.doc.sel.from,a.doc.sel.to,
  null,"push")}function ub(a,b,c,d){var e=!1,f=b,g=c||1;a.cantEdit=!1;a:for(;;){var h=q(a,f.line);if(h.markedSpans)for(var i=0;i<h.markedSpans.length;++i){var j=h.markedSpans[i],k=j.marker;if((null==j.from||(k.inclusiveLeft?j.from<=f.ch:j.from<f.ch))&&(null==j.to||(k.inclusiveRight?j.to>=f.ch:j.to>f.ch))){if(d&&(D(k,"beforeCursorEnter"),k.explicitlyCleared))if(h.markedSpans){--i;continue}else break;if(k.atomic){i=k.find()[0>g?"from":"to"];if(w(i,f)&&(i.ch+=g,0>i.ch?i=i.line>a.first?r(a,o(i.line-1)):
  null:i.ch>h.text.length&&(i=i.line<a.first+a.size-1?o(i.line+1,0):null),!i)){if(e){if(!d)return ub(a,b,c,!0);a.cantEdit=!0;return o(a.first,0)}e=!0;i=b;g=-g}f=i;continue a}}}return f}}function Qc(a,b,c){for(null==c&&(c=0);;){var d=!1,e=P(a,b),f=mb(a,e.left,e.top-c,e.left,e.bottom+c),g=a.doc.scrollTop,h=a.doc.scrollLeft;null!=f.scrollTop&&(Oa(a,f.scrollTop),1<Math.abs(a.doc.scrollTop-g)&&(d=!0));null!=f.scrollLeft&&(ua(a,f.scrollLeft),1<Math.abs(a.doc.scrollLeft-h)&&(d=!0));if(!d)return e}}function mb(a,
  b,c,d,e){var f=a.display,g=f.lineSpace.offsetTop,c=c+g,e=e+g;0>c&&(c=0);var h=f.scroller.clientHeight-ja,i=f.scroller.scrollTop,j={},a=a.doc.height+(f.mover.offsetHeight-f.lineSpace.offsetHeight),k=c<g+10,g=e+g>a-10;c<i?j.scrollTop=k?0:c:e>i+h&&(c=Math.min(c,(g?a:e)-h),c!=i&&(j.scrollTop=c));i=f.scroller.clientWidth-ja;c=f.scroller.scrollLeft;b+=f.gutters.offsetWidth;d+=f.gutters.offsetWidth;f=f.gutters.offsetWidth;e=b<f+10;b<c+f||e?(e&&(b=0),j.scrollLeft=Math.max(0,b-10-f)):d>i+c-3&&(j.scrollLeft=
  d+10-i);return j}function vb(a,b,c){a.curOp.updateScrollPos={scrollLeft:null==b?a.doc.scrollLeft:b,scrollTop:null==c?a.doc.scrollTop:c}}function ld(a,b,c){var d=a.curOp.updateScrollPos||(a.curOp.updateScrollPos={scrollLeft:a.doc.scrollLeft,scrollTop:a.doc.scrollTop}),a=a.display.scroller;d.scrollTop=Math.max(0,Math.min(a.scrollHeight-a.clientHeight,d.scrollTop+c));d.scrollLeft=Math.max(0,Math.min(a.scrollWidth-a.clientWidth,d.scrollLeft+b))}function sb(a,b,c,d){var e=a.doc;c||(c="add");if("smart"==
  c)if(a.doc.mode.indent)var f=Ia(a,b);else c="prev";var g=a.options.tabSize,h=q(e,b),i=qa(h.text,null,g),j=h.text.match(/^\s*/)[0],k;if("smart"==c&&(k=a.doc.mode.indent(f,h.text.slice(j.length),h.text),k==Yc)){if(!d)return;c="prev"}"prev"==c?k=b>e.first?qa(q(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c&&(k=i-a.options.indentUnit);k=Math.max(0,k);c="";d=0;if(a.options.indentWithTabs)for(e=Math.floor(k/g);e;--e)d+=g,c+="\t";d<k&&(c+=md(k-d));c!=j&&Z(a.doc,c,o(b,0),o(b,j.length),
  "+input");h.stateAfter=null}function wb(a,b,c){var d=b,e=b,f=a.doc;"number"==typeof b?e=q(f,Math.max(f.first,Math.min(b,f.first+f.size-1))):d=H(b);if(null!=d&&c(e,d))u(a,d,d+1);else return null;return e}function tc(a,b,c,d,e){function f(b){var d=(e?bc:nd)(i,h,c,!0);if(null==d){if(b=!b)b=g+c,b<a.first||b>=a.first+a.size?b=j=!1:(g=b,b=i=q(a,b));if(b)h=e?(0>c?jb:ib)(i):0>c?i.text.length:0;else return j=!1}else h=d;return!0}var g=b.line,h=b.ch,b=c,i=q(a,g),j=!0;if("char"==d)f();else if("column"==d)f(!0);
  else if("word"==d||"group"==d)for(var k=null,d="group"==d,m=!0;!(0>c)||f(!m);m=!1){var s=i.text.charAt(h)||"\n",s=xb(s)?"w":!d?null:/\s/.test(s)?null:"p";if(k&&k!=s){0>c&&(c=1,f());break}s&&(k=s);if(0<c&&!f(!m))break}b=ub(a,o(g,h),b,!0);j||(b.hitSide=!0);return b}function od(a,b,c,d){var e=a.doc,f=b.left,g;"page"==d?(d=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),g=b.top+c*(d-(0>c?1.5:0.5)*Da(a.display))):"line"==d&&(g=0<c?b.bottom+3:b.top-3);
  for(;;){var h=ac(a,f,g);if(!h.outside)break;if(0>c?0>=g:g>=e.height){h.hitSide=!0;break}g+=5*c}return h}function fc(a,b){var c=b.ch,d=b.ch;if(a){!1===b.after||d==a.length?--c:++d;for(var e=a.charAt(c),e=xb(e)?xb:/\s/.test(e)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!xb(a)};0<c&&e(a.charAt(c-1));)--c;for(;d<a.length&&e(a.charAt(d));)++d}return{from:o(b.line,c),to:o(b.line,d)}}function ae(a,b){A(a.doc,o(b,0),r(a.doc,o(b+1,0)))}function v(a,b,c,d){l.defaults[a]=b;c&&(ia[a]=d?
  function(a,b,d){d!=Dc&&c(a,b,d)}:c)}function pa(a,b){if(!0===b)return b;if(a.copyState)return a.copyState(b);var c={},d;for(d in b){var e=b[d];e instanceof Array&&(e=e.concat([]));c[d]=e}return c}function Nc(a,b,c){return a.startState?a.startState(b,c):!0}function jc(a){return"string"==typeof a?V[a]:a}function Pa(a,b,c){function d(b){var b=jc(b),e=b[a];if(!1===e)return"stop";if(null!=e&&c(e))return!0;if(b.nofallthrough)return"stop";b=b.fallthrough;if(null==b)return!1;if("[object Array]"!=Object.prototype.toString.call(b))return d(b);
  for(var e=0,f=b.length;e<f;++e){var j=d(b[e]);if(j)return j}return!1}for(var e=0;e<b.length;++e){var f=d(b[e]);if(f)return f}}function bd(a){a=ga[a.keyCode];return"Ctrl"==a||"Alt"==a||"Shift"==a||"Mod"==a}function cd(a,b){if(S&&34==a.keyCode&&a["char"])return!1;var c=ga[a.keyCode];if(null==c||a.altGraphKey)return!1;a.altKey&&(c="Alt-"+c);if(pd?a.metaKey:a.ctrlKey)c="Ctrl-"+c;if(pd?a.ctrlKey:a.metaKey)c="Cmd-"+c;!b&&a.shiftKey&&(c="Shift-"+c);return c}function Ra(a,b){this.pos=this.start=0;this.string=
  a;this.tabSize=b||8;this.lastColumnPos=this.lastColumnValue=0}function ha(a,b){this.lines=[];this.type=b;this.doc=a}function Sa(a,b,c,d,e){if(d&&d.shared)return ge(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return p(a.cm,Sa)(a,b,c,d,e);var f=new ha(a,e);if("range"==e&&!x(b,c))return f;d&&yb(d,f);f.replacedWith&&(f.collapsed=!0,f.replacedWith=n("span",[f.replacedWith],"CodeMirror-widget"));f.collapsed&&(Ha=!0);f.addToHistory&&fd(a,{from:b,to:c,origin:"markText"},{head:a.sel.head,anchor:a.sel.anchor},NaN);var g=
  b.line,h=0,i,j,k=a.cm,m;a.iter(g,c.line+1,function(d){k&&(f.collapsed&&!k.options.lineWrapping&&ma(a,d)==k.display.maxLine)&&(m=true);var e={from:null,to:null,marker:f};h=h+d.text.length;if(g==b.line){e.from=b.ch;h=h-b.ch}if(g==c.line){e.to=c.ch;h=h-(d.text.length-c.ch)}if(f.collapsed){g==c.line&&(j=ba(d,c.ch));g==b.line?i=ba(d,b.ch):M(d,0)}d.markedSpans=d.markedSpans?d.markedSpans.concat([e]):[e];e.marker.attachLine(d);++g});f.collapsed&&a.iter(b.line,c.line+1,function(b){aa(a,b)&&M(b,0)});f.clearOnEnter&&
  t(f,"beforeCursorEnter",function(){f.clear()});f.readOnly&&(ed=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory());if(f.collapsed){if(i!=j)throw Error("Inserting collapsed marker overlapping an existing one");f.size=h;f.atomic=!0}k&&(m&&(k.curOp.updateMaxLine=!0),(f.className||f.startStyle||f.endStyle||f.collapsed)&&u(k,b.line,c.line+1),f.atomic&&kd(k));return f}function zb(a,b){this.markers=a;this.primary=b;for(var c=0,d=this;c<a.length;++c)a[c].parent=this,t(a[c],"clear",function(){d.clear()})}
  function ge(a,b,c,d,e){d=yb(d);d.shared=!1;var f=[Sa(a,b,c,d,e)],g=f[0],h=d.replacedWith;za(a,function(a){h&&(d.replacedWith=h.cloneNode(!0));f.push(Sa(a,r(a,b),r(a,c),d,e));for(var j=0;j<a.linked.length;++j)if(a.linked[j].isParent)return;g=E(f)});return new zb(f,g)}function Ta(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function pc(a,b){var c=Aa(a,b.from.line)&&q(a,b.from.line).markedSpans,d=Aa(a,b.to.line)&&q(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,
  f=b.to.ch,g=w(b.from,b.to);if(c)for(var h=0,i;h<c.length;++h){var j=c[h],k=j.marker;if(null==j.from||(k.inclusiveLeft?j.from<=e:j.from<e)||"bookmark"==k.type&&j.from==e&&(!g||!j.marker.insertLeft)){var m=null==j.to||(k.inclusiveRight?j.to>=e:j.to>e);(i||(i=[])).push({from:j.from,to:m?null:j.to,marker:k})}}c=i;if(d)for(var h=0,s;h<d.length;++h)if(i=d[h],j=i.marker,null==i.to||(j.inclusiveRight?i.to>=f:i.to>f)||"bookmark"==j.type&&i.from==f&&(!g||i.marker.insertLeft))k=null==i.from||(j.inclusiveLeft?
  i.from<=f:i.from<f),(s||(s=[])).push({from:k?null:i.from-f,to:null==i.to?null:i.to-f,marker:j});d=s;g=1==b.text.length;s=E(b.text).length+(g?e:0);if(c)for(f=0;f<c.length;++f)h=c[f],null==h.to&&((i=Ta(d,h.marker))?g&&(h.to=null==i.to?null:i.to+s):h.to=e);if(d)for(f=0;f<d.length;++f)(h=d[f],null!=h.to&&(h.to+=s),null==h.from)?(i=Ta(c,h.marker),i||(h.from=s,g&&(c||(c=[])).push(h))):(h.from+=s,g&&(c||(c=[])).push(h));e=[c];if(!g){var g=b.text.length-2,l;if(0<g&&c)for(f=0;f<c.length;++f)null==c[f].to&&
  (l||(l=[])).push({from:null,to:null,marker:c[f].marker});for(f=0;f<g;++f)e.push(l);e.push(d)}return e}function id(a,b){var c;if(c=b["spans_"+a.id]){for(var d=0,e=[];d<b.text.length;++d)e.push(he(c[d]));c=e}else c=null;d=pc(a,b);if(!c)return d;if(!d)return c;for(e=0;e<c.length;++e){var f=c[e],g=d[e];if(f&&g){var h=0;a:for(;h<g.length;++h){for(var i=g[h],j=0;j<f.length;++j)if(f[j].marker==i.marker)continue a;f.push(i)}}else g&&(c[e]=g)}return c}function ee(a,b,c){var d=null;a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=
  0;b<a.markedSpans.length;++b){var c=a.markedSpans[b].marker;if(c.readOnly&&(!d||-1==U(d,c)))(d||(d=[])).push(c)}});if(!d)return null;a=[{from:b,to:c}];for(b=0;b<d.length;++b)for(var c=d[b],e=c.find(),f=0;f<a.length;++f){var g=a[f];if(!x(g.to,e.from)&&!x(e.to,g.from)){var h=[f,1];(x(g.from,e.from)||!c.inclusiveLeft&&w(g.from,e.from))&&h.push({from:g.from,to:e.from});(x(e.to,g.to)||!c.inclusiveRight&&w(g.to,e.to))&&h.push({from:e.to,to:g.to});a.splice.apply(a,h);f+=h.length-1}}return a}function ba(a,
  b){var c=Ha&&a.markedSpans,d;if(c)for(var e,f=0;f<c.length;++f)if(e=c[f],e.marker.collapsed&&(null==e.from||e.from<b)&&(null==e.to||e.to>b)&&(!d||d.width<e.marker.width))d=e.marker;return d}function Fa(a){return ba(a,a.text.length+1)}function ma(a,b){for(var c;c=ba(b,-1);)b=q(a,c.find().from.line);return b}function aa(a,b){var c=Ha&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed&&(null==d.from||0==d.from&&d.marker.inclusiveLeft&&uc(a,b,d)))return!0}function uc(a,b,c){if(null==
  c.to)return b=c.marker.find().to,b=q(a,b.line),uc(a,b,Ta(b.markedSpans,c.marker));if(c.marker.inclusiveRight&&c.to==b.text.length)return!0;for(var d,e=0;e<b.markedSpans.length;++e)if(d=b.markedSpans[e],d.marker.collapsed&&d.from==c.to&&(d.marker.inclusiveLeft||c.marker.inclusiveRight)&&uc(a,b,d))return!0}function qd(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function rd(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=
  b}}function sd(a){return function(){var b=!this.cm.curOp;b&&sa(this.cm);try{var c=a.apply(this,arguments)}finally{b&&ta(this.cm)}return c}}function gb(a){if(null!=a.height)return a.height;(!a.node.parentNode||1!=a.node.parentNode.nodeType)&&R(a.cm.display.measure,n("div",[a.node],null,"position: relative"));return a.height=a.node.offsetHeight}function ie(a,b,c,d){var e=new vc(a,c,d);e.noHScroll&&(a.display.alignWidgets=!0);wb(a,b,function(b){(b.widgets||(b.widgets=[])).push(e);e.line=b;if(!aa(a.doc,
  b)||e.showIfHidden){var c=na(a,b)<a.display.scroller.scrollTop;M(b,b.height+gb(e));c&&ld(a,0,e.height)}return true});return e}function Ua(a,b,c){a={text:a};rd(a,b);a.height=c?c(a):1;return a}function td(a,b,c,d,e){var f=c.flattenSpans;null==f&&(f=a.options.flattenSpans);var g="",h=null,i=new Ra(b,a.options.tabSize),j;for(""==b&&c.blankLine&&c.blankLine(d);!i.eol();){i.pos>a.options.maxHighlightLength?(f=!1,i.pos=Math.min(b.length,i.start+5E4),j=null):j=c.token(i,d);var k=i.current();i.start=i.pos;
  !f||h!=j?(g&&e(g,h),g=k,h=j):g+=k}g&&e(g,h)}function Lc(a,b,c){var d=[a.state.modeGen];td(a,b.text,a.doc.mode,c,function(a,b){d.push(a,b)});for(c=0;c<a.state.overlays.length;++c){var e=a.state.overlays[c],f=1;td(a,b.text,e.mode,!0,function(a,b){for(var c=f,j=a.length;j;){var k=d[f],m=k.length;if(m<=j)j=j-m;else{d.splice(f,1,k.slice(0,j),d[f+1],k.slice(j));j=0}f=f+2}if(b)if(e.opaque){d.splice(c,f-c,a,b);f=c+2}else for(;c<f;c=c+2){k=d[c+1];d[c+1]=k?k+" "+b:b}})}return d}function Mc(a,b,c){var d=a.doc.mode,
  e=new Ra(b.text,a.options.tabSize);for(""==b.text&&d.blankLine&&d.blankLine(c);!e.eol()&&e.pos<=a.options.maxHighlightLength;)d.token(e,c),e.start=e.pos}function ud(a){return!a?null:vd[a]||(vd[a]="cm-"+a.replace(/ +/g," cm-"))}function Vb(a,b,c){for(var d,e=b,f,g,h=!0;d=ba(e,-1);)h=!1,e=q(a.doc,d.find().from.line),f||(f=e);d={pre:n("pre"),col:0,pos:0,display:!c,measure:null,addedOne:!1,cm:a};e.textClass&&(d.pre.className=e.textClass);do{d.measure=e==b&&c;d.pos=0;d.addToken=d.measure?je:wd;if((B||
  L)&&a.getOption("lineWrapping"))d.addToken=ke(d.addToken);c&&(g&&e!=b&&!d.addedOne)&&(c[0]=d.pre.appendChild(lb(a.display.measure)),d.addedOne=!0);var i=e;g=d;var j=e;if(!j.styles||j.styles[0]!=a.state.modeGen)j.styles=Lc(a,j,j.stateAfter=Ia(a,H(j)));a:{var k=i,j=j.styles;if(i=k.markedSpans)for(var k=k.text.length,m=0,s=1,l="",o=void 0,p=0,r=void 0,t=void 0,v=void 0,u=void 0;;){if(p==m){for(var r=t=v="",u=null,p=Infinity,w=null,y=0;y<i.length;++y){var x=i[y],z=x.marker;if(x.from<=m&&(null==x.to||
  x.to>m)){if(null!=x.to&&p>x.to&&(p=x.to,t=""),z.className&&(r+=" "+z.className),z.startStyle&&x.from==m&&(v+=" "+z.startStyle),z.endStyle&&x.to==p&&(t+=" "+z.endStyle),z.collapsed&&(!u||u.marker.width<z.width))u=x}else x.from>m&&p>x.from&&(p=x.from);"bookmark"==z.type&&(x.from==m&&z.replacedWith)&&(w=z.replacedWith)}if(u&&(u.from||0)==m)if(xd(g,(null==u.to?k:u.to)-m,null!=u.from&&u.marker.replacedWith),null==u.to){j=u.marker.find();break a}w&&!u&&xd(g,0,w)}if(m>=k)break;for(w=Math.min(k,p);;){if(l){y=
  m+l.length;u||(x=y>w?l.slice(0,w-m):l,g.addToken(g,x,o?o+r:r,v,m+x.length==p?t:""));if(y>=w){l=l.slice(w-m);m=w;break}m=y;v=""}l=j[s++];o=ud(j[s++])}}else for(var s=1;s<j.length;s+=2)g.addToken(g,j[s],ud(j[s+1]));j=void 0}g=e==f;j&&(e=q(a.doc,j.to.line),h=!1)}while(j);c&&!d.addedOne&&(c[0]=d.pre.appendChild(h?n("span"," "):lb(a.display.measure)));!d.pre.firstChild&&!aa(a.doc,b)&&d.pre.appendChild(document.createTextNode(" "));var A;if(c&&B&&(A=Q(e)))if(f=A.length-1,A[f].from==A[f].to&&--f,e=A[f],
  A=A[f-1],e.from+1==e.to&&(A&&e.level<A.level)&&(c=c[d.pos-1]))c.parentNode.insertBefore(c.measureRight=lb(a.display.measure),c.nextSibling);D(a,"renderLine",a,b,d.pre);return d.pre}function wd(a,b,c,d,e){if(b){if(wc.test(b))for(var f=document.createDocumentFragment(),g=0;;){wc.lastIndex=g;var h=wc.exec(b),i=h?h.index-g:b.length-g;i&&(f.appendChild(document.createTextNode(b.slice(g,g+i))),a.col+=i);if(!h)break;g+=i+1;"\t"==h[0]?(h=a.cm.options.tabSize,h-=a.col%h,f.appendChild(n("span",md(h),"cm-tab")),
  a.col+=h):(i=n("span","•","cm-invalidchar"),i.title="\\u"+h[0].charCodeAt(0).toString(16),f.appendChild(i),a.col+=1)}else{a.col+=b.length;var f=document.createTextNode(b)}if(c||d||e||a.measure)return b=c||"",d&&(b+=d),e&&(b+=e),a.pre.appendChild(n("span",[f],b));a.pre.appendChild(f)}}function je(a,b,c,d,e){for(var f=a.cm.options.lineWrapping,g=0;g<b.length;++g){var h=b.charAt(g),i=0==g;"\ud800"<=h&&"\udbff">h&&g<b.length-1?(h=b.slice(g,g+2),++g):g&&(f&&Ab(b,g))&&a.pre.appendChild(n("wbr"));i=a.measure[a.pos]=
  wd(a,h,c,i&&d,g==b.length-1&&e);B&&(f&&" "==h&&g&&!/\s/.test(b.charAt(g-1))&&g<b.length-1&&!/\s/.test(b.charAt(g+1)))&&(i.style.whiteSpace="normal");a.pos+=h.length}b.length&&(a.addedOne=!0)}function ke(a){function b(a){for(var b=" ",e=0;e<a.length-2;++e)b+=e%2?" ":" ";return b+" "}return function(c,d,e,f,g){return a(c,d.replace(/ {3,}/,b),e,f,g)}}function xd(a,b,c){c&&(a.display||(c=c.cloneNode(!0)),a.pre.appendChild(c),a.measure&&b&&(a.measure[a.pos]=c,a.addedOne=!0));a.pos+=b}function sc(a,b,c,
  d,e){function f(a){return c?c[a]:null}function g(a,c,d){var f=e;a.text=c;a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null);null!=a.order&&(a.order=null);qd(a);rd(a,d);c=f?f(a):1;c!=a.height&&M(a,c);O(a,"change",a,b)}var h=b.from,i=b.to,j=b.text,k=q(a,h.line),m=q(a,i.line),s=E(j),l=f(j.length-1),o=i.line-h.line;if(0==h.ch&&0==i.ch&&""==s){for(var n=0,p=j.length-1,r=[];n<p;++n)r.push(Ua(j[n],f(n),e));g(m,m.text,l);o&&a.remove(h.line,o);r.length&&a.insert(h.line,r)}else if(k==m)if(1==j.length)g(k,
  k.text.slice(0,h.ch)+s+k.text.slice(i.ch),l);else{r=[];n=1;for(p=j.length-1;n<p;++n)r.push(Ua(j[n],f(n),e));r.push(Ua(s+k.text.slice(i.ch),l,e));g(k,k.text.slice(0,h.ch)+j[0],f(0));a.insert(h.line+1,r)}else if(1==j.length)g(k,k.text.slice(0,h.ch)+j[0]+m.text.slice(i.ch),f(0)),a.remove(h.line+1,o);else{g(k,k.text.slice(0,h.ch)+j[0],f(0));g(m,s+m.text.slice(i.ch),l);n=1;p=j.length-1;for(r=[];n<p;++n)r.push(Ua(j[n],f(n),e));1<o&&a.remove(h.line+1,o-1);a.insert(h.line+1,r)}O(a,"change",a,b);Y(a,d.anchor,
  d.head,null,!0)}function Bb(a){this.lines=a;this.parent=null;for(var b=0,c=a.length,d=0;b<c;++b)a[b].parent=this,d+=a[b].height;this.height=d}function Va(a){this.children=a;for(var b=0,c=0,d=0,e=a.length;d<e;++d){var f=a[d],b=b+f.chunkSize(),c=c+f.height;f.parent=this}this.size=b;this.height=c;this.parent=null}function za(a,b,c){function d(a,f,g){if(a.linked)for(var h=0;h<a.linked.length;++h){var i=a.linked[h];if(i.doc!=f){var j=g&&i.sharedHist;if(!c||j)b(i.doc,j),d(i.doc,a,j)}}}d(a,null,!0)}function Cc(a,
  b){if(b.cm)throw Error("This document is already in use.");a.doc=b;b.cm=a;Gc(a);Ca(a);a.options.lineWrapping||Pb(a);a.options.mode=b.modeOption;u(a)}function q(a,b){for(b-=a.first;!a.lines;)for(var c=0;;++c){var d=a.children[c],e=d.chunkSize();if(b<e){a=d;break}b-=e}return a.lines[b]}function rc(a,b,c){var d=[],e=b.line;a.iter(b.line,c.line+1,function(a){a=a.text;e==c.line&&(a=a.slice(0,c.ch));e==b.line&&(a=a.slice(b.ch));d.push(a);++e});return d}function xc(a,b,c){var d=[];a.iter(b,c,function(a){d.push(a.text)});
  return d}function M(a,b){for(var c=b-a.height,d=a;d;d=d.parent)d.height+=c}function H(a){if(null==a.parent)return null;for(var b=a.parent,a=U(b.lines,a),c=b.parent;c;b=c,c=c.parent)for(var d=0;c.children[d]!=b;++d)a+=c.children[d].chunkSize();return a+b.first}function cb(a,b){var c=a.first;a:do{for(var d=0,e=a.children.length;d<e;++d){var f=a.children[d],g=f.height;if(b<g){a=f;continue a}b-=g;c+=f.chunkSize()}return c}while(!a.lines);d=0;for(e=a.lines.length;d<e;++d){f=a.lines[d].height;if(b<f)break;
  b-=f}return c+d}function na(a,b){for(var b=ma(a.doc,b),c=0,d=b.parent,e=0;e<d.lines.length;++e){var f=d.lines[e];if(f==b)break;else c+=f.height}for(f=d.parent;f;d=f,f=d.parent)for(e=0;e<f.children.length;++e){var g=f.children[e];if(g==d)break;else c+=g.height}return c}function Q(a){var b=a.order;null==b&&(b=a.order=le(a.text));return b}function Cb(){return{done:[],undone:[],undoDepth:Infinity,lastTime:0,lastOp:null,lastOrigin:null,dirtyCounter:0}}function yd(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,
  c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans);++f})}function qc(a,b){var c={from:b.from,to:mc(b),text:rc(a,b.from,b.to)};yd(a,c,b.from.line,b.to.line+1);za(a,function(a){yd(a,c,b.from.line,b.to.line+1)},!0);return c}function fd(a,b,c,d){var e=a.history;e.undone.length=0;var f=+new Date,g=E(e.done);if(g&&(e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))){var h=
  E(g.changes);w(b.from,b.to)&&w(b.from,h.to)?h.to=mc(b):g.changes.push(qc(a,b));g.anchorAfter=c.anchor;g.headAfter=c.head}else{g={changes:[qc(a,b)],anchorBefore:a.sel.anchor,headBefore:a.sel.head,anchorAfter:c.anchor,headAfter:c.head};for(e.done.push(g);e.done.length>e.undoDepth;)e.done.shift();0>e.dirtyCounter?e.dirtyCounter=NaN:e.dirtyCounter++}e.lastTime=f;e.lastOp=d;e.lastOrigin=b.origin}function he(a){if(!a)return null;for(var b=0,c;b<a.length;++b)a[b].marker.explicitlyCleared?c||(c=a.slice(0,
  b)):c&&c.push(a[b]);return!c?a:c.length?c:null}function Db(a,b){for(var c=0,d=[];c<a.length;++c){var e=a[c],f=e.changes,g=[];d.push({changes:g,anchorBefore:e.anchorBefore,headBefore:e.headBefore,anchorAfter:e.anchorAfter,headAfter:e.headAfter});for(e=0;e<f.length;++e){var h=f[e],i;g.push({from:h.from,to:h.to,text:h.text});if(b)for(var j in h)if((i=j.match(/^spans_(\d+)$/))&&-1<U(b,Number(i[1])))E(g)[j]=h[j],delete h[j]}}return d}function Eb(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}
  function zd(a,b,c,d){for(var e=0;e<a.length;++e){for(var f=a[e],g=!0,h=0;h<f.changes.length;++h){var i=f.changes[h];f.copied||(i.from=fa(i.from),i.to=fa(i.to));if(c<i.from.line)i.from.line+=d,i.to.line+=d;else if(b<=i.to.line){g=!1;break}}f.copied||(f.anchorBefore=fa(f.anchorBefore),f.headBefore=fa(f.headBefore),f.anchorAfter=fa(f.anchorAfter),f.readAfter=fa(f.headAfter),f.copied=!0);g?(Eb(f.anchorBefore),Eb(f.headBefore),Eb(f.anchorAfter),Eb(f.headAfter)):(a.splice(0,e+1),e=0)}}function gd(a,b){var c=
  b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;zd(a.done,c,d,e);zd(a.undone,c,d,e)}function me(){Na(this)}function Ma(a){a.stop||(a.stop=me);return a}function z(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Ad(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function Na(a){z(a);Ad(a)}function Xc(a){var b=a.which;null==b&&(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));oa&&(a.ctrlKey&&1==b)&&(b=3);return b}function t(a,b,c){a.addEventListener?a.addEventListener(b,c,
  !1):a.attachEvent?a.attachEvent("on"+b,c):(a=a._handlers||(a._handlers={}),(a[b]||(a[b]=[])).push(c))}function T(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else if(a=a._handlers&&a._handlers[b])for(b=0;b<a.length;++b)if(a[b]==c){a.splice(b,1);break}}function D(a,b){var c=a._handlers&&a._handlers[b];if(c)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,d)}function O(a,b){function c(a){return function(){a.apply(null,
  e)}}var d=a._handlers&&a._handlers[b];if(d){var e=Array.prototype.slice.call(arguments,2);X||(++kb,X=[],setTimeout(ne,0));for(var f=0;f<d.length;++f)X.push(c(d[f]))}}function ne(){--kb;var a=X;X=null;for(var b=0;b<a.length;++b)a[b]()}function xa(a,b){var c=a._handlers&&a._handlers[b];return c&&0<c.length}function Kb(){this.id=null}function qa(a,b,c,d,e){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));d=d||0;for(e=e||0;d<b;++d)"\t"==a.charAt(d)?e+=c-e%c:++e;return e}function md(a){for(;Fb.length<=
  a;)Fb.push(E(Fb)+" ");return Fb[a]}function E(a){return a[a.length-1]}function Sc(a){Ba?(a.selectionStart=0,a.selectionEnd=a.value.length):a.select()}function U(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;++c)if(a[c]==b)return c;return-1}function Bd(a,b){function c(){}c.prototype=a;var d=new c;b&&yb(b,d);return d}function yb(a,b){b||(b={});for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function Oc(a){for(var b=[],c=0;c<a;++c)b.push(void 0);return b}function K(a){var b=
  Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function xb(a){return/\w/.test(a)||""<a&&(a.toUpperCase()!=a.toLowerCase()||oe.test(a))}function Cd(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function n(a,b,c,d){a=document.createElement(a);c&&(a.className=c);d&&(a.style.cssText=d);if("string"==typeof b)Ic(a,b);else if(b)for(c=0;c<b.length;++c)a.appendChild(b[c]);return a}function ab(a){for(var b=a.childNodes.length;0<b;--b)a.removeChild(a.firstChild);
  return a}function R(a,b){return ab(a).appendChild(b)}function Ic(a,b){J?(a.innerHTML="",a.appendChild(document.createTextNode(b))):a.textContent=b}function y(a){return a.getBoundingClientRect()}function Ab(){return!1}function Ga(a){if(null!=Gb)return Gb;var b=n("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");R(a,b);b.offsetWidth&&(Gb=b.offsetHeight-b.clientHeight);return Gb||0}function lb(a){if(null==yc){var b=n("span","​");R(a,n("span",[b,document.createTextNode("x")]));0!=a.firstChild.offsetHeight&&
  (yc=1>=b.offsetWidth&&2<b.offsetHeight&&!ka)}return yc?n("span","​"):n("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function Qd(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=0;e<a.length;++e){var f=a[e];if(f.from<c&&f.to>b||b==c&&f.to==b)d(Math.max(f.from,b),Math.min(f.to,c),1==f.level?"rtl":"ltr")}}function Zb(a){return a.level%2?a.from:a.to}function ib(a){return(a=Q(a))?a[0].level%2?a[0].to:a[0].from:0}function jb(a){var b=Q(a);return!b?a.text.length:Zb(E(b))}function Dd(a,
  b){var c=q(a.doc,b),d=ma(a.doc,c);d!=c&&(b=H(d));c=Q(d);d=!c?0:c[0].level%2?jb(d):ib(d);return o(b,d)}function pe(a,b){for(var c,d;c=Fa(d=q(a.doc,b));)b=c.find().to.line;c=Q(d);d=!c?d.text.length:c[0].level%2?ib(d):jb(d);return o(b,d)}function $b(a,b){for(var c=0,d;c<a.length;++c){var e=a[c];if(e.from<b&&e.to>b)return ra=null,c;if(e.from==b||e.to==b)if(null==d)d=c;else{var e=e.level,f=a[d].level,g=a[0].level,e=e==g?!0:f==g?!1:e<f;if(e)return ra=d,c;ra=c;return d}}ra=null;return d}function zc(a,b,
  c,d){if(!d)return b+c;do b+=c;while(0<b&&cc.test(a.text.charAt(b)));return b}function bc(a,b,c,d){var e=Q(a);if(!e)return nd(a,b,c,d);for(var f=$b(e,b),g=e[f],b=zc(a,b,g.level%2?-c:c,d);;){if(b>g.from&&b<g.to)return b;if(b==g.from||b==g.to){if($b(e,b)==f)return b;g=e[f+c];return 0<c==g.level%2?g.to:g.from}g=e[f+=c];if(!g)return null;b=0<c==g.level%2?zc(a,g.to,-1,d):zc(a,g.from,1,d)}}function nd(a,b,c,d){b+=c;if(d)for(;0<b&&cc.test(a.text.charAt(b));)b+=c;return 0>b||b>a.text.length?null:b}var ya=
  /gecko\/\d/i.test(navigator.userAgent),B=/MSIE \d/.test(navigator.userAgent),ka=B&&(null==document.documentMode||8>document.documentMode),J=B&&(null==document.documentMode||9>document.documentMode),L=/WebKit\//.test(navigator.userAgent),qe=L&&/Qt\/\d+\.\d+/.test(navigator.userAgent),re=/Chrome\//.test(navigator.userAgent),S=/Opera\//.test(navigator.userAgent),hc=/Apple Computer/.test(navigator.vendor),Nb=/KHTML\//.test(navigator.userAgent),Hd=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),
  Id=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),Wd=/PhantomJS/.test(navigator.userAgent),Ba=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Jb=Ba||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),oa=Ba||/Mac/.test(navigator.platform),se=/windows/i.test(navigator.platform),Wa=S&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Wa&&(Wa=Number(Wa[1]));var pd=oa&&(qe||S&&(null==Wa||12.11>Wa)),gc=ya||B&&!J,ed=!1,Ha=!1,ca,
  Vd=0,pb,ob,qb=0,N=null;B?N=-0.53:ya?N=15:re?N=-0.7:hc&&(N=-1/3);var ad,kc=null,lc;l.Pos=o;l.prototype={constructor:l,focus:function(){window.focus();G(this);$(this);Ka(this)},setOption:function(a,b){var c=this.options,d=c[a];c[a]==b&&"mode"!=a||(c[a]=b,ia.hasOwnProperty(a)&&p(this,ia[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](a)},removeKeyMap:function(a){for(var b=this.state.keyMaps,
  c=0;c<b.length;++c)if(("string"==typeof a?b[c].name:b[c])==a)return b.splice(c,1),!0},addOverlay:p(null,function(a,b){var c=a.token?a:l.getMode(this.options,a);if(c.startState)throw Error("Overlays may not be stateful.");this.state.overlays.push({mode:c,modeSpec:a,opaque:b&&b.opaque});this.state.modeGen++;u(this)}),removeOverlay:p(null,function(a){for(var b=this.state.overlays,c=0;c<b.length;++c)if(b[c].modeSpec==a){b.splice(c,1);this.state.modeGen++;u(this);break}}),indentLine:p(null,function(a,
  b,c){"string"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract");Aa(this.doc,a)&&sb(this,a,b,c)}),indentSelection:p(null,function(a){var b=this.doc.sel;if(w(b.from,b.to))return sb(this,b.from.line,a);for(var c=b.to.line-(b.to.ch?0:1),b=b.from.line;b<=c;++b)sb(this,b,a)}),getTokenAt:function(a){for(var b=this.doc,a=r(b,a),c=Ia(this,a.line),d=this.doc.mode,b=q(b,a.line),b=new Ra(b.text,this.options.tabSize);b.pos<a.ch&&!b.eol();){b.start=b.pos;var e=d.token(b,c)}return{start:b.start,
  end:b.pos,string:b.current(),className:e||null,type:e||null,state:c}},getStateAfter:function(a){var b=this.doc,a=Math.max(b.first,Math.min(null==a?b.first+b.size-1:a,b.first+b.size-1));return Ia(this,a+1)},cursorCoords:function(a,b){var c;c=this.doc.sel;c=null==a?c.head:"object"==typeof a?r(this.doc,a):a?c.from:c.to;return P(this,c,b||"page")},charCoords:function(a,b){return eb(this,r(this.doc,a),b||"page")},coordsChar:function(a,b){var c=b||"page";if("div"!=c){var d=a.left,e=a.top;"page"==c&&(d-=
  window.pageXOffset||(document.documentElement||document.body).scrollLeft,e-=window.pageYOffset||(document.documentElement||document.body).scrollTop);var f=y(this.display.lineSpace),d=d-f.left,e=e-f.top;if("local"==c||!c)c=y(this.display.wrapper),d+=c.left,e+=c.top;a={left:d,top:e}}return ac(this,a.left,a.top)},defaultTextHeight:function(){return Da(this.display)},defaultCharWidth:function(){return Fc(this.display)},setGutterMarker:p(null,function(a,b,c){return wb(this,a,function(a){var e=a.gutterMarkers||
  (a.gutterMarkers={});e[b]=c;!c&&Cd(e)&&(a.gutterMarkers=null);return!0})}),clearGutter:p(null,function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,u(b,d,d+1),Cd(c.gutterMarkers)&&(c.gutterMarkers=null));++d})}),addLineClass:p(null,function(a,b,c){return wb(this,a,function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"wrapClass";if(a[e]){if(RegExp("\\b"+c+"\\b").test(a[e]))return!1;a[e]+=" "+c}else a[e]=c;return!0})}),
  removeLineClass:p(null,function(a,b,c){return wb(this,a,function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"wrapClass",f=a[e];if(f)if(null==c)a[e]=null;else{var g=f.replace(RegExp("^"+c+"\\b\\s*|\\s*\\b"+c+"\\b"),"");if(g==f)return!1;a[e]=g||null}else return!1;return!0})}),addLineWidget:p(null,function(a,b,c){return ie(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if("number"==typeof a){if(!Aa(this.doc,a))return null;var b=a,a=q(this.doc,a);if(!a)return null}else if(b=
  H(a),null==b)return null;return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(a,b,c,d,e){var f=this.display,a=P(this,r(this.doc,a)),g=a.bottom,h=a.left;b.style.position="absolute";f.sizer.appendChild(b);if("over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),
  j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom);h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+f.lineSpace.offsetTop+"px";b.style.left=b.style.right="";"right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px");c&&(a=mb(this,h,g,h+b.offsetWidth,g+b.offsetHeight),
  null!=a.scrollTop&&Oa(this,a.scrollTop),null!=a.scrollLeft&&ua(this,a.scrollLeft))},triggerOnKeyDown:p(null,Wc),execCommand:function(a){return ic[a](this)},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,a=r(this.doc,a);f<b&&!(a=tc(this.doc,a,e,c,d),a.hitSide);++f);return a},moveH:p(null,function(a,b){var c=this.doc.sel,c=c.shift||c.extend||w(c.from,c.to)?tc(this.doc,c.head,a,b,this.options.rtlMoveVisually):0>a?c.from:c.to;A(this.doc,c,c,a)}),deleteH:p(null,function(a,b){var c=this.doc.sel;
  w(c.from,c.to)?Z(this.doc,"",c.from,tc(this.doc,c.head,a,b,!1),"+delete"):Z(this.doc,"",c.from,c.to,"+delete");this.curOp.userSelChange=!0}),findPosV:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,a=r(this.doc,a);f<b&&!(a=P(this,a,"div"),null==d?d=a.left:a.left=d,a=od(this,a,e,c),a.hitSide);++f);return a},moveV:p(null,function(a,b){var c=this.doc.sel,d=P(this,c.head,"div");null!=c.goalColumn&&(d.left=c.goalColumn);var e=od(this,d,a,b);"page"==b&&ld(this,0,eb(this,e,"div").top-d.top);A(this.doc,
  e,e,a);c.goalColumn=d.left}),toggleOverwrite:function(a){null!=a&&a==this.state.overwrite||(this.display.cursor.className=(this.state.overwrite=!this.state.overwrite)?this.display.cursor.className+" CodeMirror-overwrite":this.display.cursor.className.replace(" CodeMirror-overwrite",""))},hasFocus:function(){return this.state.focused},scrollTo:p(null,function(a,b){vb(this,a,b)}),getScrollInfo:function(){var a=this.display.scroller,b=ja;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-
  b,width:a.scrollWidth-b,clientHeight:a.clientHeight-b,clientWidth:a.clientWidth-b}},scrollIntoView:p(null,function(a,b){"number"==typeof a&&(a=o(a,0));b||(b=0);var c=a;if(!a||null!=a.line)this.curOp.scrollToPos=a?r(this.doc,a):this.doc.sel.head,this.curOp.scrollToPosMargin=b,c=P(this,this.curOp.scrollToPos);c=mb(this,c.left,c.top-b,c.right,c.bottom+b);vb(this,c.scrollLeft,c.scrollTop)}),setSize:function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(""+a)?a+"px":a}null!=a&&(this.display.wrapper.style.width=
  c(a));null!=b&&(this.display.wrapper.style.height=c(b));this.refresh()},on:function(a,b){t(this,a,b)},off:function(a,b){T(this,a,b)},operation:function(a){return dc(this,a)},refresh:p(null,function(){la(this);vb(this,this.doc.scrollLeft,this.doc.scrollTop);u(this)}),swapDoc:p(null,function(a){var b=this.doc;b.cm=null;Cc(this,a);la(this);W(this,!0);vb(this,a.scrollLeft,a.scrollTop);return b}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},
  getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};var ia=l.optionHandlers={},Hb=l.defaults={},Dc=l.Init={toString:function(){return"CodeMirror.Init"}};v("value","",function(a,b){a.setValue(b)},!0);v("mode",null,function(a,b){a.doc.modeOption=b;Ca(a)},!0);v("indentUnit",2,Ca,!0);v("indentWithTabs",!1);v("smartIndent",!0);v("tabSize",4,function(a){Ca(a);la(a);u(a)},!0);v("electricChars",!0);v("rtlMoveVisually",!se);v("theme","default",
  function(a){Bc(a);Ea(a)},!0);v("keyMap","default",function(a){var b=V[a.options.keyMap].style;a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(b?" cm-keymap-"+b:"")});v("extraKeys",null);v("onKeyEvent",null);v("onDragEvent",null);v("lineWrapping",!1,function(a){if(a.options.lineWrapping){a.display.wrapper.className=a.display.wrapper.className+" CodeMirror-wrap";a.display.sizer.style.minWidth=""}else{a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-wrap",
  "");Pb(a)}Gc(a);u(a);la(a);setTimeout(function(){Qb(a)},100)},!0);v("gutters",[],function(a){Ib(a.options);Ea(a)},!0);v("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?Sb(a.display)+"px":"0";a.refresh()},!0);v("coverGutterNextToScrollbar",!1,Qb,!0);v("lineNumbers",!1,function(a){Ib(a.options);Ea(a)},!0);v("firstLineNumber",1,Ea,!0);v("lineNumberFormatter",function(a){return a},Ea,!0);v("showCursorWhenSelecting",!1,Tb,!0);v("readOnly",!1,function(a,b){if(b=="nocursor"){Lb(a);a.display.input.blur()}else b||
  W(a,true)});v("dragDrop",!0);v("cursorBlinkRate",530);v("cursorScrollMargin",0);v("cursorHeight",1);v("workTime",100);v("workDelay",100);v("flattenSpans",!0);v("pollInterval",100);v("undoDepth",40,function(a,b){a.doc.history.undoDepth=b});v("historyEventDelay",500);v("viewportMargin",10,function(a){a.refresh()},!0);v("maxHighlightLength",1E4,function(a){Ca(a);a.refresh()},!0);v("moveInputWithCursor",!0,function(a,b){if(!b)a.display.inputDiv.style.top=a.display.inputDiv.style.left=0});v("tabindex",
  null,function(a,b){a.display.input.tabIndex=b||""});v("autofocus",null);var Ed=l.modes={},Xa=l.mimeModes={};l.defineMode=function(a,b){!l.defaults.mode&&"null"!=a&&(l.defaults.mode=a);if(2<arguments.length){b.dependencies=[];for(var c=2;c<arguments.length;++c)b.dependencies.push(arguments[c])}Ed[a]=b};l.defineMIME=function(a,b){Xa[a]=b};l.resolveMode=function(a){if("string"==typeof a&&Xa.hasOwnProperty(a))a=Xa[a];else if(a&&"string"==typeof a.name&&Xa.hasOwnProperty(a.name)){var b=Xa[a.name],a=Bd(b,
  a);a.name=b.name}else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return l.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}};l.getMode=function(a,b){var b=l.resolveMode(b),c=Ed[b.name];if(!c)return l.getMode(a,"text/plain");c=c(a,b);if(Ya.hasOwnProperty(b.name)){var d=Ya[b.name],e;for(e in d)d.hasOwnProperty(e)&&(c.hasOwnProperty(e)&&(c["_"+e]=c[e]),c[e]=d[e])}c.name=b.name;return c};l.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}});
  l.defineMIME("text/plain","null");var Ya=l.modeExtensions={};l.extendMode=function(a,b){var c=Ya.hasOwnProperty(a)?Ya[a]:Ya[a]={};yb(b,c)};l.defineExtension=function(a,b){l.prototype[a]=b};l.defineDocExtension=function(a,b){F.prototype[a]=b};l.defineOption=v;var Mb=[];l.defineInitHook=function(a){Mb.push(a)};l.copyState=pa;l.startState=Nc;l.innerMode=function(a,b){for(;a.innerMode;)var c=a.innerMode(b),b=c.state,a=c.mode;return c||{mode:a,state:b}};var ic=l.commands={selectAll:function(a){a.setSelection(o(a.firstLine(),
  0),o(a.lastLine()))},killLine:function(a){var b=a.getCursor(!0),c=a.getCursor(!1),d=!w(b,c);!d&&a.getLine(b.line).length==b.ch?a.replaceRange("",b,o(b.line+1,0),"+delete"):a.replaceRange("",b,d?c:o(b.line),"+delete")},deleteLine:function(a){var b=a.getCursor().line;a.replaceRange("",o(b,0),o(b),"+delete")},undo:function(a){a.undo()},redo:function(a){a.redo()},goDocStart:function(a){a.extendSelection(o(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(o(a.lastLine()))},goLineStart:function(a){a.extendSelection(Dd(a,
  a.getCursor().line))},goLineStartSmart:function(a){var b=a.getCursor(),c=Dd(a,b.line),d=a.getLineHandle(c.line),e=Q(d);!e||0==e[0].level?(d=Math.max(0,d.text.search(/\S/)),a.extendSelection(o(c.line,b.line==c.line&&b.ch<=d&&b.ch?0:d))):a.extendSelection(c)},goLineEnd:function(a){a.extendSelection(pe(a,a.getCursor().line))},goLineRight:function(a){var b=a.charCoords(a.getCursor(),"div").top+5;a.extendSelection(a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:b},"div"))},goLineLeft:function(a){var b=
  a.charCoords(a.getCursor(),"div").top+5;a.extendSelection(a.coordsChar({left:0,top:b},"div"))},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goGroupRight:function(a){a.moveH(1,
  "group")},goGroupLeft:function(a){a.moveH(-1,"group")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,"word")},delGroupBefore:function(a){a.deleteH(-1,"group")},delGroupAfter:function(a){a.deleteH(1,"group")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},
  insertTab:function(a){a.replaceSelection("\t","end","+input")},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.replaceSelection("\t","end","+input")},transposeChars:function(a){var b=a.getCursor(),c=a.getLine(b.line);0<b.ch&&b.ch<c.length-1&&a.replaceRange(c.charAt(b.ch)+c.charAt(b.ch-1),o(b.line,b.ch-1),o(b.line,b.ch+1))},newlineAndIndent:function(a){p(a,function(){a.replaceSelection("\n","end","+input");a.indentLine(a.getCursor().line,null,!0)})()},toggleOverwrite:function(a){a.toggleOverwrite()}},
  V=l.keyMap={};V.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"};V.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd",
  "Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore",fallthrough:"basic"};V.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd",
  "Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore",fallthrough:["basic","emacsy"]};V["default"]=oa?V.macDefault:V.pcDefault;V.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft",
  "Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};l.lookupKey=Pa;l.isModifierKey=bd;l.keyName=cd;l.fromTextArea=function(a,b){function c(){a.value=j.getValue()}b||(b={});b.value=a.value;!b.tabindex&&a.tabindex&&(b.tabindex=
  a.tabindex);!b.placeholder&&a.placeholder&&(b.placeholder=a.placeholder);if(null==b.autofocus){var d=document.body;try{d=document.activeElement}catch(e){}b.autofocus=d==a||null!=a.getAttribute("autofocus")&&d==document.body}if(a.form&&(t(a.form,"submit",c),!b.leaveSubmitMethodAlone)){var f=a.form,g=f.submit;try{var h=f.submit=function(){c();f.submit=g;f.submit();f.submit=h}}catch(i){}}a.style.display="none";var j=l(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);j.save=c;j.getTextArea=
  function(){return a};j.toTextArea=function(){c();a.parentNode.removeChild(j.getWrapperElement());a.style.display="";if(a.form){T(a.form,"submit",c);if(typeof a.form.submit=="function")a.form.submit=g}};return j};Ra.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(a){var b=this.string.charAt(this.pos);
  if("string"==typeof a?b==a:b&&(a.test?a.test(b):a(b)))return++this.pos,b},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){a=this.string.indexOf(a,this.pos);if(-1<a)return this.pos=a,!0},backUp:function(a){this.pos-=a},column:function(){this.lastColumnPos<this.start&&(this.lastColumnValue=
  qa(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start);return this.lastColumnValue},indentation:function(){return qa(this.string,null,this.tabSize)},match:function(a,b,c){if("string"==typeof a){var d=this.string.substr(this.pos,a.length);if((c?d.toLowerCase():d)==(c?a.toLowerCase():a))return!1!==b&&(this.pos+=a.length),!0}else{if((a=this.string.slice(this.pos).match(a))&&0<a.index)return null;a&&!1!==b&&(this.pos+=a[0].length);return a}},current:function(){return this.string.slice(this.start,
  this.pos)}};l.StringStream=Ra;l.TextMarker=ha;ha.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&sa(a);for(var c=null,d=null,e=0;e<this.lines.length;++e){var f=this.lines[e],g=Ta(f.markedSpans,this);null!=g.to&&(d=H(f));for(var h=f,i=f.markedSpans,j=g,k=void 0,m=0;m<i.length;++m)i[m]!=j&&(k||(k=[])).push(i[m]);h.markedSpans=k;null!=g.from?c=H(f):this.collapsed&&(!aa(this.doc,f)&&a)&&M(f,Da(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(e=0;e<
  this.lines.length;++e)f=ma(a.doc,this.lines[e]),g=bb(a.doc,f),g>a.display.maxLineLength&&(a.display.maxLine=f,a.display.maxLineLength=g,a.display.maxLineChanged=!0);null!=c&&a&&u(a,c,d+1);this.lines.length=0;this.explicitlyCleared=!0;this.collapsed&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&kd(a));b&&ta(a);O(this,"clear")}};ha.prototype.find=function(){for(var a,b,c=0;c<this.lines.length;++c){var d=this.lines[c],e=Ta(d.markedSpans,this);if(null!=e.from||null!=e.to)d=H(d),null!=e.from&&(a=o(d,e.from)),
  null!=e.to&&(b=o(d,e.to))}return"bookmark"==this.type?a:a&&{from:a,to:b}};ha.prototype.changed=function(){var a=this.find(),b=this.doc.cm;if(a&&b){var c=q(this.doc,a.from.line);Td(b,c);if(a.from.line>=b.display.showingFrom&&a.from.line<b.display.showingTo){for(a=b.display.lineDiv.firstChild;a;a=a.nextSibling)if(a.lineObj==c){a.offsetHeight!=c.height&&M(c,a.offsetHeight);break}dc(b,function(){b.curOp.selectionChanged=!0})}}};ha.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=
  this.doc.cm.curOp;if(!b.maybeHiddenMarkers||-1==U(b.maybeHiddenMarkers,this))(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)};ha.prototype.detachLine=function(a){this.lines.splice(U(this.lines,a),1);!this.lines.length&&this.doc.cm&&(a=this.doc.cm.curOp,(a.maybeHiddenMarkers||(a.maybeHiddenMarkers=[])).push(this))};l.SharedTextMarker=zb;zb.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();
  O(this,"clear")}};zb.prototype.find=function(){return this.primary.find()};var vc=l.LineWidget=function(a,b,c){for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.cm=a;this.node=b};vc.prototype.clear=sd(function(){var a=this.line.widgets,b=H(this.line);if(null!=b&&a){for(var c=0;c<a.length;++c)a[c]==this&&a.splice(c--,1);a.length||(this.line.widgets=null);M(this.line,Math.max(0,this.line.height-gb(this)));u(this.cm,b,b+1)}});vc.prototype.changed=sd(function(){var a=this.height;this.height=null;
  if(a=gb(this)-a)M(this.line,this.line.height+a),a=H(this.line),u(this.cm,a,a+1)});var vd={},wc=/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;Bb.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=a,d=a+b;c<d;++c){var e=this.lines[c];this.height-=e.height;var f=e;f.parent=null;qd(f);O(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertInner:function(a,b,c){this.height+=c;this.lines=this.lines.slice(0,
  a).concat(b).concat(this.lines.slice(a));a=0;for(c=b.length;a<c;++a)b[a].parent=this},iterN:function(a,b,c){for(b=a+b;a<b;++a)if(c(this.lines[a]))return!0}};Va.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(a<e){var f=Math.min(b,e-a),g=d.height;d.removeInner(a,f);this.height-=g-d.height;e==f&&(this.children.splice(c--,1),d.parent=null);if(0==(b-=f))break;a=0}else a-=e}25>this.size-
  b&&(c=[],this.collapse(c),this.children=[new Bb(c)],this.children[0].parent=this)},collapse:function(a){for(var b=0,c=this.children.length;b<c;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=b.length;this.height+=c;for(var d=0,e=this.children.length;d<e;++d){var f=this.children[d],g=f.chunkSize();if(a<=g){f.insertInner(a,b,c);if(f.lines&&50<f.lines.length){for(;50<f.lines.length;)a=f.lines.splice(f.lines.length-25,25),a=new Bb(a),f.height-=a.height,this.children.splice(d+
  1,0,a),a.parent=this;this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(!(10>=this.children.length)){var a=this;do{var b=a.children.splice(a.children.length-5,5),b=new Va(b);if(a.parent){a.size-=b.size;a.height-=b.height;var c=U(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else c=new Va(a.children),c.parent=a,a.children=[c,b],a=c;b.parent=a.parent}while(10<a.children.length);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0,e=this.children.length;d<e;++d){var f=this.children[d],
  g=f.chunkSize();if(a<g){g=Math.min(b,g-a);if(f.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=g}}};var te=0,F=l.Doc=function(a,b,c){if(!(this instanceof F))return new F(a,b,c);null==c&&(c=0);Va.call(this,[new Bb([Ua("",null)])]);this.first=c;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.history=Cb();this.frontier=c;c=o(c,0);this.sel={from:c,to:c,head:c,anchor:c,shift:!1,extend:!1,goalColumn:null};this.id=++te;this.modeOption=b;"string"==typeof a&&(a=da(a));sc(this,{from:c,to:c,text:a},
  null,{head:c,anchor:c})};F.prototype=Bd(Va.prototype,{constructor:F,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0,e=b.length;d<e;++d)c+=b[d].height;this.insertInner(a-this.first,b,c)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=xc(this,this.first,this.first+this.size);return!1===a?b:b.join(a||"\n")},setValue:function(a){var b=o(this.first,0),c=this.first+this.size-1;va(this,
  {from:b,to:o(c,q(this,c).text.length),text:da(a),origin:"setValue"},{head:b,anchor:b},!0)},replaceRange:function(a,b,c,d){b=r(this,b);c=c?r(this,c):b;Z(this,a,b,c,d)},getRange:function(a,b,c){a=rc(this,r(this,a),r(this,b));return!1===c?a:a.join(c||"\n")},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},setLine:function(a,b){Aa(this,a)&&Z(this,b,o(a,0),r(this,o(a)))},removeLine:function(a){a?Z(this,"",r(this,o(a-1)),r(this,o(a))):Z(this,"",o(0,0),r(this,o(1,0)))},getLineHandle:function(a){if(Aa(this,
  a))return q(this,a)},getLineNumber:function(a){return H(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(a){return r(this,a)},getCursor:function(a){var b=this.sel;return fa(null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||!1===a?b.to:b.from)},somethingSelected:function(){return!w(this.sel.head,this.sel.anchor)},setCursor:Ja(function(a,b,c){a=r(this,"number"==typeof a?o(a,b||0):a);c?A(this,
  a):Y(this,a,a)}),setSelection:Ja(function(a,b){Y(this,r(this,a),r(this,b||a))}),extendSelection:Ja(function(a,b){A(this,r(this,a),b&&r(this,b))}),getSelection:function(a){return this.getRange(this.sel.from,this.sel.to,a)},replaceSelection:function(a,b,c){va(this,{from:this.sel.from,to:this.sel.to,text:da(a),origin:c},b||"around")},undo:Ja(function(){hd(this,"undo")}),redo:Ja(function(){hd(this,"redo")}),setExtending:function(a){this.sel.extend=a},historySize:function(){var a=this.history;return{undo:a.done.length,
  redo:a.undone.length}},clearHistory:function(){this.history=Cb()},markClean:function(){this.history.dirtyCounter=0;this.history.lastOp=this.history.lastOrigin=null},isClean:function(){return 0==this.history.dirtyCounter},getHistory:function(){return{done:Db(this.history.done),undone:Db(this.history.undone)}},setHistory:function(a){var b=this.history=Cb();b.done=a.done.slice(0);b.undone=a.undone.slice(0)},markText:function(a,b,c){return Sa(this,r(this,a),r(this,b),c,"range")},setBookmark:function(a,
  b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft},a=r(this,a);return Sa(this,a,a,c,"bookmark")},findMarksAt:function(a){var a=r(this,a),b=[],c=q(this,a.line).markedSpans;if(c)for(var d=0;d<c.length;++d){var e=c[d];if((null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=a.ch))b.push(e.marker.parent||e.marker)}return b},getAllMarks:function(){var a=[];this.iter(function(b){if(b=b.markedSpans)for(var c=0;c<b.length;++c)null!=b[c].from&&a.push(b[c].marker)});return a},posFromIndex:function(a){var b,
  c=this.first;this.iter(function(d){d=d.text.length+1;if(d>a)return b=a,!0;a-=d;++c});return r(this,o(c,b))},indexFromPos:function(a){var a=r(this,a),b=a.ch;if(a.line<this.first||0>a.ch)return 0;this.iter(this.first,a.line,function(a){b+=a.text.length+1});return b},copy:function(a){var b=new F(xc(this,this.first,this.first+this.size),this.modeOption,this.first);b.scrollTop=this.scrollTop;b.scrollLeft=this.scrollLeft;b.sel={from:this.sel.from,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,
  shift:this.sel.shift,extend:!1,goalColumn:this.sel.goalColumn};a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory()));return b},linkedDoc:function(a){a||(a={});var b=this.first,c=this.first+this.size;null!=a.from&&a.from>b&&(b=a.from);null!=a.to&&a.to<c&&(c=a.to);b=new F(xc(this,b,c),a.mode||this.modeOption,b);a.sharedHist&&(b.history=this.history);(this.linked||(this.linked=[])).push({doc:b,sharedHist:a.sharedHist});b.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}];
  return b},unlinkDoc:function(a){a instanceof l&&(a=a.doc);if(this.linked)for(var b=0;b<this.linked.length;++b)if(this.linked[b].doc==a){this.linked.splice(b,1);a.unlinkDoc(this);break}if(a.history==this.history){var c=[a.id];za(a,function(a){c.push(a.id)},!0);a.history=Cb();a.history.done=Db(this.history.done,c);a.history.undone=Db(this.history.undone,c)}},iterLinkedDocs:function(a){za(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm}});F.prototype.eachLine=F.prototype.iter;
  var ue=["iter","insert","remove","copy","getEditor"],Za;for(Za in F.prototype)F.prototype.hasOwnProperty(Za)&&0>U(ue,Za)&&(l.prototype[Za]=function(a){return function(){return a.apply(this.doc,arguments)}}(F.prototype[Za]));l.e_stop=Na;l.e_preventDefault=z;l.e_stopPropagation=Ad;var X,kb=0;l.on=t;l.off=T;l.signal=D;var ja=30,Yc=l.Pass={toString:function(){return"CodeMirror.Pass"}};Kb.prototype={set:function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)}};l.countColumn=qa;var Fb=[""],oe=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,
  cc=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff]/;l.replaceGetRect=function(a){y=a};var be=function(){if(J)return!1;var a=n("div");return"draggable"in a||"dragDrop"in a}();ya?Ab=function(a,b){return 36==a.charCodeAt(b-1)&&39==a.charCodeAt(b)}:hc&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)?Ab=function(a,b){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(a.slice(b-
  1,b+1))}:L&&(Ab=function(a,b){return 1<b&&45==a.charCodeAt(b-1)&&/\w/.test(a.charAt(b-2))&&/[^\-?\.]/.test(a.charAt(b))?!0:/[~!#%&*)=+}\]|\"\.>,:;][({[<]|\?[\w~`@#$%\^&*(_=+{[|><]/.test(a.slice(b-1,b+1))});var Gb,yc,da=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;b<=d;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)};
  l.splitLines=da;var Xd=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return!b||b.parentElement()!=a?!1:0!=b.compareEndPoints("StartToEnd",b)},Rc=function(){var a=n("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),ga={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",
  32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};l.keyNames=ga;(function(){for(var a=0;10>a;a++)ga[a+48]=""+a;for(a=65;90>=a;a++)ga[a]=
  String.fromCharCode(a);for(a=1;12>=a;a++)ga[a+111]=ga[a+63235]="F"+a})();var ra,le=function(){function a(a){return 255>=a?b.charAt(a):1424<=a&&1524>=a?"R":1536<=a&&1791>=a?c.charAt(a-1536):1792<=a&&2220>=a?"r":"L"}var b="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",c="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",
  d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/;return function(b){if(!d.test(b))return!1;for(var c=b.length,k=[],m=0,l;m<c;++m)k.push(a(b.charCodeAt(m)));for(var m=0,n="L";m<c;++m)l=k[m],"m"==l?k[m]=n:n=l;m=0;for(n="L";m<c;++m)l=k[m],"1"==l&&"r"==n?k[m]="n":f.test(l)&&(n=l,"r"==l&&(k[m]="R"));m=1;for(n=k[0];m<c-1;++m){l=k[m];if("+"==l&&"1"==n&&"1"==k[m+1])k[m]="1";else if(","==l&&n==k[m+1]&&("1"==n||"n"==n))k[m]=n;n=l}for(m=0;m<c;++m)if(l=k[m],","==l)k[m]="N";
  else if("%"==l){for(n=m+1;n<c&&"%"==k[n];++n);var o=m&&"!"==k[m-1]||n<c-1&&"1"==k[n]?"1":"N";for(l=m;l<n;++l)k[l]=o;m=n-1}m=0;for(n="L";m<c;++m)l=k[m],"L"==n&&"1"==l?k[m]="L":f.test(l)&&(n=l);for(m=0;m<c;++m)if(e.test(k[m])){for(n=m+1;n<c&&e.test(k[n]);++n);l="L"==(n<c-1?k[n]:"L");o="L"==(m?k[m-1]:"L")||l?"L":"R";for(l=m;l<n;++l)k[l]=o;m=n-1}for(var n=[],q,m=0;m<c;)if(g.test(k[m])){l=m;for(++m;m<c&&g.test(k[m]);++m);n.push({from:l,to:m,level:0})}else{var p=m,o=n.length;for(++m;m<c&&"L"!=k[m];++m);
  for(l=p;l<m;)if(h.test(k[l])){p<l&&n.splice(o,0,{from:p,to:l,level:1});p=l;for(++l;l<m&&h.test(k[l]);++l);n.splice(o,0,{from:p,to:l,level:2});p=l}else++l;p<m&&n.splice(o,0,{from:p,to:m,level:1})}if(1==n[0].level&&(q=b.match(/^\s+/)))n[0].from=q[0].length,n.unshift({from:0,to:q[0].length,level:0});if(1==E(n).level&&(q=b.match(/\s+$/)))E(n).to-=q[0].length,n.push({from:c-q[0].length,to:c,level:0});n[0].level!=E(n).level&&n.push({from:c,to:c,level:n[0].level});return n}}();l.version="3.13";return l}();