/*! venus 08-11-2018 */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.CodeMirror=t()}(this,function(){"use strict";var e=navigator.userAgent,t=navigator.platform,g=/gecko\/\d/i.test(e),r=/MSIE \d/.test(e),n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),i=/Edge\/(\d+)/.exec(e),w=r||n||i,C=w&&(r?document.documentMode||6:+(i||n)[1]),b=!i&&/WebKit\//.test(e),o=b&&/Qt\/\d+\.\d+/.test(e),l=!i&&/Chrome\//.test(e),v=/Opera\//.test(e),a=/Apple Computer/.test(navigator.vendor),s=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),u=/PhantomJS/.test(e),c=!i&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e),h=/Android/.test(e),f=c||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),x=c||/Mac/.test(t),d=/\bCrOS\b/.test(e),p=/win/i.test(t),m=v&&e.match(/Version\/(\d*\.\d*)/);m&&(m=Number(m[1])),m&&15<=m&&(b=!(v=!1));var y=x&&(o||v&&(null==m||m<12.11)),S=g||w&&9<=C;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var k,M=function(e,t){var r=e.className,n=L(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}};function T(e){for(var t=e.childNodes.length;0=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&&to?ve(o,ae(e,o).text.length):(n=ae(e,(r=t).line).text.length,null==(i=r.ch)||n=t:o.to>t);(n||(n=[])).push(new Te(l,o.from,s?null:o.to))}}return n}(r,i,l),a=function(e,t,r){var n;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(l.inclusiveLeft?o.from<=t:o.frome.lastLine())return t;var r,n=ae(e,t);if(!Ke(e,n))return t;for(;r=Re(n);)n=r.find(1,!0).line;return fe(n)+1}function Ke(e,t){var r=Me&&t.markedSpans;if(r)for(var n=void 0,i=0;ir.maxLineLength&&(r.maxLineLength=t,r.maxLine=e)})}var qe=null;function $e(e,t,r){var n;qe=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:qe=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:qe=i)}return null!=n?n:qe}var Ze=function(){var z="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",I="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";var R=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,B=/[stwN]/,G=/[LRr]/,U=/[Lb1n]/,V=/[1n]/;function K(e,t,r){this.level=e,this.from=t,this.to=r}return function(e,t){var r="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!R.test(e))return!1;for(var n,i=e.length,o=[],l=0;le.text.length?null:n}function et(e,t,r){var n=Je(e,t.ch,r);return null==n?null:new ve(t.line,n,r<0?"after":"before")}function tt(e,t,r,n,i){if(e){var o=Qe(r,t.doc.direction);if(o){var l,s=i<0?q(o):o[0],a=i<0==(1==s.level)?"after":"before";if(0=l.text.length?(s.ch=l.text.length,s.sticky="before"):s.ch<=0&&(s.ch=0,s.sticky="after");var t=$e(a,s.ch,s.sticky),r=a[t];if("ltr"==o.doc.direction&&r.level%2==0&&(0s.ch:r.from=r.from&&f>=i.begin)){var d=h?"before":"after";return new ve(s.line,f,d)}}var p=function(e,t,r){for(var n=function(e,t){return t?new ve(s.line,c(e,1),"before"):new ve(s.line,e,"after")};0<=e&&e=this.string.length},zt.prototype.sol=function(){return this.pos==this.lineStart},zt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},zt.prototype.next=function(){if(this.post},zt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},zt.prototype.skipToEnd=function(){this.pos=this.string.length},zt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(-1e.options.maxHighlightLength&&Ft(e.doc.mode,n.state),o=Bt(e,t,n);i&&(n.state=i),t.stateAfter=n.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Ut(r,n,e){var t=r.doc,i=r.display;if(!t.mode.startState)return new Rt(t,!0,n);var o=function(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;lt.first&&ae(t,o-1).stateAfter,s=l?Rt.fromSaved(t,l,o):new Rt(t,Pt(t.mode),o);return t.iter(o,n,function(e){Vt(r,e.text,s);var t=s.line;e.stateAfter=t==n-1||t%5==0||t>=i.viewFrom&&tt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}Rt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Rt.prototype.nextLine=function(){this.line++,0e.options.maxHighlightLength?(s=!1,l&&Vt(e,t,n,h.pos),h.pos=t.length,null):Yt(jt(r,h,n.state,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;us&&u.from<=s);c++);if(u.to>=a)return h(e,t,r,n,i,o,l);h(e,t.slice(0,u.to-s),r,n,null,o,l),n=null,t=t.slice(u.to-s),s=u.to}}}function ir(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 or(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var l,s,a,u,c,h,f,d=i.length,p=0,g=1,v="",m=0;;){if(m==p){a=u=c=h=s="",f=null,m=1/0;for(var y=[],b=void 0,x=0;xp||C.collapsed&&w.to==p&&w.from==p)?(null!=w.to&&w.to!=p&&m>w.to&&(m=w.to,u=""),C.className&&(a+=" "+C.className),C.css&&(s=(s?s+";":"")+C.css),C.startStyle&&w.from==p&&(c+=" "+C.startStyle),C.endStyle&&w.to==m&&(b||(b=[])).push(C.endStyle,w.to),C.title&&!h&&(h=C.title),C.collapsed&&(!f||Pe(f.marker,C)<0)&&(f=w)):w.from>p&&m>w.from&&(m=w.from)}if(b)for(var S=0;Sr)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Wr(e,t,r,n){return Fr(e,Hr(e,t),r,n)}function Dr(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&tt)&&(i=(o=a-s)-1,a<=t&&(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[2+(u-=3)],l="left";if("right"==r&&i==a-s)for(;u=o.text.length?(t=o.text.length,r="before"):t<=0&&(t=0,r="after"),!u)return a("before"==r?t-1:t,"before"==r);function c(e,t,r){return a(r?e-1:e,u[t].level%2!=0!=r)}var h=$e(u,t,r),f=qe,d=c(t,h,"before"==r);return null!=f&&(d.other=c(t,f,"before"!=r)),d}function Yr(e,t){var r=0;t=Se(e.doc,t),e.options.lineWrapping||(r=en(e.display)*t.ch);var n=ae(e.doc,t.line),i=Xe(n)+Lr(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function qr(e,t,r,n,i){var o=ve(e,t,r);return o.xRel=i,n&&(o.outside=!0),o}function $r(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return qr(n.first,0,null,!0,-1);var i=de(n,r),o=n.first+n.size-1;if(ou.from.ch||s.ch==u.from.ch&&0i},l,e)}}function Qr(r,n,e,i,o){o-=Xe(n);var t,l=0,s=n.text.length,a=Hr(r,n);if(Qe(n,r.doc.direction)){var u;if(r.options.lineWrapping)l=(u=Zr(r,n,a,o)).begin,s=u.end;t=new ve(e,Math.floor(l+(s-l)/2));var c,h,f=_r(r,t,"line",n,a).left,d=fMath.abs(c)){if(p<0==c<0)throw new Error("Broke out of infinite loop in coordsCharInner");t=h}}else{var b=le(function(e){var t=Kr(r,n,Fr(r,a,e),"line");return t.top>o?(s=Math.min(e,s),!0):!(t.bottom<=o)&&(t.left>i||!(t.rightx.right?1:0,t}function Jr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Er){Er=O("pre");for(var t=0;t<49;++t)Er.appendChild(document.createTextNode("x")),Er.appendChild(O("br"));Er.appendChild(document.createTextNode("x"))}N(e.measure,Er);var r=Er.offsetHeight/50;return 3=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var r=e.display.view,n=0;n=e.display.viewTo||s.to().linet||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")}(Qe(n,o.direction),a||0,null==u?f:u,function(e,t,r){var n,i,o,l=d(e,"left");if(e==t)i=o=(n=l).left;else{if(n=d(t-1,"right"),"rtl"==r){var s=l;l=n,n=s}i=l.left,o=n.right}null==a&&0==e&&(i=p),3h.bottom||n.bottom==h.bottom&&n.right>h.right)&&(h=n),i=l&&(o=de(t,Xe(ae(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function xn(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=rn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;lo&&(t.bottom=t.top+o);var s=e.doc.height+kr(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 h=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:r.scroller.scrollLeft,f=Nr(e)-(e.options.fixedGutter?r.gutters.offsetWidth:0),d=t.right-t.left>f;return d&&(t.right=t.left+f),t.left<10?l.scrollLeft=0:t.leftf+h-3&&(l.scrollLeft=t.right+(d?0:10)-f),l}function Sn(e,t){null!=t&&(Mn(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Ln(e){Mn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function kn(e,t,r){null==t&&null==r||Mn(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function Mn(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Tn(e,Yr(e,t.from),Yr(e,t.to),t.margin))}function Tn(e,t,r,n){var i=Cn(e,{left:Math.min(t.left,r.left),top:Math.min(t.top,r.top)-n,right:Math.max(t.right,r.right),bottom:Math.max(t.bottom,r.bottom)+n});kn(e,i.scrollLeft,i.scrollTop)}function Nn(e,t){Math.abs(e.doc.scrollTop-t)<2||(g||oi(e,{top:t}),On(e,t,!0),g&&oi(e),ei(e,100))}function On(e,t,r){t=Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t),(e.display.scroller.scrollTop!=t||r)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function An(e,t,r,n){t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!n||(e.doc.scrollLeft=t,xn(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Wn(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+kr(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Tr(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}var Dn=function(e,t,r){this.cm=r;var n=this.vert=O("div",[O("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=O("div",[O("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),it(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),it(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,w&&C<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Dn.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&&0=i.viewTo)||i.maxLineChanged&&n.options.lineWrapping,e.update=e.mustUpdate&&new ri(n,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Un(e){var t=e.cm,r=t.display;e.updatedDisplay&&mn(t),e.barMeasure=Wn(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Wr(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+Tr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Nr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection(e.focus))}function Vn(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!u){var o=O("div","​",null,"position: absolute;\n top: "+(t.top-r.viewOffset-Lr(e.display))+"px;\n height: "+(t.bottom-t.top+Tr(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}(t,function(e,t,r,n){var i;null==n&&(n=0),e.options.lineWrapping||t!=r||(r="before"==(t=t.ch?ve(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?ve(t.line,t.ch+1,"before"):t);for(var o=0;o<5;o++){var l=!1,s=_r(e,t),a=r&&r!=t?_r(e,r):s,u=Cn(e,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}),c=e.doc.scrollTop,h=e.doc.scrollLeft;if(null!=u.scrollTop&&(Nn(e,u.scrollTop),1t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Me&&Ue(e.doc,t)i.viewFrom?Zn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)Zn(e);else if(t<=i.viewFrom){var o=Qn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):Zn(e)}else if(r>=i.viewTo){var l=Qn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):Zn(e)}else{var s=Qn(e,t,t,-1),a=Qn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(sr(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):Zn(e)}var u=i.externalMeasured;u&&(r=i.lineN&&t=n.viewTo)){var o=n.view[sn(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==B(l,r)&&l.push(r)}}}function Zn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Qn(e,t,r,n){var i,o=sn(e,t),l=e.display.view;if(!Me||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,a=0;a=a.display.viewTo)){var c=+new Date+a.options.workTime,h=Ut(a,u.highlightFrontier),f=[];u.iter(h.line,Math.min(u.first+u.size,a.display.viewTo+500),function(e){if(h.line>=a.display.viewFrom){var t=e.styles,r=e.text.length>a.options.maxHighlightLength?Ft(u.mode,h.state):null,n=Bt(a,e,h,!0);r&&(h.state=r),e.styles=n.styles;var i=e.styleClasses,o=n.classes;o?e.styleClasses=o:i&&(e.styleClasses=null);for(var l=!t||t.length!=e.styles.length||i!=o&&(!i||!o||i.bgClass!=o.bgClass||i.textClass!=o.textClass),s=0;!l&&sc)return ei(a,a.options.workDelay),!0}),u.highlightFrontier=h.line,u.modeFrontier=Math.max(u.modeFrontier,h.line),f.length&&jn(a,function(){for(var e=0;e=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Jn(e))return!1;wn(e)&&(Zn(e),t.dims=tn(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFroml&&r.viewTo-l<20&&(l=Math.min(i,r.viewTo)),Me&&(o=Ue(e.doc,o),l=Ve(e.doc,l));var s,a,u,c,h=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;a=o,u=l,0==(c=(s=e).display).view.length||a>=c.viewTo||u<=c.viewFrom?(c.view=sr(s,a,u),c.viewFrom=a):(c.viewFrom>a?c.view=sr(s,a,c.viewFrom).concat(c.view):c.viewFromu&&(c.view=c.view.slice(0,sn(s,u)))),c.viewTo=u,r.viewOffset=Xe(ae(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var f=Jn(e);if(!h&&0==f&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var d=function(e){if(e.hasFocus())return null;var t=D();if(!t||!W(e.display.lineDiv,t))return null;var r={activeElt:t};if(window.getSelection){var n=window.getSelection();n.anchorNode&&n.extend&&W(e.display.lineDiv,n.anchorNode)&&(r.anchorNode=n.anchorNode,r.anchorOffset=n.anchorOffset,r.focusNode=n.focusNode,r.focusOffset=n.focusOffset)}return r}(e);return 4=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&ni(e,t);n=!1){mn(e);var i=Wn(e);an(e),Fn(e,i),si(e,i),t.force=!1}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 oi(e,t){var r=new ri(e,t);if(ni(e,r)){mn(e),ii(e,r);var n=Wn(e);an(e),Fn(e,n),si(e,n),r.finish()}}function li(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function si(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+Tr(e)+"px"}function ai(e){var t=e.display.gutters,r=e.options.gutters;T(t);for(var n=0;nl.clientWidth,a=l.scrollHeight>l.clientHeight;if(n&&s||i&&a){if(i&&x&&b)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var h=0;ha-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=(s=i).lastOp==n?(Di(s.done),q(s.done)):s.done.length&&!q(s.done).ranges?q(s.done):1i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||st(e,"historyAdded")}function Fi(e,t,r,n){var i,o,l,s,a,u=e.history,c=n&&n.origin;r==u.lastSelOp||c&&u.lastSelOrigin==c&&(u.lastModTime==u.lastSelTime&&u.lastOrigin==c||(i=e,o=c,l=q(u.done),s=t,"*"==(a=o.charAt(0))||"+"==a&&l.ranges.length==s.ranges.length&&l.somethingSelected()==s.somethingSelected()&&new Date-i.history.lastSelTime<=(i.cm?i.cm.options.historyEventDelay:500)))?u.done[u.done.length-1]=t:Ei(t,u.done),u.lastSelTime=+new Date,u.lastSelOrigin=c,u.lastSelOp=r,n&&!1!==n.clearRedo&&Di(u.undone)}function Ei(e,t){var r=q(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Pi(t,r,e,n){var i=r["spans_"+t.id],o=0;t.iter(Math.max(t.first,e),Math.min(t.first+t.size,n),function(e){e.markedSpans&&((i||(i=r["spans_"+t.id]={}))[o]=e.markedSpans),++o})}function zi(e){if(!e)return null;for(var t,r=0;r=t.ch:s.to>t.ch))){if(i&&(st(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=Ji(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=me(u,r))&&(n<0?c<0:0e.first?Se(e,ve(t.line-1)):null:0e.lastLine())){if(t.from.lineo&&(t={from:t.from,to:ve(o,ae(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ue(e,t.from,t.to),r||(r=wi(e,t)),e.cm?function(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=fe(Ge(ae(n,o.line))),n.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0}));-1i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontiert.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=h,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&qn(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&qi(t.doc)),t&&cr(t,"markerCleared",t,this,i,o),r&&Bn(t),this.parent&&this.parent.clear()}},yo.prototype.find=function(e,t){var r,n;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(i,o,l){i=Se(this,i),o=Se(this,o);var s=[],a=i.line;return this.iter(i.line,o.line+1,function(e){var t=e.markedSpans;if(t)for(var r=0;r=n.to||null==n.from&&a!=i.line||null!=n.from&&a==o.line&&n.from>=o.ch||l&&!l(n.marker)||s.push(n.marker.parent||n.marker)}++a}),s},getAllMarks:function(){var n=[];return this.iter(function(e){var t=e.markedSpans;if(t)for(var r=0;rt&&(t=e.from),null!=e.to&&e.tol.doc.first){var o=ae(l.doc,n.line-1).text;o&&(n=new ve(n.line,1),l.replaceRange(i.charAt(0)+l.doc.lineSeparator()+o.charAt(o.length-1),ve(n.line-1,o.length-1),n,"+transpose"))}t.push(new vi(n,n))}l.setSelections(t)})},newlineAndIndent:function(n){return jn(n,function(){for(var e=n.listSelections(),t=e.length-1;0<=t;t--)n.replaceRange(n.doc.lineSeparator(),e[t].anchor,e[t].head,"+input");e=n.listSelections();for(var r=0;rc&&t.push(new vi(ve(s,c),ve(s,X(u,l,r))))}t.length||t.push(new vi(m,m)),Xi(b,mi(C.ranges.slice(0,w).concat(t),w),{origin:"*mouse",scroll:!1}),v.scrollIntoView(e)}else{var h,f=x,d=ll(v,e,y.unit),p=f.anchor;p=0=n.to||r.linel.bottom?20:0;i&&setTimeout(Xn(v,function(){s==t&&(o.scroller.scrollTop+=i,a(e))}),50)}}function n(e){v.state.selectingText=!1,s=1/0,ft(e),o.input.focus(),lt(document,"mousemove",i),lt(document,"mouseup",u),b.history.lastSelOrigin=null}var i=Xn(v,function(e){mt(e)?a(e):n(e)}),u=Xn(v,n);v.state.selectingText=u,it(document,"mousemove",i),it(document,"mouseup",u)}(e,n,t,o)}(t,l,a,e):vt(e)==r.scroller&&ft(e):2==s?(l&&Gi(t.doc,l),setTimeout(function(){return r.input.focus()},20)):3==s&&(S?ul(t,e):pn(t)))}}function ll(e,t,r){if("char"==r)return new vi(t,t);if("word"==r)return e.findWordAt(t);if("line"==r)return new vi(ve(t.line,0),Se(e.doc,ve(t.line+1,0)));var n=r(e,t);return new vi(n.from,n.to)}function sl(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&&ft(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!ct(e,r))return pt(t);o-=s.top-l.viewOffset;for(var a=0;a=i)return st(e,r,e,de(e.doc,o),e.options.gutters[a],t),pt(t)}}function al(e,t){return sl(e,t,"gutterClick",!0)}function ul(e,t){var r,n;Sr(e.display,t)||(n=t,ct(r=e,"gutterContextMenu")&&sl(r,n,"gutterContextMenu",!1))||(at(e,t,"contextmenu")||e.display.input.onContextMenu(t))}function cl(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Gr(e)}il.prototype.compare=function(e,t,r){return this.time+400>e&&0==me(t,this.pos)&&r==this.button};var hl={toString:function(){return"CodeMirror.Init"}},fl={},dl={};function pl(e){ai(e),qn(e),xn(e)}function gl(e,t,r){if(!t!=!(r&&r!=hl)){var n=e.display.dragFunctions,i=t?it:lt;i(e.display.scroller,"dragstart",n.start),i(e.display.scroller,"dragenter",n.enter),i(e.display.scroller,"dragover",n.over),i(e.display.scroller,"dragleave",n.leave),i(e.display.scroller,"drop",n.drop)}}function vl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(M(e.display.wrapper,"CodeMirror-wrap"),Ye(e)),on(e),qn(e),Gr(e),setTimeout(function(){return Fn(e)},100)}function ml(e,t){var r=this;if(!(this instanceof ml))return new ml(e,t);this.options=t=t?z(t):{},z(fl,t,!1),ui(t);var n=t.value;"string"==typeof n&&(n=new Lo(n,t.mode,null,t.lineSeparator,t.direction)),this.doc=n;var i=new ml.inputStyles[t.inputStyle](this),o=this.display=new se(e,n,i);for(var l in ai(o.wrapper.CodeMirror=this),cl(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),zn(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 R,keySeq:null,specialChars:null},t.autofocus&&!f&&o.input.focus(),w&&C<11&&setTimeout(function(){return r.display.input.reset(!0)},20),function(i){var o=i.display;it(o.scroller,"mousedown",Xn(i,ol)),it(o.scroller,"dblclick",w&&C<11?Xn(i,function(e){if(!at(i,e)){var t=ln(i,e);if(t&&!al(i,e)&&!Sr(i.display,e)){ft(e);var r=i.findWordAt(t);Gi(i.doc,r.anchor,r.head)}}}):function(e){return at(i,e)||ft(e)});S||it(o.scroller,"contextmenu",function(e){return ul(i,e)});var r,n={end:0};function l(){o.activeTouch&&(r=setTimeout(function(){return o.activeTouch=null},1e3),(n=o.activeTouch).end=+new Date)}function s(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return 400o.first?I(ae(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="",f=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)f+=l,h+="\t";if(f=n.first+n.size||(i=new ve(r,i.ch,i.sticky),!(s=ae(n,r))))return!1;i=tt(l,n.cm,s,i.line,o)}else i=t;return!0}if("char"==e)a();else if("column"==e)a(!0);else if("word"==e||"group"==e)for(var u=null,c="group"==e,h=n.cm&&n.cm.getHelper(i,"wordChars"),f=!0;!(o<0)||a(!f);f=!1){var d=s.text.charAt(i.ch)||"\n",p=te(d,h)?"w":c&&"\n"==d?"n":!c||/\s/.test(d)?null:"p";if(!c||f||p||(p="s"),u&&u!=p){o<0&&(o=1,a(),i.sticky="after");break}if(p&&(u=p),0=l.height){o.hitSide=!0;break}i+=5*r}return o}var Al=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new R,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Wl(e,t){var r=Dr(e,t.line);if(!r||r.hidden)return null;var n=ae(e.doc,t.line),i=Ar(r,n,t.line),o=Qe(n,e.doc.direction),l="left";o&&(l=$e(o,t.ch)%2?"right":"left");var s=zr(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Dl(e,t){return t&&(e.bad=!0),e}function Hl(e,t,r){var n;if(t==e.display.lineDiv){if(!(n=e.display.lineDiv.childNodes[r]))return Dl(e.clipPos(ve(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i=t.display.viewTo||i.line=t.display.viewFrom&&Wl(t,n)||{node:s[0].measure.map[2],offset:0},u=i.linen.firstLine()&&(l=ve(l.line-1,ae(n.doc,l.line-1).length)),s.ch==ae(n.doc,s.line).text.length&&s.linei.viewTo-1)return!1;r=l.line==i.viewFrom||0==(e=sn(n,l.line))?(t=fe(i.view[0].line),i.view[0].node):(t=fe(i.view[e].line),i.view[e-1].node.nextSibling);var a,u,c=sn(n,s.line);if(u=c==i.view.length-1?(a=i.viewTo-1,i.lineDiv.lastChild):(a=fe(i.view[c+1].line)-1,i.view[c+1].node.previousSibling),!r)return!1;for(var h=n.doc.splitLines(function(a,e,t,u,c){var r="",h=!1,f=a.doc.lineSeparator();function d(){h&&(r+=f,h=!1)}function p(e){e&&(d(),r+=e)}function g(e){if(1==e.nodeType){var t=e.getAttribute("cm-text");if(null!=t)return void p(t||e.textContent.replace(/\u200b/g,""));var r,n=e.getAttribute("cm-marker");if(n){var i=a.findMarks(ve(u,0),ve(c+1,0),(s=+n,function(e){return e.id==s}));return void(i.length&&(r=i[0].find())&&p(ue(a.doc,r.from,r.to).join(f)))}if("false"==e.getAttribute("contenteditable"))return;var o=/^(pre|div|p)$/i.test(e.nodeName);o&&d();for(var l=0;ll.ch&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)d--,p++;h[h.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(d).replace(/\u200b+$/,"");var w=ve(t,d),C=ve(a,f.length?q(f).length-p:0);return 1n&&(bl(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&Ln(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;u>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]h)&&e.top>t.offsetHeight?u=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=h&&(u=e.bottom),c+t.offsetWidth>f&&(c=f-t.offsetWidth)}t.style.top=u+"px",t.style.left=t.style.right="","right"==i?(c=a.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?c=0:"middle"==i&&(c=(a.sizer.clientWidth-t.offsetWidth)/2),t.style.left=c+"px"),r&&(o=this,l={left:c,top:u,right:c+t.offsetWidth,bottom:u+t.offsetHeight},null!=(s=Cn(o,l)).scrollTop&&Nn(o,s.scrollTop),null!=s.scrollLeft&&An(o,s.scrollLeft))},triggerOnKeyDown:_n(Jo),triggerOnKeyPress:_n(tl),triggerOnKeyUp:el,triggerOnMouseDown:_n(ol),execCommand:function(e){if(jo.hasOwnProperty(e))return jo[e].call(null,this)},triggerElectric:_n(function(e){Ll(this,e)}),findPosH:function(e,t,r,n){var i=1;t<0&&(i=-1,t=-t);for(var o=Se(this.doc,e),l=0;l