mergely
Version:
A javascript UI for diff/merge
1 lines • 335 kB
JavaScript
(()=>{var e={95:(e,t,n)=>{!function(e){"use strict";var t,n,r=e.Pos;function i(e){var t=e.flags;return null!=t?t:(e.ignoreCase?"i":"")+(e.global?"g":"")+(e.multiline?"m":"")}function o(e,t){for(var n=i(e),r=n,o=0;o<t.length;o++)-1==r.indexOf(t.charAt(o))&&(r+=t.charAt(o));return n==r?e:new RegExp(e.source,r)}function s(e){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(e.source)}function a(e,t,n){t=o(t,"g");for(var i=n.line,s=n.ch,a=e.lastLine();i<=a;i++,s=0){t.lastIndex=s;var l=e.getLine(i),c=t.exec(l);if(c)return{from:r(i,c.index),to:r(i,c.index+c[0].length),match:c}}}function l(e,t,n){if(!s(t))return a(e,t,n);t=o(t,"gm");for(var i,l=1,c=n.line,u=e.lastLine();c<=u;){for(var h=0;h<l&&!(c>u);h++){var d=e.getLine(c++);i=null==i?d:i+"\n"+d}l*=2,t.lastIndex=n.ch;var f=t.exec(i);if(f){var p=i.slice(0,f.index).split("\n"),m=f[0].split("\n"),g=n.line+p.length-1,v=p[p.length-1].length;return{from:r(g,v),to:r(g+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:f}}}}function c(e,t,n){for(var r,i=0;i<=e.length;){t.lastIndex=i;var o=t.exec(e);if(!o)break;var s=o.index+o[0].length;if(s>e.length-n)break;(!r||s>r.index+r[0].length)&&(r=o),i=o.index+1}return r}function u(e,t,n){t=o(t,"g");for(var i=n.line,s=n.ch,a=e.firstLine();i>=a;i--,s=-1){var l=e.getLine(i),u=c(l,t,s<0?0:l.length-s);if(u)return{from:r(i,u.index),to:r(i,u.index+u[0].length),match:u}}}function h(e,t,n){if(!s(t))return u(e,t,n);t=o(t,"gm");for(var i,a=1,l=e.getLine(n.line).length-n.ch,h=n.line,d=e.firstLine();h>=d;){for(var f=0;f<a&&h>=d;f++){var p=e.getLine(h--);i=null==i?p:p+"\n"+i}a*=2;var m=c(i,t,l);if(m){var g=i.slice(0,m.index).split("\n"),v=m[0].split("\n"),y=h+g.length,x=g[g.length-1].length;return{from:r(y,x),to:r(y+v.length-1,1==v.length?x+v[0].length:v[v.length-1].length),match:m}}}}function d(e,t,n,r){if(e.length==t.length)return n;for(var i=0,o=n+Math.max(0,e.length-t.length);;){if(i==o)return i;var s=i+o>>1,a=r(e.slice(0,s)).length;if(a==n)return s;a>n?o=s:i=s+1}}function f(e,i,o,s){if(!i.length)return null;var a=s?t:n,l=a(i).split(/\r|\n\r?/);e:for(var c=o.line,u=o.ch,h=e.lastLine()+1-l.length;c<=h;c++,u=0){var f=e.getLine(c).slice(u),p=a(f);if(1==l.length){var m=p.indexOf(l[0]);if(-1==m)continue e;return o=d(f,p,m,a)+u,{from:r(c,d(f,p,m,a)+u),to:r(c,d(f,p,m+l[0].length,a)+u)}}var g=p.length-l[0].length;if(p.slice(g)==l[0]){for(var v=1;v<l.length-1;v++)if(a(e.getLine(c+v))!=l[v])continue e;var y=e.getLine(c+l.length-1),x=a(y),b=l[l.length-1];if(x.slice(0,b.length)==b)return{from:r(c,d(f,p,g,a)+u),to:r(c+l.length-1,d(y,x,b.length,a))}}}}function p(e,i,o,s){if(!i.length)return null;var a=s?t:n,l=a(i).split(/\r|\n\r?/);e:for(var c=o.line,u=o.ch,h=e.firstLine()-1+l.length;c>=h;c--,u=-1){var f=e.getLine(c);u>-1&&(f=f.slice(0,u));var p=a(f);if(1==l.length){var m=p.lastIndexOf(l[0]);if(-1==m)continue e;return{from:r(c,d(f,p,m,a)),to:r(c,d(f,p,m+l[0].length,a))}}var g=l[l.length-1];if(p.slice(0,g.length)==g){var v=1;for(o=c-l.length+1;v<l.length-1;v++)if(a(e.getLine(o+v))!=l[v])continue e;var y=e.getLine(c+1-l.length),x=a(y);if(x.slice(x.length-l[0].length)==l[0])return{from:r(c+1-l.length,d(y,x,y.length-l[0].length,a)),to:r(c,d(f,p,g.length,a))}}}}function m(e,t,n,i){var s;this.atOccurrence=!1,this.afterEmptyMatch=!1,this.doc=e,n=n?e.clipPos(n):r(0,0),this.pos={from:n,to:n},"object"==typeof i?s=i.caseFold:(s=i,i=null),"string"==typeof t?(null==s&&(s=!1),this.matches=function(n,r){return(n?p:f)(e,t,r,s)}):(t=o(t,"gm"),i&&!1===i.multiline?this.matches=function(n,r){return(n?u:a)(e,t,r)}:this.matches=function(n,r){return(n?h:l)(e,t,r)})}String.prototype.normalize?(t=function(e){return e.normalize("NFD").toLowerCase()},n=function(e){return e.normalize("NFD")}):(t=function(e){return e.toLowerCase()},n=function(e){return e}),m.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(t){var n=this.doc.clipPos(t?this.pos.from:this.pos.to);if(this.afterEmptyMatch&&this.atOccurrence&&(n=r(n.line,n.ch),t?(n.ch--,n.ch<0&&(n.line--,n.ch=(this.doc.getLine(n.line)||"").length)):(n.ch++,n.ch>(this.doc.getLine(n.line)||"").length&&(n.ch=0,n.line++)),0!=e.cmpPos(n,this.doc.clipPos(n))))return this.atOccurrence=!1;var i=this.matches(t,n);if(this.afterEmptyMatch=i&&0==e.cmpPos(i.from,i.to),i)return this.pos=i,this.atOccurrence=!0,this.pos.match||!0;var o=r(t?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:o,to:o},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(t,n){if(this.atOccurrence){var i=e.splitLines(t);this.doc.replaceRange(i,this.pos.from,this.pos.to,n),this.pos.to=r(this.pos.from.line+i.length-1,i[i.length-1].length+(1==i.length?this.pos.from.ch:0))}}},e.defineExtension("getSearchCursor",(function(e,t,n){return new m(this.doc,e,t,n)})),e.defineDocExtension("getSearchCursor",(function(e,t,n){return new m(this,e,t,n)})),e.defineExtension("selectMatches",(function(t,n){for(var r=[],i=this.getSearchCursor(t,this.getCursor("from"),n);i.findNext()&&!(e.cmpPos(i.to(),this.getCursor("to"))>0);)r.push({anchor:i.from(),head:i.to()});r.length&&this.setSelections(r,0)}))}(n(631))},20:(e,t,n)=>{!function(e){"use strict";function t(e){e.state.markedSelection&&e.operation((function(){c(e)}))}function n(e){e.state.markedSelection&&e.state.markedSelection.length&&e.operation((function(){a(e)}))}e.defineOption("styleSelectedText",!1,(function(r,i,o){var s=o&&o!=e.Init;i&&!s?(r.state.markedSelection=[],r.state.markedSelectionStyle="string"==typeof i?i:"CodeMirror-selectedtext",l(r),r.on("cursorActivity",t),r.on("change",n)):!i&&s&&(r.off("cursorActivity",t),r.off("change",n),a(r),r.state.markedSelection=r.state.markedSelectionStyle=null)}));var r=8,i=e.Pos,o=e.cmpPos;function s(e,t,n,s){if(0!=o(t,n))for(var a=e.state.markedSelection,l=e.state.markedSelectionStyle,c=t.line;;){var u=c==t.line?t:i(c,0),h=c+r,d=h>=n.line,f=d?n:i(h,0),p=e.markText(u,f,{className:l});if(null==s?a.push(p):a.splice(s++,0,p),d)break;c=h}}function a(e){for(var t=e.state.markedSelection,n=0;n<t.length;++n)t[n].clear();t.length=0}function l(e){a(e);for(var t=e.listSelections(),n=0;n<t.length;n++)s(e,t[n].from(),t[n].to())}function c(e){if(!e.somethingSelected())return a(e);if(e.listSelections().length>1)return l(e);var t=e.getCursor("start"),n=e.getCursor("end"),i=e.state.markedSelection;if(!i.length)return s(e,t,n);var c=i[0].find(),u=i[i.length-1].find();if(!c||!u||n.line-t.line<=r||o(t,u.to)>=0||o(n,c.from)<=0)return l(e);for(;o(t,c.from)>0;)i.shift().clear(),c=i[0].find();for(o(t,c.from)<0&&(c.to.line-t.line<r?(i.shift().clear(),s(e,t,c.to,0)):s(e,t,c.from,0));o(n,u.to)<0;)i.pop().clear(),u=i[i.length-1].find();o(n,u.to)>0&&(n.line-u.from.line<r?(i.pop().clear(),s(e,u.from,n)):s(e,u.to,n))}}(n(631))},631:function(e){e.exports=function(){"use strict";var e=navigator.userAgent,t=navigator.platform,n=/gecko\/\d/i.test(e),r=/MSIE \d/.test(e),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),o=/Edge\/(\d+)/.exec(e),s=r||i||o,a=s&&(r?document.documentMode||6:+(o||i)[1]),l=!o&&/WebKit\//.test(e),c=l&&/Qt\/\d+\.\d+/.test(e),u=!o&&/Chrome\/(\d+)/.exec(e),h=u&&+u[1],d=/Opera\//.test(e),f=/Apple Computer/.test(navigator.vendor),p=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),m=/PhantomJS/.test(e),g=f&&(/Mobile\/\w+/.test(e)||navigator.maxTouchPoints>2),v=/Android/.test(e),y=g||v||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),x=g||/Mac/.test(t),b=/\bCrOS\b/.test(e),w=/win/i.test(t),k=d&&e.match(/Version\/(\d*\.\d*)/);k&&(k=Number(k[1])),k&&k>=15&&(d=!1,l=!0);var _=x&&(c||d&&(null==k||k<12.11)),C=n||s&&a>=9;function S(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var M,L=function(e,t){var n=e.className,r=S(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function T(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function D(e,t){return T(e).appendChild(t)}function A(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function E(e,t,n,r){var i=A(e,t,n,r);return i.setAttribute("role","presentation"),i}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 F(e){var t;try{t=e.activeElement}catch(n){t=e.body||null}for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function N(e,t){var n=e.className;S(t).test(n)||(e.className+=(n?" ":"")+t)}function z(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!S(n[r]).test(t)&&(t+=" "+n[r]);return t}M=document.createRange?function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(e){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};var P=function(e){e.select()};function W(e){return e.display.wrapper.ownerDocument}function I(e){return W(e).defaultView}function H(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function B(e,t,n){for(var r in t||(t={}),e)!e.hasOwnProperty(r)||!1===n&&t.hasOwnProperty(r)||(t[r]=e[r]);return t}function j(e,t,n,r,i){null==t&&-1==(t=e.search(/[^\s\u00a0]/))&&(t=e.length);for(var o=r||0,s=i||0;;){var a=e.indexOf("\t",o);if(a<0||a>=t)return s+(t-o);s+=a-o,s+=n-s%n,o=a+1}}g?P=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:s&&(P=function(e){try{e.select()}catch(e){}});var R=function(){this.id=null,this.f=null,this.time=0,this.handler=H(this.onTimeout,this)};function q(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}R.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},R.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 $=50,V={toString:function(){return"CodeMirror.Pass"}},U={scroll:!1},G={origin:"*mouse"},K={origin:"+move"};function X(e,t,n){for(var r=0,i=0;;){var o=e.indexOf("\t",r);-1==o&&(o=e.length);var s=o-r;if(o==e.length||i+s>=t)return r+Math.min(s,t-i);if(i+=o-r,r=o+1,(i+=n-i%n)>=t)return r}}var Y=[""];function Z(e){for(;Y.length<=e;)Y.push(J(Y)+" ");return Y[e]}function J(e){return e[e.length-1]}function Q(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function ee(e,t,n){for(var r=0,i=n(t);r<e.length&&n(e[r])<=i;)r++;e.splice(r,0,t)}function te(){}function ne(e,t){var n;return Object.create?n=Object.create(e):(te.prototype=e,n=new te),t&&B(t,n),n}var re=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function ie(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||re.test(e))}function oe(e,t){return t?!!(t.source.indexOf("\\w")>-1&&ie(e))||t.test(e):ie(e)}function se(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ae=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function le(e){return e.charCodeAt(0)>=768&&ae.test(e)}function ce(e,t,n){for(;(n<0?t>0:t<e.length)&&le(e.charAt(t));)t+=n;return t}function ue(e,t,n){for(var r=t>n?-1:1;;){if(t==n)return t;var i=(t+n)/2,o=r<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:n;e(o)?n=o:t=o+r}}function he(e,t,n,r){if(!e)return r(t,n,"ltr",0);for(var i=!1,o=0;o<e.length;++o){var s=e[o];(s.from<n&&s.to>t||t==n&&s.to==t)&&(r(Math.max(s.from,t),Math.min(s.to,n),1==s.level?"rtl":"ltr",o),i=!0)}i||r(t,n,"ltr")}var de=null;function fe(e,t,n){var r;de=null;for(var i=0;i<e.length;++i){var o=e[i];if(o.from<t&&o.to>t)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:de=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:de=i)}return null!=r?r:de}var pe=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(n){return n<=247?e.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1785?t.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":8204==n?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,o=/[LRr]/,s=/[Lb1n]/,a=/[1n]/;function l(e,t,n){this.level=e,this.from=t,this.to=n}return function(e,t){var c="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!r.test(e))return!1;for(var u=e.length,h=[],d=0;d<u;++d)h.push(n(e.charCodeAt(d)));for(var f=0,p=c;f<u;++f){var m=h[f];"m"==m?h[f]=p:p=m}for(var g=0,v=c;g<u;++g){var y=h[g];"1"==y&&"r"==v?h[g]="n":o.test(y)&&(v=y,"r"==y&&(h[g]="R"))}for(var x=1,b=h[0];x<u-1;++x){var w=h[x];"+"==w&&"1"==b&&"1"==h[x+1]?h[x]="1":","!=w||b!=h[x+1]||"1"!=b&&"n"!=b||(h[x]=b),b=w}for(var k=0;k<u;++k){var _=h[k];if(","==_)h[k]="N";else if("%"==_){var C=void 0;for(C=k+1;C<u&&"%"==h[C];++C);for(var S=k&&"!"==h[k-1]||C<u&&"1"==h[C]?"1":"N",M=k;M<C;++M)h[M]=S;k=C-1}}for(var L=0,T=c;L<u;++L){var D=h[L];"L"==T&&"1"==D?h[L]="L":o.test(D)&&(T=D)}for(var A=0;A<u;++A)if(i.test(h[A])){var E=void 0;for(E=A+1;E<u&&i.test(h[E]);++E);for(var O="L"==(A?h[A-1]:c),F=O==("L"==(E<u?h[E]:c))?O?"L":"R":c,N=A;N<E;++N)h[N]=F;A=E-1}for(var z,P=[],W=0;W<u;)if(s.test(h[W])){var I=W;for(++W;W<u&&s.test(h[W]);++W);P.push(new l(0,I,W))}else{var H=W,B=P.length,j="rtl"==t?1:0;for(++W;W<u&&"L"!=h[W];++W);for(var R=H;R<W;)if(a.test(h[R])){H<R&&(P.splice(B,0,new l(1,H,R)),B+=j);var q=R;for(++R;R<W&&a.test(h[R]);++R);P.splice(B,0,new l(2,q,R)),B+=j,H=R}else++R;H<W&&P.splice(B,0,new l(1,H,W))}return"ltr"==t&&(1==P[0].level&&(z=e.match(/^\s+/))&&(P[0].from=z[0].length,P.unshift(new l(0,0,z[0].length))),1==J(P).level&&(z=e.match(/\s+$/))&&(J(P).to-=z[0].length,P.push(new l(0,u-z[0].length,u)))),"rtl"==t?P.reverse():P}}();function me(e,t){var n=e.order;return null==n&&(n=e.order=pe(e.text,t)),n}var ge=[],ve=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={});r[t]=(r[t]||ge).concat(n)}};function ye(e,t){return e._handlers&&e._handlers[t]||ge}function xe(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers,i=r&&r[t];if(i){var o=q(i,n);o>-1&&(r[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function be(e,t){var n=ye(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i<n.length;++i)n[i].apply(null,r)}function we(e,t,n){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),be(e,n||t.type,e,t),Le(t)||t.codemirrorIgnore}function ke(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)-1==q(n,t[r])&&n.push(t[r])}function _e(e,t){return ye(e,t).length>0}function Ce(e){e.prototype.on=function(e,t){ve(this,e,t)},e.prototype.off=function(e,t){xe(this,e,t)}}function Se(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Me(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Le(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function Te(e){Se(e),Me(e)}function De(e){return e.target||e.srcElement}function Ae(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),x&&e.ctrlKey&&1==t&&(t=3),t}var Ee,Oe,Fe=function(){if(s&&a<9)return!1;var e=A("div");return"draggable"in e||"dragDrop"in e}();function Ne(e){if(null==Ee){var t=A("span","");D(e,A("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Ee=t.offsetWidth<=1&&t.offsetHeight>2&&!(s&&a<8))}var n=Ee?A("span",""):A("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function ze(e){if(null!=Oe)return Oe;var t=D(e,document.createTextNode("AخA")),n=M(t,0,1).getBoundingClientRect(),r=M(t,1,2).getBoundingClientRect();return T(e),!(!n||n.left==n.right)&&(Oe=r.right-n.right<3)}var Pe,We=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),s=o.indexOf("\r");-1!=s?(n.push(o.slice(0,s)),t+=s+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},Ie=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},He="oncopy"in(Pe=A("div"))||(Pe.setAttribute("oncopy","return;"),"function"==typeof Pe.oncopy),Be=null;function je(e){if(null!=Be)return Be;var t=D(e,A("span","x")),n=t.getBoundingClientRect(),r=M(t,0,1).getBoundingClientRect();return Be=Math.abs(n.left-r.left)>1}var Re={},qe={};function $e(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Re[e]=t}function Ve(e,t){qe[e]=t}function Ue(e){if("string"==typeof e&&qe.hasOwnProperty(e))e=qe[e];else if(e&&"string"==typeof e.name&&qe.hasOwnProperty(e.name)){var t=qe[e.name];"string"==typeof t&&(t={name:t}),(e=ne(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ue("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ue("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Ge(e,t){t=Ue(t);var n=Re[t.name];if(!n)return Ge(e,"text/plain");var r=n(e,t);if(Ke.hasOwnProperty(t.name)){var i=Ke[t.name];for(var o in i)i.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=i[o])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var s in t.modeProps)r[s]=t.modeProps[s];return r}var Ke={};function Xe(e,t){B(t,Ke.hasOwnProperty(e)?Ke[e]:Ke[e]={})}function Ye(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function Ze(e,t){for(var n;e.innerMode&&(n=e.innerMode(t))&&n.mode!=e;)t=n.state,e=n.mode;return n||{mode:e,state:t}}function Je(e,t,n){return!e.startState||e.startState(t,n)}var Qe=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};function et(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t<o){n=i;break}t-=o}return n.lines[t]}function tt(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,(function(e){var o=e.text;i==n.line&&(o=o.slice(0,n.ch)),i==t.line&&(o=o.slice(t.ch)),r.push(o),++i})),r}function nt(e,t,n){var r=[];return e.iter(t,n,(function(e){r.push(e.text)})),r}function rt(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function it(e){if(null==e.parent)return null;for(var t=e.parent,n=q(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;r.children[i]!=t;++i)n+=r.children[i].chunkSize();return n+t.first}function ot(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],o=i.height;if(t<o){e=i;continue e}t-=o,n+=i.chunkSize()}return n}while(!e.lines);for(var s=0;s<e.lines.length;++s){var a=e.lines[s].height;if(t<a)break;t-=a}return n+s}function st(e,t){return t>=e.first&&t<e.first+e.size}function at(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function lt(e,t,n){if(void 0===n&&(n=null),!(this instanceof lt))return new lt(e,t,n);this.line=e,this.ch=t,this.sticky=n}function ct(e,t){return e.line-t.line||e.ch-t.ch}function ut(e,t){return e.sticky==t.sticky&&0==ct(e,t)}function ht(e){return lt(e.line,e.ch)}function dt(e,t){return ct(e,t)<0?t:e}function ft(e,t){return ct(e,t)<0?e:t}function pt(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function mt(e,t){if(t.line<e.first)return lt(e.first,0);var n=e.first+e.size-1;return t.line>n?lt(n,et(e,n).text.length):gt(t,et(e,t.line).text.length)}function gt(e,t){var n=e.ch;return null==n||n>t?lt(e.line,t):n<0?lt(e.line,0):e}function vt(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=mt(e,t[r]);return n}Qe.prototype.eol=function(){return this.pos>=this.string.length},Qe.prototype.sol=function(){return this.pos==this.lineStart},Qe.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Qe.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Qe.prototype.eat=function(e){var t=this.string.charAt(this.pos);if("string"==typeof e?t==e:t&&(e.test?e.test(t):e(t)))return++this.pos,t},Qe.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Qe.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Qe.prototype.skipToEnd=function(){this.pos=this.string.length},Qe.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Qe.prototype.backUp=function(e){this.pos-=e},Qe.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=j(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?j(this.string,this.lineStart,this.tabSize):0)},Qe.prototype.indentation=function(){return j(this.string,null,this.tabSize)-(this.lineStart?j(this.string,this.lineStart,this.tabSize):0)},Qe.prototype.match=function(e,t,n){if("string"!=typeof e){var r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},Qe.prototype.current=function(){return this.string.slice(this.start,this.pos)},Qe.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Qe.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Qe.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var yt=function(e,t){this.state=e,this.lookAhead=t},xt=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};function bt(e,t,n,r){var i=[e.state.modeGen],o={};Dt(e,t.text,e.doc.mode,n,(function(e,t){return i.push(e,t)}),o,r);for(var s=n.state,a=function(r){n.baseTokens=i;var a=e.state.overlays[r],l=1,c=0;n.state=!0,Dt(e,t.text,a.mode,n,(function(e,t){for(var n=l;c<e;){var r=i[l];r>e&&i.splice(l,1,e,i[l+1],r),l+=2,c=Math.min(e,r)}if(t)if(a.opaque)i.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;n<l;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"overlay "+t}}),o),n.state=s,n.baseTokens=null,n.baseTokenPos=1},l=0;l<e.state.overlays.length;++l)a(l);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function wt(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=kt(e,it(t)),i=t.text.length>e.options.maxHighlightLength&&Ye(e.doc.mode,r.state),o=bt(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),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 kt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new xt(r,!0,t);var o=At(e,t,n),s=o>r.first&&et(r,o-1).stateAfter,a=s?xt.fromSaved(r,s,o):new xt(r,Je(r.mode),o);return r.iter(o,t,(function(n){_t(e,n.text,a);var r=a.line;n.stateAfter=r==t-1||r%5==0||r>=i.viewFrom&&r<i.viewTo?a.save():null,a.nextLine()})),n&&(r.modeFrontier=a.line),a}function _t(e,t,n,r){var i=e.doc.mode,o=new Qe(t,e.options.tabSize,n);for(o.start=o.pos=r||0,""==t&&Ct(i,n.state);!o.eol();)St(i,o,n.state),o.start=o.pos}function Ct(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var n=Ze(e,t);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function St(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=Ze(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.")}xt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},xt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},xt.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},xt.fromSaved=function(e,t,n){return t instanceof yt?new xt(e,Ye(e.mode,t.state),n,t.lookAhead):new xt(e,Ye(e.mode,t),n)},xt.prototype.save=function(e){var t=!1!==e?Ye(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new yt(t,this.maxLookAhead):t};var Mt=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function Lt(e,t,n,r){var i,o,s=e.doc,a=s.mode,l=et(s,(t=mt(s,t)).line),c=kt(e,t.line,n),u=new Qe(l.text,e.options.tabSize,c);for(r&&(o=[]);(r||u.pos<t.ch)&&!u.eol();)u.start=u.pos,i=St(a,u,c.state),r&&o.push(new Mt(u,i,Ye(s.mode,c.state)));return r?o:new Mt(u,i,c.state)}function Tt(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 r=n[1]?"bgClass":"textClass";null==t[r]?t[r]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+n[2])}return e}function Dt(e,t,n,r,i,o,s){var a=n.flattenSpans;null==a&&(a=e.options.flattenSpans);var l,c=0,u=null,h=new Qe(t,e.options.tabSize,r),d=e.options.addModeClass&&[null];for(""==t&&Tt(Ct(n,r.state),o);!h.eol();){if(h.pos>e.options.maxHighlightLength?(a=!1,s&&_t(e,t,r,h.pos),h.pos=t.length,l=null):l=Tt(St(n,h,r.state,d),o),d){var f=d[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!a||u!=l){for(;c<h.start;)i(c=Math.min(h.start,c+5e3),u);u=l}h.start=h.pos}for(;c<h.pos;){var p=Math.min(h.pos,c+5e3);i(p,u),c=p}}function At(e,t,n){for(var r,i,o=e.doc,s=n?-1:t-(e.doc.mode.innerMode?1e3:100),a=t;a>s;--a){if(a<=o.first)return o.first;var l=et(o,a-1),c=l.stateAfter;if(c&&(!n||a+(c instanceof yt?c.lookAhead:0)<=o.modeFrontier))return a;var u=j(l.text,null,e.options.tabSize);(null==i||r>u)&&(i=a-1,r=u)}return i}function Et(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontier<t-10)){for(var n=e.first,r=t-1;r>n;r--){var i=et(e,r).stateAfter;if(i&&(!(i instanceof yt)||r+i.lookAhead<t)){n=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}}var Ot=!1,Ft=!1;function Nt(){Ot=!0}function zt(){Ft=!0}function Pt(e,t,n){this.marker=e,this.from=t,this.to=n}function Wt(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function It(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function Ht(e,t,n){var r=n&&window.WeakSet&&(n.markedSpans||(n.markedSpans=new WeakSet));r&&e.markedSpans&&r.has(e.markedSpans)?e.markedSpans.push(t):(e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],r&&r.add(e.markedSpans)),t.marker.attachLine(e)}function Bt(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var o=e[i],s=o.marker;if(null==o.from||(s.inclusiveLeft?o.from<=t:o.from<t)||o.from==t&&"bookmark"==s.type&&(!n||!o.marker.insertLeft)){var a=null==o.to||(s.inclusiveRight?o.to>=t:o.to>t);(r||(r=[])).push(new Pt(s,o.from,a?null:o.to))}}return r}function jt(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var o=e[i],s=o.marker;if(null==o.to||(s.inclusiveRight?o.to>=t:o.to>t)||o.from==t&&"bookmark"==s.type&&(!n||o.marker.insertLeft)){var a=null==o.from||(s.inclusiveLeft?o.from<=t:o.from<t);(r||(r=[])).push(new Pt(s,a?null:o.from-t,null==o.to?null:o.to-t))}}return r}function Rt(e,t){if(t.full)return null;var n=st(e,t.from.line)&&et(e,t.from.line).markedSpans,r=st(e,t.to.line)&&et(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,o=t.to.ch,s=0==ct(t.from,t.to),a=Bt(n,i,s),l=jt(r,o,s),c=1==t.text.length,u=J(t.text).length+(c?i:0);if(a)for(var h=0;h<a.length;++h){var d=a[h];if(null==d.to){var f=Wt(l,d.marker);f?c&&(d.to=null==f.to?null:f.to+u):d.to=i}}if(l)for(var p=0;p<l.length;++p){var m=l[p];null!=m.to&&(m.to+=u),null==m.from?Wt(a,m.marker)||(m.from=u,c&&(a||(a=[])).push(m)):(m.from+=u,c&&(a||(a=[])).push(m))}a&&(a=qt(a)),l&&l!=a&&(l=qt(l));var g=[a];if(!c){var v,y=t.text.length-2;if(y>0&&a)for(var x=0;x<a.length;++x)null==a[x].to&&(v||(v=[])).push(new Pt(a[x].marker,null,null));for(var b=0;b<y;++b)g.push(v);g.push(l)}return g}function qt(e){for(var t=0;t<e.length;++t){var n=e[t];null!=n.from&&n.from==n.to&&!1!==n.marker.clearWhenEmpty&&e.splice(t--,1)}return e.length?e:null}function $t(e,t,n){var r=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||r&&-1!=q(r,n)||(r||(r=[])).push(n)}})),!r)return null;for(var i=[{from:t,to:n}],o=0;o<r.length;++o)for(var s=r[o],a=s.find(0),l=0;l<i.length;++l){var c=i[l];if(!(ct(c.to,a.from)<0||ct(c.from,a.to)>0)){var u=[l,1],h=ct(c.from,a.from),d=ct(c.to,a.to);(h<0||!s.inclusiveLeft&&!h)&&u.push({from:c.from,to:a.from}),(d>0||!s.inclusiveRight&&!d)&&u.push({from:a.to,to:c.to}),i.splice.apply(i,u),l+=u.length-3}}return i}function Vt(e){var t=e.markedSpans;if(t){for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}}function Ut(e,t){if(t){for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}}function Gt(e){return e.inclusiveLeft?-1:0}function Kt(e){return e.inclusiveRight?1:0}function Xt(e,t){var n=e.lines.length-t.lines.length;if(0!=n)return n;var r=e.find(),i=t.find(),o=ct(r.from,i.from)||Gt(e)-Gt(t);if(o)return-o;var s=ct(r.to,i.to)||Kt(e)-Kt(t);return s||t.id-e.id}function Yt(e,t){var n,r=Ft&&e.markedSpans;if(r)for(var i=void 0,o=0;o<r.length;++o)(i=r[o]).marker.collapsed&&null==(t?i.from:i.to)&&(!n||Xt(n,i.marker)<0)&&(n=i.marker);return n}function Zt(e){return Yt(e,!0)}function Jt(e){return Yt(e,!1)}function Qt(e,t){var n,r=Ft&&e.markedSpans;if(r)for(var i=0;i<r.length;++i){var o=r[i];o.marker.collapsed&&(null==o.from||o.from<t)&&(null==o.to||o.to>t)&&(!n||Xt(n,o.marker)<0)&&(n=o.marker)}return n}function en(e,t,n,r,i){var o=et(e,t),s=Ft&&o.markedSpans;if(s)for(var a=0;a<s.length;++a){var l=s[a];if(l.marker.collapsed){var c=l.marker.find(0),u=ct(c.from,n)||Gt(l.marker)-Gt(i),h=ct(c.to,r)||Kt(l.marker)-Kt(i);if(!(u>=0&&h<=0||u<=0&&h>=0)&&(u<=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?ct(c.to,n)>=0:ct(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?ct(c.from,r)<=0:ct(c.from,r)<0)))return!0}}}function tn(e){for(var t;t=Zt(e);)e=t.find(-1,!0).line;return e}function nn(e){for(var t;t=Jt(e);)e=t.find(1,!0).line;return e}function rn(e){for(var t,n;t=Jt(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function on(e,t){var n=et(e,t),r=tn(n);return n==r?t:it(r)}function sn(e,t){if(t>e.lastLine())return t;var n,r=et(e,t);if(!an(e,r))return t;for(;n=Jt(r);)r=n.find(1,!0).line;return it(r)+1}function an(e,t){var n=Ft&&t.markedSpans;if(n)for(var r=void 0,i=0;i<n.length;++i)if((r=n[i]).marker.collapsed){if(null==r.from)return!0;if(!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&ln(e,t,r))return!0}}function ln(e,t,n){if(null==n.to){var r=n.marker.find(1,!0);return ln(e,r.line,Wt(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i=void 0,o=0;o<t.markedSpans.length;++o)if((i=t.markedSpans[o]).marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(null==i.to||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&ln(e,t,i))return!0}function cn(e){for(var t=0,n=(e=tn(e)).parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var o=n.parent;o;o=(n=o).parent)for(var s=0;s<o.children.length;++s){var a=o.children[s];if(a==n)break;t+=a.height}return t}function un(e){if(0==e.height)return 0;for(var t,n=e.text.length,r=e;t=Zt(r);){var i=t.find(0,!0);r=i.from.line,n+=i.from.ch-i.to.ch}for(r=e;t=Jt(r);){var o=t.find(0,!0);n-=r.text.length-o.from.ch,n+=(r=o.to.line).text.length-o.to.ch}return n}function hn(e){var t=e.display,n=e.doc;t.maxLine=et(n,n.first),t.maxLineLength=un(t.maxLine),t.maxLineChanged=!0,n.iter((function(e){var n=un(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)}))}var dn=function(e,t,n){this.text=e,Ut(this,t),this.height=n?n(this):1};function fn(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),Vt(e),Ut(e,n);var i=r?r(e):1;i!=e.height&&rt(e,i)}function pn(e){e.parent=null,Vt(e)}dn.prototype.lineNo=function(){return it(this)},Ce(dn);var mn={},gn={};function vn(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?gn:mn;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function yn(e,t){var n=E("span",null,null,l?"padding-right: .1px":null),r={pre:E("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,s=void 0;r.pos=0,r.addToken=bn,ze(e.display.measure)&&(s=me(o,e.doc.direction))&&(r.addToken=kn(r.addToken,s)),r.map=[],Cn(o,r,wt(e,o,t!=e.display.externalMeasured&&it(o))),o.styleClasses&&(o.styleClasses.bgClass&&(r.bgClass=z(o.styleClasses.bgClass,r.bgClass||"")),o.styleClasses.textClass&&(r.textClass=z(o.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Ne(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(l){var a=r.content.lastChild;(/\bcm-tab\b/.test(a.className)||a.querySelector&&a.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return be(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=z(r.pre.className,r.textClass||"")),r}function xn(e){var t=A("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function bn(e,t,n,r,i,o,l){if(t){var c,u=e.splitSpaces?wn(t,e.trailingSpace):t,h=e.cm.state.specialChars,d=!1;if(h.test(t)){c=document.createDocumentFragment();for(var f=0;;){h.lastIndex=f;var p=h.exec(t),m=p?p.index-f:t.length-f;if(m){var g=document.createTextNode(u.slice(f,f+m));s&&a<9?c.appendChild(A("span",[g])):c.appendChild(g),e.map.push(e.pos,e.pos+m,g),e.col+=m,e.pos+=m}if(!p)break;f+=m+1;var v=void 0;if("\t"==p[0]){var y=e.cm.options.tabSize,x=y-e.col%y;(v=c.appendChild(A("span",Z(x),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),e.col+=x}else"\r"==p[0]||"\n"==p[0]?((v=c.appendChild(A("span","\r"==p[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",p[0]),e.col+=1):((v=e.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text",p[0]),s&&a<9?c.appendChild(A("span",[v])):c.appendChild(v),e.col+=1);e.map.push(e.pos,e.pos+1,v),e.pos++}}else e.col+=t.length,c=document.createTextNode(u),e.map.push(e.pos,e.pos+t.length,c),s&&a<9&&(d=!0),e.pos+=t.length;if(e.trailingSpace=32==u.charCodeAt(t.length-1),n||r||i||d||o||l){var b=n||"";r&&(b+=r),i&&(b+=i);var w=A("span",[c],b,o);if(l)for(var k in l)l.hasOwnProperty(k)&&"style"!=k&&"class"!=k&&w.setAttribute(k,l[k]);return e.content.appendChild(w)}e.content.appendChild(c)}}function wn(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",i=0;i<e.length;i++){var o=e.charAt(i);" "!=o||!n||i!=e.length-1&&32!=e.charCodeAt(i+1)||(o=" "),r+=o,n=" "==o}return r}function kn(e,t){return function(n,r,i,o,s,a,l){i=i?i+" cm-force-border":"cm-force-border";for(var c=n.pos,u=c+r.length;;){for(var h=void 0,d=0;d<t.length&&!((h=t[d]).to>c&&h.from<=c);d++);if(h.to>=u)return e(n,r,i,o,s,a,l);e(n,r.slice(0,h.to-c),i,o,null,a,l),o=null,r=r.slice(h.to-c),c=h.to}}}function _n(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function Cn(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var s,a,l,c,u,h,d,f=i.length,p=0,m=1,g="",v=0;;){if(v==p){l=c=u=a="",d=null,h=null,v=1/0;for(var y=[],x=void 0,b=0;b<r.length;++b){var w=r[b],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&&(a=(a?a+";":"")+k.css),k.startStyle&&w.from==p&&(u+=" "+k.startStyle),k.endStyle&&w.to==v&&(x||(x=[])).push(k.endStyle,w.to),k.title&&((d||(d={})).title=k.title),k.attributes)for(var _ in k.attributes)(d||(d={}))[_]=k.attributes[_];k.collapsed&&(!h||Xt(h.marker,k)<0)&&(h=w)}else w.from>p&&v>w.from&&(v=w.from)}if(x)for(var C=0;C<x.length;C+=2)x[C+1]==v&&(c+=" "+x[C]);if(!h||h.from==p)for(var S=0;S<y.length;++S)_n(t,0,y[S]);if(h&&(h.from||0)==p){if(_n(t,(null==h.to?f+1:h.to)-p,h.marker,null==h.from),null==h.to)return;h.to==p&&(h=!1)}}if(p>=f)break;for(var M=Math.min(f,v);;){if(g){var L=p+g.length;if(!h){var T=L>M?g.slice(0,M-p):g;t.addToken(t,T,s?s+l:l,u,p+T.length==v?c:"",a,d)}if(L>=M){g=g.slice(M-p),p=M;break}p=L,u=""}g=i.slice(o,o=n[m++]),s=vn(n[m++],t.cm.options)}}else for(var D=1;D<n.length;D+=2)t.addToken(t,i.slice(o,o=n[D]),vn(n[D+1],t.cm.options))}function Sn(e,t,n){this.line=t,this.rest=rn(t),this.size=this.rest?it(J(this.rest))-n+1:1,this.node=this.text=null,this.hidden=an(e,t)}function Mn(e,t,n){for(var r,i=[],o=t;o<n;o=r){var s=new Sn(e.doc,et(e.doc,o),o);r=o+s.size,i.push(s)}return i}var Ln=null;function Tn(e){Ln?Ln.ops.push(e):e.ownsGroup=Ln={ops:[e],delayedCallbacks:[]}}function Dn(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<t.length)}function An(e,t){var n=e.ownsGroup;if(n)try{Dn(n)}finally{Ln=null,t(n)}}var En=null;function On(e,t){var n=ye(e,t);if(n.length){var r,i=Array.prototype.slice.call(arguments,2);Ln?r=Ln.delayedCallbacks:En?r=En:(r=En=[],setTimeout(Fn,0));for(var o=function(e){r.push((function(){return n[e].apply(null,i)}))},s=0;s<n.length;++s)o(s)}}function Fn(){var e=En;En=null;for(var t=0;t<e.length;++t)e[t]()}function Nn(e,t,n,r){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?In(e,t):"gutter"==o?Bn(e,t,n,r):"class"==o?Hn(e,t):"widget"==o&&jn(e,t,r)}t.changes=null}function zn(e){return e.node==e.text&&(e.node=A("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),s&&a<8&&(e.node.style.zIndex=2)),e.node}function Pn(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=zn(t);t.background=r.insertBefore(A("div",null,n),r.firstChild),e.display.input.setUneditable(t.background)}}function Wn(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):yn(e,t)}function In(e,t){var n=t.text.className,r=Wn(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,Hn(e,t)):n&&(t.text.className=n)}function Hn(e,t){Pn(e,t),t.line.wrapClass?zn(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 Bn(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 i=zn(t);t.gutterBackground=A("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),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var s=zn(t),a=t.gutter=A("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(a.setAttribute("aria-hidden","true"),e.display.input.setUneditable(a),s.insertBefore(a,t.text),t.line.gutterClass&&(a.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(A("div",at(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var l=0;l<e.display.gutterSpecs.length;++l){var c=e.display.gutterSpecs[l].className,u=o.hasOwnProperty(c)&&o[c];u&&a.appendChild(A("div",[u],"CodeMirror-gutter-elt","left: "+r.gutterLeft[c]+"px; width: "+r.gutterWidth[c]+"px"))}}}function jn(e,t,n){t.alignable&&(t.alignable=null);for(var r=S("CodeMirror-linewidget"),i=t.node.firstChild,o=void 0;i;i=o)o=i.nextSibling,r.test(i.className)&&t.node.removeChild(i);qn(e,t,n)}function Rn(e,t,n,r){var i=Wn(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),Hn(e,t),Bn(e,t,n,r),qn(e,t,r),t.node}function qn(e,t,n){if($n(e,t.line,t,n,!0),t.rest)for(var r=0;r<t.rest.length;r++)$n(e,t.rest[r],t,n,!1)}function $n(e,t,n,r,i){if(t.widgets)for(var o=zn(n),s=0,a=t.widgets;s<a.length;++s){var l=a[s],c=A("div",[l.node],"CodeMirror-linewidget"+(l.className?" "+l.className:""));l.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),Vn(l,c,n,r),e.display.input.setUneditable(c),i&&l.above?o.insertBefore(c,n.gutter||n.text):o.appendChild(c),On(l,"redraw")}}function Vn(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function Un(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!O(document.body,e.node)){var n="position: relative;";e.coverGutter&&(n+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(n+="width: "+t.display.wrapper.clientWidth+"px;"),D(t.display.measure,A("div",[e.node],null,n))}return e.height=e.node.parentNode.offsetHeight}function Gn(e,t){for(var n=De(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 Kn(e){return e.lineSpace.offsetTop}function Xn(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Yn(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=D(e.measure,A("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(e.cachedPaddingH=r),r}function Zn(e){return $-e.display.nativeBarWidth}function Jn(e){return e.display.scroller.clientWidth-Zn(e)-e.display.barWidth}function Qn(e){return e.display.scroller.clientHeight-Zn(e)-e.display.barHeight}function er(e,t,n){var r=e.options.lineWrapping,i=r&&Jn(e);if(!t.measure.heights||r&&t.measure.width!=i){var o=t.measure.heights=[];if(r){t.measure.width=i;for(var s=t.text.firstChild.getClientRects(),a=0;a<s.length-1;a++){var l=s[a],c=s[a+1];Math.abs(l.bottom-c.bottom)>2&&o.push((l.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function tr(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};if(e.rest){for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var i=0;i<e.rest.length;i++)if(it(e.rest[i])>n)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}}function nr(e,t){var n=it(t=tn(t)),r=e.display.externalMeasured=new Sn(e.doc,t,n);r.lineN=n;var i=r.built=yn(e,r);return r.text=i.pre,D(e.display.lineMeasure,i.pre),r}function rr(e,t,n,r){return sr(e,or(e,t),n,r)}function ir(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Hr(e,t)];var n=e.display.externalMeasured;return n&&t>=n.lineN&&t<n.lineN+n.size?n:void 0}function or(e,t){var n=it(t),r=ir(e,n);r&&!r.text?r=null:r&&r.changes&&(Nn(e,r,n,Nr(e)),e.curOp.forceUpdate=!0),r||(r=nr(e,t));var i=tr(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function sr(e,t,n,r,i){t.before&&(n=-1);var o,s=n+(r||"");return t.cache.hasOwnProperty(s)?o=t.cache[s]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(er(e,t.view,t.rect),t.hasHeights=!0),(o=hr(e,t,n,r)).bogus||(t.cache[s]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}var ar,lr={left:0,right:0,top:0,bottom:0};function cr(e,t,n){for(var r,i,o,s,a,l,c=0;c<e.length;c+=3)if(a=e[c],l=e[c+1],t<a?(i=0,o=1,s="left"):t<l?o=1+(i=t-a):(c==e.length-3||t==l&&e[c+3]>t)&&(i=(o=l-a)-1,t>=l&&(s="right")),null!=i){if(r=e[c+2],a==l&&n==(r.insertLeft?"left":"right")&&(s=n),"left"==n&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)r=e[2+(c-=3)],s="left";if("right"==n&&i==l-a)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)r=e[(c+=3)+2],s="right";break}return{node:r,start:i,end:o,collapse:s,coverStart:a,coverEnd:l}}function ur(e,t){var n=lr;if("left"==t)for(var r=0;r<e.length&&(n=e[r]).left==n.right;r++);else for(var i=e.length-1;i>=0&&(n=e[i]).left==n.right;i--);return n}function hr(e,t,n,r){var i,o=cr(t.map,n,r),l=o.node,c=o.start,u=o.end,h=o.collapse;if(3==l.nodeType){for(var d=0;d<4;d++){for(;c&&le(t.line.text.charAt(o.coverStart+c));)--c;for(;o.coverStart+u<o.coverEnd&&le(t.line.text.charAt(o.coverStart+u));)++u;if((i=s&&a<9&&0==c&&u==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():ur(M(l,c,u).getClientRects(),r)).left||i.right||0==c)break;u=c,c-=1,h="right"}s&&a<11&&(i=dr(e.display.measure,i))}else{var f;c>0&&(h=r="right"),i=e.options.lineWrapping&&(f=l.getClientRects()).length>1?f["right"==r?f.length-1:0]:l.getBoundingClientRect()}if(s&&a<9&&!c&&(!i||!i.left&&!i.right)){var p=l.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+Fr(e.display),top:p.top,bottom:p.bottom}:lr}for(var m=i.top-t.rect.top,g=i.bottom-t.rect.top,v=(m+g)/2,y=t.view.measure.heights,x=0;x<y.length-1&&!(v<y[x]);x++);var b=x?y[x-1]:0,w=y[x],k={left:("right"==h?i.right:i.left)-t.rect.left,right:("left"==h?i.left:i.right)-t.rect.left,top:b,bottom:w};return i.left||i.right||(k.bogus=!0),e.options.singleCursorHeightPerLine||(k.rtop=m,k.rbottom=g),k}function dr(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!je(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function fr(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]={}}function pr(e){e.display.externalMeasure=null,T(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)fr(e.display.view[t])}function mr(e){pr(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function gr(e){return u&&v?-(e.body.getBoundingClientRect().left-parseInt(getComputedStyle(e.body).marginLeft)):e.defaultView.pageXOffset||(e.documentElement||e.body).scrollLeft}f