| 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";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function n(e,n){return t(e).appendChild(n)}function i(e,t,n,i){var r=document.createElement(e);if(n&&(r.className=n),i&&(r.style.cssText=i),"string"==typeof t)r.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)r.appendChild(t[o]);return r}function r(e,t,n,r){var o=i(e,t,n,r);return o.setAttribute("role","presentation"),o}function o(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)}function a(){var e;try{e=document.activeElement}catch(t){e=document.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function s(t,n){var i=t.className;e(n).test(i)||(t.className+=(i?" ":"")+n)}function l(t,n){for(var i=t.split(" "),r=0;r<i.length;r++)i[r]&&!e(i[r]).test(n)&&(n+=" "+i[r]);return n}function c(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function u(e,t,n){t||(t={});for(var i in e)!e.hasOwnProperty(i)||n===!1&&t.hasOwnProperty(i)||(t[i]=e[i]);return t}function d(e,t,n,i,r){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=i||0,a=r||0;;){var s=e.indexOf(" ",o);if(0>s||s>=t)return a+(t-o);a+=s-o,a+=n-a%n,o=s+1}}function h(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}function f(e,t,n){for(var i=0,r=0;;){var o=e.indexOf(" ",i);-1==o&&(o=e.length);var a=o-i;if(o==e.length||r+a>=t)return i+Math.min(a,t-r);if(r+=o-i,r+=n-r%n,i=o+1,r>=t)return i}}function p(e){for(;Qs.length<=e;)Qs.push(g(Qs)+" ");return Qs[e]}function g(e){return e[e.length-1]}function m(e,t){for(var n=[],i=0;i<e.length;i++)n[i]=t(e[i],i);return n}function v(e,t,n){for(var i=0,r=n(t);i<e.length&&n(e[i])<=r;)i++;e.splice(i,0,t)}function y(){}function b(e,t){var n;return Object.create?n=Object.create(e):(y.prototype=e,n=new y),t&&u(t,n),n}function x(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Ys.test(e))}function w(e,t){return t?t.source.indexOf("\\w")>-1&&x(e)?!0:t.test(e):x(e)}function k(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function C(e){return e.charCodeAt(0)>=768&&Zs.test(e)}function _(e,t,n){for(;(0>n?t>0:t<e.length)&&C(e.charAt(t));)t+=n;return t}function $(e,t,n){for(var i=t>n?-1:1;;){if(t==n)return t;var r=(t+n)/2,o=0>i?Math.ceil(r):Math.floor(r);if(o==t)return e(o)?t:n;e(o)?n=o:t=o+i}}function S(e,t,n,i){if(!e)return i(t,n,"ltr",0);for(var r=!1,o=0;o<e.length;++o){var a=e[o];(a.from<n&&a.to>t||t==n&&a.to==t)&&(i(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr",o),r=!0)}r||i(t,n,"ltr")}function T(e,t,n){var i;el=null;for(var r=0;r<e.length;++r){var o=e[r];if(o.from<t&&o.to>t)return r;o.to==t&&(o.from!=o.to&&"before"==n?i=r:el=r),o.from==t&&(o.from!=o.to&&"before"!=n?i=r:el=r)}return null!=i?i:el}function E(e,t){var n=e.order;return null==n&&(n=e.order=tl(e.text,t)),n}function M(e,t){return e._handlers&&e._handlers[t]||nl}function A(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var i=e._handlers,r=i&&i[t];if(r){var o=h(r,n);o>-1&&(i[t]=r.slice(0,o).concat(r.slice(o+1)))}}}function L(e,t){var n=M(e,t);if(n.length)for(var i=Array.prototype.slice.call(arguments,2),r=0;r<n.length;++r)n[r].apply(null,i)}function D(e,t,n){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),L(e,n||t.type,e,t),z(t)||t.codemirrorIgnore}function N(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),i=0;i<t.length;++i)-1==h(n,t[i])&&n.push(t[i])}function j(e,t){return M(e,t).length>0}function I(e){e.prototype.on=function(e,t){il(this,e,t)},e.prototype.off=function(e,t){A(this,e,t)}}function O(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function P(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function z(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function H(e){O(e),P(e)}function B(e){return e.target||e.srcElement}function V(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),js&&e.ctrlKey&&1==t&&(t=3),t}function F(e){if(null==Ws){var t=i("span","");n(e,i("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Ws=t.offsetWidth<=1&&t.offsetHeight>2&&!(ks&&8>Cs))}var r=Ws?i("span",""):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function R(e){if(null!=qs)return qs;var i=n(e,document.createTextNode("AخA")),r=zs(i,0,1).getBoundingClientRect(),o=zs(i,1,2).getBoundingClientRect();return t(e),r&&r.left!=r.right?qs=o.right-r.right<3:!1}function W(e){if(null!=ll)return ll;var t=n(e,i("span","x")),r=t.getBoundingClientRect(),o=zs(t,0,1).getBoundingClientRect();return ll=Math.abs(r.left-o.left)>1}function q(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),cl[e]=t}function U(e,t){ul[e]=t}function J(e){if("string"==typeof e&&ul.hasOwnProperty(e))e=ul[e];else if(e&&"string"==typeof e.name&&ul.hasOwnProperty(e.name)){var t=ul[e.name];"string"==typeof t&&(t={name:t}),e=b(t,e),e.name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return J("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return J("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function G(e,t){t=J(t);var n=cl[t.name];if(!n)return G(e,"text/plain");var i=n(e,t);if(dl.hasOwnProperty(t.name)){var r=dl[t.name];for(var o in r)r.hasOwnProperty(o)&&(i.hasOwnProperty(o)&&(i["_"+o]=i[o]),i[o]=r[o])}if(i.name=t.name,t.helperType&&(i.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)i[a]=t.modeProps[a];return i}function K(e,t){var n=dl.hasOwnProperty(e)?dl[e]:dl[e]={};u(t,n)}function X(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var i in t){var r=t[i];r instanceof Array&&(r=r.concat([])),n[i]=r}return n}function Q(e,t){for(var n;e.innerMode&&(n=e.innerMode(t),n&&n.mode!=e);)t=n.state,e=n.mode;return n||{mode:e,state:t}}function Y(e,t,n){return e.startState?e.startState(t,n):!0}function Z(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(o>t){n=r;break}t-=o}return n.lines[t]}function et(e,t,n){var i=[],r=t.line;return e.iter(t.line,n.line+1,function(e){var o=e.text;r==n.line&&(o=o.slice(0,n.ch)),r==t.line&&(o=o.slice(t.ch)),i.push(o),++r}),i}function tt(e,t,n){var i=[];return e.iter(t,n,function(e){i.push(e.text)}),i}function nt(e,t){var n=t-e.height;if(n)for(var i=e;i;i=i.parent)i.height+=n}function it(e){if(null==e.parent)return null;for(var t=e.parent,n=h(t.lines,e),i=t.parent;i;t=i,i=i.parent)for(var r=0;i.children[r]!=t;++r)n+=i.children[r].chunkSize();return n+t.first}function rt(e,t){var n=e.first;e:do{for(var i=0;i<e.children.length;++i){var r=e.children[i],o=r.height;if(o>t){e=r;continue e}t-=o,n+=r.chunkSize()}return n}while(!e.lines);for(var a=0;a<e.lines.length;++a){var s=e.lines[a],l=s.height;if(l>t)break;t-=l}return n+a}function ot(e,t){return t>=e.first&&t<e.first+e.size}function at(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function st(e,t,n){return void 0===n&&(n=null),this instanceof st?(this.line=e,this.ch=t,this.sticky=n,void 0):new st(e,t,n)}function lt(e,t){return e.line-t.line||e.ch-t.ch}function ct(e,t){return e.sticky==t.sticky&&0==lt(e,t)}function ut(e){return st(e.line,e.ch)}function dt(e,t){return lt(e,t)<0?t:e}function ht(e,t){return lt(e,t)<0?e:t}function ft(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function pt(e,t){if(t.line<e.first)return st(e.first,0);var n=e.first+e.size-1;return t.line>n?st(n,Z(e,n).text.length):gt(t,Z(e,t.line).text.length)}function gt(e,t){var n=e.ch;return null==n||n>t?st(e.line,t):0>n?st(e.line,0):e}function mt(e,t){for(var n=[],i=0;i<t.length;i++)n[i]=pt(e,t[i]);return n}function vt(e,t,n,i){var r=[e.state.modeGen],o={};$t(e,t.text,e.doc.mode,n,function(e,t){return r.push(e,t)},o,i);for(var a=n.state,s=function(i){n.baseTokens=r;var s=e.state.overlays[i],l=1,c=0;n.state=!0,$t(e,t.text,s.mode,n,function(e,t){for(var n=l;e>c;){var i=r[l];i>e&&r.splice(l,1,e,r[l+1],i),l+=2,c=Math.min(e,i)}if(t)if(s.opaque)r.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;l>n;n+=2){var o=r[n+1];r[n+1]=(o?o+" ":"")+"overlay "+t}},o),n.state=a,n.baseTokens=null,n.baseTokenPos=1},l=0;l<e.state.overlays.length;++l)s(l);return{styles:r,classes:o.bgClass||o.textClass?o:null}}function yt(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var i=bt(e,it(t)),r=t.text.length>e.options.maxHighlightLength&&X(e.doc.mode,i.state),o=vt(e,t,i);r&&(i.state=r),t.stateAfter=i.save(!r),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function bt(e,t,n){var i=e.doc,r=e.display;if(!i.mode.startState)return new pl(i,!0,t);var o=St(e,t,n),a=o>i.first&&Z(i,o-1).stateAfter,s=a?pl.fromSaved(i,a,o):new pl(i,Y(i.mode),o);return i.iter(o,t,function(n){xt(e,n.text,s);var i=s.line;n.stateAfter=i==t-1||0==i%5||i>=r.viewFrom&&i<r.viewTo?s.save():null,s.nextLine()}),n&&(i.modeFrontier=s.line),s}function xt(e,t,n,i){var r=e.doc.mode,o=new hl(t,e.options.tabSize,n);for(o.start=o.pos=i||0,""==t&&wt(r,n.state);!o.eol();)kt(r,o,n.state),o.start=o.pos}function wt(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var n=Q(e,t);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function kt(e,t,n,i){for(var r=0;10>r;r++){i&&(i[0]=Q(e,n).mode);var o=e.token(t,n);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}function Ct(e,t,n,i){var r,o=e.doc,a=o.mode;t=pt(o,t);var s,l=Z(o,t.line),c=bt(e,t.line,n),u=new hl(l.text,e.options.tabSize,c);for(i&&(s=[]);(i||u.pos<t.ch)&&!u.eol();)u.start=u.pos,r=kt(a,u,c.state),i&&s.push(new gl(u,r,X(o.mode,c.state)));return i?s:new gl(u,r,c.state)}function _t(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var i=n[1]?"bgClass":"textClass";null==t[i]?t[i]=n[2]:new RegExp("(?:^|s)"+n[2]+"(?:$|s)").test(t[i])||(t[i]+=" "+n[2])}return e}function $t(e,t,n,i,r,o,a){var s=n.flattenSpans;null==s&&(s=e.options.flattenSpans);var l,c=0,u=null,d=new hl(t,e.options.tabSize,i),h=e.options.addModeClass&&[null];for(""==t&&_t(wt(n,i.state),o);!d.eol();){if(d.pos>e.options.maxHighlightLength?(s=!1,a&&xt(e,t,i,d.pos),d.pos=t.length,l=null):l=_t(kt(n,d,i.state,h),o),h){var f=h[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!s||u!=l){for(;c<d.start;)c=Math.min(d.start,c+5e3),r(c,u);u=l}d.start=d.pos}for(;c<d.pos;){var p=Math.min(d.pos,c+5e3);r(p,u),c=p}}function St(e,t,n){for(var i,r,o=e.doc,a=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>a;--s){if(s<=o.first)return o.first;var l=Z(o,s-1),c=l.stateAfter;if(c&&(!n||s+(c instanceof fl?c.lookAhead:0)<=o.modeFrontier))return s;var u=d(l.text,null,e.options.tabSize);(null==r||i>u)&&(r=s-1,i=u)}return r}function Tt(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontier<t-10)){for(var n=e.first,i=t-1;i>n;i--){var r=Z(e,i).stateAfter;if(r&&(!(r instanceof fl)||i+r.lookAhead<t)){n=i+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}}function Et(){ml=!0}function Mt(){vl=!0}function At(e,t,n){this.marker=e,this.from=t,this.to=n}function Lt(e,t){if(e)for(var n=0;n<e.length;++n){var i=e[n];if(i.marker==t)return i}}function Dt(e,t){for(var n,i=0;i<e.length;++i)e[i]!=t&&(n||(n=[])).push(e[i]);return n}function Nt(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function jt(e,t,n){var i;if(e)for(var r=0;r<e.length;++r){var o=e[r],a=o.marker,s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);if(s||o.from==t&&"bookmark"==a.type&&(!n||!o.marker.insertLeft)){var l=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);(i||(i=[])).push(new At(a,o.from,l?null:o.to))}}return i}function It(e,t,n){var i;if(e)for(var r=0;r<e.length;++r){var o=e[r],a=o.marker,s=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);if(s||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);(i||(i=[])).push(new At(a,l?null:o.from-t,null==o.to?null:o.to-t))}}return i}function Ot(e,t){if(t.full)return null;var n=ot(e,t.from.line)&&Z(e,t.from.line).markedSpans,i=ot(e,t.to.line)&&Z(e,t.to.line).markedSpans;if(!n&&!i)return null;var r=t.from.ch,o=t.to.ch,a=0==lt(t.from,t.to),s=jt(n,r,a),l=It(i,o,a),c=1==t.text.length,u=g(t.text).length+(c?r:0);if(s)for(var d=0;d<s.length;++d){var h=s[d];if(null==h.to){var f=Lt(l,h.marker);f?c&&(h.to=null==f.to?null:f.to+u):h.to=r}}if(l)for(var p=0;p<l.length;++p){var m=l[p];if(null!=m.to&&(m.to+=u),null==m.from){var v=Lt(s,m.marker);v||(m.from=u,c&&(s||(s=[])).push(m))}else m.from+=u,c&&(s||(s=[])).push(m)}s&&(s=Pt(s)),l&&l!=s&&(l=Pt(l));var y=[s];if(!c){var b,x=t.text.length-2;if(x>0&&s)for(var w=0;w<s.length;++w)null==s[w].to&&(b||(b=[])).push(new At(s[w].marker,null,null));for(var k=0;x>k;++k)y.push(b);y.push(l)}return y}function Pt(e){for(var t=0;t<e.length;++t){var n=e[t];null!=n.from&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function zt(e,t,n){var i=null;if(e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;!n.readOnly||i&&-1!=h(i,n)||(i||(i=[])).push(n)}}),!i)return null;for(var r=[{from:t,to:n}],o=0;o<i.length;++o)for(var a=i[o],s=a.find(0),l=0;l<r.length;++l){var c=r[l];if(!(lt(c.to,s.from)<0||lt(c.from,s.to)>0)){var u=[l,1],d=lt(c.from,s.from),f=lt(c.to,s.to);(0>d||!a.inclusiveLeft&&!d)&&u.push({from:c.from,to:s.from}),(f>0||!a.inclusiveRight&&!f)&&u.push({from:s.to,to:c.to}),r.splice.apply(r,u),l+=u.length-3}}return r}function Ht(e){var t=e.markedSpans;if(t){for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}}function Bt(e,t){if(t){for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}}function Vt(e){return e.inclusiveLeft?-1:0}function Ft(e){return e.inclusiveRight?1:0}function Rt(e,t){var n=e.lines.length-t.lines.length;if(0!=n)return n;var i=e.find(),r=t.find(),o=lt(i.from,r.from)||Vt(e)-Vt(t);if(o)return-o;var a=lt(i.to,r.to)||Ft(e)-Ft(t);return a?a:t.id-e.id}function Wt(e,t){var n,i=vl&&e.markedSpans;if(i)for(var r=void 0,o=0;o<i.length;++o)r=i[o],r.marker.collapsed&&null==(t?r.from:r.to)&&(!n||Rt(n,r.marker)<0)&&(n=r.marker);return n}function qt(e){return Wt(e,!0)}function Ut(e){return Wt(e,!1)}function Jt(e,t){var n,i=vl&&e.markedSpans;if(i)for(var r=0;r<i.length;++r){var o=i[r];o.marker.collapsed&&(null==o.from||o.from<t)&&(null==o.to||o.to>t)&&(!n||Rt(n,o.marker)<0)&&(n=o.marker)}return n}function Gt(e,t,n,i,r){var o=Z(e,t),a=vl&&o.markedSpans;if(a)for(var s=0;s<a.length;++s){var l=a[s];if(l.marker.collapsed){var c=l.marker.find(0),u=lt(c.from,n)||Vt(l.marker)-Vt(r),d=lt(c.to,i)||Ft(l.marker)-Ft(r);if(!(u>=0&&0>=d||0>=u&&d>=0)&&(0>=u&&(l.marker.inclusiveRight&&r.inclusiveLeft?lt(c.to,n)>=0:lt(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?lt(c.from,i)<=0:lt(c.from,i)<0)))return!0}}}function Kt(e){for(var t;t=qt(e);)e=t.find(-1,!0).line;return e}function Xt(e){for(var t;t=Ut(e);)e=t.find(1,!0).line;return e}function Qt(e){for(var t,n;t=Ut(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function Yt(e,t){var n=Z(e,t),i=Kt(n);return n==i?t:it(i)}function Zt(e,t){if(t>e.lastLine())return t;var n,i=Z(e,t);if(!en(e,i))return t;for(;n=Ut(i);)i=n.find(1,!0).line;return it(i)+1}function en(e,t){var n=vl&&t.markedSpans;if(n)for(var i=void 0,r=0;r<n.length;++r)if(i=n[r],i.marker.collapsed){if(null==i.from)return!0;if(!i.marker.widgetNode&&0==i.from&&i.marker.inclusiveLeft&&tn(e,t,i))return!0}}function tn(e,t,n){if(null==n.to){var i=n.marker.find(1,!0);return tn(e,i.line,Lt(i.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var r=void 0,o=0;o<t.markedSpans.length;++o)if(r=t.markedSpans[o],r.marker.collapsed&&!r.marker.widgetNode&&r.from==n.to&&(null==r.to||r.to!=n.from)&&(r.marker.inclusiveLeft||n.marker.inclusiveRight)&&tn(e,t,r))return!0}function nn(e){e=Kt(e);for(var t=0,n=e.parent,i=0;i<n.lines.length;++i){var r=n.lines[i];if(r==e)break;t+=r.height}for(var o=n.parent;o;n=o,o=n.parent)for(var a=0;a<o.children.length;++a){var s=o.children[a];if(s==n)break;t+=s.height}return t}function rn(e){if(0==e.height)return 0;for(var t,n=e.text.length,i=e;t=qt(i);){var r=t.find(0,!0);i=r.from.line,n+=r.from.ch-r.to.ch}for(i=e;t=Ut(i);){var o=t.find(0,!0);n-=i.text.length-o.from.ch,i=o.to.line,n+=i.text.length-o.to.ch}return n}function on(e){var t=e.display,n=e.doc;t.maxLine=Z(n,n.first),t.maxLineLength=rn(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=rn(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function an(e,t,n,i){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),Ht(e),Bt(e,n);var r=i?i(e):1;r!=e.height&&nt(e,r)}function sn(e){e.parent=null,Ht(e)}function ln(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?wl:xl;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function cn(e,t){var n=r("span",null,null,_s?"padding-right: .1px":null),i={pre:r("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var a=o?t.rest[o-1]:t.line,s=void 0;i.pos=0,i.addToken=dn,R(e.display.measure)&&(s=E(a,e.doc.direction))&&(i.addToken=fn(i.addToken,s)),i.map=[];var c=t!=e.display.externalMeasured&&it(a);gn(a,i,yt(e,a,c)),a.styleClasses&&(a.styleClasses.bgClass&&(i.bgClass=l(a.styleClasses.bgClass,i.bgClass||"")),a.styleClasses.textClass&&(i.textClass=l(a.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(F(e.display.measure))),0==o?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(_s){var u=i.content.lastChild;(/\bcm-tab\b/.test(u.className)||u.querySelector&&u.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return L(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=l(i.pre.className,i.textClass||"")),i}function un(e){var t=i("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function dn(e,t,n,r,o,a,s){if(t){var l,c=e.splitSpaces?hn(t,e.trailingSpace):t,u=e.cm.state.specialChars,d=!1;if(u.test(t)){l=document.createDocumentFragment();for(var h=0;;){u.lastIndex=h;var f=u.exec(t),g=f?f.index-h:t.length-h;if(g){var m=document.createTextNode(c.slice(h,h+g));ks&&9>Cs?l.appendChild(i("span",[m])):l.appendChild(m),e.map.push(e.pos,e.pos+g,m),e.col+=g,e.pos+=g}if(!f)break;h+=g+1;var v=void 0;if(" "==f[0]){var y=e.cm.options.tabSize,b=y-e.col%y;v=l.appendChild(i("span",p(b),"cm-tab")),v.setAttribute("role","presentation"),v.setAttribute("cm-text"," "),e.col+=b}else"\r"==f[0]||"\n"==f[0]?(v=l.appendChild(i("span","\r"==f[0]?"␍":"","cm-invalidchar")),v.setAttribute("cm-text",f[0]),e.col+=1):(v=e.cm.options.specialCharPlaceholder(f[0]),v.setAttribute("cm-text",f[0]),ks&&9>Cs?l.appendChild(i("span",[v])):l.appendChild(v),e.col+=1);e.map.push(e.pos,e.pos+1,v),e.pos++}}else e.col+=t.length,l=document.createTextNode(c),e.map.push(e.pos,e.pos+t.length,l),ks&&9>Cs&&(d=!0),e.pos+=t.length;if(e.trailingSpace=32==c.charCodeAt(t.length-1),n||r||o||d||a){var x=n||"";r&&(x+=r),o&&(x+=o);var w=i("span",[l],x,a);if(s)for(var k in s)s.hasOwnProperty(k)&&"style"!=k&&"class"!=k&&w.setAttribute(k,s[k]);return e.content.appendChild(w)}e.content.appendChild(l)}}function hn(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,i="",r=0;r<e.length;r++){var o=e.charAt(r);" "!=o||!n||r!=e.length-1&&32!=e.charCodeAt(r+1)||(o=" "),i+=o,n=" "==o}return i}function fn(e,t){return function(n,i,r,o,a,s,l){r=r?r+" cm-force-border":"cm-force-border";for(var c=n.pos,u=c+i.length;;){for(var d=void 0,h=0;h<t.length&&(d=t[h],!(d.to>c&&d.from<=c));h++);if(d.to>=u)return e(n,i,r,o,a,s,l);e(n,i.slice(0,d.to-c),r,o,null,s,l),o=null,i=i.slice(d.to-c),c=d.to}}}function pn(e,t,n,i){var r=!i&&n.widgetNode;r&&e.map.push(e.pos,e.pos+t,r),!i&&e.cm.display.input.needsContentAttribute&&(r||(r=e.content.appendChild(document.createElement("span"))),r.setAttribute("cm-marker",n.id)),r&&(e.cm.display.input.setUneditable(r),e.content.appendChild(r)),e.pos+=t,e.trailingSpace=!1}function gn(e,t,n){var i=e.markedSpans,r=e.text,o=0;if(i)for(var a,s,l,c,u,d,h,f=r.length,p=0,g=1,m="",v=0;;){if(v==p){l=c=u=s="",h=null,d=null,v=1/0;for(var y=[],b=void 0,x=0;x<i.length;++x){var w=i[x],k=w.marker;if("bookmark"==k.type&&w.from==p&&k.widgetNode)y.push(k);else if(w.from<=p&&(null==w.to||w.to>p||k.collapsed&&w.to==p&&w.from==p)){if(null!=w.to&&w.to!=p&&v>w.to&&(v=w.to,c=""),k.className&&(l+=" "+k.className),k.css&&(s=(s?s+";":"")+k.css),k.startStyle&&w.from==p&&(u+=" "+k.startStyle),k.endStyle&&w.to==v&&(b||(b=[])).push(k.endStyle,w.to),k.title&&((h||(h={})).title=k.title),k.attributes)for(var C in k.attributes)(h||(h={}))[C]=k.attributes[C];k.collapsed&&(!d||Rt(d.marker,k)<0)&&(d=w)}else w.from>p&&v>w.from&&(v=w.from)}if(b)for(var _=0;_<b.length;_+=2)b[_+1]==v&&(c+=" "+b[_]);if(!d||d.from==p)for(var $=0;$<y.length;++$)pn(t,0,y[$]);if(d&&(d.from||0)==p){if(pn(t,(null==d.to?f+1:d.to)-p,d.marker,null==d.from),null==d.to)return;d.to==p&&(d=!1)}}if(p>=f)break;for(var S=Math.min(f,v);;){if(m){var T=p+m.length;if(!d){var E=T>S?m.slice(0,S-p):m;t.addToken(t,E,a?a+l:l,u,p+E.length==v?c:"",s,h)}if(T>=S){m=m.slice(S-p),p=S;break}p=T,u=""}m=r.slice(o,o=n[g++]),a=ln(n[g++],t.cm.options)}}else for(var M=1;M<n.length;M+=2)t.addToken(t,r.slice(o,o=n[M]),ln(n[M+1],t.cm.options))}function mn(e,t,n){this.line=t,this.rest=Qt(t),this.size=this.rest?it(g(this.rest))-n+1:1,this.node=this.text=null,this.hidden=en(e,t)}function vn(e,t,n){for(var i,r=[],o=t;n>o;o=i){var a=new mn(e.doc,Z(e.doc,o),o);i=o+a.size,r.push(a)}return r}function yn(e){kl?kl.ops.push(e):e.ownsGroup=kl={ops:[e],delayedCallbacks:[]}}function bn(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var i=0;i<e.ops.length;i++){var r=e.ops[i];if(r.cursorActivityHandlers)for(;r.cursorActivityCalled<r.cursorActivityHandlers.length;)r.cursorActivityHandlers[r.cursorActivityCalled++].call(null,r.cm)}}while(n<t.length)}function xn(e,t){var n=e.ownsGroup;if(n)try{bn(n)}finally{kl=null,t(n)}}function wn(e,t){var n=M(e,t);if(n.length){var i,r=Array.prototype.slice.call(arguments,2);kl?i=kl.delayedCallbacks:Cl?i=Cl:(i=Cl=[],setTimeout(kn,0));for(var o=function(e){i.push(function(){return n[e].apply(null,r)})},a=0;a<n.length;++a)o(a)}}function kn(){var e=Cl;Cl=null;for(var t=0;t<e.length;++t)e[t]()}function Cn(e,t,n,i){for(var r=0;r<t.changes.length;r++){var o=t.changes[r];"text"==o?Tn(e,t):"gutter"==o?Mn(e,t,n,i):"class"==o?En(e,t):"widget"==o&&An(e,t,i)}t.changes=null}function _n(e){return e.node==e.text&&(e.node=i("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),ks&&8>Cs&&(e.node.style.zIndex=2)),e.node}function $n(e,t){var n=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),t.background)n?t.background.className=n:(t.background.parentNode.removeChild(t.background),t.background=null);else if(n){var r=_n(t);t.background=r.insertBefore(i("div",null,n),r.firstChild),e.display.input.setUneditable(t.background)}}function Sn(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):cn(e,t)}function Tn(e,t){var n=t.text.className,i=Sn(e,t);t.text==t.node&&(t.node=i.pre),t.text.parentNode.replaceChild(i.pre,t.text),t.text=i.pre,i.bgClass!=t.bgClass||i.textClass!=t.textClass?(t.bgClass=i.bgClass,t.textClass=i.textClass,En(e,t)):n&&(t.text.className=n)}function En(e,t){$n(e,t),t.line.wrapClass?_n(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var n=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=n||""}function Mn(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var o=_n(t);t.gutterBackground=i("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),o.insertBefore(t.gutterBackground,t.text)}var a=t.line.gutterMarkers;if(e.options.lineNumbers||a){var s=_n(t),l=t.gutter=i("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(l),s.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||a&&a["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(i("div",at(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),a)for(var c=0;c<e.display.gutterSpecs.length;++c){var u=e.display.gutterSpecs[c].className,d=a.hasOwnProperty(u)&&a[u];d&&l.appendChild(i("div",[d],"CodeMirror-gutter-elt","left: "+r.gutterLeft[u]+"px; width: "+r.gutterWidth[u]+"px"))}}}function An(t,n,i){n.alignable&&(n.alignable=null);for(var r=e("CodeMirror-linewidget"),o=n.node.firstChild,a=void 0;o;o=a)a=o.nextSibling,r.test(o.className)&&n.node.removeChild(o);Dn(t,n,i)}function Ln(e,t,n,i){var r=Sn(e,t);return t.text=t.node=r.pre,r.bgClass&&(t.bgClass=r.bgClass),r.textClass&&(t.textClass=r.textClass),En(e,t),Mn(e,t,n,i),Dn(e,t,i),t.node}function Dn(e,t,n){if(Nn(e,t.line,t,n,!0),t.rest)for(var i=0;i<t.rest.length;i++)Nn(e,t.rest[i],t,n,!1)}function Nn(e,t,n,r,o){if(t.widgets)for(var a=_n(n),s=0,l=t.widgets;s<l.length;++s){var c=l[s],u=i("div",[c.node],"CodeMirror-linewidget"+(c.className?" "+c.className:""));c.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),jn(c,u,n,r),e.display.input.setUneditable(u),o&&c.above?a.insertBefore(u,n.gutter||n.text):a.appendChild(u),wn(c,"redraw")}}function jn(e,t,n,i){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var r=i.wrapperWidth;t.style.left=i.fixedPos+"px",e.coverGutter||(r-=i.gutterTotalWidth,t.style.paddingLeft=i.gutterTotalWidth+"px"),t.style.width=r+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-i.gutterTotalWidth+"px"))}function In(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!o(document.body,e.node)){var r="position: relative;";e.coverGutter&&(r+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(r+="width: "+t.display.wrapper.clientWidth+"px;"),n(t.display.measure,i("div",[e.node],null,r))}return e.height=e.node.parentNode.offsetHeight}function On(e,t){for(var n=B(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return!0}function Pn(e){return e.lineSpace.offsetTop}function zn(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Hn(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=n(e.measure,i("pre","x","CodeMirror-line-like")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,o={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(o.left)||isNaN(o.right)||(e.cachedPaddingH=o),o}function Bn(e){return Us-e.display.nativeBarWidth}function Vn(e){return e.display.scroller.clientWidth-Bn(e)-e.display.barWidth}function Fn(e){return e.display.scroller.clientHeight-Bn(e)-e.display.barHeight}function Rn(e,t,n){var i=e.options.lineWrapping,r=i&&Vn(e);if(!t.measure.heights||i&&t.measure.width!=r){var o=t.measure.heights=[];if(i){t.measure.width=r;for(var a=t.text.firstChild.getClientRects(),s=0;s<a.length-1;s++){var l=a[s],c=a[s+1];Math.abs(l.bottom-c.bottom)>2&&o.push((l.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Wn(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var i=0;i<e.rest.length;i++)if(e.rest[i]==t)return{map:e.measure.maps[i],cache:e.measure.caches[i]};for(var r=0;r<e.rest.length;r++)if(it(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function qn(e,t){t=Kt(t);var i=it(t),r=e.display.externalMeasured=new mn(e.doc,t,i);r.lineN=i;var o=r.built=cn(e,r);return r.text=o.pre,n(e.display.lineMeasure,o.pre),r}function Un(e,t,n,i){return Kn(e,Gn(e,t),n,i)}function Jn(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Si(e,t)];var n=e.display.externalMeasured;return n&&t>=n.lineN&&t<n.lineN+n.size?n:void 0}function Gn(e,t){var n=it(t),i=Jn(e,n);i&&!i.text?i=null:i&&i.changes&&(Cn(e,i,n,wi(e)),e.curOp.forceUpdate=!0),i||(i=qn(e,t));var r=Wn(i,t,n);return{line:t,view:i,rect:null,map:r.map,cache:r.cache,before:r.before,hasHeights:!1}}function Kn(e,t,n,i,r){t.before&&(n=-1);var o,a=n+(i||"");return t.cache.hasOwnProperty(a)?o=t.cache[a]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Rn(e,t.view,t.rect),t.hasHeights=!0),o=Yn(e,t,n,i),o.bogus||(t.cache[a]=o)),{left:o.left,right:o.right,top:r?o.rtop:o.top,bottom:r?o.rbottom:o.bottom}}function Xn(e,t,n){for(var i,r,o,a,s,l,c=0;c<e.length;c+=3)if(s=e[c],l=e[c+1],s>t?(r=0,o=1,a="left"):l>t?(r=t-s,o=r+1):(c==e.length-3||t==l&&e[c+3]>t)&&(o=l-s,r=o-1,t>=l&&(a="right")),null!=r){if(i=e[c+2],s==l&&n==(i.insertLeft?"left":"right")&&(a=n),"left"==n&&0==r)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)i=e[(c-=3)+2],a="left";if("right"==n&&r==l-s)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)i=e[(c+=3)+2],a="right";break}return{node:i,start:r,end:o,collapse:a,coverStart:s,coverEnd:l}}function Qn(e,t){var n=_l;if("left"==t)for(var i=0;i<e.length&&(n=e[i]).left==n.right;i++);else for(var r=e.length-1;r>=0&&(n=e[r]).left==n.right;r--);return n}function Yn(e,t,n,i){var r,o=Xn(t.map,n,i),a=o.node,s=o.start,l=o.end,c=o.collapse;if(3==a.nodeType){for(var u=0;4>u;u++){for(;s&&C(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+l<o.coverEnd&&C(t.line.text.charAt(o.coverStart+l));)++l;if(r=ks&&9>Cs&&0==s&&l==o.coverEnd-o.coverStart?a.parentNode.getBoundingClientRect():Qn(zs(a,s,l).getClientRects(),i),r.left||r.right||0==s)break;l=s,s-=1,c="right"}ks&&11>Cs&&(r=Zn(e.display.measure,r))}else{s>0&&(c=i="right");var d;r=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==i?d.length-1:0]:a.getBoundingClientRect()}if(ks&&9>Cs&&!s&&(!r||!r.left&&!r.right)){var h=a.parentNode.getClientRects()[0];r=h?{left:h.left,right:h.left+xi(e.display),top:h.top,bottom:h.bottom}:_l}for(var f=r.top-t.rect.top,p=r.bottom-t.rect.top,g=(f+p)/2,m=t.view.measure.heights,v=0;v<m.length-1&&!(g<m[v]);v++);var y=v?m[v-1]:0,b=m[v],x={left:("right"==c?r.right:r.left)-t.rect.left,right:("left"==c?r.left:r.right)-t.rect.left,top:y,bottom:b};return r.left||r.right||(x.bogus=!0),e.options.singleCursorHeightPerLine||(x.rtop=f,x.rbottom=p),x}function Zn(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!W(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,i=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*i,bottom:t.bottom*i}}function ei(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={} |
| 2 | }function ti(e){e.display.externalMeasure=null,t(e.display.lineMeasure);for(var n=0;n<e.display.view.length;n++)ei(e.display.view[n])}function ni(e){ti(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function ii(){return Ss&&Ds?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function ri(){return Ss&&Ds?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function oi(e){var t=0;if(e.widgets)for(var n=0;n<e.widgets.length;++n)e.widgets[n].above&&(t+=In(e.widgets[n]));return t}function ai(e,t,n,i,r){if(!r){var o=oi(t);n.top+=o,n.bottom+=o}if("line"==i)return n;i||(i="local");var a=nn(t);if("local"==i?a+=Pn(e.display):a-=e.display.viewOffset,"page"==i||"window"==i){var s=e.display.lineSpace.getBoundingClientRect();a+=s.top+("window"==i?0:ri());var l=s.left+("window"==i?0:ii());n.left+=l,n.right+=l}return n.top+=a,n.bottom+=a,n}function si(e,t,n){if("div"==n)return t;var i=t.left,r=t.top;if("page"==n)i-=ii(),r-=ri();else if("local"==n||!n){var o=e.display.sizer.getBoundingClientRect();i+=o.left,r+=o.top}var a=e.display.lineSpace.getBoundingClientRect();return{left:i-a.left,top:r-a.top}}function li(e,t,n,i,r){return i||(i=Z(e.doc,t.line)),ai(e,i,Un(e,i,t.ch,r),n)}function ci(e,t,n,i,r,o){function a(t,a){var s=Kn(e,r,t,a?"right":"left",o);return a?s.left=s.right:s.right=s.left,ai(e,i,s,n)}function s(e,t,n){var i=l[t],r=1==i.level;return a(n?e-1:e,r!=n)}i=i||Z(e.doc,t.line),r||(r=Gn(e,i));var l=E(i,e.doc.direction),c=t.ch,u=t.sticky;if(c>=i.text.length?(c=i.text.length,u="before"):0>=c&&(c=0,u="after"),!l)return a("before"==u?c-1:c,"before"==u);var d=T(l,c,u),h=el,f=s(c,d,"before"==u);return null!=h&&(f.other=s(c,h,"before"!=u)),f}function ui(e,t){var n=0;t=pt(e.doc,t),e.options.lineWrapping||(n=xi(e.display)*t.ch);var i=Z(e.doc,t.line),r=nn(i)+Pn(e.display);return{left:n,right:n,top:r,bottom:r+i.height}}function di(e,t,n,i,r){var o=st(e,t,n);return o.xRel=r,i&&(o.outside=i),o}function hi(e,t,n){var i=e.doc;if(n+=e.display.viewOffset,0>n)return di(i.first,0,null,-1,-1);var r=rt(i,n),o=i.first+i.size-1;if(r>o)return di(i.first+i.size-1,Z(i,o).text.length,null,1,1);0>t&&(t=0);for(var a=Z(i,r);;){var s=mi(e,a,r,t,n),l=Jt(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var c=l.find(1);if(c.line==r)return c;a=Z(i,r=c.line)}}function fi(e,t,n,i){i-=oi(t);var r=t.text.length,o=$(function(t){return Kn(e,n,t-1).bottom<=i},r,0);return r=$(function(t){return Kn(e,n,t).top>i},o,r),{begin:o,end:r}}function pi(e,t,n,i){n||(n=Gn(e,t));var r=ai(e,t,Kn(e,n,i),"line").top;return fi(e,t,n,r)}function gi(e,t,n,i){return e.bottom<=n?!1:e.top>n?!0:(i?e.left:e.right)>t}function mi(e,t,n,i,r){r-=nn(t);var o=Gn(e,t),a=oi(t),s=0,l=t.text.length,c=!0,u=E(t,e.doc.direction);if(u){var d=(e.options.lineWrapping?yi:vi)(e,t,n,o,u,i,r);c=1!=d.level,s=c?d.from:d.to-1,l=c?d.to:d.from-1}var h,f,p=null,g=null,m=$(function(t){var n=Kn(e,o,t);return n.top+=a,n.bottom+=a,gi(n,i,r,!1)?(n.top<=r&&n.left<=i&&(p=t,g=n),!0):!1},s,l),v=!1;if(g){var y=i-g.left<g.right-i,b=y==c;m=p+(b?0:1),f=b?"after":"before",h=y?g.left:g.right}else{c||m!=l&&m!=s||m++,f=0==m?"after":m==t.text.length?"before":Kn(e,o,m-(c?1:0)).bottom+a<=r==c?"after":"before";var x=ci(e,st(n,m,f),"line",t,o);h=x.left,v=r<x.top?-1:r>=x.bottom?1:0}return m=_(t.text,m,1),di(n,m,f,v,i-h)}function vi(e,t,n,i,r,o,a){var s=$(function(s){var l=r[s],c=1!=l.level;return gi(ci(e,st(n,c?l.to:l.from,c?"before":"after"),"line",t,i),o,a,!0)},0,r.length-1),l=r[s];if(s>0){var c=1!=l.level,u=ci(e,st(n,c?l.from:l.to,c?"after":"before"),"line",t,i);gi(u,o,a,!0)&&u.top>a&&(l=r[s-1])}return l}function yi(e,t,n,i,r,o,a){var s=fi(e,t,i,a),l=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,d=null,h=0;h<r.length;h++){var f=r[h];if(!(f.from>=c||f.to<=l)){var p=1!=f.level,g=Kn(e,i,p?Math.min(c,f.to)-1:Math.max(l,f.from)).right,m=o>g?o-g+1e9:g-o;(!u||d>m)&&(u=f,d=m)}}return u||(u=r[r.length-1]),u.from<l&&(u={from:l,to:u.to,level:u.level}),u.to>c&&(u={from:u.from,to:c,level:u.level}),u}function bi(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==bl){bl=i("pre",null,"CodeMirror-line-like");for(var r=0;49>r;++r)bl.appendChild(document.createTextNode("x")),bl.appendChild(i("br"));bl.appendChild(document.createTextNode("x"))}n(e.measure,bl);var o=bl.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function xi(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=i("span","xxxxxxxxxx"),r=i("pre",[t],"CodeMirror-line-like");n(e.measure,r);var o=t.getBoundingClientRect(),a=(o.right-o.left)/10;return a>2&&(e.cachedCharWidth=a),a||10}function wi(e){for(var t=e.display,n={},i={},r=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=e.display.gutterSpecs[a].className;n[s]=o.offsetLeft+o.clientLeft+r,i[s]=o.clientWidth}return{fixedPos:ki(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:i,wrapperWidth:t.wrapper.clientWidth}}function ki(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function Ci(e){var t=bi(e.display),n=e.options.lineWrapping,i=n&&Math.max(5,e.display.scroller.clientWidth/xi(e.display)-3);return function(r){if(en(e.doc,r))return 0;var o=0;if(r.widgets)for(var a=0;a<r.widgets.length;a++)r.widgets[a].height&&(o+=r.widgets[a].height);return n?o+(Math.ceil(r.text.length/i)||1)*t:o+t}}function _i(e){var t=e.doc,n=Ci(e);t.iter(function(e){var t=n(e);t!=e.height&&nt(e,t)})}function $i(e,t,n,i){var r=e.display;if(!n&&"true"==B(t).getAttribute("cm-not-content"))return null;var o,a,s=r.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,a=t.clientY-s.top}catch(t){return null}var l,c=hi(e,o,a);if(i&&c.xRel>0&&(l=Z(e.doc,c.line).text).length==c.ch){var u=d(l,l.length,e.options.tabSize)-l.length;c=st(c.line,Math.max(0,Math.round((o-Hn(e.display).left)/xi(e.display))-u))}return c}function Si(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var n=e.display.view,i=0;i<n.length;i++)if(t-=n[i].size,0>t)return i}function Ti(e,t,n,i){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),i||(i=0);var r=e.display;if(i&&n<r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>t)&&(r.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=r.viewTo)vl&&Yt(e.doc,t)<r.viewTo&&Mi(e);else if(n<=r.viewFrom)vl&&Zt(e.doc,n+i)>r.viewFrom?Mi(e):(r.viewFrom+=i,r.viewTo+=i);else if(t<=r.viewFrom&&n>=r.viewTo)Mi(e);else if(t<=r.viewFrom){var o=Ai(e,n,n+i,1);o?(r.view=r.view.slice(o.index),r.viewFrom=o.lineN,r.viewTo+=i):Mi(e)}else if(n>=r.viewTo){var a=Ai(e,t,t,-1);a?(r.view=r.view.slice(0,a.index),r.viewTo=a.lineN):Mi(e)}else{var s=Ai(e,t,t,-1),l=Ai(e,n,n+i,1);s&&l?(r.view=r.view.slice(0,s.index).concat(vn(e,s.lineN,l.lineN)).concat(r.view.slice(l.index)),r.viewTo+=i):Mi(e)}var c=r.externalMeasured;c&&(n<c.lineN?c.lineN+=i:t<c.lineN+c.size&&(r.externalMeasured=null))}function Ei(e,t,n){e.curOp.viewChanged=!0;var i=e.display,r=e.display.externalMeasured;if(r&&t>=r.lineN&&t<r.lineN+r.size&&(i.externalMeasured=null),!(t<i.viewFrom||t>=i.viewTo)){var o=i.view[Si(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==h(a,n)&&a.push(n)}}}function Mi(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Ai(e,t,n,i){var r,o=Si(e,t),a=e.display.view;if(!vl||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=e.display.viewFrom,l=0;o>l;l++)s+=a[l].size;if(s!=t){if(i>0){if(o==a.length-1)return null;r=s+a[o].size-t,o++}else r=s-t;t+=r,n+=r}for(;Yt(e.doc,n)!=n;){if(o==(0>i?0:a.length-1))return null;n+=i*a[o-(0>i?1:0)].size,o+=i}return{index:o,lineN:n}}function Li(e,t,n){var i=e.display,r=i.view;0==r.length||t>=i.viewTo||n<=i.viewFrom?(i.view=vn(e,t,n),i.viewFrom=t):(i.viewFrom>t?i.view=vn(e,t,i.viewFrom).concat(i.view):i.viewFrom<t&&(i.view=i.view.slice(Si(e,t))),i.viewFrom=t,i.viewTo<n?i.view=i.view.concat(vn(e,i.viewTo,n)):i.viewTo>n&&(i.view=i.view.slice(0,Si(e,n)))),i.viewTo=n}function Di(e){for(var t=e.display.view,n=0,i=0;i<t.length;i++){var r=t[i];r.hidden||r.node&&!r.changes||++n}return n}function Ni(e){e.display.input.showSelection(e.display.input.prepareSelection())}function ji(e,t){void 0===t&&(t=!0);for(var n=e.doc,i={},r=i.cursors=document.createDocumentFragment(),o=i.selection=document.createDocumentFragment(),a=0;a<n.sel.ranges.length;a++)if(t||a!=n.sel.primIndex){var s=n.sel.ranges[a];if(!(s.from().line>=e.display.viewTo||s.to().line<e.display.viewFrom)){var l=s.empty();(l||e.options.showCursorWhenSelecting)&&Ii(e,s.head,r),l||Pi(e,s,o)}}return i}function Ii(e,t,n){var r=ci(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),o=n.appendChild(i("div"," ","CodeMirror-cursor"));if(o.style.left=r.left+"px",o.style.top=r.top+"px",o.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var a=n.appendChild(i("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));a.style.display="",a.style.left=r.other.left+"px",a.style.top=r.other.top+"px",a.style.height=.85*(r.other.bottom-r.other.top)+"px"}}function Oi(e,t){return e.top-t.top||e.left-t.left}function Pi(e,t,n){function r(e,t,n,r){0>t&&(t=0),t=Math.round(t),r=Math.round(r),l.appendChild(i("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==n?d-e:n)+"px;\n height: "+(r-t)+"px"))}function o(t,n,i){function o(n,i){return li(e,st(t,n),"div",f,i)}function a(t,n,i){var r=pi(e,f,null,t),a="ltr"==n==("after"==i)?"left":"right",s="after"==i?r.begin:r.end-(/\s/.test(f.text.charAt(r.end-1))?2:1);return o(s,a)[a]}var l,c,f=Z(s,t),p=f.text.length,g=E(f,s.direction);return S(g,n||0,null==i?p:i,function(e,t,s,f){var m="ltr"==s,v=o(e,m?"left":"right"),y=o(t-1,m?"right":"left"),b=null==n&&0==e,x=null==i&&t==p,w=0==f,k=!g||f==g.length-1;if(y.top-v.top<=3){var C=(h?b:x)&&w,_=(h?x:b)&&k,$=C?u:(m?v:y).left,S=_?d:(m?y:v).right;r($,v.top,S-$,v.bottom)}else{var T,E,M,A;m?(T=h&&b&&w?u:v.left,E=h?d:a(e,s,"before"),M=h?u:a(t,s,"after"),A=h&&x&&k?d:y.right):(T=h?a(e,s,"before"):u,E=!h&&b&&w?d:v.right,M=!h&&x&&k?u:y.left,A=h?a(t,s,"after"):d),r(T,v.top,E-T,v.bottom),v.bottom<y.top&&r(u,v.bottom,null,y.top),r(M,y.top,A-M,y.bottom)}(!l||Oi(v,l)<0)&&(l=v),Oi(y,l)<0&&(l=y),(!c||Oi(v,c)<0)&&(c=v),Oi(y,c)<0&&(c=y)}),{start:l,end:c}}var a=e.display,s=e.doc,l=document.createDocumentFragment(),c=Hn(e.display),u=c.left,d=Math.max(a.sizerWidth,Vn(e)-a.sizer.offsetLeft)-c.right,h="ltr"==s.direction,f=t.from(),p=t.to();if(f.line==p.line)o(f.line,f.ch,p.ch);else{var g=Z(s,f.line),m=Z(s,p.line),v=Kt(g)==Kt(m),y=o(f.line,f.ch,v?g.text.length+1:null).end,b=o(p.line,v?0:null,p.ch).start;v&&(y.top<b.top-2?(r(y.right,y.top,null,y.bottom),r(u,b.top,b.left,b.bottom)):r(y.right,y.top,b.left-y.right,y.bottom)),y.bottom<b.top&&r(u,y.bottom,null,b.top)}n.appendChild(l)}function zi(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Hi(e){e.state.focused||(e.display.input.focus(),Vi(e))}function Bi(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,Fi(e))},100)}function Vi(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(L(e,"focus",e,t),e.state.focused=!0,s(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),_s&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),zi(e))}function Fi(e,t){e.state.delayingBlurEvent||(e.state.focused&&(L(e,"blur",e,t),e.state.focused=!1,Vs(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function Ri(e){for(var t=e.display,n=t.lineDiv.offsetTop,i=0;i<t.view.length;i++){var r=t.view[i],o=e.options.lineWrapping,a=void 0,s=0;if(!r.hidden){if(ks&&8>Cs){var l=r.node.offsetTop+r.node.offsetHeight;a=l-n,n=l}else{var c=r.node.getBoundingClientRect();a=c.bottom-c.top,!o&&r.text.firstChild&&(s=r.text.firstChild.getBoundingClientRect().right-c.left-1)}var u=r.line.height-a;if((u>.005||-.005>u)&&(nt(r.line,a),Wi(r.line),r.rest))for(var d=0;d<r.rest.length;d++)Wi(r.rest[d]);if(s>e.display.sizerWidth){var h=Math.ceil(s/xi(e.display));h>e.display.maxLineLength&&(e.display.maxLineLength=h,e.display.maxLine=r.line,e.display.maxLineChanged=!0)}}}}function Wi(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],i=n.node.parentNode;i&&(n.height=i.offsetHeight)}}function qi(e,t,n){var i=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;i=Math.floor(i-Pn(e));var r=n&&null!=n.bottom?n.bottom:i+e.wrapper.clientHeight,o=rt(t,i),a=rt(t,r);if(n&&n.ensure){var s=n.ensure.from.line,l=n.ensure.to.line;o>s?(o=s,a=rt(t,nn(Z(t,s))+e.wrapper.clientHeight)):Math.min(l,t.lastLine())>=a&&(o=rt(t,nn(Z(t,l))-e.wrapper.clientHeight),a=l)}return{from:o,to:Math.max(a,o+1)}}function Ui(e,t){if(!D(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),o=null;if(t.top+r.top<0?o=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!As){var a=i("div","",null,"position: absolute;\n top: "+(t.top-n.viewOffset-Pn(e.display))+"px;\n height: "+(t.bottom-t.top+Bn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(o),e.display.lineSpace.removeChild(a)}}}function Ji(e,t,n,i){null==i&&(i=0);var r;e.options.lineWrapping||t!=n||(t=t.ch?st(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t,n="before"==t.sticky?st(t.line,t.ch+1,"before"):t);for(var o=0;5>o;o++){var a=!1,s=ci(e,t),l=n&&n!=t?ci(e,n):s;r={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-i,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+i};var c=Ki(e,r),u=e.doc.scrollTop,d=e.doc.scrollLeft;if(null!=c.scrollTop&&(nr(e,c.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(a=!0)),null!=c.scrollLeft&&(rr(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(a=!0)),!a)break}return r}function Gi(e,t){var n=Ki(e,t);null!=n.scrollTop&&nr(e,n.scrollTop),null!=n.scrollLeft&&rr(e,n.scrollLeft)}function Ki(e,t){var n=e.display,i=bi(e.display);t.top<0&&(t.top=0);var r=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=Fn(e),a={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+zn(n),l=t.top<i,c=t.bottom>s-i;if(t.top<r)a.scrollTop=l?0:t.top;else if(t.bottom>r+o){var u=Math.min(t.top,(c?s:t.bottom)-o);u!=r&&(a.scrollTop=u)}var d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft,h=Vn(e)-(e.options.fixedGutter?n.gutters.offsetWidth:0),f=t.right-t.left>h;return f&&(t.right=t.left+h),t.left<10?a.scrollLeft=0:t.left<d?a.scrollLeft=Math.max(0,t.left-(f?0:10)):t.right>h+d-3&&(a.scrollLeft=t.right+(f?0:10)-h),a}function Xi(e,t){null!=t&&(er(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Qi(e){er(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Yi(e,t,n){(null!=t||null!=n)&&er(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function Zi(e,t){er(e),e.curOp.scrollToPos=t}function er(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=ui(e,t.from),i=ui(e,t.to);tr(e,n,i,t.margin)}}function tr(e,t,n,i){var r=Ki(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-i,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+i});Yi(e,r.scrollLeft,r.scrollTop)}function nr(e,t){Math.abs(e.doc.scrollTop-t)<2||(ys||Er(e,{top:t}),ir(e,t,!0),ys&&Er(e),wr(e,100))}function ir(e,t,n){t=Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function rr(e,t,n,i){t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),(!(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||i)&&(e.doc.scrollLeft=t,Dr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function or(e){var t=e.display,n=t.gutters.offsetWidth,i=Math.round(e.doc.height+zn(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?n:0,docHeight:i,scrollHeight:i+Bn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function ar(e,t){t||(t=or(e));var n=e.display.barWidth,i=e.display.barHeight;sr(e,t);for(var r=0;4>r&&n!=e.display.barWidth||i!=e.display.barHeight;r++)n!=e.display.barWidth&&e.options.lineWrapping&&Ri(e),sr(e,or(e)),n=e.display.barWidth,i=e.display.barHeight}function sr(e,t){var n=e.display,i=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=i.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=i.bottom)+"px",n.heightForcer.style.borderBottom=i.bottom+"px solid transparent",i.right&&i.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=i.bottom+"px",n.scrollbarFiller.style.width=i.right+"px"):n.scrollbarFiller.style.display="",i.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=i.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}function lr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Vs(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Tl[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),il(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,n){"horizontal"==n?rr(e,t):nr(e,t)},e),e.display.scrollbars.addClass&&s(e.display.wrapper,e.display.scrollbars.addClass)}function cr(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++El},yn(e.curOp)}function ur(e){var t=e.curOp;t&&xn(t,function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;dr(e)})}function dr(e){for(var t=e.ops,n=0;n<t.length;n++)hr(t[n]);for(var i=0;i<t.length;i++)fr(t[i]);for(var r=0;r<t.length;r++)pr(t[r]);for(var o=0;o<t.length;o++)gr(t[o]);for(var a=0;a<t.length;a++)mr(t[a])}function hr(e){var t=e.cm,n=t.display;Cr(t),e.updateMaxLine&&on(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Ml(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function fr(e){e.updatedDisplay=e.mustUpdate&&Sr(e.cm,e.update)}function pr(e){var t=e.cm,n=t.display;e.updatedDisplay&&Ri(t),e.barMeasure=or(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Un(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Bn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Vn(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function gr(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&rr(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var n=e.focus&&e.focus==a();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,n),(e.updatedDisplay||e.startHeight!=t.doc.height)&&ar(t,e.barMeasure),e.updatedDisplay&&Lr(t,e.barMeasure),e.selectionChanged&&zi(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),n&&Hi(e.cm)}function mr(e){var t=e.cm,n=t.display,i=t.doc;if(e.updatedDisplay&&Tr(t,e.update),null==n.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(n.wheelStartX=n.wheelStartY=null),null!=e.scrollTop&&ir(t,e.scrollTop,e.forceScroll),null!=e.scrollLeft&&rr(t,e.scrollLeft,!0,!0),e.scrollToPos){var r=Ji(t,pt(i,e.scrollToPos.from),pt(i,e.scrollToPos.to),e.scrollToPos.margin);Ui(t,r)}var o=e.maybeHiddenMarkers,a=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||L(o[s],"hide");if(a)for(var l=0;l<a.length;++l)a[l].lines.length&&L(a[l],"unhide");n.wrapper.offsetHeight&&(i.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&L(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function vr(e,t){if(e.curOp)return t();cr(e);try{return t()}finally{ur(e)}}function yr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);cr(e);try{return t.apply(e,arguments)}finally{ur(e)}}}function br(e){return function(){if(this.curOp)return e.apply(this,arguments);cr(this);try{return e.apply(this,arguments)}finally{ur(this)}}}function xr(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);cr(t);try{return e.apply(this,arguments)}finally{ur(t)}}}function wr(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,c(kr,e))}function kr(e){var t=e.doc;if(!(t.highlightFrontier>=e.display.viewTo)){var n=+new Date+e.options.workTime,i=bt(e,t.highlightFrontier),r=[];t.iter(i.line,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(i.line>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength?X(t.mode,i.state):null,l=vt(e,o,i,!0);s&&(i.state=s),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),h=0;!d&&h<a.length;++h)d=a[h]!=o.styles[h];d&&r.push(i.line),o.stateAfter=i.save(),i.nextLine()}else o.text.length<=e.options.maxHighlightLength&&xt(e,o.text,i),o.stateAfter=0==i.line%5?i.save():null,i.nextLine();return+new Date>n?(wr(e,e.options.workDelay),!0):void 0}),t.highlightFrontier=i.line,t.modeFrontier=Math.max(t.modeFrontier,i.line),r.length&&vr(e,function(){for(var t=0;t<r.length;t++)Ei(e,r[t],"text")})}}function Cr(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Bn(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Bn(e)+"px",t.scrollbarsClipped=!0)}function _r(e){if(e.hasFocus())return null;var t=a();if(!t||!o(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var i=window.getSelection();i.anchorNode&&i.extend&&o(e.display.lineDiv,i.anchorNode)&&(n.anchorNode=i.anchorNode,n.anchorOffset=i.anchorOffset,n.focusNode=i.focusNode,n.focusOffset=i.focusOffset)}return n}function $r(e){if(e&&e.activeElt&&e.activeElt!=a()&&(e.activeElt.focus(),e.anchorNode&&o(document.body,e.anchorNode)&&o(document.body,e.focusNode))){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}function Sr(e,n){var i=e.display,r=e.doc;if(n.editorIsHidden)return Mi(e),!1;if(!n.force&&n.visible.from>=i.viewFrom&&n.visible.to<=i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo)&&i.renderedView==i.view&&0==Di(e))return!1;Nr(e)&&(Mi(e),n.dims=wi(e));var o=r.first+r.size,a=Math.max(n.visible.from-e.options.viewportMargin,r.first),s=Math.min(o,n.visible.to+e.options.viewportMargin);i.viewFrom<a&&a-i.viewFrom<20&&(a=Math.max(r.first,i.viewFrom)),i.viewTo>s&&i.viewTo-s<20&&(s=Math.min(o,i.viewTo)),vl&&(a=Yt(e.doc,a),s=Zt(e.doc,s));var l=a!=i.viewFrom||s!=i.viewTo||i.lastWrapHeight!=n.wrapperHeight||i.lastWrapWidth!=n.wrapperWidth;Li(e,a,s),i.viewOffset=nn(Z(e.doc,i.viewFrom)),e.display.mover.style.top=i.viewOffset+"px";var c=Di(e);if(!l&&0==c&&!n.force&&i.renderedView==i.view&&(null==i.updateLineNumbers||i.updateLineNumbers>=i.viewTo))return!1;var u=_r(e);return c>4&&(i.lineDiv.style.display="none"),Mr(e,i.updateLineNumbers,n.dims),c>4&&(i.lineDiv.style.display=""),i.renderedView=i.view,$r(u),t(i.cursorDiv),t(i.selectionDiv),i.gutters.style.height=i.sizer.style.minHeight=0,l&&(i.lastWrapHeight=n.wrapperHeight,i.lastWrapWidth=n.wrapperWidth,wr(e,400)),i.updateLineNumbers=null,!0}function Tr(e,t){for(var n=t.viewport,i=!0;(i&&e.options.lineWrapping&&t.oldDisplayWidth!=Vn(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+zn(e.display)-Fn(e),n.top)}),t.visible=qi(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Sr(e,t);i=!1){Ri(e);var r=or(e);Ni(e),ar(e,r),Lr(e,r),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 Er(e,t){var n=new Ml(e,t);if(Sr(e,n)){Ri(e),Tr(e,n);var i=or(e);Ni(e),ar(e,i),Lr(e,i),n.finish()}}function Mr(e,n,i){function r(t){var n=t.nextSibling;return _s&&js&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var o=e.display,a=e.options.lineNumbers,s=o.lineDiv,l=s.firstChild,c=o.view,u=o.viewFrom,d=0;d<c.length;d++){var f=c[d];if(f.hidden);else if(f.node&&f.node.parentNode==s){for(;l!=f.node;)l=r(l);var p=a&&null!=n&&u>=n&&f.lineNumber;f.changes&&(h(f.changes,"gutter")>-1&&(p=!1),Cn(e,f,u,i)),p&&(t(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(at(e.options,u)))),l=f.node.nextSibling}else{var g=Ln(e,f,u,i);s.insertBefore(g,l)}u+=f.size}for(;l;)l=r(l)}function Ar(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Lr(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+Bn(e)+"px"}function Dr(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var i=ki(t)-t.scroller.scrollLeft+e.doc.scrollLeft,r=t.gutters.offsetWidth,o=i+"px",a=0;a<n.length;a++)if(!n[a].hidden){e.options.fixedGutter&&(n[a].gutter&&(n[a].gutter.style.left=o),n[a].gutterBackground&&(n[a].gutterBackground.style.left=o));var s=n[a].alignable;if(s)for(var l=0;l<s.length;l++)s[l].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=i+r+"px")}}function Nr(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=at(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var o=r.measure.appendChild(i("div",[i("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),a=o.firstChild.offsetWidth,s=o.offsetWidth-a;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(a,r.lineGutter.offsetWidth-s)+1,r.lineNumWidth=r.lineNumInnerWidth+s,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",Ar(e.display),!0}return!1}function jr(e,t){for(var n=[],i=!1,r=0;r<e.length;r++){var o=e[r],a=null;if("string"!=typeof o&&(a=o.style,o=o.className),"CodeMirror-linenumbers"==o){if(!t)continue;i=!0}n.push({className:o,style:a})}return t&&!i&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function Ir(e){var n=e.gutters,r=e.gutterSpecs;t(n),e.lineGutter=null;for(var o=0;o<r.length;++o){var a=r[o],s=a.className,l=a.style,c=n.appendChild(i("div",null,"CodeMirror-gutter "+s));l&&(c.style.cssText=l),"CodeMirror-linenumbers"==s&&(e.lineGutter=c,c.style.width=(e.lineNumWidth||1)+"px")}n.style.display=r.length?"":"none",Ar(e)}function Or(e){Ir(e.display),Ti(e),Dr(e)}function Pr(e,t,n,o){var a=this;this.input=n,a.scrollbarFiller=i("div",null,"CodeMirror-scrollbar-filler"),a.scrollbarFiller.setAttribute("cm-not-content","true"),a.gutterFiller=i("div",null,"CodeMirror-gutter-filler"),a.gutterFiller.setAttribute("cm-not-content","true"),a.lineDiv=r("div",null,"CodeMirror-code"),a.selectionDiv=i("div",null,null,"position: relative; z-index: 1"),a.cursorDiv=i("div",null,"CodeMirror-cursors"),a.measure=i("div",null,"CodeMirror-measure"),a.lineMeasure=i("div",null,"CodeMirror-measure"),a.lineSpace=r("div",[a.measure,a.lineMeasure,a.selectionDiv,a.cursorDiv,a.lineDiv],null,"position: relative; outline: none");var s=r("div",[a.lineSpace],"CodeMirror-lines");a.mover=i("div",[s],null,"position: relative"),a.sizer=i("div",[a.mover],"CodeMirror-sizer"),a.sizerWidth=null,a.heightForcer=i("div",null,null,"position: absolute; height: "+Us+"px; width: 1px;"),a.gutters=i("div",null,"CodeMirror-gutters"),a.lineGutter=null,a.scroller=i("div",[a.sizer,a.heightForcer,a.gutters],"CodeMirror-scroll"),a.scroller.setAttribute("tabIndex","-1"),a.wrapper=i("div",[a.scrollbarFiller,a.gutterFiller,a.scroller],"CodeMirror"),ks&&8>Cs&&(a.gutters.style.zIndex=-1,a.scroller.style.paddingRight=0),_s||ys&&Ns||(a.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(a.wrapper):e(a.wrapper)),a.viewFrom=a.viewTo=t.first,a.reportedViewFrom=a.reportedViewTo=t.first,a.view=[],a.renderedView=null,a.externalMeasured=null,a.viewOffset=0,a.lastWrapHeight=a.lastWrapWidth=0,a.updateLineNumbers=null,a.nativeBarWidth=a.barHeight=a.barWidth=0,a.scrollbarsClipped=!1,a.lineNumWidth=a.lineNumInnerWidth=a.lineNumChars=null,a.alignWidgets=!1,a.cachedCharWidth=a.cachedTextHeight=a.cachedPaddingH=null,a.maxLine=null,a.maxLineLength=0,a.maxLineChanged=!1,a.wheelDX=a.wheelDY=a.wheelStartX=a.wheelStartY=null,a.shift=!1,a.selForContextMenu=null,a.activeTouch=null,a.gutterSpecs=jr(o.gutters,o.lineNumbers),Ir(a),n.init(a)}function zr(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}}function Hr(e){var t=zr(e);return t.x*=Ll,t.y*=Ll,t}function Br(e,t){var n=zr(t),i=n.x,r=n.y,o=e.display,a=o.scroller,s=a.scrollWidth>a.clientWidth,l=a.scrollHeight>a.clientHeight;if(i&&s||r&&l){if(r&&js&&_s)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var d=0;d<u.length;d++)if(u[d].node==c){e.display.currentWheelTarget=c;break e}if(i&&!ys&&!Ts&&null!=Ll)return r&&l&&nr(e,Math.max(0,a.scrollTop+r*Ll)),rr(e,Math.max(0,a.scrollLeft+i*Ll)),(!r||r&&l)&&O(t),o.wheelStartX=null,void 0;if(r&&null!=Ll){var h=r*Ll,f=e.doc.scrollTop,p=f+o.wrapper.clientHeight;0>h?f=Math.max(0,f+h-50):p=Math.min(e.doc.height,p+h+50),Er(e,{top:f,bottom:p})}20>Al&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=i,o.wheelDY=r,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(Ll=(Ll*Al+n)/(Al+1),++Al)}},200)):(o.wheelDX+=i,o.wheelDY+=r))}}function Vr(e,t,n){var i=e&&e.options.selectionsMayTouch,r=t[n];t.sort(function(e,t){return lt(e.from(),t.from())}),n=h(t,r);for(var o=1;o<t.length;o++){var a=t[o],s=t[o-1],l=lt(s.to(),a.from());if(i&&!a.empty()?l>0:l>=0){var c=ht(s.from(),a.from()),u=dt(s.to(),a.to()),d=s.empty()?a.from()==a.head:s.from()==s.head;n>=o&&--n,t.splice(--o,2,new Nl(d?u:c,d?c:u))}}return new Dl(t,n) |
| 3 | }function Fr(e,t){return new Dl([new Nl(e,t||e)],0)}function Rr(e){return e.text?st(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Wr(e,t){if(lt(e,t.from)<0)return e;if(lt(e,t.to)<=0)return Rr(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,i=e.ch;return e.line==t.to.line&&(i+=Rr(t).ch-t.to.ch),st(n,i)}function qr(e,t){for(var n=[],i=0;i<e.sel.ranges.length;i++){var r=e.sel.ranges[i];n.push(new Nl(Wr(r.anchor,t),Wr(r.head,t)))}return Vr(e.cm,n,e.sel.primIndex)}function Ur(e,t,n){return e.line==t.line?st(n.line,e.ch-t.ch+n.ch):st(n.line+(e.line-t.line),e.ch)}function Jr(e,t,n){for(var i=[],r=st(e.first,0),o=r,a=0;a<t.length;a++){var s=t[a],l=Ur(s.from,r,o),c=Ur(Rr(s),r,o);if(r=s.to,o=c,"around"==n){var u=e.sel.ranges[a],d=lt(u.head,u.anchor)<0;i[a]=new Nl(d?c:l,d?l:c)}else i[a]=new Nl(l,l)}return new Dl(i,e.sel.primIndex)}function Gr(e){e.doc.mode=G(e.options,e.doc.modeOption),Kr(e)}function Kr(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,wr(e,100),e.state.modeGen++,e.curOp&&Ti(e)}function Xr(e,t){return 0==t.from.ch&&0==t.to.ch&&""==g(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Qr(e,t,n,i){function r(e){return n?n[e]:null}function o(e,n,r){an(e,n,r,i),wn(e,"change",e,t)}function a(e,t){for(var n=[],o=e;t>o;++o)n.push(new yl(c[o],r(o),i));return n}var s=t.from,l=t.to,c=t.text,u=Z(e,s.line),d=Z(e,l.line),h=g(c),f=r(c.length-1),p=l.line-s.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Xr(e,t)){var m=a(0,c.length-1);o(d,d.text,f),p&&e.remove(s.line,p),m.length&&e.insert(s.line,m)}else if(u==d)if(1==c.length)o(u,u.text.slice(0,s.ch)+h+u.text.slice(l.ch),f);else{var v=a(1,c.length-1);v.push(new yl(h+u.text.slice(l.ch),f,i)),o(u,u.text.slice(0,s.ch)+c[0],r(0)),e.insert(s.line+1,v)}else if(1==c.length)o(u,u.text.slice(0,s.ch)+c[0]+d.text.slice(l.ch),r(0)),e.remove(s.line+1,p);else{o(u,u.text.slice(0,s.ch)+c[0],r(0)),o(d,h+d.text.slice(l.ch),f);var y=a(1,c.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,y)}wn(e,"change",e,t)}function Yr(e,t,n){function i(e,r,o){if(e.linked)for(var a=0;a<e.linked.length;++a){var s=e.linked[a];if(s.doc!=r){var l=o&&s.sharedHist;(!n||l)&&(t(s.doc,l),i(s.doc,e,l))}}}i(e,null,!0)}function Zr(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,_i(e),Gr(e),eo(e),e.options.lineWrapping||on(e),e.options.mode=t.modeOption,Ti(e)}function eo(e){("rtl"==e.doc.direction?s:Vs)(e.display.lineDiv,"CodeMirror-rtl")}function to(e){vr(e,function(){eo(e),Ti(e)})}function no(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function io(e,t){var n={from:ut(t.from),to:Rr(t),text:et(e,t.from,t.to)};return uo(e,n,t.from.line,t.to.line+1),Yr(e,function(e){return uo(e,n,t.from.line,t.to.line+1)},!0),n}function ro(e){for(;e.length;){var t=g(e);if(!t.ranges)break;e.pop()}}function oo(e,t){return t?(ro(e.done),g(e.done)):e.done.length&&!g(e.done).ranges?g(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}function ao(e,t,n,i){var r=e.history;r.undone.length=0;var o,a,s=+new Date;if((r.lastOp==i||r.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&r.lastModTime>s-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=oo(r,r.lastOp==i)))a=g(o.changes),0==lt(t.from,t.to)&&0==lt(t.from,a.to)?a.to=Rr(t):o.changes.push(io(e,t));else{var l=g(r.done);for(l&&l.ranges||co(e.sel,r.done),o={changes:[io(e,t)],generation:r.generation},r.done.push(o);r.done.length>r.undoDepth;)r.done.shift(),r.done[0].ranges||r.done.shift()}r.done.push(n),r.generation=++r.maxGeneration,r.lastModTime=r.lastSelTime=s,r.lastOp=r.lastSelOp=i,r.lastOrigin=r.lastSelOrigin=t.origin,a||L(e,"historyAdded")}function so(e,t,n,i){var r=t.charAt(0);return"*"==r||"+"==r&&n.ranges.length==i.ranges.length&&n.somethingSelected()==i.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function lo(e,t,n,i){var r=e.history,o=i&&i.origin;n==r.lastSelOp||o&&r.lastSelOrigin==o&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==o||so(e,o,g(r.done),t))?r.done[r.done.length-1]=t:co(t,r.done),r.lastSelTime=+new Date,r.lastSelOrigin=o,r.lastSelOp=n,i&&i.clearRedo!==!1&&ro(r.undone)}function co(e,t){var n=g(t);n&&n.ranges&&n.equals(e)||t.push(e)}function uo(e,t,n,i){var r=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,i),function(n){n.markedSpans&&((r||(r=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function ho(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t||(t=e.slice(0,n)):t&&t.push(e[n]);return t?t.length?t:null:e}function fo(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var i=[],r=0;r<t.text.length;++r)i.push(ho(n[r]));return i}function po(e,t){var n=fo(e,t),i=Ot(e,t);if(!n)return i;if(!i)return n;for(var r=0;r<n.length;++r){var o=n[r],a=i[r];if(o&&a)e:for(var s=0;s<a.length;++s){for(var l=a[s],c=0;c<o.length;++c)if(o[c].marker==l.marker)continue e;o.push(l)}else a&&(n[r]=a)}return n}function go(e,t,n){for(var i=[],r=0;r<e.length;++r){var o=e[r];if(o.ranges)i.push(n?Dl.prototype.deepCopy.call(o):o);else{var a=o.changes,s=[];i.push({changes:s});for(var l=0;l<a.length;++l){var c=a[l],u=void 0;if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var d in c)(u=d.match(/^spans_(\d+)$/))&&h(t,Number(u[1]))>-1&&(g(s)[d]=c[d],delete c[d])}}}return i}function mo(e,t,n,i){if(i){var r=e.anchor;if(n){var o=lt(t,r)<0;o!=lt(n,r)<0?(r=t,t=n):o!=lt(t,n)<0&&(t=n)}return new Nl(r,t)}return new Nl(n||t,t)}function vo(e,t,n,i,r){null==r&&(r=e.cm&&(e.cm.display.shift||e.extend)),Co(e,new Dl([mo(e.sel.primary(),t,n,r)],0),i)}function yo(e,t,n){for(var i=[],r=e.cm&&(e.cm.display.shift||e.extend),o=0;o<e.sel.ranges.length;o++)i[o]=mo(e.sel.ranges[o],t[o],null,r);var a=Vr(e.cm,i,e.sel.primIndex);Co(e,a,n)}function bo(e,t,n,i){var r=e.sel.ranges.slice(0);r[t]=n,Co(e,Vr(e.cm,r,e.sel.primIndex),i)}function xo(e,t,n,i){Co(e,Fr(t,n),i)}function wo(e,t,n){var i={ranges:t.ranges,update:function(t){var n=this;this.ranges=[];for(var i=0;i<t.length;i++)n.ranges[i]=new Nl(pt(e,t[i].anchor),pt(e,t[i].head))},origin:n&&n.origin};return L(e,"beforeSelectionChange",e,i),e.cm&&L(e.cm,"beforeSelectionChange",e.cm,i),i.ranges!=t.ranges?Vr(e.cm,i.ranges,i.ranges.length-1):t}function ko(e,t,n){var i=e.history.done,r=g(i);r&&r.ranges?(i[i.length-1]=t,_o(e,t,n)):Co(e,t,n)}function Co(e,t,n){_o(e,t,n),lo(e,e.sel,e.cm?e.cm.curOp.id:0/0,n)}function _o(e,t,n){(j(e,"beforeSelectionChange")||e.cm&&j(e.cm,"beforeSelectionChange"))&&(t=wo(e,t,n));var i=n&&n.bias||(lt(t.primary().head,e.sel.primary().head)<0?-1:1);$o(e,To(e,t,i,!0)),n&&n.scroll===!1||!e.cm||Qi(e.cm)}function $o(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,N(e.cm)),wn(e,"cursorActivity",e))}function So(e){$o(e,To(e,e.sel,null,!1))}function To(e,t,n,i){for(var r,o=0;o<t.ranges.length;o++){var a=t.ranges[o],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],l=Mo(e,a.anchor,s&&s.anchor,n,i),c=Mo(e,a.head,s&&s.head,n,i);(r||l!=a.anchor||c!=a.head)&&(r||(r=t.ranges.slice(0,o)),r[o]=new Nl(l,c))}return r?Vr(e.cm,r,t.primIndex):t}function Eo(e,t,n,i,r){var o=Z(e,t.line);if(o.markedSpans)for(var a=0;a<o.markedSpans.length;++a){var s=o.markedSpans[a],l=s.marker,c="selectLeft"in l?!l.selectLeft:l.inclusiveLeft,u="selectRight"in l?!l.selectRight:l.inclusiveRight;if((null==s.from||(c?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(u?s.to>=t.ch:s.to>t.ch))){if(r&&(L(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!l.atomic)continue;if(n){var d=l.find(0>i?1:-1),h=void 0;if((0>i?u:c)&&(d=Ao(e,d,-i,d&&d.line==t.line?o:null)),d&&d.line==t.line&&(h=lt(d,n))&&(0>i?0>h:h>0))return Eo(e,d,t,i,r)}var f=l.find(0>i?-1:1);return(0>i?c:u)&&(f=Ao(e,f,i,f.line==t.line?o:null)),f?Eo(e,f,t,i,r):null}}return t}function Mo(e,t,n,i,r){var o=i||1,a=Eo(e,t,n,o,r)||!r&&Eo(e,t,n,o,!0)||Eo(e,t,n,-o,r)||!r&&Eo(e,t,n,-o,!0);return a?a:(e.cantEdit=!0,st(e.first,0))}function Ao(e,t,n,i){return 0>n&&0==t.ch?t.line>e.first?pt(e,st(t.line-1)):null:n>0&&t.ch==(i||Z(e,t.line)).text.length?t.line<e.first+e.size-1?st(t.line+1,0):null:new st(t.line,t.ch+n)}function Lo(e){e.setSelection(st(e.firstLine(),0),st(e.lastLine()),Gs)}function Do(e,t,n){var i={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return i.canceled=!0}};return n&&(i.update=function(t,n,r,o){t&&(i.from=pt(e,t)),n&&(i.to=pt(e,n)),r&&(i.text=r),void 0!==o&&(i.origin=o)}),L(e,"beforeChange",e,i),e.cm&&L(e.cm,"beforeChange",e.cm,i),i.canceled?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:i.from,to:i.to,text:i.text,origin:i.origin}}function No(e,t,n){if(e.cm){if(!e.cm.curOp)return yr(e.cm,No)(e,t,n);if(e.cm.state.suppressEdits)return}if(!(j(e,"beforeChange")||e.cm&&j(e.cm,"beforeChange"))||(t=Do(e,t,!0))){var i=ml&&!n&&zt(e,t.from,t.to);if(i)for(var r=i.length-1;r>=0;--r)jo(e,{from:i[r].from,to:i[r].to,text:r?[""]:t.text,origin:t.origin});else jo(e,t)}}function jo(e,t){if(1!=t.text.length||""!=t.text[0]||0!=lt(t.from,t.to)){var n=qr(e,t);ao(e,t,n,e.cm?e.cm.curOp.id:0/0),Po(e,t,n,Ot(e,t));var i=[];Yr(e,function(e,n){n||-1!=h(i,e.history)||(Fo(e.history,t),i.push(e.history)),Po(e,t,null,Ot(e,t))})}}function Io(e,t,n){var i=e.cm&&e.cm.state.suppressEdits;if(!i||n){for(var r,o=e.history,a=e.sel,s="undo"==t?o.done:o.undone,l="undo"==t?o.undone:o.done,c=0;c<s.length&&(r=s[c],n?!r.ranges||r.equals(e.sel):r.ranges);c++);if(c!=s.length){for(o.lastOrigin=o.lastSelOrigin=null;;){if(r=s.pop(),!r.ranges){if(i)return s.push(r),void 0;break}if(co(r,l),n&&!r.equals(e.sel))return Co(e,r,{clearRedo:!1}),void 0;a=r}var u=[];co(a,l),l.push({changes:u,generation:o.generation}),o.generation=r.generation||++o.maxGeneration;for(var d=j(e,"beforeChange")||e.cm&&j(e.cm,"beforeChange"),f=function(n){var i=r.changes[n];if(i.origin=t,d&&!Do(e,i,!1))return s.length=0,{};u.push(io(e,i));var o=n?qr(e,i):g(s);Po(e,i,o,po(e,i)),!n&&e.cm&&e.cm.scrollIntoView({from:i.from,to:Rr(i)});var a=[];Yr(e,function(e,t){t||-1!=h(a,e.history)||(Fo(e.history,i),a.push(e.history)),Po(e,i,null,po(e,i))})},p=r.changes.length-1;p>=0;--p){var m=f(p);if(m)return m.v}}}}function Oo(e,t){if(0!=t&&(e.first+=t,e.sel=new Dl(m(e.sel.ranges,function(e){return new Nl(st(e.anchor.line+t,e.anchor.ch),st(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Ti(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,i=n.viewFrom;i<n.viewTo;i++)Ei(e.cm,i,"gutter")}}function Po(e,t,n,i){if(e.cm&&!e.cm.curOp)return yr(e.cm,Po)(e,t,n,i);if(t.to.line<e.first)return Oo(e,t.text.length-1-(t.to.line-t.from.line)),void 0;if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var r=t.text.length-1-(e.first-t.from.line);Oo(e,r),t={from:st(e.first,0),to:st(t.to.line+r,t.to.ch),text:[g(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:st(o,Z(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=et(e,t.from,t.to),n||(n=qr(e,t)),e.cm?zo(e.cm,t,i):Qr(e,t,i),_o(e,n,Gs),e.cantEdit&&Mo(e,st(e.firstLine(),0))&&(e.cantEdit=!1)}}function zo(e,t,n){var i=e.doc,r=e.display,o=t.from,a=t.to,s=!1,l=o.line;e.options.lineWrapping||(l=it(Kt(Z(i,o.line))),i.iter(l,a.line+1,function(e){return e==r.maxLine?(s=!0,!0):void 0})),i.sel.contains(t.from,t.to)>-1&&N(e),Qr(i,t,n,Ci(e)),e.options.lineWrapping||(i.iter(l,o.line+t.text.length,function(e){var t=rn(e);t>r.maxLineLength&&(r.maxLine=e,r.maxLineLength=t,r.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),Tt(i,o.line),wr(e,400);var c=t.text.length-(a.line-o.line)-1;t.full?Ti(e):o.line!=a.line||1!=t.text.length||Xr(e.doc,t)?Ti(e,o.line,a.line+1,c):Ei(e,o.line,"text");var u=j(e,"changes"),d=j(e,"change");if(d||u){var h={from:o,to:a,text:t.text,removed:t.removed,origin:t.origin};d&&wn(e,"change",e,h),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Ho(e,t,n,i,r){var o;i||(i=n),lt(i,n)<0&&(o=[i,n],n=o[0],i=o[1]),"string"==typeof t&&(t=e.splitLines(t)),No(e,{from:n,to:i,text:t,origin:r})}function Bo(e,t,n,i){n<e.line?e.line+=i:t<e.line&&(e.line=t,e.ch=0)}function Vo(e,t,n,i){for(var r=0;r<e.length;++r){var o=e[r],a=!0;if(o.ranges){o.copied||(o=e[r]=o.deepCopy(),o.copied=!0);for(var s=0;s<o.ranges.length;s++)Bo(o.ranges[s].anchor,t,n,i),Bo(o.ranges[s].head,t,n,i)}else{for(var l=0;l<o.changes.length;++l){var c=o.changes[l];if(n<c.from.line)c.from=st(c.from.line+i,c.from.ch),c.to=st(c.to.line+i,c.to.ch);else if(t<=c.to.line){a=!1;break}}a||(e.splice(0,r+1),r=0)}}}function Fo(e,t){var n=t.from.line,i=t.to.line,r=t.text.length-(i-n)-1;Vo(e.done,n,i,r),Vo(e.undone,n,i,r)}function Ro(e,t,n,i){var r=t,o=t;return"number"==typeof t?o=Z(e,ft(e,t)):r=it(t),null==r?null:(i(o,r)&&e.cm&&Ei(e.cm,r,n),o)}function Wo(e){var t=this;this.lines=e,this.parent=null;for(var n=0,i=0;i<e.length;++i)e[i].parent=t,n+=e[i].height;this.height=n}function qo(e){var t=this;this.children=e;for(var n=0,i=0,r=0;r<e.length;++r){var o=e[r];n+=o.chunkSize(),i+=o.height,o.parent=t}this.size=n,this.height=i,this.parent=null}function Uo(e,t,n){nn(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Xi(e,n)}function Jo(e,t,n,i){var r=new jl(e,n,i),o=e.cm;return o&&r.noHScroll&&(o.display.alignWidgets=!0),Ro(e,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);if(null==r.insertAt?n.push(r):n.splice(Math.min(n.length-1,Math.max(0,r.insertAt)),0,r),r.line=t,o&&!en(e,t)){var i=nn(t)<e.scrollTop;nt(t,t.height+In(r)),i&&Xi(o,r.height),o.curOp.forceUpdate=!0}return!0}),o&&wn(o,"lineWidgetAdded",o,r,"number"==typeof t?t:it(t)),r}function Go(e,t,n,i,o){if(i&&i.shared)return Ko(e,t,n,i,o);if(e.cm&&!e.cm.curOp)return yr(e.cm,Go)(e,t,n,i,o);var a=new Ol(e,o),s=lt(t,n);if(i&&u(i,a,!1),s>0||0==s&&a.clearWhenEmpty!==!1)return a;if(a.replacedWith&&(a.collapsed=!0,a.widgetNode=r("span",[a.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||a.widgetNode.setAttribute("cm-ignore-events","true"),i.insertLeft&&(a.widgetNode.insertLeft=!0)),a.collapsed){if(Gt(e,t.line,t,n,a)||t.line!=n.line&&Gt(e,n.line,t,n,a))throw new Error("Inserting collapsed marker partially overlapping an existing one");Mt()}a.addToHistory&&ao(e,{from:t,to:n,origin:"markText"},e.sel,0/0);var l,c=t.line,d=e.cm;if(e.iter(c,n.line+1,function(e){d&&a.collapsed&&!d.options.lineWrapping&&Kt(e)==d.display.maxLine&&(l=!0),a.collapsed&&c!=t.line&&nt(e,0),Nt(e,new At(a,c==t.line?t.ch:null,c==n.line?n.ch:null)),++c}),a.collapsed&&e.iter(t.line,n.line+1,function(t){en(e,t)&&nt(t,0)}),a.clearOnEnter&&il(a,"beforeCursorEnter",function(){return a.clear()}),a.readOnly&&(Et(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),a.collapsed&&(a.id=++Il,a.atomic=!0),d){if(l&&(d.curOp.updateMaxLine=!0),a.collapsed)Ti(d,t.line,n.line+1);else if(a.className||a.startStyle||a.endStyle||a.css||a.attributes||a.title)for(var h=t.line;h<=n.line;h++)Ei(d,h,"text");a.atomic&&So(d.doc),wn(d,"markerAdded",d,a)}return a}function Ko(e,t,n,i,r){i=u(i),i.shared=!1;var o=[Go(e,t,n,i,r)],a=o[0],s=i.widgetNode;return Yr(e,function(e){s&&(i.widgetNode=s.cloneNode(!0)),o.push(Go(e,pt(e,t),pt(e,n),i,r));for(var l=0;l<e.linked.length;++l)if(e.linked[l].isParent)return;a=g(o)}),new Pl(o,a)}function Xo(e){return e.findMarks(st(e.first,0),e.clipPos(st(e.lastLine())),function(e){return e.parent})}function Qo(e,t){for(var n=0;n<t.length;n++){var i=t[n],r=i.find(),o=e.clipPos(r.from),a=e.clipPos(r.to);if(lt(o,a)){var s=Go(e,o,a,i.primary,i.primary.type);i.markers.push(s),s.parent=i}}}function Yo(e){for(var t=function(t){var n=e[t],i=[n.primary.doc];Yr(n.primary.doc,function(e){return i.push(e)});for(var r=0;r<n.markers.length;r++){var o=n.markers[r];-1==h(i,o.doc)&&(o.parent=null,n.markers.splice(r--,1))}},n=0;n<e.length;n++)t(n)}function Zo(e){var t=this;if(na(t),!D(t,e)&&!On(t.display,e)){O(e),ks&&(Bl=+new Date);var n=$i(t,e,!0),i=e.dataTransfer.files;if(n&&!t.isReadOnly())if(i&&i.length&&window.FileReader&&window.File)for(var r=i.length,o=Array(r),a=0,s=function(e,i){if(!t.options.allowDropFileTypes||-1!=h(t.options.allowDropFileTypes,e.type)){var s=new FileReader;s.onload=yr(t,function(){var e=s.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[i]=e,++a==r){n=pt(t.doc,n);var l={from:n,to:n,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};No(t.doc,l),ko(t.doc,Fr(n,Rr(l)))}}),s.readAsText(e)}},l=0;r>l;++l)s(i[l],l);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20),void 0;try{var c=e.dataTransfer.getData("Text");if(c){var u;if(t.state.draggingText&&!t.state.draggingText.copy&&(u=t.listSelections()),_o(t.doc,Fr(n,n)),u)for(var d=0;d<u.length;++d)Ho(t.doc,"",u[d].anchor,u[d].head,"drag");t.replaceSelection(c,"around","paste"),t.display.input.focus()}}catch(e){}}}}function ea(e,t){if(ks&&(!e.state.draggingText||+new Date-Bl<100))return H(t),void 0;if(!D(e,t)&&!On(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!Es)){var n=i("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",Ts&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),Ts&&n.parentNode.removeChild(n)}}function ta(e,t){var r=$i(e,t);if(r){var o=document.createDocumentFragment();Ii(e,r,o),e.display.dragCursor||(e.display.dragCursor=i("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),n(e.display.dragCursor,o)}}function na(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function ia(e){if(document.getElementsByClassName){for(var t=document.getElementsByClassName("CodeMirror"),n=[],i=0;i<t.length;i++){var r=t[i].CodeMirror;r&&n.push(r)}n.length&&n[0].operation(function(){for(var t=0;t<n.length;t++)e(n[t])})}}function ra(){Vl||(oa(),Vl=!0)}function oa(){var e;il(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,ia(aa)},100))}),il(window,"blur",function(){return ia(Fi)})}function aa(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}function sa(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var n,i,r,o,a=0;a<t.length-1;a++){var s=t[a];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))i=!0;else{if(!/^s(hift)?$/i.test(s))throw new Error("Unrecognized modifier name: "+s);r=!0}}return n&&(e="Alt-"+e),i&&(e="Ctrl-"+e),o&&(e="Cmd-"+e),r&&(e="Shift-"+e),e}function la(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var i=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==i){delete e[n];continue}for(var r=m(n.split(" "),sa),o=0;o<r.length;o++){var a=void 0,s=void 0;o==r.length-1?(s=r.join(" "),a=i):(s=r.slice(0,o+1).join(" "),a="...");var l=t[s];if(l){if(l!=a)throw new Error("Inconsistent bindings for "+s)}else t[s]=a}delete e[n]}for(var c in t)e[c]=t[c];return e}function ca(e,t,n,i){t=fa(t);var r=t.call?t.call(e,i):t[e];if(r===!1)return"nothing";if("..."===r)return"multi";if(null!=r&&n(r))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return ca(e,t.fallthrough,n,i);for(var o=0;o<t.fallthrough.length;o++){var a=ca(e,t.fallthrough[o],n,i);if(a)return a}}}function ua(e){var t="string"==typeof e?e:Fl[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function da(e,t,n){var i=e;return t.altKey&&"Alt"!=i&&(e="Alt-"+e),(Hs?t.metaKey:t.ctrlKey)&&"Ctrl"!=i&&(e="Ctrl-"+e),(Hs?t.ctrlKey:t.metaKey)&&"Cmd"!=i&&(e="Cmd-"+e),!n&&t.shiftKey&&"Shift"!=i&&(e="Shift-"+e),e}function ha(e,t){if(Ts&&34==e.keyCode&&e["char"])return!1;var n=Fl[e.keyCode];return null==n||e.altGraphKey?!1:(3==e.keyCode&&e.code&&(n=e.code),da(n,e,t))}function fa(e){return"string"==typeof e?Ul[e]:e}function pa(e,t){for(var n=e.doc.sel.ranges,i=[],r=0;r<n.length;r++){for(var o=t(n[r]);i.length&<(o.from,g(i).to)<=0;){var a=i.pop();if(lt(a.from,o.from)<0){o.from=a.from;break}}i.push(o)}vr(e,function(){for(var t=i.length-1;t>=0;t--)Ho(e.doc,"",i[t].from,i[t].to,"+delete");Qi(e)})}function ga(e,t,n){var i=_(e.text,t+n,n);return 0>i||i>e.text.length?null:i}function ma(e,t,n){var i=ga(e,t.ch,n);return null==i?null:new st(t.line,i,0>n?"after":"before")}function va(e,t,n,i,r){if(e){var o=E(n,t.doc.direction);if(o){var a,s=0>r?g(o):o[0],l=0>r==(1==s.level),c=l?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var u=Gn(t,n);a=0>r?n.text.length-1:0;var d=Kn(t,u,a).top;a=$(function(e){return Kn(t,u,e).top==d},0>r==(1==s.level)?s.from:s.to-1,a),"before"==c&&(a=ga(n,a,1))}else a=0>r?s.to:s.from;return new st(i,a,c)}}return new st(i,0>r?n.text.length:0,0>r?"before":"after")}function ya(e,t,n,i){var r=E(t,e.doc.direction);if(!r)return ma(t,n,i);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=T(r,n.ch,n.sticky),a=r[o];if("ltr"==e.doc.direction&&0==a.level%2&&(i>0?a.to>n.ch:a.from<n.ch))return ma(t,n,i);var s,l=function(e,n){return ga(t,e instanceof st?e.ch:e,n)},c=function(n){return e.options.lineWrapping?(s=s||Gn(e,t),pi(e,t,s,n)):{begin:0,end:t.text.length}},u=c("before"==n.sticky?l(n,-1):n.ch);if("rtl"==e.doc.direction||1==a.level){var d=1==a.level==0>i,h=l(n,d?1:-1);if(null!=h&&(d?h<=a.to&&h<=u.end:h>=a.from&&h>=u.begin)){var f=d?"before":"after";return new st(n.line,h,f)}}var p=function(e,t,i){for(var o=function(e,t){return t?new st(n.line,l(e,1),"before"):new st(n.line,e,"after")};e>=0&&e<r.length;e+=t){var a=r[e],s=t>0==(1!=a.level),c=s?i.begin:l(i.end,-1);if(a.from<=c&&c<a.to)return o(c,s);if(c=s?a.from:l(a.to,-1),i.begin<=c&&c<i.end)return o(c,s)}},g=p(o+i,i,u);if(g)return g;var m=i>0?u.end:l(u.begin,-1);return null==m||i>0&&m==t.text.length||!(g=p(i>0?0:r.length-1,i,c(m)))?null:g}function ba(e,t){var n=Z(e.doc,t),i=Kt(n);return i!=n&&(t=it(i)),va(!0,e,i,t,1)}function xa(e,t){var n=Z(e.doc,t),i=Xt(n);return i!=n&&(t=it(i)),va(!0,e,n,t,-1)}function wa(e,t){var n=ba(e,t.line),i=Z(e.doc,n.line),r=E(i,e.doc.direction);if(!r||0==r[0].level){var o=Math.max(0,i.text.search(/\S/)),a=t.line==n.line&&t.ch<=o&&t.ch;return st(n.line,a?0:o,n.sticky)}return n}function ka(e,t,n){if("string"==typeof t&&(t=Jl[t],!t))return!1;e.display.input.ensurePolled();var i=e.display.shift,r=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),r=t(e)!=Js}finally{e.display.shift=i,e.state.suppressEdits=!1}return r}function Ca(e,t,n){for(var i=0;i<e.state.keyMaps.length;i++){var r=ca(t,e.state.keyMaps[i],n,e);if(r)return r}return e.options.extraKeys&&ca(t,e.options.extraKeys,n,e)||ca(t,e.options.keyMap,n,e)}function _a(e,t,n,i){var r=e.state.keySeq;if(r){if(ua(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Gl.set(50,function(){e.state.keySeq==r&&(e.state.keySeq=null,e.display.input.reset())}),$a(e,r+" "+t,n,i))return!0}return $a(e,t,n,i)}function $a(e,t,n,i){var r=Ca(e,t,i);return"multi"==r&&(e.state.keySeq=t),"handled"==r&&wn(e,"keyHandled",e,t,n),("handled"==r||"multi"==r)&&(O(n),zi(e)),!!r}function Sa(e,t){var n=ha(t,!0);return n?t.shiftKey&&!e.state.keySeq?_a(e,"Shift-"+n,t,function(t){return ka(e,t,!0)})||_a(e,n,t,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?ka(e,t):void 0}):_a(e,n,t,function(t){return ka(e,t)}):!1}function Ta(e,t,n){return _a(e,"'"+n+"'",t,function(t){return ka(e,t,!0)})}function Ea(e){var t=this;if(t.curOp.focus=a(),!D(t,e)){ks&&11>Cs&&27==e.keyCode&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=16==n||e.shiftKey;var i=Sa(t,e);Ts&&(Kl=i?n:null,!i&&88==n&&!sl&&(js?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),ys&&!js&&!i&&46==n&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=n||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||Ma(t)}}function Ma(e){function t(e){18!=e.keyCode&&e.altKey||(Vs(n,"CodeMirror-crosshair"),A(document,"keyup",t),A(document,"mouseover",t))}var n=e.display.lineDiv;s(n,"CodeMirror-crosshair"),il(document,"keyup",t),il(document,"mouseover",t)}function Aa(e){16==e.keyCode&&(this.doc.sel.shift=!1),D(this,e)}function La(e){var t=this;if(!(On(t.display,e)||D(t,e)||e.ctrlKey&&!e.altKey||js&&e.metaKey)){var n=e.keyCode,i=e.charCode;if(Ts&&n==Kl)return Kl=null,O(e),void 0;if(!Ts||e.which&&!(e.which<10)||!Sa(t,e)){var r=String.fromCharCode(null==i?n:i);"\b"!=r&&(Ta(t,e,r)||t.display.input.onKeyPress(e))}}}function Da(e,t){var n=+new Date;return Zl&&Zl.compare(n,e,t)?(Yl=Zl=null,"triple"):Yl&&Yl.compare(n,e,t)?(Zl=new Ql(n,e,t),Yl=null,"double"):(Yl=new Ql(n,e,t),Zl=null,"single")}function Na(e){var t=this,n=t.display;if(!(D(t,e)||n.activeTouch&&n.input.supportsTouch())){if(n.input.ensurePolled(),n.shift=e.shiftKey,On(n,e))return _s||(n.scroller.draggable=!1,setTimeout(function(){return n.scroller.draggable=!0},100)),void 0;if(!Fa(t,e)){var i=$i(t,e),r=V(e),o=i?Da(i,r):"single";window.focus(),1==r&&t.state.selectingText&&t.state.selectingText(e),i&&ja(t,r,i,o,e)||(1==r?i?Oa(t,i,o,e):B(e)==n.scroller&&O(e):2==r?(i&&vo(t.doc,i),setTimeout(function(){return n.input.focus()},20)):3==r&&(Bs?t.display.input.onContextMenu(e):Bi(t)))}}}function ja(e,t,n,i,r){var o="Click";return"double"==i?o="Double"+o:"triple"==i&&(o="Triple"+o),o=(1==t?"Left":2==t?"Middle":"Right")+o,_a(e,da(o,r),r,function(t){if("string"==typeof t&&(t=Jl[t]),!t)return!1;var i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),i=t(e,n)!=Js}finally{e.state.suppressEdits=!1}return i})}function Ia(e,t,n){var i=e.getOption("configureMouse"),r=i?i(e,t,n):{};if(null==r.unit){var o=Is?n.shiftKey&&n.metaKey:n.altKey;r.unit=o?"rectangle":"single"==t?"char":"double"==t?"word":"line"}return(null==r.extend||e.doc.extend)&&(r.extend=e.doc.extend||n.shiftKey),null==r.addNew&&(r.addNew=js?n.metaKey:n.ctrlKey),null==r.moveOnDrag&&(r.moveOnDrag=!(js?n.altKey:n.ctrlKey)),r}function Oa(e,t,n,i){ks?setTimeout(c(Hi,e),0):e.curOp.focus=a();var r,o=Ia(e,n,i),s=e.doc.sel;e.options.dragDrop&&rl&&!e.isReadOnly()&&"single"==n&&(r=s.contains(t))>-1&&(lt((r=s.ranges[r]).from(),t)<0||t.xRel>0)&&(lt(r.to(),t)>0||t.xRel<0)?Pa(e,i,t,o):Ha(e,i,t,o)}function Pa(e,t,n,i){var r=e.display,o=!1,a=yr(e,function(t){_s&&(r.scroller.draggable=!1),e.state.draggingText=!1,A(r.wrapper.ownerDocument,"mouseup",a),A(r.wrapper.ownerDocument,"mousemove",s),A(r.scroller,"dragstart",l),A(r.scroller,"drop",a),o||(O(t),i.addNew||vo(e.doc,n,null,null,i.extend),_s||ks&&9==Cs?setTimeout(function(){r.wrapper.ownerDocument.body.focus(),r.input.focus()},20):r.input.focus())}),s=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},l=function(){return o=!0};_s&&(r.scroller.draggable=!0),e.state.draggingText=a,a.copy=!i.moveOnDrag,r.scroller.dragDrop&&r.scroller.dragDrop(),il(r.wrapper.ownerDocument,"mouseup",a),il(r.wrapper.ownerDocument,"mousemove",s),il(r.scroller,"dragstart",l),il(r.scroller,"drop",a),Bi(e),setTimeout(function(){return r.input.focus()},20)}function za(e,t,n){if("char"==n)return new Nl(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new Nl(st(t.line,0),pt(e.doc,st(t.line+1,0)));var i=n(e,t);return new Nl(i.from,i.to)}function Ha(e,t,n,i){function r(t){if(0!=lt(v,t))if(v=t,"rectangle"==i.unit){for(var r=[],o=e.options.tabSize,a=d(Z(c,n.line).text,n.ch,o),s=d(Z(c,t.line).text,t.ch,o),l=Math.min(a,s),g=Math.max(a,s),m=Math.min(n.line,t.line),y=Math.min(e.lastLine(),Math.max(n.line,t.line));y>=m;m++){var b=Z(c,m).text,x=f(b,l,o);l==g?r.push(new Nl(st(m,x),st(m,x))):b.length>x&&r.push(new Nl(st(m,x),st(m,f(b,g,o))))}r.length||r.push(new Nl(n,n)),Co(c,Vr(e,p.ranges.slice(0,h).concat(r),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var w,k=u,C=za(e,t,i.unit),_=k.anchor;lt(C.anchor,_)>0?(w=C.head,_=ht(k.from(),C.anchor)):(w=C.anchor,_=dt(k.to(),C.head));var $=p.ranges.slice(0);$[h]=Ba(e,new Nl(pt(c,_),w)),Co(c,Vr(e,$,h),Ks)}}function o(t){var n=++b,s=$i(e,t,!0,"rectangle"==i.unit);if(s)if(0!=lt(s,v)){e.curOp.focus=a(),r(s);var u=qi(l,c);(s.line>=u.to||s.line<u.from)&&setTimeout(yr(e,function(){b==n&&o(t)}),150)}else{var d=t.clientY<y.top?-20:t.clientY>y.bottom?20:0;d&&setTimeout(yr(e,function(){b==n&&(l.scroller.scrollTop+=d,o(t))}),50)}}function s(t){e.state.selectingText=!1,b=1/0,t&&(O(t),l.input.focus()),A(l.wrapper.ownerDocument,"mousemove",x),A(l.wrapper.ownerDocument,"mouseup",w),c.history.lastSelOrigin=null}var l=e.display,c=e.doc;O(t);var u,h,p=c.sel,g=p.ranges;if(i.addNew&&!i.extend?(h=c.sel.contains(n),u=h>-1?g[h]:new Nl(n,n)):(u=c.sel.primary(),h=c.sel.primIndex),"rectangle"==i.unit)i.addNew||(u=new Nl(n,n)),n=$i(e,t,!0,!0),h=-1;else{var m=za(e,n,i.unit);u=i.extend?mo(u,m.anchor,m.head,i.extend):m}i.addNew?-1==h?(h=g.length,Co(c,Vr(e,g.concat([u]),h),{scroll:!1,origin:"*mouse"})):g.length>1&&g[h].empty()&&"char"==i.unit&&!i.extend?(Co(c,Vr(e,g.slice(0,h).concat(g.slice(h+1)),0),{scroll:!1,origin:"*mouse"}),p=c.sel):bo(c,h,u,Ks):(h=0,Co(c,new Dl([u],0),Ks),p=c.sel);var v=n,y=l.wrapper.getBoundingClientRect(),b=0,x=yr(e,function(e){0!==e.buttons&&V(e)?o(e):s(e)}),w=yr(e,s);e.state.selectingText=w,il(l.wrapper.ownerDocument,"mousemove",x),il(l.wrapper.ownerDocument,"mouseup",w)}function Ba(e,t){var n=t.anchor,i=t.head,r=Z(e.doc,n.line);if(0==lt(n,i)&&n.sticky==i.sticky)return t;var o=E(r);if(!o)return t;var a=T(o,n.ch,n.sticky),s=o[a];if(s.from!=n.ch&&s.to!=n.ch)return t;var l=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==l||l==o.length)return t;var c;if(i.line!=n.line)c=(i.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var u=T(o,i.ch,i.sticky),d=u-a||(i.ch-n.ch)*(1==s.level?-1:1);c=u==l-1||u==l?0>d:d>0}var h=o[l+(c?-1:0)],f=c==(1==h.level),p=f?h.from:h.to,g=f?"after":"before";return n.ch==p&&n.sticky==g?t:new Nl(new st(n.line,p,g),i)}function Va(e,t,n,i){var r,o;if(t.touches)r=t.touches[0].clientX,o=t.touches[0].clientY;else try{r=t.clientX,o=t.clientY}catch(t){return!1}if(r>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;i&&O(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!j(e,n))return z(t);o-=s.top-a.viewOffset;for(var l=0;l<e.display.gutterSpecs.length;++l){var c=a.gutters.childNodes[l];if(c&&c.getBoundingClientRect().right>=r){var u=rt(e.doc,o),d=e.display.gutterSpecs[l];return L(e,n,e,u,d.className,t),z(t)}}}function Fa(e,t){return Va(e,t,"gutterClick",!0)}function Ra(e,t){On(e.display,t)||Wa(e,t)||D(e,t,"contextmenu")||Bs||e.display.input.onContextMenu(t)}function Wa(e,t){return j(e,"gutterContextMenu")?Va(e,t,"gutterContextMenu",!1):!1}function qa(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ni(e)}function Ua(e){function t(t,i,r,o){e.defaults[t]=i,r&&(n[t]=o?function(e,t,n){n!=ec&&r(e,t,n)}:r)}var n=e.optionHandlers;e.defineOption=t,e.Init=ec,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,Gr(e)},!0),t("indentUnit",2,Gr,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){Kr(e),ni(e),Ti(e)},!0),t("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],i=e.doc.first;e.doc.iter(function(e){for(var r=0;;){var o=e.text.indexOf(t,r);if(-1==o)break;r=o+t.length,n.push(st(i,o))}i++});for(var r=n.length-1;r>=0;r--)Ho(e.doc,t,n[r],st(n[r].line,n[r].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test(" ")?"":"| "),"g"),n!=ec&&e.refresh()}),t("specialCharPlaceholder",un,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",Ns?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor") |
| 4 | },!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("autocorrect",!1,function(e,t){return e.getInputField().autocorrect=t},!0),t("autocapitalize",!1,function(e,t){return e.getInputField().autocapitalize=t},!0),t("rtlMoveVisually",!Os),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){qa(e),Or(e)},!0),t("keyMap","default",function(e,t,n){var i=fa(t),r=n!=ec&&fa(n);r&&r.detach&&r.detach(e,i),i.attach&&i.attach(e,r||null)}),t("extraKeys",null),t("configureMouse",null),t("lineWrapping",!1,Ga,!0),t("gutters",[],function(e,t){e.display.gutterSpecs=jr(t,e.options.lineNumbers),Or(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?ki(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return ar(e)},!0),t("scrollbarStyle","native",function(e){lr(e),ar(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e,t){e.display.gutterSpecs=jr(e.options.gutters,t),Or(e)},!0),t("firstLineNumber",1,Or,!0),t("lineNumberFormatter",function(e){return e},Or,!0),t("showCursorWhenSelecting",!1,Ni,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("pasteLinesPerSelection",!0),t("selectionsMayTouch",!1),t("readOnly",!1,function(e,t){"nocursor"==t&&(Fi(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,Ja),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Ni,!0),t("singleCursorHeightPerLine",!0,Ni,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,Kr,!0),t("addModeClass",!1,Kr,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,Kr,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null),t("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0),t("phrases",null)}function Ja(e,t,n){var i=n&&n!=ec;if(!t!=!i){var r=e.display.dragFunctions,o=t?il:A;o(e.display.scroller,"dragstart",r.start),o(e.display.scroller,"dragenter",r.enter),o(e.display.scroller,"dragover",r.over),o(e.display.scroller,"dragleave",r.leave),o(e.display.scroller,"drop",r.drop)}}function Ga(e){e.options.lineWrapping?(s(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Vs(e.display.wrapper,"CodeMirror-wrap"),on(e)),_i(e),Ti(e),ni(e),setTimeout(function(){return ar(e)},100)}function Ka(e,t){var n=this;if(!(this instanceof Ka))return new Ka(e,t);this.options=t=t?u(t):{},u(tc,t,!1);var i=t.value;"string"==typeof i?i=new Hl(i,t.mode,null,t.lineSeparator,t.direction):t.mode&&(i.modeOption=t.mode),this.doc=i;var r=new Ka.inputStyles[t.inputStyle](this),o=this.display=new Pr(e,i,r,t);o.wrapper.CodeMirror=this,qa(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),lr(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 Rs,keySeq:null,specialChars:null},t.autofocus&&!Ns&&o.input.focus(),ks&&11>Cs&&setTimeout(function(){return n.display.input.reset(!0)},20),Xa(this),ra(),cr(this),this.curOp.forceUpdate=!0,Zr(this,i),t.autofocus&&!Ns||this.hasFocus()?setTimeout(c(Vi,this),20):Fi(this);for(var a in nc)nc.hasOwnProperty(a)&&nc[a](n,t[a],ec);Nr(this),t.finishInit&&t.finishInit(this);for(var s=0;s<ic.length;++s)ic[s](n);ur(this),_s&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}function Xa(e){function t(){r.activeTouch&&(o=setTimeout(function(){return r.activeTouch=null},1e3),a=r.activeTouch,a.end=+new Date)}function n(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function i(e,t){if(null==t.left)return!0;var n=t.left-e.left,i=t.top-e.top;return n*n+i*i>400}var r=e.display;il(r.scroller,"mousedown",yr(e,Na)),ks&&11>Cs?il(r.scroller,"dblclick",yr(e,function(t){if(!D(e,t)){var n=$i(e,t);if(n&&!Fa(e,t)&&!On(e.display,t)){O(t);var i=e.findWordAt(n);vo(e.doc,i.anchor,i.head)}}})):il(r.scroller,"dblclick",function(t){return D(e,t)||O(t)}),il(r.scroller,"contextmenu",function(t){return Ra(e,t)});var o,a={end:0};il(r.scroller,"touchstart",function(t){if(!D(e,t)&&!n(t)&&!Fa(e,t)){r.input.ensurePolled(),clearTimeout(o);var i=+new Date;r.activeTouch={start:i,moved:!1,prev:i-a.end<=300?a:null},1==t.touches.length&&(r.activeTouch.left=t.touches[0].pageX,r.activeTouch.top=t.touches[0].pageY)}}),il(r.scroller,"touchmove",function(){r.activeTouch&&(r.activeTouch.moved=!0)}),il(r.scroller,"touchend",function(n){var o=r.activeTouch;if(o&&!On(r,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var a,s=e.coordsChar(r.activeTouch,"page");a=!o.prev||i(o,o.prev)?new Nl(s,s):!o.prev.prev||i(o,o.prev.prev)?e.findWordAt(s):new Nl(st(s.line,0),pt(e.doc,st(s.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),O(n)}t()}),il(r.scroller,"touchcancel",t),il(r.scroller,"scroll",function(){r.scroller.clientHeight&&(nr(e,r.scroller.scrollTop),rr(e,r.scroller.scrollLeft,!0),L(e,"scroll",e))}),il(r.scroller,"mousewheel",function(t){return Br(e,t)}),il(r.scroller,"DOMMouseScroll",function(t){return Br(e,t)}),il(r.wrapper,"scroll",function(){return r.wrapper.scrollTop=r.wrapper.scrollLeft=0}),r.dragFunctions={enter:function(t){D(e,t)||H(t)},over:function(t){D(e,t)||(ta(e,t),H(t))},start:function(t){return ea(e,t)},drop:yr(e,Zo),leave:function(t){D(e,t)||na(e)}};var s=r.input.getField();il(s,"keyup",function(t){return Aa.call(e,t)}),il(s,"keydown",yr(e,Ea)),il(s,"keypress",yr(e,La)),il(s,"focus",function(t){return Vi(e,t)}),il(s,"blur",function(t){return Fi(e,t)})}function Qa(e,t,n,i){var r,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?r=bt(e,t).state:n="prev");var a=e.options.tabSize,s=Z(o,t),l=d(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var c,u=s.text.match(/^\s*/)[0];if(i||/\S/.test(s.text)){if("smart"==n&&(c=o.mode.indent(r,s.text.slice(u.length),s.text),c==Js||c>150)){if(!i)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?d(Z(o,t-1).text,null,a):0:"add"==n?c=l+e.options.indentUnit:"subtract"==n?c=l-e.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var h="",f=0;if(e.options.indentWithTabs)for(var g=Math.floor(c/a);g;--g)f+=a,h+=" ";if(c>f&&(h+=p(c-f)),h!=u)return Ho(o,h,st(t,0),st(t,u.length),"+input"),s.stateAfter=null,!0;for(var m=0;m<o.sel.ranges.length;m++){var v=o.sel.ranges[m];if(v.head.line==t&&v.head.ch<u.length){var y=st(t,u.length);bo(o,m,new Nl(y,y));break}}}function Ya(e){rc=e}function Za(e,t,n,i,r){var o=e.doc;e.display.shift=!1,i||(i=o.sel);var a=+new Date-200,s="paste"==r||e.state.pasteIncoming>a,l=ol(t),c=null;if(s&&i.ranges.length>1)if(rc&&rc.text.join("\n")==t){if(0==i.ranges.length%rc.text.length){c=[];for(var u=0;u<rc.text.length;u++)c.push(o.splitLines(rc.text[u]))}}else l.length==i.ranges.length&&e.options.pasteLinesPerSelection&&(c=m(l,function(e){return[e]}));for(var d=e.curOp.updateInput,h=i.ranges.length-1;h>=0;h--){var f=i.ranges[h],p=f.from(),v=f.to();f.empty()&&(n&&n>0?p=st(p.line,p.ch-n):e.state.overwrite&&!s?v=st(v.line,Math.min(Z(o,v.line).text.length,v.ch+g(l).length)):s&&rc&&rc.lineWise&&rc.text.join("\n")==t&&(p=v=st(p.line,0)));var y={from:p,to:v,text:c?c[h%c.length]:l,origin:r||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};No(e.doc,y),wn(e,"inputRead",e,y)}t&&!s&&ts(e,t),Qi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=d),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function es(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");return n?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||vr(t,function(){return Za(t,n,0,null,"paste")}),!0):void 0}function ts(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,i=n.ranges.length-1;i>=0;i--){var r=n.ranges[i];if(!(r.head.ch>100||i&&n.ranges[i-1].head.line==r.head.line)){var o=e.getModeAt(r.head),a=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(t.indexOf(o.electricChars.charAt(s))>-1){a=Qa(e,r.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Z(e.doc,r.head.line).text.slice(0,r.head.ch))&&(a=Qa(e,r.head.line,"smart"));a&&wn(e,"electricInput",e,r.head.line)}}}function ns(e){for(var t=[],n=[],i=0;i<e.doc.sel.ranges.length;i++){var r=e.doc.sel.ranges[i].head.line,o={anchor:st(r,0),head:st(r+1,0)};n.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:n}}function is(e,t,n,i){e.setAttribute("autocorrect",n?"":"off"),e.setAttribute("autocapitalize",i?"":"off"),e.setAttribute("spellcheck",!!t)}function rs(){var e=i("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=i("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return _s?e.style.width="1000px":e.setAttribute("wrap","off"),Ls&&(e.style.border="1px solid black"),is(e),t}function os(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,n){var i=this.options,r=i[e];(i[e]!=n||"mode"==e)&&(i[e]=n,t.hasOwnProperty(e)&&yr(this,t[e])(this,n,r),L(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"](fa(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:br(function(t,n){var i=t.token?t:e.getMode(this.options,t);if(i.startState)throw new Error("Overlays may not be stateful.");v(this.state.overlays,{mode:i,modeSpec:t,opaque:n&&n.opaque,priority:n&&n.priority||0},function(e){return e.priority}),this.state.modeGen++,Ti(this)}),removeOverlay:br(function(e){for(var t=this,n=this.state.overlays,i=0;i<n.length;++i){var r=n[i].modeSpec;if(r==e||"string"==typeof e&&r.name==e)return n.splice(i,1),t.state.modeGen++,Ti(t),void 0}}),indentLine:br(function(e,t,n){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),ot(this.doc,e)&&Qa(this,e,t,n)}),indentSelection:br(function(e){for(var t=this,n=this.doc.sel.ranges,i=-1,r=0;r<n.length;r++){var o=n[r];if(o.empty())o.head.line>i&&(Qa(t,o.head.line,e,!0),i=o.head.line,r==t.doc.sel.primIndex&&Qi(t));else{var a=o.from(),s=o.to(),l=Math.max(i,a.line);i=Math.min(t.lastLine(),s.line-(s.ch?0:1))+1;for(var c=l;i>c;++c)Qa(t,c,e);var u=t.doc.sel.ranges;0==a.ch&&n.length==u.length&&u[r].from().ch>0&&bo(t.doc,r,new Nl(a,u[r].to()),Gs)}}}),getTokenAt:function(e,t){return Ct(this,e,t)},getLineTokens:function(e,t){return Ct(this,st(e),t,!0)},getTokenTypeAt:function(e){e=pt(this.doc,e);var t,n=yt(this,Z(this.doc,e.line)),i=0,r=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=i+r>>1;if((a?n[2*a-1]:0)>=o)r=a;else{if(!(n[2*a+1]<o)){t=n[2*a+2];break}i=a+1}}var s=t?t.indexOf("overlay "):-1;return 0>s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var i=this,r=[];if(!n.hasOwnProperty(t))return r;var o=n[t],a=this.getModeAt(e);if("string"==typeof a[t])o[a[t]]&&r.push(o[a[t]]);else if(a[t])for(var s=0;s<a[t].length;s++){var l=o[a[t][s]];l&&r.push(l)}else a.helperType&&o[a.helperType]?r.push(o[a.helperType]):o[a.name]&&r.push(o[a.name]);for(var c=0;c<o._global.length;c++){var u=o._global[c];u.pred(a,i)&&-1==h(r,u.val)&&r.push(u.val)}return r},getStateAfter:function(e,t){var n=this.doc;return e=ft(n,null==e?n.first+n.size-1:e),bt(this,e+1,t).state},cursorCoords:function(e,t){var n,i=this.doc.sel.primary();return n=null==e?i.head:"object"==typeof e?pt(this.doc,e):e?i.from():i.to(),ci(this,n,t||"page")},charCoords:function(e,t){return li(this,pt(this.doc,e),t||"page")},coordsChar:function(e,t){return e=si(this,e,t||"page"),hi(this,e.left,e.top)},lineAtHeight:function(e,t){return e=si(this,{top:e,left:0},t||"page").top,rt(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t,n){var i,r=!1;if("number"==typeof e){var o=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>o&&(e=o,r=!0),i=Z(this.doc,e)}else i=e;return ai(this,i,{top:0,left:0},t||"page",n||r).top+(r?this.doc.height-nn(i):0)},defaultTextHeight:function(){return bi(this.display)},defaultCharWidth:function(){return xi(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,i,r){var o=this.display;e=ci(this,pt(this.doc,e));var a=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==i)a=e.top;else if("above"==i||"near"==i){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==i||e.bottom+t.offsetHeight>l)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=l&&(a=e.bottom),s+t.offsetWidth>c&&(s=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==r?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==r?s=0:"middle"==r&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),n&&Gi(this,{left:s,top:a,right:s+t.offsetWidth,bottom:a+t.offsetHeight})},triggerOnKeyDown:br(Ea),triggerOnKeyPress:br(La),triggerOnKeyUp:Aa,triggerOnMouseDown:br(Na),execCommand:function(e){return Jl.hasOwnProperty(e)?Jl[e].call(null,this):void 0},triggerElectric:br(function(e){ts(this,e)}),findPosH:function(e,t,n,i){var r=this,o=1;0>t&&(o=-1,t=-t);for(var a=pt(this.doc,e),s=0;t>s&&(a=as(r.doc,a,o,n,i),!a.hitSide);++s);return a},moveH:br(function(e,t){var n=this;this.extendSelectionsBy(function(i){return n.display.shift||n.doc.extend||i.empty()?as(n.doc,i.head,e,t,n.options.rtlMoveVisually):0>e?i.from():i.to()},Xs)}),deleteH:br(function(e,t){var n=this.doc.sel,i=this.doc;n.somethingSelected()?i.replaceSelection("",null,"+delete"):pa(this,function(n){var r=as(i,n.head,e,t,!1);return 0>e?{from:r,to:n.head}:{from:n.head,to:r}})}),findPosV:function(e,t,n,i){var r=this,o=1,a=i;0>t&&(o=-1,t=-t);for(var s=pt(this.doc,e),l=0;t>l;++l){var c=ci(r,s,"div");if(null==a?a=c.left:c.left=a,s=ss(r,c,o,n),s.hitSide)break}return s},moveV:br(function(e,t){var n=this,i=this.doc,r=[],o=!this.display.shift&&!i.extend&&i.sel.somethingSelected();if(i.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var s=ci(n,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),r.push(s.left);var l=ss(n,s,e,t);return"page"==t&&a==i.sel.primary()&&Xi(n,li(n,l,"div").top-s.top),l},Xs),r.length)for(var a=0;a<i.sel.ranges.length;a++)i.sel.ranges[a].goalColumn=r[a]}),findWordAt:function(e){var t=this.doc,n=Z(t,e.line).text,i=e.ch,r=e.ch;if(n){var o=this.getHelper(e,"wordChars");"before"!=e.sticky&&r!=n.length||!i?++r:--i;for(var a=n.charAt(i),s=w(a,o)?function(e){return w(e,o)}:/\s/.test(a)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!w(e)};i>0&&s(n.charAt(i-1));)--i;for(;r<n.length&&s(n.charAt(r));)++r}return new Nl(st(e.line,i),st(e.line,r))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?s(this.display.cursorDiv,"CodeMirror-overwrite"):Vs(this.display.cursorDiv,"CodeMirror-overwrite"),L(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==a()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:br(function(e,t){Yi(this,e,t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Bn(this)-this.display.barHeight,width:e.scrollWidth-Bn(this)-this.display.barWidth,clientHeight:Fn(this),clientWidth:Vn(this)}},scrollIntoView:br(function(e,t){null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:st(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line?Zi(this,e):tr(this,e.from,e.to,e.margin)}),setSize:br(function(e,t){var n=this,i=function(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e};null!=e&&(this.display.wrapper.style.width=i(e)),null!=t&&(this.display.wrapper.style.height=i(t)),this.options.lineWrapping&&ti(this);var r=this.display.viewFrom;this.doc.iter(r,this.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){Ei(n,r,"widget");break}++r}),this.curOp.forceUpdate=!0,L(this,"refresh",this)}),operation:function(e){return vr(this,e)},startOperation:function(){return cr(this)},endOperation:function(){return ur(this)},refresh:br(function(){var e=this.display.cachedTextHeight;Ti(this),this.curOp.forceUpdate=!0,ni(this),Yi(this,this.doc.scrollLeft,this.doc.scrollTop),Ar(this.display),(null==e||Math.abs(e-bi(this.display))>.5)&&_i(this),L(this,"refresh",this)}),swapDoc:br(function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),Zr(this,e),ni(this),this.display.input.reset(),Yi(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,wn(this,"swapDoc",this,t),t}),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},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}},I(e),e.registerHelper=function(t,i,r){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][i]=r},e.registerGlobalHelper=function(t,i,r,o){e.registerHelper(t,i,o),n[t]._global.push({pred:r,val:o})}}function as(e,t,n,i,r){function o(){var i=t.line+n;return i<e.first||i>=e.first+e.size?!1:(t=new st(i,t.ch,t.sticky),c=Z(e,i))}function a(i){var a;if(a=r?ya(e.cm,c,t,n):ma(c,t,n),null==a){if(i||!o())return!1;t=va(r,e.cm,c,t.line,n)}else t=a;return!0}var s=t,l=n,c=Z(e,t.line);if("char"==i)a();else if("column"==i)a(!0);else if("word"==i||"group"==i)for(var u=null,d="group"==i,h=e.cm&&e.cm.getHelper(t,"wordChars"),f=!0;!(0>n)||a(!f);f=!1){var p=c.text.charAt(t.ch)||"\n",g=w(p,h)?"w":d&&"\n"==p?"n":!d||/\s/.test(p)?null:"p";if(!d||f||g||(g="s"),u&&u!=g){0>n&&(n=1,a(),t.sticky="after");break}if(g&&(u=g),n>0&&!a(!f))break}var m=Mo(e,t,s,l,!0);return ct(s,m)&&(m.hitSide=!0),m}function ss(e,t,n,i){var r,o=e.doc,a=t.left;if("page"==i){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),l=Math.max(s-.5*bi(e.display),3);r=(n>0?t.bottom:t.top)+n*l}else"line"==i&&(r=n>0?t.bottom+3:t.top-3);for(var c;c=hi(e,a,r),c.outside;){if(0>n?0>=r:r>=o.height){c.hitSide=!0;break}r+=5*n}return c}function ls(e,t){var n=Jn(e,t.line);if(!n||n.hidden)return null;var i=Z(e.doc,t.line),r=Wn(n,i,t.line),o=E(i,e.doc.direction),a="left";if(o){var s=T(o,t.ch);a=s%2?"right":"left"}var l=Xn(r.map,t.ch,a);return l.offset="right"==l.collapse?l.end:l.start,l}function cs(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function us(e,t){return t&&(e.bad=!0),e}function ds(e,t,n,i,r){function o(e){return function(t){return t.id==e}}function a(){u&&(c+=d,h&&(c+=d),u=h=!1)}function s(e){e&&(a(),c+=e)}function l(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return s(n),void 0;var c,f=t.getAttribute("cm-marker");if(f){var p=e.findMarks(st(i,0),st(r+1,0),o(+f));return p.length&&(c=p[0].find(0))&&s(et(e.doc,c.from,c.to).join(d)),void 0}if("false"==t.getAttribute("contenteditable"))return;var g=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;g&&a();for(var m=0;m<t.childNodes.length;m++)l(t.childNodes[m]);/^(pre|p)$/i.test(t.nodeName)&&(h=!0),g&&(u=!0)}else 3==t.nodeType&&s(t.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(var c="",u=!1,d=e.doc.lineSeparator(),h=!1;l(t),t!=n;)t=t.nextSibling,h=!1;return c}function hs(e,t,n){var i;if(t==e.display.lineDiv){if(i=e.display.lineDiv.childNodes[n],!i)return us(e.clipPos(st(e.display.viewTo-1)),!0);t=null,n=0}else for(i=t;;i=i.parentNode){if(!i||i==e.display.lineDiv)return null;if(i.parentNode&&i.parentNode==e.display.lineDiv)break}for(var r=0;r<e.display.view.length;r++){var o=e.display.view[r];if(o.node==i)return fs(o,t,n)}}function fs(e,t,n){function i(t,n,i){for(var r=-1;r<(d?d.length:0);r++)for(var o=0>r?u.map:d[r],a=0;a<o.length;a+=3){var s=o[a+2];if(s==t||s==n){var l=it(0>r?e.line:e.rest[r]),c=o[a]+i;return(0>i||s!=t)&&(c=o[a+(i?1:0)]),st(l,c)}}}var r=e.text.firstChild,a=!1;if(!t||!o(r,t))return us(st(it(e.line),0),!0);if(t==r&&(a=!0,t=r.childNodes[n],n=0,!t)){var s=e.rest?g(e.rest):e.line;return us(st(it(s),s.text.length),a)}var l=3==t.nodeType?t:null,c=t;for(l||1!=t.childNodes.length||3!=t.firstChild.nodeType||(l=t.firstChild,n&&(n=l.nodeValue.length));c.parentNode!=r;)c=c.parentNode;var u=e.measure,d=u.maps,h=i(l,c,n);if(h)return us(h,a);for(var f=c.nextSibling,p=l?l.nodeValue.length-n:0;f;f=f.nextSibling){if(h=i(f,f.firstChild,0))return us(st(h.line,h.ch-p),a);p+=f.textContent.length}for(var m=c.previousSibling,v=n;m;m=m.previousSibling){if(h=i(m,m.firstChild,-1))return us(st(h.line,h.ch+v),a);v+=m.textContent.length}}function ps(e,t){function n(){e.value=c.getValue()}if(t=t?u(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var i=a();t.autofocus=i==e||null!=e.getAttribute("autofocus")&&i==document.body}var r;if(e.form&&(il(e.form,"submit",n),!t.leaveSubmitMethodAlone)){var o=e.form;r=o.submit;try{var s=o.submit=function(){n(),o.submit=r,o.submit(),o.submit=s}}catch(l){}}t.finishInit=function(i){i.save=n,i.getTextArea=function(){return e},i.toTextArea=function(){i.toTextArea=isNaN,n(),e.parentNode.removeChild(i.getWrapperElement()),e.style.display="",e.form&&(A(e.form,"submit",n),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=r))}},e.style.display="none";var c=Ka(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return c}function gs(e){e.off=A,e.on=il,e.wheelEventPixels=Hr,e.Doc=Hl,e.splitLines=ol,e.countColumn=d,e.findColumn=f,e.isWordChar=x,e.Pass=Js,e.signal=L,e.Line=yl,e.changeEnd=Rr,e.scrollbarModel=Tl,e.Pos=st,e.cmpPos=lt,e.modes=cl,e.mimeModes=ul,e.resolveMode=J,e.getMode=G,e.modeExtensions=dl,e.extendMode=K,e.copyState=X,e.startState=Y,e.innerMode=Q,e.commands=Jl,e.keyMap=Ul,e.keyName=ha,e.isModifierKey=ua,e.lookupKey=ca,e.normalizeKeyMap=la,e.StringStream=hl,e.SharedTextMarker=Pl,e.TextMarker=Ol,e.LineWidget=jl,e.e_preventDefault=O,e.e_stopPropagation=P,e.e_stop=H,e.addClass=s,e.contains=o,e.rmClass=Vs,e.keyNames=Fl}var ms=navigator.userAgent,vs=navigator.platform,ys=/gecko\/\d/i.test(ms),bs=/MSIE \d/.test(ms),xs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ms),ws=/Edge\/(\d+)/.exec(ms),ks=bs||xs||ws,Cs=ks&&(bs?document.documentMode||6:+(ws||xs)[1]),_s=!ws&&/WebKit\//.test(ms),$s=_s&&/Qt\/\d+\.\d+/.test(ms),Ss=!ws&&/Chrome\//.test(ms),Ts=/Opera\//.test(ms),Es=/Apple Computer/.test(navigator.vendor),Ms=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(ms),As=/PhantomJS/.test(ms),Ls=!ws&&/AppleWebKit/.test(ms)&&/Mobile\/\w+/.test(ms),Ds=/Android/.test(ms),Ns=Ls||Ds||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(ms),js=Ls||/Mac/.test(vs),Is=/\bCrOS\b/.test(ms),Os=/win/i.test(vs),Ps=Ts&&ms.match(/Version\/(\d*\.\d*)/);Ps&&(Ps=Number(Ps[1])),Ps&&Ps>=15&&(Ts=!1,_s=!0);var zs,Hs=js&&($s||Ts&&(null==Ps||12.11>Ps)),Bs=ys||ks&&Cs>=9,Vs=function(t,n){var i=t.className,r=e(n).exec(i);if(r){var o=i.slice(r.index+r[0].length);t.className=i.slice(0,r.index)+(o?r[1]+o:"")}};zs=document.createRange?function(e,t,n,i){var r=document.createRange();return r.setEnd(i||e,n),r.setStart(e,t),r}:function(e,t,n){var i=document.body.createTextRange();try{i.moveToElementText(e.parentNode)}catch(r){return i}return i.collapse(!0),i.moveEnd("character",n),i.moveStart("character",t),i};var Fs=function(e){e.select()};Ls?Fs=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:ks&&(Fs=function(e){try{e.select()}catch(t){}});var Rs=function(){this.id=null,this.f=null,this.time=0,this.handler=c(this.onTimeout,this)};Rs.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},Rs.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=n)};var Ws,qs,Us=30,Js={toString:function(){return"CodeMirror.Pass"}},Gs={scroll:!1},Ks={origin:"*mouse"},Xs={origin:"+move"},Qs=[""],Ys=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Zs=/[\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]/,el=null,tl=function(){function e(e){return 247>=e?n.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1785>=e?i.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,n){this.level=e,this.from=t,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",i="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,s=/[Lb1n]/,l=/[1n]/;return function(n,i){var c="ltr"==i?"L":"R";if(0==n.length||"ltr"==i&&!r.test(n))return!1;for(var u=n.length,d=[],h=0;u>h;++h)d.push(e(n.charCodeAt(h)));for(var f=0,p=c;u>f;++f){var m=d[f];"m"==m?d[f]=p:p=m}for(var v=0,y=c;u>v;++v){var b=d[v];"1"==b&&"r"==y?d[v]="n":a.test(b)&&(y=b,"r"==b&&(d[v]="R"))}for(var x=1,w=d[0];u-1>x;++x){var k=d[x];"+"==k&&"1"==w&&"1"==d[x+1]?d[x]="1":","!=k||w!=d[x+1]||"1"!=w&&"n"!=w||(d[x]=w),w=k}for(var C=0;u>C;++C){var _=d[C];if(","==_)d[C]="N";else if("%"==_){var $=void 0;for($=C+1;u>$&&"%"==d[$];++$);for(var S=C&&"!"==d[C-1]||u>$&&"1"==d[$]?"1":"N",T=C;$>T;++T)d[T]=S;C=$-1}}for(var E=0,M=c;u>E;++E){var A=d[E];"L"==M&&"1"==A?d[E]="L":a.test(A)&&(M=A)}for(var L=0;u>L;++L)if(o.test(d[L])){var D=void 0;for(D=L+1;u>D&&o.test(d[D]);++D);for(var N="L"==(L?d[L-1]:c),j="L"==(u>D?d[D]:c),I=N==j?N?"L":"R":c,O=L;D>O;++O)d[O]=I;L=D-1}for(var P,z=[],H=0;u>H;)if(s.test(d[H])){var B=H;for(++H;u>H&&s.test(d[H]);++H);z.push(new t(0,B,H))}else{var V=H,F=z.length;for(++H;u>H&&"L"!=d[H];++H);for(var R=V;H>R;)if(l.test(d[R])){R>V&&z.splice(F,0,new t(1,V,R));var W=R;for(++R;H>R&&l.test(d[R]);++R);z.splice(F,0,new t(2,W,R)),V=R}else++R;H>V&&z.splice(F,0,new t(1,V,H))}return"ltr"==i&&(1==z[0].level&&(P=n.match(/^\s+/))&&(z[0].from=P[0].length,z.unshift(new t(0,0,P[0].length))),1==g(z).level&&(P=n.match(/\s+$/))&&(g(z).to-=P[0].length,z.push(new t(0,u-P[0].length,u)))),"rtl"==i?z.reverse():z}}(),nl=[],il=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var i=e._handlers||(e._handlers={});i[t]=(i[t]||nl).concat(n)}},rl=function(){if(ks&&9>Cs)return!1;var e=i("div");return"draggable"in e||"dragDrop"in e}(),ol=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],i=e.length;i>=t;){var r=e.indexOf("\n",t);-1==r&&(r=e.length);var o=e.slice(t,"\r"==e.charAt(r-1)?r-1:r),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=r+1)}return n}:function(e){return e.split(/\r\n?|\n/)},al=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(n){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},sl=function(){var e=i("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),ll=null,cl={},ul={},dl={},hl=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};hl.prototype.eol=function(){return this.pos>=this.string.length},hl.prototype.sol=function(){return this.pos==this.lineStart},hl.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},hl.prototype.next=function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},hl.prototype.eat=function(e){var t,n=this.string.charAt(this.pos);return t="string"==typeof e?n==e:n&&(e.test?e.test(n):e(n)),t?(++this.pos,n):void 0},hl.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},hl.prototype.eatSpace=function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},hl.prototype.skipToEnd=function(){this.pos=this.string.length},hl.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},hl.prototype.backUp=function(e){this.pos-=e},hl.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=d(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?d(this.string,this.lineStart,this.tabSize):0)},hl.prototype.indentation=function(){return d(this.string,null,this.tabSize)-(this.lineStart?d(this.string,this.lineStart,this.tabSize):0)},hl.prototype.match=function(e,t,n){if("string"!=typeof e){var i=this.string.slice(this.pos).match(e);return i&&i.index>0?null:(i&&t!==!1&&(this.pos+=i[0].length),i)}var r=function(e){return n?e.toLowerCase():e},o=this.string.substr(this.pos,e.length); |