X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Fckeditor%2Fsamples%2Ftoolbarconfigurator%2Flib%2Fcodemirror%2Fcodemirror.js;fp=httemplate%2Felements%2Fckeditor%2Fsamples%2Ftoolbarconfigurator%2Flib%2Fcodemirror%2Fcodemirror.js;h=2550fefab21fdb7c4c98bd5f79a225702442879b;hb=c94eff6021ef963f08f67da501e756d53a61c50d;hp=0000000000000000000000000000000000000000;hpb=0736a91a87c46f7097ddef9782ddbb59a0ce3304;p=freeside.git diff --git a/httemplate/elements/ckeditor/samples/toolbarconfigurator/lib/codemirror/codemirror.js b/httemplate/elements/ckeditor/samples/toolbarconfigurator/lib/codemirror/codemirror.js new file mode 100644 index 000000000..2550fefab --- /dev/null +++ b/httemplate/elements/ckeditor/samples/toolbarconfigurator/lib/codemirror/codemirror.js @@ -0,0 +1,290 @@ +(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?S(b):{};S(jf,b,!1);rc(b);var c=b.value;"string"==typeof c&&(c=new M(c,b.mode));this.doc=c;var d=new m.inputStyles[b.inputStyle](this),d=this.display=new kf(a,c,d);d.wrapper.CodeMirror=this;sd(this);td(this);b.lineWrapping&&(this.display.wrapper.className+= +" CodeMirror-wrap");b.autofocus&&!Xa&&d.input.focus();ud(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Ya,keySeq:null,specialChars:null};var e=this;y&&11>z&&setTimeout(function(){e.display.input.reset(true)},20);lf(this);vd||(mf(),vd=!0);Fa(this);this.curOp.forceUpdate=!0;wd(this,c);b.autofocus&&!Xa||e.hasFocus()?setTimeout(Za(sc,this),20):$a(this);for(var f in Ga)if(Ga.hasOwnProperty(f))Ga[f](this, +b[f],xd);yd(this);b.finishInit&&b.finishInit(this);for(c=0;cz&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight= +0);if(!E&&(!sa||!Xa))this.scroller.draggable=!0;a&&(a.appendChild?a.appendChild(this.wrapper):a(this.wrapper));this.reportedViewFrom=this.reportedViewTo=this.viewFrom=this.viewTo=b.first;this.view=[];this.externalMeasured=this.renderedView=null;this.lastWrapHeight=this.lastWrapWidth=this.viewOffset=0;this.updateLineNumbers=null;this.nativeBarWidth=this.barHeight=this.barWidth=0;this.scrollbarsClipped=!1;this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null;this.alignWidgets=!1;this.maxLine= +this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null;this.maxLineLength=0;this.maxLineChanged=!1;this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null;this.shift=!1;this.activeTouch=this.selForContextMenu=null;c.init(this)}function uc(a){a.doc.mode=m.getMode(a.options,a.doc.modeOption);ab(a)}function ab(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.frontier=a.doc.first;bb(a,100);a.state.modeGen++;a.curOp&&N(a)}function Ad(a){var b= +ta(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/cb(a.display)-3);return function(e){if(ua(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;gb.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function rc(a){var b=G(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]): +-1z&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function Ac(){}function ud(a){a.display.scrollbars&& +(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&gb(a.display.wrapper,a.display.scrollbars.addClass));a.display.scrollbars=new m.scrollbarModel[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller);p(b,"mousedown",function(){a.state.focused&&setTimeout(function(){a.display.input.focus()},0)});b.setAttribute("cm-not-content","true")},function(b,c){c=="horizontal"?Ia(a,b):hb(a,b)},a);a.display.scrollbars.addClass&&ib(a.display.wrapper,a.display.scrollbars.addClass)} +function Ja(a,b){b||(b=fb(a));var c=a.display.barWidth,d=a.display.barHeight;Bd(a,b);for(var e=0;4>e&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&Hb(a),Bd(a,fb(a)),c=a.display.barWidth,d=a.display.barHeight}function Bd(a,b){var c=a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px";c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px";d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height= +d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="";d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function Bc(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=xa(b,d), +e=xa(b,e);if(c&&c.ensure){var f=c.ensure.from.line,c=c.ensure.to.line;f=e&&(d=xa(b,ga(r(b,c))-a.wrapper.clientHeight),e=c)}return{from:d,to:Math.max(e,d+1)}}function wc(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=Cc(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&0==Cd(a))return!1;yd(a)&&(ma(a),b.dims=Dc(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFromf-c.viewFrom&&(f=Math.max(d.first, +c.viewFrom));c.viewTo>g&&20>c.viewTo-g&&(g=Math.min(e,c.viewTo));na&&(f=Fc(a.doc,f),g=Dd(a.doc,g));d=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;e=a.display;0==e.view.length||f>=e.viewTo||g<=e.viewFrom?(e.view=Jb(a,f,g),e.viewFrom=f):(e.viewFrom>f?e.view=Jb(a,f,e.viewFrom).concat(e.view):e.viewFromg&&(e.view=e.view.slice(0,ya(a,g)));e.viewTo= +g;c.viewOffset=ga(r(a.doc,c.viewFrom));a.display.mover.style.top=c.viewOffset+"px";g=Cd(a);if(!d&&0==g&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;f=aa();4=a.display.viewFrom&&b.visible.to<=a.display.viewTo)break;if(!Ec(a,b))break;Hb(a);d=fb(a);jb(a);Hc(a,d);Ja(a,d)}b.signal(a,"update",a);if(a.display.viewFrom!=a.display.reportedViewFrom|| +a.display.viewTo!=a.display.reportedViewTo)b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo}function Ic(a,b){var c=new Ib(a,b);if(Ec(a,c)){Hb(a);Ed(a,c);var d=fb(a);jb(a);Hc(a,d);Ja(a,d);c.finish()}}function Hc(a,b){a.display.sizer.style.minHeight=b.docHeight+"px";var c=b.docHeight+a.display.barHeight;a.display.heightForcer.style.top=c+"px";a.display.gutters.style.height=Math.max(c+$(a),b.clientHeight)+ +"px"}function Hb(a){for(var a=a.display,b=a.lineDiv.offsetTop,c=0;cz){var f=d.node.offsetTop+d.node.offsetHeight;e=f-b;b=f}else e=d.node.getBoundingClientRect(),e=e.bottom-e.top;f=d.line.height-e;2>e&&(e=ta(a));if(0.001f)if(Z(d.line,e),Fd(d.line),d.rest)for(e=0;ez&&(a.node.style.zIndex=2));return a.node}function Hd(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):Kd(a,b)}function Jc(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=Kb(a);a.background=c.insertBefore(q("div",null,b),c.firstChild)}a.line.wrapClass?Kb(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 Id(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=Kb(b),g=b.gutter=q("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px");a.display.input.setUneditable(g);f.insertBefore(g,b.text);b.line.gutterClass&&(g.className+=" "+b.line.gutterClass);if(a.options.lineNumbers&&(!e||!e["CodeMirror-linenumbers"]))b.lineNumber=g.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;bv(a,b)?b:a}function Mb(a,b){return 0>v(a,b)?a:b}function Md(a){a.state.focused||(a.display.input.focus(),sc(a))}function Nb(a){return a.options.readOnly||a.doc.cantEdit}function Kc(a,b,c,d,e){var f=a.doc;a.display.shift=!1;d||(d=f.sel);var g=oa(b),h=null;a.state.pasteIncoming&&1j.head.ch&&(!i||d.ranges[i-1].head.line!=j.head.line)){j=a.getModeAt(j.head);k=pa(k);n=!1;if(j.electricChars)for(var s=0;se?i.map:j[e],g=0;ge?a.line:a.rest[e]);e=f[g]+d;if(0>d||h!=b)e=f[g+(d?1:0)];return o(c,e)}}}var e=a.text.firstChild,f=!1;if(!b||!Oc(e,b))return Na(o(C(a.line),0),!0);if(b==e&&(f=!0,b=e.childNodes[c],c=0,!b))return c=a.rest?x(a.rest):a.line,Na(o(C(c),c.text.length),f);var g=3==b.nodeType?b:null,h=b;!g&&(1==b.childNodes.length&& +3==b.firstChild.nodeType)&&(g=b.firstChild,c&&(c=g.nodeValue.length));for(;h.parentNode!=e;)h=h.parentNode;var i=a.measure,j=i.maps;if(b=d(g,h,c))return Na(b,f);e=h.nextSibling;for(g=g?g.nodeValue.length-c:0;e;e=e.nextSibling){if(b=d(e,e.firstChild,0))return Na(o(b.line,b.ch-g),f);g+=e.textContent.length}h=h.previousSibling;for(g=c;h;h=h.previousSibling){if(b=d(h,h.firstChild,-1))return Na(o(b.line,b.ch+g),f);g+=e.textContent.length}}function qf(a,b,c,d,e){function f(a){return function(b){return b.id== +a}}function g(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)""==c&&(c=b.textContent.replace(/\u200b/g,"")),h+=c;else{var c=b.getAttribute("cm-marker"),n;if(c){if(b=a.findMarks(o(d,0),o(e+1,0),f(+c)),b.length&&(n=b[0].find()))h+=za(a.doc,n.from,n.to).join("\n")}else if("false"!=b.getAttribute("contenteditable")){for(n=0;nc)return o(c,r(a,c).text.length);var c=r(a,b.line).text.length,d=b.ch,c=null==d||d>c?o(b.line,c):0>d?o(b.line,0):b;return c}function mb(a,b){return b>=a.first&&bv(c,a),b!=0>v(d,a)?(a=c,c=d):b!=0>v(c,d)&&(c=d)),new w(a,c)):new w(d||c,c)}function Qb(a,b,c,d){A(a,new ha([nb(a,a.sel.primary(),b,c)],0),d)}function Td(a, +b,c){for(var d=[],e=0;ev(b.primary().head,a.sel.primary().head)?-1:1);Wd(a,Xd(a,b,d,!0));!(c&&!1===c.scroll)&&a.cm&&La(a.cm)}function Wd(a,b){b.equals(a.sel)||(a.sel=b,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,Yd(a.cm)),H(a,"cursorActivity",a))}function Zd(a){Wd(a,Xd(a,a.sel,null, +!1),ca)}function Xd(a,b,c,d){for(var e,f=0;f=f.ch: +j.to>f.ch))){if(d&&(F(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?t(a,o(i.line-1)):null:i.ch>h.text.length&&(i=i.lineb&&(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;tf(V(f), +c||0,null==e?h:e,function(g,m,q){var r=Ub(a,o(b,g),"div",f,"left"),p,t;g==m?(p=r,q=t=r.left):(p=Ub(a,o(b,m-1),"div",f,"right"),"rtl"==q&&(q=r,r=p,p=q),q=r.left,t=p.right);null==c&&0==g&&(q=j);3n.bottom||p.bottom==n.bottom&&p.right>n.right)n=p;qa.options.cursorBlinkRate&&(b.cursorDiv.style.visibility="hidden")}}function bb(a,b){a.doc.mode.startState&&a.doc.frontier=a.display.viewTo)){var c=+new Date+ +a.options.workTime,d=Oa(b.mode,ob(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=be(a,f,d,true);f.styles=h.styles;var i=f.styleClasses;if(h=h.classes)f.styleClasses=h;else if(i)f.styleClasses=null;i=!g||g.length!=f.styles.length||i!=h&&(!i||!h||i.bgClass!=h.bgClass||i.textClass!=h.textClass);for(h=0;!i&&hc){bb(a,a.options.workDelay);return true}});e.length&&Q(a,function(){for(var b=0;bg;--b){if(b<=f.first)return f.first;var h=r(f,b-1);if(h.stateAfter&&(!c||b<=f.frontier))return b;h=X(h.text,null,a.options.tabSize);if(null==e||d>h)e=b-1,d=h}return e}function ob(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0; +var f=vf(a,b,c),g=f>d.first&&r(d,f-1).stateAfter,g=g?Oa(d.mode,g):wf(d.mode);d.iter(f,b,function(c){Rc(a,c.text,g);c.stateAfter=f==b-1||0==f%5||f>=e.viewFrom&&fc)return{map:a.measure.maps[d],cache:a.measure.caches[d],before:!0}} +function Nc(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bk;k++){for(;h&&pb(b.line.text.charAt(i.coverStart+h));)--h;for(;i.coverStart+jz&&0==h&&j==i.coverEnd-i.coverStart)l=d.parentNode.getBoundingClientRect();else if(y&&a.options.lineWrapping){var s=Aa(d,h,j).getClientRects();l=s.length?s["right"==g?s.length-1:0]:Tc}else l=Aa(d,h,j).getBoundingClientRect()||Tc;if(l.left||l.right||0==h)break;j= +h;h-=1;c="right"}if(y&&11>z){if(!(s=!window.screen))if(!(s=null==screen.logicalXDPI))if(!(s=screen.logicalXDPI==screen.deviceXDPI))null!=Uc?s=Uc:(k=R(a.display.measure,q("span","x")),s=k.getBoundingClientRect(),k=Aa(k,0,1).getBoundingClientRect(),s=Uc=1z&&!h&&(!l||!l.left&&!l.right))l=(l=d.parentNode.getClientRects()[0])?{left:l.left,right:l.left+cb(a.display),top:l.top,bottom:l.bottom}:Tc;s=l.top-b.rect.top;d=l.bottom-b.rect.top;h=(s+d)/2;g=b.view.measure.heights;for(k=0;kb)f=j-i,e=f-1,b>=j&&(g="right");if(null!=e){d=a[h+2];if(i==j&&c==(d.insertLeft?"left":"right"))g=c;if("left"==c&&0==e)for(;h&&a[h-2]==a[h-3]&&a[h-1].insertLeft;)d=a[(h-=3)+2],g="left";if("right"==c&&e==j-i)for(;h< +a.length-3&&a[h+3]==a[h+4]&&!a[h+5].insertLeft;)d=a[(h+=3)+2],g="right";break}}return{node:d,start:e,end:f,collapse:g,coverStart:i,coverEnd:j}}function de(a){if(a.measure&&(a.measure.cache={},a.measure.heights=null,a.rest))for(var b=0;bc.from? +g(a-1):g(a,d)}d=d||r(a.doc,b.line);e||(e=Vb(a,d));var i=V(d),b=b.ch;if(!i)return g(b);var j=Ob(i,b),j=h(b,j);null!=rb&&(j.other=h(b,rb));return j}function ge(a,b){var c=0,b=t(a.doc,b);a.options.lineWrapping||(c=cb(a.display)*b.ch);var d=r(a.doc,b.line),e=ga(d)+a.display.lineSpace.offsetTop;return{left:c,right:c,top:e,bottom:e+d.height}}function Wb(a,b,c,d){a=o(a,b);a.xRel=d;c&&(a.outside=!0);return a}function Xc(a,b,c){var d=a.doc,c=c+a.display.viewOffset;if(0>c)return Wb(d.first,0,!0,-1);var e=xa(d, +c),f=d.first+d.size-1;if(e>f)return Wb(d.first+d.size-1,r(d,f).text.length,!0,1);0>b&&(b=0);for(d=r(d,e);;)if(e=xf(a,d,e,b,c),f=(d=wa(d,!1))&&d.find(0,!0),d&&(e.ch>f.from.ch||e.ch==f.from.ch&&0d.bottom)return d.left-i;if(gm)return Wb(c,l,q,1);for(;;){if(k?l==e||l==Yc(b,e,1):1>=l-e){k=dd?-1:1d){l=p;m=t;if(q=h)m+=1E3;n=r}else e=p,s=t,I=h,n-=r}}function ta(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==Ba){Ba=q("pre");for(var b=0;49>b;++b)Ba.appendChild(document.createTextNode("x")),Ba.appendChild(q("br"));Ba.appendChild(document.createTextNode("x"))}R(a.measure, +Ba);b=Ba.offsetHeight/50;3=d.viewTo)|| +d.maxLineChanged&&c.options.lineWrapping;e.update=e.mustUpdate&&new Ib(c,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}for(b=0;bj;j++){var k=!1,n=ia(c,h),l=!g||g==h?n:ia(c,g),l=Zb(c,Math.min(n.left,l.left),Math.min(n.top,l.top)-i,Math.max(n.left,l.left),Math.max(n.bottom,l.bottom)+i),s=c.doc.scrollTop,I=c.doc.scrollLeft;null!=l.scrollTop&&(hb(c,l.scrollTop),1g.top+j.top)h=!0;else if(g.bottom+j.top>(window.innerHeight||document.documentElement.clientHeight))h=!1;null!=h&&!zf&&(g=q("div","​",null,"position: absolute; top: "+(g.top-i.viewOffset-c.display.lineSpace.offsetTop)+"px; height: "+(g.bottom-g.top+$(c)+i.barHeight)+"px; left: "+g.left+"px; width: 2px;"),c.display.lineSpace.appendChild(g),g.scrollIntoView(h),c.display.lineSpace.removeChild(g))}}h=e.maybeHiddenMarkers;g=e.maybeUnhiddenMarkers;if(h)for(i=0;ib))e.updateLineNumbers=b;a.curOp.viewChanged=!0;if(b>=e.viewTo)na&&Fc(a.doc,b)e.viewFrom?ma(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)ma(a);else if(b<=e.viewFrom){var f=$b(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):ma(a)}else if(c>= +e.viewTo)(f=$b(a,b,b,-1))?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):ma(a);else{var f=$b(a,b,b,-1),g=$b(a,c,c+d,1);f&&g?(e.view=e.view.slice(0,f.index).concat(Jb(a,f.lineN,g.lineN)).concat(e.view.slice(g.index)),e.viewTo+=d):ma(a)}if(a=e.externalMeasured)c=e.lineN&&b=d.viewTo|| +(a=d.view[ya(a,b)],null!=a.node&&(a=a.changes||(a.changes=[]),-1==G(a,c)&&a.push(c)))}function ma(a){a.display.viewFrom=a.display.viewTo=a.doc.first;a.display.view=[];a.display.viewOffset=0}function ya(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;db)return d}function $b(a,b,c,d){var e=ya(a,b),f=a.display.view;if(!na||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(0d?0:f.length-1))return null;c+=d*f[e-(0>d?1:0)].size;e+=d}return{index:e,lineN:c}}function Cd(a){for(var a=a.display.view,b=0,c=0;cz?p(d.scroller,"dblclick",B(a,function(b){if(!ea(a,b)){var c=Qa(a,b);c&&(!Zc(a,b,"gutterClick",!0,H)&&!ka(a.display,b))&&(L(b),b=a.findWordAt(c),Qb(a.doc,b.anchor,b.head))}})):p(d.scroller,"dblclick",function(b){ea(a,b)||L(b)});$c||p(d.scroller,"contextmenu",function(b){ie(a,b)});var e,f={end:0};p(d.scroller,"touchstart",function(a){var b;1!=a.touches.length?b=!1:(b=a.touches[0],b=1>=b.radiusX&& +1>=b.radiusY);b||(clearTimeout(e),b=+new Date,d.activeTouch={start:b,moved:!1,prev:300>=b-f.end?f:null},1==a.touches.length&&(d.activeTouch.left=a.touches[0].pageX,d.activeTouch.top=a.touches[0].pageY))});p(d.scroller,"touchmove",function(){d.activeTouch&&(d.activeTouch.moved=!0)});p(d.scroller,"touchend",function(e){var f=d.activeTouch;if(f&&!ka(d,e)&&null!=f.left&&!f.moved&&300>new Date-f.start){var g=a.coordsChar(d.activeTouch,"page"),f=!f.prev||c(f,f.prev)?new w(g,g):!f.prev.prev||c(f,f.prev.prev)? +a.findWordAt(g):new w(o(g.line,0),t(a.doc,o(g.line+1,0)));a.setSelection(f.anchor,f.head);a.focus();L(e)}b()});p(d.scroller,"touchcancel",b);p(d.scroller,"scroll",function(){d.scroller.clientHeight&&(hb(a,d.scroller.scrollTop),Ia(a,d.scroller.scrollLeft,!0),F(a,"scroll",a))});p(d.scroller,"mousewheel",function(b){je(a,b)});p(d.scroller,"DOMMouseScroll",function(b){je(a,b)});p(d.wrapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0});d.dragFunctions={simple:function(b){ea(a,b)||ad(b)}, +start:function(b){if(y&&(!a.state.draggingText||100>+new Date-ke))ad(b);else if(!ea(a,b)&&!ka(a.display,b)&&(b.dataTransfer.setData("Text",a.getSelection()),b.dataTransfer.setDragImage&&!le)){var c=q("img",null,null,"position: fixed; left: 0; top: 0;");c.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";Y&&(c.width=c.height=1,a.display.wrapper.appendChild(c),c._top=c.offsetTop);b.dataTransfer.setDragImage(c,0,0);Y&&c.parentNode.removeChild(c)}},drop:B(a,Af)};var g=d.input.getField(); +p(g,"keyup",function(b){me.call(a,b)});p(g,"keydown",B(a,ne));p(g,"keypress",B(a,oe));p(g,"focus",Za(sc,a));p(g,"blur",Za($a,a))}function Bf(a){var b=a.display;b.lastWrapHeight==b.wrapper.clientHeight&&b.lastWrapWidth==b.wrapper.clientWidth||(b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,b.scrollbarsClipped=!1,a.setSize())}function ka(a,b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(!c||1==c.nodeType&&"true"==c.getAttribute("cm-ignore-events")||c.parentNode==a.sizer&& +c!=a.mover)return!0}function Qa(a,b,c,d){var e=a.display;if(!c&&"true"==(b.target||b.srcElement).getAttribute("cm-not-content"))return null;var f,g,c=e.lineSpace.getBoundingClientRect();try{f=b.clientX-c.left,g=b.clientY-c.top}catch(h){return null}var b=Xc(a,f,g),i;if(d&&1==b.xRel&&(i=r(a.doc,b.line).text).length==b.ch)d=X(i,i.length,a.options.tabSize)-i.length,b=o(b.line,Math.max(0,Math.round((f-ae(a.display).left)/cb(a.display))-d));return b}function he(a){var b=this.display;if(!(b.activeTouch&& +b.input.supportsTouch()||ea(this,a)))if(b.shift=a.shiftKey,ka(b,a))E||(b.scroller.draggable=!1,setTimeout(function(){b.scroller.draggable=!0},100));else if(!Zc(this,a,"gutterClick",!0,H)){var c=Qa(this,a);window.focus();switch(pe(a)){case 1:c?Cf(this,a,c):(a.target||a.srcElement)==b.scroller&&L(a);break;case 2:E&&(this.state.lastMiddleDown=+new Date);c&&Qb(this.doc,c);setTimeout(function(){b.input.focus()},20);L(a);break;case 3:$c?ie(this,a):Df(this)}}}function Cf(a,b,c){y?setTimeout(Za(Md,a),0): +a.curOp.focus=aa();var d=+new Date,e;ac&&ac.time>d-400&&0==v(ac.pos,c)?e="triple":bc&&bc.time>d-400&&0==v(bc.pos,c)?(e="double",ac={time:d,pos:c}):(e="single",bc={time:d,pos:c});var d=a.doc.sel,f=T?b.metaKey:b.ctrlKey,g;a.options.dragDrop&&Ef&&!Nb(a)&&"single"==e&&-1<(g=d.contains(c))&&!d.ranges[g].empty()?Ff(a,b,c,f):Gf(a,b,c,e,f)}function Ff(a,b,c,d){var e=a.display,f=+new Date,g=B(a,function(h){E&&(e.scroller.draggable=!1);a.state.draggingText=!1;fa(document,"mouseup",g);fa(e.scroller,"drop",g); +10>Math.abs(b.clientX-h.clientX)+Math.abs(b.clientY-h.clientY)&&(L(h),!d&&+new Date-200q&&e.push(new w(o(h,q),o(h,qe(I,g,f))))}e.length||e.push(new w(c,c));A(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?a.findWordAt(b):new w(o(b.line,0),t(j,o(b.line+1,0))),0=h.to||e.lineq.bottom?20:0;k&&setTimeout(B(a,function(){u==c&&(i.scroller.scrollTop+=k,g(b))}),50)}}function h(a){u=Infinity;L(a);i.input.focus();fa(document,"mousemove",y);fa(document,"mouseup",x);j.history.lastSelOrigin= +null}var i=a.display,j=a.doc;L(b);var k,n,l=j.sel,s=l.ranges;e&&!b.shiftKey?(n=j.sel.contains(c),k=-1=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&L(b);var d=a.display,i=d.lineDiv.getBoundingClientRect(); +if(g>i.bottom||!P(a,c))return cd(b);g-=i.top-d.viewOffset;for(i=0;i=f)return f=xa(a.doc,g),e(a,c,a,f,a.options.gutters[i],b),cd(b)}}function Af(a){var b=this;if(!ea(b,a)&&!ka(b.display,a)){L(a);y&&(ke=+new Date);var c=Qa(b,a,!0),d=a.dataTransfer.files;if(c&&!Nb(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=t(b.doc,c);var a={from:c,to:c,text:oa(f.join("\n")),origin:"paste"};Ka(b.doc,a);Ud(b.doc,ba(c,pa(a)))}});h.readAsText(a)},h=0;hMath.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,sa||Ic(a,{top:b}),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbars.setScrollTop(b),sa&&Ic(a),bb(a,100))}function Ia(a,b,c){if(!(c?b==a.doc.scrollLeft:2>Math.abs(a.doc.scrollLeft-b)))b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,wc(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft= +b),a.display.scrollbars.setScrollLeft(b)}function je(a,b){var c=re(b),d=c.x,c=c.y,e=a.display,f=e.scroller;if(d&&f.scrollWidth>f.clientWidth||c&&f.scrollHeight>f.clientHeight){if(c&&T&&E){var g=b.target,h=e.view;a:for(;g!=f;g=g.parentNode)for(var i=0;ig?h=Math.max(0,h+g-50):i=Math.min(a.doc.height,i+g+50),Ic(a,{top:h,bottom:i})),20>cc)null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=d,e.wheelDY=c,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){O=(O*cc+a)/(cc+1);++cc}}}, +200)):(e.wheelDX+=d,e.wheelDY+=c)}}function dc(a,b,c){if("string"==typeof b&&(b=ec[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{Nb(a)&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=se}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function Hf(a,b,c){for(var d=0;dz&&27==a.keyCode)&&(a.returnValue=!1);var b=a.keyCode;this.display.shift=16==b||a.shiftKey;var c=te(this,a);Y&&(dd=c?b:null,!c&&(88==b&&!ue&&(T?a.metaKey:a.ctrlKey))&&this.replaceSelection("",null,"cut"));18==b&&!/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)&&Mf(this)}}function Mf(a){function b(a){if(18== +a.keyCode||!a.altKey)gb(c,"CodeMirror-crosshair"),fa(document,"keyup",b),fa(document,"mouseover",b)}var c=a.display.lineDiv;ib(c,"CodeMirror-crosshair");p(document,"keyup",b);p(document,"mouseover",b)}function me(a){16==a.keyCode&&(this.doc.sel.shift=!1);ea(this,a)}function oe(a){if(!ka(this.display,a)&&!ea(this,a)&&!(a.ctrlKey&&!a.altKey||T&&a.metaKey)){var b=a.keyCode,c=a.charCode;if(Y&&b==dd)dd=null,L(a);else if(!Y||a.which&&!(10>a.which)||!te(this,a))if(b=String.fromCharCode(null==c?b:c),!Lf(this, +a,b))this.display.input.onKeyPress(a)}}function Df(a){a.state.delayingBlurEvent=!0;setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,$a(a))},100)}function sc(a){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1);"nocursor"!=a.options.readOnly&&(a.state.focused||(F(a,"focus",a),a.state.focused=!0,ib(a.display.wrapper,"CodeMirror-focused"),!a.curOp&&a.display.selForContextMenu!=a.doc.sel&&(a.display.input.reset(),E&&setTimeout(function(){a.display.input.reset(true)}, +20)),a.display.input.receivedFocus()),Qc(a))}function $a(a){a.state.delayingBlurEvent||(a.state.focused&&(F(a,"blur",a),a.state.focused=!1,gb(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){if(!a.state.focused)a.display.shift=false},150))}function ie(a,b){var c;if(!(c=ka(a.display,b)))c=P(a,"gutterContextMenu")?Zc(a,b,"gutterContextMenu",!1,F):!1;if(!c)a.display.input.onContextMenu(b)}function ve(a,b){if(0>v(a,b.from))return a;if(0>=v(a,b.to))return pa(b); +var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;a.line==b.to.line&&(d+=pa(b).ch-b.to.ch);return o(c,d)}function ed(a,b){for(var c=[],d=0;da.lastLine())){if(b.from.linee&&(b={from:b.from,to:o(e,r(a,e).text.length),text:[b.text[0]],origin:b.origin});b.removed=za(a,b.from,b.to);c||(c=ed(a,b));a.cm?Of(a.cm,b,d):hd(a,b,d);Rb(a,c,ca)}}function Of(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=C(da(r(d,f.line))),d.iter(i,g.line+1,function(a){if(a==e.maxLine)return h=!0}));-1e.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);bb(a,400);c=b.text.length-(g.line-f.line)-1;b.full?N(a):f.line==g.line&&1==b.text.length&&!Ee(a.doc,b)?ja(a,f.line,"text"):N(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&&H(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=oa(b));Ka(a,{from:c,to:d,text:b,origin:e})}function Zb(a,b,c,d,e){var f=a.display,g=ta(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,i=Gc(a), +j={};e-c>i&&(e=c+i);var k=a.doc.height+(f.mover.offsetHeight-f.lineSpace.offsetHeight),n=ck-g;ch+i&&(c=Math.min(c,(g?k:e)-i),c!=h&&(j.scrollTop=c));h=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft;a=la(a)-(a.options.fixedGutter?f.gutters.offsetWidth:0);(f=d-b>a)&&(d=b+a);10>b?j.scrollLeft=0:ba+h-3&&(j.scrollLeft=d+(f?0:10)-a);return j}function id(a,b,c){(null!=b||null!=c)&&hc(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 La(a){hc(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?o(b.line,b.ch-1):b,d=o(b.line,b.ch+1));a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function hc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=ge(a,b.from),d=ge(a,b.to),b=Zb(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 lb(a,b,c,d){var e=a.doc,f;null==c&&(c="add");"smart"==c&&(e.mode.indent?f=ob(a,b):c="prev");var g=a.options.tabSize,h=r(e,b),i=X(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=e.mode.indent(f,h.text.slice(j.length),h.text),k==se||150e.first? +X(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);c="";d=0;if(a.options.indentWithTabs)for(a=Math.floor(k/g);a;--a)d+=g,c+="\t";d=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)}Q(a,function(){for(var b=d.length-1;0<=b;b--)sb(a.doc,"",d[b].from,d[b].to,"+delete");La(a)})}function jd(a,b,c,d,e){function f(b){var d=(e?Yc:Ge)(j,h,c,!0);if(null==d){if(b=!b)b=g+c,b=a.first+ +a.size?b=k=!1:(g=b,b=j=r(a,b));if(b)h=e?(0>c?Yb:Xb)(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 s=j.text.charAt(h)||"\n",s=jc(s,b)?"w":d&&"\n"==s?"n":!d||/\s/.test(s)?null:"p";d&&(!l&&!s)&&(s="s");if(n&&n!=s){0>c&&(c=1,f());break}s&&(n=s);if(0c?1.5:0.5)*ta(a.display))):"line"==d&&(g=0c?0>=g:g>=e.height){h.hitSide=!0;break}g+=5*c}return h}function u(a,b,c,d){m.defaults[a]=b;c&&(Ga[a]=d?function(a,b,d){d!=xd&&c(a,b,d)}:c)}function Pf(a){for(var b=a.split(/-(?!$)/),a=b[b.length- +1],c,d,e,f,g=0;g=e:j.to>e);(i||(i=[])).push(new lc(k,j.from,n?null:j.to))}}c=i;if(d)for(var h=0,l;h=f:i.to>f)||i.from==f&&"bookmark"==j.type&&(!g||i.marker.insertLeft))k=null==i.from||(j.inclusiveLeft?i.from<=f:i.fromv(g.to,e.from)||0i||!c.inclusiveLeft&&!i)&&h.push({from:g.from,to:e.from});(0Ne(d,e.marker)))d=e.marker;return d}function Ie(a,b,c,d,e){a=r(a,b);if(a=na&&a.markedSpans)for(b=0;b=i||0>=h&&0<=i))if(0>=h&&(0v(g.from,d)||f.marker.inclusiveLeft&&e.inclusiveRight))return!0}}}function da(a){for(var b;b=wa(a,!0);)a=b.find(-1,!0).line;return a}function Fc(a,b){var c=r(a,b),d=da(c);return c==d?b:C(d)}function Dd(a,b){if(b> +a.lastLine())return b;var c=r(a,b),d;if(!ua(a,c))return b;for(;d=wa(c,!1);)c=d.find(1,!0).line;return C(c)+1}function ua(a,b){var c=na&&b.markedSpans;if(c)for(var d,e=0;ee;e++){d&&(d[0]=m.innerMode(a,c).mode);var f=a.token(b,c);if(b.pos>b.start)return f}throw Error("Mode "+a.name+" failed to advance stream."); +}function Re(a,b,c,d){function e(a){return{start:k.start,end:k.pos,string:k.current(),type:h||null,state:a?Oa(f.mode,j):j}}var f=a.doc,g=f.mode,h,b=t(f,b),i=r(f,b.line),j=ob(a,b.line,c),k=new oc(i.text,a.options.tabSize),n;for(d&&(n=[]);(d||k.posa.options.maxHighlightLength?(h=!1,g&&Rc(a,b,d,k.pos),k.pos=b.length,n=null):n=Pe(md(c,k,d,l),f);if(l){var s=l[0].name;s&&(n="m-"+(n?s+" "+n:s))}if(!h||j!=n){for(;ia&&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(;cAa(g,1,2).getBoundingClientRect().right-h.right}if(g&&(f=V(e)))c.addToken=Xf(c.addToken,f);c.map=[];h=b!=a.display.externalMeasured&&C(e);a:{g=c;var h=Te(a,e,h),i=e.markedSpans,j=e.text,k=0;if(i)for(var n=j.length,l=0,s=1,m="",o=void 0,r=void 0,p=0,t=void 0,u=void 0,v=void 0, +x=void 0,w=void 0;;){if(p==l){for(var t=u=v=x=r="",w=null,p=Infinity,z=[],B=0;Bl||A.collapsed&&D.to==l&&D.from==l)){if(null!=D.to&&(D.to!=l&&p>D.to)&&(p=D.to,u=""),A.className&&(t+=" "+A.className),A.css&&(r=A.css),A.startStyle&&D.from==l&&(v+=" "+A.startStyle),A.endStyle&&D.to==p&&(u+=" "+A.endStyle),A.title&&!x&&(x=A.title),A.collapsed&&(!w||0>Ne(w.marker,A)))w=D}else D.from> +l&&p>D.from&&(p=D.from)}if(w&&(w.from||0)==l){Ve(g,(null==w.to?n+1:w.to)-l,w.marker,null==w.from);if(null==w.to)break a;w.to==l&&(w=!1)}if(!w&&z.length)for(B=0;B=n)break;for(z=Math.min(n,p);;){if(m){B=l+m.length;w||(D=B>z?m.slice(0,z-l):m,g.addToken(g,D,o?o+t:t,v,l+D.length==p?u:"",x,r));if(B>=z){m=m.slice(z-l);l=z;break}l=B;v=""}m=j.slice(k,k=h[s++]);o=Ue(h[s++],g.cm.options)}}else for(var s=1;sz?k.appendChild(q("span",[m])):k.appendChild(m);a.map.push(a.pos,a.pos+s,m);a.col+=s;a.pos+=s}if(!l)break;n+=s+1;"\t"==l[0]?(m= +a.cm.options.tabSize,l=m-a.col%m,m=k.appendChild(q("span",Fe(l),"cm-tab")),m.setAttribute("role","presentation"),m.setAttribute("cm-text","\t"),a.col+=l):(m=a.cm.options.specialCharPlaceholder(l[0]),m.setAttribute("cm-text",l[0]),y&&9>z?k.appendChild(q("span",[m])):k.appendChild(m),a.col+=1);a.map.push(a.pos,a.pos+1,m);a.pos++}else{a.col+=b.length;var k=document.createTextNode(h);a.map.push(a.pos,a.pos+b.length,k);y&&9>z&&(j=!0);a.pos+=b.length}if(c||d||e||j||g)return b=c||"",d&&(b+=d),e&&(b+=e), +d=q("span",[k],b,g),f&&(d.title=f),a.content.appendChild(d);a.content.appendChild(k)}}function Zf(a){for(var b=" ",c=0;cj&&l.from<=j)break}if(l.to>=k)return a(c,d,e,f,g,h,i);a(c,d.slice(0,l.to-j),e,f,null,h,i);f=null;d=d.slice(l.to-j);j=l.to}}}function Ve(a,b,c,d){var e=!d&&c.widgetNode; +e&&a.map.push(a.pos,a.pos+b,e);!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id));e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e));a.pos+=b}function Ee(a,b){return 0==b.from.ch&&0==b.to.ch&&""==x(b.text)&&(!a.cm||a.cm.options.wholeLineUpdateBefore)}function hd(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);Le(a);Me(a,e);c=f?f(a):1;c!=a.height&&Z(a,c);H(a,"change",a,b)}function g(a,b){for(var c=a,f=[];cb||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(bf-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0))){var i;e.lastOp==d?(Vd(e.done),i=x(e.done)):e.done.length&&!x(e.done).ranges? +i=x(e.done):1e.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=e.lastSelOp=d;e.lastOrigin=e.lastSelOrigin= +b.origin;j||F(a,"historyAdded")}function Sb(a,b){var c=x(b);(!c||!c.ranges||!c.equals(a))&&b.push(a)}function We(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 Sf(a){if(!a)return null;for(var b=0,c;b=b)return d+Math.min(g,b-e);e+=f-d;e+=c-e%c;d=f+1;if(e>=b)return d}}function Fe(a){for(;qc.length<=a;)qc.push(x(qc)+" ");return qc[a]}function x(a){return a[a.length-1]}function G(a,b){for(var c=0;c=b.offsetWidth&&2z))}a=qd?q("span","​"):q("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");a.setAttribute("cm-text","");return a} +function tf(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;fb||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 Wc(a){return a.level%2?a.from:a.to}function Xb(a){return(a=V(a))?a[0].level%2?a[0].to:a[0].from:0}function Yb(a){var b=V(a);return!b?a.text.length:Wc(x(b))}function cf(a,b){var c=r(a.doc,b),d=da(c);d!=c&&(b=C(d));c=V(d);d=!c?0:c[0].level%2?Yb(d):Xb(d);return o(b,d)}function df(a,b){var c= +cf(a,b.line),d=r(a.doc,c.line),e=V(d);return!e||0==e[0].level?(d=Math.max(0,d.text.search(/\S/)),o(c.line,b.line==c.line&&b.ch<=d&&b.ch?0:d)):c}function Ob(a,b){rb=null;for(var c=0,d;cb)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:fg.from&&bb||b>a.text.length?null:b}var sa=/gecko\/\d/i.test(navigator.userAgent),ef=/MSIE \d/.test(navigator.userAgent),ff=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent), +y=ef||ff,z=y&&(ef?document.documentMode||6:ff[1]),E=/WebKit\//.test(navigator.userAgent),cg=E&&/Qt\/\d+\.\d+/.test(navigator.userAgent),dg=/Chrome\//.test(navigator.userAgent),Y=/Opera\//.test(navigator.userAgent),le=/Apple Computer/.test(navigator.vendor),eg=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),zf=/PhantomJS/.test(navigator.userAgent),Ma=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Xa=Ma||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent), +T=Ma||/Mac/.test(navigator.platform),fg=/win/i.test(navigator.platform),Ea=Y&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Ea&&(Ea=Number(Ea[1]));Ea&&15<=Ea&&(Y=!1,E=!0);var gf=T&&(cg||Y&&(null==Ea||12.11>Ea)),$c=sa||y&&9<=z,ye=!1,na=!1;zc.prototype=S({update:function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;if(c){this.vert.style.display="block";this.vert.style.bottom=b?d+"px":"0";this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+ +(a.viewHeight-(b?d:0)))+"px"}else{this.vert.style.display="";this.vert.firstChild.style.height="0"}if(b){this.horiz.style.display="block";this.horiz.style.right=c?d+"px":"0";this.horiz.style.left=a.barLeft+"px";this.horiz.firstChild.style.width=a.scrollWidth-a.clientWidth+(a.viewWidth-a.barLeft-(c?d:0))+"px"}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0"}if(!this.checkedOverlay&&a.clientHeight>0){d==0&&this.overlayHack();this.checkedOverlay=true}return{right:c?d:0,bottom:b? +d:0}},setScrollLeft:function(a){if(this.horiz.scrollLeft!=a)this.horiz.scrollLeft=a},setScrollTop:function(a){if(this.vert.scrollTop!=a)this.vert.scrollTop=a},overlayHack:function(){this.horiz.style.minHeight=this.vert.style.minWidth=T&&!eg?"12px":"18px";var a=this,b=function(b){(b.target||b.srcElement)!=a.vert&&(b.target||b.srcElement)!=a.horiz&&B(a.cm,he)(b)};p(this.vert,"mousedown",b);p(this.horiz,"mousedown",b)},clear:function(){var a=this.horiz.parentNode;a.removeChild(this.horiz);a.removeChild(this.vert)}}, +zc.prototype);Ac.prototype=S({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},Ac.prototype);m.scrollbarModel={"native":zc,"null":Ac};Ib.prototype.signal=function(a,b){P(a,b)&&this.events.push(arguments)};Ib.prototype.finish=function(){for(var a=0;a=9&&c.hasSelection)c.hasSelection=null;c.poll()});p(f,"paste",function(){if(E&&!d.state.fakedLastChar&&!(new Date-d.state.lastMiddleDown<200)){var a=f.selectionStart,b=f.selectionEnd;f.value=f.value+"$";f.selectionEnd=b;f.selectionStart=a;d.state.fakedLastChar=true}d.state.pasteIncoming=true;c.fastPoll()});p(f,"cut",b);p(f,"copy",b);p(a.scroller,"paste",function(b){if(!ka(a,b)){d.state.pasteIncoming=true;c.focus()}});p(a.lineSpace, +"selectstart",function(b){ka(a,b)||L(b)});p(f,"compositionstart",function(){var a=d.getCursor("from");c.composing={start:a,range:d.markText(a,d.getCursor("to"),{className:"CodeMirror-composing"})}});p(f,"compositionend",function(){if(c.composing){c.poll();c.composing.range.clear();c.composing=null}})},prepareSelection:function(){var a=this.cm,b=a.display,c=a.doc,d=$d(a);if(a.options.moveInputWithCursor){var a=ia(a,c.sel.primary().head,"div"),c=b.wrapper.getBoundingClientRect(),e=b.lineDiv.getBoundingClientRect(); +d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,a.top+e.top-c.top));d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,a.left+e.left-c.left))}return d},showSelection:function(a){var b=this.cm.display;R(b.cursorDiv,a.cursors);R(b.selectionDiv,a.selection);if(a.teTop!=null){this.wrapper.style.top=a.teTop+"px";this.wrapper.style.left=a.teLeft+"px"}},reset:function(a){if(!this.contextMenuPending){var b,c,d=this.cm,e=d.doc;if(d.somethingSelected()){this.prevInput="";b=e.sel.primary();c=(b=ue&& +(b.to().line-b.from().line>100||(c=d.getSelection()).length>1E3))?"-":c||d.getSelection();this.textarea.value=c;d.state.focused&&Va(this.textarea);if(y&&z>=9)this.hasSelection=c}else if(!a){this.prevInput=this.textarea.value="";if(y&&z>=9)this.hasSelection=null}this.inaccurateSelection=b}},getField:function(){return this.textarea},supportsTouch:function(){return false},focus:function(){if(this.cm.options.readOnly!="nocursor"&&(!Xa||aa()!=this.textarea))try{this.textarea.focus()}catch(a){}},blur:function(){this.textarea.blur()}, +resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var a=this;a.pollingFast||a.polling.set(this.cm.options.pollInterval,function(){a.poll();a.cm.state.focused&&a.slowPoll()})},fastPoll:function(){function a(){if(!c.poll()&&!b){b=true;c.polling.set(60,a)}else{c.pollingFast=false;c.slowPoll()}}var b=false,c=this;c.pollingFast=true;c.polling.set(20,a)},poll:function(){var a=this.cm,b=this.textarea,c=this.prevInput; +if(!a.state.focused||gg(b)&&!c||Nb(a)||a.options.disableInput||a.state.keySeq)return false;if(a.state.pasteIncoming&&a.state.fakedLastChar){b.value=b.value.substring(0,b.value.length-1);a.state.fakedLastChar=false}var d=b.value;if(d==c&&!a.somethingSelected())return false;if(y&&z>=9&&this.hasSelection===d||T&&/[\uf700-\uf7ff]/.test(d)){a.display.input.reset();return false}if(a.doc.sel==a.display.selForContextMenu){var e=d.charCodeAt(0);e==8203&&!c&&(c="​");if(e==8666){this.reset();return this.cm.execCommand("undo")}}for(var f= +0,e=Math.min(c.length,d.length);f1E3||d.indexOf("\n")>-1?b.value=g.prevInput="":g.prevInput=d;if(g.composing){g.composing.range.clear();g.composing.range=a.markText(g.composing.start,a.getCursor("to"),{className:"CodeMirror-composing"})}});return true},ensurePolled:function(){if(this.pollingFast&&this.poll())this.pollingFast=false},onKeyPress:function(){if(y&&z>= +9)this.hasSelection=null;this.fastPoll()},onContextMenu:function(a){function b(){if(g.selectionStart!=null){var a=e.somethingSelected(),b="​"+(a?g.value:"");g.value="⇚";g.value=b;d.prevInput=a?"":"​";g.selectionStart=1;g.selectionEnd=b.length;f.selForContextMenu=e.doc.sel}}function c(){d.contextMenuPending=false;d.wrapper.style.position="relative";g.style.cssText=j;if(y&&z<9)f.scrollbars.setScrollTop(f.scroller.scrollTop=i);if(g.selectionStart!=null){(!y||y&&z<9)&&b();var a=0,c=function(){f.selForContextMenu== +e.doc.sel&&g.selectionStart==0&&g.selectionEnd>0&&d.prevInput=="​"?B(e,ec.selectAll)(e):a++<10?f.detectingSelectAll=setTimeout(c,500):f.input.reset()};f.detectingSelectAll=setTimeout(c,200)}}var d=this,e=d.cm,f=e.display,g=d.textarea,h=Qa(e,a),i=f.scroller.scrollTop;if(h&&!Y){e.options.resetSelectionOnContextMenu&&e.doc.sel.contains(h)==-1&&B(e,A)(e.doc,ba(h),ca);var j=g.style.cssText;d.wrapper.style.position="absolute";g.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(a.clientY- +5)+"px; left: "+(a.clientX-5)+"px; z-index: 1000; background: "+(y?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(E)var k=window.scrollY;f.input.focus();E&&window.scrollTo(null,k);f.input.reset();if(!e.somethingSelected())g.value=d.prevInput=" ";d.contextMenuPending=true;f.selForContextMenu=e.doc.sel;clearTimeout(f.detectingSelectAll);y&&z>=9&&b();if($c){ad(a);var n=function(){fa(window,"mouseup", +n);setTimeout(c,20)};p(window,"mouseup",n)}else setTimeout(c,50)}},setUneditable:Ab,needsContentAttribute:!1},Lc.prototype);Mc.prototype=S({init:function(a){function b(a){if(d.somethingSelected()){U=d.getSelections();a.type=="cut"&&d.replaceSelection("",null,"cut")}else if(d.options.lineWiseCopyCut){var b=Nd(d);U=b.text;a.type=="cut"&&d.operation(function(){d.setSelections(b.ranges,0,ca);d.replaceSelection("",null,"cut")})}else return;if(a.clipboardData&&!Ma){a.preventDefault();a.clipboardData.clearData(); +a.clipboardData.setData("text/plain",U.join("\n"))}else{var c=Pd(),a=c.firstChild;d.display.lineSpace.insertBefore(c,d.display.lineSpace.firstChild);a.value=U.join("\n");var h=document.activeElement;Va(a);setTimeout(function(){d.display.lineSpace.removeChild(c);h.focus()},50)}}var c=this,d=c.cm,a=c.div=a.lineDiv;a.contentEditable="true";Od(a);p(a,"paste",function(a){var b=a.clipboardData&&a.clipboardData.getData("text/plain");if(b){a.preventDefault();d.replaceSelection(b,null,"paste")}});p(a,"compositionstart", +function(a){a=a.data;c.composing={sel:d.doc.sel,data:a,startData:a};if(a){var b=d.doc.sel.primary(),g=d.getLine(b.head.line).indexOf(a,Math.max(0,b.head.ch-a.length));if(g>-1&&g<=b.head.ch)c.composing.sel=ba(o(b.head.line,g),o(b.head.line,g+a.length))}});p(a,"compositionupdate",function(a){c.composing.data=a.data});p(a,"compositionend",function(a){var b=c.composing;if(b){if(a.data!=b.startData&&!/\u200b/.test(a.data))b.data=a.data;setTimeout(function(){b.handled||c.applyComposition(b);if(c.composing== +b)c.composing=null},50)}});p(a,"touchstart",function(){c.forceCompositionEnd()});p(a,"input",function(){c.composing||c.pollContent()||Q(c.cm,function(){N(d)})});p(a,"copy",b);p(a,"cut",b)},prepareSelection:function(){var a=$d(this.cm,false);a.focus=this.cm.state.focused;return a},showSelection:function(a){if(a&&this.cm.display.view.length){a.focus&&this.showPrimarySelection();this.showMultipleSelections(a)}},showPrimarySelection:function(){var a=window.getSelection(),b=this.cm.doc.sel.primary(),c= +Pb(this.cm,a.anchorNode,a.anchorOffset),d=Pb(this.cm,a.focusNode,a.focusOffset);if(!c||c.bad||!d||d.bad||!(v(Mb(c,d),b.from())==0&&v(Lb(c,d),b.to())==0)){c=Qd(this.cm,b.from());d=Qd(this.cm,b.to());if(c||d){var e=this.cm.display.view,b=a.rangeCount&&a.getRangeAt(0);if(c){if(!d){d=e[e.length-1].measure;d=d.maps?d.maps[d.maps.length-1]:d.map;d={node:d[d.length-1],offset:d[d.length-2]-d[d.length-3]}}}else c={node:e[0].measure.map[2],offset:0};try{var f=Aa(c.node,c.offset,d.offset,d.node)}catch(g){}if(f){a.removeAllRanges(); +a.addRange(f);b&&a.anchorNode==null?a.addRange(b):sa&&this.startGracePeriod()}this.rememberSelection()}}},startGracePeriod:function(){var a=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){a.gracePeriod=false;a.selectionChanged()&&a.cm.operation(function(){a.cm.curOp.selectionChanged=true})},20)},showMultipleSelections:function(a){R(this.cm.display.cursorDiv,a.cursors);R(this.cm.display.selectionDiv,a.selection)},rememberSelection:function(){var a=window.getSelection();this.lastAnchorNode= +a.anchorNode;this.lastAnchorOffset=a.anchorOffset;this.lastFocusNode=a.focusNode;this.lastFocusOffset=a.focusOffset},selectionInEditor:function(){var a=window.getSelection();if(!a.rangeCount)return false;a=a.getRangeAt(0).commonAncestorContainer;return Oc(this.div,a)},focus:function(){this.cm.options.readOnly!="nocursor"&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return true},receivedFocus:function(){function a(){if(b.cm.state.focused){b.pollSelection(); +b.polling.set(b.cm.options.pollInterval,a)}}var b=this;this.selectionInEditor()?this.pollSelection():Q(this.cm,function(){b.cm.curOp.selectionChanged=true});this.polling.set(this.cm.options.pollInterval,a)},selectionChanged:function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode||a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var a= +window.getSelection(),b=this.cm;this.rememberSelection();var c=Pb(b,a.anchorNode,a.anchorOffset),d=Pb(b,a.focusNode,a.focusOffset);c&&d&&Q(b,function(){A(b.doc,ba(c,d),ca);if(c.bad||d.bad)b.curOp.selectionChanged=true})}},pollContent:function(){var a=this.cm,b=a.display,c=a.doc.sel.primary(),d=c.from(),c=c.to();if(d.lineb.viewTo-1)return false;var e;if(d.line==b.viewFrom||(e=ya(a,d.line))==0){d=C(b.view[0].line);e=b.view[0].node}else{d=C(b.view[e].line);e=b.view[e-1].node.nextSibling}var f= +ya(a,c.line);if(f==b.view.length-1){c=b.viewTo-1;b=b.view[f].node}else{c=C(b.view[f+1].line)-1;b=b.view[f+1].node.previousSibling}b=oa(qf(a,e,b,d,c));for(e=za(a.doc,o(d,0),o(c,r(a.doc,c).text.length));b.length>1&&e.length>1;)if(x(b)==x(e)){b.pop();e.pop();c--}else if(b[0]==e[0]){b.shift();e.shift();d++}else break;for(var g=0,f=0,h=b[0],i=e[0],j=Math.min(h.length,i.length);g1||b[0]||v(d,c)){sb(a.doc,b,d,c,"+input");return true}},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){if(this.composing&&!this.composing.handled){this.applyComposition(this.composing);this.composing.handled=true;this.div.blur();this.div.focus()}},applyComposition:function(a){a.data&& +a.data!=a.startData&&B(this.cm,Kc)(this.cm,a.data,0,a.sel)},setUneditable:function(a){a.setAttribute("contenteditable","false")},onKeyPress:function(a){a.preventDefault();B(this.cm,Kc)(this.cm,String.fromCharCode(a.charCode==null?a.keyCode:a.charCode),0)},onContextMenu:Ab,resetPosition:Ab,needsContentAttribute:!0},Mc.prototype);m.inputStyles={textarea:Lc,contenteditable:Mc};ha.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=0&&v(a,d.to())<=0)return c}return-1}};w.prototype={from:function(){return Mb(this.anchor,this.head)},to:function(){return Lb(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Tc={left:0,right:0,top:0,bottom:0},Ba,Pa=null,yf=0,bc,ac,ke=0,cc=0,O=null;y?O=-0.53:sa?O=15:dg?O=-0.7:le&&(O=-1/3);var re=function(a){var b= +a.wheelDeltaX,c=a.wheelDeltaY;if(b==null&&a.detail&&a.axis==a.HORIZONTAL_AXIS)b=a.detail;if(c==null&&a.detail&&a.axis==a.VERTICAL_AXIS)c=a.detail;else if(c==null)c=a.wheelDelta;return{x:b,y:c}};m.wheelEventPixels=function(a){a=re(a);a.x=a.x*O;a.y=a.y*O;return a};var Jf=new Ya,dd=null,pa=m.changeEnd=function(a){return!a.text?a.to:o(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();this.display.input.focus()},setOption:function(a, +b){var c=this.options,d=c[a];if(!(c[a]==b&&a!="mode")){c[a]=b;Ga.hasOwnProperty(a)&&B(this,Ga[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"](kc(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;cc){lb(this,e.head.line,a,true);c=e.head.line;d==this.doc.sel.primIndex&&La(this)}}else{for(var f=e.from(),e=e.to(),g=Math.max(c,f.line),c=Math.min(this.lastLine(),e.line-(e.ch?0:1))+1,e=g;e0)&&Pc(this.doc,d,new w(f,e[d].to()),ca)}}}),getTokenAt:function(a,b){return Re(this,a,b)},getLineTokens:function(a,b){return Re(this,o(a),b,true)},getTokenTypeAt:function(a){var a= +t(this.doc,a),b=Te(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]d){a=d;c=true}d=r(this.doc,a)}else d=a;return Vc(this,d,{top:0,left:0},b||"page").top+(c?this.doc.height-ga(d):0)},defaultTextHeight:function(){return ta(this.display)},defaultCharWidth:function(){return cb(this.display)},setGutterMarker:J(function(a,b,c){return ic(this.doc,a,"gutter",function(a){var e=a.gutterMarkers||(a.gutterMarkers={});e[b]=c;if(!c&&af(e))a.gutterMarkers=null;return true})}),clearGutter:J(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;ja(b,d,"gutter");if(af(c.gutterMarkers))c.gutterMarkers=null}++d})}),lineInfo:function(a){if(typeof a=="number"){if(!mb(this.doc,a))return null;var b=a,a=r(this.doc,a);if(!a)return null}else{b=C(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=ia(this,t(this.doc,a)),g=a.bottom,h=a.left;b.style.position="absolute";b.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(b);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=Zb(this,h,g,h+b.offsetWidth,g+b.offsetHeight);a.scrollTop!=null&&hb(this,a.scrollTop);a.scrollLeft!=null&&Ia(this,a.scrollLeft)}},triggerOnKeyDown:J(ne),triggerOnKeyPress:J(oe),triggerOnKeyUp:me,execCommand:function(a){if(ec.hasOwnProperty(a))return ec[a](this)}, +findPosH:function(a,b,c,d){var e=1;if(b<0){e=-1;b=-b}for(var f=0,a=t(this.doc,a);f0&&f(b.charAt(c-1));)--c;for(;d0.5)&&vc(this);F(this,"refresh",this)}),swapDoc:J(function(a){var b=this.doc;b.cm=null;wd(this,a);db(this);this.display.input.reset(); +this.scrollTo(a.scrollLeft,a.scrollTop);this.curOp.forceScroll=true;H(this,"swapDoc",this,b);return b}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};Ua(m);var jf=m.defaults={},Ga=m.optionHandlers={},xd=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;uc(a)},!0);u("indentUnit",2,uc,!0);u("indentWithTabs",!1);u("smartIndent",!0);u("tabSize",4,function(a){ab(a);db(a);N(a)},!0);u("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b,c){a.state.specialChars=RegExp(b.source+(b.test("\t")?"":"|\t"),"g");c!=m.Init&&a.refresh()});u("specialCharPlaceholder",function(a){var b=q("span","•","cm-invalidchar");b.title="\\u"+a.charCodeAt(0).toString(16);b.setAttribute("aria-label",b.title); +return b},function(a){a.refresh()},!0);u("electricChars",!0);u("inputStyle",Xa?"contenteditable":"textarea",function(){throw Error("inputStyle can not (yet) be changed in a running editor");},!0);u("rtlMoveVisually",!fg);u("wholeLineUpdateBefore",!0);u("theme","default",function(a){td(a);eb(a)},!0);u("keyMap","default",function(a,b,c){b=kc(b);(c=c!=m.Init&&kc(c))&&c.detach&&c.detach(a,b);b.attach&&b.attach(a,c||null)});u("extraKeys",null);u("lineWrapping",!1,function(a){if(a.options.lineWrapping){ib(a.display.wrapper, +"CodeMirror-wrap");a.display.sizer.style.minWidth="";a.display.sizerWidth=null}else{gb(a.display.wrapper,"CodeMirror-wrap");yc(a)}vc(a);N(a);db(a);setTimeout(function(){Ja(a)},100)},!0);u("gutters",[],function(a){rc(a.options);eb(a)},!0);u("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?Cc(a.display)+"px":"0";a.refresh()},!0);u("coverGutterNextToScrollbar",!1,function(a){Ja(a)},!0);u("scrollbarStyle","native",function(a){ud(a);Ja(a);a.display.scrollbars.setScrollTop(a.doc.scrollTop); +a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0);u("lineNumbers",!1,function(a){rc(a.options);eb(a)},!0);u("firstLineNumber",1,eb,!0);u("lineNumberFormatter",function(a){return a},eb,!0);u("showCursorWhenSelecting",!1,jb,!0);u("resetSelectionOnContextMenu",!0);u("lineWiseCopyCut",!0);u("readOnly",!1,function(a,b){if(b=="nocursor"){$a(a);a.display.input.blur();a.display.disabled=true}else{a.display.disabled=false;b||a.display.input.reset()}});u("disableInput",!1,function(a,b){b||a.display.input.reset()}, +!0);u("dragDrop",!0,function(a,b,c){if(!b!=!(c&&c!=m.Init)){c=a.display.dragFunctions;b=b?p:fa;b(a.display.scroller,"dragstart",c.start);b(a.display.scroller,"dragenter",c.simple);b(a.display.scroller,"dragover",c.simple);b(a.display.scroller,"drop",c.drop)}});u("cursorBlinkRate",530);u("cursorScrollMargin",0);u("cursorHeight",1,jb,!0);u("singleCursorHeightPerLine",!0,jb,!0);u("workTime",100);u("workDelay",100);u("flattenSpans",!0,ab,!0);u("addModeClass",!1,ab,!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,ab,!0);u("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()});u("tabindex",null,function(a,b){a.display.input.getField().tabIndex=b||""});u("autofocus",null);var hf=m.modes={},Db=m.mimeModes={};m.defineMode=function(a,b){if(!m.defaults.mode&&a!="null")m.defaults.mode=a;if(arguments.length>2)b.dependencies=Array.prototype.slice.call(arguments, +2);hf[a]=b};m.defineMIME=function(a,b){Db[a]=b};m.resolveMode=function(a){if(typeof a=="string"&&Db.hasOwnProperty(a))a=Db[a];else if(a&&typeof a.name=="string"&&Db.hasOwnProperty(a.name)){var b=Db[a.name];typeof b=="string"&&(b={name:b});a=Ze(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=hf[b.name];if(!c)return m.getMode(a, +"text/plain");c=c(a,b);if(Eb.hasOwnProperty(b.name)){var d=Eb[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 Eb=m.modeExtensions={};m.extendMode=function(a,b){var c=Eb.hasOwnProperty(a)?Eb[a]:Eb[a]={};S(b,c)};m.defineExtension= +function(a,b){m.prototype[a]=b};m.defineDocExtension=function(a,b){M.prototype[a]=b};m.defineOption=u;var tc=[];m.defineInitHook=function(a){tc.push(a)};var Wa=m.helpers={};m.registerHelper=function(a,b,c){Wa.hasOwnProperty(a)||(Wa[a]=m[a]={_global:[]});Wa[a][b]=c};m.registerGlobalHelper=function(a,b,c,d){m.registerHelper(a,b,d);Wa[a]._global.push({pred:c,val:d})};var Oa=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},wf=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 ec=m.commands={selectAll:function(a){a.setSelection(o(a.firstLine(),0),o(a.lastLine()),ca)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),ca)},killLine:function(a){Ra(a,function(b){if(b.empty()){var c=r(a.doc, +b.head.line).text.length;return b.head.ch==c&&b.head.line0){e=new o(e.line,e.ch+1);a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),o(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),o(e.line-1,g.length-1),o(e.line,1),"+transpose")}}c.push(new w(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){Q(a,function(){for(var b=a.listSelections().length,c=0;c=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.posb},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.lastColumnPos0)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 kd=0,Da=m.TextMarker=function(a,b){this.lines=[];this.type=b;this.doc=a;this.id=++kd};Ua(Da);Da.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b= +a&&!a.curOp;b&&Fa(a);if(P(this,"clear")){var c=this.find();c&&H(this,"clear",c.from,c.to)}for(var d=c=null,e=0;ea.display.maxLineLength){a.display.maxLine=f;a.display.maxLineLength=g;a.display.maxLineChanged=true}}c!=null&&(a&&this.collapsed)&&N(a,c,d+1);this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=false;a&&Zd(a.doc)}a&&H(a,"markerCleared",a,this);b&&Ha(a);this.parent&&this.parent.clear()}};Da.prototype.find=function(a,b){a==null&&this.type=="bookmark"&&(a=1);for(var c,d,e=0;e1||!(this.children[0]instanceof xb))){c=[];this.collapse(c);this.children=[new xb(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;d50){for(;e.lines.length>50;){a=e.lines.splice(e.lines.length-25,25);a=new xb(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 yb(b);if(a.parent){a.size=a.size-b.size;a.height=a.height-b.height;var c=G(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else{c=new yb(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=0;f--)Ka(this,d[f]);b?Ud(this,b):this.cm&&La(this.cm)}),undo:K(function(){gc(this,"undo")}), +redo:K(function(){gc(this,"redo")}),undoSelection:K(function(){gc(this,"undo",true)}),redoSelection:K(function(){gc(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.ch))b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){var a=t(this,a),b=t(this,b),d=[],e=a.line;this.iter(a.line,b.line+1,function(f){if(f=f.markedSpans)for(var g=0;gh.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;ca){b=a;return true}a=a-d;++c});return t(this,o(c,b))},indexFromPos:function(a){var a=t(this,a),b=a.ch;if(a.lineb)b=a.from;if(a.to!=null&&a.toG(ig,Fb)&&(m.prototype[Fb]=function(a){return function(){return a.apply(this.doc,arguments)}}(M.prototype[Fb])); +Ua(M);var L=m.e_preventDefault=function(a){a.preventDefault?a.preventDefault():a.returnValue=false},jg=m.e_stopPropagation=function(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=true},ad=m.e_stop=function(a){L(a);jg(a)},p=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)}},fa=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=b)return e+(b-d);e=e+(f-d);e=e+(c-e%c);d=f+1}},qc=[""],Va=function(a){a.select()};Ma?Va=function(a){a.selectionStart=0;a.selectionEnd=a.value.length}:y&&(Va=function(a){try{a.select()}catch(b){}});var kg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,$e=m.isWordChar=function(a){return/\w/.test(a)||a>"€"&&(a.toUpperCase()!=a.toLowerCase()|| +kg.test(a))},bg=/[\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]/, +Aa;Aa=document.createRange?function(a,b,c,d){var e=document.createRange();e.setEnd(d||a,c);e.setStart(a,b);return e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}d.collapse(true);d.moveEnd("character",c);d.moveStart("character",b);return d};var Oc=m.contains=function(a,b){if(b.nodeType==3)b=b.parentNode;if(a.contains)return a.contains(b);do{if(b.nodeType==11)b=b.host;if(b==a)return true}while(b=b.parentNode)};y&&11>z&&(aa=function(){try{return document.activeElement}catch(a){return document.body}}); +var gb=m.rmClass=function(a,b){var c=a.className,d=Bb(b).exec(c);if(d){var e=c.slice(d.index+d[0].length);a.className=c.slice(0,d.index)+(e?d[1]+e:"")}},ib=m.addClass=function(a,b){var c=a.className;if(!Bb(b).test(c))a.className=a.className+((c?" ":"")+b)},vd=!1,Ef=function(){if(y&&z<9)return false;var a=q("div");return"draggable"in a||"dragDrop"in a}(),qd,nd,oa=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/)},gg=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},ue=function(){var a=q("div");if("oncopy"in a)return true;a.setAttribute("oncopy","return;"); +return typeof a.oncopy=="function"}(),Uc=null,ra={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=ra;(function(){for(var a=0;a<10;a++)ra[a+48]=ra[a+96]=""+a;for(a=65;a<=90;a++)ra[a]=String.fromCharCode(a);for(a=1;a<=12;a++)ra[a+111]=ra[a+63235]="F"+a})();var rb,$f=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,m;l