eruda-code
Version:
Eruda plugin for running JavaScript code
1 lines • 358 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.erudaCode=e():t.erudaCode=e()}(self,(()=>(()=>{var t={845:(t,e,n)=>{"use strict";function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function r(t){var e=function(t,e){if("object"!=i(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==i(e)?e:e+""}function o(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,r(i.key),i)}}function s(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function l(){return l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},l.apply(null,arguments)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}n.d(e,{default:()=>x});var c,h=n(237),p=n.n(h),_=(n(792),n(41)),d=n.n(_),f=n(844),g=n.n(f),m=n(418),v=n.n(m),y=n(773),b=n.n(y);function w(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(w=function(){return!!t})()}function x(t){var e=t.util.evalCss,i=function(i){function h(){var t,i,r,o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,h),i=this,r=a(r=h),(t=s(i,w()?Reflect.construct(r,o||[],a(i).constructor):r.apply(i,o))).name="code",t._style=e(n(261)),t._CodeMirrorStyle=e(n(873)+n(512)),t._CodeMirrorCustomStyle=e(n(822)),t._editor=null,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}(h,i),_=h,f=[{key:"init",value:function(t,e){var n,i;l(a(h.prototype),"init",this).call(this,t,e),t.html(b()(c||(n=['<textarea class="eruda-editor">function fib(num) {\n if (num <= 2) return 1;\n return fib(num - 1) + fib(num - 2);\n }\n console.log(fib(5));</textarea>\n <div class="eruda-bottom-bar">\n <div class="eruda-btn eruda-beautify">\n Beautify\n </div>\n <div class="eruda-btn eruda-copy">\n Copy\n </div>\n <div class="eruda-btn eruda-clear">\n Clear\n </div>\n <div class="eruda-btn eruda-run">\n Run\n </div>\n </div>'],i||(i=n.slice(0)),c=Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(i)}}))))),this._bindEvent()}},{key:"show",value:function(){var t=this;if(l(a(h.prototype),"show",this).call(this),!this._editor){var e=this._$el.find(".eruda-editor").get(0);this._editor=p().fromTextArea(e,{lineNumbers:"true",mode:"javascript"}),d()((function(){return t._editor.refresh()}))}}},{key:"hide",value:function(){l(a(h.prototype),"hide",this).call(this)}},{key:"run",value:function(){try{r(this._editor.getValue())}catch(t){console.error(t)}}},{key:"beautify",value:function(){var t=this._editor,e=t.getValue();t.setValue(v()(e))}},{key:"copy",value:function(){g()(this._editor.getValue()),t.get().notify("Copied",{icon:"success"})}},{key:"clear",value:function(){this._editor.setValue("")}},{key:"destroy",value:function(){l(a(h.prototype),"destroy",this).call(this),e.remove(this._style),e.remove(this._CodeMirrorStyle),e.remove(this._CodeMirrorCustomStyle)}},{key:"_bindEvent",value:function(){var t=this;this._$el.on("click",".eruda-run",(function(){return t.run()})).on("click",".eruda-beautify",(function(){return t.beautify()})).on("click",".eruda-clear",(function(){return t.clear()})).on("click",".eruda-copy",(function(){return t.copy()}))}}],f&&o(_.prototype,f),m&&o(_,m),Object.defineProperty(_,"prototype",{writable:!1}),_;var _,f,m}(t.Tool),r=function(t){var e;try{e=eval.call(window,"(".concat(t,")"))}catch(n){e=eval.call(window,t)}return e};return new i}},954:(t,e,n)=>{t.exports=n(845).default},237:function(t){t.exports=function(){"use strict";var t=navigator.userAgent,e=navigator.platform,n=/gecko\/\d/i.test(t),i=/MSIE \d/.test(t),r=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(t),o=/Edge\/(\d+)/.exec(t),s=i||r||o,a=s&&(i?document.documentMode||6:+(o||r)[1]),l=!o&&/WebKit\//.test(t),u=l&&/Qt\/\d+\.\d+/.test(t),c=!o&&/Chrome\/(\d+)/.exec(t),h=c&&+c[1],p=/Opera\//.test(t),_=/Apple Computer/.test(navigator.vendor),d=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(t),f=/PhantomJS/.test(t),g=_&&(/Mobile\/\w+/.test(t)||navigator.maxTouchPoints>2),m=/Android/.test(t),v=g||m||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(t),y=g||/Mac/.test(e),b=/\bCrOS\b/.test(t),w=/win/i.test(e),x=p&&t.match(/Version\/(\d*\.\d*)/);x&&(x=Number(x[1])),x&&x>=15&&(p=!1,l=!0);var k=y&&(u||p&&(null==x||x<12.11)),C=n||s&&a>=9;function T(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}var S,O=function(t,e){var n=t.className,i=T(e).exec(n);if(i){var r=n.slice(i.index+i[0].length);t.className=n.slice(0,i.index)+(r?i[1]+r:"")}};function M(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function L(t,e){return M(t).appendChild(e)}function E(t,e,n,i){var r=document.createElement(t);if(n&&(r.className=n),i&&(r.style.cssText=i),"string"==typeof e)r.appendChild(document.createTextNode(e));else if(e)for(var o=0;o<e.length;++o)r.appendChild(e[o]);return r}function A(t,e,n,i){var r=E(t,e,n,i);return r.setAttribute("role","presentation"),r}function N(t,e){if(3==e.nodeType&&(e=e.parentNode),t.contains)return t.contains(e);do{if(11==e.nodeType&&(e=e.host),e==t)return!0}while(e=e.parentNode)}function R(t){var e,n=t.ownerDocument||t;try{e=t.activeElement}catch(t){e=n.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function D(t,e){var n=t.className;T(e).test(n)||(t.className+=(n?" ":"")+e)}function W(t,e){for(var n=t.split(" "),i=0;i<n.length;i++)n[i]&&!T(n[i]).test(e)&&(e+=" "+n[i]);return e}S=document.createRange?function(t,e,n,i){var r=document.createRange();return r.setEnd(i||t,n),r.setStart(t,e),r}:function(t,e,n){var i=document.body.createTextRange();try{i.moveToElementText(t.parentNode)}catch(t){return i}return i.collapse(!0),i.moveEnd("character",n),i.moveStart("character",e),i};var z=function(t){t.select()};function P(t){return t.display.wrapper.ownerDocument}function I(t){return F(t.display.wrapper)}function F(t){return t.getRootNode?t.getRootNode():t.ownerDocument}function j(t){return P(t).defaultView}function B(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e)}}function H(t,e,n){for(var i in e||(e={}),t)!t.hasOwnProperty(i)||!1===n&&e.hasOwnProperty(i)||(e[i]=t[i]);return e}function U(t,e,n,i,r){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);for(var o=i||0,s=r||0;;){var a=t.indexOf("\t",o);if(a<0||a>=e)return s+(e-o);s+=a-o,s+=n-s%n,o=a+1}}g?z=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:s&&(z=function(t){try{t.select()}catch(t){}});var K=function(){this.id=null,this.f=null,this.time=0,this.handler=B(this.onTimeout,this)};function V(t,e){for(var n=0;n<t.length;++n)if(t[n]==e)return n;return-1}K.prototype.onTimeout=function(t){t.id=0,t.time<=+new Date?t.f():setTimeout(t.handler,t.time-+new Date)},K.prototype.set=function(t,e){this.f=e;var n=+new Date+t;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,t),this.time=n)};var G=50,X={toString:function(){return"CodeMirror.Pass"}},$={scroll:!1},q={origin:"*mouse"},Y={origin:"+move"};function Q(t,e,n){for(var i=0,r=0;;){var o=t.indexOf("\t",i);-1==o&&(o=t.length);var s=o-i;if(o==t.length||r+s>=e)return i+Math.min(s,e-r);if(r+=o-i,i=o+1,(r+=n-r%n)>=e)return i}}var Z=[""];function J(t){for(;Z.length<=t;)Z.push(tt(Z)+" ");return Z[t]}function tt(t){return t[t.length-1]}function et(t,e){for(var n=[],i=0;i<t.length;i++)n[i]=e(t[i],i);return n}function nt(t,e,n){for(var i=0,r=n(e);i<t.length&&n(t[i])<=r;)i++;t.splice(i,0,e)}function it(){}function rt(t,e){var n;return Object.create?n=Object.create(t):(it.prototype=t,n=new it),e&&H(e,n),n}var ot=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function st(t){return/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||ot.test(t))}function at(t,e){return e?!!(e.source.indexOf("\\w")>-1&&st(t))||e.test(t):st(t)}function lt(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}var ut=/[\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 ct(t){return t.charCodeAt(0)>=768&&ut.test(t)}function ht(t,e,n){for(;(n<0?e>0:e<t.length)&&ct(t.charAt(e));)e+=n;return e}function pt(t,e,n){for(var i=e>n?-1:1;;){if(e==n)return e;var r=(e+n)/2,o=i<0?Math.ceil(r):Math.floor(r);if(o==e)return t(o)?e:n;t(o)?n=o:e=o+i}}function _t(t,e,n,i){if(!t)return i(e,n,"ltr",0);for(var r=!1,o=0;o<t.length;++o){var s=t[o];(s.from<n&&s.to>e||e==n&&s.to==e)&&(i(Math.max(s.from,e),Math.min(s.to,n),1==s.level?"rtl":"ltr",o),r=!0)}r||i(e,n,"ltr")}var dt=null;function ft(t,e,n){var i;dt=null;for(var r=0;r<t.length;++r){var o=t[r];if(o.from<e&&o.to>e)return r;o.to==e&&(o.from!=o.to&&"before"==n?i=r:dt=r),o.from==e&&(o.from!=o.to&&"before"!=n?i=r:dt=r)}return null!=i?i:dt}var gt=function(){var t="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",e="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(n){return n<=247?t.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1785?e.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":8204==n?"b":"L"}var i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,r=/[stwN]/,o=/[LRr]/,s=/[Lb1n]/,a=/[1n]/;function l(t,e,n){this.level=t,this.from=e,this.to=n}return function(t,e){var u="ltr"==e?"L":"R";if(0==t.length||"ltr"==e&&!i.test(t))return!1;for(var c=t.length,h=[],p=0;p<c;++p)h.push(n(t.charCodeAt(p)));for(var _=0,d=u;_<c;++_){var f=h[_];"m"==f?h[_]=d:d=f}for(var g=0,m=u;g<c;++g){var v=h[g];"1"==v&&"r"==m?h[g]="n":o.test(v)&&(m=v,"r"==v&&(h[g]="R"))}for(var y=1,b=h[0];y<c-1;++y){var w=h[y];"+"==w&&"1"==b&&"1"==h[y+1]?h[y]="1":","!=w||b!=h[y+1]||"1"!=b&&"n"!=b||(h[y]=b),b=w}for(var x=0;x<c;++x){var k=h[x];if(","==k)h[x]="N";else if("%"==k){var C=void 0;for(C=x+1;C<c&&"%"==h[C];++C);for(var T=x&&"!"==h[x-1]||C<c&&"1"==h[C]?"1":"N",S=x;S<C;++S)h[S]=T;x=C-1}}for(var O=0,M=u;O<c;++O){var L=h[O];"L"==M&&"1"==L?h[O]="L":o.test(L)&&(M=L)}for(var E=0;E<c;++E)if(r.test(h[E])){var A=void 0;for(A=E+1;A<c&&r.test(h[A]);++A);for(var N="L"==(E?h[E-1]:u),R=N==("L"==(A<c?h[A]:u))?N?"L":"R":u,D=E;D<A;++D)h[D]=R;E=A-1}for(var W,z=[],P=0;P<c;)if(s.test(h[P])){var I=P;for(++P;P<c&&s.test(h[P]);++P);z.push(new l(0,I,P))}else{var F=P,j=z.length,B="rtl"==e?1:0;for(++P;P<c&&"L"!=h[P];++P);for(var H=F;H<P;)if(a.test(h[H])){F<H&&(z.splice(j,0,new l(1,F,H)),j+=B);var U=H;for(++H;H<P&&a.test(h[H]);++H);z.splice(j,0,new l(2,U,H)),j+=B,F=H}else++H;F<P&&z.splice(j,0,new l(1,F,P))}return"ltr"==e&&(1==z[0].level&&(W=t.match(/^\s+/))&&(z[0].from=W[0].length,z.unshift(new l(0,0,W[0].length))),1==tt(z).level&&(W=t.match(/\s+$/))&&(tt(z).to-=W[0].length,z.push(new l(0,c-W[0].length,c)))),"rtl"==e?z.reverse():z}}();function mt(t,e){var n=t.order;return null==n&&(n=t.order=gt(t.text,e)),n}var vt=[],yt=function(t,e,n){if(t.addEventListener)t.addEventListener(e,n,!1);else if(t.attachEvent)t.attachEvent("on"+e,n);else{var i=t._handlers||(t._handlers={});i[e]=(i[e]||vt).concat(n)}};function bt(t,e){return t._handlers&&t._handlers[e]||vt}function wt(t,e,n){if(t.removeEventListener)t.removeEventListener(e,n,!1);else if(t.detachEvent)t.detachEvent("on"+e,n);else{var i=t._handlers,r=i&&i[e];if(r){var o=V(r,n);o>-1&&(i[e]=r.slice(0,o).concat(r.slice(o+1)))}}}function xt(t,e){var n=bt(t,e);if(n.length)for(var i=Array.prototype.slice.call(arguments,2),r=0;r<n.length;++r)n[r].apply(null,i)}function kt(t,e,n){return"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}}),xt(t,n||e.type,t,e),Lt(e)||e.codemirrorIgnore}function Ct(t){var e=t._handlers&&t._handlers.cursorActivity;if(e)for(var n=t.curOp.cursorActivityHandlers||(t.curOp.cursorActivityHandlers=[]),i=0;i<e.length;++i)-1==V(n,e[i])&&n.push(e[i])}function Tt(t,e){return bt(t,e).length>0}function St(t){t.prototype.on=function(t,e){yt(this,t,e)},t.prototype.off=function(t,e){wt(this,t,e)}}function Ot(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function Mt(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function Lt(t){return null!=t.defaultPrevented?t.defaultPrevented:0==t.returnValue}function Et(t){Ot(t),Mt(t)}function At(t){return t.target||t.srcElement}function Nt(t){var e=t.which;return null==e&&(1&t.button?e=1:2&t.button?e=3:4&t.button&&(e=2)),y&&t.ctrlKey&&1==e&&(e=3),e}var Rt,Dt,Wt=function(){if(s&&a<9)return!1;var t=E("div");return"draggable"in t||"dragDrop"in t}();function zt(t){if(null==Rt){var e=E("span","");L(t,E("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(Rt=e.offsetWidth<=1&&e.offsetHeight>2&&!(s&&a<8))}var n=Rt?E("span",""):E("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Pt(t){if(null!=Dt)return Dt;var e=L(t,document.createTextNode("AخA")),n=S(e,0,1).getBoundingClientRect(),i=S(e,1,2).getBoundingClientRect();return M(t),!(!n||n.left==n.right)&&(Dt=i.right-n.right<3)}var It,Ft=3!="\n\nb".split(/\n/).length?function(t){for(var e=0,n=[],i=t.length;e<=i;){var r=t.indexOf("\n",e);-1==r&&(r=t.length);var o=t.slice(e,"\r"==t.charAt(r-1)?r-1:r),s=o.indexOf("\r");-1!=s?(n.push(o.slice(0,s)),e+=s+1):(n.push(o),e=r+1)}return n}:function(t){return t.split(/\r\n?|\n/)},jt=window.getSelection?function(t){try{return t.selectionStart!=t.selectionEnd}catch(t){return!1}}:function(t){var e;try{e=t.ownerDocument.selection.createRange()}catch(t){}return!(!e||e.parentElement()!=t)&&0!=e.compareEndPoints("StartToEnd",e)},Bt="oncopy"in(It=E("div"))||(It.setAttribute("oncopy","return;"),"function"==typeof It.oncopy),Ht=null;function Ut(t){if(null!=Ht)return Ht;var e=L(t,E("span","x")),n=e.getBoundingClientRect(),i=S(e,0,1).getBoundingClientRect();return Ht=Math.abs(n.left-i.left)>1}var Kt={},Vt={};function Gt(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),Kt[t]=e}function Xt(t,e){Vt[t]=e}function $t(t){if("string"==typeof t&&Vt.hasOwnProperty(t))t=Vt[t];else if(t&&"string"==typeof t.name&&Vt.hasOwnProperty(t.name)){var e=Vt[t.name];"string"==typeof e&&(e={name:e}),(t=rt(e,t)).name=e.name}else{if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return $t("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return $t("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function qt(t,e){e=$t(e);var n=Kt[e.name];if(!n)return qt(t,"text/plain");var i=n(t,e);if(Yt.hasOwnProperty(e.name)){var r=Yt[e.name];for(var o in r)r.hasOwnProperty(o)&&(i.hasOwnProperty(o)&&(i["_"+o]=i[o]),i[o]=r[o])}if(i.name=e.name,e.helperType&&(i.helperType=e.helperType),e.modeProps)for(var s in e.modeProps)i[s]=e.modeProps[s];return i}var Yt={};function Qt(t,e){H(e,Yt.hasOwnProperty(t)?Yt[t]:Yt[t]={})}function Zt(t,e){if(!0===e)return e;if(t.copyState)return t.copyState(e);var n={};for(var i in e){var r=e[i];r instanceof Array&&(r=r.concat([])),n[i]=r}return n}function Jt(t,e){for(var n;t.innerMode&&(n=t.innerMode(e))&&n.mode!=t;)e=n.state,t=n.mode;return n||{mode:t,state:e}}function te(t,e,n){return!t.startState||t.startState(e,n)}var ee=function(t,e,n){this.pos=this.start=0,this.string=t,this.tabSize=e||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};function ne(t,e){if((e-=t.first)<0||e>=t.size)throw new Error("There is no line "+(e+t.first)+" in the document.");for(var n=t;!n.lines;)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(e<o){n=r;break}e-=o}return n.lines[e]}function ie(t,e,n){var i=[],r=e.line;return t.iter(e.line,n.line+1,(function(t){var o=t.text;r==n.line&&(o=o.slice(0,n.ch)),r==e.line&&(o=o.slice(e.ch)),i.push(o),++r})),i}function re(t,e,n){var i=[];return t.iter(e,n,(function(t){i.push(t.text)})),i}function oe(t,e){var n=e-t.height;if(n)for(var i=t;i;i=i.parent)i.height+=n}function se(t){if(null==t.parent)return null;for(var e=t.parent,n=V(e.lines,t),i=e.parent;i;e=i,i=i.parent)for(var r=0;i.children[r]!=e;++r)n+=i.children[r].chunkSize();return n+e.first}function ae(t,e){var n=t.first;t:do{for(var i=0;i<t.children.length;++i){var r=t.children[i],o=r.height;if(e<o){t=r;continue t}e-=o,n+=r.chunkSize()}return n}while(!t.lines);for(var s=0;s<t.lines.length;++s){var a=t.lines[s].height;if(e<a)break;e-=a}return n+s}function le(t,e){return e>=t.first&&e<t.first+t.size}function ue(t,e){return String(t.lineNumberFormatter(e+t.firstLineNumber))}function ce(t,e,n){if(void 0===n&&(n=null),!(this instanceof ce))return new ce(t,e,n);this.line=t,this.ch=e,this.sticky=n}function he(t,e){return t.line-e.line||t.ch-e.ch}function pe(t,e){return t.sticky==e.sticky&&0==he(t,e)}function _e(t){return ce(t.line,t.ch)}function de(t,e){return he(t,e)<0?e:t}function fe(t,e){return he(t,e)<0?t:e}function ge(t,e){return Math.max(t.first,Math.min(e,t.first+t.size-1))}function me(t,e){if(e.line<t.first)return ce(t.first,0);var n=t.first+t.size-1;return e.line>n?ce(n,ne(t,n).text.length):ve(e,ne(t,e.line).text.length)}function ve(t,e){var n=t.ch;return null==n||n>e?ce(t.line,e):n<0?ce(t.line,0):t}function ye(t,e){for(var n=[],i=0;i<e.length;i++)n[i]=me(t,e[i]);return n}ee.prototype.eol=function(){return this.pos>=this.string.length},ee.prototype.sol=function(){return this.pos==this.lineStart},ee.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ee.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},ee.prototype.eat=function(t){var e=this.string.charAt(this.pos);if("string"==typeof t?e==t:e&&(t.test?t.test(e):t(e)))return++this.pos,e},ee.prototype.eatWhile=function(t){for(var e=this.pos;this.eat(t););return this.pos>e},ee.prototype.eatSpace=function(){for(var t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t},ee.prototype.skipToEnd=function(){this.pos=this.string.length},ee.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},ee.prototype.backUp=function(t){this.pos-=t},ee.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=U(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?U(this.string,this.lineStart,this.tabSize):0)},ee.prototype.indentation=function(){return U(this.string,null,this.tabSize)-(this.lineStart?U(this.string,this.lineStart,this.tabSize):0)},ee.prototype.match=function(t,e,n){if("string"!=typeof t){var i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}var r=function(t){return n?t.toLowerCase():t};if(r(this.string.substr(this.pos,t.length))==r(t))return!1!==e&&(this.pos+=t.length),!0},ee.prototype.current=function(){return this.string.slice(this.start,this.pos)},ee.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},ee.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},ee.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var be=function(t,e){this.state=t,this.lookAhead=e},we=function(t,e,n,i){this.state=e,this.doc=t,this.line=n,this.maxLookAhead=i||0,this.baseTokens=null,this.baseTokenPos=1};function xe(t,e,n,i){var r=[t.state.modeGen],o={};Ae(t,e.text,t.doc.mode,n,(function(t,e){return r.push(t,e)}),o,i);for(var s=n.state,a=function(i){n.baseTokens=r;var a=t.state.overlays[i],l=1,u=0;n.state=!0,Ae(t,e.text,a.mode,n,(function(t,e){for(var n=l;u<t;){var i=r[l];i>t&&r.splice(l,1,t,r[l+1],i),l+=2,u=Math.min(t,i)}if(e)if(a.opaque)r.splice(n,l-n,t,"overlay "+e),l=n+2;else for(;n<l;n+=2){var o=r[n+1];r[n+1]=(o?o+" ":"")+"overlay "+e}}),o),n.state=s,n.baseTokens=null,n.baseTokenPos=1},l=0;l<t.state.overlays.length;++l)a(l);return{styles:r,classes:o.bgClass||o.textClass?o:null}}function ke(t,e,n){if(!e.styles||e.styles[0]!=t.state.modeGen){var i=Ce(t,se(e)),r=e.text.length>t.options.maxHighlightLength&&Zt(t.doc.mode,i.state),o=xe(t,e,i);r&&(i.state=r),e.stateAfter=i.save(!r),e.styles=o.styles,o.classes?e.styleClasses=o.classes:e.styleClasses&&(e.styleClasses=null),n===t.doc.highlightFrontier&&(t.doc.modeFrontier=Math.max(t.doc.modeFrontier,++t.doc.highlightFrontier))}return e.styles}function Ce(t,e,n){var i=t.doc,r=t.display;if(!i.mode.startState)return new we(i,!0,e);var o=Ne(t,e,n),s=o>i.first&&ne(i,o-1).stateAfter,a=s?we.fromSaved(i,s,o):new we(i,te(i.mode),o);return i.iter(o,e,(function(n){Te(t,n.text,a);var i=a.line;n.stateAfter=i==e-1||i%5==0||i>=r.viewFrom&&i<r.viewTo?a.save():null,a.nextLine()})),n&&(i.modeFrontier=a.line),a}function Te(t,e,n,i){var r=t.doc.mode,o=new ee(e,t.options.tabSize,n);for(o.start=o.pos=i||0,""==e&&Se(r,n.state);!o.eol();)Oe(r,o,n.state),o.start=o.pos}function Se(t,e){if(t.blankLine)return t.blankLine(e);if(t.innerMode){var n=Jt(t,e);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Oe(t,e,n,i){for(var r=0;r<10;r++){i&&(i[0]=Jt(t,n).mode);var o=t.token(e,n);if(e.pos>e.start)return o}throw new Error("Mode "+t.name+" failed to advance stream.")}we.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},we.prototype.baseToken=function(t){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=t;)this.baseTokenPos+=2;var e=this.baseTokens[this.baseTokenPos+1];return{type:e&&e.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-t}},we.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},we.fromSaved=function(t,e,n){return e instanceof be?new we(t,Zt(t.mode,e.state),n,e.lookAhead):new we(t,Zt(t.mode,e),n)},we.prototype.save=function(t){var e=!1!==t?Zt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new be(e,this.maxLookAhead):e};var Me=function(t,e,n){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=n};function Le(t,e,n,i){var r,o,s=t.doc,a=s.mode,l=ne(s,(e=me(s,e)).line),u=Ce(t,e.line,n),c=new ee(l.text,t.options.tabSize,u);for(i&&(o=[]);(i||c.pos<e.ch)&&!c.eol();)c.start=c.pos,r=Oe(a,c,u.state),i&&o.push(new Me(c,r,Zt(s.mode,u.state)));return i?o:new Me(c,r,u.state)}function Ee(t,e){if(t)for(;;){var n=t.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;t=t.slice(0,n.index)+t.slice(n.index+n[0].length);var i=n[1]?"bgClass":"textClass";null==e[i]?e[i]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(e[i])||(e[i]+=" "+n[2])}return t}function Ae(t,e,n,i,r,o,s){var a=n.flattenSpans;null==a&&(a=t.options.flattenSpans);var l,u=0,c=null,h=new ee(e,t.options.tabSize,i),p=t.options.addModeClass&&[null];for(""==e&&Ee(Se(n,i.state),o);!h.eol();){if(h.pos>t.options.maxHighlightLength?(a=!1,s&&Te(t,e,i,h.pos),h.pos=e.length,l=null):l=Ee(Oe(n,h,i.state,p),o),p){var _=p[0].name;_&&(l="m-"+(l?_+" "+l:_))}if(!a||c!=l){for(;u<h.start;)r(u=Math.min(h.start,u+5e3),c);c=l}h.start=h.pos}for(;u<h.pos;){var d=Math.min(h.pos,u+5e3);r(d,c),u=d}}function Ne(t,e,n){for(var i,r,o=t.doc,s=n?-1:e-(t.doc.mode.innerMode?1e3:100),a=e;a>s;--a){if(a<=o.first)return o.first;var l=ne(o,a-1),u=l.stateAfter;if(u&&(!n||a+(u instanceof be?u.lookAhead:0)<=o.modeFrontier))return a;var c=U(l.text,null,t.options.tabSize);(null==r||i>c)&&(r=a-1,i=c)}return r}function Re(t,e){if(t.modeFrontier=Math.min(t.modeFrontier,e),!(t.highlightFrontier<e-10)){for(var n=t.first,i=e-1;i>n;i--){var r=ne(t,i).stateAfter;if(r&&(!(r instanceof be)||i+r.lookAhead<e)){n=i+1;break}}t.highlightFrontier=Math.min(t.highlightFrontier,n)}}var De=!1,We=!1;function ze(){De=!0}function Pe(){We=!0}function Ie(t,e,n){this.marker=t,this.from=e,this.to=n}function Fe(t,e){if(t)for(var n=0;n<t.length;++n){var i=t[n];if(i.marker==e)return i}}function je(t,e){for(var n,i=0;i<t.length;++i)t[i]!=e&&(n||(n=[])).push(t[i]);return n}function Be(t,e,n){var i=n&&window.WeakSet&&(n.markedSpans||(n.markedSpans=new WeakSet));i&&t.markedSpans&&i.has(t.markedSpans)?t.markedSpans.push(e):(t.markedSpans=t.markedSpans?t.markedSpans.concat([e]):[e],i&&i.add(t.markedSpans)),e.marker.attachLine(t)}function He(t,e,n){var i;if(t)for(var r=0;r<t.length;++r){var o=t[r],s=o.marker;if(null==o.from||(s.inclusiveLeft?o.from<=e:o.from<e)||o.from==e&&"bookmark"==s.type&&(!n||!o.marker.insertLeft)){var a=null==o.to||(s.inclusiveRight?o.to>=e:o.to>e);(i||(i=[])).push(new Ie(s,o.from,a?null:o.to))}}return i}function Ue(t,e,n){var i;if(t)for(var r=0;r<t.length;++r){var o=t[r],s=o.marker;if(null==o.to||(s.inclusiveRight?o.to>=e:o.to>e)||o.from==e&&"bookmark"==s.type&&(!n||o.marker.insertLeft)){var a=null==o.from||(s.inclusiveLeft?o.from<=e:o.from<e);(i||(i=[])).push(new Ie(s,a?null:o.from-e,null==o.to?null:o.to-e))}}return i}function Ke(t,e){if(e.full)return null;var n=le(t,e.from.line)&&ne(t,e.from.line).markedSpans,i=le(t,e.to.line)&&ne(t,e.to.line).markedSpans;if(!n&&!i)return null;var r=e.from.ch,o=e.to.ch,s=0==he(e.from,e.to),a=He(n,r,s),l=Ue(i,o,s),u=1==e.text.length,c=tt(e.text).length+(u?r:0);if(a)for(var h=0;h<a.length;++h){var p=a[h];if(null==p.to){var _=Fe(l,p.marker);_?u&&(p.to=null==_.to?null:_.to+c):p.to=r}}if(l)for(var d=0;d<l.length;++d){var f=l[d];null!=f.to&&(f.to+=c),null==f.from?Fe(a,f.marker)||(f.from=c,u&&(a||(a=[])).push(f)):(f.from+=c,u&&(a||(a=[])).push(f))}a&&(a=Ve(a)),l&&l!=a&&(l=Ve(l));var g=[a];if(!u){var m,v=e.text.length-2;if(v>0&&a)for(var y=0;y<a.length;++y)null==a[y].to&&(m||(m=[])).push(new Ie(a[y].marker,null,null));for(var b=0;b<v;++b)g.push(m);g.push(l)}return g}function Ve(t){for(var e=0;e<t.length;++e){var n=t[e];null!=n.from&&n.from==n.to&&!1!==n.marker.clearWhenEmpty&&t.splice(e--,1)}return t.length?t:null}function Ge(t,e,n){var i=null;if(t.iter(e.line,n.line+1,(function(t){if(t.markedSpans)for(var e=0;e<t.markedSpans.length;++e){var n=t.markedSpans[e].marker;!n.readOnly||i&&-1!=V(i,n)||(i||(i=[])).push(n)}})),!i)return null;for(var r=[{from:e,to:n}],o=0;o<i.length;++o)for(var s=i[o],a=s.find(0),l=0;l<r.length;++l){var u=r[l];if(!(he(u.to,a.from)<0||he(u.from,a.to)>0)){var c=[l,1],h=he(u.from,a.from),p=he(u.to,a.to);(h<0||!s.inclusiveLeft&&!h)&&c.push({from:u.from,to:a.from}),(p>0||!s.inclusiveRight&&!p)&&c.push({from:a.to,to:u.to}),r.splice.apply(r,c),l+=c.length-3}}return r}function Xe(t){var e=t.markedSpans;if(e){for(var n=0;n<e.length;++n)e[n].marker.detachLine(t);t.markedSpans=null}}function $e(t,e){if(e){for(var n=0;n<e.length;++n)e[n].marker.attachLine(t);t.markedSpans=e}}function qe(t){return t.inclusiveLeft?-1:0}function Ye(t){return t.inclusiveRight?1:0}function Qe(t,e){var n=t.lines.length-e.lines.length;if(0!=n)return n;var i=t.find(),r=e.find(),o=he(i.from,r.from)||qe(t)-qe(e);if(o)return-o;var s=he(i.to,r.to)||Ye(t)-Ye(e);return s||e.id-t.id}function Ze(t,e){var n,i=We&&t.markedSpans;if(i)for(var r=void 0,o=0;o<i.length;++o)(r=i[o]).marker.collapsed&&null==(e?r.from:r.to)&&(!n||Qe(n,r.marker)<0)&&(n=r.marker);return n}function Je(t){return Ze(t,!0)}function tn(t){return Ze(t,!1)}function en(t,e){var n,i=We&&t.markedSpans;if(i)for(var r=0;r<i.length;++r){var o=i[r];o.marker.collapsed&&(null==o.from||o.from<e)&&(null==o.to||o.to>e)&&(!n||Qe(n,o.marker)<0)&&(n=o.marker)}return n}function nn(t,e,n,i,r){var o=ne(t,e),s=We&&o.markedSpans;if(s)for(var a=0;a<s.length;++a){var l=s[a];if(l.marker.collapsed){var u=l.marker.find(0),c=he(u.from,n)||qe(l.marker)-qe(r),h=he(u.to,i)||Ye(l.marker)-Ye(r);if(!(c>=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?he(u.to,n)>=0:he(u.to,n)>0)||c>=0&&(l.marker.inclusiveRight&&r.inclusiveLeft?he(u.from,i)<=0:he(u.from,i)<0)))return!0}}}function rn(t){for(var e;e=Je(t);)t=e.find(-1,!0).line;return t}function on(t){for(var e;e=tn(t);)t=e.find(1,!0).line;return t}function sn(t){for(var e,n;e=tn(t);)t=e.find(1,!0).line,(n||(n=[])).push(t);return n}function an(t,e){var n=ne(t,e),i=rn(n);return n==i?e:se(i)}function ln(t,e){if(e>t.lastLine())return e;var n,i=ne(t,e);if(!un(t,i))return e;for(;n=tn(i);)i=n.find(1,!0).line;return se(i)+1}function un(t,e){var n=We&&e.markedSpans;if(n)for(var i=void 0,r=0;r<n.length;++r)if((i=n[r]).marker.collapsed){if(null==i.from)return!0;if(!i.marker.widgetNode&&0==i.from&&i.marker.inclusiveLeft&&cn(t,e,i))return!0}}function cn(t,e,n){if(null==n.to){var i=n.marker.find(1,!0);return cn(t,i.line,Fe(i.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==e.text.length)return!0;for(var r=void 0,o=0;o<e.markedSpans.length;++o)if((r=e.markedSpans[o]).marker.collapsed&&!r.marker.widgetNode&&r.from==n.to&&(null==r.to||r.to!=n.from)&&(r.marker.inclusiveLeft||n.marker.inclusiveRight)&&cn(t,e,r))return!0}function hn(t){for(var e=0,n=(t=rn(t)).parent,i=0;i<n.lines.length;++i){var r=n.lines[i];if(r==t)break;e+=r.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;e+=a.height}return e}function pn(t){if(0==t.height)return 0;for(var e,n=t.text.length,i=t;e=Je(i);){var r=e.find(0,!0);i=r.from.line,n+=r.from.ch-r.to.ch}for(i=t;e=tn(i);){var o=e.find(0,!0);n-=i.text.length-o.from.ch,n+=(i=o.to.line).text.length-o.to.ch}return n}function _n(t){var e=t.display,n=t.doc;e.maxLine=ne(n,n.first),e.maxLineLength=pn(e.maxLine),e.maxLineChanged=!0,n.iter((function(t){var n=pn(t);n>e.maxLineLength&&(e.maxLineLength=n,e.maxLine=t)}))}var dn=function(t,e,n){this.text=t,$e(this,e),this.height=n?n(this):1};function fn(t,e,n,i){t.text=e,t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null),null!=t.order&&(t.order=null),Xe(t),$e(t,n);var r=i?i(t):1;r!=t.height&&oe(t,r)}function gn(t){t.parent=null,Xe(t)}dn.prototype.lineNo=function(){return se(this)},St(dn);var mn={},vn={};function yn(t,e){if(!t||/^\s*$/.test(t))return null;var n=e.addModeClass?vn:mn;return n[t]||(n[t]=t.replace(/\S+/g,"cm-$&"))}function bn(t,e){var n=A("span",null,null,l?"padding-right: .1px":null),i={pre:A("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:t,trailingSpace:!1,splitSpaces:t.getOption("lineWrapping")};e.measure={};for(var r=0;r<=(e.rest?e.rest.length:0);r++){var o=r?e.rest[r-1]:e.line,s=void 0;i.pos=0,i.addToken=xn,Pt(t.display.measure)&&(s=mt(o,t.doc.direction))&&(i.addToken=Cn(i.addToken,s)),i.map=[],Sn(o,i,ke(t,o,e!=t.display.externalMeasured&&se(o))),o.styleClasses&&(o.styleClasses.bgClass&&(i.bgClass=W(o.styleClasses.bgClass,i.bgClass||"")),o.styleClasses.textClass&&(i.textClass=W(o.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(zt(t.display.measure))),0==r?(e.measure.map=i.map,e.measure.cache={}):((e.measure.maps||(e.measure.maps=[])).push(i.map),(e.measure.caches||(e.measure.caches=[])).push({}))}if(l){var a=i.content.lastChild;(/\bcm-tab\b/.test(a.className)||a.querySelector&&a.querySelector(".cm-tab"))&&(i.content.className="cm-tab-wrap-hack")}return xt(t,"renderLine",t,e.line,i.pre),i.pre.className&&(i.textClass=W(i.pre.className,i.textClass||"")),i}function wn(t){var e=E("span","•","cm-invalidchar");return e.title="\\u"+t.charCodeAt(0).toString(16),e.setAttribute("aria-label",e.title),e}function xn(t,e,n,i,r,o,l){if(e){var u,c=t.splitSpaces?kn(e,t.trailingSpace):e,h=t.cm.state.specialChars,p=!1;if(h.test(e)){u=document.createDocumentFragment();for(var _=0;;){h.lastIndex=_;var d=h.exec(e),f=d?d.index-_:e.length-_;if(f){var g=document.createTextNode(c.slice(_,_+f));s&&a<9?u.appendChild(E("span",[g])):u.appendChild(g),t.map.push(t.pos,t.pos+f,g),t.col+=f,t.pos+=f}if(!d)break;_+=f+1;var m=void 0;if("\t"==d[0]){var v=t.cm.options.tabSize,y=v-t.col%v;(m=u.appendChild(E("span",J(y),"cm-tab"))).setAttribute("role","presentation"),m.setAttribute("cm-text","\t"),t.col+=y}else"\r"==d[0]||"\n"==d[0]?((m=u.appendChild(E("span","\r"==d[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",d[0]),t.col+=1):((m=t.cm.options.specialCharPlaceholder(d[0])).setAttribute("cm-text",d[0]),s&&a<9?u.appendChild(E("span",[m])):u.appendChild(m),t.col+=1);t.map.push(t.pos,t.pos+1,m),t.pos++}}else t.col+=e.length,u=document.createTextNode(c),t.map.push(t.pos,t.pos+e.length,u),s&&a<9&&(p=!0),t.pos+=e.length;if(t.trailingSpace=32==c.charCodeAt(e.length-1),n||i||r||p||o||l){var b=n||"";i&&(b+=i),r&&(b+=r);var w=E("span",[u],b,o);if(l)for(var x in l)l.hasOwnProperty(x)&&"style"!=x&&"class"!=x&&w.setAttribute(x,l[x]);return t.content.appendChild(w)}t.content.appendChild(u)}}function kn(t,e){if(t.length>1&&!/ /.test(t))return t;for(var n=e,i="",r=0;r<t.length;r++){var o=t.charAt(r);" "!=o||!n||r!=t.length-1&&32!=t.charCodeAt(r+1)||(o=" "),i+=o,n=" "==o}return i}function Cn(t,e){return function(n,i,r,o,s,a,l){r=r?r+" cm-force-border":"cm-force-border";for(var u=n.pos,c=u+i.length;;){for(var h=void 0,p=0;p<e.length&&!((h=e[p]).to>u&&h.from<=u);p++);if(h.to>=c)return t(n,i,r,o,s,a,l);t(n,i.slice(0,h.to-u),r,o,null,a,l),o=null,i=i.slice(h.to-u),u=h.to}}}function Tn(t,e,n,i){var r=!i&&n.widgetNode;r&&t.map.push(t.pos,t.pos+e,r),!i&&t.cm.display.input.needsContentAttribute&&(r||(r=t.content.appendChild(document.createElement("span"))),r.setAttribute("cm-marker",n.id)),r&&(t.cm.display.input.setUneditable(r),t.content.appendChild(r)),t.pos+=e,t.trailingSpace=!1}function Sn(t,e,n){var i=t.markedSpans,r=t.text,o=0;if(i)for(var s,a,l,u,c,h,p,_=r.length,d=0,f=1,g="",m=0;;){if(m==d){l=u=c=a="",p=null,h=null,m=1/0;for(var v=[],y=void 0,b=0;b<i.length;++b){var w=i[b],x=w.marker;if("bookmark"==x.type&&w.from==d&&x.widgetNode)v.push(x);else if(w.from<=d&&(null==w.to||w.to>d||x.collapsed&&w.to==d&&w.from==d)){if(null!=w.to&&w.to!=d&&m>w.to&&(m=w.to,u=""),x.className&&(l+=" "+x.className),x.css&&(a=(a?a+";":"")+x.css),x.startStyle&&w.from==d&&(c+=" "+x.startStyle),x.endStyle&&w.to==m&&(y||(y=[])).push(x.endStyle,w.to),x.title&&((p||(p={})).title=x.title),x.attributes)for(var k in x.attributes)(p||(p={}))[k]=x.attributes[k];x.collapsed&&(!h||Qe(h.marker,x)<0)&&(h=w)}else w.from>d&&m>w.from&&(m=w.from)}if(y)for(var C=0;C<y.length;C+=2)y[C+1]==m&&(u+=" "+y[C]);if(!h||h.from==d)for(var T=0;T<v.length;++T)Tn(e,0,v[T]);if(h&&(h.from||0)==d){if(Tn(e,(null==h.to?_+1:h.to)-d,h.marker,null==h.from),null==h.to)return;h.to==d&&(h=!1)}}if(d>=_)break;for(var S=Math.min(_,m);;){if(g){var O=d+g.length;if(!h){var M=O>S?g.slice(0,S-d):g;e.addToken(e,M,s?s+l:l,c,d+M.length==m?u:"",a,p)}if(O>=S){g=g.slice(S-d),d=S;break}d=O,c=""}g=r.slice(o,o=n[f++]),s=yn(n[f++],e.cm.options)}}else for(var L=1;L<n.length;L+=2)e.addToken(e,r.slice(o,o=n[L]),yn(n[L+1],e.cm.options))}function On(t,e,n){this.line=e,this.rest=sn(e),this.size=this.rest?se(tt(this.rest))-n+1:1,this.node=this.text=null,this.hidden=un(t,e)}function Mn(t,e,n){for(var i,r=[],o=e;o<n;o=i){var s=new On(t.doc,ne(t.doc,o),o);i=o+s.size,r.push(s)}return r}var Ln=null;function En(t){Ln?Ln.ops.push(t):t.ownsGroup=Ln={ops:[t],delayedCallbacks:[]}}function An(t){var e=t.delayedCallbacks,n=0;do{for(;n<e.length;n++)e[n].call(null);for(var i=0;i<t.ops.length;i++){var r=t.ops[i];if(r.cursorActivityHandlers)for(;r.cursorActivityCalled<r.cursorActivityHandlers.length;)r.cursorActivityHandlers[r.cursorActivityCalled++].call(null,r.cm)}}while(n<e.length)}function Nn(t,e){var n=t.ownsGroup;if(n)try{An(n)}finally{Ln=null,e(n)}}var Rn=null;function Dn(t,e){var n=bt(t,e);if(n.length){var i,r=Array.prototype.slice.call(arguments,2);Ln?i=Ln.delayedCallbacks:Rn?i=Rn:(i=Rn=[],setTimeout(Wn,0));for(var o=function(t){i.push((function(){return n[t].apply(null,r)}))},s=0;s<n.length;++s)o(s)}}function Wn(){var t=Rn;Rn=null;for(var e=0;e<t.length;++e)t[e]()}function zn(t,e,n,i){for(var r=0;r<e.changes.length;r++){var o=e.changes[r];"text"==o?jn(t,e):"gutter"==o?Hn(t,e,n,i):"class"==o?Bn(t,e):"widget"==o&&Un(t,e,i)}e.changes=null}function Pn(t){return t.node==t.text&&(t.node=E("div",null,null,"position: relative"),t.text.parentNode&&t.text.parentNode.replaceChild(t.node,t.text),t.node.appendChild(t.text),s&&a<8&&(t.node.style.zIndex=2)),t.node}function In(t,e){var n=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),e.background)n?e.background.className=n:(e.background.parentNode.removeChild(e.background),e.background=null);else if(n){var i=Pn(e);e.background=i.insertBefore(E("div",null,n),i.firstChild),t.display.input.setUneditable(e.background)}}function Fn(t,e){var n=t.display.externalMeasured;return n&&n.line==e.line?(t.display.externalMeasured=null,e.measure=n.measure,n.built):bn(t,e)}function jn(t,e){var n=e.text.className,i=Fn(t,e);e.text==e.node&&(e.node=i.pre),e.text.parentNode.replaceChild(i.pre,e.text),e.text=i.pre,i.bgClass!=e.bgClass||i.textClass!=e.textClass?(e.bgClass=i.bgClass,e.textClass=i.textClass,Bn(t,e)):n&&(e.text.className=n)}function Bn(t,e){In(t,e),e.line.wrapClass?Pn(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var n=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=n||""}function Hn(t,e,n,i){if(e.gutter&&(e.node.removeChild(e.gutter),e.gutter=null),e.gutterBackground&&(e.node.removeChild(e.gutterBackground),e.gutterBackground=null),e.line.gutterClass){var r=Pn(e);e.gutterBackground=E("div",null,"CodeMirror-gutter-background "+e.line.gutterClass,"left: "+(t.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px; width: "+i.gutterTotalWidth+"px"),t.display.input.setUneditable(e.gutterBackground),r.insertBefore(e.gutterBackground,e.text)}var o=e.line.gutterMarkers;if(t.options.lineNumbers||o){var s=Pn(e),a=e.gutter=E("div",null,"CodeMirror-gutter-wrapper","left: "+(t.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px");if(a.setAttribute("aria-hidden","true"),t.display.input.setUneditable(a),s.insertBefore(a,e.text),e.line.gutterClass&&(a.className+=" "+e.line.gutterClass),!t.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(e.lineNumber=a.appendChild(E("div",ue(t.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+t.display.lineNumInnerWidth+"px"))),o)for(var l=0;l<t.display.gutterSpecs.length;++l){var u=t.display.gutterSpecs[l].className,c=o.hasOwnProperty(u)&&o[u];c&&a.appendChild(E("div",[c],"CodeMirror-gutter-elt","left: "+i.gutterLeft[u]+"px; width: "+i.gutterWidth[u]+"px"))}}}function Un(t,e,n){e.alignable&&(e.alignable=null);for(var i=T("CodeMirror-linewidget"),r=e.node.firstChild,o=void 0;r;r=o)o=r.nextSibling,i.test(r.className)&&e.node.removeChild(r);Vn(t,e,n)}function Kn(t,e,n,i){var r=Fn(t,e);return e.text=e.node=r.pre,r.bgClass&&(e.bgClass=r.bgClass),r.textClass&&(e.textClass=r.textClass),Bn(t,e),Hn(t,e,n,i),Vn(t,e,i),e.node}function Vn(t,e,n){if(Gn(t,e.line,e,n,!0),e.rest)for(var i=0;i<e.rest.length;i++)Gn(t,e.rest[i],e,n,!1)}function Gn(t,e,n,i,r){if(e.widgets)for(var o=Pn(n),s=0,a=e.widgets;s<a.length;++s){var l=a[s],u=E("div",[l.node],"CodeMirror-linewidget"+(l.className?" "+l.className:""));l.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),Xn(l,u,n,i),t.display.input.setUneditable(u),r&&l.above?o.insertBefore(u,n.gutter||n.text):o.appendChild(u),Dn(l,"redraw")}}function Xn(t,e,n,i){if(t.noHScroll){(n.alignable||(n.alignable=[])).push(e);var r=i.wrapperWidth;e.style.left=i.fixedPos+"px",t.coverGutter||(r-=i.gutterTotalWidth,e.style.paddingLeft=i.gutterTotalWidth+"px"),e.style.width=r+"px"}t.coverGutter&&(e.style.zIndex=5,e.style.position="relative",t.noHScroll||(e.style.marginLeft=-i.gutterTotalWidth+"px"))}function $n(t){if(null!=t.height)return t.height;var e=t.doc.cm;if(!e)return 0;if(!N(document.body,t.node)){var n="position: relative;";t.coverGutter&&(n+="margin-left: -"+e.display.gutters.offsetWidth+"px;"),t.noHScroll&&(n+="width: "+e.display.wrapper.clientWidth+"px;"),L(e.display.measure,E("div",[t.node],null,n))}return t.height=t.node.parentNode.offsetHeight}function qn(t,e){for(var n=At(e);n!=t.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==t.sizer&&n!=t.mover)return!0}function Yn(t){return t.lineSpace.offsetTop}function Qn(t){return t.mover.offsetHeight-t.lineSpace.offsetHeight}function Zn(t){if(t.cachedPaddingH)return t.cachedPaddingH;var e=L(t.measure,E("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,i={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(i.left)||isNaN(i.right)||(t.cachedPaddingH=i),i}function Jn(t){return G-t.display.nativeBarWidth}function ti(t){return t.display.scroller.clientWidth-Jn(t)-t.display.barWidth}function ei(t){return t.display.scroller.clientHeight-Jn(t)-t.display.barHeight}function ni(t,e,n){var i=t.options.lineWrapping,r=i&&ti(t);if(!e.measure.heights||i&&e.measure.width!=r){var o=e.measure.heights=[];if(i){e.measure.width=r;for(var s=e.text.firstChild.getClientRects(),a=0;a<s.length-1;a++){var l=s[a],u=s[a+1];Math.abs(l.bottom-u.bottom)>2&&o.push((l.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}function ii(t,e,n){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};if(t.rest){for(var i=0;i<t.rest.length;i++)if(t.rest[i]==e)return{map:t.measure.maps[i],cache:t.measure.caches[i]};for(var r=0;r<t.rest.length;r++)if(se(t.rest[r])>n)return{map:t.measure.maps[r],cache:t.measure.caches[r],before:!0}}}function ri(t,e){var n=se(e=rn(e)),i=t.display.externalMeasured=new On(t.doc,e,n);i.lineN=n;var r=i.built=bn(t,i);return i.text=r.pre,L(t.display.lineMeasure,r.pre),i}function oi(t,e,n,i){return li(t,ai(t,e),n,i)}function si(t,e){if(e>=t.display.viewFrom&&e<t.display.viewTo)return t.display.view[Bi(t,e)];var n=t.display.externalMeasured;return n&&e>=n.lineN&&e<n.lineN+n.size?n:void 0}function ai(t,e){var n=se(e),i=si(t,n);i&&!i.text?i=null:i&&i.changes&&(zn(t,i,n,zi(t)),t.curOp.forceUpdate=!0),i||(i=ri(t,e));var r=ii(i,e,n);return{line:e,view:i,rect:null,map:r.map,cache:r.cache,before:r.before,hasHeights:!1}}function li(t,e,n,i,r){e.before&&(n=-1);var o,s=n+(i||"");return e.cache.hasOwnProperty(s)?o=e.cache[s]:(e.rect||(e.rect=e.view.text.getBoundingClientRect()),e.hasHeights||(ni(t,e.view,e.rect),e.hasHeights=!0),(o=_i(t,e,n,i)).bogus||(e.cache[s]=o)),{left:o.left,right:o.right,top:r?o.rtop:o.top,bottom:r?o.rbottom:o.bottom}}var ui,ci={left:0,right:0,top:0,bottom:0};function hi(t,e,n){for(var i,r,o,s,a,l,u=0;u<t.length;u+=3)if(a=t[u],l=t[u+1],e<a?(r=0,o=1,s="left"):e<l?o=1+(r=e-a):(u==t.length-3||e==l&&t[u+3]>e)&&(r=(o=l-a)-1,e>=l&&(s="right")),null!=r){if(i=t[u+2],a==l&&n==(i.insertLeft?"left":"right")&&(s=n),"left"==n&&0==r)for(;u&&t[u-2]==t[u-3]&&t[u-1].insertLeft;)i=t[2+(u-=3)],s="left";if("right"==n&&r==l-a)for(;u<t.length-3&&t[u+3]==t[u+4]&&!t[u+5].insertLeft;)i=t[(u+=3)+2],s="right";break}return{node:i,start:r,end:o,collapse:s,coverStart:a,coverEnd:l}}function pi(t,e){var n=ci;if("left"==e)for(var i=0;i<t.length&&(n=t[i]).left==n.right;i++);else for(var r=t.length-1;r>=0&&(n=t[r]).left==n.right;r--);return n}function _i(t,e,n,i){var r,o=hi(e.map,n,i),l=o.node,u=o.start,c=o.end,h=o.collapse;if(3==l.nodeType){for(var p=0;p<4;p++){for(;u&&ct(e.line.text.charAt(o.coverStart+u));)--u;for(;o.coverStart+c<o.coverEnd&&ct(e.line.text.charAt(o.coverStart+c));)++c;if((r=s&&a<9&&0==u&&c==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():pi(S(l,u,c).getClientRects(),i)).left||r.right||0==u)break;c=u,u-=1,h="right"}s&&a<11&&(r=di(t.display.measure,r))}else{var _;u>0&&(h=i="right"),r=t.options.lineWrapping&&(_=l.getClientRects()).length>1?_["right"==i?_.length-1:0]:l.getBoundingClientRect()}if(s&&a<9&&!u&&(!r||!r.left&&!r.right)){var d=l.parentNode.getClientRects()[0];r=d?{left:d.left,right:d.left+Wi(t.display),top:d.top,bottom:d.bottom}:ci}for(var f=r.top-e.rect.top,g=r.bottom-e.rect.top,m=(f+g)/2,v=e.view.measure.heights,y=0;y<v.length-1&&!(m<v[y]);y++);var b=y?v[y-1]:0,w=v[y],x={left:("right"==h?r.right:r.left)-e.rect.left,right:("left"==h?r.left:r.right)-e.rect.left,top:b,bottom:w};return r.left||r.right||(x.bogus=!0),t.options.singleCursorHeightPerLine||(x.rtop=f,x.rbottom=g),x}function di(t,e){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Ut(t))return e;var n=screen.logicalXDPI/screen.deviceXDPI,i=screen.logicalYDPI/screen.deviceYDPI;return{left:e.left*n,right:e.right*n,top:e.top*i,bottom:e.bottom*i}}function fi(t){if(t.measure&&(t.measure.cache={},t.measure.heights=null,t.rest))for(var e=0;e<t.rest.length;e++)t.measure.caches[e]={}}function gi(t){t.display.externalMeasure=null,M(t.display.lineMeasure);for(var e=0;e<t.display.view.length;e++)fi(t.display.view[e])}function mi(t){gi(t),t.display.cachedCharWidth=t.display.cachedTextHeight=t.display.cachedPaddingH=null,t.options.lineWrapping||(t.display.maxLineChanged=!0),t.display.lineNumChars=null}function vi(t){return c&&m?-(t.body.getBoundingClientRect().left-parseInt(getComputedStyle(t.body).marginLeft)):t.defaultView.pageXOffset||(t.documentElement||t.body).scrollLeft}function yi(t){return c&&m?-(t.body.getBoundingClientRect().top-parseInt(getComputedStyle(t.body).marginTop)):t.defaultView.pageYOffset||(t.documentElement||t.body).scrollTop}function bi(t){var e=rn(t).widgets,n=0;if(e)for(var i=0;i<e.length;++i)e[i].above&&(n+=$n(e[i]));return n}function wi(t,e,n,i,r){if(!r){var o=bi(e);n.top+=o,n.bottom+=o}if("line"==i)return n;i||(i="local");var s=hn(e);if("local"==i?s+=Yn(t.display):s-=t.display.viewOffset,"page"==i||"window"==i){var a=t.display.lineSpace.getBoundingClientRect();s+=a.top+("window"==i?0:yi(P(t)));var l=a.left+("window"==i?0:vi(P(t)));n.left+=l,n.right+=l}return n.top+=s,n.bottom+=s,n}function xi(t,e,n){if("div"==n)return e;var i=e.left,r=e.top;if("page"==n)i-=vi(P(t)),r-=yi(P(t));else if("local"==n||!n){var o=t.display.sizer.getBoundingClientRect();i+=o.left,r+=o.top}var s=t.display.lineSpace.getBoundingClientRect();return{left:i-s.left,top:r-s.top}}function ki(t,e,n,i,r){return i||(i=ne(t.doc,e.line)),wi(t,i,oi(t,i,e.ch,r),n)}function Ci(t,e,n,i,r,o){function s(e,s){var a=li(t,r,e,s?"right":"left",o);return s?a.left=a.right:a.right=a.left,wi(t,i,a,n)}i=i||ne(t.doc,e.line),r||(r=ai(t,i));var a=mt(i,t.doc.direction),l=e.ch,u=e.sticky;if(l>=i.text.length?(l=i.text.length,u="before"):l<=0&&(l=0,u="after"),!a)return s("before"==u?l-1:l,"before"==u);function c(t,e,n){return s(n?t-1:t,1==a[e].level!=n)}var h=ft(a,l,u),p=dt,_=c(l,h,"before"==u);return null!=p&&(_.other=c(l,p,"before"!=u)),_}function Ti(t,e){var n=0;e=me(t.doc,e),t.options.lineWrapping||(n=Wi(t.display)*e.ch);var i=ne(t.doc,e.line),r=hn(i)+Yn(t.display);return{left:n,right:n,top:r,bottom:r+i.height}}function Si(t,e,n,i,r){var o=ce(t,e,n);return o.xRel=r,i&&(o.outside=i),o}function Oi(t,e,n){var i=