patch_file/ckeditor/plugins/codemirror/js/codemirror.min.js

247 lines
125 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(m){if("object"==typeof exports&&"object"==typeof module)module.exports=m();else{if("function"==typeof define&&define.amd)return define([],m);this.CodeMirror=m()}})(function(){function m(a,b){if(!(this instanceof m))return new m(a,b);this.options=b=b||{};Ra(Ne,b,!1);jc(b);var c=b.value;"string"==typeof c&&(c=new L(c,b.mode));this.doc=c;var d=this.display=new Oe(a,c);d.wrapper.CodeMirror=this;id(this);jd(this);b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");b.autofocus&&
!kc&&M(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new lc};aa&&setTimeout(T(U,this,!0),20);Pe(this);kd||(Qe(),kd=!0);var e=this;ba(this,function(){e.curOp.forceUpdate=true;ld(e,c);b.autofocus&&!kc||ja()==d.input?setTimeout(T(mc,e),20):vb(e);for(var a in Fa)if(Fa.hasOwnProperty(a))Fa[a](e,b[a],md);for(a=0;a<nc.length;++a)nc[a](e)})}function Oe(a,b){var c=this.input=q("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
J?c.style.width="1000px":c.setAttribute("wrap","off");Sa&&(c.style.border="1px solid black");c.setAttribute("autocorrect","off");c.setAttribute("autocapitalize","off");c.setAttribute("spellcheck","false");this.inputDiv=q("div",[c],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");this.scrollbarH=q("div",[q("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");this.scrollbarV=q("div",[q("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar");this.scrollbarFiller=
q("div",null,"CodeMirror-scrollbar-filler");this.gutterFiller=q("div",null,"CodeMirror-gutter-filler");this.lineDiv=q("div",null,"CodeMirror-code");this.selectionDiv=q("div",null,null,"position: relative; z-index: 1");this.cursorDiv=q("div",null,"CodeMirror-cursors");this.measure=q("div",null,"CodeMirror-measure");this.lineMeasure=q("div",null,"CodeMirror-measure");this.lineSpace=q("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");
this.mover=q("div",[q("div",[this.lineSpace],"CodeMirror-lines")],null,"position: relative");this.sizer=q("div",[this.mover],"CodeMirror-sizer");this.heightForcer=q("div",null,null,"position: absolute; height: "+ca+"px; width: 1px;");this.gutters=q("div",null,"CodeMirror-gutters");this.lineGutter=null;this.scroller=q("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll");this.scroller.setAttribute("tabIndex","-1");this.wrapper=q("div",[this.inputDiv,this.scrollbarH,this.scrollbarV,
this.scrollbarFiller,this.gutterFiller,this.scroller],"CodeMirror");Ta&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0);Sa&&(c.style.width="0px");J||(this.scroller.draggable=!0);oc&&(this.inputDiv.style.height="1px",this.inputDiv.style.position="absolute");Ta&&(this.scrollbarH.style.minHeight=this.scrollbarV.style.minWidth="18px");a.appendChild?a.appendChild(this.wrapper):a(this.wrapper);this.viewFrom=this.viewTo=b.first;this.view=[];this.externalMeasured=null;this.lastSizeC=this.viewOffset=
0;this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=this.updateLineNumbers=null;this.prevInput="";this.pollingFast=this.alignWidgets=!1;this.poll=new lc;this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null;this.inaccurateSelection=!1;this.maxLine=null;this.maxLineLength=0;this.maxLineChanged=!1;this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null;this.shift=!1;this.selForContextMenu=null}function pc(a){a.doc.mode=m.getMode(a.options,a.doc.modeOption);Ua(a)}function Ua(a){a.doc.iter(function(a){a.stateAfter&&
(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.frontier=a.doc.first;Va(a,100);a.state.modeGen++;a.curOp&&O(a)}function nd(a){var b=qa(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/Wa(a.display)-3);return function(e){if(ra(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;g<e.widgets.length;g++)e.widgets[g].height&&(f+=e.widgets[g].height);return c?f+(Math.ceil(e.text.length/d)||1)*b:f+b}}function qc(a){var b=a.doc,c=nd(a);b.iter(function(a){var b=c(a);
b!=a.height&&V(a,b)})}function od(a){var b=da[a.options.keyMap].style;a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(b?" cm-keymap-"+b:"")}function jd(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");Xa(a)}function Ya(a){id(a);O(a);setTimeout(function(){rc(a)},20)}function id(a){var b=a.display.gutters,c=a.options.gutters;sa(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(q("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";sc(a)}function sc(a){var b=a.display.gutters.offsetWidth;a.display.sizer.style.marginLeft=b+"px";a.display.scrollbarH.style.left=a.options.fixedGutter?b+"px":0}function wb(a){if(0==a.height)return 0;for(var b=a.text.length,c,d=a;c=ta(d,!0);)c=c.find(0,!0),d=c.from.line,b+=c.from.ch-c.to.ch;for(d=a;c=ta(d,!1);)c=c.find(0,!0),b-=d.text.length-
c.from.ch,d=c.to.line,b+=d.text.length-c.to.ch;return b}function tc(a){var b=a.display,a=a.doc;b.maxLine=r(a,a.first);b.maxLineLength=wb(b.maxLine);b.maxLineChanged=!0;a.iter(function(a){var d=wb(a);d>b.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function jc(a){var b=F(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):-1<b&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function pd(a){var b=a.display.scroller;
return{clientHeight:b.clientHeight,barHeight:a.display.scrollbarV.clientHeight,scrollWidth:b.scrollWidth,clientWidth:b.clientWidth,barWidth:a.display.scrollbarH.clientWidth,docHeight:Math.round(a.doc.height+(a.display.mover.offsetHeight-a.display.lineSpace.offsetHeight))}}function xb(a,b){b||(b=pd(a));var c=a.display,d=b.docHeight+ca,e=b.scrollWidth>b.clientWidth,f=d>b.clientHeight;f?(c.scrollbarV.style.display="block",c.scrollbarV.style.bottom=e?Za(c.measure)+"px":"0",c.scrollbarV.firstChild.style.height=
Math.max(0,d-b.clientHeight+(b.barHeight||c.scrollbarV.clientHeight))+"px"):(c.scrollbarV.style.display="",c.scrollbarV.firstChild.style.height="0");e?(c.scrollbarH.style.display="block",c.scrollbarH.style.right=f?Za(c.measure)+"px":"0",c.scrollbarH.firstChild.style.width=b.scrollWidth-b.clientWidth+(b.barWidth||c.scrollbarH.clientWidth)+"px"):(c.scrollbarH.style.display="",c.scrollbarH.firstChild.style.width="0");e&&f?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=c.scrollbarFiller.style.width=
Za(c.measure)+"px"):c.scrollbarFiller.style.display="";e&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=Za(c.measure)+"px",c.gutterFiller.style.width=c.gutters.offsetWidth+"px"):c.gutterFiller.style.display="";!a.state.checkedOverlayScrollbar&&0<b.clientHeight&&(0===Za(c.measure)&&(c.scrollbarV.style.minWidth=c.scrollbarH.style.minHeight=ea&&!Re?"12px":"18px",d=function(b){(b.target||b.srcElement)!=c.scrollbarV&&(b.target||
b.srcElement)!=c.scrollbarH&&B(a,qd)(b)},t(c.scrollbarV,"mousedown",d),t(c.scrollbarH,"mousedown",d)),a.state.checkedOverlayScrollbar=!0)}function uc(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop,d=Math.floor(d-a.lineSpace.offsetTop),e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,d=ua(b,d),e=ua(b,e);if(c&&c.ensure){var f=c.ensure.from.line,c=c.ensure.to.line;if(f<d)return{from:f,to:ua(b,fa(r(b,f))+a.wrapper.clientHeight)};if(Math.min(c,b.lastLine())>=e)return{from:ua(b,
fa(r(b,c))-a.wrapper.clientHeight),to:c}}return{from:d,to:Math.max(e,d+1)}}function rc(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=vc(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g<c.length;g++)if(!c[g].hidden){a.options.fixedGutter&&c[g].gutter&&(c[g].gutter.style.left=f);var h=c[g].alignable;if(h)for(var i=0;i<h.length;i++)h[i].style.left=f}a.options.fixedGutter&&(b.gutters.style.left=d+e+"px")}}function vc(a){return a.scroller.getBoundingClientRect().left-
a.sizer.getBoundingClientRect().left}function yb(a,b,c){for(var d=a.display.viewFrom,e=a.display.viewTo,f,g=uc(a.display,a.doc,b),h=!0;;h=!1){var i=a.display.scroller.clientWidth,j;j=a;var k=g,n=c,c=j.display,l=j.doc;if(c.wrapper.offsetWidth)if(!n&&k.from>=c.viewFrom&&k.to<=c.viewTo&&0==rd(j))j=void 0;else{var o;o=j;if(o.options.lineNumbers){var w=o.doc,w=""+o.options.lineNumberFormatter(w.first+w.size-1+o.options.firstLineNumber),C=o.display;if(w.length!=C.lineNumChars){var m=C.measure.appendChild(q("div",
[q("div",w)],"CodeMirror-linenumber CodeMirror-gutter-elt")),p=m.firstChild.offsetWidth,m=m.offsetWidth-p;C.lineGutter.style.width="";C.lineNumInnerWidth=Math.max(p,C.lineGutter.offsetWidth-m);C.lineNumWidth=C.lineNumInnerWidth+m;C.lineNumChars=C.lineNumInnerWidth?w.length:-1;C.lineGutter.style.width=C.lineNumWidth+"px";sc(o);o=!0}else o=!1}else o=!1;o&&ka(j);o=sd(j);p=l.first+l.size;w=Math.max(k.from-j.options.viewportMargin,l.first);C=Math.min(p,k.to+j.options.viewportMargin);c.viewFrom<w&&20>w-
c.viewFrom&&(w=Math.max(l.first,c.viewFrom));c.viewTo>C&&20>c.viewTo-C&&(C=Math.min(p,c.viewTo));la&&(w=wc(j.doc,w),C=td(j.doc,C));k=w!=c.viewFrom||C!=c.viewTo||c.lastSizeC!=c.wrapper.clientHeight;l=j;p=l.display;0==p.view.length||w>=p.viewTo||C<=p.viewFrom?(p.view=zb(l,w,C),p.viewFrom=w):(p.viewFrom>w?p.view=zb(l,w,p.viewFrom).concat(p.view):p.viewFrom<w&&(p.view=p.view.slice($a(l,w))),p.viewFrom=w,p.viewTo<C)?p.view=p.view.concat(zb(l,p.viewTo,C)):p.viewTo>C&&(p.view=p.view.slice(0,$a(l,C)));p.viewTo=
C;c.viewOffset=fa(r(j.doc,c.viewFrom));j.display.mover.style.top=c.viewOffset+"px";l=rd(j);if(!k&&0==l&&!n)j=void 0;else{n=ja();4<l&&(c.lineDiv.style.display="none");Se(j,c.updateLineNumbers,o);4<l&&(c.lineDiv.style.display="");n&&(ja()!=n&&n.offsetHeight)&&n.focus();sa(c.cursorDiv);sa(c.selectionDiv);k&&(c.lastSizeC=c.wrapper.clientHeight,Va(j,400));j=j.display;c=j.lineDiv.offsetTop;for(n=0;n<j.view.length;n++)if(k=j.view[n],!k.hidden&&(Ta?(o=k.node.offsetTop+k.node.offsetHeight,l=o-c,c=o):(l=k.node.getBoundingClientRect(),
l=l.bottom-l.top),o=k.line.height-l,2>l&&(l=qa(j)),0.001<o||-0.001>o))if(V(k.line,l),ud(k.line),k.rest)for(l=0;l<k.rest.length;l++)ud(k.rest[l]);j=!0}}else ka(j),j=void 0;if(!j)break;f=!0;a.display.maxLineChanged&&!a.options.lineWrapping&&(j=a,c=j.display,n=xc(j,Ab(j,c.maxLine),c.maxLine.text.length,void 0).left,c.maxLineChanged=!1,n=Math.max(0,n+3),k=Math.max(0,c.sizer.offsetLeft+n+ca-c.scroller.clientWidth),c.sizer.style.minWidth=n+"px",k<j.doc.scrollLeft&&Ga(j,Math.min(c.scroller.scrollLeft,k),
!0));j=pd(a);yc(a);c=a;n=j;c.display.sizer.style.minHeight=c.display.heightForcer.style.top=n.docHeight+"px";c.display.gutters.style.height=Math.max(n.docHeight,n.clientHeight-ca)+"px";xb(a,j);J&&a.options.lineWrapping&&(c=a,n=j,c.display.sizer.offsetWidth+c.display.gutters.offsetWidth<c.display.scroller.clientWidth-1&&(c.display.sizer.style.minHeight=c.display.heightForcer.style.top="0px",c.display.gutters.style.height=n.docHeight+"px"));if(h&&a.options.lineWrapping&&i!=a.display.scroller.clientWidth)c=
!0;else if(c=!1,b&&null!=b.top&&(b={top:Math.min(j.docHeight-ca-j.clientHeight,b.top)}),g=uc(a.display,a.doc,b),g.from>=a.display.viewFrom&&g.to<=a.display.viewTo)break}a.display.updateLineNumbers=null;f&&(D(a,"update",a),(a.display.viewFrom!=d||a.display.viewTo!=e)&&D(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo));return f}function ud(a){if(a.widgets)for(var b=0;b<a.widgets.length;++b)a.widgets[b].height=a.widgets[b].node.offsetHeight}function sd(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:vc(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function Se(a,b,c){function d(b){var c=b.nextSibling;J&&ea&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b);return c}for(var e=a.display,f=a.options.lineNumbers,g=e.lineDiv,h=g.firstChild,i=e.view,e=e.viewFrom,j=0;j<i.length;j++){var k=i[j];
if(!k.hidden)if(k.node){for(;h!=k.node;)h=d(h);h=f&&null!=b&&b<=e&&k.lineNumber;k.changes&&(-1<F(k.changes,"gutter")&&(h=!1),vd(a,k,e,c));h&&(sa(k.lineNumber),k.lineNumber.appendChild(document.createTextNode(""+a.options.lineNumberFormatter(e+a.options.firstLineNumber))));h=k.node.nextSibling}else{var n=Te(a,k,e,c);g.insertBefore(n,h)}e+=k.size}for(;h;)h=d(h)}function vd(a,b,c,d){for(var e=0;e<b.changes.length;e++){var f=b.changes[e];if("text"==f){var f=b,g=f.text.className,h=wd(a,f);f.text==f.node&&
(f.node=h.pre);f.text.parentNode.replaceChild(h.pre,f.text);f.text=h.pre;h.bgClass!=f.bgClass||h.textClass!=f.textClass?(f.bgClass=h.bgClass,f.textClass=h.textClass,zc(f)):g&&(f.text.className=g)}else if("gutter"==f)xd(a,b,c,d);else if("class"==f)zc(b);else if("widget"==f){f=b;g=d;f.alignable&&(f.alignable=null);for(var h=f.node.firstChild,i=void 0;h;h=i)i=h.nextSibling,"CodeMirror-linewidget"==h.className&&f.node.removeChild(h);yd(f,g)}}b.changes=null}function Bb(a){a.node==a.text&&(a.node=q("div",
null,null,"position: relative"),a.text.parentNode&&a.text.parentNode.replaceChild(a.node,a.text),a.node.appendChild(a.text),Ta&&(a.node.style.zIndex=2));return a.node}function wd(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):zd(a,b)}function zc(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;b&&(b+=" CodeMirror-linebackground");if(a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),
a.background=null);else if(b){var c=Bb(a);a.background=c.insertBefore(q("div",null,b),c.firstChild)}a.line.wrapClass?Bb(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");a.text.className=(a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass)||""}function xd(a,b,c,d){b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null);var e=b.line.gutterMarkers;if(a.options.lineNumbers||e){var f=Bb(b),f=b.gutter=f.insertBefore(q("div",null,"CodeMirror-gutter-wrapper","position: absolute; left: "+
(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px"),b.text);if(a.options.lineNumbers&&(!e||!e["CodeMirror-linenumbers"]))b.lineNumber=f.appendChild(q("div",""+a.options.lineNumberFormatter(c+a.options.firstLineNumber),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px"));if(e)for(b=0;b<a.options.gutters.length;++b){var c=a.options.gutters[b],g=e.hasOwnProperty(c)&&e[c];g&&f.appendChild(q("div",[g],"CodeMirror-gutter-elt",
"left: "+d.gutterLeft[c]+"px; width: "+d.gutterWidth[c]+"px"))}}}function Te(a,b,c,d){var e=wd(a,b);b.text=b.node=e.pre;e.bgClass&&(b.bgClass=e.bgClass);e.textClass&&(b.textClass=e.textClass);zc(b);xd(a,b,c,d);yd(b,d);return b.node}function yd(a,b){Ad(a.line,a,b,!0);if(a.rest)for(var c=0;c<a.rest.length;c++)Ad(a.rest[c],a,b,!1)}function Ad(a,b,c,d){if(a.widgets)for(var e=Bb(b),f=0,a=a.widgets;f<a.length;++f){var g=a[f],h=q("div",[g.node],"CodeMirror-linewidget");g.handleMouseEvents||(h.ignoreEvents=
!0);var i=g,j=h,k=c;if(i.noHScroll){(b.alignable||(b.alignable=[])).push(j);var n=k.wrapperWidth;j.style.left=k.fixedPos+"px";i.coverGutter||(n-=k.gutterTotalWidth,j.style.paddingLeft=k.gutterTotalWidth+"px");j.style.width=n+"px"}i.coverGutter&&(j.style.zIndex=5,j.style.position="relative",i.noHScroll||(j.style.marginLeft=-k.gutterTotalWidth+"px"));d&&g.above?e.insertBefore(h,b.gutter||b.text):e.appendChild(h);D(g,"redraw")}}function Ac(a,b){return 0>v(a,b)?b:a}function Bc(a,b){return 0>v(a,b)?a:
b}function ga(a,b){this.ranges=a;this.primIndex=b}function z(a,b){this.anchor=a;this.head=b}function W(a,b){var c=a[b];a.sort(function(a,b){return v(a.from(),b.from())});b=F(a,c);for(c=1;c<a.length;c++){var d=a[c],e=a[c-1];if(0<=v(e.to(),d.from())){var f=Bc(e.from(),d.from()),g=Ac(e.to(),d.to()),d=e.empty()?d.from()==d.head:e.from()==e.head;c<=b&&--b;a.splice(--c,2,new z(d?g:f,d?f:g))}}return new ga(a,b)}function ma(a,b){return new ga([new z(a,b||a)],0)}function s(a,b){if(b.line<a.first)return p(a.first,
0);var c=a.first+a.size-1;if(b.line>c)return p(c,r(a,c).text.length);var c=r(a,b.line).text.length,d=b.ch,c=null==d||d>c?p(b.line,c):0>d?p(b.line,0):b;return c}function ab(a,b){return b>=a.first&&b<a.first+a.size}function bb(a,b,c,d){return a.cm&&a.cm.display.shift||a.extend?(a=b.anchor,d&&(b=0>v(c,a),b!=0>v(d,a)?(a=c,c=d):b!=0>v(c,d)&&(c=d)),new z(a,c)):new z(d||c,c)}function Cb(a,b,c,d){G(a,new ga([bb(a,a.sel.primary(),b,c)],0),d)}function Bd(a,b,c){for(var d=[],e=0;e<a.sel.ranges.length;e++)d[e]=
bb(a,a.sel.ranges[e],b[e],null);b=W(d,a.sel.primIndex);G(a,b,c)}function Cd(a,b,c,d){var e=a.sel.ranges.slice(0);e[b]=c;G(a,W(e,a.sel.primIndex),d)}function Ue(a,b){var c={ranges:b.ranges,update:function(b){this.ranges=[];for(var c=0;c<b.length;c++)this.ranges[c]=new z(s(a,b[c].anchor),s(a,b[c].head))}};E(a,"beforeSelectionChange",a,c);a.cm&&E(a.cm,"beforeSelectionChange",a.cm,c);return c.ranges!=b.ranges?W(c.ranges,c.ranges.length-1):b}function Dd(a,b,c){var d=a.history.done,e=x(d);e&&e.ranges?(d[d.length-
1]=b,Db(a,b,c)):G(a,b,c)}function G(a,b,c){Db(a,b,c);var b=a.sel,d=a.cm?a.cm.curOp.id:NaN,e=a.history,f=c&&c.origin,g;if(!(g=d==e.lastOp))if(g=f)if(g=e.lastSelOrigin==f)if(!(g=e.lastModTime==e.lastSelTime&&e.lastOrigin==f)){g=x(e.done);var h=f.charAt(0);g="*"==h||"+"==h&&g.ranges.length==b.ranges.length&&g.somethingSelected()==b.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}g?e.done[e.done.length-1]=b:Eb(b,e.done);e.lastSelTime=+new Date;e.lastSelOrigin=
f;e.lastOp=d;c&&!1!==c.clearRedo&&Ed(e.undone)}function Db(a,b,c){if(P(a,"beforeSelectionChange")||a.cm&&P(a.cm,"beforeSelectionChange"))b=Ue(a,b);var d=c&&c.bias||(0>v(b.primary().head,a.sel.primary().head)?-1:1);Fd(a,Gd(a,b,d,!0));!(c&&!1===c.scroll)&&a.cm&&Ha(a.cm)}function Fd(a,b){b.equals(a.sel)||(a.sel=b,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,Hd(a.cm)),D(a,"cursorActivity",a))}function Id(a){Fd(a,Gd(a,a.sel,null,!1),va)}function Gd(a,b,c,d){for(var e,f=0;f<b.ranges.length;f++){var g=
b.ranges[f],h=Fb(a,g.anchor,c,d),i=Fb(a,g.head,c,d);if(e||h!=g.anchor||i!=g.head)e||(e=b.ranges.slice(0,f)),e[f]=new z(h,i)}return e?W(e,b.primIndex):b}function Fb(a,b,c,d){var e=!1,f=b,g=c||1;a.cantEdit=!1;a:for(;;){var h=r(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&&(E(k,"beforeCursorEnter"),k.explicitlyCleared))if(h.markedSpans){--i;
continue}else break;if(k.atomic){i=k.find(0>g?-1:1);if(0==v(i,f)&&(i.ch+=g,0>i.ch?i=i.line>a.first?s(a,p(i.line-1)):null:i.ch>h.text.length&&(i=i.line<a.first+a.size-1?p(i.line+1,0):null),!i)){if(e){if(!d)return Fb(a,b,c,!0);a.cantEdit=!0;return p(a.first,0)}e=!0;i=b;g=-g}f=i;continue a}}}return f}}function yc(a){for(var b=a.display,c=a.doc,d=document.createDocumentFragment(),e=document.createDocumentFragment(),f=0;f<c.sel.ranges.length;f++){var g=c.sel.ranges[f],h=g.empty();if(h||a.options.showCursorWhenSelecting){var i=
a,j=d,k=ha(i,g.head,"div"),n=j.appendChild(q("div"," ","CodeMirror-cursor"));n.style.left=k.left+"px";n.style.top=k.top+"px";n.style.height=Math.max(0,k.bottom-k.top)*i.options.cursorHeight+"px";k.other&&(i=j.appendChild(q("div"," ","CodeMirror-cursor CodeMirror-secondarycursor")),i.style.display="",i.style.left=k.other.left+"px",i.style.top=k.other.top+"px",i.style.height=0.85*(k.other.bottom-k.other.top)+"px")}h||Ve(a,g,e)}a.options.moveInputWithCursor&&(c=ha(a,c.sel.primary().head,"div"),f=b.wrapper.getBoundingClientRect(),
g=b.lineDiv.getBoundingClientRect(),a=Math.max(0,Math.min(b.wrapper.clientHeight-10,c.top+g.top-f.top)),c=Math.max(0,Math.min(b.wrapper.clientWidth-10,c.left+g.left-f.left)),b.inputDiv.style.top=a+"px",b.inputDiv.style.left=c+"px");X(b.cursorDiv,d);X(b.selectionDiv,e)}function Ve(a,b,c){function d(a,b,c,d){0>b&&(b=0);b=Math.round(b);d=Math.round(d);h.appendChild(q("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?k-a:c)+"px; height: "+(d-b)+"px"))}
function e(b,c,e){var f=r(g,b),h=f.text.length,i,n;We(Y(f),c||0,null==e?h:e,function(g,m,q){var r=Gb(a,p(b,g),"div",f,"left"),s,t;g==m?(s=r,q=t=r.left):(s=Gb(a,p(b,m-1),"div",f,"right"),"rtl"==q&&(q=r,r=s,s=q),q=r.left,t=s.right);null==c&&0==g&&(q=j);3<s.top-r.top&&(d(q,r.top,null,r.bottom),q=j,r.bottom<s.top&&d(q,r.bottom,null,s.top));null==e&&m==h&&(t=k);if(!i||r.top<i.top||r.top==i.top&&r.left<i.left)i=r;if(!n||s.bottom>n.bottom||s.bottom==n.bottom&&s.right>n.right)n=s;q<j+1&&(q=j);d(q,s.top,t-
q,s.bottom)});return{start:i,end:n}}var f=a.display,g=a.doc,h=document.createDocumentFragment(),i=Jd(a.display),j=i.left,k=f.lineSpace.offsetWidth-i.right,f=b.from(),b=b.to();if(f.line==b.line)e(f.line,f.ch,b.ch);else{var n=r(g,f.line),i=r(g,b.line),i=Z(n)==Z(i),f=e(f.line,f.ch,i?n.text.length+1:null).end,b=e(b.line,i?0:null,b.ch).start;i&&(f.top<b.top-2?(d(f.right,f.top,null,f.bottom),d(j,b.top,b.left,b.bottom)):d(f.right,f.top,b.left-f.right,f.bottom));f.bottom<b.top&&d(j,f.bottom,null,b.top)}c.appendChild(h)}
function Hb(a){if(a.state.focused){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursorDiv.style.visibility="";0<a.options.cursorBlinkRate&&(b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate))}}function Va(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.viewTo&&a.state.highlight.set(b,T(Xe,a))}function Xe(a){var b=a.doc;b.frontier<b.first&&(b.frontier=b.first);if(!(b.frontier>=a.display.viewTo)){var c=+new Date+a.options.workTime,
d=cb(b.mode,db(a,b.frontier));ba(a,function(){b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(e){if(b.frontier>=a.display.viewFrom){var f=e.styles,g=Kd(a,e,d,true);e.styles=g.styles;if(g.classes)e.styleClasses=g.classes;else if(e.styleClasses)e.styleClasses=null;for(var g=!f||f.length!=e.styles.length,h=0;!g&&h<f.length;++h)g=f[h]!=e.styles[h];g&&na(a,b.frontier,"text");e.stateAfter=cb(b.mode,d)}else{Cc(a,e.text,d);e.stateAfter=b.frontier%5==0?cb(b.mode,d):null}++b.frontier;
if(+new Date>c){Va(a,a.options.workDelay);return true}})})}}function Ye(a,b,c){for(var d,e,f=a.doc,g=c?-1:b-(a.doc.mode.innerMode?1E3:100);b>g;--b){if(b<=f.first)return f.first;var h=r(f,b-1);if(h.stateAfter&&(!c||b<=f.frontier))return b;h=Q(h.text,null,a.options.tabSize);if(null==e||d>h)e=b-1,d=h}return e}function db(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=Ye(a,b,c),g=f>d.first&&r(d,f-1).stateAfter,g=g?cb(d.mode,g):Ze(d.mode);d.iter(f,b,function(c){Cc(a,c.text,g);c.stateAfter=
f==b-1||0==f%5||f>=e.viewFrom&&f<e.viewTo?cb(d.mode,g):null;++f});c&&(d.frontier=f);return g}function Jd(a){if(a.cachedPaddingH)return a.cachedPaddingH;var b=X(a.measure,q("pre","x")),b=window.getComputedStyle?window.getComputedStyle(b):b.currentStyle,b={left:parseInt(b.paddingLeft),right:parseInt(b.paddingRight)};!isNaN(b.left)&&!isNaN(b.right)&&(a.cachedPaddingH=b);return b}function Ld(a,b){if(b>=a.display.viewFrom&&b<a.display.viewTo)return a.display.view[$a(a,b)];var c=a.display.externalMeasured;
if(c&&b>=c.lineN&&b<c.lineN+c.size)return c}function Ab(a,b){var c=A(b),d=Ld(a,c);d&&!d.text?d=null:d&&d.changes&&vd(a,d,c,sd(a));if(!d){var e;e=Z(b);d=A(e);e=a.display.externalMeasured=new Md(a.doc,e,d);e.lineN=d;d=e.built=zd(a,e);e.text=d.pre;X(a.display.lineMeasure,d.pre);d=e}a:if(e=d,e.line==b)c={map:e.measure.map,cache:e.measure.cache};else{for(var f=0;f<e.rest.length;f++)if(e.rest[f]==b){c={map:e.measure.maps[f],cache:e.measure.caches[f]};break a}for(f=0;f<e.rest.length;f++)if(A(e.rest[f])>
c){c={map:e.measure.maps[f],cache:e.measure.caches[f],before:!0};break a}c=void 0}return{line:b,view:d,rect:null,map:c.map,cache:c.cache,before:c.before,hasHeights:!1}}function xc(a,b,c,d){b.before&&(c=-1);var e=c+(d||""),f;if(b.cache.hasOwnProperty(e))f=b.cache[e];else{b.rect||(b.rect=b.view.text.getBoundingClientRect());if(!b.hasHeights){var g=b.view,h=b.rect,i=a.options.lineWrapping,j=i&&a.display.scroller.clientWidth;if(!g.measure.heights||i&&g.measure.width!=j){var k=g.measure.heights=[];if(i){g.measure.width=
j;g=g.text.firstChild.getClientRects();for(i=0;i<g.length-1;i++){var j=g[i],n=g[i+1];2<Math.abs(j.bottom-n.bottom)&&k.push((j.bottom+n.top)/2-h.top)}}k.push(h.bottom-h.top)}b.hasHeights=!0}for(var h=d,k=b.map,l,o,w,d=0;d<k.length;d+=3){var p=k[d],m=k[d+1];if(c<p)o=0,w=1,f="left";else if(c<m)o=c-p,w=o+1;else if(d==k.length-3||c==m&&k[d+3]>c)w=m-p,o=w-1,c>=m&&(f="right");if(null!=o){l=k[d+2];if(p==m&&h==(l.insertLeft?"left":"right"))f=h;if("left"==h&&0==o)for(;d&&k[d-2]==k[d-3]&&k[d-1].insertLeft;)l=
k[(d-=3)+2],f="left";if("right"==h&&o==m-p)for(;d<k.length-3&&k[d+3]==k[d+4]&&!k[d+5].insertLeft;)l=k[(d+=3)+2],f="right";break}}if(3==l.nodeType){for(;o&&eb(b.line.text.charAt(p+o));)--o;for(;p+w<m&&eb(b.line.text.charAt(p+w));)++w;if(H&&0==o&&w==m-p)c=l.parentNode.getBoundingClientRect();else if(I&&a.options.lineWrapping)var q=fb(l,o,w).getClientRects(),c=q.length?q["right"==h?q.length-1:0]:Dc;else c=fb(l,o,w).getBoundingClientRect()||Dc}else 0<o&&(f=h="right"),c=a.options.lineWrapping&&1<(q=l.getClientRects()).length?
q["right"==h?q.length-1:0]:l.getBoundingClientRect();if(H&&!o&&(!c||!c.left&&!c.right))c=(l=l.parentNode.getClientRects()[0])?{left:l.left,right:l.left+Wa(a.display),top:l.top,bottom:l.bottom}:Dc;l=(c.bottom+c.top)/2-b.rect.top;o=b.view.measure.heights;for(d=0;d<o.length-1&&!(l<o[d]);d++);a=d?o[d-1]:0;l=o[d];f={left:("right"==f?c.right:c.left)-b.rect.left,right:("left"==f?c.left:c.right)-b.rect.left,top:a,bottom:l};!c.left&&!c.right&&(f.bogus=!0);f.bogus||(b.cache[e]=f)}return{left:f.left,right:f.right,
top:f.top,bottom:f.bottom}}function Nd(a){if(a.measure&&(a.measure.cache={},a.measure.heights=null,a.rest))for(var b=0;b<a.rest.length;b++)a.measure.caches[b]={}}function Od(a){a.display.externalMeasure=null;sa(a.display.lineMeasure);for(var b=0;b<a.display.view.length;b++)Nd(a.display.view[b])}function Xa(a){Od(a);a.display.cachedCharWidth=a.display.cachedTextHeight=a.display.cachedPaddingH=null;a.options.lineWrapping||(a.display.maxLineChanged=!0);a.display.lineNumChars=null}function Ec(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=fa(b);b="local"==d?b+a.display.lineSpace.offsetTop:b-a.display.viewOffset;if("page"==d||"window"==d)a=a.display.lineSpace.getBoundingClientRect(),b+=a.top+("window"==d?0:window.pageYOffset||(document.documentElement||document.body).scrollTop),d=a.left+("window"==d?0:window.pageXOffset||(document.documentElement||document.body).scrollLeft),c.left+=d,c.right+=d;c.top+=b;
c.bottom+=b;return c}function Pd(a,b,c){if("div"==c)return b;var d=b.left,b=b.top;if("page"==c)d-=window.pageXOffset||(document.documentElement||document.body).scrollLeft,b-=window.pageYOffset||(document.documentElement||document.body).scrollTop;else if("local"==c||!c)c=a.display.sizer.getBoundingClientRect(),d+=c.left,b+=c.top;a=a.display.lineSpace.getBoundingClientRect();return{left:d-a.left,top:b-a.top}}function Gb(a,b,c,d,e){d||(d=r(a.doc,b.line));return Ec(a,d,xc(a,Ab(a,d),b.ch,e),c)}function ha(a,
b,c,d,e){function f(b,f){var g=xc(a,e,b,f?"right":"left");f?g.left=g.right:g.right=g.left;return Ec(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=Fc(c)-(c.level%2?0:1),d=!0):a==Fc(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||r(a.doc,b.line);e||(e=Ab(a,d));var h=Y(d),b=b.ch;if(!h)return f(b);var i=Gc(h,b),i=g(b,i);null!=hb&&(i.other=g(b,hb));
return i}function Qd(a,b){var c=0,b=s(a.doc,b);a.options.lineWrapping||(c=Wa(a.display)*b.ch);var d=r(a.doc,b.line),e=fa(d)+a.display.lineSpace.offsetTop;return{left:c,right:c,top:e,bottom:e+d.height}}function Ib(a,b,c,d){a=p(a,b);a.xRel=d;c&&(a.outside=!0);return a}function Hc(a,b,c){var d=a.doc,c=c+a.display.viewOffset;if(0>c)return Ib(d.first,0,!0,-1);var e=ua(d,c),f=d.first+d.size-1;if(e>f)return Ib(d.first+d.size-1,r(d,f).text.length,!0,1);0>b&&(b=0);for(d=r(d,e);;)if(e=$e(a,d,e,b,c),f=(d=ta(d,
!1))&&d.find(0,!0),d&&(e.ch>f.from.ch||e.ch==f.from.ch&&0<e.xRel))e=A(d=f.to.line);else return e}function $e(a,b,c,d,e){function f(d){d=ha(a,p(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-fa(b),h=!1,i=2*a.display.wrapper.clientWidth,j=Ab(a,b),k=Y(b),n=b.text.length,e=Jb(b),l=Kb(b),o=f(e),w=h,m=f(l),q=h;if(d>m)return Ib(c,l,q,1);for(;;){if(k?l==e||l==Ic(b,e,1):1>=l-e){k=d<o||d-o<=m-d?e:l;for(d-=k==e?o:m;eb(b.text.charAt(k));)++k;return Ib(c,
k,k==e?w:q,-1>d?-1:1<d?1:0)}var r=Math.ceil(n/2),s=e+r;if(k)for(var s=e,t=0;t<r;++t)s=Ic(b,s,1);t=f(s);if(t>d){l=s;m=t;if(q=h)m+=1E3;n=r}else e=s,o=t,w=h,n-=r}}function qa(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==wa){wa=q("pre");for(var b=0;49>b;++b)wa.appendChild(document.createTextNode("x")),wa.appendChild(q("br"));wa.appendChild(document.createTextNode("x"))}X(a.measure,wa);b=wa.offsetHeight/50;3<b&&(a.cachedTextHeight=b);sa(a.measure);return b||1}function Wa(a){if(null!=
a.cachedCharWidth)return a.cachedCharWidth;var b=q("span","xxxxxxxxxx"),c=q("pre",[b]);X(a.measure,c);b=b.getBoundingClientRect();b=(b.right-b.left)/10;2<b&&(a.cachedCharWidth=b);return b||10}function Ia(a){a.curOp={viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++af};Lb++||(oa=[])}function Ja(a){var b=a.curOp,c=a.doc,d=a.display;a.curOp=
null;b.updateMaxLine&&tc(a);if(b.viewChanged||b.forceUpdate||null!=b.scrollTop||b.scrollToPos&&(b.scrollToPos.from.line<d.viewFrom||b.scrollToPos.to.line>=d.viewTo)||d.maxLineChanged&&a.options.lineWrapping){var e=yb(a,{top:b.scrollTop,ensure:b.scrollToPos},b.forceUpdate);a.display.scroller.offsetHeight&&(a.doc.scrollTop=a.display.scroller.scrollTop)}!e&&b.selectionChanged&&yc(a);!e&&b.startHeight!=a.doc.height&&xb(a);if(null!=d.wheelStartX&&(null!=b.scrollTop||null!=b.scrollLeft||b.scrollToPos))d.wheelStartX=
d.wheelStartY=null;null!=b.scrollTop&&d.scroller.scrollTop!=b.scrollTop&&(e=Math.max(0,Math.min(d.scroller.scrollHeight-d.scroller.clientHeight,b.scrollTop)),d.scroller.scrollTop=d.scrollbarV.scrollTop=c.scrollTop=e);null!=b.scrollLeft&&d.scroller.scrollLeft!=b.scrollLeft&&(e=Math.max(0,Math.min(d.scroller.scrollWidth-d.scroller.clientWidth,b.scrollLeft)),d.scroller.scrollLeft=d.scrollbarH.scrollLeft=c.scrollLeft=e,rc(a));if(b.scrollToPos){a:{c=s(a.doc,b.scrollToPos.from);d=s(a.doc,b.scrollToPos.to);
e=b.scrollToPos.margin;for(null==e&&(e=0);;){var f=!1,g=ha(a,c),h=!d||d==c?g:ha(a,d),h=Mb(a,Math.min(g.left,h.left),Math.min(g.top,h.top)-e,Math.max(g.left,h.left),Math.max(g.bottom,h.bottom)+e),i=a.doc.scrollTop,j=a.doc.scrollLeft;null!=h.scrollTop&&(ib(a,h.scrollTop),1<Math.abs(a.doc.scrollTop-i)&&(f=!0));null!=h.scrollLeft&&(Ga(a,h.scrollLeft),1<Math.abs(a.doc.scrollLeft-j)&&(f=!0));if(!f){c=g;break a}}c=void 0}if(b.scrollToPos.isCursor&&a.state.focused){d=c;e=a.display;f=e.sizer.getBoundingClientRect();
c=null;if(0>d.top+f.top)c=!0;else if(d.bottom+f.top>(window.innerHeight||document.documentElement.clientHeight))c=!1;null!=c&&!bf&&(d=q("div","",null,"position: absolute; top: "+(d.top-e.viewOffset-a.display.lineSpace.offsetTop)+"px; height: "+(d.bottom-d.top+ca)+"px; left: "+d.left+"px; width: 2px;"),a.display.lineSpace.appendChild(d),d.scrollIntoView(c),a.display.lineSpace.removeChild(d))}}b.selectionChanged&&Hb(a);a.state.focused&&b.updateInput&&U(a,b.typing);c=b.maybeHiddenMarkers;d=b.maybeUnhiddenMarkers;
if(c)for(e=0;e<c.length;++e)c[e].lines.length||E(c[e],"hide");if(d)for(e=0;e<d.length;++e)d[e].lines.length&&E(d[e],"unhide");var k;--Lb||(k=oa,oa=null);b.changeObjs&&E(a,"changes",a,b.changeObjs);if(k)for(e=0;e<k.length;++e)k[e]();if(b.cursorActivityHandlers)for(e=0;e<b.cursorActivityHandlers.length;e++)b.cursorActivityHandlers[e](a)}function ba(a,b){if(a.curOp)return b();Ia(a);try{return b()}finally{Ja(a)}}function B(a,b){return function(){if(a.curOp)return b.apply(a,arguments);Ia(a);try{return b.apply(a,
arguments)}finally{Ja(a)}}}function y(a){return function(){if(this.curOp)return a.apply(this,arguments);Ia(this);try{return a.apply(this,arguments)}finally{Ja(this)}}}function N(a){return function(){var b=this.cm;if(!b||b.curOp)return a.apply(this,arguments);Ia(b);try{return a.apply(this,arguments)}finally{Ja(b)}}}function Md(a,b,c){for(var d=this.line=b,e;d=ta(d,!1);)d=d.find(1,!0).line,(e||(e=[])).push(d);this.size=(this.rest=e)?A(x(this.rest))-c+1:1;this.node=this.text=null;this.hidden=ra(a,b)}
function zb(a,b,c){var d=[],e;for(e=b;e<c;)b=new Md(a.doc,r(a.doc,e),e),e+=b.size,d.push(b);return d}function O(a,b,c,d){null==b&&(b=a.doc.first);null==c&&(c=a.doc.first+a.doc.size);d||(d=0);var e=a.display;if(d&&c<e.viewTo&&(null==e.updateLineNumbers||e.updateLineNumbers>b))e.updateLineNumbers=b;a.curOp.viewChanged=!0;if(b>=e.viewTo)la&&wc(a.doc,b)<e.viewTo&&ka(a);else if(c<=e.viewFrom)la&&td(a.doc,c+d)>e.viewFrom?ka(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)ka(a);else if(b<=
e.viewFrom){var f=Nb(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):ka(a)}else if(c>=e.viewTo)(f=Nb(a,b,b,-1))?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):ka(a);else{var f=Nb(a,b,b,-1),g=Nb(a,c,c+d,1);f&&g?(e.view=e.view.slice(0,f.index).concat(zb(a,f.lineN,g.lineN)).concat(e.view.slice(g.index)),e.viewTo+=d):ka(a)}if(a=e.externalMeasured)c<a.lineN?a.lineN+=d:b<a.lineN+a.size&&(e.externalMeasured=null)}function na(a,b,c){a.curOp.viewChanged=!0;var d=a.display,e=a.display.externalMeasured;
e&&(b>=e.lineN&&b<e.lineN+e.size)&&(d.externalMeasured=null);b<d.viewFrom||b>=d.viewTo||(a=d.view[$a(a,b)],null!=a.node&&(a=a.changes||(a.changes=[]),-1==F(a,c)&&a.push(c)))}function ka(a){a.display.viewFrom=a.display.viewTo=a.doc.first;a.display.view=[];a.display.viewOffset=0}function $a(a,b){if(b>=a.display.viewTo)return null;b-=a.display.viewFrom;if(0>b)return null;for(var c=a.display.view,d=0;d<c.length;d++)if(b-=c[d].size,0>b)return d}function Nb(a,b,c,d){var e=$a(a,b),f=a.display.view;if(!la||
c==a.doc.first+a.doc.size)return{index:e,lineN:c};for(var g=0,h=a.display.viewFrom;g<e;g++)h+=f[g].size;if(h!=b){if(0<d){if(e==f.length-1)return null;b=h+f[e].size-b;e++}else b=h-b;c+=b}for(;wc(a.doc,c)!=c;){if(e==(0>d?0:f.length-1))return null;c+=d*f[e-(0>d?1:0)].size;e+=d}return{index:e,lineN:c}}function rd(a){for(var a=a.display.view,b=0,c=0;c<a.length;c++){var d=a[c];!d.hidden&&(!d.node||d.changes)&&++b}return b}function Ob(a){a.display.pollingFast||a.display.poll.set(a.options.pollInterval,function(){Jc(a);
a.state.focused&&Ob(a)})}function jb(a){function b(){!Jc(a)&&!c?(c=!0,a.display.poll.set(60,b)):(a.display.pollingFast=!1,Ob(a))}var c=!1;a.display.pollingFast=!0;a.display.poll.set(20,b)}function Jc(a){var b=a.display.input,c=a.display.prevInput,d=a.doc;if(!a.state.focused||cf(b)&&!c||Pb(a)||a.options.disableInput)return!1;a.state.pasteIncoming&&a.state.fakedLastChar&&(b.value=b.value.substring(0,b.value.length-1),a.state.fakedLastChar=!1);var e=b.value;if(e==c&&!a.somethingSelected())return!1;if(I&&
!H&&a.display.inputHasSelection===e)return U(a),!1;var f=!a.curOp;f&&Ia(a);a.display.shift=!1;8203==e.charCodeAt(0)&&(d.sel==a.display.selForContextMenu&&!c)&&(c="");for(var g=0,h=Math.min(c.length,e.length);g<h&&c.charCodeAt(g)==e.charCodeAt(g);)++g;for(var h=e.slice(g),i=Ka(h),j=a.state.pasteIncoming&&1<i.length&&d.sel.ranges.length==i.length,k=d.sel.ranges.length-1;0<=k;k--){var n=d.sel.ranges[k],l=n.from(),o=n.to();g<c.length?l=p(l.line,l.ch-(c.length-g)):a.state.overwrite&&(n.empty()&&!a.state.pasteIncoming)&&
(o=p(o.line,Math.min(r(d,o.line).text.length,o.ch+x(i).length)));var w=a.curOp.updateInput,o={from:l,to:o,text:j?[i[k]]:i,origin:a.state.pasteIncoming?"paste":a.state.cutIncoming?"cut":"+input"};La(a.doc,o);D(a,"inputRead",a,o);if(h&&!a.state.pasteIncoming&&a.options.electricChars&&a.options.smartIndent&&100>n.head.ch&&(!k||d.sel.ranges[k-1].head.line!=n.head.line))if(l=a.getModeAt(n.head),l.electricChars)for(o=0;o<l.electricChars.length;o++){if(-1<h.indexOf(l.electricChars.charAt(o))){kb(a,n.head.line,
"smart");break}}else l.electricInput&&(o=xa(o),l.electricInput.test(r(d,o.line).text.slice(0,o.ch))&&kb(a,n.head.line,"smart"))}Ha(a);a.curOp.updateInput=w;a.curOp.typing=!0;1E3<e.length||-1<e.indexOf("\n")?b.value=a.display.prevInput="":a.display.prevInput=e;f&&Ja(a);a.state.pasteIncoming=a.state.cutIncoming=!1;return!0}function U(a,b){var c,d,e=a.doc;a.somethingSelected()?(a.display.prevInput="",c=e.sel.primary(),d=(c=Rd&&(100<c.to().line-c.from().line||1E3<(d=a.getSelection()).length))?"-":d||
a.getSelection(),a.display.input.value=d,a.state.focused&&lb(a.display.input),I&&!H&&(a.display.inputHasSelection=d)):b||(a.display.prevInput=a.display.input.value="",I&&!H&&(a.display.inputHasSelection=null));a.display.inaccurateSelection=c}function M(a){"nocursor"!=a.options.readOnly&&(!kc||ja()!=a.display.input)&&a.display.input.focus()}function Kc(a){a.state.focused||(M(a),mc(a))}function Pb(a){return a.options.readOnly||a.doc.cantEdit}function Pe(a){function b(){a.state.focused&&setTimeout(T(M,
a),0)}function c(b){$(a,b)||Lc(b)}function d(b){if(a.somethingSelected())e.inaccurateSelection&&(e.prevInput="",e.inaccurateSelection=!1,e.input.value=a.getSelection(),lb(e.input));else{for(var c="",d=[],i=0;i<a.doc.sel.ranges.length;i++){var j=a.doc.sel.ranges[i].head.line,j={anchor:p(j,0),head:p(j+1,0)};d.push(j);c+=a.getRange(j.anchor,j.head)}"cut"==b.type?a.setSelections(d,null,va):(e.prevInput="",e.input.value=c,lb(e.input))}"cut"==b.type&&(a.state.cutIncoming=!0)}var e=a.display;t(e.scroller,
"mousedown",B(a,qd));aa?t(e.scroller,"dblclick",B(a,function(b){if(!$(a,b)){var c=Ma(a,b);c&&(!Mc(a,b,"gutterClick",!0,D)&&!ya(a.display,b))&&(K(b),b=Nc(a,c),Cb(a.doc,b.anchor,b.head))}})):t(e.scroller,"dblclick",function(b){$(a,b)||K(b)});t(e.lineSpace,"selectstart",function(a){ya(e,a)||K(a)});Oc||t(e.scroller,"contextmenu",function(b){Sd(a,b)});t(e.scroller,"scroll",function(){e.scroller.clientHeight&&(ib(a,e.scroller.scrollTop),Ga(a,e.scroller.scrollLeft,!0),E(a,"scroll",a))});t(e.scrollbarV,"scroll",
function(){e.scroller.clientHeight&&ib(a,e.scrollbarV.scrollTop)});t(e.scrollbarH,"scroll",function(){e.scroller.clientHeight&&Ga(a,e.scrollbarH.scrollLeft)});t(e.scroller,"mousewheel",function(b){Td(a,b)});t(e.scroller,"DOMMouseScroll",function(b){Td(a,b)});t(e.scrollbarH,"mousedown",b);t(e.scrollbarV,"mousedown",b);t(e.wrapper,"scroll",function(){e.wrapper.scrollTop=e.wrapper.scrollLeft=0});t(e.input,"keyup",B(a,Ud));t(e.input,"input",function(){I&&(!H&&a.display.inputHasSelection)&&(a.display.inputHasSelection=
null);jb(a)});t(e.input,"keydown",B(a,Vd));t(e.input,"keypress",B(a,Wd));t(e.input,"focus",T(mc,a));t(e.input,"blur",T(vb,a));a.options.dragDrop&&(t(e.scroller,"dragstart",function(b){var c=a;if(I&&(!c.state.draggingText||100>+new Date-Xd))Lc(b);else if(!$(c,b)&&!ya(c.display,b)&&(b.dataTransfer.setData("Text",c.getSelection()),b.dataTransfer.setDragImage&&!Yd)){var d=q("img",null,null,"position: fixed; left: 0; top: 0;");d.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
R&&(d.width=d.height=1,c.display.wrapper.appendChild(d),d._top=d.offsetTop);b.dataTransfer.setDragImage(d,0,0);R&&d.parentNode.removeChild(d)}}),t(e.scroller,"dragenter",c),t(e.scroller,"dragover",c),t(e.scroller,"drop",B(a,df)));t(e.scroller,"paste",function(b){if(!ya(e,b)){a.state.pasteIncoming=true;M(a);jb(a)}});t(e.input,"paste",function(){if(J&&!a.state.fakedLastChar&&!(new Date-a.state.lastMiddleDown<200)){var b=e.input.selectionStart,c=e.input.selectionEnd;e.input.value=e.input.value+"$";e.input.selectionStart=
b;e.input.selectionEnd=c;a.state.fakedLastChar=true}a.state.pasteIncoming=true;jb(a)});t(e.input,"cut",d);t(e.input,"copy",d);oc&&t(e.sizer,"mouseup",function(){ja()==e.input&&e.input.blur();M(a)})}function ef(a){var b=a.display;b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null;a.setSize()}function ya(a,b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(!c||c.ignoreEvents||c.parentNode==a.sizer&&c!=a.mover)return!0}function Ma(a,b,c,d){var e=a.display;if(!c&&(c=b.target||
b.srcElement,c==e.scrollbarH||c==e.scrollbarV||c==e.scrollbarFiller||c==e.gutterFiller))return null;var f,g,e=e.lineSpace.getBoundingClientRect();try{f=b.clientX-e.left,g=b.clientY-e.top}catch(h){return null}var b=Hc(a,f,g),i;if(d&&1==b.xRel&&(i=r(a.doc,b.line).text).length==b.ch)d=Q(i,i.length,a.options.tabSize)-i.length,b=p(b.line,Math.max(0,Math.round((f-Jd(a.display).left)/Wa(a.display))-d));return b}function qd(a){if(!$(this,a)){var b=this.display;b.shift=a.shiftKey;if(ya(b,a))J||(b.scroller.draggable=
!1,setTimeout(function(){b.scroller.draggable=!0},100));else if(!Mc(this,a,"gutterClick",!0,D)){var c=Ma(this,a);window.focus();switch(Zd(a)){case 1:c?ff(this,a,c):(a.target||a.srcElement)==b.scroller&&K(a);break;case 2:J&&(this.state.lastMiddleDown=+new Date);c&&Cb(this.doc,c);setTimeout(T(M,this),20);K(a);break;case 3:Oc&&Sd(this,a)}}}}function ff(a,b,c){setTimeout(T(Kc,a),0);var d=+new Date,e;Qb&&Qb.time>d-400&&0==v(Qb.pos,c)?e="triple":Rb&&Rb.time>d-400&&0==v(Rb.pos,c)?(e="double",Qb={time:d,
pos:c}):(e="single",Rb={time:d,pos:c});var d=a.doc.sel,f=ea?b.metaKey:b.ctrlKey;a.options.dragDrop&&gf&&!Pb(a)&&"single"==e&&-1<d.contains(c)&&d.somethingSelected()?hf(a,b,c,f):jf(a,b,c,e,f)}function hf(a,b,c,d){var e=a.display,f=B(a,function(g){J&&(e.scroller.draggable=!1);a.state.draggingText=!1;ia(document,"mouseup",f);ia(e.scroller,"drop",f);10>Math.abs(b.clientX-g.clientX)+Math.abs(b.clientY-g.clientY)&&(K(g),d||Cb(a.doc,c),M(a),aa&&!H&&setTimeout(function(){document.body.focus();M(a)},20))});
J&&(e.scroller.draggable=!0);a.state.draggingText=f;e.scroller.dragDrop&&e.scroller.dragDrop();t(document,"mouseup",f);t(e.scroller,"drop",f)}function jf(a,b,c,d,e){function f(b){if(0!=v(o,b))if(o=b,"rect"==d){for(var e=[],f=a.options.tabSize,g=Q(r(j,c.line).text,c.ch,f),h=Q(r(j,b.line).text,b.ch,f),i=Math.min(g,h),g=Math.max(g,h),h=Math.min(c.line,b.line),w=Math.min(a.lastLine(),Math.max(c.line,b.line));h<=w;h++){var m=r(j,h).text,q=$d(m,i,f);i==g?e.push(new z(p(h,q),p(h,q))):m.length>q&&e.push(new z(p(h,
q),p(h,$d(m,g,f))))}e.length||e.push(new z(c,c));G(j,W(l.ranges.slice(0,n).concat(e),n),{origin:"*mouse",scroll:!1});a.scrollIntoView(b)}else e=k,f=e.anchor,i=b,"single"!=d&&(b="double"==d?Nc(a,b):new z(p(b.line,0),s(j,p(b.line+1,0))),0<v(b.anchor,f)?(i=b.head,f=Bc(e.from(),b.anchor)):(i=b.anchor,f=Ac(e.to(),b.head))),e=l.ranges.slice(0),e[n]=new z(s(j,f),i),G(j,W(e,n),Pc)}function g(b){var c=++m,e=Ma(a,b,!0,"rect"==d);if(e)if(0!=v(e,o)){Kc(a);f(e);var h=uc(i,j);(e.line>=h.to||e.line<h.from)&&setTimeout(B(a,
function(){m==c&&g(b)}),150)}else{var k=b.clientY<w.top?-20:b.clientY>w.bottom?20:0;k&&setTimeout(B(a,function(){m==c&&(i.scroller.scrollTop+=k,g(b))}),50)}}function h(b){m=Infinity;K(b);M(a);ia(document,"mousemove",q);ia(document,"mouseup",u);j.history.lastSelOrigin=null}var i=a.display,j=a.doc;K(b);var k,n,l=j.sel;e&&!b.shiftKey?(n=j.sel.contains(c),k=-1<n?j.sel.ranges[n]:new z(c,c)):k=j.sel.primary();b.altKey?(d="rect",e||(k=new z(c,c)),c=Ma(a,b,!0,!0),n=-1):"double"==d?(b=Nc(a,c),k=a.display.shift||
j.extend?bb(j,k,b.anchor,b.head):b):"triple"==d?(b=new z(p(c.line,0),s(j,p(c.line+1,0))),k=a.display.shift||j.extend?bb(j,k,b.anchor,b.head):b):k=bb(j,k,c);e?-1<n?Cd(j,n,k,Pc):(n=j.sel.ranges.length,G(j,W(j.sel.ranges.concat([k]),n),{scroll:!1,origin:"*mouse"})):(n=0,G(j,new ga([k],0),Pc),l=j.sel);var o=c,w=i.wrapper.getBoundingClientRect(),m=0,q=B(a,function(a){(I&&!kf?!a.buttons:!Zd(a))?h(a):g(a)}),u=B(a,h);t(document,"mousemove",q);t(document,"mouseup",u)}function Mc(a,b,c,d,e){try{var f=b.clientX,
g=b.clientY}catch(h){return!1}if(f>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&K(b);var d=a.display,i=d.lineDiv.getBoundingClientRect();if(g>i.bottom||!P(a,c))return Qc(b);g-=i.top-d.viewOffset;for(i=0;i<a.options.gutters.length;++i){var j=d.gutters.childNodes[i];if(j&&j.getBoundingClientRect().right>=f)return f=ua(a.doc,g),e(a,c,a,f,a.options.gutters[i],b),Qc(b)}}function df(a){var b=this;if(!$(b,a)&&!ya(b.display,a)){K(a);I&&(Xd=+new Date);var c=Ma(b,a,!0),d=a.dataTransfer.files;
if(c&&!Pb(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=B(b,function(){f[d]=h.result;if(++g==e){c=s(b.doc,c);var a={from:c,to:c,text:Ka(f.join("\n")),origin:"paste"};La(b.doc,a);Dd(b.doc,ma(c,xa(a)))}});h.readAsText(a)},h=0;h<e;++h)a(d[h],h);else if(b.state.draggingText&&-1<b.doc.sel.contains(c))b.state.draggingText(a),setTimeout(T(M,b),20);else try{if(f=a.dataTransfer.getData("Text")){if(b.state.draggingText&&!(ea?
a.metaKey:a.ctrlKey))var i=b.listSelections();Db(b.doc,ma(c,c));if(i)for(h=0;h<i.length;++h)Sb(b.doc,"",i[h].anchor,i[h].head,"drag");b.replaceSelection(f,"around","paste");M(b)}}catch(j){}}}function ib(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,mb||yb(a,{top:b}),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbarV.scrollTop!=b&&(a.display.scrollbarV.scrollTop=b),mb&&yb(a),Va(a,100))}function Ga(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,rc(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbarH.scrollLeft!=b)a.display.scrollbarH.scrollLeft=b}function Td(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&&ea&&J){var g=b.target,h=e.view;a:for(;g!=f;g=g.parentNode)for(var i=0;i<h.length;i++)if(h[i].node==g){a.display.currentWheelTarget=g;break a}}if(c&&!mb&&!R&&null!=S)d&&ib(a,Math.max(0,Math.min(f.scrollTop+d*S,f.scrollHeight-f.clientHeight))),Ga(a,Math.max(0,Math.min(f.scrollLeft+c*S,f.scrollWidth-f.clientWidth))),K(b),e.wheelStartX=null;else if(d&&null!=S&&(g=d*S,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),yb(a,{top:h,bottom:i})),20>Tb)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){S=(S*Tb+a)/(Tb+1);++Tb}}},200)):(e.wheelDX+=c,e.wheelDY+=d)}}function Ub(a,b,c){if("string"==typeof b&&(b=Vb[b],!b))return!1;a.display.pollingFast&&Jc(a)&&(a.display.pollingFast=
!1);var d=a.display.shift,e=!1;try{Pb(a)&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=ae}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function be(a){var b=a.state.keyMaps.slice(0);a.options.extraKeys&&b.push(a.options.extraKeys);b.push(a.options.keyMap);return b}function ce(a,b){var c=Rc(a.options.keyMap),d=c.auto;clearTimeout(de);d&&!lf(b)&&(de=setTimeout(function(){Rc(a.options.keyMap)==c&&(a.options.keyMap=d.call?d.call(null,a):d,od(a))},50));var e=mf(b,!0),f=!1;if(!e)return!1;
f=be(a);if(f=b.shiftKey?Wb("Shift-"+e,f,function(b){return Ub(a,b,!0)})||Wb(e,f,function(b){if("string"==typeof b?/^go[A-Z]/.test(b):b.motion)return Ub(a,b)}):Wb(e,f,function(b){return Ub(a,b)}))K(b),Hb(a),D(a,"keyHandled",a,e,b);return f}function nf(a,b,c){var d=Wb("'"+c+"'",be(a),function(b){return Ub(a,b,!0)});d&&(K(b),Hb(a),D(a,"keyHandled",a,"'"+c+"'",b));return d}function Vd(a){Kc(this);if(!$(this,a)){aa&&27==a.keyCode&&(a.returnValue=!1);var b=a.keyCode;this.display.shift=16==b||a.shiftKey;
var c=ce(this,a);R&&(Sc=c?b:null,!c&&(88==b&&!Rd&&(ea?a.metaKey:a.ctrlKey))&&this.replaceSelection("",null,"cut"));18==b&&!/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)&&of(this)}}function of(a){function b(a){if(18==a.keyCode||!a.altKey)Xb(c,"CodeMirror-crosshair"),ia(document,"keyup",b),ia(document,"mouseover",b)}var c=a.display.lineDiv;Yb(c,"CodeMirror-crosshair");t(document,"keyup",b);t(document,"mouseover",b)}function Ud(a){!$(this,a)&&16==a.keyCode&&(this.doc.sel.shift=!1)}
function Wd(a){if(!$(this,a)){var b=a.keyCode,c=a.charCode;if(R&&b==Sc)Sc=null,K(a);else if(!(R&&(!a.which||10>a.which)||oc)||!ce(this,a))b=String.fromCharCode(null==c?b:c),nf(this,a,b)||(I&&!H&&(this.display.inputHasSelection=null),jb(this))}}function mc(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(E(a,"focus",a),a.state.focused=!0,Yb(a.display.wrapper,"CodeMirror-focused"),!a.curOp&&a.display.selForContextMenu!=a.doc.sel&&(U(a),J&&setTimeout(T(U,a,!0),0))),Ob(a),Hb(a))}function vb(a){a.state.focused&&
(E(a,"blur",a),a.state.focused=!1,Xb(a.display.wrapper,"CodeMirror-focused"));clearInterval(a.display.blinker);setTimeout(function(){if(!a.state.focused)a.display.shift=false},150)}function Sd(a,b){function c(){if(null!=e.input.selectionStart){var b=a.somethingSelected(),c=e.input.value=""+(b?e.input.value:"");e.prevInput=b?"":"";e.input.selectionStart=1;e.input.selectionEnd=c.length;e.selForContextMenu=a.doc.sel}}function d(){e.inputDiv.style.position="relative";e.input.style.cssText=h;H&&(e.scrollbarV.scrollTop=
e.scroller.scrollTop=g);Ob(a);if(null!=e.input.selectionStart){(!I||H)&&c();var b=0,d=function(){e.selForContextMenu==a.doc.sel&&e.input.selectionStart==0?B(a,Vb.selectAll)(a):b++<10?e.detectingSelectAll=setTimeout(d,500):U(a)};e.detectingSelectAll=setTimeout(d,200)}}if(!$(a,b,"contextmenu")){var e=a.display;if(!ya(e,b)&&!(!P(a,"gutterContextMenu")?0:Mc(a,b,"gutterContextMenu",!1,E))){var f=Ma(a,b),g=e.scroller.scrollTop;if(f&&!R){a.options.resetSelectionOnContextMenu&&-1==a.doc.sel.contains(f)&&
B(a,G)(a.doc,ma(f),va);var h=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: "+(I?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";M(a);U(a);a.somethingSelected()||(e.input.value=e.prevInput=" ");e.selForContextMenu=a.doc.sel;clearTimeout(e.detectingSelectAll);
I&&!H&&c();if(Oc){Lc(b);var i=function(){ia(window,"mouseup",i);setTimeout(d,20)};t(window,"mouseup",i)}else setTimeout(d,50)}}}}function ee(a,b){if(0>v(a,b.from))return a;if(0>=v(a,b.to))return xa(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;a.line==b.to.line&&(d+=xa(b).ch-b.to.ch);return p(c,d)}function Tc(a,b){for(var c=[],d=0;d<a.sel.ranges.length;d++){var e=a.sel.ranges[d];c.push(new z(ee(e.anchor,b),ee(e.head,b)))}return W(c,a.sel.primIndex)}function fe(a,b,c){return a.line==
b.line?p(c.line,a.ch-b.ch+c.ch):p(c.line+(a.line-b.line),a.ch)}function ge(a,b,c){b={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,cancel:function(){this.canceled=!0}};c&&(b.update=function(b,c,f,g){b&&(this.from=s(a,b));c&&(this.to=s(a,c));f&&(this.text=f);void 0!==g&&(this.origin=g)});E(a,"beforeChange",a,b);a.cm&&E(a.cm,"beforeChange",a.cm,b);return b.canceled?null:{from:b.from,to:b.to,text:b.text,origin:b.origin}}function La(a,b,c){if(a.cm){if(!a.cm.curOp)return B(a.cm,La)(a,b,c);
if(a.cm.state.suppressEdits)return}if(P(a,"beforeChange")||a.cm&&P(a.cm,"beforeChange"))if(b=ge(a,b,!0),!b)return;if(c=he&&!c&&pf(a,b.from,b.to))for(var d=c.length-1;0<=d;--d)ie(a,{from:c[d].from,to:c[d].to,text:d?[""]:b.text});else ie(a,b)}function ie(a,b){if(!(1==b.text.length&&""==b.text[0]&&0==v(b.from,b.to))){var c=Tc(a,b);je(a,b,c,a.cm?a.cm.curOp.id:NaN);nb(a,b,c,Uc(a,b));var d=[];za(a,function(a,c){!c&&-1==F(d,a.history)&&(ke(a.history,b),d.push(a.history));nb(a,b,null,Uc(a,b))})}}function Zb(a,
b,c){if(!a.cm||!a.cm.state.suppressEdits){for(var d=a.history,e,f=a.sel,g="undo"==b?d.done:d.undone,h="undo"==b?d.undone:d.done,i=0;i<g.length&&!(e=g[i],c?e.ranges&&!e.equals(a.sel):!e.ranges);i++);if(i!=g.length){for(d.lastOrigin=d.lastSelOrigin=null;;)if(e=g.pop(),e.ranges){Eb(e,h);if(c&&!e.equals(a.sel)){G(a,e,{clearRedo:!1});return}f=e}else break;c=[];Eb(f,h);h.push({changes:c,generation:d.generation});d.generation=e.generation||++d.maxGeneration;d=P(a,"beforeChange")||a.cm&&P(a.cm,"beforeChange");
for(i=e.changes.length-1;0<=i;--i){var j=e.changes[i];j.origin=b;if(d&&!ge(a,j,!1)){g.length=0;break}c.push(Vc(a,j));f=i?Tc(a,j,null):x(g);nb(a,j,f,le(a,j));!i&&a.cm&&a.cm.scrollIntoView(j);var k=[];za(a,function(a,b){!b&&-1==F(k,a.history)&&(ke(a.history,j),k.push(a.history));nb(a,j,null,le(a,j))})}}}}function me(a,b){if(0!=b&&(a.first+=b,a.sel=new ga(Wc(a.sel.ranges,function(a){return new z(p(a.anchor.line+b,a.anchor.ch),p(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){O(a.cm,a.first,a.first-
b,b);for(var c=a.cm.display,d=c.viewFrom;d<c.viewTo;d++)na(a.cm,d,"gutter")}}function nb(a,b,c,d){if(a.cm&&!a.cm.curOp)return B(a.cm,nb)(a,b,c,d);if(b.to.line<a.first)me(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);me(a,e);b={from:p(a.first,0),to:p(b.to.line+e,b.to.ch),text:[x(b.text)],origin:b.origin}}e=a.lastLine();b.to.line>e&&(b={from:b.from,to:p(e,r(a,e).text.length),text:[b.text[0]],origin:b.origin});
b.removed=ob(a,b.from,b.to);c||(c=Tc(a,b,null));a.cm?qf(a.cm,b,d):Xc(a,b,d);Db(a,c,va)}}function qf(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to,h=!1,i=f.line;a.options.lineWrapping||(i=A(Z(r(d,f.line))),d.iter(i,g.line+1,function(a){if(a==e.maxLine)return h=!0}));-1<d.sel.contains(b.from,b.to)&&Hd(a);Xc(d,b,c,nd(a));a.options.lineWrapping||(d.iter(i,f.line+b.text.length,function(a){var b=wb(a);if(b>e.maxLineLength){e.maxLine=a;e.maxLineLength=b;e.maxLineChanged=true;h=false}}),h&&(a.curOp.updateMaxLine=
!0));d.frontier=Math.min(d.frontier,f.line);Va(a,400);c=b.text.length-(g.line-f.line)-1;f.line==g.line&&1==b.text.length&&!ne(a.doc,b)?na(a,f.line,"text"):O(a,f.line,g.line+1,c);c=P(a,"changes");if((d=P(a,"change"))||c)b={from:f,to:g,text:b.text,removed:b.removed,origin:b.origin},d&&D(a,"change",a,b),c&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(b);a.display.selForContextMenu=null}function Sb(a,b,c,d,e){d||(d=c);if(0>v(d,c))var f=d,d=c,c=f;"string"==typeof b&&(b=Ka(b));La(a,{from:c,to:d,text:b,
origin:e})}function Mb(a,b,c,d,e){var f=a.display,g=qa(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,i=f.scroller.clientHeight-ca,j={},k=a.doc.height+(f.mover.offsetHeight-f.lineSpace.offsetHeight),n=c<g,g=e>k-g;c<h?j.scrollTop=n?0:c:e>h+i&&(c=Math.min(c,(g?k:e)-i),c!=h&&(j.scrollTop=c));a=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft;h=f.scroller.clientWidth-ca;b+=f.gutters.offsetWidth;d+=f.gutters.offsetWidth;f=f.gutters.offsetWidth;
c=b<f+10;b<a+f||c?(c&&(b=0),j.scrollLeft=Math.max(0,b-10-f)):d>h+a-3&&(j.scrollLeft=d+10-h);return j}function Yc(a,b,c){(null!=b||null!=c)&&$b(a);null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b);null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function Ha(a){$b(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?p(b.line,b.ch-1):b,d=p(b.line,b.ch+1));a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,
isCursor:!0}}function $b(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=Qd(a,b.from),d=Qd(a,b.to),b=Mb(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(b.scrollLeft,b.scrollTop)}}function kb(a,b,c,d){var e=a.doc,f;null==c&&(c="add");"smart"==c&&(a.doc.mode.indent?f=db(a,b):c="prev");var g=a.options.tabSize,h=r(e,b),i=Q(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var j=h.text.match(/^\s*/)[0],
k;if(!d&&!/\S/.test(h.text))k=0,c="not";else if("smart"==c&&(k=a.doc.mode.indent(f,h.text.slice(j.length),h.text),k==ae)){if(!d)return;c="prev"}"prev"==c?k=b>e.first?Q(r(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c?k=i-a.options.indentUnit:"number"==typeof c&&(k=i+c);k=Math.max(0,k);d="";f=0;if(a.options.indentWithTabs)for(c=Math.floor(k/g);c;--c)f+=g,d+="\t";f<k&&(d+=oe(k-f));if(d!=j)Sb(a.doc,d,p(b,0),p(b,j.length),"+input");else for(c=0;c<e.sel.ranges.length;c++)if(a=e.sel.ranges[c],
a.head.line==b&&a.head.ch<j.length){f=p(b,j.length);Cd(e,c,new z(f,f));break}h.stateAfter=null}function ac(a,b,c,d){var e=b,f=b,g=a.doc;"number"==typeof b?f=r(g,Math.max(g.first,Math.min(b,g.first+g.size-1))):e=A(b);if(null==e)return null;d(f,e)&&na(a,e,c);return f}function bc(a,b){for(var c=a.doc.sel.ranges,d=[],e=0;e<c.length;e++){for(var f=b(c[e]);d.length&&0>=v(f.from,x(d).to);){var g=d.pop();if(0>v(g.from,f.from)){f.from=g.from;break}}d.push(f)}ba(a,function(){for(var b=d.length-1;0<=b;b--)Sb(a.doc,
"",d[b].from,d[b].to,"+delete");Ha(a)})}function Zc(a,b,c,d,e){function f(b){var d=(e?Ic:pe)(j,h,c,!0);if(null==d){if(b=!b)b=g+c,b<a.first||b>=a.first+a.size?b=k=!1:(g=b,b=j=r(a,b));if(b)h=e?(0>c?Kb:Jb)(j):0>c?j.text.length:0;else return k=!1}else h=d;return!0}var g=b.line,h=b.ch,i=c,j=r(a,g),k=!0;if("char"==d)f();else if("column"==d)f(!0);else if("word"==d||"group"==d)for(var n=null,d="group"==d,b=a.cm&&a.cm.getHelper(b,"wordChars"),l=!0;!(0>c)||f(!l);l=!1){var o=j.text.charAt(h)||"\n",o=cc(o,b)?
"w":d&&"\n"==o?"n":!d||/\s/.test(o)?null:"p";d&&(!l&&!o)&&(o="s");if(n&&n!=o){0>c&&(c=1,f());break}o&&(n=o);if(0<c&&!f(!l))break}i=Fb(a,p(g,h),i,!0);k||(i.hitSide=!0);return i}function qe(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)*qa(a.display))):"line"==d&&(g=0<c?b.bottom+3:b.top-3);for(;;){var h=Hc(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 Nc(a,b){var c=r(a.doc,b.line).text,d=b.ch,e=b.ch;if(c){var f=a.getHelper(b,"wordChars");(0>b.xRel||e==c.length)&&d?--d:++e;for(var g=c.charAt(d),g=cc(g,f)?function(a){return cc(a,f)}:/\s/.test(g)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!cc(a)};0<d&&g(c.charAt(d-1));)--d;for(;e<c.length&&g(c.charAt(e));)++e}return new z(p(b.line,d),p(b.line,e))}function u(a,b,c,d){m.defaults[a]=b;c&&(Fa[a]=d?function(a,b,d){d!=md&&c(a,b,d)}:c)}function Rc(a){return"string"==
typeof a?da[a]:a}function Na(a,b,c,d,e){if(d&&d.shared)return rf(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return B(a.cm,Na)(a,b,c,d,e);var f=new Aa(a,e),e=v(b,c);d&&Ra(d,f,!1);if(0<e||0==e&&!1!==f.clearWhenEmpty)return f;if(f.replacedWith&&(f.collapsed=!0,f.widgetNode=q("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||(f.widgetNode.ignoreEvents=!0),d.insertLeft))f.widgetNode.insertLeft=!0;if(f.collapsed){if(re(a,b.line,b,c,f)||b.line!=c.line&&re(a,c.line,b,c,f))throw Error("Inserting collapsed marker partially overlapping an existing one");
la=!0}f.addToHistory&&je(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var g=b.line,h=a.cm,i;a.iter(g,c.line+1,function(a){h&&(f.collapsed&&!h.options.lineWrapping&&Z(a)==h.display.maxLine)&&(i=!0);f.collapsed&&g!=b.line&&V(a,0);var d=new dc(f,g==b.line?b.ch:null,g==c.line?c.ch:null);a.markedSpans=a.markedSpans?a.markedSpans.concat([d]):[d];d.marker.attachLine(a);++g});f.collapsed&&a.iter(b.line,c.line+1,function(b){ra(a,b)&&V(b,0)});f.clearOnEnter&&t(f,"beforeCursorEnter",function(){f.clear()});f.readOnly&&
(he=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory());f.collapsed&&(f.id=++sf,f.atomic=!0);if(h){i&&(h.curOp.updateMaxLine=!0);if(f.collapsed)O(h,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle)for(d=b.line;d<=c.line;d++)na(h,d,"text");f.atomic&&Id(h.doc);D(h,"markerAdded",h,f)}return f}function rf(a,b,c,d,e){d=Ra(d);d.shared=!1;var f=[Na(a,b,c,d,e)],g=f[0],h=d.widgetNode;za(a,function(a){h&&(d.widgetNode=h.cloneNode(!0));f.push(Na(a,s(a,b),s(a,c),d,e));
for(var j=0;j<a.linked.length;++j)if(a.linked[j].isParent)return;g=x(f)});return new ec(f,g)}function se(a){return a.findMarks(p(a.first,0),a.clipPos(p(a.lastLine())),function(a){return a.parent})}function tf(a){for(var b=0;b<a.length;b++){var c=a[b],d=[c.primary.doc];za(c.primary.doc,function(a){d.push(a)});for(var e=0;e<c.markers.length;e++){var f=c.markers[e];-1==F(d,f.doc)&&(f.parent=null,c.markers.splice(e--,1))}}}function dc(a,b,c){this.marker=a;this.from=b;this.to=c}function pb(a,b){if(a)for(var c=
0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function Uc(a,b){var c=ab(a,b.from.line)&&r(a,b.from.line).markedSpans,d=ab(a,b.to.line)&&r(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,f=b.to.ch,g=0==v(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)||j.from==e&&"bookmark"==k.type&&(!g||!j.marker.insertLeft)){var n=null==j.to||(k.inclusiveRight?j.to>=e:j.to>e);(i||(i=[])).push(new dc(k,j.from,n?null:
j.to))}}c=i;if(d)for(var h=0,l;h<d.length;++h)if(i=d[h],j=i.marker,null==i.to||(j.inclusiveRight?i.to>=f:i.to>f)||i.from==f&&"bookmark"==j.type&&(!g||i.marker.insertLeft))k=null==i.from||(j.inclusiveLeft?i.from<=f:i.from<f),(l||(l=[])).push(new dc(j,k?null:i.from-f,null==i.to?null:i.to-f));d=l;g=1==b.text.length;l=x(b.text).length+(g?e:0);if(c)for(f=0;f<c.length;++f)h=c[f],null==h.to&&((i=pb(d,h.marker))?g&&(h.to=null==i.to?null:i.to+l):h.to=e);if(d)for(f=0;f<d.length;++f)(h=d[f],null!=h.to&&(h.to+=
l),null==h.from)?(i=pb(c,h.marker),i||(h.from=l,g&&(c||(c=[])).push(h))):(h.from+=l,g&&(c||(c=[])).push(h));c&&(c=te(c));d&&d!=c&&(d=te(d));e=[c];if(!g){var g=b.text.length-2,o;if(0<g&&c)for(f=0;f<c.length;++f)null==c[f].to&&(o||(o=[])).push(new dc(c[f].marker,null,null));for(f=0;f<g;++f)e.push(o);e.push(d)}return e}function te(a){for(var b=0;b<a.length;++b){var c=a[b];null!=c.from&&(c.from==c.to&&!1!==c.marker.clearWhenEmpty)&&a.splice(b--,1)}return!a.length?null:a}function le(a,b){var c;if(c=b["spans_"+
a.id]){for(var d=0,e=[];d<b.text.length;++d)e.push(uf(c[d]));c=e}else c=null;d=Uc(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 pf(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==F(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(0),f=0;f<a.length;++f){var g=a[f];if(!(0>v(g.to,e.from)||0<v(g.from,e.to))){var h=[f,1],i=v(g.from,e.from),j=v(g.to,e.to);(0>i||!c.inclusiveLeft&&!i)&&h.push({from:g.from,to:e.from});(0<j||!c.inclusiveRight&&!j)&&h.push({from:e.to,to:g.to});a.splice.apply(a,h);f+=h.length-1}}return a}function ue(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function ve(a,b){if(b){for(var c=
0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=b}}function we(a,b){var c=a.lines.length-b.lines.length;if(0!=c)return c;var c=a.find(),d=b.find(),e=v(c.from,d.from)||(a.inclusiveLeft?-1:0)-(b.inclusiveLeft?-1:0);return e?-e:(c=v(c.to,d.to)||(a.inclusiveRight?1:0)-(b.inclusiveRight?1:0))?c:b.id-a.id}function ta(a,b){var c=la&&a.markedSpans,d;if(c)for(var e,f=0;f<c.length;++f)if(e=c[f],e.marker.collapsed&&null==(b?e.from:e.to)&&(!d||0>we(d,e.marker)))d=e.marker;return d}function re(a,b,c,
d,e){a=r(a,b);if(a=la&&a.markedSpans)for(b=0;b<a.length;++b){var f=a[b];if(f.marker.collapsed){var g=f.marker.find(0),h=v(g.from,c)||(f.marker.inclusiveLeft?-1:0)-(e.inclusiveLeft?-1:0),i=v(g.to,d)||(f.marker.inclusiveRight?1:0)-(e.inclusiveRight?1:0);if(!(0<=h&&0>=i||0>=h&&0<=i))if(0>=h&&0<(v(g.to,c)||(f.marker.inclusiveRight?1:0)-(e.inclusiveLeft?-1:0))||0<=h&&0>(v(g.from,d)||(f.marker.inclusiveLeft?-1:0)-(e.inclusiveRight?1:0)))return!0}}}function Z(a){for(var b;b=ta(a,!0);)a=b.find(-1,!0).line;
return a}function wc(a,b){var c=r(a,b),d=Z(c);return c==d?b:A(d)}function td(a,b){if(b>a.lastLine())return b;var c=r(a,b),d;if(!ra(a,c))return b;for(;d=ta(c,!1);)c=d.find(1,!0).line;return A(c)+1}function ra(a,b){var c=la&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed&&(null==d.from||!d.marker.widgetNode&&0==d.from&&d.marker.inclusiveLeft&&$c(a,b,d)))return!0}function $c(a,b,c){if(null==c.to)return b=c.marker.find(1,!0),$c(a,b.line,pb(b.line.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.marker.widgetNode&&d.from==c.to&&(null==d.to||d.to!=c.from)&&(d.marker.inclusiveLeft||c.marker.inclusiveRight)&&$c(a,b,d))return!0}function xe(a,b,c){fa(b)<(a.curOp&&a.curOp.scrollTop||a.doc.scrollTop)&&Yc(a,null,c)}function gb(a){if(null!=a.height)return a.height;var b;a:{var c=document.body,d=a.node;if(c.contains)b=c.contains(d);else for(;d=d.parentNode;)if(d==c){b=!0;break a}}b||X(a.cm.display.measure,
q("div",[a.node],null,"position: relative"));return a.height=a.node.offsetHeight}function vf(a,b,c,d){var e=new fc(a,c,d);e.noHScroll&&(a.display.alignWidgets=!0);ac(a,b,"widget",function(b){var c=b.widgets||(b.widgets=[]);e.insertAt==null?c.push(e):c.splice(Math.min(c.length-1,Math.max(0,e.insertAt)),0,e);e.line=b;if(!ra(a.doc,b)){c=fa(b)<a.doc.scrollTop;V(b,b.height+gb(e));c&&Yc(a,null,e.height);a.curOp.forceUpdate=true}return true});return e}function ye(a,b){if(a)for(;;){var c=a.match(/(?:^|\s+)line-(background-)?(\S+)/);
if(!c)break;var a=a.slice(0,c.index)+a.slice(c.index+c[0].length),d=c[1]?"bgClass":"textClass";null==b[d]?b[d]=c[2]:RegExp("(?:^|s)"+c[2]+"(?:$|s)").test(b[d])||(b[d]+=" "+c[2])}return a}function ze(a,b){if(a.blankLine)return a.blankLine(b);if(a.innerMode){var c=m.innerMode(a,b);if(c.mode.blankLine)return c.mode.blankLine(c.state)}}function ad(a,b,c){for(var d=0;10>d;d++){var e=a.token(b,c);if(b.pos>b.start)return e}throw Error("Mode "+a.name+" failed to advance stream.");}function Ae(a,b,c,d,e,f,
g){var h=c.flattenSpans;null==h&&(h=a.options.flattenSpans);var i=0,j=null,k=new gc(b,a.options.tabSize),n;for(""==b&&ye(ze(c,d),f);!k.eol();){k.pos>a.options.maxHighlightLength?(h=!1,g&&Cc(a,b,d,k.pos),k.pos=b.length,n=null):n=ye(ad(c,k,d),f);if(a.options.addModeClass){var l=m.innerMode(c,d).mode.name;l&&(n="m-"+(n?l+" "+n:l))}if(!h||j!=n)i<k.start&&e(k.start,j),i=k.start,j=n;k.start=k.pos}for(;i<k.pos;)a=Math.min(k.pos,i+5E4),e(a,j),i=a}function Kd(a,b,c,d){var e=[a.state.modeGen],f={};Ae(a,b.text,
a.doc.mode,c,function(a,b){e.push(a,b)},f,d);for(c=0;c<a.state.overlays.length;++c){var g=a.state.overlays[c],h=1,i=0;Ae(a,b.text,g.mode,!0,function(a,b){for(var c=h;i<a;){var d=e[h];d>a&&e.splice(h,1,a,e[h+1],d);h=h+2;i=Math.min(a,d)}if(b)if(g.opaque){e.splice(c,h-c,a,"cm-overlay "+b);h=c+2}else for(;c<h;c=c+2){d=e[c+1];e[c+1]=(d?d+" ":"")+"cm-overlay "+b}},f)}return{styles:e,classes:f.bgClass||f.textClass?f:null}}function Be(a,b){if(!b.styles||b.styles[0]!=a.state.modeGen){var c=Kd(a,b,b.stateAfter=
db(a,A(b)));b.styles=c.styles;c.classes?b.styleClasses=c.classes:b.styleClasses&&(b.styleClasses=null)}return b.styles}function Cc(a,b,c,d){var e=a.doc.mode,f=new gc(b,a.options.tabSize);f.start=f.pos=d||0;for(""==b&&ze(e,c);!f.eol()&&f.pos<=a.options.maxHighlightLength;)ad(e,f,c),f.start=f.pos}function Ce(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?wf:xf;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function zd(a,b){var c=q("span",null,null,J?"padding-right: .1px":null),c={pre:q("pre",
[c]),content:c,col:0,pos:0,cm:a};b.measure={};for(var d=0;d<=(b.rest?b.rest.length:0);d++){var e=d?b.rest[d-1]:b.line,f;c.pos=0;c.addToken=yf;if((I||J)&&a.getOption("lineWrapping"))c.addToken=zf(c.addToken);var g;if(null!=bd)g=bd;else{g=X(a.display.measure,document.createTextNode("AخA"));var h=fb(g,0,1).getBoundingClientRect();g=h.left==h.right?!1:bd=3>fb(g,1,2).getBoundingClientRect().right-h.right}if(g&&(f=Y(e)))c.addToken=Af(c.addToken,f);c.map=[];a:{g=c;var h=Be(a,e),i=e.markedSpans,j=e.text,
k=0;if(i)for(var n=j.length,l=0,o=1,m="",p=void 0,r=0,s=void 0,t=void 0,u=void 0,v=void 0,x=void 0;;){if(r==l){for(var s=t=u=v="",x=null,r=Infinity,z=[],A=0;A<i.length;++A){var y=i[A],B=y.marker;if(y.from<=l&&(null==y.to||y.to>l)){if(null!=y.to&&r>y.to&&(r=y.to,t=""),B.className&&(s+=" "+B.className),B.startStyle&&y.from==l&&(u+=" "+B.startStyle),B.endStyle&&y.to==r&&(t+=" "+B.endStyle),B.title&&!v&&(v=B.title),B.collapsed&&(!x||0>we(x.marker,B)))x=y}else y.from>l&&r>y.from&&(r=y.from);"bookmark"==
B.type&&(y.from==l&&B.widgetNode)&&z.push(B)}if(x&&(x.from||0)==l)if(De(g,(null==x.to?n+1:x.to)-l,x.marker,null==x.from),null==x.to)break a;if(!x&&z.length)for(A=0;A<z.length;++A)De(g,0,z[A])}if(l>=n)break;for(z=Math.min(n,r);;){if(m){A=l+m.length;x||(y=A>z?m.slice(0,z-l):m,g.addToken(g,y,p?p+s:s,u,l+y.length==r?t:"",v));if(A>=z){m=m.slice(z-l);l=z;break}l=A;u=""}m=j.slice(k,k=h[o++]);p=Ce(h[o++],g.cm.options)}}else for(var o=1;o<h.length;o+=2)g.addToken(g,j.slice(k,k=h[o]),Ce(h[o+1],g.cm.options))}if(e.styleClasses&&
(e.styleClasses.bgClass&&(c.bgClass=cd(e.styleClasses.bgClass,c.bgClass||"")),e.styleClasses.textClass))c.textClass=cd(e.styleClasses.textClass,c.textClass||"");0==c.map.length&&c.map.push(0,0,c.content.appendChild(Bf(a.display.measure)));0==d?(b.measure.map=c.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(c.map),(b.measure.caches||(b.measure.caches=[])).push({}))}E(a,"renderLine",a,b.line,c.pre);c.pre.className&&(c.textClass=cd(c.pre.className,c.textClass||""));return c}function yf(a,
b,c,d,e,f){if(b){var g=a.cm.options.specialChars,h=!1;if(g.test(b))for(var i=document.createDocumentFragment(),j=0;;){g.lastIndex=j;var k=g.exec(b),n=k?k.index-j:b.length-j;if(n){var l=document.createTextNode(b.slice(j,j+n));H?i.appendChild(q("span",[l])):i.appendChild(l);a.map.push(a.pos,a.pos+n,l);a.col+=n;a.pos+=n}if(!k)break;j+=n+1;"\t"==k[0]?(l=a.cm.options.tabSize,k=l-a.col%l,l=i.appendChild(q("span",oe(k),"cm-tab")),a.col+=k):(l=a.cm.options.specialCharPlaceholder(k[0]),H?i.appendChild(q("span",
[l])):i.appendChild(l),a.col+=1);a.map.push(a.pos,a.pos+1,l);a.pos++}else{a.col+=b.length;var i=document.createTextNode(b);a.map.push(a.pos,a.pos+b.length,i);H&&(h=!0);a.pos+=b.length}if(c||d||e||h)return b=c||"",d&&(b+=d),e&&(b+=e),d=q("span",[i],b),f&&(d.title=f),a.content.appendChild(d);a.content.appendChild(i)}}function zf(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,h){a(c,d.replace(/ {3,}/g,b),e,f,g,h)}}function Af(a,b){return function(c,
d,e,f,g,h){for(var e=e?e+" cm-force-border":"cm-force-border",i=c.pos,j=i+d.length;;){for(var k=0;k<b.length;k++){var n=b[k];if(n.to>i&&n.from<=i)break}if(n.to>=j)return a(c,d,e,f,g,h);a(c,d.slice(0,n.to-i),e,f,null,h);f=null;d=d.slice(n.to-i);i=n.to}}}function De(a,b,c,d){if(c=!d&&c.widgetNode)a.map.push(a.pos,a.pos+b,c),a.content.appendChild(c);a.pos+=b}function ne(a,b){return 0==b.from.ch&&0==b.to.ch&&""==x(b.text)&&(!a.cm||a.cm.options.wholeLineUpdateBefore)}function Xc(a,b,c,d){function e(a){return c?
c[a]:null}function f(a,c,e){var f=d;a.text=c;a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null);null!=a.order&&(a.order=null);ue(a);ve(a,e);c=f?f(a):1;c!=a.height&&V(a,c);D(a,"change",a,b)}var g=b.from,h=b.to,i=b.text,j=r(a,g.line),k=r(a,h.line),n=x(i),l=e(i.length-1),o=h.line-g.line;if(ne(a,b)){for(var m=0,p=[];m<i.length-1;++m)p.push(new Ba(i[m],e(m),d));f(k,k.text,l);o&&a.remove(g.line,o);p.length&&a.insert(g.line,p)}else if(j==k)if(1==i.length)f(j,j.text.slice(0,g.ch)+n+j.text.slice(h.ch),
l);else{p=[];for(m=1;m<i.length-1;++m)p.push(new Ba(i[m],e(m),d));p.push(new Ba(n+j.text.slice(h.ch),l,d));f(j,j.text.slice(0,g.ch)+i[0],e(0));a.insert(g.line+1,p)}else if(1==i.length)f(j,j.text.slice(0,g.ch)+i[0]+k.text.slice(h.ch),e(0)),a.remove(g.line+1,o);else{f(j,j.text.slice(0,g.ch)+i[0],e(0));f(k,n+k.text.slice(h.ch),l);m=1;for(p=[];m<i.length-1;++m)p.push(new Ba(i[m],e(m),d));1<o&&a.remove(g.line+1,o-1);a.insert(g.line+1,p)}D(a,"change",a,b)}function qb(a){this.lines=a;this.parent=null;for(var b=
0,c=0;b<a.length;++b)a[b].parent=this,c+=a[b].height;this.height=c}function rb(a){this.children=a;for(var b=0,c=0,d=0;d<a.length;++d){var e=a[d],b=b+e.chunkSize(),c=c+e.height;e.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 ld(a,b){if(b.cm)throw Error("This document is already in use.");a.doc=b;b.cm=
a;qc(a);pc(a);a.options.lineWrapping||tc(a);a.options.mode=b.modeOption;O(a)}function r(a,b){b-=a.first;if(0>b||b>=a.size)throw Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(b<f){c=e;break}b-=f}return c.lines[b]}function ob(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 dd(a,b,c){var d=[];a.iter(b,
c,function(a){d.push(a.text)});return d}function V(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function A(a){if(null==a.parent)return null;for(var b=a.parent,a=F(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 ua(a,b){var c=a.first;a:do{for(var d=0;d<a.children.length;++d){var e=a.children[d],f=e.height;if(b<f){a=e;continue a}b-=f;c+=e.chunkSize()}return c}while(!a.lines);for(d=0;d<a.lines.length;++d){e=
a.lines[d].height;if(b<e)break;b-=e}return c+d}function fa(a){for(var a=Z(a),b=0,c=a.parent,d=0;d<c.lines.length;++d){var e=c.lines[d];if(e==a)break;else b+=e.height}for(a=c.parent;a;c=a,a=c.parent)for(d=0;d<a.children.length&&!(e=a.children[d],e==c);++d)b+=e.height;return b}function Y(a){var b=a.order;null==b&&(b=a.order=Cf(a.text));return b}function hc(a){this.done=[];this.undone=[];this.undoDepth=Infinity;this.lastModTime=this.lastSelTime=0;this.lastOrigin=this.lastSelOrigin=this.lastOp=null;this.generation=
this.maxGeneration=a||1}function Vc(a,b){var c={from:p(b.from.line,b.from.ch),to:xa(b),text:ob(a,b.from,b.to)};Ee(a,c,b.from.line,b.to.line+1);za(a,function(a){Ee(a,c,b.from.line,b.to.line+1)},!0);return c}function Ed(a){for(;a.length;)if(x(a).ranges)a.pop();else break}function je(a,b,c,d){var e=a.history;e.undone.length=0;var f=+new Date,g,h;if(h=e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0))){var i;
e.lastOp==d?(Ed(e.done),i=x(e.done)):e.done.length&&!x(e.done).ranges?i=x(e.done):1<e.done.length&&!e.done[e.done.length-2].ranges&&(e.done.pop(),i=x(e.done));h=g=i}if(h){var j=x(g.changes);0==v(b.from,b.to)&&0==v(b.from,j.to)?j.to=xa(b):g.changes.push(Vc(a,b))}else{g=x(e.done);(!g||!g.ranges)&&Eb(a.sel,e.done);g={changes:[Vc(a,b)],generation:e.generation};for(e.done.push(g);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c);e.generation=++e.maxGeneration;e.lastModTime=
e.lastSelTime=f;e.lastOp=d;e.lastOrigin=e.lastSelOrigin=b.origin;j||E(a,"historyAdded")}function Eb(a,b){var c=x(b);(!c||!c.ranges||!c.equals(a))&&b.push(a)}function Ee(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 uf(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 Oa(a,
b,c){for(var d=0,e=[];d<a.length;++d){var f=a[d];if(f.ranges)e.push(c?ga.prototype.deepCopy.call(f):f);else{var f=f.changes,g=[];e.push({changes:g});for(var h=0;h<f.length;++h){var i=f[h],j;g.push({from:i.from,to:i.to,text:i.text});if(b)for(var k in i)if((j=k.match(/^spans_(\d+)$/))&&-1<F(b,Number(j[1])))x(g)[k]=i[k],delete i[k]}}}return e}function Fe(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function Ge(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e],g=!0;if(f.ranges){f.copied||(f=
a[e]=f.deepCopy(),f.copied=!0);for(var h=0;h<f.ranges.length;h++)Fe(f.ranges[h].anchor,b,c,d),Fe(f.ranges[h].head,b,c,d)}else{for(h=0;h<f.changes.length;++h){var i=f.changes[h];if(c<i.from.line)i.from=p(i.from.line+d,i.from.ch),i.to=p(i.to.line+d,i.to.ch);else if(b<=i.to.line){g=!1;break}}g||(a.splice(0,e+1),e=0)}}}function ke(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;Ge(a.done,c,d,e);Ge(a.undone,c,d,e)}function Qc(a){return null!=a.defaultPrevented?a.defaultPrevented:!1==a.returnValue}
function Zd(a){var b=a.which;null==b&&(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));ea&&(a.ctrlKey&&1==b)&&(b=3);return b}function D(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);oa||(++Lb,oa=[],setTimeout(Df,0));for(var f=0;f<d.length;++f)oa.push(c(d[f]))}}function Df(){--Lb;var a=oa;oa=null;for(var b=0;b<a.length;++b)a[b]()}function $(a,b,c){E(a,c||b.type,a,b);return Qc(b)||b.codemirrorIgnore}function Hd(a){var b=
a._handlers&&a._handlers.cursorActivity;if(b)for(var a=a.curOp.cursorActivityHandlers||(a.curOp.cursorActivityHandlers=[]),c=0;c<b.length;++c)-1==F(a,b[c])&&a.push(b[c])}function P(a,b){var c=a._handlers&&a._handlers[b];return c&&0<c.length}function Pa(a){a.prototype.on=function(a,c){t(this,a,c)};a.prototype.off=function(a,c){ia(this,a,c)}}function lc(){this.id=null}function $d(a,b,c){for(var d=0,e=0;;){var f=a.indexOf("\t",d);-1==f&&(f=a.length);var g=f-d;if(f==a.length||e+g>=b)return d+Math.min(g,
b-e);e+=f-d;e+=c-e%c;d=f+1;if(e>=b)return d}}function oe(a){for(;ic.length<=a;)ic.push(x(ic)+" ");return ic[a]}function x(a){return a[a.length-1]}function F(a,b){for(var c=0;c<a.length;++c)if(a[c]==b)return c;return-1}function Wc(a,b){for(var c=[],d=0;d<a.length;d++)c[d]=b(a[d],d);return c}function He(a,b){var c;Object.create?c=Object.create(a):(c=function(){},c.prototype=a,c=new c);b&&Ra(b,c);return c}function Ra(a,b,c){b||(b={});for(var d in a)if(a.hasOwnProperty(d)&&(!1!==c||!b.hasOwnProperty(d)))b[d]=
a[d];return b}function T(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function cc(a,b){return!b?Ie(a):-1<b.source.indexOf("\\w")&&Ie(a)?!0:b.test(a)}function Je(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function eb(a){return 768<=a.charCodeAt(0)&&Ef.test(a)}function q(a,b,c,d){a=document.createElement(a);c&&(a.className=c);d&&(a.style.cssText=d);if("string"==typeof b)a.appendChild(document.createTextNode(b));else if(b)for(c=0;c<
b.length;++c)a.appendChild(b[c]);return a}function sa(a){for(var b=a.childNodes.length;0<b;--b)a.removeChild(a.firstChild);return a}function X(a,b){return sa(a).appendChild(b)}function ja(){return document.activeElement}function ed(a){return RegExp("\\b"+a+"\\b\\s*")}function Xb(a,b){var c=ed(b);c.test(a.className)&&(a.className=a.className.replace(c,""))}function Yb(a,b){ed(b).test(a.className)||(a.className+=" "+b)}function cd(a,b){for(var c=a.split(" "),d=0;d<c.length;d++)c[d]&&!ed(c[d]).test(b)&&
(b+=" "+c[d]);return b}function Ke(a){if(document.body.getElementsByClassName)for(var b=document.body.getElementsByClassName("CodeMirror"),c=0;c<b.length;c++){var d=b[c].CodeMirror;d&&a(d)}}function Qe(){var a;t(window,"resize",function(){null==a&&(a=setTimeout(function(){sb=a=null;Ke(ef)},100))});t(window,"blur",function(){Ke(vb)})}function Za(a){if(null!=sb)return sb;var b=q("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");X(a,b);b.offsetWidth&&(sb=b.offsetHeight-b.clientHeight);
return sb||0}function Bf(a){if(null==fd){var b=q("span","");X(a,q("span",[b,document.createTextNode("x")]));0!=a.firstChild.offsetHeight&&(fd=1>=b.offsetWidth&&2<b.offsetHeight&&!Ta)}return fd?q("span",""):q("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function We(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;f<a.length;++f){var g=a[f];if(g.from<c&&g.to>b||b==c&&g.to==b)d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0}e||d(b,c,"ltr")}function Fc(a){return a.level%
2?a.from:a.to}function Jb(a){return(a=Y(a))?a[0].level%2?a[0].to:a[0].from:0}function Kb(a){var b=Y(a);return!b?a.text.length:Fc(x(b))}function Le(a,b){var c=r(a.doc,b),d=Z(c);d!=c&&(b=A(d));c=Y(d);d=!c?0:c[0].level%2?Kb(d):Jb(d);return p(b,d)}function Gc(a,b){hb=null;for(var c=0,d;c<a.length;++c){var e=a[c];if(e.from<b&&e.to>b)return c;if(e.from==b||e.to==b)if(null==d)d=c;else{var f;f=e.level;var g=a[d].level,h=a[0].level;f=f==h?!0:g==h?!1:f<g;if(f)return e.from!=e.to&&(hb=d),c;e.from!=e.to&&(hb=
c);break}}return d}function gd(a,b,c,d){if(!d)return b+c;do b+=c;while(0<b&&eb(a.text.charAt(b)));return b}function Ic(a,b,c,d){var e=Y(a);if(!e)return pe(a,b,c,d);for(var f=Gc(e,b),g=e[f],b=gd(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(Gc(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?gd(a,g.to,-1,d):gd(a,g.from,1,d)}}function pe(a,b,c,d){b+=c;if(d)for(;0<b&&eb(a.text.charAt(b));)b+=c;return 0>b||b>a.text.length?
null:b}var mb=/gecko\/\d/i.test(navigator.userAgent),aa=/MSIE \d/.test(navigator.userAgent),Ta=aa&&(null==document.documentMode||8>document.documentMode),H=aa&&(null==document.documentMode||9>document.documentMode),kf=aa&&(null==document.documentMode||10>document.documentMode),Ff=/Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent),I=aa||Ff,J=/WebKit\//.test(navigator.userAgent),Gf=J&&/Qt\/\d+\.\d+/.test(navigator.userAgent),Hf=/Chrome\//.test(navigator.userAgent),R=/Opera\//.test(navigator.userAgent),
Yd=/Apple Computer/.test(navigator.vendor),oc=/KHTML\//.test(navigator.userAgent),Re=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),bf=/PhantomJS/.test(navigator.userAgent),Sa=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),kc=Sa||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),ea=Sa||/Mac/.test(navigator.platform),If=/win/i.test(navigator.platform),Ca=R&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Ca&&(Ca=Number(Ca[1]));
Ca&&15<=Ca&&(R=!1,J=!0);var Me=ea&&(Gf||R&&(null==Ca||12.11>Ca)),Oc=mb||I&&!H,he=!1,la=!1,p=m.Pos=function(a,b){if(!(this instanceof p))return new p(a,b);this.line=a;this.ch=b},v=m.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch};ga.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return true;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return false;for(var b=0;b<this.ranges.length;b++){var c=this.ranges[b],d=a.ranges[b];if(v(c.anchor,
d.anchor)!=0||v(c.head,d.head)!=0)return false}return true},deepCopy:function(){for(var a=[],b=0;b<this.ranges.length;b++)a[b]=new z(p(this.ranges[b].anchor.line,this.ranges[b].anchor.ch),p(this.ranges[b].head.line,this.ranges[b].head.ch));return new ga(a,this.primIndex)},somethingSelected:function(){for(var a=0;a<this.ranges.length;a++)if(!this.ranges[a].empty())return true;return false},contains:function(a,b){b||(b=a);for(var c=0;c<this.ranges.length;c++){var d=this.ranges[c];if(v(b,d.from())>=
0&&v(a,d.to())<=0)return c}return-1}};z.prototype={from:function(){return Bc(this.anchor,this.head)},to:function(){return Ac(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Dc={left:0,right:0,top:0,bottom:0},wa,af=0,Rb,Qb,Xd=0,Tb=0,S=null;I?S=-0.53:mb?S=15:Hf?S=-0.7:Yd&&(S=-1/3);var de,Sc=null,xa=m.changeEnd=function(a){return!a.text?a.to:p(a.from.line+a.text.length-1,x(a.text).length+(a.text.length==1?a.from.ch:0))};m.prototype=
{constructor:m,focus:function(){window.focus();M(this);jb(this)},setOption:function(a,b){var c=this.options,d=c[a];if(!(c[a]==b&&a!="mode")){c[a]=b;Fa.hasOwnProperty(a)&&B(this,Fa[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(b[c]==a||typeof b[c]!="string"&&b[c].name==a){b.splice(c,1);return true}},addOverlay:y(function(a,
b){var c=a.token?a:m.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++;O(this)}),removeOverlay:y(function(a){for(var b=this.state.overlays,c=0;c<b.length;++c){var d=b[c].modeSpec;if(d==a||typeof a=="string"&&d.name==a){b.splice(c,1);this.state.modeGen++;O(this);break}}}),indentLine:y(function(a,b,c){typeof b!="string"&&typeof b!="number"&&(b=b==null?this.options.smartIndent?"smart":
"prev":b?"add":"subtract");ab(this.doc,a)&&kb(this,a,b,c)}),indentSelection:y(function(a){for(var b=this.doc.sel.ranges,c=-1,d=0;d<b.length;d++){var e=b[d];if(e.empty()){if(e.head.line>c){kb(this,e.head.line,a,true);c=e.head.line;d==this.doc.sel.primIndex&&Ha(this)}}else for(var f=Math.max(c,e.from().line),c=e.to(),c=Math.min(this.lastLine(),c.line-(c.ch?0:1))+1;f<c;++f)kb(this,f,a)}}),getTokenAt:function(a,b){for(var c=this.doc,a=s(c,a),d=db(this,a.line,b),e=this.doc.mode,c=r(c,a.line),c=new gc(c.text,
this.options.tabSize);c.pos<a.ch&&!c.eol();){c.start=c.pos;var f=ad(e,c,d)}return{start:c.start,end:c.pos,string:c.current(),type:f||null,state:d}},getTokenTypeAt:function(a){var a=s(this.doc,a),b=Be(this,r(this.doc,a.line)),c=0,d=(b.length-1)/2,a=a.ch,e;if(a==0)e=b[2];else for(;;){var f=c+d>>1;if((f?b[f*2-1]:0)>=a)d=f;else if(b[f*2+1]<a)c=f+1;else{e=b[f*2+2];break}}b=e?e.indexOf("cm-overlay "):-1;return b<0?e:b==0?null:e.slice(0,b-1)},getModeAt:function(a){var b=this.doc.mode;return!b.innerMode?
b:m.innerMode(b,this.getTokenAt(a).state).mode},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!Da.hasOwnProperty(b))return Da;var d=Da[b],e=this.getModeAt(a);if(typeof e[b]=="string")d[e[b]]&&c.push(d[e[b]]);else if(e[b])for(var f=0;f<e[b].length;f++){var g=d[e[b][f]];g&&c.push(g)}else e.helperType&&d[e.helperType]?c.push(d[e.helperType]):d[e.name]&&c.push(d[e.name]);for(f=0;f<d._global.length;f++){g=d._global[f];g.pred(e,this)&&F(c,g.val)==-1&&c.push(g.val)}return c},
getStateAfter:function(a,b){var c=this.doc,a=Math.max(c.first,Math.min(a==null?c.first+c.size-1:a,c.first+c.size-1));return db(this,a+1,b)},cursorCoords:function(a,b){var c;c=this.doc.sel.primary();c=a==null?c.head:typeof a=="object"?s(this.doc,a):a?c.from():c.to();return ha(this,c,b||"page")},charCoords:function(a,b){return Gb(this,s(this.doc,a),b||"page")},coordsChar:function(a,b){a=Pd(this,a,b||"page");return Hc(this,a.left,a.top)},lineAtHeight:function(a,b){a=Pd(this,{top:a,left:0},b||"page").top;
return ua(this.doc,a+this.display.viewOffset)},heightAtLine:function(a,b){var c=false,d=this.doc.first+this.doc.size-1;if(a<this.doc.first)a=this.doc.first;else if(a>d){a=d;c=true}d=r(this.doc,a);return Ec(this,d,{top:0,left:0},b||"page").top+(c?this.doc.height-fa(d):0)},defaultTextHeight:function(){return qa(this.display)},defaultCharWidth:function(){return Wa(this.display)},setGutterMarker:y(function(a,b,c){return ac(this,a,"gutter",function(a){var e=a.gutterMarkers||(a.gutterMarkers={});e[b]=c;
if(!c&&Je(e))a.gutterMarkers=null;return true})}),clearGutter:y(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){if(c.gutterMarkers&&c.gutterMarkers[a]){c.gutterMarkers[a]=null;na(b,d,"gutter");if(Je(c.gutterMarkers))c.gutterMarkers=null}++d})}),addLineClass:y(function(a,b,c){return ac(this,a,"class",function(a){var e=b=="text"?"textClass":b=="background"?"bgClass":"wrapClass";if(a[e]){if(RegExp("(?:^|\\s)"+c+"(?:$|\\s)").test(a[e]))return false;a[e]=a[e]+(" "+c)}else a[e]=c;return true})}),
removeLineClass:y(function(a,b,c){return ac(this,a,"class",function(a){var e=b=="text"?"textClass":b=="background"?"bgClass":"wrapClass",f=a[e];if(f)if(c==null)a[e]=null;else{var g=f.match(RegExp("(?:^|\\s+)"+c+"(?:$|\\s+)"));if(!g)return false;var h=g.index+g[0].length;a[e]=f.slice(0,g.index)+(!g.index||h==f.length?"":" ")+f.slice(h)||null}else return false;return true})}),addLineWidget:y(function(a,b,c){return vf(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if(typeof a==
"number"){if(!ab(this.doc,a))return null;var b=a,a=r(this.doc,a);if(!a)return null}else{b=A(a);if(b==null)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.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display,a=ha(this,s(this.doc,a)),g=a.bottom,h=a.left;b.style.position="absolute";f.sizer.appendChild(b);if(d=="over")g=
a.top;else if(d=="above"||d=="near"){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);if((d=="above"||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight)g=a.top-b.offsetHeight;else if(a.bottom+b.offsetHeight<=i)g=a.bottom;h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px";b.style.left=b.style.right="";if(e=="right"){h=f.sizer.clientWidth-b.offsetWidth;b.style.right="0px"}else{e=="left"?h=0:e=="middle"&&(h=(f.sizer.clientWidth-b.offsetWidth)/
2);b.style.left=h+"px"}if(c){a=Mb(this,h,g,h+b.offsetWidth,g+b.offsetHeight);a.scrollTop!=null&&ib(this,a.scrollTop);a.scrollLeft!=null&&Ga(this,a.scrollLeft)}},triggerOnKeyDown:y(Vd),triggerOnKeyPress:y(Wd),triggerOnKeyUp:y(Ud),execCommand:function(a){if(Vb.hasOwnProperty(a))return Vb[a](this)},findPosH:function(a,b,c,d){var e=1;if(b<0){e=-1;b=-b}for(var f=0,a=s(this.doc,a);f<b;++f){a=Zc(this.doc,a,e,c,d);if(a.hitSide)break}return a},moveH:y(function(a,b){var c=this;c.extendSelectionsBy(function(d){return c.display.shift||
c.doc.extend||d.empty()?Zc(c.doc,d.head,a,b,c.options.rtlMoveVisually):a<0?d.from():d.to()},Ea)}),deleteH:y(function(a,b){var c=this.doc;this.doc.sel.somethingSelected()?c.replaceSelection("",null,"+delete"):bc(this,function(d){var e=Zc(c,d.head,a,b,false);return a<0?{from:e,to:d.head}:{from:d.head,to:e}})}),findPosV:function(a,b,c,d){var e=1;if(b<0){e=-1;b=-b}for(var f=0,a=s(this.doc,a);f<b;++f){a=ha(this,a,"div");d==null?d=a.left:a.left=d;a=qe(this,a,e,c);if(a.hitSide)break}return a},moveV:y(function(a,
b){var c=this,d=this.doc,e=[],f=!c.display.shift&&!d.extend&&d.sel.somethingSelected();d.extendSelectionsBy(function(g){if(f)return a<0?g.from():g.to();var i=ha(c,g.head,"div");if(g.goalColumn!=null)i.left=g.goalColumn;e.push(i.left);var j=qe(c,i,a,b);b=="page"&&g==d.sel.primary()&&Yc(c,null,Gb(c,j,"div").top-i.top);return j},Ea);if(e.length)for(var g=0;g<d.sel.ranges.length;g++)d.sel.ranges[g].goalColumn=e[g]}),toggleOverwrite:function(a){if(!(a!=null&&a==this.state.overwrite)){(this.state.overwrite=
!this.state.overwrite)?Yb(this.display.cursorDiv,"CodeMirror-overwrite"):Xb(this.display.cursorDiv,"CodeMirror-overwrite");E(this,"overwriteToggle",this,this.state.overwrite)}},hasFocus:function(){return ja()==this.display.input},scrollTo:y(function(a,b){(a!=null||b!=null)&&$b(this);if(a!=null)this.curOp.scrollLeft=a;if(b!=null)this.curOp.scrollTop=b}),getScrollInfo:function(){var a=this.display.scroller,b=ca;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-b,width:a.scrollWidth-b,clientHeight:a.clientHeight-
b,clientWidth:a.clientWidth-b}},scrollIntoView:y(function(a,b){if(a==null){a={from:this.doc.sel.primary().head,to:null};if(b==null)b=this.options.cursorScrollMargin}else typeof a=="number"?a={from:p(a,0),to:null}:a.from==null&&(a={from:a,to:null});if(!a.to)a.to=a.from;a.margin=b||0;if(a.from.line!=null){$b(this);this.curOp.scrollToPos=a}else{var c=Mb(this,Math.min(a.from.left,a.to.left),Math.min(a.from.top,a.to.top)-a.margin,Math.max(a.from.right,a.to.right),Math.max(a.from.bottom,a.to.bottom)+a.margin);
this.scrollTo(c.scrollLeft,c.scrollTop)}}),setSize:y(function(a,b){function c(a){return typeof a=="number"||/^\d+$/.test(""+a)?a+"px":a}if(a!=null)this.display.wrapper.style.width=c(a);if(b!=null)this.display.wrapper.style.height=c(b);this.options.lineWrapping&&Od(this);this.curOp.forceUpdate=true;E(this,"refresh",this)}),operation:function(a){return ba(this,a)},refresh:y(function(){var a=this.display.cachedTextHeight;O(this);this.curOp.forceUpdate=true;Xa(this);this.scrollTo(this.doc.scrollLeft,
this.doc.scrollTop);sc(this);(a==null||Math.abs(a-qa(this.display))>0.5)&&qc(this);E(this,"refresh",this)}),swapDoc:y(function(a){var b=this.doc;b.cm=null;ld(this,a);Xa(this);U(this);this.scrollTo(a.scrollLeft,a.scrollTop);D(this,"swapDoc",this,b);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}};Pa(m);var Ne=m.defaults=
{},Fa=m.optionHandlers={},md=m.Init={toString:function(){return"CodeMirror.Init"}};u("value","",function(a,b){a.setValue(b)},!0);u("mode",null,function(a,b){a.doc.modeOption=b;pc(a)},!0);u("indentUnit",2,pc,!0);u("indentWithTabs",!1);u("smartIndent",!0);u("tabSize",4,function(a){Ua(a);Xa(a);O(a)},!0);u("specialChars",/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g,function(a,b){a.options.specialChars=RegExp(b.source+(b.test("\t")?"":"|\t"),"g");a.refresh()},!0);u("specialCharPlaceholder",function(a){var b=
q("span","•","cm-invalidchar");b.title="\\u"+a.charCodeAt(0).toString(16);return b},function(a){a.refresh()},!0);u("electricChars",!0);u("rtlMoveVisually",!If);u("wholeLineUpdateBefore",!0);u("theme","default",function(a){jd(a);Ya(a)},!0);u("keyMap","default",od);u("extraKeys",null);u("lineWrapping",!1,function(a){if(a.options.lineWrapping){Yb(a.display.wrapper,"CodeMirror-wrap");a.display.sizer.style.minWidth=""}else{Xb(a.display.wrapper,"CodeMirror-wrap");tc(a)}qc(a);O(a);Xa(a);setTimeout(function(){xb(a)},
100)},!0);u("gutters",[],function(a){jc(a.options);Ya(a)},!0);u("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?vc(a.display)+"px":"0";a.refresh()},!0);u("coverGutterNextToScrollbar",!1,xb,!0);u("lineNumbers",!1,function(a){jc(a.options);Ya(a)},!0);u("firstLineNumber",1,Ya,!0);u("lineNumberFormatter",function(a){return a},Ya,!0);u("showCursorWhenSelecting",!1,yc,!0);u("resetSelectionOnContextMenu",!0);u("readOnly",!1,function(a,b){if(b=="nocursor"){vb(a);a.display.input.blur();a.display.disabled=
true}else{a.display.disabled=false;b||U(a)}});u("disableInput",!1,function(a,b){b||U(a)},!0);u("dragDrop",!0);u("cursorBlinkRate",530);u("cursorScrollMargin",0);u("cursorHeight",1);u("workTime",100);u("workDelay",100);u("flattenSpans",!0,Ua,!0);u("addModeClass",!1,Ua,!0);u("pollInterval",100);u("undoDepth",200,function(a,b){a.doc.history.undoDepth=b});u("historyEventDelay",1250);u("viewportMargin",10,function(a){a.refresh()},!0);u("maxHighlightLength",1E4,Ua,!0);u("moveInputWithCursor",!0,function(a,
b){if(!b)a.display.inputDiv.style.top=a.display.inputDiv.style.left=0});u("tabindex",null,function(a,b){a.display.input.tabIndex=b||""});u("autofocus",null);var hd=m.modes={},Qa=m.mimeModes={},hd=m.modes={},Qa=m.mimeModes={};m.defineMode=function(a,b){if(!m.defaults.mode&&a!="null")m.defaults.mode=a;if(arguments.length>2){b.dependencies=[];for(var c=2;c<arguments.length;++c)b.dependencies.push(arguments[c])}hd[a]=b};m.defineMIME=function(a,b){Qa[a]=b};m.resolveMode=function(a){if(typeof a=="string"&&
Qa.hasOwnProperty(a))a=Qa[a];else if(a&&typeof a.name=="string"&&Qa.hasOwnProperty(a.name)){var b=Qa[a.name];typeof b=="string"&&(b={name:b});a=He(b,a);a.name=b.name}else if(typeof a=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return m.resolveMode("application/xml");return typeof a=="string"?{name:a}:a||{name:"null"}};m.getMode=function(a,b){var b=m.resolveMode(b),c=hd[b.name];if(!c)return m.getMode(a,"text/plain");c=c(a,b);if(tb.hasOwnProperty(b.name)){var d=tb[b.name],e;for(e in d)if(d.hasOwnProperty(e)){c.hasOwnProperty(e)&&
(c["_"+e]=c[e]);c[e]=d[e]}}c.name=b.name;if(b.helperType)c.helperType=b.helperType;if(b.modeProps)for(e in b.modeProps)c[e]=b.modeProps[e];return c};m.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}});m.defineMIME("text/plain","null");var tb=m.modeExtensions={};m.extendMode=function(a,b){var c=tb.hasOwnProperty(a)?tb[a]:tb[a]={};Ra(b,c)};m.defineExtension=function(a,b){m.prototype[a]=b};m.defineDocExtension=function(a,b){L.prototype[a]=b};m.defineOption=u;var nc=[];m.defineInitHook=
function(a){nc.push(a)};var Da=m.helpers={};m.registerHelper=function(a,b,c){Da.hasOwnProperty(a)||(Da[a]=m[a]={_global:[]});Da[a][b]=c};m.registerGlobalHelper=function(a,b,c,d){m.registerHelper(a,b,d);Da[a]._global.push({pred:c,val:d})};var cb=m.copyState=function(a,b){if(b===true)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},Ze=m.startState=function(a,b,c){return a.startState?a.startState(b,c):true};m.innerMode=
function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state;a=c.mode}return c||{mode:a,state:b}};var Vb=m.commands={selectAll:function(a){a.setSelection(p(a.firstLine(),0),p(a.lastLine()),va)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),va)},killLine:function(a){bc(a,function(b){if(b.empty()){var c=r(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line<a.lastLine()?{from:b.head,to:p(b.head.line+1,0)}:{from:b.head,to:p(b.head.line,
c)}}return{from:b.from(),to:b.to()}})},deleteLine:function(a){bc(a,function(b){return{from:p(b.from().line,0),to:s(a.doc,p(b.to().line+1,0))}})},delLineLeft:function(a){bc(a,function(a){return{from:p(a.from().line,0),to:a.from()}})},undo:function(a){a.undo()},redo:function(a){a.redo()},undoSelection:function(a){a.undoSelection()},redoSelection:function(a){a.redoSelection()},goDocStart:function(a){a.extendSelection(p(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(p(a.lastLine()))},goLineStart:function(a){a.extendSelectionsBy(function(b){return Le(a,
b.head.line)},Ea)},goLineStartSmart:function(a){a.extendSelectionsBy(function(b){var c=Le(a,b.head.line),d=a.getLineHandle(c.line),e=Y(d);if(!e||e[0].level==0){d=Math.max(0,d.text.search(/\S/));return p(c.line,b.head.line==c.line&&b.head.ch<=d&&b.head.ch?0:d)}return c},Ea)},goLineEnd:function(a){a.extendSelectionsBy(function(b){for(var b=b.head.line,c,d=r(a.doc,b);c=ta(d,false);){d=c.find(1,true).line;b=null}c=Y(d);c=!c?d.text.length:c[0].level%2?Jb(d):Kb(d);return p(b==null?A(d):b,c)},Ea)},goLineRight:function(a){a.extendSelectionsBy(function(b){b=
a.charCoords(b.head,"div").top+5;return a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:b},"div")},Ea)},goLineLeft:function(a){a.extendSelectionsBy(function(b){b=a.charCoords(b.head,"div").top+5;return a.coordsChar({left:0,top:b},"div")},Ea)},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")},insertSoftTab:function(a){for(var b=[],c=a.listSelections(),d=a.options.tabSize,e=0;e<c.length;e++){var f=c[e].from(),f=Q(a.getLine(f.line),f.ch,d);b.push(Array(d-f%d+1).join(" "))}a.replaceSelections(b)},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):
a.execCommand("insertTab")},transposeChars:function(a){ba(a,function(){for(var b=a.listSelections(),c=[],d=0;d<b.length;d++){var e=b[d].head,f=r(a.doc,e.line).text;if(f){e.ch==f.length&&(e=new p(e.line,e.ch-1));if(e.ch>0){e=new p(e.line,e.ch+1);a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),p(e.line,e.ch-2),e,"+transpose")}else if(e.line>a.doc.first){var g=r(a.doc,e.line-1).text;g&&a.replaceRange(f.charAt(0)+"\n"+g.charAt(g.length-1),p(e.line-1,g.length-1),p(e.line,1),"+transpose")}}c.push(new z(e,
e))}a.setSelections(c)})},newlineAndIndent:function(a){ba(a,function(){for(var b=a.listSelections().length,c=0;c<b;c++){var d=a.listSelections()[c];a.replaceRange("\n",d.anchor,d.head,"+input");a.indentLine(d.from().line+1,null,true);Ha(a)}})},toggleOverwrite:function(a){a.toggleOverwrite()}},da=m.keyMap={};da.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore",
"Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};da.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-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","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};da.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","Cmd-Backspace":"delLineLeft","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection",fallthrough:["basic","emacsy"]};da.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"};da["default"]=ea?da.macDefault:da.pcDefault;var Wb=m.lookupKey=function(a,b,c){function d(b){var b=Rc(b),e=b[a];if(e===false)return"stop";if(e!=null&&c(e))return true;if(b.nofallthrough)return"stop";b=b.fallthrough;
if(b==null)return false;if(Object.prototype.toString.call(b)!="[object Array]")return d(b);for(e=0;e<b.length;++e){var f=d(b[e]);if(f)return f}return false}for(var e=0;e<b.length;++e){var f=d(b[e]);if(f)return f!="stop"}},lf=m.isModifierKey=function(a){a=pa[a.keyCode];return a=="Ctrl"||a=="Alt"||a=="Shift"||a=="Mod"},mf=m.keyName=function(a,b){if(R&&a.keyCode==34&&a["char"])return false;var c=pa[a.keyCode];if(c==null||a.altGraphKey)return false;a.altKey&&(c="Alt-"+c);if(Me?a.metaKey:a.ctrlKey)c="Ctrl-"+
c;if(Me?a.ctrlKey:a.metaKey)c="Cmd-"+c;!b&&a.shiftKey&&(c="Shift-"+c);return c};m.fromTextArea=function(a,b){function c(){a.value=i.getValue()}b||(b={});b.value=a.value;if(!b.tabindex&&a.tabindex)b.tabindex=a.tabindex;if(!b.placeholder&&a.placeholder)b.placeholder=a.placeholder;if(b.autofocus==null){var d=ja();b.autofocus=d==a||a.getAttribute("autofocus")!=null&&d==document.body}if(a.form){t(a.form,"submit",c);if(!b.leaveSubmitMethodAlone){var e=a.form,f=e.submit;try{var g=e.submit=function(){c();
e.submit=f;e.submit();e.submit=g}}catch(h){}}}a.style.display="none";var i=m(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);i.save=c;i.getTextArea=function(){return a};i.toTextArea=function(){c();a.parentNode.removeChild(i.getWrapperElement());a.style.display="";if(a.form){ia(a.form,"submit",c);if(typeof a.form.submit=="function")a.form.submit=f}};return i};var gc=m.StringStream=function(a,b){this.pos=this.start=0;this.string=a;this.tabSize=b||8;this.lineStart=this.lastColumnPos=this.lastColumnValue=
0};gc.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},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(typeof a=="string"?b==a:b&&(a.test?a.test(b):a(b))){++this.pos;return 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(a>-1){this.pos=a;return true}},backUp:function(a){this.pos=this.pos-a},column:function(){if(this.lastColumnPos<this.start){this.lastColumnValue=Q(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue);this.lastColumnPos=this.start}return this.lastColumnValue-(this.lineStart?Q(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Q(this.string,
null,this.tabSize)-(this.lineStart?Q(this.string,this.lineStart,this.tabSize):0)},match:function(a,b,c){if(typeof a=="string"){var d=this.string.substr(this.pos,a.length);if((c?d.toLowerCase():d)==(c?a.toLowerCase():a)){if(b!==false)this.pos=this.pos+a.length;return true}}else{if((a=this.string.slice(this.pos).match(a))&&a.index>0)return null;if(a&&b!==false)this.pos=this.pos+a[0].length;return a}},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(a,b){this.lineStart=
this.lineStart+a;try{return b()}finally{this.lineStart=this.lineStart-a}}};var Aa=m.TextMarker=function(a,b){this.lines=[];this.type=b;this.doc=a};Pa(Aa);Aa.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&Ia(a);if(P(this,"clear")){var c=this.find();c&&D(this,"clear",c.from,c.to)}for(var d=c=null,e=0;e<this.lines.length;++e){var f=this.lines[e],g=pb(f.markedSpans,this);if(a&&!this.collapsed)na(a,A(f),"text");else if(a){g.to!=null&&(d=A(f));g.from!=null&&(c=
A(f))}for(var h=f,i=f.markedSpans,j=g,k=void 0,n=0;n<i.length;++n)i[n]!=j&&(k||(k=[])).push(i[n]);h.markedSpans=k;g.from==null&&(this.collapsed&&!ra(this.doc,f)&&a)&&V(f,qa(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(e=0;e<this.lines.length;++e){f=Z(this.lines[e]);g=wb(f);if(g>a.display.maxLineLength){a.display.maxLine=f;a.display.maxLineLength=g;a.display.maxLineChanged=true}}c!=null&&(a&&this.collapsed)&&O(a,c,d+1);this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&
this.doc.cantEdit){this.doc.cantEdit=false;a&&Id(a.doc)}a&&D(a,"markerCleared",a,this);b&&Ja(a);this.parent&&this.parent.clear()}};Aa.prototype.find=function(a,b){a==null&&this.type=="bookmark"&&(a=1);for(var c,d,e=0;e<this.lines.length;++e){var f=this.lines[e],g=pb(f.markedSpans,this);if(g.from!=null){c=p(b?f:A(f),g.from);if(a==-1)return c}if(g.to!=null){d=p(b?f:A(f),g.to);if(a==1)return d}}return c&&{from:c,to:d}};Aa.prototype.changed=function(){var a=this.find(-1,true),b=this,c=this.doc.cm;a&&
c&&ba(c,function(){var d=a.line,e=A(a.line);if(e=Ld(c,e)){Nd(e);c.curOp.selectionChanged=c.curOp.forceUpdate=true}c.curOp.updateMaxLine=true;if(!ra(b.doc,d)&&b.height!=null){e=b.height;b.height=null;(e=gb(b)-e)&&V(d,d.height+e)}})};Aa.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;if(!b.maybeHiddenMarkers||F(b.maybeHiddenMarkers,this)==-1)(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)};Aa.prototype.detachLine=function(a){this.lines.splice(F(this.lines,
a),1);if(!this.lines.length&&this.doc.cm){a=this.doc.cm.curOp;(a.maybeHiddenMarkers||(a.maybeHiddenMarkers=[])).push(this)}};var sf=0,ec=m.SharedTextMarker=function(a,b){this.markers=a;this.primary=b;for(var c=0;c<a.length;++c)a[c].parent=this};Pa(ec);ec.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=true;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();D(this,"clear")}};ec.prototype.find=function(a,b){return this.primary.find(a,b)};var fc=m.LineWidget=
function(a,b,c){if(c)for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.cm=a;this.node=b};Pa(fc);fc.prototype.clear=function(){var a=this.cm,b=this.line.widgets,c=this.line,d=A(c);if(d!=null&&b){for(var e=0;e<b.length;++e)b[e]==this&&b.splice(e--,1);if(!b.length)c.widgets=null;var f=gb(this);ba(a,function(){xe(a,c,-f);na(a,d,"widget");V(c,Math.max(0,c.height-f))})}};fc.prototype.changed=function(){var a=this.height,b=this.cm,c=this.line;this.height=null;var d=gb(this)-a;d&&ba(b,function(){b.curOp.forceUpdate=
true;xe(b,c,d);V(c,c.height+d)})};var Ba=m.Line=function(a,b,c){this.text=a;ve(this,b);this.height=c?c(this):1};Pa(Ba);Ba.prototype.lineNo=function(){return A(this)};var xf={},wf={};qb.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=this.height-e.height;var f=e;f.parent=null;ue(f);D(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height=
this.height+c;this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(a=0;a<b.length;++a)b[a].parent=this},iterN:function(a,b,c){for(b=a+b;a<b;++a)if(c(this.lines[a]))return true}};rb.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size=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=this.height-(g-d.height);if(e==f){this.children.splice(c--,
1);d.parent=null}if((b=b-f)==0)break;a=0}else a=a-e}if(this.size-b<25&&(this.children.length>1||!(this.children[0]instanceof qb))){c=[];this.collapse(c);this.children=[new qb(c)];this.children[0].parent=this}},collapse:function(a){for(var b=0;b<this.children.length;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size=this.size+b.length;this.height=this.height+c;for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(a<=f){e.insertInner(a,b,c);if(e.lines&&
e.lines.length>50){for(;e.lines.length>50;){a=e.lines.splice(e.lines.length-25,25);a=new qb(a);e.height=e.height-a.height;this.children.splice(d+1,0,a);a.parent=this}this.maybeSpill()}break}a=a-f}},maybeSpill:function(){if(!(this.children.length<=10)){var a=this;do{var b=a.children.splice(a.children.length-5,5),b=new rb(b);if(a.parent){a.size=a.size-b.size;a.height=a.height-b.height;var c=F(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else{c=new rb(a.children);c.parent=a;a.children=[c,b];
a=c}b.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(a<f){f=Math.min(b,f-a);if(e.iterN(a,f,c))return true;if((b=b-f)==0)break;a=0}else a=a-f}}};var Jf=0,L=m.Doc=function(a,b,c){if(!(this instanceof L))return new L(a,b,c);c==null&&(c=0);rb.call(this,[new qb([new Ba("",null)])]);this.first=c;this.scrollTop=this.scrollLeft=0;this.cantEdit=false;this.cleanGeneration=1;this.frontier=
c;c=p(c,0);this.sel=ma(c);this.history=new hc(null);this.id=++Jf;this.modeOption=b;typeof a=="string"&&(a=Ka(a));Xc(this,{from:c,to:c,text:a});G(this,ma(c),va)};L.prototype=He(rb.prototype,{constructor:L,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;d<b.length;++d)c=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=dd(this,this.first,
this.first+this.size);return a===false?b:b.join(a||"\n")},setValue:N(function(a){var b=p(this.first,0),c=this.first+this.size-1;La(this,{from:b,to:p(c,r(this,c).text.length),text:Ka(a),origin:"setValue"},true);G(this,ma(b))}),replaceRange:function(a,b,c,d){b=s(this,b);c=c?s(this,c):b;Sb(this,a,b,c,d)},getRange:function(a,b,c){a=ob(this,s(this,a),s(this,b));return c===false?a:a.join(c||"\n")},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},getLineHandle:function(a){if(ab(this,a))return r(this,
a)},getLineNumber:function(a){return A(a)},getLineHandleVisualStart:function(a){typeof a=="number"&&(a=r(this,a));return Z(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(a){return s(this,a)},getCursor:function(a){var b=this.sel.primary();return a==null||a=="head"?b.head:a=="anchor"?b.anchor:a=="end"||a=="to"||a===false?b.to():b.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},
setCursor:N(function(a,b,c){a=s(this,typeof a=="number"?p(a,b||0):a);G(this,ma(a,null),c)}),setSelection:N(function(a,b,c){var d=s(this,a),a=s(this,b||a);G(this,ma(d,a),c)}),extendSelection:N(function(a,b,c){Cb(this,s(this,a),b&&s(this,b),c)}),extendSelections:N(function(a){for(var b=[],c=0;c<a.length;c++)b[c]=s(this,a[c]);Bd(this,b)}),extendSelectionsBy:N(function(a,b){Bd(this,Wc(this.sel.ranges,a),b)}),setSelections:N(function(a,b,c){if(a.length){for(var d=0,e=[];d<a.length;d++)e[d]=new z(s(this,
a[d].anchor),s(this,a[d].head));b==null&&(b=Math.min(a.length-1,this.sel.primIndex));G(this,W(e,b),c)}}),addSelection:N(function(a,b,c){var d=this.sel.ranges.slice(0);d.push(new z(s(this,a),s(this,b||a)));G(this,W(d,d.length-1),c)}),getSelection:function(a){for(var b=this.sel.ranges,c,d=0;d<b.length;d++){var e=ob(this,b[d].from(),b[d].to());c=c?c.concat(e):e}return a===false?c:c.join(a||"\n")},getSelections:function(a){for(var b=[],c=this.sel.ranges,d=0;d<c.length;d++){var e=ob(this,c[d].from(),c[d].to());
a!==false&&(e=e.join(a||"\n"));b[d]=e}return b},replaceSelection:function(a,b,c){for(var d=[],e=0;e<this.sel.ranges.length;e++)d[e]=a;this.replaceSelections(d,b,c||"+input")},replaceSelections:N(function(a,b,c){for(var d=[],e=this.sel,f=0;f<e.ranges.length;f++){var g=e.ranges[f];d[f]={from:g.from(),to:g.to(),text:Ka(a[f]),origin:c}}if(f=b)if(f=b!="end"){f=[];c=a=p(this.first,0);for(e=0;e<d.length;e++){var h=d[e],g=fe(h.from,a,c),i=fe(xa(h),a,c),a=h.to,c=i;if(b=="around"){h=this.sel.ranges[e];h=v(h.head,
h.anchor)<0;f[e]=new z(h?i:g,h?g:i)}else f[e]=new z(g,g)}f=new ga(f,this.sel.primIndex)}b=f;for(f=d.length-1;f>=0;f--)La(this,d[f]);b?Dd(this,b):this.cm&&Ha(this.cm)}),undo:N(function(){Zb(this,"undo")}),redo:N(function(){Zb(this,"redo")}),undoSelection:N(function(){Zb(this,"undo",true)}),redoSelection:N(function(){Zb(this,"redo",true)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d<a.done.length;d++)a.done[d].ranges||
++b;for(d=0;d<a.undone.length;d++)a.undone[d].ranges||++c;return{undo:b,redo:c}},clearHistory:function(){this.history=new hc(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(true)},changeGeneration:function(a){if(a)this.history.lastOp=this.history.lastOrigin=null;return this.history.generation},isClean:function(a){return this.history.generation==(a||this.cleanGeneration)},getHistory:function(){return{done:Oa(this.history.done),undone:Oa(this.history.undone)}},
setHistory:function(a){var b=this.history=new hc(this.history.maxGeneration);b.done=Oa(a.done.slice(0),null,true);b.undone=Oa(a.undone.slice(0),null,true)},markText:function(a,b,c){return Na(this,s(this,a),s(this,b),c,"range")},setBookmark:function(a,b){var c={replacedWith:b&&(b.nodeType==null?b.widget:b),insertLeft:b&&b.insertLeft,clearWhenEmpty:false,shared:b&&b.shared},a=s(this,a);return Na(this,a,a,c,"bookmark")},findMarksAt:function(a){var a=s(this,a),b=[],c=r(this,a.line).markedSpans;if(c)for(var d=
0;d<c.length;++d){var e=c[d];if((e.from==null||e.from<=a.ch)&&(e.to==null||e.to>=a.ch))b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){var a=s(this,a),b=s(this,b),d=[],e=a.line;this.iter(a.line,b.line+1,function(f){if(f=f.markedSpans)for(var g=0;g<f.length;g++){var h=f[g];if(!(e==a.line&&a.ch>h.to||h.from==null&&e!=a.line||e==b.line&&h.from>b.ch)&&(!c||c(h.marker)))d.push(h.marker.parent||h.marker)}++e});return d},getAllMarks:function(){var a=[];this.iter(function(b){if(b=b.markedSpans)for(var c=
0;c<b.length;++c)b[c].from!=null&&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){b=a;return true}a=a-d;++c});return s(this,p(c,b))},indexFromPos:function(a){var a=s(this,a),b=a.ch;if(a.line<this.first||a.ch<0)return 0;this.iter(this.first,a.line,function(a){b=b+(a.text.length+1)});return b},copy:function(a){var b=new L(dd(this,this.first,this.first+this.size),this.modeOption,this.first);b.scrollTop=this.scrollTop;b.scrollLeft=
this.scrollLeft;b.sel=this.sel;b.extend=false;if(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;if(a.from!=null&&a.from>b)b=a.from;if(a.to!=null&&a.to<c)c=a.to;b=new L(dd(this,b,c),a.mode||this.modeOption,b);if(a.sharedHist)b.history=this.history;(this.linked||(this.linked=[])).push({doc:b,sharedHist:a.sharedHist});b.linked=[{doc:this,isParent:true,sharedHist:a.sharedHist}];a=se(this);
for(c=0;c<a.length;c++){var d=a[c],e=d.find(),f=b.clipPos(e.from),e=b.clipPos(e.to);if(v(f,e)){f=Na(b,f,e,d.primary,d.primary.type);d.markers.push(f);f.parent=d}}return b},unlinkDoc:function(a){if(a instanceof m)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);tf(se(this));break}if(a.history==this.history){var c=[a.id];za(a,function(a){c.push(a.id)},true);a.history=new hc(null);a.history.done=Oa(this.history.done,c);a.history.undone=
Oa(this.history.undone,c)}},iterLinkedDocs:function(a){za(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm}});L.prototype.eachLine=L.prototype.iter;var Kf=["iter","insert","remove","copy","getEditor"],ub;for(ub in L.prototype)L.prototype.hasOwnProperty(ub)&&0>F(Kf,ub)&&(m.prototype[ub]=function(a){return function(){return a.apply(this.doc,arguments)}}(L.prototype[ub]));Pa(L);var K=m.e_preventDefault=function(a){a.preventDefault?a.preventDefault():a.returnValue=false},
Lf=m.e_stopPropagation=function(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=true},Lc=m.e_stop=function(a){K(a);Lf(a)},t=m.on=function(a,b,c){if(a.addEventListener)a.addEventListener(b,c,false);else if(a.attachEvent)a.attachEvent("on"+b,c);else{a=a._handlers||(a._handlers={});(a[b]||(a[b]=[])).push(c)}},ia=m.off=function(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,false);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}},E=m.signal=function(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)},oa,Lb=0,ca=30,ae=m.Pass={toString:function(){return"CodeMirror.Pass"}},va={scroll:!1},Pc={origin:"*mouse"},Ea={origin:"+move"};lc.prototype.set=function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)};var Q=m.countColumn=function(a,b,c,d,e){if(b==null){b=a.search(/[^\s\u00a0]/);if(b==-1)b=a.length}d=d||0;for(e=e||0;;){var f=
a.indexOf("\t",d);if(f<0||f>=b)return e+(b-d);e=e+(f-d);e=e+(c-e%c);d=f+1}},ic=[""],lb=function(a){a.select()};Sa?lb=function(a){a.selectionStart=0;a.selectionEnd=a.value.length}:I&&(lb=function(a){try{a.select()}catch(b){}});[].indexOf&&(F=function(a,b){return a.indexOf(b)});[].map&&(Wc=function(a,b){return a.map(b)});var Mf=/[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ie=m.isWordChar=function(a){return/\w/.test(a)||a>"€"&&(a.toUpperCase()!=a.toLowerCase()||Mf.test(a))},
Ef=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,
fb;fb=document.createRange?function(a,b,c){var d=document.createRange();d.setEnd(a,c);d.setStart(a,b);return d}:function(a,b,c){var d=document.body.createTextRange();d.moveToElementText(a.parentNode);d.collapse(true);d.moveEnd("character",c);d.moveStart("character",b);return d};aa&&(ja=function(){try{return document.activeElement}catch(a){return document.body}});var kd=!1,gf=function(){if(H)return false;var a=q("div");return"draggable"in a||"dragDrop"in a}(),sb,fd,bd,Ka=m.splitLines=3!="\n\nb".split(/\n/).length?
function(a){for(var b=0,c=[],d=a.length;b<=d;){var e=a.indexOf("\n",b);if(e==-1)e=a.length;var f=a.slice(b,a.charAt(e-1)=="\r"?e-1:e),g=f.indexOf("\r");if(g!=-1){c.push(f.slice(0,g));b=b+(g+1)}else{c.push(f);b=e+1}}return c}:function(a){return a.split(/\r\n?|\n/)},cf=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return false}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return!b||b.parentElement()!=a?false:b.compareEndPoints("StartToEnd",
b)!=0},Rd=function(){var a=q("div");if("oncopy"in a)return true;a.setAttribute("oncopy","return;");return typeof a.oncopy=="function"}(),pa={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:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",
192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};m.keyNames=pa;(function(){for(var a=0;a<10;a++)pa[a+48]=pa[a+96]=""+a;for(a=65;a<=90;a++)pa[a]=String.fromCharCode(a);for(a=1;a<=12;a++)pa[a+111]=pa[a+63235]="F"+a})();var hb,Cf=function(){function a(a){return a<=247?c.charAt(a):1424<=a&&a<=1524?"R":1536<=a&&a<=1773?d.charAt(a-1536):1774<=a&&a<=2220?"r":8192<=a&&a<=8203?
"w":a==8204?"b":"L"}function b(a,b,c){this.level=a;this.from=b;this.to=c}var c="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",d="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",
e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,f=/[stwN]/,g=/[LRr]/,h=/[Lb1n]/,i=/[1n]/;return function(c){if(!e.test(c))return false;for(var d=c.length,n=[],l=0,o;l<d;++l)n.push(a(c.charCodeAt(l)));for(var l=0,m="L";l<d;++l){o=n[l];o=="m"?n[l]=m:m=o}l=0;for(m="L";l<d;++l){o=n[l];if(o=="1"&&m=="r")n[l]="n";else if(g.test(o)){m=o;o=="r"&&(n[l]="R")}}l=1;for(m=n[0];l<d-1;++l){o=n[l];if(o=="+"&&m=="1"&&n[l+1]=="1")n[l]="1";else if(o==","&&m==n[l+1]&&(m=="1"||m=="n"))n[l]=m;m=o}for(l=0;l<d;++l){o=n[l];
if(o==",")n[l]="N";else if(o=="%"){for(m=l+1;m<d&&n[m]=="%";++m);var p=l&&n[l-1]=="!"||m<d&&n[m]=="1"?"1":"N";for(o=l;o<m;++o)n[o]=p;l=m-1}}l=0;for(m="L";l<d;++l){o=n[l];m=="L"&&o=="1"?n[l]="L":g.test(o)&&(m=o)}for(l=0;l<d;++l)if(f.test(n[l])){for(m=l+1;m<d&&f.test(n[m]);++m);o=(m<d?n[m]:"L")=="L";p=(l?n[l-1]:"L")=="L"||o?"L":"R";for(o=l;o<m;++o)n[o]=p;l=m-1}for(var m=[],q,l=0;l<d;)if(h.test(n[l])){o=l;for(++l;l<d&&h.test(n[l]);++l);m.push(new b(0,o,l))}else{var r=l,p=m.length;for(++l;l<d&&n[l]!=
"L";++l);for(o=r;o<l;)if(i.test(n[o])){r<o&&m.splice(p,0,new b(1,r,o));r=o;for(++o;o<l&&i.test(n[o]);++o);m.splice(p,0,new b(2,r,o));r=o}else++o;r<l&&m.splice(p,0,new b(1,r,l))}if(m[0].level==1&&(q=c.match(/^\s+/))){m[0].from=q[0].length;m.unshift(new b(0,0,q[0].length))}if(x(m).level==1&&(q=c.match(/\s+$/))){x(m).to-=q[0].length;m.push(new b(0,d-q[0].length,d))}m[0].level!=x(m).level&&m.push(new b(m[0].level,d,d));return m}}();m.version="4.2.0";return m});