=c.viewTo)){var g=c.view[Hu(a,u)];if(g.node!=null){var E=g.changes||(g.changes=[]);we(E,f)==-1&&E.push(f)}}}function qo(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function Eh(a,u,f,c){var p=Hu(a,u),g,E=a.display.view;if(!uo||f==a.doc.first+a.doc.size)return{index:p,lineN:f};for(var N=a.display.viewFrom,C=0;C0){if(p==E.length-1)return null;g=N+E[p].size-u,p++}else g=N-u;u+=g,f+=g}for(;Zy(a.doc,f)!=f;){if(p==(c<0?0:E.length-1))return null;f+=c*E[p-(c<0?1:0)].size,p+=c}return{index:p,lineN:f}}function I2(a,u,f){var c=a.display,p=c.view;p.length==0||u>=c.viewTo||f<=c.viewFrom?(c.view=yh(a,u,f),c.viewFrom=u):(c.viewFrom>u?c.view=yh(a,u,c.viewFrom).concat(c.view):c.viewFromf&&(c.view=c.view.slice(0,Hu(a,f)))),c.viewTo=f}function GN(a){for(var u=a.display.view,f=0,c=0;c=a.display.viewTo||C.to().line0?E:a.defaultCharWidth())+"px"}if(c.other){var N=f.appendChild(P("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));N.style.display="",N.style.left=c.other.left+"px",N.style.top=c.other.top+"px",N.style.height=(c.other.bottom-c.other.top)*.85+"px"}}function Sh(a,u){return a.top-u.top||a.left-u.left}function A2(a,u,f){var c=a.display,p=a.doc,g=document.createDocumentFragment(),E=DN(a.display),N=E.left,C=Math.max(c.sizerWidth,Qu(a)-c.sizer.offsetLeft)-E.right,I=p.direction=="ltr";function U(Te,Ce,Ge,qe){Ce<0&&(Ce=0),Ce=Math.round(Ce),qe=Math.round(qe),g.appendChild(P("div",null,"CodeMirror-selected","position: absolute; left: "+Te+`px;
- top: `+Ce+"px; width: "+(Ge==null?C-Te:Ge)+`px;
- height: `+(qe-Ce)+"px"))}function K(Te,Ce,Ge){var qe=Ae(p,Te),lt=qe.text.length,Ht,zr;function lr(wr,Xn){return _h(a,W(Te,wr),"div",qe,Xn)}function li(wr,Xn,sn){var Fr=VN(a,qe,null,wr),Nr=Xn=="ltr"==(sn=="after")?"left":"right",mr=sn=="after"?Fr.begin:Fr.end-(/\s/.test(qe.text.charAt(Fr.end-1))?2:1);return lr(mr,Nr)[Nr]}var Jn=xn(qe,p.direction);return hn(Jn,Ce||0,Ge==null?lt:Ge,function(wr,Xn,sn,Fr){var Nr=sn=="ltr",mr=lr(wr,Nr?"left":"right"),Zn=lr(Xn-1,Nr?"right":"left"),vl=Ce==null&&wr==0,Ko=Ge==null&&Xn==lt,mn=Fr==0,Ca=!Jn||Fr==Jn.length-1;if(Zn.top-mr.top<=3){var Wr=(I?vl:Ko)&&mn,q0=(I?Ko:vl)&&Ca,po=Wr?N:(Nr?mr:Zn).left,Xu=q0?C:(Nr?Zn:mr).right;U(po,mr.top,Xu-po,mr.bottom)}else{var Zu,In,gl,V0;Nr?(Zu=I&&vl&&mn?N:mr.left,In=I?C:li(wr,sn,"before"),gl=I?N:li(Xn,sn,"after"),V0=I&&Ko&&Ca?C:Zn.right):(Zu=I?li(wr,sn,"before"):N,In=!I&&vl&&mn?C:mr.right,gl=!I&&Ko&&Ca?N:Zn.left,V0=I?li(Xn,sn,"after"):C),U(Zu,mr.top,In-Zu,mr.bottom),mr.bottom0?u.blinker=setInterval(function(){a.hasFocus()||nl(a),u.cursorDiv.style.visibility=(f=!f)?"":"hidden"},a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(u.cursorDiv.style.visibility="hidden")}}function BN(a){a.hasFocus()||(a.display.input.focus(),a.state.focused||v0(a))}function h0(a){a.state.delayingBlurEvent=!0,setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,a.state.focused&&nl(a))},100)}function v0(a,u){a.state.delayingBlurEvent&&!a.state.draggingText&&(a.state.delayingBlurEvent=!1),a.options.readOnly!="nocursor"&&(a.state.focused||(Ft(a,"focus",a,u),a.state.focused=!0,Le(a.display.wrapper,"CodeMirror-focused"),!a.curOp&&a.display.selForContextMenu!=a.doc.sel&&(a.display.input.reset(),d&&setTimeout(function(){return a.display.input.reset(!0)},20)),a.display.input.receivedFocus()),p0(a))}function nl(a,u){a.state.delayingBlurEvent||(a.state.focused&&(Ft(a,"blur",a,u),a.state.focused=!1,z(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function kh(a){for(var u=a.display,f=u.lineDiv.offsetTop,c=Math.max(0,u.scroller.getBoundingClientRect().top),p=u.lineDiv.getBoundingClientRect().top,g=0,E=0;E.005||X<-.005)&&(pa.display.sizerWidth){var le=Math.ceil(U/rl(a.display));le>a.display.maxLineLength&&(a.display.maxLineLength=le,a.display.maxLine=N.line,a.display.maxLineChanged=!0)}}}Math.abs(g)>2&&(u.scroller.scrollTop+=g)}function KN(a){if(a.widgets)for(var u=0;u=E&&(g=wa(u,so(Ae(u,C))-a.wrapper.clientHeight),E=C)}return{from:g,to:Math.max(E,g+1)}}function R2(a,u){if(!nr(a,"scrollCursorIntoView")){var f=a.display,c=f.sizer.getBoundingClientRect(),p=null,g=f.wrapper.ownerDocument;if(u.top+c.top<0?p=!0:u.bottom+c.top>(g.defaultView.innerHeight||g.documentElement.clientHeight)&&(p=!1),p!=null&&!k){var E=P("div","\u200B",null,`position: absolute;
- top: `+(u.top-f.viewOffset-bh(a.display))+`px;
- height: `+(u.bottom-u.top+Da(a)+f.barHeight)+`px;
- left: `+u.left+"px; width: "+Math.max(2,u.right-u.left)+"px;");a.display.lineSpace.appendChild(E),E.scrollIntoView(p),a.display.lineSpace.removeChild(E)}}}function j2(a,u,f,c){c==null&&(c=0);var p;!a.options.lineWrapping&&u==f&&(f=u.sticky=="before"?W(u.line,u.ch+1,"before"):u,u=u.ch?W(u.line,u.sticky=="before"?u.ch-1:u.ch,"after"):u);for(var g=0;g<5;g++){var E=!1,N=fa(a,u),C=!f||f==u?N:fa(a,f);p={left:Math.min(N.left,C.left),top:Math.min(N.top,C.top)-c,right:Math.max(N.left,C.left),bottom:Math.max(N.bottom,C.bottom)+c};var I=g0(a,p),U=a.doc.scrollTop,K=a.doc.scrollLeft;if(I.scrollTop!=null&&(pf(a,I.scrollTop),Math.abs(a.doc.scrollTop-U)>1&&(E=!0)),I.scrollLeft!=null&&(zu(a,I.scrollLeft),Math.abs(a.doc.scrollLeft-K)>1&&(E=!0)),!E)break}return p}function P2(a,u){var f=g0(a,u);f.scrollTop!=null&&pf(a,f.scrollTop),f.scrollLeft!=null&&zu(a,f.scrollLeft)}function g0(a,u){var f=a.display,c=tl(a.display);u.top<0&&(u.top=0);var p=a.curOp&&a.curOp.scrollTop!=null?a.curOp.scrollTop:f.scroller.scrollTop,g=n0(a),E={};u.bottom-u.top>g&&(u.bottom=u.top+g);var N=a.doc.height+r0(f),C=u.topN-c;if(u.topp+g){var U=Math.min(u.top,(I?N:u.bottom)-g);U!=p&&(E.scrollTop=U)}var K=a.options.fixedGutter?0:f.gutters.offsetWidth,$=a.curOp&&a.curOp.scrollLeft!=null?a.curOp.scrollLeft:f.scroller.scrollLeft-K,X=Qu(a)-f.gutters.offsetWidth,ae=u.right-u.left>X;return ae&&(u.right=u.left+X),u.left<10?E.scrollLeft=0:u.left<$?E.scrollLeft=Math.max(0,u.left+K-(ae?0:10)):u.right>X+$-3&&(E.scrollLeft=u.right+(ae?0:10)-X),E}function m0(a,u){u!=null&&(wh(a),a.curOp.scrollTop=(a.curOp.scrollTop==null?a.doc.scrollTop:a.curOp.scrollTop)+u)}function il(a){wh(a);var u=a.getCursor();a.curOp.scrollToPos={from:u,to:u,margin:a.options.cursorScrollMargin}}function df(a,u,f){(u!=null||f!=null)&&wh(a),u!=null&&(a.curOp.scrollLeft=u),f!=null&&(a.curOp.scrollTop=f)}function F2(a,u){wh(a),a.curOp.scrollToPos=u}function wh(a){var u=a.curOp.scrollToPos;if(u){a.curOp.scrollToPos=null;var f=MN(a,u.from),c=MN(a,u.to);HN(a,f,c,u.margin)}}function HN(a,u,f,c){var p=g0(a,{left:Math.min(u.left,f.left),top:Math.min(u.top,f.top)-c,right:Math.max(u.right,f.right),bottom:Math.max(u.bottom,f.bottom)+c});df(a,p.scrollLeft,p.scrollTop)}function pf(a,u){Math.abs(a.doc.scrollTop-u)<2||(r||b0(a,{top:u}),zN(a,u,!0),r&&b0(a),gf(a,100))}function zN(a,u,f){u=Math.max(0,Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,u)),!(a.display.scroller.scrollTop==u&&!f)&&(a.doc.scrollTop=u,a.display.scrollbars.setScrollTop(u),a.display.scroller.scrollTop!=u&&(a.display.scroller.scrollTop=u))}function zu(a,u,f,c){u=Math.max(0,Math.min(u,a.display.scroller.scrollWidth-a.display.scroller.clientWidth)),!((f?u==a.doc.scrollLeft:Math.abs(a.doc.scrollLeft-u)<2)&&!c)&&(a.doc.scrollLeft=u,ZN(a),a.display.scroller.scrollLeft!=u&&(a.display.scroller.scrollLeft=u),a.display.scrollbars.setScrollLeft(u))}function hf(a){var u=a.display,f=u.gutters.offsetWidth,c=Math.round(a.doc.height+r0(a.display));return{clientHeight:u.scroller.clientHeight,viewHeight:u.wrapper.clientHeight,scrollWidth:u.scroller.scrollWidth,clientWidth:u.scroller.clientWidth,viewWidth:u.wrapper.clientWidth,barLeft:a.options.fixedGutter?f:0,docHeight:c,scrollHeight:c+Da(a)+u.barHeight,nativeBarWidth:u.nativeBarWidth,gutterWidth:f}}var Wu=function(a,u,f){this.cm=f;var c=this.vert=P("div",[P("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),p=this.horiz=P("div",[P("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");c.tabIndex=p.tabIndex=-1,a(c),a(p),_e(c,"scroll",function(){c.clientHeight&&u(c.scrollTop,"vertical")}),_e(p,"scroll",function(){p.clientWidth&&u(p.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,s&&l<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Wu.prototype.update=function(a){var u=a.scrollWidth>a.clientWidth+1,f=a.scrollHeight>a.clientHeight+1,c=a.nativeBarWidth;if(f){this.vert.style.display="block",this.vert.style.bottom=u?c+"px":"0";var p=a.viewHeight-(u?c:0);this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+p)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(u){this.horiz.style.display="block",this.horiz.style.right=f?c+"px":"0",this.horiz.style.left=a.barLeft+"px";var g=a.viewWidth-a.barLeft-(f?c:0);this.horiz.firstChild.style.width=Math.max(0,a.scrollWidth-a.clientWidth+g)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&a.clientHeight>0&&(c==0&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:f?c:0,bottom:u?c:0}},Wu.prototype.setScrollLeft=function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Wu.prototype.setScrollTop=function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Wu.prototype.zeroWidthHack=function(){var a=w&&!_?"12px":"18px";this.horiz.style.height=this.vert.style.width=a,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new ce,this.disableVert=new ce},Wu.prototype.enableZeroWidthBar=function(a,u,f){a.style.visibility="";function c(){var p=a.getBoundingClientRect(),g=f=="vert"?document.elementFromPoint(p.right-1,(p.top+p.bottom)/2):document.elementFromPoint((p.right+p.left)/2,p.bottom-1);g!=a?a.style.visibility="hidden":u.set(1e3,c)}u.set(1e3,c)},Wu.prototype.clear=function(){var a=this.horiz.parentNode;a.removeChild(this.horiz),a.removeChild(this.vert)};var vf=function(){};vf.prototype.update=function(){return{bottom:0,right:0}},vf.prototype.setScrollLeft=function(){},vf.prototype.setScrollTop=function(){},vf.prototype.clear=function(){};function al(a,u){u||(u=hf(a));var f=a.display.barWidth,c=a.display.barHeight;WN(a,u);for(var p=0;p<4&&f!=a.display.barWidth||c!=a.display.barHeight;p++)f!=a.display.barWidth&&a.options.lineWrapping&&kh(a),WN(a,hf(a)),f=a.display.barWidth,c=a.display.barHeight}function WN(a,u){var f=a.display,c=f.scrollbars.update(u);f.sizer.style.paddingRight=(f.barWidth=c.right)+"px",f.sizer.style.paddingBottom=(f.barHeight=c.bottom)+"px",f.heightForcer.style.borderBottom=c.bottom+"px solid transparent",c.right&&c.bottom?(f.scrollbarFiller.style.display="block",f.scrollbarFiller.style.height=c.bottom+"px",f.scrollbarFiller.style.width=c.right+"px"):f.scrollbarFiller.style.display="",c.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(f.gutterFiller.style.display="block",f.gutterFiller.style.height=c.bottom+"px",f.gutterFiller.style.width=u.gutterWidth+"px"):f.gutterFiller.style.display=""}var YN={native:Wu,null:vf};function JN(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&z(a.display.wrapper,a.display.scrollbars.addClass)),a.display.scrollbars=new YN[a.options.scrollbarStyle](function(u){a.display.wrapper.insertBefore(u,a.display.scrollbarFiller),_e(u,"mousedown",function(){a.state.focused&&setTimeout(function(){return a.display.input.focus()},0)}),u.setAttribute("cm-not-content","true")},function(u,f){f=="horizontal"?zu(a,u):pf(a,u)},a),a.display.scrollbars.addClass&&Le(a.display.wrapper,a.display.scrollbars.addClass)}var M2=0;function Yu(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.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:++M2,markArrays:null},v2(a.curOp)}function Ju(a){var u=a.curOp;u&&m2(u,function(f){for(var c=0;c=f.viewTo)||f.maxLineChanged&&u.options.lineWrapping,a.update=a.mustUpdate&&new Nh(u,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function U2(a){a.updatedDisplay=a.mustUpdate&&y0(a.cm,a.update)}function G2(a){var u=a.cm,f=u.display;a.updatedDisplay&&kh(u),a.barMeasure=hf(u),f.maxLineChanged&&!u.options.lineWrapping&&(a.adjustWidthTo=CN(u,f.maxLine,f.maxLine.text.length).left+3,u.display.sizerWidth=a.adjustWidthTo,a.barMeasure.scrollWidth=Math.max(f.scroller.clientWidth,f.sizer.offsetLeft+a.adjustWidthTo+Da(u)+u.display.barWidth),a.maxScrollLeft=Math.max(0,f.sizer.offsetLeft+a.adjustWidthTo-Qu(u))),(a.updatedDisplay||a.selectionChanged)&&(a.preparedSelection=f.input.prepareSelection())}function Q2(a){var u=a.cm;a.adjustWidthTo!=null&&(u.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeft=a.display.viewTo)){var f=+new Date+a.options.workTime,c=af(a,u.highlightFrontier),p=[];u.iter(c.line,Math.min(u.first+u.size,a.display.viewTo+500),function(g){if(c.line>=a.display.viewFrom){var E=g.styles,N=g.text.length>a.options.maxHighlightLength?ao(u.mode,c.state):null,C=iN(a,g,c,!0);N&&(c.state=N),g.styles=C.styles;var I=g.styleClasses,U=C.classes;U?g.styleClasses=U:I&&(g.styleClasses=null);for(var K=!E||E.length!=g.styles.length||I!=U&&(!I||!U||I.bgClass!=U.bgClass||I.textClass!=U.textClass),$=0;!K&&$f)return gf(a,a.options.workDelay),!0}),u.highlightFrontier=c.line,u.modeFrontier=Math.max(u.modeFrontier,c.line),p.length&&si(a,function(){for(var g=0;g=f.viewFrom&&u.visible.to<=f.viewTo&&(f.updateLineNumbers==null||f.updateLineNumbers>=f.viewTo)&&f.renderedView==f.view&&GN(a)==0)return!1;$N(a)&&(qo(a),u.dims=l0(a));var p=c.first+c.size,g=Math.max(u.visible.from-a.options.viewportMargin,c.first),E=Math.min(p,u.visible.to+a.options.viewportMargin);f.viewFromE&&f.viewTo-E<20&&(E=Math.min(p,f.viewTo)),uo&&(g=Zy(a.doc,g),E=yN(a.doc,E));var N=g!=f.viewFrom||E!=f.viewTo||f.lastWrapHeight!=u.wrapperHeight||f.lastWrapWidth!=u.wrapperWidth;I2(a,g,E),f.viewOffset=so(Ae(a.doc,f.viewFrom)),a.display.mover.style.top=f.viewOffset+"px";var C=GN(a);if(!N&&C==0&&!u.force&&f.renderedView==f.view&&(f.updateLineNumbers==null||f.updateLineNumbers>=f.viewTo))return!1;var I=z2(a);return C>4&&(f.lineDiv.style.display="none"),Y2(a,f.updateLineNumbers,u.dims),C>4&&(f.lineDiv.style.display=""),f.renderedView=f.view,W2(I),B(f.cursorDiv),B(f.selectionDiv),f.gutters.style.height=f.sizer.style.minHeight=0,N&&(f.lastWrapHeight=u.wrapperHeight,f.lastWrapWidth=u.wrapperWidth,gf(a,400)),f.updateLineNumbers=null,!0}function XN(a,u){for(var f=u.viewport,c=!0;;c=!1){if(!c||!a.options.lineWrapping||u.oldDisplayWidth==Qu(a)){if(f&&f.top!=null&&(f={top:Math.min(a.doc.height+r0(a.display)-n0(a),f.top)}),u.visible=Oh(a.display,a.doc,f),u.visible.from>=a.display.viewFrom&&u.visible.to<=a.display.viewTo)break}else c&&(u.visible=Oh(a.display,a.doc,f));if(!y0(a,u))break;kh(a);var p=hf(a);ff(a),al(a,p),_0(a,p),u.force=!1}u.signal(a,"update",a),(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)&&(u.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo)}function b0(a,u){var f=new Nh(a,u);if(y0(a,f)){kh(a),XN(a,f);var c=hf(a);ff(a),al(a,c),_0(a,c),f.finish()}}function Y2(a,u,f){var c=a.display,p=a.options.lineNumbers,g=c.lineDiv,E=g.firstChild;function N(ae){var le=ae.nextSibling;return d&&w&&a.display.currentWheelTarget==ae?ae.style.display="none":ae.parentNode.removeChild(ae),le}for(var C=c.view,I=c.viewFrom,U=0;U-1&&(X=!1),SN(a,K,I,f)),X&&(B(K.lineNumber),K.lineNumber.appendChild(document.createTextNode(H(a.options,I)))),E=K.node.nextSibling}I+=K.size}for(;E;)E=N(E)}function T0(a){var u=a.gutters.offsetWidth;a.sizer.style.marginLeft=u+"px",Br(a,"gutterChanged",a)}function _0(a,u){a.display.sizer.style.minHeight=u.docHeight+"px",a.display.heightForcer.style.top=u.docHeight+"px",a.display.gutters.style.height=u.docHeight+a.display.barHeight+Da(a)+"px"}function ZN(a){var u=a.display,f=u.view;if(!(!u.alignWidgets&&(!u.gutters.firstChild||!a.options.fixedGutter))){for(var c=c0(u)-u.scroller.scrollLeft+a.doc.scrollLeft,p=u.gutters.offsetWidth,g=c+"px",E=0;E=105&&(p.wrapper.style.clipPath="inset(0px)"),p.wrapper.setAttribute("translate","no"),s&&l<8&&(p.gutters.style.zIndex=-1,p.scroller.style.paddingRight=0),!d&&!(r&&m)&&(p.scroller.draggable=!0),a&&(a.appendChild?a.appendChild(p.wrapper):a(p.wrapper)),p.viewFrom=p.viewTo=u.first,p.reportedViewFrom=p.reportedViewTo=u.first,p.view=[],p.renderedView=null,p.externalMeasured=null,p.viewOffset=0,p.lastWrapHeight=p.lastWrapWidth=0,p.updateLineNumbers=null,p.nativeBarWidth=p.barHeight=p.barWidth=0,p.scrollbarsClipped=!1,p.lineNumWidth=p.lineNumInnerWidth=p.lineNumChars=null,p.alignWidgets=!1,p.cachedCharWidth=p.cachedTextHeight=p.cachedPaddingH=null,p.maxLine=null,p.maxLineLength=0,p.maxLineChanged=!1,p.wheelDX=p.wheelDY=p.wheelStartX=p.wheelStartY=null,p.shift=!1,p.selForContextMenu=null,p.activeTouch=null,p.gutterSpecs=E0(c.gutters,c.lineNumbers),eD(p),f.init(p)}var Dh=0,co=null;s?co=-.53:r?co=15:v?co=-.7:D&&(co=-1/3);function tD(a){var u=a.wheelDeltaX,f=a.wheelDeltaY;return u==null&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(u=a.detail),f==null&&a.detail&&a.axis==a.VERTICAL_AXIS?f=a.detail:f==null&&(f=a.wheelDelta),{x:u,y:f}}function X2(a){var u=tD(a);return u.x*=co,u.y*=co,u}function rD(a,u){v&&y==102&&(a.display.chromeScrollHack==null?a.display.sizer.style.pointerEvents="none":clearTimeout(a.display.chromeScrollHack),a.display.chromeScrollHack=setTimeout(function(){a.display.chromeScrollHack=null,a.display.sizer.style.pointerEvents=""},100));var f=tD(u),c=f.x,p=f.y,g=co;u.deltaMode===0&&(c=u.deltaX,p=u.deltaY,g=1);var E=a.display,N=E.scroller,C=N.scrollWidth>N.clientWidth,I=N.scrollHeight>N.clientHeight;if(!!(c&&C||p&&I)){if(p&&w&&d){e:for(var U=u.target,K=E.view;U!=N;U=U.parentNode)for(var $=0;$=0&&ie(a,c.to())<=0)return f}return-1};var Nt=function(a,u){this.anchor=a,this.head=u};Nt.prototype.from=function(){return Pr(this.anchor,this.head)},Nt.prototype.to=function(){return _t(this.anchor,this.head)},Nt.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function da(a,u,f){var c=a&&a.options.selectionsMayTouch,p=u[f];u.sort(function($,X){return ie($.from(),X.from())}),f=we(u,p);for(var g=1;g0:C>=0){var I=Pr(N.from(),E.from()),U=_t(N.to(),E.to()),K=N.empty()?E.from()==E.head:N.from()==N.head;g<=f&&--f,u.splice(--g,2,new Nt(K?U:I,K?I:U))}}return new ki(u,f)}function Vo(a,u){return new ki([new Nt(a,u||a)],0)}function Uo(a){return a.text?W(a.from.line+a.text.length-1,se(a.text).length+(a.text.length==1?a.from.ch:0)):a.to}function nD(a,u){if(ie(a,u.from)<0)return a;if(ie(a,u.to)<=0)return Uo(u);var f=a.line+u.text.length-(u.to.line-u.from.line)-1,c=a.ch;return a.line==u.to.line&&(c+=Uo(u).ch-u.to.ch),W(f,c)}function S0(a,u){for(var f=[],c=0;c1&&a.remove(N.line+1,ae-1),a.insert(N.line+1,be)}Br(a,"change",a,u)}function Go(a,u,f){function c(p,g,E){if(p.linked)for(var N=0;N1&&!a.done[a.done.length-2].ranges)return a.done.pop(),se(a.done)}function lD(a,u,f,c){var p=a.history;p.undone.length=0;var g=+new Date,E,N;if((p.lastOp==c||p.lastOrigin==u.origin&&u.origin&&(u.origin.charAt(0)=="+"&&p.lastModTime>g-(a.cm?a.cm.options.historyEventDelay:500)||u.origin.charAt(0)=="*"))&&(E=eB(p,p.lastOp==c)))N=se(E.changes),ie(u.from,u.to)==0&&ie(u.from,N.to)==0?N.to=Uo(u):E.changes.push(w0(a,u));else{var C=se(p.done);for((!C||!C.ranges)&&Ch(a.sel,p.done),E={changes:[w0(a,u)],generation:p.generation},p.done.push(E);p.done.length>p.undoDepth;)p.done.shift(),p.done[0].ranges||p.done.shift()}p.done.push(f),p.generation=++p.maxGeneration,p.lastModTime=p.lastSelTime=g,p.lastOp=p.lastSelOp=c,p.lastOrigin=p.lastSelOrigin=u.origin,N||Ft(a,"historyAdded")}function tB(a,u,f,c){var p=u.charAt(0);return p=="*"||p=="+"&&f.ranges.length==c.ranges.length&&f.somethingSelected()==c.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function rB(a,u,f,c){var p=a.history,g=c&&c.origin;f==p.lastSelOp||g&&p.lastSelOrigin==g&&(p.lastModTime==p.lastSelTime&&p.lastOrigin==g||tB(a,g,se(p.done),u))?p.done[p.done.length-1]=u:Ch(u,p.done),p.lastSelTime=+new Date,p.lastSelOrigin=g,p.lastSelOp=f,c&&c.clearRedo!==!1&&sD(p.undone)}function Ch(a,u){var f=se(u);f&&f.ranges&&f.equals(a)||u.push(a)}function cD(a,u,f,c){var p=u["spans_"+a.id],g=0;a.iter(Math.max(a.first,f),Math.min(a.first+a.size,c),function(E){E.markedSpans&&((p||(p=u["spans_"+a.id]={}))[g]=E.markedSpans),++g})}function nB(a){if(!a)return null;for(var u,f=0;f-1&&(se(N)[K]=I[K],delete I[K])}}return c}function N0(a,u,f,c){if(c){var p=a.anchor;if(f){var g=ie(u,p)<0;g!=ie(f,p)<0?(p=u,u=f):g!=ie(u,f)<0&&(u=f)}return new Nt(p,u)}else return new Nt(f||u,u)}function Lh(a,u,f,c,p){p==null&&(p=a.cm&&(a.cm.display.shift||a.extend)),gn(a,new ki([N0(a.sel.primary(),u,f,p)],0),c)}function dD(a,u,f){for(var c=[],p=a.cm&&(a.cm.display.shift||a.extend),g=0;g=u.ch:N.to>u.ch))){if(p&&(Ft(C,"beforeCursorEnter"),C.explicitlyCleared))if(g.markedSpans){--E;continue}else break;if(!C.atomic)continue;if(f){var K=C.find(c<0?1:-1),$=void 0;if((c<0?U:I)&&(K=yD(a,K,-c,K&&K.line==u.line?g:null)),K&&K.line==u.line&&($=ie(K,f))&&(c<0?$<0:$>0))return ul(a,K,u,c,p)}var X=C.find(c<0?-1:1);return(c<0?I:U)&&(X=yD(a,X,c,X.line==u.line?g:null)),X?ul(a,X,u,c,p):null}}return u}function Ah(a,u,f,c,p){var g=c||1,E=ul(a,u,f,g,p)||!p&&ul(a,u,f,g,!0)||ul(a,u,f,-g,p)||!p&&ul(a,u,f,-g,!0);return E||(a.cantEdit=!0,W(a.first,0))}function yD(a,u,f,c){return f<0&&u.ch==0?u.line>a.first?Ye(a,W(u.line-1)):null:f>0&&u.ch==(c||Ae(a,u.line)).text.length?u.line=0;--p)_D(a,{from:c[p].from,to:c[p].to,text:p?[""]:u.text,origin:u.origin});else _D(a,u)}}function _D(a,u){if(!(u.text.length==1&&u.text[0]==""&&ie(u.from,u.to)==0)){var f=S0(a,u);lD(a,u,f,a.cm?a.cm.curOp.id:NaN),bf(a,u,f,Jy(a,u));var c=[];Go(a,function(p,g){!g&&we(c,p.history)==-1&&(OD(p.history,u),c.push(p.history)),bf(p,u,null,Jy(p,u))})}}function Rh(a,u,f){var c=a.cm&&a.cm.state.suppressEdits;if(!(c&&!f)){for(var p=a.history,g,E=a.sel,N=u=="undo"?p.done:p.undone,C=u=="undo"?p.undone:p.done,I=0;I=0;--X){var ae=$(X);if(ae)return ae.v}}}}function ED(a,u){if(u!=0&&(a.first+=u,a.sel=new ki(Ue(a.sel.ranges,function(p){return new Nt(W(p.anchor.line+u,p.anchor.ch),W(p.head.line+u,p.head.ch))}),a.sel.primIndex),a.cm)){Wn(a.cm,a.first,a.first-u,u);for(var f=a.cm.display,c=f.viewFrom;ca.lastLine())){if(u.from.lineg&&(u={from:u.from,to:W(g,Ae(a,g).text.length),text:[u.text[0]],origin:u.origin}),u.removed=oo(a,u.from,u.to),f||(f=S0(a,u)),a.cm?oB(a.cm,u,c):O0(a,u,c),Ih(a,f,Qe),a.cantEdit&&Ah(a,W(a.firstLine(),0))&&(a.cantEdit=!1)}}function oB(a,u,f){var c=a.doc,p=a.display,g=u.from,E=u.to,N=!1,C=g.line;a.options.lineWrapping||(C=wt(ca(Ae(c,g.line))),c.iter(C,E.line+1,function(X){if(X==p.maxLine)return N=!0,!0})),c.sel.contains(u.from,u.to)>-1&&Ys(a),O0(c,u,f,UN(a)),a.options.lineWrapping||(c.iter(C,g.line+u.text.length,function(X){var ae=mh(X);ae>p.maxLineLength&&(p.maxLine=X,p.maxLineLength=ae,p.maxLineChanged=!0,N=!1)}),N&&(a.curOp.updateMaxLine=!0)),YQ(c,g.line),gf(a,400);var I=u.text.length-(E.line-g.line)-1;u.full?Wn(a):g.line==E.line&&u.text.length==1&&!aD(a.doc,u)?Mo(a,g.line,"text"):Wn(a,g.line,E.line+1,I);var U=on(a,"changes"),K=on(a,"change");if(K||U){var $={from:g,to:E,text:u.text,removed:u.removed,origin:u.origin};K&&Br(a,"change",a,$),U&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push($)}a.display.selForContextMenu=null}function ll(a,u,f,c,p){var g;c||(c=f),ie(c,f)<0&&(g=[c,f],f=g[0],c=g[1]),typeof u=="string"&&(u=a.splitLines(u)),sl(a,{from:f,to:c,text:u,origin:p})}function SD(a,u,f,c){f1||!(this.children[0]instanceof _f))){var N=[];this.collapse(N),this.children=[new _f(N)],this.children[0].parent=this}},collapse:function(a){for(var u=0;u50){for(var E=p.lines.length%25+25,N=E;N10);a.parent.maybeSpill()}},iterN:function(a,u,f){for(var c=0;ca.display.maxLineLength&&(a.display.maxLine=I,a.display.maxLineLength=U,a.display.maxLineChanged=!0)}c!=null&&a&&this.collapsed&&Wn(a,c,p+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&gD(a.doc)),a&&Br(a,"markerCleared",a,this,c,p),u&&Ju(a),this.parent&&this.parent.clear()}},Qo.prototype.find=function(a,u){a==null&&this.type=="bookmark"&&(a=1);for(var f,c,p=0;p