diff --git a/plugins/tiddlywiki/codemirror/files/codemirror.js b/plugins/tiddlywiki/codemirror/files/codemirror.js index d302148a3..801840569 100755 --- a/plugins/tiddlywiki/codemirror/files/codemirror.js +++ b/plugins/tiddlywiki/codemirror/files/codemirror.js @@ -1 +1 @@ -!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,r=/gecko\/\d/i.test(e),n=/MSIE \d/.test(e),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),o=/Edge\/(\d+)/.exec(e),l=n||i||o,s=l&&(n?document.documentMode||6:+(o||i)[1]),a=!o&&/WebKit\//.test(e),u=a&&/Qt\/\d+\.\d+/.test(e),c=!o&&/Chrome\//.test(e),h=/Opera\//.test(e),f=/Apple Computer/.test(navigator.vendor),d=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),p=/PhantomJS/.test(e),g=!o&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e),v=/Android/.test(e),m=g||v||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=g||/Mac/.test(t),b=/\bCrOS\b/.test(e),w=/win/i.test(t),x=h&&e.match(/Version\/(\d*\.\d*)/);x&&(x=Number(x[1])),x&&x>=15&&(h=!1,a=!0);var C=y&&(u||h&&(null==x||x<12.11)),S=r||l&&s>=9;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var k,T=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 M(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function N(e,t){return M(e).appendChild(t)}function O(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}}g?P=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:l&&(P=function(e){try{e.select()}catch(e){}});var R=function(){this.id=null};function B(e,t){for(var r=0;r=t)return n+Math.min(l,t-i);if(i+=o-n,n=o+1,(i+=r-i%r)>=t)return n}}var Y=[""];function _(e){for(;Y.length<=e;)Y.push(q(Y)+" ");return Y[e]}function q(e){return e[e.length-1]}function $(e,t){for(var r=[],n=0;n"€"&&(e.toUpperCase()!=e.toLowerCase()||J.test(e))}function te(e,t){return t?!!(t.source.indexOf("\\w")>-1&&ee(e))||t.test(e):ee(e)}function re(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ne=/[\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 ie(e){return e.charCodeAt(0)>=768&&ne.test(e)}function oe(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 se(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&&to?ge(o,se(e,o).text.length):(r=t,n=se(e,t.line).text.length,null==(i=r.ch)||i>n?ge(r.line,n):i<0?ge(r.line,0):r)}function Se(e,t){for(var r=[],n=0;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.from0&&s)for(var b=0;b=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ve(u.to,r)>=0:ve(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ve(u.from,n)<=0:ve(u.from,n)<0)))return!0}}}function Be(e){for(var t;t=ze(e);)e=t.find(-1,!0).line;return e}function Ge(e,t){var r=se(e,t),n=Be(r);return r==n?t:he(n)}function Ue(e,t){if(t>e.lastLine())return t;var r,n=se(e,t);if(!Ve(e,n))return t;for(;r=Ie(n);)n=r.find(1,!0).line;return he(n)+1}function Ve(e,t){var r=ke&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}var _e=null;function qe(e,t,r){var n;_e=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:_e=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:_e=i)}return null!=n?n:_e}var $e=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,i=/[LRr]/,o=/[Lb1n]/,l=/[1n]/;function s(e,t,r){this.level=e,this.from=t,this.to=r}return function(a,u){var c="ltr"==u?"L":"R";if(0==a.length||"ltr"==u&&!r.test(a))return!1;for(var h,f=a.length,d=[],p=0;p-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function rt(e,t){var r=et(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function lt(e){e.prototype.on=function(e,t){Je(this,e,t)},e.prototype.off=function(e,t){tt(this,e,t)}}function st(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function at(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ut(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function ct(e){st(e),at(e)}function ht(e){return e.target||e.srcElement}function ft(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),y&&e.ctrlKey&&1==t&&(t=3),t}var dt,pt,gt=function(){if(l&&s<9)return!1;var e=O("div");return"draggable"in e||"dragDrop"in e}();function vt(e){if(null==dt){var t=O("span","​");N(e,O("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(dt=t.offsetWidth<=1&&t.offsetHeight>2&&!(l&&s<8))}var r=dt?O("span","​"):O("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function mt(e){if(null!=pt)return pt;var t=N(e,document.createTextNode("AخA")),r=k(t,0,1).getBoundingClientRect(),n=k(t,1,2).getBoundingClientRect();return M(e),!(!r||r.left==r.right)&&(pt=n.right-r.right<3)}var yt,bt=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),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},wt=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)},xt="oncopy"in(yt=O("div"))||(yt.setAttribute("oncopy","return;"),"function"==typeof yt.oncopy),Ct=null;var St={},Lt={};function kt(e){if("string"==typeof e&&Lt.hasOwnProperty(e))e=Lt[e];else if(e&&"string"==typeof e.name&&Lt.hasOwnProperty(e.name)){var t=Lt[e.name];"string"==typeof t&&(t={name:t}),(e=Q(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return kt("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return kt("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Tt(e,t){t=kt(t);var r=St[t.name];if(!r)return Tt(e,"text/plain");var n=r(e,t);if(Mt.hasOwnProperty(t.name)){var i=Mt[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}var Mt={};function Nt(e,t){z(t,Mt.hasOwnProperty(e)?Mt[e]:Mt[e]={})}function Ot(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 At(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 Dt(e,t,r){return!e.startState||e.startState(t,r)}var Wt=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};Wt.prototype.eol=function(){return this.pos>=this.string.length},Wt.prototype.sol=function(){return this.pos==this.lineStart},Wt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Wt.prototype.next=function(){if(this.post},Wt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Wt.prototype.skipToEnd=function(){this.pos=this.string.length},Wt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Wt.prototype.backUp=function(e){this.pos-=e},Wt.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},Wt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Wt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Wt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Wt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var Ht=function(e,t){this.state=e,this.lookAhead=t},Ft=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 Pt(e,t,r,n){var i=[e.state.modeGen],o={};Kt(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var l=r.state,s=function(n){r.baseTokens=i;var s=e.state.overlays[n],a=1,u=0;r.state=!0,Kt(e,t.text,s.mode,r,function(e,t){for(var r=a;ue&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"overlay "+t),a=r+2;else for(;re.options.maxHighlightLength&&Ot(e.doc.mode,n.state),o=Pt(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 zt(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return new Ft(n,!0,t);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;s>l;--s){if(s<=o.first)return o.first;var a=se(o,s-1),u=a.stateAfter;if(u&&(!r||s+(u instanceof Ht?u.lookAhead:0)<=o.modeFrontier))return s;var c=I(a.text,null,e.options.tabSize);(null==i||n>c)&&(i=s-1,n=c)}return i}(e,t,r),l=o>n.first&&se(n,o-1).stateAfter,s=l?Ft.fromSaved(n,l,o):new Ft(n,Dt(n.mode),o);return n.iter(o,t,function(r){It(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.")}Ft.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Ft.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}},Ft.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Ft.fromSaved=function(e,t,r){return t instanceof Ht?new Ft(e,Ot(e.mode,t.state),r,t.lookAhead):new Ft(e,Ot(e.mode,t),r)},Ft.prototype.save=function(e){var t=!1!==e?Ot(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Ht(t,this.maxLookAhead):t};var Gt=function(e,t,r){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=r};function Ut(e,t,r,n){var i,o,l=e.doc,s=l.mode,a=se(l,(t=Ce(l,t)).line),u=zt(e,t.line,r),c=new Wt(a.text,e.options.tabSize,u);for(n&&(o=[]);(n||c.pose.options.maxHighlightLength?(s=!1,l&&It(e,t,n,h.pos),h.pos=t.length,a=null):a=Vt(Bt(r,h,n.state,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u1&&!/ /.test(e))return e;for(var r=t,n="",i=0;iu&&h.from<=u);f++);if(h.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,h.to-u),i,o,null,s,a),o=null,n=n.slice(h.to-u),u=h.to}}}function Jt(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 er(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,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&&!h&&(h=C.title),C.collapsed&&(!f||Pe(f.marker,C)<0)&&(f=x)):x.from>p&&m>x.from&&(m=x.from)}if(b)for(var S=0;S=d)break;for(var k=Math.min(d,m);;){if(v){var T=p+v.length;if(!f){var M=T>k?v.slice(0,k-p):v;t.addToken(t,M,l?l+a:a,c,p+M.length==m?u:"",h,s)}if(T>=k){v=v.slice(k-p),p=k;break}p=T,c=""}v=i.slice(o,o=r[g++]),l=_t(r[g++],t.cm.options)}}else for(var N=1;Nr)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Tr(e,t,r,n){return Or(e,Nr(e,t),r,n)}function Mr(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&t2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}(e,t.view,t.rect),t.hasHeights=!0),(o=function(e,t,r,n){var i,o=Wr(t.map,r,n),a=o.node,u=o.start,c=o.end,h=o.collapse;if(3==a.nodeType){for(var f=0;f<4;f++){for(;u&&ie(t.line.text.charAt(o.coverStart+u));)--u;for(;o.coverStart+c1}(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}(e.display.measure,i))}else{var d;u>0&&(h=n="right"),i=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==n?d.length-1:0]:a.getBoundingClientRect()}if(l&&s<9&&!u&&(!i||!i.left&&!i.right)){var p=a.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+Qr(e.display),top:p.top,bottom:p.bottom}:Dr}for(var g=i.top-t.rect.top,v=i.bottom-t.rect.top,m=(g+v)/2,y=t.view.measure.heights,b=0;bt)&&(i=(o=a-s)-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[2+(u-=3)],l="left";if("right"==r&&i==a-s)for(;u=0&&(r=e[i]).left==r.right;i--);return r}function Fr(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=n.text.length?(a=n.text.length,u="before"):a<=0&&(a=0,u="after"),!s)return l("before"==u?a-1:a,"before"==u);function c(e,t,r){return l(r?e-1:e,1==s[t].level!=r)}var h=qe(s,a,u),f=_e,d=c(a,h,"before"==u);return null!=f&&(d.other=c(a,f,"before"!=u)),d}function Kr(e,t){var r=0;t=Ce(e.doc,t),e.options.lineWrapping||(r=Qr(e.display)*t.ch);var n=se(e.doc,t.line),i=je(n)+br(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function jr(e,t,r,n,i){var o=ge(e,t,r);return o.xRel=i,n&&(o.outside=!0),o}function Xr(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return jr(n.first,0,null,!0,-1);var i=fe(n,r),o=n.first+n.size-1;if(i>o)return jr(n.first+n.size-1,se(n,o).text.length,null,!0,1);t<0&&(t=0);for(var l=se(n,i);;){var s=$r(e,l,i,t,r),a=Ie(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=he(l=u.to.line)}}function Yr(e,t,r,n){n-=Rr(t);var i=t.text.length,o=le(function(t){return Or(e,r,t-1).bottom<=n},i,0);return{begin:o,end:i=le(function(t){return Or(e,r,t).top>n},o,i)}}function _r(e,t,r,n){return r||(r=Nr(e,t)),Yr(e,t,r,Br(e,t,Or(e,r,n),"line").top)}function qr(e,t,r,n){return!(e.bottom<=r)&&(e.top>r||(n?e.left:e.right)>t)}function $r(e,t,r,n,i){i-=je(t);var o=Nr(e,t),l=Rr(t),s=0,a=t.text.length,u=!0,c=Ze(t,e.doc.direction);if(c){var h=(e.options.lineWrapping?function(e,t,r,n,i,o,l){var s=Yr(e,t,n,l),a=s.begin,u=s.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var c=null,h=null,f=0;f=u||d.to<=a)){var p=1!=d.level,g=Or(e,n,p?Math.min(u,d.to)-1:Math.max(a,d.from)).right,v=gv)&&(c=d,h=v)}}c||(c=i[i.length-1]);c.fromu&&(c={from:c.from,to:u,level:c.level});return c}:function(e,t,r,n,i,o,l){var s=le(function(s){var a=i[s],u=1!=a.level;return qr(Vr(e,ge(r,u?a.to:a.from,u?"before":"after"),"line",t,n),o,l,!0)},0,i.length-1),a=i[s];if(s>0){var u=1!=a.level,c=Vr(e,ge(r,u?a.from:a.to,u?"after":"before"),"line",t,n);qr(c,o,l,!0)&&c.top>l&&(a=i[s-1])}return a})(e,t,r,o,c,n,i);s=(u=1!=h.level)?h.from:h.to-1,a=u?h.to:h.from-1}var f,d,p=null,g=null,v=le(function(t){var r=Or(e,o,t);return r.top+=l,r.bottom+=l,!!qr(r,n,i,!1)&&(r.top<=i&&r.left<=n&&(p=t,g=r),!0)},s,a),m=!1;if(g){var y=n-g.left=w.bottom}return jr(r,v=oe(t.text,v,1),d,m,n-f)}function Zr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Ar){Ar=O("pre");for(var t=0;t<49;++t)Ar.appendChild(document.createTextNode("x")),Ar.appendChild(O("br"));Ar.appendChild(document.createTextNode("x"))}N(e.measure,Ar);var r=Ar.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),M(e.measure),r||1}function Qr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=O("span","xxxxxxxxxx"),r=O("pre",[t]);N(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function Jr(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:en(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function en(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function tn(e){var t=Zr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/Qr(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)<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",o),i=!0)}i||n(t,r,"ltr")}(g,r||0,null==n?f:n,function(e,t,i,h){var v="ltr"==i,m=d(e,v?"left":"right"),y=d(t-1,v?"right":"left"),b=null==r&&0==e,w=null==n&&t==f,x=0==h,C=!g||h==g.length-1;if(y.top-m.top<=3){var S=(u?w:b)&&C,L=(u?b:w)&&x?s:(v?m:y).left,k=S?a:(v?y:m).right;c(L,m.top,k-L,m.bottom)}else{var T,M,N,O;v?(T=u&&b&&x?s:m.left,M=u?a:p(e,i,"before"),N=u?s:p(t,i,"after"),O=u&&w&&C?a:y.right):(T=u?p(e,i,"before"):s,M=!u&&b&&x?a:m.right,N=!u&&w&&C?s:y.left,O=u?p(t,i,"after"):a),c(T,m.top,M-T,m.bottom),m.bottom0?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 fn(e){e.state.focused||(e.display.input.focus(),pn(e))}function dn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,gn(e))},100)}function pn(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(rt(e,"focus",e,t),e.state.focused=!0,H(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),a&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),hn(e))}function gn(e,t){e.state.delayingBlurEvent||(e.state.focused&&(rt(e,"blur",e,t),e.state.focused=!1,T(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function vn(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n.005||c<-.005)&&(ce(i.line,o),mn(i.line),i.rest))for(var h=0;h=l&&(o=fe(t,je(se(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function bn(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=en(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+wr(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=Sr(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 Cn(e,t){null!=t&&(kn(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Sn(e){kn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Ln(e,t,r){null==t&&null==r||kn(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function kn(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Tn(e,Kr(e,t.from),Kr(e,t.to),t.margin))}function Tn(e,t,r,n){var i=xn(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});Ln(e,i.scrollLeft,i.scrollTop)}function Mn(e,t){Math.abs(e.doc.scrollTop-t)<2||(r||ii(e,{top:t}),Nn(e,t,!0),r&&ii(e),Jn(e,100))}function Nn(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 On(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,bn(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function An(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+wr(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+Cr(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),Je(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Je(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,l&&s<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&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},Dn.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Dn.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Dn.prototype.zeroWidthHack=function(){var e=y&&!d?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new R,this.disableVert=new R},Dn.prototype.enableZeroWidthBar=function(e,t,r){e.style.pointerEvents="auto",t.set(1e3,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.pointerEvents="none":t.set(1e3,n)})},Dn.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Wn=function(){};function Hn(e,t){t||(t=An(e));var r=e.display.barWidth,n=e.display.barHeight;Fn(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&vn(e),Fn(e,An(e)),r=e.display.barWidth,n=e.display.barHeight}function Fn(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=""}Wn.prototype.update=function(){return{bottom:0,right:0}},Wn.prototype.setScrollLeft=function(){},Wn.prototype.setScrollTop=function(){},Wn.prototype.clear=function(){};var Pn={native:Dn,null:Wn};function En(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&T(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Pn[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Je(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?On(e,t):Mn(e,t)},e),e.display.scrollbars.addClass&&H(e.display.wrapper,e.display.scrollbars.addClass)}var zn=0;function In(e){var t;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:++zn},t=e.curOp,nr?nr.ops.push(t):t.ownsGroup=nr={ops:[t],delayedCallbacks:[]}}function Rn(e){!function(e,t){var r=e.ownsGroup;if(r)try{!function(e){var t=e.delayedCallbacks,r=0;do{for(;r=i.viewTo)||i.maxLineChanged&&n.options.lineWrapping,e.update=e.mustUpdate&&new ti(n,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Gn(e){var t=e.cm,r=t.display;e.updatedDisplay&&vn(t),e.barMeasure=An(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Tr(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+Cr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Sr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Un(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&&!p){var o=O("div","​",null,"position: absolute;\n top: "+(t.top-r.viewOffset-br(e.display))+"px;\n height: "+(t.bottom-t.top+Cr(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?ge(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?ge(t.line,t.ch+1,"before"):t);for(var o=0;o<5;o++){var l=!1,s=Vr(e,t),a=r&&r!=t?Vr(e,r):s,u=xn(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&&(Mn(e,u.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(l=!0)),null!=u.scrollLeft&&(On(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-h)>1&&(l=!0)),!l)break}return i}(t,Ce(n,e.scrollToPos.from),Ce(n,e.scrollToPos.to),e.scrollToPos.margin));var i=e.maybeHiddenMarkers,o=e.maybeUnhiddenMarkers;if(i)for(var l=0;lt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)ke&&Ge(e.doc,t)i.viewFrom?$n(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)$n(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):$n(e)}else if(r>=i.viewTo){var l=Zn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):$n(e)}else{var s=Zn(e,t,t,-1),a=Zn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(rr(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):$n(e)}var u=i.externalMeasured;u&&(r=i.lineN&&t=n.viewTo)){var o=n.view[on(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==B(l,r)&&l.push(r)}}}function $n(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=on(e,t),l=e.display.view;if(!ke||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(;Ge(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 Qn(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo)){var r=+new Date+e.options.workTime,n=zt(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 l=o.styles,s=o.text.length>e.options.maxHighlightLength?Ot(t.mode,n.state):null,a=Pt(e,o,n,!0);s&&(n.state=s),o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),f=0;!h&&fr)return Jn(e,e.options.workDelay),!0}),t.highlightFrontier=n.line,t.modeFrontier=Math.max(t.modeFrontier,n.line),i.length&&Kn(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==Qn(e))return!1;wn(e)&&($n(e),t.dims=Jr(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)),ke&&(o=Ge(e.doc,o),l=Ue(e.doc,l));var s,u,c,h,f=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;u=o,c=l,0==(h=(s=e).display).view.length||u>=h.viewTo||c<=h.viewFrom?(h.view=rr(s,u,c),h.viewFrom=u):(h.viewFrom>u?h.view=rr(s,u,h.viewFrom).concat(h.view):h.viewFromc&&(h.view=h.view.slice(0,on(s,c)))),h.viewTo=c,r.viewOffset=je(se(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var d=Qn(e);if(!f&&0==d&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var p=function(e){if(e.hasFocus())return null;var t=W();if(!t||!D(e.display.lineDiv,t))return null;var r={activeElt:t};if(window.getSelection){var n=window.getSelection();n.anchorNode&&n.extend&&D(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 d>4&&(r.lineDiv.style.display="none"),function(e,t,r){var n=e.display,i=e.options.lineNumbers,o=n.lineDiv,l=o.firstChild;function s(t){var r=t.nextSibling;return a&&y&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var u=n.view,c=n.viewFrom,h=0;h-1&&(d=!1),sr(e,f,c,r)),d&&(M(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(pe(e.options,c)))),l=f.node.nextSibling}else{var p=(m=c,b=r,void 0,w=ur(g=e,v=f),v.text=v.node=w.pre,w.bgClass&&(v.bgClass=w.bgClass),w.textClass&&(v.textClass=w.textClass),hr(g,v),fr(g,v,m,b),pr(g,v,b),v.node);o.insertBefore(p,l)}c+=f.size}var g,v,m,b,w;for(;l;)l=s(l)}(e,r.updateLineNumbers,t.dims),d>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,function(e){if(e&&e.activeElt&&e.activeElt!=W()&&(e.activeElt.focus(),e.anchorNode&&D(document.body,e.anchorNode)&&D(document.body,e.focusNode))){var t=window.getSelection(),r=document.createRange();r.setEnd(e.anchorNode,e.anchorOffset),r.collapse(!1),t.removeAllRanges(),t.addRange(r),t.extend(e.focusNode,e.focusOffset)}}(p),M(r.cursorDiv),M(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,f&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Jn(e,400)),r.updateLineNumbers=null,!0}function ni(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Sr(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+wr(e.display)-Lr(e),r.top)}),t.visible=yn(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&ri(e,t);n=!1){vn(e);var i=An(e);ln(e),Hn(e,i),li(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 ii(e,t){var r=new ti(e,t);if(ri(e,r)){vn(e),ni(e,r);var n=An(e);ln(e),Hn(e,n),li(e,n),r.finish()}}function oi(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function li(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+Cr(e)+"px"}function si(e){var t=e.display.gutters,r=e.options.gutters;M(t);for(var n=0;n-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}ti.prototype.signal=function(e,t){ot(e,t)&&this.events.push(arguments)},ti.prototype.finish=function(){for(var e=0;es.clientWidth,c=s.scrollHeight>s.clientHeight;if(i&&u||o&&c){if(o&&y&&a)e:for(var f=t.target,d=l.view;f!=s;f=f.parentNode)for(var p=0;p=0&&ve(e,n.to())<=0)return r}return-1};var gi=function(e,t){this.anchor=e,this.head=t};function vi(e,t){var r=e[t];e.sort(function(e,t){return ve(e.from(),t.from())}),t=B(e,r);for(var n=1;n=0){var l=we(o.from(),i.from()),s=be(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new gi(a?s:l,a?l:s))}}return new pi(e,t)}function mi(e,t){return new pi([new gi(e,t||e)],0)}function yi(e){return e.text?ge(e.from.line+e.text.length-1,q(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function bi(e,t){if(ve(e,t.from)<0)return e;if(ve(e,t.to)<=0)return yi(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+=yi(t).ch-t.to.ch),ge(r,n)}function wi(e,t){for(var r=[],n=0;n1&&e.remove(s.line+1,p-1),e.insert(s.line+1,m)}or(e,"change",e,t)}function Ti(e,t,r){!function e(n,i,o){if(n.linked)for(var l=0;la-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(s=i,o=i.lastOp==n?(Di(s.done),q(s.done)):s.done.length&&!q(s.done).ranges?q(s.done):s.done.length>1&&!s.done[s.done.length-2].ranges?(s.done.pop(),q(s.done)):void 0))l=q(o.changes),0==ve(t.from,t.to)&&0==ve(t.from,l.to)?l.to=yi(t):o.changes.push(Ai(e,t));else{var u=q(i.done);for(u&&u.ranges||Fi(e.sel,i.done),o={changes:[Ai(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=a,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||rt(e,"historyAdded")}function Hi(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:Fi(t,u.done),u.lastSelTime=+new Date,u.lastSelOrigin=c,u.lastSelOp=r,n&&!1!==n.clearRedo&&Di(u.undone)}function Fi(e,t){var r=q(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Pi(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 Ei(e){if(!e)return null;for(var t,r=0;r-1&&(q(s)[h]=u[h],delete u[h])}}}return n}function Ri(e,t,r,n){if(n){var i=e.anchor;if(r){var o=ve(t,i)<0;o!=ve(r,i)<0?(i=t,t=r):o!=ve(t,r)<0&&(t=r)}return new gi(i,t)}return new gi(r||t,t)}function Bi(e,t,r,n,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),ji(e,new pi([Ri(e.sel.primary(),t,r,i)],0),n)}function Gi(e,t,r){for(var n=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:s.to>t.ch))){if(i&&(rt(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=Qi(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=ve(u,r))&&(n<0?c<0:c>0))return $i(e,u,t,n,i)}var h=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(h=Qi(e,h,n,h.line==t.line?o:null)),h?$i(e,h,t,n,i):null}}return t}function Zi(e,t,r,n,i){var o=n||1,l=$i(e,t,r,o,i)||!i&&$i(e,t,r,o,!0)||$i(e,t,r,-o,i)||!i&&$i(e,t,r,-o,!0);return l||(e.cantEdit=!0,ge(e.first,0))}function Qi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?Ce(e,ge(t.line-1)):null:r>0&&t.ch==(n||se(e,t.line)).text.length?t.line0)){var c=[a,1],h=ve(u.from,s.from),f=ve(u.to,s.to);(h<0||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(f>0||!l.inclusiveRight&&!f)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-3}}return i}(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)ro(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text,origin:t.origin});else ro(e,t)}}function ro(e,t){if(1!=t.text.length||""!=t.text[0]||0!=ve(t.from,t.to)){var r=wi(e,t);Wi(e,t,r,e.cm?e.cm.curOp.id:NaN),oo(e,t,r,Oe(e,t));var n=[];Ti(e,function(e,r){r||-1!=B(n,e.history)||(uo(e.history,t),n.push(e.history)),oo(e,t,null,Oe(e,t))})}}function no(e,t,r){var n=e.cm&&e.cm.state.suppressEdits;if(!n||r){for(var i,o=e.history,l=e.sel,s="undo"==t?o.done:o.undone,a="undo"==t?o.undone:o.done,u=0;u=0;--d){var p=f(d);if(p)return p.v}}}}function io(e,t){if(0!=t&&(e.first+=t,e.sel=new pi($(e.sel.ranges,function(e){return new gi(ge(e.anchor.line+t,e.anchor.ch),ge(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){_n(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:ge(o,se(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ae(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=he(Be(se(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&&it(e);ki(n,t,r,tn(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=Xe(e);t>i.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.highlightFrontierr;n--){var i=se(e,n).stateAfter;if(i&&(!(i instanceof Ht)||n+i.lookAhead1||!(this.children[0]instanceof ho))){var s=[];this.collapse(s),this.children=[new ho(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var l=i.lines.length%25+25,s=l;s10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n0||0==l&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=A("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Re(e,t.line,t,r,o)||t.line!=r.line&&Re(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");ke=!0}o.addToHistory&&Wi(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){var n,i;u&&o.collapsed&&!u.options.lineWrapping&&Be(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&ce(e,0),n=e,i=new Te(o,a==t.line?t.ch:null,a==r.line?r.ch:null),n.markedSpans=n.markedSpans?n.markedSpans.concat([i]):[i],i.marker.attachLine(n),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){Ve(e,t)&&ce(t,0)}),o.clearOnEnter&&Je(o,"beforeCursorEnter",function(){return o.clear()}),o.readOnly&&(Le=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++vo,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)_n(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)qn(u,c,"text");o.atomic&&_i(u.doc),or(u,"markerAdded",u,o)}return o}mo.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){var t=this.doc.cm,r=t&&!t.curOp;if(r&&In(t),ot(this,"clear")){var n=this.find();n&&or(this,"clear",n.from,n.to)}for(var i=null,o=null,l=0;lt.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=h,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&_n(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&_i(t.doc)),t&&or(t,"markerCleared",t,this,i,o),r&&Rn(t),this.parent&&this.parent.clear()}},mo.prototype.find=function(e,t){var r,n;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=0;a--)to(this,n[a]);s?Ki(this,s):this.cm&&Sn(this.cm)}),undo:Yn(function(){no(this,"undo")}),redo:Yn(function(){no(this,"redo")}),undoSelection:Yn(function(){no(this,"undo",!0)}),redoSelection:Yn(function(){no(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=Ce(this,e),t=Ce(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)return t=e,!0;e-=o,++r}),Ce(this,ge(r,t))},indexFromPos:function(e){var t=(e=Ce(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var c=e.dataTransfer.getData("Text");if(c){var h;if(t.state.draggingText&&!t.state.draggingText.copy&&(h=t.listSelections()),Xi(t.doc,mi(r,r)),h)for(var f=0;f=0;t--)lo(e.doc,"",n[t].from,n[t].to,"+delete");Sn(e)})}function Ko(e,t,r){var n=oe(e.text,t+r,r);return n<0||n>e.text.length?null:n}function jo(e,t,r){var n=Ko(e,t.ch,r);return null==n?null:new ge(t.line,n,r<0?"after":"before")}function Xo(e,t,r,n,i){if(e){var o=Ze(r,t.doc.direction);if(o){var l,s=i<0?q(o):o[0],a=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var u=Nr(t,r);l=i<0?r.text.length-1:0;var c=Or(t,u,l).top;l=le(function(e){return Or(t,u,e).top==c},i<0==(1==s.level)?s.from:s.to-1,l),"before"==a&&(l=Ko(r,l,1))}else l=i<0?s.to:s.from;return new ge(n,l,a)}}return new ge(n,i<0?r.text.length:0,i<0?"before":"after")}Po.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Po.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Po.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Po.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Po.default=y?Po.macDefault:Po.pcDefault;var Yo={selectAll:Ji,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),V)},killLine:function(e){return Vo(e,function(t){if(t.empty()){var r=se(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line0)i=new ge(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),ge(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=se(e.doc,i.line-1).text;l&&(i=new ge(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),ge(i.line-1,l.length-1),i,"+transpose"))}r.push(new gi(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return Kn(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;n-1&&(ve((i=u.ranges[i]).from(),t)<0||t.xRel>0)&&(ve(i.to(),t)>0||t.xRel<0)?function(e,t,r,n){var i=e.display,o=!1,u=jn(e,function(t){a&&(i.scroller.draggable=!1),e.state.draggingText=!1,tt(i.wrapper.ownerDocument,"mouseup",u),tt(i.wrapper.ownerDocument,"mousemove",c),tt(i.scroller,"dragstart",h),tt(i.scroller,"drop",u),o||(st(t),n.addNew||Bi(e.doc,r,null,null,n.extend),a||l&&9==s?setTimeout(function(){i.wrapper.ownerDocument.body.focus(),i.input.focus()},20):i.input.focus())}),c=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},h=function(){return o=!0};a&&(i.scroller.draggable=!0);e.state.draggingText=u,u.copy=!n.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop();Je(i.wrapper.ownerDocument,"mouseup",u),Je(i.wrapper.ownerDocument,"mousemove",c),Je(i.scroller,"dragstart",h),Je(i.scroller,"drop",u),dn(e),setTimeout(function(){return i.input.focus()},20)}(e,n,t,o):function(e,t,r,n){var i=e.display,o=e.doc;st(t);var l,s,a=o.sel,u=a.ranges;n.addNew&&!n.extend?(s=o.sel.contains(r),l=s>-1?u[s]:new gi(r,r)):(l=o.sel.primary(),s=o.sel.primIndex);if("rectangle"==n.unit)n.addNew||(l=new gi(r,r)),r=nn(e,t,!0,!0),s=-1;else{var c=ul(e,r,n.unit);l=n.extend?Ri(l,c.anchor,c.head,n.extend):c}n.addNew?-1==s?(s=u.length,ji(o,vi(u.concat([l]),s),{scroll:!1,origin:"*mouse"})):u.length>1&&u[s].empty()&&"char"==n.unit&&!n.extend?(ji(o,vi(u.slice(0,s).concat(u.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),a=o.sel):Ui(o,s,l,K):(s=0,ji(o,new pi([l],0),K),a=o.sel);var h=r;function f(t){if(0!=ve(h,t))if(h=t,"rectangle"==n.unit){for(var i=[],u=e.options.tabSize,c=I(se(o,r.line).text,r.ch,u),f=I(se(o,t.line).text,t.ch,u),d=Math.min(c,f),p=Math.max(c,f),g=Math.min(r.line,t.line),v=Math.min(e.lastLine(),Math.max(r.line,t.line));g<=v;g++){var m=se(o,g).text,y=X(m,d,u);d==p?i.push(new gi(ge(g,y),ge(g,y))):m.length>y&&i.push(new gi(ge(g,y),ge(g,X(m,p,u))))}i.length||i.push(new gi(r,r)),ji(o,vi(a.ranges.slice(0,s).concat(i),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,w=l,x=ul(e,t,n.unit),C=w.anchor;ve(x.anchor,C)>0?(b=x.head,C=we(w.from(),x.anchor)):(b=x.anchor,C=be(w.to(),x.head));var S=a.ranges.slice(0);S[s]=function(e,t){var r=t.anchor,n=t.head,i=se(e.doc,r.line);if(0==ve(r,n)&&r.sticky==n.sticky)return t;var o=Ze(i);if(!o)return t;var l=qe(o,r.ch,r.sticky),s=o[l];if(s.from!=r.ch&&s.to!=r.ch)return t;var a,u=l+(s.from==r.ch==(1!=s.level)?0:1);if(0==u||u==o.length)return t;if(n.line!=r.line)a=(n.line-r.line)*("ltr"==e.doc.direction?1:-1)>0;else{var c=qe(o,n.ch,n.sticky),h=c-l||(n.ch-r.ch)*(1==s.level?-1:1);a=c==u-1||c==u?h<0:h>0}var f=o[u+(a?-1:0)],d=a==(1==f.level),p=d?f.from:f.to,g=d?"after":"before";return r.ch==p&&r.sticky==g?t:new gi(new ge(r.line,p,g),n)}(e,new gi(Ce(o,C),b)),ji(o,vi(S,s),K)}}var d=i.wrapper.getBoundingClientRect(),p=0;function g(t){e.state.selectingText=!1,p=1/0,st(t),i.input.focus(),tt(i.wrapper.ownerDocument,"mousemove",v),tt(i.wrapper.ownerDocument,"mouseup",m),o.history.lastSelOrigin=null}var v=jn(e,function(t){ft(t)?function t(r){var l=++p;var s=nn(e,r,!0,"rectangle"==n.unit);if(!s)return;if(0!=ve(s,h)){e.curOp.focus=W(),f(s);var a=yn(i,o);(s.line>=a.to||s.lined.bottom?20:0;u&&setTimeout(jn(e,function(){p==l&&(i.scroller.scrollTop+=u,t(r))}),50)}}(t):g(t)}),m=jn(e,g);e.state.selectingText=m,Je(i.wrapper.ownerDocument,"mousemove",v),Je(i.wrapper.ownerDocument,"mouseup",m)}(e,n,t,o)}(t,u,h,e):ht(e)==r.scroller&&st(e):2==c?(u&&Bi(t.doc,u),setTimeout(function(){return r.input.focus()},20)):3==c&&(S?fl(t,e):dn(t)))}}function ul(e,t,r){if("char"==r)return new gi(t,t);if("word"==r)return e.findWordAt(t);if("line"==r)return new gi(ge(t.line,0),Ce(e.doc,ge(t.line+1,0)));var n=r(e,t);return new gi(n.from,n.to)}function cl(e,t,r,n){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&st(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!ot(e,r))return ut(t);o-=s.top-l.viewOffset;for(var a=0;a=i)return rt(e,r,e,fe(e.doc,o),e.options.gutters[a],t),ut(t)}}function hl(e,t){return cl(e,t,"gutterClick",!0)}function fl(e,t){yr(e.display,t)||function(e,t){if(!ot(e,"gutterContextMenu"))return!1;return cl(e,t,"gutterContextMenu",!1)}(e,t)||nt(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function dl(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Er(e)}sl.prototype.compare=function(e,t,r){return this.time+400>e&&0==ve(t,this.pos)&&r==this.button};var pl={toString:function(){return"CodeMirror.Init"}},gl={},vl={};function ml(e){si(e),_n(e),bn(e)}function yl(e,t,r){if(!t!=!(r&&r!=pl)){var n=e.display.dragFunctions,i=t?Je:tt;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 bl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(T(e.display.wrapper,"CodeMirror-wrap"),Ye(e)),rn(e),_n(e),Er(e),setTimeout(function(){return Hn(e)},100)}function wl(e,t){var n=this;if(!(this instanceof wl))return new wl(e,t);this.options=t=t?z(t):{},z(gl,t,!1),ai(t);var i=t.value;"string"==typeof i&&(i=new So(i,t.mode,null,t.lineSeparator,t.direction)),this.doc=i;var o=new wl.inputStyles[t.inputStyle](this),u=this.display=new function(e,t,n){var i=this;this.input=n,i.scrollbarFiller=O("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=O("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=A("div",null,"CodeMirror-code"),i.selectionDiv=O("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=O("div",null,"CodeMirror-cursors"),i.measure=O("div",null,"CodeMirror-measure"),i.lineMeasure=O("div",null,"CodeMirror-measure"),i.lineSpace=A("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none");var o=A("div",[i.lineSpace],"CodeMirror-lines");i.mover=O("div",[o],null,"position: relative"),i.sizer=O("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=O("div",null,null,"position: absolute; height: "+G+"px; width: 1px;"),i.gutters=O("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=O("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=O("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),l&&s<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),a||r&&m||(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,n.init(i)}(e,i,o);for(var c in u.wrapper.CodeMirror=this,si(this),dl(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),En(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&&!m&&u.input.focus(),l&&s<11&&setTimeout(function(){return n.display.input.reset(!0)},20),function(e){var t=e.display;Je(t.scroller,"mousedown",jn(e,al)),Je(t.scroller,"dblclick",l&&s<11?jn(e,function(t){if(!nt(e,t)){var r=nn(e,t);if(r&&!hl(e,t)&&!yr(e.display,t)){st(t);var n=e.findWordAt(r);Bi(e.doc,n.anchor,n.head)}}}):function(t){return nt(e,t)||st(t)});S||Je(t.scroller,"contextmenu",function(t){return fl(e,t)});var r,n={end:0};function i(){t.activeTouch&&(r=setTimeout(function(){return t.activeTouch=null},1e3),(n=t.activeTouch).end=+new Date)}function o(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}Je(t.scroller,"touchstart",function(i){if(!nt(e,i)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(i)&&!hl(e,i)){t.input.ensurePolled(),clearTimeout(r);var o=+new Date;t.activeTouch={start:o,moved:!1,prev:o-n.end<=300?n:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}}),Je(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Je(t.scroller,"touchend",function(r){var n=t.activeTouch;if(n&&!yr(t,r)&&null!=n.left&&!n.moved&&new Date-n.start<300){var l,s=e.coordsChar(t.activeTouch,"page");l=!n.prev||o(n,n.prev)?new gi(s,s):!n.prev.prev||o(n,n.prev.prev)?e.findWordAt(s):new gi(ge(s.line,0),Ce(e.doc,ge(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),st(r)}i()}),Je(t.scroller,"touchcancel",i),Je(t.scroller,"scroll",function(){t.scroller.clientHeight&&(Mn(e,t.scroller.scrollTop),On(e,t.scroller.scrollLeft,!0),rt(e,"scroll",e))}),Je(t.scroller,"mousewheel",function(t){return di(e,t)}),Je(t.scroller,"DOMMouseScroll",function(t){return di(e,t)}),Je(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(t){nt(e,t)||ct(t)},over:function(t){nt(e,t)||(!function(e,t){var r=nn(e,t);if(r){var n=document.createDocumentFragment();an(e,r,n),e.display.dragCursor||(e.display.dragCursor=O("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),N(e.display.dragCursor,n)}}(e,t),ct(t))},start:function(t){return function(e,t){if(t.preventDefault&&t.preventDefault(),l&&(!e.state.draggingText||+new Date-Lo<100))ct(t);else if(!nt(e,t)&&!yr(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!f)){var r=O("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",h&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),h&&r.parentNode.removeChild(r)}}(e,t)},drop:jn(e,ko),leave:function(t){nt(e,t)||To(e)}};var a=t.input.getField();Je(a,"keyup",function(t){return nl.call(e,t)}),Je(a,"keydown",jn(e,rl)),Je(a,"keypress",jn(e,il)),Je(a,"focus",function(t){return pn(e,t)}),Je(a,"blur",function(t){return gn(e,t)})}(this),Oo(),In(this),this.curOp.forceUpdate=!0,Mi(this,i),t.autofocus&&!m||this.hasFocus()?setTimeout(E(pn,this),20):gn(this),vl)vl.hasOwnProperty(c)&&vl[c](n,t[c],pl);wn(this),t.finishInit&&t.finishInit(this);for(var d=0;d150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?I(se(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(f1)if(Sl&&Sl.text.join("\n")==t){if(n.ranges.length%Sl.text.length==0){u=[];for(var c=0;c=0;h--){var f=n.ranges[h],d=f.from(),p=f.to();f.empty()&&(r&&r>0?d=ge(d.line,d.ch-r):e.state.overwrite&&!s?p=ge(p.line,Math.min(se(o,p.line).text.length,p.ch+q(a).length)):Sl&&Sl.lineWise&&Sl.text.join("\n")==t&&(d=p=ge(d.line,0))),l=e.curOp.updateInput;var g={from:d,to:p,text:u?u[h%u.length]:a,origin:i||(s?"paste":e.state.cutIncoming?"cut":"+input")};to(e.doc,g),or(e,"inputRead",e,g)}t&&!s&&Ml(e,t),Sn(e),e.curOp.updateInput=l,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Tl(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||Kn(t,function(){return kl(t,r,0,null,"paste")}),!0}function Ml(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=Cl(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(se(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Cl(e,i.head.line,"smart"));l&&or(e,"electricInput",e,i.head.line)}}}function Nl(e){for(var t=[],r=[],n=0;n=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=qe(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&&f>=c.begin)){var d=h?"before":"after";return new ge(r.line,f,d)}}var p=function(e,t,n){for(var o=function(e,t){return t?new ge(r.line,a(e,1),"before"):new ge(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}(e.cm,s,t,r):jo(s,t,r))){if(n||(l=t.line+r)=e.first+e.size||(t=new ge(l,t.ch,t.sticky),!(s=se(e,l))))return!1;t=Xo(i,e.cm,s,t.line,r)}else t=o;return!0}if("char"==n)a();else if("column"==n)a(!0);else if("word"==n||"group"==n)for(var u=null,c="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),f=!0;!(r<0)||a(!f);f=!1){var d=s.text.charAt(t.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){r<0&&(r=1,a(),t.sticky="after");break}if(p&&(u=p),r>0&&!a(!f))break}var g=Zi(e,t,o,l,!0);return me(o,g)&&(g.hitSide=!0),g}function Wl(e,t,r,n){var i,o,l=e.doc,s=t.left;if("page"==n){var a=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=Math.max(a-.5*Zr(e.display),3);i=(r>0?t.bottom:t.top)+r*u}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;(o=Xr(e,s,i)).outside;){if(r<0?i<=0:i>=l.height){o.hitSide=!0;break}i+=5*r}return o}var Hl=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 Fl(e,t){var r=Mr(e,t.line);if(!r||r.hidden)return null;var n=se(e.doc,t.line),i=kr(r,n,t.line),o=Ze(n,e.doc.direction),l="left";o&&(l=qe(o,t.ch)%2?"right":"left");var s=Wr(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Pl(e,t){return t&&(e.bad=!0),e}function El(e,t,r){var n;if(t==e.display.lineDiv){if(!(n=e.display.lineDiv.childNodes[r]))return Pl(e.clipPos(ge(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||o.line=t.display.viewFrom&&Fl(t,i)||{node:a[0].measure.map[2],offset:0},c=o.linen.firstLine()&&(l=ge(l.line-1,se(n.doc,l.line-1).length)),s.ch==se(n.doc,s.line).text.length&&s.linei.viewTo-1)return!1;l.line==i.viewFrom||0==(e=on(n,l.line))?(t=he(i.view[0].line),r=i.view[0].node):(t=he(i.view[e].line),r=i.view[e-1].node.nextSibling);var a,u,c=on(n,s.line);if(c==i.view.length-1?(a=i.viewTo-1,u=i.lineDiv.lastChild):(a=he(i.view[c+1].line)-1,u=i.view[c+1].node.previousSibling),!r)return!1;for(var h=n.doc.splitLines(function(e,t,r,n,i){var o="",l=!1,s=e.doc.lineSeparator();function a(){l&&(o+=s,l=!1)}function u(e){e&&(a(),o+=e)}function c(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return void u(r||t.textContent.replace(/\u200b/g,""));var o,h=t.getAttribute("cm-marker");if(h){var f=e.findMarks(ge(n,0),ge(i+1,0),(g=+h,function(e){return e.id==g}));return void(f.length&&(o=f[0].find(0))&&u(ae(e.doc,o.from,o.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var d=/^(pre|div|p)$/i.test(t.nodeName);d&&a();for(var p=0;p1&&f.length>1;)if(q(h)==q(f))h.pop(),f.pop(),a--;else{if(h[0]!=f[0])break;h.shift(),f.shift(),t++}for(var d=0,p=0,g=h[0],v=f[0],m=Math.min(g.length,v.length);dl.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 x=ge(t,d),C=ge(a,f.length?q(f).length-p:0);return h.length>1||h[0]||ve(x,C)?(lo(n.doc,h,x,C,"+input"),!0):void 0},Hl.prototype.ensurePolled=function(){this.forceCompositionEnd()},Hl.prototype.reset=function(){this.forceCompositionEnd()},Hl.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Hl.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))},Hl.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||Kn(this.cm,function(){return _n(e.cm)})},Hl.prototype.setUneditable=function(e){e.contentEditable="false"},Hl.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||jn(this.cm,kl)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Hl.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Hl.prototype.onContextMenu=function(){},Hl.prototype.resetPosition=function(){},Hl.prototype.needsContentAttribute=!0;var Il,Rl,Bl,Gl=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new R,this.hasSelection=!1,this.composing=null};Gl.prototype.init=function(e){var t=this,r=this,n=this.cm;this.createField(e);var i=this.textarea;function o(e){if(!nt(n,e)){if(n.somethingSelected())Ll({lineWise:!1,text:n.getSelections()});else{if(!n.options.lineWiseCopyCut)return;var t=Nl(n);Ll({lineWise:!0,text:t.text}),"cut"==e.type?n.setSelections(t.ranges,null,V):(r.prevInput="",i.value=t.text.join("\n"),P(i))}"cut"==e.type&&(n.state.cutIncoming=!0)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),g&&(i.style.width="0px"),Je(i,"input",function(){l&&s>=9&&t.hasSelection&&(t.hasSelection=null),r.poll()}),Je(i,"paste",function(e){nt(n,e)||Tl(e,n)||(n.state.pasteIncoming=!0,r.fastPoll())}),Je(i,"cut",o),Je(i,"copy",o),Je(e.scroller,"paste",function(t){yr(e,t)||nt(n,t)||(n.state.pasteIncoming=!0,r.focus())}),Je(e.lineSpace,"selectstart",function(t){yr(e,t)||st(t)}),Je(i,"compositionstart",function(){var e=n.getCursor("from");r.composing&&r.composing.range.clear(),r.composing={start:e,range:n.markText(e,n.getCursor("to"),{className:"CodeMirror-composing"})}}),Je(i,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},Gl.prototype.createField=function(e){this.wrapper=Al(),this.textarea=this.wrapper.firstChild},Gl.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=sn(e);if(e.options.moveInputWithCursor){var i=Vr(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},Gl.prototype.showSelection=function(e){var t=this.cm.display;N(t.cursorDiv,e.cursors),N(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Gl.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var r=t.getSelection();this.textarea.value=r,t.state.focused&&P(this.textarea),l&&s>=9&&(this.hasSelection=r)}else e||(this.prevInput=this.textarea.value="",l&&s>=9&&(this.hasSelection=null))}},Gl.prototype.getField=function(){return this.textarea},Gl.prototype.supportsTouch=function(){return!1},Gl.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!m||W()!=this.textarea))try{this.textarea.focus()}catch(e){}},Gl.prototype.blur=function(){this.textarea.blur()},Gl.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Gl.prototype.receivedFocus=function(){this.slowPoll()},Gl.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Gl.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0,t.polling.set(20,function r(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,r))})},Gl.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||wt(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(l&&s>=9&&this.hasSelection===i||y&&/[\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 a=0,u=Math.min(n.length,i.length);a1e3||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},Gl.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Gl.prototype.onKeyPress=function(){l&&s>=9&&(this.hasSelection=null),this.fastPoll()},Gl.prototype.onContextMenu=function(e){var t=this,r=t.cm,n=r.display,i=t.textarea,o=nn(r,e),u=n.scroller.scrollTop;if(o&&!h){r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(o)&&jn(r,ji)(r.doc,mi(o),V);var c=i.style.cssText,f=t.wrapper.style.cssText;t.wrapper.style.cssText="position: absolute";var d,p=t.wrapper.getBoundingClientRect();if(i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-p.top-5)+"px; left: "+(e.clientX-p.left-5)+"px;\n z-index: 1000; background: "+(l?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",a&&(d=window.scrollY),n.input.focus(),a&&window.scrollTo(null,d),n.input.reset(),r.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=!0,n.selForContextMenu=r.doc.sel,clearTimeout(n.detectingSelectAll),l&&s>=9&&v(),S){ct(e);var g=function(){tt(window,"mouseup",g),setTimeout(m,20)};Je(window,"mouseup",g)}else setTimeout(m,50)}function v(){if(null!=i.selectionStart){var e=r.somethingSelected(),o="​"+(e?i.value:"");i.value="⇚",i.value=o,t.prevInput=e?"":"​",i.selectionStart=1,i.selectionEnd=o.length,n.selForContextMenu=r.doc.sel}}function m(){if(t.contextMenuPending=!1,t.wrapper.style.cssText=f,i.style.cssText=c,l&&s<9&&n.scrollbars.setScrollTop(n.scroller.scrollTop=u),null!=i.selectionStart){(!l||l&&s<9)&&v();var e=0,o=function(){n.selForContextMenu==r.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&"​"==t.prevInput?jn(r,Ji)(r):e++<10?n.detectingSelectAll=setTimeout(o,500):(n.selForContextMenu=null,n.input.reset())};n.detectingSelectAll=setTimeout(o,200)}}},Gl.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},Gl.prototype.setUneditable=function(){},Gl.prototype.needsContentAttribute=!1,function(e){var t=e.optionHandlers;function r(r,n,i,o){e.defaults[r]=n,i&&(t[r]=o?function(e,t,r){r!=pl&&i(e,t,r)}:i)}e.defineOption=r,e.Init=pl,r("value","",function(e,t){return e.setValue(t)},!0),r("mode",null,function(e,t){e.doc.modeOption=t,Ci(e)},!0),r("indentUnit",2,Ci,!0),r("indentWithTabs",!1),r("smartIndent",!0),r("tabSize",4,function(e){Si(e),Er(e),_n(e)},!0),r("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(-1==o)break;i=o+t.length,r.push(ge(n,o))}n++});for(var i=r.length-1;i>=0;i--)lo(e.doc,t,r[i],ge(r[i].line,r[i].ch+t.length))}}),r("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!=pl&&e.refresh()}),r("specialCharPlaceholder",$t,function(e){return e.refresh()},!0),r("electricChars",!0),r("inputStyle",m?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),r("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),r("rtlMoveVisually",!w),r("wholeLineUpdateBefore",!0),r("theme","default",function(e){dl(e),ml(e)},!0),r("keyMap","default",function(e,t,r){var n=Uo(t),i=r!=pl&&Uo(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),r("extraKeys",null),r("configureMouse",null),r("lineWrapping",!1,bl,!0),r("gutters",[],function(e){ai(e.options),ml(e)},!0),r("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?en(e.display)+"px":"0",e.refresh()},!0),r("coverGutterNextToScrollbar",!1,function(e){return Hn(e)},!0),r("scrollbarStyle","native",function(e){En(e),Hn(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),r("lineNumbers",!1,function(e){ai(e.options),ml(e)},!0),r("firstLineNumber",1,ml,!0),r("lineNumberFormatter",function(e){return e},ml,!0),r("showCursorWhenSelecting",!1,ln,!0),r("resetSelectionOnContextMenu",!0),r("lineWiseCopyCut",!0),r("pasteLinesPerSelection",!0),r("readOnly",!1,function(e,t){"nocursor"==t&&(gn(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),r("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),r("dragDrop",!0,yl),r("allowDropFileTypes",null),r("cursorBlinkRate",530),r("cursorScrollMargin",0),r("cursorHeight",1,ln,!0),r("singleCursorHeightPerLine",!0,ln,!0),r("workTime",100),r("workDelay",100),r("flattenSpans",!0,Si,!0),r("addModeClass",!1,Si,!0),r("pollInterval",100),r("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),r("historyEventDelay",1250),r("viewportMargin",10,function(e){return e.refresh()},!0),r("maxHighlightLength",1e4,Si,!0),r("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),r("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),r("autofocus",null),r("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0)}(wl),Rl=(Il=wl).optionHandlers,Bl=Il.helpers={},Il.prototype={constructor:Il,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];r[e]==t&&"mode"!=e||(r[e]=t,Rl.hasOwnProperty(e)&&jn(this,Rl[e])(this,t,n),rt(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Uo(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;rn&&(Cl(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&Sn(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&&Ui(t.doc,i,new gi(l,c[i].to()),V)}}}),getTokenAt:function(e,t){return Ut(this,e,t)},getLineTokens:function(e,t){return Ut(this,ge(e),t,!0)},getTokenTypeAt:function(e){e=Ce(this.doc,e);var t,r=Et(this,se(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=se(this.doc,e)}else n=e;return Br(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-je(n):0)},defaultTextHeight:function(){return Zr(this.display)},defaultCharWidth:function(){return Qr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o,l,s,a=this.display,u=(e=Vr(this,Ce(this.doc,e))).bottom,c=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),a.sizer.appendChild(t),"over"==n)u=e.top;else if("above"==n||"near"==n){var h=Math.max(a.wrapper.clientHeight,this.doc.height),f=Math.max(a.sizer.clientWidth,a.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>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=xn(o,l)).scrollTop&&Mn(o,s.scrollTop),null!=s.scrollLeft&&On(o,s.scrollLeft))},triggerOnKeyDown:Xn(rl),triggerOnKeyPress:Xn(il),triggerOnKeyUp:nl,triggerOnMouseDown:Xn(al),execCommand:function(e){if(Yo.hasOwnProperty(e))return Yo[e].call(null,this)},triggerElectric:Xn(function(e){Ml(this,e)}),findPosH:function(e,t,r,n){var i=1;t<0&&(i=-1,t=-t);for(var o=Ce(this.doc,e),l=0;l0&&l(t.charAt(r-1));)--r;for(;n.5)&&rn(this),rt(this,"refresh",this)}),swapDoc:Xn(function(e){var t=this.doc;return t.cm=null,Mi(this,e),Er(this),this.display.input.reset(),Ln(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,or(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}},lt(Il),Il.registerHelper=function(e,t,r){Bl.hasOwnProperty(e)||(Bl[e]=Il[e]={_global:[]}),Bl[e][t]=r},Il.registerGlobalHelper=function(e,t,r,n){Il.registerHelper(e,t,n),Bl[e]._global.push({pred:r,val:n})};var Ul,Vl="iter insert remove copy getEditor constructor".split(" ");for(var Kl in So.prototype)So.prototype.hasOwnProperty(Kl)&&B(Vl,Kl)<0&&(wl.prototype[Kl]=function(e){return function(){return e.apply(this.doc,arguments)}}(So.prototype[Kl]));return lt(So),wl.inputStyles={textarea:Gl,contenteditable:Hl},wl.defineMode=function(e){wl.defaults.mode||"null"==e||(wl.defaults.mode=e),function(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),St[e]=t}.apply(this,arguments)},wl.defineMIME=function(e,t){Lt[e]=t},wl.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),wl.defineMIME("text/plain","null"),wl.defineExtension=function(e,t){wl.prototype[e]=t},wl.defineDocExtension=function(e,t){So.prototype[e]=t},wl.fromTextArea=function(e,t){if((t=t?z(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var r=W();t.autofocus=r==e||null!=e.getAttribute("autofocus")&&r==document.body}function n(){e.value=s.getValue()}var i;if(e.form&&(Je(e.form,"submit",n),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var l=o.submit=function(){n(),o.submit=i,o.submit(),o.submit=l}}catch(e){}}t.finishInit=function(t){t.save=n,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,n(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(tt(e.form,"submit",n),"function"==typeof e.form.submit&&(e.form.submit=i))}},e.style.display="none";var s=wl(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return s},(Ul=wl).off=tt,Ul.on=Je,Ul.wheelEventPixels=fi,Ul.Doc=So,Ul.splitLines=bt,Ul.countColumn=I,Ul.findColumn=X,Ul.isWordChar=ee,Ul.Pass=U,Ul.signal=rt,Ul.Line=jt,Ul.changeEnd=yi,Ul.scrollbarModel=Pn,Ul.Pos=ge,Ul.cmpPos=ve,Ul.modes=St,Ul.mimeModes=Lt,Ul.resolveMode=kt,Ul.getMode=Tt,Ul.modeExtensions=Mt,Ul.extendMode=Nt,Ul.copyState=Ot,Ul.startState=Dt,Ul.innerMode=At,Ul.commands=Yo,Ul.keyMap=Po,Ul.keyName=Go,Ul.isModifierKey=Ro,Ul.lookupKey=Io,Ul.normalizeKeyMap=zo,Ul.StringStream=Wt,Ul.SharedTextMarker=bo,Ul.TextMarker=mo,Ul.LineWidget=po,Ul.e_preventDefault=st,Ul.e_stopPropagation=at,Ul.e_stop=ct,Ul.addClass=H,Ul.contains=D,Ul.rmClass=T,Ul.keyNames=Do,wl.version="5.37.1",wl}); +!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,r=/gecko\/\d/i.test(e),n=/MSIE \d/.test(e),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),o=/Edge\/(\d+)/.exec(e),l=n||i||o,s=l&&(n?document.documentMode||6:+(o||i)[1]),a=!o&&/WebKit\//.test(e),u=a&&/Qt\/\d+\.\d+/.test(e),c=!o&&/Chrome\//.test(e),h=/Opera\//.test(e),f=/Apple Computer/.test(navigator.vendor),d=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),p=/PhantomJS/.test(e),g=!o&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e),v=/Android/.test(e),m=g||v||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=g||/Mac/.test(t),b=/\bCrOS\b/.test(e),w=/win/i.test(t),x=h&&e.match(/Version\/(\d*\.\d*)/);x&&(x=Number(x[1])),x&&x>=15&&(h=!1,a=!0);var C=y&&(u||h&&(null==x||x<12.11)),S=r||l&&s>=9;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var k,T=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 M(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function N(e,t){return M(e).appendChild(t)}function O(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}}g?P=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:l&&(P=function(e){try{e.select()}catch(e){}});var R=function(){this.id=null};function B(e,t){for(var r=0;r=t)return n+Math.min(l,t-i);if(i+=o-n,n=o+1,(i+=r-i%r)>=t)return n}}var Y=[""];function _(e){for(;Y.length<=e;)Y.push(q(Y)+" ");return Y[e]}function q(e){return e[e.length-1]}function $(e,t){for(var r=[],n=0;n"€"&&(e.toUpperCase()!=e.toLowerCase()||J.test(e))}function te(e,t){return t?!!(t.source.indexOf("\\w")>-1&&ee(e))||t.test(e):ee(e)}function re(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ne=/[\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 ie(e){return e.charCodeAt(0)>=768&&ne.test(e)}function oe(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 se(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&&to?ge(o,se(e,o).text.length):(r=t,n=se(e,t.line).text.length,null==(i=r.ch)||i>n?ge(r.line,n):i<0?ge(r.line,0):r)}function Se(e,t){for(var r=[],n=0;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.from0&&s)for(var b=0;b=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ve(u.to,r)>=0:ve(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ve(u.from,n)<=0:ve(u.from,n)<0)))return!0}}}function Be(e){for(var t;t=ze(e);)e=t.find(-1,!0).line;return e}function Ge(e,t){var r=se(e,t),n=Be(r);return r==n?t:he(n)}function Ue(e,t){if(t>e.lastLine())return t;var r,n=se(e,t);if(!Ve(e,n))return t;for(;r=Ie(n);)n=r.find(1,!0).line;return he(n)+1}function Ve(e,t){var r=ke&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}var _e=null;function qe(e,t,r){var n;_e=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:_e=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:_e=i)}return null!=n?n:_e}var $e=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,n=/[stwN]/,i=/[LRr]/,o=/[Lb1n]/,l=/[1n]/;function s(e,t,r){this.level=e,this.from=t,this.to=r}return function(a,u){var c="ltr"==u?"L":"R";if(0==a.length||"ltr"==u&&!r.test(a))return!1;for(var h,f=a.length,d=[],p=0;p-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function rt(e,t){var r=et(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function lt(e){e.prototype.on=function(e,t){Je(this,e,t)},e.prototype.off=function(e,t){tt(this,e,t)}}function st(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function at(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function ut(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function ct(e){st(e),at(e)}function ht(e){return e.target||e.srcElement}function ft(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),y&&e.ctrlKey&&1==t&&(t=3),t}var dt,pt,gt=function(){if(l&&s<9)return!1;var e=O("div");return"draggable"in e||"dragDrop"in e}();function vt(e){if(null==dt){var t=O("span","​");N(e,O("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(dt=t.offsetWidth<=1&&t.offsetHeight>2&&!(l&&s<8))}var r=dt?O("span","​"):O("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function mt(e){if(null!=pt)return pt;var t=N(e,document.createTextNode("AخA")),r=k(t,0,1).getBoundingClientRect(),n=k(t,1,2).getBoundingClientRect();return M(e),!(!r||r.left==r.right)&&(pt=n.right-r.right<3)}var yt,bt=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),l=o.indexOf("\r");-1!=l?(r.push(o.slice(0,l)),t+=l+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},wt=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)},xt="oncopy"in(yt=O("div"))||(yt.setAttribute("oncopy","return;"),"function"==typeof yt.oncopy),Ct=null;var St={},Lt={};function kt(e){if("string"==typeof e&&Lt.hasOwnProperty(e))e=Lt[e];else if(e&&"string"==typeof e.name&&Lt.hasOwnProperty(e.name)){var t=Lt[e.name];"string"==typeof t&&(t={name:t}),(e=Q(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return kt("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return kt("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Tt(e,t){t=kt(t);var r=St[t.name];if(!r)return Tt(e,"text/plain");var n=r(e,t);if(Mt.hasOwnProperty(t.name)){var i=Mt[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}var Mt={};function Nt(e,t){z(t,Mt.hasOwnProperty(e)?Mt[e]:Mt[e]={})}function Ot(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 At(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 Dt(e,t,r){return!e.startState||e.startState(t,r)}var Wt=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};Wt.prototype.eol=function(){return this.pos>=this.string.length},Wt.prototype.sol=function(){return this.pos==this.lineStart},Wt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Wt.prototype.next=function(){if(this.post},Wt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Wt.prototype.skipToEnd=function(){this.pos=this.string.length},Wt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Wt.prototype.backUp=function(e){this.pos-=e},Wt.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},Wt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Wt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Wt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Wt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var Ht=function(e,t){this.state=e,this.lookAhead=t},Ft=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 Pt(e,t,r,n){var i=[e.state.modeGen],o={};Kt(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var l=r.state,s=function(n){r.baseTokens=i;var s=e.state.overlays[n],a=1,u=0;r.state=!0,Kt(e,t.text,s.mode,r,function(e,t){for(var r=a;ue&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"overlay "+t),a=r+2;else for(;re.options.maxHighlightLength&&Ot(e.doc.mode,n.state),o=Pt(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 zt(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return new Ft(n,!0,t);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;s>l;--s){if(s<=o.first)return o.first;var a=se(o,s-1),u=a.stateAfter;if(u&&(!r||s+(u instanceof Ht?u.lookAhead:0)<=o.modeFrontier))return s;var c=I(a.text,null,e.options.tabSize);(null==i||n>c)&&(i=s-1,n=c)}return i}(e,t,r),l=o>n.first&&se(n,o-1).stateAfter,s=l?Ft.fromSaved(n,l,o):new Ft(n,Dt(n.mode),o);return n.iter(o,t,function(r){It(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.")}Ft.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Ft.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}},Ft.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Ft.fromSaved=function(e,t,r){return t instanceof Ht?new Ft(e,Ot(e.mode,t.state),r,t.lookAhead):new Ft(e,Ot(e.mode,t),r)},Ft.prototype.save=function(e){var t=!1!==e?Ot(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Ht(t,this.maxLookAhead):t};var Gt=function(e,t,r){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=r};function Ut(e,t,r,n){var i,o,l=e.doc,s=l.mode,a=se(l,(t=Ce(l,t)).line),u=zt(e,t.line,r),c=new Wt(a.text,e.options.tabSize,u);for(n&&(o=[]);(n||c.pose.options.maxHighlightLength?(s=!1,l&&It(e,t,n,h.pos),h.pos=t.length,a=null):a=Vt(Bt(r,h,n.state,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u1&&!/ /.test(e))return e;for(var r=t,n="",i=0;iu&&h.from<=u);f++);if(h.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,h.to-u),i,o,null,s,a),o=null,n=n.slice(h.to-u),u=h.to}}}function Jt(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 er(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,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&&!h&&(h=C.title),C.collapsed&&(!f||Pe(f.marker,C)<0)&&(f=x)):x.from>p&&m>x.from&&(m=x.from)}if(b)for(var S=0;S=d)break;for(var k=Math.min(d,m);;){if(v){var T=p+v.length;if(!f){var M=T>k?v.slice(0,k-p):v;t.addToken(t,M,l?l+a:a,c,p+M.length==m?u:"",h,s)}if(T>=k){v=v.slice(k-p),p=k;break}p=T,c=""}v=i.slice(o,o=r[g++]),l=_t(r[g++],t.cm.options)}}else for(var N=1;Nr)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Tr(e,t,r,n){return Or(e,Nr(e,t),r,n)}function Mr(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&t2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}(e,t.view,t.rect),t.hasHeights=!0),(o=function(e,t,r,n){var i,o=Wr(t.map,r,n),a=o.node,u=o.start,c=o.end,h=o.collapse;if(3==a.nodeType){for(var f=0;f<4;f++){for(;u&&ie(t.line.text.charAt(o.coverStart+u));)--u;for(;o.coverStart+c1}(e))return t;var r=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*r,right:t.right*r,top:t.top*n,bottom:t.bottom*n}}(e.display.measure,i))}else{var d;u>0&&(h=n="right"),i=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==n?d.length-1:0]:a.getBoundingClientRect()}if(l&&s<9&&!u&&(!i||!i.left&&!i.right)){var p=a.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+Qr(e.display),top:p.top,bottom:p.bottom}:Dr}for(var g=i.top-t.rect.top,v=i.bottom-t.rect.top,m=(g+v)/2,y=t.view.measure.heights,b=0;bt)&&(i=(o=a-s)-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[2+(u-=3)],l="left";if("right"==r&&i==a-s)for(;u=0&&(r=e[i]).left==r.right;i--);return r}function Fr(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=n.text.length?(a=n.text.length,u="before"):a<=0&&(a=0,u="after"),!s)return l("before"==u?a-1:a,"before"==u);function c(e,t,r){return l(r?e-1:e,1==s[t].level!=r)}var h=qe(s,a,u),f=_e,d=c(a,h,"before"==u);return null!=f&&(d.other=c(a,f,"before"!=u)),d}function Kr(e,t){var r=0;t=Ce(e.doc,t),e.options.lineWrapping||(r=Qr(e.display)*t.ch);var n=se(e.doc,t.line),i=je(n)+br(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function jr(e,t,r,n,i){var o=ge(e,t,r);return o.xRel=i,n&&(o.outside=!0),o}function Xr(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return jr(n.first,0,null,!0,-1);var i=fe(n,r),o=n.first+n.size-1;if(i>o)return jr(n.first+n.size-1,se(n,o).text.length,null,!0,1);t<0&&(t=0);for(var l=se(n,i);;){var s=$r(e,l,i,t,r),a=Ie(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=he(l=u.to.line)}}function Yr(e,t,r,n){n-=Rr(t);var i=t.text.length,o=le(function(t){return Or(e,r,t-1).bottom<=n},i,0);return{begin:o,end:i=le(function(t){return Or(e,r,t).top>n},o,i)}}function _r(e,t,r,n){return r||(r=Nr(e,t)),Yr(e,t,r,Br(e,t,Or(e,r,n),"line").top)}function qr(e,t,r,n){return!(e.bottom<=r)&&(e.top>r||(n?e.left:e.right)>t)}function $r(e,t,r,n,i){i-=je(t);var o=Nr(e,t),l=Rr(t),s=0,a=t.text.length,u=!0,c=Ze(t,e.doc.direction);if(c){var h=(e.options.lineWrapping?function(e,t,r,n,i,o,l){var s=Yr(e,t,n,l),a=s.begin,u=s.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var c=null,h=null,f=0;f=u||d.to<=a)){var p=1!=d.level,g=Or(e,n,p?Math.min(u,d.to)-1:Math.max(a,d.from)).right,v=gv)&&(c=d,h=v)}}c||(c=i[i.length-1]);c.fromu&&(c={from:c.from,to:u,level:c.level});return c}:function(e,t,r,n,i,o,l){var s=le(function(s){var a=i[s],u=1!=a.level;return qr(Vr(e,ge(r,u?a.to:a.from,u?"before":"after"),"line",t,n),o,l,!0)},0,i.length-1),a=i[s];if(s>0){var u=1!=a.level,c=Vr(e,ge(r,u?a.from:a.to,u?"after":"before"),"line",t,n);qr(c,o,l,!0)&&c.top>l&&(a=i[s-1])}return a})(e,t,r,o,c,n,i);s=(u=1!=h.level)?h.from:h.to-1,a=u?h.to:h.from-1}var f,d,p=null,g=null,v=le(function(t){var r=Or(e,o,t);return r.top+=l,r.bottom+=l,!!qr(r,n,i,!1)&&(r.top<=i&&r.left<=n&&(p=t,g=r),!0)},s,a),m=!1;if(g){var y=n-g.left=w.bottom}return jr(r,v=oe(t.text,v,1),d,m,n-f)}function Zr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Ar){Ar=O("pre");for(var t=0;t<49;++t)Ar.appendChild(document.createTextNode("x")),Ar.appendChild(O("br"));Ar.appendChild(document.createTextNode("x"))}N(e.measure,Ar);var r=Ar.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),M(e.measure),r||1}function Qr(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=O("span","xxxxxxxxxx"),r=O("pre",[t]);N(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function Jr(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:en(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function en(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function tn(e){var t=Zr(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/Qr(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)<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",o),i=!0)}i||n(t,r,"ltr")}(g,r||0,null==n?f:n,function(e,t,i,h){var v="ltr"==i,m=d(e,v?"left":"right"),y=d(t-1,v?"right":"left"),b=null==r&&0==e,w=null==n&&t==f,x=0==h,C=!g||h==g.length-1;if(y.top-m.top<=3){var S=(u?w:b)&&C,L=(u?b:w)&&x?s:(v?m:y).left,k=S?a:(v?y:m).right;c(L,m.top,k-L,m.bottom)}else{var T,M,N,O;v?(T=u&&b&&x?s:m.left,M=u?a:p(e,i,"before"),N=u?s:p(t,i,"after"),O=u&&w&&C?a:y.right):(T=u?p(e,i,"before"):s,M=!u&&b&&x?a:m.right,N=!u&&w&&C?s:y.left,O=u?p(t,i,"after"):a),c(T,m.top,M-T,m.bottom),m.bottom0?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 fn(e){e.state.focused||(e.display.input.focus(),pn(e))}function dn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,gn(e))},100)}function pn(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(rt(e,"focus",e,t),e.state.focused=!0,H(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),a&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),hn(e))}function gn(e,t){e.state.delayingBlurEvent||(e.state.focused&&(rt(e,"blur",e,t),e.state.focused=!1,T(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function vn(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n.005||c<-.005)&&(ce(i.line,o),mn(i.line),i.rest))for(var h=0;h=l&&(o=fe(t,je(se(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function bn(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=en(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+wr(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=Sr(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 Cn(e,t){null!=t&&(kn(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Sn(e){kn(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Ln(e,t,r){null==t&&null==r||kn(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function kn(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Tn(e,Kr(e,t.from),Kr(e,t.to),t.margin))}function Tn(e,t,r,n){var i=xn(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});Ln(e,i.scrollLeft,i.scrollTop)}function Mn(e,t){Math.abs(e.doc.scrollTop-t)<2||(r||ii(e,{top:t}),Nn(e,t,!0),r&&ii(e),Jn(e,100))}function Nn(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 On(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,bn(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function An(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+wr(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+Cr(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),Je(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Je(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,l&&s<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&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},Dn.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Dn.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Dn.prototype.zeroWidthHack=function(){var e=y&&!d?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new R,this.disableVert=new R},Dn.prototype.enableZeroWidthBar=function(e,t,r){e.style.pointerEvents="auto",t.set(1e3,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.pointerEvents="none":t.set(1e3,n)})},Dn.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Wn=function(){};function Hn(e,t){t||(t=An(e));var r=e.display.barWidth,n=e.display.barHeight;Fn(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&vn(e),Fn(e,An(e)),r=e.display.barWidth,n=e.display.barHeight}function Fn(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=""}Wn.prototype.update=function(){return{bottom:0,right:0}},Wn.prototype.setScrollLeft=function(){},Wn.prototype.setScrollTop=function(){},Wn.prototype.clear=function(){};var Pn={native:Dn,null:Wn};function En(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&T(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Pn[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Je(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?On(e,t):Mn(e,t)},e),e.display.scrollbars.addClass&&H(e.display.wrapper,e.display.scrollbars.addClass)}var zn=0;function In(e){var t;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:++zn},t=e.curOp,nr?nr.ops.push(t):t.ownsGroup=nr={ops:[t],delayedCallbacks:[]}}function Rn(e){!function(e,t){var r=e.ownsGroup;if(r)try{!function(e){var t=e.delayedCallbacks,r=0;do{for(;r=i.viewTo)||i.maxLineChanged&&n.options.lineWrapping,e.update=e.mustUpdate&&new ti(n,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Gn(e){var t=e.cm,r=t.display;e.updatedDisplay&&vn(t),e.barMeasure=An(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Tr(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+Cr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Sr(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Un(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&&!p){var o=O("div","​",null,"position: absolute;\n top: "+(t.top-r.viewOffset-br(e.display))+"px;\n height: "+(t.bottom-t.top+Cr(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?ge(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?ge(t.line,t.ch+1,"before"):t);for(var o=0;o<5;o++){var l=!1,s=Vr(e,t),a=r&&r!=t?Vr(e,r):s,u=xn(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&&(Mn(e,u.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(l=!0)),null!=u.scrollLeft&&(On(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-h)>1&&(l=!0)),!l)break}return i}(t,Ce(n,e.scrollToPos.from),Ce(n,e.scrollToPos.to),e.scrollToPos.margin));var i=e.maybeHiddenMarkers,o=e.maybeUnhiddenMarkers;if(i)for(var l=0;lt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)ke&&Ge(e.doc,t)i.viewFrom?$n(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)$n(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):$n(e)}else if(r>=i.viewTo){var l=Zn(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):$n(e)}else{var s=Zn(e,t,t,-1),a=Zn(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(rr(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):$n(e)}var u=i.externalMeasured;u&&(r=i.lineN&&t=n.viewTo)){var o=n.view[on(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==B(l,r)&&l.push(r)}}}function $n(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=on(e,t),l=e.display.view;if(!ke||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(;Ge(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 Qn(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo)){var r=+new Date+e.options.workTime,n=zt(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 l=o.styles,s=o.text.length>e.options.maxHighlightLength?Ot(t.mode,n.state):null,a=Pt(e,o,n,!0);s&&(n.state=s),o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),f=0;!h&&fr)return Jn(e,e.options.workDelay),!0}),t.highlightFrontier=n.line,t.modeFrontier=Math.max(t.modeFrontier,n.line),i.length&&Kn(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==Qn(e))return!1;wn(e)&&($n(e),t.dims=Jr(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)),ke&&(o=Ge(e.doc,o),l=Ue(e.doc,l));var s,u,c,h,f=o!=r.viewFrom||l!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;u=o,c=l,0==(h=(s=e).display).view.length||u>=h.viewTo||c<=h.viewFrom?(h.view=rr(s,u,c),h.viewFrom=u):(h.viewFrom>u?h.view=rr(s,u,h.viewFrom).concat(h.view):h.viewFromc&&(h.view=h.view.slice(0,on(s,c)))),h.viewTo=c,r.viewOffset=je(se(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var d=Qn(e);if(!f&&0==d&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var p=function(e){if(e.hasFocus())return null;var t=W();if(!t||!D(e.display.lineDiv,t))return null;var r={activeElt:t};if(window.getSelection){var n=window.getSelection();n.anchorNode&&n.extend&&D(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 d>4&&(r.lineDiv.style.display="none"),function(e,t,r){var n=e.display,i=e.options.lineNumbers,o=n.lineDiv,l=o.firstChild;function s(t){var r=t.nextSibling;return a&&y&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var u=n.view,c=n.viewFrom,h=0;h-1&&(d=!1),sr(e,f,c,r)),d&&(M(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(pe(e.options,c)))),l=f.node.nextSibling}else{var p=(m=c,b=r,void 0,w=ur(g=e,v=f),v.text=v.node=w.pre,w.bgClass&&(v.bgClass=w.bgClass),w.textClass&&(v.textClass=w.textClass),hr(g,v),fr(g,v,m,b),pr(g,v,b),v.node);o.insertBefore(p,l)}c+=f.size}var g,v,m,b,w;for(;l;)l=s(l)}(e,r.updateLineNumbers,t.dims),d>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,function(e){if(e&&e.activeElt&&e.activeElt!=W()&&(e.activeElt.focus(),e.anchorNode&&D(document.body,e.anchorNode)&&D(document.body,e.focusNode))){var t=window.getSelection(),r=document.createRange();r.setEnd(e.anchorNode,e.anchorOffset),r.collapse(!1),t.removeAllRanges(),t.addRange(r),t.extend(e.focusNode,e.focusOffset)}}(p),M(r.cursorDiv),M(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,f&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Jn(e,400)),r.updateLineNumbers=null,!0}function ni(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Sr(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+wr(e.display)-Lr(e),r.top)}),t.visible=yn(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&ri(e,t);n=!1){vn(e);var i=An(e);ln(e),Hn(e,i),li(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 ii(e,t){var r=new ti(e,t);if(ri(e,r)){vn(e),ni(e,r);var n=An(e);ln(e),Hn(e,n),li(e,n),r.finish()}}function oi(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function li(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+Cr(e)+"px"}function si(e){var t=e.display.gutters,r=e.options.gutters;M(t);for(var n=0;n-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}ti.prototype.signal=function(e,t){ot(e,t)&&this.events.push(arguments)},ti.prototype.finish=function(){for(var e=0;es.clientWidth,c=s.scrollHeight>s.clientHeight;if(i&&u||o&&c){if(o&&y&&a)e:for(var f=t.target,d=l.view;f!=s;f=f.parentNode)for(var p=0;p=0&&ve(e,n.to())<=0)return r}return-1};var gi=function(e,t){this.anchor=e,this.head=t};function vi(e,t){var r=e[t];e.sort(function(e,t){return ve(e.from(),t.from())}),t=B(e,r);for(var n=1;n=0){var l=we(o.from(),i.from()),s=be(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;n<=t&&--t,e.splice(--n,2,new gi(a?s:l,a?l:s))}}return new pi(e,t)}function mi(e,t){return new pi([new gi(e,t||e)],0)}function yi(e){return e.text?ge(e.from.line+e.text.length-1,q(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function bi(e,t){if(ve(e,t.from)<0)return e;if(ve(e,t.to)<=0)return yi(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+=yi(t).ch-t.to.ch),ge(r,n)}function wi(e,t){for(var r=[],n=0;n1&&e.remove(s.line+1,p-1),e.insert(s.line+1,m)}or(e,"change",e,t)}function Ti(e,t,r){!function e(n,i,o){if(n.linked)for(var l=0;la-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(s=i,o=i.lastOp==n?(Di(s.done),q(s.done)):s.done.length&&!q(s.done).ranges?q(s.done):s.done.length>1&&!s.done[s.done.length-2].ranges?(s.done.pop(),q(s.done)):void 0))l=q(o.changes),0==ve(t.from,t.to)&&0==ve(t.from,l.to)?l.to=yi(t):o.changes.push(Ai(e,t));else{var u=q(i.done);for(u&&u.ranges||Fi(e.sel,i.done),o={changes:[Ai(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=a,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||rt(e,"historyAdded")}function Hi(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:Fi(t,u.done),u.lastSelTime=+new Date,u.lastSelOrigin=c,u.lastSelOp=r,n&&!1!==n.clearRedo&&Di(u.undone)}function Fi(e,t){var r=q(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Pi(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 Ei(e){if(!e)return null;for(var t,r=0;r-1&&(q(s)[h]=u[h],delete u[h])}}}return n}function Ri(e,t,r,n){if(n){var i=e.anchor;if(r){var o=ve(t,i)<0;o!=ve(r,i)<0?(i=t,t=r):o!=ve(t,r)<0&&(t=r)}return new gi(i,t)}return new gi(r||t,t)}function Bi(e,t,r,n,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),ji(e,new pi([Ri(e.sel.primary(),t,r,i)],0),n)}function Gi(e,t,r){for(var n=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:s.to>t.ch))){if(i&&(rt(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=Qi(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=ve(u,r))&&(n<0?c<0:c>0))return $i(e,u,t,n,i)}var h=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(h=Qi(e,h,n,h.line==t.line?o:null)),h?$i(e,h,t,n,i):null}}return t}function Zi(e,t,r,n,i){var o=n||1,l=$i(e,t,r,o,i)||!i&&$i(e,t,r,o,!0)||$i(e,t,r,-o,i)||!i&&$i(e,t,r,-o,!0);return l||(e.cantEdit=!0,ge(e.first,0))}function Qi(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?Ce(e,ge(t.line-1)):null:r>0&&t.ch==(n||se(e,t.line)).text.length?t.line0)){var c=[a,1],h=ve(u.from,s.from),f=ve(u.to,s.to);(h<0||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(f>0||!l.inclusiveRight&&!f)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-3}}return i}(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)ro(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text,origin:t.origin});else ro(e,t)}}function ro(e,t){if(1!=t.text.length||""!=t.text[0]||0!=ve(t.from,t.to)){var r=wi(e,t);Wi(e,t,r,e.cm?e.cm.curOp.id:NaN),oo(e,t,r,Oe(e,t));var n=[];Ti(e,function(e,r){r||-1!=B(n,e.history)||(uo(e.history,t),n.push(e.history)),oo(e,t,null,Oe(e,t))})}}function no(e,t,r){var n=e.cm&&e.cm.state.suppressEdits;if(!n||r){for(var i,o=e.history,l=e.sel,s="undo"==t?o.done:o.undone,a="undo"==t?o.undone:o.done,u=0;u=0;--d){var p=f(d);if(p)return p.v}}}}function io(e,t){if(0!=t&&(e.first+=t,e.sel=new pi($(e.sel.ranges,function(e){return new gi(ge(e.anchor.line+t,e.anchor.ch),ge(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){_n(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:ge(o,se(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=ae(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=he(Be(se(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&&it(e);ki(n,t,r,tn(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=Xe(e);t>i.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.highlightFrontierr;n--){var i=se(e,n).stateAfter;if(i&&(!(i instanceof Ht)||n+i.lookAhead1||!(this.children[0]instanceof ho))){var s=[];this.collapse(s),this.children=[new ho(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var l=i.lines.length%25+25,s=l;s10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n0||0==l&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=A("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Re(e,t.line,t,r,o)||t.line!=r.line&&Re(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");ke=!0}o.addToHistory&&Wi(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,a=t.line,u=e.cm;if(e.iter(a,r.line+1,function(e){var n,i;u&&o.collapsed&&!u.options.lineWrapping&&Be(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&ce(e,0),n=e,i=new Te(o,a==t.line?t.ch:null,a==r.line?r.ch:null),n.markedSpans=n.markedSpans?n.markedSpans.concat([i]):[i],i.marker.attachLine(n),++a}),o.collapsed&&e.iter(t.line,r.line+1,function(t){Ve(e,t)&&ce(t,0)}),o.clearOnEnter&&Je(o,"beforeCursorEnter",function(){return o.clear()}),o.readOnly&&(Le=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++vo,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)_n(u,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=r.line;c++)qn(u,c,"text");o.atomic&&_i(u.doc),or(u,"markerAdded",u,o)}return o}mo.prototype.clear=function(){var e=this;if(!this.explicitlyCleared){var t=this.doc.cm,r=t&&!t.curOp;if(r&&In(t),ot(this,"clear")){var n=this.find();n&&or(this,"clear",n.from,n.to)}for(var i=null,o=null,l=0;lt.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=h,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&_n(t,i,o+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&_i(t.doc)),t&&or(t,"markerCleared",t,this,i,o),r&&Rn(t),this.parent&&this.parent.clear()}},mo.prototype.find=function(e,t){var r,n;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=0;a--)to(this,n[a]);s?Ki(this,s):this.cm&&Sn(this.cm)}),undo:Yn(function(){no(this,"undo")}),redo:Yn(function(){no(this,"redo")}),undoSelection:Yn(function(){no(this,"undo",!0)}),redoSelection:Yn(function(){no(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=Ce(this,e),t=Ce(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)return t=e,!0;e-=o,++r}),Ce(this,ge(r,t))},indexFromPos:function(e){var t=(e=Ce(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var c=e.dataTransfer.getData("Text");if(c){var h;if(t.state.draggingText&&!t.state.draggingText.copy&&(h=t.listSelections()),Xi(t.doc,mi(r,r)),h)for(var f=0;f=0;t--)lo(e.doc,"",n[t].from,n[t].to,"+delete");Sn(e)})}function Ko(e,t,r){var n=oe(e.text,t+r,r);return n<0||n>e.text.length?null:n}function jo(e,t,r){var n=Ko(e,t.ch,r);return null==n?null:new ge(t.line,n,r<0?"after":"before")}function Xo(e,t,r,n,i){if(e){var o=Ze(r,t.doc.direction);if(o){var l,s=i<0?q(o):o[0],a=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var u=Nr(t,r);l=i<0?r.text.length-1:0;var c=Or(t,u,l).top;l=le(function(e){return Or(t,u,e).top==c},i<0==(1==s.level)?s.from:s.to-1,l),"before"==a&&(l=Ko(r,l,1))}else l=i<0?s.to:s.from;return new ge(n,l,a)}}return new ge(n,i<0?r.text.length:0,i<0?"before":"after")}Po.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Po.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Po.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Po.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Po.default=y?Po.macDefault:Po.pcDefault;var Yo={selectAll:Ji,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),V)},killLine:function(e){return Vo(e,function(t){if(t.empty()){var r=se(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line0)i=new ge(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),ge(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=se(e.doc,i.line-1).text;l&&(i=new ge(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),ge(i.line-1,l.length-1),i,"+transpose"))}r.push(new gi(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return Kn(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;n-1&&(ve((i=u.ranges[i]).from(),t)<0||t.xRel>0)&&(ve(i.to(),t)>0||t.xRel<0)?function(e,t,r,n){var i=e.display,o=!1,u=jn(e,function(t){a&&(i.scroller.draggable=!1),e.state.draggingText=!1,tt(i.wrapper.ownerDocument,"mouseup",u),tt(i.wrapper.ownerDocument,"mousemove",c),tt(i.scroller,"dragstart",h),tt(i.scroller,"drop",u),o||(st(t),n.addNew||Bi(e.doc,r,null,null,n.extend),a||l&&9==s?setTimeout(function(){i.wrapper.ownerDocument.body.focus(),i.input.focus()},20):i.input.focus())}),c=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},h=function(){return o=!0};a&&(i.scroller.draggable=!0);e.state.draggingText=u,u.copy=!n.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop();Je(i.wrapper.ownerDocument,"mouseup",u),Je(i.wrapper.ownerDocument,"mousemove",c),Je(i.scroller,"dragstart",h),Je(i.scroller,"drop",u),dn(e),setTimeout(function(){return i.input.focus()},20)}(e,n,t,o):function(e,t,r,n){var i=e.display,o=e.doc;st(t);var l,s,a=o.sel,u=a.ranges;n.addNew&&!n.extend?(s=o.sel.contains(r),l=s>-1?u[s]:new gi(r,r)):(l=o.sel.primary(),s=o.sel.primIndex);if("rectangle"==n.unit)n.addNew||(l=new gi(r,r)),r=nn(e,t,!0,!0),s=-1;else{var c=ul(e,r,n.unit);l=n.extend?Ri(l,c.anchor,c.head,n.extend):c}n.addNew?-1==s?(s=u.length,ji(o,vi(u.concat([l]),s),{scroll:!1,origin:"*mouse"})):u.length>1&&u[s].empty()&&"char"==n.unit&&!n.extend?(ji(o,vi(u.slice(0,s).concat(u.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),a=o.sel):Ui(o,s,l,K):(s=0,ji(o,new pi([l],0),K),a=o.sel);var h=r;function f(t){if(0!=ve(h,t))if(h=t,"rectangle"==n.unit){for(var i=[],u=e.options.tabSize,c=I(se(o,r.line).text,r.ch,u),f=I(se(o,t.line).text,t.ch,u),d=Math.min(c,f),p=Math.max(c,f),g=Math.min(r.line,t.line),v=Math.min(e.lastLine(),Math.max(r.line,t.line));g<=v;g++){var m=se(o,g).text,y=X(m,d,u);d==p?i.push(new gi(ge(g,y),ge(g,y))):m.length>y&&i.push(new gi(ge(g,y),ge(g,X(m,p,u))))}i.length||i.push(new gi(r,r)),ji(o,vi(a.ranges.slice(0,s).concat(i),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,w=l,x=ul(e,t,n.unit),C=w.anchor;ve(x.anchor,C)>0?(b=x.head,C=we(w.from(),x.anchor)):(b=x.anchor,C=be(w.to(),x.head));var S=a.ranges.slice(0);S[s]=function(e,t){var r=t.anchor,n=t.head,i=se(e.doc,r.line);if(0==ve(r,n)&&r.sticky==n.sticky)return t;var o=Ze(i);if(!o)return t;var l=qe(o,r.ch,r.sticky),s=o[l];if(s.from!=r.ch&&s.to!=r.ch)return t;var a,u=l+(s.from==r.ch==(1!=s.level)?0:1);if(0==u||u==o.length)return t;if(n.line!=r.line)a=(n.line-r.line)*("ltr"==e.doc.direction?1:-1)>0;else{var c=qe(o,n.ch,n.sticky),h=c-l||(n.ch-r.ch)*(1==s.level?-1:1);a=c==u-1||c==u?h<0:h>0}var f=o[u+(a?-1:0)],d=a==(1==f.level),p=d?f.from:f.to,g=d?"after":"before";return r.ch==p&&r.sticky==g?t:new gi(new ge(r.line,p,g),n)}(e,new gi(Ce(o,C),b)),ji(o,vi(S,s),K)}}var d=i.wrapper.getBoundingClientRect(),p=0;function g(t){e.state.selectingText=!1,p=1/0,st(t),i.input.focus(),tt(i.wrapper.ownerDocument,"mousemove",v),tt(i.wrapper.ownerDocument,"mouseup",m),o.history.lastSelOrigin=null}var v=jn(e,function(t){ft(t)?function t(r){var l=++p;var s=nn(e,r,!0,"rectangle"==n.unit);if(!s)return;if(0!=ve(s,h)){e.curOp.focus=W(),f(s);var a=yn(i,o);(s.line>=a.to||s.lined.bottom?20:0;u&&setTimeout(jn(e,function(){p==l&&(i.scroller.scrollTop+=u,t(r))}),50)}}(t):g(t)}),m=jn(e,g);e.state.selectingText=m,Je(i.wrapper.ownerDocument,"mousemove",v),Je(i.wrapper.ownerDocument,"mouseup",m)}(e,n,t,o)}(t,u,h,e):ht(e)==r.scroller&&st(e):2==c?(u&&Bi(t.doc,u),setTimeout(function(){return r.input.focus()},20)):3==c&&(S?fl(t,e):dn(t)))}}function ul(e,t,r){if("char"==r)return new gi(t,t);if("word"==r)return e.findWordAt(t);if("line"==r)return new gi(ge(t.line,0),Ce(e.doc,ge(t.line+1,0)));var n=r(e,t);return new gi(n.from,n.to)}function cl(e,t,r,n){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&st(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!ot(e,r))return ut(t);o-=s.top-l.viewOffset;for(var a=0;a=i)return rt(e,r,e,fe(e.doc,o),e.options.gutters[a],t),ut(t)}}function hl(e,t){return cl(e,t,"gutterClick",!0)}function fl(e,t){yr(e.display,t)||function(e,t){if(!ot(e,"gutterContextMenu"))return!1;return cl(e,t,"gutterContextMenu",!1)}(e,t)||nt(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function dl(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Er(e)}sl.prototype.compare=function(e,t,r){return this.time+400>e&&0==ve(t,this.pos)&&r==this.button};var pl={toString:function(){return"CodeMirror.Init"}},gl={},vl={};function ml(e){si(e),_n(e),bn(e)}function yl(e,t,r){if(!t!=!(r&&r!=pl)){var n=e.display.dragFunctions,i=t?Je:tt;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 bl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(T(e.display.wrapper,"CodeMirror-wrap"),Ye(e)),rn(e),_n(e),Er(e),setTimeout(function(){return Hn(e)},100)}function wl(e,t){var n=this;if(!(this instanceof wl))return new wl(e,t);this.options=t=t?z(t):{},z(gl,t,!1),ai(t);var i=t.value;"string"==typeof i&&(i=new So(i,t.mode,null,t.lineSeparator,t.direction)),this.doc=i;var o=new wl.inputStyles[t.inputStyle](this),u=this.display=new function(e,t,n){var i=this;this.input=n,i.scrollbarFiller=O("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=O("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=A("div",null,"CodeMirror-code"),i.selectionDiv=O("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=O("div",null,"CodeMirror-cursors"),i.measure=O("div",null,"CodeMirror-measure"),i.lineMeasure=O("div",null,"CodeMirror-measure"),i.lineSpace=A("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none");var o=A("div",[i.lineSpace],"CodeMirror-lines");i.mover=O("div",[o],null,"position: relative"),i.sizer=O("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=O("div",null,null,"position: absolute; height: "+G+"px; width: 1px;"),i.gutters=O("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=O("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=O("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),l&&s<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),a||r&&m||(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,n.init(i)}(e,i,o);for(var c in u.wrapper.CodeMirror=this,si(this),dl(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),En(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&&!m&&u.input.focus(),l&&s<11&&setTimeout(function(){return n.display.input.reset(!0)},20),function(e){var t=e.display;Je(t.scroller,"mousedown",jn(e,al)),Je(t.scroller,"dblclick",l&&s<11?jn(e,function(t){if(!nt(e,t)){var r=nn(e,t);if(r&&!hl(e,t)&&!yr(e.display,t)){st(t);var n=e.findWordAt(r);Bi(e.doc,n.anchor,n.head)}}}):function(t){return nt(e,t)||st(t)});S||Je(t.scroller,"contextmenu",function(t){return fl(e,t)});var r,n={end:0};function i(){t.activeTouch&&(r=setTimeout(function(){return t.activeTouch=null},1e3),(n=t.activeTouch).end=+new Date)}function o(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}Je(t.scroller,"touchstart",function(i){if(!nt(e,i)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(i)&&!hl(e,i)){t.input.ensurePolled(),clearTimeout(r);var o=+new Date;t.activeTouch={start:o,moved:!1,prev:o-n.end<=300?n:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}}),Je(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),Je(t.scroller,"touchend",function(r){var n=t.activeTouch;if(n&&!yr(t,r)&&null!=n.left&&!n.moved&&new Date-n.start<300){var l,s=e.coordsChar(t.activeTouch,"page");l=!n.prev||o(n,n.prev)?new gi(s,s):!n.prev.prev||o(n,n.prev.prev)?e.findWordAt(s):new gi(ge(s.line,0),Ce(e.doc,ge(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),st(r)}i()}),Je(t.scroller,"touchcancel",i),Je(t.scroller,"scroll",function(){t.scroller.clientHeight&&(Mn(e,t.scroller.scrollTop),On(e,t.scroller.scrollLeft,!0),rt(e,"scroll",e))}),Je(t.scroller,"mousewheel",function(t){return di(e,t)}),Je(t.scroller,"DOMMouseScroll",function(t){return di(e,t)}),Je(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(t){nt(e,t)||ct(t)},over:function(t){nt(e,t)||(!function(e,t){var r=nn(e,t);if(r){var n=document.createDocumentFragment();an(e,r,n),e.display.dragCursor||(e.display.dragCursor=O("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),N(e.display.dragCursor,n)}}(e,t),ct(t))},start:function(t){return function(e,t){if(l&&(!e.state.draggingText||+new Date-Lo<100))ct(t);else if(!nt(e,t)&&!yr(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!f)){var r=O("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",h&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),h&&r.parentNode.removeChild(r)}}(e,t)},drop:jn(e,ko),leave:function(t){nt(e,t)||To(e)}};var a=t.input.getField();Je(a,"keyup",function(t){return nl.call(e,t)}),Je(a,"keydown",jn(e,rl)),Je(a,"keypress",jn(e,il)),Je(a,"focus",function(t){return pn(e,t)}),Je(a,"blur",function(t){return gn(e,t)})}(this),Oo(),In(this),this.curOp.forceUpdate=!0,Mi(this,i),t.autofocus&&!m||this.hasFocus()?setTimeout(E(pn,this),20):gn(this),vl)vl.hasOwnProperty(c)&&vl[c](n,t[c],pl);wn(this),t.finishInit&&t.finishInit(this);for(var d=0;d150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?I(se(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(f1)if(Sl&&Sl.text.join("\n")==t){if(n.ranges.length%Sl.text.length==0){u=[];for(var c=0;c=0;h--){var f=n.ranges[h],d=f.from(),p=f.to();f.empty()&&(r&&r>0?d=ge(d.line,d.ch-r):e.state.overwrite&&!s?p=ge(p.line,Math.min(se(o,p.line).text.length,p.ch+q(a).length)):Sl&&Sl.lineWise&&Sl.text.join("\n")==t&&(d=p=ge(d.line,0))),l=e.curOp.updateInput;var g={from:d,to:p,text:u?u[h%u.length]:a,origin:i||(s?"paste":e.state.cutIncoming?"cut":"+input")};to(e.doc,g),or(e,"inputRead",e,g)}t&&!s&&Ml(e,t),Sn(e),e.curOp.updateInput=l,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Tl(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||Kn(t,function(){return kl(t,r,0,null,"paste")}),!0}function Ml(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=Cl(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(se(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Cl(e,i.head.line,"smart"));l&&or(e,"electricInput",e,i.head.line)}}}function Nl(e){for(var t=[],r=[],n=0;n=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=qe(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&&f>=c.begin)){var d=h?"before":"after";return new ge(r.line,f,d)}}var p=function(e,t,n){for(var o=function(e,t){return t?new ge(r.line,a(e,1),"before"):new ge(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}(e.cm,s,t,r):jo(s,t,r))){if(n||(l=t.line+r)=e.first+e.size||(t=new ge(l,t.ch,t.sticky),!(s=se(e,l))))return!1;t=Xo(i,e.cm,s,t.line,r)}else t=o;return!0}if("char"==n)a();else if("column"==n)a(!0);else if("word"==n||"group"==n)for(var u=null,c="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),f=!0;!(r<0)||a(!f);f=!1){var d=s.text.charAt(t.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){r<0&&(r=1,a(),t.sticky="after");break}if(p&&(u=p),r>0&&!a(!f))break}var g=Zi(e,t,o,l,!0);return me(o,g)&&(g.hitSide=!0),g}function Wl(e,t,r,n){var i,o,l=e.doc,s=t.left;if("page"==n){var a=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=Math.max(a-.5*Zr(e.display),3);i=(r>0?t.bottom:t.top)+r*u}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;(o=Xr(e,s,i)).outside;){if(r<0?i<=0:i>=l.height){o.hitSide=!0;break}i+=5*r}return o}var Hl=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 Fl(e,t){var r=Mr(e,t.line);if(!r||r.hidden)return null;var n=se(e.doc,t.line),i=kr(r,n,t.line),o=Ze(n,e.doc.direction),l="left";o&&(l=qe(o,t.ch)%2?"right":"left");var s=Wr(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Pl(e,t){return t&&(e.bad=!0),e}function El(e,t,r){var n;if(t==e.display.lineDiv){if(!(n=e.display.lineDiv.childNodes[r]))return Pl(e.clipPos(ge(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||o.line=t.display.viewFrom&&Fl(t,i)||{node:a[0].measure.map[2],offset:0},c=o.linen.firstLine()&&(l=ge(l.line-1,se(n.doc,l.line-1).length)),s.ch==se(n.doc,s.line).text.length&&s.linei.viewTo-1)return!1;l.line==i.viewFrom||0==(e=on(n,l.line))?(t=he(i.view[0].line),r=i.view[0].node):(t=he(i.view[e].line),r=i.view[e-1].node.nextSibling);var a,u,c=on(n,s.line);if(c==i.view.length-1?(a=i.viewTo-1,u=i.lineDiv.lastChild):(a=he(i.view[c+1].line)-1,u=i.view[c+1].node.previousSibling),!r)return!1;for(var h=n.doc.splitLines(function(e,t,r,n,i){var o="",l=!1,s=e.doc.lineSeparator();function a(){l&&(o+=s,l=!1)}function u(e){e&&(a(),o+=e)}function c(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return void u(r||t.textContent.replace(/\u200b/g,""));var o,h=t.getAttribute("cm-marker");if(h){var f=e.findMarks(ge(n,0),ge(i+1,0),(g=+h,function(e){return e.id==g}));return void(f.length&&(o=f[0].find(0))&&u(ae(e.doc,o.from,o.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var d=/^(pre|div|p)$/i.test(t.nodeName);d&&a();for(var p=0;p1&&f.length>1;)if(q(h)==q(f))h.pop(),f.pop(),a--;else{if(h[0]!=f[0])break;h.shift(),f.shift(),t++}for(var d=0,p=0,g=h[0],v=f[0],m=Math.min(g.length,v.length);dl.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 x=ge(t,d),C=ge(a,f.length?q(f).length-p:0);return h.length>1||h[0]||ve(x,C)?(lo(n.doc,h,x,C,"+input"),!0):void 0},Hl.prototype.ensurePolled=function(){this.forceCompositionEnd()},Hl.prototype.reset=function(){this.forceCompositionEnd()},Hl.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Hl.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))},Hl.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||Kn(this.cm,function(){return _n(e.cm)})},Hl.prototype.setUneditable=function(e){e.contentEditable="false"},Hl.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||jn(this.cm,kl)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Hl.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Hl.prototype.onContextMenu=function(){},Hl.prototype.resetPosition=function(){},Hl.prototype.needsContentAttribute=!0;var Il,Rl,Bl,Gl=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new R,this.hasSelection=!1,this.composing=null};Gl.prototype.init=function(e){var t=this,r=this,n=this.cm;this.createField(e);var i=this.textarea;function o(e){if(!nt(n,e)){if(n.somethingSelected())Ll({lineWise:!1,text:n.getSelections()});else{if(!n.options.lineWiseCopyCut)return;var t=Nl(n);Ll({lineWise:!0,text:t.text}),"cut"==e.type?n.setSelections(t.ranges,null,V):(r.prevInput="",i.value=t.text.join("\n"),P(i))}"cut"==e.type&&(n.state.cutIncoming=!0)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),g&&(i.style.width="0px"),Je(i,"input",function(){l&&s>=9&&t.hasSelection&&(t.hasSelection=null),r.poll()}),Je(i,"paste",function(e){nt(n,e)||Tl(e,n)||(n.state.pasteIncoming=!0,r.fastPoll())}),Je(i,"cut",o),Je(i,"copy",o),Je(e.scroller,"paste",function(t){yr(e,t)||nt(n,t)||(n.state.pasteIncoming=!0,r.focus())}),Je(e.lineSpace,"selectstart",function(t){yr(e,t)||st(t)}),Je(i,"compositionstart",function(){var e=n.getCursor("from");r.composing&&r.composing.range.clear(),r.composing={start:e,range:n.markText(e,n.getCursor("to"),{className:"CodeMirror-composing"})}}),Je(i,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},Gl.prototype.createField=function(e){this.wrapper=Al(),this.textarea=this.wrapper.firstChild},Gl.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=sn(e);if(e.options.moveInputWithCursor){var i=Vr(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},Gl.prototype.showSelection=function(e){var t=this.cm.display;N(t.cursorDiv,e.cursors),N(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Gl.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var r=t.getSelection();this.textarea.value=r,t.state.focused&&P(this.textarea),l&&s>=9&&(this.hasSelection=r)}else e||(this.prevInput=this.textarea.value="",l&&s>=9&&(this.hasSelection=null))}},Gl.prototype.getField=function(){return this.textarea},Gl.prototype.supportsTouch=function(){return!1},Gl.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!m||W()!=this.textarea))try{this.textarea.focus()}catch(e){}},Gl.prototype.blur=function(){this.textarea.blur()},Gl.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Gl.prototype.receivedFocus=function(){this.slowPoll()},Gl.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Gl.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0,t.polling.set(20,function r(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,r))})},Gl.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||wt(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(l&&s>=9&&this.hasSelection===i||y&&/[\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 a=0,u=Math.min(n.length,i.length);a1e3||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},Gl.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Gl.prototype.onKeyPress=function(){l&&s>=9&&(this.hasSelection=null),this.fastPoll()},Gl.prototype.onContextMenu=function(e){var t=this,r=t.cm,n=r.display,i=t.textarea,o=nn(r,e),u=n.scroller.scrollTop;if(o&&!h){r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(o)&&jn(r,ji)(r.doc,mi(o),V);var c=i.style.cssText,f=t.wrapper.style.cssText;t.wrapper.style.cssText="position: absolute";var d,p=t.wrapper.getBoundingClientRect();if(i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-p.top-5)+"px; left: "+(e.clientX-p.left-5)+"px;\n z-index: 1000; background: "+(l?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",a&&(d=window.scrollY),n.input.focus(),a&&window.scrollTo(null,d),n.input.reset(),r.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=!0,n.selForContextMenu=r.doc.sel,clearTimeout(n.detectingSelectAll),l&&s>=9&&v(),S){ct(e);var g=function(){tt(window,"mouseup",g),setTimeout(m,20)};Je(window,"mouseup",g)}else setTimeout(m,50)}function v(){if(null!=i.selectionStart){var e=r.somethingSelected(),o="​"+(e?i.value:"");i.value="⇚",i.value=o,t.prevInput=e?"":"​",i.selectionStart=1,i.selectionEnd=o.length,n.selForContextMenu=r.doc.sel}}function m(){if(t.contextMenuPending=!1,t.wrapper.style.cssText=f,i.style.cssText=c,l&&s<9&&n.scrollbars.setScrollTop(n.scroller.scrollTop=u),null!=i.selectionStart){(!l||l&&s<9)&&v();var e=0,o=function(){n.selForContextMenu==r.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&"​"==t.prevInput?jn(r,Ji)(r):e++<10?n.detectingSelectAll=setTimeout(o,500):(n.selForContextMenu=null,n.input.reset())};n.detectingSelectAll=setTimeout(o,200)}}},Gl.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},Gl.prototype.setUneditable=function(){},Gl.prototype.needsContentAttribute=!1,function(e){var t=e.optionHandlers;function r(r,n,i,o){e.defaults[r]=n,i&&(t[r]=o?function(e,t,r){r!=pl&&i(e,t,r)}:i)}e.defineOption=r,e.Init=pl,r("value","",function(e,t){return e.setValue(t)},!0),r("mode",null,function(e,t){e.doc.modeOption=t,Ci(e)},!0),r("indentUnit",2,Ci,!0),r("indentWithTabs",!1),r("smartIndent",!0),r("tabSize",4,function(e){Si(e),Er(e),_n(e)},!0),r("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(-1==o)break;i=o+t.length,r.push(ge(n,o))}n++});for(var i=r.length-1;i>=0;i--)lo(e.doc,t,r[i],ge(r[i].line,r[i].ch+t.length))}}),r("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!=pl&&e.refresh()}),r("specialCharPlaceholder",$t,function(e){return e.refresh()},!0),r("electricChars",!0),r("inputStyle",m?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),r("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),r("rtlMoveVisually",!w),r("wholeLineUpdateBefore",!0),r("theme","default",function(e){dl(e),ml(e)},!0),r("keyMap","default",function(e,t,r){var n=Uo(t),i=r!=pl&&Uo(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),r("extraKeys",null),r("configureMouse",null),r("lineWrapping",!1,bl,!0),r("gutters",[],function(e){ai(e.options),ml(e)},!0),r("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?en(e.display)+"px":"0",e.refresh()},!0),r("coverGutterNextToScrollbar",!1,function(e){return Hn(e)},!0),r("scrollbarStyle","native",function(e){En(e),Hn(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),r("lineNumbers",!1,function(e){ai(e.options),ml(e)},!0),r("firstLineNumber",1,ml,!0),r("lineNumberFormatter",function(e){return e},ml,!0),r("showCursorWhenSelecting",!1,ln,!0),r("resetSelectionOnContextMenu",!0),r("lineWiseCopyCut",!0),r("pasteLinesPerSelection",!0),r("readOnly",!1,function(e,t){"nocursor"==t&&(gn(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),r("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),r("dragDrop",!0,yl),r("allowDropFileTypes",null),r("cursorBlinkRate",530),r("cursorScrollMargin",0),r("cursorHeight",1,ln,!0),r("singleCursorHeightPerLine",!0,ln,!0),r("workTime",100),r("workDelay",100),r("flattenSpans",!0,Si,!0),r("addModeClass",!1,Si,!0),r("pollInterval",100),r("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),r("historyEventDelay",1250),r("viewportMargin",10,function(e){return e.refresh()},!0),r("maxHighlightLength",1e4,Si,!0),r("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),r("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),r("autofocus",null),r("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0)}(wl),Rl=(Il=wl).optionHandlers,Bl=Il.helpers={},Il.prototype={constructor:Il,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];r[e]==t&&"mode"!=e||(r[e]=t,Rl.hasOwnProperty(e)&&jn(this,Rl[e])(this,t,n),rt(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Uo(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;rn&&(Cl(t,o.head.line,e,!0),n=o.head.line,i==t.doc.sel.primIndex&&Sn(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&&Ui(t.doc,i,new gi(l,c[i].to()),V)}}}),getTokenAt:function(e,t){return Ut(this,e,t)},getLineTokens:function(e,t){return Ut(this,ge(e),t,!0)},getTokenTypeAt:function(e){e=Ce(this.doc,e);var t,r=Et(this,se(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=se(this.doc,e)}else n=e;return Br(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-je(n):0)},defaultTextHeight:function(){return Zr(this.display)},defaultCharWidth:function(){return Qr(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o,l,s,a=this.display,u=(e=Vr(this,Ce(this.doc,e))).bottom,c=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),a.sizer.appendChild(t),"over"==n)u=e.top;else if("above"==n||"near"==n){var h=Math.max(a.wrapper.clientHeight,this.doc.height),f=Math.max(a.sizer.clientWidth,a.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>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=xn(o,l)).scrollTop&&Mn(o,s.scrollTop),null!=s.scrollLeft&&On(o,s.scrollLeft))},triggerOnKeyDown:Xn(rl),triggerOnKeyPress:Xn(il),triggerOnKeyUp:nl,triggerOnMouseDown:Xn(al),execCommand:function(e){if(Yo.hasOwnProperty(e))return Yo[e].call(null,this)},triggerElectric:Xn(function(e){Ml(this,e)}),findPosH:function(e,t,r,n){var i=1;t<0&&(i=-1,t=-t);for(var o=Ce(this.doc,e),l=0;l0&&l(t.charAt(r-1));)--r;for(;n.5)&&rn(this),rt(this,"refresh",this)}),swapDoc:Xn(function(e){var t=this.doc;return t.cm=null,Mi(this,e),Er(this),this.display.input.reset(),Ln(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,or(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}},lt(Il),Il.registerHelper=function(e,t,r){Bl.hasOwnProperty(e)||(Bl[e]=Il[e]={_global:[]}),Bl[e][t]=r},Il.registerGlobalHelper=function(e,t,r,n){Il.registerHelper(e,t,n),Bl[e]._global.push({pred:r,val:n})};var Ul,Vl="iter insert remove copy getEditor constructor".split(" ");for(var Kl in So.prototype)So.prototype.hasOwnProperty(Kl)&&B(Vl,Kl)<0&&(wl.prototype[Kl]=function(e){return function(){return e.apply(this.doc,arguments)}}(So.prototype[Kl]));return lt(So),wl.inputStyles={textarea:Gl,contenteditable:Hl},wl.defineMode=function(e){wl.defaults.mode||"null"==e||(wl.defaults.mode=e),function(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),St[e]=t}.apply(this,arguments)},wl.defineMIME=function(e,t){Lt[e]=t},wl.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),wl.defineMIME("text/plain","null"),wl.defineExtension=function(e,t){wl.prototype[e]=t},wl.defineDocExtension=function(e,t){So.prototype[e]=t},wl.fromTextArea=function(e,t){if((t=t?z(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var r=W();t.autofocus=r==e||null!=e.getAttribute("autofocus")&&r==document.body}function n(){e.value=s.getValue()}var i;if(e.form&&(Je(e.form,"submit",n),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var l=o.submit=function(){n(),o.submit=i,o.submit(),o.submit=l}}catch(e){}}t.finishInit=function(t){t.save=n,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,n(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(tt(e.form,"submit",n),"function"==typeof e.form.submit&&(e.form.submit=i))}},e.style.display="none";var s=wl(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return s},(Ul=wl).off=tt,Ul.on=Je,Ul.wheelEventPixels=fi,Ul.Doc=So,Ul.splitLines=bt,Ul.countColumn=I,Ul.findColumn=X,Ul.isWordChar=ee,Ul.Pass=U,Ul.signal=rt,Ul.Line=jt,Ul.changeEnd=yi,Ul.scrollbarModel=Pn,Ul.Pos=ge,Ul.cmpPos=ve,Ul.modes=St,Ul.mimeModes=Lt,Ul.resolveMode=kt,Ul.getMode=Tt,Ul.modeExtensions=Mt,Ul.extendMode=Nt,Ul.copyState=Ot,Ul.startState=Dt,Ul.innerMode=At,Ul.commands=Yo,Ul.keyMap=Po,Ul.keyName=Go,Ul.isModifierKey=Ro,Ul.lookupKey=Io,Ul.normalizeKeyMap=zo,Ul.StringStream=Wt,Ul.SharedTextMarker=bo,Ul.TextMarker=mo,Ul.LineWidget=po,Ul.e_preventDefault=st,Ul.e_stopPropagation=at,Ul.e_stop=ct,Ul.addClass=H,Ul.contains=D,Ul.rmClass=T,Ul.keyNames=Do,wl.version="5.37.1",wl});