f.clientHeight+1;if(setTimeout((function(){w=a.getScrollInfo()})),x.bottom-_>0){var D=x.bottom-x.top,P=x.top-(y.bottom-y.top)-2;_-x.topP&&(f.style.height=(D=P)+"px"),f.style.top=(N=y.top-D)+O+"px",A=!1):f.style.height=_-x.top-2+"px"}var k,U=x.right-b;if(M&&(U+=a.display.nativeBarWidth),U>0&&(x.right-x.left>b&&(f.style.width=b-5+"px",U-=x.right-x.left-b),f.style.left=(R=Math.max(y.left-U-S,0))+"px"),M)for(var F=f.firstChild;F;F=F.nextSibling)F.style.paddingRight=a.display.nativeBarWidth+"px";a.addKeyMap(this.keyMap=l(n,{moveFocus:function(e,t){o.changeActive(o.selectedHint+e,t)},setFocus:function(e){o.changeActive(e)},menuSize:function(){return o.screenAmount()},length:p.length,close:function(){n.close()},pick:function(){o.pick()},data:i})),n.options.closeOnUnfocus&&(a.on("blur",this.onBlur=function(){k=setTimeout((function(){n.close()}),100)}),a.on("focus",this.onFocus=function(){clearTimeout(k)})),a.on("scroll",this.onScroll=function(){var e=a.getScrollInfo(),t=a.getWrapperElement().getBoundingClientRect();w||(w=a.getScrollInfo());var r=N+w.top-e.top,i=r-(d.pageYOffset||(u.documentElement||u.body).scrollTop);if(A||(i+=f.offsetHeight),i<=t.top||i>=t.bottom)return n.close();f.style.top=r+"px",f.style.left=R+w.left-e.left+"px"}),e.on(f,"dblclick",(function(e){var t=c(f,e.target||e.srcElement);t&&null!=t.hintId&&(o.changeActive(t.hintId),o.pick())})),e.on(f,"click",(function(e){var t=c(f,e.target||e.srcElement);t&&null!=t.hintId&&(o.changeActive(t.hintId),n.options.completeOnSingleClick&&o.pick())})),e.on(f,"mousedown",(function(){setTimeout((function(){a.focus()}),20)}));var H=this.getSelectedHintRange();return 0===H.from&&0===H.to||this.scrollToActive(),e.signal(i,"select",p[this.selectedHint],f.childNodes[this.selectedHint]),!0}function d(e,t){if(!e.somethingSelected())return t;for(var r=[],n=0;n0?t(e):o(i+1)}))}o(0)};return o.async=!0,o.supportsSelection=!0,o}return(n=t.getHelper(t.getCursor(),"hintWords"))?function(t){return e.hint.fromList(t,{words:n})}:e.hint.anyword?function(t,r){return e.hint.anyword(t,r)}:function(){}}n.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.options.updateOnCursorActivity&&this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&e.signal(this.data,"close"),this.widget&&this.widget.close(),e.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(t,r){var n=t.list[r],i=this;this.cm.operation((function(){n.hint?n.hint(i.cm,t,n):i.cm.replaceRange(s(n),n.from||t.from,n.to||t.to,"complete"),e.signal(t,"pick",n),i.cm.scrollIntoView()})),this.options.closeOnPick&&this.close()},cursorActivity:function(){this.debounce&&(o(this.debounce),this.debounce=0);var e=this.startPos;this.data&&(e=this.data.from);var t=this.cm.getCursor(),r=this.cm.getLine(t.line);if(t.line!=this.startPos.line||r.length-t.ch!=this.startLen-this.startPos.ch||t.ch=this.data.list.length?t=n?this.data.list.length-1:0:t<0&&(t=n?0:this.data.list.length-1),this.selectedHint!=t){var i=this.hints.childNodes[this.selectedHint];i&&(i.className=i.className.replace(" "+r,""),i.removeAttribute("aria-selected")),(i=this.hints.childNodes[this.selectedHint=t]).className+=" "+r,i.setAttribute("aria-selected","true"),this.completion.cm.getInputField().setAttribute("aria-activedescendant",i.id),this.scrollToActive(),e.signal(this.data,"select",this.data.list[this.selectedHint],i)}},scrollToActive:function(){var e=this.getSelectedHintRange(),t=this.hints.childNodes[e.from],r=this.hints.childNodes[e.to],n=this.hints.firstChild;t.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=r.offsetTop+r.offsetHeight-this.hints.clientHeight+n.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1},getSelectedHintRange:function(){var e=this.completion.options.scrollMargin||0;return{from:Math.max(0,this.selectedHint-e),to:Math.min(this.data.list.length-1,this.selectedHint+e)}}},e.registerHelper("hint","auto",{resolve:h}),e.registerHelper("hint","fromList",(function(t,r){var n,i=t.getCursor(),o=t.getTokenAt(i),a=e.Pos(i.line,o.start),s=i;o.start,]/,closeOnPick:!0,closeOnUnfocus:!0,updateOnCursorActivity:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null,paddingForScrollbar:!0,moveOnOverlap:!0};e.defineOption("hintOptions",null)}(r(15237))},79102:function(e,t,r){!function(e){"use strict";var t,r,n,i,o={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},a=e.Pos,s=e.cmpPos;function l(e){return"[object Array]"==Object.prototype.toString.call(e)}function c(t,r){return t.getModeAt(t.getCursor()).config[r]||e.resolveMode("text/x-sql")[r]}function u(e){return c(e,"keywords")||[]}function d(e){return c(e,"identifierQuote")||"`"}function f(e){return"string"==typeof e?e:e.text}function h(e,t){return l(t)&&(t={columns:t}),t.text||(t.text=e),t}function p(e){var t={};if(l(e))for(var r=e.length-1;r>=0;r--){var n=e[r];t[f(n).toUpperCase()]=h(f(n),n)}else if(e)for(var i in e)t[i.toUpperCase()]=h(i,e[i]);return t}function E(e){return t[e.toUpperCase()]}function m(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function g(e,t){var r=e.length,n=f(t).substr(0,r);return e.toUpperCase()===n.toUpperCase()}function v(e,t,r,n){if(l(r))for(var i=0;i0)&&s(p,u[m])<=0){d={start:h,end:u[m]};break}h=u[m]}if(d.start){var g=r.getRange(d.start,d.end,!1);for(m=0;mm.ch&&(T.end=m.ch,T.string=T.string.slice(0,m.ch-T.start)),T.string.match(/^[.`"'\w@][\w$#]*$/g)?(h=T.string,c=T.start,f=T.end):(c=f=m.ch,h=""),"."==h.charAt(0)||h.charAt(0)==i)c=R(m,T,g,e);else{var y=function(e,t){return"object"==typeof e?e.className=t:e={text:e,className:t},e};v(g,h,r,(function(e){return y(e,"CodeMirror-hint-table CodeMirror-hint-default-table")})),v(g,h,t,(function(e){return y(e,"CodeMirror-hint-table")})),l||v(g,h,n,(function(e){return y(e.toUpperCase(),"CodeMirror-hint-keyword")}))}return{list:g,from:a(m.line,c),to:a(m.line,f)}}))}(r(15237),r(29532))},50436:function(e,t,r){!function(e){"use strict";var t="CodeMirror-activeline",r="CodeMirror-activeline-background",n="CodeMirror-activeline-gutter";function i(e){for(var i=0;i2),g=/Android/.test(e),v=m||g||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),T=m||/Mac/.test(t),y=/\bCrOS\b/.test(e),R=/win/i.test(t),N=f&&e.match(/Version\/(\d*\.\d*)/);N&&(N=Number(N[1])),N&&N>=15&&(f=!1,l=!0);var A=T&&(c||f&&(null==N||N<12.11)),S=r||a&&s>=9;function O(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var L,I=function(e,t){var r=e.className,n=O(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 C(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function b(e,t){return C(e).appendChild(t)}function _(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 a+(t-o);a+=s-o,a+=r-a%r,o=s+1}}m?k=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:a&&(k=function(e){try{e.select()}catch(e){}});var Y=function(){this.id=null,this.f=null,this.time=0,this.handler=G(this.onTimeout,this)};function z(e,t){for(var r=0;r=t)return n+Math.min(a,t-i);if(i+=o-n,n=o+1,(i+=r-i%r)>=t)return n}}var Z=[""];function $(e){for(;Z.length<=e;)Z.push(ee(Z)+" ");return Z[e]}function ee(e){return e[e.length-1]}function te(e,t){for(var r=[],n=0;n""&&(e.toUpperCase()!=e.toLowerCase()||oe.test(e))}function se(e,t){return t?!!(t.source.indexOf("\\w")>-1&&ae(e))||t.test(e):ae(e)}function le(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ce=/[\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]/;function ue(e){return e.charCodeAt(0)>=768&&ce.test(e)}function de(e,t,r){for(;(r<0?t>0:tr?-1:1;;){if(t==r)return t;var i=(t+r)/2,o=n<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:r;e(o)?r=o:t=o+n}}function he(e,t,r,n){if(!e)return n(t,r,"ltr",0);for(var i=!1,o=0;ot||t==r&&a.to==t)&&(n(Math.max(a.from,t),Math.min(a.to,r),1==a.level?"rtl":"ltr",o),i=!0)}i||n(t,r,"ltr")}var pe=null;function Ee(e,t,r){var n;pe=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:pe=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:pe=i)}return null!=n?n:pe}var me=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function r(r){return r<=247?e.charAt(r):1424<=r&&r<=1524?"R":1536<=r&&r<=1785?t.charAt(r-1536):1774<=r&&r<=2220?"r":8192<=r&&r<=8203?"w":8204==r?"b":"L"}var n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,o=/[LRr]/,a=/[Lb1n]/,s=/[1n]/;function l(e,t,r){this.level=e,this.from=t,this.to=r}return function(e,t){var c="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!n.test(e))return!1;for(var u=e.length,d=[],f=0;f-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function Ne(e,t){var r=ye(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function Le(e){e.prototype.on=function(e,t){Te(this,e,t)},e.prototype.off=function(e,t){Re(this,e,t)}}function Ie(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Ce(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function be(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function _e(e){Ie(e),Ce(e)}function we(e){return e.target||e.srcElement}function xe(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),T&&e.ctrlKey&&1==t&&(t=3),t}var Me,De,Pe=function(){if(a&&s<9)return!1;var e=_("div");return"draggable"in e||"dragDrop"in e}();function ke(e){if(null==Me){var t=_("span","");b(e,_("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Me=t.offsetWidth<=1&&t.offsetHeight>2&&!(a&&s<8))}var r=Me?_("span",""):_("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function Ue(e){if(null!=De)return De;var t=b(e,document.createTextNode("AخA")),r=L(t,0,1).getBoundingClientRect(),n=L(t,1,2).getBoundingClientRect();return C(e),!(!r||r.left==r.right)&&(De=n.right-r.right<3)}var Fe,He=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;t<=n;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(r.push(o.slice(0,a)),t+=a+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},We=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Ge="oncopy"in(Fe=_("div"))||(Fe.setAttribute("oncopy","return;"),"function"==typeof Fe.oncopy),Be=null;function Ve(e){if(null!=Be)return Be;var t=b(e,_("span","x")),r=t.getBoundingClientRect(),n=L(t,0,1).getBoundingClientRect();return Be=Math.abs(r.left-n.left)>1}var Ye={},ze={};function Xe(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ye[e]=t}function je(e,t){ze[e]=t}function Ke(e){if("string"==typeof e&&ze.hasOwnProperty(e))e=ze[e];else if(e&&"string"==typeof e.name&&ze.hasOwnProperty(e.name)){var t=ze[e.name];"string"==typeof t&&(t={name:t}),(e=ie(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ke("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ke("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function qe(e,t){t=Ke(t);var r=Ye[t.name];if(!r)return qe(e,"text/plain");var n=r(e,t);if(Je.hasOwnProperty(t.name)){var i=Je[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 a in t.modeProps)n[a]=t.modeProps[a];return n}var Je={};function Qe(e,t){B(t,Je.hasOwnProperty(e)?Je[e]:Je[e]={})}function Ze(e,t){if(!0===t)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.mode!=e;)t=r.state,e=r.mode;return r||{mode:e,state:t}}function et(e,t,r){return!e.startState||e.startState(t,r)}var tt=function(e,t,r){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=r};function rt(e,t){if((t-=e.first)<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?ut(r,rt(e,r).text.length):vt(t,rt(e,t.line).text.length)}function vt(e,t){var r=e.ch;return null==r||r>t?ut(e.line,t):r<0?ut(e.line,0):e}function Tt(e,t){for(var r=[],n=0;n=this.string.length},tt.prototype.sol=function(){return this.pos==this.lineStart},tt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},tt.prototype.next=function(){if(this.post},tt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},tt.prototype.skipToEnd=function(){this.pos=this.string.length},tt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},tt.prototype.backUp=function(e){this.pos-=e},tt.prototype.column=function(){return this.lastColumnPos0?null:(n&&!1!==t&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},tt.prototype.current=function(){return this.string.slice(this.start,this.pos)},tt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},tt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},tt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var yt=function(e,t){this.state=e,this.lookAhead=t},Rt=function(e,t,r,n){this.state=t,this.doc=e,this.line=r,this.maxLookAhead=n||0,this.baseTokens=null,this.baseTokenPos=1};function Nt(e,t,r,n){var i=[e.state.modeGen],o={};wt(e,t.text,e.doc.mode,r,(function(e,t){return i.push(e,t)}),o,n);for(var a=r.state,s=function(n){r.baseTokens=i;var s=e.state.overlays[n],l=1,c=0;r.state=!0,wt(e,t.text,s.mode,r,(function(e,t){for(var r=l;ce&&i.splice(l,1,e,i[l+1],n),l+=2,c=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,l-r,e,"overlay "+t),l=r+2;else for(;re.options.maxHighlightLength&&Ze(e.doc.mode,n.state),o=Nt(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 St(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return new Rt(n,!0,t);var o=xt(e,t,r),a=o>n.first&&rt(n,o-1).stateAfter,s=a?Rt.fromSaved(n,a,o):new Rt(n,et(n.mode),o);return n.iter(o,t,(function(r){Ot(e,r.text,s);var n=s.line;r.stateAfter=n==t-1||n%5==0||n>=i.viewFrom&&nt.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.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Rt.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Rt.fromSaved=function(e,t,r){return t instanceof yt?new Rt(e,Ze(e.mode,t.state),r,t.lookAhead):new Rt(e,Ze(e.mode,t),r)},Rt.prototype.save=function(e){var t=!1!==e?Ze(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new yt(t,this.maxLookAhead):t};var Ct=function(e,t,r){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=r};function bt(e,t,r,n){var i,o,a=e.doc,s=a.mode,l=rt(a,(t=gt(a,t)).line),c=St(e,t.line,r),u=new tt(l.text,e.options.tabSize,c);for(n&&(o=[]);(n||u.pose.options.maxHighlightLength?(s=!1,a&&Ot(e,t,n,d.pos),d.pos=t.length,l=null):l=_t(It(r,d,n.state,f),o),f){var h=f[0].name;h&&(l="m-"+(l?h+" "+l:h))}if(!s||u!=l){for(;ca;--s){if(s<=o.first)return o.first;var l=rt(o,s-1),c=l.stateAfter;if(c&&(!r||s+(c instanceof yt?c.lookAhead:0)<=o.modeFrontier))return s;var u=V(l.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Mt(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontierr;n--){var i=rt(e,n).stateAfter;if(i&&(!(i instanceof yt)||n+i.lookAhead=t:o.to>t);(n||(n=[])).push(new Ft(a,o.from,s?null:o.to))}}return n}function Vt(e,t,r){var n;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==a.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&s)for(var T=0;T0)){var u=[l,1],d=dt(c.from,s.from),f=dt(c.to,s.to);(d<0||!a.inclusiveLeft&&!d)&&u.push({from:c.from,to:s.from}),(f>0||!a.inclusiveRight&&!f)&&u.push({from:s.to,to:c.to}),i.splice.apply(i,u),l+=u.length-3}}return i}function jt(e){var t=e.markedSpans;if(t){for(var r=0;rt)&&(!r||Qt(r,o.marker)<0)&&(r=o.marker)}return r}function rr(e,t,r,n,i){var o=rt(e,t),a=Pt&&o.markedSpans;if(a)for(var s=0;s=0&&d<=0||u<=0&&d>=0)&&(u<=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?dt(c.to,r)>=0:dt(c.to,r)>0)||u>=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?dt(c.from,n)<=0:dt(c.from,n)<0)))return!0}}}function nr(e){for(var t;t=$t(e);)e=t.find(-1,!0).line;return e}function ir(e){for(var t;t=er(e);)e=t.find(1,!0).line;return e}function or(e){for(var t,r;t=er(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function ar(e,t){var r=rt(e,t),n=nr(r);return r==n?t:at(n)}function sr(e,t){if(t>e.lastLine())return t;var r,n=rt(e,t);if(!lr(e,n))return t;for(;r=er(n);)n=r.find(1,!0).line;return at(n)+1}function lr(e,t){var r=Pt&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)}))}var hr=function(e,t,r){this.text=e,Kt(this,t),this.height=r?r(this):1};function pr(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),jt(e),Kt(e,r);var i=n?n(e):1;i!=e.height&&ot(e,i)}function Er(e){e.parent=null,jt(e)}hr.prototype.lineNo=function(){return at(this)},Le(hr);var mr={},gr={};function vr(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?gr:mr;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Tr(e,t){var r=w("span",null,null,l?"padding-right: .1px":null),n={pre:w("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,a=void 0;n.pos=0,n.addToken=Rr,Ue(e.display.measure)&&(a=ge(o,e.doc.direction))&&(n.addToken=Ar(n.addToken,a)),n.map=[],Or(o,n,At(e,o,t!=e.display.externalMeasured&&at(o))),o.styleClasses&&(o.styleClasses.bgClass&&(n.bgClass=P(o.styleClasses.bgClass,n.bgClass||"")),o.styleClasses.textClass&&(n.textClass=P(o.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(ke(e.display.measure))),0==i?(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(l){var s=n.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(n.content.className="cm-tab-wrap-hack")}return Ne(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=P(n.pre.className,n.textClass||"")),n}function yr(e){var t=_("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Rr(e,t,r,n,i,o,l){if(t){var c,u=e.splitSpaces?Nr(t,e.trailingSpace):t,d=e.cm.state.specialChars,f=!1;if(d.test(t)){c=document.createDocumentFragment();for(var h=0;;){d.lastIndex=h;var p=d.exec(t),E=p?p.index-h:t.length-h;if(E){var m=document.createTextNode(u.slice(h,h+E));a&&s<9?c.appendChild(_("span",[m])):c.appendChild(m),e.map.push(e.pos,e.pos+E,m),e.col+=E,e.pos+=E}if(!p)break;h+=E+1;var g=void 0;if("\t"==p[0]){var v=e.cm.options.tabSize,T=v-e.col%v;(g=c.appendChild(_("span",$(T),"cm-tab"))).setAttribute("role","presentation"),g.setAttribute("cm-text","\t"),e.col+=T}else"\r"==p[0]||"\n"==p[0]?((g=c.appendChild(_("span","\r"==p[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",p[0]),e.col+=1):((g=e.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text",p[0]),a&&s<9?c.appendChild(_("span",[g])):c.appendChild(g),e.col+=1);e.map.push(e.pos,e.pos+1,g),e.pos++}}else e.col+=t.length,c=document.createTextNode(u),e.map.push(e.pos,e.pos+t.length,c),a&&s<9&&(f=!0),e.pos+=t.length;if(e.trailingSpace=32==u.charCodeAt(t.length-1),r||n||i||f||o||l){var y=r||"";n&&(y+=n),i&&(y+=i);var R=_("span",[c],y,o);if(l)for(var N in l)l.hasOwnProperty(N)&&"style"!=N&&"class"!=N&&R.setAttribute(N,l[N]);return e.content.appendChild(R)}e.content.appendChild(c)}}function Nr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;ic&&d.from<=c);f++);if(d.to>=u)return e(r,n,i,o,a,s,l);e(r,n.slice(0,d.to-c),i,o,null,s,l),o=null,n=n.slice(d.to-c),c=d.to}}}function Sr(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 a,s,l,c,u,d,f,h=i.length,p=0,E=1,m="",g=0;;){if(g==p){l=c=u=s="",f=null,d=null,g=1/0;for(var v=[],T=void 0,y=0;yp||N.collapsed&&R.to==p&&R.from==p)){if(null!=R.to&&R.to!=p&&g>R.to&&(g=R.to,c=""),N.className&&(l+=" "+N.className),N.css&&(s=(s?s+";":"")+N.css),N.startStyle&&R.from==p&&(u+=" "+N.startStyle),N.endStyle&&R.to==g&&(T||(T=[])).push(N.endStyle,R.to),N.title&&((f||(f={})).title=N.title),N.attributes)for(var A in N.attributes)(f||(f={}))[A]=N.attributes[A];N.collapsed&&(!d||Qt(d.marker,N)<0)&&(d=R)}else R.from>p&&g>R.from&&(g=R.from)}if(T)for(var S=0;S=h)break;for(var L=Math.min(h,g);;){if(m){var I=p+m.length;if(!d){var C=I>L?m.slice(0,L-p):m;t.addToken(t,C,a?a+l:l,u,p+C.length==g?c:"",s,f)}if(I>=L){m=m.slice(L-p),p=L;break}p=I,u=""}m=i.slice(o,o=r[E++]),a=vr(r[E++],t.cm.options)}}else for(var b=1;b2&&o.push((l.bottom+c.top)/2-r.top)}}o.push(r.bottom-r.top)}}function rn(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};if(e.rest){for(var n=0;nr)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}}function nn(e,t){var r=at(t=nr(t)),n=e.display.externalMeasured=new Lr(e.doc,t,r);n.lineN=r;var i=n.built=Tr(e,n);return n.text=i.pre,b(e.display.lineMeasure,i.pre),n}function on(e,t,r,n){return ln(e,sn(e,t),r,n)}function an(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&tt)&&(i=(o=l-s)-1,t>=l&&(a="right")),null!=i){if(n=e[c+2],s==l&&r==(n.insertLeft?"left":"right")&&(a=r),"left"==r&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)n=e[2+(c-=3)],a="left";if("right"==r&&i==l-s)for(;c=0&&(r=e[i]).left==r.right;i--);return r}function hn(e,t,r,n){var i,o=dn(t.map,r,n),l=o.node,c=o.start,u=o.end,d=o.collapse;if(3==l.nodeType){for(var f=0;f<4;f++){for(;c&&ue(t.line.text.charAt(o.coverStart+c));)--c;for(;o.coverStart+u0&&(d=n="right"),i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==n?h.length-1:0]:l.getBoundingClientRect()}if(a&&s<9&&!c&&(!i||!i.left&&!i.right)){var p=l.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+Pn(e.display),top:p.top,bottom:p.bottom}:un}for(var E=i.top-t.rect.top,m=i.bottom-t.rect.top,g=(E+m)/2,v=t.view.measure.heights,T=0;T=n.text.length?(l=n.text.length,c="before"):l<=0&&(l=0,c="after"),!s)return a("before"==c?l-1:l,"before"==c);function u(e,t,r){return a(r?e-1:e,1==s[t].level!=r)}var d=Ee(s,l,c),f=pe,h=u(l,d,"before"==c);return null!=f&&(h.other=u(l,f,"before"!=c)),h}function On(e,t){var r=0;t=gt(e.doc,t),e.options.lineWrapping||(r=Pn(e.display)*t.ch);var n=rt(e.doc,t.line),i=ur(n)+qr(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function Ln(e,t,r,n,i){var o=ut(e,t,r);return o.xRel=i,n&&(o.outside=n),o}function In(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return Ln(n.first,0,null,-1,-1);var i=st(n,r),o=n.first+n.size-1;if(i>o)return Ln(n.first+n.size-1,rt(n,o).text.length,null,1,1);t<0&&(t=0);for(var a=rt(n,i);;){var s=wn(e,a,i,t,r),l=tr(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var c=l.find(1);if(c.line==i)return c;a=rt(n,i=c.line)}}function Cn(e,t,r,n){n-=yn(t);var i=t.text.length,o=fe((function(t){return ln(e,r,t-1).bottom<=n}),i,0);return{begin:o,end:i=fe((function(t){return ln(e,r,t).top>n}),o,i)}}function bn(e,t,r,n){return r||(r=sn(e,t)),Cn(e,t,r,Rn(e,t,ln(e,r,n),"line").top)}function _n(e,t,r,n){return!(e.bottom<=r)&&(e.top>r||(n?e.left:e.right)>t)}function wn(e,t,r,n,i){i-=ur(t);var o=sn(e,t),a=yn(t),s=0,l=t.text.length,c=!0,u=ge(t,e.doc.direction);if(u){var d=(e.options.lineWrapping?Mn:xn)(e,t,r,o,u,n,i);s=(c=1!=d.level)?d.from:d.to-1,l=c?d.to:d.from-1}var f,h,p=null,E=null,m=fe((function(t){var r=ln(e,o,t);return r.top+=a,r.bottom+=a,!!_n(r,n,i,!1)&&(r.top<=i&&r.left<=n&&(p=t,E=r),!0)}),s,l),g=!1;if(E){var v=n-E.left=y.bottom?1:0}return Ln(r,m=de(t.text,m,1),h,g,n-f)}function xn(e,t,r,n,i,o,a){var s=fe((function(s){var l=i[s],c=1!=l.level;return _n(Sn(e,ut(r,c?l.to:l.from,c?"before":"after"),"line",t,n),o,a,!0)}),0,i.length-1),l=i[s];if(s>0){var c=1!=l.level,u=Sn(e,ut(r,c?l.from:l.to,c?"after":"before"),"line",t,n);_n(u,o,a,!0)&&u.top>a&&(l=i[s-1])}return l}function Mn(e,t,r,n,i,o,a){var s=Cn(e,t,n,a),l=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,d=null,f=0;f=c||h.to<=l)){var p=ln(e,n,1!=h.level?Math.min(c,h.to)-1:Math.max(l,h.from)).right,E=pE)&&(u=h,d=E)}}return u||(u=i[i.length-1]),u.fromc&&(u={from:u.from,to:c,level:u.level}),u}function Dn(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==cn){cn=_("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)cn.appendChild(document.createTextNode("x")),cn.appendChild(_("br"));cn.appendChild(document.createTextNode("x"))}b(e.measure,cn);var r=cn.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),C(e.measure),r||1}function Pn(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=_("span","xxxxxxxxxx"),r=_("pre",[t],"CodeMirror-line-like");b(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function kn(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=e.display.gutterSpecs[a].className;r[s]=o.offsetLeft+o.clientLeft+i,n[s]=o.clientWidth}return{fixedPos:Un(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function Un(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function Fn(e){var t=Dn(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/Pn(e.display)-3);return function(i){if(lr(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a0&&(l=rt(e.doc,c.line).text).length==c.ch){var u=V(l,l.length,e.options.tabSize)-l.length;c=ut(c.line,Math.max(0,Math.round((o-Qr(e.display).left)/Pn(e.display))-u))}return c}function Gn(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var r=e.display.view,n=0;nt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Pt&&ar(e.doc,t)i.viewFrom?Yn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)Yn(e);else if(t<=i.viewFrom){var o=zn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):Yn(e)}else if(r>=i.viewTo){var a=zn(e,t,t,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):Yn(e)}else{var s=zn(e,t,t,-1),l=zn(e,r,r+n,1);s&&l?(i.view=i.view.slice(0,s.index).concat(Ir(e,s.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=n):Yn(e)}var c=i.externalMeasured;c&&(r=i.lineN&&t=n.viewTo)){var o=n.view[Gn(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==z(a,r)&&a.push(r)}}}function Yn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zn(e,t,r,n){var i,o=Gn(e,t),a=e.display.view;if(!Pt||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,l=0;l0){if(o==a.length-1)return null;i=s+a[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;ar(e.doc,r)!=r;){if(o==(n<0?0:a.length-1))return null;r+=n*a[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function Xn(e,t,r){var n=e.display;0==n.view.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ir(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ir(e,t,n.viewFrom).concat(n.view):n.viewFromr&&(n.view=n.view.slice(0,Gn(e,r)))),n.viewTo=r}function jn(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo||l.to().line0?a:e.defaultCharWidth())+"px"}if(n.other){var s=r.appendChild(_("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));s.style.display="",s.style.left=n.other.left+"px",s.style.top=n.other.top+"px",s.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Qn(e,t){return e.top-t.top||e.left-t.left}function Zn(e,t,r){var n=e.display,i=e.doc,o=document.createDocumentFragment(),a=Qr(e.display),s=a.left,l=Math.max(n.sizerWidth,$r(e)-n.sizer.offsetLeft)-a.right,c="ltr"==i.direction;function u(e,t,r,n){t<0&&(t=0),t=Math.round(t),n=Math.round(n),o.appendChild(_("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==r?l-e:r)+"px;\n height: "+(n-t)+"px"))}function d(t,r,n){var o,a,d=rt(i,t),f=d.text.length;function h(r,n){return An(e,ut(t,r),"div",d,n)}function p(t,r,n){var i=bn(e,d,null,t),o="ltr"==r==("after"==n)?"left":"right";return h("after"==n?i.begin:i.end-(/\s/.test(d.text.charAt(i.end-1))?2:1),o)[o]}var E=ge(d,i.direction);return he(E,r||0,null==n?f:n,(function(e,t,i,d){var m="ltr"==i,g=h(e,m?"left":"right"),v=h(t-1,m?"right":"left"),T=null==r&&0==e,y=null==n&&t==f,R=0==d,N=!E||d==E.length-1;if(v.top-g.top<=3){var A=(c?y:T)&&N,S=(c?T:y)&&R?s:(m?g:v).left,O=A?l:(m?v:g).right;u(S,g.top,O-S,g.bottom)}else{var L,I,C,b;m?(L=c&&T&&R?s:g.left,I=c?l:p(e,i,"before"),C=c?s:p(t,i,"after"),b=c&&y&&N?l:v.right):(L=c?p(e,i,"before"):s,I=!c&&T&&R?l:g.right,C=!c&&y&&N?s:v.left,b=c?p(t,i,"after"):l),u(L,g.top,I-L,g.bottom),g.bottom0?t.blinker=setInterval((function(){e.hasFocus()||ni(e),t.cursorDiv.style.visibility=(r=!r)?"":"hidden"}),e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function ei(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||ri(e))}function ti(e){e.state.delayingBlurEvent=!0,setTimeout((function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&ni(e))}),100)}function ri(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ne(e,"focus",e,t),e.state.focused=!0,D(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),l&&setTimeout((function(){return e.display.input.reset(!0)}),20)),e.display.input.receivedFocus()),$n(e))}function ni(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Ne(e,"blur",e,t),e.state.focused=!1,I(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout((function(){e.state.focused||(e.display.shift=!1)}),150))}function ii(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=Math.max(0,t.scroller.getBoundingClientRect().top),i=t.lineDiv.getBoundingClientRect().top,o=0,l=0;l.005||E<-.005)&&(ie.display.sizerWidth){var g=Math.ceil(f/Pn(e.display));g>e.display.maxLineLength&&(e.display.maxLineLength=g,e.display.maxLine=c.line,e.display.maxLineChanged=!0)}}}Math.abs(o)>2&&(t.scroller.scrollTop+=o)}function oi(e){if(e.widgets)for(var t=0;t=a&&(o=st(t,ur(rt(t,l))-e.wrapper.clientHeight),a=l)}return{from:o,to:Math.max(a,o+1)}}function si(e,t){if(!Ae(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null,o=r.wrapper.ownerDocument;if(t.top+n.top<0?i=!0:t.bottom+n.top>(o.defaultView.innerHeight||o.documentElement.clientHeight)&&(i=!1),null!=i&&!E){var a=_("div","",null,"position: absolute;\n top: "+(t.top-r.viewOffset-qr(e.display))+"px;\n height: "+(t.bottom-t.top+Zr(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(i),e.display.lineSpace.removeChild(a)}}}function li(e,t,r,n){var i;null==n&&(n=0),e.options.lineWrapping||t!=r||(r="before"==t.sticky?ut(t.line,t.ch+1,"before"):t,t=t.ch?ut(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t);for(var o=0;o<5;o++){var a=!1,s=Sn(e,t),l=r&&r!=t?Sn(e,r):s,c=ui(e,i={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-n,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+n}),u=e.doc.scrollTop,d=e.doc.scrollLeft;if(null!=c.scrollTop&&(gi(e,c.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(a=!0)),null!=c.scrollLeft&&(Ti(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(a=!0)),!a)break}return i}function ci(e,t){var r=ui(e,t);null!=r.scrollTop&&gi(e,r.scrollTop),null!=r.scrollLeft&&Ti(e,r.scrollLeft)}function ui(e,t){var r=e.display,n=Dn(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:r.scroller.scrollTop,o=en(e),a={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+Jr(r),l=t.tops-n;if(t.topi+o){var u=Math.min(t.top,(c?s:t.bottom)-o);u!=i&&(a.scrollTop=u)}var d=e.options.fixedGutter?0:r.gutters.offsetWidth,f=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:r.scroller.scrollLeft-d,h=$r(e)-r.gutters.offsetWidth,p=t.right-t.left>h;return p&&(t.right=t.left+h),t.left<10?a.scrollLeft=0:t.lefth+f-3&&(a.scrollLeft=t.right+(p?0:10)-h),a}function di(e,t){null!=t&&(Ei(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function fi(e){Ei(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function hi(e,t,r){null==t&&null==r||Ei(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function pi(e,t){Ei(e),e.curOp.scrollToPos=t}function Ei(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,mi(e,On(e,t.from),On(e,t.to),t.margin))}function mi(e,t,r,n){var i=ui(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});hi(e,i.scrollLeft,i.scrollTop)}function gi(e,t){Math.abs(e.doc.scrollTop-t)<2||(r||Ki(e,{top:t}),vi(e,t,!0),r&&Ki(e),Wi(e,100))}function vi(e,t,r){t=Math.max(0,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 Ti(e,t,r,n){t=Math.max(0,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,Zi(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function yi(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Jr(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+Zr(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}var Ri=function(e,t,r){this.cm=r;var n=this.vert=_("div",[_("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=_("div",[_("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");n.tabIndex=i.tabIndex=-1,e(n),e(i),Te(n,"scroll",(function(){n.clientHeight&&t(n.scrollTop,"vertical")})),Te(i,"scroll",(function(){i.clientWidth&&t(i.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,a&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ri.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.scrollTop=0,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}},Ri.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ri.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ri.prototype.zeroWidthHack=function(){var e=T&&!p?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new Y,this.disableVert=new Y},Ri.prototype.enableZeroWidthBar=function(e,t,r){function n(){var i=e.getBoundingClientRect();("vert"==r?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1))!=e?e.style.visibility="hidden":t.set(1e3,n)}e.style.visibility="",t.set(1e3,n)},Ri.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Ni=function(){};function Ai(e,t){t||(t=yi(e));var r=e.display.barWidth,n=e.display.barHeight;Si(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&ii(e),Si(e,yi(e)),r=e.display.barWidth,n=e.display.barHeight}function Si(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",r.heightForcer.style.borderBottom=n.bottom+"px solid transparent",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}Ni.prototype.update=function(){return{bottom:0,right:0}},Ni.prototype.setScrollLeft=function(){},Ni.prototype.setScrollTop=function(){},Ni.prototype.clear=function(){};var Oi={native:Ri,null:Ni};function Li(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&I(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Oi[e.options.scrollbarStyle]((function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Te(t,"mousedown",(function(){e.state.focused&&setTimeout((function(){return e.display.input.focus()}),0)})),t.setAttribute("cm-not-content","true")}),(function(t,r){"horizontal"==r?Ti(e,t):gi(e,t)}),e),e.display.scrollbars.addClass&&D(e.display.wrapper,e.display.scrollbars.addClass)}var Ii=0;function Ci(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Ii,markArrays:null},br(e.curOp)}function bi(e){var t=e.curOp;t&&wr(t,(function(e){for(var t=0;t=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Bi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function xi(e){e.updatedDisplay=e.mustUpdate&&Xi(e.cm,e.update)}function Mi(e){var t=e.cm,r=t.display;e.updatedDisplay&&ii(t),e.barMeasure=yi(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=on(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+Zr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-$r(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Di(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var r=+new Date+e.options.workTime,n=St(e,t.highlightFrontier),i=[];t.iter(n.line,Math.min(t.first+t.size,e.display.viewTo+500),(function(o){if(n.line>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength?Ze(t.mode,n.state):null,l=Nt(e,o,n,!0);s&&(n.state=s),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),f=0;!d&&fr)return Wi(e,e.options.workDelay),!0})),t.highlightFrontier=n.line,t.modeFrontier=Math.max(t.modeFrontier,n.line),i.length&&ki(e,(function(){for(var t=0;t=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==jn(e))return!1;$i(e)&&(Yn(e),t.dims=kn(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFroma&&r.viewTo-a<20&&(a=Math.min(i,r.viewTo)),Pt&&(o=ar(e.doc,o),a=sr(e.doc,a));var s=o!=r.viewFrom||a!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Xn(e,o,a),r.viewOffset=ur(rt(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var l=jn(e);if(!s&&0==l&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var c=Yi(e);return l>4&&(r.lineDiv.style.display="none"),qi(e,r.updateLineNumbers,t.dims),l>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,zi(c),C(r.cursorDiv),C(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Wi(e,400)),r.updateLineNumbers=null,!0}function ji(e,t){for(var r=t.viewport,n=!0;;n=!1){if(n&&e.options.lineWrapping&&t.oldDisplayWidth!=$r(e))n&&(t.visible=ai(e.display,e.doc,r));else if(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Jr(e.display)-en(e),r.top)}),t.visible=ai(e.display,e.doc,r),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!Xi(e,t))break;ii(e);var i=yi(e);Kn(e),Ai(e,i),Qi(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 Ki(e,t){var r=new Bi(e,t);if(Xi(e,r)){ii(e),ji(e,r);var n=yi(e);Kn(e),Ai(e,n),Qi(e,n),r.finish()}}function qi(e,t,r){var n=e.display,i=e.options.lineNumbers,o=n.lineDiv,a=o.firstChild;function s(t){var r=t.nextSibling;return l&&T&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var c=n.view,u=n.viewFrom,d=0;d-1&&(h=!1),Pr(e,f,u,r)),h&&(C(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(ct(e.options,u)))),a=f.node.nextSibling}else{var p=Vr(e,f,u,r);o.insertBefore(p,a)}u+=f.size}for(;a;)a=s(a)}function Ji(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",Mr(e,"gutterChanged",e)}function Qi(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+Zr(e)+"px"}function Zi(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=Un(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",a=0;a