0?null:(l&&n!==!1&&(this.pos+=l[0].length),l)}var d=function(c){return h?c.toLowerCase():c};if(d(this.string.substr(this.pos,i.length))==d(i))return n!==!1&&(this.pos+=i.length),!0},ge.prototype.current=function(){return this.string.slice(this.start,this.pos)},ge.prototype.hideFirstChars=function(i,n){this.lineStart+=i;try{return n()}finally{this.lineStart-=i}},ge.prototype.lookAhead=function(i){var n=this.lineOracle;return n&&n.lookAhead(i)},ge.prototype.baseToken=function(){var i=this.lineOracle;return i&&i.baseToken(this.pos)};var Li=function(i,n){this.state=i,this.lookAhead=n},tr=function(i,n,h,l){this.state=n,this.doc=i,this.line=h,this.maxLookAhead=l||0,this.baseTokens=null,this.baseTokenPos=1};function Dn(i,n,h,l){var d=[i.state.modeGen],c={};Sn(i,n.text,i.doc.mode,h,function(w,L){return d.push(w,L)},c,l);for(var f=h.state,g=function(w){h.baseTokens=d;var L=i.state.overlays[w],S=1,z=0;h.state=!0,Sn(i,n.text,L.mode,h,function(P,te){for(var re=S;zP&&d.splice(S,1,P,d[S+1],Y),S+=2,z=Math.min(P,Y)}if(te)if(L.opaque)d.splice(re,S-re,P,"overlay "+te),S=re+2;else for(;rei.options.maxHighlightLength&&be(i.doc.mode,l.state),c=Dn(i,n,l);d&&(l.state=d),n.stateAfter=l.save(!d),n.styles=c.styles,c.classes?n.styleClasses=c.classes:n.styleClasses&&(n.styleClasses=null),h===i.doc.highlightFrontier&&(i.doc.modeFrontier=Math.max(i.doc.modeFrontier,++i.doc.highlightFrontier))}return n.styles}function on(i,n,h){var l=i.doc,d=i.display;if(!l.mode.startState)return new tr(l,!0,n);var c=function(_,w,L){for(var S,z,P=_.doc,te=L?-1:w-(_.doc.mode.innerMode?1e3:100),re=w;re>te;--re){if(re<=P.first)return P.first;var Y=X(P,re-1),ve=Y.stateAfter;if(ve&&(!L||re+(ve instanceof Li?ve.lookAhead:0)<=P.modeFrontier))return re;var $e=Xe(Y.text,null,_.options.tabSize);(z==null||S>$e)&&(z=re-1,S=$e)}return z}(i,n,h),f=c>l.first&&X(l,c-1).stateAfter,g=f?tr.fromSaved(l,f,c):new tr(l,tt(l.mode),c);return l.iter(c,n,function(_){cn(i,_.text,g);var w=g.line;_.stateAfter=w==n-1||w%5==0||w>=d.viewFrom&&wn.start)return c}throw new Error("Mode "+i.name+" failed to advance stream.")}tr.prototype.lookAhead=function(i){var n=this.doc.getLine(this.line+i);return n!=null&&i>this.maxLookAhead&&(this.maxLookAhead=i),n},tr.prototype.baseToken=function(i){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=i;)this.baseTokenPos+=2;var n=this.baseTokens[this.baseTokenPos+1];return{type:n&&n.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-i}},tr.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},tr.fromSaved=function(i,n,h){return n instanceof Li?new tr(i,be(i.mode,n.state),h,n.lookAhead):new tr(i,be(i.mode,n),h)},tr.prototype.save=function(i){var n=i!==!1?be(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Li(n,this.maxLookAhead):n};var Xr=function(i,n,h){this.start=i.start,this.end=i.pos,this.string=i.current(),this.type=n||null,this.state=h};function Lr(i,n,h,l){var d,c,f=i.doc,g=f.mode,_=X(f,(n=st(f,n)).line),w=on(i,n.line,h),L=new ge(_.text,i.options.tabSize,w);for(l&&(c=[]);(l||L.posi.options.maxHighlightLength?(g=!1,f&&cn(i,n,l,S.pos),S.pos=n.length,_=null):_=Ln(yr(h,S,l.state,z),c),z){var P=z[0].name;P&&(_="m-"+(_?P+" "+_:P))}if(!g||L!=_){for(;w=qe:gt.to>qe);(lt||(lt=[])).push(new ir(Wt,gt.from,hi?null:gt.to))}}return lt}(h,d,f),_=function(ze,qe,xt){var lt;if(ze)for(var Rt=0;Rt=qe:gt.to>qe)||gt.from==qe&&Wt.type=="bookmark"&&(!xt||gt.marker.insertLeft)){var hi=gt.from==null||(Wt.inclusiveLeft?gt.from<=qe:gt.from0&&g)for(var Ae=0;Aen)&&(!h||hr(h,c.marker)<0)&&(h=c.marker)}return h}function Hr(i,n,h,l,d){var c=X(i,n),f=$r&&c.markedSpans;if(f)for(var g=0;g=0&&S<=0||L<=0&&S>=0)&&(L<=0&&(_.marker.inclusiveRight&&d.inclusiveLeft?Ce(w.to,h)>=0:Ce(w.to,h)>0)||L>=0&&(_.marker.inclusiveRight&&d.inclusiveLeft?Ce(w.from,l)<=0:Ce(w.from,l)<0)))return!0}}}function Vi(i){for(var n;n=Hn(i);)i=n.find(-1,!0).line;return i}function mn(i,n){var h=X(i,n),l=Vi(h);return h==l?n:Ge(l)}function Tn(i,n){if(n>i.lastLine())return n;var h,l=X(i,n);if(!rr(i,l))return n;for(;h=pn(l);)l=h.find(1,!0).line;return Ge(l)+1}function rr(i,n){var h=$r&&n.markedSpans;if(h){for(var l=void 0,d=0;dn.maxLineLength&&(n.maxLineLength=d,n.maxLine=l)})}var Qt=function(i,n,h){this.text=i,Ir(this,n),this.height=h?h(this):1};function Et(i){i.parent=null,In(i)}Qt.prototype.lineNo=function(){return Ge(this)},yt(Qt);var ai={},yi={};function xi(i,n){if(!i||/^\s*$/.test(i))return null;var h=n.addModeClass?yi:ai;return h[i]||(h[i]=i.replace(/\S+/g,"cm-$&"))}function ri(i,n){var h=me("span",null,null,D?"padding-right: .1px":null),l={pre:me("pre",[h],"CodeMirror-line"),content:h,col:0,pos:0,cm:i,trailingSpace:!1,splitSpaces:i.getOption("lineWrapping")};n.measure={};for(var d=0;d<=(n.rest?n.rest.length:0);d++){var c=d?n.rest[d-1]:n.line,f=void 0;l.pos=0,l.addToken=Hi,un(i.display.measure)&&(f=de(c,i.doc.direction))&&(l.addToken=Tt(l.addToken,f)),l.map=[],nr(c,l,Rr(i,c,n!=i.display.externalMeasured&&Ge(c))),c.styleClasses&&(c.styleClasses.bgClass&&(l.bgClass=Ke(c.styleClasses.bgClass,l.bgClass||"")),c.styleClasses.textClass&&(l.textClass=Ke(c.styleClasses.textClass,l.textClass||""))),l.map.length==0&&l.map.push(0,0,l.content.appendChild(Br(i.display.measure))),d==0?(n.measure.map=l.map,n.measure.cache={}):((n.measure.maps||(n.measure.maps=[])).push(l.map),(n.measure.caches||(n.measure.caches=[])).push({}))}if(D){var g=l.content.lastChild;(/\bcm-tab\b/.test(g.className)||g.querySelector&&g.querySelector(".cm-tab"))&&(l.content.className="cm-tab-wrap-hack")}return Ye(i,"renderLine",i,n.line,l.pre),l.pre.className&&(l.textClass=Ke(l.pre.className,l.textClass||"")),l}function ji(i){var n=J("span","•","cm-invalidchar");return n.title="\\u"+i.charCodeAt(0).toString(16),n.setAttribute("aria-label",n.title),n}function Hi(i,n,h,l,d,c,f){if(n){var g,_=i.splitSpaces?function(ze,qe){if(ze.length>1&&!/ /.test(ze))return ze;for(var xt=qe,lt="",Rt=0;Rtw&&S.from<=w);z++);if(S.to>=L)return i(h,l,d,c,f,g,_);i(h,l.slice(0,S.to-w),d,c,null,g,_),c=null,l=l.slice(S.to-w),w=S.to}}}function Jt(i,n,h,l){var d=!l&&h.widgetNode;d&&i.map.push(i.pos,i.pos+n,d),!l&&i.cm.display.input.needsContentAttribute&&(d||(d=i.content.appendChild(document.createElement("span"))),d.setAttribute("cm-marker",h.id)),d&&(i.cm.display.input.setUneditable(d),i.content.appendChild(d)),i.pos+=n,i.trailingSpace=!1}function nr(i,n,h){var l=i.markedSpans,d=i.text,c=0;if(l)for(var f,g,_,w,L,S,z,P=d.length,te=0,re=1,Y="",ve=0;;){if(ve==te){_=w=L=g="",z=null,S=null,ve=1/0;for(var $e=[],Ae=void 0,He=0;Hete||qe.collapsed&&ze.to==te&&ze.from==te)){if(ze.to!=null&&ze.to!=te&&ve>ze.to&&(ve=ze.to,w=""),qe.className&&(_+=" "+qe.className),qe.css&&(g=(g?g+";":"")+qe.css),qe.startStyle&&ze.from==te&&(L+=" "+qe.startStyle),qe.endStyle&&ze.to==ve&&(Ae||(Ae=[])).push(qe.endStyle,ze.to),qe.title&&((z||(z={})).title=qe.title),qe.attributes)for(var xt in qe.attributes)(z||(z={}))[xt]=qe.attributes[xt];qe.collapsed&&(!S||hr(S.marker,qe)<0)&&(S=ze)}else ze.from>te&&ve>ze.from&&(ve=ze.from)}if(Ae)for(var lt=0;lt=P)break;for(var gt=Math.min(P,ve);;){if(Y){var Wt=te+Y.length;if(!S){var hi=Wt>gt?Y.slice(0,gt-te):Y;n.addToken(n,hi,f?f+_:_,L,te+hi.length==ve?w:"",g,z)}if(Wt>=gt){Y=Y.slice(gt-te),te=gt;break}te=Wt,L=""}Y=d.slice(c,c=h[re++]),f=xi(h[re++],n.cm.options)}}else for(var Zt=1;Zth)return{map:i.measure.maps[d],cache:i.measure.caches[d],before:!0}}}function Be(i,n,h,l){return dt(i,At(i,n),h,l)}function ct(i,n){if(n>=i.display.viewFrom&&n=h.lineN&&n2&&z.push((re.bottom+Y.top)/2-w.top)}}z.push(w.bottom-w.top)}}(i,n.view,n.rect),n.hasHeights=!0),c=function(g,_,w,L){var S,z=su(_.map,w,L),P=z.node,te=z.start,re=z.end,Y=z.collapse;if(P.nodeType==3){for(var ve=0;ve<4;ve++){for(;te&&ot(_.line.text.charAt(z.coverStart+te));)--te;for(;z.coverStart+re1}(hi))return Zt;var Ut=screen.logicalXDPI/screen.deviceXDPI,Yt=screen.logicalYDPI/screen.deviceYDPI;return{left:Zt.left*Ut,right:Zt.right*Ut,top:Zt.top*Yt,bottom:Zt.bottom*Yt}}(g.display.measure,S))}else{var $e;te>0&&(Y=L="right"),S=g.options.lineWrapping&&($e=P.getClientRects()).length>1?$e[L=="right"?$e.length-1:0]:P.getBoundingClientRect()}if(v&&M<9&&!te&&(!S||!S.left&&!S.right)){var Ae=P.parentNode.getClientRects()[0];S=Ae?{left:Ae.left,right:Ae.left+Zs(g.display),top:Ae.top,bottom:Ae.bottom}:ln}for(var He=S.top-_.rect.top,ze=S.bottom-_.rect.top,qe=(He+ze)/2,xt=_.view.measure.heights,lt=0;ltn)&&(d=(c=_-g)-1,n>=_&&(f="right")),d!=null){if(l=i[w+2],g==_&&h==(l.insertLeft?"left":"right")&&(f=h),h=="left"&&d==0)for(;w&&i[w-2]==i[w-3]&&i[w-1].insertLeft;)l=i[2+(w-=3)],f="left";if(h=="right"&&d==_-g)for(;w=0&&(h=i[d]).left==h.right;d--);return h}function ou(i){if(i.measure&&(i.measure.cache={},i.measure.heights=null,i.rest))for(var n=0;n=l.text.length?(_=l.text.length,w="before"):_<=0&&(_=0,w="after"),!g)return f(w=="before"?_-1:_,w=="before");function L(te,re,Y){return f(Y?te-1:te,g[re].level==1!=Y)}var S=R(g,_,w),z=H,P=L(_,S,w=="before");return z!=null&&(P.other=L(_,z,w!="before")),P}function uu(i,n){var h=0;n=st(i.doc,n),i.options.lineWrapping||(h=Zs(i.display)*n.ch);var l=X(i.doc,n.line),d=Q(l)+Vr(i.display);return{left:h,right:h,top:d,bottom:d+l.height}}function nh(i,n,h,l,d){var c=ne(i,n,h);return c.xRel=d,l&&(c.outside=l),c}function sh(i,n,h){var l=i.doc;if((h+=i.display.viewOffset)<0)return nh(l.first,0,null,-1,-1);var d=Ht(l,h),c=l.first+l.size-1;if(d>c)return nh(l.first+l.size-1,X(l,c).text.length,null,1,1);n<0&&(n=0);for(var f=X(l,d);;){var g=sg(i,f,d,n,h),_=$n(f,g.ch+(g.xRel>0||g.outside>0?1:0));if(!_)return g;var w=_.find(1);if(w.line==d)return w;f=X(l,d=w.line)}}function cu(i,n,h,l){l-=rh(n);var d=n.text.length,c=j(function(f){return dt(i,h,f-1).bottom<=l},d,0);return{begin:c,end:d=j(function(f){return dt(i,h,f).top>l},c,d)}}function pu(i,n,h,l){return h||(h=At(i,n)),cu(i,n,h,Ba(i,n,dt(i,h,l),"line").top)}function oh(i,n,h,l){return!(i.bottom<=h)&&(i.top>h||(l?i.left:i.right)>n)}function sg(i,n,h,l,d){d-=Q(n);var c=At(i,n),f=rh(n),g=0,_=n.text.length,w=!0,L=de(n,i.doc.direction);if(L){var S=(i.options.lineWrapping?ag:og)(i,n,h,c,L,l,d);g=(w=S.level!=1)?S.from:S.to-1,_=w?S.to:S.from-1}var z,P,te=null,re=null,Y=j(function(ze){var qe=dt(i,c,ze);return qe.top+=f,qe.bottom+=f,!!oh(qe,l,d,!1)&&(qe.top<=d&&qe.left<=l&&(te=ze,re=qe),!0)},g,_),ve=!1;if(re){var $e=l-re.left=He.bottom?1:0}return nh(h,Y=C(n.text,Y,1),P,ve,l-z)}function og(i,n,h,l,d,c,f){var g=j(function(S){var z=d[S],P=z.level!=1;return oh(bn(i,ne(h,P?z.to:z.from,P?"before":"after"),"line",n,l),c,f,!0)},0,d.length-1),_=d[g];if(g>0){var w=_.level!=1,L=bn(i,ne(h,w?_.from:_.to,w?"after":"before"),"line",n,l);oh(L,c,f,!0)&&L.top>f&&(_=d[g-1])}return _}function ag(i,n,h,l,d,c,f){var g=cu(i,n,l,f),_=g.begin,w=g.end;/\s/.test(n.text.charAt(w-1))&&w--;for(var L=null,S=null,z=0;z=w||P.to<=_)){var te=dt(i,l,P.level!=1?Math.min(w,P.to)-1:Math.max(_,P.from)).right,re=tere)&&(L=P,S=re)}}return L||(L=d[d.length-1]),L.from<_&&(L={from:_,to:L.to,level:L.level}),L.to>w&&(L={from:L.from,to:w,level:L.level}),L}function Ws(i){if(i.cachedTextHeight!=null)return i.cachedTextHeight;if(pi==null){pi=J("pre",null,"CodeMirror-line-like");for(var n=0;n<49;++n)pi.appendChild(document.createTextNode("x")),pi.appendChild(J("br"));pi.appendChild(document.createTextNode("x"))}ue(i.measure,pi);var h=pi.offsetHeight/50;return h>3&&(i.cachedTextHeight=h),q(i.measure),h||1}function Zs(i){if(i.cachedCharWidth!=null)return i.cachedCharWidth;var n=J("span","xxxxxxxxxx"),h=J("pre",[n],"CodeMirror-line-like");ue(i.measure,h);var l=n.getBoundingClientRect(),d=(l.right-l.left)/10;return d>2&&(i.cachedCharWidth=d),d||10}function ah(i){for(var n=i.display,h={},l={},d=n.gutters.clientLeft,c=n.gutters.firstChild,f=0;c;c=c.nextSibling,++f){var g=i.display.gutterSpecs[f].className;h[g]=c.offsetLeft+c.clientLeft+d,l[g]=c.clientWidth}return{fixedPos:lh(n),gutterTotalWidth:n.gutters.offsetWidth,gutterLeft:h,gutterWidth:l,wrapperWidth:n.wrapper.clientWidth}}function lh(i){return i.scroller.getBoundingClientRect().left-i.sizer.getBoundingClientRect().left}function mu(i){var n=Ws(i.display),h=i.options.lineWrapping,l=h&&Math.max(5,i.display.scroller.clientWidth/Zs(i.display)-3);return function(d){if(rr(i.doc,d))return 0;var c=0;if(d.widgets)for(var f=0;f0&&(_=X(i.doc,w.line).text).length==w.ch){var L=Xe(_,_.length,i.options.tabSize)-_.length;w=ne(w.line,Math.max(0,Math.round((c-qs(i.display).left)/Zs(i.display))-L))}return w}function _s(i,n){if(n>=i.display.viewTo||(n-=i.display.viewFrom)<0)return null;for(var h=i.display.view,l=0;ln)&&(d.updateLineNumbers=n),i.curOp.viewChanged=!0,n>=d.viewTo)$r&&mn(i.doc,n)d.viewFrom?os(i):(d.viewFrom+=l,d.viewTo+=l);else if(n<=d.viewFrom&&h>=d.viewTo)os(i);else if(n<=d.viewFrom){var c=Ra(i,h,h+l,1);c?(d.view=d.view.slice(c.index),d.viewFrom=c.lineN,d.viewTo+=l):os(i)}else if(h>=d.viewTo){var f=Ra(i,n,n,-1);f?(d.view=d.view.slice(0,f.index),d.viewTo=f.lineN):os(i)}else{var g=Ra(i,n,n,-1),_=Ra(i,h,h+l,1);g&&_?(d.view=d.view.slice(0,g.index).concat(Si(i,g.lineN,_.lineN)).concat(d.view.slice(_.index)),d.viewTo+=l):os(i)}var w=d.externalMeasured;w&&(h=d.lineN&&n=l.viewTo)){var c=l.view[_s(i,n)];if(c.node!=null){var f=c.changes||(c.changes=[]);jt(f,h)==-1&&f.push(h)}}}function os(i){i.display.viewFrom=i.display.viewTo=i.doc.first,i.display.view=[],i.display.viewOffset=0}function Ra(i,n,h,l){var d,c=_s(i,n),f=i.display.view;if(!$r||h==i.doc.first+i.doc.size)return{index:c,lineN:h};for(var g=i.display.viewFrom,_=0;_0){if(c==f.length-1)return null;d=g+f[c].size-n,c++}else d=g-n;n+=d,h+=d}for(;mn(i.doc,h)!=h;){if(c==(l<0?0:f.length-1))return null;h+=l*f[c-(l<0?1:0)].size,c+=l}return{index:c,lineN:h}}function fu(i){for(var n=i.display.view,h=0,l=0;l=i.display.viewTo||_.to().line0?f:i.defaultCharWidth())+"px"}if(l.other){var g=h.appendChild(J("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));g.style.display="",g.style.left=l.other.left+"px",g.style.top=l.other.top+"px",g.style.height=.85*(l.other.bottom-l.other.top)+"px"}}function Pa(i,n){return i.top-n.top||i.left-n.left}function lg(i,n,h){var l=i.display,d=i.doc,c=document.createDocumentFragment(),f=qs(i.display),g=f.left,_=Math.max(l.sizerWidth,gn(i)-l.sizer.offsetLeft)-f.right,w=d.direction=="ltr";function L(Ae,He,ze,qe){He<0&&(He=0),He=Math.round(He),qe=Math.round(qe),c.appendChild(J("div",null,"CodeMirror-selected","position: absolute; left: "+Ae+`px;
+ top: `+He+"px; width: "+(ze??_-Ae)+`px;
+ height: `+(qe-He)+"px"))}function S(Ae,He,ze){var qe,xt,lt=X(d,Ae),Rt=lt.text.length;function gt(Zt,Ut){return Na(i,ne(Ae,Zt),"div",lt,Ut)}function Wt(Zt,Ut,Yt){var Bt=pu(i,lt,null,Zt),di=Ut=="ltr"==(Yt=="after")?"left":"right";return gt(Yt=="after"?Bt.begin:Bt.end-(/\s/.test(lt.text.charAt(Bt.end-1))?2:1),di)[di]}var hi=de(lt,d.direction);return function(Zt,Ut,Yt,Bt){if(!Zt)return Bt(Ut,Yt,"ltr",0);for(var di=!1,Mt=0;MtUt||Ut==Yt&&qt.to==Ut)&&(Bt(Math.max(qt.from,Ut),Math.min(qt.to,Yt),qt.level==1?"rtl":"ltr",Mt),di=!0)}di||Bt(Ut,Yt,"ltr")}(hi,He||0,ze??Rt,function(Zt,Ut,Yt,Bt){var di=Yt=="ltr",Mt=gt(Zt,di?"left":"right"),qt=gt(Ut-1,di?"right":"left"),Nt=He==null&&Zt==0,ti=ze==null&&Ut==Rt,Cr=Bt==0,ui=!hi||Bt==hi.length-1;if(qt.top-Mt.top<=3){var ur=(w?ti:Nt)&&ui,cr=(w?Nt:ti)&&Cr?g:(di?Mt:qt).left,Ai=ur?_:(di?qt:Mt).right;L(cr,Mt.top,Ai-cr,Mt.bottom)}else{var kr,xn,pr,wn;di?(kr=w&&Nt&&Cr?g:Mt.left,xn=w?_:Wt(Zt,Yt,"before"),pr=w?g:Wt(Ut,Yt,"after"),wn=w&&ti&&ui?_:qt.right):(kr=w?Wt(Zt,Yt,"before"):g,xn=!w&&Nt&&Cr?_:Mt.right,pr=!w&&ti&&ui?g:qt.left,wn=w?Wt(Ut,Yt,"after"):_),L(kr,Mt.top,xn-kr,Mt.bottom),Mt.bottom0?n.blinker=setInterval(function(){i.hasFocus()||Ys(i),n.cursorDiv.style.visibility=(h=!h)?"":"hidden"},i.options.cursorBlinkRate):i.options.cursorBlinkRate<0&&(n.cursorDiv.style.visibility="hidden")}}function bu(i){i.hasFocus()||(i.display.input.focus(),i.state.focused||ph(i))}function ch(i){i.state.delayingBlurEvent=!0,setTimeout(function(){i.state.delayingBlurEvent&&(i.state.delayingBlurEvent=!1,i.state.focused&&Ys(i))},100)}function ph(i,n){i.state.delayingBlurEvent&&!i.state.draggingText&&(i.state.delayingBlurEvent=!1),i.options.readOnly!="nocursor"&&(i.state.focused||(Ye(i,"focus",i,n),i.state.focused=!0,A(i.display.wrapper,"CodeMirror-focused"),i.curOp||i.display.selForContextMenu==i.doc.sel||(i.display.input.reset(),D&&setTimeout(function(){return i.display.input.reset(!0)},20)),i.display.input.receivedFocus()),uh(i))}function Ys(i,n){i.state.delayingBlurEvent||(i.state.focused&&(Ye(i,"blur",i,n),i.state.focused=!1,Oe(i.display.wrapper,"CodeMirror-focused")),clearInterval(i.display.blinker),setTimeout(function(){i.state.focused||(i.display.shift=!1)},150))}function Ia(i){for(var n=i.display,h=n.lineDiv.offsetTop,l=Math.max(0,n.scroller.getBoundingClientRect().top),d=n.lineDiv.getBoundingClientRect().top,c=0,f=0;f.005||P<-.005)&&(di.display.sizerWidth){var re=Math.ceil(L/Zs(i.display));re>i.display.maxLineLength&&(i.display.maxLineLength=re,i.display.maxLine=g.line,i.display.maxLineChanged=!0)}}}Math.abs(c)>2&&(n.scroller.scrollTop+=c)}function vu(i){if(i.widgets)for(var n=0;n=f&&(c=Ht(n,Q(X(n,_))-i.wrapper.clientHeight),f=_)}return{from:c,to:Math.max(f,c+1)}}function mh(i,n){var h=i.display,l=Ws(i.display);n.top<0&&(n.top=0);var d=i.curOp&&i.curOp.scrollTop!=null?i.curOp.scrollTop:h.scroller.scrollTop,c=k(i),f={};n.bottom-n.top>c&&(n.bottom=n.top+c);var g=i.doc.height+xs(h),_=n.topg-l;if(n.topd+c){var L=Math.min(n.top,(w?g:n.bottom)-c);L!=d&&(f.scrollTop=L)}var S=i.options.fixedGutter?0:h.gutters.offsetWidth,z=i.curOp&&i.curOp.scrollLeft!=null?i.curOp.scrollLeft:h.scroller.scrollLeft-S,P=gn(i)-h.gutters.offsetWidth,te=n.right-n.left>P;return te&&(n.right=n.left+P),n.left<10?f.scrollLeft=0:n.leftP+z-3&&(f.scrollLeft=n.right+(te?0:10)-P),f}function fh(i,n){n!=null&&(za(i),i.curOp.scrollTop=(i.curOp.scrollTop==null?i.doc.scrollTop:i.curOp.scrollTop)+n)}function Gs(i){za(i);var n=i.getCursor();i.curOp.scrollToPos={from:n,to:n,margin:i.options.cursorScrollMargin}}function Mo(i,n,h){n==null&&h==null||za(i),n!=null&&(i.curOp.scrollLeft=n),h!=null&&(i.curOp.scrollTop=h)}function za(i){var n=i.curOp.scrollToPos;n&&(i.curOp.scrollToPos=null,yu(i,uu(i,n.from),uu(i,n.to),n.margin))}function yu(i,n,h,l){var d=mh(i,{left:Math.min(n.left,h.left),top:Math.min(n.top,h.top)-l,right:Math.max(n.right,h.right),bottom:Math.max(n.bottom,h.bottom)+l});Mo(i,d.scrollLeft,d.scrollTop)}function Oo(i,n){Math.abs(i.doc.scrollTop-n)<2||(m||bh(i,{top:n}),xu(i,n,!0),m&&bh(i),Bo(i,100))}function xu(i,n,h){n=Math.max(0,Math.min(i.display.scroller.scrollHeight-i.display.scroller.clientHeight,n)),(i.display.scroller.scrollTop!=n||h)&&(i.doc.scrollTop=n,i.display.scrollbars.setScrollTop(n),i.display.scroller.scrollTop!=n&&(i.display.scroller.scrollTop=n))}function Cs(i,n,h,l){n=Math.max(0,Math.min(n,i.display.scroller.scrollWidth-i.display.scroller.clientWidth)),(h?n==i.doc.scrollLeft:Math.abs(i.doc.scrollLeft-n)<2)&&!l||(i.doc.scrollLeft=n,Eu(i),i.display.scroller.scrollLeft!=n&&(i.display.scroller.scrollLeft=n),i.display.scrollbars.setScrollLeft(n))}function Fo(i){var n=i.display,h=n.gutters.offsetWidth,l=Math.round(i.doc.height+xs(i.display));return{clientHeight:n.scroller.clientHeight,viewHeight:n.wrapper.clientHeight,scrollWidth:n.scroller.scrollWidth,clientWidth:n.scroller.clientWidth,viewWidth:n.wrapper.clientWidth,barLeft:i.options.fixedGutter?h:0,docHeight:l,scrollHeight:l+Ur(i)+n.barHeight,nativeBarWidth:n.nativeBarWidth,gutterWidth:h}}var ks=function(i,n,h){this.cm=h;var l=this.vert=J("div",[J("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),d=this.horiz=J("div",[J("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");l.tabIndex=d.tabIndex=-1,i(l),i(d),he(l,"scroll",function(){l.clientHeight&&n(l.scrollTop,"vertical")}),he(d,"scroll",function(){d.clientWidth&&n(d.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,v&&M<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ks.prototype.update=function(i){var n=i.scrollWidth>i.clientWidth+1,h=i.scrollHeight>i.clientHeight+1,l=i.nativeBarWidth;if(h){this.vert.style.display="block",this.vert.style.bottom=n?l+"px":"0";var d=i.viewHeight-(n?l:0);this.vert.firstChild.style.height=Math.max(0,i.scrollHeight-i.clientHeight+d)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(n){this.horiz.style.display="block",this.horiz.style.right=h?l+"px":"0",this.horiz.style.left=i.barLeft+"px";var c=i.viewWidth-i.barLeft-(h?l:0);this.horiz.firstChild.style.width=Math.max(0,i.scrollWidth-i.clientWidth+c)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&i.clientHeight>0&&(l==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:h?l:0,bottom:n?l:0}},ks.prototype.setScrollLeft=function(i){this.horiz.scrollLeft!=i&&(this.horiz.scrollLeft=i),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},ks.prototype.setScrollTop=function(i){this.vert.scrollTop!=i&&(this.vert.scrollTop=i),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},ks.prototype.zeroWidthHack=function(){var i=ke&&!Re?"12px":"18px";this.horiz.style.height=this.vert.style.width=i,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new bt,this.disableVert=new bt},ks.prototype.enableZeroWidthBar=function(i,n,h){i.style.visibility="",n.set(1e3,function l(){var d=i.getBoundingClientRect();(h=="vert"?document.elementFromPoint(d.right-1,(d.top+d.bottom)/2):document.elementFromPoint((d.right+d.left)/2,d.bottom-1))!=i?i.style.visibility="hidden":n.set(1e3,l)})},ks.prototype.clear=function(){var i=this.horiz.parentNode;i.removeChild(this.horiz),i.removeChild(this.vert)};var jo=function(){};function Js(i,n){n||(n=Fo(i));var h=i.display.barWidth,l=i.display.barHeight;wu(i,n);for(var d=0;d<4&&h!=i.display.barWidth||l!=i.display.barHeight;d++)h!=i.display.barWidth&&i.options.lineWrapping&&Ia(i),wu(i,Fo(i)),h=i.display.barWidth,l=i.display.barHeight}function wu(i,n){var h=i.display,l=h.scrollbars.update(n);h.sizer.style.paddingRight=(h.barWidth=l.right)+"px",h.sizer.style.paddingBottom=(h.barHeight=l.bottom)+"px",h.heightForcer.style.borderBottom=l.bottom+"px solid transparent",l.right&&l.bottom?(h.scrollbarFiller.style.display="block",h.scrollbarFiller.style.height=l.bottom+"px",h.scrollbarFiller.style.width=l.right+"px"):h.scrollbarFiller.style.display="",l.bottom&&i.options.coverGutterNextToScrollbar&&i.options.fixedGutter?(h.gutterFiller.style.display="block",h.gutterFiller.style.height=l.bottom+"px",h.gutterFiller.style.width=n.gutterWidth+"px"):h.gutterFiller.style.display=""}jo.prototype.update=function(){return{bottom:0,right:0}},jo.prototype.setScrollLeft=function(){},jo.prototype.setScrollTop=function(){},jo.prototype.clear=function(){};var _u={native:ks,null:jo};function Cu(i){i.display.scrollbars&&(i.display.scrollbars.clear(),i.display.scrollbars.addClass&&Oe(i.display.wrapper,i.display.scrollbars.addClass)),i.display.scrollbars=new _u[i.options.scrollbarStyle](function(n){i.display.wrapper.insertBefore(n,i.display.scrollbarFiller),he(n,"mousedown",function(){i.state.focused&&setTimeout(function(){return i.display.input.focus()},0)}),n.setAttribute("cm-not-content","true")},function(n,h){h=="horizontal"?Cs(i,n):Oo(i,n)},i),i.display.scrollbars.addClass&&A(i.display.wrapper,i.display.scrollbars.addClass)}var hg=0;function Es(i){var n;i.curOp={cm:i,viewChanged:!1,startHeight:i.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++hg,markArrays:null},n=i.curOp,$i?$i.ops.push(n):n.ownsGroup=$i={ops:[n],delayedCallbacks:[]}}function As(i){var n=i.curOp;n&&function(h,l){var d=h.ownsGroup;if(d)try{(function(c){var f=c.delayedCallbacks,g=0;do{for(;g=h.viewTo)||h.maxLineChanged&&n.options.lineWrapping,i.update=i.mustUpdate&&new Va(n,i.mustUpdate&&{top:i.scrollTop,ensure:i.scrollToPos},i.forceUpdate)}function ug(i){i.updatedDisplay=i.mustUpdate&&gh(i.cm,i.update)}function cg(i){var n=i.cm,h=n.display;i.updatedDisplay&&Ia(n),i.barMeasure=Fo(n),h.maxLineChanged&&!n.options.lineWrapping&&(i.adjustWidthTo=Be(n,h.maxLine,h.maxLine.text.length).left+3,n.display.sizerWidth=i.adjustWidthTo,i.barMeasure.scrollWidth=Math.max(h.scroller.clientWidth,h.sizer.offsetLeft+i.adjustWidthTo+Ur(n)+n.display.barWidth),i.maxScrollLeft=Math.max(0,h.sizer.offsetLeft+i.adjustWidthTo-gn(n))),(i.updatedDisplay||i.selectionChanged)&&(i.preparedSelection=h.input.prepareSelection())}function pg(i){var n=i.cm;i.adjustWidthTo!=null&&(n.display.sizer.style.minWidth=i.adjustWidthTo+"px",i.maxScrollLeft1&&(re=!0)),$e.scrollLeft!=null&&(Cs(w,$e.scrollLeft),Math.abs(w.doc.scrollLeft-He)>1&&(re=!0)),!re)break}return P}(n,st(l,i.scrollToPos.from),st(l,i.scrollToPos.to),i.scrollToPos.margin);(function(w,L){if(!ht(w,"scrollCursorIntoView")){var S=w.display,z=S.sizer.getBoundingClientRect(),P=null,te=S.wrapper.ownerDocument;if(L.top+z.top<0?P=!0:L.bottom+z.top>(te.defaultView.innerHeight||te.documentElement.clientHeight)&&(P=!1),P!=null&&!le){var re=J("div","",null,`position: absolute;
+ top: `+(L.top-S.viewOffset-Vr(w.display))+`px;
+ height: `+(L.bottom-L.top+Ur(w)+S.barHeight)+`px;
+ left: `+L.left+"px; width: "+Math.max(2,L.right-L.left)+"px;");w.display.lineSpace.appendChild(re),re.scrollIntoView(P),w.display.lineSpace.removeChild(re)}}})(n,d)}var c=i.maybeHiddenMarkers,f=i.maybeUnhiddenMarkers;if(c)for(var g=0;g=i.display.viewTo)){var h=+new Date+i.options.workTime,l=on(i,n.highlightFrontier),d=[];n.iter(l.line,Math.min(n.first+n.size,i.display.viewTo+500),function(c){if(l.line>=i.display.viewFrom){var f=c.styles,g=c.text.length>i.options.maxHighlightLength?be(n.mode,l.state):null,_=Dn(i,c,l,!0);g&&(l.state=g),c.styles=_.styles;var w=c.styleClasses,L=_.classes;L?c.styleClasses=L:w&&(c.styleClasses=null);for(var S=!f||f.length!=c.styles.length||w!=L&&(!w||!L||w.bgClass!=L.bgClass||w.textClass!=L.textClass),z=0;!S&&zh)return Bo(i,i.options.workDelay),!0}),n.highlightFrontier=l.line,n.modeFrontier=Math.max(n.modeFrontier,l.line),d.length&&qr(i,function(){for(var c=0;c=h.viewFrom&&n.visible.to<=h.viewTo&&(h.updateLineNumbers==null||h.updateLineNumbers>=h.viewTo)&&h.renderedView==h.view&&fu(i)==0)return!1;Au(i)&&(os(i),n.dims=ah(i));var d=l.first+l.size,c=Math.max(n.visible.from-i.options.viewportMargin,l.first),f=Math.min(d,n.visible.to+i.options.viewportMargin);h.viewFromf&&h.viewTo-f<20&&(f=Math.min(d,h.viewTo)),$r&&(c=mn(i.doc,c),f=Tn(i.doc,f));var g=c!=h.viewFrom||f!=h.viewTo||h.lastWrapHeight!=n.wrapperHeight||h.lastWrapWidth!=n.wrapperWidth;(function(L,S,z){var P=L.display;P.view.length==0||S>=P.viewTo||z<=P.viewFrom?(P.view=Si(L,S,z),P.viewFrom=S):(P.viewFrom>S?P.view=Si(L,S,P.viewFrom).concat(P.view):P.viewFromz&&(P.view=P.view.slice(0,_s(L,z)))),P.viewTo=z})(i,c,f),h.viewOffset=Q(X(i.doc,h.viewFrom)),i.display.mover.style.top=h.viewOffset+"px";var _=fu(i);if(!g&&_==0&&!n.force&&h.renderedView==h.view&&(h.updateLineNumbers==null||h.updateLineNumbers>=h.viewTo))return!1;var w=gg(i);return _>4&&(h.lineDiv.style.display="none"),function(L,S,z){var P=L.display,te=L.options.lineNumbers,re=P.lineDiv,Y=re.firstChild;function ve(lt){var Rt=lt.nextSibling;return D&&ke&&L.display.currentWheelTarget==lt?lt.style.display="none":lt.parentNode.removeChild(lt),Rt}for(var $e=P.view,Ae=P.viewFrom,He=0;He<$e.length;He++){var ze=$e[He];if(!ze.hidden)if(ze.node&&ze.node.parentNode==re){for(;Y!=ze.node;)Y=ve(Y);var qe=te&&S!=null&&S<=Ae&&ze.lineNumber;ze.changes&&(jt(ze.changes,"gutter")>-1&&(qe=!1),Mn(L,ze,Ae,z)),qe&&(q(ze.lineNumber),ze.lineNumber.appendChild(document.createTextNode(Ze(L.options,Ae)))),Y=ze.node.nextSibling}else{var xt=qn(L,ze,Ae,z);re.insertBefore(xt,Y)}Ae+=ze.size}for(;Y;)Y=ve(Y)}(i,h.updateLineNumbers,n.dims),_>4&&(h.lineDiv.style.display=""),h.renderedView=h.view,function(L){if(L&&L.activeElt&&L.activeElt!=I(L.activeElt.ownerDocument)&&(L.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(L.activeElt.nodeName)&&L.anchorNode&&De(document.body,L.anchorNode)&&De(document.body,L.focusNode))){var S=L.activeElt.ownerDocument,z=S.defaultView.getSelection(),P=S.createRange();P.setEnd(L.anchorNode,L.anchorOffset),P.collapse(!1),z.removeAllRanges(),z.addRange(P),z.extend(L.focusNode,L.focusOffset)}}(w),q(h.cursorDiv),q(h.selectionDiv),h.gutters.style.height=h.sizer.style.minHeight=0,g&&(h.lastWrapHeight=n.wrapperHeight,h.lastWrapWidth=n.wrapperWidth,Bo(i,400)),h.updateLineNumbers=null,!0}function ku(i,n){for(var h=n.viewport,l=!0;;l=!1){if(l&&i.options.lineWrapping&&n.oldDisplayWidth!=gn(i))l&&(n.visible=Ha(i.display,i.doc,h));else if(h&&h.top!=null&&(h={top:Math.min(i.doc.height+xs(i.display)-k(i),h.top)}),n.visible=Ha(i.display,i.doc,h),n.visible.from>=i.display.viewFrom&&n.visible.to<=i.display.viewTo)break;if(!gh(i,n))break;Ia(i);var d=Fo(i);To(i),Js(i,d),yh(i,d),n.force=!1}n.signal(i,"update",i),i.display.viewFrom==i.display.reportedViewFrom&&i.display.viewTo==i.display.reportedViewTo||(n.signal(i,"viewportChange",i,i.display.viewFrom,i.display.viewTo),i.display.reportedViewFrom=i.display.viewFrom,i.display.reportedViewTo=i.display.viewTo)}function bh(i,n){var h=new Va(i,n);if(gh(i,h)){Ia(i),ku(i,h);var l=Fo(i);To(i),Js(i,l),yh(i,l),h.finish()}}function vh(i){var n=i.gutters.offsetWidth;i.sizer.style.marginLeft=n+"px",ni(i,"gutterChanged",i)}function yh(i,n){i.display.sizer.style.minHeight=n.docHeight+"px",i.display.heightForcer.style.top=n.docHeight+"px",i.display.gutters.style.height=n.docHeight+i.display.barHeight+Ur(i)+"px"}function Eu(i){var n=i.display,h=n.view;if(n.alignWidgets||n.gutters.firstChild&&i.options.fixedGutter){for(var l=lh(n)-n.scroller.scrollLeft+i.doc.scrollLeft,d=n.gutters.offsetWidth,c=l+"px",f=0;f=105&&(d.wrapper.style.clipPath="inset(0px)"),d.wrapper.setAttribute("translate","no"),v&&M<8&&(d.gutters.style.zIndex=-1,d.scroller.style.paddingRight=0),D||m&&Ee||(d.scroller.draggable=!0),i&&(i.appendChild?i.appendChild(d.wrapper):i(d.wrapper)),d.viewFrom=d.viewTo=n.first,d.reportedViewFrom=d.reportedViewTo=n.first,d.view=[],d.renderedView=null,d.externalMeasured=null,d.viewOffset=0,d.lastWrapHeight=d.lastWrapWidth=0,d.updateLineNumbers=null,d.nativeBarWidth=d.barHeight=d.barWidth=0,d.scrollbarsClipped=!1,d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null,d.alignWidgets=!1,d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null,d.maxLine=null,d.maxLineLength=0,d.maxLineChanged=!1,d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null,d.shift=!1,d.selForContextMenu=null,d.activeTouch=null,d.gutterSpecs=xh(l.gutters,l.lineNumbers),Du(d),h.init(d)}Va.prototype.signal=function(i,n){et(i,n)&&this.events.push(arguments)},Va.prototype.finish=function(){for(var i=0;ig.clientWidth,w=g.scrollHeight>g.clientHeight;if(l&&_||d&&w){if(d&&ke&&D){e:for(var L=n.target,S=f.view;L!=g;L=L.parentNode)for(var z=0;z=0&&Ce(i,l.to())<=0)return h}return-1};var li=function(i,n){this.anchor=i,this.head=n};function vn(i,n,h){var l=i&&i.options.selectionsMayTouch,d=n[h];n.sort(function(z,P){return Ce(z.from(),P.from())}),h=jt(n,d);for(var c=1;c0:_>=0){var w=kt(g.from(),f.from()),L=Dt(g.to(),f.to()),S=g.empty()?f.from()==f.head:g.from()==g.head;c<=h&&--h,n.splice(--c,2,new li(S?L:w,S?w:L))}}return new Qr(n,h)}function as(i,n){return new Qr([new li(i,n||i)],0)}function ls(i){return i.text?ne(i.from.line+i.text.length-1,$(i.text).length+(i.text.length==1?i.from.ch:0)):i.to}function $u(i,n){if(Ce(i,n.from)<0)return i;if(Ce(i,n.to)<=0)return ls(n);var h=i.line+n.text.length-(n.to.line-n.from.line)-1,l=i.ch;return i.line==n.to.line&&(l+=ls(n).ch-n.to.ch),ne(h,l)}function wh(i,n){for(var h=[],l=0;l1&&i.remove(g.line+1,te-1),i.insert(g.line+1,ve)}ni(i,"change",i,n)}function hs(i,n,h){(function l(d,c,f){if(d.linked)for(var g=0;gg-(i.cm?i.cm.options.historyEventDelay:500)||n.origin.charAt(0)=="*"))&&(c=function(w,L){return L?(ju(w.done),$(w.done)):w.done.length&&!$(w.done).ranges?$(w.done):w.done.length>1&&!w.done[w.done.length-2].ranges?(w.done.pop(),$(w.done)):void 0}(d,d.lastOp==l)))f=$(c.changes),Ce(n.from,n.to)==0&&Ce(n.from,f.to)==0?f.to=ls(n):c.changes.push(kh(i,n));else{var _=$(d.done);for(_&&_.ranges||Wa(i.sel,d.done),c={changes:[kh(i,n)],generation:d.generation},d.done.push(c);d.done.length>d.undoDepth;)d.done.shift(),d.done[0].ranges||d.done.shift()}d.done.push(h),d.generation=++d.maxGeneration,d.lastModTime=d.lastSelTime=g,d.lastOp=d.lastSelOp=l,d.lastOrigin=d.lastSelOrigin=n.origin,f||Ye(i,"historyAdded")}function yg(i,n,h,l){var d=i.history,c=l&&l.origin;h==d.lastSelOp||c&&d.lastSelOrigin==c&&(d.lastModTime==d.lastSelTime&&d.lastOrigin==c||function(f,g,_,w){var L=g.charAt(0);return L=="*"||L=="+"&&_.ranges.length==w.ranges.length&&_.somethingSelected()==w.somethingSelected()&&new Date-f.history.lastSelTime<=(f.cm?f.cm.options.historyEventDelay:500)}(i,c,$(d.done),n))?d.done[d.done.length-1]=n:Wa(n,d.done),d.lastSelTime=+new Date,d.lastSelOrigin=c,d.lastSelOp=h,l&&l.clearRedo!==!1&&ju(d.undone)}function Wa(i,n){var h=$(n);h&&h.ranges&&h.equals(i)||n.push(i)}function Nu(i,n,h,l){var d=n["spans_"+i.id],c=0;i.iter(Math.max(i.first,h),Math.min(i.first+i.size,l),function(f){f.markedSpans&&((d||(d=n["spans_"+i.id]={}))[c]=f.markedSpans),++c})}function xg(i){if(!i)return null;for(var n,h=0;h-1&&($(g)[S]=w[S],delete w[S])}}}return l}function Eh(i,n,h,l){if(l){var d=i.anchor;if(h){var c=Ce(n,d)<0;c!=Ce(h,d)<0?(d=n,n=h):c!=Ce(n,h)<0&&(n=h)}return new li(d,n)}return new li(h||n,n)}function Za(i,n,h,l,d){d==null&&(d=i.cm&&(i.cm.display.shift||i.extend)),dr(i,new Qr([Eh(i.sel.primary(),n,h,d)],0),l)}function Pu(i,n,h){for(var l=[],d=i.cm&&(i.cm.display.shift||i.extend),c=0;c=n.ch:g.to>n.ch))){if(d&&(Ye(_,"beforeCursorEnter"),_.explicitlyCleared)){if(c.markedSpans){--f;continue}break}if(!_.atomic)continue;if(h){var S=_.find(l<0?1:-1),z=void 0;if((l<0?L:w)&&(S=qu(i,S,-l,S&&S.line==n.line?c:null)),S&&S.line==n.line&&(z=Ce(S,h))&&(l<0?z<0:z>0))return Ks(i,S,n,l,d)}var P=_.find(l<0?-1:1);return(l<0?w:L)&&(P=qu(i,P,l,P.line==n.line?c:null)),P?Ks(i,P,n,l,d):null}}return n}function Ga(i,n,h,l,d){var c=l||1,f=Ks(i,n,h,c,d)||!d&&Ks(i,n,h,c,!0)||Ks(i,n,h,-c,d)||!d&&Ks(i,n,h,-c,!0);return f||(i.cantEdit=!0,ne(i.first,0))}function qu(i,n,h,l){return h<0&&n.ch==0?n.line>i.first?st(i,ne(n.line-1)):null:h>0&&n.ch==(l||X(i,n.line)).text.length?n.line0)){var re=[P,1],Y=Ce(te.from,z.from),ve=Ce(te.to,z.to);(Y<0||!S.inclusiveLeft&&!Y)&&re.push({from:te.from,to:z.from}),(ve>0||!S.inclusiveRight&&!ve)&&re.push({from:z.to,to:te.to}),w.splice.apply(w,re),P+=re.length-3}}return w}(i,n.from,n.to);if(l)for(var d=l.length-1;d>=0;--d)Yu(i,{from:l[d].from,to:l[d].to,text:d?[""]:n.text,origin:n.origin});else Yu(i,n)}}function Yu(i,n){if(n.text.length!=1||n.text[0]!=""||Ce(n.from,n.to)!=0){var h=wh(i,n);Bu(i,n,h,i.cm?i.cm.curOp.id:NaN),Po(i,n,h,Pn(i,n));var l=[];hs(i,function(d,c){c||jt(l,d.history)!=-1||(Ku(d.history,n),l.push(d.history)),Po(d,n,null,Pn(d,n))})}}function Ja(i,n,h){var l=i.cm&&i.cm.state.suppressEdits;if(!l||h){for(var d,c=i.history,f=i.sel,g=n=="undo"?c.done:c.undone,_=n=="undo"?c.undone:c.done,w=0;w=0;--P){var te=z(P);if(te)return te.v}}}}function Gu(i,n){if(n!=0&&(i.first+=n,i.sel=new Qr(O(i.sel.ranges,function(d){return new li(ne(d.anchor.line+n,d.anchor.ch),ne(d.head.line+n,d.head.ch))}),i.sel.primIndex),i.cm)){Or(i.cm,i.first,i.first-n,n);for(var h=i.cm.display,l=h.viewFrom;li.lastLine())){if(n.from.linec&&(n={from:n.from,to:ne(c,X(i,c).text.length),text:[n.text[0]],origin:n.origin}),n.removed=Qe(i,n.from,n.to),h||(h=wh(i,n)),i.cm?function(f,g,_){var w=f.doc,L=f.display,S=g.from,z=g.to,P=!1,te=S.line;f.options.lineWrapping||(te=Ge(Vi(X(w,S.line))),w.iter(te,z.line+1,function(Ae){if(Ae==L.maxLine)return P=!0,!0})),w.sel.contains(g.from,g.to)>-1&&Ct(f),Ch(w,g,_,mu(f)),f.options.lineWrapping||(w.iter(te,S.line+g.text.length,function(Ae){var He=Fe(Ae);He>L.maxLineLength&&(L.maxLine=Ae,L.maxLineLength=He,L.maxLineChanged=!0,P=!1)}),P&&(f.curOp.updateMaxLine=!0)),function(Ae,He){if(Ae.modeFrontier=Math.min(Ae.modeFrontier,He),!(Ae.highlightFrontierze;qe--){var xt=X(Ae,qe).stateAfter;if(xt&&(!(xt instanceof Li)||qe+xt.lookAhead1||!(this.children[0]instanceof Ho))){var g=[];this.collapse(g),this.children=[new Ho(g)],this.children[0].parent=this}},collapse:function(i){for(var n=0;n50){for(var f=d.lines.length%25+25,g=f;g10);i.parent.maybeSpill()}},iterN:function(i,n,h){for(var l=0;l0||f==0&&c.clearWhenEmpty!==!1)return c;if(c.replacedWith&&(c.collapsed=!0,c.widgetNode=me("span",[c.replacedWith],"CodeMirror-widget"),l.handleMouseEvents||c.widgetNode.setAttribute("cm-ignore-events","true"),l.insertLeft&&(c.widgetNode.insertLeft=!0)),c.collapsed){if(Hr(i,n.line,n,h,c)||n.line!=h.line&&Hr(i,h.line,n,h,c))throw new Error("Inserting collapsed marker partially overlapping an existing one");$r=!0}c.addToHistory&&Bu(i,{from:n,to:h,origin:"markText"},i.sel,NaN);var g,_=n.line,w=i.cm;if(i.iter(_,h.line+1,function(S){w&&c.collapsed&&!w.options.lineWrapping&&Vi(S)==w.display.maxLine&&(g=!0),c.collapsed&&_!=n.line&&Ne(S,0),function(z,P,te){var re=te&&window.WeakSet&&(te.markedSpans||(te.markedSpans=new WeakSet));re&&z.markedSpans&&re.has(z.markedSpans)?z.markedSpans.push(P):(z.markedSpans=z.markedSpans?z.markedSpans.concat([P]):[P],re&&re.add(z.markedSpans)),P.marker.attachLine(z)}(S,new ir(c,_==n.line?n.ch:null,_==h.line?h.ch:null),i.cm&&i.cm.curOp),++_}),c.collapsed&&i.iter(n.line,h.line+1,function(S){rr(i,S)&&Ne(S,0)}),c.clearOnEnter&&he(c,"beforeCursorEnter",function(){return c.clear()}),c.readOnly&&(Sr=!0,(i.history.done.length||i.history.undone.length)&&i.clearHistory()),c.collapsed&&(c.id=++ec,c.atomic=!0),w){if(g&&(w.curOp.updateMaxLine=!0),c.collapsed)Or(w,n.line,h.line+1);else if(c.className||c.startStyle||c.endStyle||c.css||c.attributes||c.title)for(var L=n.line;L<=h.line;L++)ss(w,L,"text");c.atomic&&Vu(w.doc),ni(w,"markerAdded",w,c)}return c}ds.prototype.clear=function(){if(!this.explicitlyCleared){var i=this.doc.cm,n=i&&!i.curOp;if(n&&Es(i),et(this,"clear")){var h=this.find();h&&ni(this,"clear",h.from,h.to)}for(var l=null,d=null,c=0;ci.display.maxLineLength&&(i.display.maxLine=w,i.display.maxLineLength=L,i.display.maxLineChanged=!0)}l!=null&&i&&this.collapsed&&Or(i,l,d+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,i&&Vu(i.doc)),i&&ni(i,"markerCleared",i,this,l,d),n&&As(i),this.parent&&this.parent.clear()}},ds.prototype.find=function(i,n){var h,l;i==null&&this.type=="bookmark"&&(i=1);for(var d=0;d=0;_--)Qs(this,l[_]);g?Hu(this,g):this.cm&&Gs(this.cm)}),undo:Ki(function(){Ja(this,"undo")}),redo:Ki(function(){Ja(this,"redo")}),undoSelection:Ki(function(){Ja(this,"undo",!0)}),redoSelection:Ki(function(){Ja(this,"redo",!0)}),setExtending:function(i){this.extend=i},getExtending:function(){return this.extend},historySize:function(){for(var i=this.history,n=0,h=0,l=0;l=i.ch)&&n.push(d.marker.parent||d.marker)}return n},findMarks:function(i,n,h){i=st(this,i),n=st(this,n);var l=[],d=i.line;return this.iter(i.line,n.line+1,function(c){var f=c.markedSpans;if(f)for(var g=0;g=_.to||_.from==null&&d!=i.line||_.from!=null&&d==n.line&&_.from>=n.ch||h&&!h(_.marker)||l.push(_.marker.parent||_.marker)}++d}),l},getAllMarks:function(){var i=[];return this.iter(function(n){var h=n.markedSpans;if(h)for(var l=0;li)return n=i,!0;i-=c,++h}),st(this,ne(h,n))},indexFromPos:function(i){var n=(i=st(this,i)).ch;if(i.linen&&(n=i.from),i.to!=null&&i.to-1)return n.state.draggingText(i),void setTimeout(function(){return n.display.input.focus()},20);try{var L=i.dataTransfer.getData("Text");if(L){var S;if(n.state.draggingText&&!n.state.draggingText.copy&&(S=n.listSelections()),Ya(n.doc,as(h,h)),S)for(var z=0;z=0;g--)eo(i.doc,"",l[g].from,l[g].to,"+delete");Gs(i)})}function Dh(i,n,h){var l=C(i.text,n+h,h);return l<0||l>i.text.length?null:l}function Lh(i,n,h){var l=Dh(i,n.ch,h);return l==null?null:new ne(n.line,l,h<0?"after":"before")}function Sh(i,n,h,l,d){if(i){n.doc.direction=="rtl"&&(d=-d);var c=de(h,n.doc.direction);if(c){var f,g=d<0?$(c):c[0],_=d<0==(g.level==1)?"after":"before";if(g.level>0||n.doc.direction=="rtl"){var w=At(n,h);f=d<0?h.text.length-1:0;var L=dt(n,w,f).top;f=j(function(S){return dt(n,w,S).top==L},d<0==(g.level==1)?g.from:g.to-1,f),_=="before"&&(f=Dh(h,f,1))}else f=d<0?g.to:g.from;return new ne(l,f,_)}}return new ne(l,d<0?h.text.length:0,d<0?"before":"after")}Yn.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"},Yn.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","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"},Yn.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Yn.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","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":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Yn.default=ke?Yn.macDefault:Yn.pcDefault;var Zo={selectAll:Wu,singleSelection:function(i){return i.setSelection(i.getCursor("anchor"),i.getCursor("head"),Gt)},killLine:function(i){return ro(i,function(n){if(n.empty()){var h=X(i.doc,n.head.line).text.length;return n.head.ch==h&&n.head.line0)d=new ne(d.line,d.ch+1),i.replaceRange(c.charAt(d.ch-1)+c.charAt(d.ch-2),ne(d.line,d.ch-2),d,"+transpose");else if(d.line>i.doc.first){var f=X(i.doc,d.line-1).text;f&&(d=new ne(d.line,1),i.replaceRange(c.charAt(0)+i.doc.lineSeparator()+f.charAt(f.length-1),ne(d.line-1,f.length-1),d,"+transpose"))}}h.push(new li(d,d))}i.setSelections(h)})},newlineAndIndent:function(i){return qr(i,function(){for(var n=i.listSelections(),h=n.length-1;h>=0;h--)i.replaceRange(i.doc.lineSeparator(),n[h].anchor,n[h].head,"+input");n=i.listSelections();for(var l=0;l-1&&(Ce((L=z.ranges[L]).from(),g)<0||g.xRel>0)&&(Ce(L.to(),g)>0||g.xRel<0)?function(P,te,re,Y){var ve=P.display,$e=!1,Ae=Xi(P,function(qe){D&&(ve.scroller.draggable=!1),P.state.draggingText=!1,P.state.delayingBlurEvent&&(P.hasFocus()?P.state.delayingBlurEvent=!1:ch(P)),Me(ve.wrapper.ownerDocument,"mouseup",Ae),Me(ve.wrapper.ownerDocument,"mousemove",He),Me(ve.scroller,"dragstart",ze),Me(ve.scroller,"drop",Ae),$e||($t(qe),Y.addNew||Za(P.doc,re,null,null,Y.extend),D&&!Ie||v&&M==9?setTimeout(function(){ve.wrapper.ownerDocument.body.focus({preventScroll:!0}),ve.input.focus()},20):ve.input.focus())}),He=function(qe){$e=$e||Math.abs(te.clientX-qe.clientX)+Math.abs(te.clientY-qe.clientY)>=10},ze=function(){return $e=!0};D&&(ve.scroller.draggable=!0),P.state.draggingText=Ae,Ae.copy=!Y.moveOnDrag,he(ve.wrapper.ownerDocument,"mouseup",Ae),he(ve.wrapper.ownerDocument,"mousemove",He),he(ve.scroller,"dragstart",ze),he(ve.scroller,"drop",Ae),P.state.delayingBlurEvent=!0,setTimeout(function(){return ve.input.focus()},20),ve.scroller.dragDrop&&ve.scroller.dragDrop()}(f,w,g,S):function(P,te,re,Y){v&&ch(P);var ve=P.display,$e=P.doc;$t(te);var Ae,He,ze=$e.sel,qe=ze.ranges;if(Y.addNew&&!Y.extend?(He=$e.sel.contains(re),Ae=He>-1?qe[He]:new li(re,re)):(Ae=$e.sel.primary(),He=$e.sel.primIndex),Y.unit=="rectangle")Y.addNew||(Ae=new li(re,re)),re=ws(P,te,!0,!0),He=-1;else{var xt=bc(P,re,Y.unit);Ae=Y.extend?Eh(Ae,xt.anchor,xt.head,Y.extend):xt}Y.addNew?He==-1?(He=qe.length,dr($e,vn(P,qe.concat([Ae]),He),{scroll:!1,origin:"*mouse"})):qe.length>1&&qe[He].empty()&&Y.unit=="char"&&!Y.extend?(dr($e,vn(P,qe.slice(0,He).concat(qe.slice(He+1)),0),{scroll:!1,origin:"*mouse"}),ze=$e.sel):Ah($e,He,Ae,Ni):(He=0,dr($e,new Qr([Ae],0),Ni),ze=$e.sel);var lt=re;function Rt(Bt){if(Ce(lt,Bt)!=0)if(lt=Bt,Y.unit=="rectangle"){for(var di=[],Mt=P.options.tabSize,qt=Xe(X($e,re.line).text,re.ch,Mt),Nt=Xe(X($e,Bt.line).text,Bt.ch,Mt),ti=Math.min(qt,Nt),Cr=Math.max(qt,Nt),ui=Math.min(re.line,Bt.line),ur=Math.min(P.lastLine(),Math.max(re.line,Bt.line));ui<=ur;ui++){var cr=X($e,ui).text,Ai=ki(cr,ti,Mt);ti==Cr?di.push(new li(ne(ui,Ai),ne(ui,Ai))):cr.length>Ai&&di.push(new li(ne(ui,Ai),ne(ui,ki(cr,Cr,Mt))))}di.length||di.push(new li(re,re)),dr($e,vn(P,ze.ranges.slice(0,He).concat(di),He),{origin:"*mouse",scroll:!1}),P.scrollIntoView(Bt)}else{var kr,xn=Ae,pr=bc(P,Bt,Y.unit),wn=xn.anchor;Ce(pr.anchor,wn)>0?(kr=pr.head,wn=kt(xn.from(),pr.anchor)):(kr=pr.anchor,wn=Dt(xn.to(),pr.head));var nl=ze.ranges.slice(0);nl[He]=function(Sc,Ds){var Wr=Ds.anchor,cs=Ds.head,Og=X(Sc.doc,Wr.line);if(Ce(Wr,cs)==0&&Wr.sticky==cs.sticky)return Ds;var oo=de(Og);if(!oo)return Ds;var Bh=R(oo,Wr.ch,Wr.sticky),Ko=oo[Bh];if(Ko.from!=Wr.ch&&Ko.to!=Wr.ch)return Ds;var sl,Qo=Bh+(Ko.from==Wr.ch==(Ko.level!=1)?0:1);if(Qo==0||Qo==oo.length)return Ds;if(cs.line!=Wr.line)sl=(cs.line-Wr.line)*(Sc.doc.direction=="ltr"?1:-1)>0;else{var Nh=R(oo,cs.ch,cs.sticky),$c=Nh-Bh||(cs.ch-Wr.ch)*(Ko.level==1?-1:1);sl=Nh==Qo-1||Nh==Qo?$c<0:$c>0}var Rh=oo[Qo+(sl?-1:0)],Tc=sl==(Rh.level==1),Mc=Tc?Rh.from:Rh.to,Oc=Tc?"after":"before";return Wr.ch==Mc&&Wr.sticky==Oc?Ds:new li(new ne(Wr.line,Mc,Oc),cs)}(P,new li(st($e,wn),kr)),dr($e,vn(P,nl,He),Ni)}}var gt=ve.wrapper.getBoundingClientRect(),Wt=0;function hi(Bt){var di=++Wt,Mt=ws(P,Bt,!0,Y.unit=="rectangle");if(Mt)if(Ce(Mt,lt)!=0){P.curOp.focus=I(ut(P)),Rt(Mt);var qt=Ha(ve,$e);(Mt.line>=qt.to||Mt.linegt.bottom?20:0;Nt&&setTimeout(Xi(P,function(){Wt==di&&(ve.scroller.scrollTop+=Nt,hi(Bt))}),50)}}function Zt(Bt){P.state.selectingText=!1,Wt=1/0,Bt&&($t(Bt),ve.input.focus()),Me(ve.wrapper.ownerDocument,"mousemove",Ut),Me(ve.wrapper.ownerDocument,"mouseup",Yt),$e.history.lastSelOrigin=null}var Ut=Xi(P,function(Bt){Bt.buttons!==0&&br(Bt)?hi(Bt):Zt(Bt)}),Yt=Xi(P,Zt);P.state.selectingText=Yt,he(ve.wrapper.ownerDocument,"mousemove",Ut),he(ve.wrapper.ownerDocument,"mouseup",Yt)}(f,w,g,S)}(n,l,c,i):Oi(i)==h.scroller&&$t(i):d==2?(l&&Za(n.doc,l),setTimeout(function(){return h.input.focus()},20)):d==3&&(rt?n.display.input.onContextMenu(i):ch(n)))}}}function bc(i,n,h){if(h=="char")return new li(n,n);if(h=="word")return i.findWordAt(n);if(h=="line")return new li(ne(n.line,0),st(i.doc,ne(n.line+1,0)));var l=h(i,n);return new li(l.from,l.to)}function vc(i,n,h,l){var d,c;if(n.touches)d=n.touches[0].clientX,c=n.touches[0].clientY;else try{d=n.clientX,c=n.clientY}catch{return!1}if(d>=Math.floor(i.display.gutters.getBoundingClientRect().right))return!1;l&&$t(n);var f=i.display,g=f.lineDiv.getBoundingClientRect();if(c>g.bottom||!et(i,h))return si(n);c-=g.top-f.viewOffset;for(var _=0;_=d)return Ye(i,h,i,Ht(i.doc,c),i.display.gutterSpecs[_].className,n),si(n)}}function Mh(i,n){return vc(i,n,"gutterClick",!0)}function yc(i,n){Mr(i.display,n)||function(h,l){return et(h,"gutterContextMenu")?vc(h,l,"gutterContextMenu",!1):!1}(i,n)||ht(i,n,"contextmenu")||rt||i.display.input.onContextMenu(n)}function xc(i){i.display.wrapper.className=i.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+i.options.theme.replace(/(^|\s)\s*/g," cm-s-"),$o(i)}Th.prototype.compare=function(i,n,h){return this.time+400>i&&Ce(n,this.pos)==0&&h==this.button};var no={toString:function(){return"CodeMirror.Init"}},wc={},el={};function Sg(i,n,h){if(!n!=!(h&&h!=no)){var l=i.display.dragFunctions,d=n?he:Me;d(i.display.scroller,"dragstart",l.start),d(i.display.scroller,"dragenter",l.enter),d(i.display.scroller,"dragover",l.over),d(i.display.scroller,"dragleave",l.leave),d(i.display.scroller,"drop",l.drop)}}function $g(i){i.options.lineWrapping?(A(i.display.wrapper,"CodeMirror-wrap"),i.display.sizer.style.minWidth="",i.display.sizerWidth=null):(Oe(i.display.wrapper,"CodeMirror-wrap"),at(i)),hh(i),Or(i),$o(i),setTimeout(function(){return Js(i)},100)}function Ei(i,n){var h=this;if(!(this instanceof Ei))return new Ei(i,n);this.options=n=n?Ue(n):{},Ue(wc,n,!1);var l=n.value;typeof l=="string"?l=new Fr(l,n.mode,null,n.lineSeparator,n.direction):n.mode&&(l.modeOption=n.mode),this.doc=l;var d=new Ei.inputStyles[n.inputStyle](this),c=this.display=new bg(i,l,d,n);for(var f in c.wrapper.CodeMirror=this,xc(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Cu(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new bt,keySeq:null,specialChars:null},n.autofocus&&!Ee&&c.input.focus(),v&&M<11&&setTimeout(function(){return h.display.input.reset(!0)},20),function(_){var w=_.display;he(w.scroller,"mousedown",Xi(_,gc)),he(w.scroller,"dblclick",v&&M<11?Xi(_,function(Y){if(!ht(_,Y)){var ve=ws(_,Y);if(ve&&!Mh(_,Y)&&!Mr(_.display,Y)){$t(Y);var $e=_.findWordAt(ve);Za(_.doc,$e.anchor,$e.head)}}}):function(Y){return ht(_,Y)||$t(Y)}),he(w.scroller,"contextmenu",function(Y){return yc(_,Y)}),he(w.input.getField(),"contextmenu",function(Y){w.scroller.contains(Y.target)||yc(_,Y)});var L,S={end:0};function z(){w.activeTouch&&(L=setTimeout(function(){return w.activeTouch=null},1e3),(S=w.activeTouch).end=+new Date)}function P(Y){if(Y.touches.length!=1)return!1;var ve=Y.touches[0];return ve.radiusX<=1&&ve.radiusY<=1}function te(Y,ve){if(ve.left==null)return!0;var $e=ve.left-Y.left,Ae=ve.top-Y.top;return $e*$e+Ae*Ae>400}he(w.scroller,"touchstart",function(Y){if(!ht(_,Y)&&!P(Y)&&!Mh(_,Y)){w.input.ensurePolled(),clearTimeout(L);var ve=+new Date;w.activeTouch={start:ve,moved:!1,prev:ve-S.end<=300?S:null},Y.touches.length==1&&(w.activeTouch.left=Y.touches[0].pageX,w.activeTouch.top=Y.touches[0].pageY)}}),he(w.scroller,"touchmove",function(){w.activeTouch&&(w.activeTouch.moved=!0)}),he(w.scroller,"touchend",function(Y){var ve=w.activeTouch;if(ve&&!Mr(w,Y)&&ve.left!=null&&!ve.moved&&new Date-ve.start<300){var $e,Ae=_.coordsChar(w.activeTouch,"page");$e=!ve.prev||te(ve,ve.prev)?new li(Ae,Ae):!ve.prev.prev||te(ve,ve.prev.prev)?_.findWordAt(Ae):new li(ne(Ae.line,0),st(_.doc,ne(Ae.line+1,0))),_.setSelection($e.anchor,$e.head),_.focus(),$t(Y)}z()}),he(w.scroller,"touchcancel",z),he(w.scroller,"scroll",function(){w.scroller.clientHeight&&(Oo(_,w.scroller.scrollTop),Cs(_,w.scroller.scrollLeft,!0),Ye(_,"scroll",_))}),he(w.scroller,"mousewheel",function(Y){return Su(_,Y)}),he(w.scroller,"DOMMouseScroll",function(Y){return Su(_,Y)}),he(w.wrapper,"scroll",function(){return w.wrapper.scrollTop=w.wrapper.scrollLeft=0}),w.dragFunctions={enter:function(Y){ht(_,Y)||Kt(Y)},over:function(Y){ht(_,Y)||(function(ve,$e){var Ae=ws(ve,$e);if(Ae){var He=document.createDocumentFragment();dh(ve,Ae,He),ve.display.dragCursor||(ve.display.dragCursor=J("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),ve.display.lineSpace.insertBefore(ve.display.dragCursor,ve.display.cursorDiv)),ue(ve.display.dragCursor,He)}}(_,Y),Kt(Y))},start:function(Y){return function(ve,$e){if(v&&(!ve.state.draggingText||+new Date-ic<100))Kt($e);else if(!ht(ve,$e)&&!Mr(ve.display,$e)&&($e.dataTransfer.setData("Text",ve.getSelection()),$e.dataTransfer.effectAllowed="copyMove",$e.dataTransfer.setDragImage&&!Ie)){var Ae=J("img",null,null,"position: fixed; left: 0; top: 0;");Ae.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",we&&(Ae.width=Ae.height=1,ve.display.wrapper.appendChild(Ae),Ae._top=Ae.offsetTop),$e.dataTransfer.setDragImage(Ae,0,0),we&&Ae.parentNode.removeChild(Ae)}}(_,Y)},drop:Xi(_,Cg),leave:function(Y){ht(_,Y)||rc(_)}};var re=w.input.getField();he(re,"keyup",function(Y){return mc.call(_,Y)}),he(re,"keydown",Xi(_,pc)),he(re,"keypress",Xi(_,fc)),he(re,"focus",function(Y){return ph(_,Y)}),he(re,"blur",function(Y){return Ys(_,Y)})}(this),kg(),Es(this),this.curOp.forceUpdate=!0,Ou(this,l),n.autofocus&&!Ee||this.hasFocus()?setTimeout(function(){h.hasFocus()&&!h.state.focused&&ph(h)},20):Ys(this),el)el.hasOwnProperty(f)&&el[f](this,n[f],no);Au(this),n.finishInit&&n.finishInit(this);for(var g=0;g150)){if(!l)return;h="prev"}}else w=0,h="not";h=="prev"?w=n>c.first?Xe(X(c,n-1).text,null,f):0:h=="add"?w=_+i.options.indentUnit:h=="subtract"?w=_-i.options.indentUnit:typeof h=="number"&&(w=_+h),w=Math.max(0,w);var S="",z=0;if(i.options.indentWithTabs)for(var P=Math.floor(w/f);P;--P)z+=f,S+=" ";if(zf,_=ii(n),w=null;if(g&&l.ranges.length>1)if(yn&&yn.text.join(`
+`)==n){if(l.ranges.length%yn.text.length==0){w=[];for(var L=0;L=0;z--){var P=l.ranges[z],te=P.from(),re=P.to();P.empty()&&(h&&h>0?te=ne(te.line,te.ch-h):i.state.overwrite&&!g?re=ne(re.line,Math.min(X(c,re.line).text.length,re.ch+$(_).length)):g&&yn&&yn.lineWise&&yn.text.join(`
+`)==_.join(`
+`)&&(te=re=ne(te.line,0)));var Y={from:te,to:re,text:w?w[z%w.length]:_,origin:d||(g?"paste":i.state.cutIncoming>f?"cut":"+input")};Qs(i.doc,Y),ni(i,"inputRead",i,Y)}n&&!g&&Cc(i,n),Gs(i),i.curOp.updateInput<2&&(i.curOp.updateInput=S),i.curOp.typing=!0,i.state.pasteIncoming=i.state.cutIncoming=-1}function _c(i,n){var h=i.clipboardData&&i.clipboardData.getData("Text");if(h)return i.preventDefault(),n.isReadOnly()||n.options.disableInput||!n.hasFocus()||qr(n,function(){return Fh(n,h,0,null,"paste")}),!0}function Cc(i,n){if(i.options.electricChars&&i.options.smartIndent)for(var h=i.doc.sel,l=h.ranges.length-1;l>=0;l--){var d=h.ranges[l];if(!(d.head.ch>100||l&&h.ranges[l-1].head.line==d.head.line)){var c=i.getModeAt(d.head),f=!1;if(c.electricChars){for(var g=0;g-1){f=Xo(i,d.head.line,"smart");break}}else c.electricInput&&c.electricInput.test(X(i.doc,d.head.line).text.slice(0,d.head.ch))&&(f=Xo(i,d.head.line,"smart"));f&&ni(i,"electricInput",i,d.head.line)}}}function kc(i){for(var n=[],h=[],l=0;l0?0:-1));if(isNaN(He))$e=null;else{var ze=h>0?He>=55296&&He<56320:He>=56320&&He<57343;$e=new ne(n.line,Math.max(0,Math.min(g.text.length,n.ch+h*(ze?2:1))),-h)}}else $e=d?function(qe,xt,lt,Rt){var gt=de(xt,qe.doc.direction);if(!gt)return Lh(xt,lt,Rt);lt.ch>=xt.text.length?(lt.ch=xt.text.length,lt.sticky="before"):lt.ch<=0&&(lt.ch=0,lt.sticky="after");var Wt=R(gt,lt.ch,lt.sticky),hi=gt[Wt];if(qe.doc.direction=="ltr"&&hi.level%2==0&&(Rt>0?hi.to>lt.ch:hi.from=hi.from&&Mt>=Bt.begin)){var qt=di?"before":"after";return new ne(lt.line,Mt,qt)}}var Nt=function(ui,ur,cr){for(var Ai=function(wn,nl){return nl?new ne(lt.line,Ut(wn,1),"before"):new ne(lt.line,wn,"after")};ui>=0&&ui0==(kr.level!=1),pr=xn?cr.begin:Ut(cr.end,-1);if(kr.from<=pr&&pr0?Bt.end:Ut(Bt.begin,-1);return Cr==null||Rt>0&&Cr==xt.text.length||!(ti=Nt(Rt>0?0:gt.length-1,Rt,Yt(Cr)))?null:ti}(i.cm,g,n,h):Lh(g,n,h);if($e==null){if(ve||(Ae=n.line+_)=i.first+i.size||(n=new ne(Ae,n.ch,n.sticky),!(g=X(i,Ae))))return!1;n=Sh(d,i.cm,g,n.line,_)}else n=$e;return!0}if(l=="char"||l=="codepoint")w();else if(l=="column")w(!0);else if(l=="word"||l=="group")for(var L=null,S=l=="group",z=i.cm&&i.cm.getHelper(n,"wordChars"),P=!0;!(h<0)||w(!P);P=!1){var te=g.text.charAt(n.ch)||`
+`,re=_e(te,z)?"w":S&&te==`
+`?"n":!S||/\s/.test(te)?null:"p";if(!S||P||re||(re="s"),L&&L!=re){h<0&&(h=1,w(),n.sticky="after");break}if(re&&(L=re),h>0&&!w(!P))break}var Y=Ga(i,n,c,f,!0);return ft(c,Y)&&(Y.hitSide=!0),Y}function Dc(i,n,h,l){var d,c,f=i.doc,g=n.left;if(l=="page"){var _=Math.min(i.display.wrapper.clientHeight,wt(i).innerHeight||f(i).documentElement.clientHeight),w=Math.max(_-.5*Ws(i.display),3);d=(h>0?n.bottom:n.top)+h*w}else l=="line"&&(d=h>0?n.bottom+3:n.top-3);for(;(c=sh(i,g,d)).outside;){if(h<0?d<=0:d>=f.height){c.hitSide=!0;break}d+=5*h}return c}var fi=function(i){this.cm=i,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new bt,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Lc(i,n){var h=ct(i,n.line);if(!h||h.hidden)return null;var l=X(i.doc,n.line),d=Z(h,l,n.line),c=de(l,i.doc.direction),f="left";c&&(f=R(c,n.ch)%2?"right":"left");var g=su(d.map,n.ch,f);return g.offset=g.collapse=="right"?g.end:g.start,g}function so(i,n){return n&&(i.bad=!0),i}function il(i,n,h){var l;if(n==i.display.lineDiv){if(!(l=i.display.lineDiv.childNodes[h]))return so(i.clipPos(ne(i.display.viewTo-1)),!0);n=null,h=0}else for(l=n;;l=l.parentNode){if(!l||l==i.display.lineDiv)return null;if(l.parentNode&&l.parentNode==i.display.lineDiv)break}for(var d=0;d=n.display.viewTo||d.line=n.display.viewFrom&&Lc(n,l)||{node:g[0].measure.map[2],offset:0},w=d.linel.firstLine()&&(f=ne(f.line-1,X(l.doc,f.line-1).length)),g.ch==X(l.doc,g.line).text.length&&g.lined.viewTo-1)return!1;f.line==d.viewFrom||(i=_s(l,f.line))==0?(n=Ge(d.view[0].line),h=d.view[0].node):(n=Ge(d.view[i].line),h=d.view[i-1].node.nextSibling);var _,w,L=_s(l,g.line);if(L==d.view.length-1?(_=d.viewTo-1,w=d.lineDiv.lastChild):(_=Ge(d.view[L+1].line)-1,w=d.view[L+1].node.previousSibling),!h)return!1;for(var S=l.doc.splitLines(function(xt,lt,Rt,gt,Wt){var hi="",Zt=!1,Ut=xt.doc.lineSeparator(),Yt=!1;function Bt(Nt){return function(ti){return ti.id==Nt}}function di(){Zt&&(hi+=Ut,Yt&&(hi+=Ut),Zt=Yt=!1)}function Mt(Nt){Nt&&(di(),hi+=Nt)}function qt(Nt){if(Nt.nodeType==1){var ti=Nt.getAttribute("cm-text");if(ti)return void Mt(ti);var Cr,ui=Nt.getAttribute("cm-marker");if(ui){var ur=xt.findMarks(ne(gt,0),ne(Wt+1,0),Bt(+ui));return void(ur.length&&(Cr=ur[0].find(0))&&Mt(Qe(xt.doc,Cr.from,Cr.to).join(Ut)))}if(Nt.getAttribute("contenteditable")=="false")return;var cr=/^(pre|div|p|li|table|br)$/i.test(Nt.nodeName);if(!/^br$/i.test(Nt.nodeName)&&Nt.textContent.length==0)return;cr&&di();for(var Ai=0;Ai1&&z.length>1;)if($(S)==$(z))S.pop(),z.pop(),_--;else{if(S[0]!=z[0])break;S.shift(),z.shift(),n++}for(var P=0,te=0,re=S[0],Y=z[0],ve=Math.min(re.length,Y.length);Pf.ch&&$e.charCodeAt($e.length-te-1)==Ae.charCodeAt(Ae.length-te-1);)P--,te++;S[S.length-1]=$e.slice(0,$e.length-te).replace(/^\u200b+/,""),S[0]=S[0].slice(P).replace(/\u200b+$/,"");var ze=ne(n,P),qe=ne(_,z.length?$(z).length-te:0);return S.length>1||S[0]||Ce(ze,qe)?(eo(l.doc,S,ze,qe,"+input"),!0):void 0},fi.prototype.ensurePolled=function(){this.forceCompositionEnd()},fi.prototype.reset=function(){this.forceCompositionEnd()},fi.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},fi.prototype.readFromDOMSoon=function(){var i=this;this.readDOMTimeout==null&&(this.readDOMTimeout=setTimeout(function(){if(i.readDOMTimeout=null,i.composing){if(!i.composing.done)return;i.composing=null}i.updateFromDOM()},80))},fi.prototype.updateFromDOM=function(){var i=this;!this.cm.isReadOnly()&&this.pollContent()||qr(this.cm,function(){return Or(i.cm)})},fi.prototype.setUneditable=function(i){i.contentEditable="false"},fi.prototype.onKeyPress=function(i){i.charCode==0||this.composing||(i.preventDefault(),this.cm.isReadOnly()||Xi(this.cm,Fh)(this.cm,String.fromCharCode(i.charCode==null?i.keyCode:i.charCode),0))},fi.prototype.readOnlyChanged=function(i){this.div.contentEditable=String(i!="nocursor")},fi.prototype.onContextMenu=function(){},fi.prototype.resetPosition=function(){},fi.prototype.needsContentAttribute=!0;var Ri=function(i){this.cm=i,this.prevInput="",this.pollingFast=!1,this.polling=new bt,this.hasSelection=!1,this.composing=null,this.resetting=!1};Ri.prototype.init=function(i){var n=this,h=this,l=this.cm;this.createField(i);var d=this.textarea;function c(f){if(!ht(l,f)){if(l.somethingSelected())tl({lineWise:!1,text:l.getSelections()});else{if(!l.options.lineWiseCopyCut)return;var g=kc(l);tl({lineWise:!0,text:g.text}),f.type=="cut"?l.setSelections(g.ranges,null,Gt):(h.prevInput="",d.value=g.text.join(`
+`),Pe(d))}f.type=="cut"&&(l.state.cutIncoming=+new Date)}}i.wrapper.insertBefore(this.wrapper,i.wrapper.firstChild),ee&&(d.style.width="0px"),he(d,"input",function(){v&&M>=9&&n.hasSelection&&(n.hasSelection=null),h.poll()}),he(d,"paste",function(f){ht(l,f)||_c(f,l)||(l.state.pasteIncoming=+new Date,h.fastPoll())}),he(d,"cut",c),he(d,"copy",c),he(i.scroller,"paste",function(f){if(!Mr(i,f)&&!ht(l,f)){if(!d.dispatchEvent)return l.state.pasteIncoming=+new Date,void h.focus();var g=new Event("paste");g.clipboardData=f.clipboardData,d.dispatchEvent(g)}}),he(i.lineSpace,"selectstart",function(f){Mr(i,f)||$t(f)}),he(d,"compositionstart",function(){var f=l.getCursor("from");h.composing&&h.composing.range.clear(),h.composing={start:f,range:l.markText(f,l.getCursor("to"),{className:"CodeMirror-composing"})}}),he(d,"compositionend",function(){h.composing&&(h.poll(),h.composing.range.clear(),h.composing=null)})},Ri.prototype.createField=function(i){this.wrapper=Ac(),this.textarea=this.wrapper.firstChild},Ri.prototype.screenReaderLabelChanged=function(i){i?this.textarea.setAttribute("aria-label",i):this.textarea.removeAttribute("aria-label")},Ri.prototype.prepareSelection=function(){var i=this.cm,n=i.display,h=i.doc,l=gu(i);if(i.options.moveInputWithCursor){var d=bn(i,h.sel.primary().head,"div"),c=n.wrapper.getBoundingClientRect(),f=n.lineDiv.getBoundingClientRect();l.teTop=Math.max(0,Math.min(n.wrapper.clientHeight-10,d.top+f.top-c.top)),l.teLeft=Math.max(0,Math.min(n.wrapper.clientWidth-10,d.left+f.left-c.left))}return l},Ri.prototype.showSelection=function(i){var n=this.cm.display;ue(n.cursorDiv,i.cursors),ue(n.selectionDiv,i.selection),i.teTop!=null&&(this.wrapper.style.top=i.teTop+"px",this.wrapper.style.left=i.teLeft+"px")},Ri.prototype.reset=function(i){if(!(this.contextMenuPending||this.composing&&i)){var n=this.cm;if(this.resetting=!0,n.somethingSelected()){this.prevInput="";var h=n.getSelection();this.textarea.value=h,n.state.focused&&Pe(this.textarea),v&&M>=9&&(this.hasSelection=h)}else i||(this.prevInput=this.textarea.value="",v&&M>=9&&(this.hasSelection=null));this.resetting=!1}},Ri.prototype.getField=function(){return this.textarea},Ri.prototype.supportsTouch=function(){return!1},Ri.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!Ee||I(this.textarea.ownerDocument)!=this.textarea))try{this.textarea.focus()}catch{}},Ri.prototype.blur=function(){this.textarea.blur()},Ri.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Ri.prototype.receivedFocus=function(){this.slowPoll()},Ri.prototype.slowPoll=function(){var i=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){i.poll(),i.cm.state.focused&&i.slowPoll()})},Ri.prototype.fastPoll=function(){var i=!1,n=this;n.pollingFast=!0,n.polling.set(20,function h(){n.poll()||i?(n.pollingFast=!1,n.slowPoll()):(i=!0,n.polling.set(60,h))})},Ri.prototype.poll=function(){var i=this,n=this.cm,h=this.textarea,l=this.prevInput;if(this.contextMenuPending||this.resetting||!n.state.focused||Di(h)&&!l&&!this.composing||n.isReadOnly()||n.options.disableInput||n.state.keySeq)return!1;var d=h.value;if(d==l&&!n.somethingSelected())return!1;if(v&&M>=9&&this.hasSelection===d||ke&&/[\uf700-\uf7ff]/.test(d))return n.display.input.reset(),!1;if(n.doc.sel==n.display.selForContextMenu){var c=d.charCodeAt(0);if(c!=8203||l||(l=""),c==8666)return this.reset(),this.cm.execCommand("undo")}for(var f=0,g=Math.min(l.length,d.length);f1e3||d.indexOf(`
+`)>-1?h.value=i.prevInput="":i.prevInput=d,i.composing&&(i.composing.range.clear(),i.composing.range=n.markText(i.composing.start,n.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Ri.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Ri.prototype.onKeyPress=function(){v&&M>=9&&(this.hasSelection=null),this.fastPoll()},Ri.prototype.onContextMenu=function(i){var n=this,h=n.cm,l=h.display,d=n.textarea;n.contextMenuPending&&n.contextMenuPending();var c=ws(h,i),f=l.scroller.scrollTop;if(c&&!we){h.options.resetSelectionOnContextMenu&&h.doc.sel.contains(c)==-1&&Xi(h,dr)(h.doc,as(c),Gt);var g,_=d.style.cssText,w=n.wrapper.style.cssText,L=n.wrapper.offsetParent.getBoundingClientRect();if(n.wrapper.style.cssText="position: static",d.style.cssText=`position: absolute; width: 30px; height: 30px;
+ top: `+(i.clientY-L.top-5)+"px; left: "+(i.clientX-L.left-5)+`px;
+ z-index: 1000; background: `+(v?"rgba(255, 255, 255, .05)":"transparent")+`;
+ outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`,D&&(g=d.ownerDocument.defaultView.scrollY),l.input.focus(),D&&d.ownerDocument.defaultView.scrollTo(null,g),l.input.reset(),h.somethingSelected()||(d.value=n.prevInput=" "),n.contextMenuPending=P,l.selForContextMenu=h.doc.sel,clearTimeout(l.detectingSelectAll),v&&M>=9&&z(),rt){Kt(i);var S=function(){Me(window,"mouseup",S),setTimeout(P,20)};he(window,"mouseup",S)}else setTimeout(P,50)}function z(){if(d.selectionStart!=null){var te=h.somethingSelected(),re=""+(te?d.value:"");d.value="⇚",d.value=re,n.prevInput=te?"":"",d.selectionStart=1,d.selectionEnd=re.length,l.selForContextMenu=h.doc.sel}}function P(){if(n.contextMenuPending==P&&(n.contextMenuPending=!1,n.wrapper.style.cssText=w,d.style.cssText=_,v&&M<9&&l.scrollbars.setScrollTop(l.scroller.scrollTop=f),d.selectionStart!=null)){(!v||v&&M<9)&&z();var te=0,re=function(){l.selForContextMenu==h.doc.sel&&d.selectionStart==0&&d.selectionEnd>0&&n.prevInput==""?Xi(h,Wu)(h):te++<10?l.detectingSelectAll=setTimeout(re,500):(l.selForContextMenu=null,l.input.reset())};l.detectingSelectAll=setTimeout(re,200)}}},Ri.prototype.readOnlyChanged=function(i){i||this.reset(),this.textarea.disabled=i=="nocursor",this.textarea.readOnly=!!i},Ri.prototype.setUneditable=function(){},Ri.prototype.needsContentAttribute=!1,function(i){var n=i.optionHandlers;function h(l,d,c,f){i.defaults[l]=d,c&&(n[l]=f?function(g,_,w){w!=no&&c(g,_,w)}:c)}i.defineOption=h,i.Init=no,h("value","",function(l,d){return l.setValue(d)},!0),h("mode",null,function(l,d){l.doc.modeOption=d,_h(l)},!0),h("indentUnit",2,_h,!0),h("indentWithTabs",!1),h("smartIndent",!0),h("tabSize",4,function(l){Ro(l),$o(l),Or(l)},!0),h("lineSeparator",null,function(l,d){if(l.doc.lineSep=d,d){var c=[],f=l.doc.first;l.doc.iter(function(_){for(var w=0;;){var L=_.text.indexOf(d,w);if(L==-1)break;w=L+d.length,c.push(ne(f,L))}f++});for(var g=c.length-1;g>=0;g--)eo(l.doc,d,c[g],ne(c[g].line,c[g].ch+d.length))}}),h("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g,function(l,d,c){l.state.specialChars=new RegExp(d.source+(d.test(" ")?"":"| "),"g"),c!=no&&l.refresh()}),h("specialCharPlaceholder",ji,function(l){return l.refresh()},!0),h("electricChars",!0),h("inputStyle",Ee?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),h("spellcheck",!1,function(l,d){return l.getInputField().spellcheck=d},!0),h("autocorrect",!1,function(l,d){return l.getInputField().autocorrect=d},!0),h("autocapitalize",!1,function(l,d){return l.getInputField().autocapitalize=d},!0),h("rtlMoveVisually",!pe),h("wholeLineUpdateBefore",!0),h("theme","default",function(l){xc(l),No(l)},!0),h("keyMap","default",function(l,d,c){var f=Ka(d),g=c!=no&&Ka(c);g&&g.detach&&g.detach(l,f),f.attach&&f.attach(l,g||null)}),h("extraKeys",null),h("configureMouse",null),h("lineWrapping",!1,$g,!0),h("gutters",[],function(l,d){l.display.gutterSpecs=xh(d,l.options.lineNumbers),No(l)},!0),h("fixedGutter",!0,function(l,d){l.display.gutters.style.left=d?lh(l.display)+"px":"0",l.refresh()},!0),h("coverGutterNextToScrollbar",!1,function(l){return Js(l)},!0),h("scrollbarStyle","native",function(l){Cu(l),Js(l),l.display.scrollbars.setScrollTop(l.doc.scrollTop),l.display.scrollbars.setScrollLeft(l.doc.scrollLeft)},!0),h("lineNumbers",!1,function(l,d){l.display.gutterSpecs=xh(l.options.gutters,d),No(l)},!0),h("firstLineNumber",1,No,!0),h("lineNumberFormatter",function(l){return l},No,!0),h("showCursorWhenSelecting",!1,To,!0),h("resetSelectionOnContextMenu",!0),h("lineWiseCopyCut",!0),h("pasteLinesPerSelection",!0),h("selectionsMayTouch",!1),h("readOnly",!1,function(l,d){d=="nocursor"&&(Ys(l),l.display.input.blur()),l.display.input.readOnlyChanged(d)}),h("screenReaderLabel",null,function(l,d){d=d===""?null:d,l.display.input.screenReaderLabelChanged(d)}),h("disableInput",!1,function(l,d){d||l.display.input.reset()},!0),h("dragDrop",!0,Sg),h("allowDropFileTypes",null),h("cursorBlinkRate",530),h("cursorScrollMargin",0),h("cursorHeight",1,To,!0),h("singleCursorHeightPerLine",!0,To,!0),h("workTime",100),h("workDelay",100),h("flattenSpans",!0,Ro,!0),h("addModeClass",!1,Ro,!0),h("pollInterval",100),h("undoDepth",200,function(l,d){return l.doc.history.undoDepth=d}),h("historyEventDelay",1250),h("viewportMargin",10,function(l){return l.refresh()},!0),h("maxHighlightLength",1e4,Ro,!0),h("moveInputWithCursor",!0,function(l,d){d||l.display.input.resetPosition()}),h("tabindex",null,function(l,d){return l.display.input.getField().tabIndex=d||""}),h("autofocus",null),h("direction","ltr",function(l,d){return l.doc.setDirection(d)},!0),h("phrases",null)}(Ei),function(i){var n=i.optionHandlers,h=i.helpers={};i.prototype={constructor:i,focus:function(){wt(this).focus(),this.display.input.focus()},setOption:function(l,d){var c=this.options,f=c[l];c[l]==d&&l!="mode"||(c[l]=d,n.hasOwnProperty(l)&&Xi(this,n[l])(this,d,f),Ye(this,"optionChange",this,l))},getOption:function(l){return this.options[l]},getDoc:function(){return this.doc},addKeyMap:function(l,d){this.state.keyMaps[d?"push":"unshift"](Ka(l))},removeKeyMap:function(l){for(var d=this.state.keyMaps,c=0;cc&&(Xo(this,g.head.line,l,!0),c=g.head.line,f==this.doc.sel.primIndex&&Gs(this));else{var _=g.from(),w=g.to(),L=Math.max(c,_.line);c=Math.min(this.lastLine(),w.line-(w.ch?0:1))+1;for(var S=L;S0&&Ah(this.doc,f,new li(_,z[f].to()),Gt)}}}),getTokenAt:function(l,d){return Lr(this,l,d)},getLineTokens:function(l,d){return Lr(this,ne(l),d,!0)},getTokenTypeAt:function(l){l=st(this.doc,l);var d,c=Rr(this,X(this.doc,l.line)),f=0,g=(c.length-1)/2,_=l.ch;if(_==0)d=c[2];else for(;;){var w=f+g>>1;if((w?c[2*w-1]:0)>=_)g=w;else{if(!(c[2*w+1]<_)){d=c[2*w+2];break}f=w+1}}var L=d?d.indexOf("overlay "):-1;return L<0?d:L==0?null:d.slice(0,L-1)},getModeAt:function(l){var d=this.doc.mode;return d.innerMode?i.innerMode(d,this.getTokenAt(l).state).mode:d},getHelper:function(l,d){return this.getHelpers(l,d)[0]},getHelpers:function(l,d){var c=[];if(!h.hasOwnProperty(d))return c;var f=h[d],g=this.getModeAt(l);if(typeof g[d]=="string")f[g[d]]&&c.push(f[g[d]]);else if(g[d])for(var _=0;__&&(l=_,g=!0),f=X(this.doc,l)}else f=l;return Ba(this,f,{top:0,left:0},d||"page",c||g).top+(g?this.doc.height-Q(f):0)},defaultTextHeight:function(){return Ws(this.display)},defaultCharWidth:function(){return Zs(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(l,d,c,f,g){var _,w,L,S=this.display,z=(l=bn(this,st(this.doc,l))).bottom,P=l.left;if(d.style.position="absolute",d.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(d),S.sizer.appendChild(d),f=="over")z=l.top;else if(f=="above"||f=="near"){var te=Math.max(S.wrapper.clientHeight,this.doc.height),re=Math.max(S.sizer.clientWidth,S.lineSpace.clientWidth);(f=="above"||l.bottom+d.offsetHeight>te)&&l.top>d.offsetHeight?z=l.top-d.offsetHeight:l.bottom+d.offsetHeight<=te&&(z=l.bottom),P+d.offsetWidth>re&&(P=re-d.offsetWidth)}d.style.top=z+"px",d.style.left=d.style.right="",g=="right"?(P=S.sizer.clientWidth-d.offsetWidth,d.style.right="0px"):(g=="left"?P=0:g=="middle"&&(P=(S.sizer.clientWidth-d.offsetWidth)/2),d.style.left=P+"px"),c&&(_=this,w={left:P,top:z,right:P+d.offsetWidth,bottom:z+d.offsetHeight},(L=mh(_,w)).scrollTop!=null&&Oo(_,L.scrollTop),L.scrollLeft!=null&&Cs(_,L.scrollLeft))},triggerOnKeyDown:_r(pc),triggerOnKeyPress:_r(fc),triggerOnKeyUp:mc,triggerOnMouseDown:_r(gc),execCommand:function(l){if(Zo.hasOwnProperty(l))return Zo[l].call(null,this)},triggerElectric:_r(function(l){Cc(this,l)}),findPosH:function(l,d,c,f){var g=1;d<0&&(g=-1,d=-d);for(var _=st(this.doc,l),w=0;w0&&w(d.charAt(c-1));)--c;for(;f