@uiw/react-codemirror 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -1
- package/cjs/index.js +13 -4
- package/cjs/index.js.map +4 -2
- package/cjs/useCodeMirror.js +1 -1
- package/cjs/useCodeMirror.js.map +3 -3
- package/dist/codemirror.js +35094 -0
- package/dist/codemirror.min.js +2 -0
- package/dist/codemirror.min.js.LICENSE.txt +14 -0
- package/esm/index.js +10 -4
- package/esm/index.js.map +4 -2
- package/esm/useCodeMirror.js +2 -2
- package/esm/useCodeMirror.js.map +3 -3
- package/package.json +18 -20
- package/src/__tests__/index.test.tsx +87 -0
- package/src/index.tsx +9 -3
- package/src/useCodeMirror.ts +2 -2
- package/src/react-app-env.d.ts +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see codemirror.min.js.LICENSE.txt */
|
|
2
|
+
!function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e(require("react")):"function"===typeof define&&define.amd?define(["react"],e):"object"===typeof exports?exports.codemirror=e(require("react")):t.codemirror=e(t.React)}(self,(function(t){return function(){"use strict";var e={13:function(t){var e=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function r(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(t){i[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(r){return!1}}()?Object.assign:function(t,o){for(var s,a,u=r(t),l=1;l<arguments.length;l++){for(var h in s=Object(arguments[l]))n.call(s,h)&&(u[h]=s[h]);if(e){a=e(s);for(var c=0;c<a.length;c++)i.call(s,a[c])&&(u[a[c]]=s[a[c]])}}return u}},829:function(t,e,n){n(13);var i=n(787),r=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var o=Symbol.for;r=o("react.element"),o("react.fragment")}var s=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,u={key:!0,ref:!0,__self:!0,__source:!0};function l(t,e,n){var i,o={},l=null,h=null;for(i in void 0!==n&&(l=""+n),void 0!==e.key&&(l=""+e.key),void 0!==e.ref&&(h=e.ref),e)a.call(e,i)&&!u.hasOwnProperty(i)&&(o[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps)void 0===o[i]&&(o[i]=e[i]);return{$$typeof:r,type:t,key:l,ref:h,props:o,_owner:s.current}}e.jsx=l},364:function(t,e,n){t.exports=n(829)},787:function(e){e.exports=t}},n={};function i(t){var r=n[t];if(void 0!==r)return r.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,{a:e}),e},i.d=function(t,e){for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return function(){function t(){return t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},t.apply(this,arguments)}i.r(r),i.d(r,{Annotation:function(){return Lt},AnnotationType:function(){return Pt},BidiSpan:function(){return Oi},BlockInfo:function(){return Er},BlockType:function(){return Dn},ChangeDesc:function(){return J},ChangeSet:function(){return $},CharCategory:function(){return Ut},Compartment:function(){return wt},Decoration:function(){return Tn},Direction:function(){return fi},EditorSelection:function(){return it},EditorState:function(){return Jt},EditorView:function(){return co},Facet:function(){return at},MapMode:function(){return G},MatchDecorator:function(){return Jo},PluginField:function(){return ti},PluginFieldProvider:function(){return Zn},Prec:function(){return yt},Range:function(){return ie},SelectionRange:function(){return nt},StateEffect:function(){return Nt},StateEffectType:function(){return It},StateField:function(){return ct},Text:function(){return N},Transaction:function(){return Vt},ViewPlugin:function(){return ii},ViewUpdate:function(){return ci},WidgetType:function(){return On},__test:function(){return fs},basicSetup:function(){return dd},combineConfig:function(){return $t},default:function(){return Dd},drawSelection:function(){return Po},dropCursor:function(){return Ko},highlightActiveLine:function(){return as},highlightSpecialChars:function(){return ts},keymap:function(){return Ao},logException:function(){return Xn},placeholder:function(){return cs},runScopeHandlers:function(){return Do},scrollPastEnd:function(){return ss},useCodeMirror:function(){return Cd}});var e=i(787),n=i.n(e);function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function s(t,e){if(t){if("string"===typeof t)return o(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(t,e):void 0}}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(u){a=!0,r=u}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t,e)||s(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!==typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||s(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function c(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}function f(){return f="undefined"!==typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=c(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},f.apply(this,arguments)}function d(t,e){return d=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},d(t,e)}function v(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&&d(t,e)}function p(t){return p="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},p(t)}function m(t,e){if(e&&("object"===p(e)||"function"===typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return l(t)}function g(t){var e=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=h(t);if(e){var r=h(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return m(this,n)}}function y(t,e){var n="undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=s(t))||e&&t&&"number"===typeof t.length){n&&(t=n);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function k(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function w(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,i.key,i)}}function b(t,e,n){return e&&w(t.prototype,e),n&&w(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}for(var x="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((function(t){return t?parseInt(t,36):1})),S=1;S<x.length;S++)x[S]+=x[S-1];function C(t){for(var e=1;e<x.length;e+=2)if(x[e]>t)return x[e-1]<=t;return!1}function A(t){return t>=127462&&t<=127487}function M(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return(n?O:D)(t,e,i)}function O(t,e,n){if(e==t.length)return e;e&&T(t.charCodeAt(e))&&E(t.charCodeAt(e-1))&&e--;var i=R(t,e);for(e+=L(i);e<t.length;){var r=R(t,e);if(8205==i||8205==r||n&&C(r))e+=L(r),i=r;else{if(!A(r))break;for(var o=0,s=e-2;s>=0&&A(R(t,s));)o++,s-=2;if(o%2==0)break;e+=2}}return e}function D(t,e,n){for(;e>0;){var i=O(t,e-2,n);if(i<e)return i;e--}return 0}function T(t){return t>=56320&&t<57344}function E(t){return t>=55296&&t<56320}function R(t,e){var n=t.charCodeAt(e);if(!E(n)||e+1==t.length)return n;var i=t.charCodeAt(e+1);return T(i)?i-56320+(n-55296<<10)+65536:n}function B(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function L(t){return t<65536?1:2}function P(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length,i=0,r=0;r<n;)9==t.charCodeAt(r)?(i+=e-i%e,r++):(i++,r=M(t,r));return i}function I(t,e,n,i){for(var r=0,o=0;;){if(o>=e)return r;if(r==t.length)break;o+=9==t.charCodeAt(r)?n-o%n:1,r=M(t,r)}return!0===i?-1:t.length}var N=function(){function t(){k(this,t)}return b(t,[{key:"lineAt",value:function(t){if(t<0||t>this.length)throw new RangeError("Invalid position ".concat(t," in document of length ").concat(this.length));return this.lineInner(t,!1,1,0)}},{key:"line",value:function(t){if(t<1||t>this.lines)throw new RangeError("Invalid line number ".concat(t," in ").concat(this.lines,"-line document"));return this.lineInner(t,!0,1,0)}},{key:"replace",value:function(t,e,n){var i=[];return this.decompose(0,t,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(e,this.length,i,1),H.from(i,this.length-(e-t)+n.length)}},{key:"append",value:function(t){return this.replace(this.length,this.length,t)}},{key:"slice",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=[];return this.decompose(t,e,n,0),H.from(n,e-t)}},{key:"eq",value:function(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;for(var e=this.scanIdentical(t,1),n=this.length-this.scanIdentical(t,-1),i=new q(this),r=new q(t),o=e,s=e;;){if(i.next(o),r.next(o),o=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(s+=i.value.length,i.done||s>=n)return!0}}},{key:"iter",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new q(this,t)}},{key:"iterRange",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return new j(this,t,e)}},{key:"iterLines",value:function(t,e){var n;if(null==t)n=this.iter();else{null==e&&(e=this.lines+1);var i=this.line(t).from;n=this.iterRange(i,Math.max(i,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new _(n)}},{key:"toString",value:function(){return this.sliceString(0)}},{key:"toJSON",value:function(){var t=[];return this.flatten(t),t}}],[{key:"of",value:function(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new V(e):H.from(V.split(e,[])):t.empty}}]),t}(),V=function(t){v(n,t);var e=g(n);function n(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:W(t);return k(this,n),(i=e.call(this)).text=t,i.length=r,i}return b(n,[{key:"lines",get:function(){return this.text.length}},{key:"children",get:function(){return null}},{key:"lineInner",value:function(t,e,n,i){for(var r=0;;r++){var o=this.text[r],s=i+o.length;if((e?n:s)>=t)return new U(i,s,n,o);i=s+1,n++}}},{key:"decompose",value:function(t,e,i,r){var o=t<=0&&e>=this.length?this:new n(z(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&r){var s=i.pop(),a=F(o.text,s.text.slice(),0,o.length);if(a.length<=32)i.push(new n(a,s.length+o.length));else{var u=a.length>>1;i.push(new n(a.slice(0,u)),new n(a.slice(u)))}}else i.push(o)}},{key:"replace",value:function(t,e,i){if(!(i instanceof n))return f(h(n.prototype),"replace",this).call(this,t,e,i);var r=F(this.text,F(i.text,z(this.text,0,t)),e),o=this.length+i.length-(e-t);return r.length<=32?new n(r,o):H.from(n.split(r,[]),o)}},{key:"sliceString",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",i="",r=0,o=0;r<=e&&o<this.text.length;o++){var s=this.text[o],a=r+s.length;r>t&&o&&(i+=n),t<a&&e>r&&(i+=s.slice(Math.max(0,t-r),e-r)),r=a+1}return i}},{key:"flatten",value:function(t){var e,n=y(this.text);try{for(n.s();!(e=n.n()).done;){var i=e.value;t.push(i)}}catch(r){n.e(r)}finally{n.f()}}},{key:"scanIdentical",value:function(){return 0}}],[{key:"split",value:function(t,e){var i,r=[],o=-1,s=y(t);try{for(s.s();!(i=s.n()).done;){var a=i.value;r.push(a),o+=a.length+1,32==r.length&&(e.push(new n(r,o)),r=[],o=-1)}}catch(u){s.e(u)}finally{s.f()}return o>-1&&e.push(new n(r,o)),e}}]),n}(N),H=function(t){v(n,t);var e=g(n);function n(t,i){var r;k(this,n),(r=e.call(this)).children=t,r.length=i,r.lines=0;var o,s=y(t);try{for(s.s();!(o=s.n()).done;){var a=o.value;r.lines+=a.lines}}catch(u){s.e(u)}finally{s.f()}return r}return b(n,[{key:"lineInner",value:function(t,e,n,i){for(var r=0;;r++){var o=this.children[r],s=i+o.length,a=n+o.lines-1;if((e?a:s)>=t)return o.lineInner(t,e,n,i);i=s+1,n=a+1}}},{key:"decompose",value:function(t,e,n,i){for(var r=0,o=0;o<=e&&r<this.children.length;r++){var s=this.children[r],a=o+s.length;if(t<=a&&e>=o){var u=i&((o<=t?1:0)|(a>=e?2:0));o>=t&&a<=e&&!u?n.push(s):s.decompose(t-o,e-o,n,u)}o=a+1}}},{key:"replace",value:function(t,e,i){if(i.lines<this.lines)for(var r=0,o=0;r<this.children.length;r++){var s=this.children[r],a=o+s.length;if(t>=o&&e<=a){var u=s.replace(t-o,e-o,i),l=this.lines-s.lines+u.lines;if(u.lines<l>>4&&u.lines>l>>6){var c=this.children.slice();return c[r]=u,new n(c,this.length-(e-t)+i.length)}return f(h(n.prototype),"replace",this).call(this,o,a,u)}o=a+1}return f(h(n.prototype),"replace",this).call(this,t,e,i)}},{key:"sliceString",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",i="",r=0,o=0;r<this.children.length&&o<=e;r++){var s=this.children[r],a=o+s.length;o>t&&r&&(i+=n),t<a&&e>o&&(i+=s.sliceString(t-o,e-o,n)),o=a+1}return i}},{key:"flatten",value:function(t){var e,n=y(this.children);try{for(n.s();!(e=n.n()).done;){e.value.flatten(t)}}catch(i){n.e(i)}finally{n.f()}}},{key:"scanIdentical",value:function(t,e){if(!(t instanceof n))return 0;for(var i=0,r=a(e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1],4),o=r[0],s=r[1],u=r[2],l=r[3];;o+=e,s+=e){if(o==u||s==l)return i;var h=this.children[o],c=t.children[s];if(h!=c)return i+h.scanIdentical(c,e);i+=h.length+1}}}],[{key:"from",value:function(t){var e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.reduce((function(t,e){return t+e.length+1}),-1),r=0,o=y(t);try{for(o.s();!(e=o.n()).done;){var s=e.value;r+=s.lines}}catch(C){o.e(C)}finally{o.f()}if(r<32){var a,u=[],l=y(t);try{for(l.s();!(a=l.n()).done;){var h=a.value;h.flatten(u)}}catch(C){l.e(C)}finally{l.f()}return new V(u,i)}var c=Math.max(32,r>>5),f=c<<1,d=c>>1,v=[],p=0,m=-1,g=[];function k(t){var e;if(t.lines>f&&t instanceof n){var i,r=y(t.children);try{for(r.s();!(i=r.n()).done;){k(i.value)}}catch(C){r.e(C)}finally{r.f()}}else t.lines>d&&(p>d||!p)?(w(),v.push(t)):t instanceof V&&p&&(e=g[g.length-1])instanceof V&&t.lines+e.lines<=32?(p+=t.lines,m+=t.length+1,g[g.length-1]=new V(e.text.concat(t.text),e.length+1+t.length)):(p+t.lines>c&&w(),p+=t.lines,m+=t.length+1,g.push(t))}function w(){0!=p&&(v.push(1==g.length?g[0]:n.from(g,m)),m=-1,p=g.length=0)}var b,x=y(t);try{for(x.s();!(b=x.n()).done;){var S=b.value;k(S)}}catch(C){x.e(C)}finally{x.f()}return w(),1==v.length?v[0]:new n(v,i)}}]),n}(N);function W(t){var e,n=-1,i=y(t);try{for(i.s();!(e=i.n()).done;){n+=e.value.length+1}}catch(r){i.e(r)}finally{i.f()}return n}function F(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e9,r=0,o=0,s=!0;o<t.length&&r<=i;o++){var a=t[o],u=r+a.length;u>=n&&(u>i&&(a=a.slice(0,i-r)),r<n&&(a=a.slice(n-r)),s?(e[e.length-1]+=a,s=!1):e.push(a)),r=u+1}return e}function z(t,e,n){return F(t,[""],e,n)}N.empty=new V([""],0);var q=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;k(this,t),this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof V?e.text.length:e.children.length)<<1]}return b(t,[{key:"nextInner",value:function(t,e){for(this.done=this.lineBreak=!1;;){var n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],o=r>>1,s=i instanceof V?i.text.length:i.children.length;if(o==(e>0?s:0)){if(0==n)return this.done=!0,this.value="",this;e>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(e>0?0:1)){if(this.offsets[n]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(i instanceof V){var a=i.text[o+(e<0?-1:0)];if(this.offsets[n]+=e,a.length>Math.max(0,t))return this.value=0==t?a:e>0?a.slice(t):a.slice(0,a.length-t),this;t-=a.length}else{var u=i.children[o+(e<0?-1:0)];t>u.length?(t-=u.length,this.offsets[n]+=e):(e<0&&this.offsets[n]--,this.nodes.push(u),this.offsets.push(e>0?1:(u instanceof V?u.text.length:u.children.length)<<1))}}}},{key:"next",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}]),t}(),j=function(){function t(e,n,i){k(this,t),this.value="",this.done=!1,this.cursor=new q(e,n>i?-1:1),this.pos=n>i?e.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}return b(t,[{key:"nextInner",value:function(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);var n=e<0?this.pos-this.from:this.to-this.pos;t>n&&(t=n),n-=t;var i=this.cursor.next(t).value;return this.pos+=(i.length+t)*e,this.value=i.length<=n?i:e<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}},{key:"next",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}},{key:"lineBreak",get:function(){return this.cursor.lineBreak&&""!=this.value}}]),t}(),_=function(){function t(e){k(this,t),this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}return b(t,[{key:"next",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=this.inner.next(t),n=e.done,i=e.lineBreak,r=e.value;return n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}},{key:"lineBreak",get:function(){return!1}}]),t}();"undefined"!=typeof Symbol&&(N.prototype[Symbol.iterator]=function(){return this.iter()},q.prototype[Symbol.iterator]=j.prototype[Symbol.iterator]=_.prototype[Symbol.iterator]=function(){return this});var U=function(){function t(e,n,i,r){k(this,t),this.from=e,this.to=n,this.number=i,this.text=r}return b(t,[{key:"length",get:function(){return this.to-this.from}}]),t}(),K=/\r\n?|\n/,G=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(G||(G={})),J=function(){function t(e){k(this,t),this.sections=e}return b(t,[{key:"length",get:function(){for(var t=0,e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}},{key:"newLength",get:function(){for(var t=0,e=0;e<this.sections.length;e+=2){var n=this.sections[e+1];t+=n<0?this.sections[e]:n}return t}},{key:"empty",get:function(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}},{key:"iterGaps",value:function(t){for(var e=0,n=0,i=0;e<this.sections.length;){var r=this.sections[e++],o=this.sections[e++];o<0?(t(n,i,r),i+=r):i+=o,n+=r}}},{key:"iterChangedRanges",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Q(this,t,e)}},{key:"invertedDesc",get:function(){for(var e=[],n=0;n<this.sections.length;){var i=this.sections[n++],r=this.sections[n++];r<0?e.push(i,r):e.push(r,i)}return new t(e)}},{key:"composeDesc",value:function(t){return this.empty?t:t.empty?this:tt(this,t)}},{key:"mapDesc",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t.empty?this:Z(this,t,e)}},{key:"mapPos",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:G.Simple,i=0,r=0,o=0;o<this.sections.length;){var s=this.sections[o++],a=this.sections[o++],u=i+s;if(a<0){if(u>t)return r+(t-i);r+=s}else{if(n!=G.Simple&&u>=t&&(n==G.TrackDel&&i<t&&u>t||n==G.TrackBefore&&i<t||n==G.TrackAfter&&u>t))return null;if(u>t||u==t&&e<0&&!s)return t==i||e<0?r:r+a;r+=a}i=u}if(t>i)throw new RangeError("Position ".concat(t," is out of range for changeset of length ").concat(i));return r}},{key:"touchesRange",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,n=0,i=0;n<this.sections.length&&i<=e;){var r=this.sections[n++],o=this.sections[n++],s=i+r;if(o>=0&&i<=e&&s>=t)return!(i<t&&s>e)||"cover";i=s}return!1}},{key:"toString",value:function(){for(var t="",e=0;e<this.sections.length;){var n=this.sections[e++],i=this.sections[e++];t+=(t?" ":"")+n+(i>=0?":"+i:"")}return t}},{key:"toJSON",value:function(){return this.sections}}],[{key:"fromJSON",value:function(e){if(!Array.isArray(e)||e.length%2||e.some((function(t){return"number"!=typeof t})))throw new RangeError("Invalid JSON representation of ChangeDesc");return new t(e)}}]),t}(),$=function(t){v(n,t);var e=g(n);function n(t,i){var r;return k(this,n),(r=e.call(this,t)).inserted=i,r}return b(n,[{key:"apply",value:function(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return Q(this,(function(e,n,i,r,o){return t=t.replace(i,i+(n-e),o)}),!1),t}},{key:"mapDesc",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Z(this,t,e,!0)}},{key:"invert",value:function(t){for(var e=this.sections.slice(),i=[],r=0,o=0;r<e.length;r+=2){var s=e[r],a=e[r+1];if(a>=0){e[r]=a,e[r+1]=s;for(var u=r>>1;i.length<u;)i.push(N.empty);i.push(s?t.slice(o,o+s):N.empty)}o+=s}return new n(e,i)}},{key:"compose",value:function(t){return this.empty?t:t.empty?this:tt(this,t,!0)}},{key:"map",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t.empty?this:Z(this,t,e,!0)}},{key:"iterChanges",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Q(this,t,e)}},{key:"desc",get:function(){return new J(this.sections)}},{key:"filter",value:function(t){var e=[],i=[],r=[],o=new et(this);t:for(var s=0,a=0;;){for(var u=s==t.length?1e9:t[s++];a<u||a==u&&0==o.len;){if(o.done)break t;var l=Math.min(o.len,u-a);Y(r,l,-1);var h=-1==o.ins?-1:0==o.off?o.ins:0;Y(e,l,h),h>0&&X(i,e,o.text),o.forward(l),a+=l}for(var c=t[s++];a<c;){if(o.done)break t;var f=Math.min(o.len,c-a);Y(e,f,-1),Y(r,f,-1==o.ins?-1:0==o.off?o.ins:0),o.forward(f),a+=f}}return{changes:new n(e,i),filtered:new J(r)}}},{key:"toJSON",value:function(){for(var t=[],e=0;e<this.sections.length;e+=2){var n=this.sections[e],i=this.sections[e+1];i<0?t.push(n):0==i?t.push([n]):t.push([n].concat(this.inserted[e>>1].toJSON()))}return t}}],[{key:"of",value:function(t,e,i){var r=[],o=[],s=0,a=null;function u(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(t||r.length){s<e&&Y(r,e-s,-1);var i=new n(r,o);a=a?a.compose(i.map(a)):i,r=[],o=[],s=0}}return function t(l){if(Array.isArray(l)){var h,c=y(l);try{for(c.s();!(h=c.n()).done;){t(h.value)}}catch(k){c.e(k)}finally{c.f()}}else if(l instanceof n){if(l.length!=e)throw new RangeError("Mismatched change set length (got ".concat(l.length,", expected ").concat(e,")"));u(),a=a?a.compose(l.map(a)):l}else{var f=l.from,d=l.to,v=void 0===d?f:d,p=l.insert;if(f>v||f<0||v>e)throw new RangeError("Invalid change range ".concat(f," to ").concat(v," (in doc of length ").concat(e,")"));var m=p?"string"==typeof p?N.of(p.split(i||K)):p:N.empty,g=m.length;if(f==v&&0==g)return;f<s&&u(),f>s&&Y(r,f-s,-1),Y(r,v-f,g),X(o,r,m),s=v}}(t),u(!a),a}},{key:"empty",value:function(t){return new n(t?[t,-1]:[],[])}},{key:"fromJSON",value:function(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");for(var e=[],i=[],r=0;r<t.length;r++){var o=t[r];if("number"==typeof o)e.push(o,-1);else{if(!Array.isArray(o)||"number"!=typeof o[0]||o.some((function(t,e){return e&&"string"!=typeof t})))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==o.length)e.push(o[0],0);else{for(;i.length<r;)i.push(N.empty);i[r]=N.of(o.slice(1)),e.push(o[0],i[r].length)}}}return new n(e,i)}}]),n}(J);function Y(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!(0==e&&n<=0)){var r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:0==e&&0==t[r]?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}}function X(t,e,n){if(0!=n.length){var i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<i;)t.push(N.empty);t.push(n)}}}function Q(t,e,n){for(var i=t.inserted,r=0,o=0,s=0;s<t.sections.length;){var a=t.sections[s++],u=t.sections[s++];if(u<0)r+=a,o+=a;else{for(var l=r,h=o,c=N.empty;l+=a,h+=u,u&&i&&(c=c.append(i[s-2>>1])),!(n||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],u=t.sections[s++];e(r,l,o,h,c),r=l,o=h}}}function Z(t,e,n){for(var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=[],o=i?[]:null,s=new et(t),a=new et(e),u=0,l=0;;)if(-1==s.ins)u+=s.len,s.next();else if(-1==a.ins&&l<u){var h=Math.min(a.len,u-l);a.forward(h),Y(r,h,-1),l+=h}else if(a.ins>=0&&(s.done||l<u||l==u&&(a.len<s.len||a.len==s.len&&!n))){for(Y(r,a.ins,-1);u>l&&!s.done&&u+s.len<l+a.len;)u+=s.len,s.next();l+=a.len,a.next()}else{if(!(s.ins>=0)){if(s.done&&a.done)return o?new $(r,o):new J(r);throw new Error("Mismatched change set lengths")}for(var c=0,f=u+s.len;;)if(a.ins>=0&&l>u&&l+a.len<f)c+=a.ins,l+=a.len,a.next();else{if(!(-1==a.ins&&l<f))break;var d=Math.min(a.len,f-l);c+=d,a.forward(d),l+=d}Y(r,c,s.ins),o&&X(o,r,s.text),u=f,s.next()}}function tt(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[],r=n?[]:null,o=new et(t),s=new et(e),a=!1;;){if(o.done&&s.done)return r?new $(i,r):new J(i);if(0==o.ins)Y(i,o.len,0,a),o.next();else if(0!=s.len||s.done){if(o.done||s.done)throw new Error("Mismatched change set lengths");var u=Math.min(o.len2,s.len),l=i.length;if(-1==o.ins){var h=-1==s.ins?-1:s.off?0:s.ins;Y(i,u,h,a),r&&h&&X(r,i,s.text)}else-1==s.ins?(Y(i,o.off?0:o.len,u,a),r&&X(r,i,o.textBit(u))):(Y(i,o.off?0:o.len,s.off?0:s.ins,a),r&&!s.off&&X(r,i,s.text));a=(o.ins>u||s.ins>=0&&s.len>u)&&(a||i.length>l),o.forward2(u),s.forward(u)}else Y(i,0,s.ins,a),r&&X(r,i,s.text),s.next()}}var et=function(){function t(e){k(this,t),this.set=e,this.i=0,this.next()}return b(t,[{key:"next",value:function(){var t=this.set.sections;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}},{key:"done",get:function(){return-2==this.ins}},{key:"len2",get:function(){return this.ins<0?this.len:this.ins}},{key:"text",get:function(){var t=this.set.inserted,e=this.i-2>>1;return e>=t.length?N.empty:t[e]}},{key:"textBit",value:function(t){var e=this.set.inserted,n=this.i-2>>1;return n>=e.length&&!t?N.empty:e[n].slice(this.off,null==t?void 0:this.off+t)}},{key:"forward",value:function(t){t==this.len?this.next():(this.len-=t,this.off+=t)}},{key:"forward2",value:function(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}]),t}(),nt=function(){function t(e,n,i){k(this,t),this.from=e,this.to=n,this.flags=i}return b(t,[{key:"anchor",get:function(){return 16&this.flags?this.to:this.from}},{key:"head",get:function(){return 16&this.flags?this.from:this.to}},{key:"empty",get:function(){return this.from==this.to}},{key:"assoc",get:function(){return 4&this.flags?-1:8&this.flags?1:0}},{key:"bidiLevel",get:function(){var t=3&this.flags;return 3==t?null:t}},{key:"goalColumn",get:function(){var t=this.flags>>5;return 33554431==t?void 0:t}},{key:"map",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,i=e.mapPos(this.from,n),r=e.mapPos(this.to,n);return i==this.from&&r==this.to?this:new t(i,r,this.flags)}},{key:"extend",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;if(t<=this.anchor&&e>=this.anchor)return it.range(t,e);var n=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return it.range(this.anchor,n)}},{key:"eq",value:function(t){return this.anchor==t.anchor&&this.head==t.head}},{key:"toJSON",value:function(){return{anchor:this.anchor,head:this.head}}}],[{key:"fromJSON",value:function(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return it.range(t.anchor,t.head)}}]),t}(),it=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;k(this,t),this.ranges=e,this.mainIndex=n}return b(t,[{key:"map",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return e.empty?this:t.create(this.ranges.map((function(t){return t.map(e,n)})),this.mainIndex)}},{key:"eq",value:function(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}},{key:"main",get:function(){return this.ranges[this.mainIndex]}},{key:"asSingle",value:function(){return 1==this.ranges.length?this:new t([this.main])}},{key:"addRange",value:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.create([e].concat(this.ranges),n?0:this.mainIndex+1)}},{key:"replaceRange",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.mainIndex,i=this.ranges.slice();return i[n]=e,t.create(i,this.mainIndex)}},{key:"toJSON",value:function(){return{ranges:this.ranges.map((function(t){return t.toJSON()})),main:this.mainIndex}}}],[{key:"fromJSON",value:function(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new t(e.ranges.map((function(t){return nt.fromJSON(t)})),e.main)}},{key:"single",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return new t([t.range(e,n)],0)}},{key:"create",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(0==e.length)throw new RangeError("A selection needs at least one range");for(var i=0,r=0;r<e.length;r++){var o=e[r];if(o.empty?o.from<=i:o.from<i)return rt(e.slice(),n);i=o.to}return new t(e,n)}},{key:"cursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return new nt(t,t,(0==e?0:e<0?4:8)|(null==n?3:Math.min(2,n))|(null!==i&&void 0!==i?i:33554431)<<5)}},{key:"range",value:function(t,e,n){var i=(null!==n&&void 0!==n?n:33554431)<<5;return e<t?new nt(e,t,24|i):new nt(t,e,i|(e>t?4:0))}}]),t}();function rt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t[e];t.sort((function(t,e){return t.from-e.from})),e=t.indexOf(n);for(var i=1;i<t.length;i++){var r=t[i],o=t[i-1];if(r.empty?r.from<=o.to:r.from<o.to){var s=o.from,a=Math.max(r.to,o.to);i<=e&&e--,t.splice(--i,2,r.anchor>r.head?it.range(a,s):it.range(s,a))}}return new it(t,e)}function ot(t,e){var n,i=y(t.ranges);try{for(i.s();!(n=i.n()).done;){if(n.value.to>e)throw new RangeError("Selection points outside of document")}}catch(r){i.e(r)}finally{i.f()}}var st=0,at=function(){function t(e,n,i,r,o){k(this,t),this.combine=e,this.compareInput=n,this.compare=i,this.isStatic=r,this.extensions=o,this.id=st++,this.default=e([])}return b(t,[{key:"of",value:function(t){return new lt([],this,0,t)}},{key:"compute",value:function(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new lt(t,this,1,e)}},{key:"computeN",value:function(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new lt(t,this,2,e)}},{key:"from",value:function(t,e){return e||(e=function(t){return t}),this.compute([t],(function(n){return e(n.field(t))}))}}],[{key:"define",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new t(e.combine||function(t){return t},e.compareInput||function(t,e){return t===e},e.compare||(e.combine?function(t,e){return t===e}:ut),!!e.static,e.enables)}}]),t}();function ut(t,e){return t==e||t.length==e.length&&t.every((function(t,n){return t===e[n]}))}var lt=function(){function t(e,n,i,r){k(this,t),this.dependencies=e,this.facet=n,this.type=i,this.value=r,this.id=st++}return b(t,[{key:"dynamicSlot",value:function(t){var e,n,i=this.value,r=this.facet.compareInput,o=t[this.id]>>1,s=2==this.type,a=!1,u=!1,l=[],h=y(this.dependencies);try{for(h.s();!(n=h.n()).done;){var c=n.value;"doc"==c?a=!0:"selection"==c?u=!0:0==(1&(null!==(e=t[c.id])&&void 0!==e?e:1))&&l.push(t[c.id])}}catch(f){h.e(f)}finally{h.f()}return function(t,e){var n=t.values[o];if(n===St)return t.values[o]=i(t),1;if(e&&(a&&e.docChanged||u&&(e.docChanged||e.selection)||l.some((function(e){return(1&Ct(t,e))>0})))){var h=i(t);if(s?!function(t,e,n){if(t.length!=e.length)return!1;for(var i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}(h,n,r):!r(h,n))return t.values[o]=h,1}return 0}}}]),t}();var ht=at.define({static:!0}),ct=function(){function t(e,n,i,r,o){k(this,t),this.id=e,this.createF=n,this.updateF=i,this.compareF=r,this.spec=o,this.provides=void 0}return b(t,[{key:"create",value:function(t){var e=this,n=t.facet(ht).find((function(t){return t.field==e}));return((null===n||void 0===n?void 0:n.create)||this.createF)(t)}},{key:"slot",value:function(t){var e=this,n=t[this.id]>>1;return function(t,i){var r=t.values[n];if(r===St)return t.values[n]=e.create(t),1;if(i){var o=e.updateF(r,i);if(!e.compareF(r,o))return t.values[n]=o,1}return 0}}},{key:"init",value:function(t){return[this,ht.of({field:this,create:t})]}},{key:"extension",get:function(){return this}}],[{key:"define",value:function(e){var n=new t(st++,e.create,e.update,e.compare||function(t,e){return t===e},e);return e.provide&&(n.provides=e.provide(n)),n}}]),t}(),ft=4,dt=3,vt=2,pt=1,mt=0;function gt(t){return function(e){return new kt(e,t)}}var yt={lowest:gt(ft),low:gt(dt),default:gt(vt),high:gt(pt),highest:gt(mt),fallback:gt(ft),extend:gt(pt),override:gt(mt)},kt=b((function t(e,n){k(this,t),this.inner=e,this.prec=n})),wt=function(){function t(){k(this,t)}return b(t,[{key:"of",value:function(t){return new bt(this,t)}},{key:"reconfigure",value:function(e){return t.reconfigure.of({compartment:this,extension:e})}},{key:"get",value:function(t){return t.config.compartments.get(this)}}]),t}(),bt=b((function t(e,n){k(this,t),this.compartment=e,this.inner=n})),xt=function(){function t(e,n,i,r,o,s){for(k(this,t),this.base=e,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}return b(t,[{key:"staticFacet",value:function(t){var e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}}],[{key:"resolve",value:function(e,n,i){var r,o=[],s=Object.create(null),a=new Map,u=y(function(t,e,n){var i=[[],[],[],[],[]],r=new Map;function o(t,s){var a=r.get(t);if(null!=a){if(a>=s)return;var u=i[a].indexOf(t);u>-1&&i[a].splice(u,1),t instanceof bt&&n.delete(t.compartment)}if(r.set(t,s),Array.isArray(t)){var l,h=y(t);try{for(h.s();!(l=h.n()).done;){o(l.value,s)}}catch(d){h.e(d)}finally{h.f()}}else if(t instanceof bt){if(n.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");var c=e.get(t.compartment)||t.inner;n.set(t.compartment,c),o(c,s)}else if(t instanceof kt)o(t.inner,t.prec);else if(t instanceof ct)i[s].push(t),t.provides&&o(t.provides,s);else if(t instanceof lt)i[s].push(t),t.facet.extensions&&o(t.facet.extensions,s);else{var f=t.extension;if(!f)throw new Error("Unrecognized extension value in extension set (".concat(t,"). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks."));o(f,s)}}return o(t,vt),i.reduce((function(t,e){return t.concat(e)}))}(e,n,a));try{for(u.s();!(r=u.n()).done;){var l=r.value;l instanceof ct?o.push(l):(s[l.facet.id]||(s[l.facet.id]=[])).push(l)}}catch(S){u.e(S)}finally{u.f()}for(var h=Object.create(null),c=[],f=[],d=[],v=function(){var t=m[p];h[t.id]=f.length<<1,f.push((function(e){return t.slot(e)})),d.push(i&&null!=i.config.address[t.id]?i.field(t):St)},p=0,m=o;p<m.length;p++)v();var g=new Map,k=function t(e){if(!(e instanceof at))return!0;var n=g.get(e);if(null!=n)return n;if(g.set(e,!1),w&&ut(w[e.id]||[],s[e.id]||[])){var i,r=y(s[e.id]||[]);try{for(r.s();!(i=r.n()).done;){if(!i.value.dependencies.every(t))return}}catch(S){r.e(S)}finally{r.f()}g.set(e,!0)}},w=null===i||void 0===i?void 0:i.config.facets,b=function(t){var e=s[t],n=e[0].facet,r=w&&w[t]||[],o=ut(e,r);if(e.every((function(t){return 0==t.type}))){h[n.id]=c.length<<1|1;var a,u=o?i.facet(n):n.combine(e.map((function(t){return t.value})));!o&&i&&n.compare(u,a=i.facet(n))&&(u=a),c.push(u)}else{var l,v=y(e);try{var p=function(){var t=l.value,e=t.dependencies.every(k);if(e||(o=!1),0==t.type)h[t.id]=c.length<<1|1,c.push(t.value);else{h[t.id]=f.length<<1,f.push((function(e){return t.dynamicSlot(e)}));var n=i&&e?i.config.address[t.id]:null;d.push(null!=n?At(i,n):St)}};for(v.s();!(l=v.n()).done;)p()}catch(S){v.e(S)}finally{v.f()}h[n.id]=f.length<<1,f.push((function(t){return function(t,e,n){var i=n.map((function(e){return t[e.id]})),r=n.map((function(t){return t.type})),o=i.filter((function(t){return!(1&t)})),s=t[e.id]>>1;return function(t,n){var a,u=t.values[s],l=u===St,h=y(o);try{for(h.s();!(a=h.n()).done;)1&Ct(t,a.value)&&(l=!0)}catch(S){h.e(S)}finally{h.f()}if(!l)return 0;for(var c=[],f=0;f<i.length;f++){var d=At(t,i[f]);if(2==r[f]){var v,p=y(d);try{for(p.s();!(v=p.n()).done;){var m=v.value;c.push(m)}}catch(S){p.e(S)}finally{p.f()}}else c.push(d)}var g=e.combine(c);return u!==St&&e.compare(g,u)?0:(t.values[s]=g,1)}}(t,n,e)})),d.push(o||r.length?i.facet(n):St)}};for(var x in s)b(x);return{configuration:new t(e,a,f.map((function(t){return t(h)})),h,c,s),values:d}}}]),t}();var St={};function Ct(t,e){if(1&e)return 2;var n=e>>1,i=t.status[n];if(4==i)throw new Error("Cyclic dependency between fields and/or facets");if(2&i)return i;t.status[n]=4;var r=t.config.dynamicSlots[n](t,t.applying);return t.status[n]=2|r}function At(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}var Mt=at.define(),Ot=at.define({combine:function(t){return t.some((function(t){return t}))},static:!0}),Dt=at.define({combine:function(t){return t.length?t[0]:void 0},static:!0}),Tt=at.define(),Et=at.define(),Rt=at.define(),Bt=at.define({combine:function(t){return!!t.length&&t[0]}}),Lt=function(){function t(e,n){k(this,t),this.type=e,this.value=n}return b(t,null,[{key:"define",value:function(){return new Pt}}]),t}(),Pt=function(){function t(){k(this,t)}return b(t,[{key:"of",value:function(t){return new Lt(this,t)}}]),t}(),It=function(){function t(e){k(this,t),this.map=e}return b(t,[{key:"of",value:function(t){return new Nt(this,t)}}]),t}(),Nt=function(){function t(e,n){k(this,t),this.type=e,this.value=n}return b(t,[{key:"map",value:function(e){var n=this.type.map(this.value,e);return void 0===n?void 0:n==this.value?this:new t(this.type,n)}},{key:"is",value:function(t){return this.type==t}}],[{key:"define",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new It(t.map||function(t){return t})}},{key:"mapEffects",value:function(t,e){if(!t.length)return t;var n,i=[],r=y(t);try{for(r.s();!(n=r.n()).done;){var o=n.value.map(e);o&&i.push(o)}}catch(s){r.e(s)}finally{r.f()}return i}}]),t}();Nt.reconfigure=Nt.define(),Nt.appendConfig=Nt.define();var Vt=function(){function t(e,n,i,r,o,s){k(this,t),this.startState=e,this.changes=n,this.selection=i,this.effects=r,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,i&&ot(i,n.newLength),o.some((function(e){return e.type==t.time}))||(this.annotations=o.concat(t.time.of(Date.now())))}return b(t,[{key:"newDoc",get:function(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}},{key:"newSelection",get:function(){return this.selection||this.startState.selection.map(this.changes)}},{key:"state",get:function(){return this._state||this.startState.applyTransaction(this),this._state}},{key:"annotation",value:function(t){var e,n=y(this.annotations);try{for(n.s();!(e=n.n()).done;){var i=e.value;if(i.type==t)return i.value}}catch(r){n.e(r)}finally{n.f()}}},{key:"docChanged",get:function(){return!this.changes.empty}},{key:"reconfigured",get:function(){return this.startState.config!=this.state.config}},{key:"isUserEvent",value:function(e){var n=this.annotation(t.userEvent);return!(!n||!(n==e||n.length>e.length&&n.slice(0,e.length)==e&&"."==n[e.length]))}}]),t}();function Ht(t,e){for(var n=[],i=0,r=0;;){var o=void 0,s=void 0;if(i<t.length&&(r==e.length||e[r]>=t[i]))o=t[i++],s=t[i++];else{if(!(r<e.length))return n;o=e[r++],s=e[r++]}!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function Wt(t,e,n){var i,r,o,s;return n?(r=e.changes,o=$.empty(e.changes.length),s=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(r)),{changes:s,selection:e.selection?e.selection.map(o):null===(i=t.selection)||void 0===i?void 0:i.map(r),effects:Nt.mapEffects(t.effects,r).concat(Nt.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Ft(t,e,n){var i=e.selection,r=jt(e.annotations);return e.userEvent&&(r=r.concat(Vt.userEvent.of(e.userEvent))),{changes:e.changes instanceof $?e.changes:$.of(e.changes||[],n,t.facet(Dt)),selection:i&&(i instanceof it?i:it.single(i.anchor,i.head)),effects:jt(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function zt(t,e,n){var i=Ft(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(n=!1);for(var r=1;r<e.length;r++){!1===e[r].filter&&(n=!1);var o=!!e[r].sequential;i=Wt(i,Ft(t,e[r],o?i.changes.newLength:t.doc.length),o)}var s=new Vt(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return function(t){for(var e=t.startState,n=e.facet(Rt),i=t,r=n.length-1;r>=0;r--){var o=n[r](t);o&&Object.keys(o).length&&(i=Wt(t,Ft(e,o,t.changes.newLength),!0))}return i==t?t:new Vt(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}(n?function(t){var e,n=t.startState,i=!0,r=y(n.facet(Tt));try{for(r.s();!(e=r.n()).done;){var o=(0,e.value)(t);if(!1===o){i=!1;break}Array.isArray(o)&&(i=!0===i?o:Ht(i,o))}}catch(f){r.e(f)}finally{r.f()}if(!0!==i){var s,a;if(!1===i)a=t.changes.invertedDesc,s=$.empty(n.doc.length);else{var u=t.changes.filter(i);s=u.changes,a=u.filtered.invertedDesc}t=new Vt(n,s,t.selection&&t.selection.map(a),Nt.mapEffects(t.effects,a),t.annotations,t.scrollIntoView)}for(var l=n.facet(Et),h=l.length-1;h>=0;h--){var c=l[h](t);t=c instanceof Vt?c:Array.isArray(c)&&1==c.length&&c[0]instanceof Vt?c[0]:zt(n,jt(c),!1)}return t}(s):s)}Vt.time=Lt.define(),Vt.userEvent=Lt.define(),Vt.addToHistory=Lt.define(),Vt.remote=Lt.define();var qt=[];function jt(t){return null==t?qt:Array.isArray(t)?t:[t]}var _t,Ut=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ut||(Ut={})),Kt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{_t=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(Td){}function Gt(t){return function(e){if(!/\S/.test(e))return Ut.Space;if(function(t){if(_t)return _t.test(t);for(var e=0;e<t.length;e++){var n=t[e];if(/\w/.test(n)||n>"\x80"&&(n.toUpperCase()!=n.toLowerCase()||Kt.test(n)))return!0}return!1}(e))return Ut.Word;for(var n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return Ut.Word;return Ut.Other}}var Jt=function(){function t(e,n,i,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;k(this,t),this.config=e,this.doc=n,this.selection=i,this.values=r,this.applying=null,this.status=e.statusTemplate.slice(),this.applying=o,o&&(o._state=this);for(var s=0;s<this.config.dynamicSlots.length;s++)Ct(this,s<<1);this.applying=null}return b(t,[{key:"field",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.config.address[t.id];if(null!=n)return Ct(this,n),At(this,n);if(e)throw new RangeError("Field is not present in this state")}},{key:"update",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return zt(this,e,!0)}},{key:"applyTransaction",value:function(e){var n,i,r=this.config,o=r,s=o.base,a=o.compartments,u=y(e.effects);try{for(u.s();!(n=u.n()).done;){var l=n.value;l.is(wt.reconfigure)?(r&&(a=new Map,r.compartments.forEach((function(t,e){return a.set(e,t)})),r=null),a.set(l.value.compartment,l.value.extension)):l.is(Nt.reconfigure)?(r=null,s=l.value):l.is(Nt.appendConfig)&&(r=null,s=jt(s).concat(l.value))}}catch(c){u.e(c)}finally{u.f()}if(r)i=e.startState.values.slice();else{var h=xt.resolve(s,a,this);i=new t(r=h.configuration,this.doc,this.selection,h.values,null).values}new t(r,e.newDoc,e.newSelection,i,e)}},{key:"replaceSelection",value:function(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((function(e){return{changes:{from:e.from,to:e.to,insert:t},range:it.cursor(e.from+t.length)}}))}},{key:"changeByRange",value:function(t){for(var e=this.selection,n=t(e.ranges[0]),i=this.changes(n.changes),r=[n.range],o=jt(n.effects),s=1;s<e.ranges.length;s++){for(var a=t(e.ranges[s]),u=this.changes(a.changes),l=u.map(i),h=0;h<s;h++)r[h]=r[h].map(l);var c=i.mapDesc(u,!0);r.push(a.range.map(c)),i=i.compose(l),o=Nt.mapEffects(o,l).concat(Nt.mapEffects(jt(a.effects),c))}return{changes:i,selection:it.create(r,e.mainIndex),effects:o}}},{key:"changes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e instanceof $?e:$.of(e,this.doc.length,this.facet(t.lineSeparator))}},{key:"toText",value:function(e){return N.of(e.split(this.facet(t.lineSeparator)||K))}},{key:"sliceDoc",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.doc.length;return this.doc.sliceString(t,e,this.lineBreak)}},{key:"facet",value:function(t){var e=this.config.address[t.id];return null==e?t.default:(Ct(this,e),At(this,e))}},{key:"toJSON",value:function(t){var e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(var n in t){var i=t[n];i instanceof ct&&(e[n]=i.spec.toJSON(this.field(t[n]),this))}return e}},{key:"tabSize",get:function(){return this.facet(t.tabSize)}},{key:"lineBreak",get:function(){return this.facet(t.lineSeparator)||"\n"}},{key:"readOnly",get:function(){return this.facet(Bt)}},{key:"phrase",value:function(e){var n,i=y(this.facet(t.phrases));try{for(i.s();!(n=i.n()).done;){var r=n.value;if(Object.prototype.hasOwnProperty.call(r,e))return r[e]}}catch(o){i.e(o)}finally{i.f()}return e}},{key:"languageDataAt",value:function(t,e){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=[],o=y(this.facet(Mt));try{for(o.s();!(n=o.n()).done;){var s,a=n.value,u=y(a(this,e,i));try{for(u.s();!(s=u.n()).done;){var l=s.value;Object.prototype.hasOwnProperty.call(l,t)&&r.push(l[t])}}catch(h){u.e(h)}finally{u.f()}}}catch(h){o.e(h)}finally{o.f()}return r}},{key:"charCategorizer",value:function(t){return Gt(this.languageDataAt("wordChars",t).join(""))}},{key:"wordAt",value:function(t){for(var e=this.doc.lineAt(t),n=e.text,i=e.from,r=e.length,o=this.charCategorizer(t),s=t-i,a=t-i;s>0;){var u=M(n,s,!1);if(o(n.slice(u,s))!=Ut.Word)break;s=u}for(;a<r;){var l=M(n,a);if(o(n.slice(a,l))!=Ut.Word)break;a=l}return s==a?null:it.range(s+i,a+i)}}],[{key:"fromJSON",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");var r=[];if(i){var o=function(t){var n=i[t],o=e[t];r.push(n.init((function(t){return n.spec.fromJSON(o,t)})))};for(var s in i)o(s)}return t.create({doc:e.doc,selection:it.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}},{key:"create",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=xt.resolve(e.extensions||[],new Map),i=n.configuration,r=n.values,o=e.doc instanceof N?e.doc:N.of((e.doc||"").split(i.staticFacet(t.lineSeparator)||K)),s=e.selection?e.selection instanceof it?e.selection:it.single(e.selection.anchor,e.selection.head):it.single(0);return ot(s,o.length),i.staticFacet(Ot)||(s=s.asSingle()),new t(i,o,s,r)}}]),t}();function $t(t,e){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r={},o=y(t);try{for(o.s();!(n=o.n()).done;)for(var s=n.value,a=0,u=Object.keys(s);a<u.length;a++){var l=u[a],h=s[l],c=r[l];if(void 0===c)r[l]=h;else if(c===h||void 0===h);else{if(!Object.hasOwnProperty.call(i,l))throw new Error("Config merge conflict for field "+l);r[l]=i[l](c,h)}}}catch(d){o.e(d)}finally{o.f()}for(var f in e)void 0===r[f]&&(r[f]=e[f]);return r}Jt.allowMultipleSelections=Ot,Jt.tabSize=at.define({combine:function(t){return t.length?t[0]:4}}),Jt.lineSeparator=Dt,Jt.readOnly=Bt,Jt.phrases=at.define(),Jt.languageData=Mt,Jt.changeFilter=Tt,Jt.transactionFilter=Et,Jt.transactionExtender=Rt,wt.reconfigure=Nt.define();var Yt="undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c"),Xt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Qt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{},Zt=function(){function t(e,n){k(this,t),this.rules=[];var i=(n||{}).finish;function r(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function o(t,e,n,s){var a=[],u=/^@(\w+)\b/.exec(t[0]),l=u&&"keyframes"==u[1];if(u&&null==e)return n.push(t[0]+";");for(var h in e){var c=e[h];if(/&/.test(h))o(h.split(/,\s*/).map((function(e){return t.map((function(t){return e.replace(/&/,t)}))})).reduce((function(t,e){return t.concat(e)})),c,n);else if(c&&"object"==typeof c){if(!u)throw new RangeError("The value of a property ("+h+") should be a primitive value.");o(r(h),c,a,l)}else null!=c&&a.push(h.replace(/_.*/,"").replace(/[A-Z]/g,(function(t){return"-"+t.toLowerCase()}))+": "+c+";")}(a.length||l)&&n.push((!i||u||s?t:t.map(i)).join(", ")+" {"+a.join(" ")+"}")}for(var s in e)o(r(s),e[s],this.rules)}return b(t,[{key:"getRules",value:function(){return this.rules.join("\n")}}],[{key:"newName",value:function(){var t=Qt[Yt]||1;return Qt[Yt]=t+1,"\u037c"+t.toString(36)}},{key:"mount",value:function(t,e){(t[Xt]||new ee(t)).mount(Array.isArray(e)?e:[e])}}]),t}(),te=null,ee=function(){function t(e){if(k(this,t),!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(te)return e.adoptedStyleSheets=[te.sheet].concat(e.adoptedStyleSheets),e[Xt]=te;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),te=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");var n=e.head||e;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],e[Xt]=this}return b(t,[{key:"mount",value:function(t){for(var e=this.sheet,n=0,i=0,r=0;r<t.length;r++){var o=t[r],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),i--,s=-1),-1==s){if(this.modules.splice(i++,0,o),e)for(var a=0;a<o.rules.length;a++)e.insertRule(o.rules[a],n++)}else{for(;i<s;)n+=this.modules[i++].rules.length;n+=o.rules.length,i++}}if(!e){for(var u="",l=0;l<this.modules.length;l++)u+=this.modules[l].getRules()+"\n";this.styleTag.textContent=u}}}]),t}(),ne=function(){function t(){k(this,t)}return b(t,[{key:"eq",value:function(t){return this==t}},{key:"range",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return new ie(t,e,this)}}]),t}();ne.prototype.startSide=ne.prototype.endSide=0,ne.prototype.point=!1,ne.prototype.mapMode=G.TrackDel;var ie=b((function t(e,n,i){k(this,t),this.from=e,this.to=n,this.value=i}));function re(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}var oe=function(){function t(e,n,i,r){k(this,t),this.from=e,this.to=n,this.value=i,this.maxPoint=r}return b(t,[{key:"length",get:function(){return this.to[this.to.length-1]}},{key:"findIndex",value:function(t,e,n){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=n?this.to:this.from,o=i,s=r.length;;){if(o==s)return o;var a=o+s>>1,u=r[a]-t||(n?this.value[a].endSide:this.value[a].startSide)-e;if(a==o)return u>=0?o:s;u>=0?s=a:o=a+1}}},{key:"between",value:function(t,e,n,i){for(var r=this.findIndex(e,-1e9,!0),o=this.findIndex(n,1e9,!1,r);r<o;r++)if(!1===i(this.from[r]+t,this.to[r]+t,this.value[r]))return!1}},{key:"map",value:function(e,n){for(var i=[],r=[],o=[],s=-1,a=-1,u=0;u<this.value.length;u++){var l=this.value[u],h=this.from[u]+e,c=this.to[u]+e,f=void 0,d=void 0;if(h==c){var v=n.mapPos(h,l.startSide,l.mapMode);if(null==v)continue;if(f=d=v,l.startSide!=l.endSide&&(d=n.mapPos(h,l.endSide))<f)continue}else if((f=n.mapPos(h,l.startSide))>(d=n.mapPos(c,l.endSide))||f==d&&l.startSide>0&&l.endSide<=0)continue;(d-f||l.endSide-l.startSide)<0||(s<0&&(s=f),l.point&&(a=Math.max(a,d-f)),i.push(l),r.push(f-s),o.push(d-s))}return{mapped:i.length?new t(r,o,i,a):null,pos:s}}}]),t}(),se=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.empty,r=arguments.length>3?arguments[3]:void 0;k(this,t),this.chunkPos=e,this.chunk=n,this.nextLayer=i,this.maxPoint=r}return b(t,[{key:"length",get:function(){var t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}},{key:"size",get:function(){if(this.isEmpty)return 0;var t,e=this.nextLayer.size,n=y(this.chunk);try{for(n.s();!(t=n.n()).done;){e+=t.value.value.length}}catch(i){n.e(i)}finally{n.f()}return e}},{key:"chunkEnd",value:function(t){return this.chunkPos[t]+this.chunk[t].length}},{key:"update",value:function(e){var n=e.add,i=void 0===n?[]:n,r=e.sort,o=void 0!==r&&r,s=e.filterFrom,a=void 0===s?0:s,u=e.filterTo,l=void 0===u?this.length:u,h=e.filter;if(0==i.length&&!h)return this;if(o&&i.slice().sort(re),this.isEmpty)return i.length?t.of(i):this;for(var c=new he(this,null,-1).goto(0),f=0,d=[],v=new ue;c.value||f<i.length;)if(f<i.length&&(c.from-i[f].from||c.startSide-i[f].value.startSide)>=0){var p=i[f++];v.addInner(p.from,p.to,p.value)||d.push(p)}else 1==c.rangeIndex&&c.chunkIndex<this.chunk.length&&(f==i.length||this.chunkEnd(c.chunkIndex)<i[f].from)&&(!h||a>this.chunkEnd(c.chunkIndex)||l<this.chunkPos[c.chunkIndex])&&v.addChunk(this.chunkPos[c.chunkIndex],this.chunk[c.chunkIndex])?c.nextChunk():((!h||a>c.to||l<c.from||h(c.from,c.to,c.value))&&(v.addInner(c.from,c.to,c.value)||d.push(new ie(c.from,c.to,c.value))),c.next());return v.finishInner(this.nextLayer.isEmpty&&!d.length?t.empty:this.nextLayer.update({add:d,filter:h,filterFrom:a,filterTo:l}))}},{key:"map",value:function(e){if(0==e.length||this.isEmpty)return this;for(var n=[],i=[],r=-1,o=0;o<this.chunk.length;o++){var s=this.chunkPos[o],a=this.chunk[o],u=e.touchesRange(s,s+a.length);if(!1===u)r=Math.max(r,a.maxPoint),n.push(a),i.push(e.mapPos(s));else if(!0===u){var l=a.map(s,e),h=l.mapped,c=l.pos;h&&(r=Math.max(r,h.maxPoint),n.push(h),i.push(c))}}var f=this.nextLayer.map(e);return 0==n.length?f:new t(i,n,f,r)}},{key:"between",value:function(t,e,n){if(!this.isEmpty){for(var i=0;i<this.chunk.length;i++){var r=this.chunkPos[i],o=this.chunk[i];if(e>=r&&t<=r+o.length&&!1===o.between(r,t-r,e-r,n))return}this.nextLayer.between(t,e,n)}}},{key:"iter",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return ce.from([this]).goto(t)}},{key:"isEmpty",get:function(){return this.nextLayer==this}}],[{key:"iter",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ce.from(t).goto(e)}},{key:"compare",value:function(t,e,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=t.filter((function(t){return t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r})),s=e.filter((function(t){return t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r})),a=le(o,s,n),u=new de(o,a,r),l=new de(s,a,r);n.iterGaps((function(t,e,n){return ve(u,t,l,e,n,i)})),n.empty&&0==n.length&&ve(u,0,l,0,0,i)}},{key:"eq",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null==i&&(i=1e9);var r=t.filter((function(t){return!t.isEmpty&&e.indexOf(t)<0})),o=e.filter((function(e){return!e.isEmpty&&t.indexOf(e)<0}));if(r.length!=o.length)return!1;if(!r.length)return!0;for(var s=le(r,o),a=new de(r,s,0).goto(n),u=new de(o,s,0).goto(n);;){if(a.to!=u.to||!pe(a.active,u.active)||a.point&&(!u.point||!a.point.eq(u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}},{key:"spans",value:function(t,e,n,i){for(var r,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=new de(t,null,o,null===(r=i.filterPoint)||void 0===r?void 0:r.bind(i)).goto(e),a=e,u=s.openStart;;){var l=Math.min(s.to,n);if(s.point?(i.point(a,l,s.point,s.activeForPoint(s.to),u),u=s.openEnd(l)+(s.to>l?1:0)):l>a&&(i.span(a,l,s.active,u),u=s.openEnd(l)),s.to>n)break;a=s.to,s.next()}return u}},{key:"of",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=new ue,r=y(t instanceof ie?[t]:n?ae(t):t);try{for(r.s();!(e=r.n()).done;){var o=e.value;i.add(o.from,o.to,o.value)}}catch(s){r.e(s)}finally{r.f()}return i.finish()}}]),t}();function ae(t){if(t.length>1)for(var e=t[0],n=1;n<t.length;n++){var i=t[n];if(re(e,i)>0)return t.slice().sort(re);e=i}return t}se.empty=new se([],[],null,-1),se.empty.nextLayer=se.empty;var ue=function(){function t(){k(this,t),this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}return b(t,[{key:"finishChunk",value:function(t){this.chunks.push(new oe(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}},{key:"add",value:function(e,n,i){this.addInner(e,n,i)||(this.nextLayer||(this.nextLayer=new t)).add(e,n,i)}},{key:"addInner",value:function(t,e,n){var i=t-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&(t-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=n,this.lastFrom=t,this.lastTo=e,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}},{key:"addChunk",value:function(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);var n=e.value.length-1;return this.last=e.value[n],this.lastFrom=e.from[n]+t,this.lastTo=e.to[n]+t,!0}},{key:"finish",value:function(){return this.finishInner(se.empty)}},{key:"finishInner",value:function(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;var e=new se(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}]),t}();function le(t,e,n){var i,r=new Map,o=y(t);try{for(o.s();!(i=o.n()).done;)for(var s=i.value,a=0;a<s.chunk.length;a++)s.chunk[a].maxPoint<=0&&r.set(s.chunk[a],s.chunkPos[a])}catch(v){o.e(v)}finally{o.f()}var u,l=new Set,h=y(e);try{for(h.s();!(u=h.n()).done;)for(var c=u.value,f=0;f<c.chunk.length;f++){var d=r.get(c.chunk[f]);null==d||(n?n.mapPos(d):d)!=c.chunkPos[f]||(null===n||void 0===n?void 0:n.touchesRange(d,d+c.chunk[f].length))||l.add(c.chunk[f])}}catch(v){h.e(v)}finally{h.f()}return l}var he=function(){function t(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;k(this,t),this.layer=e,this.skip=n,this.minPoint=i,this.rank=r}return b(t,[{key:"startSide",get:function(){return this.value?this.value.startSide:0}},{key:"endSide",get:function(){return this.value?this.value.endSide:0}},{key:"goto",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}},{key:"gotoInner",value:function(t,e,n){for(;this.chunkIndex<this.layer.chunk.length;){var i=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(i)||this.layer.chunkEnd(this.chunkIndex)<t||i.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){var r=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}},{key:"forward",value:function(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}},{key:"next",value:function(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}var t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],n=t+e.from[this.rangeIndex];if(this.from=n,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}},{key:"setRangeIndex",value:function(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}},{key:"nextChunk",value:function(){this.chunkIndex++,this.rangeIndex=0,this.next()}},{key:"compare",value:function(t){return this.from-t.from||this.startSide-t.startSide||this.to-t.to||this.endSide-t.endSide}}]),t}(),ce=function(){function t(e){k(this,t),this.heap=e}return b(t,[{key:"startSide",get:function(){return this.value?this.value.startSide:0}},{key:"goto",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9,i=y(this.heap);try{for(i.s();!(e=i.n()).done;){var r=e.value;r.goto(t,n)}}catch(s){i.e(s)}finally{i.f()}for(var o=this.heap.length>>1;o>=0;o--)fe(this.heap,o);return this.next(),this}},{key:"forward",value:function(t,e){var n,i=y(this.heap);try{for(i.s();!(n=i.n()).done;){n.value.forward(t,e)}}catch(o){i.e(o)}finally{i.f()}for(var r=this.heap.length>>1;r>=0;r--)fe(this.heap,r);(this.to-t||this.value.endSide-e)<0&&this.next()}},{key:"next",value:function(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{var t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),fe(this.heap,0)}}}],[{key:"from",value:function(e){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=[],o=0;o<e.length;o++)for(var s=e[o];!s.isEmpty;s=s.nextLayer)s.maxPoint>=i&&r.push(new he(s,n,i,o));return 1==r.length?r[0]:new t(r)}}]),t}();function fe(t,e){for(var n=t[e];;){var i=1+(e<<1);if(i>=t.length)break;var r=t[i];if(i+1<t.length&&r.compare(t[i+1])>=0&&(r=t[i+1],i++),n.compare(r)<0)break;t[i]=n,t[e]=r,e=i}}var de=function(){function t(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){return!0};k(this,t),this.minPoint=i,this.filterPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ce.from(e,n,i)}return b(t,[{key:"goto",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}},{key:"forward",value:function(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}},{key:"removeActive",value:function(t){me(this.active,t),me(this.activeTo,t),me(this.activeRank,t),this.minActive=ye(this.active,this.activeTo)}},{key:"addActive",value:function(t){for(var e=0,n=this.cursor,i=n.value,r=n.to,o=n.rank;e<this.activeRank.length&&this.activeRank[e]<=o;)e++;ge(this.active,e,i),ge(this.activeTo,e,r),ge(this.activeRank,e,o),t&&ge(t,e,this.cursor.from),this.minActive=ye(this.active,this.activeTo)}},{key:"next",value:function(){var t=this.to,e=this.point;this.point=null;for(var n=this.openStart<0?[]:null,i=0;;){var r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>t){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&me(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}var o=this.cursor.value;if(o.point)if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{if(this.filterPoint(this.cursor.from,this.cursor.to,this.cursor.value,this.cursor.rank)){this.point=o,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=o.endSide,this.cursor.from<t&&(i=1),this.cursor.next(),this.to>t&&this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(n),this.cursor.next()}}if(n){for(var s=0;s<n.length&&n[s]<t;)s++;this.openStart=s+i}}},{key:"activeForPoint",value:function(t){if(!this.active.length)return this.active;for(var e=[],n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>t||this.activeTo[n]==t&&this.active[n].endSide>=this.point.endSide)&&e.push(this.active[n]);return e.reverse()}},{key:"openEnd",value:function(t){for(var e=0,n=this.activeTo.length-1;n>=0&&this.activeTo[n]>t;n--)e++;return e}}]),t}();function ve(t,e,n,i,r,o){t.goto(e),n.goto(i);for(var s=i+r,a=i,u=i-e;;){var l=t.to+u-n.to||t.endSide-n.endSide,h=l<0?t.to+u:n.to,c=Math.min(h,s);if(t.point||n.point?t.point&&n.point&&(t.point==n.point||t.point.eq(n.point))&&pe(t.activeForPoint(t.to+u),n.activeForPoint(n.to))||o.comparePoint(a,c,t.point,n.point):c>a&&!pe(t.active,n.active)&&o.compareRange(a,c,t.active,n.active),h>s)break;a=h,l<=0&&t.next(),l>=0&&n.next()}}function pe(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!=e[n]&&!t[n].eq(e[n]))return!1;return!0}function me(t,e){for(var n=e,i=t.length-1;n<i;n++)t[n]=t[n+1];t.pop()}function ge(t,e,n){for(var i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=n}function ye(t,e){for(var n=-1,i=1e9,r=0;r<e.length;r++)(e[r]-i||t[r].endSide-t[n].endSide)<0&&(n=r,i=e[r]);return n}for(var ke={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",229:"q"},we={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},be="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),xe="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Se="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),Ce="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ae="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Me=be&&(Ce||+be[1]<57)||Se&&Ce,Oe=0;Oe<10;Oe++)ke[48+Oe]=ke[96+Oe]=String(Oe);for(Oe=1;Oe<=24;Oe++)ke[Oe+111]="F"+Oe;for(Oe=65;Oe<=90;Oe++)ke[Oe]=String.fromCharCode(Oe+32),we[Oe]=String.fromCharCode(Oe);for(var De in ke)we.hasOwnProperty(De)||(we[De]=ke[De]);function Te(t){return(11==t.nodeType?t.getSelection?t:t.ownerDocument:t).getSelection()}function Ee(t,e){return!!e&&t.contains(1!=e.nodeType?e.parentNode:e)}function Re(t,e){if(!e.anchorNode)return!1;try{return Ee(t,e.anchorNode)}catch(Td){return!1}}function Be(t){return 3==t.nodeType?_e(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Le(t,e,n,i){return!!n&&(Ie(t,e,n,i,-1)||Ie(t,e,n,i,1))}function Pe(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Ie(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:Ne(t))){if("DIV"==t.nodeName)return!1;var o=t.parentNode;if(!o||1!=o.nodeType)return!1;e=Pe(t)+(r<0?0:1),t=o}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(r<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=r<0?Ne(t):0}}}function Ne(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}var Ve={left:0,right:0,top:0,bottom:0};function He(t,e){var n=e?t.left:t.right;return{left:n,right:n,top:t.top,bottom:t.bottom}}function We(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}var Fe,ze=function(){function t(){k(this,t),this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}return b(t,[{key:"eq",value:function(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}},{key:"setRange",value:function(t){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}},{key:"set",value:function(t,e,n,i){this.anchorNode=t,this.anchorOffset=e,this.focusNode=n,this.focusOffset=i}}]),t}(),qe=null;function je(t){if(t.setActive)return t.setActive();if(qe)return t.focus(qe);for(var e=[],n=t;n&&(e.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(t.focus(null==qe?{get preventScroll(){return qe={preventScroll:!0},!0}}:void 0),!qe){qe=!1;for(var i=0;i<e.length;){var r=e[i++],o=e[i++],s=e[i++];r.scrollTop!=o&&(r.scrollTop=o),r.scrollLeft!=s&&(r.scrollLeft=s)}}}function _e(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,i=Fe||(Fe=document.createRange());return i.setEnd(t,n),i.setStart(t,e),i}function Ue(t,e,n){var i={key:e,code:e,keyCode:n,which:n,cancelable:!0},r=new KeyboardEvent("keydown",i);r.synthetic=!0,t.dispatchEvent(r);var o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function Ke(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Ge(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}var Je=function(){function t(e,n){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];k(this,t),this.node=e,this.offset=n,this.precise=i}return b(t,null,[{key:"before",value:function(e,n){return new t(e.parentNode,Pe(e),n)}},{key:"after",value:function(e,n){return new t(e.parentNode,Pe(e)+1,n)}}]),t}(),$e=[],Ye=function(){function t(){k(this,t),this.parent=null,this.dom=null,this.dirty=2}return b(t,[{key:"editorView",get:function(){if(!this.parent)throw new Error("Accessing view in orphan content view");return this.parent.editorView}},{key:"overrideDOMText",get:function(){return null}},{key:"posAtStart",get:function(){return this.parent?this.parent.posBefore(this):0}},{key:"posAtEnd",get:function(){return this.posAtStart+this.length}},{key:"posBefore",value:function(t){var e,n=this.posAtStart,i=y(this.children);try{for(i.s();!(e=i.n()).done;){var r=e.value;if(r==t)return n;n+=r.length+r.breakAfter}}catch(o){i.e(o)}finally{i.f()}throw new RangeError("Invalid child in posBefore")}},{key:"posAfter",value:function(t){return this.posBefore(t)+t.length}},{key:"coordsAt",value:function(t,e){return null}},{key:"sync",value:function(e){if(2&this.dirty){var n,i=this.dom,r=i.firstChild,o=y(this.children);try{for(o.s();!(n=o.n()).done;){var s=n.value;if(s.dirty){if(!s.dom&&r){var a=t.get(r);a&&(a.parent||a.constructor!=s.constructor)||s.reuseDOM(r)}s.sync(e),s.dirty=0}if(e&&!e.written&&e.node==i&&r!=s.dom&&(e.written=!0),s.dom.parentNode==i){for(;r&&r!=s.dom;)r=Xe(r);r=s.dom.nextSibling}else i.insertBefore(s.dom,r)}}catch(c){o.e(c)}finally{o.f()}for(r&&e&&e.node==i&&(e.written=!0);r;)r=Xe(r)}else if(1&this.dirty){var u,l=y(this.children);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.dirty&&(h.sync(e),h.dirty=0)}}catch(c){l.e(c)}finally{l.f()}}}},{key:"reuseDOM",value:function(t){}},{key:"localPosFromDOM",value:function(e,n){var i;if(e==this.dom)i=this.dom.childNodes[n];else{for(var r=0==Ne(e)?0:0==n?-1:1;;){var o=e.parentNode;if(o==this.dom)break;0==r&&o.firstChild!=o.lastChild&&(r=e==o.firstChild?-1:1),e=o}i=r<0?e:e.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!t.get(i);)i=i.nextSibling;if(!i)return this.length;for(var s=0,a=0;;s++){var u=this.children[s];if(u.dom==i)return a;a+=u.length+u.breakAfter}}},{key:"domBoundsAround",value:function(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=-1,r=-1,o=-1,s=-1,a=0,u=n,l=n;a<this.children.length;a++){var h=this.children[a],c=u+h.length;if(u<t&&c>e)return h.domBoundsAround(t,e,u);if(c>=t&&-1==i&&(i=a,r=u),u>e&&h.dom.parentNode==this.dom){o=a,s=l;break}l=c,u=c+h.breakAfter}return{from:r,to:s<0?n+this.length:s,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}},{key:"markDirty",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.dirty|=2,this.markParentsDirty(t)}},{key:"markParentsDirty",value:function(t){for(var e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}},{key:"setParent",value:function(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}},{key:"setDOM",value:function(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}},{key:"rootView",get:function(){for(var t=this;;){var e=t.parent;if(!e)return t;t=e}}},{key:"replaceChildren",value:function(t,e){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:$e;this.markDirty();for(var r=t;r<e;r++){var o=this.children[r];o.parent==this&&o.destroy()}(n=this.children).splice.apply(n,[t,e-t].concat(u(i)));for(var s=0;s<i.length;s++)i[s].setParent(this)}},{key:"ignoreMutation",value:function(t){return!1}},{key:"ignoreEvent",value:function(t){return!1}},{key:"childCursor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.length;return new Qe(this.children,t,this.children.length)}},{key:"childPos",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.childCursor().findPos(t,e)}},{key:"toString",value:function(){var t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}},{key:"isEditable",get:function(){return!0}},{key:"merge",value:function(t,e,n,i,r,o){return!1}},{key:"become",value:function(t){return!1}},{key:"getSide",value:function(){return 0}},{key:"destroy",value:function(){this.parent=null}}],[{key:"get",value:function(t){return t.cmView}}]),t}();function Xe(t){var e=t.nextSibling;return t.parentNode.removeChild(t),e}Ye.prototype.breakAfter=0;var Qe=function(){function t(e,n,i){k(this,t),this.children=e,this.pos=n,this.i=i,this.off=0}return b(t,[{key:"findPos",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;var n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}]),t}();function Ze(t,e,n,i,r,o,s,a,u){var l=t.children,h=l.length?l[e]:null,c=o.length?o[o.length-1]:null,f=c?c.breakAfter:s;if(!(e==i&&h&&!s&&!f&&o.length<2&&h.merge(n,r,o.length?c:null,0==n,a,u))){if(i<l.length){var d=l[i];d&&r<d.length?(e==i&&(d=d.split(r),r=0),!f&&c&&d.merge(0,r,c,!0,0,u)?o[o.length-1]=d:(r&&d.merge(0,r,null,!1,0,u),o.push(d))):(null===d||void 0===d?void 0:d.breakAfter)&&(c?c.breakAfter=1:s=1),i++}for(h&&(h.breakAfter=s,n>0&&(!s&&o.length&&h.merge(n,h.length,o[0],!1,a,0)?h.breakAfter=o.shift().breakAfter:(n<h.length||h.children.length&&0==h.children[h.children.length-1].length)&&h.merge(n,h.length,null,!1,a,0),e++));e<i&&o.length;)if(l[i-1].become(o[o.length-1]))i--,o.pop(),u=o.length?0:a;else{if(!l[e].become(o[0]))break;e++,o.shift(),a=o.length?0:u}!o.length&&e&&i<l.length&&!l[e-1].breakAfter&&l[i].merge(0,0,l[e-1],!1,a,u)&&e--,(e<i||o.length)&&t.replaceChildren(e,i,o)}}function tn(t,e,n,i,r,o){var s,a=t.childCursor(),u=a.findPos(n,1),l=u.i,h=u.off,c=a.findPos(e,-1),f=c.i,d=c.off,v=e-n,p=y(i);try{for(p.s();!(s=p.n()).done;){v+=s.value.length}}catch(m){p.e(m)}finally{p.f()}t.length+=v,Ze(t,f,d,l,h,i,0,r,o)}var en="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},nn="undefined"!=typeof document?document:{documentElement:{style:{}}},rn=/Edge\/(\d+)/.exec(en.userAgent),on=/MSIE \d/.test(en.userAgent),sn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(en.userAgent),an=!!(on||sn||rn),un=!an&&/gecko\/(\d+)/i.test(en.userAgent),ln=!an&&/Chrome\/(\d+)/.exec(en.userAgent),hn="webkitFontSmoothing"in nn.documentElement.style,cn=!an&&/Apple Computer/.test(en.vendor),fn=cn&&(/Mobile\/\w+/.test(en.userAgent)||en.maxTouchPoints>2),dn={mac:fn||/Mac/.test(en.platform),windows:/Win/.test(en.platform),linux:/Linux|X11/.test(en.platform),ie:an,ie_version:on?nn.documentMode||6:sn?+sn[1]:rn?+rn[1]:0,gecko:un,gecko_version:un?+(/Firefox\/(\d+)/.exec(en.userAgent)||[0,0])[1]:0,chrome:!!ln,chrome_version:ln?+ln[1]:0,ios:fn,android:/Android\b/.test(en.userAgent),webkit:hn,safari:cn,webkit_version:hn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=nn.documentElement.style.tabSize?"tab-size":"-moz-tab-size"},vn=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).text=t,i}return b(n,[{key:"length",get:function(){return this.text.length}},{key:"createDOM",value:function(t){this.setDOM(t||document.createTextNode(this.text))}},{key:"sync",value:function(t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}},{key:"reuseDOM",value:function(t){3==t.nodeType&&this.createDOM(t)}},{key:"merge",value:function(t,e,i){return(!i||i instanceof n&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}},{key:"split",value:function(t){var e=new n(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}},{key:"localPosFromDOM",value:function(t,e){return t==this.dom?e:e?this.text.length:0}},{key:"domAtPos",value:function(t){return new Je(this.dom,t)}},{key:"domBoundsAround",value:function(t,e,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}},{key:"coordsAt",value:function(t,e){return mn(this.dom,t,e)}}]),n}(Ye),pn=function(t){v(n,t);var e=g(n);function n(t){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;k(this,n),(i=e.call(this)).mark=t,i.children=r,i.length=o;var s,a=y(r);try{for(a.s();!(s=a.n()).done;){var u=s.value;u.setParent(l(i))}}catch(h){a.e(h)}finally{a.f()}return i}return b(n,[{key:"setAttrs",value:function(t){if(Ge(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(var e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}},{key:"reuseDOM",value:function(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}},{key:"sync",value:function(t){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),f(h(n.prototype),"sync",this).call(this,t)}},{key:"merge",value:function(t,e,i,r,o,s){return(!i||!(!(i instanceof n&&i.mark.eq(this.mark))||t&&o<=0||e<this.length&&s<=0))&&(tn(this,t,e,i?i.children:[],o-1,s-1),this.markDirty(),!0)}},{key:"split",value:function(t){var e,i=[],r=0,o=-1,s=0,a=y(this.children);try{for(a.s();!(e=a.n()).done;){var u=e.value,l=r+u.length;l>t&&i.push(r<t?u.split(t-r):u),o<0&&r>=t&&(o=s),r=l,s++}}catch(c){a.e(c)}finally{a.f()}var h=this.length-t;return this.length=t,o>-1&&(this.children.length=o,this.markDirty()),new n(this.mark,i,h)}},{key:"domAtPos",value:function(t){return bn(this.dom,this.children,t)}},{key:"coordsAt",value:function(t,e){return Sn(this,t,e)}}]),n}(Ye);function mn(t,e,n){var i=t.nodeValue.length;e>i&&(e=i);var r=e,o=e,s=0;0==e&&n<0||e==i&&n>=0?dn.chrome||dn.gecko||(e?(r--,s=1):(o++,s=-1)):n<0?r--:o++;var a=_e(t,r,o).getClientRects();if(!a.length)return Ve;var u=a[(s?s<0:n>=0)?0:a.length-1];return dn.safari&&!s&&0==u.width&&(u=Array.prototype.find.call(a,(function(t){return t.width}))||u),s?He(u,s<0):u||null}var gn=function(t){v(n,t);var e=g(n);function n(t,i,r){var o;return k(this,n),(o=e.call(this)).widget=t,o.length=i,o.side=r,o}return b(n,[{key:"split",value:function(t){var e=n.create(this.widget,this.length-t,this.side);return this.length-=t,e}},{key:"sync",value:function(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}},{key:"getSide",value:function(){return this.side}},{key:"merge",value:function(t,e,i,r,o,s){return!(i&&(!(i instanceof n&&this.widget.compare(i.widget))||t>0&&o<=0||e<this.length&&s<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}},{key:"become",value:function(t){return t.length==this.length&&t instanceof n&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.eq(t.widget)||this.markDirty(!0),this.widget=t.widget,!0)}},{key:"ignoreMutation",value:function(){return!0}},{key:"ignoreEvent",value:function(t){return this.widget.ignoreEvent(t)}},{key:"overrideDOMText",get:function(){if(0==this.length)return N.empty;for(var t=this;t.parent;)t=t.parent;var e=t.editorView,n=e&&e.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):N.empty}},{key:"domAtPos",value:function(t){return 0==t?Je.before(this.dom):Je.after(this.dom,t==this.length)}},{key:"domBoundsAround",value:function(){return null}},{key:"coordsAt",value:function(t,e){var n=this.dom.getClientRects(),i=null;if(!n.length)return Ve;for(var r=t>0?n.length-1:0;i=n[r],!(t>0?0==r:r==n.length-1||i.top<i.bottom);r+=t>0?-1:1);return 0==t&&e>0||t==this.length&&e<=0?i:He(i,0==t)}},{key:"isEditable",get:function(){return!1}},{key:"destroy",value:function(){f(h(n.prototype),"destroy",this).call(this),this.dom&&this.widget.destroy(this.dom)}}],[{key:"create",value:function(t,e,i){return new(t.customView||n)(t,e,i)}}]),n}(Ye),yn=function(t){v(n,t);var e=g(n);function n(){return k(this,n),e.apply(this,arguments)}return b(n,[{key:"domAtPos",value:function(t){return new Je(this.widget.text,t)}},{key:"sync",value:function(){this.setDOM(this.widget.toDOM())}},{key:"localPosFromDOM",value:function(t,e){return e?3==t.nodeType?Math.min(e,this.length):this.length:0}},{key:"ignoreMutation",value:function(){return!1}},{key:"overrideDOMText",get:function(){return null}},{key:"coordsAt",value:function(t,e){return mn(this.widget.text,t,e)}},{key:"isEditable",get:function(){return!0}}]),n}(gn),kn=dn.android?"\u200b\u200b":"\u200b",wn=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).side=t,i}return b(n,[{key:"length",get:function(){return 0}},{key:"merge",value:function(){return!1}},{key:"become",value:function(t){return t instanceof n&&t.side==this.side}},{key:"split",value:function(){return new n(this.side)}},{key:"sync",value:function(){this.dom?this.dirty&&this.dom.nodeValue!=kn&&(this.dom.nodeValue=kn):this.setDOM(document.createTextNode(kn))}},{key:"getSide",value:function(){return this.side}},{key:"domAtPos",value:function(t){return Je.before(this.dom)}},{key:"localPosFromDOM",value:function(){return 0}},{key:"domBoundsAround",value:function(){return null}},{key:"coordsAt",value:function(t){var e=Be(this.dom);return e[e.length-1]||null}},{key:"overrideDOMText",get:function(){return N.of([this.dom.nodeValue.replace(/\u200b/g,"")])}}]),n}(Ye);function bn(t,e,n){for(var i=0,r=0;i<e.length;i++){var o=e[i],s=r+o.length;if(!(s==r&&o.getSide()<=0)){if(n>r&&n<s&&o.dom.parentNode==t)return o.domAtPos(n-r);if(n<=r)break;r=s}}for(;i>0;i--){var a=e[i-1].dom;if(a.parentNode==t)return Je.after(a)}return new Je(t,0)}function xn(t,e,n){var i,r=t.children;n>0&&e instanceof pn&&r.length&&(i=r[r.length-1])instanceof pn&&i.mark.eq(e.mark)?xn(i,e.children[0],n-1):(r.push(e),e.setParent(t)),t.length+=e.length}function Sn(t,e,n){for(var i=0,r=0;r<t.children.length;r++){var o=t.children[r],s=i+o.length,a=void 0;if((n<=0||s==t.length||o.getSide()>0?s>=e:s>e)&&(e<s||r+1==t.children.length||(a=t.children[r+1]).length||a.getSide()>0)){var u=0;if(s==i){if(o.getSide()<=0)continue;u=n=-o.getSide()}var l=o.coordsAt(e-i,n);return u&&l?He(l,n<0):l}i=s}var h=t.dom.lastChild;if(!h)return t.dom.getBoundingClientRect();var c=Be(h);return c[c.length-1]||null}function Cn(t,e){for(var n in t)"class"==n&&e.class?e.class+=" "+t.class:"style"==n&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}function An(t,e){if(t==e)return!0;if(!t||!e)return!1;var n=Object.keys(t),i=Object.keys(e);if(n.length!=i.length)return!1;for(var r=0,o=n;r<o.length;r++){var s=o[r];if(-1==i.indexOf(s)||t[s]!==e[s])return!1}return!0}function Mn(t,e,n){if(e)for(var i in e)n&&i in n||t.removeAttribute(i);if(n)for(var r in n)e&&e[r]==n[r]||t.setAttribute(r,n[r])}vn.prototype.children=gn.prototype.children=wn.prototype.children=$e;var On=function(){function t(){k(this,t)}return b(t,[{key:"eq",value:function(t){return!1}},{key:"updateDOM",value:function(t){return!1}},{key:"compare",value:function(t){return this==t||this.constructor==t.constructor&&this.eq(t)}},{key:"estimatedHeight",get:function(){return-1}},{key:"ignoreEvent",value:function(t){return!0}},{key:"customView",get:function(){return null}},{key:"destroy",value:function(t){}}]),t}(),Dn=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Dn||(Dn={})),Tn=function(t){v(n,t);var e=g(n);function n(t,i,r,o){var s;return k(this,n),(s=e.call(this)).startSide=t,s.endSide=i,s.widget=r,s.spec=o,s}return b(n,[{key:"heightRelevant",get:function(){return!1}},{key:"hasHeight",value:function(){return!!this.widget&&this.widget.estimatedHeight>-1}}],[{key:"mark",value:function(t){return new En(t)}},{key:"widget",value:function(t){var e=t.side||0,n=!!t.block;return new Bn(t,e+=n?e>0?3e8:-4e8:e>0?1e8:-1e8,e,n,t.widget||null,!1)}},{key:"replace",value:function(t){var e=!!t.block,n=Ln(t,e),i=n.start,r=n.end;return new Bn(t,(i?e?-3e8:-1:4e8)-1,1+(r?e?2e8:1:-5e8),e,t.widget||null,!0)}},{key:"line",value:function(t){return new Rn(t)}},{key:"set",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return se.of(t,e)}}]),n}(ne);Tn.none=se.empty;var En=function(t){v(n,t);var e=g(n);function n(t){var i;k(this,n);var r=Ln(t),o=r.start,s=r.end;return(i=e.call(this,o?-1:4e8,s?1:-5e8,null,t)).tagName=t.tagName||"span",i.class=t.class||"",i.attrs=t.attributes||null,i}return b(n,[{key:"eq",value:function(t){return this==t||t instanceof n&&this.tagName==t.tagName&&this.class==t.class&&An(this.attrs,t.attrs)}},{key:"range",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;if(t>=e)throw new RangeError("Mark decorations may not be empty");return f(h(n.prototype),"range",this).call(this,t,e)}}]),n}(Tn);En.prototype.point=!1;var Rn=function(t){v(n,t);var e=g(n);function n(t){return k(this,n),e.call(this,-2e8,-2e8,null,t)}return b(n,[{key:"eq",value:function(t){return t instanceof n&&An(this.spec.attributes,t.spec.attributes)}},{key:"range",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return f(h(n.prototype),"range",this).call(this,t,e)}}]),n}(Tn);Rn.prototype.mapMode=G.TrackBefore,Rn.prototype.point=!0;var Bn=function(t){v(n,t);var e=g(n);function n(t,i,r,o,s,a){var u;return k(this,n),(u=e.call(this,i,r,s,t)).block=o,u.isReplace=a,u.mapMode=o?i<=0?G.TrackBefore:G.TrackAfter:G.TrackDel,u}return b(n,[{key:"type",get:function(){return this.startSide<this.endSide?Dn.WidgetRange:this.startSide<=0?Dn.WidgetBefore:Dn.WidgetAfter}},{key:"heightRelevant",get:function(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}},{key:"eq",value:function(t){return t instanceof n&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}},{key:"range",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return f(h(n.prototype),"range",this).call(this,t,e)}}]),n}(Tn);function Ln(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t.inclusiveStart,i=t.inclusiveEnd;return null==n&&(n=t.inclusive),null==i&&(i=t.inclusive),{start:null!==n&&void 0!==n?n:e,end:null!==i&&void 0!==i?i:e}}function Pn(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=n.length-1;r>=0&&n[r]+i>=t?n[r]=Math.max(n[r],e):n.push(t,e)}Bn.prototype.point=!0;var In=function(t){v(n,t);var e=g(n);function n(){var t;return k(this,n),(t=e.apply(this,arguments)).children=[],t.length=0,t.prevAttrs=void 0,t.attrs=null,t.breakAfter=0,t}return b(n,[{key:"merge",value:function(t,e,i,r,o,s){if(i){if(!(i instanceof n))return!1;this.dom||i.transferDOM(this)}return r&&this.setDeco(i?i.attrs:null),tn(this,t,e,i?i.children:[],o,s),!0}},{key:"split",value:function(t){var e=new n;if(e.breakAfter=this.breakAfter,0==this.length)return e;var i=this.childPos(t),r=i.i,o=i.off;o&&(e.append(this.children[r].split(o),0),this.children[r].merge(o,this.children[r].length,null,!1,0,0),r++);for(var s=r;s<this.children.length;s++)e.append(this.children[s],0);for(;r>0&&0==this.children[r-1].length;)this.children[--r].destroy();return this.children.length=r,this.markDirty(),this.length=t,e}},{key:"transferDOM",value:function(t){this.dom&&(t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}},{key:"setDeco",value:function(t){An(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}},{key:"append",value:function(t,e){xn(this,t,e)}},{key:"addLineDeco",value:function(t){var e=t.spec.attributes,n=t.spec.class;e&&(this.attrs=Cn(e,this.attrs||{})),n&&(this.attrs=Cn({class:n},this.attrs||{}))}},{key:"domAtPos",value:function(t){return bn(this.dom,this.children,t)}},{key:"reuseDOM",value:function(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}},{key:"sync",value:function(t){var e;this.dom?4&this.dirty&&(Ge(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Mn(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),f(h(n.prototype),"sync",this).call(this,t);for(var i=this.dom.lastChild;i&&Ye.get(i)instanceof pn;)i=i.lastChild;if(!i||"BR"!=i.nodeName&&0==(null===(e=Ye.get(i))||void 0===e?void 0:e.isEditable)&&(!dn.ios||!this.children.some((function(t){return t instanceof vn})))){var r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}},{key:"measureTextSize",value:function(){if(0==this.children.length||this.length>20)return null;var t,e=0,n=y(this.children);try{for(n.s();!(t=n.n()).done;){var i=t.value;if(!(i instanceof vn))return null;var r=Be(i.dom);if(1!=r.length)return null;e+=r[0].width}}catch(o){n.e(o)}finally{n.f()}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length}}},{key:"coordsAt",value:function(t,e){return Sn(this,t,e)}},{key:"become",value:function(t){return!1}},{key:"type",get:function(){return Dn.Text}}],[{key:"find",value:function(t,e){for(var i=0,r=0;i<t.children.length;i++){var o=t.children[i],s=r+o.length;if(s>=e){if(o instanceof n)return o;if(s>e)break}r=s+o.breakAfter}return null}}]),n}(Ye),Nn=function(t){v(n,t);var e=g(n);function n(t,i,r){var o;return k(this,n),(o=e.call(this)).widget=t,o.length=i,o.type=r,o.breakAfter=0,o}return b(n,[{key:"merge",value:function(t,e,i,r,o,s){return!(i&&(!(i instanceof n&&this.widget.compare(i.widget))||t>0&&o<=0||e<this.length&&s<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}},{key:"domAtPos",value:function(t){return 0==t?Je.before(this.dom):Je.after(this.dom,t==this.length)}},{key:"split",value:function(t){var e=this.length-t;this.length=t;var i=new n(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}},{key:"children",get:function(){return $e}},{key:"sync",value:function(){this.dom&&this.widget.updateDOM(this.dom)||(this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}},{key:"overrideDOMText",get:function(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):N.empty}},{key:"domBoundsAround",value:function(){return null}},{key:"become",value:function(t){return t instanceof n&&t.type==this.type&&t.widget.constructor==this.widget.constructor&&(t.widget.eq(this.widget)||this.markDirty(!0),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0)}},{key:"ignoreMutation",value:function(){return!0}},{key:"ignoreEvent",value:function(t){return this.widget.ignoreEvent(t)}},{key:"destroy",value:function(){f(h(n.prototype),"destroy",this).call(this),this.dom&&this.widget.destroy(this.dom)}}]),n}(Ye),Vn=function(){function t(e,n,i,r){k(this,t),this.doc=e,this.pos=n,this.end=i,this.disallowBlockEffectsBelow=r,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=n}return b(t,[{key:"posCovered",value:function(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;var t=this.content[this.content.length-1];return!t.breakAfter&&!(t instanceof Nn&&t.type==Dn.WidgetBefore)}},{key:"getLine",value:function(){return this.curLine||(this.content.push(this.curLine=new In),this.atCursorPos=!0),this.curLine}},{key:"flushBuffer",value:function(t){this.pendingBuffer&&(this.curLine.append(Hn(new wn(-1),t),t.length),this.pendingBuffer=0)}},{key:"addBlockWidget",value:function(t){this.flushBuffer([]),this.curLine=null,this.content.push(t)}},{key:"finish",value:function(t){t?this.pendingBuffer=0:this.flushBuffer([]),this.posCovered()||this.getLine()}},{key:"buildText",value:function(t,e,n){for(;t>0;){if(this.textOff==this.text.length){var i=this.cursor.next(this.skip),r=i.value,o=i.lineBreak,s=i.done;if(this.skip=0,s)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,t--;continue}this.text=r,this.textOff=0}var a=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(0,n)),this.getLine().append(Hn(new vn(this.text.slice(this.textOff,this.textOff+a)),e),n),this.atCursorPos=!0,this.textOff+=a,t-=a,n=0}}},{key:"span",value:function(t,e,n,i){this.buildText(e-t,n,i),this.pos=e,this.openStart<0&&(this.openStart=i)}},{key:"point",value:function(t,e,n,i,r){var o=e-t;if(n instanceof Bn)if(n.block){var s=n.type;s!=Dn.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Nn(n.widget||new Wn("div"),o,s))}else{var a=gn.create(n.widget||new Wn("span"),o,n.startSide),u=this.atCursorPos&&!a.isEditable&&r<=i.length&&(t<e||n.startSide>0),l=!a.isEditable&&(t<e||n.startSide<=0),h=this.getLine();2!=this.pendingBuffer||u||(this.pendingBuffer=0),this.flushBuffer(i),u&&(h.append(Hn(new wn(1),i),r),r=i.length+Math.max(0,r-i.length)),h.append(Hn(a,i),r),this.atCursorPos=l,this.pendingBuffer=l?t<e?1:2:0}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=r)}},{key:"filterPoint",value:function(t,e,n,i){if(i<this.disallowBlockEffectsBelow&&n instanceof Bn){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}return!0}}],[{key:"build",value:function(e,n,i,r,o){var s=new t(e,n,i,o);return s.openEnd=se.spans(r,n,i,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}]),t}();function Hn(t,e){var n,i=y(e);try{for(i.s();!(n=i.n()).done;){var r=n.value;t=new pn(r,[t],t.length)}}catch(o){i.e(o)}finally{i.f()}return t}var Wn=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).tag=t,i}return b(n,[{key:"eq",value:function(t){return t.tag==this.tag}},{key:"toDOM",value:function(){return document.createElement(this.tag)}},{key:"updateDOM",value:function(t){return t.nodeName.toLowerCase()==this.tag}}]),n}(On),Fn=[],zn=at.define(),qn=at.define(),jn=at.define(),_n=at.define(),Un=at.define(),Kn=at.define(),Gn=Nt.define({map:function(t,e){return t.map(e)}}),Jn=Nt.define({map:function(t,e){return t.map(e)}}),$n=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"nearest",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"nearest",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:5;k(this,t),this.range=e,this.y=n,this.x=i,this.yMargin=r,this.xMargin=o}return b(t,[{key:"map",value:function(e){return e.empty?this:new t(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}]),t}(),Yn=Nt.define({map:function(t,e){return t.map(e)}});function Xn(t,e,n){var i=t.facet(_n);i.length?i[0](e):window.onerror?window.onerror(String(e),n,void 0,void 0,e):n?console.error(n+":",e):console.error(e)}var Qn=at.define({combine:function(t){return!t.length||t[0]}}),Zn=b((function t(e,n){k(this,t),this.field=e,this.get=n})),ti=function(){function t(){k(this,t)}return b(t,[{key:"from",value:function(t){return new Zn(this,t)}}],[{key:"define",value:function(){return new t}}]),t}();ti.decorations=ti.define(),ti.atomicRanges=ti.define(),ti.scrollMargins=ti.define();var ei=0,ni=at.define(),ii=function(){function t(e,n,i){k(this,t),this.id=e,this.create=n,this.fields=i,this.extension=ni.of(this)}return b(t,null,[{key:"define",value:function(e,n){var i=n||{},r=i.eventHandlers,o=i.provide,s=i.decorations,a=[];if(o){var u,l=y(Array.isArray(o)?o:[o]);try{for(l.s();!(u=l.n()).done;){var h=u.value;a.push(h)}}catch(c){l.e(c)}finally{l.f()}}return r&&a.push(ri.from((function(t){return{plugin:t,handlers:r}}))),s&&a.push(ti.decorations.from(s)),new t(ei++,e,a)}},{key:"fromClass",value:function(e,n){return t.define((function(t){return new e(t)}),n)}}]),t}(),ri=ti.define(),oi=function(){function t(e){k(this,t),this.spec=e,this.mustUpdate=null,this.value=null}return b(t,[{key:"takeField",value:function(t,e){if(this.spec){var n,i=y(this.spec.fields);try{for(i.s();!(n=i.n()).done;){var r=n.value,o=r.field,s=r.get;o==t&&e.push(s(this.value))}}catch(a){i.e(a)}finally{i.f()}}}},{key:"update",value:function(t){if(this.value){if(this.mustUpdate){var e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(n){if(Xn(e.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(Td){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(n){Xn(t.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}},{key:"destroy",value:function(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(n){Xn(t.state,n,"CodeMirror plugin crashed")}}},{key:"deactivate",value:function(){this.spec=this.value=null}}]),t}(),si=at.define(),ai=at.define(),ui=at.define(),li=at.define(),hi=function(){function t(e,n,i,r){k(this,t),this.fromA=e,this.toA=n,this.fromB=i,this.toB=r}return b(t,[{key:"join",value:function(e){return new t(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}},{key:"addToSet",value:function(t){for(var e=t.length,n=this;e>0;e--){var i=t[e-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),t.splice(e-1,1)}}return t.splice(e,0,n),t}}],[{key:"extendWithRanges",value:function(e,n){if(0==n.length)return e;for(var i=[],r=0,o=0,s=0,a=0;;r++){for(var u=r==e.length?null:e[r],l=s-a,h=u?u.fromB:1e9;o<n.length&&n[o]<h;){var c=n[o],f=n[o+1],d=Math.max(a,c),v=Math.min(h,f);if(d<=v&&new t(d+l,v+l,d,v).addToSet(i),f>h)break;o+=2}if(!u)return i;new t(u.fromA,u.toA,u.fromB,u.toB).addToSet(i),s=u.toA,a=u.toB}}}]),t}(),ci=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Fn;k(this,t),this.view=e,this.state=n,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=$.empty(this.startState.doc.length);var r,o=y(i);try{for(o.s();!(r=o.n()).done;){var s=r.value;this.changes=this.changes.compose(s.changes)}}catch(l){o.e(l)}finally{o.f()}var a=[];this.changes.iterChangedRanges((function(t,e,n,i){return a.push(new hi(t,e,n,i))})),this.changedRanges=a;var u=e.hasFocus;u!=e.inputState.notifiedFocused&&(e.inputState.notifiedFocused=u,this.flags|=1)}return b(t,[{key:"viewportChanged",get:function(){return(4&this.flags)>0}},{key:"heightChanged",get:function(){return(2&this.flags)>0}},{key:"geometryChanged",get:function(){return this.docChanged||(10&this.flags)>0}},{key:"focusChanged",get:function(){return(1&this.flags)>0}},{key:"docChanged",get:function(){return!this.changes.empty}},{key:"selectionSet",get:function(){return this.transactions.some((function(t){return t.selection}))}},{key:"empty",get:function(){return 0==this.flags&&0==this.transactions.length}}]),t}(),fi=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(fi||(fi={})),di=fi.LTR,vi=fi.RTL;function pi(t){for(var e=[],n=0;n<t.length;n++)e.push(1<<+t[n]);return e}for(var mi=pi("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),gi=pi("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),yi=Object.create(null),ki=[],wi=0,bi=["()","[]","{}"];wi<bi.length;wi++){var xi=bi[wi],Si=xi.charCodeAt(0),Ci=xi.charCodeAt(1);yi[Si]=Ci,yi[Ci]=-Si}function Ai(t){return t<=247?mi[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?gi[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8203||8204==t?256:1}var Mi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,Oi=function(){function t(e,n,i){k(this,t),this.from=e,this.to=n,this.level=i}return b(t,[{key:"dir",get:function(){return this.level%2?vi:di}},{key:"side",value:function(t,e){return this.dir==e==t?this.to:this.from}}],[{key:"find",value:function(t,e,n,i){for(var r=-1,o=0;o<t.length;o++){var s=t[o];if(s.from<=e&&s.to>=e){if(s.level==n)return o;(r<0||(0!=i?i<0?s.from<e:s.to>e:t[r].level>s.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}]),t}(),Di=[];function Ti(t,e){var n=t.length,i=e==di?1:2,r=e==di?2:1;if(!t||1==i&&!Mi.test(t))return Ei(n);for(var o=0,s=i,a=i;o<n;o++){var u=Ai(t.charCodeAt(o));512==u?u=s:8==u&&4==a&&(u=16),Di[o]=4==u?2:u,7&u&&(a=u),s=u}for(var l=0,h=i,c=i;l<n;l++){var f=Di[l];if(128==f)l<n-1&&h==Di[l+1]&&24&h?f=Di[l]=h:Di[l]=256;else if(64==f){for(var d=l+1;d<n&&64==Di[d];)d++;for(var v=l&&8==h||d<n&&8==Di[d]?1==c?1:8:256,p=l;p<d;p++)Di[p]=v;l=d-1}else 8==f&&1==c&&(Di[l]=1);h=f,7&f&&(c=f)}for(var m,g,y,k=0,w=0,b=0;k<n;k++)if(g=yi[m=t.charCodeAt(k)])if(g<0){for(var x=w-3;x>=0;x-=3)if(ki[x+1]==-g){var S=ki[x+2],C=2&S?i:4&S?1&S?r:i:0;C&&(Di[k]=Di[ki[x]]=C),w=x;break}}else{if(189==ki.length)break;ki[w++]=k,ki[w++]=m,ki[w++]=b}else if(2==(y=Di[k])||1==y){var A=y==i;b=A?0:1;for(var M=w-3;M>=0;M-=3){var O=ki[M+2];if(2&O)break;if(A)ki[M+2]|=2;else{if(4&O)break;ki[M+2]|=4}}}for(var D=0;D<n;D++)if(256==Di[D]){for(var T=D+1;T<n&&256==Di[T];)T++;for(var E=1==(D?Di[D-1]:i),R=E==(1==(T<n?Di[T]:i))?E?1:2:i,B=D;B<T;B++)Di[B]=R;D=T-1}var L=[];if(1==i)for(var P=0;P<n;){for(var I=P,N=1!=Di[P++];P<n&&N==(1!=Di[P]);)P++;if(N)for(var V=P;V>I;){for(var H=V,W=2!=Di[--V];V>I&&W==(2!=Di[V-1]);)V--;L.push(new Oi(V,H,W?2:1))}else L.push(new Oi(I,P,0))}else for(var F=0;F<n;){for(var z=F,q=2==Di[F++];F<n&&q==(2==Di[F]);)F++;L.push(new Oi(z,F,q?1:2))}return L}function Ei(t){return[new Oi(0,t,0)]}var Ri="";function Bi(t,e,n,i,r){var o,s=i.head-t.from,a=-1;if(0==s){if(!r||!t.length)return null;e[0].level!=n&&(s=e[0].side(!1,n),a=0)}else if(s==t.length){if(r)return null;var u=e[e.length-1];u.level!=n&&(s=u.side(!0,n),a=e.length-1)}a<0&&(a=Oi.find(e,s,null!==(o=i.bidiLevel)&&void 0!==o?o:-1,i.assoc));var l=e[a];s==l.side(r,n)&&(s=(l=e[a+=r?1:-1]).side(!r,n));var h=r==(l.dir==n),c=M(t.text,s,h);if(Ri=t.text.slice(Math.min(s,c),Math.max(s,c)),c!=l.side(r,n))return it.cursor(c+t.from,h?-1:1,l.level);var f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f||l.level==n?f&&f.level<l.level?it.cursor(f.side(!r,n)+t.from,r?1:-1,f.level):it.cursor(c+t.from,r?-1:1,l.level):it.cursor(r?t.to:t.from,r?-1:1,n)}var Li="\uffff",Pi=function(){function t(e,n){k(this,t),this.points=e,this.text="",this.lineSeparator=n.facet(Jt.lineSeparator)}return b(t,[{key:"append",value:function(t){this.text+=t}},{key:"lineBreak",value:function(){this.text+=Li}},{key:"readRange",value:function(t,e){if(!t)return this;for(var n=t.parentNode,i=t;;){this.findPointBefore(n,i),this.readNode(i);var r=i.nextSibling;if(r==e)break;var o=Ye.get(i),s=Ye.get(r);(o&&s?o.breakAfter:(o?o.breakAfter:Ii(i))||Ii(r)&&("BR"!=i.nodeName||i.cmIgnore))&&this.lineBreak(),i=r}return this.findPointBefore(n,e),this}},{key:"readTextNode",value:function(t){var e,n=t.nodeValue,i=y(this.points);try{for(i.s();!(e=i.n()).done;){var r=e.value;r.node==t&&(r.pos=this.text.length+Math.min(r.offset,n.length))}}catch(d){i.e(d)}finally{i.f()}for(var o=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){var a=-1,u=1,l=void 0;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,o),u=this.lineSeparator.length):(l=s.exec(n))&&(a=l.index,u=l[0].length),this.append(n.slice(o,a<0?n.length:a)),a<0)break;if(this.lineBreak(),u>1){var h,c=y(this.points);try{for(c.s();!(h=c.n()).done;){var f=h.value;f.node==t&&f.pos>this.text.length&&(f.pos-=u-1)}}catch(d){c.e(d)}finally{c.f()}}o=a+u}}},{key:"readNode",value:function(t){if(!t.cmIgnore){var e=Ye.get(t),n=e&&e.overrideDOMText;if(null!=n){this.findPointInside(t,n.length);for(var i=n.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}}},{key:"findPointBefore",value:function(t,e){var n,i=y(this.points);try{for(i.s();!(n=i.n()).done;){var r=n.value;r.node==t&&t.childNodes[r.offset]==e&&(r.pos=this.text.length)}}catch(o){i.e(o)}finally{i.f()}}},{key:"findPointInside",value:function(t,e){var n,i=y(this.points);try{for(i.s();!(n=i.n()).done;){var r=n.value;(3==t.nodeType?r.node==t:t.contains(r.node))&&(r.pos=this.text.length+Math.min(e,r.offset))}}catch(o){i.e(o)}finally{i.f()}}}]),t}();function Ii(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}var Ni=b((function t(e,n){k(this,t),this.node=e,this.offset=n,this.pos=-1})),Vi=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).view=t,i.compositionDeco=Tn.none,i.decorations=[],i.pluginDecorationLength=0,i.minWidth=0,i.minWidthFrom=0,i.minWidthTo=0,i.impreciseAnchor=null,i.impreciseHead=null,i.forceSelection=!1,i.lastUpdate=Date.now(),i.setDOM(t.contentDOM),i.children=[new In],i.children[0].setParent(l(i)),i.updateDeco(),i.updateInner([new hi(0,0,0,t.state.doc.length)],0),i}return b(n,[{key:"root",get:function(){return this.view.root}},{key:"editorView",get:function(){return this.view}},{key:"length",get:function(){return this.view.state.doc.length}},{key:"update",value:function(t){var e=this,n=t.changedRanges;this.minWidth>0&&n.length&&(n.every((function(t){var n=t.fromA;return t.toA<e.minWidthFrom||n>e.minWidthTo}))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=Tn.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){var n=Fi(t);if(!n)return Tn.none;var i=n.from,r=n.to,o=n.node,s=n.text,a=e.mapPos(i,1),u=Math.max(a,e.mapPos(r,-1)),l=t.state,h=3==o.nodeType?o.nodeValue:new Pi([],l).readRange(o.firstChild,null).text;if(u-a<h.length)if(l.doc.sliceString(a,Math.min(l.doc.length,a+h.length),Li)==h)u=a+h.length;else{if(l.doc.sliceString(Math.max(0,u-h.length),u,Li)!=h)return Tn.none;a=u-h.length}else if(l.doc.sliceString(a,u,Li)!=h)return Tn.none;return Tn.set(Tn.replace({widget:new zi(o,s)}).range(a,u))}(this.view,t.changes)),(dn.ie||dn.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);var i=function(t,e,n){var i=new _i;return se.compare(t,e,n,i),i.changes}(this.decorations,this.updateDeco(),t.changes);return n=hi.extendWithRanges(n,i),(0!=this.dirty||0!=n.length)&&(this.updateInner(n,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}},{key:"updateInner",value:function(t,e){var n=this;this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);var i=this.view.observer;i.ignore((function(){n.dom.style.height=n.view.viewState.contentHeight+"px",n.dom.style.minWidth=n.minWidth?n.minWidth+"px":"";var t=dn.chrome||dn.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;n.sync(t),n.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(n.forceSelection=!0),n.dom.style.height=""}));var r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length){var o,s=y(this.children);try{for(s.s();!(o=s.n()).done;){var a=o.value;a instanceof Nn&&a.widget instanceof Wi&&r.push(a.dom)}}catch(u){s.e(u)}finally{s.f()}}i.updateGaps(r)}},{key:"updateChildren",value:function(t,e){for(var n=this.childCursor(e),i=t.length-1;;i--){var r=i>=0?t[i]:null;if(!r)break;var o=r.fromA,s=r.toA,a=r.fromB,u=r.toB,l=Vn.build(this.view.state.doc,a,u,this.decorations,this.pluginDecorationLength),h=l.content,c=l.breakAtStart,f=l.openStart,d=l.openEnd,v=n.findPos(s,1),p=v.i,m=v.off,g=n.findPos(o,-1);Ze(this,g.i,g.off,p,m,h,c,f,d)}}},{key:"updateSelection",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&this.view.observer.readSelectionRange(),!(!n&&!this.mayControlSelection()||dn.ios&&this.view.inputState.rapidCompositionStart)){var i=this.forceSelection;this.forceSelection=!1;var r=this.view.state.selection.main,o=this.domAtPos(r.anchor),s=r.empty?o:this.domAtPos(r.head);if(dn.gecko&&r.empty&&Hi(o)){var a=document.createTextNode("");this.view.observer.ignore((function(){return o.node.insertBefore(a,o.node.childNodes[o.offset]||null)})),o=s=new Je(a,0),i=!0}var u=this.view.observer.selectionRange;!i&&u.focusNode&&Le(o.node,o.offset,u.anchorNode,u.anchorOffset)&&Le(s.node,s.offset,u.focusNode,u.focusOffset)||(this.view.observer.ignore((function(){dn.android&&dn.chrome&&t.dom.contains(u.focusNode)&&Ui(u.focusNode,t.dom)&&(t.dom.blur(),t.dom.focus({preventScroll:!0}));var e=Te(t.root);if(r.empty){if(dn.gecko){var n=ji(o.node,o.offset);if(n&&3!=n){var i=qi(o.node,o.offset,1==n?1:-1);i&&(o=new Je(i,1==n?0:i.nodeValue.length))}}e.collapse(o.node,o.offset),null!=r.bidiLevel&&null!=u.cursorBidiLevel&&(u.cursorBidiLevel=r.bidiLevel)}else if(e.extend)e.collapse(o.node,o.offset),e.extend(s.node,s.offset);else{var a=document.createRange();if(r.anchor>r.head){var l=[s,o];o=l[0],s=l[1]}a.setEnd(s.node,s.offset),a.setStart(o.node,o.offset),e.removeAllRanges(),e.addRange(a)}})),this.view.observer.setSelectionRange(o,s)),this.impreciseAnchor=o.precise?null:new Je(u.anchorNode,u.anchorOffset),this.impreciseHead=s.precise?null:new Je(u.focusNode,u.focusOffset)}}},{key:"enforceCursorAssoc",value:function(){if(!this.compositionDeco.size){var t=this.view.state.selection.main,e=Te(this.root);if(t.empty&&t.assoc&&e.modify){var n=In.find(this,t.head);if(n){var i=n.posAtStart;if(t.head!=i&&t.head!=i+n.length){var r=this.coordsAt(t.head,-1),o=this.coordsAt(t.head,1);if(r&&o&&!(r.bottom>o.top)){var s=this.domAtPos(t.head+t.assoc);e.collapse(s.node,s.offset),e.modify("move",t.assoc<0?"forward":"backward","lineboundary")}}}}}}},{key:"mayControlSelection",value:function(){return this.view.state.facet(Qn)?this.root.activeElement==this.dom:Re(this.dom,this.view.observer.selectionRange)}},{key:"nearest",value:function(t){for(var e=t;e;){var n=Ye.get(e);if(n&&n.rootView==this)return n;e=e.parentNode}return null}},{key:"posFromDOM",value:function(t,e){var n=this.nearest(t);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(t,e)+n.posAtStart}},{key:"domAtPos",value:function(t){for(var e=this.childCursor().findPos(t,-1),n=e.i,i=e.off;n<this.children.length-1;){var r=this.children[n];if(i<r.length||r instanceof In)break;n++,i=0}return this.children[n].domAtPos(i)}},{key:"coordsAt",value:function(t,e){for(var n=this.length,i=this.children.length-1;;i--){var r=this.children[i],o=n-r.breakAfter-r.length;if(t>o||t==o&&r.type!=Dn.WidgetBefore&&r.type!=Dn.WidgetAfter&&(!i||2==e||this.children[i-1].breakAfter||this.children[i-1].type==Dn.WidgetBefore&&e>-2))return r.coordsAt(t-o,e);n=o}}},{key:"measureVisibleLineHeights",value:function(){for(var t=[],e=this.view.viewState.viewport,n=e.from,i=e.to,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=0,u=0;u<this.children.length;u++){var l=this.children[u],h=a+l.length;if(h>i)break;if(a>=n){var c=l.dom.getBoundingClientRect();if(t.push(c.height),o){var f=l.dom.lastChild,d=f?Be(f):[];if(d.length){var v=d[d.length-1],p=this.view.textDirection==fi.LTR?v.right-c.left:c.right-v.left;p>s&&(s=p,this.minWidth=r,this.minWidthFrom=a,this.minWidthTo=h)}}}a=h+l.breakAfter}return t}},{key:"measureTextSize",value:function(){var t,e=this,n=y(this.children);try{for(n.s();!(t=n.n()).done;){var i=t.value;if(i instanceof In){var r=i.measureTextSize();if(r)return r}}}catch(u){n.e(u)}finally{n.f()}var o,s,a=document.createElement("div");return a.className="cm-line",a.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((function(){e.dom.appendChild(a);var t=Be(a.firstChild)[0];o=a.getBoundingClientRect().height,s=t?t.width/27:7,a.remove()})),{lineHeight:o,charWidth:s}}},{key:"childCursor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.length,e=this.children.length;return e&&(t-=this.children[--e].length),new Qe(this.children,t,e)}},{key:"computeBlockGapDeco",value:function(){for(var t=[],e=this.view.viewState,n=0,i=0;;i++){var r=i==e.viewports.length?null:e.viewports[i],o=r?r.from-1:this.length;if(o>n){var s=e.lineBlockAt(o).bottom-e.lineBlockAt(n).top;t.push(Tn.replace({widget:new Wi(s),block:!0,inclusive:!0}).range(n,o))}if(!r)break;n=r.to+1}return Tn.set(t)}},{key:"updateDeco",value:function(){var t=this.view.pluginField(ti.decorations);return this.pluginDecorationLength=t.length,this.decorations=[].concat(u(t),u(this.view.state.facet(ui)),[this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco])}},{key:"scrollIntoView",value:function(t){var e,n=t.range,i=this.coordsAt(n.head,n.empty?n.assoc:n.head>n.anchor?-1:1);if(i){!n.empty&&(e=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,e.left),top:Math.min(i.top,e.top),right:Math.max(i.right,e.right),bottom:Math.max(i.bottom,e.bottom)});var r,o=0,s=0,a=0,u=0,l=y(this.view.pluginField(ti.scrollMargins));try{for(l.s();!(r=l.n()).done;){var h=r.value;if(h){var c=h.left,f=h.right,d=h.top,v=h.bottom;null!=c&&(o=Math.max(o,c)),null!=f&&(s=Math.max(s,f)),null!=d&&(a=Math.max(a,d)),null!=v&&(u=Math.max(u,v))}}}catch(m){l.e(m)}finally{l.f()}var p={left:i.left-o,top:i.top-a,right:i.right+s,bottom:i.bottom+u};!function(t,e,n,i,r,o,s,a){for(var u=t.ownerDocument,l=u.defaultView,h=t;h;)if(1==h.nodeType){var c=void 0,f=h==u.body;if(f)c=We(l);else{if(h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.parentNode;continue}var d=h.getBoundingClientRect();c={left:d.left,right:d.left+h.clientWidth,top:d.top,bottom:d.top+h.clientHeight}}var v=0,p=0;if("nearest"==r)e.top<c.top?(p=-(c.top-e.top+s),n>0&&e.bottom>c.bottom+p&&(p=e.bottom-c.bottom+p+s)):e.bottom>c.bottom&&(p=e.bottom-c.bottom+s,n<0&&e.top-p<c.top&&(p=-(c.top+p-e.top+s)));else{var m=e.bottom-e.top,g=c.bottom-c.top;p=("center"==r&&m<=g?e.top+m/2-g/2:"start"==r||"center"==r&&n<0?e.top-s:e.bottom-g+s)-c.top}if("nearest"==i?e.left<c.left?(v=-(c.left-e.left+o),n>0&&e.right>c.right+v&&(v=e.right-c.right+v+o)):e.right>c.right&&(v=e.right-c.right+o,n<0&&e.left<c.left+v&&(v=-(c.left+v-e.left+o))):v=("center"==i?e.left+(e.right-e.left)/2-(c.right-c.left)/2:"start"==i==a?e.left-o:e.right-(c.right-c.left)+o)-c.left,v||p)if(f)l.scrollBy(v,p);else{if(p){var y=h.scrollTop;h.scrollTop+=p,p=h.scrollTop-y}if(v){var k=h.scrollLeft;h.scrollLeft+=v,v=h.scrollLeft-k}e={left:e.left-v,top:e.top-p,right:e.right-v,bottom:e.bottom-p}}if(f)break;h=h.assignedSlot||h.parentNode,i=r="nearest"}else{if(11!=h.nodeType)break;h=h.host}}(this.view.scrollDOM,p,n.head<n.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==fi.LTR)}}}]),n}(Ye);function Hi(t){return 1==t.node.nodeType&&t.node.firstChild&&(0==t.offset||"false"==t.node.childNodes[t.offset-1].contentEditable)&&(t.offset==t.node.childNodes.length||"false"==t.node.childNodes[t.offset].contentEditable)}var Wi=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).height=t,i}return b(n,[{key:"toDOM",value:function(){var t=document.createElement("div");return this.updateDOM(t),t}},{key:"eq",value:function(t){return t.height==this.height}},{key:"updateDOM",value:function(t){return t.style.height=this.height+"px",!0}},{key:"estimatedHeight",get:function(){return this.height}}]),n}(On);function Fi(t){var e=t.observer.selectionRange,n=e.focusNode&&qi(e.focusNode,e.focusOffset,0);if(!n)return null;var i=t.docView.nearest(n);if(!i)return null;if(i instanceof In){for(var r=n;r.parentNode!=i.dom;)r=r.parentNode;for(var o=r.previousSibling;o&&!Ye.get(o);)o=o.previousSibling;var s=o?Ye.get(o).posAtEnd:i.posAtStart;return{from:s,to:s,node:r,text:n}}for(;;){var a=i.parent;if(!a)return null;if(a instanceof In)break;i=a}var u=i.posAtStart;return{from:u,to:u+i.length,node:i.dom,text:n}}var zi=function(t){v(n,t);var e=g(n);function n(t,i){var r;return k(this,n),(r=e.call(this)).top=t,r.text=i,r}return b(n,[{key:"eq",value:function(t){return this.top==t.top&&this.text==t.text}},{key:"toDOM",value:function(){return this.top}},{key:"ignoreEvent",value:function(){return!1}},{key:"customView",get:function(){return yn}}]),n}(On);function qi(t,e,n){for(;;){if(3==t.nodeType)return t;if(1==t.nodeType&&e>0&&n<=0)e=Ne(t=t.childNodes[e-1]);else{if(!(1==t.nodeType&&e<t.childNodes.length&&n>=0))return null;t=t.childNodes[e],e=0}}}function ji(t,e){return 1!=t.nodeType?0:(e&&"false"==t.childNodes[e-1].contentEditable?1:0)|(e<t.childNodes.length&&"false"==t.childNodes[e].contentEditable?2:0)}var _i=function(){function t(){k(this,t),this.changes=[]}return b(t,[{key:"compareRange",value:function(t,e){Pn(t,e,this.changes)}},{key:"comparePoint",value:function(t,e){Pn(t,e,this.changes)}}]),t}();function Ui(t,e){for(var n=t;n&&n!=e;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}function Ki(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Gi(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Ji(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function $i(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Yi(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Xi(t,e,n){for(var i,r,o,s,a,u,l,h,c=t.firstChild;c;c=c.nextSibling)for(var f=Be(c),d=0;d<f.length;d++){var v=f[d];r&&Ji(r,v)&&(v=$i(Yi(v,r.bottom),r.top));var p=Ki(e,v),m=Gi(n,v);if(0==p&&0==m)return 3==c.nodeType?Qi(c,e,n):Xi(c,e,n);(!i||s>m||s==m&&o>p)&&(i=c,r=v,o=p,s=m),0==p?n>v.bottom&&(!l||l.bottom<v.bottom)?(a=c,l=v):n<v.top&&(!h||h.top>v.top)&&(u=c,h=v):l&&Ji(l,v)?l=Yi(l,v.bottom):h&&Ji(h,v)&&(h=$i(h,v.top))}if(l&&l.bottom>=n?(i=a,r=l):h&&h.top<=n&&(i=u,r=h),!i)return{node:t,offset:0};var g=Math.max(r.left,Math.min(r.right,e));return 3==i.nodeType?Qi(i,g,n):o||"true"!=i.contentEditable?{node:t,offset:Array.prototype.indexOf.call(t.childNodes,i)+(e>=(r.left+r.right)/2?1:0)}:Xi(i,g,n)}function Qi(t,e,n){for(var i=t.nodeValue.length,r=-1,o=1e9,s=0,a=0;a<i;a++)for(var u=_e(t,a,a+1).getClientRects(),l=0;l<u.length;l++){var h=u[l];if(h.top!=h.bottom){s||(s=e-h.left);var c=(h.top>n?h.top-n:n-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<o){var f=e>=(h.left+h.right)/2,d=f;if(dn.chrome||dn.gecko)_e(t,a).getBoundingClientRect().left==h.right&&(d=!f);if(c<=0)return{node:t,offset:a+(d?1:0)};r=a+(d?1:0),o=c}}}return{node:t,offset:r>-1?r:s>0?t.nodeValue.length:0}}function Zi(t,e,n){var i,r,o=e.x,s=e.y,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,u=t.contentDOM.getBoundingClientRect(),l=u.top+t.viewState.paddingTop,h=t.viewState.docHeight,c=s-l;if(c<0)return 0;if(c>h)return t.state.doc.length;for(var f=t.defaultLineHeight/2,d=!1;(r=t.elementAtHeight(c)).type!=Dn.Text;)for(;!((c=a>0?r.bottom+f:r.top-f)>=0&&c<=h);){if(d)return n?null:0;d=!0,a=-a}s=l+c;var v=r.from;if(v<t.viewport.from)return 0==t.viewport.from?0:n?null:tr(t,u,r,o,s);if(v>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:n?null:tr(t,u,r,o,s);var p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(o,s);g&&!t.contentDOM.contains(g)&&(g=null),g||(o=Math.max(u.left+1,Math.min(u.right-1,o)),(g=m.elementFromPoint(o,s))&&!t.contentDOM.contains(g)&&(g=null));var y,k=-1;if(g&&0!=(null===(i=t.docView.nearest(g))||void 0===i?void 0:i.isEditable))if(p.caretPositionFromPoint){var w=p.caretPositionFromPoint(o,s);w&&(y=w.offsetNode,k=w.offset)}else if(p.caretRangeFromPoint){var b=p.caretRangeFromPoint(o,s);b&&(y=b.startContainer,k=b.startOffset,dn.safari&&er(y,k,o)&&(y=void 0))}if(!y||!t.docView.dom.contains(y)){var x=In.find(t.docView,v);if(!x)return c>r.top+r.height/2?r.to:r.from;var S=Xi(x.dom,o,s);y=S.node,k=S.offset}return t.docView.posFromDOM(y,k)}function tr(t,e,n,i,r){var o=Math.round((i-e.left)*t.defaultCharacterWidth);t.lineWrapping&&n.height>1.5*t.defaultLineHeight&&(o+=Math.floor((r-n.top)/t.defaultLineHeight)*t.viewState.heightOracle.lineLength);var s=t.state.sliceDoc(n.from,n.to);return n.from+I(s,o,t.state.tabSize)}function er(t,e,n){var i;if(3!=t.nodeType||e!=(i=t.nodeValue.length))return!1;for(var r=t.nextSibling;r;r=r.nextSibling)if(1!=r.nodeType||"BR"!=r.nodeName)return!1;return _e(t,i-1,i).getBoundingClientRect().left>n}function nr(t,e,n,i){var r=t.state.doc.lineAt(e.head),o=i&&t.lineWrapping?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(o){var s=t.dom.getBoundingClientRect(),a=t.posAtCoords({x:n==(t.textDirection==fi.LTR)?s.right-1:s.left+1,y:(o.top+o.bottom)/2});if(null!=a)return it.cursor(a,n?-1:1)}var u=In.find(t.docView,e.head),l=u?n?u.posAtEnd:u.posAtStart:n?r.to:r.from;return it.cursor(l,n?-1:1)}function ir(t,e,n,i){for(var r=t.state.doc.lineAt(e.head),o=t.bidiSpans(r),s=e,a=null;;){var u=Bi(r,o,t.textDirection,s,n),l=Ri;if(!u){if(r.number==(n?t.state.doc.lines:1))return s;l="\n",r=t.state.doc.line(r.number+(n?1:-1)),o=t.bidiSpans(r),u=it.cursor(n?r.from:r.to)}if(a){if(!a(l))return s}else{if(!i)return u;a=i(l)}s=u}}function rr(t,e,n){for(var i=t.pluginField(ti.atomicRanges);;){var r,o=!1,s=y(i);try{for(s.s();!(r=s.n()).done;){r.value.between(n.from-1,n.from+1,(function(t,i,r){n.from>t&&n.from<i&&(n=e.from>n.from?it.cursor(t,1):it.cursor(i,-1),o=!0)}))}}catch(a){s.e(a)}finally{s.f()}if(!o)return n}}var or=function(){function t(e){var n=this;k(this,t),this.lastKeyCode=0,this.lastKeyTime=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;var i=function(t){var i=hr[t];e.contentDOM.addEventListener(t,(function(r){"keydown"==t&&n.keydown(e,r)||lr(e,r)&&!n.ignoreDuringComposition(r)&&(n.mustFlushObserver(r)&&e.observer.forceFlush(),n.runCustomHandlers(t,e,r)?r.preventDefault():i(e,r))})),n.registeredEvents.push(t)};for(var r in hr)i(r);this.notifiedFocused=e.hasFocus,this.ensureHandlers(e),dn.safari&&e.contentDOM.addEventListener("input",(function(){return null}))}return b(t,[{key:"setSelectionOrigin",value:function(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}},{key:"ensureHandlers",value:function(t){var e,n=this,i=y(this.customHandlers=t.pluginField(ri));try{for(i.s();!(e=i.n()).done;){var r=e.value,o=function(e){n.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(n.registeredEvents.push(e),t.contentDOM.addEventListener(e,(function(i){lr(t,i)&&n.runCustomHandlers(e,t,i)&&i.preventDefault()})))};for(var s in r.handlers)o(s)}}catch(a){i.e(a)}finally{i.f()}}},{key:"runCustomHandlers",value:function(t,e,n){var i,r=y(this.customHandlers);try{for(r.s();!(i=r.n()).done;){var o=i.value,s=o.handlers[t];if(s)try{if(s.call(o.plugin,n,e)||n.defaultPrevented)return!0}catch(a){Xn(e.state,a)}}}catch(u){r.e(u)}finally{r.f()}return!1}},{key:"runScrollHandlers",value:function(t,e){var n,i=y(this.customHandlers);try{for(i.s();!(n=i.n()).done;){var r=n.value,o=r.handlers.scroll;if(o)try{o.call(r.plugin,e,t)}catch(s){Xn(t.state,s)}}}catch(a){i.e(a)}finally{i.f()}}},{key:"keydown",value:function(t,e){var n,i=this;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!this.screenKeyEvent(t,e)||(!dn.android||!dn.chrome||e.synthetic||13!=e.keyCode&&8!=e.keyCode?!(!dn.ios||!(n=sr.find((function(t){return t.keyCode==e.keyCode})))||e.ctrlKey||e.altKey||e.metaKey||e.synthetic)&&(this.pendingIOSKey=n,setTimeout((function(){return i.flushIOSKey(t)}),250),!0):(t.observer.delayAndroidKey(e.key,e.keyCode),!0))}},{key:"flushIOSKey",value:function(t){var e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,Ue(t.contentDOM,e.key,e.keyCode))}},{key:"ignoreDuringComposition",value:function(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(dn.safari&&Date.now()-this.compositionEndedAt<500)&&(this.compositionEndedAt=0,!0))}},{key:"screenKeyEvent",value:function(t,e){var n=9==e.keyCode&&Date.now()<this.lastEscPress+2e3;return 27==e.keyCode?this.lastEscPress=Date.now():ar.indexOf(e.keyCode)<0&&(this.lastEscPress=0),n}},{key:"mustFlushObserver",value:function(t){return"keydown"==t.type&&229!=t.keyCode||"compositionend"==t.type&&!dn.ios}},{key:"startMouseSelection",value:function(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}},{key:"update",value:function(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}},{key:"destroy",value:function(){this.mouseSelection&&this.mouseSelection.destroy()}}]),t}(),sr=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ar=[16,17,18,20,91,92,224,225],ur=function(){function t(e,n,i,r){k(this,t),this.view=e,this.style=i,this.mustSelect=r,this.lastEvent=n;var o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Jt.allowMultipleSelections)&&function(t,e){var n=t.state.facet(zn);return n.length?n[0](e):dn.mac?e.metaKey:e.ctrlKey}(e,n),this.dragMove=function(t,e){var n=t.state.facet(qn);return n.length?n[0](e):dn.mac?!e.altKey:!e.ctrlKey}(e,n),this.dragging=!(!function(t,e){if(t.state.selection.main.empty)return!1;var n=Te(t.root);if(0==n.rangeCount)return!0;for(var i=n.getRangeAt(0).getClientRects(),r=0;r<i.length;r++){var o=i[r];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}(e,n)||1!=Sr(n))&&null,!1===this.dragging&&(n.preventDefault(),this.select(n))}return b(t,[{key:"move",value:function(t){if(0==t.buttons)return this.destroy();!1===this.dragging&&this.select(this.lastEvent=t)}},{key:"up",value:function(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}},{key:"destroy",value:function(){var t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}},{key:"select",value:function(t){var e=this.style.get(t,this.extend,this.multiple);!this.mustSelect&&e.eq(this.view.state.selection)&&e.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:e,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}},{key:"update",value:function(t){var e=this;t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((function(){return e.select(e.lastEvent)}),20)}}]),t}();function lr(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(var n,i=e.target;i!=t.contentDOM;i=i.parentNode)if(!i||11==i.nodeType||(n=Ye.get(i))&&n.ignoreEvent(e))return!1;return!0}var hr=Object.create(null),cr=dn.ie&&dn.ie_version<15||dn.ios&&dn.webkit_version<604;function fr(t,e){var n,i=t.state,r=1,o=i.toText(e),s=o.lines==i.selection.ranges.length,a=null!=Ar&&i.selection.ranges.every((function(t){return t.empty}))&&Ar==o.toString();if(a){var u=-1;n=i.changeByRange((function(t){var n=i.doc.lineAt(t.from);if(n.from==u)return{range:t};u=n.from;var a=i.toText((s?o.line(r++).text:e)+i.lineBreak);return{changes:{from:n.from,insert:a},range:it.cursor(t.from+a.length)}}))}else n=s?i.changeByRange((function(t){var e=o.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:it.cursor(t.from+e.length)}})):i.replaceSelection(o);t.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}hr.keydown=function(t,e){t.inputState.setSelectionOrigin("select")};var dr=0;function vr(t,e,n,i){if(1==i)return it.cursor(e,n);if(2==i)return function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=t.charCategorizer(e),r=t.doc.lineAt(e),o=e-r.from;if(0==r.length)return it.cursor(e);0==o?n=1:o==r.length&&(n=-1);var s=o,a=o;n<0?s=M(r.text,o,!1):a=M(r.text,o);for(var u=i(r.text.slice(s,a));s>0;){var l=M(r.text,s,!1);if(i(r.text.slice(l,s))!=u)break;s=l}for(;a<r.length;){var h=M(r.text,a);if(i(r.text.slice(a,h))!=u)break;a=h}return it.range(s+r.from,a+r.from)}(t.state,e,n);var r=In.find(t.docView,e),o=t.state.doc.lineAt(r?r.posAtEnd:e),s=r?r.posAtStart:o.from,a=r?r.posAtEnd:o.to;return a<t.state.doc.length&&a==o.to&&a++,it.range(s,a)}hr.touchstart=function(t,e){dr=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},hr.touchmove=function(t){t.inputState.setSelectionOrigin("select.pointer")},hr.mousedown=function(t,e){if(t.observer.flush(),!(dr>Date.now()-2e3&&1==Sr(e))){var n,i=null,r=y(t.state.facet(jn));try{for(r.s();!(n=r.n()).done;){if(i=(0,n.value)(t,e))break}}catch(s){r.e(s)}finally{r.f()}if(i||0!=e.button||(i=function(t,e){var n=yr(t,e),i=Sr(e),r=t.state.selection,o=n,s=e;return{update:function(t){t.docChanged&&(n&&(n.pos=t.changes.mapPos(n.pos)),r=r.map(t.changes),s=null)},get:function(e,a,u){var l;if(s&&e.clientX==s.clientX&&e.clientY==s.clientY?l=o:(l=o=yr(t,e),s=e),!l||!n)return r;var h=vr(t,l.pos,l.bias,i);if(n.pos!=l.pos&&!a){var c=vr(t,n.pos,n.bias,i),f=Math.min(c.from,h.from),d=Math.max(c.to,h.to);h=f<h.from?it.range(f,d):it.range(d,f)}return a?r.replaceRange(r.main.extend(h.from,h.to)):u?r.addRange(h):it.create([h])}}}(t,e)),i){var o=t.root.activeElement!=t.contentDOM;o&&t.observer.ignore((function(){return je(t.contentDOM)})),t.inputState.startMouseSelection(new ur(t,e,i,o))}}};var pr=function(t,e){return t>=e.top&&t<=e.bottom},mr=function(t,e,n){return pr(e,n)&&t>=n.left&&t<=n.right};function gr(t,e,n,i){var r=In.find(t.docView,e);if(!r)return 1;var o=e-r.posAtStart;if(0==o)return 1;if(o==r.length)return-1;var s=r.coordsAt(o,-1);if(s&&mr(n,i,s))return-1;var a=r.coordsAt(o,1);return a&&mr(n,i,a)?1:s&&pr(i,s)?-1:1}function yr(t,e){var n=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:n,bias:gr(t,n,e.clientX,e.clientY)}}var kr=dn.ie&&dn.ie_version<=11,wr=null,br=0,xr=0;function Sr(t){if(!kr)return t.detail;var e=wr,n=xr;return wr=t,xr=Date.now(),br=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(br+1)%3:1}function Cr(t,e,n,i){if(n){var r=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();var o=t.inputState.mouseSelection,s=i&&o&&o.dragging&&o.dragMove?{from:o.dragging.from,to:o.dragging.to}:null,a={from:r,insert:n},u=t.state.changes(s?[s,a]:a);t.focus(),t.dispatch({changes:u,selection:{anchor:u.mapPos(r,-1),head:u.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"})}}hr.dragstart=function(t,e){var n=t.state.selection.main,i=t.inputState.mouseSelection;i&&(i.dragging=n),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(n.from,n.to)),e.dataTransfer.effectAllowed="copyMove")},hr.drop=function(t,e){if(e.dataTransfer){if(t.state.readOnly)return e.preventDefault();var n=e.dataTransfer.files;n&&n.length?function(){e.preventDefault();for(var i=Array(n.length),r=0,o=function(){++r==n.length&&Cr(t,e,i.filter((function(t){return null!=t})).join(t.state.lineBreak),!1)},s=function(t){var e=new FileReader;e.onerror=o,e.onload=function(){/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(i[t]=e.result),o()},e.readAsText(n[t])},a=0;a<n.length;a++)s(a)}():Cr(t,e,e.dataTransfer.getData("Text"),!0)}},hr.paste=function(t,e){if(t.state.readOnly)return e.preventDefault();t.observer.flush();var n=cr?null:e.clipboardData;n?(fr(t,n.getData("text/plain")),e.preventDefault()):function(t){var e=t.dom.parentNode;if(e){var n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout((function(){t.focus(),n.remove(),fr(t,n.value)}),50)}}(t)};var Ar=null;function Mr(t,e){if(t.docView.compositionDeco.size){t.inputState.rapidCompositionStart=e;try{t.update([])}finally{t.inputState.rapidCompositionStart=!1}}}hr.copy=hr.cut=function(t,e){var n=function(t){var e,n=[],i=[],r=!1,o=y(t.selection.ranges);try{for(o.s();!(e=o.n()).done;){var s=e.value;s.empty||(n.push(t.sliceDoc(s.from,s.to)),i.push(s))}}catch(f){o.e(f)}finally{o.f()}if(!n.length){var a,u=-1,l=y(t.selection.ranges);try{for(l.s();!(a=l.n()).done;){var h=a.value.from,c=t.doc.lineAt(h);c.number>u&&(n.push(c.text),i.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),u=c.number}}catch(f){l.e(f)}finally{l.f()}r=!0}return{text:n.join(t.lineBreak),ranges:i,linewise:r}}(t.state),i=n.text,r=n.ranges,o=n.linewise;if(i||o){Ar=o?i:null;var s=cr?null:e.clipboardData;s?(e.preventDefault(),s.clearData(),s.setData("text/plain",i)):function(t,e){var n=t.dom.parentNode;if(n){var i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout((function(){i.remove(),t.focus()}),50)}}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"})}},hr.focus=hr.blur=function(t){setTimeout((function(){t.hasFocus!=t.inputState.notifiedFocused&&t.update([])}),10)},hr.beforeprint=function(t){t.viewState.printing=!0,t.requestMeasure(),setTimeout((function(){t.viewState.printing=!1,t.requestMeasure()}),2e3)},hr.compositionstart=hr.compositionupdate=function(t){null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0,t.docView.compositionDeco.size&&(t.observer.flush(),Mr(t,!0)))},hr.compositionend=function(t){t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionFirstChange=null,setTimeout((function(){t.inputState.composing<0&&Mr(t,!1)}),50)},hr.contextmenu=function(t){t.inputState.lastContextMenu=Date.now()},hr.beforeinput=function(t,e){var n,i;if(dn.chrome&&dn.android&&(i=sr.find((function(t){return t.inputType==e.inputType})))&&(t.observer.delayAndroidKey(i.key,i.keyCode),"Backspace"==i.key||"Delete"==i.key)){var r=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout((function(){var e;((null===(e=window.visualViewport)||void 0===e?void 0:e.height)||0)>r+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};var Or=["pre-wrap","normal","pre-line","break-spaces"],Dr=function(){function t(){k(this,t),this.doc=N.empty,this.lineWrapping=!1,this.direction=fi.LTR,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}return b(t,[{key:"heightForGap",value:function(t,e){var n=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(n+=Math.ceil((e-t-n*this.lineLength*.5)/this.lineLength)),this.lineHeight*n}},{key:"heightForLine",value:function(t){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}},{key:"setDoc",value:function(t){return this.doc=t,this}},{key:"mustRefreshForStyle",value:function(t,e){return Or.indexOf(t)>-1!=this.lineWrapping||this.direction!=e}},{key:"mustRefreshForHeights",value:function(t){for(var e=!1,n=0;n<t.length;n++){var i=t[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(e=!0,this.heightSamples[Math.floor(10*i)]=!0)}return e}},{key:"refresh",value:function(t,e,n,i,r,o){var s=Or.indexOf(t)>-1,a=Math.round(n)!=Math.round(this.lineHeight)||this.lineWrapping!=s||this.direction!=e;if(this.lineWrapping=s,this.direction=e,this.lineHeight=n,this.charWidth=i,this.lineLength=r,a){this.heightSamples={};for(var u=0;u<o.length;u++){var l=o[u];l<0?u++:this.heightSamples[Math.floor(10*l)]=!0}}return a}}]),t}(),Tr=function(){function t(e,n){k(this,t),this.from=e,this.heights=n,this.index=0}return b(t,[{key:"more",get:function(){return this.index<this.heights.length}}]),t}(),Er=function(){function t(e,n,i,r,o){k(this,t),this.from=e,this.length=n,this.top=i,this.height=r,this.type=o}return b(t,[{key:"to",get:function(){return this.from+this.length}},{key:"bottom",get:function(){return this.top+this.height}},{key:"join",value:function(e){var n=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(e.type)?e.type:[e]);return new t(this.from,this.length+e.length,this.top,this.height+e.height,n)}},{key:"moveY",value:function(e){return e?new t(this.from,this.length,this.top+e,this.height,Array.isArray(this.type)?this.type.map((function(t){return t.moveY(e)})):this.type):this}}]),t}(),Rr=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Rr||(Rr={})),Br=.001,Lr=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;k(this,t),this.length=e,this.height=n,this.flags=i}return b(t,[{key:"outdated",get:function(){return(2&this.flags)>0},set:function(t){this.flags=(t?2:0)|-3&this.flags}},{key:"setHeight",value:function(t,e){this.height!=e&&(Math.abs(this.height-e)>Br&&(t.heightChanged=!0),this.height=e)}},{key:"replace",value:function(e,n,i){return t.of(i)}},{key:"decomposeLeft",value:function(t,e){e.push(this)}},{key:"decomposeRight",value:function(t,e){e.push(this)}},{key:"applyChanges",value:function(t,e,n,i){for(var r=this,o=i.length-1;o>=0;o--){var s=i[o],a=s.fromA,u=s.toA,l=s.fromB,h=s.toB,c=r.lineAt(a,Rr.ByPosNoHeight,e,0,0),f=c.to>=u?c:r.lineAt(u,Rr.ByPosNoHeight,e,0,0);for(h+=f.to-u,u=f.to;o>0&&c.from<=i[o-1].toA;)a=i[o-1].fromA,l=i[o-1].fromB,o--,a<c.from&&(c=r.lineAt(a,Rr.ByPosNoHeight,e,0,0));l+=c.from-a,a=c.from;var d=Wr.build(n,t,l,h);r=r.replace(a,u,d)}return r.updateHeight(n,0)}}],[{key:"empty",value:function(){return new Ir(0,0)}},{key:"of",value:function(e){if(1==e.length)return e[0];for(var n=0,i=e.length,r=0,o=0;;)if(n==i)if(r>2*o){var s=e[n-1];s.break?e.splice(--n,1,s.left,null,s.right):e.splice(--n,1,s.left,s.right),i+=1+s.break,r-=s.size}else{if(!(o>2*r))break;var a=e[i];a.break?e.splice(i,1,a.left,null,a.right):e.splice(i,1,a.left,a.right),i+=2+a.break,o-=a.size}else if(r<o){var u=e[n++];u&&(r+=u.size)}else{var l=e[--i];l&&(o+=l.size)}var h=0;return null==e[n-1]?(h=1,n--):null==e[n]&&(h=1,i++),new Vr(t.of(e.slice(0,n)),h,t.of(e.slice(i)))}}]),t}();Lr.prototype.size=1;var Pr=function(t){v(n,t);var e=g(n);function n(t,i,r){var o;return k(this,n),(o=e.call(this,t,i)).type=r,o}return b(n,[{key:"blockAt",value:function(t,e,n,i){return new Er(i,this.length,n,this.height,this.type)}},{key:"lineAt",value:function(t,e,n,i,r){return this.blockAt(0,n,i,r)}},{key:"forEachLine",value:function(t,e,n,i,r,o){o(this.blockAt(0,n,i,r))}},{key:"updateHeight",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>3?arguments[3]:void 0;return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}},{key:"toString",value:function(){return"block(".concat(this.length,")")}}]),n}(Lr),Ir=function(t){v(n,t);var e=g(n);function n(t,i){var r;return k(this,n),(r=e.call(this,t,i,Dn.Text)).collapsed=0,r.widgetHeight=0,r}return b(n,[{key:"replace",value:function(t,e,i){var r=i[0];return 1==i.length&&(r instanceof n||r instanceof Nr&&4&r.flags)&&Math.abs(this.length-r.length)<10?(r instanceof Nr?r=new n(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Lr.of(i)}},{key:"updateHeight",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;return i&&i.from<=e&&i.more?this.setHeight(t,i.heights[i.index++]):(n||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))),this.outdated=!1,this}},{key:"toString",value:function(){return"line(".concat(this.length).concat(this.collapsed?-this.collapsed:"").concat(this.widgetHeight?":"+this.widgetHeight:"",")")}}]),n}(Pr),Nr=function(t){v(n,t);var e=g(n);function n(t){return k(this,n),e.call(this,t,0)}return b(n,[{key:"lines",value:function(t,e){var n=t.lineAt(e).number,i=t.lineAt(e+this.length).number;return{firstLine:n,lastLine:i,lineHeight:this.height/(i-n+1)}}},{key:"blockAt",value:function(t,e,n,i){var r=this.lines(e,i),o=r.firstLine,s=r.lastLine,a=r.lineHeight,u=Math.max(0,Math.min(s-o,Math.floor((t-n)/a))),l=e.line(o+u),h=l.from,c=l.length;return new Er(h,c,n+a*u,a,Dn.Text)}},{key:"lineAt",value:function(t,e,n,i,r){if(e==Rr.ByHeight)return this.blockAt(t,n,i,r);if(e==Rr.ByPosNoHeight){var o=n.lineAt(t),s=o.from,a=o.to;return new Er(s,a-s,0,0,Dn.Text)}var u=this.lines(n,r),l=u.firstLine,h=u.lineHeight,c=n.lineAt(t),f=c.from,d=c.length,v=c.number;return new Er(f,d,i+h*(v-l),h,Dn.Text)}},{key:"forEachLine",value:function(t,e,n,i,r,o){for(var s=this.lines(n,r),a=s.firstLine,u=s.lineHeight,l=Math.max(t,r),h=Math.min(r+this.length,e);l<=h;){var c=n.lineAt(l);l==t&&(i+=u*(c.number-a)),o(new Er(c.from,c.length,i,u,Dn.Text)),i+=u,l=c.to+1}}},{key:"replace",value:function(t,e,i){var r=this.length-e;if(r>0){var o=i[i.length-1];o instanceof n?i[i.length-1]=new n(o.length+r):i.push(null,new n(r-1))}if(t>0){var s=i[0];s instanceof n?i[0]=new n(t+s.length):i.unshift(new n(t-1),null)}return Lr.of(i)}},{key:"decomposeLeft",value:function(t,e){e.push(new n(t-1),null)}},{key:"decomposeRight",value:function(t,e){e.push(null,new n(this.length-t-1))}},{key:"updateHeight",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0,o=e+this.length;if(r&&r.from<=e+this.length&&r.more){var s=[],a=Math.max(e,r.from),u=-1,l=t.heightChanged;for(r.from>e&&s.push(new n(r.from-e-1).updateHeight(t,e));a<=o&&r.more;){var h=t.doc.lineAt(a).length;s.length&&s.push(null);var c=r.heights[r.index++];-1==u?u=c:Math.abs(c-u)>=Br&&(u=-2);var f=new Ir(h,c);f.outdated=!1,s.push(f),a+=h+1}a<=o&&s.push(null,new n(o-a).updateHeight(t,a));var d=Lr.of(s);return t.heightChanged=l||u<0||Math.abs(d.height-this.height)>=Br||Math.abs(u-this.lines(t.doc,e).lineHeight)>=Br,d}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}},{key:"toString",value:function(){return"gap(".concat(this.length,")")}}]),n}(Lr),Vr=function(t){v(n,t);var e=g(n);function n(t,i,r){var o;return k(this,n),(o=e.call(this,t.length+i+r.length,t.height+r.height,i|(t.outdated||r.outdated?2:0))).left=t,o.right=r,o.size=t.size+r.size,o}return b(n,[{key:"break",get:function(){return 1&this.flags}},{key:"blockAt",value:function(t,e,n,i){var r=n+this.left.height;return t<r?this.left.blockAt(t,e,n,i):this.right.blockAt(t,e,r,i+this.left.length+this.break)}},{key:"lineAt",value:function(t,e,n,i,r){var o=i+this.left.height,s=r+this.left.length+this.break,a=e==Rr.ByHeight?t<o:t<s,u=a?this.left.lineAt(t,e,n,i,r):this.right.lineAt(t,e,n,o,s);if(this.break||(a?u.to<s:u.from>s))return u;var l=e==Rr.ByPosNoHeight?Rr.ByPosNoHeight:Rr.ByPos;return a?u.join(this.right.lineAt(s,l,n,o,s)):this.left.lineAt(s,l,n,i,r).join(u)}},{key:"forEachLine",value:function(t,e,n,i,r,o){var s=i+this.left.height,a=r+this.left.length+this.break;if(this.break)t<a&&this.left.forEachLine(t,e,n,i,r,o),e>=a&&this.right.forEachLine(t,e,n,s,a,o);else{var u=this.lineAt(a,Rr.ByPos,n,i,r);t<u.from&&this.left.forEachLine(t,u.from-1,n,i,r,o),u.to>=t&&u.from<=e&&o(u),e>u.to&&this.right.forEachLine(u.to+1,e,n,s,a,o)}}},{key:"replace",value:function(t,e,n){var i=this.left.length+this.break;if(e<i)return this.balanced(this.left.replace(t,e,n),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-i,e-i,n));var r=[];t>0&&this.decomposeLeft(t,r);var o,s=r.length,a=y(n);try{for(a.s();!(o=a.n()).done;){var u=o.value;r.push(u)}}catch(h){a.e(h)}finally{a.f()}if(t>0&&Hr(r,s-1),e<this.length){var l=r.length;this.decomposeRight(e,r),Hr(r,l)}return Lr.of(r)}},{key:"decomposeLeft",value:function(t,e){var n=this.left.length;if(t<=n)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&t>=++n&&e.push(null),t>n&&this.right.decomposeLeft(t-n,e)}},{key:"decomposeRight",value:function(t,e){var n=this.left.length,i=n+this.break;if(t>=i)return this.right.decomposeRight(t-i,e);t<n&&this.left.decomposeRight(t,e),this.break&&t<i&&e.push(null),e.push(this.right)}},{key:"balanced",value:function(t,e){return t.size>2*e.size||e.size>2*t.size?Lr.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=t.height+e.height,this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}},{key:"updateHeight",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,r=this.left,o=this.right,s=e+r.length+this.break,a=null;return i&&i.from<=e+r.length&&i.more?a=r=r.updateHeight(t,e,n,i):r.updateHeight(t,e,n),i&&i.from<=s+o.length&&i.more?a=o=o.updateHeight(t,s,n,i):o.updateHeight(t,s,n),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}},{key:"toString",value:function(){return this.left+(this.break?" ":"-")+this.right}}]),n}(Lr);function Hr(t,e){var n,i;null==t[e]&&(n=t[e-1])instanceof Nr&&(i=t[e+1])instanceof Nr&&t.splice(e-1,3,new Nr(n.length+1+i.length))}var Wr=function(){function t(e,n){k(this,t),this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}return b(t,[{key:"isCovered",get:function(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}},{key:"span",value:function(t,e){if(this.lineStart>-1){var n=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Ir?i.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Ir(n-this.pos,-1)),this.writtenTo=n,e>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}},{key:"point",value:function(t,e,n){if(t<e||n.heightRelevant){var i=n.widget?n.widget.estimatedHeight:0;i<0&&(i=this.oracle.lineHeight);var r=e-t;n.block?this.addBlock(new Pr(r,i,n.type)):(r||i>=5)&&this.addLineDeco(i,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}},{key:"enterLine",value:function(){if(!(this.lineStart>-1)){var t=this.oracle.doc.lineAt(this.pos),e=t.from,n=t.to;this.lineStart=e,this.lineEnd=n,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ir(this.pos-e,-1)),this.writtenTo=this.pos}}},{key:"blankContent",value:function(t,e){var n=new Nr(e-t);return this.oracle.doc.lineAt(t).to==e&&(n.flags|=4),n}},{key:"ensureLine",value:function(){this.enterLine();var t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Ir)return t;var e=new Ir(0,-1);return this.nodes.push(e),e}},{key:"addBlock",value:function(t){this.enterLine(),t.type!=Dn.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=Dn.WidgetBefore&&(this.covering=t)}},{key:"addLineDeco",value:function(t,e){var n=this.ensureLine();n.length+=e,n.collapsed+=e,n.widgetHeight=Math.max(n.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}},{key:"finish",value:function(t){var e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Ir||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Ir(0,-1));var n,i=t,r=y(this.nodes);try{for(r.s();!(n=r.n()).done;){var o=n.value;o instanceof Ir&&o.updateHeight(this.oracle,i),i+=o?o.length:1}}catch(s){r.e(s)}finally{r.f()}return this.nodes}}],[{key:"build",value:function(e,n,i,r){var o=new t(i,e);return se.spans(n,i,r,o,0),o.finish(i)}}]),t}();function Fr(t,e,n){var i=new zr;return se.compare(t,e,n,i,0),i.changes}var zr=function(){function t(){k(this,t),this.changes=[]}return b(t,[{key:"compareRange",value:function(){}},{key:"comparePoint",value:function(t,e,n,i){(t<e||n&&n.heightRelevant||i&&i.heightRelevant)&&Pn(t,e,this.changes,5)}}]),t}();var qr=function(){function t(e,n,i){k(this,t),this.from=e,this.to=n,this.size=i}return b(t,[{key:"draw",value:function(t){return Tn.replace({widget:new jr(this.size,t)}).range(this.from,this.to)}}],[{key:"same",value:function(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++){var i=t[n],r=e[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}}]),t}(),jr=function(t){v(n,t);var e=g(n);function n(t,i){var r;return k(this,n),(r=e.call(this)).size=t,r.vertical=i,r}return b(n,[{key:"eq",value:function(t){return t.size==this.size&&t.vertical==this.vertical}},{key:"toDOM",value:function(){var t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}},{key:"estimatedHeight",get:function(){return this.vertical?this.size:-1}}]),n}(On),_r=function(){function t(e){k(this,t),this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.heightOracle=new Dr,this.scaler=$r,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.heightMap=Lr.empty().applyChanges(e.facet(ui),N.empty,this.heightOracle.setDoc(e.doc),[new hi(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Tn.set(this.lineGaps.map((function(t){return t.draw(!1)}))),this.computeVisibleRanges()}return b(t,[{key:"updateForViewport",value:function(){for(var t=this,e=[this.viewport],n=this.state.selection.main,i=function(i){var r=i?n.head:n.anchor;if(!e.some((function(t){var e=t.from,n=t.to;return r>=e&&r<=n}))){var o=t.lineBlockAt(r),s=o.from,a=o.to;e.push(new Ur(s,a))}},r=0;r<=1;r++)i(r);this.viewports=e.sort((function(t,e){return t.from-e.from})),this.scaler=this.heightMap.height<=7e6?$r:new Yr(this.heightOracle.doc,this.heightMap,this.viewports)}},{key:"updateViewportLines",value:function(){var t=this;this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,(function(e){t.viewportLines.push(1==t.scaler.scale?e:Xr(e,t.scaler))}))}},{key:"update",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.state;this.state=t.state;var i=this.state.facet(ui),r=t.changedRanges,o=hi.extendWithRanges(r,Fr(t.startState.facet(ui),i,t?t.changes:$.empty(this.state.doc.length))),s=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(i,n.doc,this.heightOracle.setDoc(this.state.doc),o),this.heightMap.height!=s&&(t.flags|=2);var a=o.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<a.from||e.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,e));var u=!t.changes.empty||2&t.flags||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),u&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}},{key:"measure",value:function(t){var e=t.contentDOM,n=window.getComputedStyle(e),i=this.heightOracle,r=n.whiteSpace,o="rtl"==n.direction?fi.RTL:fi.LTR,s=this.heightOracle.mustRefreshForStyle(r,o),a=s||this.mustMeasureContent||this.contentDOMHeight!=e.clientHeight,u=0,l=0;if(this.editorWidth!=t.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=t.scrollDOM.clientWidth,u|=8),a){this.mustMeasureContent=!1,this.contentDOMHeight=e.clientHeight;var h=parseInt(n.paddingTop)||0,c=parseInt(n.paddingBottom)||0;this.paddingTop==h&&this.paddingBottom==c||(u|=8,this.paddingTop=h,this.paddingBottom=c)}var f=this.printing?{top:-1e8,bottom:1e8,left:-1e8,right:1e8}:function(t,e){for(var n=t.getBoundingClientRect(),i=Math.max(0,n.left),r=Math.min(innerWidth,n.right),o=Math.max(0,n.top),s=Math.min(innerHeight,n.bottom),a=t.ownerDocument.body,u=t.parentNode;u&&u!=a;)if(1==u.nodeType){var l=u,h=window.getComputedStyle(l);if((l.scrollHeight>l.clientHeight||l.scrollWidth>l.clientWidth)&&"visible"!=h.overflow){var c=l.getBoundingClientRect();i=Math.max(i,c.left),r=Math.min(r,c.right),o=Math.max(o,c.top),s=Math.min(s,c.bottom)}u="absolute"==h.position||"fixed"==h.position?l.offsetParent:l.parentNode}else{if(11!=u.nodeType)break;u=u.host}return{left:i-n.left,right:Math.max(i,r)-n.left,top:o-(n.top+e),bottom:Math.max(o,s)-(n.top+e)}}(e,this.paddingTop),d=f.top-this.pixelViewport.top,v=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;var p=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(p!=this.inView&&(this.inView=p,p&&(a=!0)),!this.inView)return 0;var m=e.clientWidth;if(this.contentDOMWidth==m&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=m,this.editorHeight=t.scrollDOM.clientHeight,u|=8),a){var g=t.docView.measureVisibleLineHeights();if(i.mustRefreshForHeights(g)&&(s=!0),s||i.lineWrapping&&Math.abs(m-this.contentDOMWidth)>i.charWidth){var y=t.docView.measureTextSize(),k=y.lineHeight,w=y.charWidth;(s=i.refresh(r,o,k,w,m/w,g))&&(t.docView.minWidth=0,u|=8)}d>0&&v>0?l=Math.max(d,v):d<0&&v<0&&(l=Math.min(d,v)),i.heightChanged=!1,this.heightMap=this.heightMap.updateHeight(i,0,s,new Tr(this.viewport.from,g)),i.heightChanged&&(u|=2)}var b=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(this.viewport=this.getViewport(l,this.scrollTarget)),this.updateForViewport(),(2&u||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),u}},{key:"visibleTop",get:function(){return this.scaler.fromDOM(this.pixelViewport.top)}},{key:"visibleBottom",get:function(){return this.scaler.fromDOM(this.pixelViewport.bottom)}},{key:"getViewport",value:function(t,e){var n=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),i=this.heightMap,r=this.state.doc,o=this.visibleTop,s=this.visibleBottom,a=new Ur(i.lineAt(o-1e3*n,Rr.ByHeight,r,0,0).from,i.lineAt(s+1e3*(1-n),Rr.ByHeight,r,0,0).to);if(e){var u=e.range.head;if(u<a.from||u>a.to){var l,h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=i.lineAt(u,Rr.ByPos,r,0,0);l="center"==e.y?(c.top+c.bottom)/2-h/2:"start"==e.y||"nearest"==e.y&&u<a.from?c.top:c.bottom-h,a=new Ur(i.lineAt(l-500,Rr.ByHeight,r,0,0).from,i.lineAt(l+h+500,Rr.ByHeight,r,0,0).to)}}return a}},{key:"mapViewport",value:function(t,e){var n=e.mapPos(t.from,-1),i=e.mapPos(t.to,1);return new Ur(this.heightMap.lineAt(n,Rr.ByPos,this.state.doc,0,0).from,this.heightMap.lineAt(i,Rr.ByPos,this.state.doc,0,0).to)}},{key:"viewportIsAppropriate",value:function(t){var e=t.from,n=t.to,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.inView)return!0;var r=this.heightMap.lineAt(e,Rr.ByPos,this.state.doc,0,0),o=r.top,s=this.heightMap.lineAt(n,Rr.ByPos,this.state.doc,0,0),a=s.bottom,u=this.visibleTop,l=this.visibleBottom;return(0==e||o<=u-Math.max(10,Math.min(-i,250)))&&(n==this.state.doc.length||a>=l+Math.max(10,Math.min(i,250)))&&o>u-2e3&&a<l+2e3}},{key:"mapLineGaps",value:function(t,e){if(!t.length||e.empty)return t;var n,i=[],r=y(t);try{for(r.s();!(n=r.n()).done;){var o=n.value;e.touchesRange(o.from,o.to)||i.push(new qr(e.mapPos(o.from),e.mapPos(o.to),o.size))}}catch(s){r.e(s)}finally{r.f()}return i}},{key:"ensureLineGaps",value:function(t){var e=this,n=[];if(this.heightOracle.direction!=fi.LTR)return n;var i,r=y(this.viewportLines);try{var o=function(){var r=i.value;if(r.length<4e3)return"continue";var o=function(t,e,n){var i=[],r=t,o=0;se.spans(n.facet(ui),t,e,{span:function(){},point:function(t,e){t>r&&(i.push({from:r,to:t}),o+=t-r),r=e}},20),r<e&&(i.push({from:r,to:e}),o+=e-r);return{total:o,ranges:i}}(r.from,r.to,e.state);if(o.total<4e3)return"continue";var s=void 0,a=void 0;if(e.heightOracle.lineWrapping){var u=2e3/e.heightOracle.lineLength*e.heightOracle.lineHeight;s=Kr(o,(e.visibleTop-r.top-u)/r.height),a=Kr(o,(e.visibleBottom-r.top+u)/r.height)}else{var l=o.total*e.heightOracle.charWidth,h=2e3*e.heightOracle.charWidth;s=Kr(o,(e.pixelViewport.left-h)/l),a=Kr(o,(e.pixelViewport.right+h)/l)}var c=[];s>r.from&&c.push({from:r.from,to:s}),a<r.to&&c.push({from:a,to:r.to});var f=e.state.selection.main;f.from>=r.from&&f.from<=r.to&&Jr(c,f.from-10,f.from+10),!f.empty&&f.to>=r.from&&f.to<=r.to&&Jr(c,f.to-10,f.to+10);for(var d=function(){var i=p[v],s=i.from,a=i.to;a-s>1e3&&n.push(function(t,e){var n,i=y(t);try{for(i.s();!(n=i.n()).done;){var r=n.value;if(e(r))return r}}catch(o){i.e(o)}finally{i.f()}return}(t,(function(t){return t.from>=r.from&&t.to<=r.to&&Math.abs(t.from-s)<1e3&&Math.abs(t.to-a)<1e3}))||new qr(s,a,e.gapSize(r,s,a,o)))},v=0,p=c;v<p.length;v++)d()};for(r.s();!(i=r.n()).done;)o()}catch(s){r.e(s)}finally{r.f()}return n}},{key:"gapSize",value:function(t,e,n,i){var r=Gr(i,n)-Gr(i,e);return this.heightOracle.lineWrapping?t.height*r:i.total*this.heightOracle.charWidth*r}},{key:"updateLineGaps",value:function(t){var e=this;qr.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Tn.set(t.map((function(t){return t.draw(e.heightOracle.lineWrapping)}))))}},{key:"computeVisibleRanges",value:function(){var t=this.state.facet(ui);this.lineGaps.length&&(t=t.concat(this.lineGapDeco));var e=[];se.spans(t,this.viewport.from,this.viewport.to,{span:function(t,n){e.push({from:t,to:n})},point:function(){}},20);var n=e.length!=this.visibleRanges.length||this.visibleRanges.some((function(t,n){return t.from!=e[n].from||t.to!=e[n].to}));return this.visibleRanges=e,n?4:0}},{key:"lineBlockAt",value:function(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((function(e){return e.from<=t&&e.to>=t}))||Xr(this.heightMap.lineAt(t,Rr.ByPos,this.state.doc,0,0),this.scaler)}},{key:"lineBlockAtHeight",value:function(t){return Xr(this.heightMap.lineAt(this.scaler.fromDOM(t),Rr.ByHeight,this.state.doc,0,0),this.scaler)}},{key:"elementAtHeight",value:function(t){return Xr(this.heightMap.blockAt(this.scaler.fromDOM(t),this.state.doc,0,0),this.scaler)}},{key:"docHeight",get:function(){return this.scaler.toDOM(this.heightMap.height)}},{key:"contentHeight",get:function(){return this.docHeight+this.paddingTop+this.paddingBottom}}]),t}(),Ur=b((function t(e,n){k(this,t),this.from=e,this.to=n}));function Kr(t,e){var n=t.total,i=t.ranges;if(e<=0)return i[0].from;if(e>=1)return i[i.length-1].to;for(var r=Math.floor(n*e),o=0;;o++){var s=i[o],a=s.from,u=s.to-a;if(r<=u)return a+r;r-=u}}function Gr(t,e){var n,i=0,r=y(t.ranges);try{for(r.s();!(n=r.n()).done;){var o=n.value,s=o.from,a=o.to;if(e<=a){i+=e-s;break}i+=a-s}}catch(u){r.e(u)}finally{r.f()}return i/t.total}function Jr(t,e,n){for(var i=0;i<t.length;i++){var r=t[i];if(r.from<n&&r.to>e){var o=[];r.from<e&&o.push({from:r.from,to:e}),r.to>n&&o.push({from:n,to:r.to}),t.splice.apply(t,[i,1].concat(o)),i+=o.length-1}}}var $r={toDOM:function(t){return t},fromDOM:function(t){return t},scale:1},Yr=function(){function t(e,n,i){k(this,t);var r=0,o=0,s=0;this.viewports=i.map((function(t){var i=t.from,o=t.to,s=n.lineAt(i,Rr.ByPos,e,0,0).top,a=n.lineAt(o,Rr.ByPos,e,0,0).bottom;return r+=a-s,{from:i,to:o,top:s,bottom:a,domTop:0,domBottom:0}})),this.scale=(7e6-r)/(n.height-r);var a,u=y(this.viewports);try{for(u.s();!(a=u.n()).done;){var l=a.value;l.domTop=s+(l.top-o)*this.scale,s=l.domBottom=l.domTop+(l.bottom-l.top),o=l.bottom}}catch(h){u.e(h)}finally{u.f()}}return b(t,[{key:"toDOM",value:function(t){for(var e=0,n=0,i=0;;e++){var r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return i+(t-n)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);n=r.bottom,i=r.domBottom}}},{key:"fromDOM",value:function(t){for(var e=0,n=0,i=0;;e++){var r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return n+(t-i)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);n=r.bottom,i=r.domBottom}}}]),t}();function Xr(t,e){if(1==e.scale)return t;var n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new Er(t.from,t.length,n,i-n,Array.isArray(t.type)?t.type.map((function(t){return Xr(t,e)})):t.type)}var Qr=at.define({combine:function(t){return t.join(" ")}}),Zr=at.define({combine:function(t){return t.indexOf(!0)>-1}}),to=Zt.newName(),eo=Zt.newName(),no=Zt.newName(),io={"&light":"."+eo,"&dark":"."+no};function ro(t,e,n){return new Zt(e,{finish:function(e){return/&/.test(e)?e.replace(/&\w*/,(function(e){if("&"==e)return t;if(!n||!n[e])throw new RangeError("Unsupported selector: ".concat(e));return n[e]})):t+" "+e}})}var oo=ro("."+to,{"&.cm-editor":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},io),so={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ao=dn.ie&&dn.ie_version<=11,uo=function(){function t(e,n,i){var r=this;k(this,t),this.view=e,this.onChange=n,this.onScrollChanged=i,this.active=!1,this.selectionRange=new ze,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver((function(t){var n,i=y(t);try{for(i.s();!(n=i.n()).done;){var o=n.value;r.queue.push(o)}}catch(s){i.e(s)}finally{i.f()}(dn.ie&&dn.ie_version<=11||dn.ios&&e.composing)&&t.some((function(t){return"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length}))?r.flushSoon():r.flush()})),ao&&(this.onCharData=function(t){r.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),r.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),"function"==typeof ResizeObserver&&(this.resize=new ResizeObserver((function(){r.view.docView.lastUpdate<Date.now()-75&&r.resizeTimeout<0&&(r.resizeTimeout=setTimeout((function(){r.resizeTimeout=-1,r.view.requestMeasure()}),50))})),this.resize.observe(e.scrollDOM)),this.start(),this.onScroll=this.onScroll.bind(this),window.addEventListener("scroll",this.onScroll),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((function(t){r.parentCheck<0&&(r.parentCheck=setTimeout(r.listenForScroll.bind(r),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=r.intersecting&&(r.intersecting=!r.intersecting,r.intersecting!=r.view.inView&&r.onScrollChanged(document.createEvent("Event")))}),{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((function(t){t.length>0&&t[t.length-1].intersectionRatio>0&&r.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}return b(t,[{key:"onScroll",value:function(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}},{key:"updateGaps",value:function(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((function(e,n){return e!=t[n]})))){this.gapIntersection.disconnect();var e,n=y(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.gapIntersection.observe(i)}}catch(r){n.e(r)}finally{n.f()}this.gaps=t}}},{key:"onSelectionChange",value:function(t){if(this.readSelectionRange()&&!this.delayedAndroidKey){var e=this.view,n=this.selectionRange;if(e.state.facet(Qn)?e.root.activeElement==this.dom:Re(e.dom,n)){var i=n.anchorNode&&e.docView.nearest(n.anchorNode);i&&i.ignoreEvent(t)||((dn.ie&&dn.ie_version<=11||dn.android&&dn.chrome)&&!e.state.selection.main.empty&&n.focusNode&&Le(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1))}}}},{key:"readSelectionRange",value:function(){var t=this.view.root,e=Te(t),n=dn.safari&&11==t.nodeType&&function(){for(var t=document.activeElement;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}()==this.view.contentDOM&&function(t){var e=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",n,!0),document.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),!e)return null;var i=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,a=t.docView.domAtPos(t.state.selection.main.anchor);if(Le(a.node,a.offset,o,s)){var u=[o,s,i,r];i=u[0],r=u[1],o=u[2],s=u[3]}return{anchorNode:i,anchorOffset:r,focusNode:o,focusOffset:s}}(this.view)||e;return!this.selectionRange.eq(n)&&(this.selectionRange.setRange(n),this.selectionChanged=!0)}},{key:"setSelectionRange",value:function(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}},{key:"listenForScroll",value:function(){this.parentCheck=-1;for(var t=0,e=null,n=this.dom;n;)if(1==n.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==n?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(n),n=n.assignedSlot||n.parentNode;else{if(11!=n.nodeType)break;n=n.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){var i,r=y(this.scrollTargets);try{for(r.s();!(i=r.n()).done;){i.value.removeEventListener("scroll",this.onScroll)}}catch(a){r.e(a)}finally{r.f()}var o,s=y(this.scrollTargets=e);try{for(s.s();!(o=s.n()).done;){o.value.addEventListener("scroll",this.onScroll)}}catch(a){s.e(a)}finally{s.f()}}}},{key:"ignore",value:function(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}},{key:"start",value:function(){this.active||(this.observer.observe(this.dom,so),ao&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}},{key:"stop",value:function(){this.active&&(this.active=!1,this.observer.disconnect(),ao&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}},{key:"clear",value:function(){this.observer.takeRecords(),this.queue.length=0,this.selectionChanged=!1}},{key:"delayAndroidKey",value:function(t,e){var n=this;this.delayedAndroidKey||requestAnimationFrame((function(){var t=n.delayedAndroidKey;n.delayedAndroidKey=null;var e=n.view.state;Ue(n.view.contentDOM,t.key,t.keyCode)?n.processRecords():n.flush(),n.view.state==e&&n.view.update([])})),this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e})}},{key:"flushSoon",value:function(){var t=this;this.delayedFlush<0&&(this.delayedFlush=window.setTimeout((function(){t.delayedFlush=-1,t.flush()}),20))}},{key:"forceFlush",value:function(){this.delayedFlush>=0&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}},{key:"processRecords",value:function(){var t,e=this.queue,n=y(this.observer.takeRecords());try{for(n.s();!(t=n.n()).done;){var i=t.value;e.push(i)}}catch(c){n.e(c)}finally{n.f()}e.length&&(this.queue=[]);var r,o=-1,s=-1,a=!1,u=y(e);try{for(u.s();!(r=u.n()).done;){var l=r.value,h=this.readMutation(l);h&&(h.typeOver&&(a=!0),-1==o?(o=h.from,s=h.to):(o=Math.min(h.from,o),s=Math.max(h.to,s)))}}catch(c){u.e(c)}finally{u.f()}return{from:o,to:s,typeOver:a}}},{key:"flush",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!(this.delayedFlush>=0||this.delayedAndroidKey)){t&&this.readSelectionRange();var e=this.processRecords(),n=e.from,i=e.to,r=e.typeOver,o=this.selectionChanged&&Re(this.dom,this.selectionRange);if(!(n<0)||o){this.selectionChanged=!1;var s=this.view.state;this.onChange(n,i,r),this.view.state==s&&this.view.update([])}}}},{key:"readMutation",value:function(t){var e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.dirty|=4),"childList"==t.type){var n=lo(e,t.previousSibling||t.target.previousSibling,-1),i=lo(e,t.nextSibling||t.target.nextSibling,1);return{from:n?e.posAfter(n):e.posAtStart,to:i?e.posBefore(i):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}},{key:"destroy",value:function(){var t,e,n;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(n=this.resize)||void 0===n||n.disconnect();var i,r=y(this.scrollTargets);try{for(r.s();!(i=r.n()).done;){i.value.removeEventListener("scroll",this.onScroll)}}catch(o){r.e(o)}finally{r.f()}window.removeEventListener("scroll",this.onScroll),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}}]),t}();function lo(t,e,n){for(;e;){var i=Ye.get(e);if(i&&i.parent==t)return i;var r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function ho(t,e,n,i){var r,o,s=t.state.selection.main;if(e>-1){var a=t.docView.domBoundsAround(e,n,0);if(!a||t.state.readOnly)return;var u=a.from,l=a.to,h=t.docView.impreciseHead||t.docView.impreciseAnchor?[]:function(t){var e=[];if(t.root.activeElement!=t.contentDOM)return e;var n=t.observer.selectionRange,i=n.anchorNode,r=n.anchorOffset,o=n.focusNode,s=n.focusOffset;i&&(e.push(new Ni(i,r)),o==i&&s==r||e.push(new Ni(o,s)));return e}(t),c=new Pi(h,t.state);c.readRange(a.startDOM,a.endDOM);var f=s.from,d=null;(8===t.inputState.lastKeyCode&&t.inputState.lastKeyTime>Date.now()-100||dn.android&&c.text.length<l-u)&&(f=s.to,d="end");var v=function(t,e,n,i){var r=Math.min(t.length,e.length),o=0;for(;o<r&&t.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==r&&t.length==e.length)return null;var s=t.length,a=e.length;for(;s>0&&a>0&&t.charCodeAt(s-1)==e.charCodeAt(a-1);)s--,a--;if("end"==i){n-=s+Math.max(0,o-Math.min(s,a))-o}if(s<o&&t.length<e.length){a=(o-=n<=o&&n>=s?o-n:0)+(a-s),s=o}else if(a<o){s=(o-=n<=o&&n>=a?o-n:0)+(s-a),a=o}return{from:o,toA:s,toB:a}}(t.state.doc.sliceString(u,l,Li),c.text,f-u,d);v&&function(){var e=v;for(dn.chrome&&13==t.inputState.lastKeyCode&&v.toB==v.from+2&&"\uffff\uffff"==c.text.slice(v.from,v.toB)&&v.toB--;v.from<v.toB&&"\u200b"==c.text[v.from];)v={from:v.from+1,toA:v.toA,toB:v.toB},h.forEach((function(t){return t.pos-=t.pos>e.from?1:0}));for(;v.toB>v.from&&"\u200b"==c.text[v.toB-1];)v={from:v.from,toA:v.toA,toB:v.toB-1},h.forEach((function(t){return t.pos-=t.pos>e.toB?1:0}));r={from:u+v.from,to:u+v.toA,insert:N.of(c.text.slice(v.from,v.toB).split(Li))}}(),o=function(t,e){if(0==t.length)return null;var n=t[0].pos,i=2==t.length?t[1].pos:n;return n>-1&&i>-1?it.single(n+e,i+e):null}(h,u)}else if(t.hasFocus||!t.state.facet(Qn)){var p=t.observer.selectionRange,m=t.docView,g=m.impreciseHead,y=m.impreciseAnchor,k=g&&g.node==p.focusNode&&g.offset==p.focusOffset||!Ee(t.contentDOM,p.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(p.focusNode,p.focusOffset),w=y&&y.node==p.anchorNode&&y.offset==p.anchorOffset||!Ee(t.contentDOM,p.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(p.anchorNode,p.anchorOffset);k==s.head&&w==s.anchor||(o=it.single(w,k))}if(r||o)if(!r&&i&&!s.empty&&o&&o.main.empty?r={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:r&&r.from>=s.from&&r.to<=s.to&&(r.from!=s.from||r.to!=s.to)&&s.to-s.from-(r.to-r.from)<=4&&(r={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,r.from).append(r.insert).append(t.state.doc.slice(r.to,s.to))}),r){var b=t.state;if(dn.ios&&t.inputState.flushIOSKey(t))return;if(dn.android&&(r.from==s.from&&r.to==s.to&&1==r.insert.length&&2==r.insert.lines&&Ue(t.contentDOM,"Enter",13)||r.from==s.from-1&&r.to==s.to&&0==r.insert.length&&Ue(t.contentDOM,"Backspace",8)||r.from==s.from&&r.to==s.to+1&&0==r.insert.length&&Ue(t.contentDOM,"Delete",46)))return;var x,S=r.insert.toString();if(t.state.facet(Kn).some((function(e){return e(t,r.from,r.to,S)})))return;if(t.inputState.composing>=0&&t.inputState.composing++,r.from>=s.from&&r.to<=s.to&&r.to-r.from>=(s.to-s.from)/3&&(!o||o.main.empty&&o.main.from==r.from+r.insert.length)&&t.inputState.composing<0){var C=s.from<r.from?b.sliceDoc(s.from,r.from):"",A=s.to>r.to?b.sliceDoc(r.to,s.to):"";x=b.replaceSelection(t.state.toText(C+r.insert.sliceString(0,void 0,t.state.lineBreak)+A))}else{var M=b.changes(r),O=o&&!b.selection.main.eq(o.main)&&o.main.to<=M.newLength?o.main:void 0;if(b.selection.ranges.length>1&&t.inputState.composing>=0&&r.to<=s.to&&r.to>=s.to-10){var D=t.state.sliceDoc(r.from,r.to),T=Fi(t)||t.state.doc.lineAt(s.head),E=s.to-r.to,R=s.to-s.from;x=b.changeByRange((function(e){if(e.from==s.from&&e.to==s.to)return{changes:M,range:O||e.map(M)};var n=e.to-E,i=n-D.length;if(e.to-e.from!=R||t.state.sliceDoc(i,n)!=D||T&&e.to>=T.from&&e.from<=T.to)return{range:e};var o=b.changes({from:i,to:n,insert:r.insert}),a=e.to-s.to;return{changes:o,range:O?it.range(Math.max(0,O.anchor+a),Math.max(0,O.head+a)):e.map(o)}}))}else x={changes:M,selection:O&&b.selection.replaceRange(O)}}var B="input.type";t.composing&&(B+=".compose",t.inputState.compositionFirstChange&&(B+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(x,{scrollIntoView:!0,userEvent:B})}else if(o&&!o.main.eq(s)){var L=!1,P="select";t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(L=!0),P=t.inputState.lastSelectionOrigin),t.dispatch({selection:o,scrollIntoView:L,userEvent:P})}}var co=function(){function t(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};k(this,t),this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=n.dispatch||function(t){return e.update([t])},this.dispatch=this.dispatch.bind(this),this.root=n.root||Ke(n.parent)||document,this.viewState=new _r(n.state||Jt.create()),this.plugins=this.state.facet(ni).map((function(t){return new oi(t)}));var i,r=y(this.plugins);try{for(r.s();!(i=r.n()).done;){var o=i.value;o.update(this)}}catch(s){r.e(s)}finally{r.f()}this.observer=new uo(this,(function(t,n,i){ho(e,t,n,i)}),(function(t){e.inputState.runScrollHandlers(e,t),e.observer.intersecting&&e.measure()})),this.inputState=new or(this),this.docView=new Vi(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,mo(),this.requestMeasure(),n.parent&&n.parent.appendChild(this.dom)}return b(t,[{key:"state",get:function(){return this.viewState.state}},{key:"viewport",get:function(){return this.viewState.viewport}},{key:"visibleRanges",get:function(){return this.viewState.visibleRanges}},{key:"inView",get:function(){return this.viewState.inView}},{key:"composing",get:function(){return this.inputState.composing>0}},{key:"dispatch",value:function(){var t;this._dispatch(1==arguments.length&&(arguments.length<=0?void 0:arguments[0])instanceof Vt?arguments.length<=0?void 0:arguments[0]:(t=this.state).update.apply(t,arguments))}},{key:"update",value:function(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");var e,n,i=!1,r=this.state,o=y(t);try{for(o.s();!(n=o.n()).done;){var s=n.value;if(s.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=s.state}}catch(g){o.e(g)}finally{o.f()}if(this.destroyed)this.viewState.state=r;else{if(r.facet(Jt.phrases)!=this.state.facet(Jt.phrases))return this.setState(r);e=new ci(this,r,t);var a=this.viewState.scrollTarget;try{this.updateState=2;var u,l=y(t);try{for(l.s();!(u=l.n()).done;){var h=u.value;if(a&&(a=a.map(h.changes)),h.scrollIntoView){var c=h.state.selection.main;a=new $n(c.empty?c:it.cursor(c.head,c.head>c.anchor?-1:1))}var f,d=y(h.effects);try{for(d.s();!(f=d.n()).done;){var v=f.value;v.is(Gn)?a=new $n(v.value):v.is(Jn)?a=new $n(v.value,"center"):v.is(Yn)&&(a=v.value)}}catch(g){d.e(g)}finally{d.f()}}}catch(g){l.e(g)}finally{l.f()}this.viewState.update(e,a),this.bidiCache=ko.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(li)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((function(t){return t.isUserEvent("select.pointer")})))}finally{this.updateState=0}if((i||a||this.viewState.mustEnforceCursorAssoc)&&this.requestMeasure(),!e.empty){var p,m=y(this.state.facet(Un));try{for(m.s();!(p=m.n()).done;){(0,p.value)(e)}}catch(g){m.e(g)}finally{m.f()}}}}},{key:"setState",value:function(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)this.viewState.state=t;else{this.updateState=2;var e=this.hasFocus;try{var n,i=y(this.plugins);try{for(i.s();!(n=i.n()).done;){n.value.destroy(this)}}catch(s){i.e(s)}finally{i.f()}this.viewState=new _r(t),this.plugins=t.facet(ni).map((function(t){return new oi(t)})),this.pluginMap.clear();var r,o=y(this.plugins);try{for(o.s();!(r=o.n()).done;){r.value.update(this)}}catch(s){o.e(s)}finally{o.f()}this.docView=new Vi(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}}},{key:"updatePlugins",value:function(t){var e=t.startState.facet(ni),n=t.state.facet(ni);if(e!=n){var i,r=[],o=y(n);try{for(o.s();!(i=o.n()).done;){var s=i.value,a=e.indexOf(s);if(a<0)r.push(new oi(s));else{var u=this.plugins[a];u.mustUpdate=t,r.push(u)}}}catch(p){o.e(p)}finally{o.f()}var l,h=y(this.plugins);try{for(h.s();!(l=h.n()).done;){var c=l.value;c.mustUpdate!=t&&c.destroy(this)}}catch(p){h.e(p)}finally{h.f()}this.plugins=r,this.pluginMap.clear(),this.inputState.ensureHandlers(this)}else{var f,d=y(this.plugins);try{for(d.s();!(f=d.n()).done;){f.value.mustUpdate=t}}catch(p){d.e(p)}finally{d.f()}}for(var v=0;v<this.plugins.length;v++)this.plugins[v].update(this)}},{key:"measure",value:function(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.destroyed){this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.flush();var n=null;try{for(var i=0;;i++){this.updateState=1;var r=this.viewport,o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(i>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}var s=[];if(!(4&o)){var a=[s,this.measureRequests];this.measureRequests=a[0],s=a[1]}var u=s.map((function(e){try{return e.read(t)}catch(n){return Xn(t.state,n),yo}})),l=new ci(this,this.state),h=!1,c=!1;l.flags|=o,n?n.flags|=o:n=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),h=this.docView.update(l));for(var f=0;f<s.length;f++)if(u[f]!=yo)try{var d=s[f];d.write&&d.write(u[f],this)}catch(g){Xn(this.state,g)}if(this.viewState.scrollTarget&&(this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,c=!0),h&&this.docView.updateSelection(!0),this.viewport.from==r.from&&this.viewport.to==r.to&&!c&&0==this.measureRequests.length)break}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty){var v,p=y(this.state.facet(Un));try{for(p.s();!(v=p.n()).done;){var m=v.value;m(n)}}catch(k){p.e(k)}finally{p.f()}}}}},{key:"themeClasses",get:function(){return to+" "+(this.state.facet(Zr)?no:eo)+" "+this.state.facet(Qr)}},{key:"updateAttrs",value:function(){var t=this,e=wo(this,si,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Qn)?"true":"false",class:"cm-content",style:"".concat(dn.tabSize,": ").concat(this.state.tabSize),role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),wo(this,ai,n),this.observer.ignore((function(){Mn(t.contentDOM,t.contentAttrs,n),Mn(t.dom,t.editorAttrs,e)})),this.editorAttrs=e,this.contentAttrs=n}},{key:"showAnnouncements",value:function(e){var n,i=!0,r=y(e);try{for(r.s();!(n=r.n()).done;){var o,s=y(n.value.effects);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(a.is(t.announce))i&&(this.announceDOM.textContent=""),i=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=a.value}}catch(u){s.e(u)}finally{s.f()}}}catch(u){r.e(u)}finally{r.f()}}},{key:"mountStyles",value:function(){this.styleModules=this.state.facet(li),Zt.mount(this.root,this.styleModules.concat(oo).reverse())}},{key:"readMeasured",value:function(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}},{key:"requestMeasure",value:function(t){var e=this;if(this.measureScheduled<0&&(this.measureScheduled=requestAnimationFrame((function(){return e.measure()}))),t){if(null!=t.key)for(var n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key)return void(this.measureRequests[n]=t);this.measureRequests.push(t)}}},{key:"pluginField",value:function(t){var e,n=[],i=y(this.plugins);try{for(i.s();!(e=i.n()).done;){e.value.update(this).takeField(t,n)}}catch(r){i.e(r)}finally{i.f()}return n}},{key:"plugin",value:function(t){var e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((function(e){return e.spec==t}))||null),e&&e.update(this).value}},{key:"documentTop",get:function(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}},{key:"documentPadding",get:function(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}},{key:"blockAtHeight",value:function(t,e){var n=vo(e,this);return this.elementAtHeight(t-n).moveY(n)}},{key:"elementAtHeight",value:function(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}},{key:"visualLineAtHeight",value:function(t,e){var n=vo(e,this);return this.lineBlockAtHeight(t-n).moveY(n)}},{key:"lineBlockAtHeight",value:function(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}},{key:"viewportLines",value:function(t,e){var n,i=vo(e,this),r=y(this.viewportLineBlocks);try{for(r.s();!(n=r.n()).done;){t(n.value.moveY(i))}}catch(o){r.e(o)}finally{r.f()}}},{key:"viewportLineBlocks",get:function(){return this.viewState.viewportLines}},{key:"visualLineAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.lineBlockAt(t).moveY(e+this.viewState.paddingTop)}},{key:"lineBlockAt",value:function(t){return this.viewState.lineBlockAt(t)}},{key:"contentHeight",get:function(){return this.viewState.contentHeight}},{key:"moveByChar",value:function(t,e,n){return rr(this,t,ir(this,t,e,n))}},{key:"moveByGroup",value:function(t,e){var n=this;return rr(this,t,ir(this,t,e,(function(e){return function(t,e,n){var i=t.state.charCategorizer(e),r=i(n);return function(t){var e=i(t);return r==Ut.Space&&(r=e),r==e}}(n,t.head,e)})))}},{key:"moveToLineBoundary",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return nr(this,t,e,n)}},{key:"moveVertically",value:function(t,e,n){return rr(this,t,function(t,e,n,i){var r=e.head,o=n?1:-1;if(r==(n?t.state.doc.length:0))return it.cursor(r,e.assoc);var s,a=e.goalColumn,u=t.contentDOM.getBoundingClientRect(),l=t.coordsAtPos(r),h=t.documentTop;if(l)null==a&&(a=l.left-u.left),s=o<0?l.top:l.bottom;else{var c=t.viewState.lineBlockAt(r-h);null==a&&(a=Math.min(u.right-u.left,t.defaultCharacterWidth*(r-c.from))),s=(o<0?c.top:c.bottom)+h}for(var f=u.left+a,d=null!==i&&void 0!==i?i:t.defaultLineHeight>>1,v=0;;v+=10){var p=s+(d+v)*o,m=Zi(t,{x:f,y:p},!1,o);if(p<u.top||p>u.bottom||(o<0?m<r:m>r))return it.cursor(m,e.assoc,void 0,a)}}(this,t,e,n))}},{key:"scrollPosIntoView",value:function(t){this.dispatch({effects:Gn.of(it.cursor(t))})}},{key:"domAtPos",value:function(t){return this.docView.domAtPos(t)}},{key:"posAtDOM",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.posFromDOM(t,e)}},{key:"posAtCoords",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.readMeasured(),Zi(this,t,e)}},{key:"coordsAtPos",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.readMeasured();var n=this.docView.coordsAt(t,e);if(!n||n.left==n.right)return n;var i=this.state.doc.lineAt(t),r=this.bidiSpans(i),o=r[Oi.find(r,t-i.from,-1,e)];return He(n,o.dir==fi.LTR==e>0)}},{key:"defaultCharacterWidth",get:function(){return this.viewState.heightOracle.charWidth}},{key:"defaultLineHeight",get:function(){return this.viewState.heightOracle.lineHeight}},{key:"textDirection",get:function(){return this.viewState.heightOracle.direction}},{key:"lineWrapping",get:function(){return this.viewState.heightOracle.lineWrapping}},{key:"bidiSpans",value:function(t){if(t.length>fo)return Ei(t.length);var e,n=this.textDirection,i=y(this.bidiCache);try{for(i.s();!(e=i.n()).done;){var r=e.value;if(r.from==t.from&&r.dir==n)return r.order}}catch(s){i.e(s)}finally{i.f()}var o=Ti(t.text,this.textDirection);return this.bidiCache.push(new ko(t.from,t.to,n,o)),o}},{key:"hasFocus",get:function(){var t;return(document.hasFocus()||dn.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}},{key:"focus",value:function(){var t=this;this.observer.ignore((function(){je(t.contentDOM),t.docView.updateSelection()}))}},{key:"destroy",value:function(){var t,e=y(this.plugins);try{for(e.s();!(t=e.n()).done;){t.value.destroy(this)}}catch(n){e.e(n)}finally{e.f()}this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}}],[{key:"scrollIntoView",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Yn.of(new $n("number"==typeof t?it.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}},{key:"domEventHandlers",value:function(t){return ii.define((function(){return{}}),{eventHandlers:t})}},{key:"theme",value:function(t,e){var n=Zt.newName(),i=[Qr.of(n),li.of(ro(".".concat(n),t))];return e&&e.dark&&i.push(Zr.of(!0)),i}},{key:"baseTheme",value:function(t){return yt.lowest(li.of(ro("."+to,t,io)))}}]),t}();co.scrollTo=Gn,co.centerOn=Jn,co.styleModule=li,co.inputHandler=Kn,co.exceptionSink=_n,co.updateListener=Un,co.editable=Qn,co.mouseSelectionStyle=jn,co.dragMovesSelection=qn,co.clickAddsSelectionRange=zn,co.decorations=ui,co.darkTheme=Zr,co.contentAttributes=ai,co.editorAttributes=si,co.lineWrapping=co.contentAttributes.of({class:"cm-lineWrapping"}),co.announce=Nt.define();var fo=4096;function vo(t,e){return(null==t?e.contentDOM.getBoundingClientRect().top:t)+e.viewState.paddingTop}var po=-1;function mo(){window.addEventListener("resize",(function(){-1==po&&(po=setTimeout(go,50))}))}function go(){po=-1;for(var t=document.querySelectorAll(".cm-content"),e=0;e<t.length;e++){var n=Ye.get(t[e]);n&&n.editorView.requestMeasure()}}var yo={},ko=function(){function t(e,n,i,r){k(this,t),this.from=e,this.to=n,this.dir=i,this.order=r}return b(t,null,[{key:"update",value:function(e,n){if(n.empty)return e;for(var i=[],r=e.length?e[e.length-1].dir:fi.LTR,o=Math.max(0,e.length-10);o<e.length;o++){var s=e[o];s.dir!=r||n.touchesRange(s.from,s.to)||i.push(new t(n.mapPos(s.from,1),n.mapPos(s.to,-1),s.dir,s.order))}return i}}]),t}();function wo(t,e,n){for(var i=t.state.facet(e),r=i.length-1;r>=0;r--){var o=i[r],s="function"==typeof o?o(t):o;s&&Cn(s,n)}return n}var bo=dn.mac?"mac":dn.windows?"win":dn.linux?"linux":"key";function xo(t,e){var n,i,r,o,s=t.split(/-(?!$)/),a=s[s.length-1];"Space"==a&&(a=" ");for(var u=0;u<s.length-1;++u){var l=s[u];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))r=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);"mac"==e?o=!0:i=!0}}return n&&(a="Alt-"+a),i&&(a="Ctrl-"+a),o&&(a="Meta-"+a),r&&(a="Shift-"+a),a}function So(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==n&&e.shiftKey&&(t="Shift-"+t),t}var Co=co.domEventHandlers({keydown:function(t,e){return Ro(Oo(e.state),t,e,"editor")}}),Ao=at.define({enables:Co}),Mo=new WeakMap;function Oo(t){var e=t.facet(Ao),n=Mo.get(e);return n||Mo.set(e,n=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:bo,i=Object.create(null),r=Object.create(null),o=function(t,e){var n=r[t];if(null==n)r[t]=e;else if(n!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},s=function(t,e,r,s){for(var a=i[t]||(i[t]=Object.create(null)),u=e.split(/ (?!$)/).map((function(t){return xo(t,n)})),l=function(e){var n=u.slice(0,e).join(" ");o(n,!0),a[n]||(a[n]={preventDefault:!0,commands:[function(e){var i=To={view:e,prefix:n,scope:t};return setTimeout((function(){To==i&&(To=null)}),Eo),!0}]})},h=1;h<u.length;h++)l(h);var c=u.join(" ");o(c,!1);var f=a[c]||(a[c]={preventDefault:!1,commands:[]});f.commands.push(r),s&&(f.preventDefault=!0)},a=y(t);try{for(a.s();!(e=a.n()).done;){var u=e.value,l=u[n]||u.key;if(l){var h,c=y(u.scope?u.scope.split(" "):["editor"]);try{for(c.s();!(h=c.n()).done;){var f=h.value;s(f,l,u.run,u.preventDefault),u.shift&&s(f,"Shift-"+l,u.shift,u.preventDefault)}}catch(d){c.e(d)}finally{c.f()}}}}catch(d){a.e(d)}finally{a.f()}return i}(e.reduce((function(t,e){return t.concat(e)}),[]))),n}function Do(t,e,n){return Ro(Oo(t.state),e,t,n)}var To=null,Eo=4e3;function Ro(t,e,n,i){var r=function(t){var e=!(Me&&(t.ctrlKey||t.altKey||t.metaKey)||(xe||Ae)&&t.shiftKey&&t.key&&1==t.key.length)&&t.key||(t.shiftKey?we:ke)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),o=1==r.length&&" "!=r,s="",a=!1;To&&To.view==n&&To.scope==i&&(s=To.prefix+" ",(a=ar.indexOf(e.keyCode)<0)&&(To=null));var u,l=function(t){if(t){var e,i=y(t.commands);try{for(i.s();!(e=i.n()).done;){if((0,e.value)(n))return!0}}catch(r){i.e(r)}finally{i.f()}t.preventDefault&&(a=!0)}return!1},h=t[i];if(h){if(l(h[s+So(r,e,!o)]))return!0;if(o&&(e.shiftKey||e.altKey||e.metaKey)&&(u=ke[e.keyCode])&&u!=r){if(l(h[s+So(u,e,!0)]))return!0}else if(o&&e.shiftKey&&l(h[s+So(r,e,!0)]))return!0}return a}var Bo=!dn.ios,Lo=at.define({combine:function(t){return $t(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:function(t,e){return Math.min(t,e)},drawRangeCursor:function(t,e){return t||e}})}});function Po(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Lo.of(t),No,Ho]}var Io=function(){function t(e,n,i,r,o){k(this,t),this.left=e,this.top=n,this.width=i,this.height=r,this.className=o}return b(t,[{key:"draw",value:function(){var t=document.createElement("div");return t.className=this.className,this.adjust(t),t}},{key:"adjust",value:function(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width>=0&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}},{key:"eq",value:function(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}}]),t}(),No=ii.fromClass(function(){function t(e){k(this,t),this.view=e,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=e.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=e.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),e.requestMeasure(this.measureReq),this.setBlinkRate()}return b(t,[{key:"setBlinkRate",value:function(){this.cursorLayer.style.animationDuration=this.view.state.facet(Lo).cursorBlinkRate+"ms"}},{key:"update",value:function(t){var e=t.startState.facet(Lo)!=t.state.facet(Lo);(e||t.selectionSet||t.geometryChanged||t.viewportChanged)&&this.view.requestMeasure(this.measureReq),t.transactions.some((function(t){return t.scrollIntoView}))&&(this.cursorLayer.style.animationName="cm-blink"==this.cursorLayer.style.animationName?"cm-blink2":"cm-blink"),e&&this.setBlinkRate()}},{key:"readPos",value:function(){var t,e=this,n=this.view.state,i=n.facet(Lo),r=n.selection.ranges.map((function(t){return t.empty?[]:function(t,e){if(e.to<=t.viewport.from||e.from>=t.viewport.to)return[];var n=Math.max(e.from,t.viewport.from),i=Math.min(e.to,t.viewport.to),r=t.textDirection==fi.LTR,o=t.contentDOM,s=o.getBoundingClientRect(),a=Wo(t),u=window.getComputedStyle(o.firstChild),l=s.left+parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)),h=s.right-parseInt(u.paddingRight),c=zo(t,n),f=zo(t,i),d=c.type==Dn.Text?c:null,v=f.type==Dn.Text?f:null;t.lineWrapping&&(d&&(d=Fo(t,n,d)),v&&(v=Fo(t,i,v)));if(d&&v&&d.from==v.from)return w(b(e.from,e.to,d));var p=d?b(e.from,null,d):x(c,!1),m=v?b(null,e.to,v):x(f,!0),g=[];return(d||c).to<(v||f).from-1?g.push(k(l,p.bottom,h,m.top)):p.bottom<m.top&&t.elementAtHeight((p.bottom+m.top)/2).type==Dn.Text&&(p.bottom=m.top=(p.bottom+m.top)/2),w(p).concat(g).concat(w(m));function k(t,e,n,i){return new Io(t-a.left,e-a.top-.01,n-t,i-e+.01,"cm-selectionBackground")}function w(t){for(var e=t.top,n=t.bottom,i=t.horizontal,r=[],o=0;o<i.length;o+=2)r.push(k(i[o],e,i[o+1],n));return r}function b(e,n,i){var o=1e9,s=-1e9,a=[];function u(e,n,u,c,f){var d=t.coordsAtPos(e,e==i.to?-2:2),v=t.coordsAtPos(u,u==i.from?2:-2);o=Math.min(d.top,v.top,o),s=Math.max(d.bottom,v.bottom,s),f==fi.LTR?a.push(r&&n?l:d.left,r&&c?h:v.right):a.push(!r&&c?l:v.left,!r&&n?h:d.right)}var c,f=null!==e&&void 0!==e?e:i.from,d=null!==n&&void 0!==n?n:i.to,v=y(t.visibleRanges);try{for(v.s();!(c=v.n()).done;){var p=c.value;if(p.to>f&&p.from<d)for(var m=Math.max(p.from,f),g=Math.min(p.to,d);;){var k,w=t.state.doc.lineAt(m),b=y(t.bidiSpans(w));try{for(b.s();!(k=b.n()).done;){var x=k.value,S=x.from+w.from,C=x.to+w.from;if(S>=g)break;C>m&&u(Math.max(S,m),null==e&&S<=f,Math.min(C,g),null==n&&C>=d,x.dir)}}catch(A){b.e(A)}finally{b.f()}if((m=w.to+1)>=g)break}}}catch(A){v.e(A)}finally{v.f()}return 0==a.length&&u(f,null==e,d,null==n,t.textDirection),{top:o,bottom:s,horizontal:a}}function x(t,e){var n=s.top+(e?t.top:t.bottom);return{top:n,bottom:n,horizontal:[]}}}(e.view,t)})).reduce((function(t,e){return t.concat(e)})),o=[],s=y(n.selection.ranges);try{for(s.s();!(t=s.n()).done;){var a=t.value,u=a==n.selection.main;if(a.empty?!u||Bo:i.drawRangeCursor){var l=qo(this.view,a,u);l&&o.push(l)}}}catch(h){s.e(h)}finally{s.f()}return{rangePieces:r,cursors:o}}},{key:"drawSel",value:function(t){var e=this,n=t.rangePieces,i=t.cursors;if(n.length!=this.rangePieces.length||n.some((function(t,n){return!t.eq(e.rangePieces[n])}))){this.selectionLayer.textContent="";var r,o=y(n);try{for(o.s();!(r=o.n()).done;){var s=r.value;this.selectionLayer.appendChild(s.draw())}}catch(c){o.e(c)}finally{o.f()}this.rangePieces=n}if(i.length!=this.cursors.length||i.some((function(t,n){return!t.eq(e.cursors[n])}))){var a=this.cursorLayer.children;if(a.length!==i.length){this.cursorLayer.textContent="";var u,l=y(i);try{for(l.s();!(u=l.n()).done;){var h=u.value;this.cursorLayer.appendChild(h.draw())}}catch(c){l.e(c)}finally{l.f()}}else i.forEach((function(t,e){return t.adjust(a[e])}));this.cursors=i}}},{key:"destroy",value:function(){this.selectionLayer.remove(),this.cursorLayer.remove()}}]),t}()),Vo={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Bo&&(Vo[".cm-line"].caretColor="transparent !important");var Ho=yt.highest(co.theme(Vo));function Wo(t){var e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==fi.LTR?e.left:e.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft,top:e.top-t.scrollDOM.scrollTop}}function Fo(t,e,n){var i=it.cursor(e);return{from:Math.max(n.from,t.moveToLineBoundary(i,!1,!0).from),to:Math.min(n.to,t.moveToLineBoundary(i,!0,!0).from),type:Dn.Text}}function zo(t,e){var n=t.lineBlockAt(e);if(Array.isArray(n.type)){var i,r=y(n.type);try{for(r.s();!(i=r.n()).done;){var o=i.value;if(o.to>e||o.to==e&&(o.to==n.to||o.type==Dn.Text))return o}}catch(s){r.e(s)}finally{r.f()}}return n}function qo(t,e,n){var i=t.coordsAtPos(e.head,e.assoc||1);if(!i)return null;var r=Wo(t);return new Io(i.left-r.left,i.top-r.top,-1,i.bottom-i.top,n?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}var jo=Nt.define({map:function(t,e){return null==t?null:e.mapPos(t)}}),_o=ct.define({create:function(){return null},update:function(t,e){return null!=t&&(t=e.changes.mapPos(t)),e.effects.reduce((function(t,e){return e.is(jo)?e.value:t}),t)}}),Uo=ii.fromClass(function(){function t(e){k(this,t),this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}return b(t,[{key:"update",value:function(t){var e,n=t.state.field(_o);null==n?null!=this.cursor&&(null===(e=this.cursor)||void 0===e||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field(_o)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}},{key:"readPos",value:function(){var t=this.view.state.field(_o),e=null!=t&&this.view.coordsAtPos(t);if(!e)return null;var n=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-n.left+this.view.scrollDOM.scrollLeft,top:e.top-n.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}},{key:"drawCursor",value:function(t){this.cursor&&(t?(this.cursor.style.left=t.left+"px",this.cursor.style.top=t.top+"px",this.cursor.style.height=t.height+"px"):this.cursor.style.left="-100000px")}},{key:"destroy",value:function(){this.cursor&&this.cursor.remove()}},{key:"setDropPos",value:function(t){this.view.state.field(_o)!=t&&this.view.dispatch({effects:jo.of(t)})}}]),t}(),{eventHandlers:{dragover:function(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave:function(t){t.target!=this.view.contentDOM&&this.view.contentDOM.contains(t.relatedTarget)||this.setDropPos(null)},dragend:function(){this.setDropPos(null)},drop:function(){this.setDropPos(null)}}});function Ko(){return[_o,Uo]}function Go(t,e,n,i,r){e.lastIndex=0;for(var o,s=t.iterRange(n,i),a=n;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=e.exec(s.value);)r(a+o.index,a+o.index+o[0].length,o)}var Jo=function(){function t(e){k(this,t);var n=e.regexp,i=e.decoration,r=e.boundary,o=e.maxLength,s=void 0===o?1e3:o;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=n,this.getDeco="function"==typeof i?i:function(){return i},this.boundary=r,this.maxLength=s}return b(t,[{key:"createDeco",value:function(t){var e,n=this,i=new ue,r=y(function(t,e){var n=t.visibleRanges;if(1==n.length&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;var i,r=[],o=y(n);try{for(o.s();!(i=o.n()).done;){var s=i.value,a=s.from,u=s.to;a=Math.max(t.state.doc.lineAt(a).from,a-e),u=Math.min(t.state.doc.lineAt(u).to,u+e),r.length&&r[r.length-1].to>=a?r[r.length-1].to=u:r.push({from:a,to:u})}}catch(l){o.e(l)}finally{o.f()}return r}(t,this.maxLength));try{for(r.s();!(e=r.n()).done;){var o=e.value,s=o.from,a=o.to;Go(t.state.doc,this.regexp,s,a,(function(e,r,o){return i.add(e,r,n.getDeco(o,t,e))}))}}catch(u){r.e(u)}finally{r.f()}return i.finish()}},{key:"updateDeco",value:function(t,e){var n=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((function(e,r,o,s){s>t.view.viewport.from&&o<t.view.viewport.to&&(n=Math.min(o,n),i=Math.max(s,i))})),t.viewportChanged||i-n>1e3?this.createDeco(t.view):i>-1?this.updateRange(t.view,e.map(t.changes),n,i):e}},{key:"updateRange",value:function(t,e,n,i){var r,o=this,s=y(t.visibleRanges);try{for(s.s();!(r=s.n()).done;){var a=r.value,u=Math.max(a.from,n),l=Math.min(a.to,i);l>u&&function(){var n=t.state.doc.lineAt(u),i=n.to<l?t.state.doc.lineAt(l):n,r=Math.max(a.from,n.from),s=Math.min(a.to,i.to);if(o.boundary){for(;u>n.from;u--)if(o.boundary.test(n.text[u-1-n.from])){r=u;break}for(;l<i.to;l++)if(o.boundary.test(i.text[l-i.from])){s=l;break}}var h=[],c=void 0;if(n==i)for(o.regexp.lastIndex=r-n.from;(c=o.regexp.exec(n.text))&&c.index<s-n.from;){var f=c.index+n.from;h.push(o.getDeco(c,t,f).range(f,f+c[0].length))}else Go(t.state.doc,o.regexp,r,s,(function(e,n,i){return h.push(o.getDeco(i,t,e).range(e,n))}));e=e.update({filterFrom:r,filterTo:s,filter:function(t,e){return t<r||e>s},add:h})}()}}catch(h){s.e(h)}finally{s.f()}return e}}]),t}(),$o=null!=/x/.unicode?"gu":"g",Yo=new RegExp("[\0-\b\n-\x1f\x7f-\x9f\xad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\ufeff\ufff9-\ufffc]",$o),Xo={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},Qo=null;var Zo=at.define({combine:function(t){var e=$t(t,{render:null,specialChars:Yo,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==Qo&&"undefined"!=typeof document&&document.body){var e=document.body.style;Qo=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return Qo||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,$o)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,$o)),e}});function ts(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Zo.of(t),ns()]}var es=null;function ns(){return es||(es=ii.fromClass(function(){function t(e){k(this,t),this.view=e,this.decorations=Tn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Zo)),this.decorations=this.decorator.createDeco(e)}return b(t,[{key:"makeDecorator",value:function(t){var e=this;return new Jo({regexp:t.specialChars,decoration:function(n,i,r){var o=i.state.doc,s=R(n[0],0);if(9==s){var a=o.lineAt(r),u=i.state.tabSize,l=P(a.text,u,r-a.from);return Tn.replace({widget:new rs((u-l%u)*e.view.defaultCharacterWidth)})}return e.decorationCache[s]||(e.decorationCache[s]=Tn.replace({widget:new is(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}},{key:"update",value:function(t){var e=t.state.facet(Zo);t.startState.facet(Zo)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}}]),t}(),{decorations:function(t){return t.decorations}}))}var is=function(t){v(n,t);var e=g(n);function n(t,i){var r;return k(this,n),(r=e.call(this)).options=t,r.code=i,r}return b(n,[{key:"eq",value:function(t){return t.code==this.code}},{key:"toDOM",value:function(t){var e=function(t){return t>=32?"\u2022":10==t?"\u2424":String.fromCharCode(9216+t)}(this.code),n=t.state.phrase("Control character")+" "+(Xo[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,n,e);if(i)return i;var r=document.createElement("span");return r.textContent=e,r.title=n,r.setAttribute("aria-label",n),r.className="cm-specialChar",r}},{key:"ignoreEvent",value:function(){return!1}}]),n}(On),rs=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).width=t,i}return b(n,[{key:"eq",value:function(t){return t.width==this.width}},{key:"toDOM",value:function(){var t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}},{key:"ignoreEvent",value:function(){return!1}}]),n}(On),os=ii.fromClass(function(){function t(){k(this,t),this.height=1e3,this.attrs={style:"padding-bottom: 1000px"}}return b(t,[{key:"update",value:function(t){var e=t.view.viewState.editorHeight-t.view.defaultLineHeight;e!=this.height&&(this.height=e,this.attrs={style:"padding-bottom: ".concat(e,"px")})}}]),t}());function ss(){return[os,ai.of((function(t){var e;return(null===(e=t.plugin(os))||void 0===e?void 0:e.attrs)||null}))]}function as(){return ls}var us=Tn.line({class:"cm-activeLine"}),ls=ii.fromClass(function(){function t(e){k(this,t),this.decorations=this.getDeco(e)}return b(t,[{key:"update",value:function(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}},{key:"getDeco",value:function(t){var e,n=-1,i=[],r=y(t.state.selection.ranges);try{for(r.s();!(e=r.n()).done;){var o=e.value;if(!o.empty)return Tn.none;var s=t.lineBlockAt(o.head);s.from>n&&(i.push(us.range(s.from)),n=s.from)}}catch(a){r.e(a)}finally{r.f()}return Tn.set(i)}}]),t}(),{decorations:function(t){return t.decorations}}),hs=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).content=t,i}return b(n,[{key:"toDOM",value:function(){var t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):this.content),"string"==typeof this.content?t.setAttribute("aria-label","placeholder "+this.content):t.setAttribute("aria-hidden","true"),t}},{key:"ignoreEvent",value:function(){return!1}}]),n}(On);function cs(t){return ii.fromClass(function(){function e(n){k(this,e),this.view=n,this.placeholder=Tn.set([Tn.widget({widget:new hs(t),side:1}).range(0)])}return b(e,[{key:"decorations",get:function(){return this.view.state.doc.length?Tn.none:this.placeholder}}]),e}(),{decorations:function(t){return t.decorations}})}var fs={HeightMap:Lr,HeightOracle:Dr,MeasuredHeights:Tr,QueryType:Rr,ChangedRange:hi,computeOrder:Ti,moveVisually:Bi},ds=Lt.define(),vs=Lt.define(),ps=at.define(),ms=at.define({combine:function(t){return $t(t,{minDepth:100,newGroupDelay:500},{minDepth:Math.max,newGroupDelay:Math.min})}});var gs=ct.define({create:function(){return Ls.empty},update:function(t,e){var n=e.state.facet(ms),i=e.annotation(ds);if(i){var r=e.docChanged?it.single(function(t){var e=0;return t.iterChangedRanges((function(t,n){return e=n})),e}(e.changes)):void 0,o=Cs.fromTransaction(e,r),s=i.side,a=0==s?t.undone:t.done;return a=o?As(a,a.length,n.minDepth,o):Ds(a,e.startState.selection),new Ls(0==s?i.rest:a,0==s?a:i.rest)}var u=e.annotation(vs);if("full"!=u&&"before"!=u||(t=t.isolate()),!1===e.annotation(Vt.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);var l=Cs.fromTransaction(e),h=e.annotation(Vt.time),c=e.annotation(Vt.userEvent);return l?t=t.addChanges(l,h,c,n.newGroupDelay,n.minDepth):e.selection&&(t=t.addSelection(e.startState.selection,h,c,n.newGroupDelay)),"full"!=u&&"after"!=u||(t=t.isolate()),t},toJSON:function(t){return{done:t.done.map((function(t){return t.toJSON()})),undone:t.undone.map((function(t){return t.toJSON()}))}},fromJSON:function(t){return new Ls(t.done.map(Cs.fromJSON),t.undone.map(Cs.fromJSON))}});function ys(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[gs,ms.of(t),co.domEventHandlers({beforeinput:function(t,e){var n="historyUndo"==t.inputType?ws:"historyRedo"==t.inputType?bs:null;return!!n&&(t.preventDefault(),n(e))}})]}function ks(t,e){return function(n){var i=n.state,r=n.dispatch;if(!e&&i.readOnly)return!1;var o=i.field(gs,!1);if(!o)return!1;var s=o.pop(t,i,e);return!!s&&(r(s),!0)}}var ws=ks(0,!1),bs=ks(1,!1),xs=ks(0,!0),Ss=ks(1,!0);var Cs=function(){function t(e,n,i,r,o){k(this,t),this.changes=e,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=o}return b(t,[{key:"setSelAfter",value:function(e){return new t(this.changes,this.effects,this.mapped,this.startSelection,e)}},{key:"toJSON",value:function(){var t,e,n;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((function(t){return t.toJSON()}))}}}],[{key:"fromJSON",value:function(e){return new t(e.changes&&$.fromJSON(e.changes),[],e.mapped&&J.fromJSON(e.mapped),e.startSelection&&it.fromJSON(e.startSelection),e.selectionsAfter.map(it.fromJSON))}},{key:"fromTransaction",value:function(e,n){var i,r=Os,o=y(e.startState.facet(ps));try{for(o.s();!(i=o.n()).done;){var s=(0,i.value)(e);s.length&&(r=r.concat(s))}}catch(a){o.e(a)}finally{o.f()}return!r.length&&e.changes.empty?null:new t(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,Os)}},{key:"selection",value:function(e){return new t(void 0,Os,void 0,void 0,e)}}]),t}();function As(t,e,n,i){var r=e+1>n+20?e-n-1:0,o=t.slice(r,e);return o.push(i),o}function Ms(t,e){return t.length?e.length?t.concat(e):t:e}var Os=[];function Ds(t,e){if(t.length){var n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),As(t,t.length-1,1e9,n.setSelAfter(i)))}return[Cs.selection([e])]}function Ts(t){var e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Es(t,e){if(!t.length)return t;for(var n=t.length,i=Os;n;){var r=Rs(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){var o=t.slice(0,n);return o[n-1]=r,o}e=r.mapped,n--,i=r.selectionsAfter}return i.length?[Cs.selection(i)]:Os}function Rs(t,e,n){var i=Ms(t.selectionsAfter.length?t.selectionsAfter.map((function(t){return t.map(e)})):Os,n);if(!t.changes)return Cs.selection(i);var r=t.changes.map(e),o=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(o):o;return new Cs(r,Nt.mapEffects(t.effects,e),s,t.startSelection.map(o),i)}var Bs=/^(input\.type|delete)($|\.)/,Ls=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;k(this,t),this.done=e,this.undone=n,this.prevTime=i,this.prevUserEvent=r}return b(t,[{key:"isolate",value:function(){return this.prevTime?new t(this.done,this.undone):this}},{key:"addChanges",value:function(e,n,i,r,o){var s=this.done,a=s[s.length-1];return s=a&&a.changes&&!a.changes.empty&&e.changes&&(!i||Bs.test(i))&&(!a.selectionsAfter.length&&n-this.prevTime<r&&function(t,e){var n=[],i=!1;return t.iterChangedRanges((function(t,e){return n.push(t,e)})),e.iterChangedRanges((function(t,e,r,o){for(var s=0;s<n.length;){var a=n[s++],u=n[s++];o>=a&&r<=u&&(i=!0)}})),i}(a.changes,e.changes)||"input.type.compose"==i)?As(s,s.length-1,o,new Cs(e.changes.compose(a.changes),Ms(e.effects,a.effects),a.mapped,a.startSelection,Os)):As(s,s.length,o,e),new t(s,Os,n,i)}},{key:"addSelection",value:function(e,n,i,r){var o,s,a=this.done.length?this.done[this.done.length-1].selectionsAfter:Os;return a.length>0&&n-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(o=a[a.length-1],s=e,o.ranges.length==s.ranges.length&&0===o.ranges.filter((function(t,e){return t.empty!=s.ranges[e].empty})).length)?this:new t(Ds(this.done,e),this.undone,n,i)}},{key:"addMapping",value:function(e){return new t(Es(this.done,e),Es(this.undone,e),this.prevTime,this.prevUserEvent)}},{key:"pop",value:function(t,e,n){var i=0==t?this.done:this.undone;if(0==i.length)return null;var r=i[i.length-1];if(n&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:ds.of({side:t,rest:Ts(i)}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){var o=1==i.length?Os:i.slice(0,i.length-1);return r.mapped&&(o=Es(o,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:ds.of({side:t,rest:o}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}]),t}();Ls.empty=new Ls(Os,Os);var Ps=[{key:"Mod-z",run:ws,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:bs,preventDefault:!0},{key:"Mod-u",run:xs,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Ss,preventDefault:!0}],Is=0,Ns=b((function t(e,n){k(this,t),this.from=e,this.to=n})),Vs=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};k(this,t),this.id=Is++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||function(){throw new Error("This node type doesn't define a deserialize function")}}return b(t,[{key:"add",value:function(t){var e=this;if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=Ws.match(t)),function(n){var i=t(n);return void 0===i?null:[e,i]}}}]),t}();Vs.closedBy=new Vs({deserialize:function(t){return t.split(" ")}}),Vs.openedBy=new Vs({deserialize:function(t){return t.split(" ")}}),Vs.group=new Vs({deserialize:function(t){return t.split(" ")}}),Vs.contextHash=new Vs({perNode:!0}),Vs.lookAhead=new Vs({perNode:!0}),Vs.mounted=new Vs({perNode:!0});var Hs=Object.create(null),Ws=function(){function t(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;k(this,t),this.name=e,this.props=n,this.id=i,this.flags=r}return b(t,[{key:"prop",value:function(t){return this.props[t.id]}},{key:"isTop",get:function(){return(1&this.flags)>0}},{key:"isSkipped",get:function(){return(2&this.flags)>0}},{key:"isError",get:function(){return(4&this.flags)>0}},{key:"isAnonymous",get:function(){return(8&this.flags)>0}},{key:"is",value:function(t){if("string"==typeof t){if(this.name==t)return!0;var e=this.prop(Vs.group);return!!e&&e.indexOf(t)>-1}return this.id==t}}],[{key:"define",value:function(e){var n=e.props&&e.props.length?Object.create(null):Hs,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new t(e.name||"",n,e.id,i);if(e.props){var o,s=y(e.props);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(Array.isArray(a)||(a=a(r)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}}catch(u){s.e(u)}finally{s.f()}}return r}},{key:"match",value:function(t){var e=Object.create(null);for(var n in t){var i,r=y(n.split(" "));try{for(r.s();!(i=r.n()).done;){var o=i.value;e[o]=t[n]}}catch(s){r.e(s)}finally{r.f()}}return function(t){for(var n=t.prop(Vs.group),i=-1;i<(n?n.length:0);i++){var r=e[i<0?t.name:n[i]];if(r)return r}}}}]),t}();Ws.none=new Ws("",Object.create(null),0,8);var Fs=new WeakMap,zs=new WeakMap,qs=function(){function t(e,n,i,r,o){if(k(this,t),this.type=e,this.children=n,this.positions=i,this.length=r,this.props=null,o&&o.length){this.props=Object.create(null);var s,u=y(o);try{for(u.s();!(s=u.n()).done;){var l=a(s.value,2),h=l[0],c=l[1];this.props["number"==typeof h?h:h.id]=c}}catch(f){u.e(f)}finally{u.f()}}}return b(t,[{key:"toString",value:function(){var t=this.prop(Vs.mounted);if(t&&!t.overlay)return t.tree.toString();var e,n="",i=y(this.children);try{for(i.s();!(e=i.n()).done;){var r=e.value.toString();r&&(n&&(n+=","),n+=r)}}catch(o){i.e(o)}finally{i.f()}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}},{key:"cursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null!=t&&Fs.get(this)||this.topNode,i=new Qs(n);return null!=t&&(i.moveTo(t,e),Fs.set(this,i._tree)),i}},{key:"fullCursor",value:function(){return new Qs(this.topNode,1)}},{key:"topNode",get:function(){return new Js(this,0,0,null)}},{key:"resolve",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Gs(Fs.get(this)||this.topNode,t,e,!1);return Fs.set(this,n),n}},{key:"resolveInner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Gs(zs.get(this)||this.topNode,t,e,!0);return zs.set(this,n),n}},{key:"iterate",value:function(t){for(var e=t.enter,n=t.leave,i=t.from,r=void 0===i?0:i,o=t.to,s=void 0===o?this.length:o,a=this.cursor(),u=function(){return a.node};;){var l=!1;if(a.from<=s&&a.to>=r&&(a.type.isAnonymous||!1!==e(a.type,a.from,a.to,u))){if(a.firstChild())continue;a.type.isAnonymous||(l=!0)}for(;l&&n&&n(a.type,a.from,a.to,u),l=a.type.isAnonymous,!a.nextSibling();){if(!a.parent())return;l=!0}}}},{key:"prop",value:function(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}},{key:"propValues",get:function(){var t=[];if(this.props)for(var e in this.props)t.push([+e,this.props[e]]);return t}},{key:"balance",value:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.children.length<=8?this:ia(Ws.none,this.children,this.positions,0,this.children.length,0,this.length,(function(n,i,r){return new t(e.type,n,i,r,e.propValues)}),n.makeTree||function(e,n,i){return new t(Ws.none,e,n,i)})}}],[{key:"build",value:function(t){return ta(t)}}]),t}();qs.empty=new qs(Ws.none,[],[],0);var js=function(){function t(e,n){k(this,t),this.buffer=e,this.index=n}return b(t,[{key:"id",get:function(){return this.buffer[this.index-4]}},{key:"start",get:function(){return this.buffer[this.index-3]}},{key:"end",get:function(){return this.buffer[this.index-2]}},{key:"size",get:function(){return this.buffer[this.index-1]}},{key:"pos",get:function(){return this.index}},{key:"next",value:function(){this.index-=4}},{key:"fork",value:function(){return new t(this.buffer,this.index)}}]),t}(),_s=function(){function t(e,n,i){k(this,t),this.buffer=e,this.length=n,this.set=i}return b(t,[{key:"type",get:function(){return Ws.none}},{key:"toString",value:function(){for(var t=[],e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}},{key:"childString",value:function(t){var e=this.buffer[t],n=this.buffer[t+3],i=this.set.types[e],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(t+=4))return r;for(var o=[];t<n;)o.push(this.childString(t)),t=this.buffer[t+3];return r+"("+o.join(",")+")"}},{key:"findChild",value:function(t,e,n,i,r){for(var o=this.buffer,s=-1,a=t;a!=e&&!(Us(r,i,o[a+1],o[a+2])&&(s=a,n>0));a=o[a+3]);return s}},{key:"slice",value:function(e,n,i,r){for(var o=this.buffer,s=new Uint16Array(n-e),a=e,u=0;a<n;)s[u++]=o[a++],s[u++]=o[a++]-i,s[u++]=o[a++]-i,s[u++]=o[a++]-e;return new t(s,r-i,this.set)}}]),t}();function Us(t,e,n,i){switch(t){case-2:return n<e;case-1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function Ks(t,e){for(var n=t.childBefore(e);n;){var i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(t=n,n=i.prevSibling):n=i}return t}function Gs(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){var o=!i&&t instanceof Js&&t.index<0?null:t.parent;if(!o)return t;t=o}if(i)for(var s=t,a=s.parent;a;a=(s=a).parent)s instanceof Js&&s.index<0&&(null===(r=a.enter(e,n,!0))||void 0===r?void 0:r.from)!=s.from&&(t=a);for(;;){var u=t.enter(e,n,i);if(!u)return t;t=u}}var Js=function(){function t(e,n,i,r){k(this,t),this.node=e,this._from=n,this.index=i,this._parent=r}return b(t,[{key:"type",get:function(){return this.node.type}},{key:"name",get:function(){return this.node.type.name}},{key:"from",get:function(){return this._from}},{key:"to",get:function(){return this._from+this.node.length}},{key:"nextChild",value:function(e,n,i,r){for(var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=this;;){for(var a=s.node,u=a.children,l=a.positions,h=n>0?u.length:-1;e!=h;e+=n){var c=u[e],f=l[e]+s._from;if(Us(r,i,f,f+c.length))if(c instanceof _s){if(2&o)continue;var d=c.findChild(0,c.buffer.length,n,i-f,r);if(d>-1)return new Xs(new Ys(s,c,e,f),null,d)}else if(1&o||!c.type.isAnonymous||Zs(c)){var v=void 0;if(!(1&o)&&c.props&&(v=c.prop(Vs.mounted))&&!v.overlay)return new t(v.tree,f,e,s);var p=new t(c,f,e,s);return 1&o||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,i,r)}}if(1&o||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+n:n<0?-1:s._parent.node.children.length,!(s=s._parent))return null}}},{key:"firstChild",get:function(){return this.nextChild(0,1,0,4)}},{key:"lastChild",get:function(){return this.nextChild(this.node.children.length-1,-1,0,4)}},{key:"childAfter",value:function(t){return this.nextChild(0,1,t,2)}},{key:"childBefore",value:function(t){return this.nextChild(this.node.children.length-1,-1,t,-2)}},{key:"enter",value:function(e,n){var i,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(r&&(i=this.node.prop(Vs.mounted))&&i.overlay){var s,a=e-this.from,u=y(i.overlay);try{for(u.s();!(s=u.n()).done;){var l=s.value,h=l.from,c=l.to;if((n>0?h<=a:h<a)&&(n<0?c>=a:c>a))return new t(i.tree,i.overlay[0].from+this.from,-1,this)}}catch(f){u.e(f)}finally{u.f()}}return this.nextChild(0,1,e,n,o?0:2)}},{key:"nextSignificantParent",value:function(){for(var t=this;t.type.isAnonymous&&t._parent;)t=t._parent;return t}},{key:"parent",get:function(){return this._parent?this._parent.nextSignificantParent():null}},{key:"nextSibling",get:function(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}},{key:"prevSibling",get:function(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}},{key:"cursor",get:function(){return new Qs(this)}},{key:"tree",get:function(){return this.node}},{key:"toTree",value:function(){return this.node}},{key:"resolve",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Gs(this,t,e,!1)}},{key:"resolveInner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Gs(this,t,e,!0)}},{key:"enterUnfinishedNodesBefore",value:function(t){return Ks(this,t)}},{key:"getChild",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=$s(this,t,e,n);return i.length?i[0]:null}},{key:"getChildren",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return $s(this,t,e,n)}},{key:"toString",value:function(){return this.node.toString()}}]),t}();function $s(t,e,n,i){var r=t.cursor,o=[];if(!r.firstChild())return o;if(null!=n)for(;!r.type.is(n);)if(!r.nextSibling())return o;for(;;){if(null!=i&&r.type.is(i))return o;if(r.type.is(e)&&o.push(r.node),!r.nextSibling())return null==i?o:[]}}var Ys=b((function t(e,n,i,r){k(this,t),this.parent=e,this.buffer=n,this.index=i,this.start=r})),Xs=function(){function t(e,n,i){k(this,t),this.context=e,this._parent=n,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}return b(t,[{key:"name",get:function(){return this.type.name}},{key:"from",get:function(){return this.context.start+this.context.buffer.buffer[this.index+1]}},{key:"to",get:function(){return this.context.start+this.context.buffer.buffer[this.index+2]}},{key:"child",value:function(e,n,i){var r=this.context.buffer,o=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,i);return o<0?null:new t(this.context,this,o)}},{key:"firstChild",get:function(){return this.child(1,0,4)}},{key:"lastChild",get:function(){return this.child(-1,0,4)}},{key:"childAfter",value:function(t){return this.child(1,t,2)}},{key:"childBefore",value:function(t){return this.child(-1,t,-2)}},{key:"enter",value:function(e,n,i){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!r)return null;var o=this.context.buffer,s=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new t(this.context,this,s)}},{key:"parent",get:function(){return this._parent||this.context.parent.nextSignificantParent()}},{key:"externalSibling",value:function(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}},{key:"nextSibling",get:function(){var e=this.context.buffer,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new t(this.context,this._parent,n):this.externalSibling(1)}},{key:"prevSibling",get:function(){var e=this.context.buffer,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new t(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}},{key:"cursor",get:function(){return new Qs(this)}},{key:"tree",get:function(){return null}},{key:"toTree",value:function(){var t=[],e=[],n=this.context.buffer,i=this.index+4,r=n.buffer[this.index+3];if(r>i){var o=n.buffer[this.index+1],s=n.buffer[this.index+2];t.push(n.slice(i,r,o,s)),e.push(0)}return new qs(this.type,t,e,this.to-this.from)}},{key:"resolve",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Gs(this,t,e,!1)}},{key:"resolveInner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Gs(this,t,e,!0)}},{key:"enterUnfinishedNodesBefore",value:function(t){return Ks(this,t)}},{key:"toString",value:function(){return this.context.buffer.childString(this.index)}},{key:"getChild",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=$s(this,t,e,n);return i.length?i[0]:null}},{key:"getChildren",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return $s(this,t,e,n)}}]),t}(),Qs=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(k(this,t),this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Js)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(var i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}return b(t,[{key:"name",get:function(){return this.type.name}},{key:"yieldNode",value:function(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}},{key:"yieldBuf",value:function(t,e){this.index=t;var n=this.buffer,i=n.start,r=n.buffer;return this.type=e||r.set.types[r.buffer[t]],this.from=i+r.buffer[t+1],this.to=i+r.buffer[t+2],!0}},{key:"yield",value:function(t){return!!t&&(t instanceof Js?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}},{key:"toString",value:function(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}},{key:"enterChild",value:function(t,e,n){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree.node.children.length-1:0,t,e,n,this.mode));var i=this.buffer.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],t,e-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}},{key:"firstChild",value:function(){return this.enterChild(1,0,4)}},{key:"lastChild",value:function(){return this.enterChild(-1,0,4)}},{key:"childAfter",value:function(t){return this.enterChild(1,t,2)}},{key:"childBefore",value:function(t){return this.enterChild(-1,t,-2)}},{key:"enter",value:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return this.buffer?!!i&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,n&&!(1&this.mode),i))}},{key:"parent",value:function(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());var t=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}},{key:"sibling",value:function(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));var e=this.buffer.buffer,n=this.stack.length-1;if(t<0){var i=n<0?0:this.stack[n]+4;if(this.index!=i)return this.yieldBuf(e.findChild(i,this.index,-1,0,4))}else{var r=e.buffer[this.index+3];if(r<(n<0?e.buffer.length:e.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}},{key:"nextSibling",value:function(){return this.sibling(1)}},{key:"prevSibling",value:function(){return this.sibling(-1)}},{key:"atLastNode",value:function(t){var e,n,i=this.buffer;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(var r=0;r<this.index;r++)if(i.buffer.buffer[r+3]<this.index)return!1;e=i.index,n=i.parent}else{var o=this._tree;e=o.index,n=o._parent}for(;n;e=(s=n).index,n=s._parent,s){var s;if(e>-1)for(var a=e+t,u=t<0?-1:n.node.children.length;a!=u;a+=t){var l=n.node.children[a];if(1&this.mode||l instanceof _s||!l.type.isAnonymous||Zs(l))return!1}}return!0}},{key:"move",value:function(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}},{key:"next",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(1,t)}},{key:"prev",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(-1,t)}},{key:"moveTo",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}},{key:"node",get:function(){if(!this.buffer)return this._tree;var t=this.bufferNode,e=null,n=0;if(t&&t.context==this.buffer)t:for(var i=this.index,r=this.stack.length;r>=0;){for(var o=t;o;o=o._parent)if(o.index==i){if(i==this.index)return o;e=o,n=r+1;break t}i=this.stack[--r]}for(var s=n;s<this.stack.length;s++)e=new Xs(this.buffer,e,this.stack[s]);return this.bufferNode=new Xs(this.buffer,e,this.index)}},{key:"tree",get:function(){return this.buffer?null:this._tree.node}}]),t}();function Zs(t){return t.children.some((function(t){return t instanceof _s||!t.type.isAnonymous||Zs(t)}))}function ta(t){var e,n=t.buffer,i=t.nodeSet,r=t.maxBufferLength,o=void 0===r?1024:r,s=t.reused,a=void 0===s?[]:s,u=t.minRepeatType,l=void 0===u?i.types.length:u,h=Array.isArray(n)?new js(n,n.length):n,c=i.types,f=0,d=0;function v(t,e,n,r,s){for(var u=h.id,y=h.start,k=h.end,w=h.size,b=d;w<0;){if(h.next(),-1==w){var x=a[u];return n.push(x),void r.push(y-t)}if(-3==w)return void(f=u);if(-4==w)return void(d=u);throw new RangeError("Unrecognized record size: ".concat(w))}var S,C,A=c[u],M=y-t;if(k-y<=o&&(C=function(t,e){var n=h.fork(),i=0,r=0,s=0,a=n.end-o,u={size:0,start:0,skip:0};t:for(var c=n.pos-t;n.pos>c;){var f=n.size;if(n.id==e&&f>=0)u.size=i,u.start=r,u.skip=s,s+=4,i+=4,n.next();else{var d=n.pos-f;if(f<0||d<c||n.start<a)break;var v=n.id>=l?4:0,p=n.start;for(n.next();n.pos>d;){if(n.size<0){if(-3!=n.size)break t;v+=4}else n.id>=l&&(v+=4);n.next()}r=p,i+=f,s+=v}}(e<0||i==t)&&(u.size=i,u.start=r,u.skip=s);return u.size>4?u:void 0}(h.pos-e,s))){for(var O=new Uint16Array(C.size-C.skip),D=h.pos-C.size,T=O.length;h.pos>D;)T=g(C.start,O,T);S=new _s(O,k-C.start,i),M=C.start-t}else{var E=h.pos-w;h.next();for(var R=[],B=[],L=u>=l?u:-1,P=0,I=k;h.pos>E;)L>=0&&h.id==L&&h.size>=0?(h.end<=I-o&&(p(R,B,y,P,h.end,I,L,b),P=R.length,I=h.end),h.next()):v(y,E,R,B,L);if(L>=0&&P>0&&P<R.length&&p(R,B,y,P,y,I,L,b),R.reverse(),B.reverse(),L>-1&&P>0){var N=function(t){return function(e,n,i){var r,o,s=0,a=e.length-1;if(a>=0&&(r=e[a])instanceof qs){if(!a&&r.type==t&&r.length==i)return r;(o=r.prop(Vs.lookAhead))&&(s=n[a]+r.length+o)}return m(t,e,n,i,s)}}(A);S=ia(A,R,B,0,R.length,0,k-y,N,N)}else S=m(A,R,B,k-y,b-k)}n.push(S),r.push(M)}function p(t,e,n,r,o,s,a,u){for(var l=[],h=[];t.length>r;)l.push(t.pop()),h.push(e.pop()+n-o);t.push(m(i.types[a],l,h,s-o,u-s)),e.push(o-n)}function m(t,e,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5?arguments[5]:void 0;if(f){var s=[Vs.contextHash,f];o=o?[s].concat(o):[s]}if(r>25){var a=[Vs.lookAhead,r];o=o?[a].concat(o):[a]}return new qs(t,e,n,i,o)}function g(t,e,n){var i=h.id,r=h.start,o=h.end,s=h.size;if(h.next(),s>=0&&i<l){var a=n;if(s>4)for(var u=h.pos-(s-4);h.pos>u;)n=g(t,e,n);e[--n]=a,e[--n]=o-t,e[--n]=r-t,e[--n]=i}else-3==s?f=i:-4==s&&(d=i);return n}for(var y=[],k=[];h.pos>0;)v(t.start||0,t.bufferStart||0,y,k,-1);var w=null!==(e=t.length)&&void 0!==e?e:y.length?k[0]+y[0].length:0;return new qs(c[t.topID],y.reverse(),k.reverse(),w)}var ea=new WeakMap;function na(t,e){if(!t.isAnonymous||e instanceof _s||e.type!=t)return 1;var n=ea.get(e);if(null==n){n=1;var i,r=y(e.children);try{for(r.s();!(i=r.n()).done;){var o=i.value;if(o.type!=t||!(o instanceof qs)){n=1;break}n+=na(t,o)}}catch(s){r.e(s)}finally{r.f()}ea.set(e,n)}return n}function ia(t,e,n,i,r,o,s,a,u){for(var l=0,h=i;h<r;h++)l+=na(t,e[h]);var c=Math.ceil(1.5*l/8),f=[],d=[];return function e(n,i,r,s,a){for(var l=r;l<s;){var h=l,v=i[l],p=na(t,n[l]);for(l++;l<s;l++){var m=na(t,n[l]);if(p+m>=c)break;p+=m}if(l==h+1){if(p>c){var g=n[h];e(g.children,g.positions,0,g.children.length,i[h]+a);continue}f.push(n[h])}else{var y=i[l-1]+n[l-1].length-v;f.push(ia(t,n,i,h,l,v,y,null,u))}d.push(v+a-o)}}(e,n,i,r,0),(a||u)(f,d,s)}var ra=function(){function t(e,n,i,r){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];k(this,t),this.from=e,this.to=n,this.tree=i,this.offset=r,this.open=(o?1:0)|(s?2:0)}return b(t,[{key:"openStart",get:function(){return(1&this.open)>0}},{key:"openEnd",get:function(){return(2&this.open)>0}}],[{key:"addTree",value:function(e){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[new t(0,e.length,e,0,!1,r)],s=y(i);try{for(s.s();!(n=s.n()).done;){var a=n.value;a.to>e.length&&o.push(a)}}catch(u){s.e(u)}finally{s.f()}return o}},{key:"applyChanges",value:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:128;if(!n.length)return e;for(var r=[],o=1,s=e.length?e[0]:null,a=0,u=0,l=0;;a++){var h=a<n.length?n[a]:null,c=h?h.fromA:1e9;if(c-u>=i)for(;s&&s.from<c;){var f=s;if(u>=f.from||c<=f.to||l){var d=Math.max(f.from,u)-l,v=Math.min(f.to,c)-l;f=d>=v?null:new t(d,v,f.tree,f.offset+l,a>0,!!h)}if(f&&r.push(f),s.to>c)break;s=o<e.length?e[o++]:null}if(!h)break;u=h.toA,l=h.toA-h.toB}return r}}]),t}(),oa=function(){function t(){k(this,t)}return b(t,[{key:"startParse",value:function(t,e,n){return"string"==typeof t&&(t=new sa(t)),n=n?n.length?n.map((function(t){return new Ns(t.from,t.to)})):[new Ns(0,0)]:[new Ns(0,t.length)],this.createParse(t,e||[],n)}},{key:"parse",value:function(t,e,n){for(var i=this.startParse(t,e,n);;){var r=i.advance();if(r)return r}}}]),t}(),sa=function(){function t(e){k(this,t),this.string=e}return b(t,[{key:"length",get:function(){return this.string.length}},{key:"chunk",value:function(t){return this.string.slice(t)}},{key:"lineChunks",get:function(){return!1}},{key:"read",value:function(t,e){return this.string.slice(t,e)}}]),t}();new Vs({perNode:!0});var aa=new Vs;var ua=function(){function t(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];k(this,t),this.data=e,this.topNode=i,Jt.prototype.hasOwnProperty("tree")||Object.defineProperty(Jt.prototype,"tree",{get:function(){return ha(this)}}),this.parser=n,this.extension=[ya.of(this),Jt.languageData.of((function(t,e,n){return t.facet(la(t,e,n))}))].concat(r)}return b(t,[{key:"isActiveAt",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;return la(t,e,n)==this.data}},{key:"findRegions",value:function(t){var e=this,n=t.facet(ya);if((null===n||void 0===n?void 0:n.data)==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];var i=[];return function t(n,r){if(n.prop(aa)!=e.data){var o=n.prop(Vs.mounted);if(o){if(o.tree.prop(aa)==e.data){if(o.overlay){var s,a=y(o.overlay);try{for(a.s();!(s=a.n()).done;){var u=s.value;i.push({from:u.from+r,to:u.to+r})}}catch(f){a.e(f)}finally{a.f()}}else i.push({from:r,to:r+n.length});return}if(o.overlay){var l=i.length;if(t(o.tree,o.overlay[0].from+r),i.length>l)return}}for(var h=0;h<n.children.length;h++){var c=n.children[h];c instanceof qs&&t(c,n.positions[h]+r)}}else i.push({from:r,to:r+n.length})}(ha(t),0),i}},{key:"allowsNesting",get:function(){return!0}}]),t}();function la(t,e,n){var i=t.facet(ya);if(!i)return null;var r=i.data;if(i.allowsNesting)for(var o=ha(t).topNode;o;o=o.enter(e,n,!0,!1))r=o.type.prop(aa)||r;return r}ua.setState=Nt.define();function ha(t){var e=t.field(ua.state,!1);return e?e.tree:qs.empty}var ca=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length;k(this,t),this.doc=e,this.length=n,this.cursorPos=0,this.string="",this.cursor=e.iter()}return b(t,[{key:"syncTo",value:function(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}},{key:"chunk",value:function(t){return this.syncTo(t),this.string}},{key:"lineChunks",get:function(){return!0}},{key:"read",value:function(t,e){var n=this.cursorPos-this.string.length;return t<n||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-n,e-n)}}]),t}(),fa=null,da=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0,u=arguments.length>7?arguments[7]:void 0;k(this,t),this.parser=e,this.state=n,this.fragments=i,this.tree=r,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=u,this.parse=null,this.tempSkipped=[]}return b(t,[{key:"startParse",value:function(){return this.parser.startParse(new ca(this.state.doc),this.fragments)}},{key:"work",value:function(t,e){var n=this;return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=qs.empty&&this.isDone(null!==e&&void 0!==e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((function(){var i,r=Date.now()+t;for(n.parse||(n.parse=n.startParse()),null!=e&&(null==n.parse.stoppedAt||n.parse.stoppedAt>e)&&e<n.state.doc.length&&n.parse.stopAt(e);;){var o=n.parse.advance();if(o){if(n.fragments=n.withoutTempSkipped(ra.addTree(o,n.fragments,null!=n.parse.stoppedAt)),n.treeLen=null!==(i=n.parse.stoppedAt)&&void 0!==i?i:n.state.doc.length,n.tree=o,n.parse=null,!(n.treeLen<(null!==e&&void 0!==e?e:n.state.doc.length)))return!0;n.parse=n.startParse()}if(Date.now()>r)return!1}}))}},{key:"takeTree",value:function(){var t,e,n=this;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((function(){for(;!(e=n.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(ra.addTree(this.tree,this.fragments,!0)),this.parse=null)}},{key:"withContext",value:function(t){var e=fa;fa=this;try{return t()}finally{fa=e}}},{key:"withoutTempSkipped",value:function(t){for(var e;e=this.tempSkipped.pop();)t=va(t,e.from,e.to);return t}},{key:"changes",value:function(e,n){var i=this.fragments,r=this.tree,o=this.treeLen,s=this.viewport,a=this.skipped;if(this.takeTree(),!e.empty){var u=[];if(e.iterChangedRanges((function(t,e,n,i){return u.push({fromA:t,toA:e,fromB:n,toB:i})})),i=ra.applyChanges(i,u),r=qs.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];var l,h=y(this.skipped);try{for(h.s();!(l=h.n()).done;){var c=l.value,f=e.mapPos(c.from,1),d=e.mapPos(c.to,-1);f<d&&a.push({from:f,to:d})}}catch(v){h.e(v)}finally{h.f()}}}return new t(this.parser,n,i,r,o,s,a,this.scheduleOn)}},{key:"updateViewport",value:function(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;for(var e=this.skipped.length,n=0;n<this.skipped.length;n++){var i=this.skipped[n],r=i.from,o=i.to;r<t.to&&o>t.from&&(this.fragments=va(this.fragments,r,o),this.skipped.splice(n--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}},{key:"reset",value:function(){this.parse&&(this.takeTree(),this.parse=null)}},{key:"skipUntilInView",value:function(t,e){this.skipped.push({from:t,to:e})}},{key:"isDone",value:function(t){t=Math.min(t,this.state.doc.length);var e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}}],[{key:"getSkippingParser",value:function(t){return new(function(e){v(i,e);var n=g(i);function i(){return k(this,i),n.apply(this,arguments)}return b(i,[{key:"createParse",value:function(e,n,i){var r=i[0].from,o=i[i.length-1].to,s={parsedPos:r,advance:function(){var e=fa;if(e){var n,s=y(i);try{for(s.s();!(n=s.n()).done;){var a=n.value;e.tempSkipped.push(a)}}catch(u){s.e(u)}finally{s.f()}t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new qs(Ws.none,[],[],o-r)},stoppedAt:null,stopAt:function(){}};return s}}]),i}(oa))}},{key:"get",value:function(){return fa}}]),t}();function va(t,e,n){return ra.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}var pa=function(){function t(e){k(this,t),this.context=e,this.tree=e.tree}return b(t,[{key:"apply",value:function(e){if(!e.docChanged)return this;var n=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new t(n)}}],[{key:"init",value:function(e){var n=Math.min(3e3,e.doc.length),i=new da(e.facet(ya).parser,e,[],qs.empty,0,{from:0,to:n},[],null);return i.work(20,n)||i.takeTree(),new t(i)}}]),t}();ua.state=ct.define({create:pa.init,update:function(t,e){var n,i=y(e.effects);try{for(i.s();!(n=i.n()).done;){var r=n.value;if(r.is(ua.setState))return r.value}}catch(o){i.e(o)}finally{i.f()}return e.startState.facet(ya)!=e.state.facet(ya)?pa.init(e.state):t.apply(e)}});var ma=function(t){var e=setTimeout((function(){return t()}),500);return function(){return clearTimeout(e)}};"undefined"!=typeof requestIdleCallback&&(ma=function(t){var e=-1,n=setTimeout((function(){e=requestIdleCallback(t,{timeout:400})}),100);return function(){return e<0?clearTimeout(n):cancelIdleCallback(e)}});var ga=ii.fromClass(function(){function t(e){k(this,t),this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}return b(t,[{key:"update",value:function(t){var e=this.view.state.field(ua.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),t.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}},{key:"scheduleWork",value:function(){if(!this.working){var t=this.view.state,e=t.field(ua.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=ma(this.work))}}},{key:"work",value:function(t){this.working=null;var e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),!(this.chunkBudget<=0)){var n=this.view,i=n.state,r=n.viewport.to,o=i.field(ua.state);if(o.tree!=o.context.tree||!o.context.isDone(r+1e5)){var s=Math.min(this.chunkBudget,100,t?Math.max(25,t.timeRemaining()-5):1e9),a=o.context.treeLen<r&&i.doc.length>r+1e3,u=o.context.work(s,r+(a?0:1e5));this.chunkBudget-=Date.now()-e,(u||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ua.setState.of(new pa(o.context))})),this.chunkBudget>0&&(!u||a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}}}},{key:"checkAsyncSchedule",value:function(t){var e=this;t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((function(){return e.scheduleWork()})).catch((function(t){return Xn(e.view.state,t)})).then((function(){return e.workScheduled--})),t.scheduleOn=null)}},{key:"destroy",value:function(){this.working&&this.working()}},{key:"isWorking",value:function(){return this.working||this.workScheduled>0}}]),t}(),{eventHandlers:{focus:function(){this.scheduleWork()}}}),ya=at.define({combine:function(t){return t.length?t[0]:null},enables:[ua.state,ga]}),ka=at.define(),wa=at.define({combine:function(t){if(!t.length)return" ";if(!/^(?: +|\t+)$/.test(t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return t[0]}});function ba(t){var e=t.facet(wa);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function xa(t,e){var n="",i=t.tabSize;if(9==t.facet(wa).charCodeAt(0))for(;e>=i;)n+="\t",e-=i;for(var r=0;r<e;r++)n+=" ";return n}function Sa(t,e){t instanceof Jt&&(t=new Ca(t));var n,i=y(t.state.facet(ka));try{for(i.s();!(n=i.n()).done;){var r=(0,n.value)(t,e);if(null!=r)return r}}catch(s){i.e(s)}finally{i.f()}var o=ha(t.state);return o?function(t,e,n){return Oa(e.resolveInner(n).enterUnfinishedNodesBefore(n),n,t)}(t,o,e):null}var Ca=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k(this,t),this.state=e,this.options=n,this.unit=ba(e)}return b(t,[{key:"lineAt",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.state.doc.lineAt(t),i=this.options.simulateBreak;return null!=i&&i>=n.from&&i<=n.to?(e<0?i<t:i<=t)?{text:n.text.slice(i-n.from),from:i}:{text:n.text.slice(0,i-n.from),from:n.from}:n}},{key:"textAfterPos",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";var n=this.lineAt(t,e),i=n.text,r=n.from;return i.slice(t-r,Math.min(i.length,t+100-r))}},{key:"column",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.lineAt(t,e),i=n.text,r=n.from,o=this.countColumn(i,t-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(o+=s-this.countColumn(i,i.search(/\S|$/))),o}},{key:"countColumn",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.length;return P(t,this.state.tabSize,e)}},{key:"lineIndent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.lineAt(t,e),i=n.text,r=n.from,o=this.options.overrideIndentation;if(o){var s=o(r);if(s>-1)return s}return this.countColumn(i,i.search(/\S|$/))}},{key:"simulatedBreak",get:function(){return this.options.simulateBreak||null}}]),t}(),Aa=new Vs;function Ma(t){var e=t.type.prop(Aa);if(e)return e;var n,i=t.firstChild;if(i&&(n=i.type.prop(Vs.closedBy))){var r=t.lastChild,o=r&&n.indexOf(r.name)>-1;return function(t){return Ra(t,!0,1,void 0,o&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?r.from:void 0)}}return null==t.parent?Da:null}function Oa(t,e,n){for(;t;t=t.parent){var i=Ma(t);if(i)return i(new Ta(n,e,t))}return null}function Da(){return 0}var Ta=function(t){v(n,t);var e=g(n);function n(t,i,r){var o;return k(this,n),(o=e.call(this,t.state,t.options)).base=t,o.pos=i,o.node=r,o}return b(n,[{key:"textAfter",get:function(){return this.textAfterPos(this.pos)}},{key:"baseIndent",get:function(){for(var t=this.state.doc.lineAt(this.node.from);;){for(var e=this.node.resolve(t.from);e.parent&&e.parent.from==e.from;)e=e.parent;if(Ea(e,this.node))break;t=this.state.doc.lineAt(e.from)}return this.lineIndent(t.from)}},{key:"continue",value:function(){var t=this.node.parent;return t?Oa(t,this.pos,this.base):0}}]),n}(Ca);function Ea(t,e){for(var n=e;n;n=n.parent)if(t==n)return!0;return!1}function Ra(t,e,n,i,r){var o=t.textAfter,s=o.match(/^\s*/)[0].length,a=i&&o.slice(s,s+i.length)==i||r==t.pos+s,u=e?function(t){var e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;for(var r=t.options.simulateBreak,o=t.state.doc.lineAt(n.from),s=null==r||r<=o.from?o.to:Math.min(o.to,r),a=n.to;;){var u=e.childAfter(a);if(!u||u==i)return null;if(!u.type.isSkipped)return u.from<s?n:null;a=u.to}}(t):null;return u?a?t.column(u.from):t.column(u.to):t.baseIndent+(a?0:t.unit*n)}function Ba(){return Jt.transactionFilter.of((function(t){if(!t.docChanged||!t.isUserEvent("input.type"))return t;var e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;var n=t.newDoc,i=t.newSelection.main.head,r=n.lineAt(i);if(i>r.from+200)return t;var o=n.sliceString(r.from,i);if(!e.some((function(t){return t.test(o)})))return t;var s,a=t.state,u=-1,l=[],h=y(a.selection.ranges);try{for(h.s();!(s=h.n()).done;){var c=s.value.head,f=a.doc.lineAt(c);if(f.from!=u){u=f.from;var d=Sa(a,f.from);if(null!=d){var v=/^\s*/.exec(f.text)[0],p=xa(a,d);v!=p&&l.push({from:f.from,to:f.from+v.length,insert:p})}}}}catch(m){h.e(m)}finally{h.f()}return l.length?[t,{changes:l,sequential:!0}]:t}))}var La=at.define(),Pa=new Vs;function Ia(t,e,n){var i,r=y(t.facet(La));try{for(r.s();!(i=r.n()).done;){var o=(0,i.value)(t,e,n);if(o)return o}}catch(s){r.e(s)}finally{r.f()}return function(t,e,n){var i=ha(t);if(0==i.length)return null;for(var r=null,o=i.resolveInner(n);o;o=o.parent)if(!(o.to<=n||o.from>n)){if(r&&o.from<e)break;var s=o.type.prop(Pa);if(s){var a=s(o,t);a&&a.from<=n&&a.from>=e&&a.to>n&&(r=a)}}return r}(t,e,n)}var Na=function(t){v(n,t);var e=g(n);function n(){return k(this,n),e.apply(this,arguments)}return b(n,[{key:"compare",value:function(t){return this==t||this.constructor==t.constructor&&this.eq(t)}},{key:"eq",value:function(t){return!1}},{key:"destroy",value:function(t){}}]),n}(ne);Na.prototype.elementClass="",Na.prototype.toDOM=void 0,Na.prototype.mapMode=G.TrackBefore,Na.prototype.startSide=Na.prototype.endSide=-1,Na.prototype.point=!0;var Va=at.define(),Ha={class:"",renderEmptyElements:!1,elementStyle:"",markers:function(){return se.empty},lineMarker:function(){return null},lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Wa=at.define();function Fa(t){return[ja(),Wa.of(Object.assign(Object.assign({},Ha),t))]}var za=co.baseTheme({".cm-gutters":{display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#999",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"}}),qa=at.define({combine:function(t){return t.some((function(t){return t}))}});function ja(t){var e=[_a,za];return t&&!1===t.fixed&&e.push(qa.of(!0)),e}var _a=ii.fromClass(function(){function t(e){k(this,t),this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=e.state.facet(Wa).map((function(t){return new Ja(e,t)}));var n,i=y(this.gutters);try{for(i.s();!(n=i.n()).done;){var r=n.value;this.dom.appendChild(r.dom)}}catch(o){i.e(o)}finally{i.f()}this.fixed=!e.state.facet(qa),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}return b(t,[{key:"update",value:function(t){if(this.updateGutters(t)){var e=this.prevViewport,n=t.view.viewport,i=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(i<.8*(n.to-n.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(qa)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}},{key:"syncGutters",value:function(t){var e=this,n=this.dom.nextSibling;t&&this.dom.remove();var i,r=se.iter(this.view.state.facet(Va),this.view.viewport.from),o=[],s=this.gutters.map((function(t){return new Ga(t,e.view.viewport,-e.view.documentPadding.top)})),a=y(this.view.viewportLineBlocks);try{for(a.s();!(i=a.n()).done;){var u=i.value,l=void 0;if(Array.isArray(u.type)){var h,c=y(u.type);try{for(c.s();!(h=c.n()).done;){var f=h.value;if(f.type==Dn.Text){l=f;break}}}catch(g){c.e(g)}finally{c.f()}}else l=u.type==Dn.Text?u:void 0;if(l){o.length&&(o=[]),Ka(r,o,u.from);var d,v=y(s);try{for(v.s();!(d=v.n()).done;){d.value.line(this.view,l,o)}}catch(g){v.e(g)}finally{v.f()}}}}catch(g){a.e(g)}finally{a.f()}var p,m=y(s);try{for(m.s();!(p=m.n()).done;){p.value.finish()}}catch(g){m.e(g)}finally{m.f()}t&&this.view.scrollDOM.insertBefore(this.dom,n)}},{key:"updateGutters",value:function(t){var e=t.startState.facet(Wa),n=t.state.facet(Wa),i=t.docChanged||t.heightChanged||t.viewportChanged||!se.eq(t.startState.facet(Va),t.state.facet(Va),t.view.viewport.from,t.view.viewport.to);if(e==n){var r,o=y(this.gutters);try{for(o.s();!(r=o.n()).done;){r.value.update(t)&&(i=!0)}}catch(g){o.e(g)}finally{o.f()}}else{i=!0;var s,a=[],u=y(n);try{for(u.s();!(s=u.n()).done;){var l=s.value,h=e.indexOf(l);h<0?a.push(new Ja(this.view,l)):(this.gutters[h].update(t),a.push(this.gutters[h]))}}catch(g){u.e(g)}finally{u.f()}var c,f=y(this.gutters);try{for(f.s();!(c=f.n()).done;){var d=c.value;d.dom.remove(),a.indexOf(d)<0&&d.destroy()}}catch(g){f.e(g)}finally{f.f()}for(var v=0,p=a;v<p.length;v++){var m=p[v];this.dom.appendChild(m.dom)}this.gutters=a}return i}},{key:"destroy",value:function(){var t,e=y(this.gutters);try{for(e.s();!(t=e.n()).done;){t.value.destroy()}}catch(n){e.e(n)}finally{e.f()}this.dom.remove()}}]),t}(),{provide:ti.scrollMargins.from((function(t){return 0!=t.gutters.length&&t.fixed?t.view.textDirection==fi.LTR?{left:t.dom.offsetWidth}:{right:t.dom.offsetWidth}:null}))});function Ua(t){return Array.isArray(t)?t:[t]}function Ka(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}var Ga=function(){function t(e,n,i){k(this,t),this.gutter=e,this.height=i,this.localMarkers=[],this.i=0,this.cursor=se.iter(e.markers,n.from)}return b(t,[{key:"line",value:function(t,e,n){this.localMarkers.length&&(this.localMarkers=[]),Ka(this.cursor,this.localMarkers,e.from);var i=n.length?this.localMarkers.concat(n):this.localMarkers,r=this.gutter.config.lineMarker(t,e,i);r&&i.unshift(r);var o=this.gutter;if(0!=i.length||o.config.renderEmptyElements){var s=e.top-this.height;if(this.i==o.elements.length){var a=new $a(t,e.height,s,i);o.elements.push(a),o.dom.appendChild(a.dom)}else o.elements[this.i].update(t,e.height,s,i);this.height=e.bottom,this.i++}}},{key:"finish",value:function(){for(var t=this.gutter;t.elements.length>this.i;){var e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}]),t}(),Ja=function(){function t(e,n){var i=this;k(this,t),this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");var r=function(t){i.dom.addEventListener(t,(function(i){var r=e.lineBlockAtHeight(i.clientY-e.documentTop);n.domEventHandlers[t](e,r,i)&&i.preventDefault()}))};for(var o in n.domEventHandlers)r(o);this.markers=Ua(n.markers(e)),n.initialSpacer&&(this.spacer=new $a(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}return b(t,[{key:"update",value:function(t){var e=this.markers;if(this.markers=Ua(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){var n=this.config.updateSpacer(this.spacer.markers[0],t);n!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[n])}var i=t.view.viewport;return!se.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}},{key:"destroy",value:function(){var t,e=y(this.elements);try{for(e.s();!(t=e.n()).done;){t.value.destroy()}}catch(n){e.e(n)}finally{e.f()}}}]),t}(),$a=function(){function t(e,n,i,r){k(this,t),this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.update(e,n,i,r)}return b(t,[{key:"update",value:function(t,e,n,i){this.height!=e&&(this.dom.style.height=(this.height=e)+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),function(t,e){if(t.length!=e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}(this.markers,i)||this.setMarkers(t,i)}},{key:"setMarkers",value:function(t,e){for(var n="cm-gutterElement",i=this.dom.firstChild,r=0,o=0;;){var s=o,a=r<e.length?e[r++]:null,u=!1;if(a){var l=a.elementClass;l&&(n+=" "+l);for(var h=o;h<this.markers.length;h++)if(this.markers[h].compare(a)){s=h,u=!0;break}}else s=this.markers.length;for(;o<s;){var c=this.markers[o++];if(c.toDOM){c.destroy(i);var f=i.nextSibling;i.remove(),i=f}}if(!a)break;a.toDOM&&(u?i=i.nextSibling:this.dom.insertBefore(a.toDOM(t),i)),u&&o++}this.dom.className=n,this.markers=e}},{key:"destroy",value:function(){this.setMarkers(null,[])}}]),t}();var Ya=at.define(),Xa=at.define({combine:function(t){return $t(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers:function(t,e){var n=Object.assign({},t),i=function(t){var i=n[t],r=e[t];n[t]=i?function(t,e,n){return i(t,e,n)||r(t,e,n)}:r};for(var r in e)i(r);return n}})}}),Qa=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).number=t,i}return b(n,[{key:"eq",value:function(t){return this.number==t.number}},{key:"toDOM",value:function(){return document.createTextNode(this.number)}}]),n}(Na);function Za(t,e){return t.state.facet(Xa).formatNumber(e,t.state)}var tu=Wa.compute([Xa],(function(t){return{class:"cm-lineNumbers",renderEmptyElements:!1,markers:function(t){return t.state.facet(Ya)},lineMarker:function(t,e,n){return n.some((function(t){return t.toDOM}))?null:new Qa(Za(t,t.state.doc.lineAt(e.from).number))},lineMarkerChange:function(t){return t.startState.facet(Xa)!=t.state.facet(Xa)},initialSpacer:function(t){return new Qa(Za(t,nu(t.state.doc.lines)))},updateSpacer:function(t,e){var n=Za(e.view,nu(e.view.state.doc.lines));return n==t.number?t:new Qa(n)},domEventHandlers:t.facet(Xa).domEventHandlers}}));function eu(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Xa.of(t),ja(),tu]}function nu(t){for(var e=9;e<t;)e=10*e+9;return e}var iu=new(function(t){v(n,t);var e=g(n);function n(){var t;return k(this,n),(t=e.apply(this,arguments)).elementClass="cm-activeLineGutter",t}return b(n)}(Na)),ru=Va.compute(["selection"],(function(t){var e,n=[],i=-1,r=y(t.selection.ranges);try{for(r.s();!(e=r.n()).done;){var o=e.value;if(o.empty){var s=t.doc.lineAt(o.head).from;s>i&&(i=s,n.push(iu.range(s)))}}}catch(a){r.e(a)}finally{r.f()}return se.of(n)}));function ou(){return ru}function su(t,e){var n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);return n>=i?void 0:{from:n,to:i}}var au=Nt.define({map:su}),uu=Nt.define({map:su});function lu(t){var e,n=[],i=y(t.state.selection.ranges);try{var r=function(){var i=e.value.head;if(n.some((function(t){return t.from<=i&&t.to>=i})))return"continue";n.push(t.lineBlockAt(i))};for(i.s();!(e=i.n()).done;)r()}catch(o){i.e(o)}finally{i.f()}return n}var hu=ct.define({create:function(){return Tn.none},update:function(t,e){t=t.map(e.changes);var n,i=y(e.effects);try{var r=function(){var e=n.value;e.is(au)&&!function(t,e,n){var i=!1;return t.between(e,e,(function(t,r){t==e&&r==n&&(i=!0)})),i}(t,e.value.from,e.value.to)?t=t.update({add:[yu.range(e.value.from,e.value.to)]}):e.is(uu)&&(t=t.update({filter:function(t,n){return e.value.from!=t||e.value.to!=n},filterFrom:e.value.from,filterTo:e.value.to}))};for(i.s();!(n=i.n()).done;)r()}catch(a){i.e(a)}finally{i.f()}if(e.selection){var o=!1,s=e.selection.main.head;t.between(s,s,(function(t,e){t<s&&e>s&&(o=!0)})),o&&(t=t.update({filterFrom:s,filterTo:s,filter:function(t,e){return e<=s||t>=s}}))}return t},provide:function(t){return co.decorations.from(t)}});function cu(t,e,n){var i,r=null;return null===(i=t.field(hu,!1))||void 0===i||i.between(e,n,(function(t,e){(!r||r.from>t)&&(r={from:t,to:e})})),r}function fu(t,e){return t.field(hu,!1)?e:e.concat(Nt.appendConfig.of(gu()))}function du(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return co.announce.of("".concat(t.state.phrase(n?"Folded lines":"Unfolded lines")," ").concat(i," ").concat(t.state.phrase("to")," ").concat(r,"."))}var vu=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:function(t){var e,n=y(lu(t));try{for(n.s();!(e=n.n()).done;){var i=e.value,r=Ia(t.state,i.from,i.to);if(r)return t.dispatch({effects:fu(t.state,[au.of(r),du(t,r)])}),!0}}catch(o){n.e(o)}finally{n.f()}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:function(t){if(!t.state.field(hu,!1))return!1;var e,n=[],i=y(lu(t));try{for(i.s();!(e=i.n()).done;){var r=e.value,o=cu(t.state,r.from,r.to);o&&n.push(uu.of(o),du(t,o,!1))}}catch(s){i.e(s)}finally{i.f()}return n.length&&t.dispatch({effects:n}),n.length>0}},{key:"Ctrl-Alt-[",run:function(t){for(var e=t.state,n=[],i=0;i<e.doc.length;){var r=t.lineBlockAt(i),o=Ia(e,r.from,r.to);o&&n.push(au.of(o)),i=(o?t.lineBlockAt(o.to):r).to+1}return n.length&&t.dispatch({effects:fu(t.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:function(t){var e=t.state.field(hu,!1);if(!e||!e.size)return!1;var n=[];return e.between(0,t.state.doc.length,(function(t,e){n.push(uu.of({from:t,to:e}))})),t.dispatch({effects:n}),!0}}],pu={placeholderDOM:null,placeholderText:"\u2026"},mu=at.define({combine:function(t){return $t(t,pu)}});function gu(t){var e=[hu,xu];return t&&e.push(mu.of(t)),e}var yu=Tn.replace({widget:new(function(t){v(n,t);var e=g(n);function n(){return k(this,n),e.apply(this,arguments)}return b(n,[{key:"toDOM",value:function(t){var e=t.state,n=e.facet(mu),i=function(e){var n=t.lineBlockAt(t.posAtDOM(e.target)),i=cu(t.state,n.from,n.to);i&&t.dispatch({effects:uu.of(i)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,i);var r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",e.phrase("folded code")),r.title=e.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=i,r}}]),n}(On))}),ku={openText:"\u2304",closedText:"\u203a",markerDOM:null,domEventHandlers:{}},wu=function(t){v(n,t);var e=g(n);function n(t,i){var r;return k(this,n),(r=e.call(this)).config=t,r.open=i,r}return b(n,[{key:"eq",value:function(t){return this.config==t.config&&this.open==t.open}},{key:"toDOM",value:function(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);var e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}]),n}(Na);function bu(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.assign(Object.assign({},ku),t),n=new wu(e,!0),i=new wu(e,!1),r=ii.fromClass(function(){function t(e){k(this,t),this.from=e.viewport.from,this.markers=this.buildMarkers(e)}return b(t,[{key:"update",value:function(t){(t.docChanged||t.viewportChanged||t.startState.facet(ya)!=t.state.facet(ya)||t.startState.field(hu,!1)!=t.state.field(hu,!1))&&(this.markers=this.buildMarkers(t.view))}},{key:"buildMarkers",value:function(t){var e,r=new ue,o=y(t.viewportLineBlocks);try{for(o.s();!(e=o.n()).done;){var s=e.value,a=cu(t.state,s.from,s.to)?i:Ia(t.state,s.from,s.to)?n:null;a&&r.add(s.from,s.from,a)}}catch(u){o.e(u)}finally{o.f()}return r.finish()}}]),t}()),o=e.domEventHandlers;return[r,Fa({class:"cm-foldGutter",markers:function(t){var e;return(null===(e=t.plugin(r))||void 0===e?void 0:e.markers)||se.empty},initialSpacer:function(){return new wu(e,!1)},domEventHandlers:Object.assign(Object.assign({},o),{click:function(t,e,n){if(o.click&&o.click(t,e,n))return!0;var i=cu(t.state,e.from,e.to);if(i)return t.dispatch({effects:uu.of(i)}),!0;var r=Ia(t.state,e.from,e.to);return!!r&&(t.dispatch({effects:au.of(r)}),!0)}})}),gu()]}var xu=co.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),Su=co.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Cu=1e4,Au="()[]{}",Mu=at.define({combine:function(t){return $t(t,{afterCursor:!0,brackets:Au,maxScanDistance:Cu})}}),Ou=Tn.mark({class:"cm-matchingBracket"}),Du=Tn.mark({class:"cm-nonmatchingBracket"}),Tu=ct.define({create:function(){return Tn.none},update:function(t,e){if(!e.docChanged&&!e.selection)return t;var n,i=[],r=e.state.facet(Mu),o=y(e.state.selection.ranges);try{for(o.s();!(n=o.n()).done;){var s=n.value;if(s.empty){var a=Lu(e.state,s.head,-1,r)||s.head>0&&Lu(e.state,s.head-1,1,r)||r.afterCursor&&(Lu(e.state,s.head,1,r)||s.head<e.state.doc.length&&Lu(e.state,s.head+1,-1,r));if(a){var u=a.matched?Ou:Du;i.push(u.range(a.start.from,a.start.to)),a.end&&i.push(u.range(a.end.from,a.end.to))}}}}catch(l){o.e(l)}finally{o.f()}return Tn.set(i,!0)},provide:function(t){return co.decorations.from(t)}}),Eu=[Tu,Su];function Ru(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Mu.of(t),Eu]}function Bu(t,e,n){var i=t.prop(e<0?Vs.openedBy:Vs.closedBy);if(i)return i;if(1==t.name.length){var r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function Lu(t,e,n){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=i.maxScanDistance||Cu,o=i.brackets||Au,s=ha(t),a=s.resolveInner(e,n),u=a;u;u=u.parent){var l=Bu(u.type,n,o);if(l&&u.from<u.to)return Pu(t,e,n,u,l,o)}return Iu(t,e,n,s,a.type,r,o)}function Pu(t,e,n,i,r,o){var s=i.parent,a={from:i.from,to:i.to},u=0,l=null===s||void 0===s?void 0:s.cursor;if(l&&(n<0?l.childBefore(i.from):l.childAfter(i.to)))do{if(n<0?l.to<=i.from:l.from>=i.to){if(0==u&&r.indexOf(l.type.name)>-1&&l.from<l.to)return{start:a,end:{from:l.from,to:l.to},matched:!0};if(Bu(l.type,n,o))u++;else if(Bu(l.type,-n,o)&&0==--u)return{start:a,end:l.from==l.to?void 0:{from:l.from,to:l.to},matched:!1}}}while(n<0?l.prevSibling():l.nextSibling());return{start:a,matched:!1}}function Iu(t,e,n,i,r,o,s){var a=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),u=s.indexOf(a);if(u<0||u%2==0!=n>0)return null;for(var l={from:n<0?e-1:e,to:n>0?e+1:e},h=t.doc.iterRange(e,n>0?t.doc.length:0),c=0,f=0;!h.next().done&&f<=o;){var d=h.value;n<0&&(f+=d.length);for(var v=e+f*n,p=n>0?0:d.length-1,m=n>0?d.length:-1;p!=m;p+=n){var g=s.indexOf(d[p]);if(!(g<0||i.resolve(v+p,1).type!=r))if(g%2==0==n>0)c++;else{if(1==c)return{start:l,end:{from:v+p,to:v+p+1},matched:g>>1==u>>1};c--}}n>0&&(f+=d.length)}return h.done?{start:l,matched:!1}:null}function Nu(t,e){return it.create(t.ranges.map(e),t.mainIndex)}function Vu(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Hu(t,e){var n=t.state,i=t.dispatch,r=Nu(n.selection,e);return!r.eq(n.selection)&&(i(Vu(n,r)),!0)}function Wu(t,e){return it.cursor(e?t.to:t.from)}function Fu(t,e){return Hu(t,(function(n){return n.empty?t.moveByChar(n,e):Wu(n,e)}))}var zu=function(t){return Fu(t,t.textDirection!=fi.LTR)},qu=function(t){return Fu(t,t.textDirection==fi.LTR)};function ju(t,e){return Hu(t,(function(n){return n.empty?t.moveByGroup(n,e):Wu(n,e)}))}function _u(t,e,n){if(e.type.prop(n))return!0;var i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Uu(t,e,n){for(var i=ha(t).resolveInner(e.head),r=n?Vs.closedBy:Vs.openedBy,o=e.head;;){var s=n?i.childAfter(o):i.childBefore(o);if(!s)break;_u(t,s,r)?i=s:o=n?s.to:s.from}var a,u;return u=i.type.prop(r)&&(a=n?Lu(t,i.from,1):Lu(t,i.to,-1))&&a.matched?n?a.end.to:a.end.from:n?i.to:i.from,it.cursor(u,n?-1:1)}function Ku(t,e){return Hu(t,(function(n){if(!n.empty)return Wu(n,e);var i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)}))}var Gu=function(t){return Ku(t,!1)},Ju=function(t){return Ku(t,!0)};function $u(t,e){var n=t.state,i=Nu(n.selection,(function(n){return n.empty?t.moveVertically(n,e,t.dom.clientHeight):Wu(n,e)}));if(i.eq(n.selection))return!1;var r=t.coordsAtPos(n.selection.main.head),o=t.scrollDOM.getBoundingClientRect();return t.dispatch(Vu(n,i),{effects:r&&r.top>o.top&&r.bottom<o.bottom?co.scrollIntoView(i.main.head,{y:"start",yMargin:r.top-o.top}):void 0}),!0}var Yu=function(t){return $u(t,!1)},Xu=function(t){return $u(t,!0)};function Qu(t,e,n){var i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){var o=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(r=it.cursor(i.from+o))}return r}var Zu=function(t){return Hu(t,(function(e){return Qu(t,e,!0)}))},tl=function(t){return Hu(t,(function(e){return Qu(t,e,!1)}))};function el(t,e,n){var i=!1,r=Nu(t.selection,(function(e){var r=Lu(t,e.head,-1)||Lu(t,e.head,1)||e.head>0&&Lu(t,e.head-1,1)||e.head<t.doc.length&&Lu(t,e.head+1,-1);if(!r||!r.end)return e;i=!0;var o=r.start.from==e.head?r.end.to:r.end.from;return n?it.range(e.anchor,o):it.cursor(o)}));return!!i&&(e(Vu(t,r)),!0)}function nl(t,e){var n=Nu(t.state.selection,(function(t){var n=e(t);return it.range(t.anchor,n.head,n.goalColumn)}));return!n.eq(t.state.selection)&&(t.dispatch(Vu(t.state,n)),!0)}function il(t,e){return nl(t,(function(n){return t.moveByChar(n,e)}))}var rl=function(t){return il(t,t.textDirection!=fi.LTR)},ol=function(t){return il(t,t.textDirection==fi.LTR)};function sl(t,e){return nl(t,(function(n){return t.moveByGroup(n,e)}))}function al(t,e){return nl(t,(function(n){return t.moveVertically(n,e)}))}var ul=function(t){return al(t,!1)},ll=function(t){return al(t,!0)};function hl(t,e){return nl(t,(function(n){return t.moveVertically(n,e,t.dom.clientHeight)}))}var cl=function(t){return hl(t,!1)},fl=function(t){return hl(t,!0)},dl=function(t){return nl(t,(function(e){return Qu(t,e,!0)}))},vl=function(t){return nl(t,(function(e){return Qu(t,e,!1)}))},pl=function(t){var e=t.state;return(0,t.dispatch)(Vu(e,{anchor:0})),!0},ml=function(t){var e=t.state;return(0,t.dispatch)(Vu(e,{anchor:e.doc.length})),!0},gl=function(t){var e=t.state;return(0,t.dispatch)(Vu(e,{anchor:e.selection.main.anchor,head:0})),!0},yl=function(t){var e=t.state;return(0,t.dispatch)(Vu(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0};function kl(t,e){var n=t.state,i=t.dispatch;if(n.readOnly)return!1;var r="delete.selection",o=n.changeByRange((function(t){var n=t.from,i=t.to;if(n==i){var o=e(n);o<n?r="delete.backward":o>n&&(r="delete.forward"),n=Math.min(n,o),i=Math.max(i,o)}return n==i?{range:t}:{changes:{from:n,to:i},range:it.cursor(n)}}));return!o.changes.empty&&(i(n.update(o,{scrollIntoView:!0,userEvent:r})),!0)}function wl(t,e,n){if(t instanceof co){var i,r=y(t.pluginField(ti.atomicRanges));try{for(r.s();!(i=r.n()).done;){i.value.between(e,e,(function(t,i){t<e&&i>e&&(e=n?i:t)}))}}catch(o){r.e(o)}finally{r.f()}}return e}var bl=function(t,e){return kl(t,(function(n){var i,r,o=t.state,s=o.doc.lineAt(n);if(!e&&n>s.from&&n<s.from+200&&!/[^ \t]/.test(i=s.text.slice(0,n-s.from))){if("\t"==i[i.length-1])return n-1;for(var a=P(i,o.tabSize)%ba(o)||ba(o),u=0;u<a&&" "==i[i.length-1-u];u++)n--;r=n}else(r=M(s.text,n-s.from,e,e)+s.from)==n&&s.number!=(e?o.doc.lines:1)&&(r+=e?1:-1);return wl(t,r,e)}))},xl=function(t){return bl(t,!1)},Sl=function(t){return bl(t,!0)},Cl=function(t,e){return kl(t,(function(n){for(var i=n,r=t.state,o=r.doc.lineAt(i),s=r.charCategorizer(i),a=null;;){if(i==(e?o.to:o.from)){i==n&&o.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}var u=M(o.text,i-o.from,e)+o.from,l=o.text.slice(Math.min(i,u)-o.from,Math.max(i,u)-o.from),h=s(l);if(null!=a&&h!=a)break;" "==l&&i==n||(a=h),i=u}return wl(t,i,e)}))},Al=function(t){return Cl(t,!1)},Ml=function(t){return kl(t,(function(e){var n=t.lineBlockAt(e).to;return wl(t,e<n?n:Math.min(t.state.doc.length,e+1),!0)}))};function Ol(t){var e,n=[],i=-1,r=y(t.selection.ranges);try{for(r.s();!(e=r.n()).done;){var o=e.value,s=t.doc.lineAt(o.from),a=t.doc.lineAt(o.to);if(o.empty||o.to!=a.from||(a=t.doc.lineAt(o.to-1)),i>=s.number){var u=n[n.length-1];u.to=a.to,u.ranges.push(o)}else n.push({from:s.from,to:a.to,ranges:[o]});i=a.number+1}}catch(l){r.e(l)}finally{r.f()}return n}function Dl(t,e,n){if(t.readOnly)return!1;var i,r=[],o=[],s=y(Ol(t));try{for(s.s();!(i=s.n()).done;){var a=i.value;if(n?a.to!=t.doc.length:0!=a.from){var u=t.doc.lineAt(n?a.to+1:a.from-1),l=u.length+1;if(n){r.push({from:a.to,to:u.to},{from:a.from,insert:u.text+t.lineBreak});var h,c=y(a.ranges);try{for(c.s();!(h=c.n()).done;){var f=h.value;o.push(it.range(Math.min(t.doc.length,f.anchor+l),Math.min(t.doc.length,f.head+l)))}}catch(m){c.e(m)}finally{c.f()}}else{r.push({from:u.from,to:a.from},{from:a.to,insert:t.lineBreak+u.text});var d,v=y(a.ranges);try{for(v.s();!(d=v.n()).done;){var p=d.value;o.push(it.range(p.anchor-l,p.head-l))}}catch(m){v.e(m)}finally{v.f()}}}}}catch(m){s.e(m)}finally{s.f()}return!!r.length&&(e(t.update({changes:r,scrollIntoView:!0,selection:it.create(o,t.selection.mainIndex),userEvent:"move.line"})),!0)}function Tl(t,e,n){if(t.readOnly)return!1;var i,r=[],o=y(Ol(t));try{for(o.s();!(i=o.n()).done;){var s=i.value;n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)})}}catch(a){o.e(a)}finally{o.f()}return e(t.update({changes:r,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var El=Rl(!1);function Rl(t){return function(e){var n=e.state,i=e.dispatch;if(n.readOnly)return!1;var r=n.changeByRange((function(e){var i=e.from,r=e.to,o=n.doc.lineAt(i),s=!t&&i==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};var n,i=ha(t).resolveInner(e),r=i.childBefore(e),o=i.childAfter(e);return r&&o&&r.to<=e&&o.from>=e&&(n=r.type.prop(Vs.closedBy))&&n.indexOf(o.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(o.from).from?{from:r.to,to:o.from}:null}(n,i);t&&(i=r=(r<=o.to?o:n.doc.lineAt(r)).to);var a=new Ca(n,{simulateBreak:i,simulateDoubleBreak:!!s}),u=Sa(a,i);for(null==u&&(u=/^\s*/.exec(n.doc.lineAt(i).text)[0].length);r<o.to&&/\s/.test(o.text[r-o.from]);)r++;s?(i=s.from,r=s.to):i>o.from&&i<o.from+100&&!/\S/.test(o.text.slice(0,i))&&(i=o.from);var l=["",xa(n,u)];return s&&l.push(xa(n,a.lineIndent(o.from,-1))),{changes:{from:i,to:r,insert:N.of(l)},range:it.cursor(i+1+l[1].length)}}));return i(n.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Bl(t,e){var n=-1;return t.changeByRange((function(i){for(var r=[],o=i.from;o<=i.to;){var s=t.doc.lineAt(o);s.number>n&&(i.empty||i.to>s.from)&&(e(s,r,i),n=s.number),o=s.to+1}var a=t.changes(r);return{changes:r,range:it.range(a.mapPos(i.anchor,1),a.mapPos(i.head,1))}}))}var Ll=function(t){var e=t.state,n=t.dispatch;return!e.readOnly&&(n(e.update(Bl(e,(function(t,n){n.push({from:t.from,insert:e.facet(wa)})})),{userEvent:"input.indent"})),!0)},Pl=function(t){var e=t.state,n=t.dispatch;return!e.readOnly&&(n(e.update(Bl(e,(function(t,n){var i=/^\s*/.exec(t.text)[0];if(i){for(var r=P(i,e.tabSize),o=0,s=xa(e,Math.max(0,r-ba(e)));o<i.length&&o<s.length&&i.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:t.from+o,to:t.from+i.length,insert:s.slice(o)})}})),{userEvent:"delete.dedent"})),!0)},Il=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:function(t){return Hu(t,(function(e){return Uu(t.state,e,t.textDirection!=fi.LTR)}))},shift:function(t){return nl(t,(function(e){return Uu(t.state,e,t.textDirection!=fi.LTR)}))}},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:function(t){return Hu(t,(function(e){return Uu(t.state,e,t.textDirection==fi.LTR)}))},shift:function(t){return nl(t,(function(e){return Uu(t.state,e,t.textDirection==fi.LTR)}))}},{key:"Alt-ArrowUp",run:function(t){return Dl(t.state,t.dispatch,!1)}},{key:"Shift-Alt-ArrowUp",run:function(t){return Tl(t.state,t.dispatch,!1)}},{key:"Alt-ArrowDown",run:function(t){return Dl(t.state,t.dispatch,!0)}},{key:"Shift-Alt-ArrowDown",run:function(t){return Tl(t.state,t.dispatch,!0)}},{key:"Escape",run:function(t){var e=t.state,n=t.dispatch,i=e.selection,r=null;return i.ranges.length>1?r=it.create([i.main]):i.main.empty||(r=it.create([it.cursor(i.main.head)])),!!r&&(n(Vu(e,r)),!0)}},{key:"Mod-Enter",run:Rl(!0)},{key:"Alt-l",mac:"Ctrl-l",run:function(t){var e=t.state,n=t.dispatch,i=Ol(e).map((function(t){var n=t.from,i=t.to;return it.range(n,Math.min(i+1,e.doc.length))}));return n(e.update({selection:it.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:function(t){var e=t.state,n=t.dispatch,i=Nu(e.selection,(function(t){for(var n,i=ha(e).resolveInner(t.head,1);!(i.from<t.from&&i.to>=t.to||i.to>t.to&&i.from<=t.from)&&(null===(n=i.parent)||void 0===n?void 0:n.parent);)i=i.parent;return it.range(i.to,i.from)}));return n(Vu(e,i)),!0},preventDefault:!0},{key:"Mod-[",run:Pl},{key:"Mod-]",run:Ll},{key:"Mod-Alt-\\",run:function(t){var e=t.state,n=t.dispatch;if(e.readOnly)return!1;var i=Object.create(null),r=new Ca(e,{overrideIndentation:function(t){var e=i[t];return null==e?-1:e}}),o=Bl(e,(function(t,n,o){var s=Sa(r,t.from);if(null!=s){/\S/.test(t.text)||(s=0);var a=/^\s*/.exec(t.text)[0],u=xa(e,s);(a!=u||o.from<t.from+a.length)&&(i[t.from]=s,n.push({from:t.from,to:t.from+a.length,insert:u}))}}));return o.changes.empty||n(e.update(o,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:function(t){if(t.state.readOnly)return!1;var e=t.state,n=e.changes(Ol(e).map((function(t){var n=t.from,i=t.to;return n>0?n--:i<e.doc.length&&i++,{from:n,to:i}}))),i=Nu(e.selection,(function(e){return t.moveVertically(e,!0)})).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:function(t){return el(t.state,t.dispatch,!1)}}].concat([{key:"ArrowLeft",run:zu,shift:rl,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:function(t){return ju(t,t.textDirection!=fi.LTR)},shift:function(t){return sl(t,t.textDirection!=fi.LTR)}},{mac:"Cmd-ArrowLeft",run:tl,shift:vl},{key:"ArrowRight",run:qu,shift:ol,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:function(t){return ju(t,t.textDirection==fi.LTR)},shift:function(t){return sl(t,t.textDirection==fi.LTR)}},{mac:"Cmd-ArrowRight",run:Zu,shift:dl},{key:"ArrowUp",run:Gu,shift:ul,preventDefault:!0},{mac:"Cmd-ArrowUp",run:pl,shift:gl},{mac:"Ctrl-ArrowUp",run:Yu,shift:cl},{key:"ArrowDown",run:Ju,shift:ll,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ml,shift:yl},{mac:"Ctrl-ArrowDown",run:Xu,shift:fl},{key:"PageUp",run:Yu,shift:cl},{key:"PageDown",run:Xu,shift:fl},{key:"Home",run:tl,shift:vl},{key:"Mod-Home",run:pl,shift:gl},{key:"End",run:Zu,shift:dl},{key:"Mod-End",run:ml,shift:yl},{key:"Enter",run:El},{key:"Mod-a",run:function(t){var e=t.state;return(0,t.dispatch)(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0}},{key:"Backspace",run:xl,shift:xl},{key:"Delete",run:Sl},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Al},{key:"Mod-Delete",mac:"Alt-Delete",run:function(t){return Cl(t,!0)}},{mac:"Mod-Backspace",run:function(t){return kl(t,(function(e){var n=t.lineBlockAt(e).from;return wl(t,e>n?n:Math.max(0,e-1),!1)}))}},{mac:"Mod-Delete",run:Ml}].concat([{key:"Ctrl-b",run:zu,shift:rl,preventDefault:!0},{key:"Ctrl-f",run:qu,shift:ol},{key:"Ctrl-p",run:Gu,shift:ul},{key:"Ctrl-n",run:Ju,shift:ll},{key:"Ctrl-a",run:function(t){return Hu(t,(function(e){return it.cursor(t.lineBlockAt(e.head).from,1)}))},shift:function(t){return nl(t,(function(e){return it.cursor(t.lineBlockAt(e.head).from)}))}},{key:"Ctrl-e",run:function(t){return Hu(t,(function(e){return it.cursor(t.lineBlockAt(e.head).to,-1)}))},shift:function(t){return nl(t,(function(e){return it.cursor(t.lineBlockAt(e.head).to)}))}},{key:"Ctrl-d",run:Sl},{key:"Ctrl-h",run:xl},{key:"Ctrl-k",run:Ml},{key:"Ctrl-Alt-h",run:Al},{key:"Ctrl-o",run:function(t){var e=t.state,n=t.dispatch;if(e.readOnly)return!1;var i=e.changeByRange((function(t){return{changes:{from:t.from,to:t.to,insert:N.of(["",""])},range:it.cursor(t.from)}}));return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:function(t){var e=t.state,n=t.dispatch;if(e.readOnly)return!1;var i=e.changeByRange((function(t){if(!t.empty||0==t.from||t.from==e.doc.length)return{range:t};var n=t.from,i=e.doc.lineAt(n),r=n==i.from?n-1:M(i.text,n-i.from,!1)+i.from,o=n==i.to?n+1:M(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:o,insert:e.doc.slice(n,o).append(e.doc.slice(r,n))},range:it.cursor(o)}}));return!i.changes.empty&&(n(e.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Xu}].map((function(t){return{mac:t.key,run:t.run,shift:t.shift}})))),Nl={key:"Tab",run:Ll,shift:Pl},Vl={brackets:["(","[","{","'",'"'],before:")]}'\":;>"},Hl=Nt.define({map:function(t,e){var n=e.mapPos(t,-1,G.TrackAfter);return null==n?void 0:n}}),Wl=Nt.define({map:function(t,e){return e.mapPos(t)}}),Fl=new(function(t){v(n,t);var e=g(n);function n(){return k(this,n),e.apply(this,arguments)}return b(n)}(ne));Fl.startSide=1,Fl.endSide=-1;var zl=ct.define({create:function(){return se.empty},update:function(t,e){if(e.selection){var n=e.state.doc.lineAt(e.selection.main.head).from,i=e.startState.doc.lineAt(e.startState.selection.main.head).from;n!=e.changes.mapPos(i,-1)&&(t=se.empty)}t=t.map(e.changes);var r,o=y(e.effects);try{var s=function(){var e=r.value;e.is(Hl)?t=t.update({add:[Fl.range(e.value,e.value+1)]}):e.is(Wl)&&(t=t.update({filter:function(t){return t!=e.value}}))};for(o.s();!(r=o.n()).done;)s()}catch(a){o.e(a)}finally{o.f()}return t}});function ql(){return[co.inputHandler.of(Kl),zl]}var jl="()[]{}<>";function _l(t){for(var e=0;e<jl.length;e+=2)if(jl.charCodeAt(e)==t)return jl.charAt(e+1);return B(t<128?t:t+1)}function Ul(t,e){return t.languageDataAt("closeBrackets",e)[0]||Vl}function Kl(t,e,n,i){if(t.composing)return!1;var r=t.state.selection.main;if(i.length>2||2==i.length&&1==L(R(i,0))||e!=r.from||n!=r.to)return!1;var o=function(t,e){var n,i=Ul(t,t.selection.main.head),r=i.brackets||Vl.brackets,o=y(r);try{for(o.s();!(n=o.n()).done;){var s=n.value,a=_l(R(s,0));if(e==s)return a==s?Ql(t,s,r.indexOf(s+s+s)>-1):Yl(t,s,a,i.before||Vl.before);if(e==a&&Jl(t,t.selection.main.from))return Xl(t,s,a)}}catch(u){o.e(u)}finally{o.f()}return null}(t.state,i);return!!o&&(t.dispatch(o),!0)}var Gl=[{key:"Backspace",run:function(t){var e=t.state,n=t.dispatch,i=Ul(e,e.selection.main.head).brackets||Vl.brackets,r=null,o=e.changeByRange((function(t){if(t.empty){var n,o=function(t,e){var n=t.sliceString(e-2,e);return L(R(n,0))==n.length?n:n.slice(1)}(e.doc,t.head),s=y(i);try{for(s.s();!(n=s.n()).done;){var a=n.value;if(a==o&&$l(e.doc,t.head)==_l(R(a,0)))return{changes:{from:t.head-a.length,to:t.head+a.length},range:it.cursor(t.head-a.length),userEvent:"delete.backward"}}}catch(u){s.e(u)}finally{s.f()}}return{range:r=t}}));return r||n(e.update(o,{scrollIntoView:!0})),!r}}];function Jl(t,e){var n=!1;return t.field(zl).between(0,t.doc.length,(function(t){t==e&&(n=!0)})),n}function $l(t,e){var n=t.sliceString(e,e+2);return n.slice(0,L(R(n,0)))}function Yl(t,e,n,i){var r=null,o=t.changeByRange((function(o){if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:Hl.of(o.to+e.length),range:it.range(o.anchor+e.length,o.head+e.length)};var s=$l(t.doc,o.head);return!s||/\s/.test(s)||i.indexOf(s)>-1?{changes:{insert:e+n,from:o.head},effects:Hl.of(o.head+e.length),range:it.cursor(o.head+e.length)}:{range:r=o}}));return r?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Xl(t,e,n){var i=null,r=t.selection.ranges.map((function(e){return e.empty&&$l(t.doc,e.head)==n?it.cursor(e.head+n.length):i=e}));return i?null:t.update({selection:it.create(r,t.selection.mainIndex),scrollIntoView:!0,effects:t.selection.ranges.map((function(t){var e=t.from;return Wl.of(e)}))})}function Ql(t,e,n){var i=null,r=t.changeByRange((function(r){if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:e,from:r.to}],effects:Hl.of(r.to+e.length),range:it.range(r.anchor+e.length,r.head+e.length)};var o=r.head,s=$l(t.doc,o);if(s==e){if(Zl(t,o))return{changes:{insert:e+e,from:o},effects:Hl.of(o+e.length),range:it.cursor(o+e.length)};if(Jl(t,o)){var a=n&&t.sliceDoc(o,o+3*e.length)==e+e+e;return{range:it.cursor(o+e.length*(a?3:1)),effects:Wl.of(o)}}}else{if(n&&t.sliceDoc(o-2*e.length,o)==e+e&&Zl(t,o-2*e.length))return{changes:{insert:e+e+e+e,from:o},effects:Hl.of(o+e.length),range:it.cursor(o+e.length)};if(t.charCategorizer(o)(s)!=Ut.Word){var u=t.sliceDoc(o-1,o);if(u!=e&&t.charCategorizer(o)(u)!=Ut.Word)return{changes:{insert:e+e,from:o},effects:Hl.of(o+e.length),range:it.cursor(o+e.length)}}}return{range:i=r}}));return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Zl(t,e){var n=ha(t).resolveInner(e+1);return n.parent&&n.from==e}var th=at.define({combine:function(t){var e,n,i,r=y(t);try{for(r.s();!(i=r.n()).done;){var o=i.value;e=e||o.topContainer,n=n||o.bottomContainer}}catch(s){r.e(s)}finally{r.f()}return{topContainer:e,bottomContainer:n}}});function eh(t,e){var n=t.plugin(nh),i=n?n.specs.indexOf(e):-1;return i>-1?n.panels[i]:null}var nh=ii.fromClass(function(){function t(e){k(this,t),this.input=e.state.facet(sh),this.specs=this.input.filter((function(t){return t})),this.panels=this.specs.map((function(t){return t(e)}));var n=e.state.facet(th);this.top=new ih(e,!0,n.topContainer),this.bottom=new ih(e,!1,n.bottomContainer),this.top.sync(this.panels.filter((function(t){return t.top}))),this.bottom.sync(this.panels.filter((function(t){return!t.top})));var i,r=y(this.panels);try{for(r.s();!(i=r.n()).done;){var o=i.value;o.dom.classList.add("cm-panel"),o.mount&&o.mount()}}catch(s){r.e(s)}finally{r.f()}}return b(t,[{key:"update",value:function(t){var e=t.state.facet(th);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ih(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ih(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();var n=t.state.facet(sh);if(n!=this.input){var i,r=n.filter((function(t){return t})),o=[],s=[],a=[],u=[],l=y(r);try{for(l.s();!(i=l.n()).done;){var h=i.value,c=this.specs.indexOf(h),f=void 0;c<0?(f=h(t.view),u.push(f)):(f=this.panels[c]).update&&f.update(t),o.push(f),(f.top?s:a).push(f)}}catch(w){l.e(w)}finally{l.f()}this.specs=r,this.panels=o,this.top.sync(s),this.bottom.sync(a);for(var d=0,v=u;d<v.length;d++){var p=v[d];p.dom.classList.add("cm-panel"),p.mount&&p.mount()}}else{var m,g=y(this.panels);try{for(g.s();!(m=g.n()).done;){var k=m.value;k.update&&k.update(t)}}catch(w){g.e(w)}finally{g.f()}}}},{key:"destroy",value:function(){this.top.sync([]),this.bottom.sync([])}}]),t}(),{provide:ti.scrollMargins.from((function(t){return{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}}))}),ih=function(){function t(e,n,i){k(this,t),this.view=e,this.top=n,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}return b(t,[{key:"sync",value:function(t){var e,n=y(this.panels);try{for(n.s();!(e=n.n()).done;){var i=e.value;i.destroy&&t.indexOf(i)<0&&i.destroy()}}catch(r){n.e(r)}finally{n.f()}this.panels=t,this.syncDOM()}},{key:"syncDOM",value:function(){if(0!=this.panels.length){if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";var t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}var e,n=this.dom.firstChild,i=y(this.panels);try{for(i.s();!(e=i.n()).done;){var r=e.value;if(r.dom.parentNode==this.dom){for(;n!=r.dom;)n=rh(n);n=n.nextSibling}else this.dom.insertBefore(r.dom,n)}}catch(o){i.e(o)}finally{i.f()}for(;n;)n=rh(n)}else this.dom&&(this.dom.remove(),this.dom=void 0)}},{key:"scrollMargin",value:function(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}},{key:"syncClasses",value:function(){if(this.container&&this.classes!=this.view.themeClasses){var t,e=y(this.classes.split(" "));try{for(e.s();!(t=e.n()).done;){var n=t.value;n&&this.container.classList.remove(n)}}catch(s){e.e(s)}finally{e.f()}var i,r=y((this.classes=this.view.themeClasses).split(" "));try{for(r.s();!(i=r.n()).done;){var o=i.value;o&&this.container.classList.add(o)}}catch(s){r.e(s)}finally{r.f()}}}}]),t}();function rh(t){var e=t.nextSibling;return t.remove(),e}var oh=co.baseTheme({".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"}}),sh=at.define({enables:[nh,oh]});function ah(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?t.setAttribute(i,r):null!=r&&(t[i]=r)}e++}for(;e<arguments.length;e++)uh(t,arguments[e]);return t}function uh(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var n=0;n<e.length;n++)uh(t,e[n])}}var lh="function"==typeof String.prototype.normalize?function(t){return t.normalize("NFKD")}:function(t){return t},hh=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length,o=arguments.length>4?arguments[4]:void 0;k(this,t),this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=o?function(t){return o(lh(t))}:lh,this.query=this.normalize(n)}return b(t,[{key:"peek",value:function(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return R(this.buffer,this.bufferPos)}},{key:"next",value:function(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}},{key:"nextOverlapping",value:function(){for(;;){var t=this.peek();if(t<0)return this.done=!0,this;var e=B(t),n=this.bufferStart+this.bufferPos;this.bufferPos+=L(t);for(var i=this.normalize(e),r=0,o=n;;r++){var s=i.charCodeAt(r),a=this.match(s,o);if(a)return this.value=a,this;if(r==i.length-1)break;o==n&&r<e.length&&e.charCodeAt(r)==s&&o++}}}},{key:"match",value:function(t,e){for(var n=null,i=0;i<this.matches.length;i+=2){var r=this.matches[i],o=!1;this.query.charCodeAt(r)==t&&(r==this.query.length-1?n={from:this.matches[i+1],to:e+1}:(this.matches[i]++,o=!0)),o||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?n={from:e,to:e+1}:this.matches.push(1,e)),n}}]),t}();"undefined"!=typeof Symbol&&(hh.prototype[Symbol.iterator]=function(){return this});var ch={from:-1,to:-1,match:/.*/.exec("")},fh="gm"+(null==/x/.unicode?"":"u"),dh=function(){function t(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.length;if(k(this,t),this.to=o,this.curLine="",this.done=!1,this.value=ch,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new mh(e,n,i,r,o);this.re=new RegExp(n,fh+((null===i||void 0===i?void 0:i.ignoreCase)?"i":"")),this.iter=e.iter();var s=e.lineAt(r);this.curLineStart=s.from,this.matchPos=r,this.getLine(this.curLineStart)}return b(t,[{key:"getLine",value:function(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}},{key:"nextLine",value:function(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}},{key:"next",value:function(){for(var t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;var e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){var n=this.curLineStart+e.index,i=n+e[0].length;if(this.matchPos=i+(n==i?1:0),n==this.curLine.length&&this.nextLine(),n<i||n>this.value.to)return this.value={from:n,to:i,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}]),t}(),vh=new WeakMap,ph=function(){function t(e,n){k(this,t),this.from=e,this.text=n}return b(t,[{key:"to",get:function(){return this.from+this.text.length}}],[{key:"get",value:function(e,n,i){var r=vh.get(e);if(!r||r.from>=i||r.to<=n){var o=new t(n,e.sliceString(n,i));return vh.set(e,o),o}if(r.from==n&&r.to==i)return r;var s=r.text,a=r.from;return a>n&&(s=e.sliceString(n,a)+s,a=n),r.to<i&&(s+=e.sliceString(r.to,i)),vh.set(e,new t(a,s)),new t(n,s.slice(n-a,i-a))}}]),t}(),mh=function(){function t(e,n,i,r,o){k(this,t),this.text=e,this.to=o,this.done=!1,this.value=ch,this.matchPos=r,this.re=new RegExp(n,fh+((null===i||void 0===i?void 0:i.ignoreCase)?"i":"")),this.flat=ph.get(e,r,this.chunkEnd(r+5e3))}return b(t,[{key:"chunkEnd",value:function(t){return t>=this.to?this.to:this.text.lineAt(t).to}},{key:"next",value:function(){for(;;){var t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e&&this.flat.to<this.to&&e.index+e[0].length>this.flat.text.length-10&&(e=null),e){var n=this.flat.from+e.index,i=n+e[0].length;return this.value={from:n,to:i,match:e},this.matchPos=i+(n==i?1:0),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ph.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}]),t}();function gh(t){var e=ah("input",{class:"cm-textfield",name:"line"});function n(){var n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(n){var i=t.state,r=i.doc.lineAt(i.selection.main.head),o=a(n,5),s=o[1],u=o[2],l=o[3],h=o[4],c=l?+l.slice(1):0,f=u?+u:r.number;if(u&&h){var d=f/100;s&&(d=d*("-"==s?-1:1)+r.number/i.doc.lines),f=Math.round(i.doc.lines*d)}else u&&s&&(f=f*("-"==s?-1:1)+r.number);var v=i.doc.line(Math.max(1,Math.min(i.doc.lines,f)));t.dispatch({effects:yh.of(!1),selection:it.cursor(v.from+Math.max(0,Math.min(c,v.length))),scrollIntoView:!0}),t.focus()}}return{dom:ah("form",{class:"cm-gotoLine",onkeydown:function(e){27==e.keyCode?(e.preventDefault(),t.dispatch({effects:yh.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),n())},onsubmit:function(t){t.preventDefault(),n()}},ah("label",t.state.phrase("Go to line"),": ",e)," ",ah("button",{class:"cm-button",type:"submit"},t.state.phrase("go"))),pos:-10}}"undefined"!=typeof Symbol&&(dh.prototype[Symbol.iterator]=mh.prototype[Symbol.iterator]=function(){return this});var yh=Nt.define(),kh=ct.define({create:function(){return!0},update:function(t,e){var n,i=y(e.effects);try{for(i.s();!(n=i.n()).done;){var r=n.value;r.is(yh)&&(t=r.value)}}catch(o){i.e(o)}finally{i.f()}return t},provide:function(t){return sh.from(t,(function(t){return t?gh:null}))}}),wh=co.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),bh={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100},xh=at.define({combine:function(t){return $t(t,bh,{highlightWordAroundCursor:function(t,e){return t||e},minSelectionLength:Math.min,maxMatches:Math.min})}});function Sh(t){var e=[Oh,Mh];return t&&e.push(xh.of(t)),e}var Ch=Tn.mark({class:"cm-selectionMatch"}),Ah=Tn.mark({class:"cm-selectionMatch cm-selectionMatch-main"}),Mh=ii.fromClass(function(){function t(e){k(this,t),this.decorations=this.getDeco(e)}return b(t,[{key:"update",value:function(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}},{key:"getDeco",value:function(t){var e=t.state.facet(xh),n=t.state,i=n.selection;if(i.ranges.length>1)return Tn.none;var r,o=i.main,s=null;if(o.empty){if(!e.highlightWordAroundCursor)return Tn.none;var a=n.wordAt(o.head);if(!a)return Tn.none;s=n.charCategorizer(o.head),r=n.sliceDoc(a.from,a.to)}else{var u=o.to-o.from;if(u<e.minSelectionLength||u>200)return Tn.none;if(!(r=n.sliceDoc(o.from,o.to).trim()))return Tn.none}var l,h=[],c=y(t.visibleRanges);try{for(c.s();!(l=c.n()).done;)for(var f=l.value,d=new hh(n.doc,r,f.from,f.to);!d.next().done;){var v=d.value,p=v.from,m=v.to;if((!s||(0==p||s(n.sliceDoc(p-1,p))!=Ut.Word)&&(m==n.doc.length||s(n.sliceDoc(m,m+1))!=Ut.Word))&&(s&&p<=o.from&&m>=o.to?h.push(Ah.range(p,m)):(p>=o.to||m<=o.from)&&h.push(Ch.range(p,m)),h.length>e.maxMatches))return Tn.none}}catch(g){c.e(g)}finally{c.f()}return Tn.set(h)}}]),t}(),{decorations:function(t){return t.decorations}}),Oh=co.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});var Dh=at.define({combine:function(t){var e;return{top:t.reduce((function(t,e){return null!==t&&void 0!==t?t:e.top}),void 0)||!1,caseSensitive:t.reduce((function(t,e){return null!==t&&void 0!==t?t:e.caseSensitive||e.matchCase}),void 0)||!1,createPanel:(null===(e=t.find((function(t){return t.createPanel})))||void 0===e?void 0:e.createPanel)||function(t){return new Xh(t)}}}});var Th=function(){function t(e){k(this,t),this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,fh),!0}catch(e){return!1}}(this.search))}return b(t,[{key:"eq",value:function(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp}},{key:"create",value:function(){return this.regexp?new Bh(this):new Rh(this)}}]),t}(),Eh=b((function t(e){k(this,t),this.spec=e})),Rh=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this,t)).unquoted=t.search.replace(/\\([nrt\\])/g,(function(t,e){return"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"})),i}return b(n,[{key:"cursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;return new hh(t,this.unquoted,e,n,this.spec.caseSensitive?void 0:function(t){return t.toLowerCase()})}},{key:"nextMatch",value:function(t,e,n){var i=this.cursor(t,n).nextOverlapping();return i.done&&(i=this.cursor(t,0,e).nextOverlapping()),i.done?null:i.value}},{key:"prevMatchInRange",value:function(t,e,n){for(var i=n;;){for(var r=Math.max(e,i-1e4-this.unquoted.length),o=this.cursor(t,r,i),s=null;!o.nextOverlapping().done;)s=o.value;if(s)return s;if(r==e)return null;i-=1e4}}},{key:"prevMatch",value:function(t,e,n){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,n,t.length)}},{key:"getReplacement",value:function(t){return this.spec.replace}},{key:"matchAll",value:function(t,e){for(var n=this.cursor(t),i=[];!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}},{key:"highlight",value:function(t,e,n,i){for(var r=this.cursor(t,Math.max(0,e-this.unquoted.length),Math.min(n+this.unquoted.length,t.length));!r.next().done;)i(r.value.from,r.value.to)}}]),n}(Eh),Bh=function(t){v(n,t);var e=g(n);function n(){return k(this,n),e.apply(this,arguments)}return b(n,[{key:"cursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;return new dh(t,this.spec.search,this.spec.caseSensitive?void 0:{ignoreCase:!0},e,n)}},{key:"nextMatch",value:function(t,e,n){var i=this.cursor(t,n).next();return i.done&&(i=this.cursor(t,0,e).next()),i.done?null:i.value}},{key:"prevMatchInRange",value:function(t,e,n){for(var i=1;;i++){for(var r=Math.max(e,n-1e4*i),o=this.cursor(t,r,n),s=null;!o.next().done;)s=o.value;if(s&&(r==e||s.from>r+10))return s;if(r==e)return null}}},{key:"prevMatch",value:function(t,e,n){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,n,t.length)}},{key:"getReplacement",value:function(t){return this.spec.replace.replace(/\$([$&\d+])/g,(function(e,n){return"$"==n?"$":"&"==n?t.match[0]:"0"!=n&&+n<t.match.length?t.match[n]:e}))}},{key:"matchAll",value:function(t,e){for(var n=this.cursor(t),i=[];!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}},{key:"highlight",value:function(t,e,n,i){for(var r=this.cursor(t,Math.max(0,e-250),Math.min(n+250,t.length));!r.next().done;)i(r.value.from,r.value.to)}}]),n}(Eh),Lh=Nt.define(),Ph=Nt.define(),Ih=ct.define({create:function(t){return new Nh(Gh(t).create(),null)},update:function(t,e){var n,i=y(e.effects);try{for(i.s();!(n=i.n()).done;){var r=n.value;r.is(Lh)?t=new Nh(r.value.create(),t.panel):r.is(Ph)&&(t=new Nh(t.query,r.value?Kh:null))}}catch(o){i.e(o)}finally{i.f()}return t},provide:function(t){return sh.from(t,(function(t){return t.panel}))}});var Nh=b((function t(e,n){k(this,t),this.query=e,this.panel=n})),Vh=Tn.mark({class:"cm-searchMatch"}),Hh=Tn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Wh=ii.fromClass(function(){function t(e){k(this,t),this.view=e,this.decorations=this.highlight(e.state.field(Ih))}return b(t,[{key:"update",value:function(t){var e=t.state.field(Ih);(e!=t.startState.field(Ih)||t.docChanged||t.selectionSet)&&(this.decorations=this.highlight(e))}},{key:"highlight",value:function(t){var e=t.query;if(!t.panel||!e.spec.valid)return Tn.none;for(var n=this.view,i=new ue,r=0,o=n.visibleRanges,s=o.length;r<s;r++){for(var a=o[r],u=a.from,l=a.to;r<s-1&&l>o[r+1].from-500;)l=o[++r].to;e.highlight(n.state.doc,u,l,(function(t,e){var r=n.state.selection.ranges.some((function(n){return n.from==t&&n.to==e}));i.add(t,e,r?Hh:Vh)}))}return i.finish()}}]),t}(),{decorations:function(t){return t.decorations}});function Fh(t){return function(e){var n=e.state.field(Ih,!1);return n&&n.query.spec.valid?t(e,n):Jh(e)}}var zh=Fh((function(t,e){var n=e.query,i=t.state.selection.main,r=i.from,o=i.to,s=n.nextMatch(t.state.doc,r,o);return!(!s||s.from==r&&s.to==o)&&(t.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:tc(t,s),userEvent:"select.search"}),!0)})),qh=Fh((function(t,e){var n=e.query,i=t.state,r=i.selection.main,o=r.from,s=r.to,a=n.prevMatch(i.doc,o,s);return!!a&&(t.dispatch({selection:{anchor:a.from,head:a.to},scrollIntoView:!0,effects:tc(t,a),userEvent:"select.search"}),!0)})),jh=Fh((function(t,e){var n=e.query.matchAll(t.state.doc,1e3);return!(!n||!n.length)&&(t.dispatch({selection:it.create(n.map((function(t){return it.range(t.from,t.to)}))),userEvent:"select.search.matches"}),!0)})),_h=Fh((function(t,e){var n=e.query,i=t.state,r=i.selection.main,o=r.from,s=r.to;if(i.readOnly)return!1;var a=n.nextMatch(i.doc,o,o);if(!a)return!1;var u,l,h=[];if(a.from==o&&a.to==s&&(l=i.toText(n.getReplacement(a)),h.push({from:a.from,to:a.to,insert:l}),a=n.nextMatch(i.doc,a.from,a.to)),a){var c=0==h.length||h[0].from>=a.to?0:a.to-a.from-l.length;u={anchor:a.from-c,head:a.to-c}}return t.dispatch({changes:h,selection:u,scrollIntoView:!!u,effects:a?tc(t,a):void 0,userEvent:"input.replace"}),!0})),Uh=Fh((function(t,e){var n=e.query;if(t.state.readOnly)return!1;var i=n.matchAll(t.state.doc,1e9).map((function(t){return{from:t.from,to:t.to,insert:n.getReplacement(t)}}));return!!i.length&&(t.dispatch({changes:i,userEvent:"input.replace.all"}),!0)}));function Kh(t){return t.state.facet(Dh).createPanel(t)}function Gh(t,e){var n,i=t.selection.main,r=i.empty||i.to>i.from+100?"":t.sliceDoc(i.from,i.to),o=null!==(n=null===e||void 0===e?void 0:e.caseSensitive)&&void 0!==n?n:t.facet(Dh).caseSensitive;return e&&!r?e:new Th({search:r.replace(/\n/g,"\\n"),caseSensitive:o})}var Jh=function(t){var e=t.state.field(Ih,!1);if(e&&e.panel){var n=eh(t,Kh);if(!n)return!1;var i=n.dom.querySelector("[name=search]");if(i!=t.root.activeElement){var r=Gh(t.state,e.query.spec);r.valid&&t.dispatch({effects:Lh.of(r)}),i.focus(),i.select()}}else t.dispatch({effects:[Ph.of(!0),e?Lh.of(Gh(t.state,e.query.spec)):Nt.appendConfig.of(nc)]});return!0},$h=function(t){var e=t.state.field(Ih,!1);if(!e||!e.panel)return!1;var n=eh(t,Kh);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Ph.of(!1)}),!0},Yh=[{key:"Mod-f",run:Jh,scope:"editor search-panel"},{key:"F3",run:zh,shift:qh,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:zh,shift:qh,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:$h,scope:"editor search-panel"},{key:"Mod-Shift-l",run:function(t){var e=t.state,n=t.dispatch,i=e.selection;if(i.ranges.length>1||i.main.empty)return!1;for(var r=i.main,o=r.from,s=r.to,a=[],u=0,l=new hh(e.doc,e.sliceDoc(o,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==o&&(u=a.length),a.push(it.range(l.value.from,l.value.to))}return n(e.update({selection:it.create(a,u),userEvent:"select.search.matches"})),!0}},{key:"Alt-g",run:function(t){var e=eh(t,gh);if(!e){var n=[yh.of(!0)];null==t.state.field(kh,!1)&&n.push(Nt.appendConfig.of([kh,wh])),t.dispatch({effects:n}),e=eh(t,gh)}return e&&e.dom.querySelector("input").focus(),!0}},{key:"Mod-d",run:function(t){var e=t.state,n=t.dispatch,i=e.selection.ranges;if(i.some((function(t){return t.from===t.to})))return function(t){var e=t.state,n=t.dispatch,i=e.selection,r=it.create(i.ranges.map((function(t){return e.wordAt(t.head)||it.cursor(t.head)})),i.mainIndex);return!r.eq(i)&&(n(e.update({selection:r})),!0)}({state:e,dispatch:n});var r=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some((function(t){return e.sliceDoc(t.from,t.to)!=r})))return!1;var o=function(t,e){for(var n=t.selection,i=n.main,r=n.ranges,o=t.wordAt(i.head),s=o&&o.from==i.from&&o.to==i.to,a=function(n,i){if(i.next(),!i.done){if(n&&r.some((function(t){return t.from==i.value.from})))return l=i,u=n,"continue";if(s){var o=t.wordAt(i.value.from);if(!o||o.from!=i.value.from||o.to!=i.value.to)return l=i,u=n,"continue"}return u=n,l=i,{v:i.value}}if(n)return l=i,u=n,{v:null};i=new hh(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),u=n=!0,l=i},u=!1,l=new hh(t.doc,e,r[r.length-1].to);;){var h=a(u,l);if("continue"!==h&&"object"===typeof h)return h.v}}(e,r);return!!o&&(n(e.update({selection:e.selection.addRange(it.range(o.from,o.to),!1),effects:co.scrollIntoView(o.to)})),!0)},preventDefault:!0}],Xh=function(){function t(e){var n=this;k(this,t),this.view=e;var i=this.query=e.state.field(Ih).query.spec;function r(t,e,n){return ah("button",{class:"cm-button",name:t,onclick:e,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=ah("input",{value:i.search,placeholder:Qh(e,"Find"),"aria-label":Qh(e,"Find"),class:"cm-textfield",name:"search",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ah("input",{value:i.replace,placeholder:Qh(e,"Replace"),"aria-label":Qh(e,"Replace"),class:"cm-textfield",name:"replace",onchange:this.commit,onkeyup:this.commit}),this.caseField=ah("input",{type:"checkbox",name:"case",checked:i.caseSensitive,onchange:this.commit}),this.reField=ah("input",{type:"checkbox",name:"re",checked:i.regexp,onchange:this.commit}),this.dom=ah("div",{onkeydown:function(t){return n.keydown(t)},class:"cm-search"},[this.searchField,r("next",(function(){return zh(e)}),[Qh(e,"next")]),r("prev",(function(){return qh(e)}),[Qh(e,"previous")]),r("select",(function(){return jh(e)}),[Qh(e,"all")]),ah("label",null,[this.caseField,Qh(e,"match case")]),ah("label",null,[this.reField,Qh(e,"regexp")])].concat(u(e.state.readOnly?[]:[ah("br"),this.replaceField,r("replace",(function(){return _h(e)}),[Qh(e,"replace")]),r("replaceAll",(function(){return Uh(e)}),[Qh(e,"replace all")]),ah("button",{name:"close",onclick:function(){return $h(e)},"aria-label":Qh(e,"close"),type:"button"},["\xd7"])])))}return b(t,[{key:"commit",value:function(){var t=new Th({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Lh.of(t)}))}},{key:"keydown",value:function(t){Do(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?qh:zh)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),_h(this.view))}},{key:"update",value:function(t){var e,n=y(t.transactions);try{for(n.s();!(e=n.n()).done;){var i,r=y(e.value.effects);try{for(r.s();!(i=r.n()).done;){var o=i.value;o.is(Lh)&&!o.value.eq(this.query)&&this.setQuery(o.value)}}catch(s){r.e(s)}finally{r.f()}}}catch(s){n.e(s)}finally{n.f()}}},{key:"setQuery",value:function(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp}},{key:"mount",value:function(){this.searchField.select()}},{key:"pos",get:function(){return 80}},{key:"top",get:function(){return this.view.state.facet(Dh).top}}]),t}();function Qh(t,e){return t.state.phrase(e)}var Zh=/[\s\.,:;?!]/;function tc(t,e){var n=e.from,i=e.to,r=t.state.doc.lineAt(n).from,o=t.state.doc.lineAt(i).to,s=Math.max(r,n-30),a=Math.min(o,i+30),u=t.state.sliceDoc(s,a);if(s!=r)for(var l=0;l<30;l++)if(!Zh.test(u[l+1])&&Zh.test(u[l])){u=u.slice(l);break}if(a!=o)for(var h=u.length-1;h>u.length-30;h--)if(!Zh.test(u[h-1])&&Zh.test(u[h])){u=u.slice(0,h);break}return co.announce.of("".concat(t.state.phrase("current match"),". ").concat(u," ").concat(t.state.phrase("on line")," ").concat(t.state.doc.lineAt(n).number))}var ec=co.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),nc=[Ih,yt.lowest(Wh),ec],ic="undefined"!=typeof navigator&&!/Edge\/(\d+)/.exec(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)&&(/Mobile\/\w+/.test(navigator.userAgent)||navigator.maxTouchPoints>2),rc="-10000px",oc=function(){function t(e,n,i){k(this,t),this.facet=n,this.createTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter((function(t){return t})),this.tooltipViews=this.tooltips.map(i)}return b(t,[{key:"update",value:function(t){var e=t.state.facet(this.facet),n=e.filter((function(t){return t}));if(e===this.input){var i,r=y(this.tooltipViews);try{for(r.s();!(i=r.n()).done;){var o=i.value;o.update&&o.update(t)}}catch(m){r.e(m)}finally{r.f()}return!1}for(var s=[],a=0;a<n.length;a++){var u=n[a],l=-1;if(u){for(var h=0;h<this.tooltips.length;h++){var c=this.tooltips[h];c&&c.create==u.create&&(l=h)}if(l<0)s[a]=this.createTooltipView(u);else{var f=s[a]=this.tooltipViews[l];f.update&&f.update(t)}}}var d,v=y(this.tooltipViews);try{for(v.s();!(d=v.n()).done;){var p=d.value;s.indexOf(p)<0&&p.dom.remove()}}catch(m){v.e(m)}finally{v.f()}return this.input=e,this.tooltips=n,this.tooltipViews=s,!0}}]),t}();function sc(){return{top:0,left:0,bottom:innerHeight,right:innerWidth}}var ac=at.define({combine:function(t){var e,n,i;return{position:ic?"absolute":(null===(e=t.find((function(t){return t.position})))||void 0===e?void 0:e.position)||"fixed",parent:(null===(n=t.find((function(t){return t.parent})))||void 0===n?void 0:n.parent)||null,tooltipSpace:(null===(i=t.find((function(t){return t.tooltipSpace})))||void 0===i?void 0:i.tooltipSpace)||sc}}}),uc=ii.fromClass(function(){function t(e){var n,i=this;k(this,t),this.view=e,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;var r=e.state.facet(ac);this.position=r.position,this.parent=r.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new oc(e,cc,(function(t){return i.createTooltip(t)})),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver((function(t){Date.now()>i.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&i.measureSoon()}),{threshold:[1]}):null,this.observeIntersection(),null===(n=e.dom.ownerDocument.defaultView)||void 0===n||n.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}return b(t,[{key:"createContainer",value:function(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}},{key:"observeIntersection",value:function(){if(this.intersectionObserver){this.intersectionObserver.disconnect();var t,e=y(this.manager.tooltipViews);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.intersectionObserver.observe(n.dom)}}catch(i){e.e(i)}finally{e.f()}}}},{key:"measureSoon",value:function(){var t=this;this.measureTimeout<0&&(this.measureTimeout=setTimeout((function(){t.measureTimeout=-1,t.maybeMeasure()}),50))}},{key:"update",value:function(t){t.transactions.length&&(this.lastTransaction=Date.now());var e=this.manager.update(t);e&&this.observeIntersection();var n=e||t.geometryChanged,i=t.state.facet(ac);if(i.position!=this.position){this.position=i.position;var r,o=y(this.manager.tooltipViews);try{for(o.s();!(r=o.n()).done;){r.value.dom.style.position=this.position}}catch(l){o.e(l)}finally{o.f()}n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();var s,a=y(this.manager.tooltipViews);try{for(a.s();!(s=a.n()).done;){var u=s.value;this.container.appendChild(u.dom)}}catch(l){a.e(l)}finally{a.f()}n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}},{key:"createTooltip",value:function(t){var e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){var n=document.createElement("div");n.className="cm-tooltip-arrow",e.dom.appendChild(n)}return e.dom.style.position=this.position,e.dom.style.top=rc,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}},{key:"destroy",value:function(){var t,e;null===(t=this.view.dom.ownerDocument.defaultView)||void 0===t||t.removeEventListener("resize",this.measureSoon);var n,i=y(this.manager.tooltipViews);try{for(i.s();!(n=i.n()).done;){n.value.dom.remove()}}catch(r){i.e(r)}finally{i.f()}null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}},{key:"readMeasure",value:function(){var t=this,e=this.view.dom.getBoundingClientRect();return{editor:e,parent:this.parent?this.container.getBoundingClientRect():e,pos:this.manager.tooltips.map((function(e){return t.view.coordsAtPos(e.pos)})),size:this.manager.tooltipViews.map((function(t){return t.dom.getBoundingClientRect()})),space:this.view.state.facet(ac).tooltipSpace(this.view)}}},{key:"writeMeasure",value:function(t){for(var e=t.editor,n=t.space,i=[],r=0;r<this.manager.tooltips.length;r++){var o=this.manager.tooltips[r],s=this.manager.tooltipViews[r],a=s.dom,u=t.pos[r],l=t.size[r];if(!u||u.bottom<=Math.max(e.top,n.top)||u.top>=Math.min(e.bottom,n.bottom)||u.right<Math.max(e.left,n.left)-.1||u.left>Math.min(e.right,n.right)+.1)a.style.top=rc;else{var h=o.arrow?s.dom.querySelector(".cm-tooltip-arrow"):null,c=h?7:0,f=l.right-l.left,d=l.bottom-l.top,v=s.offset||hc,p=this.view.textDirection==fi.LTR,m=l.width>n.right-n.left?p?n.left:n.right-l.width:p?Math.min(u.left-(h?14:0)+v.x,n.right-f):Math.max(n.left,u.left-f+(h?14:0)-v.x),g=!!o.above;!o.strictSide&&(g?u.top-(l.bottom-l.top)-v.y<n.top:u.bottom+(l.bottom-l.top)+v.y>n.bottom)&&g==n.bottom-u.bottom>u.top-n.top&&(g=!g);var k=g?u.top-d-c-v.y:u.bottom+c+v.y,w=m+f;if(!0!==s.overlap){var b,x=y(i);try{for(x.s();!(b=x.n()).done;){var S=b.value;S.left<w&&S.right>m&&S.top<k+d&&S.bottom>k&&(k=g?S.top-d-2-c:S.bottom+c+2)}}catch(C){x.e(C)}finally{x.f()}}"absolute"==this.position?(a.style.top=k-t.parent.top+"px",a.style.left=m-t.parent.left+"px"):(a.style.top=k+"px",a.style.left=m+"px"),h&&(h.style.left="".concat(u.left+(p?v.x:-v.x)-(m+14-7),"px")),!0!==s.overlap&&i.push({left:m,top:k,right:w,bottom:k+d}),a.classList.toggle("cm-tooltip-above",g),a.classList.toggle("cm-tooltip-below",!g),s.positioned&&s.positioned()}}}},{key:"maybeMeasure",value:function(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView))){var t,e=y(this.manager.tooltipViews);try{for(e.s();!(t=e.n()).done;){t.value.dom.style.top=rc}}catch(n){e.e(n)}finally{e.f()}}}}]),t}(),{eventHandlers:{scroll:function(){this.maybeMeasure()}}}),lc=co.baseTheme({".cm-tooltip":{zIndex:100},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"".concat(7,"px"),width:"".concat(14,"px"),position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"".concat(7,"px solid transparent"),borderRight:"".concat(7,"px solid transparent")},".cm-tooltip-above &":{bottom:"-".concat(7,"px"),"&:before":{borderTop:"".concat(7,"px solid #bbb")},"&:after":{borderTop:"".concat(7,"px solid #f5f5f5"),bottom:"1px"}},".cm-tooltip-below &":{top:"-".concat(7,"px"),"&:before":{borderBottom:"".concat(7,"px solid #bbb")},"&:after":{borderBottom:"".concat(7,"px solid #f5f5f5"),top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),hc={x:0,y:0},cc=at.define({enables:[uc,lc]}),fc=at.define(),dc=function(){function t(e){var n=this;k(this,t),this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new oc(e,fc,(function(t){return n.createHostedView(t)}))}return b(t,[{key:"createHostedView",value:function(t){var e=t.create(this.view);return e.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(e.dom),this.mounted&&e.mount&&e.mount(this.view),e}},{key:"mount",value:function(t){var e,n=y(this.manager.tooltipViews);try{for(n.s();!(e=n.n()).done;){var i=e.value;i.mount&&i.mount(t)}}catch(r){n.e(r)}finally{n.f()}this.mounted=!0}},{key:"positioned",value:function(){var t,e=y(this.manager.tooltipViews);try{for(e.s();!(t=e.n()).done;){var n=t.value;n.positioned&&n.positioned()}}catch(i){e.e(i)}finally{e.f()}}},{key:"update",value:function(t){this.manager.update(t)}}],[{key:"create",value:function(e){return new t(e)}}]),t}(),vc=cc.compute([fc],(function(t){var e=t.facet(fc).filter((function(t){return t}));return 0===e.length?null:{pos:Math.min.apply(Math,u(e.map((function(t){return t.pos})))),end:Math.max.apply(Math,u(e.filter((function(t){return null!=t.end})).map((function(t){return t.end})))),create:dc.create,above:e[0].above,arrow:e.some((function(t){return t.arrow}))}})),pc=function(){function t(e,n,i,r,o){k(this,t),this.view=e,this.source=n,this.field=i,this.setHover=r,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}return b(t,[{key:"update",value:function(){var t=this;this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout((function(){return t.startHover()}),20))}},{key:"active",get:function(){return this.view.state.field(this.field)}},{key:"checkHover",value:function(){if(this.hoverTimeout=-1,!this.active){var t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}}},{key:"startHover",value:function(){var t,e=this;clearTimeout(this.restartTimeout);var n=this.lastMove,i=this.view.contentDOM.contains(n.target)?this.view.posAtCoords(n):null;if(null!=i){var r=this.view.coordsAtPos(i);if(!(null==r||n.y<r.top||n.y>r.bottom||n.x<r.left-this.view.defaultCharacterWidth||n.x>r.right+this.view.defaultCharacterWidth)){var o=this.view.bidiSpans(this.view.state.doc.lineAt(i)).find((function(t){return t.from<=i&&t.to>=i})),s=o&&o.dir==fi.RTL?-1:1,a=this.source(this.view,i,n.x<r.left?-s:s);if(null===(t=a)||void 0===t?void 0:t.then){var u=this.pending={pos:i};a.then((function(t){e.pending==u&&(e.pending=null,t&&e.view.dispatch({effects:e.setHover.of(t)}))}),(function(t){return Xn(e.view.state,t,"hover tooltip")}))}else a&&this.view.dispatch({effects:this.setHover.of(a)})}}}},{key:"mousemove",value:function(t){var e;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));var n=this.active;if(n&&!function(t){for(var e=t;e;e=e.parentNode)if(1==e.nodeType&&e.classList.contains("cm-tooltip"))return!0;return!1}(this.lastMove.target)||this.pending){var i=(n||this.pending).pos,r=null!==(e=null===n||void 0===n?void 0:n.end)&&void 0!==e?e:i;(i==r?this.view.posAtCoords(this.lastMove)==i:function(t,e,n,i,r,o){var s=document.createRange(),a=t.domAtPos(e),u=t.domAtPos(n);s.setEnd(u.node,u.offset),s.setStart(a.node,a.offset);var l=s.getClientRects();s.detach();for(var h=0;h<l.length;h++){var c=l[h];if(Math.max(c.top-r,r-c.bottom,c.left-i,i-c.right)<=o)return!0}return!1}(this.view,i,r,t.clientX,t.clientY,6))||(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}},{key:"mouseleave",value:function(){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&this.view.dispatch({effects:this.setHover.of(null)})}},{key:"destroy",value:function(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}]),t}();function mc(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Nt.define(),i=ct.define({create:function(){return null},update:function(t,i){if(t&&e.hideOnChange&&(i.docChanged||i.selection))return null;var r,o=y(i.effects);try{for(o.s();!(r=o.n()).done;){var s=r.value;if(s.is(n))return s.value;if(s.is(yc))return null}}catch(l){o.e(l)}finally{o.f()}if(t&&i.docChanged){var a=i.changes.mapPos(t.pos,-1,G.TrackDel);if(null==a)return null;var u=Object.assign(Object.create(null),t);return u.pos=a,null!=t.end&&(u.end=i.changes.mapPos(t.end)),u}return t},provide:function(t){return fc.from(t)}}),r=e.hoverTime||600;return[i,ii.define((function(e){return new pc(e,t,i,n,r)})),vc]}function gc(t,e){var n=t.plugin(uc);if(!n)return null;var i=n.manager.tooltips.indexOf(e);return i<0?null:n.manager.tooltipViews[i]}var yc=Nt.define();var kc=function(){function t(e,n,i){k(this,t),this.state=e,this.pos=n,this.explicit=i,this.abortListeners=[]}return b(t,[{key:"tokenBefore",value:function(t){for(var e=ha(this.state).resolveInner(this.pos,-1);e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}},{key:"matchBefore",value:function(t){var e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),r=i.search(Cc(t,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}},{key:"aborted",get:function(){return null==this.abortListeners}},{key:"addEventListener",value:function(t,e){"abort"==t&&this.abortListeners&&this.abortListeners.push(e)}}]),t}();function wc(t){var e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),"[".concat(n?"\\w":"").concat(e.replace(/[^\w\s]/g,"\\$&"),"]")}function bc(t){var e=t.map((function(t){return"string"==typeof t?{label:t}:t})),n=e.every((function(t){return/^\w+$/.test(t.label)}))?[/\w*$/,/\w+$/]:function(t){var e,n=Object.create(null),i=Object.create(null),r=y(t);try{for(r.s();!(e=r.n()).done;){var o=e.value.label;n[o[0]]=!0;for(var s=1;s<o.length;s++)i[o[s]]=!0}}catch(u){r.e(u)}finally{r.f()}var a=wc(n)+wc(i)+"*$";return[new RegExp("^"+a),new RegExp(a)]}(e),i=a(n,2),r=i[0],o=i[1];return function(t){var n=t.matchBefore(o);return n||t.explicit?{from:n?n.from:t.pos,options:e,span:r}:null}}var xc=b((function t(e,n,i){k(this,t),this.completion=e,this.source=n,this.match=i}));function Sc(t){return t.selection.main.head}function Cc(t,e){var n,i=t.source,r=e&&"^"!=i[0],o="$"!=i[i.length-1];return r||o?new RegExp("".concat(r?"^":"","(?:").concat(i,")").concat(o?"$":""),null!==(n=t.flags)&&void 0!==n?n:t.ignoreCase?"i":""):t}var Ac=Lt.define();function Mc(t,e){var n=e.completion.apply||e.completion.label,i=e.source;"string"==typeof n?t.dispatch({changes:{from:i.from,to:i.to,insert:n},selection:{anchor:i.from+n.length},userEvent:"input.complete",annotations:Ac.of(e.completion)}):n(t,e.completion,i.from,i.to)}var Oc=new WeakMap;function Dc(t){if(!Array.isArray(t))return t;var e=Oc.get(t);return e||Oc.set(t,e=bc(t)),e}var Tc=function(){function t(e){k(this,t),this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(var n=0;n<e.length;){var i=R(e,n),r=L(i);this.chars.push(i);var o=e.slice(n,n+r),s=o.toUpperCase();this.folded.push(R(s==o?o.toLowerCase():s,0)),n+=r}this.astral=e.length!=this.chars.length}return b(t,[{key:"match",value:function(t){if(0==this.pattern.length)return[0];if(t.length<this.pattern.length)return null;var e=this.chars,n=this.folded,i=this.any,r=this.precise,o=this.byWord;if(1==e.length){var s=R(t,0);return s==e[0]?[0,0,L(s)]:s==n[0]?[-200,0,L(s)]:null}var a=t.indexOf(this.pattern);if(0==a)return[0,0,this.pattern.length];var u=e.length,l=0;if(a<0){for(var h=0,c=Math.min(t.length,200);h<c&&l<u;){var f=R(t,h);f!=e[l]&&f!=n[l]||(i[l++]=h),h+=L(f)}if(l<u)return null}for(var d=0,v=0,p=!1,m=0,g=-1,y=-1,k=/[a-z]/.test(t),w=!0,b=0,x=Math.min(t.length,200),S=0;b<x&&v<u;){var C=R(t,b);a<0&&(d<u&&C==e[d]&&(r[d++]=b),m<u&&(C==e[m]||C==n[m]?(0==m&&(g=b),y=b+1,m++):m=0));var A=void 0,M=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(A=B(C))!=A.toLowerCase()?1:A!=A.toUpperCase()?2:0;(!b||1==M&&k||0==S&&0!=M)&&(e[v]==C||n[v]==C&&(p=!0)?o[v++]=b:o.length&&(w=!1)),S=M,b+=L(C)}return v==u&&0==o[0]&&w?this.result((p?-200:0)-100,o,t):m==u&&0==g?[-200-t.length,0,y]:a>-1?[-700-t.length,a,a+this.pattern.length]:m==u?[-900-t.length,g,y]:v==u?this.result((p?-200:0)-100-700+(w?0:-1100),o,t):2==e.length?null:this.result((i[0]?-700:0)-200-1100,i,t)}},{key:"result",value:function(t,e,n){var i,r=[t-n.length],o=1,s=y(e);try{for(s.s();!(i=s.n()).done;){var a=i.value,u=a+(this.astral?L(R(n,a)):1);o>1&&r[o-1]==a?r[o-1]=u:(r[o++]=a,r[o++]=u)}}catch(l){s.e(l)}finally{s.f()}return r}}]),t}(),Ec=at.define({combine:function(t){return $t(t,{activateOnTyping:!0,override:null,maxRenderedOptions:100,defaultKeymap:!0,optionClass:function(){return""},aboveCursor:!1,icons:!0,addToOptions:[]},{defaultKeymap:function(t,e){return t&&e},icons:function(t,e){return t&&e},optionClass:function(t,e){return function(n){return function(t,e){return t?e?t+" "+e:t:e}(t(n),e(n))}},addToOptions:function(t,e){return t.concat(e)}})}});function Rc(t,e,n){if(t<=n)return{from:0,to:t};if(e<=t>>1){var i=Math.floor(e/n);return{from:i*n,to:(i+1)*n}}var r=Math.floor((t-e)/n);return{from:t-(r+1)*n,to:t-r*n}}var Bc=function(){function t(e,n){var i=this;k(this,t),this.view=e,this.stateField=n,this.info=null,this.placeInfo={read:function(){return i.measureInfo()},write:function(t){return i.positionInfo(t)},key:this};var r=e.state.field(n),o=r.open,s=o.options,a=o.selected,l=e.state.facet(Ec);this.optionContent=function(t){var e=t.addToOptions.slice();return t.icons&&e.push({render:function(t){var e,n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&(e=n.classList).add.apply(e,u(t.type.split(/\s+/g).map((function(t){return"cm-completionIcon-"+t})))),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render:function(t,e,n){var i=document.createElement("span");i.className="cm-completionLabel";for(var r=t.label,o=0,s=1;s<n.length;){var a=n[s++],u=n[s++];a>o&&i.appendChild(document.createTextNode(r.slice(o,a)));var l=i.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(a,u))),l.className="cm-completionMatchedText",o=u}return o<r.length&&i.appendChild(document.createTextNode(r.slice(o))),i},position:50},{render:function(t){if(!t.detail)return null;var e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort((function(t,e){return t.position-e.position})).map((function(t){return t.render}))}(l),this.optionClass=l.optionClass,this.range=Rc(s.length,a,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.dom.addEventListener("mousedown",(function(t){for(var n,r=t.target;r&&r!=i.dom;r=r.parentNode)if("LI"==r.nodeName&&(n=/-(\d+)$/.exec(r.id))&&+n[1]<s.length)return Mc(e,s[+n[1]]),void t.preventDefault()})),this.list=this.dom.appendChild(this.createListBox(s,r.id,this.range)),this.list.addEventListener("scroll",(function(){i.info&&i.view.requestMeasure(i.placeInfo)}))}return b(t,[{key:"mount",value:function(){this.updateSel()}},{key:"update",value:function(t){t.state.field(this.stateField)!=t.startState.field(this.stateField)&&this.updateSel()}},{key:"positioned",value:function(){this.info&&this.view.requestMeasure(this.placeInfo)}},{key:"updateSel",value:function(){var t=this,e=this.view.state.field(this.stateField),n=e.open;if((n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=Rc(n.options.length,n.selected,this.view.state.facet(Ec).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(n.options,e.id,this.range)),this.list.addEventListener("scroll",(function(){t.info&&t.view.requestMeasure(t.placeInfo)}))),this.updateSelectedOption(n.selected)){this.info&&(this.info.remove(),this.info=null);var i=n.options[n.selected];i.completion.info&&(this.info=this.dom.appendChild(function(t,e){var n=document.createElement("div");n.className="cm-tooltip cm-completionInfo";var i=t.completion.info;if("string"==typeof i)n.textContent=i;else{var r=i(t.completion);r.then?r.then((function(t){return n.appendChild(t)}),(function(t){return Xn(e.state,t,"completion info")})):n.appendChild(r)}return n}(i,this.view)),this.view.requestMeasure(this.placeInfo))}}},{key:"updateSelectedOption",value:function(t){for(var e=null,n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)i==t?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),e=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return e&&function(t,e){var n=t.getBoundingClientRect(),i=e.getBoundingClientRect();i.top<n.top?t.scrollTop-=n.top-i.top:i.bottom>n.bottom&&(t.scrollTop+=i.bottom-n.bottom)}(this.list,e),e}},{key:"measureInfo",value:function(){var t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;var e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=t.getBoundingClientRect();if(i.top>Math.min(innerHeight,e.bottom)-10||i.bottom<Math.max(0,e.top)+10)return null;var r=Math.max(0,Math.min(i.top,innerHeight-n.height))-e.top,o=this.view.textDirection==fi.RTL,s=e.left,a=innerWidth-e.right;return o&&s<Math.min(n.width,a)?o=!1:!o&&a<Math.min(n.width,s)&&(o=!0),{top:r,left:o}}},{key:"positionInfo",value:function(t){this.info&&(this.info.style.top=(t?t.top:-1e6)+"px",t&&(this.info.classList.toggle("cm-completionInfo-left",t.left),this.info.classList.toggle("cm-completionInfo-right",!t.left)))}},{key:"createListBox",value:function(t,e,n){var i=document.createElement("ul");i.id=e,i.setAttribute("role","listbox");for(var r=n.from;r<n.to;r++){var o=t[r],s=o.completion,a=o.match,u=i.appendChild(document.createElement("li"));u.id=e+"-"+r,u.setAttribute("role","option");var l=this.optionClass(s);l&&(u.className=l);var h,c=y(this.optionContent);try{for(c.s();!(h=c.n()).done;){var f=(0,h.value)(s,this.view.state,a);f&&u.appendChild(f)}}catch(d){c.e(d)}finally{c.f()}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}}]),t}();function Lc(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}var Pc=function(){function t(e,n,i,r,o){k(this,t),this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=o}return b(t,[{key:"setSelected",value:function(e,n){return e==this.selected||e>=this.options.length?this:new t(this.options,Vc(n,e),this.tooltip,this.timestamp,e)}},{key:"map",value:function(e){return new t(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected)}}],[{key:"build",value:function(e,n,i,r,o){var s=function(t,e){var n,i=[],r=0,o=y(t);try{for(o.s();!(n=o.n()).done;){var s=n.value;if(s.hasResult())if(!1===s.result.filter){var a,u=y(s.result.options);try{for(u.s();!(a=u.n()).done;){var l=a.value;i.push(new xc(l,s,[1e9-r++]))}}catch(b){u.e(b)}finally{u.f()}}else{var h,c=new Tc(e.sliceDoc(s.from,s.to)),f=void 0,d=y(s.result.options);try{for(d.s();!(h=d.n()).done;){var v=h.value;(f=c.match(v.label))&&(null!=v.boost&&(f[0]+=v.boost),i.push(new xc(v,s,f)))}}catch(b){d.e(b)}finally{d.f()}}}}catch(b){o.e(b)}finally{o.f()}i.sort(Wc);var p,m=[],g=null,k=y(i.sort(Wc));try{for(k.s();!(p=k.n()).done;){var w=p.value;if(300==m.length)break;g&&g.label==w.completion.label&&g.detail==w.completion.detail&&g.type==w.completion.type&&g.apply==w.completion.apply?Lc(w.completion)>Lc(g)&&(m[m.length-1]=w):m.push(w),g=w.completion}}catch(b){k.e(b)}finally{k.f()}return m}(e,n);if(!s.length)return null;var a,u=0;if(r&&r.selected)for(var l=r.options[r.selected].completion,h=0;h<s.length&&!u;h++)s[h].completion==l&&(u=h);return new t(s,Vc(i,u),{pos:e.reduce((function(t,e){return e.hasResult()?Math.min(t,e.from):t}),1e8),create:(a=Gc,function(t){return new Bc(t,a)}),above:o.aboveCursor},r?r.timestamp:Date.now(),u)}}]),t}(),Ic=function(){function t(e,n,i){k(this,t),this.active=e,this.id=n,this.open=i}return b(t,[{key:"update",value:function(e){var n=this,i=e.state,r=i.facet(Ec),o=(r.override||i.languageDataAt("autocomplete",Sc(i)).map(Dc)).map((function(t){return(n.active.find((function(e){return e.source==t}))||new zc(t,n.active.some((function(t){return 0!=t.state}))?1:0)).update(e,r)}));o.length==this.active.length&&o.every((function(t,e){return t==n.active[e]}))&&(o=this.active);var s=e.selection||o.some((function(t){return t.hasResult()&&e.changes.touchesRange(t.from,t.to)}))||!function(t,e){if(t==e)return!0;for(var n=0,i=0;;){for(;n<t.length&&!t[n].hasResult;)n++;for(;i<e.length&&!e[i].hasResult;)i++;var r=n==t.length,o=i==e.length;if(r||o)return r==o;if(t[n++].result!=e[i++].result)return!1}}(o,this.active)?Pc.build(o,i,this.id,this.open,r):this.open&&e.docChanged?this.open.map(e.changes):this.open;!s&&o.every((function(t){return 1!=t.state}))&&o.some((function(t){return t.hasResult()}))&&(o=o.map((function(t){return t.hasResult()?new zc(t.source,0):t})));var a,u=y(e.effects);try{for(u.s();!(a=u.n()).done;){var l=a.value;l.is(Kc)&&(s=s&&s.setSelected(l.value,this.id))}}catch(h){u.e(h)}finally{u.f()}return o==this.active&&s==this.open?this:new t(o,this.id,s)}},{key:"tooltip",get:function(){return this.open?this.open.tooltip:null}},{key:"attrs",get:function(){return this.open?this.open.attrs:Nc}}],[{key:"start",value:function(){return new t(Hc,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}}]),t}();var Nc={"aria-autocomplete":"list","aria-expanded":"false"};function Vc(t,e){return{"aria-autocomplete":"list","aria-expanded":"true","aria-activedescendant":t+"-"+e,"aria-controls":t}}var Hc=[];function Wc(t,e){var n=e.match[0]-t.match[0];return n||t.completion.label.localeCompare(e.completion.label)}function Fc(t){return t.isUserEvent("input.type")?"input":t.isUserEvent("delete.backward")?"delete":null}var zc=function(){function t(e,n){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;k(this,t),this.source=e,this.state=n,this.explicitPos=i}return b(t,[{key:"hasResult",value:function(){return!1}},{key:"update",value:function(e,n){var i=Fc(e),r=this;i?r=r.handleUserEvent(e,i,n):e.docChanged?r=r.handleChange(e):e.selection&&0!=r.state&&(r=new t(r.source,0));var o,s=y(e.effects);try{for(s.s();!(o=s.n()).done;){var a=o.value;if(a.is(jc))r=new t(r.source,1,a.value?Sc(e.state):-1);else if(a.is(_c))r=new t(r.source,0);else if(a.is(Uc)){var u,l=y(a.value);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.source==r.source&&(r=h)}}catch(c){l.e(c)}finally{l.f()}}}}catch(c){s.e(c)}finally{s.f()}return r}},{key:"handleUserEvent",value:function(e,n,i){return"delete"!=n&&i.activateOnTyping?new t(this.source,1):this.map(e.changes)}},{key:"handleChange",value:function(e){return e.changes.touchesRange(Sc(e.startState))?new t(this.source,0):this.map(e.changes)}},{key:"map",value:function(e){return e.empty||this.explicitPos<0?this:new t(this.source,this.state,e.mapPos(this.explicitPos))}}]),t}(),qc=function(t){v(n,t);var e=g(n);function n(t,i,r,o,s,a){var u;return k(this,n),(u=e.call(this,t,2,i)).result=r,u.from=o,u.to=s,u.span=a,u}return b(n,[{key:"hasResult",value:function(){return!0}},{key:"handleUserEvent",value:function(t,e,i){var r=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=Sc(t.state);if((this.explicitPos>-1?s<r:s<=r)||s>o)return new zc(this.source,"input"==e&&i.activateOnTyping?1:0);var a=this.explicitPos<0?-1:t.changes.mapPos(this.explicitPos);return this.span&&(r==o||this.span.test(t.state.sliceDoc(r,o)))?new n(this.source,a,this.result,r,o,this.span):new zc(this.source,1,a)}},{key:"handleChange",value:function(t){return t.changes.touchesRange(this.from,this.to)?new zc(this.source,0):this.map(t.changes)}},{key:"map",value:function(t){return t.empty?this:new n(this.source,this.explicitPos<0?-1:t.mapPos(this.explicitPos),this.result,t.mapPos(this.from),t.mapPos(this.to,1),this.span)}}]),n}(zc),jc=Nt.define(),_c=Nt.define(),Uc=Nt.define({map:function(t,e){return t.map((function(t){return t.map(e)}))}}),Kc=Nt.define(),Gc=ct.define({create:function(){return Ic.start()},update:function(t,e){return t.update(e)},provide:function(t){return[cc.from(t,(function(t){return t.tooltip})),co.contentAttributes.from(t,(function(t){return t.attrs}))]}});function Jc(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"option";return function(n){var i=n.state.field(Gc,!1);if(!i||!i.open||Date.now()-i.open.timestamp<75)return!1;var r,o=1;"page"==e&&(r=gc(n,i.open.tooltip))&&(o=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));var s=i.open.selected+o*(t?1:-1),a=i.open.options.length;return s<0?s="page"==e?0:a-1:s>=a&&(s="page"==e?a-1:0),n.dispatch({effects:Kc.of(s)}),!0}}var $c=b((function t(e,n){k(this,t),this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0})),Yc=ii.fromClass(function(){function t(e){k(this,t),this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;var n,i=y(e.state.field(Gc).active);try{for(i.s();!(n=i.n()).done;){var r=n.value;1==r.state&&this.startQuery(r)}}catch(o){i.e(o)}finally{i.f()}}return b(t,[{key:"update",value:function(t){var e=this,n=t.state.field(Gc);if(t.selectionSet||t.docChanged||t.startState.field(Gc)!=n){for(var i=t.transactions.some((function(t){return(t.selection||t.docChanged)&&!Fc(t)})),r=0;r<this.running.length;r++){var o=this.running[r];if(i||o.updates.length+t.transactions.length>50&&o.time-Date.now()>1e3){var s,a=y(o.context.abortListeners);try{for(a.s();!(s=a.n()).done;){var l=s.value;try{l()}catch(v){Xn(this.view.state,v)}}}catch(p){a.e(p)}finally{a.f()}o.context.abortListeners=null,this.running.splice(r--,1)}else{var h;(h=o.updates).push.apply(h,u(t.transactions))}}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=n.active.some((function(t){return 1==t.state&&!e.running.some((function(e){return e.active.source==t.source}))}))?setTimeout((function(){return e.startUpdate()}),50):-1,0!=this.composing){var c,f=y(t.transactions);try{for(f.s();!(c=f.n()).done;){var d=c.value;"input"==Fc(d)?this.composing=2:2==this.composing&&d.selection&&(this.composing=3)}}catch(p){f.e(p)}finally{f.f()}}}}},{key:"startUpdate",value:function(){var t=this;this.debounceUpdate=-1;var e,n=y(this.view.state.field(Gc).active);try{var i=function(){var n=e.value;1!=n.state||t.running.some((function(t){return t.active.source==n.source}))||t.startQuery(n)};for(n.s();!(e=n.n()).done;)i()}catch(r){n.e(r)}finally{n.f()}}},{key:"startQuery",value:function(t){var e=this,n=this.view.state,i=Sc(n),r=new kc(n,i,t.explicitPos==i),o=new $c(t,r);this.running.push(o),Promise.resolve(t.source(r)).then((function(t){o.context.aborted||(o.done=t||null,e.scheduleAccept())}),(function(t){e.view.dispatch({effects:_c.of(null)}),Xn(e.view.state,t)}))}},{key:"scheduleAccept",value:function(){var t=this;this.running.every((function(t){return void 0!==t.done}))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((function(){return t.accept()}),50))}},{key:"accept",value:function(){var t,e=this;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;for(var n=[],i=this.view.state.facet(Ec),r=function(r){var s=e.running[r];if(void 0===s.done)return o=r,"continue";if(e.running.splice(r--,1),s.done){var a,u=new qc(s.active.source,s.active.explicitPos,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:Sc(s.updates.length?s.updates[0].startState:e.view.state),s.done.span&&!1!==s.done.filter?Cc(s.done.span,!0):null),l=y(s.updates);try{for(l.s();!(a=l.n()).done;){var h=a.value;u=u.update(h,i)}}catch(m){l.e(m)}finally{l.f()}if(u.hasResult())return n.push(u),o=r,"continue"}var c=e.view.state.field(Gc).active.find((function(t){return t.source==s.active.source}));if(c&&1==c.state)if(null==s.done){var f,d=new zc(s.active.source,0),v=y(s.updates);try{for(v.s();!(f=v.n()).done;){var p=f.value;d=d.update(p,i)}}catch(m){v.e(m)}finally{v.f()}1!=d.state&&n.push(d)}else e.startQuery(c);o=r},o=0;o<this.running.length;o++)r(o);n.length&&this.view.dispatch({effects:Uc.of(n)})}}]),t}(),{eventHandlers:{compositionstart:function(){this.composing=1},compositionend:function(){var t=this;3==this.composing&&setTimeout((function(){return t.view.dispatch({effects:jc.of(!1)})}),20),this.composing=0}}}),Xc=co.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",listStyle:"none",margin:0,padding:0,"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xb7\xb7\xb7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"300px"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25cb'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25cc'"}},".cm-completionIcon-variable":{"&:after":{content:"'\ud835\udc65'"}},".cm-completionIcon-constant":{"&:after":{content:"'\ud835\udc36'"}},".cm-completionIcon-type":{"&:after":{content:"'\ud835\udc61'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222a'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25a1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\ud83d\udd11\ufe0e'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25a2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});function Qc(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[Gc,Ec.of(t),Yc,tf,Xc]}var Zc=[{key:"Ctrl-Space",run:function(t){return!!t.state.field(Gc,!1)&&(t.dispatch({effects:jc.of(!0)}),!0)}},{key:"Escape",run:function(t){var e=t.state.field(Gc,!1);return!(!e||!e.active.some((function(t){return 0!=t.state})))&&(t.dispatch({effects:_c.of(null)}),!0)}},{key:"ArrowDown",run:Jc(!0)},{key:"ArrowUp",run:Jc(!1)},{key:"PageDown",run:Jc(!0,"page")},{key:"PageUp",run:Jc(!1,"page")},{key:"Enter",run:function(t){var e=t.state.field(Gc,!1);return!(t.state.readOnly||!e||!e.open||Date.now()-e.open.timestamp<75)&&(Mc(t,e.open.options[e.open.selected]),!0)}}],tf=yt.highest(Ao.computeN([Ec],(function(t){return t.facet(Ec).defaultKeymap?[Zc]:[]})));function ef(t,e){return function(n){var i=n.state,r=n.dispatch,o=t(e,i.selection.ranges,i);return!!o&&(r(i.update(o)),!0)}}var nf=ef(uf,0),rf=ef(af,0),of=[{key:"Mod-/",run:function(t){var e=sf(t.state);return e.line?nf(t):!!e.block&&rf(t)}},{key:"Alt-A",run:rf}];function sf(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.selection.main.head,n=t.languageDataAt("commentTokens",e);return n.length?n[0]:{}}function af(t,e,n){var i=e.map((function(t){return sf(n,t.from).block}));if(!i.every((function(t){return t})))return null;var r=e.map((function(t,e){return function(t,e,n,i){var r,o,s=e.open,a=e.close,u=t.sliceDoc(n-50,n),l=t.sliceDoc(i,i+50),h=/\s*$/.exec(u)[0].length,c=/^\s*/.exec(l)[0].length,f=u.length-h;if(u.slice(f-s.length,f)==s&&l.slice(c,c+a.length)==a)return{open:{pos:n-h,margin:h&&1},close:{pos:i+c,margin:c&&1}};i-n<=100?r=o=t.sliceDoc(n,i):(r=t.sliceDoc(n,n+50),o=t.sliceDoc(i-50,i));var d=/^\s*/.exec(r)[0].length,v=/\s*$/.exec(o)[0].length,p=o.length-v-a.length;return r.slice(d,d+s.length)==s&&o.slice(p,p+a.length)==a?{open:{pos:n+d+s.length,margin:/\s/.test(r.charAt(d+s.length))?1:0},close:{pos:i-v-a.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(n,i[e],t.from,t.to)}));if(2!=t&&!r.every((function(t){return t}))){var o=0;return n.changeByRange((function(t){var e=i[o++],n=e.open,s=e.close;if(r[o])return{range:t};var a=n.length+1;return{changes:[{from:t.from,insert:n+" "},{from:t.to,insert:" "+s}],range:it.range(t.anchor+a,t.head+a)}}))}if(1!=t&&r.some((function(t){return t}))){for(var s,a=[],u=0;u<r.length;u++)if(s=r[u]){var l=i[u],h=s,c=h.open,f=h.close;a.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:f.pos-f.margin,to:f.pos+l.close.length})}return{changes:a}}return null}function uf(t,e,n){var i,r=[],o=-1,s=y(e);try{for(s.s();!(i=s.n()).done;){for(var a=i.value,u=a.from,l=a.to,h=r.length,c=1e9,f=u;f<=l;){var d=n.doc.lineAt(f);if(d.from>o&&(u==l||l>d.from)){o=d.from;var v=sf(n,f).line;if(!v)continue;var p=/^\s*/.exec(d.text)[0].length,m=p==d.length,g=d.text.slice(p,p+v.length)==v?p:-1;p<d.text.length&&p<c&&(c=p),r.push({line:d,comment:g,token:v,indent:p,empty:m,single:!1})}f=d.to+1}if(c<1e9)for(var k=h;k<r.length;k++)r[k].indent<r[k].line.text.length&&(r[k].indent=c);r.length==h+1&&(r[h].single=!0)}}catch(H){s.e(H)}finally{s.f()}if(2!=t&&r.some((function(t){return t.comment<0&&(!t.empty||t.single)}))){var w,b=[],x=y(r);try{for(x.s();!(w=x.n()).done;){var S=w.value,C=S.line,A=S.token,M=S.indent,O=S.empty;!S.single&&O||b.push({from:C.from+M,insert:A+" "})}}catch(H){x.e(H)}finally{x.f()}var D=n.changes(b);return{changes:D,selection:n.selection.map(D,1)}}if(1!=t&&r.some((function(t){return t.comment>=0}))){var T,E=[],R=y(r);try{for(R.s();!(T=R.n()).done;){var B=T.value,L=B.line,P=B.comment,I=B.token;if(P>=0){var N=L.from+P,V=N+I.length;" "==L.text[V-L.from]&&V++,E.push({from:N,to:V})}}}catch(H){R.e(H)}finally{R.f()}return{changes:E}}return null}var lf=2e3;function hf(t,e){var n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),i=t.state.doc.lineAt(n),r=n-i.from,o=r>lf?-1:r==i.length?function(t,e){var n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):P(i.text,t.state.tabSize,n-i.from);return{line:i.number,col:o,off:r}}function cf(t,e){var n=hf(t,e),i=t.state.selection;return n?{update:function(t){if(t.docChanged){var e=t.changes.mapPos(t.startState.doc.line(n.line).from),r=t.state.doc.lineAt(e);n={line:r.number,col:n.col,off:Math.min(n.off,r.length)},i=i.map(t.changes)}},get:function(e,r,o){var s=hf(t,e);if(!s)return i;var a=function(t,e,n){var i=Math.min(e.line,n.line),r=Math.max(e.line,n.line),o=[];if(e.off>lf||n.off>lf||e.col<0||n.col<0)for(var s=Math.min(e.off,n.off),a=Math.max(e.off,n.off),u=i;u<=r;u++){var l=t.doc.line(u);l.length<=a&&o.push(it.range(l.from+s,l.to+a))}else for(var h=Math.min(e.col,n.col),c=Math.max(e.col,n.col),f=i;f<=r;f++){var d=t.doc.line(f),v=I(d.text,h,t.tabSize,!0);if(v>-1){var p=I(d.text,c,t.tabSize);o.push(it.range(d.from+v,d.from+p))}}return o}(t.state,n,s);return a.length?o?it.create(a.concat(i.ranges)):it.create(a):i}}:null}function ff(t){var e=(null===t||void 0===t?void 0:t.eventFilter)||function(t){return t.altKey&&0==t.button};return co.mouseSelectionStyle.of((function(t,n){return e(n)?cf(t,n):null}))}var df=0,vf=function(){function t(e,n,i){k(this,t),this.set=e,this.base=n,this.modified=i,this.id=df++}return b(t,null,[{key:"define",value:function(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");var n=new t([],null,[]);if(n.set.push(n),e){var i,r=y(e.set);try{for(r.s();!(i=r.n()).done;){var o=i.value;n.set.push(o)}}catch(s){r.e(s)}finally{r.f()}}return n}},{key:"defineModifier",value:function(){var t=new mf;return function(e){return e.modified.indexOf(t)>-1?e:mf.get(e.base||e,e.modified.concat(t).sort((function(t,e){return t.id-e.id})))}}}]),t}(),pf=0,mf=function(){function t(){k(this,t),this.instances=[],this.id=pf++}return b(t,null,[{key:"get",value:function(e,n){if(!n.length)return e;var i=n[0].instances.find((function(t){return t.base==e&&(i=n,r=t.modified,i.length==r.length&&i.every((function(t,e){return t==r[e]})));var i,r}));if(i)return i;var r,o=[],s=new vf(o,e,n),a=y(n);try{for(a.s();!(r=a.n()).done;){r.value.instances.push(s)}}catch(p){a.e(p)}finally{a.f()}var u,l=gf(n),h=y(e.set);try{for(h.s();!(u=h.n()).done;){var c,f=u.value,d=y(l);try{for(d.s();!(c=d.n()).done;){var v=c.value;o.push(t.get(f,v))}}catch(p){d.e(p)}finally{d.f()}}}catch(p){h.e(p)}finally{h.f()}return s}}]),t}();function gf(t){for(var e=[t],n=0;n<t.length;n++){var i,r=y(gf(t.slice(0,n).concat(t.slice(n+1))));try{for(r.s();!(i=r.n()).done;){var o=i.value;e.push(o)}}catch(s){r.e(s)}finally{r.f()}}return e}var yf=new Vs,kf=at.define({combine:function(t){return t.length?xf.combinedMatch(t):null}}),wf=at.define({combine:function(t){return t.length?t[0].match:null}});function bf(t){return t.facet(kf)||t.facet(wf)}var xf=function(){function t(e,n){var i;function r(t){var e=Zt.newName();return(i||(i=Object.create(null)))["."+e]=t,e}k(this,t),this.map=Object.create(null),this.all="string"==typeof n.all?n.all:n.all?r(n.all):null;var o,s=y(e);try{for(s.s();!(o=s.n()).done;){var a=o.value,u=(a.class||r(Object.assign({},a,{tag:null})))+(this.all?" "+this.all:""),l=a.tag;if(Array.isArray(l)){var h,c=y(l);try{for(c.s();!(h=c.n()).done;){var f=h.value;this.map[f.id]=u}}catch(v){c.e(v)}finally{c.f()}}else this.map[l.id]=u}}catch(v){s.e(v)}finally{s.f()}this.module=i?new Zt(i):null,this.scope=n.scope||null,this.match=this.match.bind(this);var d=[Cf];this.module&&d.push(co.styleModule.of(this.module)),this.extension=d.concat(kf.of(this)),this.fallback=d.concat(wf.of(this))}return b(t,[{key:"match",value:function(t,e){if(this.scope&&e!=this.scope)return null;var n,i=y(t.set);try{for(i.s();!(n=i.n()).done;){var r=n.value,o=this.map[r.id];if(void 0!==o)return r!=t&&(this.map[t.id]=o),o}}catch(s){i.e(s)}finally{i.f()}return this.map[t.id]=this.all}}],[{key:"combinedMatch",value:function(t){if(1==t.length)return t[0].match;var e=t.some((function(t){return t.scope}))?void 0:Object.create(null);return function(n,i){var r=e&&e[n.id];if(void 0!==r)return r;var o,s=null,a=y(t);try{for(a.s();!(o=a.n()).done;){var u=o.value.match(n,i);u&&(s=s?s+" "+u:u)}}catch(l){a.e(l)}finally{a.f()}return e&&(e[n.id]=s),s}}},{key:"define",value:function(e,n){return new t(e,n||{})}},{key:"get",value:function(t,e,n){var i=bf(t);return i&&i(e,n||Ws.none)}}]),t}();var Sf=function(){function t(e){k(this,t),this.markCache=Object.create(null),this.tree=ha(e.state),this.decorations=this.buildDeco(e,bf(e.state))}return b(t,[{key:"update",value:function(t){var e=ha(t.state),n=bf(t.state),i=n!=t.startState.facet(kf);e.length<t.view.viewport.to&&!i&&e.type==this.tree.type?this.decorations=this.decorations.map(t.changes):(e!=this.tree||t.viewportChanged||i)&&(this.tree=e,this.decorations=this.buildDeco(t.view,n))}},{key:"buildDeco",value:function(t,e){var n=this;if(!e||!this.tree.length)return Tn.none;var i,r=new ue,o=y(t.visibleRanges);try{for(o.s();!(i=o.n()).done;){var s=i.value,a=s.from,u=s.to;Of(this.tree,a,u,e,(function(t,e,i){r.add(t,e,n.markCache[i]||(n.markCache[i]=Tn.mark({class:i})))}))}}catch(l){o.e(l)}finally{o.f()}return r.finish()}}]),t}(),Cf=yt.high(ii.fromClass(Sf,{decorations:function(t){return t.decorations}})),Af=[""],Mf=function(){function t(e,n,i){k(this,t),this.at=e,this.style=n,this.span=i,this.class=""}return b(t,[{key:"startSpan",value:function(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}},{key:"flush",value:function(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}},{key:"highlightRange",value:function(t,e,n,i,r,o){var s=t.type,a=t.from,u=t.to;if(!(a>=n||u<=e)){Af[r]=s.name,s.isTop&&(o=s);for(var l=i,h=s.prop(yf),c=!1;h;){if(!h.context||Df(h.context,Af,r)){var f,d=y(h.tags);try{for(d.s();!(f=d.n()).done;){var v=f.value,p=this.style(v,o);p&&(l&&(l+=" "),l+=p,1==h.mode?i+=(i?" ":"")+p:0==h.mode&&(c=!0))}}catch(M){d.e(M)}finally{d.f()}break}h=h.next}if(this.startSpan(t.from,l),!c){var m=t.tree&&t.tree.prop(Vs.mounted);if(m&&m.overlay){for(var g=t.node.enter(m.overlay[0].from+a,1),k=t.firstChild(),w=0,b=a;;w++){var x=w<m.overlay.length?m.overlay[w]:null,S=x?x.from+a:u,C=Math.max(e,b),A=Math.min(n,S);if(C<A&&k)for(;t.from<A&&(this.highlightRange(t,C,A,i,r+1,o),this.startSpan(Math.min(n,t.to),l),!(t.to>=S)&&t.nextSibling()););if(!x||S>n)break;(b=x.to+a)>e&&(this.highlightRange(g.cursor,Math.max(e,x.from+a),Math.min(n,b),i,r,m.tree.type),this.startSpan(b,l))}k&&t.parent()}else if(t.firstChild()){do{if(!(t.to<=e)){if(t.from>=n)break;this.highlightRange(t,e,n,i,r+1,o),this.startSpan(Math.min(n,t.to),l)}}while(t.nextSibling());t.parent()}}}}}]),t}();function Of(t,e,n,i,r){var o=new Mf(e,i,r);o.highlightRange(t.cursor(),e,n,"",0,t.type),o.flush(n)}function Df(t,e,n){if(t.length>n-1)return!1;for(var i=n-1,r=t.length-1;r>=0;r--,i--){var o=t[r];if(o&&o!=e[i])return!1}return!0}var Tf=vf.define,Ef=Tf(),Rf=Tf(),Bf=Tf(Rf),Lf=Tf(Rf),Pf=Tf(),If=Tf(Pf),Nf=Tf(Pf),Vf=Tf(),Hf=Tf(Vf),Wf=Tf(),Ff=Tf(),zf=Tf(),qf=Tf(zf),jf=Tf(),_f={comment:Ef,lineComment:Tf(Ef),blockComment:Tf(Ef),docComment:Tf(Ef),name:Rf,variableName:Tf(Rf),typeName:Bf,tagName:Tf(Bf),propertyName:Lf,attributeName:Tf(Lf),className:Tf(Rf),labelName:Tf(Rf),namespace:Tf(Rf),macroName:Tf(Rf),literal:Pf,string:If,docString:Tf(If),character:Tf(If),attributeValue:Tf(If),number:Nf,integer:Tf(Nf),float:Tf(Nf),bool:Tf(Pf),regexp:Tf(Pf),escape:Tf(Pf),color:Tf(Pf),url:Tf(Pf),keyword:Wf,self:Tf(Wf),null:Tf(Wf),atom:Tf(Wf),unit:Tf(Wf),modifier:Tf(Wf),operatorKeyword:Tf(Wf),controlKeyword:Tf(Wf),definitionKeyword:Tf(Wf),moduleKeyword:Tf(Wf),operator:Ff,derefOperator:Tf(Ff),arithmeticOperator:Tf(Ff),logicOperator:Tf(Ff),bitwiseOperator:Tf(Ff),compareOperator:Tf(Ff),updateOperator:Tf(Ff),definitionOperator:Tf(Ff),typeOperator:Tf(Ff),controlOperator:Tf(Ff),punctuation:zf,separator:Tf(zf),bracket:qf,angleBracket:Tf(qf),squareBracket:Tf(qf),paren:Tf(qf),brace:Tf(qf),content:Vf,heading:Hf,heading1:Tf(Hf),heading2:Tf(Hf),heading3:Tf(Hf),heading4:Tf(Hf),heading5:Tf(Hf),heading6:Tf(Hf),contentSeparator:Tf(Vf),list:Tf(Vf),quote:Tf(Vf),emphasis:Tf(Vf),strong:Tf(Vf),link:Tf(Vf),monospace:Tf(Vf),strikethrough:Tf(Vf),inserted:Tf(),deleted:Tf(),changed:Tf(),invalid:Tf(),meta:jf,documentMeta:Tf(jf),annotation:Tf(jf),processingInstruction:Tf(jf),definition:vf.defineModifier(),constant:vf.defineModifier(),function:vf.defineModifier(),standard:vf.defineModifier(),local:vf.defineModifier(),special:vf.defineModifier()},Uf=xf.define([{tag:_f.link,textDecoration:"underline"},{tag:_f.heading,textDecoration:"underline",fontWeight:"bold"},{tag:_f.emphasis,fontStyle:"italic"},{tag:_f.strong,fontWeight:"bold"},{tag:_f.strikethrough,textDecoration:"line-through"},{tag:_f.keyword,color:"#708"},{tag:[_f.atom,_f.bool,_f.url,_f.contentSeparator,_f.labelName],color:"#219"},{tag:[_f.literal,_f.inserted],color:"#164"},{tag:[_f.string,_f.deleted],color:"#a11"},{tag:[_f.regexp,_f.escape,_f.special(_f.string)],color:"#e40"},{tag:_f.definition(_f.variableName),color:"#00f"},{tag:_f.local(_f.variableName),color:"#30a"},{tag:[_f.typeName,_f.namespace],color:"#085"},{tag:_f.className,color:"#167"},{tag:[_f.special(_f.variableName),_f.macroName],color:"#256"},{tag:_f.definition(_f.propertyName),color:"#00c"},{tag:_f.comment,color:"#940"},{tag:_f.meta,color:"#7a757a"},{tag:_f.invalid,color:"#f00"}]),Kf=b((function t(e,n,i){k(this,t),this.from=e,this.to=n,this.diagnostic=i})),Gf=function(){function t(e,n,i){k(this,t),this.diagnostics=e,this.panel=n,this.selected=i}return b(t,null,[{key:"init",value:function(e,n,i){var r=Tn.set(e.map((function(t){return t.from==t.to||t.from==t.to-1&&i.doc.lineAt(t.from).to==t.from?Tn.widget({widget:new ad(t),diagnostic:t}).range(t.from):Tn.mark({attributes:{class:"cm-lintRange cm-lintRange-"+t.severity},diagnostic:t}).range(t.from,t.to)})),!0);return new t(r,n,Jf(r))}}]),t}();function Jf(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=null;return t.between(n,1e9,(function(t,n,r){var o=r.spec;if(!e||o.diagnostic==e)return i=new Kf(t,n,o.diagnostic),!1})),i}function $f(t,e){return t.field(Zf,!1)?e:e.concat(Nt.appendConfig.of([Zf,co.decorations.compute([Zf],(function(t){var e=t.field(Zf),n=e.selected,i=e.panel;return n&&i&&n.from!=n.to?Tn.set([td.range(n.from,n.to)]):Tn.none})),mc(ed),fd]))}var Yf=Nt.define(),Xf=Nt.define(),Qf=Nt.define(),Zf=ct.define({create:function(){return new Gf(Tn.none,null,null)},update:function(t,e){if(e.docChanged){var n=t.diagnostics.map(e.changes),i=null;if(t.selected){var r=e.changes.mapPos(t.selected.from,1);i=Jf(n,t.selected.diagnostic,r)||Jf(n,null,r)}t=new Gf(n,t.panel,i)}var o,s=y(e.effects);try{for(s.s();!(o=s.n()).done;){var a=o.value;a.is(Yf)?t=Gf.init(a.value,t.panel,e.state):a.is(Xf)?t=new Gf(t.diagnostics,a.value?ld.open:null,t.selected):a.is(Qf)&&(t=new Gf(t.diagnostics,t.panel,a.value))}}catch(u){s.e(u)}finally{s.f()}return t},provide:function(t){return[sh.from(t,(function(t){return t.panel})),co.decorations.from(t,(function(t){return t.diagnostics}))]}});var td=Tn.mark({class:"cm-lintRange cm-lintRange-active"});function ed(t,e,n){var i=t.state.field(Zf).diagnostics,r=[],o=2e8,s=0;return i.between(e-(n<0?1:0),e+(n>0?1:0),(function(t,i,a){var u=a.spec;e>=t&&e<=i&&(t==i||(e>t||n>0)&&(e<i||n<0))&&(r.push(u.diagnostic),o=Math.min(t,o),s=Math.max(i,s))})),r.length?{pos:o,end:s,above:t.state.doc.lineAt(o).to<s,create:function(){return{dom:nd(t,r)}}}:null}function nd(t,e){return ah("ul",{class:"cm-tooltip-lint"},e.map((function(e){return sd(t,e,!1)})))}var id=function(t){var e=t.state.field(Zf,!1);return!(!e||!e.panel)&&(t.dispatch({effects:Xf.of(!1)}),!0)},rd=[{key:"Mod-Shift-m",run:function(t){var e=t.state.field(Zf,!1);e&&e.panel||t.dispatch({effects:$f(t.state,[Xf.of(!0)])});var n=eh(t,ld.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0}},{key:"F8",run:function(t){var e=t.state.field(Zf,!1);if(!e)return!1;var n=t.state.selection.main,i=e.diagnostics.iter(n.to+1);return!(!i.value&&(!(i=e.diagnostics.iter(0)).value||i.from==n.from&&i.to==n.to))&&(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}];function od(t){var e=[];if(t){var n,i=y(t);try{t:for(i.s();!(n=i.n()).done;){for(var r=n.value.name,o=function(t){var n=r[t];if(/[a-zA-Z]/.test(n)&&!e.some((function(t){return t.toLowerCase()==n.toLowerCase()})))return e.push(n),"continue|actions"},s=0;s<r.length;s++){if("continue|actions"===o(s))continue t}e.push("")}}catch(a){i.e(a)}finally{i.f()}}return e}function sd(t,e,n){var i,r=n?od(e.actions):[];return ah("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ah("span",{class:"cm-diagnosticText"},e.message),null===(i=e.actions)||void 0===i?void 0:i.map((function(n,i){var o=function(i){i.preventDefault();var r=Jf(t.state.field(Zf).diagnostics,e);r&&n.apply(t,r.from,r.to)},s=n.name,a=r[i]?s.indexOf(r[i]):-1,u=a<0?s:[s.slice(0,a),ah("u",s.slice(a,a+1)),s.slice(a+1)];return ah("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":" Action: ".concat(s).concat(a<0?"":' (access key "'.concat(r[i],')"'),".")},u)})),e.source&&ah("div",{class:"cm-diagnosticSource"},e.source))}var ad=function(t){v(n,t);var e=g(n);function n(t){var i;return k(this,n),(i=e.call(this)).diagnostic=t,i}return b(n,[{key:"eq",value:function(t){return t.diagnostic==this.diagnostic}},{key:"toDOM",value:function(){return ah("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}]),n}(On),ud=b((function t(e,n){k(this,t),this.diagnostic=n,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=sd(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")})),ld=function(){function t(e){var n=this;k(this,t),this.view=e,this.items=[];this.list=ah("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:function(t){if(27==t.keyCode)id(n.view),n.view.focus();else if(38==t.keyCode||33==t.keyCode)n.moveSelection((n.selectedIndex-1+n.items.length)%n.items.length);else if(40==t.keyCode||34==t.keyCode)n.moveSelection((n.selectedIndex+1)%n.items.length);else if(36==t.keyCode)n.moveSelection(0);else if(35==t.keyCode)n.moveSelection(n.items.length-1);else if(13==t.keyCode)n.view.focus();else{if(!(t.keyCode>=65&&t.keyCode<=90&&n.selectedIndex>=0))return;for(var i=n.items[n.selectedIndex].diagnostic,r=od(i.actions),o=0;o<r.length;o++)if(r[o].toUpperCase().charCodeAt(0)==t.keyCode){var s=Jf(n.view.state.field(Zf).diagnostics,i);s&&i.actions[o].apply(e,s.from,s.to)}}t.preventDefault()},onclick:function(t){for(var e=0;e<n.items.length;e++)n.items[e].dom.contains(t.target)&&n.moveSelection(e)}}),this.dom=ah("div",{class:"cm-panel-lint"},this.list,ah("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:function(){return id(n.view)}},"\xd7")),this.update()}return b(t,[{key:"selectedIndex",get:function(){var t=this.view.state.field(Zf).selected;if(!t)return-1;for(var e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}},{key:"update",value:function(){var t=this,e=this.view.state.field(Zf),n=e.diagnostics,i=e.selected,r=0,o=!1,s=null;for(n.between(0,this.view.state.doc.length,(function(e,n,a){for(var u,l=a.spec,h=-1,c=r;c<t.items.length;c++)if(t.items[c].diagnostic==l.diagnostic){h=c;break}h<0?(u=new ud(t.view,l.diagnostic),t.items.splice(r,0,u),o=!0):(u=t.items[h],h>r&&(t.items.splice(r,h-r),o=!0)),i&&u.diagnostic==i.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),r++}));r<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();0==this.items.length&&(this.items.push(new ud(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:function(){return{sel:s.dom.getBoundingClientRect(),panel:t.list.getBoundingClientRect()}},write:function(e){var n=e.sel,i=e.panel;n.top<i.top?t.list.scrollTop-=i.top-n.top:n.bottom>i.bottom&&(t.list.scrollTop+=n.bottom-i.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}},{key:"sync",value:function(){var t=this.list.firstChild;function e(){var e=t;t=e.nextSibling,e.remove()}var n,i=y(this.items);try{for(i.s();!(n=i.n()).done;){var r=n.value;if(r.dom.parentNode==this.list){for(;t!=r.dom;)e();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t)}}catch(o){i.e(o)}finally{i.f()}for(;t;)e()}},{key:"moveSelection",value:function(t){if(!(this.selectedIndex<0)){var e=Jf(this.view.state.field(Zf).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:Qf.of(e)})}}}],[{key:"open",value:function(e){return new t(e)}}]),t}();function hd(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'viewBox="0 0 40 40"';return'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" '.concat(e,">").concat(encodeURIComponent(t),"</svg>')")}function cd(t){return hd('<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="'.concat(t,'" fill="none" stroke-width=".7"/>'),'width="6" height="3"')}var fd=co.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:cd("#d11")},".cm-lintRange-warning":{backgroundImage:cd("orange")},".cm-lintRange-info":{backgroundImage:cd("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});var dd=[eu(),ou(),ts(),ys(),bu(),Po(),Ko(),Jt.allowMultipleSelections.of(!0),Ba(),Uf.fallback,Ru(),ql(),Qc(),ff(),as(),Sh(),Ao.of([].concat(u(Gl),u(Il),u(Yh),u(Ps),u(vu),u(of),u(Zc),u(rd)))],vd="#e06c75",pd="#abb2bf",md="#7d8799",gd="#d19a66",yd="#2c313a",kd="#282c34",wd="#353a42",bd="#528bff",xd=[co.theme({"&":{color:pd,backgroundColor:kd},".cm-content":{caretColor:bd},"&.cm-focused .cm-cursor":{borderLeftColor:bd},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:pd},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:yd},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{backgroundColor:kd,color:md,border:"none"},".cm-activeLineGutter":{backgroundColor:yd},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:wd},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:wd,borderBottomColor:wd},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:yd,color:pd}}},{dark:!0}),xf.define([{tag:_f.keyword,color:"#c678dd"},{tag:[_f.name,_f.deleted,_f.character,_f.propertyName,_f.macroName],color:vd},{tag:[_f.function(_f.variableName),_f.labelName],color:"#61afef"},{tag:[_f.color,_f.constant(_f.name),_f.standard(_f.name)],color:gd},{tag:[_f.definition(_f.name),_f.separator],color:pd},{tag:[_f.typeName,_f.className,_f.number,_f.changed,_f.annotation,_f.modifier,_f.self,_f.namespace],color:"#e5c07b"},{tag:[_f.operator,_f.operatorKeyword,_f.url,_f.escape,_f.regexp,_f.link,_f.special(_f.string)],color:"#56b6c2"},{tag:[_f.meta,_f.comment],color:md},{tag:_f.strong,fontWeight:"bold"},{tag:_f.emphasis,fontStyle:"italic"},{tag:_f.strikethrough,textDecoration:"line-through"},{tag:_f.link,color:md,textDecoration:"underline"},{tag:_f.heading,fontWeight:"bold",color:vd},{tag:[_f.atom,_f.bool,_f.special(_f.variableName)],color:gd},{tag:[_f.processingInstruction,_f.string,_f.inserted],color:"#98c379"},{tag:_f.invalid,color:"#ffffff"}])],Sd=co.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function Cd(t){var n=t.value,i=t.selection,r=t.onChange,o=t.onUpdate,s=t.extensions,u=void 0===s?[]:s,l=t.autoFocus,h=t.theme,c=void 0===h?"light":h,f=t.height,d=void 0===f?"":f,v=t.minHeight,p=void 0===v?"":v,m=t.maxHeight,g=void 0===m?"":m,y=t.placeholder,k=void 0===y?"":y,w=t.width,b=void 0===w?"":w,x=t.minWidth,S=void 0===x?"":x,C=t.maxWidth,A=void 0===C?"":C,M=t.editable,O=void 0===M||M,D=t.indentWithTab,T=void 0===D||D,E=t.basicSetup,R=void 0===E||E,B=t.root,L=a((0,e.useState)(t.container),2),P=L[0],I=L[1],N=a((0,e.useState)(),2),V=N[0],H=N[1],W=a((0,e.useState)(),2),F=W[0],z=W[1],q=co.theme({"&":{height:d,minHeight:p,maxHeight:g,width:b,minWidth:S,maxWidth:A}}),j=[co.updateListener.of((function(t){if(t.docChanged&&"function"===typeof r){var e=t.state.doc.toString();r(e,t)}})),q];switch(T&&j.unshift(Ao.of([Nl])),R&&j.unshift(dd),k&&j.unshift(cs(k)),c){case"light":j.push(Sd);break;case"dark":j.push(xd);break;default:j.push(c)}return!1===O&&j.push(co.editable.of(!1)),o&&"function"===typeof o&&j.push(co.updateListener.of(o)),j=j.concat(u),(0,e.useEffect)((function(){if(P&&!F){var t=Jt.create({doc:n,selection:i,extensions:j});if(z(t),!V){var e=new co({state:t,parent:P,root:B});H(e)}}}),[P,F]),(0,e.useEffect)((function(){return function(){V&&V.destroy()}}),[V]),(0,e.useEffect)((function(){if(V){var t=V.state.doc.toString();n!==t&&V.dispatch({changes:{from:0,to:t.length,insert:n||""}})}}),[n,V]),(0,e.useEffect)((function(){V&&V.dispatch({effects:Nt.reconfigure.of(j)})}),[c,u,k,d,p,g,b,S,A,O,T,R]),(0,e.useEffect)((function(){l&&V&&V.focus()}),[l,V]),{state:F,setState:z,view:V,setView:H,container:P,setContainer:I}}var Ad=i(364),Md=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","root"],Od=n().forwardRef((function(n,i){var r=n.className,o=n.value,s=void 0===o?"":o,a=n.selection,u=n.extensions,l=void 0===u?[]:u,h=n.onChange,c=n.onUpdate,f=n.autoFocus,d=n.theme,v=void 0===d?"light":d,p=n.height,m=n.minHeight,g=n.maxHeight,y=n.width,k=n.minWidth,w=n.maxWidth,b=n.basicSetup,x=n.placeholder,S=n.indentWithTab,C=n.editable,A=n.root,M=function(t,e){if(null==t)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);return r}(n,Md),O=(0,e.useRef)(null),D=Cd({container:O.current,root:A,value:s,autoFocus:f,theme:v,height:p,minHeight:m,maxHeight:g,width:y,minWidth:k,maxWidth:w,basicSetup:b,placeholder:x,indentWithTab:S,editable:C,selection:a,onChange:h,onUpdate:c,extensions:l}),T=D.state,E=D.view,R=D.container,B=D.setContainer;if((0,e.useImperativeHandle)(i,(function(){return{editor:R,state:T,view:E}}),[R,T,E]),(0,e.useEffect)((function(){return B(O.current),function(){E&&E.destroy()}}),[]),"string"!==typeof s)throw new Error("value must be typeof string but got "+typeof s);var L="string"===typeof v?"cm-theme-"+v:"cm-theme";return(0,Ad.jsx)("div",t({ref:O,className:L+(r?" "+r:"")},M))}));Od.displayName="CodeMirror";var Dd=Od}(),r}()}));
|