v)return dr(r,d,m,1);for(;;){if(c?d==h||d==Te(t,h,1):d-h<=1){var y=n0&&y1){var x=Qt(e,u,y,"right");l<=x.bottom&&l>=x.top&&Math.abs(n-x.right)1?1:0);return C}var L=Math.ceil(f/2),T=h+L;if(c){T=h;for(var M=0;Mn?(d=T,v=k,(m=s)&&(v+=1e3),f=L):(h=T,p=k,g=s,f-=L)}}function vr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Ql){Ql=n("pre");for(var i=0;i<49;++i)Ql.appendChild(document.createTextNode("x")),Ql.appendChild(n("br"));Ql.appendChild(document.createTextNode("x"))}r(e.measure,Ql);var o=Ql.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function mr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t]);r(e.measure,i);var o=t.getBoundingClientRect(),l=(o.right-o.left)/10;return l>2&&(e.cachedCharWidth=l),l||10}function yr(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:br(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function br(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function wr(e){var t=vr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/mr(e.display)-3);return function(i){if(he(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var r=e.display.view,n=0;n=e.display.viewTo||s.to().line3&&(i(d,g.top,null,g.bottom),d=c,g.bottoma.bottom||u.bottom==a.bottom&&u.right>a.right)&&(a=u),d0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Or(e){e.state.focused||(e.display.input.focus(),Ar(e))}function Wr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Dr(e))},100)}function Ar(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(We(e,"focus",e,t),e.state.focused=!0,l(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),ul&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Nr(e))}function Dr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(We(e,"blur",e,t),e.state.focused=!1,Tl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Hr(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=br(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l.001||a<-.001)&&(N(i.line,o),Ir(i.line),i.rest))for(var u=0;u=l&&(o=W(t,pe(T(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function zr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,il||kn(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),il&&kn(e),xn(e,100))}function Rr(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,Hr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Br(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}}function Gr(e){var t=Br(e);return t.x*=os,t.y*=os,t}function Vr(e,t){var r=Br(t),n=r.x,i=r.y,o=e.display,l=o.scroller,s=l.scrollWidth>l.clientWidth,a=l.scrollHeight>l.clientHeight;if(n&&s||i&&a){if(i&&yl&&ul)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var f=0;f(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!gl){var l=n("div","",null,"position: absolute;\n top: "+(t.top-r.viewOffset-Bt(e.display))+"px;\n height: "+(t.bottom-t.top+Ut(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(l),l.scrollIntoView(o),e.display.lineSpace.removeChild(l)}}}function qr(e,t,r,n){null==n&&(n=0);for(var i,o=0;o<5;o++){var l=!1;i=fr(e,t);var s=r&&r!=t?fr(e,r):i,a=Qr(e,Math.min(i.left,s.left),Math.min(i.top,s.top)-n,Math.max(i.left,s.left),Math.max(i.bottom,s.bottom)+n),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(zr(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(l=!0)),null!=a.scrollLeft&&(Rr(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(l=!0)),!l)break}return i}function Zr(e,t,r,n,i){var o=Qr(e,t,r,n,i);null!=o.scrollTop&&zr(e,o.scrollTop),null!=o.scrollLeft&&Rr(e,o.scrollLeft)}function Qr(e,t,r,n,i){var o=e.display,l=vr(e.display);r<0&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=Kt(e),u={};i-r>a&&(i=r+a);var c=e.doc.height+Gt(o),f=rc-l;if(rs+a){var d=Math.min(r,(h?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=jt(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),v=n-t>g;return v&&(n=t+g),t<10?u.scrollLeft=0:tg+p-3&&(u.scrollLeft=n+(v?0:10)-g),u}function Jr(e,t,r){null==t&&null==r||tn(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function en(e){tn(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?H(t.line,t.ch-1):t,n=H(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function tn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=hr(e,t.from),n=hr(e,t.to),i=Qr(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function rn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++ss},xt(e.curOp)}function nn(e){var t=e.curOp;St(t,function(e){for(var t=0;t=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Sn(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function sn(e){e.updatedDisplay=e.mustUpdate&&Tn(e.cm,e.update)}function an(e){var t=e.cm,r=t.display;e.updatedDisplay&&Er(t),e.barMeasure=Ur(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=$t(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Ut(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-jt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection(e.focus))}function un(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeftt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)zl&&ce(e.doc,t)i.viewFrom?mn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)mn(e);else if(t<=i.viewFrom){var o=yn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):mn(e)}else if(r>=i.viewTo){var l=yn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):mn(e)}else{var s=yn(e,t,t,-1),a=yn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(wt(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):mn(e)}var u=i.externalMeasured;u&&(r=i.lineN&&t=n.viewTo)){var o=n.view[Sr(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);h(l,r)==-1&&l.push(r)}}}function mn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function yn(e,t,r,n){var i,o=Sr(e,t),l=e.display.view;if(!zl||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,a=0;a0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;ce(e.doc,r)!=r;){if(o==(n<0?0:l.length-1))return null;r+=n*l[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function bn(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=wt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=wt(e,t,n.viewFrom).concat(n.view):n.viewFromr&&(n.view=n.view.slice(0,Sr(e,r)))),n.viewTo=r}function wn(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo)){var r=+new Date+e.options.workTime,n=$e(t.mode,et(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=o.text.length>e.options.maxHighlightLength,a=Qe(e,o,s?$e(t.mode,n):n,!0);o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var f=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),h=0;!f&&hr)return xn(e,e.options.workDelay),!0}),i.length&&fn(e,function(){for(var t=0;t=n.viewFrom&&r.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==wn(e))return!1;Pr(e)&&(mn(e),r.dims=yr(e));var l=i.first+i.size,s=Math.max(r.visible.from-e.options.viewportMargin,i.first),a=Math.min(l,r.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(l,n.viewTo)),zl&&(s=ce(e.doc,s),a=fe(e.doc,a));var u=s!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=r.wrapperHeight||n.lastWrapWidth!=r.wrapperWidth;bn(e,s,a),n.viewOffset=pe(T(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=wn(e);if(!u&&0==c&&!r.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var f=o();return c>4&&(n.lineDiv.style.display="none"),Nn(e,n.updateLineNumbers,r.dims),c>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,f&&o()!=f&&f.offsetHeight&&f.focus(),t(n.cursorDiv),t(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,u&&(n.lastWrapHeight=r.wrapperHeight,n.lastWrapWidth=r.wrapperWidth,xn(e,400)),n.updateLineNumbers=null,!0}function Mn(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=jt(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Gt(e.display)-Kt(e),r.top)}),t.visible=Fr(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Tn(e,t);n=!1){Er(e);var i=Ur(e);Lr(e),Xr(e,i),Wn(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function kn(e,t){var r=new Sn(e,t);if(Tn(e,r)){Er(e),Mn(e,r);var n=Ur(e);Lr(e),Xr(e,n),Wn(e,n),r.finish()}}function Nn(e,r,n){function i(t){var r=t.nextSibling;return ul&&yl&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var o=e.display,l=e.options.lineNumbers,s=o.lineDiv,a=s.firstChild,u=o.view,c=o.viewFrom,f=0;f-1&&(p=!1),Mt(e,d,c,n)),p&&(t(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(D(e.options,c)))),a=d.node.nextSibling}else{var g=Pt(e,d,c,n);s.insertBefore(g,a)}c+=d.size}for(;a;)a=i(a)}function On(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function Wn(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Ut(e)+"px"}function An(e){var r=e.display.gutters,i=e.options.gutters;t(r);for(var o=0;o-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function Hn(e,t){this.ranges=e,this.primIndex=t}function Pn(e,t){this.anchor=e,this.head=t}function En(e,t){var r=e[t];e.sort(function(e,t){return P(e.from(),t.from())}),t=h(e,r);for(var n=1;n=0){var l=F(o.from(),i.from()),s=I(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new Pn(a?s:l,a?l:s))}}return new Hn(e,t)}function In(e,t){return new Hn([new Pn(e,t||e)],0)}function Fn(e){return e.text?H(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function zn(e,t){if(P(e,t.from)<0)return e;if(P(e,t.to)<=0)return Fn(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Fn(t).ch-t.to.ch),H(r,n)}function Rn(e,t){for(var r=[],n=0;n1&&e.remove(s.line+1,p-1),e.insert(s.line+1,y)}Lt(e,"change",e,t)}function Xn(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}function Qn(e,t,r,n){var i=e.history;i.undone.length=0;var o,l,s=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=Zn(i,i.lastOp==n)))l=g(o.changes),0==P(t.from,t.to)&&0==P(t.from,l.to)?l.to=Fn(t):o.changes.push($n(e,t));else{var a=g(i.done);for(a&&a.ranges||ti(e.sel,i.done),o={changes:[$n(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||We(e,"historyAdded")}function Jn(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function ei(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||Jn(e,o,g(i.done),t))?i.done[i.done.length-1]=t:ti(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&qn(i.undone)}function ti(e,t){var r=g(t);r&&r.ranges&&r.equals(e)||t.push(e)}function ri(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function ni(e){if(!e)return null;for(var t,r=0;r-1&&(g(s)[f]=u[f],delete u[f])}}}return n}function si(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=P(r,i)<0;o!=P(n,i)<0?(i=r,r=n):o!=P(r,n)<0&&(r=n)}return new Pn(i,r)}return new Pn(n||r,r)}function ai(e,t,r,n){pi(e,new Hn([si(e,e.sel.primary(),t,r)],0),n)}function ui(e,t,r){for(var n=[],i=0;i=t.ch:s.to>t.ch))){if(i&&(We(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u=a.find(n<0?1:-1),c=void 0;if((n<0?a.inclusiveRight:a.inclusiveLeft)&&(u=xi(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=P(u,r))&&(n<0?c<0:c>0))return bi(e,u,t,n,i)}var f=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(f=xi(e,f,n,f.line==t.line?o:null)),f?bi(e,f,t,n,i):null}}return t}function wi(e,t,r,n,i){var o=n||1,l=bi(e,t,r,o,i)||!i&&bi(e,t,r,o,!0)||bi(e,t,r,-o,i)||!i&&bi(e,t,r,-o,!0);return l?l:(e.cantEdit=!0,H(e.first,0))}function xi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?R(e,H(t.line-1)):null:r>0&&t.ch==(n||T(e,t.line)).text.length?t.line=0;--i)Ti(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else Ti(e,t)}}function Ti(e,t){if(1!=t.text.length||""!=t.text[0]||0!=P(t.from,t.to)){var r=Rn(e,t);Qn(e,t,r,e.cm?e.cm.curOp.id:NaN),Ni(e,t,r,q(e,t));var n=[];Xn(e,function(e,r){r||h(n,e.history)!=-1||(Hi(e.history,t),n.push(e.history)),Ni(e,t,null,q(e,t))})}}function Mi(e,t,r){if(!e.cm||!e.cm.state.suppressEdits||r){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a=0;--d){var p=f(d);if(p)return p.v}}}}function ki(e,t){if(0!=t&&(e.first+=t,e.sel=new Hn(v(e.sel.ranges,function(e){return new Pn(H(e.anchor.line+t,e.anchor.ch),H(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){gn(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;ne.lastLine())){if(t.from.lineo&&(t={from:t.from,to:H(o,T(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=M(e,t.from,t.to),r||(r=Rn(e,t)),e.cm?Oi(e.cm,t,n):Kn(e,t,n),gi(e,r,Al)}}function Oi(e,t,r){var n=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=O(ae(T(n,o.line))),n.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0,!0})),n.sel.contains(t.from,t.to)>-1&&De(e),Kn(n,t,r,wr(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=ge(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,o.line),xn(e,400);var u=t.text.length-(l.line-o.line)-1;t.full?gn(e):o.line!=l.line||1!=t.text.length||jn(e.doc,t)?gn(e,o.line,l.line+1,u):vn(e,o.line,"text");var c=He(e,"changes"),f=He(e,"change");if(f||c){var h={from:o,to:l,text:t.text,removed:t.removed,origin:t.origin};f&&Lt(e,"change",e,h),c&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Wi(e,t,r,n,i){if(n||(n=r),P(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),Li(e,{from:r,to:n,text:t,origin:i})}function Ai(e,t,r,n){r0||0==s&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=n("span",[l.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(se(e,t.line,t,r,l)||t.line!=r.line&&se(e,r.line,t,r,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");U()}l.addToHistory&&Qn(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var a,c=t.line,f=e.cm;if(e.iter(c,r.line+1,function(e){f&&l.collapsed&&!f.options.lineWrapping&&ae(e)==f.display.maxLine&&(a=!0),l.collapsed&&c!=t.line&&N(e,0),Y(e,new j(l,c==t.line?t.ch:null,c==r.line?r.ch:null)),++c}),l.collapsed&&e.iter(t.line,r.line+1,function(t){he(e,t)&&N(t,0)}),l.clearOnEnter&&Vl(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(V(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++as,l.atomic=!0),f){if(a&&(f.curOp.updateMaxLine=!0),l.collapsed)gn(f,t.line,r.line+1);else if(l.className||l.title||l.startStyle||l.endStyle||l.css)for(var h=t.line;h<=r.line;h++)vn(f,h,"text");l.atomic&&mi(f.doc),Lt(f,"markerAdded",f,l)}return l}function Vi(e,t){var r=this;this.markers=e,this.primary=t;for(var n=0;n-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var u=e.dataTransfer.getData("Text");if(u){var c;if(t.state.draggingText&&!t.state.draggingText.copy&&(c=t.listSelections()),gi(t.doc,In(r,r)),c)for(var f=0;f=0;t--)Wi(e.doc,"",n[t].from,n[t].to,"+delete");en(e)})}function ao(e,t){var r=T(e.doc,t),n=ae(r);n!=r&&(t=O(n));var i=ke(n),o=i?i[0].level%2?xe(n):we(n):0;return H(t,o)}function uo(e,t){for(var r,n=T(e.doc,t);r=le(n);)n=r.find(1,!0).line,t=null;var i=ke(n),o=i?i[0].level%2?we(n):xe(n):n.text.length;return H(null==t?O(n):t,o)}function co(e,t){var r=ao(e,t.line),n=T(e.doc,r.line),i=ke(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return H(r.line,l?0:o)}return r}function fo(e,t,r){if("string"==typeof t&&(t=ws[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Wl}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function ho(e,t,r){for(var n=0;ni-400&&0==P(bs.pos,r)?n="triple":ys&&ys.time>i-400&&0==P(ys.pos,r)?(n="double",bs={time:i,pos:r}):(n="single",ys={time:i,pos:r});var l,s=e.doc.sel,u=yl?t.metaKey:t.ctrlKey;e.options.dragDrop&&Ul&&!e.isReadOnly()&&"single"==n&&(l=s.contains(r))>-1&&(P((l=s.ranges[l]).from(),r)<0||r.xRel>0)&&(P(l.to(),r)>0||r.xRel<0)?So(e,t,r,u):Lo(e,t,r,n,u)}function So(e,t,r,n){var i=e.display,o=+new Date,l=hn(e,function(s){ul&&(i.scroller.draggable=!1),e.state.draggingText=!1,Oe(document,"mouseup",l),Oe(i.scroller,"drop",l),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(Ee(s),!n&&+new Date-200w&&i.push(new Pn(H(v,w),H(v,d(y,u,o))))}i.length||i.push(new Pn(r,r)),pi(f,En(g.ranges.slice(0,p).concat(i),p),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x=h,C=x.anchor,S=t;if("single"!=n){var L;L="double"==n?e.findWordAt(t):new Pn(H(t.line,0),R(f,H(t.line+1,0))),P(L.anchor,C)>0?(S=L.head,C=F(x.from(),L.anchor)):(S=L.anchor,C=I(x.to(),L.head))}var M=g.ranges.slice(0);M[p]=new Pn(R(f,C),S),pi(f,En(M,p),Dl)}}function s(t){var r=++x,i=Cr(e,t,!0,"rect"==n);if(i)if(0!=P(i,b)){e.curOp.focus=o(),l(i);var a=Fr(u,f);(i.line>=a.to||i.linew.bottom?20:0;c&&setTimeout(hn(e,function(){x==r&&(u.scroller.scrollTop+=c,s(t))}),50)}}function a(t){e.state.selectingText=!1,x=1/0,Ee(t),u.input.focus(),Oe(document,"mousemove",C),Oe(document,"mouseup",S),f.history.lastSelOrigin=null}var u=e.display,f=e.doc;Ee(t);var h,p,g=f.sel,v=g.ranges;if(i&&!t.shiftKey?(p=f.sel.contains(r),h=p>-1?v[p]:new Pn(r,r)):(h=f.sel.primary(),p=f.sel.primIndex),bl?t.shiftKey&&t.metaKey:t.altKey)n="rect",i||(h=new Pn(r,r)),r=Cr(e,t,!0,!0),p=-1;else if("double"==n){var m=e.findWordAt(r);h=e.display.shift||f.extend?si(f,h,m.anchor,m.head):m}else if("triple"==n){var y=new Pn(H(r.line,0),R(f,H(r.line+1,0)));h=e.display.shift||f.extend?si(f,h,y.anchor,y.head):y}else h=si(f,h,r);i?p==-1?(p=v.length,pi(f,En(v.concat([h]),p),{scroll:!1,origin:"*mouse"})):v.length>1&&v[p].empty()&&"single"==n&&!t.shiftKey?(pi(f,En(v.slice(0,p).concat(v.slice(p+1)),0),{scroll:!1,origin:"*mouse"}),g=f.sel):ci(f,p,h,Dl):(p=0,pi(f,new Hn([h],0),Dl),g=f.sel);var b=r,w=u.wrapper.getBoundingClientRect(),x=0,C=hn(e,function(e){Be(e)?s(e):a(e)}),S=hn(e,a);e.state.selectingText=S,Vl(document,"mousemove",C),Vl(document,"mouseup",S)}function To(e,t,r,n){var i,o;try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&Ee(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!He(e,r))return Fe(t);o-=s.top-l.viewOffset;for(var a=0;a=i){var c=W(e.doc,o),f=e.options.gutters[a];return We(e,r,e,c,f,t),Fe(t)}}}function Mo(e,t){return To(e,t,"gutterClick",!0)}function ko(e,t){Rt(e.display,t)||No(e,t)||Ae(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function No(e,t){return!!He(e,"gutterContextMenu")&&To(e,t,"gutterContextMenu",!1)}function Oo(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),or(e)}function Wo(e){function t(t,n,i,o){e.defaults[t]=n,i&&(r[t]=o?function(e,t,r){r!=Ss&&i(e,t,r)}:i)}var r=e.optionHandlers;e.defineOption=t,e.Init=Ss,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,Vn(e)},!0),t("indentUnit",2,Vn,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){Un(e),or(e),gn(e)},!0),t("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var r=[],n=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(o==-1)break;i=o+t.length,r.push(H(n,o))}n++});for(var i=r.length-1;i>=0;i--)Wi(e.doc,t,r[i],H(r[i].line,r[i].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=Ss&&e.refresh()}),t("specialCharPlaceholder",dt,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",ml?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("rtlMoveVisually",!wl),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){Oo(e),Ao(e)},!0),t("keyMap","default",function(e,t,r){var n=lo(t),i=r!=Ss&&lo(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),t("extraKeys",null),t("lineWrapping",!1,Ho,!0),t("gutters",[],function(e){Dn(e.options),Ao(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?br(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return Xr(e)},!0),t("scrollbarStyle","native",function(e){_r(e),Xr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e){Dn(e.options),Ao(e)},!0),t("firstLineNumber",1,Ao,!0),t("lineNumberFormatter",function(e){return e},Ao,!0),t("showCursorWhenSelecting",!1,Lr,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("readOnly",!1,function(e,t){"nocursor"==t?(Dr(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,Do),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Lr,!0),t("singleCursorHeightPerLine",!0,Lr,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,Un,!0),t("addModeClass",!1,Un,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,Un,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null)}function Ao(e){An(e),gn(e),setTimeout(function(){return Hr(e)},20)}function Do(e,t,r){var n=r&&r!=Ss;if(!t!=!n){var i=e.display.dragFunctions,o=t?Vl:Oe;o(e.display.scroller,"dragstart",i.start),o(e.display.scroller,"dragenter",i.enter),o(e.display.scroller,"dragover",i.over),o(e.display.scroller,"dragleave",i.leave),o(e.display.scroller,"drop",i.drop)}}function Ho(e){e.options.lineWrapping?(l(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Tl(e.display.wrapper,"CodeMirror-wrap"),ve(e)),xr(e),gn(e),or(e),setTimeout(function(){return Xr(e)},100)}function Po(e,t){var r=this;if(!(this instanceof Po))return new Po(e,t);this.options=t=t?u(t):{},u(Ls,t,!1),Dn(t);var n=t.value;"string"==typeof n&&(n=new cs(n,t.mode,null,t.lineSeparator)),this.doc=n;var i=new Po.inputStyles[t.inputStyle](this),o=this.display=new L(e,n,i);o.wrapper.CodeMirror=this,An(this),Oo(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),t.autofocus&&!ml&&o.input.focus(),_r(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 f,keySeq:null,specialChars:null},sl&&al<11&&setTimeout(function(){return r.display.input.reset(!0)},20),Eo(this),Qi(),rn(this),this.curOp.forceUpdate=!0,Yn(this,n),t.autofocus&&!ml||this.hasFocus()?setTimeout(a(Ar,this),20):Dr(this);for(var l in Ts)Ts.hasOwnProperty(l)&&Ts[l](r,t[l],Ss);Pr(this),t.finishInit&&t.finishInit(this);for(var s=0;s400}var i=e.display;Vl(i.scroller,"mousedown",hn(e,xo)),sl&&al<11?Vl(i.scroller,"dblclick",hn(e,function(t){if(!Ae(e,t)){var r=Cr(e,t);if(r&&!Mo(e,t)&&!Rt(e.display,t)){Ee(t);var n=e.findWordAt(r);ai(e.doc,n.anchor,n.head)}}})):Vl(i.scroller,"dblclick",function(t){return Ae(e,t)||Ee(t)}),Ll||Vl(i.scroller,"contextmenu",function(t){return ko(e,t)});var o,l={end:0};Vl(i.scroller,"touchstart",function(t){if(!Ae(e,t)&&!r(t)){i.input.ensurePolled(),clearTimeout(o);var n=+new Date;i.activeTouch={start:n,moved:!1,prev:n-l.end<=300?l:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),Vl(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Vl(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!Rt(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,s=e.coordsChar(i.activeTouch,"page");l=!o.prev||n(o,o.prev)?new Pn(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new Pn(H(s.line,0),R(e.doc,H(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),Ee(r)}t()}),Vl(i.scroller,"touchcancel",t),Vl(i.scroller,"scroll",function(){i.scroller.clientHeight&&(zr(e,i.scroller.scrollTop),Rr(e,i.scroller.scrollLeft,!0),We(e,"scroll",e))}),Vl(i.scroller,"mousewheel",function(t){return Vr(e,t)}),Vl(i.scroller,"DOMMouseScroll",function(t){return Vr(e,t)}),Vl(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0;
-}),i.dragFunctions={enter:function(t){Ae(e,t)||ze(t)},over:function(t){Ae(e,t)||($i(e,t),ze(t))},start:function(t){return _i(e,t)},drop:hn(e,Yi),leave:function(t){Ae(e,t)||qi(e)}};var s=i.input.getField();Vl(s,"keyup",function(t){return bo.call(e,t)}),Vl(s,"keydown",hn(e,mo)),Vl(s,"keypress",hn(e,wo)),Vl(s,"focus",function(t){return Ar(e,t)}),Vl(s,"blur",function(t){return Dr(e,t)})}function Io(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=et(e,t):r="prev");var l=e.options.tabSize,s=T(o,t),a=c(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,f=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(f.length),s.text),u==Wl||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?c(T(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var h="",d=0;if(e.options.indentWithTabs)for(var g=Math.floor(u/l);g;--g)d+=l,h+="\t";if(d1)if(ks&&ks.text.join("\n")==t){if(n.ranges.length%ks.text.length==0){a=[];for(var u=0;u=0;f--){var h=n.ranges[f],d=h.from(),p=h.to();h.empty()&&(r&&r>0?d=H(d.line,d.ch-r):e.state.overwrite&&!l?p=H(p.line,Math.min(T(o,p.line).text.length,p.ch+g(s).length)):ks&&ks.lineWise&&ks.text.join("\n")==t&&(d=p=H(d.line,0))),c=e.curOp.updateInput;var m={from:d,to:p,text:a?a[f%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Li(e.doc,m),Lt(e,"inputRead",e,m)}t&&!l&&Bo(e,t),en(e),e.curOp.updateInput=c,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Ro(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||fn(t,function(){return zo(t,r,0,null,"paste")}),!0}function Bo(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s-1){l=Io(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(T(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Io(e,i.head.line,"smart"));l&&Lt(e,"electricInput",e,i.head.line)}}}function Go(e){for(var t=[],r=[],n=0;nn&&(Io(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&en(t));else{var l=o.from(),s=o.to(),a=Math.max(n,l.line);n=Math.min(t.lastLine(),s.line-(s.ch?0:1))+1;for(var u=a;u0&&ci(t.doc,i,new Pn(l,c[i].to()),Al)}}}),getTokenAt:function(e,t){return it(this,e,t)},getLineTokens:function(e,t){return it(this,H(e),t,!0)},getTokenTypeAt:function(e){e=R(this.doc,e);var t,r=Je(this,T(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]o&&(e=o,i=!0),n=T(this.doc,e)}else n=e;return ar(this,n,{top:0,left:0},t||"page",r).top+(i?this.doc.height-pe(n):0)},defaultTextHeight:function(){return vr(this.display)},defaultCharWidth:function(){return mr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=fr(this,R(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Zr(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:dn(mo),triggerOnKeyPress:dn(wo),triggerOnKeyUp:bo,execCommand:function(e){if(ws.hasOwnProperty(e))return ws[e].call(null,this)},triggerElectric:dn(function(e){Bo(this,e)}),findPosH:function(e,t,r,n){var i=this,o=1;t<0&&(o=-1,t=-t);for(var l=R(this.doc,e),s=0;s0&&s(r.charAt(n-1));)--n;for(;i.5)&&xr(this),We(this,"refresh",this)}),swapDoc:dn(function(e){var t=this.doc;return t.cm=null,Yn(this,e),or(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Lt(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Pe(e),e.registerHelper=function(t,n,i){r.hasOwnProperty(t)||(r[t]=e[t]={_global:[]}),r[t][n]=i},e.registerGlobalHelper=function(t,n,i,o){e.registerHelper(t,n,o),r[t]._global.push({pred:i,val:o})}}function Ko(e,t,r,n,i){function o(){var t=s+r;return!(t=e.first+e.size)&&(s=t,c=T(e,t))}function l(e){var t=(i?Te:Me)(c,a,r,!0);if(null==t){if(e||!o())return!1;a=i?(r<0?xe:we)(c):r<0?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=r,c=T(e,s);if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var f=null,h="group"==n,d=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(r<0)||l(!p);p=!1){var g=c.text.charAt(a)||"\n",v=x(g,d)?"w":h&&"\n"==g?"n":!h||/\s/.test(g)?null:"p";if(!h||p||v||(v="s"),f&&f!=v){r<0&&(r=1,l());break}if(v&&(f=v),r>0&&!l(!p))break}var m=wi(e,H(s,a),t,u,!0);return P(t,m)||(m.hitSide=!0),m}function Xo(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),a=Math.max(s-.5*vr(e.display),3);i=(r>0?t.bottom:t.top)+r*a}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(var u;u=pr(e,l,i),u.outside;){if(r<0?i<=0:i>=o.height){u.hitSide=!0;break}i+=5*r}return u}function Yo(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new f,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null}function _o(e,t){var r=qt(e,t.line);if(!r||r.hidden)return null;var n=T(e.doc,t.line),i=Yt(r,n,t.line),o=ke(n),l="left";if(o){var s=Se(o,t.ch);l=s%2?"right":"left"}var a=Jt(i.map,t.ch,l);return a.offset="right"==a.collapse?a.end:a.start,a}function $o(e,t){return t&&(e.bad=!0),e}function qo(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return void(s+=""==r?t.textContent.replace(/\u200b/g,""):r);var c,f=t.getAttribute("cm-marker");if(f){var h=e.findMarks(H(n,0),H(i+1,0),o(+f));return void(h.length&&(c=h[0].find())&&(s+=M(e.doc,c.from,c.to).join(u)))}if("false"==t.getAttribute("contenteditable"))return;for(var d=0;d=15&&(hl=!1,ul=!0);var Cl,Sl=yl&&(cl||hl&&(null==xl||xl<12.11)),Ll=il||sl&&al>=9,Tl=function(t,r){var n=t.className,i=e(r).exec(n);if(i){var o=n.slice(i.index+i[0].length);t.className=n.slice(0,i.index)+(o?i[1]+o:"")}};Cl=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var Ml=function(e){e.select()};vl?Ml=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:sl&&(Ml=function(e){try{e.select()}catch(t){}}),f.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var kl,Nl,Ol=30,Wl={toString:function(){return"CodeMirror.Pass"}},Al={scroll:!1},Dl={origin:"*mouse"},Hl={origin:"+move"},Pl=[""],El=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Il=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Fl=!1,zl=!1,Rl=null,Bl=function(){function e(e){return e<=247?r.charAt(e):1424<=e&&e<=1524?"R":1536<=e&&e<=1773?n.charAt(e-1536):1774<=e&&e<=2220?"r":8192<=e&&e<=8203?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(r){if(!i.test(r))return!1;for(var n=r.length,c=[],f=0;f=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.post},eatSpace:function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);if(i(o)==i(e))return t!==!1&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}},Pe(at),at.prototype.lineNo=function(){return O(this)};var Ql,Jl={},es={},ts=null,rs=null,ns={left:0,right:0,top:0,bottom:0},is=0,os=null;sl?os=-.53:il?os=15:fl?os=-.7:dl&&(os=-1/3),jr.prototype=u({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var e=yl&&!pl?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new f,this.disableVert=new f},enableZeroWidthBar:function(e,t){function r(){var n=e.getBoundingClientRect(),i=document.elementFromPoint(n.left+1,n.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,r)}e.style.pointerEvents="auto",t.set(1e3,r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},jr.prototype),Kr.prototype=u({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},Kr.prototype);var ls={"native":jr,"null":Kr},ss=0;Sn.prototype.signal=function(e,t){He(e,t)&&this.events.push(arguments)},Sn.prototype.finish=function(){for(var e=this,t=0;t=0&&P(e,i.to())<=0)return n}return-1}},Pn.prototype={from:function(){return F(this.anchor,this.head)},to:function(){return I(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}},Ei.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=this,n=e,i=e+t;n1||!(this.children[0]instanceof Ei))){var a=[];this.collapse(a),this.children=[new Ei(a)],this.children[0].parent=this}},collapse:function(e){for(var t=this,r=0;r50){for(var s=o.lines.length%25+25,a=s;a10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=this,i=0;it.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=f,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&gn(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&mi(t.doc)),t&&Lt(t,"markerCleared",t,this),r&&nn(t),this.parent&&this.parent.clear()}},Bi.prototype.find=function(e,t){var r=this;null==e&&"bookmark"==this.type&&(e=1);for(var n,i,o=0;o=0;u--)Li(n,i[u]);a?di(this,a):this.cm&&en(this.cm)}),undo:pn(function(){Mi(this,"undo")}),redo:pn(function(){Mi(this,"redo")}),undoSelection:pn(function(){Mi(this,"undo",!0)}),redoSelection:pn(function(){Mi(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=R(this,e),t=R(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s=a.to||null==a.from&&i!=e.line||null!=a.from&&i==t.line&&a.from>=t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;ne?(t=e,!0):(e-=o,void++r)}),R(this,H(r,t))},indexFromPos:function(e){e=R(this,e);var t=e.ch;if(e.linet&&(t=e.from),null!=e.to&&e.to0)i=new H(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),H(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=T(e.doc,i.line-1).text;l&&(i=new H(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),H(i.line-1,l.length-1),i,"+transpose"))}r.push(new Pn(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return fn(e,function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange(e.doc.lineSeparator(),t[r].anchor,t[r].head,"+input");t=e.listSelections();for(var n=0;ne.firstLine()&&(n=H(n.line-1,T(e.doc,n.line-1).length)),i.ch==T(e.doc,i.line).text.length&&i.linet.viewTo-1)return!1;var o,l,s;n.line==t.viewFrom||0==(o=Sr(e,n.line))?(l=O(t.view[0].line),s=t.view[0].node):(l=O(t.view[o].line),s=t.view[o-1].node.nextSibling);var a,u,c=Sr(e,i.line);if(c==t.view.length-1?(a=t.viewTo-1,u=t.lineDiv.lastChild):(a=O(t.view[c+1].line)-1,u=t.view[c+1].node.previousSibling),!s)return!1;for(var f=e.doc.splitLines(qo(e,s,u,l,a)),h=M(e.doc,H(l,0),H(a,T(e.doc,a).text.length));f.length>1&&h.length>1;)if(g(f)==g(h))f.pop(),h.pop(),a--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,v=f[0],m=h[0],y=Math.min(v.length,m.length);d1||f[0]||P(C,S)?(Wi(e.doc,f,C,S,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&(this.composing=null,this.pollContent()||gn(this.cm),this.div.blur(),this.div.focus())},readFromDOMSoon:function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){e.readDOMTimeout=null,e.composing||!e.cm.isReadOnly()&&e.pollContent()||fn(e.cm,function(){return gn(e.cm)})},80))},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),this.cm.isReadOnly()||hn(this.cm,zo)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:y,resetPosition:y,needsContentAttribute:!0},Yo.prototype),Jo.prototype=u({init:function(e){function t(e){if(!Ae(i,e)){if(i.somethingSelected())Fo({lineWise:!1,text:i.getSelections()}),n.inaccurateSelection&&(n.prevInput="",n.inaccurateSelection=!1,l.value=ks.text.join("\n"),Ml(l));else{if(!i.options.lineWiseCopyCut)return;var t=Go(i);Fo({lineWise:!0,text:t.text}),"cut"==e.type?i.setSelections(t.ranges,null,Al):(n.prevInput="",l.value=t.text.join("\n"),Ml(l))}"cut"==e.type&&(i.state.cutIncoming=!0)}}var r=this,n=this,i=this.cm,o=this.wrapper=Uo(),l=this.textarea=o.firstChild;e.wrapper.insertBefore(o,e.wrapper.firstChild),vl&&(l.style.width="0px"),Vl(l,"input",function(){sl&&al>=9&&r.hasSelection&&(r.hasSelection=null),n.poll()}),Vl(l,"paste",function(e){Ae(i,e)||Ro(e,i)||(i.state.pasteIncoming=!0,n.fastPoll())}),Vl(l,"cut",t),Vl(l,"copy",t),Vl(e.scroller,"paste",function(t){Rt(e,t)||Ae(i,t)||(i.state.pasteIncoming=!0,n.focus())}),Vl(e.lineSpace,"selectstart",function(t){Rt(e,t)||Ee(t)}),Vl(l,"compositionstart",function(){var e=i.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}}),Vl(l,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=Tr(e);if(e.options.moveInputWithCursor){var i=fr(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},showSelection:function(e){var t=this.cm,n=t.display;r(n.cursorDiv,e.cursors),r(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=Xl&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&Ml(this.textarea),sl&&al>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",sl&&al>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!ml||o()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||Kl(r)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=r.value;if(i==n&&!t.somethingSelected())return!1;if(sl&&al>=9&&this.hasSelection===i||yl&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||n||(n=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,s=Math.min(n.length,i.length);l1e3||i.indexOf("\n")>-1?r.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){sl&&al>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=""+(e?l.value:"");l.value="⇚",l.value=t,n.prevInput=e?"":"",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.cssText=f,l.style.cssText=c,sl&&al<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!sl||sl&&al<9)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&""==n.prevInput?hn(i,Ci)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Cr(i,e),a=o.scroller.scrollTop;if(s&&!hl){var u=i.options.resetSelectionOnContextMenu;u&&i.doc.sel.contains(s)==-1&&hn(i,pi)(i.doc,In(s),Al);var c=l.style.cssText,f=n.wrapper.style.cssText;n.wrapper.style.cssText="position: absolute";var h=n.wrapper.getBoundingClientRect();l.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(sl?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var d;if(ul&&(d=window.scrollY),o.input.focus(),ul&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),sl&&al>=9&&t(),Ll){ze(e);var p=function(){Oe(window,"mouseup",p),setTimeout(r,20)};Vl(window,"mouseup",p)}else setTimeout(r,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:y,needsContentAttribute:!1},Jo.prototype),Wo(Po),jo(Po);var Ns="iter insert remove copy getEditor constructor".split(" ");for(var Os in cs.prototype)cs.prototype.hasOwnProperty(Os)&&h(Ns,Os)<0&&(Po.prototype[Os]=function(e){return function(){return e.apply(this.doc,arguments)}}(cs.prototype[Os]));return Pe(cs),Po.inputStyles={textarea:Jo,contenteditable:Yo},Po.defineMode=function(e){Po.defaults.mode||"null"==e||(Po.defaults.mode=e),je.apply(this,arguments)},Po.defineMIME=Ke,Po.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),Po.defineMIME("text/plain","null"),Po.defineExtension=function(e,t){Po.prototype[e]=t},Po.defineDocExtension=function(e,t){cs.prototype[e]=t},Po.fromTextArea=el,tl(Po),Po.version="5.21.0",Po})},{}],3:[function(e,t,r){(function(e){function r(e,t,r){function i(t){var r=g,n=v;return g=v=void 0,L=t,y=e.apply(n,r)}function o(e){return L=e,b=setTimeout(c,t),T?i(e):y}function a(e){var r=e-S,n=e-L,i=t-r;return M?x(i,m-n):i}function u(e){var r=e-S,n=e-L;return void 0===S||r>=t||r<0||M&&n>=m}function c(){var e=C();return u(e)?f(e):void(b=setTimeout(c,a(e)))}function f(e){return b=void 0,k&&g?i(e):(g=v=void 0,y)}function h(){void 0!==b&&clearTimeout(b),L=0,g=S=v=b=void 0}function d(){return void 0===b?y:f(C())}function p(){var e=C(),r=u(e);if(g=arguments,v=this,S=e,r){if(void 0===b)return o(S);if(M)return b=setTimeout(c,t),i(S)}return void 0===b&&(b=setTimeout(c,t)),y}var g,v,m,y,b,S,L=0,T=!1,M=!1,k=!0;if("function"!=typeof e)throw new TypeError(s);return t=l(t)||0,n(r)&&(T=!!r.leading,M="maxWait"in r,m=M?w(l(r.maxWait)||0,t):m,k="trailing"in r?!!r.trailing:k),p.cancel=h,p.flush=d,p}function n(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function i(e){return!!e&&"object"==typeof e}function o(e){return"symbol"==typeof e||i(e)&&b.call(e)==u}function l(e){if("number"==typeof e)return e;if(o(e))return a;
-if(n(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=n(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(c,"");var r=h.test(e);return r||d.test(e)?p(e.slice(2),r?2:8):f.test(e)?a:+e}var s="Expected a function",a=NaN,u="[object Symbol]",c=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,h=/^0b[01]+$/i,d=/^0o[0-7]+$/i,p=parseInt,g="object"==typeof e&&e&&e.Object===Object&&e,v="object"==typeof self&&self&&self.Object===Object&&self,m=g||v||Function("return this")(),y=Object.prototype,b=y.toString,w=Math.max,x=Math.min,C=function(){return m.Date.now()};t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,r){(function(r){"use strict";function n(e){return e?e.replace(/\r\n|\r/g,"\n"):e}var i="undefined"!=typeof window?window.React:"undefined"!=typeof r?r.React:null,o=e("react-dom"),l=o.findDOMNode,s=e("classnames"),a=e("lodash.debounce"),u=i.createClass({displayName:"CodeMirror",propTypes:{className:i.PropTypes.any,codeMirrorInstance:i.PropTypes.func,defaultValue:i.PropTypes.string,onChange:i.PropTypes.func,onFocusChange:i.PropTypes.func,onScroll:i.PropTypes.func,options:i.PropTypes.object,path:i.PropTypes.string,value:i.PropTypes.string,preserveScrollPosition:i.PropTypes.bool},getDefaultProps:function(){return{preserveScrollPosition:!1}},getCodeMirrorInstance:function(){return this.props.codeMirrorInstance||e("codemirror")},getInitialState:function(){return{isFocused:!1}},componentWillMount:function(){this.componentWillReceiveProps=a(this.componentWillReceiveProps,0)},componentDidMount:function(){var e=l(this.refs.textarea),t=this.getCodeMirrorInstance();this.codeMirror=t.fromTextArea(e,this.props.options),this.codeMirror.on("change",this.codemirrorValueChanged),this.codeMirror.on("focus",this.focusChanged.bind(this,!0)),this.codeMirror.on("blur",this.focusChanged.bind(this,!1)),this.codeMirror.on("scroll",this.scrollChanged),this.codeMirror.setValue(this.props.defaultValue||this.props.value||"")},componentWillUnmount:function(){this.codeMirror&&this.codeMirror.toTextArea()},componentWillReceiveProps:function(e){if(this.codeMirror&&void 0!==e.value&&n(this.codeMirror.getValue())!==n(e.value))if(this.props.preserveScrollPosition){var t=this.codeMirror.getScrollInfo();this.codeMirror.setValue(e.value),this.codeMirror.scrollTo(t.left,t.top)}else this.codeMirror.setValue(e.value);if("object"==typeof e.options)for(var r in e.options)e.options.hasOwnProperty(r)&&this.codeMirror.setOption(r,e.options[r])},getCodeMirror:function(){return this.codeMirror},focus:function(){this.codeMirror&&this.codeMirror.focus()},focusChanged:function(e){this.setState({isFocused:e}),this.props.onFocusChange&&this.props.onFocusChange(e)},scrollChanged:function(e){this.props.onScroll&&this.props.onScroll(e.getScrollInfo())},codemirrorValueChanged:function(e,t){this.props.onChange&&"setValue"!==t.origin&&this.props.onChange(e.getValue(),t)},render:function(){var e=s("ReactCodeMirror",this.state.isFocused?"ReactCodeMirror--focused":null,this.props.className);return i.createElement("div",{className:e},i.createElement("textarea",{ref:"textarea",name:this.props.path,defaultValue:this.props.value,autoComplete:"off"}))}});t.exports=u}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{classnames:1,codemirror:2,"lodash.debounce":3,"react-dom":void 0}]},{},[4])(4)});
\ No newline at end of file
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Codemirror=e()}}(function(){var e;return function t(e,r,n){function i(l,s){if(!r[l]){if(!e[l]){var a="function"==typeof require&&require;if(!s&&a)return a(l,!0);if(o)return o(l,!0);var u=new Error("Cannot find module '"+l+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[l]={exports:{}};e[l][0].call(c.exports,function(t){var r=e[l][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[l].exports}for(var o="function"==typeof require&&require,l=0;l0;--t)e.removeChild(e.firstChild);return e}function r(e,r){return t(e).appendChild(r)}function n(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o=t)return l+(t-o);l+=s-o,l+=r-l%r,o=s+1}}function h(e,t){for(var r=0;r=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function p(e){for(;Ol.length<=e;)Ol.push(g(Ol)+" ");return Ol[e]}function g(e){return e[e.length-1]}function v(e,t){for(var r=[],n=0;n""&&(e.toUpperCase()!=e.toLowerCase()||Nl.test(e))}function x(e,t){return t?!!(t.source.indexOf("\\w")>-1&&w(e))||t.test(e):w(e)}function C(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function S(e){return e.charCodeAt(0)>=768&&Al.test(e)}function L(e,t,r){for(;(r<0?t>0:t=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(t=e.first&&tr?I(r,k(e,r).text.length):U(t,k(e,t.line).text.length)}function U(e,t){var r=e.ch;return null==r||r>t?I(e.line,t):r<0?I(e.line,0):e}function G(e,t){for(var r=[],n=0;n=t:o.to>t);(n||(n=[])).push(new K(l,o.from,a?null:o.to))}}return n}function J(e,t,r){var n;if(e)for(var i=0;i=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from0&&s)for(var x=0;x0)){var c=[a,1],f=_(u.from,s.from),d=_(u.to,s.to);(f<0||!l.inclusiveLeft&&!f)&&c.push({from:u.from,to:s.from}),(d>0||!l.inclusiveRight&&!d)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-3}}return i}function re(e){var t=e.markedSpans;if(t){for(var r=0;r=0&&f<=0||c<=0&&f>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?_(u.to,r)>=0:_(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?_(u.from,n)<=0:_(u.from,n)<0)))return!0}}}function fe(e){for(var t;t=ae(e);)e=t.find(-1,!0).line;return e}function he(e){for(var t;t=ue(e);)e=t.find(1,!0).line;return e}function de(e){for(var t,r;t=ue(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function pe(e,t){var r=k(e,t),n=fe(r);return r==n?t:D(n)}function ge(e,t){if(t>e.lastLine())return t;var r,n=k(e,t);if(!ve(e,n))return t;for(;r=ue(n);)n=r.find(1,!0).line;return D(n)+1}function ve(e,t){var r=Wl&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function xe(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;ot||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function Ce(e,t,r){var n;El=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:El=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:El=i)}return null!=n?n:El}function Se(e,t){var r=e.order;return null==r&&(r=e.order=Pl(e.text,t)),r}function Le(e,t,r){var n=L(e.text,t+r,r);return n<0||n>e.text.length?null:n}function Te(e,t,r){var n=Le(e,t.ch,r);return null==n?null:new I(t.line,n,r<0?"after":"before")}function Me(e,t,r,n,i){if(e){var o=Se(r,t.doc.direction);if(o){var l,s=i<0?g(o):o[0],a=i<0==(1==s.level),u=a?"after":"before";if(s.level>0){var c=$t(t,r);l=i<0?r.text.length-1:0;var f=Zt(t,c,l).top;l=T(function(e){return Zt(t,c,e).top==f},i<0==(1==s.level)?s.from:s.to-1,l),"before"==u&&(l=Le(r,l,1,!0))}else l=i<0?s.to:s.from;return new I(n,l,u)}}return new I(n,i<0?r.text.length:0,i<0?"before":"after")}function ke(e,t,r,n){var i=Se(t,e.doc.direction);if(!i)return Te(t,r,n);r.ch>=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=Ce(i,r.ch,r.sticky),l=i[o];if("ltr"==e.doc.direction&&l.level%2==0&&(n>0?l.to>r.ch:l.from=l.from&&h>=c.begin)){var d=f?"before":"after";return new I(r.line,h,d)}}var p=function(e,t,n){for(var o=function(e,t){return t?new I(r.line,a(e,1),"before"):new I(r.line,e,"after")};e>=0&&e0==(1!=l.level),u=s?n.begin:a(n.end,-1);if(l.from<=u&&u0?c.end:a(c.begin,-1);return null==v||n>0&&v==t.text.length||!(g=p(n>0?0:i.length-1,n,u(v)))?null:g}function Oe(e,t){return e._handlers&&e._handlers[t]||Il}function Ne(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers,i=n&&n[t];if(i){var o=h(i,r);o>-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function Ae(e,t){var r=Oe(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function Pe(e){e.prototype.on=function(e,t){_l(this,e,t)},e.prototype.off=function(e,t){Ne(this,e,t)}}function Ie(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function _e(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Fe(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function He(e){Ie(e),_e(e)}function Re(e){return e.target||e.srcElement}function je(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),fl&&e.ctrlKey&&1==t&&(t=3),t}function ze(e){if(null==xl){var t=n("span","");r(e,n("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(xl=t.offsetWidth<=1&&t.offsetHeight>2&&!(Qo&&el<8))}var i=xl?n("span",""):n("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function Be(e){if(null!=Cl)return Cl;var n=r(e,document.createTextNode("AخA")),i=gl(n,0,1).getBoundingClientRect(),o=gl(n,1,2).getBoundingClientRect();return t(e),!(!i||i.left==i.right)&&(Cl=o.right-i.right<3)}function Ue(e){if(null!=zl)return zl;var t=r(e,n("span","x")),i=t.getBoundingClientRect(),o=gl(t,0,1).getBoundingClientRect();return zl=Math.abs(i.left-o.left)>1}function Ge(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Bl[e]=t}function Ve(e,t){Ul[e]=t}function Ye(e){if("string"==typeof e&&Ul.hasOwnProperty(e))e=Ul[e];else if(e&&"string"==typeof e.name&&Ul.hasOwnProperty(e.name)){var t=Ul[e.name];"string"==typeof t&&(t={name:t}),e=b(t,e),e.name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ye("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ye("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ke(e,t){t=Ye(t);var r=Bl[t.name];if(!r)return Ke(e,"text/plain");var n=r(e,t);if(Gl.hasOwnProperty(t.name)){var i=Gl[t.name];for(var o in i)i.hasOwnProperty(o)&&(n.hasOwnProperty(o)&&(n["_"+o]=n[o]),n[o]=i[o])}if(n.name=t.name,t.helperType&&(n.helperType=t.helperType),t.modeProps)for(var l in t.modeProps)n[l]=t.modeProps[l];return n}function Xe(e,t){var r=Gl.hasOwnProperty(e)?Gl[e]:Gl[e]={};c(t,r)}function qe(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r}function $e(e,t){for(var r;e.innerMode&&(r=e.innerMode(t),r&&r.mode!=e);)t=r.state,e=r.mode;return r||{mode:e,state:t}}function Ze(e,t,r){return!e.startState||e.startState(t,r)}function Je(e,t,r,n){var i=[e.state.modeGen],o={};lt(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var l=function(r){var n=e.state.overlays[r],l=1,s=0;lt(e,t.text,n.mode,!0,function(e,t){for(var r=l;se&&i.splice(l,1,e,i[l+1],o),l+=2,s=Math.min(e,o)}if(t)if(n.opaque)i.splice(r,l-r,e,"overlay "+t),l=r+2;else for(;re.options.maxHighlightLength?qe(e.doc.mode,n):n);t.stateAfter=n,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function et(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=st(e,t,r),l=o>n.first&&k(n,o-1).stateAfter;return l=l?qe(n.mode,l):Ze(n.mode),n.iter(o,t,function(r){tt(e,r.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&ot.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}function it(e,t,r,n){var i,o=function(e){return{start:f.start,end:f.pos,string:f.current(),type:i||null,state:e?qe(l.mode,c):c}},l=e.doc,s=l.mode;t=B(l,t);var a,u=k(l,t.line),c=et(e,t.line,r),f=new Vl(u.text,e.options.tabSize);for(n&&(a=[]);(n||f.pose.options.maxHighlightLength?(s=!1,l&&tt(e,t,n,f.pos),f.pos=t.length,a=null):a=ot(nt(r,f,n,h),o),h){var d=h[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;ul;--s){if(s<=o.first)return o.first;var a=k(o,s-1);if(a.stateAfter&&(!r||s<=o.frontier))return s;var u=f(a.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function at(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),re(e),ne(e,r);var i=n?n(e):1;i!=e.height&&A(e,i)}function ut(e){e.parent=null,re(e)}function ct(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?ql:Xl;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function ft(e,t){var r=i("span",null,null,tl?"padding-right: .1px":null),n={pre:i("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:(Qo||tl)&&e.getOption("lineWrapping")};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,s=void 0;n.pos=0,n.addToken=dt,Be(e.display.measure)&&(s=Se(l,e.doc.direction))&&(n.addToken=gt(n.addToken,s)),n.map=[];var u=t!=e.display.externalMeasured&&D(l);mt(l,n,Qe(e,l,u)),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=a(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=a(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(ze(e.display.measure))),0==o?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(tl){var c=n.content.lastChild;(/\bcm-tab\b/.test(c.className)||c.querySelector&&c.querySelector(".cm-tab"))&&(n.content.className="cm-tab-wrap-hack")}return Ae(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=a(n.pre.className,n.textClass||"")),n}function ht(e){var t=n("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function dt(e,t,r,i,o,l,s){if(t){var a,u=e.splitSpaces?pt(t,e.trailingSpace):t,c=e.cm.state.specialChars,f=!1;if(c.test(t)){a=document.createDocumentFragment();for(var h=0;;){c.lastIndex=h;var d=c.exec(t),g=d?d.index-h:t.length-h;if(g){var v=document.createTextNode(u.slice(h,h+g));Qo&&el<9?a.appendChild(n("span",[v])):a.appendChild(v),e.map.push(e.pos,e.pos+g,v),e.col+=g,e.pos+=g}if(!d)break;h+=g+1;var m=void 0;if("\t"==d[0]){var y=e.cm.options.tabSize,b=y-e.col%y;m=a.appendChild(n("span",p(b),"cm-tab")),m.setAttribute("role","presentation"),m.setAttribute("cm-text","\t"),e.col+=b}else"\r"==d[0]||"\n"==d[0]?(m=a.appendChild(n("span","\r"==d[0]?"␍":"","cm-invalidchar")),m.setAttribute("cm-text",d[0]),e.col+=1):(m=e.cm.options.specialCharPlaceholder(d[0]),m.setAttribute("cm-text",d[0]),Qo&&el<9?a.appendChild(n("span",[m])):a.appendChild(m),e.col+=1);e.map.push(e.pos,e.pos+1,m),e.pos++}}else e.col+=t.length,a=document.createTextNode(u),e.map.push(e.pos,e.pos+t.length,a),Qo&&el<9&&(f=!0),e.pos+=t.length;if(e.trailingSpace=32==u.charCodeAt(t.length-1),r||i||o||f||s){var w=r||"";i&&(w+=i),o&&(w+=o);var x=n("span",[a],w,s);return l&&(x.title=l),e.content.appendChild(x)}e.content.appendChild(a)}}function pt(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;iu&&f.from<=u));h++);if(f.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,f.to-u),i,o,null,s,a),o=null,n=n.slice(f.to-u),u=f.to}}}function vt(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function mt(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,f,h,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=f=s="",h=null,m=1/0;for(var y=[],b=void 0,w=0;wp||C.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&m>x.to&&(m=x.to,u=""),C.className&&(a+=" "+C.className),C.css&&(s=(s?s+";":"")+C.css),C.startStyle&&x.from==p&&(c+=" "+C.startStyle),C.endStyle&&x.to==m&&(b||(b=[])).push(C.endStyle,x.to),C.title&&!f&&(f=C.title),C.collapsed&&(!h||le(h.marker,C)<0)&&(h=x)):x.from>p&&m>x.from&&(m=x.from)}if(b)for(var S=0;S=d)break;for(var T=Math.min(d,m);;){if(v){var M=p+v.length;if(!h){var k=M>T?v.slice(0,T-p):v;t.addToken(t,k,l?l+a:a,c,p+k.length==m?u:"",f,s)}if(M>=T){v=v.slice(T-p),p=T;break}p=M,c=""}v=i.slice(o,o=r[g++]),l=ct(r[g++],t.cm.options)}}else for(var O=1;O2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function Yt(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;nr)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Kt(e,t){t=fe(t);var n=D(t),i=e.display.externalMeasured=new yt(e.doc,t,n);i.lineN=n;var o=i.built=ft(e,i);return i.text=o.pre,r(e.display.lineMeasure,o.pre),i}function Xt(e,t,r,n){return Zt(e,$t(e,t),r,n)}function qt(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&tt)&&(o=a-s,i=o-1,t>=a&&(l="right")),null!=i){if(n=e[u+2],s==a&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)n=e[(u-=3)+2],l="left";if("right"==r&&i==a-s)for(;u=0&&(r=e[i]).left==r.right;i--);return r}function er(e,t,r,n){var i,o=Jt(t.map,r,n),l=o.node,s=o.start,a=o.end,u=o.collapse;if(3==l.nodeType){for(var c=0;c<4;c++){for(;s&&S(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+a0&&(u=n="right");var f;i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==n?f.length-1:0]:l.getBoundingClientRect()}if(Qo&&el<9&&!s&&(!i||!i.left&&!i.right)){var h=l.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+yr(e.display),top:h.top,bottom:h.bottom}:Jl}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,v=t.view.measure.heights,m=0;m=n.text.length?(u=n.text.length,c="before"):u<=0&&(u=0,c="after"),!a)return l("before"==c?u-1:u,"before"==c);var f=Ce(a,u,c),h=El,d=s(u,f,"before"==c);return null!=h&&(d.other=s(u,h,"before"!=c)),d}function fr(e,t){var r=0;t=B(e.doc,t),e.options.lineWrapping||(r=yr(e.display)*t.ch);var n=k(e.doc,t.line),i=ye(n)+Rt(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function hr(e,t,r,n,i){var o=I(e,t,r);return o.xRel=i,n&&(o.outside=!0),o}function dr(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,r<0)return hr(n.first,0,null,!0,-1);var i=W(n,r),o=n.first+n.size-1;if(i>o)return hr(n.first+n.size-1,k(n,o).text.length,null,!0,1);t<0&&(t=0);for(var l=k(n,i);;){var s=vr(e,l,i,t,r),a=ue(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=D(l=u.to.line)}}function pr(e,t,r,n){var i=function(n){return sr(e,t,Zt(e,r,n),"line")},o=t.text.length,l=T(function(e){return i(e-1).bottom<=n},o,0);return o=T(function(e){return i(e).top>n},l,o),{begin:l,end:o}}function gr(e,t,r,n){var i=sr(e,t,Zt(e,r,n),"line").top;return pr(e,t,r,i)}function vr(e,t,r,n,i){i-=ye(t);var o,l=0,s=t.text.length,a=$t(e,t),u=Se(t,e.doc.direction);if(u){if(e.options.lineWrapping){var c;c=pr(e,t,a,i),l=c.begin,s=c.end,c}o=new I(r,l);var f,h,d=cr(e,o,"line",t,a).left,p=dMath.abs(f)){if(g<0==f<0)throw new Error("Broke out of infinite loop in coordsCharInner");o=h}}else{var v=T(function(r){var o=sr(e,t,Zt(e,a,r),"line");return o.top>i?(s=Math.min(r,s),!0):!(o.bottom<=i)&&(o.left>n||!(o.rightm.right?1:0,o}function mr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Kl){Kl=n("pre");for(var i=0;i<49;++i)Kl.appendChild(document.createTextNode("x")),Kl.appendChild(n("br"));Kl.appendChild(document.createTextNode("x"))}r(e.measure,Kl);var o=Kl.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function yr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t]);r(e.measure,i);var o=t.getBoundingClientRect(),l=(o.right-o.left)/10;return l>2&&(e.cachedCharWidth=l),l||10}function br(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:wr(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function wr(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function xr(e){var t=mr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/yr(e.display)-3);return function(i){if(ve(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l=e.display.viewTo)return null;if(t-=e.display.viewFrom,t<0)return null;for(var r=e.display.view,n=0;n=e.display.viewTo||s.to().line3&&(i(d,g.top,null,g.bottom),d=c,g.bottoma.bottom||u.bottom==a.bottom&&u.right>a.right)&&(a=u),d0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Ar(e){e.state.focused||(e.display.input.focus(),Wr(e))}function Dr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Er(e))},100)}function Wr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ae(e,"focus",e,t),e.state.focused=!0,s(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),tl&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Nr(e))}function Er(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Ae(e,"blur",e,t),e.state.focused=!1,yl(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Pr(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=wr(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;l.001||a<-.001)&&(A(i.line,o),Fr(i.line),i.rest))for(var u=0;u=l&&(o=W(t,ye(k(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function Rr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,qo||Tn(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbars.setScrollTop(t),qo&&Tn(e),wn(e,100))}function jr(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,Pr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function zr(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}}function Br(e){var t=zr(e);return t.x*=es,t.y*=es,t}function Ur(e,t){var r=zr(t),n=r.x,i=r.y,o=e.display,l=o.scroller,s=l.scrollWidth>l.clientWidth,a=l.scrollHeight>l.clientHeight;if(n&&s||i&&a){if(i&&fl&&tl)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var f=0;f(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!sl){var l=n("div","",null,"position: absolute;\n top: "+(t.top-r.viewOffset-Rt(e.display))+"px;\n height: "+(t.bottom-t.top+Bt(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(l),l.scrollIntoView(o),e.display.lineSpace.removeChild(l)}}}function qr(e,t,r,n){null==n&&(n=0);for(var i,o=0;o<5;o++){var l=!1,s=cr(e,t),a=r&&r!=t?cr(e,r):s;i={left:Math.min(s.left,a.left),top:Math.min(s.top,a.top)-n,right:Math.max(s.left,a.left),bottom:Math.max(s.bottom,a.bottom)+n};var u=Zr(e,i),c=e.doc.scrollTop,f=e.doc.scrollLeft;if(null!=u.scrollTop&&(Rr(e,u.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(l=!0)),null!=u.scrollLeft&&(jr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-f)>1&&(l=!0)),!l)break}return i}function $r(e,t){var r=Zr(e,t);null!=r.scrollTop&&Rr(e,r.scrollTop),null!=r.scrollLeft&&jr(e,r.scrollLeft)}function Zr(e,t){var r=e.display,n=mr(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:r.scroller.scrollTop,o=Gt(e),l={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+jt(r),a=t.tops-n;if(t.topi+o){var c=Math.min(t.top,(u?s:t.bottom)-o);c!=i&&(l.scrollTop=c)}var f=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:r.scroller.scrollLeft,h=Ut(e)-(e.options.fixedGutter?r.gutters.offsetWidth:0),d=t.right-t.left>h;return d&&(t.right=t.left+h),t.left<10?l.scrollLeft=0:t.lefth+f-3&&(l.scrollLeft=t.right+(d?0:10)-h),l}function Jr(e,t,r){null==t&&null==r||en(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Qr(e){en(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?I(t.line,t.ch-1):t,n=I(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin}}function en(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=fr(e,t.from),n=fr(e,t.to),i=Zr(e,{left:Math.min(r.left,n.left),top:Math.min(r.top,n.top)-t.margin,right:Math.max(r.right,n.right),bottom:Math.max(r.bottom,n.bottom)+t.margin});e.scrollTo(i.scrollLeft,i.scrollTop)}}function tn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++is},wt(e.curOp)}function rn(e){var t=e.curOp;Ct(t,function(e){for(var t=0;t=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new os(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function ln(e){e.updatedDisplay=e.mustUpdate&&Sn(e.cm,e.update)}function sn(e){var t=e.cm,r=t.display;e.updatedDisplay&&_r(t),e.barMeasure=Gr(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Xt(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Bt(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ut(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection(e.focus))}function an(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeftt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Wl&&pe(e.doc,t)i.viewFrom?vn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)vn(e);else if(t<=i.viewFrom){var o=mn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):vn(e)}else if(r>=i.viewTo){var l=mn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):vn(e)}else{var s=mn(e,t,t,-1),a=mn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(bt(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):vn(e)}var u=i.externalMeasured;u&&(r=i.lineN&&t=n.viewTo)){var o=n.view[Lr(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);h(l,r)==-1&&l.push(r)}}}function vn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function mn(e,t,r,n){var i,o=Lr(e,t),l=e.display.view;if(!Wl||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,a=0;a0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;pe(e.doc,r)!=r;){if(o==(n<0?0:l.length-1))return null;r+=n*l[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function yn(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=bt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=bt(e,t,n.viewFrom).concat(n.view):n.viewFromr&&(n.view=n.view.slice(0,Lr(e,r)))),n.viewTo=r}function bn(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo)){var r=+new Date+e.options.workTime,n=qe(t.mode,et(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var l=o.styles,s=o.text.length>e.options.maxHighlightLength,a=Je(e,o,s?qe(t.mode,n):n,!0);o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var f=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),h=0;!f&&hr)return wn(e,e.options.workDelay),!0}),i.length&&cn(e,function(){for(var t=0;t=n.viewFrom&&r.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==bn(e))return!1;Ir(e)&&(vn(e),r.dims=br(e));var o=i.first+i.size,s=Math.max(r.visible.from-e.options.viewportMargin,i.first),a=Math.min(o,r.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(o,n.viewTo)),Wl&&(s=pe(e.doc,s),a=ge(e.doc,a));var u=s!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=r.wrapperHeight||n.lastWrapWidth!=r.wrapperWidth;yn(e,s,a),n.viewOffset=ye(k(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=bn(e);if(!u&&0==c&&!r.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var f=l();return c>4&&(n.lineDiv.style.display="none"),Mn(e,n.updateLineNumbers,r.dims),c>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,f&&l()!=f&&f.offsetHeight&&f.focus(),t(n.cursorDiv),t(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,u&&(n.lastWrapHeight=r.wrapperHeight,n.lastWrapWidth=r.wrapperWidth,wn(e,400)),n.updateLineNumbers=null,!0}function Ln(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Ut(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+jt(e.display)-Gt(e),r.top)}),t.visible=Hr(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Sn(e,t);n=!1){_r(e);var i=Gr(e);Tr(e),Vr(e,i),On(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Tn(e,t){var r=new os(e,t);if(Sn(e,r)){_r(e),Ln(e,r);var n=Gr(e);Tr(e),Vr(e,n),On(e,n),r.finish()}}function Mn(e,r,n){function i(t){var r=t.nextSibling;return tl&&fl&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var o=e.display,l=e.options.lineNumbers,s=o.lineDiv,a=s.firstChild,u=o.view,c=o.viewFrom,f=0;f-1&&(p=!1),Tt(e,d,c,n)),p&&(t(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(P(e.options,c)))),a=d.node.nextSibling}else{var g=Et(e,d,c,n);s.insertBefore(g,a)}c+=d.size}for(;a;)a=i(a)}function kn(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function On(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Bt(e)+"px"}function Nn(e){var r=e.display.gutters,i=e.options.gutters;t(r);for(var o=0;o-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function Dn(e,t){var r=e[t];e.sort(function(e,t){return _(e.from(),t.from())}),t=h(e,r);for(var n=1;n=0){var l=j(o.from(),i.from()),s=R(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new ss(a?s:l,a?l:s))}}return new ls(e,t)}function Wn(e,t){return new ls([new ss(e,t||e)],0)}function En(e){return e.text?I(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Pn(e,t){if(_(e,t.from)<0)return e;if(_(e,t.to)<=0)return En(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;
+return e.line==t.to.line&&(n+=En(t).ch-t.to.ch),I(r,n)}function In(e,t){for(var r=[],n=0;n1&&e.remove(s.line+1,p-1),e.insert(s.line+1,y)}St(e,"change",e,t)}function Bn(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;l1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}function $n(e,t,r,n){var i=e.history;i.undone.length=0;var o,l,s=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=qn(i,i.lastOp==n)))l=g(o.changes),0==_(t.from,t.to)&&0==_(t.from,l.to)?l.to=En(t):o.changes.push(Kn(e,t));else{var a=g(i.done);for(a&&a.ranges||Qn(e.sel,i.done),o={changes:[Kn(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||Ae(e,"historyAdded")}function Zn(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Jn(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||Zn(e,o,g(i.done),t))?i.done[i.done.length-1]=t:Qn(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&Xn(i.undone)}function Qn(e,t){var r=g(t);r&&r.ranges&&r.equals(e)||t.push(e)}function ei(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function ti(e){if(!e)return null;for(var t,r=0;r-1&&(g(s)[f]=u[f],delete u[f])}}}return n}function oi(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=_(r,i)<0;o!=_(n,i)<0?(i=r,r=n):o!=_(r,n)<0&&(r=n)}return new ss(i,r)}return new ss(n||r,r)}function li(e,t,r,n){hi(e,new ls([oi(e,e.sel.primary(),t,r)],0),n)}function si(e,t,r){for(var n=[],i=0;i=t.ch:s.to>t.ch))){if(i&&(Ae(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u=a.find(n<0?1:-1),c=void 0;if((n<0?a.inclusiveRight:a.inclusiveLeft)&&(u=bi(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=_(u,r))&&(n<0?c<0:c>0))return mi(e,u,t,n,i)}var f=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(f=bi(e,f,n,f.line==t.line?o:null)),f?mi(e,f,t,n,i):null}}return t}function yi(e,t,r,n,i){var o=n||1,l=mi(e,t,r,o,i)||!i&&mi(e,t,r,o,!0)||mi(e,t,r,-o,i)||!i&&mi(e,t,r,-o,!0);return l?l:(e.cantEdit=!0,I(e.first,0))}function bi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?B(e,I(t.line-1)):null:r>0&&t.ch==(n||k(e,t.line)).text.length?t.line=0;--i)Si(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else Si(e,t)}}function Si(e,t){if(1!=t.text.length||""!=t.text[0]||0!=_(t.from,t.to)){var r=In(e,t);$n(e,t,r,e.cm?e.cm.curOp.id:NaN),Mi(e,t,r,Q(e,t));var n=[];Bn(e,function(e,r){r||h(n,e.history)!=-1||(Di(e.history,t),n.push(e.history)),Mi(e,t,null,Q(e,t))})}}function Li(e,t,r){if(!e.cm||!e.cm.state.suppressEdits||r){for(var n,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a=0;--d){var p=f(d);if(p)return p.v}}}}function Ti(e,t){if(0!=t&&(e.first+=t,e.sel=new ls(v(e.sel.ranges,function(e){return new ss(I(e.anchor.line+t,e.anchor.ch),I(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){pn(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;ne.lastLine())){if(t.from.lineo&&(t={from:t.from,to:I(o,k(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=O(e,t.from,t.to),r||(r=In(e,t)),e.cm?ki(e.cm,t,n):zn(e,t,n),di(e,r,Tl)}}function ki(e,t,r){var n=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=D(fe(k(n,o.line))),n.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0,!0})),n.sel.contains(t.from,t.to)>-1&&We(e),zn(n,t,r,xr(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=be(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,o.line),wn(e,400);var u=t.text.length-(l.line-o.line)-1;t.full?pn(e):o.line!=l.line||1!=t.text.length||jn(e.doc,t)?pn(e,o.line,l.line+1,u):gn(e,o.line,"text");var c=Ee(e,"changes"),f=Ee(e,"change");if(f||c){var h={from:o,to:l,text:t.text,removed:t.removed,origin:t.origin};f&&St(e,"change",e,h),c&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Oi(e,t,r,n,i){if(n||(n=r),_(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),Ci(e,{from:r,to:n,text:t,origin:i})}function Ni(e,t,r,n){r0||0==s&&l.clearWhenEmpty!==!1)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=i("span",[l.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(ce(e,t.line,t,r,l)||t.line!=r.line&&ce(e,r.line,t,r,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");Y()}l.addToHistory&&$n(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var a,u=t.line,f=e.cm;if(e.iter(u,r.line+1,function(e){f&&l.collapsed&&!f.options.lineWrapping&&fe(e)==f.display.maxLine&&(a=!0),l.collapsed&&u!=t.line&&A(e,0),$(e,new K(l,u==t.line?t.ch:null,u==r.line?r.ch:null)),++u}),l.collapsed&&e.iter(t.line,r.line+1,function(t){ve(e,t)&&A(t,0)}),l.clearOnEnter&&_l(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(V(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++fs,l.atomic=!0),f){if(a&&(f.curOp.updateMaxLine=!0),l.collapsed)pn(f,t.line,r.line+1);else if(l.className||l.title||l.startStyle||l.endStyle||l.css)for(var h=t.line;h<=r.line;h++)gn(f,h,"text");l.atomic&&gi(f.doc),St(f,"markerAdded",f,l)}return l}function _i(e,t,r,n,i){n=c(n),n.shared=!1;var o=[Ii(e,t,r,n,i)],l=o[0],s=n.widgetNode;return Bn(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Ii(e,B(e,t),B(e,r),n,i));for(var a=0;a-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var u=e.dataTransfer.getData("Text");if(u){var c;if(t.state.draggingText&&!t.state.draggingText.copy&&(c=t.listSelections()),di(t.doc,Wn(r,r)),c)for(var f=0;f=0;t--)Oi(e.doc,"",n[t].from,n[t].to,"+delete");Qr(e)})}function to(e,t){var r=k(e.doc,t),n=fe(r);return n!=r&&(t=D(n)),Me(!0,e,n,t,1)}function ro(e,t){var r=k(e.doc,t),n=he(r);return n!=r&&(t=D(n)),Me(!0,e,r,t,-1)}function no(e,t){var r=to(e,t.line),n=k(e.doc,r.line),i=Se(n,e.doc.direction);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return I(r.line,l?0:o,r.sticky)}return r}function io(e,t,r){if("string"==typeof t&&(t=Ts[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Ll}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function oo(e,t,r){for(var n=0;ni-400&&0==_(Ls.pos,r)?n="triple":Ss&&Ss.time>i-400&&0==_(Ss.pos,r)?(n="double",Ls={time:i,pos:r}):(n="single",Ss={time:i,pos:r});var o,s=e.doc.sel,a=fl?t.metaKey:t.ctrlKey;e.options.dragDrop&&Fl&&!e.isReadOnly()&&"single"==n&&(o=s.contains(r))>-1&&(_((o=s.ranges[o]).from(),r)<0||r.xRel>0)&&(_(o.to(),r)>0||r.xRel<0)?vo(e,t,r,a):mo(e,t,r,n,a)}function vo(e,t,r,n){var i=e.display,o=!1,l=fn(e,function(t){tl&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ne(document,"mouseup",l),Ne(document,"mousemove",s),Ne(i.scroller,"dragstart",a),Ne(i.scroller,"drop",l),o||(Ie(t),n||li(e.doc,r),tl||Qo&&9==el?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())}),s=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},a=function(){return o=!0};tl&&(i.scroller.draggable=!0),e.state.draggingText=l,l.copy=fl?t.altKey:t.ctrlKey,i.scroller.dragDrop&&i.scroller.dragDrop(),_l(document,"mouseup",l),_l(document,"mousemove",s),_l(i.scroller,"dragstart",a),_l(i.scroller,"drop",l),Dr(e),setTimeout(function(){return i.input.focus()},20)}function mo(e,t,r,n,i){function o(t){if(0!=_(b,t))if(b=t,"rect"==n){for(var i=[],o=e.options.tabSize,l=f(k(c,r.line).text,r.ch,o),s=f(k(c,t.line).text,t.ch,o),a=Math.min(l,s),u=Math.max(l,s),v=Math.min(r.line,t.line),m=Math.min(e.lastLine(),Math.max(r.line,t.line));v<=m;v++){var y=k(c,v).text,w=d(y,a,o);a==u?i.push(new ss(I(v,w),I(v,w))):y.length>w&&i.push(new ss(I(v,w),I(v,d(y,u,o))))}i.length||i.push(new ss(r,r)),hi(c,Dn(g.ranges.slice(0,p).concat(i),p),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x=h,C=x.anchor,S=t;if("single"!=n){var L;L="double"==n?e.findWordAt(t):new ss(I(t.line,0),B(c,I(t.line+1,0))),_(L.anchor,C)>0?(S=L.head,C=j(x.from(),L.anchor)):(S=L.anchor,C=R(x.to(),L.head))}var T=g.ranges.slice(0);T[p]=new ss(B(c,C),S),hi(c,Dn(T,p),Ml)}}function s(t){var r=++x,i=Sr(e,t,!0,"rect"==n);if(i)if(0!=_(i,b)){e.curOp.focus=l(),o(i);var a=Hr(u,c);(i.line>=a.to||i.linew.bottom?20:0;f&&setTimeout(fn(e,function(){x==r&&(u.scroller.scrollTop+=f,s(t))}),50)}}function a(t){e.state.selectingText=!1,x=1/0,Ie(t),u.input.focus(),Ne(document,"mousemove",C),Ne(document,"mouseup",S),c.history.lastSelOrigin=null}var u=e.display,c=e.doc;Ie(t);var h,p,g=c.sel,v=g.ranges;if(i&&!t.shiftKey?(p=c.sel.contains(r),h=p>-1?v[p]:new ss(r,r)):(h=c.sel.primary(),p=c.sel.primIndex),hl?t.shiftKey&&t.metaKey:t.altKey)n="rect",i||(h=new ss(r,r)),r=Sr(e,t,!0,!0),p=-1;else if("double"==n){var m=e.findWordAt(r);h=e.display.shift||c.extend?oi(c,h,m.anchor,m.head):m}else if("triple"==n){var y=new ss(I(r.line,0),B(c,I(r.line+1,0)));h=e.display.shift||c.extend?oi(c,h,y.anchor,y.head):y}else h=oi(c,h,r);i?p==-1?(p=v.length,hi(c,Dn(v.concat([h]),p),{scroll:!1,origin:"*mouse"})):v.length>1&&v[p].empty()&&"single"==n&&!t.shiftKey?(hi(c,Dn(v.slice(0,p).concat(v.slice(p+1)),0),{scroll:!1,origin:"*mouse"}),g=c.sel):ai(c,p,h,Ml):(p=0,hi(c,new ls([h],0),Ml),g=c.sel);var b=r,w=u.wrapper.getBoundingClientRect(),x=0,C=fn(e,function(e){je(e)?s(e):a(e)}),S=fn(e,a);e.state.selectingText=S,_l(document,"mousemove",C),_l(document,"mouseup",S)}function yo(e,t,r,n){var i,o;try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&Ie(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!Ee(e,r))return Fe(t);o-=s.top-l.viewOffset;for(var a=0;a=i){var c=W(e.doc,o),f=e.options.gutters[a];return Ae(e,r,e,c,f,t),Fe(t)}}}function bo(e,t){return yo(e,t,"gutterClick",!0)}function wo(e,t){Ht(e.display,t)||xo(e,t)||De(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function xo(e,t){return!!Ee(e,"gutterContextMenu")&&yo(e,t,"gutterContextMenu",!1)}function Co(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ir(e)}function So(e){function t(t,n,i,o){e.defaults[t]=n,i&&(r[t]=o?function(e,t,r){r!=Os&&i(e,t,r)}:i)}var r=e.optionHandlers;e.defineOption=t,e.Init=Os,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,Hn(e)},!0),t("indentUnit",2,Hn,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){Rn(e),ir(e),pn(e)},!0),t("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var r=[],n=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(o==-1)break;i=o+t.length,r.push(I(n,o))}n++});for(var i=r.length-1;i>=0;i--)Oi(e.doc,t,r[i],I(r[i].line,r[i].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=Os&&e.refresh()}),t("specialCharPlaceholder",ht,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",cl?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("rtlMoveVisually",!dl),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){Co(e),Lo(e)},!0),t("keyMap","default",function(e,t,r){var n=Qi(t),i=r!=Os&&Qi(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),t("extraKeys",null),t("lineWrapping",!1,Mo,!0),t("gutters",[],function(e){An(e.options),Lo(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?wr(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return Vr(e)},!0),t("scrollbarStyle","native",function(e){Kr(e),Vr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e){An(e.options),Lo(e)},!0),t("firstLineNumber",1,Lo,!0),t("lineNumberFormatter",function(e){return e},Lo,!0),t("showCursorWhenSelecting",!1,Tr,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("readOnly",!1,function(e,t){"nocursor"==t?(Er(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,To),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Tr,!0),t("singleCursorHeightPerLine",!0,Tr,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,Rn,!0),t("addModeClass",!1,Rn,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,Rn,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null),t("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0)}function Lo(e){Nn(e),pn(e),Pr(e)}function To(e,t,r){var n=r&&r!=Os;if(!t!=!n){var i=e.display.dragFunctions,o=t?_l:Ne;o(e.display.scroller,"dragstart",i.start),o(e.display.scroller,"dragenter",i.enter),o(e.display.scroller,"dragover",i.over),o(e.display.scroller,"dragleave",i.leave),o(e.display.scroller,"drop",i.drop)}}function Mo(e){e.options.lineWrapping?(s(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(yl(e.display.wrapper,"CodeMirror-wrap"),we(e)),Cr(e),pn(e),ir(e),setTimeout(function(){return Vr(e)},100)}function ko(e,t){var r=this;if(!(this instanceof ko))return new ko(e,t);this.options=t=t?c(t):{},c(Ns,t,!1),An(t);var n=t.value;"string"==typeof n&&(n=new gs(n,t.mode,null,t.lineSeparator,t.direction)),this.doc=n;var i=new ko.inputStyles[t.inputStyle](this),o=this.display=new M(e,n,i);o.wrapper.CodeMirror=this,Nn(this),Co(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Kr(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 wl,keySeq:null,specialChars:null},t.autofocus&&!cl&&o.input.focus(),Qo&&el<11&&setTimeout(function(){return r.display.input.reset(!0)},20),Oo(this),Vi(),tn(this),this.curOp.forceUpdate=!0,Un(this,n),t.autofocus&&!cl||this.hasFocus()?setTimeout(u(Wr,this),20):Er(this);for(var l in As)As.hasOwnProperty(l)&&As[l](r,t[l],Os);Ir(this),t.finishInit&&t.finishInit(this);for(var s=0;s400}var i=e.display;_l(i.scroller,"mousedown",fn(e,po)),Qo&&el<11?_l(i.scroller,"dblclick",fn(e,function(t){if(!De(e,t)){var r=Sr(e,t);if(r&&!bo(e,t)&&!Ht(e.display,t)){Ie(t);var n=e.findWordAt(r);li(e.doc,n.anchor,n.head)}}})):_l(i.scroller,"dblclick",function(t){return De(e,t)||Ie(t)}),ml||_l(i.scroller,"contextmenu",function(t){return wo(e,t)});var o,l={end:0};_l(i.scroller,"touchstart",function(t){
+if(!De(e,t)&&!r(t)){i.input.ensurePolled(),clearTimeout(o);var n=+new Date;i.activeTouch={start:n,moved:!1,prev:n-l.end<=300?l:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),_l(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),_l(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!Ht(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,s=e.coordsChar(i.activeTouch,"page");l=!o.prev||n(o,o.prev)?new ss(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new ss(I(s.line,0),B(e.doc,I(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),Ie(r)}t()}),_l(i.scroller,"touchcancel",t),_l(i.scroller,"scroll",function(){i.scroller.clientHeight&&(Rr(e,i.scroller.scrollTop),jr(e,i.scroller.scrollLeft,!0),Ae(e,"scroll",e))}),_l(i.scroller,"mousewheel",function(t){return Ur(e,t)}),_l(i.scroller,"DOMMouseScroll",function(t){return Ur(e,t)}),_l(i.wrapper,"scroll",function(){return i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){De(e,t)||He(t)},over:function(t){De(e,t)||(Bi(e,t),He(t))},start:function(t){return zi(e,t)},drop:fn(e,ji),leave:function(t){De(e,t)||Ui(e)}};var s=i.input.getField();_l(s,"keyup",function(t){return fo.call(e,t)}),_l(s,"keydown",fn(e,uo)),_l(s,"keypress",fn(e,ho)),_l(s,"focus",function(t){return Wr(e,t)}),_l(s,"blur",function(t){return Er(e,t)})}function No(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=et(e,t):r="prev");var l=e.options.tabSize,s=k(o,t),a=f(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==Ll||u>150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?f(k(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var h="",d=0;if(e.options.indentWithTabs)for(var g=Math.floor(u/l);g;--g)d+=l,h+="\t";if(d1)if(Ws&&Ws.text.join("\n")==t){if(n.ranges.length%Ws.text.length==0){a=[];for(var u=0;u=0;f--){var h=n.ranges[f],d=h.from(),p=h.to();h.empty()&&(r&&r>0?d=I(d.line,d.ch-r):e.state.overwrite&&!l?p=I(p.line,Math.min(k(o,p.line).text.length,p.ch+g(s).length)):Ws&&Ws.lineWise&&Ws.text.join("\n")==t&&(d=p=I(d.line,0))),c=e.curOp.updateInput;var m={from:d,to:p,text:a?a[f%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Ci(e.doc,m),St(e,"inputRead",e,m)}t&&!l&&Eo(e,t),Qr(e),e.curOp.updateInput=c,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Wo(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||cn(t,function(){return Do(t,r,0,null,"paste")}),!0}function Eo(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s-1){l=No(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(k(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=No(e,i.head.line,"smart"));l&&St(e,"electricInput",e,i.head.line)}}}function Po(e){for(var t=[],r=[],n=0;n=e.first+e.size)&&(t=new I(n,t.ch,t.sticky),u=k(e,n))}function l(n){var l;if(l=i?ke(e.cm,u,t,r):Te(u,t,r),null==l){if(n||!o())return!1;t=Me(i,e.cm,u,t.line,r)}else t=l;return!0}var s=t,a=r,u=k(e,t.line);if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var c=null,f="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),d=!0;!(r<0)||l(!d);d=!1){var p=u.text.charAt(t.ch)||"\n",g=x(p,h)?"w":f&&"\n"==p?"n":!f||/\s/.test(p)?null:"p";if(!f||d||g||(g="s"),c&&c!=g){r<0&&(r=1,l(),t.sticky="after");break}if(g&&(c=g),r>0&&!l(!d))break}var v=yi(e,t,s,a,!0);return F(s,v)&&(v.hitSide=!0),v}function Ho(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),a=Math.max(s-.5*mr(e.display),3);i=(r>0?t.bottom:t.top)+r*a}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(var u;u=dr(e,l,i),u.outside;){if(r<0?i<=0:i>=o.height){u.hitSide=!0;break}i+=5*r}return u}function Ro(e,t){var r=qt(e,t.line);if(!r||r.hidden)return null;var n=k(e.doc,t.line),i=Yt(r,n,t.line),o=Se(n,e.doc.direction),l="left";if(o){var s=Ce(o,t.ch);l=s%2?"right":"left"}var a=Jt(i.map,t.ch,l);return a.offset="right"==a.collapse?a.end:a.start,a}function jo(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function zo(e,t){return t&&(e.bad=!0),e}function Bo(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function l(){c&&(u+=f,c=!1)}function s(e){e&&(l(),u+=e)}function a(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return void s(r||t.textContent.replace(/\u200b/g,""));var u,h=t.getAttribute("cm-marker");if(h){var d=e.findMarks(I(n,0),I(i+1,0),o(+h));return void(d.length&&(u=d[0].find())&&s(O(e.doc,u.from,u.to).join(f)))}if("false"==t.getAttribute("contenteditable"))return;var p=/^(pre|div|p)$/i.test(t.nodeName);p&&l();for(var g=0;g=15&&(il=!1,tl=!0);var gl,vl=fl&&(rl||il&&(null==pl||pl<12.11)),ml=qo||Qo&&el>=9,yl=function(t,r){var n=t.className,i=e(r).exec(n);if(i){var o=n.slice(i.index+i[0].length);t.className=n.slice(0,i.index)+(o?i[1]+o:"")}};gl=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var bl=function(e){e.select()};al?bl=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:Qo&&(bl=function(e){try{e.select()}catch(t){}});var wl=function(){this.id=null};wl.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var xl,Cl,Sl=30,Ll={toString:function(){return"CodeMirror.Pass"}},Tl={scroll:!1},Ml={origin:"*mouse"},kl={origin:"+move"},Ol=[""],Nl=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Al=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Dl=!1,Wl=!1,El=null,Pl=function(){function e(e){return e<=247?r.charAt(e):1424<=e&&e<=1524?"R":1536<=e&&e<=1785?n.charAt(e-1536):1774<=e&&e<=2220?"r":8192<=e&&e<=8203?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/;return function(r,n){var u="ltr"==n?"L":"R";if(0==r.length||"ltr"==n&&!i.test(r))return!1;for(var c=r.length,f=[],h=0;h=this.string.length},Vl.prototype.sol=function(){return this.pos==this.lineStart},Vl.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Vl.prototype.next=function(){if(this.post},Vl.prototype.eatSpace=function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},Vl.prototype.skipToEnd=function(){this.pos=this.string.length},Vl.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Vl.prototype.backUp=function(e){this.pos-=e},Vl.prototype.column=function(){return this.lastColumnPos0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);if(i(o)==i(e))return t!==!1&&(this.pos+=e.length),!0},Vl.prototype.current=function(){return this.string.slice(this.start,this.pos)},Vl.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}};var Yl=function(e,t,r){this.text=e,ne(this,t),this.height=r?r(this):1};Yl.prototype.lineNo=function(){return D(this)},Pe(Yl);var Kl,Xl={},ql={},$l=null,Zl=null,Jl={left:0,right:0,top:0,bottom:0},Ql=0,es=null;Qo?es=-.53:qo?es=15:nl?es=-.7:ol&&(es=-1/3);var ts=function(e,t,r){this.cm=r;var i=this.vert=n("div",[n("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=n("div",[n("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(i),e(o),_l(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),_l(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,Qo&&el<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ts.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},ts.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},ts.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},ts.prototype.zeroWidthHack=function(){var e=fl&&!ll?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new wl,this.disableVert=new wl},ts.prototype.enableZeroWidthBar=function(e,t,r){function n(){var i=e.getBoundingClientRect(),o="vert"==r?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1);o!=e?e.style.pointerEvents="none":t.set(1e3,n)}e.style.pointerEvents="auto",t.set(1e3,n)},ts.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var rs=function(){};rs.prototype.update=function(){return{bottom:0,right:0}},rs.prototype.setScrollLeft=function(){},rs.prototype.setScrollTop=function(){},rs.prototype.clear=function(){};var ns={"native":ts,"null":rs},is=0,os=function(e,t,r){var n=e.display;this.viewport=t,this.visible=Hr(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=Ut(e),this.force=r,this.dims=br(e),this.events=[]};os.prototype.signal=function(e,t){Ee(e,t)&&this.events.push(arguments)},os.prototype.finish=function(){for(var e=this,t=0;t=0&&_(e,i.to())<=0)return n}return-1};var ss=function(e,t){this.anchor=e,this.head=t};ss.prototype.from=function(){return j(this.anchor,this.head)},ss.prototype.to=function(){return R(this.anchor,this.head)},ss.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};var as=function(e){var t=this;this.lines=e,this.parent=null;for(var r=0,n=0;n1||!(this.children[0]instanceof as))){var a=[];this.collapse(a),this.children=[new as(a)],this.children[0].parent=this}},us.prototype.collapse=function(e){for(var t=this,r=0;r50){for(var s=o.lines.length%25+25,a=s;a10);e.parent.maybeSpill()}},us.prototype.iterN=function(e,t,r){for(var n=this,i=0;it.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=f,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&pn(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&gi(t.doc)),t&&St(t,"markerCleared",t,this,i,o),r&&rn(t),this.parent&&this.parent.clear()}},hs.prototype.find=function(e,t){var r=this;null==e&&"bookmark"==this.type&&(e=1);for(var n,i,o=0;o=0;u--)Ci(n,i[u]);a?fi(this,a):this.cm&&Qr(this.cm)}),undo:dn(function(){Li(this,"undo")}),redo:dn(function(){Li(this,"redo")}),undoSelection:dn(function(){Li(this,"undo",!0)}),redoSelection:dn(function(){Li(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=B(this,e),t=B(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s=a.to||null==a.from&&i!=e.line||null!=a.from&&i==t.line&&a.from>=t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;ne?(t=e,!0):(e-=o,void++r)}),B(this,I(r,t))},indexFromPos:function(e){e=B(this,e);var t=e.ch;if(e.linet&&(t=e.from),null!=e.to&&e.to0)i=new I(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),I(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=k(e.doc,i.line-1).text;l&&(i=new I(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),I(i.line-1,l.length-1),i,"+transpose"))}r.push(new ss(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return cn(e,function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange(e.doc.lineSeparator(),t[r].anchor,t[r].head,"+input");t=e.listSelections();for(var n=0;nn&&(No(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&Qr(t));else{var l=o.from(),s=o.to(),a=Math.max(n,l.line);n=Math.min(t.lastLine(),s.line-(s.ch?0:1))+1;for(var u=a;u0&&ai(t.doc,i,new ss(l,c[i].to()),Tl)}}}),getTokenAt:function(e,t){return it(this,e,t)},getLineTokens:function(e,t){return it(this,I(e),t,!0)},getTokenTypeAt:function(e){e=B(this.doc,e);var t,r=Qe(this,k(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]o&&(e=o,i=!0),n=k(this.doc,e)}else n=e;return sr(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-ye(n):0)},defaultTextHeight:function(){return mr(this.display)},defaultCharWidth:function(){return yr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=cr(this,B(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&$r(this,{left:s,top:l,right:s+t.offsetWidth,bottom:l+t.offsetHeight})},triggerOnKeyDown:hn(uo),triggerOnKeyPress:hn(ho),triggerOnKeyUp:fo,execCommand:function(e){if(Ts.hasOwnProperty(e))return Ts[e].call(null,this)},triggerElectric:hn(function(e){Eo(this,e)}),findPosH:function(e,t,r,n){var i=this,o=1;t<0&&(o=-1,t=-t);for(var l=B(this.doc,e),s=0;s0&&s(r.charAt(n-1));)--n;for(;i.5)&&Cr(this),Ae(this,"refresh",this)}),swapDoc:hn(function(e){var t=this.doc;return t.cm=null,Un(this,e),ir(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,St(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Pe(e),e.registerHelper=function(t,n,i){r.hasOwnProperty(t)||(r[t]=e[t]={_global:[]}),r[t][n]=i},e.registerGlobalHelper=function(t,n,i,o){e.registerHelper(t,n,o),r[t]._global.push({pred:i,val:o})}},Ps=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new wl,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ps.prototype.init=function(e){function t(e){if(!De(i,e)){if(i.somethingSelected())Ao({lineWise:!1,text:i.getSelections()}),"cut"==e.type&&i.replaceSelection("",null,"cut");else{if(!i.options.lineWiseCopyCut)return;var t=Po(i);Ao({lineWise:!0,text:t.text}),"cut"==e.type&&i.operation(function(){i.setSelections(t.ranges,0,Tl),i.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var r=Ws.text.join("\n");if(e.clipboardData.setData("Text",r),e.clipboardData.getData("Text")==r)return void e.preventDefault()}var l=_o(),s=l.firstChild;i.display.lineSpace.insertBefore(l,i.display.lineSpace.firstChild),s.value=Ws.text.join("\n");var a=document.activeElement;bl(s),setTimeout(function(){i.display.lineSpace.removeChild(l),a.focus(),a==o&&n.showPrimarySelection()},50)}}var r=this,n=this,i=n.cm,o=n.div=e.lineDiv;Io(o,i.options.spellcheck),_l(o,"paste",function(e){De(i,e)||Wo(e,i)||el<=11&&setTimeout(fn(i,function(){return r.updateFromDOM()}),20)}),_l(o,"compositionstart",function(e){r.composing={data:e.data,done:!1}}),_l(o,"compositionupdate",function(e){r.composing||(r.composing={data:e.data,done:!1})}),_l(o,"compositionend",function(e){r.composing&&(e.data!=r.composing.data&&r.readFromDOMSoon(),r.composing.done=!0)}),_l(o,"touchstart",function(){return n.forceCompositionEnd()}),_l(o,"input",function(){r.composing||r.readFromDOMSoon()}),_l(o,"copy",t),_l(o,"cut",t)},Ps.prototype.prepareSelection=function(){var e=Mr(this.cm,!1);return e.focus=this.cm.state.focused,e},Ps.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},Ps.prototype.showPrimarySelection=function(){var e=window.getSelection(),t=this.cm,r=t.doc.sel.primary(),n=r.from(),i=r.to();if(t.display.viewTo==t.display.viewFrom||n.line>=t.display.viewTo||i.line=t.display.viewFrom&&Ro(t,n)||{node:s[0].measure.map[2],offset:0},u=i.linee.firstLine()&&(n=I(n.line-1,k(e.doc,n.line-1).length)),i.ch==k(e.doc,i.line).text.length&&i.linet.viewTo-1)return!1;var o,l,s;n.line==t.viewFrom||0==(o=Lr(e,n.line))?(l=D(t.view[0].line),s=t.view[0].node):(l=D(t.view[o].line),s=t.view[o-1].node.nextSibling);var a,u,c=Lr(e,i.line);if(c==t.view.length-1?(a=t.viewTo-1,u=t.lineDiv.lastChild):(a=D(t.view[c+1].line)-1,u=t.view[c+1].node.previousSibling),!s)return!1;for(var f=e.doc.splitLines(Bo(e,s,u,l,a)),h=O(e.doc,I(l,0),I(a,k(e.doc,a).text.length));f.length>1&&h.length>1;)if(g(f)==g(h))f.pop(),h.pop(),a--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),l++}for(var d=0,p=0,v=f[0],m=h[0],y=Math.min(v.length,m.length);dn.ch&&b.charCodeAt(b.length-p-1)==w.charCodeAt(w.length-p-1);)d--,p++;f[f.length-1]=b.slice(0,b.length-p).replace(/^\u200b+/,""),f[0]=f[0].slice(d).replace(/\u200b+$/,"");var C=I(l,d),S=I(a,h.length?g(h).length-p:0);return f.length>1||f[0]||_(C,S)?(Oi(e.doc,f,C,S,"+input"),!0):void 0},Ps.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ps.prototype.reset=function(){this.forceCompositionEnd()},Ps.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Ps.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()},80))},Ps.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||cn(this.cm,function(){return pn(e.cm)})},Ps.prototype.setUneditable=function(e){e.contentEditable="false"},Ps.prototype.onKeyPress=function(e){0!=e.charCode&&(e.preventDefault(),this.cm.isReadOnly()||fn(this.cm,Do)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Ps.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Ps.prototype.onContextMenu=function(){},Ps.prototype.resetPosition=function(){},Ps.prototype.needsContentAttribute=!0;var Is=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new wl,this.inaccurateSelection=!1,this.hasSelection=!1,this.composing=null};Is.prototype.init=function(e){function t(e){if(!De(i,e)){if(i.somethingSelected())Ao({lineWise:!1,text:i.getSelections()}),n.inaccurateSelection&&(n.prevInput="",n.inaccurateSelection=!1,l.value=Ws.text.join("\n"),bl(l));else{if(!i.options.lineWiseCopyCut)return;var t=Po(i);Ao({lineWise:!0,text:t.text}),"cut"==e.type?i.setSelections(t.ranges,null,Tl):(n.prevInput="",l.value=t.text.join("\n"),bl(l))}"cut"==e.type&&(i.state.cutIncoming=!0)}}var r=this,n=this,i=this.cm,o=this.wrapper=_o(),l=this.textarea=o.firstChild;e.wrapper.insertBefore(o,e.wrapper.firstChild),al&&(l.style.width="0px"),_l(l,"input",function(){Qo&&el>=9&&r.hasSelection&&(r.hasSelection=null),n.poll()}),_l(l,"paste",function(e){De(i,e)||Wo(e,i)||(i.state.pasteIncoming=!0,n.fastPoll())}),_l(l,"cut",t),_l(l,"copy",t),_l(e.scroller,"paste",function(t){Ht(e,t)||De(i,t)||(i.state.pasteIncoming=!0,n.focus())}),_l(e.lineSpace,"selectstart",function(t){Ht(e,t)||Ie(t)}),_l(l,"compositionstart",function(){var e=i.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}}),_l(l,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},Is.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=Mr(e);if(e.options.moveInputWithCursor){var i=cr(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},Is.prototype.showSelection=function(e){var t=this.cm,n=t.display;r(n.cursorDiv,e.cursors),r(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Is.prototype.reset=function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=jl&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var l=t?"-":r||n.getSelection();this.textarea.value=l,n.state.focused&&bl(this.textarea),Qo&&el>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",Qo&&el>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},Is.prototype.getField=function(){return this.textarea},Is.prototype.supportsTouch=function(){return!1},Is.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!cl||l()!=this.textarea))try{this.textarea.focus()}catch(e){}},Is.prototype.blur=function(){this.textarea.blur()},Is.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Is.prototype.receivedFocus=function(){this.slowPoll()},Is.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){
+e.poll(),e.cm.state.focused&&e.slowPoll()})},Is.prototype.fastPoll=function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},Is.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||Rl(r)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=r.value;if(i==n&&!t.somethingSelected())return!1;if(Qo&&el>=9&&this.hasSelection===i||fl&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||n||(n=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,s=Math.min(n.length,i.length);l1e3||i.indexOf("\n")>-1?r.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Is.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Is.prototype.onKeyPress=function(){Qo&&el>=9&&(this.hasSelection=null),this.fastPoll()},Is.prototype.onContextMenu=function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t=""+(e?l.value:"");l.value="⇚",l.value=t,n.prevInput=e?"":"",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.cssText=f,l.style.cssText=c,Qo&&el<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!Qo||Qo&&el<9)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&""==n.prevInput?fn(i,wi)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):(o.selForContextMenu=null,o.input.reset())};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea,s=Sr(i,e),a=o.scroller.scrollTop;if(s&&!il){var u=i.options.resetSelectionOnContextMenu;u&&i.doc.sel.contains(s)==-1&&fn(i,hi)(i.doc,Wn(s),Tl);var c=l.style.cssText,f=n.wrapper.style.cssText;n.wrapper.style.cssText="position: absolute";var h=n.wrapper.getBoundingClientRect();l.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(Qo?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var d;if(tl&&(d=window.scrollY),o.input.focus(),tl&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),Qo&&el>=9&&t(),ml){He(e);var p=function(){Ne(window,"mouseup",p),setTimeout(r,20)};_l(window,"mouseup",p)}else setTimeout(r,50)}},Is.prototype.readOnlyChanged=function(e){e||this.reset()},Is.prototype.setUneditable=function(){},Is.prototype.needsContentAttribute=!1,So(ko),Es(ko);var _s="iter insert remove copy getEditor constructor".split(" ");for(var Fs in gs.prototype)gs.prototype.hasOwnProperty(Fs)&&h(_s,Fs)<0&&(ko.prototype[Fs]=function(e){return function(){return e.apply(this.doc,arguments)}}(gs.prototype[Fs]));return Pe(gs),ko.inputStyles={textarea:Is,contenteditable:Ps},ko.defineMode=function(e){ko.defaults.mode||"null"==e||(ko.defaults.mode=e),Ge.apply(this,arguments)},ko.defineMIME=Ve,ko.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),ko.defineMIME("text/plain","null"),ko.defineExtension=function(e,t){ko.prototype[e]=t},ko.defineDocExtension=function(e,t){gs.prototype[e]=t},ko.fromTextArea=Vo,Yo(ko),ko.version="5.25.2",ko})},{}],3:[function(e,t,r){"use strict";function n(e){return e}function i(e,t,r){function i(e,t){var r=y.hasOwnProperty(t)?y[t]:null;x.hasOwnProperty(t)&&a("OVERRIDE_BASE"===r,"ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.",t),e&&a("DEFINE_MANY"===r||"DEFINE_MANY_MERGED"===r,"ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",t)}function o(e,r){if(r){a("function"!=typeof r,"ReactClass: You're attempting to use a component class or function as a mixin. Instead, just use a regular object."),a(!t(r),"ReactClass: You're attempting to use a component as a mixin. Instead, just use a regular object.");var n=e.prototype,o=n.__reactAutoBindPairs;r.hasOwnProperty(u)&&b.mixins(e,r.mixins);for(var l in r)if(r.hasOwnProperty(l)&&l!==u){var s=r[l],c=n.hasOwnProperty(l);if(i(c,l),b.hasOwnProperty(l))b[l](e,s);else{var f=y.hasOwnProperty(l),p="function"==typeof s,g=p&&!f&&!c&&r.autobind!==!1;if(g)o.push(l,s),n[l]=s;else if(c){var v=y[l];a(f&&("DEFINE_MANY_MERGED"===v||"DEFINE_MANY"===v),"ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.",v,l),"DEFINE_MANY_MERGED"===v?n[l]=h(n[l],s):"DEFINE_MANY"===v&&(n[l]=d(n[l],s))}else n[l]=s}}}else;}function c(e,t){if(t)for(var r in t){var n=t[r];if(t.hasOwnProperty(r)){var i=r in b;a(!i,'ReactClass: You are attempting to define a reserved property, `%s`, that shouldn\'t be on the "statics" key. Define it as an instance property instead; it will still be accessible on the constructor.',r);var o=r in e;a(!o,"ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.",r),e[r]=n}}}function f(e,t){a(e&&t&&"object"==typeof e&&"object"==typeof t,"mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.");for(var r in t)t.hasOwnProperty(r)&&(a(void 0===e[r],"mergeIntoWithNoDuplicateKeys(): Tried to merge two objects with the same key: `%s`. This conflict may be due to a mixin; in particular, this may be caused by two getInitialState() or getDefaultProps() methods returning objects with clashing keys.",r),e[r]=t[r]);return e}function h(e,t){return function(){var r=e.apply(this,arguments),n=t.apply(this,arguments);if(null==r)return n;if(null==n)return r;var i={};return f(i,r),f(i,n),i}}function d(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function p(e,t){var r=t.bind(e);return r}function g(e){for(var t=e.__reactAutoBindPairs,r=0;r=t||r<0||M&&n>=m}function c(){var e=C();return u(e)?f(e):void(b=setTimeout(c,a(e)))}function f(e){return b=void 0,k&&g?i(e):(g=v=void 0,y)}function h(){void 0!==b&&clearTimeout(b),L=0,g=S=v=b=void 0}function d(){return void 0===b?y:f(C())}function p(){var e=C(),r=u(e);if(g=arguments,v=this,S=e,r){if(void 0===b)return o(S);if(M)return b=setTimeout(c,t),i(S)}return void 0===b&&(b=setTimeout(c,t)),y}var g,v,m,y,b,S,L=0,T=!1,M=!1,k=!0;if("function"!=typeof e)throw new TypeError(s);return t=l(t)||0,n(r)&&(T=!!r.leading,M="maxWait"in r,m=M?w(l(r.maxWait)||0,t):m,k="trailing"in r?!!r.trailing:k),p.cancel=h,p.flush=d,p}function n(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function i(e){return!!e&&"object"==typeof e}function o(e){return"symbol"==typeof e||i(e)&&b.call(e)==u}function l(e){if("number"==typeof e)return e;if(o(e))return a;if(n(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=n(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(c,"");var r=h.test(e);return r||d.test(e)?p(e.slice(2),r?2:8):f.test(e)?a:+e}var s="Expected a function",a=NaN,u="[object Symbol]",c=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,h=/^0b[01]+$/i,d=/^0o[0-7]+$/i,p=parseInt,g="object"==typeof e&&e&&e.Object===Object&&e,v="object"==typeof self&&self&&self.Object===Object&&self,m=g||v||Function("return this")(),y=Object.prototype,b=y.toString,w=Math.max,x=Math.min,C=function(){return m.Date.now()};t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,r){(function(e){function n(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r-1}function L(e,t){var r=this.__data__,n=z(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function T(e){var t=-1,r=null==e?0:e.length;for(this.clear();++tu))return!1;var f=l.get(e);if(f&&l.get(t))return f==t;var h=-1,d=!0,p=r&Ce?new D:void 0;for(l.set(e,t),l.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=Se}function pe(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ge(e){return null!=e&&"object"==typeof e}function ve(e){return ce(e)?j(e):q(e)}function me(){return[]}function ye(){return!1}var be=200,we="__lodash_hash_undefined__",xe=1,Ce=2,Se=9007199254740991,Le="[object Arguments]",Te="[object Array]",Me="[object AsyncFunction]",ke="[object Boolean]",Oe="[object Date]",Ne="[object Error]",Ae="[object Function]",De="[object GeneratorFunction]",We="[object Map]",Ee="[object Number]",Pe="[object Null]",Ie="[object Object]",_e="[object Promise]",Fe="[object Proxy]",He="[object RegExp]",Re="[object Set]",je="[object String]",ze="[object Symbol]",Be="[object Undefined]",Ue="[object WeakMap]",Ge="[object ArrayBuffer]",Ve="[object DataView]",Ye="[object Float32Array]",Ke="[object Float64Array]",Xe="[object Int8Array]",qe="[object Int16Array]",$e="[object Int32Array]",Ze="[object Uint8Array]",Je="[object Uint8ClampedArray]",Qe="[object Uint16Array]",et="[object Uint32Array]",tt=/[\\^$.*+?()[\]{}|]/g,rt=/^\[object .+?Constructor\]$/,nt=/^(?:0|[1-9]\d*)$/,it={};it[Ye]=it[Ke]=it[Xe]=it[qe]=it[$e]=it[Ze]=it[Je]=it[Qe]=it[et]=!0,it[Le]=it[Te]=it[Ge]=it[ke]=it[Ve]=it[Oe]=it[Ne]=it[Ae]=it[We]=it[Ee]=it[Ie]=it[He]=it[Re]=it[je]=it[Ue]=!1;var ot="object"==typeof e&&e&&e.Object===Object&&e,lt="object"==typeof self&&self&&self.Object===Object&&self,st=ot||lt||Function("return this")(),at="object"==typeof r&&r&&!r.nodeType&&r,ut=at&&"object"==typeof t&&t&&!t.nodeType&&t,ct=ut&&ut.exports===at,ft=ct&&ot.process,ht=function(){try{return ft&&ft.binding&&ft.binding("util")}catch(e){}}(),dt=ht&&ht.isTypedArray,pt=Array.prototype,gt=Function.prototype,vt=Object.prototype,mt=st["__core-js_shared__"],yt=gt.toString,bt=vt.hasOwnProperty,wt=function(){var e=/[^.]+$/.exec(mt&&mt.keys&&mt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),xt=vt.toString,Ct=RegExp("^"+yt.call(bt).replace(tt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),St=ct?st.Buffer:void 0,Lt=st.Symbol,Tt=st.Uint8Array,Mt=vt.propertyIsEnumerable,kt=pt.splice,Ot=Lt?Lt.toStringTag:void 0,Nt=Object.getOwnPropertySymbols,At=St?St.isBuffer:void 0,Dt=f(Object.keys,Object),Wt=te(st,"DataView"),Et=te(st,"Map"),Pt=te(st,"Promise"),It=te(st,"Set"),_t=te(st,"WeakMap"),Ft=te(Object,"create"),Ht=ae(Wt),Rt=ae(Et),jt=ae(Pt),zt=ae(It),Bt=ae(_t),Ut=Lt?Lt.prototype:void 0,Gt=Ut?Ut.valueOf:void 0;d.prototype.clear=p,d.prototype["delete"]=g,d.prototype.get=v,d.prototype.has=m,d.prototype.set=y,b.prototype.clear=w,b.prototype["delete"]=x,b.prototype.get=C,b.prototype.has=S,b.prototype.set=L,T.prototype.clear=M,T.prototype["delete"]=k,T.prototype.get=O,T.prototype.has=N,T.prototype.set=A,D.prototype.add=D.prototype.push=W,D.prototype.has=E,P.prototype.clear=I,P.prototype["delete"]=_,P.prototype.get=F,P.prototype.has=H,P.prototype.set=R;var Vt=Nt?function(e){return null==e?[]:(e=Object(e),n(Nt(e),function(t){return Mt.call(e,t)}))}:me,Yt=U;(Wt&&Yt(new Wt(new ArrayBuffer(1)))!=Ve||Et&&Yt(new Et)!=We||Pt&&Yt(Pt.resolve())!=_e||It&&Yt(new It)!=Re||_t&&Yt(new _t)!=Ue)&&(Yt=function(e){var t=U(e),r=t==Ie?e.constructor:void 0,n=r?ae(r):"";if(n)switch(n){case Ht:return Ve;case Rt:return We;case jt:return _e;case zt:return Re;case Bt:return Ue}return t});var Kt=G(function(){return arguments}())?G:function(e){return ge(e)&&bt.call(e,"callee")&&!Mt.call(e,"callee")},Xt=Array.isArray,qt=At||ye,$t=dt?s(dt):X;t.exports=fe}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(e,t,r){"use strict";function n(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function i(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;var n=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==n.join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(e){i[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(o){return!1}}var o=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;t.exports=i()?Object.assign:function(e,t){for(var r,i,a=n(e),u=1;u>",A={array:f("array"),bool:f("boolean"),func:f("function"),number:f("number"),object:f("object"),string:f("string"),symbol:f("symbol"),any:h(),arrayOf:d,element:p(),instanceOf:g,node:b(),objectOf:m,oneOf:v,oneOfType:y,shape:w};return u.prototype=Error.prototype,A.checkPropTypes=s,A.PropTypes=A,A}},{"./checkPropTypes":12,"./lib/ReactPropTypesSecret":16,"fbjs/lib/emptyFunction":5,"fbjs/lib/invariant":7,"fbjs/lib/warning":8}],15:[function(e,t,r){t.exports=e("./factoryWithThrowingShims")()},{"./factoryWithThrowingShims":13,"./factoryWithTypeCheckers":14}],16:[function(e,t,r){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";t.exports=n},{}],17:[function(e,t,r){(function(r){"use strict";function n(e){return e?e.replace(/\r\n|\r/g,"\n"):e}var i="undefined"!=typeof window?window.React:"undefined"!=typeof r?r.React:null,o=(e("react-dom"),e("prop-types")),l=e("classnames"),s=e("lodash.debounce"),a=e("lodash.isequal"),u=e("create-react-class"),c=u({propTypes:{autoFocus:o.bool,className:o.any,codeMirrorInstance:o.func,defaultValue:o.string,name:o.string,onChange:o.func,onCursorActivity:o.func,onFocusChange:o.func,onScroll:o.func,options:o.object,path:o.string,value:o.string,preserveScrollPosition:o.bool},getDefaultProps:function(){return{preserveScrollPosition:!1}},getCodeMirrorInstance:function(){return this.props.codeMirrorInstance||e("codemirror")},getInitialState:function(){return{isFocused:!1}},componentWillMount:function(){this.componentWillReceiveProps=s(this.componentWillReceiveProps,0),this.props.path&&console.error("Warning: react-codemirror: the `path` prop has been changed to `name`")},componentDidMount:function(){var e=this.getCodeMirrorInstance();this.codeMirror=e.fromTextArea(this.textareaNode,this.props.options),this.codeMirror.on("change",this.codemirrorValueChanged),this.codeMirror.on("cursorActivity",this.cursorActivity),this.codeMirror.on("focus",this.focusChanged.bind(this,!0)),this.codeMirror.on("blur",this.focusChanged.bind(this,!1)),this.codeMirror.on("scroll",this.scrollChanged),this.codeMirror.setValue(this.props.defaultValue||this.props.value||"")},componentWillUnmount:function(){this.codeMirror&&this.codeMirror.toTextArea()},componentWillReceiveProps:function(e){if(this.codeMirror&&void 0!==e.value&&e.value!==this.props.value&&n(this.codeMirror.getValue())!==n(e.value))if(this.props.preserveScrollPosition){var t=this.codeMirror.getScrollInfo();this.codeMirror.setValue(e.value),this.codeMirror.scrollTo(t.left,t.top)}else this.codeMirror.setValue(e.value);if("object"==typeof e.options)for(var r in e.options)e.options.hasOwnProperty(r)&&this.setOptionIfChanged(r,e.options[r])},setOptionIfChanged:function(e,t){var r=this.codeMirror.getOption(e);a(r,t)||this.codeMirror.setOption(e,t)},getCodeMirror:function(){return this.codeMirror},focus:function(){this.codeMirror&&this.codeMirror.focus()},focusChanged:function(e){this.setState({isFocused:e}),this.props.onFocusChange&&this.props.onFocusChange(e)},cursorActivity:function(e){this.props.onCursorActivity&&this.props.onCursorActivity(e)},scrollChanged:function(e){this.props.onScroll&&this.props.onScroll(e.getScrollInfo())},codemirrorValueChanged:function(e,t){this.props.onChange&&"setValue"!==t.origin&&this.props.onChange(e.getValue(),t)},render:function(){var e=this,t=l("ReactCodeMirror",this.state.isFocused?"ReactCodeMirror--focused":null,this.props.className);return i.createElement("div",{className:t},i.createElement("textarea",{ref:function(t){return e.textareaNode=t},name:this.props.name||this.props.path,defaultValue:this.props.value,autoComplete:"off",autoFocus:this.props.autoFocus}))}});t.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});
+},{classnames:1,codemirror:2,"create-react-class":4,"lodash.debounce":9,"lodash.isequal":10,"prop-types":15,"react-dom":void 0}]},{},[17])(17)});
\ No newline at end of file
diff --git a/lib/Codemirror.js b/lib/Codemirror.js
index 3237e08..727d762 100644
--- a/lib/Codemirror.js
+++ b/lib/Codemirror.js
@@ -2,29 +2,32 @@
var React = require('react');
var ReactDOM = require('react-dom');
-var findDOMNode = ReactDOM.findDOMNode;
+var PropTypes = require('prop-types');
var className = require('classnames');
var debounce = require('lodash.debounce');
+var isEqual = require('lodash.isequal');
+var createReactClass = require('create-react-class');
function normalizeLineEndings(str) {
if (!str) return str;
return str.replace(/\r\n|\r/g, '\n');
}
-var CodeMirror = React.createClass({
- displayName: 'CodeMirror',
-
+var CodeMirror = createReactClass({
propTypes: {
- className: React.PropTypes.any,
- codeMirrorInstance: React.PropTypes.func,
- defaultValue: React.PropTypes.string,
- onChange: React.PropTypes.func,
- onFocusChange: React.PropTypes.func,
- onScroll: React.PropTypes.func,
- options: React.PropTypes.object,
- path: React.PropTypes.string,
- value: React.PropTypes.string,
- preserveScrollPosition: React.PropTypes.bool
+ autoFocus: PropTypes.bool,
+ className: PropTypes.any,
+ codeMirrorInstance: PropTypes.func,
+ defaultValue: PropTypes.string,
+ name: PropTypes.string,
+ onChange: PropTypes.func,
+ onCursorActivity: PropTypes.func,
+ onFocusChange: PropTypes.func,
+ onScroll: PropTypes.func,
+ options: PropTypes.object,
+ path: PropTypes.string,
+ value: PropTypes.string,
+ preserveScrollPosition: PropTypes.bool
},
getDefaultProps: function getDefaultProps() {
return {
@@ -41,12 +44,15 @@ var CodeMirror = React.createClass({
},
componentWillMount: function componentWillMount() {
this.componentWillReceiveProps = debounce(this.componentWillReceiveProps, 0);
+ if (this.props.path) {
+ console.error('Warning: react-codemirror: the `path` prop has been changed to `name`');
+ }
},
componentDidMount: function componentDidMount() {
- var textareaNode = findDOMNode(this.refs.textarea);
var codeMirrorInstance = this.getCodeMirrorInstance();
- this.codeMirror = codeMirrorInstance.fromTextArea(textareaNode, this.props.options);
+ this.codeMirror = codeMirrorInstance.fromTextArea(this.textareaNode, this.props.options);
this.codeMirror.on('change', this.codemirrorValueChanged);
+ this.codeMirror.on('cursorActivity', this.cursorActivity);
this.codeMirror.on('focus', this.focusChanged.bind(this, true));
this.codeMirror.on('blur', this.focusChanged.bind(this, false));
this.codeMirror.on('scroll', this.scrollChanged);
@@ -59,7 +65,7 @@ var CodeMirror = React.createClass({
}
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
- if (this.codeMirror && nextProps.value !== undefined && normalizeLineEndings(this.codeMirror.getValue()) !== normalizeLineEndings(nextProps.value)) {
+ if (this.codeMirror && nextProps.value !== undefined && nextProps.value !== this.props.value && normalizeLineEndings(this.codeMirror.getValue()) !== normalizeLineEndings(nextProps.value)) {
if (this.props.preserveScrollPosition) {
var prevScrollPosition = this.codeMirror.getScrollInfo();
this.codeMirror.setValue(nextProps.value);
@@ -71,11 +77,17 @@ var CodeMirror = React.createClass({
if (typeof nextProps.options === 'object') {
for (var optionName in nextProps.options) {
if (nextProps.options.hasOwnProperty(optionName)) {
- this.codeMirror.setOption(optionName, nextProps.options[optionName]);
+ this.setOptionIfChanged(optionName, nextProps.options[optionName]);
}
}
}
},
+ setOptionIfChanged: function setOptionIfChanged(optionName, newValue) {
+ var oldValue = this.codeMirror.getOption(optionName);
+ if (!isEqual(oldValue, newValue)) {
+ this.codeMirror.setOption(optionName, newValue);
+ }
+ },
getCodeMirror: function getCodeMirror() {
return this.codeMirror;
},
@@ -90,6 +102,9 @@ var CodeMirror = React.createClass({
});
this.props.onFocusChange && this.props.onFocusChange(focused);
},
+ cursorActivity: function cursorActivity(cm) {
+ this.props.onCursorActivity && this.props.onCursorActivity(cm);
+ },
scrollChanged: function scrollChanged(cm) {
this.props.onScroll && this.props.onScroll(cm.getScrollInfo());
},
@@ -99,11 +114,21 @@ var CodeMirror = React.createClass({
}
},
render: function render() {
+ var _this = this;
+
var editorClassName = className('ReactCodeMirror', this.state.isFocused ? 'ReactCodeMirror--focused' : null, this.props.className);
return React.createElement(
'div',
{ className: editorClassName },
- React.createElement('textarea', { ref: 'textarea', name: this.props.path, defaultValue: this.props.value, autoComplete: 'off' })
+ React.createElement('textarea', {
+ ref: function (ref) {
+ return _this.textareaNode = ref;
+ },
+ name: this.props.name || this.props.path,
+ defaultValue: this.props.value,
+ autoComplete: 'off',
+ autoFocus: this.props.autoFocus
+ })
);
}
});
diff --git a/package.json b/package.json
index 44b9766..d0ab541 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "react-codemirror",
- "version": "0.3.0",
+ "version": "1.0.0",
"description": "Codemirror",
"main": "lib/Codemirror.js",
"author": "Jed Watson",