2 lines
1.6 MiB
2 lines
1.6 MiB
export const ids=["1117"];export const modules={35709:function(t,e,i){var n=i(27847),s=i(72309),r=i(13465).f,o=n("unscopables"),h=Array.prototype;void 0===h[o]&&r(h,o,{configurable:!0,value:s(null)}),t.exports=function(t){h[o][t]=!0}},17743:function(t,e,i){var n=i(13053);t.exports=function(t,e,i){for(var s=0,r=arguments.length>2?i:n(e),o=new t(r);r>s;)o[s]=e[s++];return o}},37595:function(t,e,i){var n=i(31269),s=i(72878),r=i(25091),o=i(12360),h=i(70273),l=i(13053),a=i(72309),c=i(17743),u=Array,f=s([].push);t.exports=function(t,e,i,s){for(var d,g,p,m=o(t),w=r(m),v=n(e,i),y=a(null),b=l(w),x=0;b>x;x++)p=w[x],(g=h(v(p,x,m)))in y?f(y[g],p):y[g]=[p];if(s&&(d=s(m))!==u)for(g in y)y[g]=c(d,y[g]);return y}},81646:function(t){var e=RangeError;t.exports=function(t){if(t==t)return t;throw new e("NaN is not allowed")}},31126:function(t,e,i){var n=i(71998);t.exports=function(){var t=n(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e}},31922:function(t,e,i){var n=i(88045),s=RangeError;t.exports=function(t){var e=n(t);if(e<0)throw new s("The argument can't be less than 0");return e}},2480:function(t,e,i){var n=i(40810),s=i(97934),r=i(71998),o=i(4576),h=i(81646),l=i(31922),a=i(79995),c=i(92288),u=a((function(){for(var t,e=this.iterator,i=this.next;this.remaining;)if(this.remaining--,t=r(s(i,e)),this.done=!!t.done)return;if(t=r(s(i,e)),!(this.done=!!t.done))return t.value}));n({target:"Iterator",proto:!0,real:!0,forced:c},{drop:function(t){r(this);var e=l(h(+t));return new u(o(this),{remaining:e})}})},68107:function(t,e,i){var n=i(40810),s=i(73994),r=i(63983),o=i(71998),h=i(4576);n({target:"Iterator",proto:!0,real:!0},{every:function(t){o(this),r(t);var e=h(this),i=0;return!s(e,(function(e,n){if(!t(e,i++))return n()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},32517:function(t,e,i){var n=i(1569),s=i(85779),r=i(27803),o=i(31126),h=i(29660),l=n.RegExp,a=l.prototype;s&&h((function(){var t=!0;try{l(".","d")}catch(e){t=!1}var e={},i="",n=t?"dgimsy":"gimsy",s=function(t,n){Object.defineProperty(e,t,{get:function(){return i+=n,!0}})},r={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in t&&(r.hasIndices="d"),r)s(o,r[o]);return Object.getOwnPropertyDescriptor(a,"flags").get.call(e)!==n||i!==n}))&&r(a,"flags",{configurable:!0,get:o})},22139:function(t,e,i){var n=i(40810),s=i(37595),r=i(35709);n({target:"Array",proto:!0},{group:function(t){return s(this,t,arguments.length>1?arguments[1]:void 0)}}),r("group")},37210:function(t,e,i){i(2480)},92181:function(t,e,i){i(68107)},96232:function(t,e,i){i.d(e,{ys:()=>wf});i("92745"),i("32517"),i("39527"),i("92181"),i("99790"),i("67670"),i("13334"),i("34595"),i("36993"),i("92519"),i("42179"),i("89256"),i("24931"),i("88463"),i("57449"),i("19814"),i("41360");class n{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),r.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let i=[];return this.decompose(t,e,i,0),r.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new l(this),s=new l(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new l(this,t)}iterRange(t,e=this.length){return new a(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let e of t.children)f(e);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let e of t)f(e);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class a{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new l(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let f="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((t=>t?parseInt(t,36):1));for(let t=1;t<f.length;t++)f[t]+=f[t-1];function d(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function g(t){return t>=127462&&t<=127487}function p(t,e,i=!0,n=!0){return(i?m:w)(t,e,n)}function m(t,e,i){if(e==t.length)return e;e&&v(t.charCodeAt(e))&&y(t.charCodeAt(e-1))&&e--;let n=b(t,e);for(e+=x(n);e<t.length;){let s=b(t,e);if(8205==n||8205==s||i&&d(s))e+=x(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(b(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function w(t,e,i){for(;e>0;){let n=m(t,e-2,i);if(n<e)return n;e--}return 0}function v(t){return t>=56320&&t<57344}function y(t){return t>=55296&&t<56320}function b(t,e){let i=t.charCodeAt(e);if(!y(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return v(n)?n-56320+(i-55296<<10)+65536:i}function x(t){return t<65536?1:2}const S=/\r\n?|\n/;var k=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(k||(k={}));class A{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){D(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new A(t)}composeDesc(t){return this.empty?t:t.empty?this:E(this,t)}mapDesc(t,e=!1){return t.empty?this:T(this,t,e)}mapPos(t,e=-1,i=k.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=k.Simple&&l>=t&&(i==k.TrackDel&&n<t&&l>t||i==k.TrackBefore&&n<t||i==k.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new A(t)}static create(t){return new A(t)}}class M extends A{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return D(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return T(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new M(e,i)}compose(t){return this.empty?t:t.empty?this:E(this,t,!0)}map(t,e=!1){return t.empty?this:T(this,t,e,!0)}iterChanges(t,e=!1){D(this,t,e)}get desc(){return A.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new R(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);C(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;C(e,t,r),r>0&&O(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);C(e,t,-1),C(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new M(e,i),filtered:A.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&C(s,e-o,-1);let i=new M(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof M){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||S)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&C(s,t-o,-1),C(s,h-t,f),O(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new M(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new M(e,i)}static createSet(t,e){return new M(t,e)}}function C(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function O(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function D(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function T(t,e,i,n=!1){let s=[],r=n?[]:null,o=new R(t),h=new R(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);C(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(C(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(C(s,0,o.ins),r&&O(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?M.createSet(s,r):A.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}C(s,e,t<o.i?o.ins:0),r&&t<o.i&&O(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function E(t,e,i=!1){let n=[],s=i?[]:null,r=new R(t),o=new R(e);for(let t=!1;;){if(r.done&&o.done)return s?M.createSet(n,s):A.create(n);if(0==r.ins)C(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;C(n,e,i,t),s&&i&&O(s,n,o.text)}else-1==o.ins?(C(n,r.off?0:r.len,e,t),s&&O(s,n,r.textBit(e))):(C(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&O(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else C(n,0,o.ins,t),s&&O(s,n,o.text),o.next()}}class R{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?n.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class B{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let t=3&this.flags;return 3==t?null:t}get goalColumn(){let t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new B(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return P.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return P.range(this.anchor,i)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return P.range(t.anchor,t.head)}static create(t,e,i){return new B(t,e,i)}}class P{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:P.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new P([this.main],0)}addRange(t,e=!0){return P.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,P.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new P(t.ranges.map((t=>B.fromJSON(t))),t.main)}static single(t,e=t){return new P([P.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return P.normalized(t.slice(),e);i=s.to}return new P(t,e)}static cursor(t,e=0,i,n){return B.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?B.create(e,t,24|s):B.create(t,e,(e>t?4:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?P.range(o,r):P.range(r,o))}}return new P(t,e)}}function L(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let N=0;class I{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=N++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new I(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:H),!!t.static,t.enables)}of(t){return new V([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new V(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new V(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function H(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class V{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=N++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||F(t,a)){let e=i(t);if(o?!W(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=et(e,l);if(this.dependencies.every((i=>i instanceof I?e.facet(i)===t.facet(i):!(i instanceof q)||e.field(i,!1)==t.field(i,!1)))||(o?W(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function W(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function F(t,e){let i=!1;for(let n of e)1&tt(t,n)&&(i=!0);return i}function z(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=et(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)tt(t,e);return t.values[o]=h(t),1},update(t,i){if(!F(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=F(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&H(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const _=I.define({static:!0});class q{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new q(N++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(_).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,_.of({field:this,create:t})]}get extension(){return this}}const K=4,j=3,$=2,G=1;function J(t){return e=>new Y(e,t)}const U={highest:J(0),high:J(G),default:J($),low:J(j),lowest:J(K)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class X{of(t){return new Q(this,t)}reconfigure(t){return X.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Q{constructor(t,e){this.compartment=t,this.inner=e}}class Z{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Q&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Q){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof Y)r(t.inner,t.prec);else if(t instanceof q)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof V)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,$);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,$),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof q?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,H(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>z(t,n,e)))}}let c=l.map((t=>t(o)));return new Z(t,r,c,o,h,s)}}function tt(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function et(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const it=I.define(),nt=I.define({combine:t=>t.some((t=>t)),static:!0}),st=I.define({combine:t=>t.length?t[0]:void 0,static:!0}),rt=I.define(),ot=I.define(),ht=I.define(),lt=I.define({combine:t=>!!t.length&&t[0]});class at{constructor(t,e){this.type=t,this.value=e}static define(){return new ct}}class ct{of(t){return new at(this,t)}}class ut{constructor(t){this.map=t}of(t){return new ft(this,t)}}class ft{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new ft(this.type,e)}is(t){return this.type==t}static define(t={}){return new ut(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}ft.reconfigure=ft.define(),ft.appendConfig=ft.define();class dt{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&L(i,e.newLength),s.some((t=>t.type==dt.time))||(this.annotations=s.concat(dt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new dt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(dt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function gt(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function pt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=M.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:ft.mapEffects(t.effects,s).concat(ft.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function mt(t,e,i){let n=e.selection,s=yt(e.annotations);return e.userEvent&&(s=s.concat(dt.userEvent.of(e.userEvent))),{changes:e.changes instanceof M?e.changes:M.of(e.changes||[],i,t.facet(st)),selection:n&&(n instanceof P?n:P.single(n.anchor,n.head)),effects:yt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function wt(t,e,i){let n=mt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=pt(n,mt(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=dt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ht),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=pt(n,mt(e,r,t.changes.newLength),!0))}return n==t?t:dt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(rt)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:gt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=M.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=dt.create(e,n,t.selection&&t.selection.map(s),ft.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ot);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof dt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof dt?s[0]:wt(e,yt(s),!1)}return t}(s):s)}dt.time=at.define(),dt.userEvent=at.define(),dt.addToHistory=at.define(),dt.remote=at.define();const vt=[];function yt(t){return null==t?vt:Array.isArray(t)?t:[t]}var bt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(bt||(bt={}));const xt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let St;try{St=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function kt(t){return e=>{if(!/\S/.test(e))return bt.Space;if(function(t){if(St)return St.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||xt.test(i)))return!0}return!1}(e))return bt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return bt.Word;return bt.Other}}class At{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)tt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return tt(this,i),et(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return wt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(X.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(ft.reconfigure)?(i=null,n=e.value):e.is(ft.appendConfig)&&(i=null,n=yt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Z.resolve(n,s,this),e=new At(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new At(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:P.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=yt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=ft.mapEffects(r,l).concat(ft.mapEffects(yt(o.effects),a))}return{changes:n,selection:P.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof M?t:M.of(t,this.doc.length,this.facet(At.lineSeparator))}toText(t){return n.of(t.split(this.facet(At.lineSeparator)||S))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(tt(this,e),et(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof q&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return At.create({doc:t.doc,selection:P.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Z.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(At.lineSeparator)||S)),s=t.selection?t.selection instanceof P?t.selection:P.single(t.selection.anchor,t.selection.head):P.single(0);return L(s,i.length),e.staticFacet(nt)||(s=s.asSingle()),new At(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(At.tabSize)}get lineBreak(){return this.facet(At.lineSeparator)||"\n"}get readOnly(){return this.facet(lt)}phrase(t,...e){for(let e of this.facet(At.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(it))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return kt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=p(e,r,!1);if(s(e.slice(t,r))!=bt.Word)break;r=t}for(;o<n;){let t=p(e,o);if(s(e.slice(o,t))!=bt.Word)break;o=t}return r==o?null:P.range(r+i,o+i)}}function Mt(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}At.allowMultipleSelections=nt,At.tabSize=I.define({combine:t=>t.length?t[0]:4}),At.lineSeparator=st,At.readOnly=lt,At.phrases=I.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),At.languageData=it,At.changeFilter=rt,At.transactionFilter=ot,At.transactionExtender=ht,X.reconfigure=ft.define();class Ct{eq(t){return this==t}range(t,e=t){return Ot.create(t,e,this)}}Ct.prototype.startSide=Ct.prototype.endSide=0,Ct.prototype.point=!1,Ct.prototype.mapMode=k.TrackDel;class Ot{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Ot(t,e,i)}}function Dt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Tt{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Tt(n,s,i,o):null,pos:r}}}class Et{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Et(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Dt)),this.isEmpty)return e.length?Et.of(e):this;let o=new Pt(this,null,-1).goto(0),h=0,l=[],a=new Rt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Ot.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Et.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Et(i,e,s||Et.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Lt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Lt.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=Bt(r,o,i),l=new It(r,h,s),a=new It(o,h,s);i.iterGaps(((t,e,i)=>Ht(l,t,a,e,i,n))),i.empty&&0==i.length&&Ht(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=Bt(s,r),h=new It(s,o,0).goto(i),l=new It(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Vt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new It(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Rt;for(let n of t instanceof Ot?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Dt(e,n)>0)return t.slice().sort(Dt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Et.empty=new Et([],[],null,-1),Et.empty.nextLayer=Et.empty;class Rt{finishChunk(t){this.chunks.push(new Tt(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Rt)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Et.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Et.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Bt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Pt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Lt{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new Pt(r,e,i,s));return 1==n.length?n[0]:new Lt(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Nt(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Nt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Nt(this.heap,0)}}}function Nt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class It{constructor(t,e,i){this.minPoint=i,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=Lt.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){Wt(this.active,t),Wt(this.activeTo,t),Wt(this.activeRank,t),this.minActive=zt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;Ft(this.active,e,i),Ft(this.activeTo,e,n),Ft(this.activeRank,e,s),t&&Ft(t,e,this.cursor.from),this.minActive=zt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Wt(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Ht(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Vt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Vt(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Vt(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Wt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Ft(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function zt(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}i("84283"),i("37210");class _t{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Xt(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Kt.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Xt(this,t,e);let i=[];return this.decompose(t,e,i,0),Kt.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new Gt(this),s=new Gt(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new Gt(this,t)}iterRange(t,e=this.length){return new Jt(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new Ut(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new qt(t):Kt.from(qt.split(t,[])):_t.empty}}class qt extends _t{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new Yt(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new qt($t(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=jt(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new qt(e,t.length+s.length));else{let t=e.length>>1;i.push(new qt(e.slice(0,t)),new qt(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof qt))return super.replace(t,e,i);[t,e]=Xt(this,t,e);let n=jt(this.text,jt(i.text,$t(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new qt(n,s):Kt.from(qt.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=Xt(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new qt(i,n)),i=[],n=-1);return n>-1&&e.push(new qt(i,n)),e}}class Kt extends _t{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=Xt(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],o=s+r.length;if(t>=s&&e<=o){let h=r.replace(t-s,e-s,i),l=this.lines-r.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let s=this.children.slice();return s[n]=h,new Kt(s,this.length-(e-t)+i.length)}return super.replace(s,o,h)}s=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=Xt(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Kt))return 0;let i=0,[n,s,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==o)return i;let h=this.children[n],l=t.children[s];if(h!=l)return i+h.scanIdentical(l,e);i+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new qt(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],h=0,l=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof Kt)for(let e of t.children)c(e);else t.lines>r&&(h>r||!h)?(u(),o.push(t)):t instanceof qt&&h&&(e=a[a.length-1])instanceof qt&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,a[a.length-1]=new qt(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&u(),h+=t.lines,l+=t.length+1,a.push(t))}function u(){0!=h&&(o.push(1==a.length?a[0]:Kt.from(a,l)),l=-1,h=a.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new Kt(o,e)}}function jt(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function $t(t,e,i){return jt(t,[""],e,i)}_t.empty=new qt([""],0);class Gt{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof qt?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],r=s>>1,o=n instanceof qt?n.text.length:n.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof qt){let s=n.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[r+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof qt?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Jt{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new Gt(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class Ut{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(_t.prototype[Symbol.iterator]=function(){return this.iter()},Gt.prototype[Symbol.iterator]=Jt.prototype[Symbol.iterator]=Ut.prototype[Symbol.iterator]=function(){return this});class Yt{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function Xt(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let Qt="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((t=>t?parseInt(t,36):1));for(let t=1;t<Qt.length;t++)Qt[t]+=Qt[t-1];function Zt(t){for(let e=1;e<Qt.length;e+=2)if(Qt[e]>t)return Qt[e-1]<=t;return!1}function te(t){return t>=127462&&t<=127487}function ee(t,e,i=!0,n=!0){return(i?ie:ne)(t,e,n)}function ie(t,e,i){if(e==t.length)return e;e&&se(t.charCodeAt(e))&&re(t.charCodeAt(e-1))&&e--;let n=oe(t,e);for(e+=he(n);e<t.length;){let s=oe(t,e);if(8205==n||8205==s||i&&Zt(s))e+=he(s),n=s;else{if(!te(s))break;{let i=0,n=e-2;for(;n>=0&&te(oe(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function ne(t,e,i){for(;e>0;){let n=ie(t,e-2,i);if(n<e)return n;e--}return 0}function se(t){return t>=56320&&t<57344}function re(t){return t>=55296&&t<56320}function oe(t,e){let i=t.charCodeAt(e);if(!re(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return se(n)?n-56320+(i-55296<<10)+65536:i}function he(t){return t<65536?1:2}const le=/\r\n?|\n/;var ae=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(ae||(ae={}));class ce{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){ge(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new ce(t)}composeDesc(t){return this.empty?t:t.empty?this:me(this,t)}mapDesc(t,e=!1){return t.empty?this:pe(this,t,e)}mapPos(t,e=-1,i=ae.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=ae.Simple&&l>=t&&(i==ae.TrackDel&&n<t&&l>t||i==ae.TrackBefore&&n<t||i==ae.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ce(t)}static create(t){return new ce(t)}}class ue extends ce{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return ge(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return pe(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let r=e[n],o=e[n+1];if(o>=0){e[n]=o,e[n+1]=r;let h=n>>1;for(;i.length<h;)i.push(_t.empty);i.push(r?t.slice(s,s+r):_t.empty)}s+=r}return new ue(e,i)}compose(t){return this.empty?t:t.empty?this:me(this,t,!0)}map(t,e=!1){return t.empty?this:pe(this,t,e,!0)}iterChanges(t,e=!1){ge(this,t,e)}get desc(){return ce.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new we(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);fe(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;fe(e,t,r),r>0&&de(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);fe(e,t,-1),fe(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new ue(e,i),filtered:ce.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],r=0,o=null;function h(t=!1){if(!t&&!n.length)return;r<e&&fe(n,e-r,-1);let i=new ue(n,s);o=o?o.compose(i.map(o)):i,n=[],s=[],r=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof ue){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);h(),o=o?o.compose(l.map(o)):l}else{let{from:t,to:o=t,insert:a}=l;if(t>o||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=a?"string"==typeof a?_t.of(a.split(i||le)):a:_t.empty,u=c.length;if(t==o&&0==u)return;t<r&&h(),t>r&&fe(n,t-r,-1),fe(n,o-t,u),de(s,n,c),r=o}}(t),h(!o),o}static empty(t){return new ue(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(_t.empty);i[n]=_t.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new ue(e,i)}static createSet(t,e){return new ue(t,e)}}function fe(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function de(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(_t.empty);t.push(i)}}function ge(t,e,i){let n=t.inserted;for(let s=0,r=0,o=0;o<t.sections.length;){let h=t.sections[o++],l=t.sections[o++];if(l<0)s+=h,r+=h;else{let a=s,c=r,u=_t.empty;for(;a+=h,c+=l,l&&n&&(u=u.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)h=t.sections[o++],l=t.sections[o++];e(s,a,r,c,u),s=a,r=c}}}function pe(t,e,i,n=!1){let s=[],r=n?[]:null,o=new we(t),h=new we(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);fe(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(fe(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(fe(s,0,o.ins),r&&de(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?ue.createSet(s,r):ce.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}fe(s,e,t<o.i?o.ins:0),r&&t<o.i&&de(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function me(t,e,i=!1){let n=[],s=i?[]:null,r=new we(t),o=new we(e);for(let t=!1;;){if(r.done&&o.done)return s?ue.createSet(n,s):ce.create(n);if(0==r.ins)fe(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;fe(n,e,i,t),s&&i&&de(s,n,o.text)}else-1==o.ins?(fe(n,r.off?0:r.len,e,t),s&&de(s,n,r.textBit(e))):(fe(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&de(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else fe(n,0,o.ins,t),s&&de(s,n,o.text),o.next()}}class we{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?_t.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?_t.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class ve{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ve(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return ye.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return ye.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return ye.range(t.anchor,t.head)}static create(t,e,i){return new ve(t,e,i)}}class ye{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:ye.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new ye([this.main],0)}addRange(t,e=!0){return ye.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,ye.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ye(t.ranges.map((t=>ve.fromJSON(t))),t.main)}static single(t,e=t){return new ye([ye.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return ye.normalized(t.slice(),e);i=s.to}return new ye(t,e)}static cursor(t,e=0,i,n){return ve.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?ve.create(e,t,48|s):ve.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?ye.range(o,r):ye.range(r,o))}}return new ye(t,e)}}function be(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let xe=0;class Se{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=xe++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new Se(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:ke),!!t.static,t.enables)}of(t){return new Ae([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ae(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ae(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function ke(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class Ae{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=xe++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||Ce(t,a)){let e=i(t);if(o?!Me(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=ze(e,l);if(this.dependencies.every((i=>i instanceof Se?e.facet(i)===t.facet(i):!(i instanceof Te)||e.field(i,!1)==t.field(i,!1)))||(o?Me(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function Me(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function Ce(t,e){let i=!1;for(let n of e)1&Fe(t,n)&&(i=!0);return i}function Oe(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=ze(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)Fe(t,e);return t.values[o]=h(t),1},update(t,i){if(!Ce(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=Ce(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&ke(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const De=Se.define({static:!0});class Te{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new Te(xe++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(De).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,De.of({field:this,create:t})]}get extension(){return this}}const Ee=4,Re=3,Be=2,Pe=1;function Le(t){return e=>new Ie(e,t)}const Ne={highest:Le(0),high:Le(Pe),default:Le(Be),low:Le(Re),lowest:Le(Ee)};class Ie{constructor(t,e){this.inner=t,this.prec=e}}class He{of(t){return new Ve(this,t)}reconfigure(t){return He.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Ve{constructor(t,e){this.compartment=t,this.inner=e}}class We{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Ve&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Ve){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof Ie)r(t.inner,t.prec);else if(t instanceof Te)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof Ae)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,Be);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,Be),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof Te?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,ke(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>Oe(t,n,e)))}}let c=l.map((t=>t(o)));return new We(t,r,c,o,h,s)}}function Fe(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function ze(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const _e=Se.define(),qe=Se.define({combine:t=>t.some((t=>t)),static:!0}),Ke=Se.define({combine:t=>t.length?t[0]:void 0,static:!0}),je=Se.define(),$e=Se.define(),Ge=Se.define(),Je=Se.define({combine:t=>!!t.length&&t[0]});class Ue{constructor(t,e){this.type=t,this.value=e}static define(){return new Ye}}class Ye{of(t){return new Ue(this,t)}}class Xe{constructor(t){this.map=t}of(t){return new Qe(this,t)}}class Qe{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new Qe(this.type,e)}is(t){return this.type==t}static define(t={}){return new Xe(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}Qe.reconfigure=Qe.define(),Qe.appendConfig=Qe.define();class Ze{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&be(i,e.newLength),s.some((t=>t.type==Ze.time))||(this.annotations=s.concat(Ze.time.of(Date.now())))}static create(t,e,i,n,s,r){return new Ze(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Ze.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function ti(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function ei(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=ue.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:Qe.mapEffects(t.effects,s).concat(Qe.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ii(t,e,i){let n=e.selection,s=ri(e.annotations);return e.userEvent&&(s=s.concat(Ze.userEvent.of(e.userEvent))),{changes:e.changes instanceof ue?e.changes:ue.of(e.changes||[],i,t.facet(Ke)),selection:n&&(n instanceof ye?n:ye.single(n.anchor,n.head)),effects:ri(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function ni(t,e,i){let n=ii(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=ei(n,ii(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=Ze.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(Ge),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=ei(n,ii(e,r,t.changes.newLength),!0))}return n==t?t:Ze.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(je)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:ti(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=ue.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=Ze.create(e,n,t.selection&&t.selection.map(s),Qe.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet($e);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof Ze?s:Array.isArray(s)&&1==s.length&&s[0]instanceof Ze?s[0]:ni(e,ri(s),!1)}return t}(s):s)}Ze.time=Ue.define(),Ze.userEvent=Ue.define(),Ze.addToHistory=Ue.define(),Ze.remote=Ue.define();const si=[];function ri(t){return null==t?si:Array.isArray(t)?t:[t]}var oi=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(oi||(oi={}));const hi=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let li;try{li=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function ai(t){return e=>{if(!/\S/.test(e))return oi.Space;if(function(t){if(li)return li.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||hi.test(i)))return!0}return!1}(e))return oi.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return oi.Word;return oi.Other}}class ci{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Fe(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Fe(this,i),ze(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return ni(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(He.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(Qe.reconfigure)?(i=null,n=e.value):e.is(Qe.appendConfig)&&(i=null,n=ri(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=We.resolve(n,s,this),e=new ci(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(qe)?t.newSelection:t.newSelection.asSingle();new ci(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:ye.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=ri(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=Qe.mapEffects(r,l).concat(Qe.mapEffects(ri(o.effects),a))}return{changes:n,selection:ye.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof ue?t:ue.of(t,this.doc.length,this.facet(ci.lineSeparator))}toText(t){return _t.of(t.split(this.facet(ci.lineSeparator)||le))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Fe(this,e),ze(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof Te&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return ci.create({doc:t.doc,selection:ye.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=We.resolve(t.extensions||[],new Map),i=t.doc instanceof _t?t.doc:_t.of((t.doc||"").split(e.staticFacet(ci.lineSeparator)||le)),n=t.selection?t.selection instanceof ye?t.selection:ye.single(t.selection.anchor,t.selection.head):ye.single(0);return be(n,i.length),e.staticFacet(qe)||(n=n.asSingle()),new ci(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(ci.tabSize)}get lineBreak(){return this.facet(ci.lineSeparator)||"\n"}get readOnly(){return this.facet(Je)}phrase(t,...e){for(let e of this.facet(ci.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(_e))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return ai(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=ee(e,r,!1);if(s(e.slice(t,r))!=oi.Word)break;r=t}for(;o<n;){let t=ee(e,o);if(s(e.slice(o,t))!=oi.Word)break;o=t}return r==o?null:ye.range(r+i,o+i)}}ci.allowMultipleSelections=qe,ci.tabSize=Se.define({combine:t=>t.length?t[0]:4}),ci.lineSeparator=Ke,ci.readOnly=Je,ci.phrases=Se.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),ci.languageData=_e,ci.changeFilter=je,ci.transactionFilter=$e,ci.transactionExtender=Ge,He.reconfigure=Qe.define();class ui{eq(t){return this==t}range(t,e=t){return fi.create(t,e,this)}}ui.prototype.startSide=ui.prototype.endSide=0,ui.prototype.point=!1,ui.prototype.mapMode=ae.TrackDel;class fi{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new fi(t,e,i)}}function di(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class gi{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new gi(n,s,i,o):null,pos:r}}}class pi{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new pi(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(di)),this.isEmpty)return e.length?pi.of(e):this;let o=new vi(this,null,-1).goto(0),h=0,l=[],a=new mi;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(fi.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?pi.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new pi(i,e,s||pi.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return yi.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return yi.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=wi(r,o,i),l=new xi(r,h,s),a=new xi(o,h,s);i.iterGaps(((t,e,i)=>Si(l,t,a,e,i,n))),i.empty&&0==i.length&&Si(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=wi(s,r),h=new xi(s,o,0).goto(i),l=new xi(r,o,0).goto(i);for(;;){if(h.to!=l.to||!ki(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new xi(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new mi;for(let n of t instanceof fi?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(di(e,n)>0)return t.slice().sort(di);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return pi.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=pi.empty;n=n.nextLayer)e=new pi(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}pi.empty=new pi([],[],null,-1),pi.empty.nextLayer=pi.empty;class mi{finishChunk(t){this.chunks.push(new gi(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new mi)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(pi.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=pi.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function wi(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class vi{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class yi{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new vi(r,e,i,s));return 1==n.length?n[0]:new yi(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)bi(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)bi(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),bi(this.heap,0)}}}function bi(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class xi{constructor(t,e,i){this.minPoint=i,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=yi.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){Ai(this.active,t),Ai(this.activeTo,t),Ai(this.activeRank,t),this.minActive=Ci(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;Mi(this.active,e,i),Mi(this.activeTo,e,n),Mi(this.activeRank,e,s),t&&Mi(t,e,this.cursor.from),this.minActive=Ci(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ai(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Si(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&ki(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!ki(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function ki(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Ai(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Mi(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Ci(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}const Oi="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Di="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Ti="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Ei{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=Ti[Oi]||1;return Ti[Oi]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[Di],s=i&&i.nonce;n?s&&n.setNonce(s):n=new Bi(t,s),n.mount(Array.isArray(e)?e:[e])}}let Ri=new Map;class Bi{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=Ri.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[Di]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],Ri.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[Di]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var Pi=i("96318");function Li(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Ni(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function Ii(t,e){if(!e.anchorNode)return!1;try{return Ni(t,e.anchorNode)}catch(t){return!1}}function Hi(t){return 3==t.nodeType?Ui(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Vi(t,e,i,n){return!!i&&(Fi(t,e,i,n,-1)||Fi(t,e,i,n,1))}function Wi(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Fi(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:zi(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Wi(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?zi(t):0}}}function zi(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function _i(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function qi(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Ki(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class ji{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?zi(e):0),i,Math.min(t.focusOffset,i?zi(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let $i,Gi=null;function Ji(t){if(t.setActive)return t.setActive();if(Gi)return t.focus(Gi);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Gi?{get preventScroll(){return Gi={preventScroll:!0},!0}}:void 0),!Gi){Gi=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function Ui(t,e,i=e){let n=$i||($i=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Yi(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function Xi(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Qi(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class Zi{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Zi(t.parentNode,Wi(t),e)}static after(t,e){return new Zi(t.parentNode,Wi(t)+1,e)}}const tn=[];class en{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=en.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=nn(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=nn(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==zi(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!en.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=tn){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new sn(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function nn(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}en.prototype.breakAfter=0;class sn{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){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;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function rn(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function on(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,rn(t,a,c,h,l,n,0,s,r)}let hn="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ln="undefined"!=typeof document?document:{documentElement:{style:{}}};const an=/Edge\/(\d+)/.exec(hn.userAgent),cn=/MSIE \d/.test(hn.userAgent),un=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hn.userAgent),fn=!!(cn||un||an),dn=!fn&&/gecko\/(\d+)/i.test(hn.userAgent),gn=!fn&&/Chrome\/(\d+)/.exec(hn.userAgent),pn="webkitFontSmoothing"in ln.documentElement.style,mn=!fn&&/Apple Computer/.test(hn.vendor),wn=mn&&(/Mobile\/\w+/.test(hn.userAgent)||hn.maxTouchPoints>2);var vn={mac:wn||/Mac/.test(hn.platform),windows:/Win/.test(hn.platform),linux:/Linux|X11/.test(hn.platform),ie:fn,ie_version:cn?ln.documentMode||6:un?+un[1]:an?+an[1]:0,gecko:dn,gecko_version:dn?+(/Firefox\/(\d+)/.exec(hn.userAgent)||[0,0])[1]:0,chrome:!!gn,chrome_version:gn?+gn[1]:0,ios:wn,android:/Android\b/.test(hn.userAgent),webkit:pn,safari:mn,webkit_version:pn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=ln.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class yn extends en{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof yn)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new yn(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Zi(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?vn.chrome||vn.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=Ui(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];vn.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l);return o?_i(l,o<0):l||null}(this.dom,t,e)}}class bn extends en{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(Xi(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof bn&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(on(this,t,e,i?i.children.slice():[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new bn(this.mark,e,r)}domAtPos(t){return kn(this,t)}coordsAt(t,e){return Mn(this,t,e)}}class xn extends en{static create(t,e,i){return new xn(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=xn.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof xn&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof xn&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return _t.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):_t.empty}domAtPos(t){return(this.length?0==t:this.side>0)?Zi.before(this.dom):Zi.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return _i(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Sn extends en{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Sn&&t.side==this.side}split(){return new Sn(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?Zi.before(this.dom):Zi.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return _t.empty}get isHidden(){return!0}}function kn(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new Zi(i,0)}function An(t,e,i){let n,{children:s}=t;i>0&&e instanceof bn&&s.length&&(n=s[s.length-1])instanceof bn&&n.mark.eq(e.mark)?An(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function Mn(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Hi(e);return i[i.length-1]||null}(t)}function Cn(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}yn.prototype.children=xn.prototype.children=Sn.prototype.children=tn;const On=Object.create(null);function Dn(t,e,i){if(t==e)return!0;t||(t=On),e||(e=On);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function Tn(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function En(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class Rn extends en{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof Rn))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),on(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new Rn;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){Dn(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){An(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=Cn(e,this.attrs||{})),i&&(this.attrs=Cn({class:i},this.attrs||{}))}domAtPos(t){return kn(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(Xi(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&&(Tn(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&en.get(n)instanceof bn;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=en.get(n))||void 0===i?void 0:i.isEditable)||vn.ios&&this.children.some((t=>t instanceof yn))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof yn)||/[^ -~]/.test(i.text))return null;let n=Hi(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=Mn(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof Rn)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Bn extends en{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Bn&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?Zi.before(this.dom):Zi.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Bn(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return tn}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):_t.empty}domBoundsAround(){return null}become(t){return t instanceof Bn&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class Pn{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var Ln=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Ln||(Ln={}));class Nn extends ui{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new In(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Vn(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=Wn(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new Vn(t,e,i,n,t.widget||null,!0)}static line(t){return new Hn(t)}static set(t,e=!1){return pi.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Nn.none=pi.empty;class In extends Nn{constructor(t){let{start:e,end:i}=Wn(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof In&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&Dn(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}In.prototype.point=!1;class Hn extends Nn{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Hn&&this.spec.class==t.spec.class&&Dn(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Hn.prototype.mapMode=ae.TrackBefore,Hn.prototype.point=!0;class Vn extends Nn{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?ae.TrackBefore:ae.TrackAfter:ae.TrackDel}get type(){return this.startSide!=this.endSide?Ln.WidgetRange:this.startSide<=0?Ln.WidgetBefore:Ln.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Vn&&(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}range(t,e=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 super.range(t,e)}}function Wn(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function Fn(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}Vn.prototype.point=!0;class zn{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof Bn&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Rn),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(_n(new Sn(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof Bn||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(_n(new yn(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,r){if(this.disallowBlockEffectsFor[r]&&i instanceof Vn){if(i.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")}let o=e-t;if(i instanceof Vn)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Bn(i.widget||new qn("div"),o,i));else{let r=xn.create(i.widget||new qn("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(_n(new Sn(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(_n(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=s)}static build(t,e,i,n,s){let r=new zn(t,e,i,s);return r.openEnd=pi.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function _n(t,e){for(let i of e)t=new bn(i,[t],t.length);return t}class qn extends Pn{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}var Kn=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Kn||(Kn={}));const jn=Kn.LTR,$n=Kn.RTL;function Gn(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Jn=Gn("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Un=Gn("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Yn=Object.create(null),Xn=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Yn[e]=i,Yn[i]=-e}function Qn(t){return t<=247?Jn[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?Un[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Zn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ts{get dir(){return this.level%2?$n:jn}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}function es(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!es(n.inner,s.inner))return!1}return!0}const is=[];function ns(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=is[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(is[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new ts(l,g.from,f)),ss(t,g.direction==jn!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?is[d]!=h:is[d]==h))break;d++}u?ns(t,l,d,n+1,s,u,o):l<d&&o.push(new ts(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=is[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(is[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new ts(g.to,l,f)),ss(t,g.direction==jn!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?is[d-1]!=h:is[d-1]==h))break;d--}u?ns(t,d,l,n+1,s,u,o):d<l&&o.push(new ts(d,l,f)),l=d}}function ss(t,e,i,n,s,r,o){let h=e%2?2:1;!function(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=Qn(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),is[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=is[t];if(128==s)t<h-1&&e==is[t+1]&&24&e?s=is[t]=e:is[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==is[s];)s++;let r=t&&8==e||s<i&&8==is[s]?1==n?1:8:256;for(let e=t;e<s;e++)is[e]=r;t=s-1}else 8==s&&1==n&&(is[t]=1);e=s,7&s&&(n=s)}}}(t,s,r,n,h),function(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=Yn[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(Xn[t+1]==-i){let e=Xn[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(is[o]=is[Xn[t]]=i),h=t;break}}else{if(189==Xn.length)break;Xn[h++]=o,Xn[h++]=e,Xn[h++]=l}else if(2==(n=is[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=Xn[e+2];if(2&i)break;if(t)Xn[e+2]|=2;else{if(4&i)break;Xn[e+2]|=4}}}}}(t,s,r,n,h),function(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=is[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=is[o])break;o++}let a=1==r,c=a==(1==(o<e?is[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),is[--e]=c;l=o}else r=o,l++}}}(s,r,n,h),ns(t,s,r,e,i,n,o)}function rs(t,e,i){if(!t)return[new ts(0,0,e==$n?1:0)];if(e==jn&&!i.length&&!Zn.test(t))return os(t.length);if(i.length)for(;t.length>is.length;)is[is.length]=256;let n=[],s=e==jn?0:1;return ss(t,s,s,i,0,t.length,n),n}function os(t){return[new ts(0,t,0)]}let hs="";function ls(t,e,i,n,s){var r;let o=n.head-t.from,h=ts.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc),l=e[h],a=l.side(s,i);if(o==a){let t=h+=s?1:-1;if(t<0||t>=e.length)return null;l=e[h=t],o=l.side(!s,i),a=l.side(s,i)}let c=ee(t.text,o,l.forward(s,i));(c<l.from||c>l.to)&&(c=a),hs=t.text.slice(Math.min(o,c),Math.max(o,c));let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u&&c==a&&u.level+(s?0:1)<l.level?ye.cursor(u.side(!s,i)+t.from,u.forward(s,i)?1:-1,u.level):ye.cursor(c+t.from,l.forward(s,i)?-1:1,l.level)}function as(t,e,i){for(let n=e;n<i;n++){let e=Qn(t.charCodeAt(n));if(1==e)return jn;if(2==e||4==e)return $n}return jn}const cs=Se.define(),us=Se.define(),fs=Se.define(),ds=Se.define(),gs=Se.define(),ps=Se.define(),ms=Se.define(),ws=Se.define({combine:t=>t.some((t=>t))}),vs=Se.define({combine:t=>t.some((t=>t))});class ys{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new ys(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new ys(ye.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const bs=Qe.define({map:(t,e)=>t.map(e)});function xs(t,e,i){let n=t.facet(ds);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const Ss=Se.define({combine:t=>!t.length||t[0]});let ks=0;const As=Se.define();class Ms{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new Ms(ks++,t,i,n,(t=>{let e=[As.of(t)];return r&&e.push(Ts.of((e=>{let i=e.plugin(t);return i?r(i):Nn.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return Ms.define((e=>new t(e)),e)}}class Cs{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(xs(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){xs(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){xs(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Os=Se.define(),Ds=Se.define(),Ts=Se.define(),Es=Se.define(),Rs=Se.define(),Bs=Se.define();function Ps(t,e){let i=t.state.facet(Bs);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return pi.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let t=n.length-1;t>=0;t--,r--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=as(e.text,o,h)),r>0&&l.length&&(i=l[l.length-1]).to==o&&i.direction==s)i.to=h,l=i.inner;else{let t={from:o,to:h,direction:s,inner:[]};l.push(t),l=t.inner}}}}),s}const Ls=Se.define();function Ns(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Ls)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Is=Se.define();class Hs{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Hs(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Hs(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Hs(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Vs{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=ue.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Hs(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Vs(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class Ws extends en{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Rn],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Hs(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=-1;this.view.inputState.composing>=0&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)}));return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=zs(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new Hs(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=en.get(e);if(i instanceof bn)c.push({node:e,deco:i.mark});else{if(i instanceof Rn||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new In({inclusive:!0,attributes:En(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Hs(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(vn.ie||vn.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=function(t,e,i){let n=new qs;return pi.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=Hs.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=vn.chrome||vn.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof Bn&&t.widget instanceof Fs&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let r,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=e;if(i&&i.range.fromB<f&&i.range.toB>u){let t=zn.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=zn.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),r=t.content.concat(n).concat(e.content)}else({content:r,breakAtStart:o,openStart:h,openEnd:l}=zn.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);rn(this,p,m,d,g,r,o,h,l)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new yn(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new bn(i,[e],e.length);let i=new Rn;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=en.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&Ii(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(vn.gecko&&o.empty&&!this.hasComposition&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new Zi(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&(Vi(h.node,h.offset,c.anchorNode,c.anchorOffset)&&Vi(l.node,l.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{vn.android&&vn.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Li(this.view.root);if(t)if(o.empty){if(vn.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=_s(h.node,h.offset,1==t?1:-1);e&&(h=new Zi(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new Zi(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new Zi(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Vi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Li(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Rn.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=en.get(i.childNodes[n]);t instanceof Rn&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=en.get(i.childNodes[n]);t instanceof Rn&&(e=t.domAtPos(t.length))}return e?new Zi(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=en.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof Rn)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof Rn&&!(i instanceof Rn&&e>=0))&&(i=o,n=l),s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Rn))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof yn))return null;let s=ee(n.text,i);if(s==i)return null;let r=Ui(n.dom,i,s).getClientRects();for(let t=0;t<r.length;t++){let e=r[t];if(t==r.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==Kn.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?Hi(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Kn.RTL:Kn.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Rn){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=Hi(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new sn(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Nn.replace({widget:new Fs(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return Nn.set(t)}updateDeco(){let t=this.view.state.facet(Ts).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t)),e=!1,i=this.view.state.facet(Es).map(((t,i)=>{let n="function"==typeof t;return n&&(e=!0),n?t(this.view):t}));i.length&&(this.dynamicDecorationMap[t.length]=e,t.push(pi.join(i)));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=Ns(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;!function(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=qi(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=Ki(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n?e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r))):p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left,p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==Kn.LTR)}}class Fs extends Pn{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}}function zs(t,e){let i=t.observer.selectionRange,n=i.focusNode&&_s(i.focusNode,i.focusOffset,0);if(!n)return null;let s=e-n.offset;return{from:s,to:s+n.node.nodeValue.length,node:n.node}}function _s(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return{node:i,offset:n};if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=zi(i)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return{node:n,offset:s};if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}let qs=class{constructor(){this.changes=[]}compareRange(t,e){Fn(t,e,this.changes)}comparePoint(t,e){Fn(t,e,this.changes)}};function Ks(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function js(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function $s(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Gs(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Js(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Us(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=Hi(f);for(let d=0;d<t.length;d++){let g=t[d];s&&$s(s,g)&&(g=Gs(Js(g,s.bottom),s.top));let p=Ks(e,g),m=js(i,g);if(0==p&&0==m)return 3==f.nodeType?Ys(f,e,i):Us(f,e,i);if(!n||o>m||o==m&&r>p){n=f,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=f,a=g):i<g.top&&(!c||c.top>g.top)&&(l=f,c=g):a&&$s(a,g)?a=Js(a,g.bottom):c&&$s(c,g)&&(c=Gs(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Ys(n,f,i):u&&"false"!=n.contentEditable?Us(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Ys(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=Ui(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(vn.chrome||vn.gecko){Ui(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Xs(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=Ln.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:Qs(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Qs(t,h,o,c,u);let g=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:g,m=p.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=p.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||vn.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return Ui(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||vn.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Ui(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=Rn.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=Us(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function Qs(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=ee(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function Zs(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==Ln.Text))return t;return i}function tr(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=ls(s,r,o,h,i),a=hs;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function er(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function ir(t,e,i){let n=er(t.state.facet(Rs).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:ye.cursor(n,n<i.from?1:-1)}class nr{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){var e;this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,vn.safari&&t.contentDOM.addEventListener("input",(()=>null)),vn.gecko&&(e=t.contentDOM.ownerDocument,Tr.has(e)||(Tr.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{}))))}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=en.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let s=t.domEventHandlers[n];s&&i(n).handlers.push(sr(e.value,s))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let s=t.domEventObservers[n];s&&i(n).observers.push(sr(e.value,s))}}for(let t in cr)i(t).handlers.push(cr[t]);for(let t in ur)i(t).observers.push(ur[t]);return e}(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,r=i[t];r&&s!=!r.handlers.length&&(n.removeEventListener(t,this.handleEvent),r=null),r||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=t.keyCode&&hr.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0),vn.android&&vn.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!vn.ios||t.synthetic||t.altKey||t.metaKey||!((e=rr.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||or.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,Yi(this.view.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(vn.safari&&!vn.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function sr(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){xs(i.state,t)}}}const rr=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],or="dthko",hr=[16,17,18,20,91,92,224,225];function lr(t){return.7*Math.max(0,t)+8}class ar{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(Rs).map((e=>e(t)));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(ci.allowMultipleSelections)&&function(t,e){let i=t.state.facet(cs);return i.length?i[0](e):vn.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Li(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=kr(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let s=0,r=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},h=Ns(this.view);t.clientX-h.left<=o.left+6?s=-lr(o.left-t.clientX):t.clientX+h.right>=o.right-6&&(s=lr(t.clientX-o.right)),t.clientY-h.top<=o.top+6?r=-lr(o.top-t.clientY):t.clientY+h.bottom>=o.bottom-6&&(r=lr(t.clientY-o.bottom)),this.setScrollSpeed(s,r)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=er(this.atoms,n.from,0);t!=n.from&&(s=ye.cursor(t,-1))}else{let t=er(this.atoms,n.from,-1),e=er(this.atoms,n.to,1);t==n.from&&e==n.to||(s=ye.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?ye.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const cr=Object.create(null),ur=Object.create(null),fr=vn.ie&&vn.ie_version<15||vn.ios&&vn.webkit_version<604;function dr(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Mr&&n.selection.ranges.every((t=>t.empty))&&Mr==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:ye.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:ye.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function gr(t,e,i,n){if(1==n)return ye.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return ye.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=ee(s.text,r,!1):h=ee(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=ee(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=ee(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return ye.range(o+s.from,h+s.from)}(t.state,e,i);{let i=Rn.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,ye.range(s,r)}}ur.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},cr.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),ur.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ur.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},cr.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(fs))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=vr(t,e),n=kr(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=vr(t,e),a=gr(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=gr(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?ye.range(s,r):ye.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return ye.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?h:o?s.addRange(a):ye.create([a])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new ar(t,e,i,n)),n&&t.observer.ignore((()=>Ji(t.contentDOM)));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let pr=(t,e)=>t>=e.top&&t<=e.bottom,mr=(t,e,i)=>pr(e,i)&&t>=i.left&&t<=i.right;function wr(t,e,i,n){let s=Rn.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&mr(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&mr(i,n,h)?1:o&&pr(n,o)?-1:1}function vr(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:wr(t,i,e.clientX,e.clientY)}}const yr=vn.ie&&vn.ie_version<=11;let br=null,xr=0,Sr=0;function kr(t){if(!yr)return t.detail;let e=br,i=Sr;return br=t,Sr=Date.now(),xr=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(xr+1)%3:1}function Ar(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&function(t,e){let i=t.state.facet(us);return i.length?i[0](e):vn.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}cr.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=ye.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},cr.dragend=t=>(t.inputState.draggedContent=null,!1),cr.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&Ar(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Ar(t,e,i,!0),!0}return!1},cr.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=fr?null:e.clipboardData;return i?(dr(t,i.getData("text/plain")||i.getData("text/uri-text")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),dr(t,i.value)}),50)}(t),!1)};let Mr=null;cr.copy=cr.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;Mr=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=fr?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const Cr=Ue.define();function Or(t,e){let i=[];for(let n of t.facet(ms)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Cr.of(!0)}):null}function Dr(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Or(t.state,e);i?t.dispatch(i):t.update([])}}),10)}ur.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Dr(t)},ur.blur=t=>{t.observer.clearSelectionRange(),Dr(t)},ur.compositionstart=ur.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},ur.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,vn.chrome&&vn.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},ur.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},cr.beforeinput=(t,e)=>{var i;let n;if(vn.chrome&&vn.android&&(n=rr.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return!1};const Tr=new Set;const Er=["pre-wrap","normal","pre-line","break-spaces"];class Rr{constructor(t){this.lineWrapping=t,this.doc=_t.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Er.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Er.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class Br{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Pr{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?Ln.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Vn?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Pr(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Lr=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Lr||(Lr={}));const Nr=.001;class Ir{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>Nr&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Ir.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,Lr.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,Lr.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,Lr.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=_r.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new Vr(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new Fr(Ir.of(t.slice(0,e)),r,Ir.of(t.slice(i)))}}Ir.prototype.size=1;class Hr extends Ir{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Pr(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Vr extends Hr{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Pr(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Vr||n instanceof Wr&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Wr?n=new Vr(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Ir.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Wr extends Ir{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new Pr(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new Pr(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==Lr.ByHeight)return this.blockAt(t,i,n,s);if(e==Lr.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Pr(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new Pr(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new Pr(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Wr?i[i.length-1]=new Wr(t.length+n):i.push(null,new Wr(n-1))}if(t>0){let e=i[0];e instanceof Wr?i[0]=new Wr(t+e.length):i.unshift(new Wr(t-1),null)}return Ir.of(i)}decomposeLeft(t,e){e.push(new Wr(t-1),null)}decomposeRight(t,e){e.push(null,new Wr(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new Wr(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=Nr&&(o=-2);let h=new Vr(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Wr(s-r).updateHeight(t,r));let h=Ir.of(i);return(o<0||Math.abs(h.height-this.height)>=Nr||Math.abs(o-this.heightMetrics(t,e).perLine)>=Nr)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Fr extends Ir{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==Lr.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==Lr.ByPosNoHeight?Lr.ByPosNoHeight:Lr.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,Lr.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&zr(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),zr(s,t)}return Ir.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Ir.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)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function zr(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Wr&&(n=t[e+1])instanceof Wr&&t.splice(e-1,3,new Wr(i.length+1+n.length))}class _r{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Vr?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Vr(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new Hr(r,n,i)):(r||s||n>=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Vr(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Wr(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Vr)return t;let e=new Vr(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Vr||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Vr(0,-1));let i=t;for(let t of this.nodes)t instanceof Vr&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new _r(i,t);return pi.spans(e,i,n,s,0),s.finish(i)}}class qr{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Fn(t,e,this.changes,5)}}function Kr(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function jr(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class $r{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return Nn.replace({widget:new Gr(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class Gr extends Pn{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let 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}get estimatedHeight(){return this.vertical?this.size:-1}}class Jr{constructor(t){this.state=t,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.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Zr,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Kn.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Ds).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Rr(e),this.stateDeco=t.facet(Ts).filter((t=>"function"!=typeof t)),this.heightMap=Ir.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle.setDoc(t.doc),[new Hs(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Nn.set(this.lineGaps.map((t=>t.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new Ur(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?Zr:new to(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:eo(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Ts).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Hs.extendWithRanges(n,function(t,e,i){let n=new qr;return pi.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:ue.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),l&&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&&!t.state.facet(vs)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Kn.RTL:Kn.LTR;let r=this.heightOracle.mustRefreshForWrapping(s),o=e.getBoundingClientRect(),h=r||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let l=0,a=0;if(o.width&&o.height){let{scaleX:t,scaleY:i}=Ki(e,o);this.scaleX==t&&this.scaleY==i||(this.scaleX=t,this.scaleY=i,l|=8,r=h=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==c&&this.paddingBottom==u||(this.paddingTop=c,this.paddingBottom=u,l|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=8);let f=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=Qi(t.scrollDOM);let d=(this.printing?jr:Kr)(e,this.paddingTop),g=d.top-this.pixelViewport.top,p=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let w=o.width;if(this.contentDOMWidth==w&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,l|=8),h){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(r=!0),r||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:o,textHeight:h}=t.docView.measureTextSize();r=i>0&&n.refresh(s,i,o,h,w/o,e),r&&(t.docView.minWidth=0,l|=8)}g>0&&p>0?a=Math.max(g,p):g<0&&p<0&&(a=Math.min(g,p)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(r?Ir.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle,[new Hs(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,r,new Br(i.from,s))}n.heightChanged&&(l|=2)}let v=!this.viewportIsAppropriate(this.viewport,a)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(a,this.scrollTarget)),this.updateForViewport(),(2&l||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new Ur(n.lineAt(r-1e3*i,Lr.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),Lr.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,Lr.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new Ur(n.lineAt(i-500,Lr.ByHeight,s,0,0).from,n.lineAt(i+r+500,Lr.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Ur(this.heightMap.lineAt(i,Lr.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Lr.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Lr.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,Lr.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new $r(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,r=n<<1;if(this.defaultTextDirection!=Kn.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(ye.cursor(r),!1,!0).head;t>n&&(r=t)}f=new $r(n,r,this.gapSize(l,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.length<r)continue;let e=Yr(t.from,t.to,this.stateDeco);if(e.total<r)continue;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=Qr(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=Xr(e,i),o=Xr(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=Qr(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=Xr(e,t),o=Xr(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)}return o}gapSize(t,e,i,n){let s=Qr(n,i)-Qr(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){$r.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Nn.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];pi.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||eo(this.heightMap.lineAt(t,Lr.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return eo(this.heightMap.lineAt(this.scaler.fromDOM(t),Lr.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return eo(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Ur{constructor(t,e){this.from=t,this.to=e}}function Yr(t,e,i){let n=[],s=t,r=0;return pi.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function Xr({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function Qr(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const Zr={toDOM:t=>t,fromDOM:t=>t,scale:1};class to{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,Lr.ByPos,t,0,0).top,o=e.lineAt(s,Lr.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}}function eo(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Pr(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>eo(t,e))):t._content)}const io=Se.define({combine:t=>t.join(" ")}),no=Se.define({combine:t=>t.indexOf(!0)>-1}),so=Ei.newName(),ro=Ei.newName(),oo=Ei.newName(),ho={"&light":"."+ro,"&dark":"."+oo};function lo(t,e,i){return new Ei(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const ao=lo("."+so,{"&":{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,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},ho),co="";class uo{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(ci.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=co}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=en.get(n),o=en.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:go(n))||go(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=en.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(fo(t,i.node,i.offset)?e:0))}}function fo(t,e,i){for(;;){if(!e||i<zi(e))return!1;if(e==t)return!0;i=Wi(e)+1,e=e.parentNode}}function go(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class po{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class mo{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new po(i,n)),s==i&&r==n||e.push(new po(s,r)));return e}(t),i=new uo(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?ye.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!Ni(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!Ni(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if(vn.ios&&t.state.selection.main.empty&&i!=n&&(o.from>0||o.to<t.state.doc.length)){let e=o.from-Math.min(i,n),s=o.to-Math.max(i,n);0!=e&&1!=e||0!=s&&-1!=s||(i=0,n=t.state.doc.length)}this.newSel=ye.single(n,i)}}}function wo(t,e){let i,{newSel:n}=e,s=t.state.selection.main,r=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:o}=e.bounds,h=s.from,l=null;(8===r||vn.android&&e.text.length<o-n)&&(h=s.to,l="end");let a=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(n,o,co),e.text,h-n,l);a&&(vn.chrome&&13==r&&a.toB==a.from+2&&e.text.slice(a.from,a.toB)==co+co&&a.toB--,i={from:n+a.from,to:n+a.toA,insert:_t.of(e.text.slice(a.from,a.toB).split(co))})}else n&&(!t.hasFocus&&t.state.facet(Ss)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(vn.mac||vn.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=ye.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:_t.of([" "])}):vn.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=ye.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:_t.of([" "])}),i){if(vn.ios&&t.inputState.flushIOSKey())return!0;if(vn.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&Yi(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==r&&i.insert.length<i.to-i.from&&i.to>s.head)&&Yi(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&Yi(t.contentDOM,"Delete",46)))return!0;let e,o=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>e||(e=function(t,e,i){let n,s=t.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.from<e.from?s.sliceDoc(r.from,e.from):"",o=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=s.changes(e),h=i&&i.main.to<=o.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let l,a=t.state.sliceDoc(e.from,e.to),c=i&&zs(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-t}}else l=t.state.doc.lineAt(r.head);let u=r.to-e.to,f=r.to-r.from;n=s.changeByRange((i=>{if(i.from==r.from&&i.to==r.to)return{changes:o,range:h||i.map(o)};let n=i.to-u,c=n-a.length;if(i.to-i.from!=f||t.state.sliceDoc(c,n)!=a||i.to>=l.from&&i.from<=l.to)return{range:i};let d=s.changes({from:c,to:n,insert:e.insert}),g=i.to-r.to;return{changes:d,range:h?ye.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):i.map(d)}}))}else n={changes:o,selection:h&&s.selection.replaceRange(h)}}let o="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:o,scrollIntoView:!0})}(t,i,n));return t.state.facet(ps).some((e=>e(t,i.from,i.to,o,h)))||t.dispatch(h()),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}const vo={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},yo=vn.ie&&vn.ie_version<=11;class bo{constructor(t){this.view=t,this.active=!1,this.selectionRange=new ji,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(vn.ie&&vn.ie_version<=11||vn.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),yo&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Ss)?i.root.activeElement!=this.dom:!Ii(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(vn.ie&&vn.ie_version<=11||vn.android&&vn.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Vi(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=vn.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);Vi(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||Li(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=Ii(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,zi(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=zi(i))}else{if(i==t)return!0;n=Wi(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,vo),yo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),yo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Yi(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Ii(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new mo(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=wo(this.view,e);return this.view.state==i&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=xo(e,t.previousSibling||t.target.previousSibling,-1),n=xo(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function xo(t,e,i){for(;e;){let n=en.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}class So{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new Jr(t.state||ci.create(t)),t.scrollTo&&t.scrollTo.is(bs)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(As).map((t=>new Cs(t)));for(let t of this.plugins)t.update(this);this.observer=new bo(this),this.inputState=new nr(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ws(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof Ze?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(Cr)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=Or(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(ci.phrases)!=this.state.facet(ci.phrases))return this.setState(s);e=Vs.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new ys(t.empty?t:ye.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(bs)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=Mo.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Is)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(io)!=e.state.facet(io)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(gs))try{t(e)}catch(t){xs(this.state,t,"update listener")}(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!wo(this,a)&&l.force&&Yi(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new Jr(t),this.plugins=t.facet(As).map((t=>new Cs(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new Ws(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(As),i=t.state.facet(As);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Cs(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(Qi(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];4&o||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map((t=>{try{return t.read(this)}catch(t){return xs(this.state,t),Ao}})),a=Vs.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),c=this.docView.update(a));for(let t=0;t<h.length;t++)if(l[t]!=Ao)try{let e=h[t];e.write&&e.write(l[t],this)}catch(t){xs(this.state,t)}if(c&&this.docView.updateSelection(!0),!a.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(gs))t(e)}get themeClasses(){return so+" "+(this.state.facet(no)?oo:ro)+" "+this.state.facet(io)}updateAttrs(){let t=Co(this,Os,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Ss)?"true":"false",class:"cm-content",style:`${vn.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Co(this,Ds,e);let i=this.observer.ignore((()=>{let i=Tn(this.contentDOM,this.contentAttrs,e),n=Tn(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(So.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Is);let t=this.state.facet(So.cspNonce);Ei.mount(this.root,this.styleModules.concat(ao).reverse(),t?{nonce:t}:void 0)}readMeasured(){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)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return ir(this,t,tr(this,t,e,i))}moveByGroup(t,e){return ir(this,t,tr(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==oi.Space&&(s=e),s==e}}(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return ye.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=Zs(t,e.head),r=n&&s.type==Ln.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==Kn.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return ye.cursor(o,i?-1:1)}return ye.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return ir(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return ye.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s,e.assoc||-1),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(f+e)*r,n=Xs(t,{x:u,y:i},!1,r);if(i<l.top||i>l.bottom||(r<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return ye.cursor(n,s,void 0,h)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Xs(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return _i(i,s[ts.find(s,t-n.from,-1,e)].dir==Kn.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(ws)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>ko)return os(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||es(n.isolates,e=Ps(this,t))))return n.order;e||(e=Ps(this,t));let n=rs(t.text,i,e);return this.bidiCache.push(new Mo(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||vn.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{Ji(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return bs.of(new ys("number"==typeof t?ye.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return bs.of(new ys(ye.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return Ms.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return Ms.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=Ei.newName(),n=[io.of(i),Is.of(lo(`.${i}`,t))];return e&&e.dark&&n.push(no.of(!0)),n}static baseTheme(t){return Ne.lowest(Is.of(lo("."+so,t,ho)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&en.get(i)||en.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}So.styleModule=Is,So.inputHandler=ps,So.focusChangeEffect=ms,So.perLineTextDirection=ws,So.exceptionSink=ds,So.updateListener=gs,So.editable=Ss,So.mouseSelectionStyle=fs,So.dragMovesSelection=us,So.clickAddsSelectionRange=cs,So.decorations=Ts,So.outerDecorations=Es,So.atomicRanges=Rs,So.bidiIsolatedRanges=Bs,So.scrollMargins=Ls,So.darkTheme=no,So.cspNonce=Se.define({combine:t=>t.length?t[0]:""}),So.contentAttributes=Ds,So.editorAttributes=Os,So.lineWrapping=So.contentAttributes.of({class:"cm-lineWrapping"}),So.announce=Qe.define();const ko=4096,Ao={};class Mo{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:Kn.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new Mo(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function Co(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&Cn(r,i)}return i}const Oo=vn.mac?"mac":vn.windows?"win":vn.linux?"linux":"key";function Do(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const To=Se.define({enables:Ne.default(So.domEventHandlers({keydown:(t,e)=>Lo(Ro(e.state),t,e,"editor")}))}),Eo=new WeakMap;function Ro(t){let e=t.facet(To),i=Eo.get(e);return i||Eo.set(e,i=function(t,e=Oo){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},r=(t,n,r,o,h)=>{var l,a;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let t=0;t<i.length-1;++t){const h=i[t];if(/^(cmd|meta|m)$/i.test(h))o=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))r=!0;else{if(!/^mod$/i.test(h))throw new Error("Unrecognized modifier name: "+h);"mac"==e?o=!0:s=!0}}return n&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}(t,e)));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");s(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=Bo={view:e,prefix:i,scope:t};return setTimeout((()=>{Bo==n&&(Bo=null)}),Po),!0}]})}let f=u.join(" ");s(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(l=c._any)||void 0===l?void 0:l.run)||void 0===a?void 0:a.slice())||[]});r&&d.run.push(r),o&&(d.preventDefault=!0),h&&(d.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let e in t)t[e].run.push(n.any)}let s=n[e]||n.key;if(s)for(let e of t)r(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&r(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let Bo=null;const Po=4e3;function Lo(t,e,i,n){let s=(0,Pi.YG)(e),r=he(oe(s,0))==s.length&&" "!=s,o="",h=!1,l=!1,a=!1;Bo&&Bo.view==i&&Bo.scope==n&&(o=Bo.prefix+" ",hr.indexOf(e.keyCode)<0&&(l=!0,Bo=null));let c,u,f=new Set,d=t=>{if(t){for(let n of t.run)if(!f.has(n)&&(f.add(n),n(i,e)))return t.stopPropagation&&(a=!0),!0;t.preventDefault&&(t.stopPropagation&&(a=!0),l=!0)}return!1},g=t[n];return g&&(d(g[o+Do(s,e,!r)])?h=!0:r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(vn.windows&&e.ctrlKey&&e.altKey)&&(c=Pi.ue[e.keyCode])&&c!=s?(d(g[o+Do(c,e,!0)])||e.shiftKey&&(u=Pi.uY[e.keyCode])!=s&&u!=c&&d(g[o+Do(u,e,!1)]))&&(h=!0):r&&e.shiftKey&&d(g[o+Do(s,e,!0)])&&(h=!0),!h&&d(g._any)&&(h=!0)),l&&(h=!0),h&&a&&e.stopPropagation(),h}const No=!vn.ios;const Io={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};No&&(Io[".cm-line"].caretColor="transparent !important",Io[".cm-content"]={caretColor:"transparent !important"});const Ho="-10000px";class Vo{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter((t=>t)),this.tooltipViews=this.tooltips.map(i)}update(t,e){var i;let n=t.state.facet(this.facet),s=n.filter((t=>t));if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let r=[],o=e?[]:null;for(let i=0;i<s.length;i++){let n=s[i],h=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(h=t)}if(h<0)r[i]=this.createTooltipView(n),o&&(o[i]=!!n.above);else{let n=r[i]=this.tooltipViews[h];o&&(o[i]=e[h]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)r.indexOf(t)<0&&(t.dom.remove(),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(o.forEach(((t,i)=>e[i]=t)),e.length=o.length),this.input=n,this.tooltips=s,this.tooltipViews=r,!0}}function Wo(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const Fo=Se.define({combine:t=>{var e,i,n;return{position:vn.ios?"absolute":(null===(e=t.find((t=>t.position)))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find((t=>t.parent)))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find((t=>t.tooltipSpace)))||void 0===n?void 0:n.tooltipSpace)||Wo}}}),zo=new WeakMap,_o=Ms.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Fo);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new Vo(t,Ko,(t=>this.createTooltip(t))),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver((t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()}),{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){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}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout((()=>{this.measureTimeout=-1,this.maybeMeasure()}),50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(Fo);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t){let e=t.create(this.view);if(e.dom.classList.add("cm-tooltip"),t.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Ho,e.dom.style.left="0px",this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var t,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.intersectionObserver)||void 0===e||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=this.view.dom.getBoundingClientRect(),e=1,i=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(vn.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==Ho&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let t=this.parent.getBoundingClientRect();t.width&&t.height&&(e=t.width/this.parent.offsetWidth,i=t.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:i}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,pos:this.manager.tooltips.map(((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)})),size:this.manager.tooltipViews.map((({dom:t})=>t.getBoundingClientRect())),space:this.view.state.facet(Fo).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{editor:i,space:n,scaleX:s,scaleY:r}=t,o=[];for(let h=0;h<this.manager.tooltips.length;h++){let l=this.manager.tooltips[h],a=this.manager.tooltipViews[h],{dom:c}=a,u=t.pos[h],f=t.size[h];if(!u||u.bottom<=Math.max(i.top,n.top)||u.top>=Math.min(i.bottom,n.bottom)||u.right<Math.max(i.left,n.left)-.1||u.left>Math.min(i.right,n.right)+.1){c.style.top=Ho;continue}let d=l.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,g=d?7:0,p=f.right-f.left,m=null!==(e=zo.get(a))&&void 0!==e?e:f.bottom-f.top,w=a.offset||qo,v=this.view.textDirection==Kn.LTR,y=f.width>n.right-n.left?v?n.left:n.right-f.width:v?Math.min(u.left-(d?14:0)+w.x,n.right-p):Math.max(n.left,u.left-p+(d?14:0)-w.x),b=this.above[h];!l.strictSide&&(b?u.top-(f.bottom-f.top)-w.y<n.top:u.bottom+(f.bottom-f.top)+w.y>n.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=this.above[h]=!b);let x=(b?u.top-n.top:n.bottom-u.bottom)-g;if(x<m&&!1!==a.resize){if(x<this.view.defaultLineHeight){c.style.top=Ho;continue}zo.set(a,m),c.style.height=(m=x)/r+"px"}else c.style.height&&(c.style.height="");let S=b?u.top-m-g-w.y:u.bottom+g+w.y,k=y+p;if(!0!==a.overlap)for(let t of o)t.left<k&&t.right>y&&t.top<S+m&&t.bottom>S&&(S=b?t.top-m-2-g:t.bottom+g+2);if("absolute"==this.position?(c.style.top=(S-t.parent.top)/r+"px",c.style.left=(y-t.parent.left)/s+"px"):(c.style.top=S/r+"px",c.style.left=y/s+"px"),d){let t=u.left+(v?w.x:-w.x)-(y+14-7);d.style.left=t/s+"px"}!0!==a.overlap&&o.push({left:y,top:S,right:k,bottom:S+m}),c.classList.toggle("cm-tooltip-above",b),c.classList.toggle("cm-tooltip-below",!b),a.positioned&&a.positioned(t.space)}}maybeMeasure(){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)))for(let t of this.manager.tooltipViews)t.dom.style.top=Ho}},{eventObservers:{scroll(){this.maybeMeasure()}}}),qo={x:0,y:0},Ko=Se.define({enables:[_o,So.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&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:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}})]});function jo(t,e){let i=t.plugin(_o);if(!i)return null;let n=i.manager.tooltips.indexOf(e);return n<0?null:i.manager.tooltipViews[n]}class $o extends ui{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}$o.prototype.elementClass="",$o.prototype.toDOM=void 0,$o.prototype.mapMode=ae.TrackBefore,$o.prototype.startSide=$o.prototype.endSide=-1,$o.prototype.point=!0;var Go=i("70585"),Jo=i("29933");function Uo(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Yo(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function Xo(t,e){if(!e.anchorNode)return!1;try{return Yo(t,e.anchorNode)}catch(t){return!1}}function Qo(t){return 3==t.nodeType?ah(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Zo(t,e,i,n){return!!i&&(eh(t,e,i,n,-1)||eh(t,e,i,n,1))}function th(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function eh(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:ih(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=th(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?ih(t):0}}}function ih(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function nh(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function sh(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}class rh{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?ih(e):0),i,Math.min(t.focusOffset,i?ih(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let oh,hh=null;function lh(t){if(t.setActive)return t.setActive();if(hh)return t.focus(hh);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==hh?{get preventScroll(){return hh={preventScroll:!0},!0}}:void 0),!hh){hh=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function ah(t,e,i=e){let n=oh||(oh=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function ch(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function uh(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}class fh{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new fh(t.parentNode,th(t),e)}static after(t,e){return new fh(t.parentNode,th(t)+1,e)}}const dh=[];class gh{constructor(){this.parent=null,this.dom=null,this.dirty=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.dirty){let i,n=this.dom,s=null;for(let r of this.children){if(r.dirty){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=gh.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.dirty=0}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=ph(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=ph(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==ih(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!gh.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.dirty|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=dh){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new mh(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function ph(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}gh.prototype.breakAfter=0;class mh{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){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;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function wh(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function vh(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,wh(t,a,c,h,l,n,0,s,r)}let yh="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},bh="undefined"!=typeof document?document:{documentElement:{style:{}}};const xh=/Edge\/(\d+)/.exec(yh.userAgent),Sh=/MSIE \d/.test(yh.userAgent),kh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yh.userAgent),Ah=!!(Sh||kh||xh),Mh=!Ah&&/gecko\/(\d+)/i.test(yh.userAgent),Ch=!Ah&&/Chrome\/(\d+)/.exec(yh.userAgent),Oh="webkitFontSmoothing"in bh.documentElement.style,Dh=!Ah&&/Apple Computer/.test(yh.vendor),Th=Dh&&(/Mobile\/\w+/.test(yh.userAgent)||yh.maxTouchPoints>2);var Eh={mac:Th||/Mac/.test(yh.platform),windows:/Win/.test(yh.platform),linux:/Linux|X11/.test(yh.platform),ie:Ah,ie_version:Sh?bh.documentMode||6:kh?+kh[1]:xh?+xh[1]:0,gecko:Mh,gecko_version:Mh?+(/Firefox\/(\d+)/.exec(yh.userAgent)||[0,0])[1]:0,chrome:!!Ch,chrome_version:Ch?+Ch[1]:0,ios:Th,android:/Android\b/.test(yh.userAgent),webkit:Oh,safari:Dh,webkit_version:Oh?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=bh.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Rh extends gh{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof Rh&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Rh(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new fh(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return Ph(this.dom,t,e)}}class Bh extends gh{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(uh(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof Bh&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(vh(this,t,e,i?i.children:[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Bh(this.mark,e,r)}domAtPos(t){return zh(this,t)}coordsAt(t,e){return qh(this,t,e)}}function Ph(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?Eh.chrome||Eh.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=ah(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return Eh.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?nh(l,o<0):l||null}class Lh extends gh{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||Lh)(t,e,i)}split(t){let e=Lh.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Lh&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Lh&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return n.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):n.empty}domAtPos(t){return(this.length?0==t:this.side>0)?fh.before(this.dom):fh.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return nh(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Nh extends Lh{domAtPos(t){let{topView:e,text:i}=this.widget;return e?Ih(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new fh(t,Math.min(e,t.nodeValue.length)))):new fh(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:n}=this.widget;return i?Vh(t,e,i,n,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?Ih(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>Ph(t,e,i))):Ph(n,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function Ih(t,e,i,n,s,r,o){if(i instanceof Bh){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=gh.get(h);if(i){let l=Yo(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?Ih(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=Hh(t,e,h,o);if("number"!=typeof i)return i;t=i}}return r(i,i.length,-1)}return i.dom==n?o(n,t,e):r(i,t,e)}function Hh(t,e,i,n){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return n(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=Hh(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function Vh(t,e,i,n,s){if(i instanceof Bh){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=gh.get(o);if(i){let h=Yo(o,n);if(Yo(o,t))return r+(h?Vh(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=Wh(t,e,o);if(null!=i.result)return r+i.result;r+=i.size}}}else if(i.dom==n)return Math.min(e,n.nodeValue.length);return i.localPosFromDOM(t,e)}function Wh(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let n=0;for(let s=i.firstChild,r=0;;s=s.nextSibling,r++){if(t==i&&r==e)return{result:n};if(!s)return{size:n};let o=Wh(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class Fh extends gh{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Fh&&t.side==this.side}split(){return new Fh(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?fh.before(this.dom):fh.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.empty}get isHidden(){return!0}}function zh(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new fh(i,0)}function _h(t,e,i){let n,{children:s}=t;i>0&&e instanceof Bh&&s.length&&(n=s[s.length-1])instanceof Bh&&n.mark.eq(e.mark)?_h(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function qh(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Qo(e);return i[i.length-1]||null}(t)}function Kh(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function jh(t,e){if(t==e)return!0;if(!t||!e)return!1;let i=Object.keys(t),n=Object.keys(e);if(i.length!=n.length)return!1;for(let s of i)if(-1==n.indexOf(s)||t[s]!==e[s])return!1;return!0}function $h(t,e,i){let n=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(n=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(n=s,i[s]);return!!n}Rh.prototype.children=Lh.prototype.children=Fh.prototype.children=dh;class Gh{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get customView(){return null}get isHidden(){return!1}destroy(t){}}var Jh=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Jh||(Jh={}));class Uh extends Ct{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Yh(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Qh(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=Zh(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new Qh(t,e,i,n,t.widget||null,!0)}static line(t){return new Xh(t)}static set(t,e=!1){return Et.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Uh.none=Et.empty;class Yh extends Uh{constructor(t){let{start:e,end:i}=Zh(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof Yh&&this.tagName==t.tagName&&this.class==t.class&&jh(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Yh.prototype.point=!1;class Xh extends Uh{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Xh&&this.spec.class==t.spec.class&&jh(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}Xh.prototype.mapMode=k.TrackBefore,Xh.prototype.point=!0;class Qh extends Uh{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?k.TrackBefore:k.TrackAfter:k.TrackDel}get type(){return this.startSide<this.endSide?Jh.WidgetRange:this.startSide<=0?Jh.WidgetBefore:Jh.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Qh&&(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}range(t,e=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 super.range(t,e)}}function Zh(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function tl(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}Qh.prototype.point=!0;class el extends gh{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof el))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),vh(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new el;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){jh(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){_h(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=Kh(e,this.attrs||{})),i&&(this.attrs=Kh({class:i},this.attrs||{}))}domAtPos(t){return zh(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(uh(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&&($h(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&gh.get(n)instanceof Bh;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=gh.get(n))||void 0===i?void 0:i.isEditable)||Eh.ios&&this.children.some((t=>t instanceof Rh))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof Rh)||/[^ -~]/.test(i.text))return null;let n=Qo(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=qh(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return Jh.Text}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof el)return s;if(r>e)break}n=r+s.breakAfter}return null}}class il extends gh{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof il&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?fh.before(this.dom):fh.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new il(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return dh}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):n.empty}domBoundsAround(){return null}become(t){return t instanceof il&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.type=t.type,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class nl{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof il&&t.type==Jh.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new el),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(sl(new Fh(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(sl(new Rh(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,r){if(this.disallowBlockEffectsFor[r]&&i instanceof Qh){if(i.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")}let o=e-t;if(i instanceof Qh)if(i.block){let{type:t}=i;t!=Jh.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new il(i.widget||new rl("div"),o,t))}else{let r=Lh.create(i.widget||new rl("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(sl(new Fh(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(sl(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=s)}static build(t,e,i,n,s){let r=new nl(t,e,i,s);return r.openEnd=Et.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function sl(t,e){for(let i of e)t=new Bh(i,[t],t.length);return t}class rl extends Gh{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const ol=I.define(),hl=I.define(),ll=I.define(),al=I.define(),cl=I.define(),ul=I.define(),fl=I.define(),dl=I.define({combine:t=>t.some((t=>t))}),gl=I.define({combine:t=>t.some((t=>t))});class pl{constructor(t,e="nearest",i="nearest",n=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s}map(t){return t.empty?this:new pl(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const ml=ft.define({map:(t,e)=>t.map(e)});function wl(t,e,i){let n=t.facet(al);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const vl=I.define({combine:t=>!t.length||t[0]});let yl=0;const bl=I.define();class xl{constructor(t,e,i,n){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=n(this)}static define(t,e){const{eventHandlers:i,provide:n,decorations:s}=e||{};return new xl(yl++,t,i,(t=>{let e=[bl.of(t)];return s&&e.push(Ml.of((e=>{let i=e.plugin(t);return i?s(i):Uh.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return xl.define((e=>new t(e)),e)}}class Sl{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(wl(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){wl(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){wl(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const kl=I.define(),Al=I.define(),Ml=I.define(),Cl=I.define(),Ol=I.define();function Dl(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Ol)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Tl=I.define();class El{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new El(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new El(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new El(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Rl{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=M.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new El(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Rl(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Bl=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Bl||(Bl={}));const Pl=Bl.LTR,Ll=Bl.RTL;function Nl(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Il=Nl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Hl=Nl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Vl=Object.create(null),Wl=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Vl[e]=i,Vl[i]=-e}const Fl=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class zl{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?Ll:Pl}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}const _l=[];function ql(t,e){let i=t.length,n=e==Pl?1:2,s=e==Pl?2:1;if(!t||1==n&&!Fl.test(t))return Kl(i);for(let e=0,s=n,o=n;e<i;e++){let i=(r=t.charCodeAt(e))<=247?Il[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?Hl[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==i?i=s:8==i&&4==o&&(i=16),_l[e]=4==i?2:i,7&i&&(o=i),s=i}var r;for(let t=0,e=n,s=n;t<i;t++){let n=_l[t];if(128==n)t<i-1&&e==_l[t+1]&&24&e?n=_l[t]=e:_l[t]=256;else if(64==n){let n=t+1;for(;n<i&&64==_l[n];)n++;let r=t&&8==e||n<i&&8==_l[n]?1==s?1:8:256;for(let e=t;e<n;e++)_l[e]=r;t=n-1}else 8==n&&1==s&&(_l[t]=1);e=n,7&n&&(s=n)}for(let e,r,o,h=0,l=0,a=0;h<i;h++)if(r=Vl[e=t.charCodeAt(h)])if(r<0){for(let t=l-3;t>=0;t-=3)if(Wl[t+1]==-r){let e=Wl[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(_l[h]=_l[Wl[t]]=i),l=t;break}}else{if(189==Wl.length)break;Wl[l++]=h,Wl[l++]=e,Wl[l++]=a}else if(2==(o=_l[h])||1==o){let t=o==n;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=Wl[e+2];if(2&i)break;if(t)Wl[e+2]|=2;else{if(4&i)break;Wl[e+2]|=4}}}for(let t=0;t<i;t++)if(256==_l[t]){let e=t+1;for(;e<i&&256==_l[e];)e++;let s=1==(t?_l[t-1]:n),r=s==(1==(e<i?_l[e]:n))?s?1:2:n;for(let i=t;i<e;i++)_l[i]=r;t=e-1}let o=[];if(1==n)for(let t=0;t<i;){let e=t,n=1!=_l[t++];for(;t<i&&n==(1!=_l[t]);)t++;if(n)for(let i=t;i>e;){let t=i,n=2!=_l[--i];for(;i>e&&n==(2!=_l[i-1]);)i--;o.push(new zl(i,t,n?2:1))}else o.push(new zl(e,t,0))}else for(let t=0;t<i;){let e=t,n=2==_l[t++];for(;t<i&&n==(2==_l[t]);)t++;o.push(new zl(e,t,n?1:2))}return o}function Kl(t){return[new zl(0,t,0)]}let jl="";function $l(t,e,i,n,s){var r;let o=n.head-t.from,h=-1;if(0==o){if(!s||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),h=0)}else if(o==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),h=e.length-1)}h<0&&(h=zl.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc));let l=e[h];o==l.side(s,i)&&(l=e[h+=s?1:-1],o=l.side(!s,i));let a=s==(l.dir==i),c=p(t.text,o,a);if(jl=t.text.slice(Math.min(o,c),Math.max(o,c)),c!=l.side(s,i))return P.cursor(c+t.from,a?-1:1,l.level);let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u||l.level==i?u&&u.level<l.level?P.cursor(u.side(!s,i)+t.from,s?1:-1,u.level):P.cursor(c+t.from,s?-1:1,l.level):P.cursor(s?t.to:t.from,s?-1:1,i)}const Gl="";class Jl{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(At.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Gl}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=gh.get(n),o=gh.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:Ul(n))||Ul(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=gh.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}}function Ul(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Yl{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Xl extends gh{constructor(t){super(),this.view=t,this.compositionDeco=Uh.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new el],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new El(0,0,0,t.state.doc.length)],0)}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;this.minWidth>0&&e.length&&(e.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.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=Uh.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=Zl(t);if(!i)return Uh.none;let{from:n,to:s,node:r,text:o}=i,h=e.mapPos(n,1),l=Math.max(h,e.mapPos(s,-1)),{state:a}=t,c=new Jl([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(Gl)>-1)return Uh.none;if(l-h<u.length)if(a.doc.sliceString(h,Math.min(a.doc.length,h+u.length))==u)l=h+u.length;else{if(a.doc.sliceString(Math.max(0,l-u.length),l)!=u)return Uh.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return Uh.none;let f=gh.get(r);f instanceof Nh?f=f.widget.topView:f&&(f.parent=null);return Uh.set(Uh.replace({widget:new ta(r,o,f),inclusive:!0}).range(h,l))}(this.view,t.changes)),(Eh.ie||Eh.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=function(t,e,i){let n=new ia;return Et.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return e=El.extendWithRanges(e,i),(0!=this.dirty||0!=e.length)&&(this.updateInner(e,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=Eh.chrome||Eh.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof il&&t.widget instanceof Ql&&n.push(t.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let n=e>=0?t[e]:null;if(!n)break;let{fromA:s,toA:r,fromB:o,toB:h}=n,{content:l,breakAtStart:a,openStart:c,openEnd:u}=nl.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:g,off:p}=i.findPos(s,-1);wh(this,g,p,f,d,l,a,c,u)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&Xo(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.domAtPos(o.anchor),l=o.empty?h:this.domAtPos(o.head);if(Eh.gecko&&o.empty&&!this.compositionDeco.size&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new fh(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&Zo(h.node,h.offset,c.anchorNode,c.anchorOffset)&&Zo(l.node,l.offset,c.focusNode,c.focusOffset)||(this.view.observer.ignore((()=>{Eh.android&&Eh.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Uo(this.view.root);if(t)if(o.empty){if(Eh.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=ea(h.node,h.offset,1==t?1:-1);e&&(h=new fh(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=c.cursorBidiLevel&&(c.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new fh(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new fh(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=Uo(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=el.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}nearest(t){for(let e=t;e;){let t=gh.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof el)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,n=this.children.length-1;;n--){let s=this.children[n],r=i-s.breakAfter-s.length;if(t>r||t==r&&s.type!=Jh.WidgetBefore&&s.type!=Jh.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==Jh.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==Bl.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?Qo(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Bl.RTL:Bl.LTR}measureTextSize(){for(let t of this.children)if(t instanceof el){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=Qo(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new mh(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=e.lineBlockAt(r).bottom-e.lineBlockAt(i).top;t.push(Uh.replace({widget:new Ql(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return Uh.set(t)}updateDeco(){let t=this.view.state.facet(Ml).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=Dl(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};!function(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,u=c==l.body;if(u)t=sh(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let f=0,d=0;if("nearest"==s)e.top<t.top?(d=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+d&&(d=e.bottom-t.bottom+d+o)):e.bottom>t.bottom&&(d=e.bottom-t.bottom+o,i<0&&e.top-d<t.top&&(d=-(t.top+d-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;d=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n?e.left<t.left?(f=-(t.left-e.left+r),i>0&&e.right>t.right+f&&(f=e.right-t.right+f+r)):e.right>t.right&&(f=e.right-t.right+r,i<0&&e.left<t.left+f&&(f=-(t.left+f-e.left+r))):f=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left,f||d)if(u)a.scrollBy(f,d);else{let t=0,i=0;if(d){let t=c.scrollTop;c.scrollTop+=d,i=c.scrollTop-t}if(f){let e=c.scrollLeft;c.scrollLeft+=f,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-f)<1&&(n="nearest"),i&&Math.abs(i-d)<1&&(s="nearest")}if(u)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Bl.LTR)}}class Ql extends Gh{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function Zl(t){let e=t.observer.selectionRange,i=e.focusNode&&ea(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof el){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!gh.get(e);)e=e.previousSibling;let s=e?gh.get(e).posAtEnd:n.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=n;if(!t)return null;if(t instanceof el)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}class ta extends Gh{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return Nh}}function ea(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return i;if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=ih(i)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}class ia{constructor(){this.changes=[]}compareRange(t,e){tl(t,e,this.changes)}comparePoint(t,e){tl(t,e,this.changes)}}function na(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function sa(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function ra(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function oa(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function ha(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function la(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=Qo(f);for(let d=0;d<t.length;d++){let g=t[d];s&&ra(s,g)&&(g=oa(ha(g,s.bottom),s.top));let p=na(e,g),m=sa(i,g);if(0==p&&0==m)return 3==f.nodeType?aa(f,e,i):la(f,e,i);if(!n||o>m||o==m&&r>p){n=f,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=f,a=g):i<g.top&&(!c||c.top>g.top)&&(l=f,c=g):a&&ra(a,g)?a=ha(a,g.bottom):c&&ra(c,g)&&(c=oa(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?aa(n,f,i):u&&"false"!=n.contentEditable?la(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function aa(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=ah(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(Eh.chrome||Eh.gecko){ah(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function ca(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=Jh.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:ua(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:ua(t,h,o,c,u);let g=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:g,m=p.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=p.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||Eh.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return ah(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||Eh.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():ah(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=el.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=la(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function ua(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=p(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function fa(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==Jh.Text))return t;return i}function da(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=$l(s,r,o,h,i),a=jl;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=P.cursor(i?s.from:s.to)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function ga(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function pa(t,e,i){let n=ga(t.state.facet(Cl).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:P.cursor(n,n<i.from?1:-1)}class ma{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,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.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in ka){let n=ka[i];t.contentDOM.addEventListener(i,(i=>{Sa(t,i)&&e(n,i)}),Aa[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(ka.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),t.scrollDOM.addEventListener("drop",(i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(ka.drop,i)})),Eh.chrome&&102==Eh.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,Eh.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let n;this.customHandlers=[];for(let s of e)if(n=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:n});for(let e in n)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{Sa(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}}runCustomHandlers(t,e,i){for(let n of this.customHandlers){let s=n.handlers[t];if(s)try{if(s.call(n.plugin,i,e)||i.defaultPrevented)return!0}catch(t){wl(e.state,t)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,e,t)}catch(e){wl(t.state,e)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=e.keyCode&&ya.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),Eh.android&&Eh.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!Eh.ios||e.synthetic||e.altKey||e.metaKey||!((i=wa.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||va.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,ch(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Eh.safari&&!Eh.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const wa=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],va="dthko",ya=[16,17,18,20,91,92,224,225];function ba(t){return.7*Math.max(0,t)+8}class xa{constructor(t,e,i,n){this.view=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(Cl).map((e=>e(t)));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(At.allowMultipleSelections)&&function(t,e){let i=t.state.facet(ol);return i.length?i[0](e):Eh.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Uo(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Ia(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,n=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},r=Dl(this.view);t.clientX-r.left<=s.left+6?i=-ba(s.left-t.clientX):t.clientX+r.right>=s.right-6&&(i=ba(t.clientX-s.right)),t.clientY-r.top<=s.top+6?n=-ba(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-6&&(n=ba(t.clientY-s.bottom)),this.setScrollSpeed(i,n)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=ga(this.atoms,n.from,0);t!=n.from&&(s=P.cursor(t,-1))}else{let t=ga(this.atoms,n.from,-1),e=ga(this.atoms,n.to,1);t==n.from&&e==n.to||(s=P.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?P.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection)&&i.main.assoc==e.state.selection.main.assoc||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function Sa(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=gh.get(n))&&i.ignoreEvent(e))return!1;return!0}const ka=Object.create(null),Aa=Object.create(null),Ma=Eh.ie&&Eh.ie_version<15||Eh.ios&&Eh.webkit_version<604;function Ca(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Va&&n.selection.ranges.every((t=>t.empty))&&Va==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:P.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:P.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Oa(t,e,i,n){if(1==n)return P.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return P.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=p(s.text,r,!1):h=p(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=p(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=p(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return P.range(o+s.from,h+s.from)}(t.state,e,i);{let i=el.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,P.range(s,r)}}ka.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},ka.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},ka.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Aa.touchstart=Aa.touchmove={passive:!0},ka.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(ll))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Ra(t,e),n=Ia(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=Ra(t,e),a=Oa(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=Oa(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?P.range(s,r):P.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return P.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?h:o?s.addRange(a):P.create([a])}}}(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new xa(t,e,i,n)),n&&t.observer.ignore((()=>lh(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let Da=(t,e)=>t>=e.top&&t<=e.bottom,Ta=(t,e,i)=>Da(e,i)&&t>=i.left&&t<=i.right;function Ea(t,e,i,n){let s=el.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Ta(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Ta(i,n,h)?1:o&&Da(n,o)?-1:1}function Ra(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Ea(t,i,e.clientX,e.clientY)}}const Ba=Eh.ie&&Eh.ie_version<=11;let Pa=null,La=0,Na=0;function Ia(t){if(!Ba)return t.detail;let e=Pa,i=Na;return Pa=t,Na=Date.now(),La=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(La+1)%3:1}function Ha(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=t.inputState,o=n&&r&&r.dragging&&function(t,e){let i=t.state.facet(hl);return i.length?i[0](e):Eh.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.dragging.from,to:r.dragging.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}ka.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},ka.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let n=Array(i.length),s=0,r=()=>{++s==i.length&&Ha(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}}else Ha(t,e,e.dataTransfer.getData("Text"),!0)},ka.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=Ma?null:e.clipboardData;i?(Ca(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),Ca(t,i.value)}),50)}(t)};let Va=null;ka.copy=ka.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return;Va=s?i:null;let r=Ma?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const Wa=at.define();function Fa(t,e){let i=[];for(let n of t.facet(fl)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Wa.of(!0)}):null}function za(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Fa(t.state,e);i?t.dispatch(i):t.update([])}}),10)}ka.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),za(t)},ka.blur=t=>{t.observer.clearSelectionRange(),za(t)},ka.compositionstart=ka.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},ka.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Eh.chrome&&Eh.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},ka.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},ka.beforeinput=(t,e)=>{var i;let n;if(Eh.chrome&&Eh.android&&(n=wa.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};const _a=["pre-wrap","normal","pre-line","break-spaces"];class qa{constructor(t){this.lineWrapping=t,this.doc=n.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return _a.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=_a.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class Ka{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class ja{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?Jh.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Qh?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new ja(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var $a=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}($a||($a={}));const Ga=.001;class Ja{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>Ga&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Ja.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,$a.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,$a.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,$a.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=tc.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new Ya(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new Qa(Ja.of(t.slice(0,e)),r,Ja.of(t.slice(i)))}}Ja.prototype.size=1;class Ua extends Ja{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new ja(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ya extends Ua{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new ja(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Ya||n instanceof Xa&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Xa?n=new Ya(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Ja.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Xa extends Ja{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new ja(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new ja(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==$a.ByHeight)return this.blockAt(t,i,n,s);if(e==$a.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new ja(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new ja(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new ja(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Xa?i[i.length-1]=new Xa(t.length+n):i.push(null,new Xa(n-1))}if(t>0){let e=i[0];e instanceof Xa?i[0]=new Xa(t+e.length):i.unshift(new Xa(t-1),null)}return Ja.of(i)}decomposeLeft(t,e){e.push(new Xa(t-1),null)}decomposeRight(t,e){e.push(null,new Xa(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new Xa(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=Ga&&(o=-2);let h=new Ya(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Xa(s-r).updateHeight(t,r));let h=Ja.of(i);return(o<0||Math.abs(h.height-this.height)>=Ga||Math.abs(o-this.heightMetrics(t,e).perLine)>=Ga)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Qa extends Ja{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==$a.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==$a.ByPosNoHeight?$a.ByPosNoHeight:$a.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,$a.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&Za(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Za(s,t)}return Ja.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Ja.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)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Za(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Xa&&(n=t[e+1])instanceof Xa&&t.splice(e-1,3,new Xa(i.length+1+n.length))}class tc{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Ya?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Ya(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new Ua(r,n,i)):(r||s||n>=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Ya(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Xa(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Ya)return t;let e=new Ya(0,-1);return this.nodes.push(e),e}addBlock(t){var e;this.enterLine();let i=null===(e=t.deco)||void 0===e?void 0:e.type;i!=Jh.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=Jh.WidgetBefore&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Ya||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Ya(0,-1));let i=t;for(let t of this.nodes)t instanceof Ya&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new tc(i,t);return Et.spans(e,i,n,s,0),s.finish(i)}}class ec{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&tl(t,e,this.changes,5)}}function ic(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function nc(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class sc{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t){return Uh.replace({widget:new rc(this.size,t)}).range(this.from,this.to)}}class rc extends Gh{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let 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}get estimatedHeight(){return this.vertical?this.size:-1}}class oc{constructor(t){this.state=t,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.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=uc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Bl.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Al).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new qa(e),this.stateDeco=t.facet(Ml).filter((t=>"function"!=typeof t)),this.heightMap=Ja.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle.setDoc(t.doc),[new El(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Uh.set(this.lineGaps.map((t=>t.draw(!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new hc(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?uc:new fc(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:dc(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Ml).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=El.extendWithRanges(n,function(t,e,i){let n=new ec;return Et.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:M.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.lineBlockAtHeight(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),l&&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&&!t.state.facet(gl)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Bl.RTL:Bl.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0,u=parseInt(i.paddingTop)||0,f=parseInt(i.paddingBottom)||0;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8),this.scrollTop!=t.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=t.scrollDOM.scrollTop),this.scrolledToBottom=this.scrollTop>t.scrollDOM.scrollHeight-t.scrollDOM.clientHeight-4;let d=(this.printing?nc:ic)(e,this.paddingTop),g=d.top-this.pixelViewport.top,p=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let w=h.width;if(this.contentDOMWidth==w&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(e)&&(o=!0),o||s.lineWrapping&&Math.abs(w-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:n,textHeight:h}=t.docView.measureTextSize();o=i>0&&s.refresh(r,i,n,h,w/n,e),o&&(t.docView.minWidth=0,a|=8)}g>0&&p>0?c=Math.max(g,p):g<0&&p<0&&(c=Math.min(g,p)),s.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Ja.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle,[new El(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Ka(i.from,r))}s.heightChanged&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new hc(n.lineAt(r-1e3*i,$a.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),$a.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,$a.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new hc(n.lineAt(i-500,$a.ByHeight,s,0,0).from,n.lineAt(i+r+500,$a.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new hc(this.heightMap.lineAt(i,$a.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,$a.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,$a.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,$a.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new sc(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,r=n<<1;if(this.defaultTextDirection!=Bl.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(P.cursor(r),!1,!0).head;t>n&&(r=t)}f=new sc(n,r,this.gapSize(l,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.length<r)continue;let e=lc(t.from,t.to,this.stateDeco);if(e.total<r)continue;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=cc(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=ac(e,i),o=ac(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=cc(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=ac(e,t),o=ac(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)}return o}gapSize(t,e,i,n){let s=cc(n,i)-cc(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){sc.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Uh.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Et.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||dc(this.heightMap.lineAt(t,$a.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return dc(this.heightMap.lineAt(this.scaler.fromDOM(t),$a.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return dc(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class hc{constructor(t,e){this.from=t,this.to=e}}function lc(t,e,i){let n=[],s=t,r=0;return Et.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function ac({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function cc(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const uc={toDOM:t=>t,fromDOM:t=>t,scale:1};class fc{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,$a.ByPos,t,0,0).top,o=e.lineAt(s,$a.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}}function dc(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new ja(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>dc(t,e))):t._content)}const gc=I.define({combine:t=>t.join(" ")}),pc=I.define({combine:t=>t.indexOf(!0)>-1}),mc=Jo.V.newName(),wc=Jo.V.newName(),vc=Jo.V.newName(),yc={"&light":"."+wc,"&dark":"."+vc};function bc(t,e,i){return new Jo.V(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const xc=bc("."+mc,{"&":{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,flexShrink:0,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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},yc);class Sc{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new Yl(i,n)),s==i&&r==n||e.push(new Yl(s,r)));return e}(t),i=new Jl(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?P.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!Yo(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!Yo(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=P.single(n,i)}}}function kc(t,e){let i,{newSel:s}=e,r=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:h}=e.bounds,l=r.from,a=null;(8===o||Eh.android&&e.text.length<h-s)&&(l=r.to,a="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(s,h,Gl),e.text,l-s,a);c&&(Eh.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==Gl+Gl&&c.toB--,i={from:s+c.from,to:s+c.toA,insert:n.of(e.text.slice(c.from,c.toB).split(Gl))})}else s&&(!t.hasFocus&&t.state.facet(vl)||s.main.eq(r))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!r.empty&&s&&s.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(Eh.mac||Eh.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=P.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}):Eh.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=P.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}),i){let e=t.state;if(Eh.ios&&t.inputState.flushIOSKey(t))return!0;if(Eh.android&&(i.from==r.from&&i.to==r.to&&1==i.insert.length&&2==i.insert.lines&&ch(t.contentDOM,"Enter",13)||(i.from==r.from-1&&i.to==r.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from)&&ch(t.contentDOM,"Backspace",8)||i.from==r.from&&i.to==r.to+1&&0==i.insert.length&&ch(t.contentDOM,"Delete",46)))return!0;let n,h=i.insert.toString();if(t.state.facet(ul).some((e=>e(t,i.from,i.to,h))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=r.from&&i.to<=r.to&&i.to-i.from>=(r.to-r.from)/3&&(!s||s.main.empty&&s.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let s=r.from<i.from?e.sliceDoc(r.from,i.from):"",o=r.to>i.to?e.sliceDoc(i.to,r.to):"";n=e.replaceSelection(t.state.toText(s+i.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=e.changes(i),h=s&&s.main.to<=o.newLength?s.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=r.to&&i.to>=r.to-10){let s=t.state.sliceDoc(i.from,i.to),l=Zl(t)||t.state.doc.lineAt(r.head),a=r.to-i.to,c=r.to-r.from;n=e.changeByRange((n=>{if(n.from==r.from&&n.to==r.to)return{changes:o,range:h||n.map(o)};let u=n.to-a,f=u-s.length;if(n.to-n.from!=c||t.state.sliceDoc(f,u)!=s||l&&n.to>=l.from&&n.from<=l.to)return{range:n};let d=e.changes({from:f,to:u,insert:i.insert}),g=n.to-r.to;return{changes:d,range:h?P.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):n.map(d)}}))}else n={changes:o,selection:h&&e.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(n,{scrollIntoView:!0,userEvent:l}),!0}if(s&&!s.main.eq(r)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:s,scrollIntoView:e,userEvent:i}),!0}return!1}const Ac={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Mc=Eh.ie&&Eh.ie_version<=11;class Cc{constructor(t){this.view=t,this.active=!1,this.selectionRange=new rh,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(Eh.ie&&Eh.ie_version<=11||Eh.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Mc&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(vl)?i.root.activeElement!=this.dom:!Xo(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(Eh.ie&&Eh.ie_version<=11||Eh.android&&Eh.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Zo(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Eh.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);Zo(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||Uo(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=Xo(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,ih(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=ih(i))}else{if(i==t)return!0;n=th(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ac),Mc&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Mc&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&ch(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Xo(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new Sc(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,n=kc(this.view,e);return this.view.state==i&&this.view.update([]),n}readMutation(t){let 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){let i=Oc(e,t.previousSibling||t.target.previousSibling,-1),n=Oc(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,n;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(n=this.resizeContent)||void 0===n||n.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Oc(t,e,i){for(;e;){let n=gh.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}class Dc{constructor(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: fixed; 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=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new oc(t.state||At.create(t)),this.plugins=this.state.facet(bl).map((t=>new Sl(t)));for(let t of this.plugins)t.update(this);this.observer=new Cc(this),this.inputState=new ma(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new Xl(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){let e=1==t.length&&t[0]instanceof dt?t[0]:this.state.update(...t);this._dispatch(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(Wa)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=Fa(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(At.phrases)!=this.state.facet(At.phrases))return this.setState(s);e=Rl.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new pl(t.empty?t:P.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(ml)&&(c=t.value)}this.viewState.update(e,c),this.bidiCache=Rc.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Tl)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(gc)!=e.state.facet(gc)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(cl))t(e);(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!kc(this,a)&&l.force&&ch(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new oc(t),this.plugins=t.facet(bl).map((t=>new Sl(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new Xl(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(bl),i=t.state.facet(bl);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Sl(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,{scrollTop:n}=i,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;if(this.viewState.scrollAnchorHeight=-1,r<0||n!=this.viewState.scrollTop)if(n>i.scrollHeight-i.clientHeight-4)s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.lineBlockAtHeight(n);s=t.from,r=t.top}try{for(let t=0;;t++){this.updateState=1;let o=this.viewport,h=this.viewState.measure(this);if(!h&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&h||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(t){return wl(this.state,t),Ec}})),c=Rl.create(this,this.state,[]),u=!1,f=!1;c.flags|=h,e?e.flags|=h:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c));for(let t=0;t<l.length;t++)if(a[t]!=Ec)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){wl(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,f=!0;else if(r>-1){let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;(t>1||t<-1)&&(i.scrollTop=n+t,f=!0)}if(u&&this.docView.updateSelection(!0),this.viewport.from==o.from&&this.viewport.to==o.to&&!f&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(cl))t(e)}get themeClasses(){return mc+" "+(this.state.facet(pc)?vc:wc)+" "+this.state.facet(gc)}updateAttrs(){let t=Bc(this,kl,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(vl)?"true":"false",class:"cm-content",style:`${Eh.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Bc(this,Al,e);let i=this.observer.ignore((()=>{let i=$h(this.contentDOM,this.contentAttrs,e),n=$h(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Dc.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Tl),Jo.V.mount(this.root,this.styleModules.concat(xc).reverse())}readMeasured(){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)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return pa(this,t,da(this,t,e,i))}moveByGroup(t,e){return pa(this,t,da(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==bt.Space&&(s=e),s==e}}(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=fa(t,e.head),r=n&&s.type==Jh.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==Bl.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return P.cursor(o,i?-1:1)}return P.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return pa(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return P.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let i=0;;i+=10){let n=o+(f+i)*r,a=ca(t,{x:u,y:n},!1,r);if(n<l.top||n>l.bottom||(r<0?a<s:a>s))return P.cursor(a,e.assoc,void 0,h)}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),ca(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return nh(i,s[zl.find(s,t-n.from,-1,e)].dir==Bl.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(dl)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Tc)return Kl(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=ql(t.text,e);return this.bidiCache.push(new Rc(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Eh.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{lh(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return ml.of(new pl("number"==typeof t?P.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return xl.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=Jo.V.newName(),n=[gc.of(i),Tl.of(bc(`.${i}`,t))];return e&&e.dark&&n.push(pc.of(!0)),n}static baseTheme(t){return U.lowest(Tl.of(bc("."+mc,t,yc)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&gh.get(i)||gh.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Dc.styleModule=Tl,Dc.inputHandler=ul,Dc.focusChangeEffect=fl,Dc.perLineTextDirection=dl,Dc.exceptionSink=al,Dc.updateListener=cl,Dc.editable=vl,Dc.mouseSelectionStyle=ll,Dc.dragMovesSelection=hl,Dc.clickAddsSelectionRange=ol,Dc.decorations=Ml,Dc.atomicRanges=Cl,Dc.scrollMargins=Ol,Dc.darkTheme=pc,Dc.contentAttributes=Al,Dc.editorAttributes=kl,Dc.lineWrapping=Dc.contentAttributes.of({class:"cm-lineWrapping"}),Dc.announce=ft.define();const Tc=4096,Ec={};class Rc{constructor(t,e,i,n){this.from=t,this.to=e,this.dir=i,this.order=n}static update(t,e){if(e.empty)return t;let i=[],n=t.length?t[t.length-1].dir:Bl.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new Rc(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function Bc(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&Kh(r,i)}return i}const Pc=!Eh.ios;const Lc={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Pc&&(Lc[".cm-line"].caretColor="transparent !important");class Nc extends Ct{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Nc.prototype.elementClass="",Nc.prototype.toDOM=void 0,Nc.prototype.mapMode=k.TrackBefore,Nc.prototype.startSide=Nc.prototype.endSide=-1,Nc.prototype.point=!0;i("88972");let Ic=0;class Hc{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=Ic++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new Hc([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new Wc;return e=>e.modified.indexOf(t)>-1?e:Wc.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Vc=0;class Wc{constructor(){this.instances=[],this.id=Vc++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new Hc(n,t,e);for(let t of e)t.instances.push(s);let r=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of r)n.push(Wc.get(e,t));return s}}function Fc(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,h=i[o];if(!h)throw new RangeError("Invalid path: "+t);let l=new _c(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return zc.add(e)}const zc=new Go.md;class _c{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function qc(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}_c.empty=new _c([],2,null);const Kc=Hc.define,jc=Kc(),$c=Kc(),Gc=Kc($c),Jc=Kc($c),Uc=Kc(),Yc=Kc(Uc),Xc=Kc(Uc),Qc=Kc(),Zc=Kc(Qc),tu=Kc(),eu=Kc(),iu=Kc(),nu=Kc(iu),su=Kc(),ru={comment:jc,lineComment:Kc(jc),blockComment:Kc(jc),docComment:Kc(jc),name:$c,variableName:Kc($c),typeName:Gc,tagName:Kc(Gc),propertyName:Jc,attributeName:Kc(Jc),className:Kc($c),labelName:Kc($c),namespace:Kc($c),macroName:Kc($c),literal:Uc,string:Yc,docString:Kc(Yc),character:Kc(Yc),attributeValue:Kc(Yc),number:Xc,integer:Kc(Xc),float:Kc(Xc),bool:Kc(Uc),regexp:Kc(Uc),escape:Kc(Uc),color:Kc(Uc),url:Kc(Uc),keyword:tu,self:Kc(tu),null:Kc(tu),atom:Kc(tu),unit:Kc(tu),modifier:Kc(tu),operatorKeyword:Kc(tu),controlKeyword:Kc(tu),definitionKeyword:Kc(tu),moduleKeyword:Kc(tu),operator:eu,derefOperator:Kc(eu),arithmeticOperator:Kc(eu),logicOperator:Kc(eu),bitwiseOperator:Kc(eu),compareOperator:Kc(eu),updateOperator:Kc(eu),definitionOperator:Kc(eu),typeOperator:Kc(eu),controlOperator:Kc(eu),punctuation:iu,separator:Kc(iu),bracket:nu,angleBracket:Kc(nu),squareBracket:Kc(nu),paren:Kc(nu),brace:Kc(nu),content:Qc,heading:Zc,heading1:Kc(Zc),heading2:Kc(Zc),heading3:Kc(Zc),heading4:Kc(Zc),heading5:Kc(Zc),heading6:Kc(Zc),contentSeparator:Kc(Qc),list:Kc(Qc),quote:Kc(Qc),emphasis:Kc(Qc),strong:Kc(Qc),link:Kc(Qc),monospace:Kc(Qc),strikethrough:Kc(Qc),inserted:Kc(),deleted:Kc(),changed:Kc(),invalid:Kc(),meta:su,documentMeta:Kc(su),annotation:Kc(su),processingInstruction:Kc(su),definition:Hc.defineModifier(),constant:Hc.defineModifier(),function:Hc.defineModifier(),standard:Hc.defineModifier(),local:Hc.defineModifier(),special:Hc.defineModifier()};qc([{tag:ru.link,class:"tok-link"},{tag:ru.heading,class:"tok-heading"},{tag:ru.emphasis,class:"tok-emphasis"},{tag:ru.strong,class:"tok-strong"},{tag:ru.keyword,class:"tok-keyword"},{tag:ru.atom,class:"tok-atom"},{tag:ru.bool,class:"tok-bool"},{tag:ru.url,class:"tok-url"},{tag:ru.labelName,class:"tok-labelName"},{tag:ru.inserted,class:"tok-inserted"},{tag:ru.deleted,class:"tok-deleted"},{tag:ru.literal,class:"tok-literal"},{tag:ru.string,class:"tok-string"},{tag:ru.number,class:"tok-number"},{tag:[ru.regexp,ru.escape,ru.special(ru.string)],class:"tok-string2"},{tag:ru.variableName,class:"tok-variableName"},{tag:ru.local(ru.variableName),class:"tok-variableName tok-local"},{tag:ru.definition(ru.variableName),class:"tok-variableName tok-definition"},{tag:ru.special(ru.variableName),class:"tok-variableName2"},{tag:ru.definition(ru.propertyName),class:"tok-propertyName tok-definition"},{tag:ru.typeName,class:"tok-typeName"},{tag:ru.namespace,class:"tok-namespace"},{tag:ru.className,class:"tok-className"},{tag:ru.macroName,class:"tok-macroName"},{tag:ru.propertyName,class:"tok-propertyName"},{tag:ru.operator,class:"tok-operator"},{tag:ru.comment,class:"tok-comment"},{tag:ru.meta,class:"tok-meta"},{tag:ru.invalid,class:"tok-invalid"},{tag:ru.punctuation,class:"tok-punctuation"}]);var ou;const hu=new Go.md;const lu=new Go.md;class au{constructor(t,e,i=[],n=""){this.data=t,this.name=n,At.prototype.hasOwnProperty("tree")||Object.defineProperty(At.prototype,"tree",{get(){return uu(this)}}),this.parser=e,this.extension=[bu.of(this),At.languageData.of(((t,e,i)=>{let n=cu(t,e,i),s=n.type.prop(hu);if(!s)return[];let r=t.facet(s),o=n.type.prop(lu);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return cu(t,e,i).type.prop(hu)==this.data}findRegions(t){let e=t.facet(bu);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(hu)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(Go.md.mounted);if(s){if(s.tree.prop(hu)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof Go.mp&&n(s,t.positions[i]+e)}};return n(uu(t),0),i}get allowsNesting(){return!0}}function cu(t,e,i){let n=t.facet(bu),s=uu(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,Go.vj.ExcludeBuffers))t.type.isTop&&(s=t);return s}au.setState=ft.define();function uu(t){let e=t.field(au.state,!1);return e?e.tree:Go.mp.empty}class fu{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let du=null;class gu{constructor(t,e,i=[],n,s,r,o,h){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new gu(t,e,[],Go.mp.empty,0,i,[],null)}startParse(){return this.parser.startParse(new fu(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=Go.mp.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Go.i9.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(Go.i9.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=du;du=this;try{return t()}finally{du=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=pu(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s}))),i=Go.i9.applyChanges(i,e),n=Go.mp.empty,s=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&o.push({from:i,to:n})}}}return new gu(this.parser,e,i,n,s,r,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=pu(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Go._b{createParse(e,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let e=du;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=r,new Go.mp(Go.Jq.none,[],[],r-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return du}}function pu(t,e,i){return Go.i9.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class mu{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new mu(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=gu.create(t.facet(bu).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new mu(i)}}au.state=q.define({create:mu.init,update(t,e){for(let t of e.effects)if(t.is(au.setState))return t.value;return e.startState.facet(bu)!=e.state.facet(bu)?mu.init(e.state):t.apply(e)}});let wu=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(wu=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const vu="undefined"!=typeof navigator&&(null===(ou=navigator.scheduling)||void 0===ou?void 0:ou.isInputPending)?()=>navigator.scheduling.isInputPending():null,yu=xl.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(au.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)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(au.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=wu(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(au.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!vu?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>vu&&vu()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:au.setState.of(new mu(s.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>wl(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),bu=I.define({combine:t=>t.length?t[0]:null,enables:t=>[au.state,yu,Dc.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});class xu{constructor(t,e){let i;function n(t){let e=Jo.V.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,r=e.scope;this.scope=r instanceof au?t=>t.prop(hu)==r.data:r?t=>t==r:void 0,this.style=qc(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new Jo.V(i):null,this.themeType=e.themeType}static define(t,e){return new xu(t,e||{})}}ru.meta,ru.link,ru.heading,ru.emphasis,ru.strong,ru.strikethrough,ru.keyword,ru.atom,ru.bool,ru.url,ru.contentSeparator,ru.labelName,ru.literal,ru.inserted,ru.string,ru.deleted,ru.regexp,ru.escape,ru.string,ru.variableName,ru.variableName,ru.typeName,ru.namespace,ru.className,ru.variableName,ru.macroName,ru.propertyName,ru.comment,ru.invalid;const Su=Object.create(null),ku=[Go.Jq.none],Au=[],Mu=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Mu[t]=Ou(Su,e);function Cu(t,e){Au.indexOf(t)>-1||(Au.push(t),console.warn(e))}function Ou(t,e){let i=null;for(let n of e.split(".")){let e=t[n]||ru[n];e?"function"==typeof e?i?i=e(i):Cu(n,`Modifier ${n} used at start of tag`):i?Cu(n,`Tag ${n} used as modifier`):i=e:Cu(n,`Unknown highlighting tag ${n}`)}if(!i)return 0;let n=e.replace(/ /g,"_"),s=Go.Jq.define({id:ku.length,name:n,props:[Fc({[n]:i})]});return ku.push(s),s.id}class Du{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=uu(this.state).resolveInner(this.pos,-1);for(;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}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),s=n.search(Pu(t,!1));return s<0?null:{from:i+s,to:this.pos,text:n.slice(s)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Tu(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Eu(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=Tu(e)+Tu(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let s=t.matchBefore(n);return s||t.explicit?{from:s?s.from:t.pos,options:e,validFor:i}:null}}class Ru{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function Bu(t){return t.selection.main.from}function Pu(t,e){var i;let{source:n}=t,s=e&&"^"!=n[0],r="$"!=n[n.length-1];return s||r?new RegExp(`${s?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const Lu=at.define();const Nu=new WeakMap;function Iu(t){if(!Array.isArray(t))return t;let e=Nu.get(t);return e||Nu.set(t,e=Eu(t)),e}const Hu=ft.define(),Vu=ft.define();class Wu{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=b(t,e),n=x(i);this.chars.push(i);let s=t.slice(e,e+n),r=s.toUpperCase();this.folded.push(b(r==s?s.toLowerCase():r,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:s,byWord:r}=this;if(1==e.length){let n=b(t,0),s=x(n),r=s==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;r+=-200}return this.ret(r,[0,s])}let o=t.indexOf(this.pattern);if(0==o)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let h=e.length,l=0;if(o<0){for(let s=0,r=Math.min(t.length,200);s<r&&l<h;){let r=b(t,s);r!=e[l]&&r!=i[l]||(n[l++]=s),s+=x(r)}if(l<h)return null}let a=0,c=0,u=!1,f=0,d=-1,g=-1,p=/[a-z]/.test(t),m=!0;for(let n=0,l=Math.min(t.length,200),v=0;n<l&&c<h;){let l=b(t,n);o<0&&(a<h&&l==e[a]&&(s[a++]=n),f<h&&(l==e[f]||l==i[f]?(0==f&&(d=n),g=n+1,f++):f=0));let y,S=l<255?l>=48&&l<=57||l>=97&&l<=122?2:l>=65&&l<=90?1:0:(y=(w=l)<=65535?String.fromCharCode(w):(w-=65536,String.fromCharCode(55296+(w>>10),56320+(1023&w))))!=y.toLowerCase()?1:y!=y.toUpperCase()?2:0;(!n||1==S&&p||0==v&&0!=S)&&(e[c]==l||i[c]==l&&(u=!0)?r[c++]=n:r.length&&(m=!1)),v=S,n+=x(l)}var w;return c==h&&0==r[0]&&m?this.result((u?-200:0)-100,r,t):f==h&&0==d?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):f==h?this.ret(-900-t.length,[d,g]):c==h?this.result((u?-200:0)-100-700+(m?0:-1100),r,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],s=0;for(let t of e){let e=t+(this.astral?x(b(i,t)):1);s&&n[s-1]==t?n[s-1]=e:(n[s++]=t,n[s++]=e)}return this.ret(t-i.length,n)}}class Fu{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const zu=I.define({combine:t=>Mt(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:qu,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>_u(t(i),e(i)),optionClass:(t,e)=>i=>_u(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function _u(t,e){return t?e?t+" "+e:t:e}function qu(t,e,i,n,s,r){let o,h,l=t.textDirection==Kn.RTL,a=l,c=!1,u="top",f=e.left-s.left,d=s.right-e.right,g=n.right-n.left,p=n.bottom-n.top;if(a&&f<Math.min(g,d)?a=!1:!a&&d<Math.min(g,f)&&(a=!0),g<=(a?f:d))o=Math.max(s.top,Math.min(i.top,s.bottom-p))-e.top,h=Math.min(400,a?f:d);else{c=!0,h=Math.min(400,(l?e.right:s.right-e.left)-30);let t=s.bottom-e.bottom;t>=p||t>e.top?o=i.bottom-e.top:(u="bottom",o=e.bottom-i.top)}return{style:`${u}: ${o/((e.bottom-e.top)/r.offsetHeight)}px; max-width: ${h/((e.right-e.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(c?l?"left-narrow":"right-narrow":a?"left":"right")}}function Ku(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.floor((t-e)/i);return{from:t-(n+1)*i,to:t-n*i}}class ju{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:s,selected:r}=n.open,o=t.state.facet(zu);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let s=document.createElement("span");s.className="cm-completionLabel";let r=t.displayLabel||t.label,o=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>o&&s.appendChild(document.createTextNode(r.slice(o,e)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(r.slice(e,i))),h.className="cm-completionMatchedText",o=i}return o<r.length&&s.appendChild(document.createTextNode(r.slice(o))),s},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Ku(s.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,s=i.target;s&&s!=this.dom;s=s.parentNode)if("LI"==s.nodeName&&(e=/-(\d+)$/.exec(s.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault()})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(zu).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:Vu.of(null)})})),this.showOptions(s,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:s,selected:r,disabled:o}=i.open;n.open&&n.open.options==s||(this.range=Ku(s.length,r,t.state.facet(zu).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),o!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Ku(e.options.length,e.selected,this.view.state.facet(zu).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:i}=e.options[e.selected],{info:n}=i;if(!n)return;let s="string"==typeof n?document.createTextNode(n):n(i);if(!s)return;"then"in s?s.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,i)})).catch((t=>xs(this.view.state,t,"completion info"))):this.addInfoPane(s,i)}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected"):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),s=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/s:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/s)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),s=this.space;if(!s){let t=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:t.innerWidth,bottom:t.innerHeight}}return n.top>Math.min(s.bottom,e.bottom)-10||n.bottom<Math.max(s.top,e.top)+10?null:this.view.state.facet(zu).positionInfo(this.view,e,n,i,s,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions"));let s=null;for(let r=i.from;r<i.to;r++){let{completion:o,match:h}=t[r],{section:l}=o;if(l){let t="string"==typeof l?l:l.name;if(t!=s&&(r>i.from||0==i.from))if(s=t,"string"!=typeof l&&l.header)n.appendChild(l.header(l));else{n.appendChild(document.createElement("completion-section")).textContent=t}}const a=n.appendChild(document.createElement("li"));a.id=e+"-"+r,a.setAttribute("role","option");let c=this.optionClass(o);c&&(a.className=c);for(let t of this.optionContent){let e=t(o,this.view.state,this.view,h);e&&a.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function $u(t,e){return i=>new ju(i,t,e)}function Gu(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class Ju{constructor(t,e,i,n,s,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=s,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new Ju(this.options,Qu(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,s,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let o=function(t,e){let i=[],n=null,s=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},r=e.facet(zu);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)s(new Ru(e,n.source,t?t(e):[],1e9-i.length));else{let i,o=e.sliceDoc(n.from,n.to),h=r.filterStrict?new Fu(o):new Wu(o);for(let e of n.result.options)if(i=h.match(e.label)){let r=e.displayLabel?t?t(e,i.matched):[]:i.matched;s(new Ru(e,n.source,r,i.score+(e.boost||0)))}}}if(n){let t=Object.create(null),e=0,s=(t,e)=>{var i,n;return(null!==(i=t.rank)&&void 0!==i?i:1e9)-(null!==(n=e.rank)&&void 0!==n?n:1e9)||(t.name<e.name?-1:1)};for(let i of n.sort(s))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let o=[],h=null,l=r.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||l(t.completion,e.completion)))){let e=t.completion;!h||h.label!=e.label||h.detail!=e.detail||null!=h.type&&null!=e.type&&h.type!=e.type||h.apply!=e.apply||h.boost!=e.boost?o.push(t):Gu(t.completion)>Gu(h)&&(o[o.length-1]=t),h=t.completion}return o}(t,e);if(!o.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let h=e.facet(zu).selectOnOpen?0:-1;if(n&&n.selected!=h&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<o.length;e++)if(o[e].completion==t){h=e;break}}return new Ju(o,Qu(i,h),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:lf,above:s.aboveCursor},n?n.timestamp:Date.now(),h,!1)}map(t){return new Ju(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ju(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Uu{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Uu(Zu,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(zu),n=(i.override||e.languageDataAt("autocomplete",Bu(e)).map(Iu)).map((e=>(this.active.find((t=>t.source==e))||new ef(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let s=this.open,r=t.effects.some((t=>t.is(sf)));s&&t.docChanged&&(s=s.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let s=i==t.length,r=n==e.length;if(s||r)return s==r;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||r?s=Ju.build(n,e,this.id,s,i,r):s&&s.disabled&&!n.some((t=>t.isPending))&&(s=null),!s&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new ef(t.source,0):t)));for(let e of t.effects)e.is(rf)&&(s=s&&s.setSelected(e.value,this.id));return n==this.active&&s==this.open?this:new Uu(n,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Yu:Xu}}const Yu={"aria-autocomplete":"list"},Xu={};function Qu(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const Zu=[];function tf(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(Lu);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ef{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=tf(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new ef(n.source,0)),4&i&&0==n.state&&(n=new ef(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(Hu))n=new ef(n.source,1,e.value);else if(e.is(Vu))n=new ef(n.source,0);else if(e.is(sf))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Bu(t.state))}}class nf extends ef{constructor(t,e,i,n,s,r){super(t,3,e),this.limit=i,this.result=n,this.from=s,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let s=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),o=Bu(t.state);if(o>r||!n||2&e&&(Bu(t.startState)==this.from||o<this.limit))return new ef(this.source,4&e?1:0);let h=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let s=e.sliceDoc(i,n);return"function"==typeof t?t(s,i,n,e):Pu(t,!0).test(s)}(n.validFor,t.state,s,r)?new nf(this.source,this.explicit,h,n,s,r):n.update&&(n=n.update(n,s,r,new Du(t.state,o,!1)))?new nf(this.source,this.explicit,h,n,n.from,null!==(i=n.to)&&void 0!==i?i:Bu(t.state)):new ef(this.source,1,this.explicit)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new nf(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ef(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const sf=ft.define({map:(t,e)=>t.map((t=>t.map(e)))}),rf=ft.define(),of=q.define({create:()=>Uu.start(),update:(t,e)=>t.update(e),provide:t=>[Ko.from(t,(t=>t.tooltip)),So.contentAttributes.from(t,(t=>t.attrs))]});function hf(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(of).active.find((t=>t.source==e.source));return n instanceof nf&&("string"==typeof i?t.dispatch(Object.assign(Object.assign({},function(t,e,i,n){let{main:s}=t.selection,r=i-s.from,o=n-s.from;return Object.assign(Object.assign({},t.changeByRange((h=>{if(h!=s&&i!=n&&t.sliceDoc(h.from+r,h.from+o)!=t.sliceDoc(i,n))return{range:h};let l=t.toText(e);return{changes:{from:h.from+r,to:n==s.from?h.to:h.from+o,insert:l},range:P.cursor(h.from+r+l.length)}}))),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,i,n.from,n.to)),{annotations:Lu.of(e.completion)})):i(t,e.completion,n.from,n.to),!0)}const lf=$u(of,hf);function af(t,e="option"){return i=>{let n=i.state.field(of,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(zu).interactionDelay)return!1;let s,r=1;"page"==e&&(s=jo(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=n.open.options,h=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:o-1;return h<0?h="page"==e?0:o-1:h>=o&&(h="page"==e?o-1:0),i.dispatch({effects:rf.of(h)}),!0}}const cf=t=>!!t.state.field(of,!1)&&(t.dispatch({effects:Hu.of(!0)}),!0);class uf{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const ff=Ms.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(of).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(of),i=t.state.facet(zu);if(!t.selectionSet&&!t.docChanged&&t.startState.field(of)==e)return;let n=t.transactions.some((t=>{let e=tf(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){xs(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(Hu)))))&&(this.pendingStart=!0);let s=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),s):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(of);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(zu).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=Bu(e),n=new Du(e,i,t.explicit,this.view),s=new uf(t,n);this.running.push(s),Promise.resolve(t.source(n)).then((t=>{s.context.aborted||(s.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:Vu.of(null)}),xs(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(zu).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(zu),n=this.view.state.field(of);for(let s=0;s<this.running.length;s++){let r=this.running[s];if(void 0===r.done)continue;if(this.running.splice(s--,1),r.done){let n=Bu(r.updates.length?r.updates[0].startState:this.view.state),s=Math.min(n,r.done.from+(r.active.explicit?0:1)),o=new nf(r.active.source,r.active.explicit,s,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)o=o.update(t,i);if(o.hasResult()){e.push(o);continue}}let o=n.active.find((t=>t.source==r.active.source));if(o&&o.isPending)if(null==r.done){let t=new ef(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(o)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:sf.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(of,!1);if(e&&e.tooltip&&this.view.state.facet(zu).closeOnBlur){let i=e.open&&jo(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:Vu.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:Hu.of(!1)})),20),this.composing=0}}}),df="object"==typeof navigator&&/Win/.test(navigator.platform),gf=U.highest(So.domEventHandlers({keydown(t,e){let i=e.state.field(of,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!df||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],s=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||s.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&hf(e,n),!1}})),pf=So.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",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",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",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});const mf=new class extends Ct{};mf.startSide=1,mf.endSide=-1;"object"==typeof navigator&&navigator.userAgent;function wf(t={}){return[gf,of,zu.of(t),ff,yf,pf]}const vf=[{key:"Ctrl-Space",run:cf},{mac:"Alt-`",run:cf},{key:"Escape",run:t=>{let e=t.state.field(of,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:Vu.of(null)}),!0)}},{key:"ArrowDown",run:af(!0)},{key:"ArrowUp",run:af(!1)},{key:"PageDown",run:af(!0,"page")},{key:"PageUp",run:af(!1,"page")},{key:"Enter",run:t=>{let e=t.state.field(of,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(zu).interactionDelay)&&hf(t,e.open.options[e.open.selected])}}],yf=U.highest(To.computeN([zu],(t=>t.facet(zu).defaultKeymap?[vf]:[])))},92654:function(t,e,i){i.d(e,{at:()=>Rg,f$:()=>Id,m8:()=>yd,xi:()=>Bg,wQ:()=>Pg});i("92745"),i("39527"),i("92181"),i("99790"),i("13334"),i("36993"),i("32517"),i("92519"),i("42179"),i("89256"),i("24931"),i("88463"),i("57449"),i("19814"),i("67670"),i("41360"),i("34595");class n{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=f(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),r.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=f(this,t,e);let i=[];return this.decompose(t,e,i,0),r.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new l(this),s=new l(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new l(this,t)}iterRange(t,e=this.length){return new a(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);[t,e]=f(this,t,e);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=f(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=f(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let e of t.children)f(e);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let e of t)f(e);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class a{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new l(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function f(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let d="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((t=>t?parseInt(t,36):1));for(let t=1;t<d.length;t++)d[t]+=d[t-1];function g(t){for(let e=1;e<d.length;e+=2)if(d[e]>t)return d[e-1]<=t;return!1}function p(t){return t>=127462&&t<=127487}function m(t,e,i=!0,n=!0){return(i?w:v)(t,e,n)}function w(t,e,i){if(e==t.length)return e;e&&y(t.charCodeAt(e))&&b(t.charCodeAt(e-1))&&e--;let n=x(t,e);for(e+=S(n);e<t.length;){let s=x(t,e);if(8205==n||8205==s||i&&g(s))e+=S(s),n=s;else{if(!p(s))break;{let i=0,n=e-2;for(;n>=0&&p(x(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function v(t,e,i){for(;e>0;){let n=w(t,e-2,i);if(n<e)return n;e--}return 0}function y(t){return t>=56320&&t<57344}function b(t){return t>=55296&&t<56320}function x(t,e){let i=t.charCodeAt(e);if(!b(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return y(n)?n-56320+(i-55296<<10)+65536:i}function S(t){return t<65536?1:2}const k=/\r\n?|\n/;var A=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(A||(A={}));class M{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){T(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new M(t)}composeDesc(t){return this.empty?t:t.empty?this:R(this,t)}mapDesc(t,e=!1){return t.empty?this:E(this,t,e)}mapPos(t,e=-1,i=A.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=A.Simple&&l>=t&&(i==A.TrackDel&&n<t&&l>t||i==A.TrackBefore&&n<t||i==A.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new M(t)}static create(t){return new M(t)}}class C extends M{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return T(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return E(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new C(e,i)}compose(t){return this.empty?t:t.empty?this:R(this,t,!0)}map(t,e=!1){return t.empty?this:E(this,t,e,!0)}iterChanges(t,e=!1){T(this,t,e)}get desc(){return M.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new B(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);O(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;O(e,t,r),r>0&&D(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);O(e,t,-1),O(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new C(e,i),filtered:M.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&O(s,e-o,-1);let i=new C(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof C){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||k)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&O(s,t-o,-1),O(s,h-t,f),D(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new C(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new C(e,i)}static createSet(t,e){return new C(t,e)}}function O(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function D(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function T(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function E(t,e,i,n=!1){let s=[],r=n?[]:null,o=new B(t),h=new B(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);O(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(O(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(O(s,0,o.ins),r&&D(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?C.createSet(s,r):M.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}O(s,e,t<o.i?o.ins:0),r&&t<o.i&&D(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function R(t,e,i=!1){let n=[],s=i?[]:null,r=new B(t),o=new B(e);for(let t=!1;;){if(r.done&&o.done)return s?C.createSet(n,s):M.create(n);if(0==r.ins)O(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;O(n,e,i,t),s&&i&&D(s,n,o.text)}else-1==o.ins?(O(n,r.off?0:r.len,e,t),s&&D(s,n,r.textBit(e))):(O(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&D(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else O(n,0,o.ins,t),s&&D(s,n,o.text),o.next()}}class B{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?n.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class P{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new P(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return L.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return L.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return L.range(t.anchor,t.head)}static create(t,e,i){return new P(t,e,i)}}class L{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:L.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new L([this.main],0)}addRange(t,e=!0){return L.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,L.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new L(t.ranges.map((t=>P.fromJSON(t))),t.main)}static single(t,e=t){return new L([L.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return L.normalized(t.slice(),e);i=s.to}return new L(t,e)}static cursor(t,e=0,i,n){return P.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?P.create(e,t,48|s):P.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?L.range(o,r):L.range(r,o))}}return new L(t,e)}}function N(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let I=0;class H{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=I++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new H(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:V),!!t.static,t.enables)}of(t){return new W([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new W(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new W(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function V(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class W{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=I++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||z(t,a)){let e=i(t);if(o?!F(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=it(e,l);if(this.dependencies.every((i=>i instanceof H?e.facet(i)===t.facet(i):!(i instanceof K)||e.field(i,!1)==t.field(i,!1)))||(o?F(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function F(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function z(t,e){let i=!1;for(let n of e)1&et(t,n)&&(i=!0);return i}function _(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=it(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)et(t,e);return t.values[o]=h(t),1},update(t,i){if(!z(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=z(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&V(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const q=H.define({static:!0});class K{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new K(I++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(q).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,q.of({field:this,create:t})]}get extension(){return this}}const j=4,$=3,G=2,J=1;function U(t){return e=>new X(e,t)}const Y={highest:U(0),high:U(J),default:U(G),low:U($),lowest:U(j)};class X{constructor(t,e){this.inner=t,this.prec=e}}class Q{of(t){return new Z(this,t)}reconfigure(t){return Q.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Z{constructor(t,e){this.compartment=t,this.inner=e}}class tt{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Z&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Z){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof X)r(t.inner,t.prec);else if(t instanceof K)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof W)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,G);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,G),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof K?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,V(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>_(t,n,e)))}}let c=l.map((t=>t(o)));return new tt(t,r,c,o,h,s)}}function et(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function it(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const nt=H.define(),st=H.define({combine:t=>t.some((t=>t)),static:!0}),rt=H.define({combine:t=>t.length?t[0]:void 0,static:!0}),ot=H.define(),ht=H.define(),lt=H.define(),at=H.define({combine:t=>!!t.length&&t[0]});class ct{constructor(t,e){this.type=t,this.value=e}static define(){return new ut}}class ut{of(t){return new ct(this,t)}}class ft{constructor(t){this.map=t}of(t){return new dt(this,t)}}class dt{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new dt(this.type,e)}is(t){return this.type==t}static define(t={}){return new ft(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}dt.reconfigure=dt.define(),dt.appendConfig=dt.define();class gt{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&N(i,e.newLength),s.some((t=>t.type==gt.time))||(this.annotations=s.concat(gt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new gt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(gt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function pt(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function mt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=C.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:dt.mapEffects(t.effects,s).concat(dt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function wt(t,e,i){let n=e.selection,s=bt(e.annotations);return e.userEvent&&(s=s.concat(gt.userEvent.of(e.userEvent))),{changes:e.changes instanceof C?e.changes:C.of(e.changes||[],i,t.facet(rt)),selection:n&&(n instanceof L?n:L.single(n.anchor,n.head)),effects:bt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function vt(t,e,i){let n=wt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=mt(n,wt(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=gt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(lt),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=mt(n,wt(e,r,t.changes.newLength),!0))}return n==t?t:gt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(ot)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:pt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=C.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=gt.create(e,n,t.selection&&t.selection.map(s),dt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ht);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof gt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof gt?s[0]:vt(e,bt(s),!1)}return t}(s):s)}gt.time=ct.define(),gt.userEvent=ct.define(),gt.addToHistory=ct.define(),gt.remote=ct.define();const yt=[];function bt(t){return null==t?yt:Array.isArray(t)?t:[t]}var xt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(xt||(xt={}));const St=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let kt;try{kt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function At(t){return e=>{if(!/\S/.test(e))return xt.Space;if(function(t){if(kt)return kt.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||St.test(i)))return!0}return!1}(e))return xt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return xt.Word;return xt.Other}}class Mt{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)et(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return et(this,i),it(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return vt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Q.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(dt.reconfigure)?(i=null,n=e.value):e.is(dt.appendConfig)&&(i=null,n=bt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=tt.resolve(n,s,this),e=new Mt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(st)?t.newSelection:t.newSelection.asSingle();new Mt(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:L.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=bt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=dt.mapEffects(r,l).concat(dt.mapEffects(bt(o.effects),a))}return{changes:n,selection:L.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof C?t:C.of(t,this.doc.length,this.facet(Mt.lineSeparator))}toText(t){return n.of(t.split(this.facet(Mt.lineSeparator)||k))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(et(this,e),it(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof K&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return Mt.create({doc:t.doc,selection:L.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=tt.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(Mt.lineSeparator)||k)),s=t.selection?t.selection instanceof L?t.selection:L.single(t.selection.anchor,t.selection.head):L.single(0);return N(s,i.length),e.staticFacet(st)||(s=s.asSingle()),new Mt(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Mt.tabSize)}get lineBreak(){return this.facet(Mt.lineSeparator)||"\n"}get readOnly(){return this.facet(at)}phrase(t,...e){for(let e of this.facet(Mt.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(nt))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return At(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=m(e,r,!1);if(s(e.slice(t,r))!=xt.Word)break;r=t}for(;o<n;){let t=m(e,o);if(s(e.slice(o,t))!=xt.Word)break;o=t}return r==o?null:L.range(r+i,o+i)}}Mt.allowMultipleSelections=st,Mt.tabSize=H.define({combine:t=>t.length?t[0]:4}),Mt.lineSeparator=rt,Mt.readOnly=at,Mt.phrases=H.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Mt.languageData=nt,Mt.changeFilter=ot,Mt.transactionFilter=ht,Mt.transactionExtender=lt,Q.reconfigure=dt.define();class Ct{eq(t){return this==t}range(t,e=t){return Ot.create(t,e,this)}}Ct.prototype.startSide=Ct.prototype.endSide=0,Ct.prototype.point=!1,Ct.prototype.mapMode=A.TrackDel;class Ot{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Ot(t,e,i)}}function Dt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Tt{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Tt(n,s,i,o):null,pos:r}}}class Et{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Et(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Dt)),this.isEmpty)return e.length?Et.of(e):this;let o=new Pt(this,null,-1).goto(0),h=0,l=[],a=new Rt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Ot.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Et.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Et(i,e,s||Et.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Lt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Lt.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=Bt(r,o,i),l=new It(r,h,s),a=new It(o,h,s);i.iterGaps(((t,e,i)=>Ht(l,t,a,e,i,n))),i.empty&&0==i.length&&Ht(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=Bt(s,r),h=new It(s,o,0).goto(i),l=new It(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Vt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new It(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Rt;for(let n of t instanceof Ot?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Dt(e,n)>0)return t.slice().sort(Dt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Et.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Et.empty;n=n.nextLayer)e=new Et(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Et.empty=new Et([],[],null,-1),Et.empty.nextLayer=Et.empty;class Rt{finishChunk(t){this.chunks.push(new Tt(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Rt)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Et.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Et.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Bt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Pt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Lt{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new Pt(r,e,i,s));return 1==n.length?n[0]:new Lt(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Nt(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Nt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Nt(this.heap,0)}}}function Nt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class It{constructor(t,e,i){this.minPoint=i,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=Lt.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){Wt(this.active,t),Wt(this.activeTo,t),Wt(this.activeRank,t),this.minActive=zt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;Ft(this.active,e,i),Ft(this.activeTo,e,n),Ft(this.activeRank,e,s),t&&Ft(t,e,this.cursor.from),this.minActive=zt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Wt(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Ht(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Vt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Vt(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Vt(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Wt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Ft(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function zt(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}function _t(t,e,i=t.length){let n=0;for(let s=0;s<i;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=m(t,s));return n}i("84283"),i("37210");const qt="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Kt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),jt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class $t{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=jt[qt]||1;return jt[qt]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[Kt],s=i&&i.nonce;n?s&&n.setNonce(s):n=new Jt(t,s),n.mount(Array.isArray(e)?e:[e])}}let Gt=new Map;class Jt{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=Gt.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[Kt]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],Gt.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[Kt]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}i("96318");function Ut(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Yt(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function Xt(t,e){if(!e.anchorNode)return!1;try{return Yt(t,e.anchorNode)}catch(t){return!1}}function Qt(t){return 3==t.nodeType?ue(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Zt(t,e,i,n){return!!i&&(ie(t,e,i,n,-1)||ie(t,e,i,n,1))}function te(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function ee(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ie(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:ne(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=te(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?ne(t):0}}}function ne(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function se(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function re(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function oe(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class he{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?ne(e):0),i,Math.min(t.focusOffset,i?ne(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let le,ae=null;function ce(t){if(t.setActive)return t.setActive();if(ae)return t.focus(ae);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==ae?{get preventScroll(){return ae={preventScroll:!0},!0}}:void 0),!ae){ae=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function ue(t,e,i=e){let n=le||(le=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function fe(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,t.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function de(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function ge(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function pe(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=ne(i)}else{if(!i.parentNode||ee(i))return null;n=te(i),i=i.parentNode}}}function me(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||ee(i))return null;n=te(i)+1,i=i.parentNode}}}class we{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new we(t.parentNode,te(t),e)}static after(t,e){return new we(t.parentNode,te(t)+1,e)}}const ve=[];class ye{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=ye.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=be(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=be(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==ne(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ye.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=ve){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new xe(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function be(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ye.prototype.breakAfter=0;class xe{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){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;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Se(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function ke(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,Se(t,a,c,h,l,n,0,s,r)}let Ae="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Me="undefined"!=typeof document?document:{documentElement:{style:{}}};const Ce=/Edge\/(\d+)/.exec(Ae.userAgent),Oe=/MSIE \d/.test(Ae.userAgent),De=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ae.userAgent),Te=!!(Oe||De||Ce),Ee=!Te&&/gecko\/(\d+)/i.test(Ae.userAgent),Re=!Te&&/Chrome\/(\d+)/.exec(Ae.userAgent),Be="webkitFontSmoothing"in Me.documentElement.style,Pe=!Te&&/Apple Computer/.test(Ae.vendor),Le=Pe&&(/Mobile\/\w+/.test(Ae.userAgent)||Ae.maxTouchPoints>2);var Ne={mac:Le||/Mac/.test(Ae.platform),windows:/Win/.test(Ae.platform),linux:/Linux|X11/.test(Ae.platform),ie:Te,ie_version:Oe?Me.documentMode||6:De?+De[1]:Ce?+Ce[1]:0,gecko:Ee,gecko_version:Ee?+(/Firefox\/(\d+)/.exec(Ae.userAgent)||[0,0])[1]:0,chrome:!!Re,chrome_version:Re?+Re[1]:0,ios:Le,android:/Android\b/.test(Ae.userAgent),webkit:Be,safari:Pe,webkit_version:Be?+(/\bAppleWebKit\/(\d+)/.exec(Ae.userAgent)||[0,0])[1]:0,tabSize:null!=Me.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ie extends ye{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof Ie)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Ie(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new we(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?Ne.chrome||Ne.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=ue(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];Ne.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l);return o?se(l,o<0):l||null}(this.dom,t,e)}}class He extends ye{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(de(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof He&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(ke(this,t,e,i?i.children.slice():[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new He(this.mark,e,r)}domAtPos(t){return Fe(this,t)}coordsAt(t,e){return _e(this,t,e)}}class Ve extends ye{static create(t,e,i){return new Ve(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=Ve.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Ve&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Ve&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return n.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):n.empty}domAtPos(t){return(this.length?0==t:this.side>0)?we.before(this.dom):we.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return se(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class We extends ye{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof We&&t.side==this.side}split(){return new We(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?we.before(this.dom):we.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.empty}get isHidden(){return!0}}function Fe(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new we(i,0)}function ze(t,e,i){let n,{children:s}=t;i>0&&e instanceof He&&s.length&&(n=s[s.length-1])instanceof He&&n.mark.eq(e.mark)?ze(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function _e(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Qt(e);return i[i.length-1]||null}(t)}function qe(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}Ie.prototype.children=Ve.prototype.children=We.prototype.children=ve;const Ke=Object.create(null);function je(t,e,i){if(t==e)return!0;t||(t=Ke),e||(e=Ke);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function $e(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function Ge(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class Je extends ye{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof Je))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),ke(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new Je;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){je(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ze(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=qe(e,this.attrs||{})),i&&(this.attrs=qe({class:i},this.attrs||{}))}domAtPos(t){return Fe(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(de(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&&($e(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&ye.get(n)instanceof He;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=ye.get(n))||void 0===i?void 0:i.isEditable)||Ne.ios&&this.children.some((t=>t instanceof Ie))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof Ie)||/[^ -~]/.test(i.text))return null;let n=Qt(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=_e(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof Je&&0==this.children.length&&0==t.children.length&&je(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof Je)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Ue extends ye{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Ue&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?we.before(this.dom):we.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Ue(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return ve}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):n.empty}domBoundsAround(){return null}become(t){return t instanceof Ue&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class Ye{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var Xe=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(Xe||(Xe={}));class Qe extends Ct{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new Ze(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ei(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=ii(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new ei(t,e,i,n,t.widget||null,!0)}static line(t){return new ti(t)}static set(t,e=!1){return Et.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Qe.none=Et.empty;class Ze extends Qe{constructor(t){let{start:e,end:i}=ii(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof Ze&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&je(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}Ze.prototype.point=!1;class ti extends Qe{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof ti&&this.spec.class==t.spec.class&&je(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}ti.prototype.mapMode=A.TrackBefore,ti.prototype.point=!0;class ei extends Qe{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?A.TrackBefore:A.TrackAfter:A.TrackDel}get type(){return this.startSide!=this.endSide?Xe.WidgetRange:this.startSide<=0?Xe.WidgetBefore:Xe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ei&&(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}range(t,e=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 super.range(t,e)}}function ii(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function ni(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}ei.prototype.point=!0;class si{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof Ue&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Je),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ri(new We(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof Ue||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(ri(new Ie(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,r){if(this.disallowBlockEffectsFor[r]&&i instanceof ei){if(i.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")}let o=e-t;if(i instanceof ei)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Ue(i.widget||oi.block,o,i));else{let r=Ve.create(i.widget||oi.inline,o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(ri(new We(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(ri(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=s)}static build(t,e,i,n,s){let r=new si(t,e,i,s);return r.openEnd=Et.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function ri(t,e){for(let i of e)t=new He(i,[t],t.length);return t}class oi extends Ye{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}oi.inline=new oi("span"),oi.block=new oi("div");var hi=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(hi||(hi={}));const li=hi.LTR,ai=hi.RTL;function ci(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const ui=ci("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),fi=ci("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),di=Object.create(null),gi=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);di[e]=i,di[i]=-e}function pi(t){return t<=247?ui[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?fi[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const mi=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class wi{get dir(){return this.level%2?ai:li}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}function vi(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!vi(n.inner,s.inner))return!1}return!0}const yi=[];function bi(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=yi[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(yi[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new wi(l,g.from,f)),xi(t,g.direction==li!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?yi[d]!=h:yi[d]==h))break;d++}u?bi(t,l,d,n+1,s,u,o):l<d&&o.push(new wi(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=yi[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(yi[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new wi(g.to,l,f)),xi(t,g.direction==li!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?yi[d-1]!=h:yi[d-1]==h))break;d--}u?bi(t,d,l,n+1,s,u,o):d<l&&o.push(new wi(d,l,f)),l=d}}function xi(t,e,i,n,s,r,o){let h=e%2?2:1;!function(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=pi(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),yi[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=yi[t];if(128==s)t<h-1&&e==yi[t+1]&&24&e?s=yi[t]=e:yi[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==yi[s];)s++;let r=t&&8==e||s<i&&8==yi[s]?1==n?1:8:256;for(let e=t;e<s;e++)yi[e]=r;t=s-1}else 8==s&&1==n&&(yi[t]=1);e=s,7&s&&(n=s)}}}(t,s,r,n,h),function(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=di[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(gi[t+1]==-i){let e=gi[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(yi[o]=yi[gi[t]]=i),h=t;break}}else{if(189==gi.length)break;gi[h++]=o,gi[h++]=e,gi[h++]=l}else if(2==(n=yi[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=gi[e+2];if(2&i)break;if(t)gi[e+2]|=2;else{if(4&i)break;gi[e+2]|=4}}}}}(t,s,r,n,h),function(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=yi[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=yi[o])break;o++}let a=1==r,c=a==(1==(o<e?yi[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),yi[--e]=c;l=o}else r=o,l++}}}(s,r,n,h),bi(t,s,r,e,i,n,o)}function Si(t,e,i){if(!t)return[new wi(0,0,e==ai?1:0)];if(e==li&&!i.length&&!mi.test(t))return ki(t.length);if(i.length)for(;t.length>yi.length;)yi[yi.length]=256;let n=[],s=e==li?0:1;return xi(t,s,s,i,0,t.length,n),n}function ki(t){return[new wi(0,t,0)]}let Ai="";function Mi(t,e,i,n,s){var r;let o=n.head-t.from,h=wi.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc),l=e[h],a=l.side(s,i);if(o==a){let t=h+=s?1:-1;if(t<0||t>=e.length)return null;l=e[h=t],o=l.side(!s,i),a=l.side(s,i)}let c=m(t.text,o,l.forward(s,i));(c<l.from||c>l.to)&&(c=a),Ai=t.text.slice(Math.min(o,c),Math.max(o,c));let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u&&c==a&&u.level+(s?0:1)<l.level?L.cursor(u.side(!s,i)+t.from,u.forward(s,i)?1:-1,u.level):L.cursor(c+t.from,l.forward(s,i)?-1:1,l.level)}function Ci(t,e,i){for(let n=e;n<i;n++){let e=pi(t.charCodeAt(n));if(1==e)return li;if(2==e||4==e)return ai}return li}const Oi=H.define(),Di=H.define(),Ti=H.define(),Ei=H.define(),Ri=H.define(),Bi=H.define(),Pi=H.define(),Li=H.define({combine:t=>t.some((t=>t))}),Ni=H.define({combine:t=>t.some((t=>t))}),Ii=H.define();class Hi{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new Hi(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new Hi(L.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Vi=dt.define({map:(t,e)=>t.map(e)}),Wi=dt.define();function Fi(t,e,i){let n=t.facet(Ei);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const zi=H.define({combine:t=>!t.length||t[0]});let _i=0;const qi=H.define();class Ki{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new Ki(_i++,t,i,n,(t=>{let e=[qi.of(t)];return r&&e.push(Ji.of((e=>{let i=e.plugin(t);return i?r(i):Qe.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return Ki.define((e=>new t(e)),e)}}class ji{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(Fi(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Fi(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){Fi(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const $i=H.define(),Gi=H.define(),Ji=H.define(),Ui=H.define(),Yi=H.define(),Xi=H.define();function Qi(t,e){let i=t.state.facet(Xi);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return Et.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let t=n.length-1;t>=0;t--,r--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=Ci(e.text,o,h)),r>0&&l.length&&(i=l[l.length-1]).to==o&&i.direction==s)i.to=h,l=i.inner;else{let t={from:o,to:h,direction:s,inner:[]};l.push(t),l=t.inner}}}}),s}const Zi=H.define();function tn(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Zi)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const en=H.define();class nn{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new nn(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new nn(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new nn(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class sn{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=C.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new nn(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new sn(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class rn extends ye{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Qe.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Je],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new nn(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.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.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)}));return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=hn(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new nn(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=ye.get(e);if(i instanceof He)c.push({node:e,deco:i.mark});else{if(i instanceof Je||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new Ze({inclusive:!0,attributes:Ge(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new nn(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Ne.ie||Ne.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=function(t,e,i){let n=new ln;return Et.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=nn.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=Ne.chrome||Ne.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof Ue&&t.widget instanceof on&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let r,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=e;if(i&&i.range.fromB<f&&i.range.toB>u){let t=si.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=si.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),r=t.content.concat(n).concat(e.content)}else({content:r,breakAtStart:o,openStart:h,openEnd:l}=si.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);Se(this,p,m,d,g,r,o,h,l)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(Wi)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new Ie(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new He(i,[e],e.length);let i=new Je;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=ye.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&Xt(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(Ne.gecko&&o.empty&&!this.hasComposition&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new we(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&(Zt(h.node,h.offset,c.anchorNode,c.anchorOffset)&&Zt(l.node,l.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{Ne.android&&Ne.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Ut(this.view.root);if(t)if(o.empty){if(Ne.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=(1==t?pe:me)(h.node,h.offset);e&&(h=new we(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new we(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new we(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Zt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=Ut(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Je.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=ye.get(i.childNodes[n]);t instanceof Je&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=ye.get(i.childNodes[n]);t instanceof Je&&(e=t.domAtPos(t.length))}return e?new we(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=ye.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof Je)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;if(l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof Je&&!(i instanceof Je&&e>=0)))i=o,n=l;else if(i&&l==t&&h==t&&o instanceof Ue&&Math.abs(e)<2){if(o.deco.startSide<0)break;r&&(i=null)}s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Je))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof Ie))return null;let s=m(n.text,i);if(s==i)return null;let r=ue(n.dom,i,s).getClientRects();for(let t=0;t<r.length;t++){let e=r[t];if(t==r.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==hi.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?Qt(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?hi.RTL:hi.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Je){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=Qt(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new xe(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Qe.replace({widget:new on(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return Qe.set(t)}updateDeco(){let t=1,e=this.view.state.facet(Ji).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet(Ui).map(((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t}));for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(Et.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(Ii))try{if(e(this.view,t.range,t))return!0}catch(t){Fi(this.view.state,t,"scroll handler")}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=tn(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;!function(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=re(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=oe(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n?e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r))):p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left,p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==hi.LTR)}}class on extends Ye{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function hn(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=pe(i.focusNode,i.focusOffset),s=me(i.focusNode,i.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let e=ye.get(s.node);if(!e||e instanceof Ie&&e.text!=s.node.nodeValue)r=s;else if(t.docView.lastCompositionAfterCursor){let t=ye.get(n.node);!t||t instanceof Ie&&t.text!=n.node.nodeValue||(r=s)}}if(t.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}let ln=class{constructor(){this.changes=[]}compareRange(t,e){ni(t,e,this.changes)}comparePoint(t,e){ni(t,e,this.changes)}};function an(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function cn(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function un(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function fn(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function dn(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function gn(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=Qt(f);for(let d=0;d<t.length;d++){let g=t[d];s&&un(s,g)&&(g=fn(dn(g,s.bottom),s.top));let p=an(e,g),m=cn(i,g);if(0==p&&0==m)return 3==f.nodeType?pn(f,e,i):gn(f,e,i);if(!n||o>m||o==m&&r>p){n=f,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=f,a=g):i<g.top&&(!c||c.top>g.top)&&(l=f,c=g):a&&un(a,g)?a=dn(a,g.bottom):c&&un(c,g)&&(c=fn(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?pn(n,f,i):u&&"false"!=n.contentEditable?gn(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function pn(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=ue(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(Ne.chrome||Ne.gecko){ue(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function mn(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=Xe.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:wn(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:wn(t,h,o,c,u);let g=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:g,m=p.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=p.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||Ne.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return ue(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||Ne.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():ue(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=Je.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=gn(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function wn(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=m(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function vn(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==Xe.Text))return t;return i}function yn(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=Mi(s,r,o,h,i),a=Ai;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function bn(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function xn(t,e,i){let n=bn(t.state.facet(Yi).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:L.cursor(n,n<i.from?1:-1)}class Sn{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){var e;this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Ne.safari&&t.contentDOM.addEventListener("input",(()=>null)),Ne.gecko&&(e=t.contentDOM.ownerDocument,Jn.has(e)||(Jn.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{}))))}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=ye.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let s=t.domEventHandlers[n];s&&i(n).handlers.push(kn(e.value,s))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let s=t.domEventObservers[n];s&&i(n).observers.push(kn(e.value,s))}}for(let t in Tn)i(t).handlers.push(Tn[t]);for(let t in En)i(t).observers.push(En[t]);return e}(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,r=i[t];r&&s!=!r.handlers.length&&(n.removeEventListener(t,this.handleEvent),r=null),r||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&Cn.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),Ne.android&&Ne.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!Ne.ios||t.synthetic||t.altKey||t.metaKey||!((e=An.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||Mn.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,fe(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Ne.safari&&!Ne.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function kn(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){Fi(i.state,t)}}}const An=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Mn="dthko",Cn=[16,17,18,20,91,92,224,225];function On(t){return.7*Math.max(0,t)+8}class Dn{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(Yi).map((e=>e(t)));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(Mt.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Oi);return i.length?i[0](e):Ne.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Ut(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=_n(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let s=0,r=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},h=tn(this.view);t.clientX-h.left<=o.left+6?s=-On(o.left-t.clientX):t.clientX+h.right>=o.right-6&&(s=On(t.clientX-o.right)),t.clientY-h.top<=o.top+6?r=-On(o.top-t.clientY):t.clientY+h.bottom>=o.bottom-6&&(r=On(t.clientY-o.bottom)),this.setScrollSpeed(s,r)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=bn(this.atoms,n.from,0);t!=n.from&&(s=L.cursor(t,-1))}else{let t=bn(this.atoms,n.from,-1),e=bn(this.atoms,n.to,1);t==n.from&&e==n.to||(s=L.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?L.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some((t=>t.isUserEvent("input.type")))?this.destroy():this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const Tn=Object.create(null),En=Object.create(null),Rn=Ne.ie&&Ne.ie_version<15||Ne.ios&&Ne.webkit_version<604;function Bn(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Kn&&n.selection.ranges.every((t=>t.empty))&&Kn==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:L.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:L.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Pn(t,e,i,n){if(1==n)return L.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return L.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=m(s.text,r,!1):h=m(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=m(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=m(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return L.range(o+s.from,h+s.from)}(t.state,e,i);{let i=Je.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,L.range(s,r)}}En.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Tn.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),En.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},En.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Tn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(Ti))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Hn(t,e),n=_n(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=Hn(t,e),a=Pn(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=Pn(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?L.range(s,r):L.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return L.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?h:o?s.addRange(a):L.create([a])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Dn(t,e,i,n)),n&&t.observer.ignore((()=>{ce(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()}));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let Ln=(t,e)=>t>=e.top&&t<=e.bottom,Nn=(t,e,i)=>Ln(e,i)&&t>=i.left&&t<=i.right;function In(t,e,i,n){let s=Je.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Nn(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Nn(i,n,h)?1:o&&Ln(n,o)?-1:1}function Hn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:In(t,i,e.clientX,e.clientY)}}const Vn=Ne.ie&&Ne.ie_version<=11;let Wn=null,Fn=0,zn=0;function _n(t){if(!Vn)return t.detail;let e=Wn,i=zn;return Wn=t,zn=Date.now(),Fn=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Fn+1)%3:1}function qn(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&function(t,e){let i=t.state.facet(Di);return i.length?i[0](e):Ne.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Tn.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=L.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},Tn.dragend=t=>(t.inputState.draggedContent=null,!1),Tn.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&qn(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return qn(t,e,i,!0),!0}return!1},Tn.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Rn?null:e.clipboardData;return i?(Bn(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),Bn(t,i.value)}),50)}(t),!1)};let Kn=null;Tn.copy=Tn.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;Kn=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Rn?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const jn=ct.define();function $n(t,e){let i=[];for(let n of t.facet(Pi)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:jn.of(!0)}):null}function Gn(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=$n(t.state,e);i?t.dispatch(i):t.update([])}}),10)}En.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Gn(t)},En.blur=t=>{t.observer.clearSelectionRange(),Gn(t)},En.compositionstart=En.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},En.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Ne.chrome&&Ne.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50))},En.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Tn.beforeinput=(t,e)=>{var i;let n;if(Ne.chrome&&Ne.android&&(n=An.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return Ne.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),Ne.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>En.compositionend(t,e)),20),!1};const Jn=new Set;const Un=["pre-wrap","normal","pre-line","break-spaces"];class Yn{constructor(t){this.lineWrapping=t,this.doc=n.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Un.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Un.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class Xn{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class Qn{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?Xe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ei?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Qn(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var Zn=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(Zn||(Zn={}));const ts=.001;class es{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>ts&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return es.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,Zn.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,Zn.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,Zn.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=hs.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new ns(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new rs(es.of(t.slice(0,e)),r,es.of(t.slice(i)))}}es.prototype.size=1;class is extends es{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new Qn(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ns extends is{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new Qn(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof ns||n instanceof ss&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof ss?n=new ns(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):es.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ss extends es{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new Qn(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new Qn(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==Zn.ByHeight)return this.blockAt(t,i,n,s);if(e==Zn.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new Qn(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new Qn(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new Qn(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof ss?i[i.length-1]=new ss(t.length+n):i.push(null,new ss(n-1))}if(t>0){let e=i[0];e instanceof ss?i[0]=new ss(t+e.length):i.unshift(new ss(t-1),null)}return es.of(i)}decomposeLeft(t,e){e.push(new ss(t-1),null)}decomposeRight(t,e){e.push(null,new ss(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new ss(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=ts&&(o=-2);let h=new ns(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new ss(s-r).updateHeight(t,r));let h=es.of(i);return(o<0||Math.abs(h.height-this.height)>=ts||Math.abs(o-this.heightMetrics(t,e).perLine)>=ts)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class rs extends es{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==Zn.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==Zn.ByPosNoHeight?Zn.ByPosNoHeight:Zn.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,Zn.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&os(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),os(s,t)}return es.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?es.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)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function os(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof ss&&(n=t[e+1])instanceof ss&&t.splice(e-1,3,new ss(i.length+1+n.length))}class hs{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof ns?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new ns(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new is(r,n,i)):(r||s||n>=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new ns(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new ss(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof ns)return t;let e=new ns(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof ns||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new ns(0,-1));let i=t;for(let t of this.nodes)t instanceof ns&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new hs(i,t);return Et.spans(e,i,n,s,0),s.finish(i)}}class ls{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&ni(t,e,this.changes,5)}}function as(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function cs(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class us{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return Qe.replace({widget:new fs(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class fs extends Ye{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let 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}get estimatedHeight(){return this.vertical?this.size:-1}}class ds{constructor(t){this.state=t,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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ws,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=hi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Gi).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Yn(e),this.stateDeco=t.facet(Ji).filter((t=>"function"!=typeof t)),this.heightMap=es.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle.setDoc(t.doc),[new nn(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Qe.set(this.lineGaps.map((t=>t.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new gs(e,i))}}return this.viewports=t.sort(((t,e)=>t.from-e.from)),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?ws:new vs(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(ys(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Ji).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=nn.extendWithRanges(n,function(t,e,i){let n=new ls;return Et.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:C.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,t.flags|=this.updateForViewport(),(l||!t.changes.empty||2&t.flags)&&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&&!t.state.facet(Ni)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?hi.RTL:hi.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0;if(h.width&&h.height){let{scaleX:t,scaleY:i}=oe(e,h);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=8,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=ge(t.scrollDOM);let g=(this.printing?cs:as)(e,this.paddingTop),p=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=h.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(e)&&(o=!0),o||s.lineWrapping&&Math.abs(v-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:n,textHeight:h}=t.docView.measureTextSize();o=i>0&&s.refresh(r,i,n,h,v/n,e),o&&(t.docView.minWidth=0,a|=8)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),s.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?es.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle,[new nn(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Xn(i.from,r))}s.heightChanged&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),a|=this.updateForViewport()),(2&a||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new gs(n.lineAt(r-1e3*i,Zn.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),Zn.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,Zn.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new gs(n.lineAt(i-500,Zn.ByHeight,s,0,0).from,n.lineAt(i+r+500,Zn.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new gs(this.heightMap.lineAt(i,Zn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,Zn.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,Zn.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,Zn.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new us(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,r=n<<1;if(this.defaultTextDirection!=hi.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(L.cursor(r),!1,!0).head;t>n&&(r=t)}f=new us(n,r,this.gapSize(l,n,r,a))}o.push(f)},l=t=>{if(t.length<r||t.type!=Xe.Text)return;let e=function(t,e,i){let n=[],s=t,r=0;Et.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s);return{total:r,ranges:n}}(t.from,t.to,this.stateDeco);if(e.total<r)return;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=ms(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=ps(e,i),o=ps(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=ms(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=ps(e,t),o=ps(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(l):l(t);return o}gapSize(t,e,i,n){let s=ms(n,i)-ms(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){us.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Qe.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Et.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||ys(this.heightMap.lineAt(t,Zn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find((e=>e.top<=t&&e.bottom>=t))||ys(this.heightMap.lineAt(this.scaler.fromDOM(t),Zn.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return ys(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class gs{constructor(t,e){this.from=t,this.to=e}}function ps({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function ms(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const ws={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class vs{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,Zn.ByPos,t,0,0).top,o=e.lineAt(s,Zn.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof vs&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every(((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to)))}}function ys(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new Qn(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>ys(t,e))):t._content)}const bs=H.define({combine:t=>t.join(" ")}),xs=H.define({combine:t=>t.indexOf(!0)>-1}),Ss=$t.newName(),ks=$t.newName(),As=$t.newName(),Ms={"&light":"."+ks,"&dark":"."+As};function Cs(t,e,i){return new $t(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const Os=Cs("."+Ss,{"&":{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,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},Ms),Ds="";class Ts{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(Mt.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Ds}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=ye.get(n),o=ye.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:ee(n))||ee(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=ye.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(Es(t,i.node,i.offset)?e:0))}}function Es(t,e,i){for(;;){if(!e||i<ne(e))return!1;if(e==t)return!0;i=te(e)+1,e=e.parentNode}}class Rs{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Bs{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new Rs(i,n)),s==i&&r==n||e.push(new Rs(s,r)));return e}(t),i=new Ts(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?L.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!Yt(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!Yt(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((Ne.ios||Ne.chrome)&&t.state.selection.main.empty&&i!=n&&(o.from>0||o.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),r=o.from-e,h=o.to-s;0!=r&&1!=r&&0!=e||0!=h&&-1!=h&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}this.newSel=L.single(n,i)}}}function Ps(t,e){let i,{newSel:s}=e,r=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:h}=e.bounds,l=r.from,a=null;(8===o||Ne.android&&e.text.length<h-s)&&(l=r.to,a="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(s,h,Ds),e.text,l-s,a);c&&(Ne.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==Ds+Ds&&c.toB--,i={from:s+c.from,to:s+c.toA,insert:n.of(e.text.slice(c.from,c.toB).split(Ds))})}else s&&(!t.hasFocus&&t.state.facet(zi)||s.main.eq(r))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!r.empty&&s&&s.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(Ne.mac||Ne.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=L.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}):Ne.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=L.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}),i)return Ls(t,i,s,o);if(s&&!s.main.eq(r)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:s,scrollIntoView:e,userEvent:i}),!0}return!1}function Ls(t,e,i,n=-1){if(Ne.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Ne.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&fe(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&fe(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&fe(t.contentDOM,"Delete",46)))return!0;let r,o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>r||(r=function(t,e,i){let n,s=t.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.from<e.from?s.sliceDoc(r.from,e.from):"",o=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=s.changes(e),h=i&&i.main.to<=o.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let l,a=t.state.sliceDoc(e.from,e.to),c=i&&hn(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-t}}else l=t.state.doc.lineAt(r.head);let u=r.to-e.to,f=r.to-r.from;n=s.changeByRange((i=>{if(i.from==r.from&&i.to==r.to)return{changes:o,range:h||i.map(o)};let n=i.to-u,c=n-a.length;if(i.to-i.from!=f||t.state.sliceDoc(c,n)!=a||i.to>=l.from&&i.from<=l.to)return{range:i};let d=s.changes({from:c,to:n,insert:e.insert}),g=i.to-r.to;return{changes:d,range:h?L.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):i.map(d)}}))}else n={changes:o,selection:h&&s.selection.replaceRange(h)}}let o="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:o,scrollIntoView:!0})}(t,e,i));return t.state.facet(Bi).some((i=>i(t,e.from,e.to,o,h)))||t.dispatch(h()),!0}const Ns={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Is=Ne.ie&&Ne.ie_version<=11;class Hs{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new he,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(Ne.ie&&Ne.ie_version<=11||Ne.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),!window.EditContext||!1===t.constructor.EDIT_CONTEXT||Ne.chrome&&Ne.chrome_version<126||(this.editContext=new Fs(t),t.state.facet(zi)&&(t.contentDOM.editContext=this.editContext.editContext)),Is&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(t){("change"!=t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(zi)?i.root.activeElement!=this.dom:!Xt(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(Ne.ie&&Ne.ie_version<=11||Ne.android&&Ne.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Zt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Ut(t.root);if(!e)return!1;let i=Ne.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Ws(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?Ws(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=Xt(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,ne(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=ne(i))}else{if(i==t)return!0;n=te(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ns),Is&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Is&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&fe(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&Xt(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Bs(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=Ps(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=Vs(e,t.previousSibling||t.target.previousSibling,-1),n=Vs(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener("change",this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener("change",this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(zi)!=t.state.facet(zi)&&(t.view.contentDOM.editContext=t.state.facet(zi)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Vs(t,e,i){for(;e;){let n=ye.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function Ws(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return Zt(o.node,o.offset,s,r)&&([i,n,s,r]=[s,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}}class Fs{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});e.addEventListener("textupdate",(e=>{let{anchor:i}=t.state.selection.main,s={from:this.toEditorPos(e.updateRangeStart),to:this.toEditorPos(e.updateRangeEnd),insert:n.of(e.text.split("\n"))};s.from==this.from&&i<this.from?s.from=i:s.to==this.to&&i>this.to&&(s.to=i),(s.from!=s.to||s.insert.length)&&(this.pendingContextChange=s,Ls(t,s,L.single(this.toEditorPos(e.selectionStart),this.toEditorPos(e.selectionEnd))),this.pendingContextChange&&this.revertPending(t.state))})),e.addEventListener("characterboundsupdate",(i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),r=this.toEditorPos(i.rangeEnd);e<r;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)})),e.addEventListener("textformatupdate",(e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if("None"!=e&&"None"!=n){let s=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==n?1:2}px`;i.push(Qe.mark({attributes:{style:s}}).range(this.toEditorPos(t.rangeStart),this.toEditorPos(t.rangeEnd)))}}t.dispatch({effects:Wi.of(Qe.set(i))})})),e.addEventListener("compositionstart",(()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)})),e.addEventListener("compositionend",(()=>{t.inputState.composing=-1,t.inputState.compositionFirstChange=null})),this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=Ut(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges(((s,r,o,h,l)=>{if(i)return;let a=l.length-(r-s);if(n&&r>=n.to){if(n.from==s&&n.to==r&&n.insert.eq(l))return n=this.pendingContextChange=null,void(e+=a);n=null,this.revertPending(t.state)}if(s+=e,(r+=e)<=this.from)this.from+=a,this.to+=a;else if(s<this.to){if(s<this.from||r>this.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(r),l.toString()),this.to+=a}e+=a})),n&&!i&&this.revertPending(t.state),!i}update(t){this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet)&&this.setSelection(t.state):(this.pendingContextChange=null,this.resetRange(t.state),this.editContext.updateText(0,this.editContext.text.length,t.state.doc.sliceString(this.from,this.to)),this.setSelection(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.to+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t){return t+this.from}toContextPos(t){return t-this.from}}class zs{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new ds(t.state||Mt.create(t)),t.scrollTo&&t.scrollTo.is(Vi)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(qi).map((t=>new ji(t)));for(let t of this.plugins)t.update(this);this.observer=new Hs(this),this.inputState=new Sn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new rn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof gt?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(jn)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=$n(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(Mt.phrases)!=this.state.facet(Mt.phrases))return this.setState(s);e=sn.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new Hi(t.empty?t:L.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Vi)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=Ks.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(en)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(bs)!=e.state.facet(bs)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(Ri))try{t(e)}catch(t){Fi(this.state,t,"update listener")}(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!Ps(this,a)&&l.force&&fe(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ds(t),this.plugins=t.facet(qi).map((t=>new ji(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new rn(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(qi),i=t.state.facet(qi);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new ji(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){Fi(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(ge(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];4&o||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map((t=>{try{return t.read(this)}catch(t){return Fi(this.state,t),qs}})),a=sn.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),c=this.docView.update(a),c&&this.docViewUpdate());for(let t=0;t<h.length;t++)if(l[t]!=qs)try{let e=h[t];e.write&&e.write(l[t],this)}catch(t){Fi(this.state,t)}if(c&&this.docView.updateSelection(!0),!a.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Ri))t(e)}get themeClasses(){return Ss+" "+(this.state.facet(xs)?As:ks)+" "+this.state.facet(bs)}updateAttrs(){let t=js(this,$i,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(zi)?"true":"false",class:"cm-content",style:`${Ne.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),js(this,Gi,e);let i=this.observer.ignore((()=>{let i=$e(this.contentDOM,this.contentAttrs,e),n=$e(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(zs.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(en);let t=this.state.facet(zs.cspNonce);$t.mount(this.root,this.styleModules.concat(Os).reverse(),t?{nonce:t}:void 0)}readMeasured(){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)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return xn(this,t,yn(this,t,e,i))}moveByGroup(t,e){return xn(this,t,yn(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==xt.Space&&(s=e),s==e}}(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return L.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=vn(t,e.head),r=n&&s.type==Xe.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==hi.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return L.cursor(o,i?-1:1)}return L.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return xn(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return L.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s,e.assoc||-1),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(f+e)*r,n=mn(t,{x:u,y:i},!1,r);if(i<l.top||i>l.bottom||(r<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return L.cursor(n,s,void 0,h)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),mn(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return se(i,s[wi.find(s,t-n.from,-1,e)].dir==hi.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Li)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>_s)return ki(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||vi(n.isolates,e=Qi(this,t))))return n.order;e||(e=Qi(this,t));let n=Si(t.text,i,e);return this.bidiCache.push(new Ks(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Ne.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{ce(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Vi.of(new Hi("number"==typeof t?L.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Vi.of(new Hi(L.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Ki.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return Ki.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=$t.newName(),n=[bs.of(i),en.of(Cs(`.${i}`,t))];return e&&e.dark&&n.push(xs.of(!0)),n}static baseTheme(t){return Y.lowest(en.of(Cs("."+Ss,t,Ms)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&ye.get(i)||ye.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}zs.styleModule=en,zs.inputHandler=Bi,zs.scrollHandler=Ii,zs.focusChangeEffect=Pi,zs.perLineTextDirection=Li,zs.exceptionSink=Ei,zs.updateListener=Ri,zs.editable=zi,zs.mouseSelectionStyle=Ti,zs.dragMovesSelection=Di,zs.clickAddsSelectionRange=Oi,zs.decorations=Ji,zs.outerDecorations=Ui,zs.atomicRanges=Yi,zs.bidiIsolatedRanges=Xi,zs.scrollMargins=Zi,zs.darkTheme=xs,zs.cspNonce=H.define({combine:t=>t.length?t[0]:""}),zs.contentAttributes=Gi,zs.editorAttributes=$i,zs.lineWrapping=zs.contentAttributes.of({class:"cm-lineWrapping"}),zs.announce=dt.define();const _s=4096,qs={};class Ks{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:hi.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new Ks(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function js(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&qe(r,i)}return i}const $s=!Ne.ios;const Gs={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};$s&&(Gs[".cm-line"].caretColor=Gs[".cm-content"].caretColor="transparent !important");class Js extends Ct{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Js.prototype.elementClass="",Js.prototype.toDOM=void 0,Js.prototype.mapMode=A.TrackBefore,Js.prototype.startSide=Js.prototype.endSide=-1,Js.prototype.point=!0;i("26200"),i("25754"),i("22246"),i("71375"),i("15524"),i("20267"),i("22139");const Us=1024;let Ys=0;class Xs{constructor(t,e){this.from=t,this.to=e}}class Qs{constructor(t={}){this.id=Ys++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=tr.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}Qs.closedBy=new Qs({deserialize:t=>t.split(" ")}),Qs.openedBy=new Qs({deserialize:t=>t.split(" ")}),Qs.group=new Qs({deserialize:t=>t.split(" ")}),Qs.contextHash=new Qs({perNode:!0}),Qs.lookAhead=new Qs({perNode:!0}),Qs.mounted=new Qs({perNode:!0});const Zs=Object.create(null);class tr{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):Zs,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new tr(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(Qs.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(Qs.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}tr.none=new tr("",Object.create(null),0,8);const er=new WeakMap,ir=new WeakMap;var nr,sr;(sr=nr||(nr={}))[sr.ExcludeBuffers=1]="ExcludeBuffers",sr[sr.IncludeAnonymous=2]="IncludeAnonymous",sr[sr.IgnoreMounts=4]="IgnoreMounts",sr[sr.IgnoreOverlays=8]="IgnoreOverlays";class rr{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(Qs.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new mr(this.topNode,t)}cursorAt(t,e=0,i=0){let n=er.get(this)||this.topNode,s=new mr(n);return s.moveTo(t,e),er.set(this,s._tree),s}get topNode(){return new ur(this,0,0,null)}resolve(t,e=0){let i=cr(er.get(this)||this.topNode,t,e,!1);return er.set(this,i),i}resolveInner(t,e=0){let i=cr(ir.get(this)||this.topNode,t,e,!0);return ir.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&nr.IncludeAnonymous)>0;for(let t=this.cursor(r|nr.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:br(tr.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new rr(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new rr(tr.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=Us,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new or(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,w,v){let{id:y,start:b,end:x,size:S}=h,k=c;for(;S<0;){if(h.next(),-1==S){let e=r[y];return i.push(e),void w.push(b-t)}if(-3==S)return void(a=y);if(-4==S)return void(c=y);throw new RangeError(`Unrecognized record size: ${S}`)}let A,M,C=l[y],O=b-t;if(x-b<=s&&(M=p(h.pos-e,v))){let e=new Uint16Array(M.size-M.skip),i=h.pos-M.size,s=e.length;for(;h.pos>i;)s=m(M.start,e,s);A=new hr(e,x-M.start,n),O=M.start-t}else{let t=h.pos-S;h.next();let e=[],i=[],n=y>=o?y:-1,r=0,l=x;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(d(e,i,b,r,h.end,l,n,k),r=e.length,l=h.end),h.next()):u(b,t,e,i,n);if(n>=0&&r>0&&r<e.length&&d(e,i,b,r,b,l,n,k),e.reverse(),i.reverse(),n>-1&&r>0){let t=f(C);A=br(C,e,i,0,e.length,0,x-b,t,t)}else A=g(C,e,i,x-b,k-x)}i.push(A),w.push(O)}function f(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof rr){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(Qs.lookAhead))&&(o=i[h]+s.length+r)}return g(t,e,i,n,o)}}function d(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(g(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function g(t,e,i,n,s=0,r){if(a){let t=[Qs.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[Qs.lookAhead,s];r=r?[t].concat(r):[t]}return new rr(t,e,i,n,r)}function p(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function m(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let w=[],v=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,w,v,-1);let y=null!==(e=t.length)&&void 0!==e?e:w.length?v[0]+w[0].length:0;return new rr(l[t.topID],w.reverse(),v.reverse(),y)}(t)}}rr.empty=new rr(tr.none,[],[],0);class or{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new or(this.buffer,this.index)}}class hr{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return tr.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return s+"("+r.join(",")+")"}findChild(t,e,i,n,s){let{buffer:r}=this,o=-1;for(let h=t;h!=e&&!(lr(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new hr(s,r,this.set)}}function lr(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function ar(t,e){let i=t.childBefore(e);for(;i;){let e=i.lastChild;if(!e||e.to!=i.to)break;e.type.isError&&e.from==e.to?(t=i,i=e.prevSibling):i=e}return t}function cr(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof ur&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:nr.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof ur&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class ur{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:o,positions:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(lr(n,i,a,a+l.length))if(l instanceof hr){if(s&nr.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new pr(new gr(r,l,t,a),null,o)}else if(s&nr.IncludeAnonymous||!l.type.isAnonymous||wr(l)){let o;if(!(s&nr.IgnoreMounts)&&l.props&&(o=l.prop(Qs.mounted))&&!o.overlay)return new ur(o.tree,a,t,r);let h=new ur(l,a,t,r);return s&nr.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&nr.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&nr.IgnoreOverlays)&&(n=this._tree.prop(Qs.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new ur(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(t=0){return new mr(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return cr(this,t,e,!1)}resolveInner(t,e=0){return cr(this,t,e,!0)}enterUnfinishedNodesBefore(t){return ar(this,t)}getChild(t,e=null,i=null){let n=fr(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return fr(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return dr(this,t)}}function fr(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!s.type.is(i);)if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function dr(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class gr{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class pr{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new pr(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&nr.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new pr(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new pr(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new pr(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new mr(this,t)}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new rr(this.type,t,e,this.to-this.from)}resolve(t,e=0){return cr(this,t,e,!1)}resolveInner(t,e=0){return cr(this,t,e,!0)}enterUnfinishedNodesBefore(t){return ar(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=fr(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return fr(this,t,e,i)}get node(){return this}matchContext(t){return dr(this,t)}}class mr{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof ur)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof ur?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&nr.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&nr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&nr.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(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));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&nr.IncludeAnonymous||t instanceof hr||!t.type.isAnonymous||wr(t))return!1}return!0}move(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}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(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}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new pr(this.buffer,e,this.stack[t]);return this.bufferNode=new pr(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return dr(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return dr(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function wr(t){return t.children.some((t=>t instanceof hr||!t.type.isAnonymous||wr(t)))}const vr=new WeakMap;function yr(t,e){if(!t.isAnonymous||e instanceof hr||e.type!=t)return 1;let i=vr.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof rr)){i=1;break}i+=yr(t,n)}vr.set(e,i)}return i}function br(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=yr(t,e[i]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=yr(t,i[a]);for(a++;a<o;a++){let e=yr(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(br(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}class xr{constructor(t,e,i,n,s=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new xr(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,r=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-h>=i)for(;r&&r.from<c;){let e=r;if(h>=e.from||c<=e.to||l){let t=Math.max(e.from,h)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new xr(t,i,e.tree,e.offset+l,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=s<t.length?t[s++]:null}if(!a)break;h=a.toA,l=a.toA-a.toB}return n}}class Sr{startParse(t,e,i){return"string"==typeof t&&(t=new kr(t)),i=i?i.length?i.map((t=>new Xs(t.from,t.to))):[new Xs(0,0)]:[new Xs(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class kr{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new Qs({perNode:!0});class Ar{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),Cr.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let i=[];return this.decompose(t,e,i,0),Cr.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new Tr(this),s=new Tr(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new Tr(this,t)}iterRange(t,e=this.length){return new Er(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new Rr(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new Mr(t):Cr.from(Mr.split(t,[])):Ar.empty}}class Mr extends Ar{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new Br(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new Mr(Dr(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=Or(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new Mr(e,t.length+s.length));else{let t=e.length>>1;i.push(new Mr(e.slice(0,t)),new Mr(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof Mr))return super.replace(t,e,i);let n=Or(this.text,Or(i.text,Dr(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new Mr(n,s):Cr.from(Mr.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new Mr(i,n)),i=[],n=-1);return n>-1&&e.push(new Mr(i,n)),e}}class Cr extends Ar{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],o=s+r.length;if(t>=s&&e<=o){let h=r.replace(t-s,e-s,i),l=this.lines-r.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let s=this.children.slice();return s[n]=h,new Cr(s,this.length-(e-t)+i.length)}return super.replace(s,o,h)}s=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Cr))return 0;let i=0,[n,s,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==o)return i;let h=this.children[n],l=t.children[s];if(h!=l)return i+h.scanIdentical(l,e);i+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new Mr(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],h=0,l=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof Cr)for(let e of t.children)c(e);else t.lines>r&&(h>r||!h)?(u(),o.push(t)):t instanceof Mr&&h&&(e=a[a.length-1])instanceof Mr&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,a[a.length-1]=new Mr(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&u(),h+=t.lines,l+=t.length+1,a.push(t))}function u(){0!=h&&(o.push(1==a.length?a[0]:Cr.from(a,l)),l=-1,h=a.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new Cr(o,e)}}function Or(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function Dr(t,e,i){return Or(t,[""],e,i)}Ar.empty=new Mr([""],0);class Tr{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof Mr?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],r=s>>1,o=n instanceof Mr?n.text.length:n.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof Mr){let s=n.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[r+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof Mr?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Er{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new Tr(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class Rr{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Ar.prototype[Symbol.iterator]=function(){return this.iter()},Tr.prototype[Symbol.iterator]=Er.prototype[Symbol.iterator]=Rr.prototype[Symbol.iterator]=function(){return this});class Br{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let Pr="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((t=>t?parseInt(t,36):1));for(let t=1;t<Pr.length;t++)Pr[t]+=Pr[t-1];function Lr(t){for(let e=1;e<Pr.length;e+=2)if(Pr[e]>t)return Pr[e-1]<=t;return!1}function Nr(t){return t>=127462&&t<=127487}function Ir(t,e,i=!0,n=!0){return(i?Hr:Vr)(t,e,n)}function Hr(t,e,i){if(e==t.length)return e;e&&Wr(t.charCodeAt(e))&&Fr(t.charCodeAt(e-1))&&e--;let n=zr(t,e);for(e+=_r(n);e<t.length;){let s=zr(t,e);if(8205==n||8205==s||i&&Lr(s))e+=_r(s),n=s;else{if(!Nr(s))break;{let i=0,n=e-2;for(;n>=0&&Nr(zr(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function Vr(t,e,i){for(;e>0;){let n=Hr(t,e-2,i);if(n<e)return n;e--}return 0}function Wr(t){return t>=56320&&t<57344}function Fr(t){return t>=55296&&t<56320}function zr(t,e){let i=t.charCodeAt(e);if(!Fr(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Wr(n)?n-56320+(i-55296<<10)+65536:i}function _r(t){return t<65536?1:2}const qr=/\r\n?|\n/;var Kr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Kr||(Kr={}));class jr{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){Ur(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new jr(t)}composeDesc(t){return this.empty?t:t.empty?this:Xr(this,t)}mapDesc(t,e=!1){return t.empty?this:Yr(this,t,e)}mapPos(t,e=-1,i=Kr.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=Kr.Simple&&l>=t&&(i==Kr.TrackDel&&n<t&&l>t||i==Kr.TrackBefore&&n<t||i==Kr.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new jr(t)}static create(t){return new jr(t)}}class $r extends jr{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return Ur(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return Yr(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let r=e[n],o=e[n+1];if(o>=0){e[n]=o,e[n+1]=r;let h=n>>1;for(;i.length<h;)i.push(Ar.empty);i.push(r?t.slice(s,s+r):Ar.empty)}s+=r}return new $r(e,i)}compose(t){return this.empty?t:t.empty?this:Xr(this,t,!0)}map(t,e=!1){return t.empty?this:Yr(this,t,e,!0)}iterChanges(t,e=!1){Ur(this,t,e)}get desc(){return jr.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new Qr(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);Gr(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;Gr(e,t,r),r>0&&Jr(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);Gr(e,t,-1),Gr(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new $r(e,i),filtered:jr.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],r=0,o=null;function h(t=!1){if(!t&&!n.length)return;r<e&&Gr(n,e-r,-1);let i=new $r(n,s);o=o?o.compose(i.map(o)):i,n=[],s=[],r=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof $r){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);h(),o=o?o.compose(l.map(o)):l}else{let{from:t,to:o=t,insert:a}=l;if(t>o||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=a?"string"==typeof a?Ar.of(a.split(i||qr)):a:Ar.empty,u=c.length;if(t==o&&0==u)return;t<r&&h(),t>r&&Gr(n,t-r,-1),Gr(n,o-t,u),Jr(s,n,c),r=o}}(t),h(!o),o}static empty(t){return new $r(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(Ar.empty);i[n]=Ar.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new $r(e,i)}static createSet(t,e){return new $r(t,e)}}function Gr(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function Jr(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(Ar.empty);t.push(i)}}function Ur(t,e,i){let n=t.inserted;for(let s=0,r=0,o=0;o<t.sections.length;){let h=t.sections[o++],l=t.sections[o++];if(l<0)s+=h,r+=h;else{let a=s,c=r,u=Ar.empty;for(;a+=h,c+=l,l&&n&&(u=u.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)h=t.sections[o++],l=t.sections[o++];e(s,a,r,c,u),s=a,r=c}}}function Yr(t,e,i,n=!1){let s=[],r=n?[]:null,o=new Qr(t),h=new Qr(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);Gr(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(Gr(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(Gr(s,0,o.ins),r&&Jr(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?$r.createSet(s,r):jr.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}Gr(s,e,t<o.i?o.ins:0),r&&t<o.i&&Jr(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function Xr(t,e,i=!1){let n=[],s=i?[]:null,r=new Qr(t),o=new Qr(e);for(let t=!1;;){if(r.done&&o.done)return s?$r.createSet(n,s):jr.create(n);if(0==r.ins)Gr(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;Gr(n,e,i,t),s&&i&&Jr(s,n,o.text)}else-1==o.ins?(Gr(n,r.off?0:r.len,e,t),s&&Jr(s,n,r.textBit(e))):(Gr(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&Jr(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else Gr(n,0,o.ins,t),s&&Jr(s,n,o.text),o.next()}}class Qr{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?Ar.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?Ar.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Zr{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let t=3&this.flags;return 3==t?null:t}get goalColumn(){let t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new Zr(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return to.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return to.range(this.anchor,i)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return to.range(t.anchor,t.head)}static create(t,e,i){return new Zr(t,e,i)}}class to{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:to.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new to([this.main],0)}addRange(t,e=!0){return to.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,to.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new to(t.ranges.map((t=>Zr.fromJSON(t))),t.main)}static single(t,e=t){return new to([to.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return to.normalized(t.slice(),e);i=s.to}return new to(t,e)}static cursor(t,e=0,i,n){return Zr.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?Zr.create(e,t,24|s):Zr.create(t,e,(e>t?4:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?to.range(o,r):to.range(r,o))}}return new to(t,e)}}function eo(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let io=0;class no{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=io++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new no(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:so),!!t.static,t.enables)}of(t){return new ro([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ro(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ro(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function so(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class ro{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=io++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||ho(t,a)){let e=i(t);if(o?!oo(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=ko(e,l);if(this.dependencies.every((i=>i instanceof no?e.facet(i)===t.facet(i):!(i instanceof co)||e.field(i,!1)==t.field(i,!1)))||(o?oo(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function oo(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function ho(t,e){let i=!1;for(let n of e)1&So(t,n)&&(i=!0);return i}function lo(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=ko(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)So(t,e);return t.values[o]=h(t),1},update(t,i){if(!ho(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=ho(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&so(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const ao=no.define({static:!0});class co{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new co(io++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(ao).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,ao.of({field:this,create:t})]}get extension(){return this}}const uo=4,fo=3,go=2,po=1;function mo(t){return e=>new vo(e,t)}const wo={highest:mo(0),high:mo(po),default:mo(go),low:mo(fo),lowest:mo(uo)};class vo{constructor(t,e){this.inner=t,this.prec=e}}class yo{of(t){return new bo(this,t)}reconfigure(t){return yo.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class bo{constructor(t,e){this.compartment=t,this.inner=e}}class xo{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof bo&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof bo){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof vo)r(t.inner,t.prec);else if(t instanceof co)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof ro)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,go);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,go),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof co?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,so(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>lo(t,n,e)))}}let c=l.map((t=>t(o)));return new xo(t,r,c,o,h,s)}}function So(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function ko(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Ao=no.define(),Mo=no.define({combine:t=>t.some((t=>t)),static:!0}),Co=no.define({combine:t=>t.length?t[0]:void 0,static:!0}),Oo=no.define(),Do=no.define(),To=no.define(),Eo=no.define({combine:t=>!!t.length&&t[0]});class Ro{constructor(t,e){this.type=t,this.value=e}static define(){return new Bo}}class Bo{of(t){return new Ro(this,t)}}class Po{constructor(t){this.map=t}of(t){return new Lo(this,t)}}class Lo{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new Lo(this.type,e)}is(t){return this.type==t}static define(t={}){return new Po(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}Lo.reconfigure=Lo.define(),Lo.appendConfig=Lo.define();class No{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&eo(i,e.newLength),s.some((t=>t.type==No.time))||(this.annotations=s.concat(No.time.of(Date.now())))}static create(t,e,i,n,s,r){return new No(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(No.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function Io(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function Ho(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=$r.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:Lo.mapEffects(t.effects,s).concat(Lo.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Vo(t,e,i){let n=e.selection,s=zo(e.annotations);return e.userEvent&&(s=s.concat(No.userEvent.of(e.userEvent))),{changes:e.changes instanceof $r?e.changes:$r.of(e.changes||[],i,t.facet(Co)),selection:n&&(n instanceof to?n:to.single(n.anchor,n.head)),effects:zo(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Wo(t,e,i){let n=Vo(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=Ho(n,Vo(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=No.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(To),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=Ho(n,Vo(e,r,t.changes.newLength),!0))}return n==t?t:No.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(Oo)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Io(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=$r.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=No.create(e,n,t.selection&&t.selection.map(s),Lo.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Do);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof No?s:Array.isArray(s)&&1==s.length&&s[0]instanceof No?s[0]:Wo(e,zo(s),!1)}return t}(s):s)}No.time=Ro.define(),No.userEvent=Ro.define(),No.addToHistory=Ro.define(),No.remote=Ro.define();const Fo=[];function zo(t){return null==t?Fo:Array.isArray(t)?t:[t]}var _o=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(_o||(_o={}));const qo=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ko;try{Ko=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function jo(t){return e=>{if(!/\S/.test(e))return _o.Space;if(function(t){if(Ko)return Ko.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||qo.test(i)))return!0}return!1}(e))return _o.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return _o.Word;return _o.Other}}class $o{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)So(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return So(this,i),ko(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Wo(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(yo.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(Lo.reconfigure)?(i=null,n=e.value):e.is(Lo.appendConfig)&&(i=null,n=zo(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=xo.resolve(n,s,this),e=new $o(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new $o(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:to.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=zo(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=Lo.mapEffects(r,l).concat(Lo.mapEffects(zo(o.effects),a))}return{changes:n,selection:to.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof $r?t:$r.of(t,this.doc.length,this.facet($o.lineSeparator))}toText(t){return Ar.of(t.split(this.facet($o.lineSeparator)||qr))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(So(this,e),ko(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof co&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return $o.create({doc:t.doc,selection:to.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=xo.resolve(t.extensions||[],new Map),i=t.doc instanceof Ar?t.doc:Ar.of((t.doc||"").split(e.staticFacet($o.lineSeparator)||qr)),n=t.selection?t.selection instanceof to?t.selection:to.single(t.selection.anchor,t.selection.head):to.single(0);return eo(n,i.length),e.staticFacet(Mo)||(n=n.asSingle()),new $o(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet($o.tabSize)}get lineBreak(){return this.facet($o.lineSeparator)||"\n"}get readOnly(){return this.facet(Eo)}phrase(t,...e){for(let e of this.facet($o.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(Ao))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return jo(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=Ir(e,r,!1);if(s(e.slice(t,r))!=_o.Word)break;r=t}for(;o<n;){let t=Ir(e,o);if(s(e.slice(o,t))!=_o.Word)break;o=t}return r==o?null:to.range(r+i,o+i)}}$o.allowMultipleSelections=Mo,$o.tabSize=no.define({combine:t=>t.length?t[0]:4}),$o.lineSeparator=Co,$o.readOnly=Eo,$o.phrases=no.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),$o.languageData=Ao,$o.changeFilter=Oo,$o.transactionFilter=Do,$o.transactionExtender=To,yo.reconfigure=Lo.define();class Go{eq(t){return this==t}range(t,e=t){return Jo.create(t,e,this)}}Go.prototype.startSide=Go.prototype.endSide=0,Go.prototype.point=!1,Go.prototype.mapMode=Kr.TrackDel;class Jo{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Jo(t,e,i)}}function Uo(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Yo{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Yo(n,s,i,o):null,pos:r}}}class Xo{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Xo(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Uo)),this.isEmpty)return e.length?Xo.of(e):this;let o=new th(this,null,-1).goto(0),h=0,l=[],a=new Qo;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Jo.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Xo.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Xo(i,e,s||Xo.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return eh.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return eh.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=Zo(r,o,i),l=new nh(r,h,s),a=new nh(o,h,s);i.iterGaps(((t,e,i)=>sh(l,t,a,e,i,n))),i.empty&&0==i.length&&sh(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=Zo(s,r),h=new nh(s,o,0).goto(i),l=new nh(r,o,0).goto(i);for(;;){if(h.to!=l.to||!rh(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new nh(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Qo;for(let n of t instanceof Jo?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Uo(e,n)>0)return t.slice().sort(Uo);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Xo.empty=new Xo([],[],null,-1),Xo.empty.nextLayer=Xo.empty;class Qo{finishChunk(t){this.chunks.push(new Yo(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Qo)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Xo.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Xo.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Zo(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class th{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class eh{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new th(r,e,i,s));return 1==n.length?n[0]:new eh(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)ih(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)ih(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),ih(this.heap,0)}}}function ih(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class nh{constructor(t,e,i){this.minPoint=i,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=eh.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){oh(this.active,t),oh(this.activeTo,t),oh(this.activeRank,t),this.minActive=lh(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;hh(this.active,e,i),hh(this.activeTo,e,n),hh(this.activeRank,e,s),t&&hh(t,e,this.cursor.from),this.minActive=lh(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&oh(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function sh(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&rh(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!rh(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function rh(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function oh(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function hh(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function lh(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}var ah=i("29933");function ch(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function uh(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function fh(t,e){if(!e.anchorNode)return!1;try{return uh(t,e.anchorNode)}catch(t){return!1}}function dh(t){return 3==t.nodeType?Ah(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function gh(t,e,i,n){return!!i&&(mh(t,e,i,n,-1)||mh(t,e,i,n,1))}function ph(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function mh(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:wh(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=ph(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?wh(t):0}}}function wh(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function vh(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function yh(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}class bh{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?wh(e):0),i,Math.min(t.focusOffset,i?wh(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let xh,Sh=null;function kh(t){if(t.setActive)return t.setActive();if(Sh)return t.focus(Sh);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Sh?{get preventScroll(){return Sh={preventScroll:!0},!0}}:void 0),!Sh){Sh=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function Ah(t,e,i=e){let n=xh||(xh=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Mh(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function Ch(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}class Oh{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Oh(t.parentNode,ph(t),e)}static after(t,e){return new Oh(t.parentNode,ph(t)+1,e)}}const Dh=[];class Th{constructor(){this.parent=null,this.dom=null,this.dirty=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.dirty){let i,n=this.dom,s=null;for(let r of this.children){if(r.dirty){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=Th.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.dirty=0}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=Eh(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=Eh(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==wh(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!Th.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.dirty|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=Dh){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new Rh(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function Eh(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}Th.prototype.breakAfter=0;class Rh{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){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;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Bh(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function Ph(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,Bh(t,a,c,h,l,n,0,s,r)}let Lh="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Nh="undefined"!=typeof document?document:{documentElement:{style:{}}};const Ih=/Edge\/(\d+)/.exec(Lh.userAgent),Hh=/MSIE \d/.test(Lh.userAgent),Vh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Lh.userAgent),Wh=!!(Hh||Vh||Ih),Fh=!Wh&&/gecko\/(\d+)/i.test(Lh.userAgent),zh=!Wh&&/Chrome\/(\d+)/.exec(Lh.userAgent),_h="webkitFontSmoothing"in Nh.documentElement.style,qh=!Wh&&/Apple Computer/.test(Lh.vendor),Kh=qh&&(/Mobile\/\w+/.test(Lh.userAgent)||Lh.maxTouchPoints>2);var jh={mac:Kh||/Mac/.test(Lh.platform),windows:/Win/.test(Lh.platform),linux:/Linux|X11/.test(Lh.platform),ie:Wh,ie_version:Hh?Nh.documentMode||6:Vh?+Vh[1]:Ih?+Ih[1]:0,gecko:Fh,gecko_version:Fh?+(/Firefox\/(\d+)/.exec(Lh.userAgent)||[0,0])[1]:0,chrome:!!zh,chrome_version:zh?+zh[1]:0,ios:Kh,android:/Android\b/.test(Lh.userAgent),webkit:_h,safari:qh,webkit_version:_h?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Nh.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class $h extends Th{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof $h&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new $h(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Oh(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return Jh(this.dom,t,e)}}class Gh extends Th{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(Ch(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof Gh&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(Ph(this,t,e,i?i.children:[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Gh(this.mark,e,r)}domAtPos(t){return il(this,t)}coordsAt(t,e){return sl(this,t,e)}}function Jh(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?jh.chrome||jh.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=Ah(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return jh.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?vh(l,o<0):l||null}class Uh extends Th{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||Uh)(t,e,i)}split(t){let e=Uh.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Uh&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Uh&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return Ar.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):Ar.empty}domAtPos(t){return(this.length?0==t:this.side>0)?Oh.before(this.dom):Oh.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return vh(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Yh extends Uh{domAtPos(t){let{topView:e,text:i}=this.widget;return e?Xh(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new Oh(t,Math.min(e,t.nodeValue.length)))):new Oh(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:n}=this.widget;return i?Zh(t,e,i,n,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?Xh(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>Jh(t,e,i))):Jh(n,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function Xh(t,e,i,n,s,r,o){if(i instanceof Gh){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=Th.get(h);if(i){let l=uh(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?Xh(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=Qh(t,e,h,o);if("number"!=typeof i)return i;t=i}}return r(i,i.length,-1)}return i.dom==n?o(n,t,e):r(i,t,e)}function Qh(t,e,i,n){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return n(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=Qh(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function Zh(t,e,i,n,s){if(i instanceof Gh){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=Th.get(o);if(i){let h=uh(o,n);if(uh(o,t))return r+(h?Zh(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=tl(t,e,o);if(null!=i.result)return r+i.result;r+=i.size}}}else if(i.dom==n)return Math.min(e,n.nodeValue.length);return i.localPosFromDOM(t,e)}function tl(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let n=0;for(let s=i.firstChild,r=0;;s=s.nextSibling,r++){if(t==i&&r==e)return{result:n};if(!s)return{size:n};let o=tl(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class el extends Th{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof el&&t.side==this.side}split(){return new el(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?Oh.before(this.dom):Oh.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Ar.empty}get isHidden(){return!0}}function il(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new Oh(i,0)}function nl(t,e,i){let n,{children:s}=t;i>0&&e instanceof Gh&&s.length&&(n=s[s.length-1])instanceof Gh&&n.mark.eq(e.mark)?nl(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function sl(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=dh(e);return i[i.length-1]||null}(t)}function rl(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function ol(t,e){if(t==e)return!0;if(!t||!e)return!1;let i=Object.keys(t),n=Object.keys(e);if(i.length!=n.length)return!1;for(let s of i)if(-1==n.indexOf(s)||t[s]!==e[s])return!1;return!0}function hl(t,e,i){let n=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(n=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(n=s,i[s]);return!!n}$h.prototype.children=Uh.prototype.children=el.prototype.children=Dh;class ll{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get customView(){return null}get isHidden(){return!1}destroy(t){}}var al=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(al||(al={}));class cl extends Go{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new ul(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new dl(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=gl(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new dl(t,e,i,n,t.widget||null,!0)}static line(t){return new fl(t)}static set(t,e=!1){return Xo.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}cl.none=Xo.empty;class ul extends cl{constructor(t){let{start:e,end:i}=gl(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof ul&&this.tagName==t.tagName&&this.class==t.class&&ol(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}ul.prototype.point=!1;class fl extends cl{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof fl&&this.spec.class==t.spec.class&&ol(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}fl.prototype.mapMode=Kr.TrackBefore,fl.prototype.point=!0;class dl extends cl{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?Kr.TrackBefore:Kr.TrackAfter:Kr.TrackDel}get type(){return this.startSide<this.endSide?al.WidgetRange:this.startSide<=0?al.WidgetBefore:al.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof dl&&(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}range(t,e=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 super.range(t,e)}}function gl(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function pl(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}dl.prototype.point=!0;class ml extends Th{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof ml))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Ph(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new ml;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){ol(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){nl(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=rl(e,this.attrs||{})),i&&(this.attrs=rl({class:i},this.attrs||{}))}domAtPos(t){return il(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(Ch(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&&(hl(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&Th.get(n)instanceof Gh;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=Th.get(n))||void 0===i?void 0:i.isEditable)||jh.ios&&this.children.some((t=>t instanceof $h))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof $h)||/[^ -~]/.test(i.text))return null;let n=dh(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=sl(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return al.Text}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof ml)return s;if(r>e)break}n=r+s.breakAfter}return null}}class wl extends Th{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof wl&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?Oh.before(this.dom):Oh.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new wl(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return Dh}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):Ar.empty}domBoundsAround(){return null}become(t){return t instanceof wl&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.type=t.type,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class vl{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof wl&&t.type==al.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new ml),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(yl(new el(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(yl(new $h(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,r){if(this.disallowBlockEffectsFor[r]&&i instanceof dl){if(i.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")}let o=e-t;if(i instanceof dl)if(i.block){let{type:t}=i;t!=al.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new wl(i.widget||new bl("div"),o,t))}else{let r=Uh.create(i.widget||new bl("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(yl(new el(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(yl(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=s)}static build(t,e,i,n,s){let r=new vl(t,e,i,s);return r.openEnd=Xo.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function yl(t,e){for(let i of e)t=new Gh(i,[t],t.length);return t}class bl extends ll{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const xl=no.define(),Sl=no.define(),kl=no.define(),Al=no.define(),Ml=no.define(),Cl=no.define(),Ol=no.define(),Dl=no.define({combine:t=>t.some((t=>t))}),Tl=no.define({combine:t=>t.some((t=>t))});class El{constructor(t,e="nearest",i="nearest",n=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s}map(t){return t.empty?this:new El(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const Rl=Lo.define({map:(t,e)=>t.map(e)});function Bl(t,e,i){let n=t.facet(Al);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const Pl=no.define({combine:t=>!t.length||t[0]});let Ll=0;const Nl=no.define();class Il{constructor(t,e,i,n){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=n(this)}static define(t,e){const{eventHandlers:i,provide:n,decorations:s}=e||{};return new Il(Ll++,t,i,(t=>{let e=[Nl.of(t)];return s&&e.push(Fl.of((e=>{let i=e.plugin(t);return i?s(i):cl.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return Il.define((e=>new t(e)),e)}}class Hl{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(Bl(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Bl(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){Bl(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Vl=no.define(),Wl=no.define(),Fl=no.define(),zl=no.define(),_l=no.define();function ql(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(_l)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Kl=no.define();class jl{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new jl(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new jl(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new jl(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class $l{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=$r.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new jl(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new $l(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Gl=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Gl||(Gl={}));const Jl=Gl.LTR,Ul=Gl.RTL;function Yl(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Xl=Yl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Ql=Yl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Zl=Object.create(null),ta=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Zl[e]=i,Zl[i]=-e}const ea=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class ia{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?Ul:Jl}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}const na=[];function sa(t,e){let i=t.length,n=e==Jl?1:2,s=e==Jl?2:1;if(!t||1==n&&!ea.test(t))return ra(i);for(let e=0,s=n,o=n;e<i;e++){let i=(r=t.charCodeAt(e))<=247?Xl[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?Ql[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==i?i=s:8==i&&4==o&&(i=16),na[e]=4==i?2:i,7&i&&(o=i),s=i}var r;for(let t=0,e=n,s=n;t<i;t++){let n=na[t];if(128==n)t<i-1&&e==na[t+1]&&24&e?n=na[t]=e:na[t]=256;else if(64==n){let n=t+1;for(;n<i&&64==na[n];)n++;let r=t&&8==e||n<i&&8==na[n]?1==s?1:8:256;for(let e=t;e<n;e++)na[e]=r;t=n-1}else 8==n&&1==s&&(na[t]=1);e=n,7&n&&(s=n)}for(let e,r,o,h=0,l=0,a=0;h<i;h++)if(r=Zl[e=t.charCodeAt(h)])if(r<0){for(let t=l-3;t>=0;t-=3)if(ta[t+1]==-r){let e=ta[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(na[h]=na[ta[t]]=i),l=t;break}}else{if(189==ta.length)break;ta[l++]=h,ta[l++]=e,ta[l++]=a}else if(2==(o=na[h])||1==o){let t=o==n;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=ta[e+2];if(2&i)break;if(t)ta[e+2]|=2;else{if(4&i)break;ta[e+2]|=4}}}for(let t=0;t<i;t++)if(256==na[t]){let e=t+1;for(;e<i&&256==na[e];)e++;let s=1==(t?na[t-1]:n),r=s==(1==(e<i?na[e]:n))?s?1:2:n;for(let i=t;i<e;i++)na[i]=r;t=e-1}let o=[];if(1==n)for(let t=0;t<i;){let e=t,n=1!=na[t++];for(;t<i&&n==(1!=na[t]);)t++;if(n)for(let i=t;i>e;){let t=i,n=2!=na[--i];for(;i>e&&n==(2!=na[i-1]);)i--;o.push(new ia(i,t,n?2:1))}else o.push(new ia(e,t,0))}else for(let t=0;t<i;){let e=t,n=2==na[t++];for(;t<i&&n==(2==na[t]);)t++;o.push(new ia(e,t,n?1:2))}return o}function ra(t){return[new ia(0,t,0)]}let oa="";function ha(t,e,i,n,s){var r;let o=n.head-t.from,h=-1;if(0==o){if(!s||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),h=0)}else if(o==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),h=e.length-1)}h<0&&(h=ia.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc));let l=e[h];o==l.side(s,i)&&(l=e[h+=s?1:-1],o=l.side(!s,i));let a=s==(l.dir==i),c=Ir(t.text,o,a);if(oa=t.text.slice(Math.min(o,c),Math.max(o,c)),c!=l.side(s,i))return to.cursor(c+t.from,a?-1:1,l.level);let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u||l.level==i?u&&u.level<l.level?to.cursor(u.side(!s,i)+t.from,s?1:-1,u.level):to.cursor(c+t.from,s?-1:1,l.level):to.cursor(s?t.to:t.from,s?-1:1,i)}const la="";class aa{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet($o.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=la}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=Th.get(n),o=Th.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:ca(n))||ca(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=Th.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}}function ca(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class ua{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class fa extends Th{constructor(t){super(),this.view=t,this.compositionDeco=cl.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new ml],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new jl(0,0,0,t.state.doc.length)],0)}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;this.minWidth>0&&e.length&&(e.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.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=cl.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=ga(t);if(!i)return cl.none;let{from:n,to:s,node:r,text:o}=i,h=e.mapPos(n,1),l=Math.max(h,e.mapPos(s,-1)),{state:a}=t,c=new aa([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(la)>-1)return cl.none;if(l-h<u.length)if(a.doc.sliceString(h,Math.min(a.doc.length,h+u.length))==u)l=h+u.length;else{if(a.doc.sliceString(Math.max(0,l-u.length),l)!=u)return cl.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return cl.none;let f=Th.get(r);f instanceof Yh?f=f.widget.topView:f&&(f.parent=null);return cl.set(cl.replace({widget:new pa(r,o,f),inclusive:!0}).range(h,l))}(this.view,t.changes)),(jh.ie||jh.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=function(t,e,i){let n=new wa;return Xo.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return e=jl.extendWithRanges(e,i),(0!=this.dirty||0!=e.length)&&(this.updateInner(e,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=jh.chrome||jh.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof wl&&t.widget instanceof da&&n.push(t.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let n=e>=0?t[e]:null;if(!n)break;let{fromA:s,toA:r,fromB:o,toB:h}=n,{content:l,breakAtStart:a,openStart:c,openEnd:u}=vl.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:g,off:p}=i.findPos(s,-1);Bh(this,g,p,f,d,l,a,c,u)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&fh(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.domAtPos(o.anchor),l=o.empty?h:this.domAtPos(o.head);if(jh.gecko&&o.empty&&!this.compositionDeco.size&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new Oh(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&gh(h.node,h.offset,c.anchorNode,c.anchorOffset)&&gh(l.node,l.offset,c.focusNode,c.focusOffset)||(this.view.observer.ignore((()=>{jh.android&&jh.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=ch(this.view.root);if(t)if(o.empty){if(jh.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=ma(h.node,h.offset,1==t?1:-1);e&&(h=new Oh(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=c.cursorBidiLevel&&(c.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new Oh(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new Oh(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=ch(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=ml.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}nearest(t){for(let e=t;e;){let t=Th.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof ml)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,n=this.children.length-1;;n--){let s=this.children[n],r=i-s.breakAfter-s.length;if(t>r||t==r&&s.type!=al.WidgetBefore&&s.type!=al.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==al.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==Gl.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?dh(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Gl.RTL:Gl.LTR}measureTextSize(){for(let t of this.children)if(t instanceof ml){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=dh(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new Rh(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=e.lineBlockAt(r).bottom-e.lineBlockAt(i).top;t.push(cl.replace({widget:new da(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return cl.set(t)}updateDeco(){let t=this.view.state.facet(Fl).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=ql(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};!function(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,u=c==l.body;if(u)t=yh(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let f=0,d=0;if("nearest"==s)e.top<t.top?(d=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+d&&(d=e.bottom-t.bottom+d+o)):e.bottom>t.bottom&&(d=e.bottom-t.bottom+o,i<0&&e.top-d<t.top&&(d=-(t.top+d-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;d=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n?e.left<t.left?(f=-(t.left-e.left+r),i>0&&e.right>t.right+f&&(f=e.right-t.right+f+r)):e.right>t.right&&(f=e.right-t.right+r,i<0&&e.left<t.left+f&&(f=-(t.left+f-e.left+r))):f=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left,f||d)if(u)a.scrollBy(f,d);else{let t=0,i=0;if(d){let t=c.scrollTop;c.scrollTop+=d,i=c.scrollTop-t}if(f){let e=c.scrollLeft;c.scrollLeft+=f,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-f)<1&&(n="nearest"),i&&Math.abs(i-d)<1&&(s="nearest")}if(u)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Gl.LTR)}}class da extends ll{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function ga(t){let e=t.observer.selectionRange,i=e.focusNode&&ma(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof ml){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!Th.get(e);)e=e.previousSibling;let s=e?Th.get(e).posAtEnd:n.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=n;if(!t)return null;if(t instanceof ml)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}class pa extends ll{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return Yh}}function ma(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return i;if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=wh(i)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}class wa{constructor(){this.changes=[]}compareRange(t,e){pl(t,e,this.changes)}comparePoint(t,e){pl(t,e,this.changes)}}function va(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function ya(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function ba(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function xa(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function Sa(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function ka(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=dh(f);for(let d=0;d<t.length;d++){let g=t[d];s&&ba(s,g)&&(g=xa(Sa(g,s.bottom),s.top));let p=va(e,g),m=ya(i,g);if(0==p&&0==m)return 3==f.nodeType?Aa(f,e,i):ka(f,e,i);if(!n||o>m||o==m&&r>p){n=f,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=f,a=g):i<g.top&&(!c||c.top>g.top)&&(l=f,c=g):a&&ba(a,g)?a=Sa(a,g.bottom):c&&ba(c,g)&&(c=xa(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Aa(n,f,i):u&&"false"!=n.contentEditable?ka(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Aa(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=Ah(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(jh.chrome||jh.gecko){Ah(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Ma(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=al.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:Ca(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Ca(t,h,o,c,u);let g=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:g,m=p.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=p.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||jh.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return Ah(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||jh.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Ah(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=ml.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=ka(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function Ca(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=Ir(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function Oa(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==al.Text))return t;return i}function Da(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=ha(s,r,o,h,i),a=oa;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=to.cursor(i?s.from:s.to)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function Ta(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function Ea(t,e,i){let n=Ta(t.state.facet(zl).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:to.cursor(n,n<i.from?1:-1)}class Ra{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,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.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in Va){let n=Va[i];t.contentDOM.addEventListener(i,(i=>{Ha(t,i)&&e(n,i)}),Wa[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(Va.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),t.scrollDOM.addEventListener("drop",(i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(Va.drop,i)})),jh.chrome&&102==jh.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,jh.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let n;this.customHandlers=[];for(let s of e)if(n=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:n});for(let e in n)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{Ha(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}}runCustomHandlers(t,e,i){for(let n of this.customHandlers){let s=n.handlers[t];if(s)try{if(s.call(n.plugin,i,e)||i.defaultPrevented)return!0}catch(t){Bl(e.state,t)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,e,t)}catch(e){Bl(t.state,e)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=e.keyCode&&La.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),jh.android&&jh.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!jh.ios||e.synthetic||e.altKey||e.metaKey||!((i=Ba.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||Pa.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,Mh(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(jh.safari&&!jh.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const Ba=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Pa="dthko",La=[16,17,18,20,91,92,224,225];function Na(t){return.7*Math.max(0,t)+8}class Ia{constructor(t,e,i,n){this.view=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(zl).map((e=>e(t)));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet($o.allowMultipleSelections)&&function(t,e){let i=t.state.facet(xl);return i.length?i[0](e):jh.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=ch(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Xa(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,n=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},r=ql(this.view);t.clientX-r.left<=s.left+6?i=-Na(s.left-t.clientX):t.clientX+r.right>=s.right-6&&(i=Na(t.clientX-s.right)),t.clientY-r.top<=s.top+6?n=-Na(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-6&&(n=Na(t.clientY-s.bottom)),this.setScrollSpeed(i,n)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=Ta(this.atoms,n.from,0);t!=n.from&&(s=to.cursor(t,-1))}else{let t=Ta(this.atoms,n.from,-1),e=Ta(this.atoms,n.to,1);t==n.from&&e==n.to||(s=to.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?to.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection)&&i.main.assoc==e.state.selection.main.assoc||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function Ha(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=Th.get(n))&&i.ignoreEvent(e))return!1;return!0}const Va=Object.create(null),Wa=Object.create(null),Fa=jh.ie&&jh.ie_version<15||jh.ios&&jh.webkit_version<604;function za(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Za&&n.selection.ranges.every((t=>t.empty))&&Za==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:to.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:to.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function _a(t,e,i,n){if(1==n)return to.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return to.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=Ir(s.text,r,!1):h=Ir(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=Ir(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=Ir(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return to.range(o+s.from,h+s.from)}(t.state,e,i);{let i=ml.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,to.range(s,r)}}Va.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},Va.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Va.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Wa.touchstart=Wa.touchmove={passive:!0},Va.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(kl))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=$a(t,e),n=Xa(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=$a(t,e),a=_a(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=_a(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?to.range(s,r):to.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return to.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?h:o?s.addRange(a):to.create([a])}}}(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new Ia(t,e,i,n)),n&&t.observer.ignore((()=>kh(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let qa=(t,e)=>t>=e.top&&t<=e.bottom,Ka=(t,e,i)=>qa(e,i)&&t>=i.left&&t<=i.right;function ja(t,e,i,n){let s=ml.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Ka(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Ka(i,n,h)?1:o&&qa(n,o)?-1:1}function $a(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:ja(t,i,e.clientX,e.clientY)}}const Ga=jh.ie&&jh.ie_version<=11;let Ja=null,Ua=0,Ya=0;function Xa(t){if(!Ga)return t.detail;let e=Ja,i=Ya;return Ja=t,Ya=Date.now(),Ua=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Ua+1)%3:1}function Qa(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=t.inputState,o=n&&r&&r.dragging&&function(t,e){let i=t.state.facet(Sl);return i.length?i[0](e):jh.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.dragging.from,to:r.dragging.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}Va.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},Va.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let n=Array(i.length),s=0,r=()=>{++s==i.length&&Qa(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}}else Qa(t,e,e.dataTransfer.getData("Text"),!0)},Va.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=Fa?null:e.clipboardData;i?(za(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),za(t,i.value)}),50)}(t)};let Za=null;Va.copy=Va.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return;Za=s?i:null;let r=Fa?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const tc=Ro.define();function ec(t,e){let i=[];for(let n of t.facet(Ol)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:tc.of(!0)}):null}function ic(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=ec(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Va.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),ic(t)},Va.blur=t=>{t.observer.clearSelectionRange(),ic(t)},Va.compositionstart=Va.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},Va.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,jh.chrome&&jh.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},Va.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Va.beforeinput=(t,e)=>{var i;let n;if(jh.chrome&&jh.android&&(n=Ba.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};const nc=["pre-wrap","normal","pre-line","break-spaces"];class sc{constructor(t){this.lineWrapping=t,this.doc=Ar.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return nc.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=nc.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class rc{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class oc{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?al.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof dl?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new oc(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var hc=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(hc||(hc={}));const lc=.001;class ac{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>lc&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return ac.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,hc.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,hc.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,hc.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=pc.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new uc(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new dc(ac.of(t.slice(0,e)),r,ac.of(t.slice(i)))}}ac.prototype.size=1;class cc extends ac{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new oc(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class uc extends cc{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new oc(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof uc||n instanceof fc&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof fc?n=new uc(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):ac.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class fc extends ac{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new oc(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new oc(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==hc.ByHeight)return this.blockAt(t,i,n,s);if(e==hc.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new oc(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new oc(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new oc(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof fc?i[i.length-1]=new fc(t.length+n):i.push(null,new fc(n-1))}if(t>0){let e=i[0];e instanceof fc?i[0]=new fc(t+e.length):i.unshift(new fc(t-1),null)}return ac.of(i)}decomposeLeft(t,e){e.push(new fc(t-1),null)}decomposeRight(t,e){e.push(null,new fc(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new fc(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=lc&&(o=-2);let h=new uc(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new fc(s-r).updateHeight(t,r));let h=ac.of(i);return(o<0||Math.abs(h.height-this.height)>=lc||Math.abs(o-this.heightMetrics(t,e).perLine)>=lc)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class dc extends ac{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==hc.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==hc.ByPosNoHeight?hc.ByPosNoHeight:hc.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,hc.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&gc(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),gc(s,t)}return ac.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?ac.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)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function gc(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof fc&&(n=t[e+1])instanceof fc&&t.splice(e-1,3,new fc(i.length+1+n.length))}class pc{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof uc?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new uc(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new cc(r,n,i)):(r||s||n>=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new uc(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new fc(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof uc)return t;let e=new uc(0,-1);return this.nodes.push(e),e}addBlock(t){var e;this.enterLine();let i=null===(e=t.deco)||void 0===e?void 0:e.type;i!=al.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=al.WidgetBefore&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof uc||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new uc(0,-1));let i=t;for(let t of this.nodes)t instanceof uc&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new pc(i,t);return Xo.spans(e,i,n,s,0),s.finish(i)}}class mc{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&pl(t,e,this.changes,5)}}function wc(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function vc(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class yc{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t){return cl.replace({widget:new bc(this.size,t)}).range(this.from,this.to)}}class bc extends ll{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let 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}get estimatedHeight(){return this.vertical?this.size:-1}}class xc{constructor(t){this.state=t,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.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Cc,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Gl.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Wl).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new sc(e),this.stateDeco=t.facet(Fl).filter((t=>"function"!=typeof t)),this.heightMap=ac.empty().applyChanges(this.stateDeco,Ar.empty,this.heightOracle.setDoc(t.doc),[new jl(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=cl.set(this.lineGaps.map((t=>t.draw(!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new Sc(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?Cc:new Oc(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:Dc(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Fl).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=jl.extendWithRanges(n,function(t,e,i){let n=new mc;return Xo.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:$r.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.lineBlockAtHeight(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),l&&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&&!t.state.facet(Tl)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Gl.RTL:Gl.LTR;let r=this.heightOracle.mustRefreshForWrapping(s),o=e.getBoundingClientRect(),h=r||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let l=0,a=0,c=parseInt(i.paddingTop)||0,u=parseInt(i.paddingBottom)||0;this.paddingTop==c&&this.paddingBottom==u||(this.paddingTop=c,this.paddingBottom=u,l|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=8),this.scrollTop!=t.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=t.scrollDOM.scrollTop),this.scrolledToBottom=this.scrollTop>t.scrollDOM.scrollHeight-t.scrollDOM.clientHeight-4;let f=(this.printing?vc:wc)(e,this.paddingTop),d=f.top-this.pixelViewport.top,g=f.bottom-this.pixelViewport.bottom;this.pixelViewport=f;let p=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(p!=this.inView&&(this.inView=p,p&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let m=o.width;if(this.contentDOMWidth==m&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,l|=8),h){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(r=!0),r||n.lineWrapping&&Math.abs(m-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:o,textHeight:h}=t.docView.measureTextSize();r=i>0&&n.refresh(s,i,o,h,m/o,e),r&&(t.docView.minWidth=0,l|=8)}d>0&&g>0?a=Math.max(d,g):d<0&&g<0&&(a=Math.min(d,g)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(r?ac.empty().applyChanges(this.stateDeco,Ar.empty,this.heightOracle,[new jl(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,r,new rc(i.from,s))}n.heightChanged&&(l|=2)}let w=!this.viewportIsAppropriate(this.viewport,a)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(this.viewport=this.getViewport(a,this.scrollTarget)),this.updateForViewport(),(2&l||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new Sc(n.lineAt(r-1e3*i,hc.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),hc.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,hc.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new Sc(n.lineAt(i-500,hc.ByHeight,s,0,0).from,n.lineAt(i+r+500,hc.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Sc(this.heightMap.lineAt(i,hc.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,hc.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,hc.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,hc.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new yc(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,r=n<<1;if(this.defaultTextDirection!=Gl.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(to.cursor(r),!1,!0).head;t>n&&(r=t)}f=new yc(n,r,this.gapSize(l,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.length<r)continue;let e=kc(t.from,t.to,this.stateDeco);if(e.total<r)continue;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=Mc(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=Ac(e,i),o=Ac(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=Mc(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=Ac(e,t),o=Ac(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)}return o}gapSize(t,e,i,n){let s=Mc(n,i)-Mc(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){yc.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=cl.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Xo.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Dc(this.heightMap.lineAt(t,hc.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return Dc(this.heightMap.lineAt(this.scaler.fromDOM(t),hc.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return Dc(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Sc{constructor(t,e){this.from=t,this.to=e}}function kc(t,e,i){let n=[],s=t,r=0;return Xo.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function Ac({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function Mc(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const Cc={toDOM:t=>t,fromDOM:t=>t,scale:1};class Oc{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,hc.ByPos,t,0,0).top,o=e.lineAt(s,hc.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}}function Dc(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new oc(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>Dc(t,e))):t._content)}const Tc=no.define({combine:t=>t.join(" ")}),Ec=no.define({combine:t=>t.indexOf(!0)>-1}),Rc=ah.V.newName(),Bc=ah.V.newName(),Pc=ah.V.newName(),Lc={"&light":"."+Bc,"&dark":"."+Pc};function Nc(t,e,i){return new ah.V(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const Ic=Nc("."+Rc,{"&":{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,flexShrink:0,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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},Lc);class Hc{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new ua(i,n)),s==i&&r==n||e.push(new ua(s,r)));return e}(t),i=new aa(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?to.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!uh(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!uh(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=to.single(n,i)}}}function Vc(t,e){let i,{newSel:n}=e,s=t.state.selection.main,r=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:o}=e.bounds,h=s.from,l=null;(8===r||jh.android&&e.text.length<o-n)&&(h=s.to,l="end");let a=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(n,o,la),e.text,h-n,l);a&&(jh.chrome&&13==r&&a.toB==a.from+2&&e.text.slice(a.from,a.toB)==la+la&&a.toB--,i={from:n+a.from,to:n+a.toA,insert:Ar.of(e.text.slice(a.from,a.toB).split(la))})}else n&&(!t.hasFocus&&t.state.facet(Pl)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(jh.mac||jh.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=to.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:Ar.of([" "])}):jh.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=to.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:Ar.of([" "])}),i){let e=t.state;if(jh.ios&&t.inputState.flushIOSKey(t))return!0;if(jh.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&Mh(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==r&&i.insert.length<i.to-i.from)&&Mh(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&Mh(t.contentDOM,"Delete",46)))return!0;let o,h=i.insert.toString();if(t.state.facet(Cl).some((e=>e(t,i.from,i.to,h))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=s.from&&i.to<=s.to&&i.to-i.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let n=s.from<i.from?e.sliceDoc(s.from,i.from):"",r=s.to>i.to?e.sliceDoc(i.to,s.to):"";o=e.replaceSelection(t.state.toText(n+i.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=e.changes(i),h=n&&n.main.to<=r.newLength?n.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=s.to&&i.to>=s.to-10){let n=t.state.sliceDoc(i.from,i.to),l=ga(t)||t.state.doc.lineAt(s.head),a=s.to-i.to,c=s.to-s.from;o=e.changeByRange((o=>{if(o.from==s.from&&o.to==s.to)return{changes:r,range:h||o.map(r)};let u=o.to-a,f=u-n.length;if(o.to-o.from!=c||t.state.sliceDoc(f,u)!=n||l&&o.to>=l.from&&o.from<=l.to)return{range:o};let d=e.changes({from:f,to:u,insert:i.insert}),g=o.to-s.to;return{changes:d,range:h?to.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):o.map(d)}}))}else o={changes:r,selection:h&&e.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(o,{scrollIntoView:!0,userEvent:l}),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}const Wc={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Fc=jh.ie&&jh.ie_version<=11;class zc{constructor(t){this.view=t,this.active=!1,this.selectionRange=new bh,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(jh.ie&&jh.ie_version<=11||jh.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Fc&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Pl)?i.root.activeElement!=this.dom:!fh(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(jh.ie&&jh.ie_version<=11||jh.android&&jh.chrome)&&!i.state.selection.main.empty&&n.focusNode&&gh(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=jh.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);gh(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||ch(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=fh(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,wh(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=wh(i))}else{if(i==t)return!0;n=ph(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Wc),Fc&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Fc&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Mh(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&fh(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new Hc(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,n=Vc(this.view,e);return this.view.state==i&&this.view.update([]),n}readMutation(t){let 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){let i=_c(e,t.previousSibling||t.target.previousSibling,-1),n=_c(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,n;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(n=this.resizeContent)||void 0===n||n.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function _c(t,e,i){for(;e;){let n=Th.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}class qc{constructor(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: fixed; 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=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new xc(t.state||$o.create(t)),this.plugins=this.state.facet(Nl).map((t=>new Hl(t)));for(let t of this.plugins)t.update(this);this.observer=new zc(this),this.inputState=new Ra(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new fa(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){let e=1==t.length&&t[0]instanceof No?t[0]:this.state.update(...t);this._dispatch(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(tc)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=ec(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet($o.phrases)!=this.state.facet($o.phrases))return this.setState(s);e=$l.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new El(t.empty?t:to.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Rl)&&(c=t.value)}this.viewState.update(e,c),this.bidiCache=$c.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Kl)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(Tc)!=e.state.facet(Tc)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(Ml))t(e);(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!Vc(this,a)&&l.force&&Mh(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new xc(t),this.plugins=t.facet(Nl).map((t=>new Hl(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new fa(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Nl),i=t.state.facet(Nl);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Hl(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,{scrollTop:n}=i,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;if(this.viewState.scrollAnchorHeight=-1,r<0||n!=this.viewState.scrollTop)if(n>i.scrollHeight-i.clientHeight-4)s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.lineBlockAtHeight(n);s=t.from,r=t.top}try{for(let t=0;;t++){this.updateState=1;let o=this.viewport,h=this.viewState.measure(this);if(!h&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&h||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(t){return Bl(this.state,t),jc}})),c=$l.create(this,this.state,[]),u=!1,f=!1;c.flags|=h,e?e.flags|=h:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c));for(let t=0;t<l.length;t++)if(a[t]!=jc)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){Bl(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,f=!0;else if(r>-1){let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;(t>1||t<-1)&&(i.scrollTop=n+t,f=!0)}if(u&&this.docView.updateSelection(!0),this.viewport.from==o.from&&this.viewport.to==o.to&&!f&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Ml))t(e)}get themeClasses(){return Rc+" "+(this.state.facet(Ec)?Pc:Bc)+" "+this.state.facet(Tc)}updateAttrs(){let t=Gc(this,Vl,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Pl)?"true":"false",class:"cm-content",style:`${jh.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Gc(this,Wl,e);let i=this.observer.ignore((()=>{let i=hl(this.contentDOM,this.contentAttrs,e),n=hl(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(qc.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Kl),ah.V.mount(this.root,this.styleModules.concat(Ic).reverse())}readMeasured(){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)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Ea(this,t,Da(this,t,e,i))}moveByGroup(t,e){return Ea(this,t,Da(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==_o.Space&&(s=e),s==e}}(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=Oa(t,e.head),r=n&&s.type==al.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==Gl.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return to.cursor(o,i?-1:1)}return to.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Ea(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return to.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let i=0;;i+=10){let n=o+(f+i)*r,a=Ma(t,{x:u,y:n},!1,r);if(n<l.top||n>l.bottom||(r<0?a<s:a>s))return to.cursor(a,e.assoc,void 0,h)}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ma(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return vh(i,s[ia.find(s,t-n.from,-1,e)].dir==Gl.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Dl)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Kc)return ra(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=sa(t.text,e);return this.bidiCache.push(new $c(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||jh.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{kh(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Rl.of(new El("number"==typeof t?to.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return Il.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=ah.V.newName(),n=[Tc.of(i),Kl.of(Nc(`.${i}`,t))];return e&&e.dark&&n.push(Ec.of(!0)),n}static baseTheme(t){return wo.lowest(Kl.of(Nc("."+Rc,t,Lc)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Th.get(i)||Th.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}qc.styleModule=Kl,qc.inputHandler=Cl,qc.focusChangeEffect=Ol,qc.perLineTextDirection=Dl,qc.exceptionSink=Al,qc.updateListener=Ml,qc.editable=Pl,qc.mouseSelectionStyle=kl,qc.dragMovesSelection=Sl,qc.clickAddsSelectionRange=xl,qc.decorations=Fl,qc.atomicRanges=zl,qc.scrollMargins=_l,qc.darkTheme=Ec,qc.contentAttributes=Wl,qc.editorAttributes=Vl,qc.lineWrapping=qc.contentAttributes.of({class:"cm-lineWrapping"}),qc.announce=Lo.define();const Kc=4096,jc={};class $c{constructor(t,e,i,n){this.from=t,this.to=e,this.dir=i,this.order=n}static update(t,e){if(e.empty)return t;let i=[],n=t.length?t[t.length-1].dir:Gl.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new $c(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function Gc(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&rl(r,i)}return i}const Jc=!jh.ios;const Uc={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Jc&&(Uc[".cm-line"].caretColor="transparent !important");class Yc extends Go{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Yc.prototype.elementClass="",Yc.prototype.toDOM=void 0,Yc.prototype.mapMode=Kr.TrackBefore,Yc.prototype.startSide=Yc.prototype.endSide=-1,Yc.prototype.point=!0;i("88972");const Xc=1024;let Qc=0;class Zc{constructor(t={}){this.id=Qc++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=eu.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}Zc.closedBy=new Zc({deserialize:t=>t.split(" ")}),Zc.openedBy=new Zc({deserialize:t=>t.split(" ")}),Zc.group=new Zc({deserialize:t=>t.split(" ")}),Zc.contextHash=new Zc({perNode:!0}),Zc.lookAhead=new Zc({perNode:!0}),Zc.mounted=new Zc({perNode:!0});const tu=Object.create(null);class eu{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):tu,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new eu(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(Zc.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(Zc.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}eu.none=new eu("",Object.create(null),0,8);const iu=new WeakMap,nu=new WeakMap;var su;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(su||(su={}));class ru{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(Zc.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new mu(this.topNode,t)}cursorAt(t,e=0,i=0){let n=iu.get(this)||this.topNode,s=new mu(n);return s.moveTo(t,e),iu.set(this,s._tree),s}get topNode(){return new uu(this,0,0,null)}resolve(t,e=0){let i=cu(iu.get(this)||this.topNode,t,e,!1);return iu.set(this,i),i}resolveInner(t,e=0){let i=cu(nu.get(this)||this.topNode,t,e,!0);return nu.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&su.IncludeAnonymous)>0;for(let t=this.cursor(r|su.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:bu(eu.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new ru(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new ru(eu.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=Xc,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new ou(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,w,v){let{id:y,start:b,end:x,size:S}=h,k=c;for(;S<0;){if(h.next(),-1==S){let e=r[y];return i.push(e),void w.push(b-t)}if(-3==S)return void(a=y);if(-4==S)return void(c=y);throw new RangeError(`Unrecognized record size: ${S}`)}let A,M,C=l[y],O=b-t;if(x-b<=s&&(M=p(h.pos-e,v))){let e=new Uint16Array(M.size-M.skip),i=h.pos-M.size,s=e.length;for(;h.pos>i;)s=m(M.start,e,s);A=new hu(e,x-M.start,n),O=M.start-t}else{let t=h.pos-S;h.next();let e=[],i=[],n=y>=o?y:-1,r=0,l=x;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(d(e,i,b,r,h.end,l,n,k),r=e.length,l=h.end),h.next()):u(b,t,e,i,n);if(n>=0&&r>0&&r<e.length&&d(e,i,b,r,b,l,n,k),e.reverse(),i.reverse(),n>-1&&r>0){let t=f(C);A=bu(C,e,i,0,e.length,0,x-b,t,t)}else A=g(C,e,i,x-b,k-x)}i.push(A),w.push(O)}function f(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof ru){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(Zc.lookAhead))&&(o=i[h]+s.length+r)}return g(t,e,i,n,o)}}function d(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(g(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function g(t,e,i,n,s=0,r){if(a){let t=[Zc.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[Zc.lookAhead,s];r=r?[t].concat(r):[t]}return new ru(t,e,i,n,r)}function p(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function m(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let w=[],v=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,w,v,-1);let y=null!==(e=t.length)&&void 0!==e?e:w.length?v[0]+w[0].length:0;return new ru(l[t.topID],w.reverse(),v.reverse(),y)}(t)}}ru.empty=new ru(eu.none,[],[],0);class ou{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new ou(this.buffer,this.index)}}class hu{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return eu.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return s+"("+r.join(",")+")"}findChild(t,e,i,n,s){let{buffer:r}=this,o=-1;for(let h=t;h!=e&&!(lu(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new hu(s,r,this.set)}}function lu(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function au(t,e){let i=t.childBefore(e);for(;i;){let e=i.lastChild;if(!e||e.to!=i.to)break;e.type.isError&&e.from==e.to?(t=i,i=e.prevSibling):i=e}return t}function cu(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof uu&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:su.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof uu&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class uu{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:o,positions:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(lu(n,i,a,a+l.length))if(l instanceof hu){if(s&su.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new pu(new gu(r,l,t,a),null,o)}else if(s&su.IncludeAnonymous||!l.type.isAnonymous||wu(l)){let o;if(!(s&su.IgnoreMounts)&&l.props&&(o=l.prop(Zc.mounted))&&!o.overlay)return new uu(o.tree,a,t,r);let h=new uu(l,a,t,r);return s&su.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&su.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&su.IgnoreOverlays)&&(n=this._tree.prop(Zc.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new uu(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(t=0){return new mu(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return cu(this,t,e,!1)}resolveInner(t,e=0){return cu(this,t,e,!0)}enterUnfinishedNodesBefore(t){return au(this,t)}getChild(t,e=null,i=null){let n=fu(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return fu(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return du(this,t)}}function fu(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!s.type.is(i);)if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function du(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class gu{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class pu{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new pu(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&su.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new pu(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new pu(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new pu(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new mu(this,t)}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new ru(this.type,t,e,this.to-this.from)}resolve(t,e=0){return cu(this,t,e,!1)}resolveInner(t,e=0){return cu(this,t,e,!0)}enterUnfinishedNodesBefore(t){return au(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=fu(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return fu(this,t,e,i)}get node(){return this}matchContext(t){return du(this,t)}}class mu{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof uu)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof uu?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&su.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&su.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&su.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(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));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&su.IncludeAnonymous||t instanceof hu||!t.type.isAnonymous||wu(t))return!1}return!0}move(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}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(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}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new pu(this.buffer,e,this.stack[t]);return this.bufferNode=new pu(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return du(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return du(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function wu(t){return t.children.some((t=>t instanceof hu||!t.type.isAnonymous||wu(t)))}const vu=new WeakMap;function yu(t,e){if(!t.isAnonymous||e instanceof hu||e.type!=t)return 1;let i=vu.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof ru)){i=1;break}i+=yu(t,n)}vu.set(e,i)}return i}function bu(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=yu(t,e[i]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=yu(t,i[a]);for(a++;a<o;a++){let e=yu(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(bu(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}new Zc({perNode:!0});let xu=0;class Su{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=xu++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new Su([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new Au;return e=>e.modified.indexOf(t)>-1?e:Au.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let ku=0;class Au{constructor(){this.instances=[],this.id=ku++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new Su(n,t,e);for(let t of e)t.instances.push(s);let r=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of r)n.push(Au.get(e,t));return s}}function Mu(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,h=i[o];if(!h)throw new RangeError("Invalid path: "+t);let l=new Ou(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return Cu.add(e)}const Cu=new Zc;class Ou{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function Du(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}Ou.empty=new Ou([],2,null);const Tu=Su.define,Eu=Tu(),Ru=Tu(),Bu=Tu(Ru),Pu=Tu(Ru),Lu=Tu(),Nu=Tu(Lu),Iu=Tu(Lu),Hu=Tu(),Vu=Tu(Hu),Wu=Tu(),Fu=Tu(),zu=Tu(),_u=Tu(zu),qu=Tu(),Ku={comment:Eu,lineComment:Tu(Eu),blockComment:Tu(Eu),docComment:Tu(Eu),name:Ru,variableName:Tu(Ru),typeName:Bu,tagName:Tu(Bu),propertyName:Pu,attributeName:Tu(Pu),className:Tu(Ru),labelName:Tu(Ru),namespace:Tu(Ru),macroName:Tu(Ru),literal:Lu,string:Nu,docString:Tu(Nu),character:Tu(Nu),attributeValue:Tu(Nu),number:Iu,integer:Tu(Iu),float:Tu(Iu),bool:Tu(Lu),regexp:Tu(Lu),escape:Tu(Lu),color:Tu(Lu),url:Tu(Lu),keyword:Wu,self:Tu(Wu),null:Tu(Wu),atom:Tu(Wu),unit:Tu(Wu),modifier:Tu(Wu),operatorKeyword:Tu(Wu),controlKeyword:Tu(Wu),definitionKeyword:Tu(Wu),moduleKeyword:Tu(Wu),operator:Fu,derefOperator:Tu(Fu),arithmeticOperator:Tu(Fu),logicOperator:Tu(Fu),bitwiseOperator:Tu(Fu),compareOperator:Tu(Fu),updateOperator:Tu(Fu),definitionOperator:Tu(Fu),typeOperator:Tu(Fu),controlOperator:Tu(Fu),punctuation:zu,separator:Tu(zu),bracket:_u,angleBracket:Tu(_u),squareBracket:Tu(_u),paren:Tu(_u),brace:Tu(_u),content:Hu,heading:Vu,heading1:Tu(Vu),heading2:Tu(Vu),heading3:Tu(Vu),heading4:Tu(Vu),heading5:Tu(Vu),heading6:Tu(Vu),contentSeparator:Tu(Hu),list:Tu(Hu),quote:Tu(Hu),emphasis:Tu(Hu),strong:Tu(Hu),link:Tu(Hu),monospace:Tu(Hu),strikethrough:Tu(Hu),inserted:Tu(),deleted:Tu(),changed:Tu(),invalid:Tu(),meta:qu,documentMeta:Tu(qu),annotation:Tu(qu),processingInstruction:Tu(qu),definition:Su.defineModifier(),constant:Su.defineModifier(),function:Su.defineModifier(),standard:Su.defineModifier(),local:Su.defineModifier(),special:Su.defineModifier()};Du([{tag:Ku.link,class:"tok-link"},{tag:Ku.heading,class:"tok-heading"},{tag:Ku.emphasis,class:"tok-emphasis"},{tag:Ku.strong,class:"tok-strong"},{tag:Ku.keyword,class:"tok-keyword"},{tag:Ku.atom,class:"tok-atom"},{tag:Ku.bool,class:"tok-bool"},{tag:Ku.url,class:"tok-url"},{tag:Ku.labelName,class:"tok-labelName"},{tag:Ku.inserted,class:"tok-inserted"},{tag:Ku.deleted,class:"tok-deleted"},{tag:Ku.literal,class:"tok-literal"},{tag:Ku.string,class:"tok-string"},{tag:Ku.number,class:"tok-number"},{tag:[Ku.regexp,Ku.escape,Ku.special(Ku.string)],class:"tok-string2"},{tag:Ku.variableName,class:"tok-variableName"},{tag:Ku.local(Ku.variableName),class:"tok-variableName tok-local"},{tag:Ku.definition(Ku.variableName),class:"tok-variableName tok-definition"},{tag:Ku.special(Ku.variableName),class:"tok-variableName2"},{tag:Ku.definition(Ku.propertyName),class:"tok-propertyName tok-definition"},{tag:Ku.typeName,class:"tok-typeName"},{tag:Ku.namespace,class:"tok-namespace"},{tag:Ku.className,class:"tok-className"},{tag:Ku.macroName,class:"tok-macroName"},{tag:Ku.propertyName,class:"tok-propertyName"},{tag:Ku.operator,class:"tok-operator"},{tag:Ku.comment,class:"tok-comment"},{tag:Ku.meta,class:"tok-meta"},{tag:Ku.invalid,class:"tok-invalid"},{tag:Ku.punctuation,class:"tok-punctuation"}]);var ju;const $u=new Qs;const Gu=new Qs;class Ju{constructor(t,e,i=[],n=""){this.data=t,this.name=n,$o.prototype.hasOwnProperty("tree")||Object.defineProperty($o.prototype,"tree",{get(){return Yu(this)}}),this.parser=e,this.extension=[of.of(this),$o.languageData.of(((t,e,i)=>{let n=Uu(t,e,i),s=n.type.prop($u);if(!s)return[];let r=t.facet(s),o=n.type.prop(Gu);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return Uu(t,e,i).type.prop($u)==this.data}findRegions(t){let e=t.facet(of);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop($u)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(Qs.mounted);if(s){if(s.tree.prop($u)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof rr&&n(s,t.positions[i]+e)}};return n(Yu(t),0),i}get allowsNesting(){return!0}}function Uu(t,e,i){let n=t.facet(of),s=Yu(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,nr.ExcludeBuffers))t.type.isTop&&(s=t);return s}Ju.setState=Lo.define();function Yu(t){let e=t.field(Ju.state,!1);return e?e.tree:rr.empty}class Xu{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Qu=null;class Zu{constructor(t,e,i=[],n,s,r,o,h){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Zu(t,e,[],rr.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Xu(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=rr.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(xr.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(xr.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Qu;Qu=this;try{return t()}finally{Qu=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=tf(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s}))),i=xr.applyChanges(i,e),n=rr.empty,s=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&o.push({from:i,to:n})}}}return new Zu(this.parser,e,i,n,s,r,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=tf(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends Sr{createParse(e,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let e=Qu;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=r,new rr(tr.none,[],[],r-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Qu}}function tf(t,e,i){return xr.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class ef{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new ef(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Zu.create(t.facet(of).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new ef(i)}}Ju.state=co.define({create:ef.init,update(t,e){for(let t of e.effects)if(t.is(Ju.setState))return t.value;return e.startState.facet(of)!=e.state.facet(of)?ef.init(e.state):t.apply(e)}});let nf=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(nf=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const sf="undefined"!=typeof navigator&&(null===(ju=navigator.scheduling)||void 0===ju?void 0:ju.isInputPending)?()=>navigator.scheduling.isInputPending():null,rf=Il.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Ju.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)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Ju.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=nf(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(Ju.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!sf?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>sf&&sf()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ju.setState.of(new ef(s.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>Bl(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),of=no.define({combine:t=>t.length?t[0]:null,enables:t=>[Ju.state,rf,qc.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const hf=no.define(),lf=no.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function af(t){let e=t.facet(lf);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function cf(t,e){let i="",n=t.tabSize,s=t.facet(lf)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t<e;t++)i+=s;return i}function uf(t,e){t instanceof $o&&(t=new ff(t));for(let i of t.state.facet(hf)){let n=i(t,e);if(void 0!==n)return n}let i=Yu(t.state);return i?function(t,e,i){return pf(e.resolveInner(i).enterUnfinishedNodesBefore(i),i,t)}(t,i,e):null}class ff{constructor(t,e={}){this.state=t,this.options=e,this.unit=af(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return null!=n&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),r=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return r>-1&&(s+=r-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return function(t,e,i=t.length){let n=0;for(let s=0;s<i;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=Ir(t,s));return n}(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let t=s(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const df=new Qs;function gf(t){let e=t.type.prop(df);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(Qs.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>yf(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?mf:null}function pf(t,e,i){for(;t;t=t.parent){let n=gf(t);if(n)return n(wf.create(i,e,t))}return null}function mf(){return 0}class wf extends ff{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.node=i}static create(t,e,i){return new wf(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(vf(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){let t=this.node.parent;return t?pf(t,this.pos,this.base):0}}function vf(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function yf(t,e,i,n,s){let r=t.textAfter,o=r.match(/^\s*/)[0].length,h=n&&r.slice(o,o+n.length)==n||s==t.pos+o,l=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,r=t.state.doc.lineAt(i.from),o=null==s||s<=r.from?r.to:Math.min(r.to,s);for(let t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped)return s.from<o?i:null;t=s.to}}(t):null;return l?h?t.column(l.from):t.column(l.to):t.baseIndent+(h?0:t.unit*i)}class bf{constructor(t,e){let i;function n(t){let e=ah.V.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,r=e.scope;this.scope=r instanceof Ju?t=>t.prop($u)==r.data:r?t=>t==r:void 0,this.style=Du(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new ah.V(i):null,this.themeType=e.themeType}static define(t,e){return new bf(t,e||{})}}Ku.meta,Ku.link,Ku.heading,Ku.emphasis,Ku.strong,Ku.strikethrough,Ku.keyword,Ku.atom,Ku.bool,Ku.url,Ku.contentSeparator,Ku.labelName,Ku.literal,Ku.inserted,Ku.string,Ku.deleted,Ku.regexp,Ku.escape,Ku.string,Ku.variableName,Ku.variableName,Ku.typeName,Ku.namespace,Ku.className,Ku.variableName,Ku.macroName,Ku.propertyName,Ku.comment,Ku.invalid;const xf="()[]{}";const Sf=new Qs;function kf(t,e,i){let n=t.prop(e<0?Qs.openedBy:Qs.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function Af(t){let e=t.type.prop(Sf);return e?e(t.node):t}function Mf(t,e,i,n={}){let s=n.maxScanDistance||1e4,r=n.brackets||xf,o=Yu(t),h=o.resolveInner(e,i);for(let n=h;n;n=n.parent){let s=kf(n.type,i,r);if(s&&n.from<n.to){let o=Af(n);if(o&&(i>0?e>=o.from&&e<o.to:e>o.from&&e<=o.to))return Cf(t,e,i,n,o,s,r)}}return function(t,e,i,n,s,r,o){let h=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),l=o.indexOf(h);if(l<0||l%2==0!=i>0)return null;let a={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=r;){let r=c.value;i<0&&(t+=r.length);let h=e+t*i;for(let t=i>0?0:r.length-1,e=i>0?r.length:-1;t!=e;t+=i){let e=o.indexOf(r[t]);if(!(e<0||n.resolveInner(h+t,1).type!=s))if(e%2==0==i>0)u++;else{if(1==u)return{start:a,end:{from:h+t,to:h+t+1},matched:e>>1==l>>1};u--}}i>0&&(t+=r.length)}return c.done?{start:a,matched:!1}:null}(t,e,i,o,h.type,s,r)}function Cf(t,e,i,n,s,r,o){let h=n.parent,l={from:s.from,to:s.to},a=0,c=null==h?void 0:h.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==a&&r.indexOf(c.type.name)>-1&&c.from<c.to){let t=Af(c);return{start:l,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(kf(c.type,i,o))a++;else if(kf(c.type,-i,o)){if(0==a){let t=Af(c);return{start:l,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}a--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}const Of=Object.create(null),Df=[tr.none],Tf=[],Ef=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ef[t]=Bf(Of,e);function Rf(t,e){Tf.indexOf(t)>-1||(Tf.push(t),console.warn(e))}function Bf(t,e){let i=null;for(let n of e.split(".")){let e=t[n]||Ku[n];e?"function"==typeof e?i?i=e(i):Rf(n,`Modifier ${n} used at start of tag`):i?Rf(n,`Tag ${n} used as modifier`):i=e:Rf(n,`Unknown highlighting tag ${n}`)}if(!i)return 0;let n=e.replace(/ /g,"_"),s=tr.define({id:Df.length,name:n,props:[Mu({[n]:i})]});return Df.push(s),s.id}const Pf=1024;let Lf=0;class Nf{constructor(t={}){this.id=Lf++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=Vf.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}Nf.closedBy=new Nf({deserialize:t=>t.split(" ")}),Nf.openedBy=new Nf({deserialize:t=>t.split(" ")}),Nf.group=new Nf({deserialize:t=>t.split(" ")}),Nf.isolate=new Nf({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Nf.contextHash=new Nf({perNode:!0}),Nf.lookAhead=new Nf({perNode:!0}),Nf.mounted=new Nf({perNode:!0});class If{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[Nf.mounted.id]}}const Hf=Object.create(null);class Vf{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):Hf,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new Vf(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(Nf.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(Nf.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}Vf.none=new Vf("",Object.create(null),0,8);const Wf=new WeakMap,Ff=new WeakMap;var zf;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(zf||(zf={}));class _f{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=If.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new ed(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Wf.get(this)||this.topNode,s=new ed(n);return s.moveTo(t,e),Wf.set(this,s._tree),s}get topNode(){return new Jf(this,0,0,null)}resolve(t,e=0){let i=$f(Wf.get(this)||this.topNode,t,e,!1);return Wf.set(this,i),i}resolveInner(t,e=0){let i=$f(Ff.get(this)||this.topNode,t,e,!0);return Ff.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let t=n instanceof Jf?n:n.context.parent;t;t=t.parent)if(t.index<0){let r=t.parent;(s||(s=[n])).push(r.resolve(e,i)),t=r}else{let r=If.get(t.tree);if(r&&r.overlay&&r.overlay[0].from<=e&&r.overlay[r.overlay.length-1].to>=e){let o=new Jf(r.tree,r.overlay[0].from+t.from,-1,t);(s||(s=[n])).push($f(o,e,i,!1))}}return s?Zf(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&zf.IncludeAnonymous)>0;for(let t=this.cursor(r|zf.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:rd(Vf.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new _f(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new _f(Vf.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=Pf,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new qf(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,v,y,b){let{id:x,start:S,end:k,size:A}=h,M=c;for(;A<0;){if(h.next(),-1==A){let e=r[x];return i.push(e),void v.push(S-t)}if(-3==A)return void(a=x);if(-4==A)return void(c=x);throw new RangeError(`Unrecognized record size: ${A}`)}let C,O,D=l[x],T=S-t;if(k-S<=s&&(O=m(h.pos-e,y))){let e=new Uint16Array(O.size-O.skip),i=h.pos-O.size,s=e.length;for(;h.pos>i;)s=w(O.start,e,s);C=new Kf(e,k-O.start,n),T=O.start-t}else{let t=h.pos-A;h.next();let e=[],i=[],n=x>=o?x:-1,r=0,l=k;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(g(e,i,S,r,h.end,l,n,M),r=e.length,l=h.end),h.next()):b>2500?f(S,t,e,i):u(S,t,e,i,n,b+1);if(n>=0&&r>0&&r<e.length&&g(e,i,S,r,S,l,n,M),e.reverse(),i.reverse(),n>-1&&r>0){let t=d(D);C=rd(D,e,i,0,e.length,0,k-S,t,t)}else C=p(D,e,i,k-S,M-k)}i.push(C),v.push(T)}function f(t,e,i,r){let o=[],l=0,a=-1;for(;h.pos>e;){let{id:t,start:e,end:i,size:n}=h;if(n>4)h.next();else{if(a>-1&&e<a)break;a<0&&(a=i-s),o.push(t,e,i),l++,h.next()}}if(l){let e=new Uint16Array(4*l),s=o[o.length-2];for(let t=o.length-3,i=0;t>=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-s,e[i++]=o[t+2]-s,e[i++]=i;i.push(new Kf(e,o[2]-s,n)),r.push(s-t)}}function d(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof _f){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(Nf.lookAhead))&&(o=i[h]+s.length+r)}return p(t,e,i,n,o)}}function g(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(p(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function p(t,e,i,n,s=0,r){if(a){let t=[Nf.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[Nf.lookAhead,s];r=r?[t].concat(r):[t]}return new _f(t,e,i,n,r)}function m(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function w(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=w(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let v=[],y=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,v,y,-1,0);let b=null!==(e=t.length)&&void 0!==e?e:v.length?y[0]+v[0].length:0;return new _f(l[t.topID],v.reverse(),y.reverse(),b)}(t)}}_f.empty=new _f(Vf.none,[],[],0);class qf{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new qf(this.buffer,this.index)}}class Kf{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return Vf.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return s+"("+r.join(",")+")"}findChild(t,e,i,n,s){let{buffer:r}=this,o=-1;for(let h=t;h!=e&&!(jf(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new Kf(s,r,this.set)}}function jf(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function $f(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof Jf&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:zf.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof Jf&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class Gf{cursor(t=0){return new ed(this,t)}getChild(t,e=null,i=null){let n=Uf(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Uf(this,t,e,i)}resolve(t,e=0){return $f(this,t,e,!1)}resolveInner(t,e=0){return $f(this,t,e,!0)}matchContext(t){return Yf(this,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class Jf extends Gf{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:o,positions:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(jf(n,i,a,a+l.length))if(l instanceof Kf){if(s&zf.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new Qf(new Xf(r,l,t,a),null,o)}else if(s&zf.IncludeAnonymous||!l.type.isAnonymous||id(l)){let o;if(!(s&zf.IgnoreMounts)&&(o=If.get(l))&&!o.overlay)return new Jf(o.tree,a,t,r);let h=new Jf(l,a,t,r);return s&zf.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&zf.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&zf.IgnoreOverlays)&&(n=If.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new Jf(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Uf(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!s.type.is(i);)if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function Yf(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class Xf{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Qf extends Gf{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new Qf(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&zf.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new Qf(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Qf(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Qf(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new _f(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Zf(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}let n=i instanceof Jf&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new td(s,i)}class td{constructor(t,e){this.heads=t,this.node=e}get next(){return Zf(this.heads)}}class ed{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Jf)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof Jf?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&zf.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&zf.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&zf.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(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));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&zf.IncludeAnonymous||t instanceof Kf||!t.type.isAnonymous||id(t))return!1}return!0}move(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}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(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}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new Qf(this.buffer,e,this.stack[t]);return this.bufferNode=new Qf(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return Yf(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return Yf(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function id(t){return t.children.some((t=>t instanceof Kf||!t.type.isAnonymous||id(t)))}const nd=new WeakMap;function sd(t,e){if(!t.isAnonymous||e instanceof Kf||e.type!=t)return 1;let i=nd.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof _f)){i=1;break}i+=sd(t,n)}nd.set(e,i)}return i}function rd(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=sd(t,e[i]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=sd(t,i[a]);for(a++;a<o;a++){let e=sd(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(rd(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}new Nf({perNode:!0});function od(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=t(e,i);return!!s&&(n(i.update(s)),!0)}}const hd=od(dd,0),ld=od(fd,0),ad=od(((t,e)=>fd(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),s=i.to<=n.to?n:t.doc.lineAt(i.to);s.from>n.from&&s.from==i.to&&(s=i.to==n.to+1?n:t.doc.lineAt(i.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}(e))),0);function cd(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const ud=50;function fd(t,e,i=e.selection.ranges){let n=i.map((t=>cd(e,t.from).block));if(!n.every((t=>t)))return null;let s=i.map(((t,i)=>function(t,{open:e,close:i},n,s){let r,o,h=t.sliceDoc(n-ud,n),l=t.sliceDoc(s,s+ud),a=/\s*$/.exec(h)[0].length,c=/^\s*/.exec(l)[0].length,u=h.length-a;if(h.slice(u-e.length,u)==e&&l.slice(c,c+i.length)==i)return{open:{pos:n-a,margin:a&&1},close:{pos:s+c,margin:c&&1}};s-n<=2*ud?r=o=t.sliceDoc(n,s):(r=t.sliceDoc(n,n+ud),o=t.sliceDoc(s-ud,s));let f=/^\s*/.exec(r)[0].length,d=/\s*$/.exec(o)[0].length,g=o.length-d-i.length;return r.slice(f,f+e.length)==e&&o.slice(g,g+i.length)==i?{open:{pos:n+f+e.length,margin:/\s/.test(r.charAt(f+e.length))?1:0},close:{pos:s-d-i.length,margin:/\s/.test(o.charAt(g-1))?1:0}}:null}(e,n[i],t.from,t.to)));if(2!=t&&!s.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>s[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}])))};if(1!=t&&s.some((t=>t))){let t=[];for(let e,i=0;i<s.length;i++)if(e=s[i]){let s=n[i],{open:r,close:o}=e;t.push({from:r.pos-s.open.length,to:r.pos+r.margin},{from:o.pos-o.margin,to:o.pos+s.close.length})}return{changes:t}}return null}function dd(t,e,i=e.selection.ranges){let n=[],s=-1;for(let{from:t,to:r}of i){let i=n.length,o=1e9,h=cd(e,t).line;if(h){for(let i=t;i<=r;){let l=e.doc.lineAt(i);if(l.from>s&&(t==r||r>l.from)){s=l.from;let t=/^\s*/.exec(l.text)[0].length,e=t==l.length,i=l.text.slice(t,t+h.length)==h?t:-1;t<l.text.length&&t<o&&(o=t),n.push({line:l,comment:i,token:h,indent:t,empty:e,single:!1})}i=l.to+1}if(o<1e9)for(let t=i;t<n.length;t++)n[t].indent<n[t].line.text.length&&(n[t].indent=o);n.length==i+1&&(n[i].single=!0)}}if(2!=t&&n.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:s,empty:r,single:o}of n)!o&&r||t.push({from:e.from+s,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:s}of n)if(i>=0){let n=e.from+i,r=n+s.length;" "==e.text[r-e.from]&&r++,t.push({from:n,to:r})}return{changes:t}}return null}const gd=ct.define(),pd=ct.define(),md=H.define(),wd=H.define({combine:t=>function(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}),vd=K.define({create:()=>Nd.empty,update(t,e){let i=e.state.facet(wd),n=e.annotation(gd);if(n){let s=Md.fromTransaction(e,n.selection),r=n.side,o=0==r?t.undone:t.done;return o=s?Cd(o,o.length,i.minDepth,s):Ed(o,e.startState.selection),new Nd(0==r?n.rest:o,0==r?o:n.rest)}let s=e.annotation(pd);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(gt.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let r=Md.fromTransaction(e),o=e.annotation(gt.time),h=e.annotation(gt.userEvent);return r?t=t.addChanges(r,o,h,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,h,i.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new Nd(t.done.map(Md.fromJSON),t.undone.map(Md.fromJSON))});function yd(t={}){return[vd,wd.of(t),zs.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?xd:"historyRedo"==t.inputType?Sd:null;return!!i&&(t.preventDefault(),i(e))}})]}function bd(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(vd,!1);if(!s)return!1;let r=s.pop(t,i,e);return!!r&&(n(r),!0)}}const xd=bd(0,!1),Sd=bd(1,!1),kd=bd(0,!0),Ad=bd(1,!0);class Md{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new Md(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;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===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new Md(t.changes&&C.fromJSON(t.changes),[],t.mapped&&M.fromJSON(t.mapped),t.startSelection&&L.fromJSON(t.startSelection),t.selectionsAfter.map(L.fromJSON))}static fromTransaction(t,e){let i=Dd;for(let e of t.startState.facet(md)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new Md(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,Dd)}static selection(t){return new Md(void 0,Dd,void 0,void 0,t)}}function Cd(t,e,i,n){let s=e+1>i+20?e-i-1:0,r=t.slice(s,e);return r.push(n),r}function Od(t,e){return t.length?e.length?t.concat(e):t:e}const Dd=[],Td=200;function Ed(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-Td));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),Cd(t,t.length-1,1e9,i.setSelAfter(n)))}return[Md.selection([e])]}function Rd(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function Bd(t,e){if(!t.length)return t;let i=t.length,n=Dd;for(;i;){let s=Pd(t[i-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let e=t.slice(0,i);return e[i-1]=s,e}e=s.mapped,i--,n=s.selectionsAfter}return n.length?[Md.selection(n)]:Dd}function Pd(t,e,i){let n=Od(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):Dd,i);if(!t.changes)return Md.selection(n);let s=t.changes.map(e),r=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(r):r;return new Md(s,dt.mapEffects(t.effects,e),o,t.startSelection.map(r),n)}const Ld=/^(input\.type|delete)($|\.)/;class Nd{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Nd(this.done,this.undone):this}addChanges(t,e,i,n,s){let r=this.done,o=r[r.length-1];return r=o&&o.changes&&!o.changes.empty&&t.changes&&(!i||Ld.test(i))&&(!o.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(s,function(t,e){let i=[],n=!1;return t.iterChangedRanges(((t,e)=>i.push(t,e))),e.iterChangedRanges(((t,e,s,r)=>{for(let t=0;t<i.length;){let e=i[t++],o=i[t++];r>=e&&s<=o&&(n=!0)}})),n}(o.changes,t.changes))||"input.type.compose"==i)?Cd(r,r.length-1,n.minDepth,new Md(t.changes.compose(o.changes),Od(dt.mapEffects(t.effects,o.changes),o.effects),o.mapped,o.startSelection,Dd)):Cd(r,r.length,n.minDepth,t),new Nd(r,Dd,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:Dd;return s.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&(r=s[s.length-1],o=t,r.ranges.length==o.ranges.length&&0===r.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new Nd(Ed(this.done,t),this.undone,e,i);var r,o}addMapping(t){return new Nd(Bd(this.done,t),Bd(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let s=n[n.length-1],r=s.selectionsAfter[0]||e.selection;if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:gd.of({side:t,rest:Rd(n),selection:r}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?Dd:n.slice(0,n.length-1);return s.mapped&&(i=Bd(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:gd.of({side:t,rest:i,selection:r}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Nd.empty=new Nd(Dd,Dd);const Id=[{key:"Mod-z",run:xd,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Sd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Sd,preventDefault:!0},{key:"Mod-u",run:kd,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Ad,preventDefault:!0}];function Hd(t,e){return L.create(t.ranges.map(e),t.mainIndex)}function Vd(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Wd({state:t,dispatch:e},i){let n=Hd(t.selection,i);return!n.eq(t.selection,!0)&&(e(Vd(t,n)),!0)}function Fd(t,e){return L.cursor(e?t.to:t.from)}function zd(t,e){return Wd(t,(i=>i.empty?t.moveByChar(i,e):Fd(i,e)))}function _d(t){return t.textDirectionAt(t.state.selection.main.head)==hi.LTR}const qd=t=>zd(t,!_d(t)),Kd=t=>zd(t,_d(t));function jd(t,e){return Wd(t,(i=>i.empty?t.moveByGroup(i,e):Fd(i,e)))}"undefined"!=typeof Intl&&Intl.Segmenter;function $d(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Gd(t,e,i){let n,s,r=Yu(t).resolveInner(e.head),o=i?Nf.closedBy:Nf.openedBy;for(let n=e.head;;){let e=i?r.childAfter(n):r.childBefore(n);if(!e)break;$d(t,e,o)?r=e:n=i?e.to:e.from}return s=r.type.prop(o)&&(n=i?Mf(t,r.from,1):Mf(t,r.to,-1))&&n.matched?i?n.end.to:n.end.from:i?r.to:r.from,L.cursor(s,i?-1:1)}function Jd(t,e){return Wd(t,(i=>{if(!i.empty)return Fd(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}const Ud=t=>Jd(t,!1),Yd=t=>Jd(t,!0);function Xd(t){let e,i=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,s=0;if(i){for(let e of t.state.facet(zs.scrollMargins)){let i=e(t);(null==i?void 0:i.top)&&(n=Math.max(null==i?void 0:i.top,n)),(null==i?void 0:i.bottom)&&(s=Math.max(null==i?void 0:i.bottom,s))}e=t.scrollDOM.clientHeight-n-s}else e=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:s,selfScroll:i,height:Math.max(t.defaultLineHeight,e-5)}}function Qd(t,e){let i,n=Xd(t),{state:s}=t,r=Hd(s.selection,(i=>i.empty?t.moveVertically(i,e,n.height):Fd(i,e)));if(r.eq(s.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(s.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),h=o.top+n.marginTop,l=o.bottom-n.marginBottom;e&&e.top>h&&e.bottom<l&&(i=zs.scrollIntoView(r.main.head,{y:"start",yMargin:e.top-h}))}return t.dispatch(Vd(s,r),{effects:i}),!0}const Zd=t=>Qd(t,!1),tg=t=>Qd(t,!0);function eg(t,e,i){let n=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?n.to:n.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(s=L.cursor(n.from+i))}return s}function ig(t,e,i){let n=!1,s=Hd(t.selection,(e=>{let s=Mf(t,e.head,-1)||Mf(t,e.head,1)||e.head>0&&Mf(t,e.head-1,1)||e.head<t.doc.length&&Mf(t,e.head+1,-1);if(!s||!s.end)return e;n=!0;let r=s.start.from==e.head?s.end.to:s.end.from;return i?L.range(e.anchor,r):L.cursor(r)}));return!!n&&(e(Vd(t,s)),!0)}function ng(t,e){let i=Hd(t.state.selection,(t=>{let i=e(t);return L.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(Vd(t.state,i)),!0)}function sg(t,e){return ng(t,(i=>t.moveByChar(i,e)))}const rg=t=>sg(t,!_d(t)),og=t=>sg(t,_d(t));function hg(t,e){return ng(t,(i=>t.moveByGroup(i,e)))}function lg(t,e){return ng(t,(i=>t.moveVertically(i,e)))}const ag=t=>lg(t,!1),cg=t=>lg(t,!0);function ug(t,e){return ng(t,(i=>t.moveVertically(i,e,Xd(t).height)))}const fg=t=>ug(t,!1),dg=t=>ug(t,!0),gg=({state:t,dispatch:e})=>(e(Vd(t,{anchor:0})),!0),pg=({state:t,dispatch:e})=>(e(Vd(t,{anchor:t.doc.length})),!0),mg=({state:t,dispatch:e})=>(e(Vd(t,{anchor:t.selection.main.anchor,head:0})),!0),wg=({state:t,dispatch:e})=>(e(Vd(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function vg(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,s=n.changeByRange((n=>{let{from:s,to:r}=n;if(s==r){let o=e(n);o<s?(i="delete.backward",o=yg(t,o,!1)):o>s&&(i="delete.forward",o=yg(t,o,!0)),s=Math.min(s,o),r=Math.max(r,o)}else s=yg(t,s,!1),r=yg(t,r,!0);return s==r?{range:n}:{changes:{from:s,to:r},range:L.cursor(s,s<n.head?-1:1)}}));return!s.changes.empty&&(t.dispatch(n.update(s,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?zs.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function yg(t,e,i){if(t instanceof zs)for(let n of t.state.facet(zs.atomicRanges).map((e=>e(t))))n.between(e,e,((t,n)=>{t<e&&n>e&&(e=i?n:t)}));return e}const bg=(t,e,i)=>vg(t,(n=>{let s,r,o=n.from,{state:h}=t,l=h.doc.lineAt(o);if(i&&!e&&o>l.from&&o<l.from+200&&!/[^ \t]/.test(s=l.text.slice(0,o-l.from))){if("\t"==s[s.length-1])return o-1;let t=_t(s,h.tabSize)%af(h)||af(h);for(let e=0;e<t&&" "==s[s.length-1-e];e++)o--;r=o}else r=m(l.text,o-l.from,e,e)+l.from,r==o&&l.number!=(e?h.doc.lines:1)?r+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(l.text.slice(r-l.from,o-l.from))&&(r=m(l.text,r-l.from,!1,!1)+l.from);return r})),xg=t=>bg(t,!1,!0),Sg=t=>bg(t,!0,!1),kg=(t,e)=>vg(t,(i=>{let n=i.head,{state:s}=t,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let t=null;;){if(n==(e?r.to:r.from)){n==i.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let h=m(r.text,n-r.from,e)+r.from,l=r.text.slice(Math.min(n,h)-r.from,Math.max(n,h)-r.from),a=o(l);if(null!=t&&a!=t)break;" "==l&&n==i.head||(t=a),n=h}return n})),Ag=t=>kg(t,!1);function Mg(t){let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.from),r=t.doc.lineAt(n.to);if(n.empty||n.to!=r.from||(r=t.doc.lineAt(n.to-1)),i>=s.number){let t=e[e.length-1];t.to=r.to,t.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});i=r.number+1}return e}function Cg(t,e,i){if(t.readOnly)return!1;let n=[],s=[];for(let e of Mg(t)){if(i?e.to==t.doc.length:0==e.from)continue;let r=t.doc.lineAt(i?e.to+1:e.from-1),o=r.length+1;if(i){n.push({from:e.to,to:r.to},{from:e.from,insert:r.text+t.lineBreak});for(let i of e.ranges)s.push(L.range(Math.min(t.doc.length,i.anchor+o),Math.min(t.doc.length,i.head+o)))}else{n.push({from:r.from,to:e.from},{from:e.to,insert:t.lineBreak+r.text});for(let t of e.ranges)s.push(L.range(t.anchor-o,t.head-o))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:L.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0)}function Og(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of Mg(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Dg=Tg(!1);function Tg(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let s=e.changeByRange((i=>{let{from:s,to:r}=i,o=e.doc.lineAt(s),h=!t&&s==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=Yu(t).resolveInner(e),s=n.childBefore(e),r=n.childAfter(e);return s&&r&&s.to<=e&&r.from>=e&&(i=s.type.prop(Nf.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(s.to,r.from))?{from:s.to,to:r.from}:null}(e,s);t&&(s=r=(r<=o.to?o:e.doc.lineAt(r)).to);let l=new ff(e,{simulateBreak:s,simulateDoubleBreak:!!h}),a=uf(l,s);for(null==a&&(a=_t(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));r<o.to&&/\s/.test(o.text[r-o.from]);)r++;h?({from:s,to:r}=h):s>o.from&&s<o.from+100&&!/\S/.test(o.text.slice(0,s))&&(s=o.from);let c=["",cf(e,a)];return h&&c.push(cf(e,l.lineIndent(o.from,-1))),{changes:{from:s,to:r,insert:n.of(c)},range:L.cursor(s+1+c[1].length)}}));return i(e.update(s,{scrollIntoView:!0,userEvent:"input"})),!0}}function Eg(t,e){let i=-1;return t.changeByRange((n=>{let s=[];for(let r=n.from;r<=n.to;){let o=t.doc.lineAt(r);o.number>i&&(n.empty||n.to>o.from)&&(e(o,s,n),i=o.number),r=o.to+1}let r=t.changes(s);return{changes:s,range:L.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}}))}const Rg=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Eg(t,((e,i)=>{i.push({from:e.from,insert:t.facet(lf)})})),{userEvent:"input.indent"})),!0),Bg=({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(Eg(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=_t(n,t.tabSize),r=0,o=cf(t,Math.max(0,s-af(t)));for(;r<n.length&&r<o.length&&n.charCodeAt(r)==o.charCodeAt(r);)r++;i.push({from:e.from+r,to:e.from+n.length,insert:o.slice(r)})})),{userEvent:"delete.dedent"})),!0),Pg=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>Wd(t,(e=>Gd(t.state,e,!_d(t)))),shift:t=>ng(t,(e=>Gd(t.state,e,!_d(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>Wd(t,(e=>Gd(t.state,e,_d(t)))),shift:t=>ng(t,(e=>Gd(t.state,e,_d(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>Cg(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>Og(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>Cg(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>Og(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=L.create([i.main]):i.main.empty||(n=L.create([L.cursor(i.main.head)])),!!n&&(e(Vd(t,n)),!0)}},{key:"Mod-Enter",run:Tg(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=Mg(t).map((({from:e,to:i})=>L.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:L.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=Hd(t.selection,(e=>{let i=Yu(t),n=i.resolveStack(e.from,1);if(e.empty){let t=i.resolveStack(e.from,-1);t.node.from>=n.node.from&&t.node.to<=n.node.to&&(n=t)}for(let t=n;t;t=t.next){let{node:i}=t;if((i.from<e.from&&i.to>=e.to||i.to>e.to&&i.from<=e.from)&&t.next)return L.range(i.to,i.from)}return e}));return!i.eq(t.selection)&&(e(Vd(t,i)),!0)},preventDefault:!0},{key:"Mod-[",run:Bg},{key:"Mod-]",run:Rg},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new ff(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=Eg(t,((e,s,r)=>{let o=uf(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let h=/^\s*/.exec(e.text)[0],l=cf(t,o);(h!=l||r.from<e.from+h.length)&&(i[e.from]=o,s.push({from:e.from,to:e.from+h.length,insert:l}))}));return s.changes.empty||e(t.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(Mg(e).map((({from:t,to:i})=>(t>0?t--:i<e.doc.length&&i++,{from:t,to:i})))),n=Hd(e.selection,(e=>{let i;if(t.lineWrapping){let n=t.lineBlockAt(e.head),s=t.coordsAtPos(e.head,e.assoc||1);s&&(i=n.bottom+t.documentTop-s.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)})).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>ig(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=cd(t.state,i.from);return n.line?hd(t):!!n.block&&ad(t)}},{key:"Alt-A",run:ld},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:qd,shift:rg,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>jd(t,!_d(t)),shift:t=>hg(t,!_d(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>Wd(t,(e=>eg(t,e,!_d(t)))),shift:t=>ng(t,(e=>eg(t,e,!_d(t)))),preventDefault:!0},{key:"ArrowRight",run:Kd,shift:og,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>jd(t,_d(t)),shift:t=>hg(t,_d(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>Wd(t,(e=>eg(t,e,_d(t)))),shift:t=>ng(t,(e=>eg(t,e,_d(t)))),preventDefault:!0},{key:"ArrowUp",run:Ud,shift:ag,preventDefault:!0},{mac:"Cmd-ArrowUp",run:gg,shift:mg},{mac:"Ctrl-ArrowUp",run:Zd,shift:fg},{key:"ArrowDown",run:Yd,shift:cg,preventDefault:!0},{mac:"Cmd-ArrowDown",run:pg,shift:wg},{mac:"Ctrl-ArrowDown",run:tg,shift:dg},{key:"PageUp",run:Zd,shift:fg},{key:"PageDown",run:tg,shift:dg},{key:"Home",run:t=>Wd(t,(e=>eg(t,e,!1))),shift:t=>ng(t,(e=>eg(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:gg,shift:mg},{key:"End",run:t=>Wd(t,(e=>eg(t,e,!0))),shift:t=>ng(t,(e=>eg(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:pg,shift:wg},{key:"Enter",run:Dg,shift:Dg},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:xg,shift:xg},{key:"Delete",run:Sg},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ag},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>kg(t,!0)},{mac:"Mod-Backspace",run:t=>vg(t,(e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}))},{mac:"Mod-Delete",run:t=>vg(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}))}].concat([{key:"Ctrl-b",run:qd,shift:rg,preventDefault:!0},{key:"Ctrl-f",run:Kd,shift:og},{key:"Ctrl-p",run:Ud,shift:ag},{key:"Ctrl-n",run:Yd,shift:cg},{key:"Ctrl-a",run:t=>Wd(t,(e=>L.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>ng(t,(e=>L.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>Wd(t,(e=>L.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>ng(t,(e=>L.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:Sg},{key:"Ctrl-h",run:xg},{key:"Ctrl-k",run:t=>vg(t,(e=>{let i=t.lineBlockAt(e.head).to;return e.head<i?i:Math.min(t.state.doc.length,e.head+1)}))},{key:"Ctrl-Alt-h",run:Ag},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:n.of(["",""])},range:L.cursor(t.from)})));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,n=t.doc.lineAt(i),s=i==n.from?i-1:m(n.text,i-n.from,!1)+n.from,r=i==n.to?i+1:m(n.text,i-n.from,!0)+n.from;return{changes:{from:s,to:r,insert:t.doc.slice(i,r).append(t.doc.slice(s,i))},range:L.cursor(r)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:tg}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))))},65424:function(t,e,i){i.d(e,{rs:()=>Pl,mi:()=>Xl,y1:()=>Rl,QN:()=>sa,nF:()=>na,Qf:()=>Zl,il:()=>ua});i("92745"),i("39527"),i("13334"),i("36993"),i("84283"),i("26200"),i("25754"),i("22246"),i("32517"),i("71375"),i("15524"),i("20267"),i("22139"),i("67670");const n=1024;let s=0;class r{constructor(t,e){this.from=t,this.to=e}}class o{constructor(t={}){this.id=s++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=a.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}o.closedBy=new o({deserialize:t=>t.split(" ")}),o.openedBy=new o({deserialize:t=>t.split(" ")}),o.group=new o({deserialize:t=>t.split(" ")}),o.isolate=new o({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),o.contextHash=new o({perNode:!0}),o.lookAhead=new o({perNode:!0}),o.mounted=new o({perNode:!0});class h{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[o.mounted.id]}}const l=Object.create(null);class a{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):l,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new a(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(o.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(o.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}a.none=new a("",Object.create(null),0,8);class c{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);t&&(n||(n=Object.assign({},i.props)),n[t[0].id]=t[1])}e.push(n?new a(i.name,n,i.id,i.flags):i)}return new c(e)}}const u=new WeakMap,f=new WeakMap;var d,g;(g=d||(d={}))[g.ExcludeBuffers=1]="ExcludeBuffers",g[g.IncludeAnonymous=2]="IncludeAnonymous",g[g.IgnoreMounts=4]="IgnoreMounts",g[g.IgnoreOverlays=8]="IgnoreOverlays";class p{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=h.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new D(this.topNode,t)}cursorAt(t,e=0,i=0){let n=u.get(this)||this.topNode,s=new D(n);return s.moveTo(t,e),u.set(this,s._tree),s}get topNode(){return new x(this,0,0,null)}resolve(t,e=0){let i=y(u.get(this)||this.topNode,t,e,!1);return u.set(this,i),i}resolveInner(t,e=0){let i=y(f.get(this)||this.topNode,t,e,!0);return f.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let t=n instanceof x?n:n.context.parent;t;t=t.parent)if(t.index<0){let r=t.parent;(s||(s=[n])).push(r.resolve(e,i)),t=r}else{let r=h.get(t.tree);if(r&&r.overlay&&r.overlay[0].from<=e&&r.overlay[r.overlay.length-1].to>=e){let o=new x(r.tree,r.overlay[0].from+t.from,-1,t);(s||(s=[n])).push(y(o,e,i,!1))}}return s?C(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&d.IncludeAnonymous)>0;for(let t=this.cursor(r|d.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:B(a.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new p(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new p(a.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:r=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new m(i,i.length):i,c=s.types,u=0,f=0;function d(t,e,i,n,o,p){let{id:m,start:k,end:A,size:M}=a,C=f;for(;M<0;){if(a.next(),-1==M){let e=h[m];return i.push(e),void n.push(k-t)}if(-3==M)return void(u=m);if(-4==M)return void(f=m);throw new RangeError(`Unrecognized record size: ${M}`)}let O,D,T=c[m],E=k-t;if(A-k<=r&&(D=x(a.pos-e,o))){let e=new Uint16Array(D.size-D.skip),i=a.pos-D.size,n=e.length;for(;a.pos>i;)n=S(D.start,e,n);O=new w(e,A-D.start,s),E=D.start-t}else{let t=a.pos-M;a.next();let e=[],i=[],n=m>=l?m:-1,s=0,o=A;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=o-r&&(y(e,i,k,s,a.end,o,n,C),s=e.length,o=a.end),a.next()):p>2500?g(k,t,e,i):d(k,t,e,i,n,p+1);if(n>=0&&s>0&&s<e.length&&y(e,i,k,s,k,o,n,C),e.reverse(),i.reverse(),n>-1&&s>0){let t=v(T);O=B(T,e,i,0,e.length,0,A-k,t,t)}else O=b(T,e,i,A-k,C-A)}i.push(O),n.push(E)}function g(t,e,i,n){let o=[],h=0,l=-1;for(;a.pos>e;){let{id:t,start:e,end:i,size:n}=a;if(n>4)a.next();else{if(l>-1&&e<l)break;l<0&&(l=i-r),o.push(t,e,i),h++,a.next()}}if(h){let e=new Uint16Array(4*h),r=o[o.length-2];for(let t=o.length-3,i=0;t>=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-r,e[i++]=o[t+2]-r,e[i++]=i;i.push(new w(e,o[2]-r,s)),n.push(r-t)}}function v(t){return(e,i,n)=>{let s,r,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof p){if(!l&&s.type==t&&s.length==n)return s;(r=s.prop(o.lookAhead))&&(h=i[l]+s.length+r)}return b(t,e,i,n,h)}}function y(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(b(s.types[h],a,c,o-r,l-o)),e.push(r-i)}function b(t,e,i,n,s=0,r){if(u){let t=[o.contextHash,u];r=r?[t].concat(r):[t]}if(s>25){let t=[o.lookAhead,s];r=r?[t].concat(r):[t]}return new p(t,e,i,n,r)}function x(t,e){let i=a.fork(),n=0,s=0,o=0,h=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=o,o+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<r||i.start<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,n+=t,o+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=o),c.size>4?c:void 0}function S(t,e,i){let{id:n,start:s,end:r,size:o}=a;if(a.next(),o>=0&&n<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=S(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(f=n);return i}let k=[],A=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,k,A,-1,0);let M=null!==(e=t.length)&&void 0!==e?e:k.length?A[0]+k[0].length:0;return new p(c[t.topID],k.reverse(),A.reverse(),M)}(t)}}p.empty=new p(a.none,[],[],0);class m{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new m(this.buffer,this.index)}}class w{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return a.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return s+"("+r.join(",")+")"}findChild(t,e,i,n,s){let{buffer:r}=this,o=-1;for(let h=t;h!=e&&!(v(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new w(s,r,this.set)}}function v(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function y(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof x&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:d.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof x&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class b{cursor(t=0){return new D(this,t)}getChild(t,e=null,i=null){let n=S(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return S(this,t,e,i)}resolve(t,e=0){return y(this,t,e,!1)}resolveInner(t,e=0){return y(this,t,e,!0)}matchContext(t){return k(this,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class x extends b{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:o,positions:l}=r._tree,a=e>0?o.length:-1;t!=a;t+=e){let a=o[t],c=l[t]+r.from;if(v(n,i,c,c+a.length))if(a instanceof w){if(s&d.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,i-c,n);if(o>-1)return new M(new A(r,a,t,c),null,o)}else if(s&d.IncludeAnonymous||!a.type.isAnonymous||T(a)){let o;if(!(s&d.IgnoreMounts)&&(o=h.get(a))&&!o.overlay)return new x(o.tree,c,t,r);let l=new x(a,c,t,r);return s&d.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&d.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&d.IgnoreOverlays)&&(n=h.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new x(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function S(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!s.type.is(i);)if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function k(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class A{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class M extends b{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new M(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&d.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new M(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new M(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new M(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new p(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function C(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}let n=i instanceof x&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new O(s,i)}class O{constructor(t,e){this.heads=t,this.node=e}get next(){return C(this.heads)}}class D{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof x)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof x?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&d.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&d.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&d.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(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));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&d.IncludeAnonymous||t instanceof w||!t.type.isAnonymous||T(t))return!1}return!0}move(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}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(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}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new M(this.buffer,e,this.stack[t]);return this.bufferNode=new M(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return k(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return k(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function T(t){return t.children.some((t=>t instanceof w||!t.type.isAnonymous||T(t)))}const E=new WeakMap;function R(t,e){if(!t.isAnonymous||e instanceof w||e.type!=t)return 1;let i=E.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof p)){i=1;break}i+=R(t,n)}E.set(e,i)}return i}function B(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=R(t,e[i]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=R(t,i[a]);for(a++;a<o;a++){let e=R(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(B(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}class P{constructor(t,e,i,n,s=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new P(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,r=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-h>=i)for(;r&&r.from<c;){let e=r;if(h>=e.from||c<=e.to||l){let t=Math.max(e.from,h)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new P(t,i,e.tree,e.offset+l,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=s<t.length?t[s++]:null}if(!a)break;h=a.toA,l=a.toA-a.toB}return n}}class L{startParse(t,e,i){return"string"==typeof t&&(t=new N(t)),i=i?i.length?i.map((t=>new r(t.from,t.to))):[new r(0,0)]:[new r(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class N{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new o({perNode:!0});i("92519"),i("42179"),i("89256"),i("24931"),i("88463"),i("57449"),i("19814"),i("92181"),i("99790"),i("41360"),i("34595");class I{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),V.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let i=[];return this.decompose(t,e,i,0),V.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new z(this),s=new z(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new z(this,t)}iterRange(t,e=this.length){return new _(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new q(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new H(t):V.from(H.split(t,[])):I.empty}}class H extends I{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new K(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new H(F(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=W(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new H(e,t.length+s.length));else{let t=e.length>>1;i.push(new H(e.slice(0,t)),new H(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof H))return super.replace(t,e,i);let n=W(this.text,W(i.text,F(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new H(n,s):V.from(H.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new H(i,n)),i=[],n=-1);return n>-1&&e.push(new H(i,n)),e}}class V extends I{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],o=s+r.length;if(t>=s&&e<=o){let h=r.replace(t-s,e-s,i),l=this.lines-r.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let s=this.children.slice();return s[n]=h,new V(s,this.length-(e-t)+i.length)}return super.replace(s,o,h)}s=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof V))return 0;let i=0,[n,s,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==o)return i;let h=this.children[n],l=t.children[s];if(h!=l)return i+h.scanIdentical(l,e);i+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new H(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],h=0,l=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof V)for(let e of t.children)c(e);else t.lines>r&&(h>r||!h)?(u(),o.push(t)):t instanceof H&&h&&(e=a[a.length-1])instanceof H&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,a[a.length-1]=new H(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&u(),h+=t.lines,l+=t.length+1,a.push(t))}function u(){0!=h&&(o.push(1==a.length?a[0]:V.from(a,l)),l=-1,h=a.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new V(o,e)}}function W(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function F(t,e,i){return W(t,[""],e,i)}I.empty=new H([""],0);class z{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof H?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],r=s>>1,o=n instanceof H?n.text.length:n.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof H){let s=n.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[r+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof H?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class _{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new z(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class q{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(I.prototype[Symbol.iterator]=function(){return this.iter()},z.prototype[Symbol.iterator]=_.prototype[Symbol.iterator]=q.prototype[Symbol.iterator]=function(){return this});class K{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let j="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((t=>t?parseInt(t,36):1));for(let t=1;t<j.length;t++)j[t]+=j[t-1];function $(t){for(let e=1;e<j.length;e+=2)if(j[e]>t)return j[e-1]<=t;return!1}function G(t){return t>=127462&&t<=127487}function J(t,e,i=!0,n=!0){return(i?U:Y)(t,e,n)}function U(t,e,i){if(e==t.length)return e;e&&X(t.charCodeAt(e))&&Q(t.charCodeAt(e-1))&&e--;let n=Z(t,e);for(e+=tt(n);e<t.length;){let s=Z(t,e);if(8205==n||8205==s||i&&$(s))e+=tt(s),n=s;else{if(!G(s))break;{let i=0,n=e-2;for(;n>=0&&G(Z(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function Y(t,e,i){for(;e>0;){let n=U(t,e-2,i);if(n<e)return n;e--}return 0}function X(t){return t>=56320&&t<57344}function Q(t){return t>=55296&&t<56320}function Z(t,e){let i=t.charCodeAt(e);if(!Q(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return X(n)?n-56320+(i-55296<<10)+65536:i}function tt(t){return t<65536?1:2}const et=/\r\n?|\n/;var it=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(it||(it={}));class nt{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){ht(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new nt(t)}composeDesc(t){return this.empty?t:t.empty?this:at(this,t)}mapDesc(t,e=!1){return t.empty?this:lt(this,t,e)}mapPos(t,e=-1,i=it.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=it.Simple&&l>=t&&(i==it.TrackDel&&n<t&&l>t||i==it.TrackBefore&&n<t||i==it.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new nt(t)}static create(t){return new nt(t)}}class st extends nt{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return ht(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return lt(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let r=e[n],o=e[n+1];if(o>=0){e[n]=o,e[n+1]=r;let h=n>>1;for(;i.length<h;)i.push(I.empty);i.push(r?t.slice(s,s+r):I.empty)}s+=r}return new st(e,i)}compose(t){return this.empty?t:t.empty?this:at(this,t,!0)}map(t,e=!1){return t.empty?this:lt(this,t,e,!0)}iterChanges(t,e=!1){ht(this,t,e)}get desc(){return nt.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new ct(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);rt(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;rt(e,t,r),r>0&&ot(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);rt(e,t,-1),rt(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new st(e,i),filtered:nt.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],r=0,o=null;function h(t=!1){if(!t&&!n.length)return;r<e&&rt(n,e-r,-1);let i=new st(n,s);o=o?o.compose(i.map(o)):i,n=[],s=[],r=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof st){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);h(),o=o?o.compose(l.map(o)):l}else{let{from:t,to:o=t,insert:a}=l;if(t>o||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=a?"string"==typeof a?I.of(a.split(i||et)):a:I.empty,u=c.length;if(t==o&&0==u)return;t<r&&h(),t>r&&rt(n,t-r,-1),rt(n,o-t,u),ot(s,n,c),r=o}}(t),h(!o),o}static empty(t){return new st(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(I.empty);i[n]=I.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new st(e,i)}static createSet(t,e){return new st(t,e)}}function rt(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function ot(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(I.empty);t.push(i)}}function ht(t,e,i){let n=t.inserted;for(let s=0,r=0,o=0;o<t.sections.length;){let h=t.sections[o++],l=t.sections[o++];if(l<0)s+=h,r+=h;else{let a=s,c=r,u=I.empty;for(;a+=h,c+=l,l&&n&&(u=u.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)h=t.sections[o++],l=t.sections[o++];e(s,a,r,c,u),s=a,r=c}}}function lt(t,e,i,n=!1){let s=[],r=n?[]:null,o=new ct(t),h=new ct(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);rt(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(rt(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(rt(s,0,o.ins),r&&ot(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?st.createSet(s,r):nt.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}rt(s,e,t<o.i?o.ins:0),r&&t<o.i&&ot(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function at(t,e,i=!1){let n=[],s=i?[]:null,r=new ct(t),o=new ct(e);for(let t=!1;;){if(r.done&&o.done)return s?st.createSet(n,s):nt.create(n);if(0==r.ins)rt(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;rt(n,e,i,t),s&&i&&ot(s,n,o.text)}else-1==o.ins?(rt(n,r.off?0:r.len,e,t),s&&ot(s,n,r.textBit(e))):(rt(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&ot(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else rt(n,0,o.ins,t),s&&ot(s,n,o.text),o.next()}}class ct{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?I.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?I.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class ut{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let t=3&this.flags;return 3==t?null:t}get goalColumn(){let t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new ut(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return ft.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return ft.range(this.anchor,i)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return ft.range(t.anchor,t.head)}static create(t,e,i){return new ut(t,e,i)}}class ft{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:ft.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new ft([this.main],0)}addRange(t,e=!0){return ft.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,ft.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ft(t.ranges.map((t=>ut.fromJSON(t))),t.main)}static single(t,e=t){return new ft([ft.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return ft.normalized(t.slice(),e);i=s.to}return new ft(t,e)}static cursor(t,e=0,i,n){return ut.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?ut.create(e,t,24|s):ut.create(t,e,(e>t?4:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?ft.range(o,r):ft.range(r,o))}}return new ft(t,e)}}function dt(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let gt=0;class pt{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=gt++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new pt(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:mt),!!t.static,t.enables)}of(t){return new wt([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new wt(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new wt(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function mt(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class wt{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=gt++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||yt(t,a)){let e=i(t);if(o?!vt(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=Bt(e,l);if(this.dependencies.every((i=>i instanceof pt?e.facet(i)===t.facet(i):!(i instanceof St)||e.field(i,!1)==t.field(i,!1)))||(o?vt(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function vt(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function yt(t,e){let i=!1;for(let n of e)1&Rt(t,n)&&(i=!0);return i}function bt(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=Bt(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)Rt(t,e);return t.values[o]=h(t),1},update(t,i){if(!yt(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=yt(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&mt(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const xt=pt.define({static:!0});class St{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new St(gt++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(xt).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,xt.of({field:this,create:t})]}get extension(){return this}}const kt=2,At=1;function Mt(t){return e=>new Ot(e,t)}const Ct=Mt(At);class Ot{constructor(t,e){this.inner=t,this.prec=e}}class Dt{of(t){return new Tt(this,t)}reconfigure(t){return Dt.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Tt{constructor(t,e){this.compartment=t,this.inner=e}}class Et{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Tt&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Tt){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof Ot)r(t.inner,t.prec);else if(t instanceof St)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof wt)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,kt);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,kt),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof St?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,mt(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>bt(t,n,e)))}}let c=l.map((t=>t(o)));return new Et(t,r,c,o,h,s)}}function Rt(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function Bt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Pt=pt.define(),Lt=pt.define({combine:t=>t.some((t=>t)),static:!0}),Nt=pt.define({combine:t=>t.length?t[0]:void 0,static:!0}),It=pt.define(),Ht=pt.define(),Vt=pt.define(),Wt=pt.define({combine:t=>!!t.length&&t[0]});class Ft{constructor(t,e){this.type=t,this.value=e}static define(){return new zt}}class zt{of(t){return new Ft(this,t)}}class _t{constructor(t){this.map=t}of(t){return new qt(this,t)}}class qt{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new qt(this.type,e)}is(t){return this.type==t}static define(t={}){return new _t(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}qt.reconfigure=qt.define(),qt.appendConfig=qt.define();class Kt{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&dt(i,e.newLength),s.some((t=>t.type==Kt.time))||(this.annotations=s.concat(Kt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new Kt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Kt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function jt(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function $t(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=st.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:qt.mapEffects(t.effects,s).concat(qt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Gt(t,e,i){let n=e.selection,s=Yt(e.annotations);return e.userEvent&&(s=s.concat(Kt.userEvent.of(e.userEvent))),{changes:e.changes instanceof st?e.changes:st.of(e.changes||[],i,t.facet(Nt)),selection:n&&(n instanceof ft?n:ft.single(n.anchor,n.head)),effects:Yt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Jt(t,e,i){let n=Gt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=$t(n,Gt(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=Kt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(Vt),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=$t(n,Gt(e,r,t.changes.newLength),!0))}return n==t?t:Kt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(It)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:jt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=st.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=Kt.create(e,n,t.selection&&t.selection.map(s),qt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Ht);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof Kt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof Kt?s[0]:Jt(e,Yt(s),!1)}return t}(s):s)}Kt.time=Ft.define(),Kt.userEvent=Ft.define(),Kt.addToHistory=Ft.define(),Kt.remote=Ft.define();const Ut=[];function Yt(t){return null==t?Ut:Array.isArray(t)?t:[t]}var Xt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Xt||(Xt={}));const Qt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Zt;try{Zt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function te(t){return e=>{if(!/\S/.test(e))return Xt.Space;if(function(t){if(Zt)return Zt.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||Qt.test(i)))return!0}return!1}(e))return Xt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Xt.Word;return Xt.Other}}class ee{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Rt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Rt(this,i),Bt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Jt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Dt.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(qt.reconfigure)?(i=null,n=e.value):e.is(qt.appendConfig)&&(i=null,n=Yt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Et.resolve(n,s,this),e=new ee(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new ee(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:ft.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=Yt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=qt.mapEffects(r,l).concat(qt.mapEffects(Yt(o.effects),a))}return{changes:n,selection:ft.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof st?t:st.of(t,this.doc.length,this.facet(ee.lineSeparator))}toText(t){return I.of(t.split(this.facet(ee.lineSeparator)||et))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Rt(this,e),Bt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof St&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return ee.create({doc:t.doc,selection:ft.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Et.resolve(t.extensions||[],new Map),i=t.doc instanceof I?t.doc:I.of((t.doc||"").split(e.staticFacet(ee.lineSeparator)||et)),n=t.selection?t.selection instanceof ft?t.selection:ft.single(t.selection.anchor,t.selection.head):ft.single(0);return dt(n,i.length),e.staticFacet(Lt)||(n=n.asSingle()),new ee(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(ee.tabSize)}get lineBreak(){return this.facet(ee.lineSeparator)||"\n"}get readOnly(){return this.facet(Wt)}phrase(t,...e){for(let e of this.facet(ee.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(Pt))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return te(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=J(e,r,!1);if(s(e.slice(t,r))!=Xt.Word)break;r=t}for(;o<n;){let t=J(e,o);if(s(e.slice(o,t))!=Xt.Word)break;o=t}return r==o?null:ft.range(r+i,o+i)}}ee.allowMultipleSelections=Lt,ee.tabSize=pt.define({combine:t=>t.length?t[0]:4}),ee.lineSeparator=Nt,ee.readOnly=Wt,ee.phrases=pt.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),ee.languageData=Pt,ee.changeFilter=It,ee.transactionFilter=Ht,ee.transactionExtender=Vt,Dt.reconfigure=qt.define();class ie{eq(t){return this==t}range(t,e=t){return ne.create(t,e,this)}}ie.prototype.startSide=ie.prototype.endSide=0,ie.prototype.point=!1,ie.prototype.mapMode=it.TrackDel;class ne{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new ne(t,e,i)}}function se(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class re{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new re(n,s,i,o):null,pos:r}}}class oe{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new oe(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(se)),this.isEmpty)return e.length?oe.of(e):this;let o=new ae(this,null,-1).goto(0),h=0,l=[],a=new he;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(ne.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?oe.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new oe(i,e,s||oe.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return ce.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return ce.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=le(r,o,i),l=new fe(r,h,s),a=new fe(o,h,s);i.iterGaps(((t,e,i)=>de(l,t,a,e,i,n))),i.empty&&0==i.length&&de(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=le(s,r),h=new fe(s,o,0).goto(i),l=new fe(r,o,0).goto(i);for(;;){if(h.to!=l.to||!ge(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new fe(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new he;for(let n of t instanceof ne?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(se(e,n)>0)return t.slice().sort(se);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}oe.empty=new oe([],[],null,-1),oe.empty.nextLayer=oe.empty;class he{finishChunk(t){this.chunks.push(new re(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new he)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(oe.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=oe.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function le(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class ae{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class ce{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new ae(r,e,i,s));return 1==n.length?n[0]:new ce(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)ue(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)ue(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),ue(this.heap,0)}}}function ue(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class fe{constructor(t,e,i){this.minPoint=i,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(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){pe(this.active,t),pe(this.activeTo,t),pe(this.activeRank,t),this.minActive=we(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;me(this.active,e,i),me(this.activeTo,e,n),me(this.activeRank,e,s),t&&me(t,e,this.cursor.from),this.minActive=we(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&pe(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function de(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&ge(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!ge(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function ge(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function pe(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function me(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function we(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}i("37210");class ve{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=Oe(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),be.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=Oe(this,t,e);let i=[];return this.decompose(t,e,i,0),be.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new ke(this),s=new ke(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new ke(this,t)}iterRange(t,e=this.length){return new Ae(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new Me(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new ye(t):be.from(ye.split(t,[])):ve.empty}}class ye extends ve{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new Ce(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new ye(Se(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=xe(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new ye(e,t.length+s.length));else{let t=e.length>>1;i.push(new ye(e.slice(0,t)),new ye(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof ye))return super.replace(t,e,i);[t,e]=Oe(this,t,e);let n=xe(this.text,xe(i.text,Se(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new ye(n,s):be.from(ye.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=Oe(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new ye(i,n)),i=[],n=-1);return n>-1&&e.push(new ye(i,n)),e}}class be extends ve{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=Oe(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],o=s+r.length;if(t>=s&&e<=o){let h=r.replace(t-s,e-s,i),l=this.lines-r.lines+h.lines;if(h.lines<l>>4&&h.lines>l>>6){let s=this.children.slice();return s[n]=h,new be(s,this.length-(e-t)+i.length)}return super.replace(s,o,h)}s=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=Oe(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof be))return 0;let i=0,[n,s,r,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==o)return i;let h=this.children[n],l=t.children[s];if(h!=l)return i+h.scanIdentical(l,e);i+=h.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new ye(i,e)}let n=Math.max(32,i>>5),s=n<<1,r=n>>1,o=[],h=0,l=-1,a=[];function c(t){let e;if(t.lines>s&&t instanceof be)for(let e of t.children)c(e);else t.lines>r&&(h>r||!h)?(u(),o.push(t)):t instanceof ye&&h&&(e=a[a.length-1])instanceof ye&&t.lines+e.lines<=32?(h+=t.lines,l+=t.length+1,a[a.length-1]=new ye(e.text.concat(t.text),e.length+1+t.length)):(h+t.lines>n&&u(),h+=t.lines,l+=t.length+1,a.push(t))}function u(){0!=h&&(o.push(1==a.length?a[0]:be.from(a,l)),l=-1,h=a.length=0)}for(let e of t)c(e);return u(),1==o.length?o[0]:new be(o,e)}}function xe(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function Se(t,e,i){return xe(t,[""],e,i)}ve.empty=new ye([""],0);class ke{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof ye?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],r=s>>1,o=n instanceof ye?n.text.length:n.children.length;if(r==(e>0?o:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof ye){let s=n.text[r+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[r+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof ye?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class Ae{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new ke(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class Me{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(ve.prototype[Symbol.iterator]=function(){return this.iter()},ke.prototype[Symbol.iterator]=Ae.prototype[Symbol.iterator]=Me.prototype[Symbol.iterator]=function(){return this});class Ce{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function Oe(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let De="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((t=>t?parseInt(t,36):1));for(let t=1;t<De.length;t++)De[t]+=De[t-1];function Te(t){for(let e=1;e<De.length;e+=2)if(De[e]>t)return De[e-1]<=t;return!1}function Ee(t){return t>=127462&&t<=127487}function Re(t,e,i=!0,n=!0){return(i?Be:Pe)(t,e,n)}function Be(t,e,i){if(e==t.length)return e;e&&Le(t.charCodeAt(e))&&Ne(t.charCodeAt(e-1))&&e--;let n=Ie(t,e);for(e+=He(n);e<t.length;){let s=Ie(t,e);if(8205==n||8205==s||i&&Te(s))e+=He(s),n=s;else{if(!Ee(s))break;{let i=0,n=e-2;for(;n>=0&&Ee(Ie(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function Pe(t,e,i){for(;e>0;){let n=Be(t,e-2,i);if(n<e)return n;e--}return 0}function Le(t){return t>=56320&&t<57344}function Ne(t){return t>=55296&&t<56320}function Ie(t,e){let i=t.charCodeAt(e);if(!Ne(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return Le(n)?n-56320+(i-55296<<10)+65536:i}function He(t){return t<65536?1:2}const Ve=/\r\n?|\n/;var We=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(We||(We={}));class Fe{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){Ke(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new Fe(t)}composeDesc(t){return this.empty?t:t.empty?this:$e(this,t)}mapDesc(t,e=!1){return t.empty?this:je(this,t,e)}mapPos(t,e=-1,i=We.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=We.Simple&&l>=t&&(i==We.TrackDel&&n<t&&l>t||i==We.TrackBefore&&n<t||i==We.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Fe(t)}static create(t){return new Fe(t)}}class ze extends Fe{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return Ke(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return je(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let r=e[n],o=e[n+1];if(o>=0){e[n]=o,e[n+1]=r;let h=n>>1;for(;i.length<h;)i.push(ve.empty);i.push(r?t.slice(s,s+r):ve.empty)}s+=r}return new ze(e,i)}compose(t){return this.empty?t:t.empty?this:$e(this,t,!0)}map(t,e=!1){return t.empty?this:je(this,t,e,!0)}iterChanges(t,e=!1){Ke(this,t,e)}get desc(){return Fe.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new Ge(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);_e(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;_e(e,t,r),r>0&&qe(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);_e(e,t,-1),_e(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new ze(e,i),filtered:Fe.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],r=0,o=null;function h(t=!1){if(!t&&!n.length)return;r<e&&_e(n,e-r,-1);let i=new ze(n,s);o=o?o.compose(i.map(o)):i,n=[],s=[],r=0}return function t(l){if(Array.isArray(l))for(let e of l)t(e);else if(l instanceof ze){if(l.length!=e)throw new RangeError(`Mismatched change set length (got ${l.length}, expected ${e})`);h(),o=o?o.compose(l.map(o)):l}else{let{from:t,to:o=t,insert:a}=l;if(t>o||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let c=a?"string"==typeof a?ve.of(a.split(i||Ve)):a:ve.empty,u=c.length;if(t==o&&0==u)return;t<r&&h(),t>r&&_e(n,t-r,-1),_e(n,o-t,u),qe(s,n,c),r=o}}(t),h(!o),o}static empty(t){return new ze(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(ve.empty);i[n]=ve.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new ze(e,i)}static createSet(t,e){return new ze(t,e)}}function _e(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function qe(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(ve.empty);t.push(i)}}function Ke(t,e,i){let n=t.inserted;for(let s=0,r=0,o=0;o<t.sections.length;){let h=t.sections[o++],l=t.sections[o++];if(l<0)s+=h,r+=h;else{let a=s,c=r,u=ve.empty;for(;a+=h,c+=l,l&&n&&(u=u.append(n[o-2>>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)h=t.sections[o++],l=t.sections[o++];e(s,a,r,c,u),s=a,r=c}}}function je(t,e,i,n=!1){let s=[],r=n?[]:null,o=new Ge(t),h=new Ge(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);_e(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(_e(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(_e(s,0,o.ins),r&&qe(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?ze.createSet(s,r):Fe.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}_e(s,e,t<o.i?o.ins:0),r&&t<o.i&&qe(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function $e(t,e,i=!1){let n=[],s=i?[]:null,r=new Ge(t),o=new Ge(e);for(let t=!1;;){if(r.done&&o.done)return s?ze.createSet(n,s):Fe.create(n);if(0==r.ins)_e(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;_e(n,e,i,t),s&&i&&qe(s,n,o.text)}else-1==o.ins?(_e(n,r.off?0:r.len,e,t),s&&qe(s,n,r.textBit(e))):(_e(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&qe(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else _e(n,0,o.ins,t),s&&qe(s,n,o.text),o.next()}}class Ge{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?ve.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?ve.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Je{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new Je(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return Ue.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return Ue.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Ue.range(t.anchor,t.head)}static create(t,e,i){return new Je(t,e,i)}}class Ue{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:Ue.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new Ue([this.main],0)}addRange(t,e=!0){return Ue.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,Ue.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ue(t.ranges.map((t=>Je.fromJSON(t))),t.main)}static single(t,e=t){return new Ue([Ue.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return Ue.normalized(t.slice(),e);i=s.to}return new Ue(t,e)}static cursor(t,e=0,i,n){return Je.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?Je.create(e,t,48|s):Je.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?Ue.range(o,r):Ue.range(r,o))}}return new Ue(t,e)}}function Ye(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let Xe=0;class Qe{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=Xe++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new Qe(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:Ze),!!t.static,t.enables)}of(t){return new ti([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ti(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new ti(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function Ze(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class ti{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=Xe++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||ii(t,a)){let e=i(t);if(o?!ei(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=wi(e,l);if(this.dependencies.every((i=>i instanceof Qe?e.facet(i)===t.facet(i):!(i instanceof ri)||e.field(i,!1)==t.field(i,!1)))||(o?ei(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function ei(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function ii(t,e){let i=!1;for(let n of e)1&mi(t,n)&&(i=!0);return i}function ni(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=wi(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)mi(t,e);return t.values[o]=h(t),1},update(t,i){if(!ii(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=ii(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&Ze(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const si=Qe.define({static:!0});class ri{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new ri(Xe++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(si).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,si.of({field:this,create:t})]}get extension(){return this}}const oi=4,hi=3,li=2,ai=1;function ci(t){return e=>new fi(e,t)}const ui={highest:ci(0),high:ci(ai),default:ci(li),low:ci(hi),lowest:ci(oi)};class fi{constructor(t,e){this.inner=t,this.prec=e}}class di{of(t){return new gi(this,t)}reconfigure(t){return di.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class gi{constructor(t,e){this.compartment=t,this.inner=e}}class pi{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof gi&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof gi){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof fi)r(t.inner,t.prec);else if(t instanceof ri)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof ti)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,li);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,li),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof ri?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,Ze(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>ni(t,n,e)))}}let c=l.map((t=>t(o)));return new pi(t,r,c,o,h,s)}}function mi(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function wi(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const vi=Qe.define(),yi=Qe.define({combine:t=>t.some((t=>t)),static:!0}),bi=Qe.define({combine:t=>t.length?t[0]:void 0,static:!0}),xi=Qe.define(),Si=Qe.define(),ki=Qe.define(),Ai=Qe.define({combine:t=>!!t.length&&t[0]});class Mi{constructor(t,e){this.type=t,this.value=e}static define(){return new Ci}}class Ci{of(t){return new Mi(this,t)}}class Oi{constructor(t){this.map=t}of(t){return new Di(this,t)}}class Di{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new Di(this.type,e)}is(t){return this.type==t}static define(t={}){return new Oi(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}Di.reconfigure=Di.define(),Di.appendConfig=Di.define();class Ti{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&Ye(i,e.newLength),s.some((t=>t.type==Ti.time))||(this.annotations=s.concat(Ti.time.of(Date.now())))}static create(t,e,i,n,s,r){return new Ti(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(Ti.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function Ei(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function Ri(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=ze.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:Di.mapEffects(t.effects,s).concat(Di.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function Bi(t,e,i){let n=e.selection,s=Ni(e.annotations);return e.userEvent&&(s=s.concat(Ti.userEvent.of(e.userEvent))),{changes:e.changes instanceof ze?e.changes:ze.of(e.changes||[],i,t.facet(bi)),selection:n&&(n instanceof Ue?n:Ue.single(n.anchor,n.head)),effects:Ni(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Pi(t,e,i){let n=Bi(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=Ri(n,Bi(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=Ti.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ki),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=Ri(n,Bi(e,r,t.changes.newLength),!0))}return n==t?t:Ti.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(xi)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:Ei(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=ze.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=Ti.create(e,n,t.selection&&t.selection.map(s),Di.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Si);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof Ti?s:Array.isArray(s)&&1==s.length&&s[0]instanceof Ti?s[0]:Pi(e,Ni(s),!1)}return t}(s):s)}Ti.time=Mi.define(),Ti.userEvent=Mi.define(),Ti.addToHistory=Mi.define(),Ti.remote=Mi.define();const Li=[];function Ni(t){return null==t?Li:Array.isArray(t)?t:[t]}var Ii=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ii||(Ii={}));const Hi=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Vi;try{Vi=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function Wi(t){return e=>{if(!/\S/.test(e))return Ii.Space;if(function(t){if(Vi)return Vi.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||Hi.test(i)))return!0}return!1}(e))return Ii.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return Ii.Word;return Ii.Other}}class Fi{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)mi(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return mi(this,i),wi(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return Pi(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(di.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(Di.reconfigure)?(i=null,n=e.value):e.is(Di.appendConfig)&&(i=null,n=Ni(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=pi.resolve(n,s,this),e=new Fi(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(yi)?t.newSelection:t.newSelection.asSingle();new Fi(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:Ue.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=Ni(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=Di.mapEffects(r,l).concat(Di.mapEffects(Ni(o.effects),a))}return{changes:n,selection:Ue.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof ze?t:ze.of(t,this.doc.length,this.facet(Fi.lineSeparator))}toText(t){return ve.of(t.split(this.facet(Fi.lineSeparator)||Ve))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(mi(this,e),wi(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof ri&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return Fi.create({doc:t.doc,selection:Ue.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=pi.resolve(t.extensions||[],new Map),i=t.doc instanceof ve?t.doc:ve.of((t.doc||"").split(e.staticFacet(Fi.lineSeparator)||Ve)),n=t.selection?t.selection instanceof Ue?t.selection:Ue.single(t.selection.anchor,t.selection.head):Ue.single(0);return Ye(n,i.length),e.staticFacet(yi)||(n=n.asSingle()),new Fi(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Fi.tabSize)}get lineBreak(){return this.facet(Fi.lineSeparator)||"\n"}get readOnly(){return this.facet(Ai)}phrase(t,...e){for(let e of this.facet(Fi.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(vi))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return Wi(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=Re(e,r,!1);if(s(e.slice(t,r))!=Ii.Word)break;r=t}for(;o<n;){let t=Re(e,o);if(s(e.slice(o,t))!=Ii.Word)break;o=t}return r==o?null:Ue.range(r+i,o+i)}}Fi.allowMultipleSelections=yi,Fi.tabSize=Qe.define({combine:t=>t.length?t[0]:4}),Fi.lineSeparator=bi,Fi.readOnly=Ai,Fi.phrases=Qe.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),Fi.languageData=vi,Fi.changeFilter=xi,Fi.transactionFilter=Si,Fi.transactionExtender=ki,di.reconfigure=Di.define();class zi{eq(t){return this==t}range(t,e=t){return _i.create(t,e,this)}}zi.prototype.startSide=zi.prototype.endSide=0,zi.prototype.point=!1,zi.prototype.mapMode=We.TrackDel;class _i{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new _i(t,e,i)}}function qi(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Ki{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Ki(n,s,i,o):null,pos:r}}}class ji{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new ji(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(qi)),this.isEmpty)return e.length?ji.of(e):this;let o=new Ji(this,null,-1).goto(0),h=0,l=[],a=new $i;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(_i.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?ji.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new ji(i,e,s||ji.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Ui.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Ui.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=Gi(r,o,i),l=new Xi(r,h,s),a=new Xi(o,h,s);i.iterGaps(((t,e,i)=>Qi(l,t,a,e,i,n))),i.empty&&0==i.length&&Qi(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=Gi(s,r),h=new Xi(s,o,0).goto(i),l=new Xi(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Zi(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Xi(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new $i;for(let n of t instanceof _i?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(qi(e,n)>0)return t.slice().sort(qi);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return ji.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=ji.empty;n=n.nextLayer)e=new ji(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}ji.empty=new ji([],[],null,-1),ji.empty.nextLayer=ji.empty;class $i{finishChunk(t){this.chunks.push(new Ki(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new $i)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(ji.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=ji.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Gi(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Ji{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Ui{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new Ji(r,e,i,s));return 1==n.length?n[0]:new Ui(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Yi(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Yi(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Yi(this.heap,0)}}}function Yi(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class Xi{constructor(t,e,i){this.minPoint=i,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=Ui.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){tn(this.active,t),tn(this.activeTo,t),tn(this.activeRank,t),this.minActive=nn(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;en(this.active,e,i),en(this.activeTo,e,n),en(this.activeRank,e,s),t&&en(t,e,this.cursor.from),this.minActive=nn(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&tn(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Qi(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Zi(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Zi(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Zi(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function tn(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function en(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function nn(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}const sn="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),rn="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),on="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class hn{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=on[sn]||1;return on[sn]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[rn],s=i&&i.nonce;n?s&&n.setNonce(s):n=new an(t,s),n.mount(Array.isArray(e)?e:[e])}}let ln=new Map;class an{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=ln.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[rn]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],ln.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[rn]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}i("96318");function cn(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function un(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function fn(t,e){if(!e.anchorNode)return!1;try{return un(t,e.anchorNode)}catch(t){return!1}}function dn(t){return 3==t.nodeType?Mn(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function gn(t,e,i,n){return!!i&&(mn(t,e,i,n,-1)||mn(t,e,i,n,1))}function pn(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function mn(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:wn(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=pn(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?wn(t):0}}}function wn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function vn(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function yn(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function bn(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class xn{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?wn(e):0),i,Math.min(t.focusOffset,i?wn(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let Sn,kn=null;function An(t){if(t.setActive)return t.setActive();if(kn)return t.focus(kn);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==kn?{get preventScroll(){return kn={preventScroll:!0},!0}}:void 0),!kn){kn=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function Mn(t,e,i=e){let n=Sn||(Sn=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Cn(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function On(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Dn(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}class Tn{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Tn(t.parentNode,pn(t),e)}static after(t,e){return new Tn(t.parentNode,pn(t)+1,e)}}const En=[];class Rn{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=Rn.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=Bn(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=Bn(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==wn(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!Rn.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=En){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new Pn(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function Bn(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}Rn.prototype.breakAfter=0;class Pn{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){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;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Ln(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function Nn(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,Ln(t,a,c,h,l,n,0,s,r)}let In="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},Hn="undefined"!=typeof document?document:{documentElement:{style:{}}};const Vn=/Edge\/(\d+)/.exec(In.userAgent),Wn=/MSIE \d/.test(In.userAgent),Fn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(In.userAgent),zn=!!(Wn||Fn||Vn),_n=!zn&&/gecko\/(\d+)/i.test(In.userAgent),qn=!zn&&/Chrome\/(\d+)/.exec(In.userAgent),Kn="webkitFontSmoothing"in Hn.documentElement.style,jn=!zn&&/Apple Computer/.test(In.vendor),$n=jn&&(/Mobile\/\w+/.test(In.userAgent)||In.maxTouchPoints>2);var Gn={mac:$n||/Mac/.test(In.platform),windows:/Win/.test(In.platform),linux:/Linux|X11/.test(In.platform),ie:zn,ie_version:Wn?Hn.documentMode||6:Fn?+Fn[1]:Vn?+Vn[1]:0,gecko:_n,gecko_version:_n?+(/Firefox\/(\d+)/.exec(In.userAgent)||[0,0])[1]:0,chrome:!!qn,chrome_version:qn?+qn[1]:0,ios:$n,android:/Android\b/.test(In.userAgent),webkit:Kn,safari:jn,webkit_version:Kn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Hn.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Jn extends Rn{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof Jn)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Jn(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Tn(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?Gn.chrome||Gn.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=Mn(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];Gn.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l);return o?vn(l,o<0):l||null}(this.dom,t,e)}}class Un extends Rn{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(On(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof Un&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(Nn(this,t,e,i?i.children.slice():[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Un(this.mark,e,r)}domAtPos(t){return Qn(this,t)}coordsAt(t,e){return ts(this,t,e)}}class Yn extends Rn{static create(t,e,i){return new Yn(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=Yn.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Yn&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Yn&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return ve.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):ve.empty}domAtPos(t){return(this.length?0==t:this.side>0)?Tn.before(this.dom):Tn.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return vn(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Xn extends Rn{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Xn&&t.side==this.side}split(){return new Xn(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?Tn.before(this.dom):Tn.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return ve.empty}get isHidden(){return!0}}function Qn(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new Tn(i,0)}function Zn(t,e,i){let n,{children:s}=t;i>0&&e instanceof Un&&s.length&&(n=s[s.length-1])instanceof Un&&n.mark.eq(e.mark)?Zn(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function ts(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=dn(e);return i[i.length-1]||null}(t)}function es(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}Jn.prototype.children=Yn.prototype.children=Xn.prototype.children=En;const is=Object.create(null);function ns(t,e,i){if(t==e)return!0;t||(t=is),e||(e=is);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function ss(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function rs(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class os extends Rn{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof os))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Nn(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new os;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){ns(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){Zn(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=es(e,this.attrs||{})),i&&(this.attrs=es({class:i},this.attrs||{}))}domAtPos(t){return Qn(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(On(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&&(ss(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&Rn.get(n)instanceof Un;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=Rn.get(n))||void 0===i?void 0:i.isEditable)||Gn.ios&&this.children.some((t=>t instanceof Jn))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof Jn)||/[^ -~]/.test(i.text))return null;let n=dn(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=ts(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof os)return s;if(r>e)break}n=r+s.breakAfter}return null}}class hs extends Rn{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof hs&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?Tn.before(this.dom):Tn.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new hs(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return En}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):ve.empty}domBoundsAround(){return null}become(t){return t instanceof hs&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class ls{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var as=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(as||(as={}));class cs extends zi{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new us(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new ds(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=gs(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new ds(t,e,i,n,t.widget||null,!0)}static line(t){return new fs(t)}static set(t,e=!1){return ji.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}cs.none=ji.empty;class us extends cs{constructor(t){let{start:e,end:i}=gs(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof us&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&ns(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}us.prototype.point=!1;class fs extends cs{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof fs&&this.spec.class==t.spec.class&&ns(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}fs.prototype.mapMode=We.TrackBefore,fs.prototype.point=!0;class ds extends cs{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?We.TrackBefore:We.TrackAfter:We.TrackDel}get type(){return this.startSide!=this.endSide?as.WidgetRange:this.startSide<=0?as.WidgetBefore:as.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof ds&&(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}range(t,e=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 super.range(t,e)}}function gs(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function ps(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}ds.prototype.point=!0;class ms{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof hs&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new os),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ws(new Xn(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof hs||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(ws(new Jn(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,r){if(this.disallowBlockEffectsFor[r]&&i instanceof ds){if(i.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")}let o=e-t;if(i instanceof ds)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new hs(i.widget||new vs("div"),o,i));else{let r=Yn.create(i.widget||new vs("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(ws(new Xn(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(ws(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=s)}static build(t,e,i,n,s){let r=new ms(t,e,i,s);return r.openEnd=ji.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function ws(t,e){for(let i of e)t=new Un(i,[t],t.length);return t}class vs extends ls{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}var ys=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(ys||(ys={}));const bs=ys.LTR,xs=ys.RTL;function Ss(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const ks=Ss("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),As=Ss("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ms=Object.create(null),Cs=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Ms[e]=i,Ms[i]=-e}function Os(t){return t<=247?ks[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?As[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Ds=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ts{get dir(){return this.level%2?xs:bs}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}function Es(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!Es(n.inner,s.inner))return!1}return!0}const Rs=[];function Bs(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=Rs[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(Rs[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new Ts(l,g.from,f)),Ps(t,g.direction==bs!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?Rs[d]!=h:Rs[d]==h))break;d++}u?Bs(t,l,d,n+1,s,u,o):l<d&&o.push(new Ts(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=Rs[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(Rs[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new Ts(g.to,l,f)),Ps(t,g.direction==bs!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?Rs[d-1]!=h:Rs[d-1]==h))break;d--}u?Bs(t,d,l,n+1,s,u,o):d<l&&o.push(new Ts(d,l,f)),l=d}}function Ps(t,e,i,n,s,r,o){let h=e%2?2:1;!function(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=Os(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),Rs[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=Rs[t];if(128==s)t<h-1&&e==Rs[t+1]&&24&e?s=Rs[t]=e:Rs[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==Rs[s];)s++;let r=t&&8==e||s<i&&8==Rs[s]?1==n?1:8:256;for(let e=t;e<s;e++)Rs[e]=r;t=s-1}else 8==s&&1==n&&(Rs[t]=1);e=s,7&s&&(n=s)}}}(t,s,r,n,h),function(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=Ms[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(Cs[t+1]==-i){let e=Cs[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(Rs[o]=Rs[Cs[t]]=i),h=t;break}}else{if(189==Cs.length)break;Cs[h++]=o,Cs[h++]=e,Cs[h++]=l}else if(2==(n=Rs[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=Cs[e+2];if(2&i)break;if(t)Cs[e+2]|=2;else{if(4&i)break;Cs[e+2]|=4}}}}}(t,s,r,n,h),function(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=Rs[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=Rs[o])break;o++}let a=1==r,c=a==(1==(o<e?Rs[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),Rs[--e]=c;l=o}else r=o,l++}}}(s,r,n,h),Bs(t,s,r,e,i,n,o)}function Ls(t,e,i){if(!t)return[new Ts(0,0,e==xs?1:0)];if(e==bs&&!i.length&&!Ds.test(t))return Ns(t.length);if(i.length)for(;t.length>Rs.length;)Rs[Rs.length]=256;let n=[],s=e==bs?0:1;return Ps(t,s,s,i,0,t.length,n),n}function Ns(t){return[new Ts(0,t,0)]}let Is="";function Hs(t,e,i,n,s){var r;let o=n.head-t.from,h=Ts.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc),l=e[h],a=l.side(s,i);if(o==a){let t=h+=s?1:-1;if(t<0||t>=e.length)return null;l=e[h=t],o=l.side(!s,i),a=l.side(s,i)}let c=Re(t.text,o,l.forward(s,i));(c<l.from||c>l.to)&&(c=a),Is=t.text.slice(Math.min(o,c),Math.max(o,c));let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u&&c==a&&u.level+(s?0:1)<l.level?Ue.cursor(u.side(!s,i)+t.from,u.forward(s,i)?1:-1,u.level):Ue.cursor(c+t.from,l.forward(s,i)?-1:1,l.level)}function Vs(t,e,i){for(let n=e;n<i;n++){let e=Os(t.charCodeAt(n));if(1==e)return bs;if(2==e||4==e)return xs}return bs}const Ws=Qe.define(),Fs=Qe.define(),zs=Qe.define(),_s=Qe.define(),qs=Qe.define(),Ks=Qe.define(),js=Qe.define(),$s=Qe.define({combine:t=>t.some((t=>t))}),Gs=Qe.define({combine:t=>t.some((t=>t))});class Js{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new Js(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new Js(Ue.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Us=Di.define({map:(t,e)=>t.map(e)});function Ys(t,e,i){let n=t.facet(_s);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const Xs=Qe.define({combine:t=>!t.length||t[0]});let Qs=0;const Zs=Qe.define();class tr{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new tr(Qs++,t,i,n,(t=>{let e=[Zs.of(t)];return r&&e.push(sr.of((e=>{let i=e.plugin(t);return i?r(i):cs.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return tr.define((e=>new t(e)),e)}}class er{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(Ys(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Ys(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){Ys(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ir=Qe.define(),nr=Qe.define(),sr=Qe.define(),rr=Qe.define(),or=Qe.define(),hr=Qe.define();function lr(t,e){let i=t.state.facet(hr);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return ji.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let t=n.length-1;t>=0;t--,r--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=Vs(e.text,o,h)),r>0&&l.length&&(i=l[l.length-1]).to==o&&i.direction==s)i.to=h,l=i.inner;else{let t={from:o,to:h,direction:s,inner:[]};l.push(t),l=t.inner}}}}),s}const ar=Qe.define();function cr(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(ar)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const ur=Qe.define();class fr{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new fr(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new fr(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new fr(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class dr{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=ze.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new fr(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new dr(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class gr extends Rn{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new os],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new fr(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=-1;this.view.inputState.composing>=0&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)}));return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=mr(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new fr(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=Rn.get(e);if(i instanceof Un)c.push({node:e,deco:i.mark});else{if(i instanceof os||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new us({inclusive:!0,attributes:rs(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new fr(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Gn.ie||Gn.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=function(t,e,i){let n=new vr;return ji.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=fr.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=Gn.chrome||Gn.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof hs&&t.widget instanceof pr&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let r,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=e;if(i&&i.range.fromB<f&&i.range.toB>u){let t=ms.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=ms.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),r=t.content.concat(n).concat(e.content)}else({content:r,breakAtStart:o,openStart:h,openEnd:l}=ms.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);Ln(this,p,m,d,g,r,o,h,l)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new Jn(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new Un(i,[e],e.length);let i=new os;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=Rn.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&fn(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(Gn.gecko&&o.empty&&!this.hasComposition&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new Tn(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&(gn(h.node,h.offset,c.anchorNode,c.anchorOffset)&&gn(l.node,l.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{Gn.android&&Gn.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=cn(this.view.root);if(t)if(o.empty){if(Gn.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=wr(h.node,h.offset,1==t?1:-1);e&&(h=new Tn(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new Tn(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new Tn(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&gn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=cn(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=os.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=Rn.get(i.childNodes[n]);t instanceof os&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=Rn.get(i.childNodes[n]);t instanceof os&&(e=t.domAtPos(t.length))}return e?new Tn(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=Rn.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof os)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof os&&!(i instanceof os&&e>=0))&&(i=o,n=l),s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof os))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof Jn))return null;let s=Re(n.text,i);if(s==i)return null;let r=Mn(n.dom,i,s).getClientRects();for(let t=0;t<r.length;t++){let e=r[t];if(t==r.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==ys.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?dn(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?ys.RTL:ys.LTR}measureTextSize(){for(let t of this.children)if(t instanceof os){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=dn(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new Pn(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(cs.replace({widget:new pr(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return cs.set(t)}updateDeco(){let t=this.view.state.facet(sr).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t)),e=!1,i=this.view.state.facet(rr).map(((t,i)=>{let n="function"==typeof t;return n&&(e=!0),n?t(this.view):t}));i.length&&(this.dynamicDecorationMap[t.length]=e,t.push(ji.join(i)));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=cr(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;!function(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=yn(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=bn(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n?e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r))):p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left,p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==ys.LTR)}}class pr extends ls{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}}function mr(t,e){let i=t.observer.selectionRange,n=i.focusNode&&wr(i.focusNode,i.focusOffset,0);if(!n)return null;let s=e-n.offset;return{from:s,to:s+n.node.nodeValue.length,node:n.node}}function wr(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return{node:i,offset:n};if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=wn(i)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return{node:n,offset:s};if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}let vr=class{constructor(){this.changes=[]}compareRange(t,e){ps(t,e,this.changes)}comparePoint(t,e){ps(t,e,this.changes)}};function yr(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function br(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function xr(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function Sr(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function kr(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Ar(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=dn(f);for(let d=0;d<t.length;d++){let g=t[d];s&&xr(s,g)&&(g=Sr(kr(g,s.bottom),s.top));let p=yr(e,g),m=br(i,g);if(0==p&&0==m)return 3==f.nodeType?Mr(f,e,i):Ar(f,e,i);if(!n||o>m||o==m&&r>p){n=f,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=f,a=g):i<g.top&&(!c||c.top>g.top)&&(l=f,c=g):a&&xr(a,g)?a=kr(a,g.bottom):c&&xr(c,g)&&(c=Sr(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?Mr(n,f,i):u&&"false"!=n.contentEditable?Ar(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function Mr(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=Mn(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(Gn.chrome||Gn.gecko){Mn(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function Cr(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=as.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:Or(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Or(t,h,o,c,u);let g=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:g,m=p.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=p.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||Gn.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return Mn(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||Gn.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Mn(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=os.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=Ar(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function Or(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=Re(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function Dr(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==as.Text))return t;return i}function Tr(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=Hs(s,r,o,h,i),a=Is;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function Er(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function Rr(t,e,i){let n=Er(t.state.facet(or).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:Ue.cursor(n,n<i.from?1:-1)}class Br{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){var e;this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Gn.safari&&t.contentDOM.addEventListener("input",(()=>null)),Gn.gecko&&(e=t.contentDOM.ownerDocument,so.has(e)||(so.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{}))))}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=Rn.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let s=t.domEventHandlers[n];s&&i(n).handlers.push(Pr(e.value,s))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let s=t.domEventObservers[n];s&&i(n).observers.push(Pr(e.value,s))}}for(let t in Wr)i(t).handlers.push(Wr[t]);for(let t in Fr)i(t).observers.push(Fr[t]);return e}(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,r=i[t];r&&s!=!r.handlers.length&&(n.removeEventListener(t,this.handleEvent),r=null),r||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=t.keyCode&&Ir.indexOf(t.keyCode)<0&&(this.view.inputState.lastEscPress=0),Gn.android&&Gn.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!Gn.ios||t.synthetic||t.altKey||t.metaKey||!((e=Lr.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||Nr.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,Cn(this.view.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Gn.safari&&!Gn.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Pr(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){Ys(i.state,t)}}}const Lr=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Nr="dthko",Ir=[16,17,18,20,91,92,224,225];function Hr(t){return.7*Math.max(0,t)+8}class Vr{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(or).map((e=>e(t)));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(Fi.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Ws);return i.length?i[0](e):Gn.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=cn(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Qr(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let s=0,r=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},h=cr(this.view);t.clientX-h.left<=o.left+6?s=-Hr(o.left-t.clientX):t.clientX+h.right>=o.right-6&&(s=Hr(t.clientX-o.right)),t.clientY-h.top<=o.top+6?r=-Hr(o.top-t.clientY):t.clientY+h.bottom>=o.bottom-6&&(r=Hr(t.clientY-o.bottom)),this.setScrollSpeed(s,r)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=Er(this.atoms,n.from,0);t!=n.from&&(s=Ue.cursor(t,-1))}else{let t=Er(this.atoms,n.from,-1),e=Er(this.atoms,n.to,1);t==n.from&&e==n.to||(s=Ue.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?Ue.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const Wr=Object.create(null),Fr=Object.create(null),zr=Gn.ie&&Gn.ie_version<15||Gn.ios&&Gn.webkit_version<604;function _r(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=to&&n.selection.ranges.every((t=>t.empty))&&to==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:Ue.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:Ue.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function qr(t,e,i,n){if(1==n)return Ue.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return Ue.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=Re(s.text,r,!1):h=Re(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=Re(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=Re(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return Ue.range(o+s.from,h+s.from)}(t.state,e,i);{let i=os.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,Ue.range(s,r)}}Fr.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Wr.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),Fr.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Fr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Wr.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(zs))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Gr(t,e),n=Qr(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=Gr(t,e),a=qr(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=qr(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?Ue.range(s,r):Ue.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return Ue.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?h:o?s.addRange(a):Ue.create([a])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Vr(t,e,i,n)),n&&t.observer.ignore((()=>An(t.contentDOM)));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let Kr=(t,e)=>t>=e.top&&t<=e.bottom,jr=(t,e,i)=>Kr(e,i)&&t>=i.left&&t<=i.right;function $r(t,e,i,n){let s=os.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&jr(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&jr(i,n,h)?1:o&&Kr(n,o)?-1:1}function Gr(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:$r(t,i,e.clientX,e.clientY)}}const Jr=Gn.ie&&Gn.ie_version<=11;let Ur=null,Yr=0,Xr=0;function Qr(t){if(!Jr)return t.detail;let e=Ur,i=Xr;return Ur=t,Xr=Date.now(),Yr=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Yr+1)%3:1}function Zr(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&function(t,e){let i=t.state.facet(Fs);return i.length?i[0](e):Gn.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Wr.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=Ue.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},Wr.dragend=t=>(t.inputState.draggedContent=null,!1),Wr.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&Zr(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Zr(t,e,i,!0),!0}return!1},Wr.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=zr?null:e.clipboardData;return i?(_r(t,i.getData("text/plain")||i.getData("text/uri-text")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),_r(t,i.value)}),50)}(t),!1)};let to=null;Wr.copy=Wr.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;to=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=zr?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const eo=Mi.define();function io(t,e){let i=[];for(let n of t.facet(js)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:eo.of(!0)}):null}function no(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=io(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Fr.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),no(t)},Fr.blur=t=>{t.observer.clearSelectionRange(),no(t)},Fr.compositionstart=Fr.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},Fr.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Gn.chrome&&Gn.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},Fr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Wr.beforeinput=(t,e)=>{var i;let n;if(Gn.chrome&&Gn.android&&(n=Lr.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return!1};const so=new Set;const ro=["pre-wrap","normal","pre-line","break-spaces"];class oo{constructor(t){this.lineWrapping=t,this.doc=ve.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return ro.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=ro.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class ho{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class lo{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?as.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof ds?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new lo(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var ao=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(ao||(ao={}));const co=.001;class uo{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>co&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return uo.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,ao.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,ao.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,ao.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=vo.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new go(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new mo(uo.of(t.slice(0,e)),r,uo.of(t.slice(i)))}}uo.prototype.size=1;class fo extends uo{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new lo(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class go extends fo{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new lo(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof go||n instanceof po&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof po?n=new go(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):uo.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class po extends uo{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new lo(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new lo(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==ao.ByHeight)return this.blockAt(t,i,n,s);if(e==ao.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new lo(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new lo(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new lo(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof po?i[i.length-1]=new po(t.length+n):i.push(null,new po(n-1))}if(t>0){let e=i[0];e instanceof po?i[0]=new po(t+e.length):i.unshift(new po(t-1),null)}return uo.of(i)}decomposeLeft(t,e){e.push(new po(t-1),null)}decomposeRight(t,e){e.push(null,new po(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new po(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=co&&(o=-2);let h=new go(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new po(s-r).updateHeight(t,r));let h=uo.of(i);return(o<0||Math.abs(h.height-this.height)>=co||Math.abs(o-this.heightMetrics(t,e).perLine)>=co)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class mo extends uo{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==ao.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==ao.ByPosNoHeight?ao.ByPosNoHeight:ao.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,ao.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&wo(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),wo(s,t)}return uo.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?uo.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)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function wo(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof po&&(n=t[e+1])instanceof po&&t.splice(e-1,3,new po(i.length+1+n.length))}class vo{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof go?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new go(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new fo(r,n,i)):(r||s||n>=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new go(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new po(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof go)return t;let e=new go(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof go||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new go(0,-1));let i=t;for(let t of this.nodes)t instanceof go&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new vo(i,t);return ji.spans(e,i,n,s,0),s.finish(i)}}class yo{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&ps(t,e,this.changes,5)}}function bo(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function xo(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class So{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return cs.replace({widget:new ko(this.size*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class ko extends ls{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let 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}get estimatedHeight(){return this.vertical?this.size:-1}}class Ao{constructor(t){this.state=t,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.scrollTop=0,this.scrolledToBottom=!0,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=To,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ys.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(nr).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new oo(e),this.stateDeco=t.facet(sr).filter((t=>"function"!=typeof t)),this.heightMap=uo.empty().applyChanges(this.stateDeco,ve.empty,this.heightOracle.setDoc(t.doc),[new fr(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=cs.set(this.lineGaps.map((t=>t.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new Mo(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?To:new Eo(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:Ro(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(sr).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=fr.extendWithRanges(n,function(t,e,i){let n=new yo;return ji.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:ze.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),l&&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&&!t.state.facet(Gs)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?ys.RTL:ys.LTR;let r=this.heightOracle.mustRefreshForWrapping(s),o=e.getBoundingClientRect(),h=r||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let l=0,a=0;if(o.width&&o.height){let{scaleX:t,scaleY:i}=bn(e,o);this.scaleX==t&&this.scaleY==i||(this.scaleX=t,this.scaleY=i,l|=8,r=h=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==c&&this.paddingBottom==u||(this.paddingTop=c,this.paddingBottom=u,l|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,l|=8);let f=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=f&&(this.scrollAnchorHeight=-1,this.scrollTop=f),this.scrolledToBottom=Dn(t.scrollDOM);let d=(this.printing?xo:bo)(e,this.paddingTop),g=d.top-this.pixelViewport.top,p=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let w=o.width;if(this.contentDOMWidth==w&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,l|=8),h){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(r=!0),r||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:o,textHeight:h}=t.docView.measureTextSize();r=i>0&&n.refresh(s,i,o,h,w/o,e),r&&(t.docView.minWidth=0,l|=8)}g>0&&p>0?a=Math.max(g,p):g<0&&p<0&&(a=Math.min(g,p)),n.heightChanged=!1;for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(r?uo.empty().applyChanges(this.stateDeco,ve.empty,this.heightOracle,[new fr(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,r,new ho(i.from,s))}n.heightChanged&&(l|=2)}let v=!this.viewportIsAppropriate(this.viewport,a)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(a,this.scrollTarget)),this.updateForViewport(),(2&l||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(r?[]:this.lineGaps,t)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new Mo(n.lineAt(r-1e3*i,ao.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),ao.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,ao.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new Mo(n.lineAt(i-500,ao.ByHeight,s,0,0).from,n.lineAt(i+r+500,ao.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Mo(this.heightMap.lineAt(i,ao.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,ao.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,ao.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,ao.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new So(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,r=n<<1;if(this.defaultTextDirection!=ys.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(Ue.cursor(r),!1,!0).head;t>n&&(r=t)}f=new So(n,r,this.gapSize(l,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.length<r)continue;let e=Co(t.from,t.to,this.stateDeco);if(e.total<r)continue;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=Do(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=Oo(e,i),o=Oo(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=Do(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=Oo(e,t),o=Oo(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)}return o}gapSize(t,e,i,n){let s=Do(n,i)-Do(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){So.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=cs.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];ji.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Ro(this.heightMap.lineAt(t,ao.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return Ro(this.heightMap.lineAt(this.scaler.fromDOM(t),ao.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Ro(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Mo{constructor(t,e){this.from=t,this.to=e}}function Co(t,e,i){let n=[],s=t,r=0;return ji.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function Oo({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function Do(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const To={toDOM:t=>t,fromDOM:t=>t,scale:1};class Eo{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,ao.ByPos,t,0,0).top,o=e.lineAt(s,ao.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}}function Ro(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new lo(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>Ro(t,e))):t._content)}const Bo=Qe.define({combine:t=>t.join(" ")}),Po=Qe.define({combine:t=>t.indexOf(!0)>-1}),Lo=hn.newName(),No=hn.newName(),Io=hn.newName(),Ho={"&light":"."+No,"&dark":"."+Io};function Vo(t,e,i){return new hn(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const Wo=Vo("."+Lo,{"&":{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,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},Ho),Fo="";class zo{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(Fi.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Fo}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=Rn.get(n),o=Rn.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:qo(n))||qo(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=Rn.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(_o(t,i.node,i.offset)?e:0))}}function _o(t,e,i){for(;;){if(!e||i<wn(e))return!1;if(e==t)return!0;i=pn(e)+1,e=e.parentNode}}function qo(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class Ko{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class jo{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new Ko(i,n)),s==i&&r==n||e.push(new Ko(s,r)));return e}(t),i=new zo(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?Ue.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!un(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!un(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if(Gn.ios&&t.state.selection.main.empty&&i!=n&&(o.from>0||o.to<t.state.doc.length)){let e=o.from-Math.min(i,n),s=o.to-Math.max(i,n);0!=e&&1!=e||0!=s&&-1!=s||(i=0,n=t.state.doc.length)}this.newSel=Ue.single(n,i)}}}function $o(t,e){let i,{newSel:n}=e,s=t.state.selection.main,r=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:o}=e.bounds,h=s.from,l=null;(8===r||Gn.android&&e.text.length<o-n)&&(h=s.to,l="end");let a=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(n,o,Fo),e.text,h-n,l);a&&(Gn.chrome&&13==r&&a.toB==a.from+2&&e.text.slice(a.from,a.toB)==Fo+Fo&&a.toB--,i={from:n+a.from,to:n+a.toA,insert:ve.of(e.text.slice(a.from,a.toB).split(Fo))})}else n&&(!t.hasFocus&&t.state.facet(Xs)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:(Gn.mac||Gn.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=Ue.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:ve.of([" "])}):Gn.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=Ue.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:ve.of([" "])}),i){if(Gn.ios&&t.inputState.flushIOSKey())return!0;if(Gn.android&&(i.from==s.from&&i.to==s.to&&1==i.insert.length&&2==i.insert.lines&&Cn(t.contentDOM,"Enter",13)||(i.from==s.from-1&&i.to==s.to&&0==i.insert.length||8==r&&i.insert.length<i.to-i.from&&i.to>s.head)&&Cn(t.contentDOM,"Backspace",8)||i.from==s.from&&i.to==s.to+1&&0==i.insert.length&&Cn(t.contentDOM,"Delete",46)))return!0;let e,o=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>e||(e=function(t,e,i){let n,s=t.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.from<e.from?s.sliceDoc(r.from,e.from):"",o=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=s.changes(e),h=i&&i.main.to<=o.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let l,a=t.state.sliceDoc(e.from,e.to),c=i&&mr(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-t}}else l=t.state.doc.lineAt(r.head);let u=r.to-e.to,f=r.to-r.from;n=s.changeByRange((i=>{if(i.from==r.from&&i.to==r.to)return{changes:o,range:h||i.map(o)};let n=i.to-u,c=n-a.length;if(i.to-i.from!=f||t.state.sliceDoc(c,n)!=a||i.to>=l.from&&i.from<=l.to)return{range:i};let d=s.changes({from:c,to:n,insert:e.insert}),g=i.to-r.to;return{changes:d,range:h?Ue.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):i.map(d)}}))}else n={changes:o,selection:h&&s.selection.replaceRange(h)}}let o="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:o,scrollIntoView:!0})}(t,i,n));return t.state.facet(Ks).some((e=>e(t,i.from,i.to,o,h)))||t.dispatch(h()),!0}if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}const Go={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Jo=Gn.ie&&Gn.ie_version<=11;class Uo{constructor(t){this.view=t,this.active=!1,this.selectionRange=new xn,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(Gn.ie&&Gn.ie_version<=11||Gn.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Jo&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Xs)?i.root.activeElement!=this.dom:!fn(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(Gn.ie&&Gn.ie_version<=11||Gn.android&&Gn.chrome)&&!i.state.selection.main.empty&&n.focusNode&&gn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Gn.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);gn(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||cn(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=fn(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,wn(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=wn(i))}else{if(i==t)return!0;n=pn(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Go),Jo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Jo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Cn(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&fn(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new jo(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=$o(this.view,e);return this.view.state==i&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=Yo(e,t.previousSibling||t.target.previousSibling,-1),n=Yo(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function Yo(t,e,i){for(;e;){let n=Rn.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}class Xo{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new Ao(t.state||Fi.create(t)),t.scrollTo&&t.scrollTo.is(Us)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Zs).map((t=>new er(t)));for(let t of this.plugins)t.update(this);this.observer=new Uo(this),this.inputState=new Br(this),this.inputState.ensureHandlers(this.plugins),this.docView=new gr(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof Ti?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(eo)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=io(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(Fi.phrases)!=this.state.facet(Fi.phrases))return this.setState(s);e=dr.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new Js(t.empty?t:Ue.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Us)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=th.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(ur)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(Bo)!=e.state.facet(Bo)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(qs))try{t(e)}catch(t){Ys(this.state,t,"update listener")}(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!$o(this,a)&&l.force&&Cn(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new Ao(t),this.plugins=t.facet(Zs).map((t=>new er(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new gr(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Zs),i=t.state.facet(Zs);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new er(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(Dn(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];4&o||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map((t=>{try{return t.read(this)}catch(t){return Ys(this.state,t),Zo}})),a=dr.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),c=this.docView.update(a));for(let t=0;t<h.length;t++)if(l[t]!=Zo)try{let e=h[t];e.write&&e.write(l[t],this)}catch(t){Ys(this.state,t)}if(c&&this.docView.updateSelection(!0),!a.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(qs))t(e)}get themeClasses(){return Lo+" "+(this.state.facet(Po)?Io:No)+" "+this.state.facet(Bo)}updateAttrs(){let t=eh(this,ir,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Xs)?"true":"false",class:"cm-content",style:`${Gn.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),eh(this,nr,e);let i=this.observer.ignore((()=>{let i=ss(this.contentDOM,this.contentAttrs,e),n=ss(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Xo.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(ur);let t=this.state.facet(Xo.cspNonce);hn.mount(this.root,this.styleModules.concat(Wo).reverse(),t?{nonce:t}:void 0)}readMeasured(){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)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Rr(this,t,Tr(this,t,e,i))}moveByGroup(t,e){return Rr(this,t,Tr(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==Ii.Space&&(s=e),s==e}}(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return Ue.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=Dr(t,e.head),r=n&&s.type==as.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==ys.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return Ue.cursor(o,i?-1:1)}return Ue.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Rr(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return Ue.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s,e.assoc||-1),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(f+e)*r,n=Cr(t,{x:u,y:i},!1,r);if(i<l.top||i>l.bottom||(r<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return Ue.cursor(n,s,void 0,h)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Cr(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return vn(i,s[Ts.find(s,t-n.from,-1,e)].dir==ys.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet($s)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Qo)return Ns(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||Es(n.isolates,e=lr(this,t))))return n.order;e||(e=lr(this,t));let n=Ls(t.text,i,e);return this.bidiCache.push(new th(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Gn.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{An(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Us.of(new Js("number"==typeof t?Ue.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Us.of(new Js(Ue.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return tr.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return tr.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=hn.newName(),n=[Bo.of(i),ur.of(Vo(`.${i}`,t))];return e&&e.dark&&n.push(Po.of(!0)),n}static baseTheme(t){return ui.lowest(ur.of(Vo("."+Lo,t,Ho)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Rn.get(i)||Rn.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Xo.styleModule=ur,Xo.inputHandler=Ks,Xo.focusChangeEffect=js,Xo.perLineTextDirection=$s,Xo.exceptionSink=_s,Xo.updateListener=qs,Xo.editable=Xs,Xo.mouseSelectionStyle=zs,Xo.dragMovesSelection=Fs,Xo.clickAddsSelectionRange=Ws,Xo.decorations=sr,Xo.outerDecorations=rr,Xo.atomicRanges=or,Xo.bidiIsolatedRanges=hr,Xo.scrollMargins=ar,Xo.darkTheme=Po,Xo.cspNonce=Qe.define({combine:t=>t.length?t[0]:""}),Xo.contentAttributes=nr,Xo.editorAttributes=ir,Xo.lineWrapping=Xo.contentAttributes.of({class:"cm-lineWrapping"}),Xo.announce=Di.define();const Qo=4096,Zo={};class th{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:ys.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new th(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function eh(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&es(r,i)}return i}const ih=!Gn.ios;const nh={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};ih&&(nh[".cm-line"].caretColor="transparent !important",nh[".cm-content"]={caretColor:"transparent !important"});class sh extends zi{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}sh.prototype.elementClass="",sh.prototype.toDOM=void 0,sh.prototype.mapMode=We.TrackBefore,sh.prototype.startSide=sh.prototype.endSide=-1,sh.prototype.point=!0;const rh=Qe.define(),oh={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>ji.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},hh=Qe.define();function lh(t){return[ch(),hh.of(Object.assign(Object.assign({},oh),t))]}const ah=Qe.define({combine:t=>t.some((t=>t))});function ch(t){let e=[uh];return t&&!1===t.fixed&&e.push(ah.of(!0)),e}const uh=tr.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(hh).map((e=>new ph(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(ah),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(ah)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=ji.iter(this.view.state.facet(rh),this.view.viewport.from),n=[],s=this.gutters.map((t=>new gh(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let r of t.type)if(r.type==as.Text&&e){dh(i,n,r.from);for(let t of s)t.line(this.view,r,n);e=!1}else if(r.widget)for(let t of s)t.widget(this.view,r)}else if(t.type==as.Text){dh(i,n,t.from);for(let e of s)e.line(this.view,t,n)}else if(t.widget)for(let e of s)e.widget(this.view,t);for(let t of s)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(hh),i=t.state.facet(hh),n=t.docChanged||t.heightChanged||t.viewportChanged||!ji.eq(t.startState.facet(rh),t.state.facet(rh),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new ph(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>Xo.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==ys.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function fh(t){return Array.isArray(t)?t:[t]}function dh(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class gh{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=ji.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,r=e.height/t.scaleY;if(this.i==n.elements.length){let e=new mh(t,r,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,r,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];dh(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let r=this.gutter;(0!=n.length||r.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[i])}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class ph{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(n=>{let s,r=n.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=fh(e.markers(t)),e.initialSpacer&&(this.spacer=new mh(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=fh(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!ji.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class mh{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,r=0;;){let o=r,h=s<e.length?e[s++]:null,l=!1;if(h){let t=h.elementClass;t&&(i+=" "+t);for(let t=r;t<this.markers.length;t++)if(this.markers[t].compare(h)){o=t,l=!0;break}}else o=this.markers.length;for(;r<o;){let t=this.markers[r++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!h)break;h.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(h.toDOM(t),n)),l&&r++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}i("88972");const wh=1024;let vh=0;class yh{constructor(t={}){this.id=vh++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=xh.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}yh.closedBy=new yh({deserialize:t=>t.split(" ")}),yh.openedBy=new yh({deserialize:t=>t.split(" ")}),yh.group=new yh({deserialize:t=>t.split(" ")}),yh.contextHash=new yh({perNode:!0}),yh.lookAhead=new yh({perNode:!0}),yh.mounted=new yh({perNode:!0});const bh=Object.create(null);class xh{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):bh,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new xh(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(yh.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(yh.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}xh.none=new xh("",Object.create(null),0,8);const Sh=new WeakMap,kh=new WeakMap;var Ah;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(Ah||(Ah={}));class Mh{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(yh.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new Ih(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Sh.get(this)||this.topNode,s=new Ih(n);return s.moveTo(t,e),Sh.set(this,s._tree),s}get topNode(){return new Rh(this,0,0,null)}resolve(t,e=0){let i=Eh(Sh.get(this)||this.topNode,t,e,!1);return Sh.set(this,i),i}resolveInner(t,e=0){let i=Eh(kh.get(this)||this.topNode,t,e,!0);return kh.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&Ah.IncludeAnonymous)>0;for(let t=this.cursor(r|Ah.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:Fh(xh.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new Mh(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new Mh(xh.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=wh,reused:r=[],minRepeatType:o=n.types.length}=t,h=Array.isArray(i)?new Ch(i,i.length):i,l=n.types,a=0,c=0;function u(t,e,i,w,v){let{id:y,start:b,end:x,size:S}=h,k=c;for(;S<0;){if(h.next(),-1==S){let e=r[y];return i.push(e),void w.push(b-t)}if(-3==S)return void(a=y);if(-4==S)return void(c=y);throw new RangeError(`Unrecognized record size: ${S}`)}let A,M,C=l[y],O=b-t;if(x-b<=s&&(M=p(h.pos-e,v))){let e=new Uint16Array(M.size-M.skip),i=h.pos-M.size,s=e.length;for(;h.pos>i;)s=m(M.start,e,s);A=new Oh(e,x-M.start,n),O=M.start-t}else{let t=h.pos-S;h.next();let e=[],i=[],n=y>=o?y:-1,r=0,l=x;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=l-s&&(d(e,i,b,r,h.end,l,n,k),r=e.length,l=h.end),h.next()):u(b,t,e,i,n);if(n>=0&&r>0&&r<e.length&&d(e,i,b,r,b,l,n,k),e.reverse(),i.reverse(),n>-1&&r>0){let t=f(C);A=Fh(C,e,i,0,e.length,0,x-b,t,t)}else A=g(C,e,i,x-b,k-x)}i.push(A),w.push(O)}function f(t){return(e,i,n)=>{let s,r,o=0,h=e.length-1;if(h>=0&&(s=e[h])instanceof Mh){if(!h&&s.type==t&&s.length==n)return s;(r=s.prop(yh.lookAhead))&&(o=i[h]+s.length+r)}return g(t,e,i,n,o)}}function d(t,e,i,s,r,o,h,l){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(g(n.types[h],a,c,o-r,l-o)),e.push(r-i)}function g(t,e,i,n,s=0,r){if(a){let t=[yh.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[yh.lookAhead,s];r=r?[t].concat(r):[t]}return new Mh(t,e,i,n,r)}function p(t,e){let i=h.fork(),n=0,r=0,l=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=l,l+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<s||i.start<a)break;let u=i.id>=o?4:0,f=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,l+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=l),c.size>4?c:void 0}function m(t,e,i){let{id:n,start:s,end:r,size:l}=h;if(h.next(),l>=0&&n<o){let o=i;if(l>4){let n=h.pos-(l-4);for(;h.pos>n;)i=m(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==l?a=n:-4==l&&(c=n);return i}let w=[],v=[];for(;h.pos>0;)u(t.start||0,t.bufferStart||0,w,v,-1);let y=null!==(e=t.length)&&void 0!==e?e:w.length?v[0]+w[0].length:0;return new Mh(l[t.topID],w.reverse(),v.reverse(),y)}(t)}}Mh.empty=new Mh(xh.none,[],[],0);class Ch{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Ch(this.buffer,this.index)}}class Oh{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return xh.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return s+"("+r.join(",")+")"}findChild(t,e,i,n,s){let{buffer:r}=this,o=-1;for(let h=t;h!=e&&!(Dh(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new Oh(s,r,this.set)}}function Dh(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Th(t,e){let i=t.childBefore(e);for(;i;){let e=i.lastChild;if(!e||e.to!=i.to)break;e.type.isError&&e.from==e.to?(t=i,i=e.prevSibling):i=e}return t}function Eh(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof Rh&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:Ah.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof Rh&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class Rh{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:o,positions:h}=r._tree,l=e>0?o.length:-1;t!=l;t+=e){let l=o[t],a=h[t]+r.from;if(Dh(n,i,a,a+l.length))if(l instanceof Oh){if(s&Ah.ExcludeBuffers)continue;let o=l.findChild(0,l.buffer.length,e,i-a,n);if(o>-1)return new Nh(new Lh(r,l,t,a),null,o)}else if(s&Ah.IncludeAnonymous||!l.type.isAnonymous||Hh(l)){let o;if(!(s&Ah.IgnoreMounts)&&l.props&&(o=l.prop(yh.mounted))&&!o.overlay)return new Rh(o.tree,a,t,r);let h=new Rh(l,a,t,r);return s&Ah.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(e<0?l.children.length-1:0,e,i,n)}}if(s&Ah.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&Ah.IgnoreOverlays)&&(n=this._tree.prop(yh.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new Rh(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(t=0){return new Ih(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return Eh(this,t,e,!1)}resolveInner(t,e=0){return Eh(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Th(this,t)}getChild(t,e=null,i=null){let n=Bh(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Bh(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return Ph(this,t)}}function Bh(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!s.type.is(i);)if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function Ph(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class Lh{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Nh{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new Nh(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&Ah.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new Nh(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Nh(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new Nh(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new Ih(this,t)}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new Mh(this.type,t,e,this.to-this.from)}resolve(t,e=0){return Eh(this,t,e,!1)}resolveInner(t,e=0){return Eh(this,t,e,!0)}enterUnfinishedNodesBefore(t){return Th(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=Bh(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Bh(this,t,e,i)}get node(){return this}matchContext(t){return Ph(this,t)}}class Ih{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Rh)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof Rh?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&Ah.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ah.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Ah.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(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));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&Ah.IncludeAnonymous||t instanceof Oh||!t.type.isAnonymous||Hh(t))return!1}return!0}move(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}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(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}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new Nh(this.buffer,e,this.stack[t]);return this.bufferNode=new Nh(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return Ph(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return Ph(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function Hh(t){return t.children.some((t=>t instanceof Oh||!t.type.isAnonymous||Hh(t)))}const Vh=new WeakMap;function Wh(t,e){if(!t.isAnonymous||e instanceof Oh||e.type!=t)return 1;let i=Vh.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Mh)){i=1;break}i+=Wh(t,n)}Vh.set(e,i)}return i}function Fh(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=Wh(t,e[i]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=Wh(t,i[a]);for(a++;a<o;a++){let e=Wh(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(Fh(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}new yh({perNode:!0});let zh=0;class _h{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=zh++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new _h([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new Kh;return e=>e.modified.indexOf(t)>-1?e:Kh.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let qh=0;class Kh{constructor(){this.instances=[],this.id=qh++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new _h(n,t,e);for(let t of e)t.instances.push(s);let r=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of r)n.push(Kh.get(e,t));return s}}function jh(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let o=t[e++];if(e==t.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,h=i[o];if(!h)throw new RangeError("Invalid path: "+t);let l=new Gh(n,s,o>0?i.slice(0,o):null);e[h]=l.sort(e[h])}}return $h.add(e)}const $h=new yh;class Gh{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function Jh(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function Uh(t,e,i,n=0,s=t.length){let r=new Yh(n,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),n,s,"",r.highlighters),r.flush(s)}Gh.empty=new Gh([],2,null);class Yh{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:r,from:o,to:h}=t;if(o>=i||h<=e)return;r.isTop&&(s=this.highlighters.filter((t=>!t.scope||t.scope(r))));let l=n,a=function(t){let e=t.type.prop($h);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Gh.empty,c=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(s,a.tags);if(c&&(l&&(l+=" "),l+=c,1==a.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(e,o),l),a.opaque)return;let u=t.tree&&t.tree.prop(yh.mounted);if(u&&u.overlay){let r=t.node.enter(u.overlay[0].from+o,1),a=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),c=t.firstChild();for(let f=0,d=o;;f++){let g=f<u.overlay.length?u.overlay[f]:null,p=g?g.from+o:h,m=Math.max(e,d),w=Math.min(i,p);if(m<w&&c)for(;t.from<w&&(this.highlightRange(t,m,w,n,s),this.startSpan(Math.min(w,t.to),l),!(t.to>=p)&&t.nextSibling()););if(!g||p>i)break;d=g.to+o,d>e&&(this.highlightRange(r.cursor(),Math.max(e,g.from+o),Math.min(i,d),"",a),this.startSpan(Math.min(i,d),l))}c&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),l)}}while(t.nextSibling());t.parent()}}}const Xh=_h.define,Qh=Xh(),Zh=Xh(),tl=Xh(Zh),el=Xh(Zh),il=Xh(),nl=Xh(il),sl=Xh(il),rl=Xh(),ol=Xh(rl),hl=Xh(),ll=Xh(),al=Xh(),cl=Xh(al),ul=Xh(),fl={comment:Qh,lineComment:Xh(Qh),blockComment:Xh(Qh),docComment:Xh(Qh),name:Zh,variableName:Xh(Zh),typeName:tl,tagName:Xh(tl),propertyName:el,attributeName:Xh(el),className:Xh(Zh),labelName:Xh(Zh),namespace:Xh(Zh),macroName:Xh(Zh),literal:il,string:nl,docString:Xh(nl),character:Xh(nl),attributeValue:Xh(nl),number:sl,integer:Xh(sl),float:Xh(sl),bool:Xh(il),regexp:Xh(il),escape:Xh(il),color:Xh(il),url:Xh(il),keyword:hl,self:Xh(hl),null:Xh(hl),atom:Xh(hl),unit:Xh(hl),modifier:Xh(hl),operatorKeyword:Xh(hl),controlKeyword:Xh(hl),definitionKeyword:Xh(hl),moduleKeyword:Xh(hl),operator:ll,derefOperator:Xh(ll),arithmeticOperator:Xh(ll),logicOperator:Xh(ll),bitwiseOperator:Xh(ll),compareOperator:Xh(ll),updateOperator:Xh(ll),definitionOperator:Xh(ll),typeOperator:Xh(ll),controlOperator:Xh(ll),punctuation:al,separator:Xh(al),bracket:cl,angleBracket:Xh(cl),squareBracket:Xh(cl),paren:Xh(cl),brace:Xh(cl),content:rl,heading:ol,heading1:Xh(ol),heading2:Xh(ol),heading3:Xh(ol),heading4:Xh(ol),heading5:Xh(ol),heading6:Xh(ol),contentSeparator:Xh(rl),list:Xh(rl),quote:Xh(rl),emphasis:Xh(rl),strong:Xh(rl),link:Xh(rl),monospace:Xh(rl),strikethrough:Xh(rl),inserted:Xh(),deleted:Xh(),changed:Xh(),invalid:Xh(),meta:ul,documentMeta:Xh(ul),annotation:Xh(ul),processingInstruction:Xh(ul),definition:_h.defineModifier(),constant:_h.defineModifier(),function:_h.defineModifier(),standard:_h.defineModifier(),local:_h.defineModifier(),special:_h.defineModifier()};Jh([{tag:fl.link,class:"tok-link"},{tag:fl.heading,class:"tok-heading"},{tag:fl.emphasis,class:"tok-emphasis"},{tag:fl.strong,class:"tok-strong"},{tag:fl.keyword,class:"tok-keyword"},{tag:fl.atom,class:"tok-atom"},{tag:fl.bool,class:"tok-bool"},{tag:fl.url,class:"tok-url"},{tag:fl.labelName,class:"tok-labelName"},{tag:fl.inserted,class:"tok-inserted"},{tag:fl.deleted,class:"tok-deleted"},{tag:fl.literal,class:"tok-literal"},{tag:fl.string,class:"tok-string"},{tag:fl.number,class:"tok-number"},{tag:[fl.regexp,fl.escape,fl.special(fl.string)],class:"tok-string2"},{tag:fl.variableName,class:"tok-variableName"},{tag:fl.local(fl.variableName),class:"tok-variableName tok-local"},{tag:fl.definition(fl.variableName),class:"tok-variableName tok-definition"},{tag:fl.special(fl.variableName),class:"tok-variableName2"},{tag:fl.definition(fl.propertyName),class:"tok-propertyName tok-definition"},{tag:fl.typeName,class:"tok-typeName"},{tag:fl.namespace,class:"tok-namespace"},{tag:fl.className,class:"tok-className"},{tag:fl.macroName,class:"tok-macroName"},{tag:fl.propertyName,class:"tok-propertyName"},{tag:fl.operator,class:"tok-operator"},{tag:fl.comment,class:"tok-comment"},{tag:fl.meta,class:"tok-meta"},{tag:fl.invalid,class:"tok-invalid"},{tag:fl.punctuation,class:"tok-punctuation"}]);var dl,gl=i("29933");const pl=new o;function ml(t){return pt.define({combine:t?e=>e.concat(t):void 0})}const wl=new o;class vl{constructor(t,e,i=[],n=""){this.data=t,this.name=n,ee.prototype.hasOwnProperty("tree")||Object.defineProperty(ee.prototype,"tree",{get(){return bl(this)}}),this.parser=e,this.extension=[Tl.of(this),ee.languageData.of(((t,e,i)=>{let n=yl(t,e,i),s=n.type.prop(pl);if(!s)return[];let r=t.facet(s),o=n.type.prop(wl);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return yl(t,e,i).type.prop(pl)==this.data}findRegions(t){let e=t.facet(Tl);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop(pl)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(o.mounted);if(s){if(s.tree.prop(pl)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof p&&n(s,t.positions[i]+e)}};return n(bl(t),0),i}get allowsNesting(){return!0}}function yl(t,e,i){let n=t.facet(Tl),s=bl(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,d.ExcludeBuffers))t.type.isTop&&(s=t);return s}vl.setState=qt.define();function bl(t){let e=t.field(vl.state,!1);return e?e.tree:p.empty}class xl{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Sl=null;class kl{constructor(t,e,i=[],n,s,r,o,h){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new kl(t,e,[],p.empty,0,i,[],null)}startParse(){return this.parser.startParse(new xl(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=p.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(P.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}}))}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext((()=>{for(;!(e=this.parse.advance()););})),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(P.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Sl;Sl=this;try{return t()}finally{Sl=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Al(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s}))),i=P.applyChanges(i,e),n=p.empty,s=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&o.push({from:i,to:n})}}}return new kl(this.parser,e,i,n,s,r,o,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=Al(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends L{createParse(e,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let e=Sl;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=r,new p(a.none,[],[],r-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return Sl}}function Al(t,e,i){return P.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Ml{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new Ml(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=kl.create(t.facet(Tl).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Ml(i)}}vl.state=St.define({create:Ml.init,update(t,e){for(let t of e.effects)if(t.is(vl.setState))return t.value;return e.startState.facet(Tl)!=e.state.facet(Tl)?Ml.init(e.state):t.apply(e)}});let Cl=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Cl=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Ol="undefined"!=typeof navigator&&(null===(dl=navigator.scheduling)||void 0===dl?void 0:dl.isInputPending)?()=>navigator.scheduling.isInputPending():null,Dl=tr.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(vl.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(vl.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Cl(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(vl.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let r=Date.now()+Math.min(this.chunkBudget,100,t&&!Ol?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<n&&i.doc.length>n+1e3,h=s.context.work((()=>Ol&&Ol()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:vl.setState.of(new Ml(s.context))})),this.chunkBudget>0&&(!h||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>Ys(this.view.state,t))).then((()=>this.workScheduled--)),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Tl=pt.define({combine:t=>t.length?t[0]:null,enables:t=>[vl.state,Dl,Xo.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const El=pt.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some((t=>t!=e[0])))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Rl(t){let e=t.facet(El);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}const Bl=new o;const Pl=pt.define(),Ll=new o;function Nl(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Il(t,e,i){for(let n of t.facet(Pl)){let s=n(t,e,i);if(s)return s}return function(t,e,i){let n=bl(t);if(n.length<i)return null;let s=null;for(let r=n.resolveStack(i,1);r;r=r.next){let o=r.node;if(o.to<=i||o.from>i)continue;if(s&&o.from<e)break;let h=o.type.prop(Ll);if(h&&(o.to<n.length-50||n.length==t.doc.length||!Nl(o))){let n=h(o,t);n&&n.from<=i&&n.from>=e&&n.to>i&&(s=n)}}return s}(t,e,i)}function Hl(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}const Vl=qt.define({map:Hl}),Wl=qt.define({map:Hl});const Fl=St.define({create:()=>cs.none,update(t,e){t=t.map(e.changes);for(let i of e.effects)if(i.is(Vl)&&!_l(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(Kl),s=n?cs.replace({widget:new Jl(n(e.state,i.value))}):Gl;t=t.update({add:[s.range(i.value.from,i.value.to)]})}else i.is(Wl)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));if(e.selection){let i=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{t<n&&e>n&&(i=!0)})),i&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}return t},provide:t=>Xo.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,((t,e)=>{i.push(t,e)})),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let n=t[i++],s=t[i++];if("number"!=typeof n||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");e.push(Gl.range(n,s))}return cs.set(e,!0)}});function zl(t,e,i){var n;let s=null;return null===(n=t.field(Fl,!1))||void 0===n||n.between(e,i,((t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})})),s}function _l(t,e,i){let n=!1;return t.between(e,e,((t,s)=>{t==e&&s==i&&(n=!0)})),n}const ql={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Kl=pt.define({combine:t=>function(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}(t,ql)});function jl(t){let e=[Fl,Ql];return t&&e.push(Kl.of(t)),e}function $l(t,e){let{state:i}=t,n=i.facet(Kl),s=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=zl(t.state,i.from,i.to);n&&t.dispatch({effects:Wl.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,s,e);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",i.phrase("folded code")),r.title=i.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const Gl=cs.replace({widget:new class extends ls{toDOM(t){return $l(t,null)}}});class Jl extends ls{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return $l(t,this.value)}}const Ul={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Yl extends sh{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let 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}}function Xl(t={}){let e=Object.assign(Object.assign({},Ul),t),i=new Yl(e,!0),n=new Yl(e,!1),s=tr.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(Tl)!=t.state.facet(Tl)||t.startState.field(Fl,!1)!=t.state.field(Fl,!1)||bl(t.startState)!=bl(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new he;for(let s of t.viewportLineBlocks){let r=zl(t.state,s.from,s.to)?n:Il(t.state,s.from,s.to)?i:null;r&&e.add(s.from,s.from,r)}return e.finish()}}),{domEventHandlers:r}=e;return[s,lh({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.markers)||oe.empty},initialSpacer:()=>new Yl(e,!1),domEventHandlers:Object.assign(Object.assign({},r),{click:(t,e,i)=>{if(r.click&&r.click(t,e,i))return!0;let n=zl(t.state,e.from,e.to);if(n)return t.dispatch({effects:Wl.of(n)}),!0;let s=Il(t.state,e.from,e.to);return!!s&&(t.dispatch({effects:Vl.of(s)}),!0)}})}),jl()]}const Ql=Xo.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"}});class Zl{constructor(t,e){let i;function n(t){let e=gl.V.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,r=e.scope;this.scope=r instanceof vl?t=>t.prop(pl)==r.data:r?t=>t==r:void 0,this.style=Jh(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new gl.V(i):null,this.themeType=e.themeType}static define(t,e){return new Zl(t,e||{})}}const ta=pt.define(),ea=pt.define({combine:t=>t.length?[t[0]]:null});function ia(t){let e=t.facet(ta);return e.length?e:t.facet(ea)}function na(t,e){let i,n=[oa];return t instanceof Zl&&(t.module&&n.push(Xo.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(ea.of(t)):i?n.push(ta.computeN([Xo.darkTheme],(e=>e.facet(Xo.darkTheme)==("dark"==i)?[t]:[]))):n.push(ta.of(t)),n}function sa(t,e,i){let n=ia(t),s=null;if(n)for(let t of n)if(!t.scope||i&&t.scope(i)){let i=t.style(e);i&&(s=s?s+" "+i:i)}return s}class ra{constructor(t){this.markCache=Object.create(null),this.tree=bl(t.state),this.decorations=this.buildDeco(t,ia(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=bl(t.state),i=ia(t.state),n=i!=ia(t.startState),{viewport:s}=t.view,r=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&r>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=r):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return cs.none;let i=new he;for(let{from:n,to:s}of t.visibleRanges)Uh(this.tree,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=cs.mark({class:n})))}),n,s);return i.finish()}}const oa=Ct(tr.fromClass(ra,{decorations:t=>t.decorations}));fl.meta,fl.link,fl.heading,fl.emphasis,fl.strong,fl.strikethrough,fl.keyword,fl.atom,fl.bool,fl.url,fl.contentSeparator,fl.labelName,fl.literal,fl.inserted,fl.string,fl.deleted,fl.regexp,fl.escape,fl.string,fl.variableName,fl.variableName,fl.typeName,fl.namespace,fl.className,fl.variableName,fl.macroName,fl.propertyName,fl.comment,fl.invalid;function ha(t,e,i,n=0,s=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let r=s;for(let s=n;s<e;s++)9==t.charCodeAt(s)?r+=i-r%i:r++;return r}class la{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ha(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:ha(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let n=t=>i?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function aa(t){if("object"!=typeof t)return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const ca=new WeakMap;class ua extends vl{constructor(t){let e,i=ml(t.languageData),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||aa,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||ma};var s;super(i,new class extends L{createParse(t,i,n){return new ga(e,t,i,n)}},[],t.name),this.topNode=function(t,e){let i=a.define({id:wa.length,name:"Document",props:[pl.add((()=>t)),Bl.add((()=>t=>e.getIndent(t)))],top:!0});return wa.push(i),i}(i,this),e=this,this.streamParser=n,this.stateAfter=new o({perNode:!0}),this.tokenTable=t.tokenTable?new Sa(n.tokenTable):ka}static define(t){return new ua(t)}getIndent(t){let e,{overrideIndentation:i}=t.options;i&&(e=ca.get(t.state),null!=e&&e<t.pos-1e4&&(e=void 0));let n,s,r=fa(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos);if(r?(s=r.state,n=r.pos+1):(s=this.streamParser.startState(t.unit),n=t.node.from),t.pos-n>1e4)return null;for(;n<t.pos;){let e=t.state.doc.lineAt(n),r=Math.min(t.pos,e.to);if(e.length){let n=i?i(e.from):-1,o=new la(e.text,t.state.tabSize,t.unit,n<0?void 0:n);for(;o.pos<r-e.from;)pa(this.streamParser.token,o,s)}else this.streamParser.blankLine(s,t.unit);if(r==t.pos)break;n=e.to+1}let o=t.lineAt(t.pos);return i&&null==e&&ca.set(t.state,o.from),this.streamParser.indent(s,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function fa(t,e,i,n,s){let r=i>=n&&i+e.length<=s&&e.prop(t.stateAfter);if(r)return{state:t.streamParser.copyState(r),pos:i+e.length};for(let r=e.children.length-1;r>=0;r--){let o=e.children[r],h=i+e.positions[r],l=o instanceof p&&h<s&&fa(t,o,h,n,s);if(l)return l}return null}function da(t,e,i,n,s){if(s&&i<=0&&n>=e.length)return e;s||0!=i||e.type!=t.topNode||(s=!0);for(let r=e.children.length-1;r>=0;r--){let o,h=e.positions[r],l=e.children[r];if(h<n&&l instanceof p){if(!(o=da(t,l,i-h,n-h,s)))break;return s?new p(e.type,e.children.slice(0,r).concat(o),e.positions.slice(0,r+1),h+o.length):o}}return null}class ga{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let s=kl.get(),r=n[0].from,{state:o,tree:h}=function(t,e,i,n,s){for(let s of e){let e,r=s.from+(s.openStart?25:0),o=s.to-(s.openEnd?25:0),h=r<=i&&o>i&&fa(t,s.tree,0-s.offset,i,o);if(h&&h.pos<=n&&(e=da(t,s.tree,i+s.offset,h.pos+s.offset,!1)))return{state:h.state,tree:e}}return{state:t.streamParser.startState(s?Rl(s):4),tree:p.empty}}(t,i,r,this.to,null==s?void 0:s.state);this.state=o,this.parsedPos=this.chunkStart=r+h.length;for(let t=0;t<h.children.length;t++)this.chunks.push(h.children[t]),this.chunkPos.push(h.positions[t]);s&&this.parsedPos<s.viewport.from-1e5&&n.some((t=>t.from<=s.viewport.from&&t.to>=s.viewport.from))&&(this.state=this.lang.streamParser.startState(Rl(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=kl.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+2048);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=i)break;if(e=e.slice(0,n-(i-e.length)),t++,t==this.ranges.length)break;let s=this.ranges[t].from,r=this.lineAfter(s);e+=r,i=s+r.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,s=t+e;if(i>0?n>s:n>=s)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n){let s=4;if(this.ranges.length>1){e+=n=this.skipGapsTo(e,n,1);let t=this.chunk.length;i+=n=this.skipGapsTo(i,n,-1),s+=this.chunk.length-t}let r=this.chunk.length-4;return 4==s&&r>=0&&this.chunk[r]==t&&this.chunk[r+2]==e?this.chunk[r+2]=i:this.chunk.push(t,e,i,s),n}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,r=new la(e,t?t.state.tabSize:4,t?Rl(t.state):2);if(r.eol())s.blankLine(this.state,r.indentUnit);else for(;!r.eol();){let t=pa(s.token,r,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+r.start,this.parsedPos+r.pos,n)),r.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=p.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:va,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new p(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new p(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function pa(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,i);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const ma=Object.create(null),wa=[a.none],va=new c(wa),ya=[],ba=Object.create(null),xa=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])xa[t]=Ma(ma,e);class Sa{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),xa)}resolve(t){return t?this.table[t]||(this.table[t]=Ma(this.extra,t)):0}}const ka=new Sa(ma);function Aa(t,e){ya.indexOf(t)>-1||(ya.push(t),console.warn(e))}function Ma(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||fl[i];n?"function"==typeof n?e.length?e=e.map(n):Aa(i,`Modifier ${i} used at start of tag`):e.length?Aa(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:Aa(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+i.map((t=>t.id)),r=ba[s];if(r)return r.id;let o=ba[s]=a.define({id:wa.length,name:n,props:[jh({[n]:i})]});return wa.push(o),o.id}ys.RTL,ys.LTR},3191:function(t,e,i){i.d(e,{b:function(){return a}});var n=["and","as","block","endblock","by","cycle","debug","else","elif","extends","filter","endfilter","firstof","do","for","endfor","if","endif","ifchanged","endifchanged","ifequal","endifequal","ifnotequal","set","raw","endraw","endifnotequal","in","include","load","not","now","or","parsed","regroup","reversed","spaceless","call","endcall","macro","endmacro","endspaceless","ssi","templatetag","openblock","closeblock","openvariable","closevariable","without","context","openbrace","closebrace","opencomment","closecomment","widthratio","url","with","endwith","get_current_language","trans","endtrans","noop","blocktrans","endblocktrans","get_available_languages","get_current_language_bidi","pluralize","autoescape","endautoescape"],s=/^[+\-*&%=<>!?|~^]/,r=/^[:\[\(\{]/,o=["true","false"],h=/^(\d[+\-\*\/])?\d+(\.\d+)?/;function l(t,e){var i=t.peek();if(e.incomment)return t.skipTo("#}")?(t.eatWhile(/\#|}/),e.incomment=!1):t.skipToEnd(),"comment";if(e.intag){if(e.operator){if(e.operator=!1,t.match(o))return"atom";if(t.match(h))return"number"}if(e.sign){if(e.sign=!1,t.match(o))return"atom";if(t.match(h))return"number"}if(e.instring)return i==e.instring&&(e.instring=!1),t.next(),"string";if("'"==i||'"'==i)return e.instring=i,t.next(),"string";if(e.inbraces>0&&")"==i)t.next(),e.inbraces--;else if("("==i)t.next(),e.inbraces++;else if(e.inbrackets>0&&"]"==i)t.next(),e.inbrackets--;else if("["==i)t.next(),e.inbrackets++;else{if(!e.lineTag&&(t.match(e.intag+"}")||t.eat("-")&&t.match(e.intag+"}")))return e.intag=!1,"tag";if(t.match(s))return e.operator=!0,"operator";if(t.match(r))e.sign=!0;else{if(1==t.column()&&e.lineTag&&t.match(n))return"keyword";if(t.eat(" ")||t.sol()){if(t.match(n))return"keyword";if(t.match(o))return"atom";if(t.match(h))return"number";t.sol()&&t.next()}else t.next()}}return"variable"}if(t.eat("{")){if(t.eat("#"))return e.incomment=!0,t.skipTo("#}")?(t.eatWhile(/\#|}/),e.incomment=!1):t.skipToEnd(),"comment";if(i=t.eat(/\{|%/))return e.intag=i,e.inbraces=0,e.inbrackets=0,"{"==i&&(e.intag="}"),t.eat("-"),"tag"}else if(t.eat("#")){if("#"==t.peek())return t.skipToEnd(),"comment";if(!t.eol())return e.intag=!0,e.lineTag=!0,e.inbraces=0,e.inbrackets=0,"tag"}t.next()}n=new RegExp("(("+n.join(")|(")+"))\\b"),o=new RegExp("(("+o.join(")|(")+"))\\b");const a={name:"jinja2",startState:function(){return{tokenize:l,inbrackets:0,inbraces:0}},token:function(t,e){var i=e.tokenize(t,e);return t.eol()&&e.lineTag&&!e.instring&&0==e.inbraces&&0==e.inbrackets&&(e.intag=!1,e.lineTag=!1),i},languageData:{commentTokens:{block:{open:"{#",close:"#}",line:"##"}}}}},91847:function(t,e,i){i.d(e,{r:function(){return s}});var n=new RegExp("\\b(("+["true","false","on","off","yes","no"].join(")|(")+"))$","i");const s={name:"yaml",token:function(t,e){var i=t.peek(),s=e.escaped;if(e.escaped=!1,"#"==i&&(0==t.pos||/\s/.test(t.string.charAt(t.pos-1))))return t.skipToEnd(),"comment";if(t.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))return"string";if(e.literal&&t.indentation()>e.keyCol)return t.skipToEnd(),"string";if(e.literal&&(e.literal=!1),t.sol()){if(e.keyCol=0,e.pair=!1,e.pairStart=!1,t.match("---"))return"def";if(t.match("..."))return"def";if(t.match(/^\s*-\s+/))return"meta"}if(t.match(/^(\{|\}|\[|\])/))return"{"==i?e.inlinePairs++:"}"==i?e.inlinePairs--:"["==i?e.inlineList++:e.inlineList--,"meta";if(e.inlineList>0&&!s&&","==i)return t.next(),"meta";if(e.inlinePairs>0&&!s&&","==i)return e.keyCol=0,e.pair=!1,e.pairStart=!1,t.next(),"meta";if(e.pairStart){if(t.match(/^\s*(\||\>)\s*/))return e.literal=!0,"meta";if(t.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i))return"variable";if(0==e.inlinePairs&&t.match(/^\s*-?[0-9\.\,]+\s?$/))return"number";if(e.inlinePairs>0&&t.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/))return"number";if(t.match(n))return"keyword"}return!e.pair&&t.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)?(e.pair=!0,e.keyCol=t.indentation(),"atom"):e.pair&&t.match(/^:\s*/)?(e.pairStart=!0,"meta"):(e.pairStart=!1,e.escaped="\\"==i,t.next(),null)},startState:function(){return{pair:!1,pairStart:!1,keyCol:0,inlinePairs:0,inlineList:0,literal:!1,escaped:!1}},languageData:{commentTokens:{line:"#"}}}},85159:function(t,e,i){i.d(e,{sW:()=>ar,Lp:()=>qr});i("92745"),i("39527"),i("13334"),i("36993"),i("84283"),i("32517"),i("92519"),i("42179"),i("89256"),i("24931"),i("88463"),i("57449"),i("19814"),i("37210"),i("92181"),i("99790"),i("67670"),i("34595"),i("41360");class n{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),r.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let i=[];return this.decompose(t,e,i,0),r.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new l(this),s=new l(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new l(this,t)}iterRange(t,e=this.length){return new a(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new c(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new s(t):r.from(s.split(t,[])):n.empty}}class s extends n{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new u(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new s(h(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=o(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new s(e,t.length+r.length));else{let t=e.length>>1;i.push(new s(e.slice(0,t)),new s(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof s))return super.replace(t,e,i);let n=o(this.text,o(i.text,h(this.text,0,t)),e),l=this.length+i.length-(e-t);return n.length<=32?new s(n,l):r.from(s.split(n,[]),l)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new s(i,n)),i=[],n=-1);return n>-1&&e.push(new s(i,n)),e}}class r extends n{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],h=s+o.length;if(t>=s&&e<=h){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new r(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof r))return 0;let i=0,[n,s,o,h]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==h)return i;let r=this.children[n],l=t.children[s];if(r!=l)return i+r.scanIdentical(l,e);i+=r.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new s(i,e)}let n=Math.max(32,i>>5),o=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>o&&t instanceof r)for(let e of t.children)f(e);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof s&&a&&(e=u[u.length-1])instanceof s&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new s(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:r.from(u,c)),c=-1,a=u.length=0)}for(let e of t)f(e);return d(),1==l.length?l[0]:new r(l,e)}}function o(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function h(t,e,i){return o(t,[""],e,i)}n.empty=new s([""],0);class l{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof s?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,h=n instanceof s?n.text.length:n.children.length;if(o==(e>0?h:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof s){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let r=n.children[o+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof s?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class a{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new l(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class c{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(n.prototype[Symbol.iterator]=function(){return this.iter()},l.prototype[Symbol.iterator]=a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=function(){return this});class u{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}let f="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((t=>t?parseInt(t,36):1));for(let t=1;t<f.length;t++)f[t]+=f[t-1];function d(t){for(let e=1;e<f.length;e+=2)if(f[e]>t)return f[e-1]<=t;return!1}function g(t){return t>=127462&&t<=127487}function p(t,e,i=!0,n=!0){return(i?m:w)(t,e,n)}function m(t,e,i){if(e==t.length)return e;e&&v(t.charCodeAt(e))&&y(t.charCodeAt(e-1))&&e--;let n=b(t,e);for(e+=x(n);e<t.length;){let s=b(t,e);if(8205==n||8205==s||i&&d(s))e+=x(s),n=s;else{if(!g(s))break;{let i=0,n=e-2;for(;n>=0&&g(b(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function w(t,e,i){for(;e>0;){let n=m(t,e-2,i);if(n<e)return n;e--}return 0}function v(t){return t>=56320&&t<57344}function y(t){return t>=55296&&t<56320}function b(t,e){let i=t.charCodeAt(e);if(!y(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return v(n)?n-56320+(i-55296<<10)+65536:i}function x(t){return t<65536?1:2}const S=/\r\n?|\n/;var k=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(k||(k={}));class A{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){D(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new A(t)}composeDesc(t){return this.empty?t:t.empty?this:E(this,t)}mapDesc(t,e=!1){return t.empty?this:T(this,t,e)}mapPos(t,e=-1,i=k.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=k.Simple&&l>=t&&(i==k.TrackDel&&n<t&&l>t||i==k.TrackBefore&&n<t||i==k.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new A(t)}static create(t){return new A(t)}}class M extends A{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return D(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return T(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let s=0,r=0;s<e.length;s+=2){let o=e[s],h=e[s+1];if(h>=0){e[s]=h,e[s+1]=o;let l=s>>1;for(;i.length<l;)i.push(n.empty);i.push(o?t.slice(r,r+o):n.empty)}r+=o}return new M(e,i)}compose(t){return this.empty?t:t.empty?this:E(this,t,!0)}map(t,e=!1){return t.empty?this:T(this,t,e,!0)}iterChanges(t,e=!1){D(this,t,e)}get desc(){return A.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new R(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);C(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;C(e,t,r),r>0&&O(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);C(e,t,-1),C(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new M(e,i),filtered:A.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let s=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!s.length)return;o<e&&C(s,e-o,-1);let i=new M(s,r);h=h?h.compose(i.map(h)):i,s=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof M){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?n.of(c.split(i||S)):c:n.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&C(s,t-o,-1),C(s,h-t,f),O(r,s,u),o=h}}(t),l(!h),h}static empty(t){return new M(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let s=0;s<t.length;s++){let r=t[s];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<s;)i.push(n.empty);i[s]=n.of(r.slice(1)),e.push(r[0],i[s].length)}}}return new M(e,i)}static createSet(t,e){return new M(t,e)}}function C(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function O(t,e,i){if(0==i.length)return;let s=e.length-2>>1;if(s<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<s;)t.push(n.empty);t.push(i)}}function D(t,e,i){let s=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=n.empty;for(;c+=l,u+=a,a&&s&&(f=f.append(s[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function T(t,e,i,n=!1){let s=[],r=n?[]:null,o=new R(t),h=new R(e);for(let t=-1;;)if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);C(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(C(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(C(s,0,o.ins),r&&O(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?M.createSet(s,r):A.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}C(s,e,t<o.i?o.ins:0),r&&t<o.i&&O(r,s,o.text),t=o.i,o.forward(o.len-i)}}}function E(t,e,i=!1){let n=[],s=i?[]:null,r=new R(t),o=new R(e);for(let t=!1;;){if(r.done&&o.done)return s?M.createSet(n,s):A.create(n);if(0==r.ins)C(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;C(n,e,i,t),s&&i&&O(s,n,o.text)}else-1==o.ins?(C(n,r.off?0:r.len,e,t),s&&O(s,n,r.textBit(e))):(C(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&O(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else C(n,0,o.ins,t),s&&O(s,n,o.text),o.next()}}class R{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?n.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?n.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class B{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let t=3&this.flags;return 3==t?null:t}get goalColumn(){let t=this.flags>>5;return 33554431==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new B(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return P.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return P.range(this.anchor,i)}eq(t){return this.anchor==t.anchor&&this.head==t.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return P.range(t.anchor,t.head)}static create(t,e,i){return new B(t,e,i)}}class P{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:P.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let e=0;e<this.ranges.length;e++)if(!this.ranges[e].eq(t.ranges[e]))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new P([this.main],0)}addRange(t,e=!0){return P.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,P.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new P(t.ranges.map((t=>B.fromJSON(t))),t.main)}static single(t,e=t){return new P([P.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return P.normalized(t.slice(),e);i=s.to}return new P(t,e)}static cursor(t,e=0,i,n){return B.create(t,t,(0==e?0:e<0?4:8)|(null==i?3:Math.min(2,i))|(null!=n?n:33554431)<<5)}static range(t,e,i,n){let s=(null!=i?i:33554431)<<5|(null==n?3:Math.min(2,n));return e<t?B.create(e,t,24|s):B.create(t,e,(e>t?4:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?P.range(o,r):P.range(r,o))}}return new P(t,e)}}function L(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let N=0;class I{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=N++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}static define(t={}){return new I(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:H),!!t.static,t.enables)}of(t){return new V([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new V(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new V(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function H(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class V{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=N++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||F(t,a)){let e=i(t);if(o?!W(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=et(e,l);if(this.dependencies.every((i=>i instanceof I?e.facet(i)===t.facet(i):!(i instanceof q)||e.field(i,!1)==t.field(i,!1)))||(o?W(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function W(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function F(t,e){let i=!1;for(let n of e)1&tt(t,n)&&(i=!0);return i}function z(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=et(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)tt(t,e);return t.values[o]=h(t),1},update(t,i){if(!F(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=F(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&H(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const _=I.define({static:!0});class q{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new q(N++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(_).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,_.of({field:this,create:t})]}get extension(){return this}}const K=4,j=3,$=2,G=1;function J(t){return e=>new Y(e,t)}const U={highest:J(0),high:J(G),default:J($),low:J(j),lowest:J(K)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class X{of(t){return new Q(this,t)}reconfigure(t){return X.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Q{constructor(t,e){this.compartment=t,this.inner=e}}class Z{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof Q&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Q){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof Y)r(t.inner,t.prec);else if(t instanceof q)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof V)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,$);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,$),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof q?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,H(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>z(t,n,e)))}}let c=l.map((t=>t(o)));return new Z(t,r,c,o,h,s)}}function tt(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function et(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const it=I.define(),nt=I.define({combine:t=>t.some((t=>t)),static:!0}),st=I.define({combine:t=>t.length?t[0]:void 0,static:!0}),rt=I.define(),ot=I.define(),ht=I.define(),lt=I.define({combine:t=>!!t.length&&t[0]});class at{constructor(t,e){this.type=t,this.value=e}static define(){return new ct}}class ct{of(t){return new at(this,t)}}class ut{constructor(t){this.map=t}of(t){return new ft(this,t)}}class ft{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new ft(this.type,e)}is(t){return this.type==t}static define(t={}){return new ut(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}ft.reconfigure=ft.define(),ft.appendConfig=ft.define();class dt{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&L(i,e.newLength),s.some((t=>t.type==dt.time))||(this.annotations=s.concat(dt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new dt(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(dt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function gt(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function pt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=M.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:ft.mapEffects(t.effects,s).concat(ft.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function mt(t,e,i){let n=e.selection,s=yt(e.annotations);return e.userEvent&&(s=s.concat(dt.userEvent.of(e.userEvent))),{changes:e.changes instanceof M?e.changes:M.of(e.changes||[],i,t.facet(st)),selection:n&&(n instanceof P?n:P.single(n.anchor,n.head)),effects:yt(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function wt(t,e,i){let n=mt(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=pt(n,mt(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=dt.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(ht),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=pt(n,mt(e,r,t.changes.newLength),!0))}return n==t?t:dt.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(rt)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:gt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=M.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=dt.create(e,n,t.selection&&t.selection.map(s),ft.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ot);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof dt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof dt?s[0]:wt(e,yt(s),!1)}return t}(s):s)}dt.time=at.define(),dt.userEvent=at.define(),dt.addToHistory=at.define(),dt.remote=at.define();const vt=[];function yt(t){return null==t?vt:Array.isArray(t)?t:[t]}var bt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(bt||(bt={}));const xt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let St;try{St=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function kt(t){return e=>{if(!/\S/.test(e))return bt.Space;if(function(t){if(St)return St.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||xt.test(i)))return!0}return!1}(e))return bt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return bt.Word;return bt.Other}}class At{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)tt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return tt(this,i),et(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return wt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(X.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(ft.reconfigure)?(i=null,n=e.value):e.is(ft.appendConfig)&&(i=null,n=yt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Z.resolve(n,s,this),e=new At(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}new At(i,t.newDoc,t.newSelection,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:P.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=yt(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=ft.mapEffects(r,l).concat(ft.mapEffects(yt(o.effects),a))}return{changes:n,selection:P.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof M?t:M.of(t,this.doc.length,this.facet(At.lineSeparator))}toText(t){return n.of(t.split(this.facet(At.lineSeparator)||S))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(tt(this,e),et(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof q&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return At.create({doc:t.doc,selection:P.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Z.resolve(t.extensions||[],new Map),i=t.doc instanceof n?t.doc:n.of((t.doc||"").split(e.staticFacet(At.lineSeparator)||S)),s=t.selection?t.selection instanceof P?t.selection:P.single(t.selection.anchor,t.selection.head):P.single(0);return L(s,i.length),e.staticFacet(nt)||(s=s.asSingle()),new At(e,i,s,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(At.tabSize)}get lineBreak(){return this.facet(At.lineSeparator)||"\n"}get readOnly(){return this.facet(lt)}phrase(t,...e){for(let e of this.facet(At.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(it))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return kt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=p(e,r,!1);if(s(e.slice(t,r))!=bt.Word)break;r=t}for(;o<n;){let t=p(e,o);if(s(e.slice(o,t))!=bt.Word)break;o=t}return r==o?null:P.range(r+i,o+i)}}function Mt(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}At.allowMultipleSelections=nt,At.tabSize=I.define({combine:t=>t.length?t[0]:4}),At.lineSeparator=st,At.readOnly=lt,At.phrases=I.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),At.languageData=it,At.changeFilter=rt,At.transactionFilter=ot,At.transactionExtender=ht,X.reconfigure=ft.define();class Ct{eq(t){return this==t}range(t,e=t){return Ot.create(t,e,this)}}Ct.prototype.startSide=Ct.prototype.endSide=0,Ct.prototype.point=!1,Ct.prototype.mapMode=k.TrackDel;class Ot{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Ot(t,e,i)}}function Dt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Tt{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new Tt(n,s,i,o):null,pos:r}}}class Et{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Et(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Dt)),this.isEmpty)return e.length?Et.of(e):this;let o=new Pt(this,null,-1).goto(0),h=0,l=[],a=new Rt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(Ot.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?Et.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Et(i,e,s||Et.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Lt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Lt.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=Bt(r,o,i),l=new It(r,h,s),a=new It(o,h,s);i.iterGaps(((t,e,i)=>Ht(l,t,a,e,i,n))),i.empty&&0==i.length&&Ht(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=Bt(s,r),h=new It(s,o,0).goto(i),l=new It(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Vt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new It(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Rt;for(let n of t instanceof Ot?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Dt(e,n)>0)return t.slice().sort(Dt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}}Et.empty=new Et([],[],null,-1),Et.empty.nextLayer=Et.empty;class Rt{finishChunk(t){this.chunks.push(new Tt(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Rt)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Et.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Et.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Bt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Pt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Lt{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new Pt(r,e,i,s));return 1==n.length?n[0]:new Lt(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Nt(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Nt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Nt(this.heap,0)}}}function Nt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class It{constructor(t,e,i){this.minPoint=i,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=Lt.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){Wt(this.active,t),Wt(this.activeTo,t),Wt(this.activeRank,t),this.minActive=zt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=s;)e++;Ft(this.active,e,i),Ft(this.activeTo,e,n),Ft(this.activeRank,e,s),t&&Ft(t,e,this.cursor.from),this.minActive=zt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Wt(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Ht(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to||t.endSide-i.endSide,n=e<0?t.to+l:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Vt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,s,t.point,i.point):s>h&&!Vt(t.active,i.active)&&r.compareRange(h,s,t.active,i.active),n>o)break;h=n,e<=0&&t.next(),e>=0&&i.next()}}function Vt(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Wt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Ft(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function zt(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}var _t=i("29933"),qt=i("96318");function Kt(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function jt(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function $t(t,e){if(!e.anchorNode)return!1;try{return jt(t,e.anchorNode)}catch(t){return!1}}function Gt(t){return 3==t.nodeType?se(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Jt(t,e,i,n){return!!i&&(Yt(t,e,i,n,-1)||Yt(t,e,i,n,1))}function Ut(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Yt(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:Xt(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Ut(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?Xt(t):0}}}function Xt(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Qt(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function Zt(t){return{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}class te{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Xt(e):0),i,Math.min(t.focusOffset,i?Xt(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ee,ie=null;function ne(t){if(t.setActive)return t.setActive();if(ie)return t.focus(ie);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==ie?{get preventScroll(){return ie={preventScroll:!0},!0}}:void 0),!ie){ie=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function se(t,e,i=e){let n=ee||(ee=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function re(t,e,i){let n={key:e,code:e,keyCode:i,which:i,cancelable:!0},s=new KeyboardEvent("keydown",n);s.synthetic=!0,t.dispatchEvent(s);let r=new KeyboardEvent("keyup",n);return r.synthetic=!0,t.dispatchEvent(r),s.defaultPrevented||r.defaultPrevented}function oe(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}class he{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new he(t.parentNode,Ut(t),e)}static after(t,e){return new he(t.parentNode,Ut(t)+1,e)}}const le=[];class ae{constructor(){this.parent=null,this.dom=null,this.dirty=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.dirty){let i,n=this.dom,s=null;for(let r of this.children){if(r.dirty){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=ae.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.dirty=0}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=ce(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=ce(i)}else if(1&this.dirty)for(let i of this.children)i.dirty&&(i.sync(t,e),i.dirty=0)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==Xt(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!ae.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.dirty|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.dirty|=2),1&e.dirty)return;e.dirty|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,this.dirty&&this.markParentsDirty(!0))}setDOM(t){this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=le){this.markDirty();for(let i=t;i<e;i++){let t=this.children[i];t.parent==this&&t.destroy()}this.children.splice(t,e-t,...i);for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new ue(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function ce(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}ae.prototype.breakAfter=0;class ue{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){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;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function fe(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&s<t.length?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:(s&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function de(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,fe(t,a,c,h,l,n,0,s,r)}let ge="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},pe="undefined"!=typeof document?document:{documentElement:{style:{}}};const me=/Edge\/(\d+)/.exec(ge.userAgent),we=/MSIE \d/.test(ge.userAgent),ve=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ge.userAgent),ye=!!(we||ve||me),be=!ye&&/gecko\/(\d+)/i.test(ge.userAgent),xe=!ye&&/Chrome\/(\d+)/.exec(ge.userAgent),Se="webkitFontSmoothing"in pe.documentElement.style,ke=!ye&&/Apple Computer/.test(ge.vendor),Ae=ke&&(/Mobile\/\w+/.test(ge.userAgent)||ge.maxTouchPoints>2);var Me={mac:Ae||/Mac/.test(ge.platform),windows:/Win/.test(ge.platform),linux:/Linux|X11/.test(ge.platform),ie:ye,ie_version:we?pe.documentMode||6:ve?+ve[1]:me?+me[1]:0,gecko:be,gecko_version:be?+(/Firefox\/(\d+)/.exec(ge.userAgent)||[0,0])[1]:0,chrome:!!xe,chrome_version:xe?+xe[1]:0,ios:Ae,android:/Android\b/.test(ge.userAgent),webkit:Se,safari:ke,webkit_version:Se?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=pe.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ce extends ae{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return(!i||i instanceof Ce&&!(this.length-(e-t)+i.length>256))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Ce(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new he(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return De(this.dom,t,e)}}class Oe extends ae{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(oe(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.dirty|=6)}sync(t,e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof Oe&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(de(this,t,e,i?i.children:[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Oe(this.mark,e,r)}domAtPos(t){return Ie(this,t)}coordsAt(t,e){return Ve(this,t,e)}}function De(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?Me.chrome||Me.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=se(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];return Me.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l),o?Qt(l,o<0):l||null}class Te extends ae{constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}static create(t,e,i){return new(t.customView||Te)(t,e,i)}split(t){let e=Te.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Te&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Te&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return n.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,s=this.posAtStart;return i?i.slice(s,s+this.length):n.empty}domAtPos(t){return(this.length?0==t:this.side>0)?he.before(this.dom):he.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return Qt(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Ee extends Te{domAtPos(t){let{topView:e,text:i}=this.widget;return e?Re(t,0,e,i,this.length-e.length,((t,e)=>t.domAtPos(e)),((t,e)=>new he(t,Math.min(e,t.nodeValue.length)))):new he(i,Math.min(t,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(t,e){let{topView:i,text:n}=this.widget;return i?Pe(t,e,i,n,this.length-i.length):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?Re(t,e,i,n,this.length-i.length,((t,e,i)=>t.coordsAt(e,i)),((t,e,i)=>De(t,e,i))):De(n,t,e)}destroy(){var t;super.destroy(),null===(t=this.widget.topView)||void 0===t||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function Re(t,e,i,n,s,r,o){if(i instanceof Oe){for(let h=i.dom.firstChild;h;h=h.nextSibling){let i=ae.get(h);if(i){let l=jt(h,n),a=i.length+(l?s:0);if(t<a||t==a&&i.getSide()<=0)return l?Re(t,e,i,n,s,r,o):r(i,t,e);t-=a}else{let i=Be(t,e,h,o);if("number"!=typeof i)return i;t=i}}return r(i,i.length,-1)}return i.dom==n?o(n,t,e):r(i,t,e)}function Be(t,e,i,n){if(3==i.nodeType){let s=i.nodeValue.length;if(t<=s)return n(i,t,e);t-=s}else if(1==i.nodeType&&"false"!=i.contentEditable)for(let s=i.firstChild;s;s=s.nextSibling){let i=Be(t,e,s,n);if("number"!=typeof i)return i;t=i}return t}function Pe(t,e,i,n,s){if(i instanceof Oe){let r=0;for(let o=i.dom.firstChild;o;o=o.nextSibling){let i=ae.get(o);if(i){let h=jt(o,n);if(jt(o,t))return r+(h?Pe(t,e,i,n,s):i.localPosFromDOM(t,e));r+=i.length+(h?s:0)}else{let i=Le(t,e,o);if(null!=i.result)return r+i.result;r+=i.size}}}else if(i.dom==n)return Math.min(e,n.nodeValue.length);return i.localPosFromDOM(t,e)}function Le(t,e,i){if(3==i.nodeType)return t==i?{result:e}:{size:i.nodeValue.length};if(1!=i.nodeType||"false"==i.contentEditable)return i.contains(t)?{result:0}:{size:0};{let n=0;for(let s=i.firstChild,r=0;;s=s.nextSibling,r++){if(t==i&&r==e)return{result:n};if(!s)return{size:n};let o=Le(t,e,s);if(null!=o.result)return{result:e+o.result};n+=o.size}}}class Ne extends ae{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Ne&&t.side==this.side}split(){return new Ne(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?he.before(this.dom):he.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return n.empty}get isHidden(){return!0}}function Ie(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new he(i,0)}function He(t,e,i){let n,{children:s}=t;i>0&&e instanceof Oe&&s.length&&(n=s[s.length-1])instanceof Oe&&n.mark.eq(e.mark)?He(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function Ve(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=Gt(e);return i[i.length-1]||null}(t)}function We(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}function Fe(t,e){if(t==e)return!0;if(!t||!e)return!1;let i=Object.keys(t),n=Object.keys(e);if(i.length!=n.length)return!1;for(let s of i)if(-1==n.indexOf(s)||t[s]!==e[s])return!1;return!0}function ze(t,e,i){let n=null;if(e)for(let s in e)i&&s in i||t.removeAttribute(n=s);if(i)for(let s in i)e&&e[s]==i[s]||t.setAttribute(n=s,i[s]);return!!n}Ce.prototype.children=Te.prototype.children=Ne.prototype.children=le;class _e{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get customView(){return null}get isHidden(){return!1}destroy(t){}}var qe=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(qe||(qe={}));class Ke extends Ct{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new je(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Ge(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=Je(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new Ge(t,e,i,n,t.widget||null,!0)}static line(t){return new $e(t)}static set(t,e=!1){return Et.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Ke.none=Et.empty;class je extends Ke{constructor(t){let{start:e,end:i}=Je(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){return this==t||t instanceof je&&this.tagName==t.tagName&&this.class==t.class&&Fe(this.attrs,t.attrs)}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}je.prototype.point=!1;class $e extends Ke{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof $e&&this.spec.class==t.spec.class&&Fe(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}$e.prototype.mapMode=k.TrackBefore,$e.prototype.point=!0;class Ge extends Ke{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?k.TrackBefore:k.TrackAfter:k.TrackDel}get type(){return this.startSide<this.endSide?qe.WidgetRange:this.startSide<=0?qe.WidgetBefore:qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Ge&&(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}range(t,e=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 super.range(t,e)}}function Je(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function Ue(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}Ge.prototype.point=!0;class Ye extends ae{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof Ye))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),de(this,t,e,i?i.children:[],s,r),!0}split(t){let e=new Ye;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){Fe(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){He(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=We(e,this.attrs||{})),i&&(this.attrs=We({class:i},this.attrs||{}))}domAtPos(t){return Ie(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?4&this.dirty&&(oe(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&&(ze(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&ae.get(n)instanceof Oe;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=ae.get(n))||void 0===i?void 0:i.isEditable)||Me.ios&&this.children.some((t=>t instanceof Ce))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof Ce)||/[^ -~]/.test(i.text))return null;let n=Gt(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=Ve(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return!1}get type(){return qe.Text}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof Ye)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Xe extends ae{constructor(t,e,i){super(),this.widget=t,this.length=e,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Xe&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?he.before(this.dom):he.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Xe(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return le}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.dom.contentEditable="false")}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):n.empty}domBoundsAround(){return null}become(t){return t instanceof Xe&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.type=t.type,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){return this.widget.coordsAt(this.dom,t,e)}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Qe{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof Xe&&t.type==qe.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ye),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ze(new Ne(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(Ze(new Ce(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,r){if(this.disallowBlockEffectsFor[r]&&i instanceof Ge){if(i.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")}let o=e-t;if(i instanceof Ge)if(i.block){let{type:t}=i;t!=qe.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Xe(i.widget||new ti("div"),o,t))}else{let r=Te.create(i.widget||new ti("span"),o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(Ze(new Ne(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(Ze(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=s)}static build(t,e,i,n,s){let r=new Qe(t,e,i,s);return r.openEnd=Et.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function Ze(t,e){for(let i of e)t=new Oe(i,[t],t.length);return t}class ti extends _e{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const ei=I.define(),ii=I.define(),ni=I.define(),si=I.define(),ri=I.define(),oi=I.define(),hi=I.define(),li=I.define({combine:t=>t.some((t=>t))}),ai=I.define({combine:t=>t.some((t=>t))});class ci{constructor(t,e="nearest",i="nearest",n=5,s=5){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s}map(t){return t.empty?this:new ci(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}}const ui=ft.define({map:(t,e)=>t.map(e)});function fi(t,e,i){let n=t.facet(si);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const di=I.define({combine:t=>!t.length||t[0]});let gi=0;const pi=I.define();class mi{constructor(t,e,i,n){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=n(this)}static define(t,e){const{eventHandlers:i,provide:n,decorations:s}=e||{};return new mi(gi++,t,i,(t=>{let e=[pi.of(t)];return s&&e.push(bi.of((e=>{let i=e.plugin(t);return i?s(i):Ke.none}))),n&&e.push(n(t)),e}))}static fromClass(t,e){return mi.define((e=>new t(e)),e)}}class wi{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(fi(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){fi(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){fi(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const vi=I.define(),yi=I.define(),bi=I.define(),xi=I.define(),Si=I.define();function ki(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Si)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Ai=I.define();class Mi{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Mi(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Mi(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Mi(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class Ci{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=M.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Mi(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new Ci(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Oi=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(Oi||(Oi={}));const Di=Oi.LTR,Ti=Oi.RTL;function Ei(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const Ri=Ei("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),Bi=Ei("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Pi=Object.create(null),Li=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);Pi[e]=i,Pi[i]=-e}const Ni=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Ii{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?Ti:Di}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}const Hi=[];function Vi(t,e){let i=t.length,n=e==Di?1:2,s=e==Di?2:1;if(!t||1==n&&!Ni.test(t))return Wi(i);for(let e=0,s=n,o=n;e<i;e++){let i=(r=t.charCodeAt(e))<=247?Ri[r]:1424<=r&&r<=1524?2:1536<=r&&r<=1785?Bi[r-1536]:1774<=r&&r<=2220?4:8192<=r&&r<=8203?256:64336<=r&&r<=65023?4:8204==r?256:1;512==i?i=s:8==i&&4==o&&(i=16),Hi[e]=4==i?2:i,7&i&&(o=i),s=i}var r;for(let t=0,e=n,s=n;t<i;t++){let n=Hi[t];if(128==n)t<i-1&&e==Hi[t+1]&&24&e?n=Hi[t]=e:Hi[t]=256;else if(64==n){let n=t+1;for(;n<i&&64==Hi[n];)n++;let r=t&&8==e||n<i&&8==Hi[n]?1==s?1:8:256;for(let e=t;e<n;e++)Hi[e]=r;t=n-1}else 8==n&&1==s&&(Hi[t]=1);e=n,7&n&&(s=n)}for(let e,r,o,h=0,l=0,a=0;h<i;h++)if(r=Pi[e=t.charCodeAt(h)])if(r<0){for(let t=l-3;t>=0;t-=3)if(Li[t+1]==-r){let e=Li[t+2],i=2&e?n:4&e?1&e?s:n:0;i&&(Hi[h]=Hi[Li[t]]=i),l=t;break}}else{if(189==Li.length)break;Li[l++]=h,Li[l++]=e,Li[l++]=a}else if(2==(o=Hi[h])||1==o){let t=o==n;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=Li[e+2];if(2&i)break;if(t)Li[e+2]|=2;else{if(4&i)break;Li[e+2]|=4}}}for(let t=0;t<i;t++)if(256==Hi[t]){let e=t+1;for(;e<i&&256==Hi[e];)e++;let s=1==(t?Hi[t-1]:n),r=s==(1==(e<i?Hi[e]:n))?s?1:2:n;for(let i=t;i<e;i++)Hi[i]=r;t=e-1}let o=[];if(1==n)for(let t=0;t<i;){let e=t,n=1!=Hi[t++];for(;t<i&&n==(1!=Hi[t]);)t++;if(n)for(let i=t;i>e;){let t=i,n=2!=Hi[--i];for(;i>e&&n==(2!=Hi[i-1]);)i--;o.push(new Ii(i,t,n?2:1))}else o.push(new Ii(e,t,0))}else for(let t=0;t<i;){let e=t,n=2==Hi[t++];for(;t<i&&n==(2==Hi[t]);)t++;o.push(new Ii(e,t,n?1:2))}return o}function Wi(t){return[new Ii(0,t,0)]}let Fi="";function zi(t,e,i,n,s){var r;let o=n.head-t.from,h=-1;if(0==o){if(!s||!t.length)return null;e[0].level!=i&&(o=e[0].side(!1,i),h=0)}else if(o==t.length){if(s)return null;let t=e[e.length-1];t.level!=i&&(o=t.side(!0,i),h=e.length-1)}h<0&&(h=Ii.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc));let l=e[h];o==l.side(s,i)&&(l=e[h+=s?1:-1],o=l.side(!s,i));let a=s==(l.dir==i),c=p(t.text,o,a);if(Fi=t.text.slice(Math.min(o,c),Math.max(o,c)),c!=l.side(s,i))return P.cursor(c+t.from,a?-1:1,l.level);let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u||l.level==i?u&&u.level<l.level?P.cursor(u.side(!s,i)+t.from,s?1:-1,u.level):P.cursor(c+t.from,s?-1:1,l.level):P.cursor(s?t.to:t.from,s?-1:1,i)}const _i="";class qi{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(At.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=_i}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=ae.get(n),o=ae.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:Ki(n))||Ki(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=ae.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}}function Ki(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}class ji{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class $i extends ae{constructor(t){super(),this.view=t,this.compositionDeco=Ke.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Mi(0,0,0,t.state.doc.length)],0)}get length(){return this.view.state.doc.length}update(t){let e=t.changedRanges;this.minWidth>0&&e.length&&(e.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.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=Ke.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=function(t,e){let i=Ji(t);if(!i)return Ke.none;let{from:n,to:s,node:r,text:o}=i,h=e.mapPos(n,1),l=Math.max(h,e.mapPos(s,-1)),{state:a}=t,c=new qi([],a);3==r.nodeType?c.readTextNode(r):c.readRange(r.firstChild,null);let{text:u}=c;if(u.indexOf(_i)>-1)return Ke.none;if(l-h<u.length)if(a.doc.sliceString(h,Math.min(a.doc.length,h+u.length))==u)l=h+u.length;else{if(a.doc.sliceString(Math.max(0,l-u.length),l)!=u)return Ke.none;h=l-u.length}else if(a.doc.sliceString(h,l)!=u)return Ke.none;let f=ae.get(r);f instanceof Ee?f=f.widget.topView:f&&(f.parent=null);return Ke.set(Ke.replace({widget:new Ui(r,o,f),inclusive:!0}).range(h,l))}(this.view,t.changes)),(Me.ie||Me.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=function(t,e,i){let n=new Xi;return Et.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return e=Mi.extendWithRanges(e,i),(0!=this.dirty||0!=e.length)&&(this.updateInner(e,t.startState.doc.length),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e);let{observer:i}=this.view;i.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=Me.chrome||Me.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.dirty=0,t&&(t.written||i.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let n=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof Xe&&t.widget instanceof Gi&&n.push(t.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let e=t.length-1;;e--){let n=e>=0?t[e]:null;if(!n)break;let{fromA:s,toA:r,fromB:o,toB:h}=n,{content:l,breakAtStart:a,openStart:c,openEnd:u}=Qe.build(this.view.state.doc,o,h,this.decorations,this.dynamicDecorationMap),{i:f,off:d}=i.findPos(r,1),{i:g,off:p}=i.findPos(s,-1);fe(this,g,p,f,d,l,a,c,u)}}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&$t(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.domAtPos(o.anchor),l=o.empty?h:this.domAtPos(o.head);if(Me.gecko&&o.empty&&!this.compositionDeco.size&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new he(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&Jt(h.node,h.offset,c.anchorNode,c.anchorOffset)&&Jt(l.node,l.offset,c.focusNode,c.focusOffset)||(this.view.observer.ignore((()=>{Me.android&&Me.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=Kt(this.view.root);if(t)if(o.empty){if(Me.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=Yi(h.node,h.offset,1==t?1:-1);e&&(h=new he(e,1==t?0:e.nodeValue.length))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&null!=c.cursorBidiLevel&&(c.cursorBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new he(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new he(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=Kt(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Ye.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}nearest(t){for(let e=t;e;){let t=ae.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof Ye)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){for(let i=this.length,n=this.children.length-1;;n--){let s=this.children[n],r=i-s.breakAfter-s.length;if(t>r||t==r&&s.type!=qe.WidgetBefore&&s.type!=qe.WidgetAfter&&(!n||2==e||this.children[n-1].breakAfter||this.children[n-1].type==qe.WidgetBefore&&e>-2))return s.coordsAt(t-r,e);i=r}}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==Oi.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?Gt(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?Oi.RTL:Oi.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Ye){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=Gt(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new ue(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=e.lineBlockAt(r).bottom-e.lineBlockAt(i).top;t.push(Ke.replace({widget:new Gi(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return Ke.set(t)}updateDeco(){let t=this.view.state.facet(bi).map(((t,e)=>(this.dynamicDecorationMap[e]="function"==typeof t)?t(this.view):t));for(let e=t.length;e<t.length+3;e++)this.dynamicDecorationMap[e]=!1;return this.decorations=[...t,this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(t){let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=ki(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};!function(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t;c;)if(1==c.nodeType){let t,u=c==l.body;if(u)t=Zt(a);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();t={left:e.left,right:e.left+c.clientWidth,top:e.top,bottom:e.top+c.clientHeight}}let f=0,d=0;if("nearest"==s)e.top<t.top?(d=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+d&&(d=e.bottom-t.bottom+d+o)):e.bottom>t.bottom&&(d=e.bottom-t.bottom+o,i<0&&e.top-d<t.top&&(d=-(t.top+d-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;d=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n?e.left<t.left?(f=-(t.left-e.left+r),i>0&&e.right>t.right+f&&(f=e.right-t.right+f+r)):e.right>t.right&&(f=e.right-t.right+r,i<0&&e.left<t.left+f&&(f=-(t.left+f-e.left+r))):f=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left,f||d)if(u)a.scrollBy(f,d);else{let t=0,i=0;if(d){let t=c.scrollTop;c.scrollTop+=d,i=c.scrollTop-t}if(f){let e=c.scrollLeft;c.scrollLeft+=f,t=c.scrollLeft-e}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-f)<1&&(n="nearest"),i&&Math.abs(i-d)<1&&(s="nearest")}if(u)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==Oi.LTR)}}class Gi extends _e{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}}function Ji(t){let e=t.observer.selectionRange,i=e.focusNode&&Yi(e.focusNode,e.focusOffset,0);if(!i)return null;let n=t.docView.nearest(i);if(!n)return null;if(n instanceof Ye){let t=i;for(;t.parentNode!=n.dom;)t=t.parentNode;let e=t.previousSibling;for(;e&&!ae.get(e);)e=e.previousSibling;let s=e?ae.get(e).posAtEnd:n.posAtStart;return{from:s,to:s,node:t,text:i}}{for(;;){let{parent:t}=n;if(!t)return null;if(t instanceof Ye)break;n=t}let t=n.posAtStart;return{from:t,to:t+n.length,node:n.dom,text:i}}}class Ui extends _e{constructor(t,e,i){super(),this.top=t,this.text=e,this.topView=i}eq(t){return this.top==t.top&&this.text==t.text}toDOM(){return this.top}ignoreEvent(){return!1}get customView(){return Ee}}function Yi(t,e,i){if(i<=0)for(let i=t,n=e;;){if(3==i.nodeType)return i;if(!(1==i.nodeType&&n>0))break;i=i.childNodes[n-1],n=Xt(i)}if(i>=0)for(let n=t,s=e;;){if(3==n.nodeType)return n;if(!(1==n.nodeType&&s<n.childNodes.length&&i>=0))break;n=n.childNodes[s],s=0}return null}class Xi{constructor(){this.changes=[]}compareRange(t,e){Ue(t,e,this.changes)}comparePoint(t,e){Ue(t,e,this.changes)}}function Qi(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function Zi(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function tn(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function en(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function nn(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function sn(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=Gt(f);for(let d=0;d<t.length;d++){let g=t[d];s&&tn(s,g)&&(g=en(nn(g,s.bottom),s.top));let p=Qi(e,g),m=Zi(i,g);if(0==p&&0==m)return 3==f.nodeType?rn(f,e,i):sn(f,e,i);if(!n||o>m||o==m&&r>p){n=f,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=f,a=g):i<g.top&&(!c||c.top>g.top)&&(l=f,c=g):a&&tn(a,g)?a=nn(a,g.bottom):c&&tn(c,g)&&(c=en(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?rn(n,f,i):u&&"false"!=n.contentEditable?sn(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function rn(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=se(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(Me.chrome||Me.gecko){se(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function on(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=qe.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:hn(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:hn(t,h,o,c,u);let g=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:g,m=p.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=p.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||Me.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return se(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||Me.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():se(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}if(!w||!t.docView.dom.contains(w)){let e=Ye.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=sn(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function hn(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=p(t,n)}return!0===n?-1:t.length}(o,r,t.state.tabSize)}function ln(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==qe.Text))return t;return i}function an(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=zi(s,r,o,h,i),a=Fi;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=P.cursor(i?s.from:s.to)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function cn(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function un(t,e,i){let n=cn(t.state.facet(xi).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:P.cursor(n,n<i.from?1:-1)}class fn{constructor(t){this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.chromeScrollHack=-1,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.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null;let e=(e,i)=>{this.ignoreDuringComposition(i)||"keydown"==i.type&&this.keydown(t,i)||(this.mustFlushObserver(i)&&t.observer.forceFlush(),this.runCustomHandlers(i.type,t,i)?i.preventDefault():e(t,i))};for(let i in yn){let n=yn[i];t.contentDOM.addEventListener(i,(i=>{vn(t,i)&&e(n,i)}),bn[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",(i=>{if(i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&(e(yn.mousedown,i),!i.defaultPrevented&&2==i.button)){let e=t.contentDOM.style.minHeight;t.contentDOM.style.minHeight="100%",setTimeout((()=>t.contentDOM.style.minHeight=e),200)}})),t.scrollDOM.addEventListener("drop",(i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(yn.drop,i)})),Me.chrome&&102==Me.chrome_version&&t.scrollDOM.addEventListener("wheel",(()=>{this.chromeScrollHack<0?t.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout((()=>{this.chromeScrollHack=-1,t.contentDOM.style.pointerEvents=""}),100)}),{passive:!0}),this.notifiedFocused=t.hasFocus,Me.safari&&t.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}ensureHandlers(t,e){var i;let n;this.customHandlers=[];for(let s of e)if(n=null===(i=s.update(t).spec)||void 0===i?void 0:i.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:n});for(let e in n)this.registeredEvents.indexOf(e)<0&&"scroll"!=e&&(this.registeredEvents.push(e),t.contentDOM.addEventListener(e,(i=>{vn(t,i)&&this.runCustomHandlers(e,t,i)&&i.preventDefault()})))}}runCustomHandlers(t,e,i){for(let n of this.customHandlers){let s=n.handlers[t];if(s)try{if(s.call(n.plugin,i,e)||i.defaultPrevented)return!0}catch(t){fi(e.state,t)}}return!1}runScrollHandlers(t,e){this.lastScrollTop=t.scrollDOM.scrollTop,this.lastScrollLeft=t.scrollDOM.scrollLeft;for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,e,t)}catch(e){fi(t.state,e)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),9==e.keyCode&&Date.now()<this.lastEscPress+2e3)return!0;if(27!=e.keyCode&&pn.indexOf(e.keyCode)<0&&(t.inputState.lastEscPress=0),Me.android&&Me.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return!(!Me.ios||e.synthetic||e.altKey||e.metaKey||!((i=dn.find((t=>t.keyCode==e.keyCode)))&&!e.ctrlKey||gn.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey))&&(this.pendingIOSKey=i||e,setTimeout((()=>this.flushIOSKey(t)),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(this.pendingIOSKey=void 0,re(t.contentDOM,e.key,e.keyCode))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}mustFlushObserver(t){return"keydown"==t.type&&229!=t.keyCode}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.mouseSelection&&this.mouseSelection.update(t),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const dn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],gn="dthko",pn=[16,17,18,20,91,92,224,225];function mn(t){return.7*Math.max(0,t)+8}class wn{constructor(t,e,i,n){this.view=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(xi).map((e=>e(t)));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(At.allowMultipleSelections)&&function(t,e){let i=t.state.facet(ei);return i.length?i[0](e):Me.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=Kt(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Bn(e))&&null}start(t){!1===this.dragging&&(t.preventDefault(),this.select(t))}move(t){var e;if(0==t.buttons)return this.destroy();if(!1!==this.dragging)return;this.select(this.lastEvent=t);let i=0,n=0,s=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},r=ki(this.view);t.clientX-r.left<=s.left+6?i=-mn(s.left-t.clientX):t.clientX+r.right>=s.right-6&&(i=mn(t.clientX-s.right)),t.clientY-r.top<=s.top+6?n=-mn(s.top-t.clientY):t.clientY+r.bottom>=s.bottom-6&&(n=mn(t.clientY-s.bottom)),this.setScrollSpeed(i,n)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=cn(this.atoms,n.from,0);t!=n.from&&(s=P.cursor(t,-1))}else{let t=cn(this.atoms,n.from,-1),e=cn(this.atoms,n.to,1);t==n.from&&e==n.to||(s=P.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?P.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection)&&i.main.assoc==e.state.selection.main.assoc||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.docChanged&&this.dragging&&(this.dragging=this.dragging.map(t.changes)),this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function vn(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=ae.get(n))&&i.ignoreEvent(e))return!1;return!0}const yn=Object.create(null),bn=Object.create(null),xn=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function Sn(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Ln&&n.selection.ranges.every((t=>t.empty))&&Ln==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:P.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:P.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function kn(t,e,i,n){if(1==n)return P.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return P.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=p(s.text,r,!1):h=p(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=p(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=p(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return P.range(o+s.from,h+s.from)}(t.state,e,i);{let i=Ye.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,P.range(s,r)}}yn.keydown=(t,e)=>{t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now())},yn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},yn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},bn.touchstart=bn.touchmove={passive:!0},yn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return;let i=null;for(let n of t.state.facet(ni))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=On(t,e),n=Bn(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=On(t,e),a=kn(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=kn(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?P.range(s,r):P.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return P.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?h:o?s.addRange(a):P.create([a])}}}(t,e)),i){let n=t.root.activeElement!=t.contentDOM;t.inputState.startMouseSelection(new wn(t,e,i,n)),n&&t.observer.ignore((()=>ne(t.contentDOM))),t.inputState.mouseSelection&&t.inputState.mouseSelection.start(e)}};let An=(t,e)=>t>=e.top&&t<=e.bottom,Mn=(t,e,i)=>An(e,i)&&t>=i.left&&t<=i.right;function Cn(t,e,i,n){let s=Ye.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Mn(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Mn(i,n,h)?1:o&&An(n,o)?-1:1}function On(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Cn(t,i,e.clientX,e.clientY)}}const Dn=Me.ie&&Me.ie_version<=11;let Tn=null,En=0,Rn=0;function Bn(t){if(!Dn)return t.detail;let e=Tn,i=Rn;return Tn=t,Rn=Date.now(),En=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(En+1)%3:1}function Pn(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=t.inputState,o=n&&r&&r.dragging&&function(t,e){let i=t.state.facet(ii);return i.length?i[0](e):Me.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.dragging.from,to:r.dragging.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}yn.dragstart=(t,e)=>{let{selection:{main:i}}=t.state,{mouseSelection:n}=t.inputState;n&&(n.dragging=i),e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove")},yn.drop=(t,e)=>{if(!e.dataTransfer)return;if(t.state.readOnly)return e.preventDefault();let i=e.dataTransfer.files;if(i&&i.length){e.preventDefault();let n=Array(i.length),s=0,r=()=>{++s==i.length&&Pn(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}}else Pn(t,e,e.dataTransfer.getData("Text"),!0)},yn.paste=(t,e)=>{if(t.state.readOnly)return e.preventDefault();t.observer.flush();let i=xn?null:e.clipboardData;i?(Sn(t,i.getData("text/plain")||i.getData("text/uri-text")),e.preventDefault()):function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),Sn(t,i.value)}),50)}(t)};let Ln=null;yn.copy=yn.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return;Ln=s?i:null;let r=xn?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",i)):function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const Nn=at.define();function In(t,e){let i=[];for(let n of t.facet(hi)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Nn.of(!0)}):null}function Hn(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=In(t.state,e);i?t.dispatch(i):t.update([])}}),10)}yn.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Hn(t)},yn.blur=t=>{t.observer.clearSelectionRange(),Hn(t)},yn.compositionstart=yn.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},yn.compositionend=t=>{t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.compositionDeco.size&&t.update([])}),50)},yn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},yn.beforeinput=(t,e)=>{var i;let n;if(Me.chrome&&Me.android&&(n=dn.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}};const Vn=["pre-wrap","normal","pre-line","break-spaces"];class Wn{constructor(t){this.lineWrapping=t,this.doc=n.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Vn.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Vn.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class Fn{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class zn{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ge?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new zn(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var _n=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(_n||(_n={}));const qn=.001;class Kn{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>qn&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return Kn.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,_n.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,_n.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,_n.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=Yn.build(i.setDoc(r),t,a,c);s=s.replace(h,l,d)}return s.updateHeight(i,0)}static empty(){return new $n(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new Jn(Kn.of(t.slice(0,e)),r,Kn.of(t.slice(i)))}}Kn.prototype.size=1;class jn extends Kn{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new zn(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class $n extends jn{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new zn(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof $n||n instanceof Gn&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof Gn?n=new $n(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Kn.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Gn extends Kn{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new zn(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new zn(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==_n.ByHeight)return this.blockAt(t,i,n,s);if(e==_n.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new zn(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new zn(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new zn(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof Gn?i[i.length-1]=new Gn(t.length+n):i.push(null,new Gn(n-1))}if(t>0){let e=i[0];e instanceof Gn?i[0]=new Gn(t+e.length):i.unshift(new Gn(t-1),null)}return Kn.of(i)}decomposeLeft(t,e){e.push(new Gn(t-1),null)}decomposeRight(t,e){e.push(null,new Gn(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new Gn(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=qn&&(o=-2);let h=new $n(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new Gn(s-r).updateHeight(t,r));let h=Kn.of(i);return(o<0||Math.abs(h.height-this.height)>=qn||Math.abs(o-this.heightMetrics(t,e).perLine)>=qn)&&(t.heightChanged=!0),h}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Jn extends Kn{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==_n.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==_n.ByPosNoHeight?_n.ByPosNoHeight:_n.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,_n.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&Un(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Un(s,t)}return Kn.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?Kn.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)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Un(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof Gn&&(n=t[e+1])instanceof Gn&&t.splice(e-1,3,new Gn(i.length+1+n.length))}class Yn{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof $n?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new $n(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new jn(r,n,i)):(r||s||n>=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new $n(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Gn(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof $n)return t;let e=new $n(0,-1);return this.nodes.push(e),e}addBlock(t){var e;this.enterLine();let i=null===(e=t.deco)||void 0===e?void 0:e.type;i!=qe.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,i!=qe.WidgetBefore&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof $n||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new $n(0,-1));let i=t;for(let t of this.nodes)t instanceof $n&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new Yn(i,t);return Et.spans(e,i,n,s,0),s.finish(i)}}class Xn{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Ue(t,e,this.changes,5)}}function Qn(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=e==t.parentNode?n.bottom:Math.min(l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function Zn(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ts{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t){return Ke.replace({widget:new es(this.size,t)}).range(this.from,this.to)}}class es extends _e{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let 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}get estimatedHeight(){return this.vertical?this.size:-1}}class is{constructor(t){this.state=t,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.scrollTop=0,this.scrolledToBottom=!0,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=hs,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Oi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(yi).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new Wn(e),this.stateDeco=t.facet(bi).filter((t=>"function"!=typeof t)),this.heightMap=Kn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle.setDoc(t.doc),[new Mi(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ke.set(this.lineGaps.map((t=>t.draw(!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new ns(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?hs:new ls(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:as(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(bi).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Mi.extendWithRanges(n,function(t,e,i){let n=new Xn;return Et.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:M.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.lineBlockAtHeight(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=!t.changes.empty||2&t.flags||h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,this.updateForViewport(),l&&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&&!t.state.facet(ai)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?Oi.RTL:Oi.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0,u=parseInt(i.paddingTop)||0,f=parseInt(i.paddingBottom)||0;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(s.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8),this.scrollTop!=t.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=t.scrollDOM.scrollTop),this.scrolledToBottom=this.scrollTop>t.scrollDOM.scrollHeight-t.scrollDOM.clientHeight-4;let d=(this.printing?Zn:Qn)(e,this.paddingTop),g=d.top-this.pixelViewport.top,p=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let w=h.width;if(this.contentDOMWidth==w&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(e)&&(o=!0),o||s.lineWrapping&&Math.abs(w-this.contentDOMWidth)>s.charWidth){let{lineHeight:i,charWidth:n,textHeight:h}=t.docView.measureTextSize();o=i>0&&s.refresh(r,i,n,h,w/n,e),o&&(t.docView.minWidth=0,a|=8)}g>0&&p>0?c=Math.max(g,p):g<0&&p<0&&(c=Math.min(g,p)),s.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?Kn.empty().applyChanges(this.stateDeco,n.empty,this.heightOracle,[new Mi(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new Fn(i.from,r))}s.heightChanged&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new ns(n.lineAt(r-1e3*i,_n.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),_n.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,_n.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new ns(n.lineAt(i-500,_n.ByHeight,s,0,0).from,n.lineAt(i+r+500,_n.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new ns(this.heightMap.lineAt(i,_n.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,_n.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,_n.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,_n.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new ts(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,r=n<<1;if(this.defaultTextDirection!=Oi.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(P.cursor(r),!1,!0).head;t>n&&(r=t)}f=new ts(n,r,this.gapSize(l,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.length<r)continue;let e=ss(t.from,t.to,this.stateDeco);if(e.total<r)continue;let s,o,l=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let i,r,h=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=l){let n=os(e,l),s=((this.visibleBottom-this.visibleTop)/2+h)/t.height;i=n-s,r=n+s}else i=(this.visibleTop-t.top-h)/t.height,r=(this.visibleBottom-t.top+h)/t.height;s=rs(e,i),o=rs(e,r)}else{let t,i,r=e.total*this.heightOracle.charWidth,h=n*this.heightOracle.charWidth;if(null!=l){let n=os(e,l),s=((this.pixelViewport.right-this.pixelViewport.left)/2+h)/r;t=n-s,i=n+s}else t=(this.pixelViewport.left-h)/r,i=(this.pixelViewport.right+h)/r;s=rs(e,t),o=rs(e,i)}s>t.from&&h(t.from,s,t,e),o<t.to&&h(o,t.to,t,e)}return o}gapSize(t,e,i,n){let s=os(n,i)-os(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){ts.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Ke.set(t.map((t=>t.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Et.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||as(this.heightMap.lineAt(t,_n.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return as(this.heightMap.lineAt(this.scaler.fromDOM(t),_n.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return as(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ns{constructor(t,e){this.from=t,this.to=e}}function ss(t,e,i){let n=[],s=t,r=0;return Et.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s),{total:r,ranges:n}}function rs({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function os(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const hs={toDOM:t=>t,fromDOM:t=>t,scale:1};class ls{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,_n.ByPos,t,0,0).top,o=e.lineAt(s,_n.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}}function as(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new zn(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>as(t,e))):t._content)}const cs=I.define({combine:t=>t.join(" ")}),us=I.define({combine:t=>t.indexOf(!0)>-1}),fs=_t.V.newName(),ds=_t.V.newName(),gs=_t.V.newName(),ps={"&light":"."+ds,"&dark":"."+gs};function ms(t,e,i){return new _t.V(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const ws=ms("."+fs,{"&":{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,flexShrink:0,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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},ps);class vs{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new ji(i,n)),s==i&&r==n||e.push(new ji(s,r)));return e}(t),i=new qi(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?P.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!jt(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!jt(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset);this.newSel=P.single(n,i)}}}function ys(t,e){let i,{newSel:s}=e,r=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:s,to:h}=e.bounds,l=r.from,a=null;(8===o||Me.android&&e.text.length<h-s)&&(l=r.to,a="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(s,h,_i),e.text,l-s,a);c&&(Me.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==_i+_i&&c.toB--,i={from:s+c.from,to:s+c.toA,insert:n.of(e.text.slice(c.from,c.toB).split(_i))})}else s&&(!t.hasFocus&&t.state.facet(di)||s.main.eq(r))&&(s=null);if(!i&&!s)return!1;if(!i&&e.typeOver&&!r.empty&&s&&s.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(Me.mac||Me.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(s&&2==i.insert.length&&(s=P.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}):Me.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(s&&(s=P.single(s.main.anchor-1,s.main.head-1)),i={from:r.from,to:r.to,insert:n.of([" "])}),i){let e=t.state;if(Me.ios&&t.inputState.flushIOSKey(t))return!0;if(Me.android&&(i.from==r.from&&i.to==r.to&&1==i.insert.length&&2==i.insert.lines&&re(t.contentDOM,"Enter",13)||(i.from==r.from-1&&i.to==r.to&&0==i.insert.length||8==o&&i.insert.length<i.to-i.from)&&re(t.contentDOM,"Backspace",8)||i.from==r.from&&i.to==r.to+1&&0==i.insert.length&&re(t.contentDOM,"Delete",46)))return!0;let n,h=i.insert.toString();if(t.state.facet(oi).some((e=>e(t,i.from,i.to,h))))return!0;if(t.inputState.composing>=0&&t.inputState.composing++,i.from>=r.from&&i.to<=r.to&&i.to-i.from>=(r.to-r.from)/3&&(!s||s.main.empty&&s.main.from==i.from+i.insert.length)&&t.inputState.composing<0){let s=r.from<i.from?e.sliceDoc(r.from,i.from):"",o=r.to>i.to?e.sliceDoc(i.to,r.to):"";n=e.replaceSelection(t.state.toText(s+i.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=e.changes(i),h=s&&s.main.to<=o.newLength?s.main:void 0;if(e.selection.ranges.length>1&&t.inputState.composing>=0&&i.to<=r.to&&i.to>=r.to-10){let s=t.state.sliceDoc(i.from,i.to),l=Ji(t)||t.state.doc.lineAt(r.head),a=r.to-i.to,c=r.to-r.from;n=e.changeByRange((n=>{if(n.from==r.from&&n.to==r.to)return{changes:o,range:h||n.map(o)};let u=n.to-a,f=u-s.length;if(n.to-n.from!=c||t.state.sliceDoc(f,u)!=s||l&&n.to>=l.from&&n.from<=l.to)return{range:n};let d=e.changes({from:f,to:u,insert:i.insert}),g=n.to-r.to;return{changes:d,range:h?P.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):n.map(d)}}))}else n={changes:o,selection:h&&e.selection.replaceRange(h)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),t.dispatch(n,{scrollIntoView:!0,userEvent:l}),!0}if(s&&!s.main.eq(r)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:s,scrollIntoView:e,userEvent:i}),!0}return!1}const bs={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},xs=Me.ie&&Me.ie_version<=11;class Ss{constructor(t){this.view=t,this.active=!1,this.selectionRange=new te,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(Me.ie&&Me.ie_version<=11||Me.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),xs&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM),this.resizeContent=new ResizeObserver((()=>this.view.requestMeasure())),this.resizeContent.observe(t.contentDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runScrollHandlers(this.view,t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(di)?i.root.activeElement!=this.dom:!$t(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Jt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=Me.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t){let e=null;function i(t){t.preventDefault(),t.stopImmediatePropagation(),e=t.getTargetRanges()[0]}if(t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),!e)return null;let n=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,h=t.docView.domAtPos(t.state.selection.main.anchor);Jt(h.node,h.offset,r,o)&&([n,s,r,o]=[r,o,n,s]);return{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:o}}(this.view)||Kt(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=$t(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,Xt(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=Xt(i))}else{if(i==t)return!0;n=Ut(i),i=i.parentNode}}(this.dom,e)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(e),i&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,bs),xs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),xs&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&re(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&$t(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new vs(this.view,t,e,i))}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return!1;let i=this.view.state,n=ys(this.view,e);return this.view.state==i&&this.view.update([]),n}readMutation(t){let 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){let i=ks(e,t.previousSibling||t.target.previousSibling,-1),n=ks(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var t,e,i,n;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect(),null===(n=this.resizeContent)||void 0===n||n.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function ks(t,e,i){for(;e;){let n=ae.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}class As{constructor(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: fixed; 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=t.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new is(t.state||At.create(t)),this.plugins=this.state.facet(pi).map((t=>new wi(t)));for(let t of this.plugins)t.update(this);this.observer=new Ss(this),this.inputState=new fn(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new $i(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),t.parent&&t.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...t){let e=1==t.length&&t[0]instanceof dt?t[0]:this.state.update(...t);this._dispatch(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(Nn)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=In(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(At.phrases)!=this.state.facet(At.phrases))return this.setState(s);e=Ci.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new ci(t.empty?t:P.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(ui)&&(c=t.value)}this.viewState.update(e,c),this.bidiCache=Os.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Ai)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(cs)!=e.state.facet(cs)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!e.empty)for(let t of this.state.facet(ri))t(e);(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!ys(this,a)&&l.force&&re(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new is(t),this.plugins=t.facet(pi).map((t=>new wi(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView=new $i(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(pi),i=t.state.facet(pi);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new wi(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,{scrollTop:n}=i,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;if(this.viewState.scrollAnchorHeight=-1,r<0||n!=this.viewState.scrollTop)if(n>i.scrollHeight-i.clientHeight-4)s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.lineBlockAtHeight(n);s=t.from,r=t.top}try{for(let t=0;;t++){this.updateState=1;let o=this.viewport,h=this.viewState.measure(this);if(!h&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&h||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map((t=>{try{return t.read(this)}catch(t){return fi(this.state,t),Cs}})),c=Ci.create(this,this.state,[]),u=!1,f=!1;c.flags|=h,e?e.flags|=h:e=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c));for(let t=0;t<l.length;t++)if(a[t]!=Cs)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){fi(this.state,t)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,f=!0;else if(r>-1){let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;(t>1||t<-1)&&(i.scrollTop=n+t,f=!0)}if(u&&this.docView.updateSelection(!0),this.viewport.from==o.from&&this.viewport.to==o.to&&!f&&0==this.measureRequests.length)break;r=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(ri))t(e)}get themeClasses(){return fs+" "+(this.state.facet(us)?gs:ds)+" "+this.state.facet(cs)}updateAttrs(){let t=Ds(this,vi,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(di)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Ds(this,yi,e);let i=this.observer.ignore((()=>{let i=ze(this.contentDOM,this.contentAttrs,e),n=ze(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(As.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Ai),_t.V.mount(this.root,this.styleModules.concat(ws).reverse())}readMeasured(){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)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return un(this,t,an(this,t,e,i))}moveByGroup(t,e){return un(this,t,an(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==bt.Space&&(s=e),s==e}}(this,t.head,e))))}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=ln(t,e.head),r=n&&s.type==qe.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==Oi.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return P.cursor(o,i?-1:1)}return P.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return un(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return P.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let i=0;;i+=10){let n=o+(f+i)*r,a=on(t,{x:u,y:n},!1,r);if(n<l.top||n>l.bottom||(r<0?a<s:a>s))return P.cursor(a,e.assoc,void 0,h)}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),on(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return Qt(i,s[Ii.find(s,t-n.from,-1,e)].dir==Oi.LTR==e>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(li)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Ms)return Wi(t.length);let e=this.textDirectionAt(t.from);for(let i of this.bidiCache)if(i.from==t.from&&i.dir==e)return i.order;let i=Vi(t.text,e);return this.bidiCache.push(new Os(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Me.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{ne(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return ui.of(new ci("number"==typeof t?P.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return mi.define((()=>({})),{eventHandlers:t})}static theme(t,e){let i=_t.V.newName(),n=[cs.of(i),Ai.of(ms(`.${i}`,t))];return e&&e.dark&&n.push(us.of(!0)),n}static baseTheme(t){return U.lowest(Ai.of(ms("."+fs,t,ps)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&ae.get(i)||ae.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}As.styleModule=Ai,As.inputHandler=oi,As.focusChangeEffect=hi,As.perLineTextDirection=li,As.exceptionSink=si,As.updateListener=ri,As.editable=di,As.mouseSelectionStyle=ni,As.dragMovesSelection=ii,As.clickAddsSelectionRange=ei,As.decorations=bi,As.atomicRanges=xi,As.scrollMargins=Si,As.darkTheme=us,As.contentAttributes=yi,As.editorAttributes=vi,As.lineWrapping=As.contentAttributes.of({class:"cm-lineWrapping"}),As.announce=ft.define();const Ms=4096,Cs={};class Os{constructor(t,e,i,n){this.from=t,this.to=e,this.dir=i,this.order=n}static update(t,e){if(e.empty)return t;let i=[],n=t.length?t[t.length-1].dir:Oi.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new Os(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.order))}return i}}function Ds(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&We(r,i)}return i}const Ts=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function Es(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const Rs=I.define({enables:U.default(As.domEventHandlers({keydown:(t,e)=>Is(Ps(e.state),t,e,"editor")}))}),Bs=new WeakMap;function Ps(t){let e=t.facet(Rs),i=Bs.get(e);return i||Bs.set(e,i=function(t,e=Ts){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},r=(t,n,r,o)=>{var h,l;let a=i[t]||(i[t]=Object.create(null)),c=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let t=0;t<i.length-1;++t){const h=i[t];if(/^(cmd|meta|m)$/i.test(h))o=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))r=!0;else{if(!/^mod$/i.test(h))throw new Error("Unrecognized modifier name: "+h);"mac"==e?o=!0:s=!0}}return n&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}(t,e)));for(let e=1;e<c.length;e++){let i=c.slice(0,e).join(" ");s(i,!0),a[i]||(a[i]={preventDefault:!0,run:[e=>{let n=Ls={view:e,prefix:i,scope:t};return setTimeout((()=>{Ls==n&&(Ls=null)}),Ns),!0}]})}let u=c.join(" ");s(u,!1);let f=a[u]||(a[u]={preventDefault:!1,run:(null===(l=null===(h=a._any)||void 0===h?void 0:h.run)||void 0===l?void 0:l.slice())||[]});r&&f.run.push(r),o&&(f.preventDefault=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,run:[]});for(let e in t)t[e].run.push(n.any)}let s=n[e]||n.key;if(s)for(let e of t)r(e,s,n.run,n.preventDefault),n.shift&&r(e,"Shift-"+s,n.shift,n.preventDefault)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let Ls=null;const Ns=4e3;function Is(t,e,i,n){let s=(0,qt.YG)(e),r=x(b(s,0))==s.length&&" "!=s,o="",h=!1;Ls&&Ls.view==i&&Ls.scope==n&&(o=Ls.prefix+" ",(h=pn.indexOf(e.keyCode)<0)&&(Ls=null));let l,a,c=new Set,u=t=>{if(t){for(let n of t.run)if(!c.has(n)&&(c.add(n),n(i,e)))return!0;t.preventDefault&&(h=!0)}return!1},f=t[n];if(f){if(u(f[o+Es(s,e,!r)]))return!0;if(r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&(l=qt.ue[e.keyCode])&&l!=s){if(u(f[o+Es(l,e,!0)]))return!0;if(e.shiftKey&&(a=qt.uY[e.keyCode])!=s&&a!=l&&u(f[o+Es(a,e,!1)]))return!0}else if(r&&e.shiftKey&&u(f[o+Es(s,e,!0)]))return!0;if(u(f._any))return!0}return h}const Hs=!Me.ios;const Vs={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Hs&&(Vs[".cm-line"].caretColor="transparent !important");const Ws=I.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function Fs(t,e){let i=t.plugin(zs),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const zs=mi.fromClass(class{constructor(t){this.input=t.state.facet(Ks),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(Ws);this.top=new _s(t,!0,e.topContainer),this.bottom=new _s(t,!1,e.bottomContainer),this.top.sync(this.panels.filter((t=>t.top))),this.bottom.sync(this.panels.filter((t=>!t.top)));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet(Ws);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new _s(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new _s(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Ks);if(i!=this.input){let e=i.filter((t=>t)),n=[],s=[],r=[],o=[];for(let i of e){let e,h=this.specs.indexOf(i);h<0?(e=i(t.view),o.push(e)):(e=this.panels[h],e.update&&e.update(t)),n.push(e),(e.top?s:r).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(r);for(let t of o)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>As.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class _s{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));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";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=qs(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=qs(t)}scrollMargin(){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)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function qs(t){let e=t.nextSibling;return t.remove(),e}const Ks=I.define({enables:zs});class js extends Ct{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}js.prototype.elementClass="",js.prototype.toDOM=void 0,js.prototype.mapMode=k.TrackBefore,js.prototype.startSide=js.prototype.endSide=-1,js.prototype.point=!0;function $s(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e<arguments.length;e++)Gs(t,arguments[e]);return t}function Gs(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 i=0;i<e.length;i++)Gs(t,e[i])}}const Js="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class Us{constructor(t,e,i=0,n=t.length,s,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=s?t=>s(Js(t)):Js,this.query=this.normalize(e)}peek(){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 b(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let i=(t=e)<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))),n=this.bufferStart+this.bufferPos;this.bufferPos+=x(e);let s=this.normalize(i);if(s.length)for(let t=0,e=n;;t++){let r=s.charCodeAt(t),o=this.match(r,e,this.bufferPos+this.bufferStart);if(t==s.length-1){if(o)return this.value=o,this;break}e==n&&t<i.length&&i.charCodeAt(t)==r&&e++}}var t}match(t,e,i){let n=null;for(let e=0;e<this.matches.length;e+=2){let s=this.matches[e],r=!1;this.query.charCodeAt(s)==t&&(s==this.query.length-1?n={from:this.matches[e+1],to:i}:(this.matches[e]++,r=!0)),r||(this.matches.splice(e,2),e-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?n={from:e,to:i}:this.matches.push(1,e)),n&&this.test&&!this.test(n.from,n.to,this.buffer,this.bufferStart)&&(n=null),n}}"undefined"!=typeof Symbol&&(Us.prototype[Symbol.iterator]=function(){return this});const Ys={from:-1,to:-1,match:/.*/.exec("")},Xs="gm"+(null==/x/.unicode?"":"u");class Qs{constructor(t,e,i,n=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=Ys,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new er(t,e,i,n,s);this.re=new RegExp(e,Xs+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.iter=t.iter();let r=t.lineAt(n);this.curLineStart=r.from,this.matchPos=ir(t,n),this.getLine(this.curLineStart)}getLine(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())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=ir(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<n||i>this.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,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}}}}const Zs=new WeakMap;class tr{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,i){let n=Zs.get(t);if(!n||n.from>=i||n.to<=e){let n=new tr(e,t.sliceString(e,i));return Zs.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:s,from:r}=n;return r>e&&(s=t.sliceString(e,r)+s,r=e),n.to<i&&(s+=t.sliceString(n.to,i)),Zs.set(t,new tr(r,s)),new tr(e,s.slice(e-r,i-r))}}class er{constructor(t,e,i,n,s){this.text=t,this.to=s,this.done=!1,this.value=Ys,this.matchPos=ir(t,n),this.re=new RegExp(e,Xs+((null==i?void 0:i.ignoreCase)?"i":"")),this.test=null==i?void 0:i.test,this.flat=tr.get(t,n,this.chunkEnd(n+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let 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){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=ir(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=tr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function ir(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}function nr(t){let e=$s("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,s=n.doc.lineAt(n.selection.main.head),[,r,o,h,l]=i,a=h?+h.slice(1):0,c=o?+o:s.number;if(o&&l){let t=c/100;r&&(t=t*("-"==r?-1:1)+s.number/n.doc.lines),c=Math.round(n.doc.lines*t)}else o&&r&&(c=c*("-"==r?-1:1)+s.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,c))),f=P.cursor(u.from+Math.max(0,Math.min(a,u.length)));t.dispatch({effects:[sr.of(!1),As.scrollIntoView(f.from,{y:"center"})],selection:f}),t.focus()}return{dom:$s("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:sr.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},$s("label",t.state.phrase("Go to line"),": ",e)," ",$s("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Qs.prototype[Symbol.iterator]=er.prototype[Symbol.iterator]=function(){return this});const sr=ft.define(),rr=q.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(sr)&&(t=i.value);return t},provide:t=>Ks.from(t,(t=>t?nr:null))}),or=As.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),hr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},lr=I.define({combine:t=>Mt(t,hr,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})});function ar(t){let e=[gr,dr];return t&&e.push(lr.of(t)),e}const cr=Ke.mark({class:"cm-selectionMatch"}),ur=Ke.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function fr(t,e,i,n){return!(0!=i&&t(e.sliceDoc(i-1,i))==bt.Word||n!=e.doc.length&&t(e.sliceDoc(n,n+1))==bt.Word)}const dr=mi.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(lr),{state:i}=t,n=i.selection;if(n.ranges.length>1)return Ke.none;let s,r=n.main,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return Ke.none;let t=i.wordAt(r.head);if(!t)return Ke.none;o=i.charCategorizer(r.head),s=i.sliceDoc(t.from,t.to)}else{let t=r.to-r.from;if(t<e.minSelectionLength||t>200)return Ke.none;if(e.wholeWords){if(s=i.sliceDoc(r.from,r.to),o=i.charCategorizer(r.head),!fr(o,i,r.from,r.to)||!function(t,e,i,n){return t(e.sliceDoc(i,i+1))==bt.Word&&t(e.sliceDoc(n-1,n))==bt.Word}(o,i,r.from,r.to))return Ke.none}else if(s=i.sliceDoc(r.from,r.to),!s)return Ke.none}let h=[];for(let n of t.visibleRanges){let t=new Us(i.doc,s,n.from,n.to);for(;!t.next().done;){let{from:n,to:s}=t.value;if((!o||fr(o,i,n,s))&&(r.empty&&n<=r.from&&s>=r.to?h.push(ur.range(n,s)):(n>=r.to||s<=r.from)&&h.push(cr.range(n,s)),h.length>e.maxMatches))return Ke.none}}return Ke.set(h)}},{decorations:t=>t.decorations}),gr=As.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const pr=I.define({combine:t=>Mt(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new Kr(t),scrollToMatch:t=>As.scrollIntoView(t)})});class mr{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,Xs),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new kr(this):new yr(this)}getCursor(t,e=0,i){let n=t.doc?t:At.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?br(this,n,e,i):vr(this,n,e,i)}}class wr{constructor(t){this.spec=t}}function vr(t,e,i,n){return new Us(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?(s=e.doc,r=e.charCategorizer(e.selection.main.head),(t,e,i,n)=>((n>t||n+i.length<e)&&(n=Math.max(0,t-2),i=s.sliceString(n,Math.min(s.length,e+2))),!(r(xr(i,t-n))==bt.Word&&r(Sr(i,t-n))==bt.Word||r(Sr(i,e-n))==bt.Word&&r(xr(i,e-n))==bt.Word))):void 0);var s,r}class yr extends wr{constructor(t){super(t)}nextMatch(t,e,i){let n=vr(this.spec,t,i,t.doc.length).nextOverlapping();if(n.done){let i=Math.min(t.doc.length,e+this.spec.unquoted.length);n=vr(this.spec,t,0,i).nextOverlapping()}return n.done||n.value.from==e&&n.value.to==i?null:n.value}prevMatchInRange(t,e,i){for(let n=i;;){let i=Math.max(e,n-1e4-this.spec.unquoted.length),s=vr(this.spec,t,i,n),r=null;for(;!s.nextOverlapping().done;)r=s.value;if(r)return r;if(i==e)return null;n-=1e4}}prevMatch(t,e,i){let n=this.prevMatchInRange(t,0,e);return n||(n=this.prevMatchInRange(t,Math.max(0,i-this.spec.unquoted.length),t.doc.length)),!n||n.from==e&&n.to==i?null:n}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let i=vr(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=vr(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function br(t,e,i,n){return new Qs(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(s=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(s(xr(i.input,i.index))!=bt.Word||s(Sr(i.input,i.index))!=bt.Word)&&(s(Sr(i.input,i.index+i[0].length))!=bt.Word||s(xr(i.input,i.index+i[0].length))!=bt.Word)):void 0},i,n);var s}function xr(t,e){return t.slice(p(t,e,!1),e)}function Sr(t,e){return t.slice(e,p(t,e))}class kr extends wr{nextMatch(t,e,i){let n=br(this.spec,t,i,t.doc.length).next();return n.done&&(n=br(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-1e4*n),r=br(this.spec,t,s,i),o=null;for(;!r.next().done;)o=r.value;if(o&&(s==e||o.from>s+10))return o;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,((e,i)=>"$"==i?"$":"&"==i?t.match[0]:"0"!=i&&+i<t.match.length?t.match[i]:e))}matchAll(t,e){let i=br(this.spec,t,0,t.doc.length),n=[];for(;!i.next().done;){if(n.length>=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=br(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const Ar=ft.define(),Mr=ft.define(),Cr=q.define({create:t=>new Or(Vr(t).create(),null),update(t,e){for(let i of e.effects)i.is(Ar)?t=new Or(i.value.create(),t.panel):i.is(Mr)&&(t=new Or(t.query,i.value?Hr:null));return t},provide:t=>Ks.from(t,(t=>t.panel))});class Or{constructor(t,e){this.query=t,this.panel=e}}const Dr=Ke.mark({class:"cm-searchMatch"}),Tr=Ke.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Er=mi.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Cr))}update(t){let e=t.state.field(Cr);(e!=t.startState.field(Cr)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Ke.none;let{view:i}=this,n=new Rt;for(let e=0,s=i.visibleRanges,r=s.length;e<r;e++){let{from:o,to:h}=s[e];for(;e<r-1&&h>s[e+1].from-500;)h=s[++e].to;t.highlight(i.state,o,h,((t,e)=>{let s=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,s?Tr:Dr)}))}return n.finish()}},{decorations:t=>t.decorations});function Rr(t){return e=>{let i=e.state.field(Cr,!1);return i&&i.query.spec.valid?t(e,i):zr(e)}}const Br=Rr(((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let s=P.single(n.from,n.to),r=t.state.facet(pr);return t.dispatch({selection:s,effects:[Jr(t,n),r.scrollToMatch(s.main,t)],userEvent:"select.search"}),Fr(t),!0})),Pr=Rr(((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,s=e.prevMatch(i,n,n);if(!s)return!1;let r=P.single(s.from,s.to),o=t.state.facet(pr);return t.dispatch({selection:r,effects:[Jr(t,s),o.scrollToMatch(r.main,t)],userEvent:"select.search"}),Fr(t),!0})),Lr=Rr(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length)&&(t.dispatch({selection:P.create(i.map((t=>P.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),Nr=Rr(((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let r=e.nextMatch(i,n,n);if(!r)return!1;let o,h,l=r,a=[],c=[];if(l.from==n&&l.to==s&&(h=i.toText(e.getReplacement(l)),a.push({from:l.from,to:l.to,insert:h}),l=e.nextMatch(i,l.from,l.to),c.push(As.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),l){let e=0==a.length||a[0].from>=r.to?0:r.to-r.from-h.length;o=P.single(l.from-e,l.to-e),c.push(Jr(t,l)),c.push(i.facet(pr).scrollToMatch(o.main,t))}return t.dispatch({changes:a,selection:o,effects:c,userEvent:"input.replace"}),!0})),Ir=Rr(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map((t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}}));if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:As.announce.of(n),userEvent:"input.replace.all"}),!0}));function Hr(t){return t.state.facet(pr).createPanel(t)}function Vr(t,e){var i,n,s,r,o;let h=t.selection.main,l=h.empty||h.to>h.from+100?"":t.sliceDoc(h.from,h.to);if(e&&!l)return e;let a=t.facet(pr);return new mr({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:a.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:a.caseSensitive,literal:null!==(s=null==e?void 0:e.literal)&&void 0!==s?s:a.literal,regexp:null!==(r=null==e?void 0:e.regexp)&&void 0!==r?r:a.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:a.wholeWord})}function Wr(t){let e=Fs(t,Hr);return e&&e.dom.querySelector("[main-field]")}function Fr(t){let e=Wr(t);e&&e==t.root.activeElement&&e.select()}const zr=t=>{let e=t.state.field(Cr,!1);if(e&&e.panel){let i=Wr(t);if(i&&i!=t.root.activeElement){let n=Vr(t.state,e.query.spec);n.valid&&t.dispatch({effects:Ar.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[Mr.of(!0),e?Ar.of(Vr(t.state,e.query.spec)):ft.appendConfig.of(Yr)]});return!0},_r=t=>{let e=t.state.field(Cr,!1);if(!e||!e.panel)return!1;let i=Fs(t,Hr);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Mr.of(!1)}),!0},qr=[{key:"Mod-f",run:zr,scope:"editor search-panel"},{key:"F3",run:Br,shift:Pr,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Br,shift:Pr,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:_r,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:s}=i.main,r=[],o=0;for(let e=new Us(t.doc,t.sliceDoc(n,s));!e.next().done;){if(r.length>1e3)return!1;e.value.from==n&&(o=r.length),r.push(P.range(e.value.from,e.value.to))}return e(t.update({selection:P.create(r,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=Fs(t,nr);if(!e){let i=[sr.of(!0)];null==t.state.field(rr,!1)&&i.push(ft.appendConfig.of([rr,or])),t.dispatch({effects:i}),e=Fs(t,nr)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=P.create(i.ranges.map((e=>t.wordAt(e.head)||P.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return!1;let s=function(t,e){let{main:i,ranges:n}=t.selection,s=t.wordAt(i.head),r=s&&s.from==i.from&&s.to==i.to;for(let i=!1,s=new Us(t.doc,e,n[n.length-1].to);;){if(s.next(),!s.done){if(i&&n.some((t=>t.from==s.value.from)))continue;if(r){let e=t.wordAt(s.value.from);if(!e||e.from!=s.value.from||e.to!=s.value.to)continue}return s.value}if(i)return null;s=new Us(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!s&&(e(t.update({selection:t.selection.addRange(P.range(s.from,s.to),!1),effects:As.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class Kr{constructor(t){this.view=t;let e=this.query=t.state.field(Cr).query.spec;function i(t,e,i){return $s("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=$s("input",{value:e.search,placeholder:jr(t,"Find"),"aria-label":jr(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=$s("input",{value:e.replace,placeholder:jr(t,"Replace"),"aria-label":jr(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=$s("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=$s("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=$s("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=$s("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Br(t)),[jr(t,"next")]),i("prev",(()=>Pr(t)),[jr(t,"previous")]),i("select",(()=>Lr(t)),[jr(t,"all")]),$s("label",null,[this.caseField,jr(t,"match case")]),$s("label",null,[this.reField,jr(t,"regexp")]),$s("label",null,[this.wordField,jr(t,"by word")]),...t.state.readOnly?[]:[$s("br"),this.replaceField,i("replace",(()=>Nr(t)),[jr(t,"replace")]),i("replaceAll",(()=>Ir(t)),[jr(t,"replace all")])],$s("button",{name:"close",onclick:()=>_r(t),"aria-label":jr(t,"close"),type:"button"},["×"])])}commit(){let t=new mr({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Ar.of(t)}))}keydown(t){var e,i,n;e=this.view,i=t,n="search-panel",Is(Ps(e.state),i,e,n)?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Pr:Br)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),Nr(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(Ar)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(pr).top}}function jr(t,e){return t.state.phrase(e)}const $r=30,Gr=/[\s\.,:;?!]/;function Jr(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(i).to,r=Math.max(n.from,e-$r),o=Math.min(s,i+$r),h=t.state.sliceDoc(r,o);if(r!=n.from)for(let t=0;t<$r;t++)if(!Gr.test(h[t+1])&&Gr.test(h[t])){h=h.slice(t);break}if(o!=s)for(let t=h.length-1;t>h.length-$r;t--)if(!Gr.test(h[t-1])&&Gr.test(h[t])){h=h.slice(0,t);break}return As.announce.of(`${t.state.phrase("current match")}. ${h} ${t.state.phrase("on line")} ${n.number}.`)}const Ur=As.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"}}),Yr=[Cr,U.low(Er),Ur]},96381:function(t,e,i){i.d(e,{BO:function(){return dt},F6:function(){return W},f_:function(){return yt},r$:function(){return T},yy:function(){return ft}});i(92745),i(32517),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(39527),i(92181),i(99790),i(67670),i(41360),i(13334),i(34595),i(36993);var n=i(23618);class s{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=d(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),o.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=d(this,t,e);let i=[];return this.decompose(t,e,i,0),o.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new a(this),s=new a(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new a(this,t)}iterRange(t,e=this.length){return new c(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new u(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new r(t):o.from(r.split(t,[])):s.empty}}class r extends s{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new f(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new r(l(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=h(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new r(e,t.length+s.length));else{let t=e.length>>1;i.push(new r(e.slice(0,t)),new r(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof r))return super.replace(t,e,i);[t,e]=d(this,t,e);let n=h(this.text,h(i.text,l(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new r(n,s):o.from(r.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new r(i,n)),i=[],n=-1);return n>-1&&e.push(new r(i,n)),e}}class o extends s{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=d(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],h=s+r.length;if(t>=s&&e<=h){let l=r.replace(t-s,e-s,i),a=this.lines-r.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new o(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof o))return 0;let i=0,[n,s,r,h]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==h)return i;let o=this.children[n],l=t.children[s];if(o!=l)return i+o.scanIdentical(l,e);i+=o.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new r(i,e)}let n=Math.max(32,i>>5),s=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>s&&t instanceof o)for(let e of t.children)f(e);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof r&&a&&(e=u[u.length-1])instanceof r&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new r(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:o.from(u,c)),c=-1,a=u.length=0)}for(let e of t)f(e);return d(),1==l.length?l[0]:new o(l,e)}}function h(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function l(t,e,i){return h(t,[""],e,i)}s.empty=new r([""],0);class a{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof r?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,h=n instanceof r?n.text.length:n.children.length;if(o==(e>0?h:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof r){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof r?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class c{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new a(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class u{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(s.prototype[Symbol.iterator]=function(){return this.iter()},a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=u.prototype[Symbol.iterator]=function(){return this});class f{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function d(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function g(t,e,i=!0,s=!0){return(0,n.c)(t,e,i,s)}const p=/\r\n?|\n/;var m=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(m||(m={}));class w{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){x(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new w(t)}composeDesc(t){return this.empty?t:t.empty?this:k(this,t)}mapDesc(t,e=!1){return t.empty?this:S(this,t,e)}mapPos(t,e=-1,i=m.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=m.Simple&&l>=t&&(i==m.TrackDel&&n<t&&l>t||i==m.TrackBefore&&n<t||i==m.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new w(t)}static create(t){return new w(t)}}class v extends w{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return x(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return S(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,r=0;n<e.length;n+=2){let o=e[n],h=e[n+1];if(h>=0){e[n]=h,e[n+1]=o;let l=n>>1;for(;i.length<l;)i.push(s.empty);i.push(o?t.slice(r,r+o):s.empty)}r+=o}return new v(e,i)}compose(t){return this.empty?t:t.empty?this:k(this,t,!0)}map(t,e=!1){return t.empty?this:S(this,t,e,!0)}iterChanges(t,e=!1){x(this,t,e)}get desc(){return w.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new A(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);y(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;y(e,t,r),r>0&&b(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);y(e,t,-1),y(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new v(e,i),filtered:w.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!n.length)return;o<e&&y(n,e-o,-1);let i=new v(n,r);h=h?h.compose(i.map(h)):i,n=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof v){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?s.of(c.split(i||p)):c:s.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&y(n,t-o,-1),y(n,h-t,f),b(r,n,u),o=h}}(t),l(!h),h}static empty(t){return new v(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let r=t[n];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<n;)i.push(s.empty);i[n]=s.of(r.slice(1)),e.push(r[0],i[n].length)}}}return new v(e,i)}static createSet(t,e){return new v(t,e)}}function y(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function b(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(s.empty);t.push(i)}}function x(t,e,i){let n=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=s.empty;for(;c+=l,u+=a,a&&n&&(f=f.append(n[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function S(t,e,i,n=!1){let s=[],r=n?[]:null,o=new A(t),h=new A(e);for(let t=-1;;){if(o.done&&h.len||h.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);y(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(y(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(y(s,0,o.ins),r&&b(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?v.createSet(s,r):w.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}y(s,e,t<o.i?o.ins:0),r&&t<o.i&&b(r,s,o.text),t=o.i,o.forward(o.len-i)}}}}function k(t,e,i=!1){let n=[],s=i?[]:null,r=new A(t),o=new A(e);for(let t=!1;;){if(r.done&&o.done)return s?v.createSet(n,s):w.create(n);if(0==r.ins)y(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;y(n,e,i,t),s&&i&&b(s,n,o.text)}else-1==o.ins?(y(n,r.off?0:r.len,e,t),s&&b(s,n,r.textBit(e))):(y(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&b(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else y(n,0,o.ins,t),s&&b(s,n,o.text),o.next()}}class A{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?s.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?s.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class M{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new M(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return C.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return C.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return C.range(t.anchor,t.head)}static create(t,e,i){return new M(t,e,i)}}class C{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:C.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new C([this.main],0)}addRange(t,e=!0){return C.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,C.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new C(t.ranges.map((t=>M.fromJSON(t))),t.main)}static single(t,e=t){return new C([C.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return C.normalized(t.slice(),e);i=s.to}return new C(t,e)}static cursor(t,e=0,i,n){return M.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?M.create(e,t,48|s):M.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?C.range(o,r):C.range(r,o))}}return new C(t,e)}}function O(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let D=0;class T{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=D++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new T(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:E),!!t.static,t.enables)}of(t){return new R([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function E(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class R{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=D++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||P(t,a)){let e=i(t);if(o?!B(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=q(e,l);if(this.dependencies.every((i=>i instanceof T?e.facet(i)===t.facet(i):!(i instanceof I)||e.field(i,!1)==t.field(i,!1)))||(o?B(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function B(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function P(t,e){let i=!1;for(let n of e)1&_(t,n)&&(i=!0);return i}function L(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=q(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)_(t,e);return t.values[o]=h(t),1},update(t,i){if(!P(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=P(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&E(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const N=T.define({static:!0});class I{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new I(D++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(N).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,N.of({field:this,create:t})]}get extension(){return this}}const H=2;class V{constructor(t,e){this.inner=t,this.prec=e}}class W{of(t){return new F(this,t)}reconfigure(t){return W.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class F{constructor(t,e){this.compartment=t,this.inner=e}}class z{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof F&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof F){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof V)r(t.inner,t.prec);else if(t instanceof I)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof R)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,H);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,H),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof I?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,E(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>L(t,n,e)))}}let c=l.map((t=>t(o)));return new z(t,r,c,o,h,s)}}function _(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function q(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const K=T.define(),j=T.define({combine:t=>t.some((t=>t)),static:!0}),$=T.define({combine:t=>t.length?t[0]:void 0,static:!0}),G=T.define(),J=T.define(),U=T.define(),Y=T.define({combine:t=>!!t.length&&t[0]});class X{constructor(t,e){this.type=t,this.value=e}static define(){return new Q}}class Q{of(t){return new X(this,t)}}class Z{constructor(t){this.map=t}of(t){return new tt(this,t)}}class tt{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new tt(this.type,e)}is(t){return this.type==t}static define(t={}){return new Z(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}tt.reconfigure=tt.define(),tt.appendConfig=tt.define();class et{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&O(i,e.newLength),s.some((t=>t.type==et.time))||(this.annotations=s.concat(et.time.of(Date.now())))}static create(t,e,i,n,s,r){return new et(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(et.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function it(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function nt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=v.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:tt.mapEffects(t.effects,s).concat(tt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function st(t,e,i){let n=e.selection,s=ht(e.annotations);return e.userEvent&&(s=s.concat(et.userEvent.of(e.userEvent))),{changes:e.changes instanceof v?e.changes:v.of(e.changes||[],i,t.facet($)),selection:n&&(n instanceof C?n:C.single(n.anchor,n.head)),effects:ht(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function rt(t,e,i){let n=st(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=nt(n,st(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=et.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(U),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=nt(n,st(e,r,t.changes.newLength),!0))}return n==t?t:et.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(G)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:it(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=v.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=et.create(e,n,t.selection&&t.selection.map(s),tt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(J);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof et?s:Array.isArray(s)&&1==s.length&&s[0]instanceof et?s[0]:rt(e,ht(s),!1)}return t}(s):s)}et.time=X.define(),et.userEvent=X.define(),et.addToHistory=X.define(),et.remote=X.define();const ot=[];function ht(t){return null==t?ot:Array.isArray(t)?t:[t]}var lt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(lt||(lt={}));const at=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ct;try{ct=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function ut(t){return e=>{if(!/\S/.test(e))return lt.Space;if(function(t){if(ct)return ct.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||at.test(i)))return!0}return!1}(e))return lt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return lt.Word;return lt.Other}}class ft{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)_(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return _(this,i),q(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return rt(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(W.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(tt.reconfigure)?(i=null,n=e.value):e.is(tt.appendConfig)&&(i=null,n=ht(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=z.resolve(n,s,this),e=new ft(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(j)?t.newSelection:t.newSelection.asSingle();new ft(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:C.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=ht(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=tt.mapEffects(r,l).concat(tt.mapEffects(ht(o.effects),a))}return{changes:n,selection:C.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof v?t:v.of(t,this.doc.length,this.facet(ft.lineSeparator))}toText(t){return s.of(t.split(this.facet(ft.lineSeparator)||p))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(_(this,e),q(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof I&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return ft.create({doc:t.doc,selection:C.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=z.resolve(t.extensions||[],new Map),i=t.doc instanceof s?t.doc:s.of((t.doc||"").split(e.staticFacet(ft.lineSeparator)||p)),n=t.selection?t.selection instanceof C?t.selection:C.single(t.selection.anchor,t.selection.head):C.single(0);return O(n,i.length),e.staticFacet(j)||(n=n.asSingle()),new ft(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(ft.tabSize)}get lineBreak(){return this.facet(ft.lineSeparator)||"\n"}get readOnly(){return this.facet(Y)}phrase(t,...e){for(let e of this.facet(ft.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(K))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return ut(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=g(e,r,!1);if(s(e.slice(t,r))!=lt.Word)break;r=t}for(;o<n;){let t=g(e,o);if(s(e.slice(o,t))!=lt.Word)break;o=t}return r==o?null:C.range(r+i,o+i)}}function dt(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}ft.allowMultipleSelections=j,ft.tabSize=T.define({combine:t=>t.length?t[0]:4}),ft.lineSeparator=$,ft.readOnly=Y,ft.phrases=T.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),ft.languageData=K,ft.changeFilter=G,ft.transactionFilter=J,ft.transactionExtender=U,W.reconfigure=tt.define();class gt{eq(t){return this==t}range(t,e=t){return pt.create(t,e,this)}}gt.prototype.startSide=gt.prototype.endSide=0,gt.prototype.point=!1,gt.prototype.mapMode=m.TrackDel;class pt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new pt(t,e,i)}}function mt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class wt{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new wt(n,s,i,o):null,pos:r}}}class vt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new vt(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(mt)),this.isEmpty)return e.length?vt.of(e):this;let o=new xt(this,null,-1).goto(0),h=0,l=[],a=new yt;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(pt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?vt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new vt(i,e,s||vt.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return St.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return St.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=bt(r,o,i),l=new At(r,h,s),a=new At(o,h,s);i.iterGaps(((t,e,i)=>Mt(l,t,a,e,i,n))),i.empty&&0==i.length&&Mt(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=bt(s,r),h=new At(s,o,0).goto(i),l=new At(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Ct(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new At(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:r.point.startSide<0?i.length:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new yt;for(let n of t instanceof pt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(mt(e,n)>0)return t.slice().sort(mt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return vt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=vt.empty;n=n.nextLayer)e=new vt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}vt.empty=new vt([],[],null,-1),vt.empty.nextLayer=vt.empty;class yt{finishChunk(t){this.chunks.push(new wt(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new yt)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(vt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=vt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function bt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class xt{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class St{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new xt(r,e,i,s));return 1==n.length?n[0]:new St(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)kt(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)kt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),kt(this.heap,0)}}}function kt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class At{constructor(t,e,i){this.minPoint=i,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=St.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){Ot(this.active,t),Ot(this.activeTo,t),Ot(this.activeRank,t),this.minActive=Tt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;Dt(this.active,e,i),Dt(this.activeTo,e,n),Dt(this.activeRank,e,s),t&&Dt(t,e,this.cursor.from),this.minActive=Tt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ot(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Mt(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+l:i.to,a=Math.min(s,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ct(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,a,t.point,i.point):a>h&&!Ct(t.active,i.active)&&r.compareRange(h,a,t.active,i.active),s>o)break;(e||t.openEnd!=i.openEnd)&&r.boundChange&&r.boundChange(s),h=s,n<=0&&t.next(),n>=0&&i.next()}}function Ct(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Ot(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Dt(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Tt(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}},84478:function(t,e,i){i.d(e,{Zs:()=>xr,Uw:()=>lr,Eu:()=>qr,$f:()=>Gs,lg:()=>zi,tk:()=>Fs,ZO:()=>pr,p:()=>Ke,S2:()=>Ar});i("92745"),i("84283"),i("32517"),i("92519"),i("42179"),i("89256"),i("24931"),i("88463"),i("57449"),i("19814"),i("39527"),i("37210"),i("92181"),i("99790"),i("67670"),i("41360"),i("13334"),i("34595"),i("36993");var n=i("23618");class s{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=d(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),o.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=d(this,t,e);let i=[];return this.decompose(t,e,i,0),o.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new a(this),s=new a(t);for(let t=e,r=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new a(this,t)}iterRange(t,e=this.length){return new c(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new u(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new r(t):o.from(r.split(t,[])):s.empty}}class r extends s{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new f(n,o,i,r);n=o+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new r(l(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=h(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new r(e,t.length+s.length));else{let t=e.length>>1;i.push(new r(e.slice(0,t)),new r(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof r))return super.replace(t,e,i);[t,e]=d(this,t,e);let n=h(this.text,h(i.text,l(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new r(n,s):o.from(r.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<=e&&r<this.text.length;r++){let o=this.text[r],h=s+o.length;s>t&&r&&(n+=i),t<h&&e>s&&(n+=o.slice(Math.max(0,t-s),e-s)),s=h+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new r(i,n)),i=[],n=-1);return n>-1&&e.push(new r(i,n)),e}}class o extends s{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let r=this.children[s],o=n+r.length,h=i+r.lines-1;if((e?h:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=h+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s<this.children.length;s++){let o=this.children[s],h=r+o.length;if(t<=h&&e>=r){let s=n&((r<=t?1:0)|(h>=e?2:0));r>=t&&h<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=h+1}}replace(t,e,i){if([t,e]=d(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],h=s+r.length;if(t>=s&&e<=h){let l=r.replace(t-s,e-s,i),a=this.lines-r.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new o(s,this.length-(e-t)+i.length)}return super.replace(s,h,l)}s=h+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=d(this,t,e);let n="";for(let s=0,r=0;s<this.children.length&&r<=e;s++){let o=this.children[s],h=r+o.length;r>t&&s&&(n+=i),t<h&&e>r&&(n+=o.sliceString(t-r,e-r,i)),r=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof o))return 0;let i=0,[n,s,r,h]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==r||s==h)return i;let o=this.children[n],l=t.children[s];if(o!=l)return i+o.scanIdentical(l,e);i+=o.length+1}}static from(t,e=t.reduce(((t,e)=>t+e.length+1),-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new r(i,e)}let n=Math.max(32,i>>5),s=n<<1,h=n>>1,l=[],a=0,c=-1,u=[];function f(t){let e;if(t.lines>s&&t instanceof o)for(let e of t.children)f(e);else t.lines>h&&(a>h||!a)?(d(),l.push(t)):t instanceof r&&a&&(e=u[u.length-1])instanceof r&&t.lines+e.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new r(e.text.concat(t.text),e.length+1+t.length)):(a+t.lines>n&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(l.push(1==u.length?u[0]:o.from(u,c)),c=-1,a=u.length=0)}for(let e of t)f(e);return d(),1==l.length?l[0]:new o(l,e)}}function h(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r<t.length&&s<=n;r++){let h=t[r],l=s+h.length;l>=i&&(l>n&&(h=h.slice(0,n-s)),s<i&&(h=h.slice(i-s)),o?(e[e.length-1]+=h,o=!1):e.push(h)),s=l+1}return e}function l(t,e,i){return h(t,[""],e,i)}s.empty=new r([""],0);class a{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof r?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,h=n instanceof r?n.text.length:n.children.length;if(o==(e>0?h:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof r){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof r?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class c{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new a(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(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);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=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)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class u{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(s.prototype[Symbol.iterator]=function(){return this.iter()},a.prototype[Symbol.iterator]=c.prototype[Symbol.iterator]=u.prototype[Symbol.iterator]=function(){return this});class f{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function d(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function g(t,e,i=!0,s=!0){return(0,n.c)(t,e,i,s)}const p=/\r\n?|\n/;var m=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(m||(m={}));class w{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],r=this.sections[e++];r<0?(t(i,n,s),n+=s):n+=r,i+=s}}iterChangedRanges(t,e=!1){x(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new w(t)}composeDesc(t){return this.empty?t:t.empty?this:k(this,t)}mapDesc(t,e=!1){return t.empty?this:S(this,t,e)}mapPos(t,e=-1,i=m.Simple){let n=0,s=0;for(let r=0;r<this.sections.length;){let o=this.sections[r++],h=this.sections[r++],l=n+o;if(h<0){if(l>t)return s+(t-n);s+=o}else{if(i!=m.Simple&&l>=t&&(i==m.TrackDel&&n<t&&l>t||i==m.TrackBefore&&n<t||i==m.TrackAfter&&l>t))return null;if(l>t||l==t&&e<0&&!o)return t==n||e<0?s:s+h;s+=h}n=l}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some((t=>"number"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new w(t)}static create(t){return new w(t)}}class v extends w{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return x(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return S(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,r=0;n<e.length;n+=2){let o=e[n],h=e[n+1];if(h>=0){e[n]=h,e[n+1]=o;let l=n>>1;for(;i.length<l;)i.push(s.empty);i.push(o?t.slice(r,r+o):s.empty)}r+=o}return new v(e,i)}compose(t){return this.empty?t:t.empty?this:k(this,t,!0)}map(t,e=!1){return t.empty?this:S(this,t,e,!0)}iterChanges(t,e=!1){x(this,t,e)}get desc(){return w.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new A(this);t:for(let r=0,o=0;;){let h=r==t.length?1e9:t[r++];for(;o<h||o==h&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,h-o);y(n,t,-1);let r=-1==s.ins?-1:0==s.off?s.ins:0;y(e,t,r),r>0&&b(i,e,s.text),s.forward(t),o+=t}let l=t[r++];for(;o<l;){if(s.done)break t;let t=Math.min(s.len,l-o);y(e,t,-1),y(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),o+=t}}return{changes:new v(e,i),filtered:w.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],r=[],o=0,h=null;function l(t=!1){if(!t&&!n.length)return;o<e&&y(n,e-o,-1);let i=new v(n,r);h=h?h.compose(i.map(h)):i,n=[],r=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof v){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),h=h?h.compose(a.map(h)):a}else{let{from:t,to:h=t,insert:c}=a;if(t>h||t<0||h>e)throw new RangeError(`Invalid change range ${t} to ${h} (in doc of length ${e})`);let u=c?"string"==typeof c?s.of(c.split(i||p)):c:s.empty,f=u.length;if(t==h&&0==f)return;t<o&&l(),t>o&&y(n,t-o,-1),y(n,h-t,f),b(r,n,u),o=h}}(t),l(!h),h}static empty(t){return new v(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let r=t[n];if("number"==typeof r)e.push(r,-1);else{if(!Array.isArray(r)||"number"!=typeof r[0]||r.some(((t,e)=>e&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length<n;)i.push(s.empty);i[n]=s.of(r.slice(1)),e.push(r[0],i[n].length)}}}return new v(e,i)}static createSet(t,e){return new v(t,e)}}function y(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function b(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(s.empty);t.push(i)}}function x(t,e,i){let n=t.inserted;for(let r=0,o=0,h=0;h<t.sections.length;){let l=t.sections[h++],a=t.sections[h++];if(a<0)r+=l,o+=l;else{let c=r,u=o,f=s.empty;for(;c+=l,u+=a,a&&n&&(f=f.append(n[h-2>>1])),!(i||h==t.sections.length||t.sections[h+1]<0);)l=t.sections[h++],a=t.sections[h++];e(r,c,o,u,f),r=c,o=u}}}function S(t,e,i,n=!1){let s=[],r=n?[]:null,o=new A(t),h=new A(e);for(let t=-1;;){if(o.done&&h.len||h.done&&o.len)throw new Error("Mismatched change set lengths");if(-1==o.ins&&-1==h.ins){let t=Math.min(o.len,h.len);y(s,t,-1),o.forward(t),h.forward(t)}else if(h.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(h.len<o.len||h.len==o.len&&!i))){let e=h.len;for(y(s,h.ins,-1);e;){let i=Math.min(o.len,e);o.ins>=0&&t<o.i&&o.len<=i&&(y(s,0,o.ins),r&&b(r,s,o.text),t=o.i),o.forward(i),e-=i}h.next()}else{if(!(o.ins>=0)){if(o.done&&h.done)return r?v.createSet(s,r):w.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.len;for(;i;)if(-1==h.ins){let t=Math.min(i,h.len);e+=t,i-=t,h.forward(t)}else{if(!(0==h.ins&&h.len<i))break;i-=h.len,h.next()}y(s,e,t<o.i?o.ins:0),r&&t<o.i&&b(r,s,o.text),t=o.i,o.forward(o.len-i)}}}}function k(t,e,i=!1){let n=[],s=i?[]:null,r=new A(t),o=new A(e);for(let t=!1;;){if(r.done&&o.done)return s?v.createSet(n,s):w.create(n);if(0==r.ins)y(n,r.len,0,t),r.next();else if(0!=o.len||o.done){if(r.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(r.len2,o.len),i=n.length;if(-1==r.ins){let i=-1==o.ins?-1:o.off?0:o.ins;y(n,e,i,t),s&&i&&b(s,n,o.text)}else-1==o.ins?(y(n,r.off?0:r.len,e,t),s&&b(s,n,r.textBit(e))):(y(n,r.off?0:r.len,o.off?0:o.ins,t),s&&!o.off&&b(s,n,o.text));t=(r.ins>e||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else y(n,0,o.ins,t),s&&b(s,n,o.text),o.next()}}class A{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?s.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?s.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class M{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new M(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return C.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return C.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return C.range(t.anchor,t.head)}static create(t,e,i){return new M(t,e,i)}}class C{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:C.create(this.ranges.map((i=>i.map(t,e))),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new C([this.main],0)}addRange(t,e=!0){return C.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,C.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((t=>t.toJSON())),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new C(t.ranges.map((t=>M.fromJSON(t))),t.main)}static single(t,e=t){return new C([C.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return C.normalized(t.slice(),e);i=s.to}return new C(t,e)}static cursor(t,e=0,i,n){return M.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?M.create(e,t,48|s):M.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort(((t,e)=>t.from-e.from)),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let r=s.from,o=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?C.range(o,r):C.range(r,o))}}return new C(t,e)}}function O(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let D=0;class T{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=D++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new T(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:E),!!t.static,t.enables)}of(t){return new R([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new R(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function E(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class R{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=D++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,h=!1,l=!1,a=[];for(let i of this.dependencies)"doc"==i?h=!0:"selection"==i?l=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(h&&e.docChanged||l&&(e.docChanged||e.selection)||P(t,a)){let e=i(t);if(o?!B(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let h,l=e.config.address[s];if(null!=l){let s=J(e,l);if(this.dependencies.every((i=>i instanceof T?e.facet(i)===t.facet(i):!(i instanceof I)||e.field(i,!1)==t.field(i,!1)))||(o?B(h=i(t),s,n):n(h=i(t),s)))return t.values[r]=s,0}else h=i(t);return t.values[r]=h,1}}}}function B(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function P(t,e){let i=!1;for(let n of e)1&G(t,n)&&(i=!0);return i}function L(t,e,i){let n=i.map((e=>t[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function h(t){let i=[];for(let e=0;e<n.length;e++){let r=J(t,n[e]);if(2==s[e])for(let t of r)i.push(t);else i.push(r)}return e.combine(i)}return{create(t){for(let e of n)G(t,e);return t.values[o]=h(t),1},update(t,i){if(!P(t,r))return 0;let n=h(t);return e.compare(n,t.values[o])?0:(t.values[o]=n,1)},reconfigure(t,s){let r=P(t,n),l=s.config.facets[e.id],a=s.facet(e);if(l&&!r&&E(i,l))return t.values[o]=a,0;let c=h(t);return e.compare(c,a)?(t.values[o]=a,0):(t.values[o]=c,1)}}}const N=T.define({static:!0});class I{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new I(D++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(N).find((t=>t.field==this));return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,N.of({field:this,create:t})]}get extension(){return this}}const H=4,V=3,W=2,F=1;function z(t){return e=>new q(e,t)}const _={highest:z(0),high:z(F),default:z(W),low:z(V),lowest:z(H)};class q{constructor(t,e){this.inner=t,this.prec=e}}class K{of(t){return new j(this,t)}reconfigure(t){return K.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class j{constructor(t,e){this.compartment=t,this.inner=e}}class ${constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let h=s.get(t);if(null!=h){if(h<=o)return;let e=n[h].indexOf(t);e>-1&&n[h].splice(e,1),t instanceof j&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof j){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),r(n,o)}else if(t instanceof q)r(t.inner,t.prec);else if(t instanceof I)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof R)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,W);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(e,o)}}return r(t,W),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof I?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),h=[],l=[];for(let t of n)o[t.id]=l.length<<1,l.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=h.length<<1|1,E(r,e))h.push(i.facet(n));else{let t=n.combine(e.map((t=>t.value)));h.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(o[t.id]=h.length<<1|1,h.push(t.value)):(o[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));o[n.id]=l.length<<1,l.push((t=>L(t,n,e)))}}let c=l.map((t=>t(o)));return new $(t,r,c,o,h,s)}}function G(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function J(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const U=T.define(),Y=T.define({combine:t=>t.some((t=>t)),static:!0}),X=T.define({combine:t=>t.length?t[0]:void 0,static:!0}),Q=T.define(),Z=T.define(),tt=T.define(),et=T.define({combine:t=>!!t.length&&t[0]});class it{constructor(t,e){this.type=t,this.value=e}static define(){return new nt}}class nt{of(t){return new it(this,t)}}class st{constructor(t){this.map=t}of(t){return new rt(this,t)}}class rt{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new rt(this.type,e)}is(t){return this.type==t}static define(t={}){return new st(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}rt.reconfigure=rt.define(),rt.appendConfig=rt.define();class ot{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&O(i,e.newLength),s.some((t=>t.type==ot.time))||(this.annotations=s.concat(ot.time.of(Date.now())))}static create(t,e,i,n,s,r){return new ot(t,e,i,n,s,r)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(ot.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function ht(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n<t.length&&(s==e.length||e[s]>=t[n]))r=t[n++],o=t[n++];else{if(!(s<e.length))return i;r=e[s++],o=e[s++]}!i.length||i[i.length-1]<r?i.push(r,o):i[i.length-1]<o&&(i[i.length-1]=o)}}function lt(t,e,i){var n;let s,r,o;return i?(s=e.changes,r=v.empty(e.changes.length),o=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),r=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:rt.mapEffects(t.effects,s).concat(rt.mapEffects(e.effects,r)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function at(t,e,i){let n=e.selection,s=ft(e.annotations);return e.userEvent&&(s=s.concat(ot.userEvent.of(e.userEvent))),{changes:e.changes instanceof v?e.changes:v.of(e.changes||[],i,t.facet(X)),selection:n&&(n instanceof C?n:C.single(n.anchor,n.head)),effects:ft(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function ct(t,e,i){let n=at(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let r=!!e[s].sequential;n=lt(n,at(t,e[s],r?n.changes.newLength:t.doc.length),r)}let s=ot.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(tt),n=t;for(let s=i.length-1;s>=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=lt(n,at(e,r,t.changes.newLength),!0))}return n==t?t:ot.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(Q)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:ht(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=v.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=ot.create(e,n,t.selection&&t.selection.map(s),rt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(Z);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof ot?s:Array.isArray(s)&&1==s.length&&s[0]instanceof ot?s[0]:ct(e,ft(s),!1)}return t}(s):s)}ot.time=it.define(),ot.userEvent=it.define(),ot.addToHistory=it.define(),ot.remote=it.define();const ut=[];function ft(t){return null==t?ut:Array.isArray(t)?t:[t]}var dt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(dt||(dt={}));const gt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let pt;try{pt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function mt(t){return e=>{if(!/\S/.test(e))return dt.Space;if(function(t){if(pt)return pt.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||gt.test(i)))return!0}return!1}(e))return dt.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return dt.Word;return dt.Other}}class wt{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)G(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return G(this,i),J(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return ct(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(K.reconfigure)?(i&&(s=new Map,i.compartments.forEach(((t,e)=>s.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(rt.reconfigure)?(i=null,n=e.value):e.is(rt.appendConfig)&&(i=null,n=ft(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=$.resolve(n,s,this),e=new wt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(Y)?t.newSelection:t.newSelection.asSingle();new wt(i,t.newDoc,r,e,((e,i)=>i.update(e,t)),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t},range:C.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=ft(i.effects);for(let i=1;i<e.ranges.length;i++){let o=t(e.ranges[i]),h=this.changes(o.changes),l=h.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(l);let a=n.mapDesc(h,!0);s.push(o.range.map(a)),n=n.compose(l),r=rt.mapEffects(r,l).concat(rt.mapEffects(ft(o.effects),a))}return{changes:n,selection:C.create(s,e.mainIndex),effects:r}}changes(t=[]){return t instanceof v?t:v.of(t,this.doc.length,this.facet(wt.lineSeparator))}toText(t){return s.of(t.split(this.facet(wt.lineSeparator)||p))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(G(this,e),J(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof I&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],r=t[e];n.push(s.init((t=>s.spec.fromJSON(r,t))))}return wt.create({doc:t.doc,selection:C.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=$.resolve(t.extensions||[],new Map),i=t.doc instanceof s?t.doc:s.of((t.doc||"").split(e.staticFacet(wt.lineSeparator)||p)),n=t.selection?t.selection instanceof C?t.selection:C.single(t.selection.anchor,t.selection.head):C.single(0);return O(n,i.length),e.staticFacet(Y)||(n=n.asSingle()),new wt(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||"\n"}get readOnly(){return this.facet(et)}phrase(t,...e){for(let e of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,((t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]}))),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(U))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return mt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=g(e,r,!1);if(s(e.slice(t,r))!=dt.Word)break;r=t}for(;o<n;){let t=g(e,o);if(s(e.slice(o,t))!=dt.Word)break;o=t}return r==o?null:C.range(r+i,o+i)}}function vt(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],r=n[t];if(void 0===r)n[t]=s;else if(r===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](r,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}wt.allowMultipleSelections=Y,wt.tabSize=T.define({combine:t=>t.length?t[0]:4}),wt.lineSeparator=X,wt.readOnly=et,wt.phrases=T.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every((i=>t[i]==e[i]))}}),wt.languageData=U,wt.changeFilter=Q,wt.transactionFilter=Z,wt.transactionExtender=tt,K.reconfigure=rt.define();class yt{eq(t){return this==t}range(t,e=t){return bt.create(t,e,this)}}yt.prototype.startSide=yt.prototype.endSide=0,yt.prototype.point=!1,yt.prototype.mapMode=m.TrackDel;class bt{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new bt(t,e,i)}}function xt(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class St{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,h=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return h>=0?r:o;h>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);s<r;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],r=-1,o=-1;for(let h=0;h<this.value.length;h++){let l,a,c=this.value[h],u=this.from[h]+t,f=this.to[h]+t;if(u==f){let t=e.mapPos(u,c.startSide,c.mapMode);if(null==t)continue;if(l=a=t,c.startSide!=c.endSide&&(a=e.mapPos(u,c.endSide),a<l))continue}else if(l=e.mapPos(u,c.startSide),a=e.mapPos(f,c.endSide),l>a||l==a&&c.startSide>0&&c.endSide<=0)continue;(a-l||c.endSide-c.startSide)<0||(r<0&&(r=l),c.point&&(o=Math.max(o,a-l)),i.push(c),n.push(l-r),s.push(a-r))}return{mapped:i.length?new St(n,s,i,o):null,pos:r}}}class kt{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new kt(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(xt)),this.isEmpty)return e.length?kt.of(e):this;let o=new Ct(this,null,-1).goto(0),h=0,l=[],a=new At;for(;o.value||h<e.length;)if(h<e.length&&(o.from-e[h].from||o.startSide-e[h].value.startSide)>=0){let t=e[h++];a.addInner(t.from,t.to,t.value)||l.push(t)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(o.chunkIndex)<e[h].from)&&(!r||n>this.chunkEnd(o.chunkIndex)||s<this.chunkPos[o.chunkIndex])&&a.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!r||n>o.to||s<o.from||r(o.from,o.to,o.value))&&(a.addInner(o.from,o.to,o.value)||l.push(bt.create(o.from,o.to,o.value))),o.next());return a.finishInner(this.nextLayer.isEmpty&&!l.length?kt.empty:this.nextLayer.update({add:l,filter:r,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s],h=t.touchesRange(r,r+o.length);if(!1===h)n=Math.max(n,o.maxPoint),e.push(o),i.push(t.mapPos(r));else if(!0===h){let{mapped:s,pos:h}=o.map(r,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(h))}}let s=this.nextLayer.map(t);return 0==e.length?s:new kt(i,e,s||kt.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],r=this.chunk[n];if(e>=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Ot.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Ot.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),h=Mt(r,o,i),l=new Tt(r,h,s),a=new Tt(o,h,s);i.iterGaps(((t,e,i)=>Et(l,t,a,e,i,n))),i.empty&&0==i.length&&Et(l,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=Mt(s,r),h=new Tt(s,o,0).goto(i),l=new Tt(r,o,0).goto(i);for(;;){if(h.to!=l.to||!Rt(h.active,l.active)||h.point&&(!l.point||!h.point.eq(l.point)))return!1;if(h.to>n)return!0;h.next(),l.next()}}static spans(t,e,i,n,s=-1){let r=new Tt(t,null,s).goto(e),o=e,h=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFrom<e?i.length+1:r.point.startSide<0?i.length:Math.min(i.length,h);n.point(o,t,r.point,i,s,r.pointRank),h=Math.min(r.openEnd(t),i.length)}else t>o&&(n.span(o,t,r.active,h),h=r.openEnd(t));if(r.to>i)return h+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new At;for(let n of t instanceof bt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(xt(e,n)>0)return t.slice().sort(xt);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return kt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=kt.empty;n=n.nextLayer)e=new kt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}kt.empty=new kt([],[],null,-1),kt.empty.nextLayer=kt.empty;class At{finishChunk(t){this.chunks.push(new St(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=[])}constructor(){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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new At)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<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=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(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);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(kt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=kt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Mt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let r=n.get(t.chunk[e]);null==r||(i?i.mapPos(r):r)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(r,r+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Ct{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,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}}}setRangeIndex(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}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Ot{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let r=t[s];!r.isEmpty;r=r.nextLayer)r.maxPoint>=i&&n.push(new Ct(r,e,i,s));return 1==n.length?n[0]:new Ot(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Dt(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Dt(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Dt(this.heap,0)}}}function Dt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class Tt{constructor(t,e,i){this.minPoint=i,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=Ot.from(t,e,i)}goto(t,e=-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}forward(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)}removeActive(t){Bt(this.active,t),Bt(this.activeTo,t),Bt(this.activeRank,t),this.minActive=Lt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;Pt(this.active,e,i),Pt(this.activeTo,e,n),Pt(this.activeRank,e,s),t&&Pt(t,e,this.cursor.from),this.minActive=Lt(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Bt(i,n)}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}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Et(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,h=n,l=n-e;for(;;){let e=t.to+l-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+l:i.to,a=Math.min(s,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Rt(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(h,a,t.point,i.point):a>h&&!Rt(t.active,i.active)&&r.compareRange(h,a,t.active,i.active),s>o)break;(e||t.openEnd!=i.openEnd)&&r.boundChange&&r.boundChange(s),h=s,n<=0&&t.next(),n>=0&&i.next()}}function Rt(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Bt(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function Pt(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function Lt(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}function Nt(t,e,i,n){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=g(t,n)}return!0===n?-1:t.length}const It="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Ht="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Vt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Wt{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=Vt[It]||1;return Vt[It]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[Ht],s=i&&i.nonce;n?s&&n.setNonce(s):n=new zt(t,s),n.mount(Array.isArray(e)?e:[e])}}let Ft=new Map;class zt{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=Ft.get(i);if(e)return t.adoptedStyleSheets=[e.sheet,...t.adoptedStyleSheets],t[Ht]=e;this.sheet=new n.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],Ft.set(i,this)}else{this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);let n=t.head||t;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],t[Ht]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}var _t=i("96318");function qt(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function Kt(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function jt(t,e){if(!e.anchorNode)return!1;try{return Kt(t,e.anchorNode)}catch(t){return!1}}function $t(t){return 3==t.nodeType?re(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function Gt(t,e,i,n){return!!i&&(Yt(t,e,i,n,-1)||Yt(t,e,i,n,1))}function Jt(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function Ut(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Yt(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:Xt(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=Jt(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?Xt(t):0}}}function Xt(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Qt(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function Zt(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function te(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class ee{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?Xt(e):0),i,Math.min(t.focusOffset,i?Xt(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ie,ne=null;function se(t){if(t.setActive)return t.setActive();if(ne)return t.focus(ne);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==ne?{get preventScroll(){return ne={preventScroll:!0},!0}}:void 0),!ne){ne=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function re(t,e,i=e){let n=ie||(ie=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function oe(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,t.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,t.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function he(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function le(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function ae(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=Xt(i)}else{if(!i.parentNode||Ut(i))return null;n=Jt(i),i=i.parentNode}}}function ce(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||Ut(i))return null;n=Jt(i)+1,i=i.parentNode}}}class ue{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new ue(t.parentNode,Jt(t),e)}static after(t,e){return new ue(t.parentNode,Jt(t)+1,e)}}const fe=[];class de{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let r of this.children){if(7&r.flags){if(!r.dom&&(i=s?s.nextSibling:n.firstChild)){let t=de.get(i);(!t||!t.parent&&t.canReuseDOM(r))&&r.reuseDOM(i)}r.sync(t,e),r.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=r.dom&&(e.written=!0),r.dom.parentNode==n)for(;i&&i!=r.dom;)i=ge(i);else n.insertBefore(r.dom,i);s=r.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=ge(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==Xt(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!de.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,r=-1,o=-1;for(let h=0,l=i,a=i;h<this.children.length;h++){let i=this.children[h],c=l+i.length;if(l<t&&c>e)return i.domBoundsAround(t,e,l);if(c>=t&&-1==n&&(n=h,s=l),l>e&&i.dom.parentNode==this.dom){r=h,o=a;break}a=c,l=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r<this.children.length&&r>=0?this.children[r].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=fe){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new pe(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,r){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function ge(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}de.prototype.breakAfter=0;class pe{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){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;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function me(t,e,i,n,s,r,o,h,l){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,h,l))){if(n<a.length){let t=a[n];t&&(s<t.length||t.breakAfter&&(null==u?void 0:u.breakAfter))?(e==n&&(t=t.split(s),s=0),!f&&u&&t.merge(0,s,u,!0,0,l)?r[r.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,l),r.push(t))):(null==t?void 0:t.breakAfter)&&(u?u.breakAfter=1:o=1),n++}for(c&&(c.breakAfter=o,i>0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,h,0)?c.breakAfter=r.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,h,0),e++));e<n&&r.length;)if(a[n-1].become(r[r.length-1]))n--,r.pop(),l=r.length?0:h;else{if(!a[e].become(r[0]))break;e++,r.shift(),h=r.length?0:l}!r.length&&e&&n<a.length&&!a[e-1].breakAfter&&a[n].merge(0,0,a[e-1],!1,h,l)&&e--,(e<n||r.length)&&t.replaceChildren(e,n,r)}}function we(t,e,i,n,s,r){let o=t.childCursor(),{i:h,off:l}=o.findPos(i,1),{i:a,off:c}=o.findPos(e,-1),u=e-i;for(let t of n)u+=t.length;t.length+=u,me(t,a,c,h,l,n,0,s,r)}let ve="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ye="undefined"!=typeof document?document:{documentElement:{style:{}}};const be=/Edge\/(\d+)/.exec(ve.userAgent),xe=/MSIE \d/.test(ve.userAgent),Se=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ve.userAgent),ke=!!(xe||Se||be),Ae=!ke&&/gecko\/(\d+)/i.test(ve.userAgent),Me=!ke&&/Chrome\/(\d+)/.exec(ve.userAgent),Ce="webkitFontSmoothing"in ye.documentElement.style,Oe=!ke&&/Apple Computer/.test(ve.vendor),De=Oe&&(/Mobile\/\w+/.test(ve.userAgent)||ve.maxTouchPoints>2);var Te={mac:De||/Mac/.test(ve.platform),windows:/Win/.test(ve.platform),linux:/Linux|X11/.test(ve.platform),ie:ke,ie_version:xe?ye.documentMode||6:Se?+Se[1]:be?+be[1]:0,gecko:Ae,gecko_version:Ae?+(/Firefox\/(\d+)/.exec(ve.userAgent)||[0,0])[1]:0,chrome:!!Me,chrome_version:Me?+Me[1]:0,ios:De,android:/Android\b/.test(ve.userAgent),webkit:Ce,safari:Oe,webkit_version:Ce?+(/\bAppleWebKit\/(\d+)/.exec(ve.userAgent)||[0,0])[1]:0,tabSize:null!=ye.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ee extends de{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof Ee)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Ee(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new ue(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,r=e,o=0;0==e&&i<0||e==n&&i>=0?Te.chrome||Te.gecko||(e?(s--,o=1):r<n&&(r++,o=-1)):i<0?s--:r<n&&r++;let h=re(t,s,r).getClientRects();if(!h.length)return null;let l=h[(o?o<0:i>=0)?0:h.length-1];Te.safari&&!o&&0==l.width&&(l=Array.prototype.find.call(h,(t=>t.width))||l);return o?Qt(l,o<0):l||null}(this.dom,t,e)}}class Re extends de{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(he(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,r){return(!i||!(!(i instanceof Re&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&r<=0))&&(we(this,t,e,i?i.children.slice():[],s-1,r-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let r of this.children){let o=i+r.length;o>t&&e.push(i<t?r.split(t-i):r),n<0&&i>=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Re(this.mark,e,r)}domAtPos(t){return Le(this,t)}coordsAt(t,e){return Ie(this,t,e)}}class Be extends de{static create(t,e,i){return new Be(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=Be.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Be&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof Be&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return s.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):s.empty}domAtPos(t){return(this.length?0==t:this.side>0)?ue.before(this.dom):ue.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=r?-1:1);return Qt(s,!r)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class Pe extends de{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof Pe&&t.side==this.side}split(){return new Pe(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?ue.before(this.dom):ue.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return s.empty}get isHidden(){return!0}}function Le(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let r=n[s],o=t+r.length;if(!(o==t&&r.getSide()<=0)){if(e>t&&e<o&&r.dom.parentNode==i)return r.domAtPos(e-t);if(e<=t)break;t=o}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new ue(i,0)}function Ne(t,e,i){let n,{children:s}=t;i>0&&e instanceof Re&&s.length&&(n=s[s.length-1])instanceof Re&&n.mark.eq(e.mark)?Ne(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function Ie(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,h){for(let l=0,a=0;l<e.children.length&&a<=h;l++){let c=e.children[l],u=a+c.length;u>=h&&(c.children.length?t(c,h-a):(!r||r.isHidden&&i>0)&&(u>h||a==u&&c.getSide()>0)?(r=c,o=h-a):(a<h||a==u&&c.getSide()<0&&!c.isHidden)&&(n=c,s=h-a)),a=u}}(t,e);let h=(i<0?n:r)||n||r;return h?h.coordsAt(Math.max(0,h==n?s:o),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=$t(e);return i[i.length-1]||null}(t)}function He(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}Ee.prototype.children=Be.prototype.children=Pe.prototype.children=fe;const Ve=Object.create(null);function We(t,e,i){if(t==e)return!0;t||(t=Ve),e||(e=Ve);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function Fe(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function ze(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class _e{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var qe=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(qe||(qe={}));class Ke extends yt{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new je(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new Ge(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:r}=Je(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new Ge(t,e,i,n,t.widget||null,!0)}static line(t){return new $e(t)}static set(t,e=!1){return kt.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Ke.none=kt.empty;class je extends Ke{constructor(t){let{start:e,end:i}=Je(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof je&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&We(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}je.prototype.point=!1;class $e extends Ke{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof $e&&this.spec.class==t.spec.class&&We(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}$e.prototype.mapMode=m.TrackBefore,$e.prototype.point=!0;class Ge extends Ke{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?m.TrackBefore:m.TrackAfter:m.TrackDel}get type(){return this.startSide!=this.endSide?qe.WidgetRange:this.startSide<=0?qe.WidgetBefore:qe.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Ge&&(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}range(t,e=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 super.range(t,e)}}function Je(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function Ue(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}Ge.prototype.point=!0;class Ye extends de{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,r){if(i){if(!(i instanceof Ye))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),we(this,t,e,i?i.children.slice():[],s,r),!0}split(t){let e=new Ye;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){We(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){Ne(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=He(e,this.attrs||{})),i&&(this.attrs=He({class:i},this.attrs||{}))}domAtPos(t){return Le(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(he(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&&(Fe(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&de.get(n)instanceof Re;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=de.get(n))||void 0===i?void 0:i.isEditable)||Te.ios&&this.children.some((t=>t instanceof Ee))))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof Ee)||/[^ -~]/.test(i.text))return null;let n=$t(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=Ie(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof Ye&&0==this.children.length&&0==t.children.length&&We(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],r=n+s.length;if(r>=e){if(s instanceof Ye)return s;if(r>e)break}n=r+s.breakAfter}return null}}class Xe extends de{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,r){return!(i&&(!(i instanceof Xe&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&r<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?ue.before(this.dom):ue.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new Xe(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return fe}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):s.empty}domBoundsAround(){return null}become(t){return t instanceof Xe&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof Qe?null:Qt(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class Qe extends _e{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class Ze{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof Xe&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ye),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ti(new Pe(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof Xe||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(ti(new Ee(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,r){if(this.disallowBlockEffectsFor[r]&&i instanceof Ge){if(i.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")}let o=e-t;if(i instanceof Ge)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Xe(i.widget||ei.block,o,i));else{let r=Be.create(i.widget||ei.inline,o,o?0:i.startSide),h=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t<e||i.startSide>0),l=!r.isEditable&&(t<e||s>n.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||h||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),h&&(a.append(ti(new Pe(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(ti(r,n),s),this.atCursorPos=l,this.pendingBuffer=l?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);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=s)}static build(t,e,i,n,s){let r=new Ze(t,e,i,s);return r.openEnd=kt.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function ti(t,e){for(let i of e)t=new Re(i,[t],t.length);return t}class ei extends _e{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ei.inline=new ei("span"),ei.block=new ei("div");var ii=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(ii||(ii={}));const ni=ii.LTR,si=ii.RTL;function ri(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const oi=ri("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),hi=ri("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),li=Object.create(null),ai=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);li[e]=i,li[i]=-e}function ci(t){return t<=247?oi[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?hi[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const ui=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class fi{get dir(){return this.level%2?si:ni}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let r=0;r<t.length;r++){let o=t[r];if(o.from<=e&&o.to>=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.from<e:o.to>e:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}function di(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!di(n.inner,s.inner))return!1}return!0}const gi=[];function pi(t,e,i,n,s,r,o){let h=n%2?2:1;if(n%2==s%2)for(let l=e,a=0;l<i;){let e=!0,c=!1;if(a==r.length||l<r[a].from){let t=gi[l];t!=h&&(e=!1,c=16==t)}let u=e||1!=h?null:[],f=e?n:n+1,d=l;t:for(;;)if(a<r.length&&d==r[a].from){if(c)break t;let g=r[a];if(!e)for(let t=g.to,e=a+1;;){if(t==i)break t;if(!(e<r.length&&r[e].from==t)){if(gi[t]==h)break t;break}t=r[e++].to}if(a++,u)u.push(g);else{g.from>l&&o.push(new fi(l,g.from,f)),mi(t,g.direction==ni!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.to}d=g.to}else{if(d==i||(e?gi[d]!=h:gi[d]==h))break;d++}u?pi(t,l,d,n+1,s,u,o):l<d&&o.push(new fi(l,d,f)),l=d}else for(let l=i,a=r.length;l>e;){let i=!0,c=!1;if(!a||l>r[a-1].to){let t=gi[l-1];t!=h&&(i=!1,c=16==t)}let u=i||1!=h?null:[],f=i?n:n+1,d=l;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let g=r[--a];if(!i)for(let t=g.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(gi[t-1]==h)break t;break}t=r[--i].from}if(u)u.push(g);else{g.to<l&&o.push(new fi(g.to,l,f)),mi(t,g.direction==ni!=!(f%2)?n+1:n,s,g.inner,g.from,g.to,o),l=g.from}d=g.from}else{if(d==e||(i?gi[d-1]!=h:gi[d-1]==h))break;d--}u?pi(t,d,l,n+1,s,u,o):d<l&&o.push(new fi(d,l,f)),l=d}}function mi(t,e,i,n,s,r,o){let h=e%2?2:1;!function(t,e,i,n,s){for(let r=0;r<=n.length;r++){let o=r?n[r-1].to:e,h=r<n.length?n[r].from:i,l=r?256:s;for(let e=o,i=l,n=l;e<h;e++){let s=ci(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),gi[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=o,e=l,n=l;t<h;t++){let s=gi[t];if(128==s)t<h-1&&e==gi[t+1]&&24&e?s=gi[t]=e:gi[t]=256;else if(64==s){let s=t+1;for(;s<h&&64==gi[s];)s++;let r=t&&8==e||s<i&&8==gi[s]?1==n?1:8:256;for(let e=t;e<s;e++)gi[e]=r;t=s-1}else 8==s&&1==n&&(gi[t]=1);e=s,7&s&&(n=s)}}}(t,s,r,n,h),function(t,e,i,n,s){let r=1==s?2:1;for(let o=0,h=0,l=0;o<=n.length;o++){let a=o?n[o-1].to:e,c=o<n.length?n[o].from:i;for(let e,i,n,o=a;o<c;o++)if(i=li[e=t.charCodeAt(o)])if(i<0){for(let t=h-3;t>=0;t-=3)if(ai[t+1]==-i){let e=ai[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(gi[o]=gi[ai[t]]=i),h=t;break}}else{if(189==ai.length)break;ai[h++]=o,ai[h++]=e,ai[h++]=l}else if(2==(n=gi[o])||1==n){let t=n==s;l=t?0:1;for(let e=h-3;e>=0;e-=3){let i=ai[e+2];if(2&i)break;if(t)ai[e+2]|=2;else{if(4&i)break;ai[e+2]|=4}}}}}(t,s,r,n,h),function(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,h=s<i.length?i[s].from:e;for(let l=o;l<h;){let o=gi[l];if(256==o){let o=l+1;for(;;)if(o==h){if(s==i.length)break;o=i[s++].to,h=s<i.length?i[s].from:e}else{if(256!=gi[o])break;o++}let a=1==r,c=a==(1==(o<e?gi[o]:n))?a?1:2:n;for(let e=o,n=s,r=n?i[n-1].to:t;e>l;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),gi[--e]=c;l=o}else r=o,l++}}}(s,r,n,h),pi(t,s,r,e,i,n,o)}function wi(t,e,i){if(!t)return[new fi(0,0,e==si?1:0)];if(e==ni&&!i.length&&!ui.test(t))return vi(t.length);if(i.length)for(;t.length>gi.length;)gi[gi.length]=256;let n=[],s=e==ni?0:1;return mi(t,s,s,i,0,t.length,n),n}function vi(t){return[new fi(0,t,0)]}let yi="";function bi(t,e,i,n,s){var r;let o=n.head-t.from,h=fi.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc),l=e[h],a=l.side(s,i);if(o==a){let t=h+=s?1:-1;if(t<0||t>=e.length)return null;l=e[h=t],o=l.side(!s,i),a=l.side(s,i)}let c=g(t.text,o,l.forward(s,i));(c<l.from||c>l.to)&&(c=a),yi=t.text.slice(Math.min(o,c),Math.max(o,c));let u=h==(s?e.length-1:0)?null:e[h+(s?1:-1)];return u&&c==a&&u.level+(s?0:1)<l.level?C.cursor(u.side(!s,i)+t.from,u.forward(s,i)?1:-1,u.level):C.cursor(c+t.from,l.forward(s,i)?-1:1,l.level)}function xi(t,e,i){for(let n=e;n<i;n++){let e=ci(t.charCodeAt(n));if(1==e)return ni;if(2==e||4==e)return si}return ni}const Si=T.define(),ki=T.define(),Ai=T.define(),Mi=T.define(),Ci=T.define(),Oi=T.define(),Di=T.define(),Ti=T.define(),Ei=T.define(),Ri=T.define({combine:t=>t.some((t=>t))}),Bi=T.define({combine:t=>t.some((t=>t))}),Pi=T.define();class Li{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new Li(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new Li(C.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Ni=rt.define({map:(t,e)=>t.map(e)}),Ii=rt.define();function Hi(t,e,i){let n=t.facet(Mi);n.length?n[0](e):window.onerror?window.onerror(String(e),i,void 0,void 0,e):i?console.error(i+":",e):console.error(e)}const Vi=T.define({combine:t=>!t.length||t[0]});let Wi=0;const Fi=T.define();class zi{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new zi(Wi++,t,i,n,(t=>{let e=[Fi.of(t)];return r&&e.push(ji.of((e=>{let i=e.plugin(t);return i?r(i):Ke.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return zi.define((e=>new t(e)),e)}}class _i{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(Hi(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Hi(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){Hi(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const qi=T.define(),Ki=T.define(),ji=T.define(),$i=T.define(),Gi=T.define(),Ji=T.define();function Ui(t,e){let i=t.state.facet(Ji);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return kt.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,h=i-e.from,l=s;for(let t=n.length-1;t>=0;t--,r--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=xi(e.text,o,h)),r>0&&l.length&&(i=l[l.length-1]).to==o&&i.direction==s)i.to=h,l=i.inner;else{let t={from:o,to:h,direction:s,inner:[]};l.push(t),l=t.inner}}}}),s}const Yi=T.define();function Xi(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(Yi)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const Qi=T.define();class Zi{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Zi(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,r=0,o=0;;n++){let h=n==t.length?null:t[n],l=r-o,a=h?h.fromB:1e9;for(;s<e.length&&e[s]<a;){let t=e[s],n=e[s+1],r=Math.max(o,t),h=Math.min(a,n);if(r<=h&&new Zi(r+l,h+l,r,h).addToSet(i),n>a)break;s+=2}if(!h)return i;new Zi(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),r=h.toA,o=h.toB}}}class tn{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=v.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges(((t,e,i,s)=>n.push(new Zi(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new tn(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class en extends de{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Ke.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new Ye],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Zi(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every((({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.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.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges(((t,n)=>{t<e.to&&n>e.from&&(i=!0)}));return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=nn(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,h=s.nodeValue;if(/[\n\r]/.test(h))return null;if(t.state.doc.sliceString(n.from,n.to)!=h)return null;let l=e.invertedDesc,a=new Zi(l.mapPos(r),l.mapPos(o),r,o),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=de.get(e);if(i instanceof Re)c.push({node:e,deco:i.mark});else{if(i instanceof Ye||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new je({inclusive:!0,attributes:ze(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new Zi(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Te.ie||Te.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=function(t,e,i){let n=new sn;return kt.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=Zi.extendWithRanges(i,r),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore((()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=Te.chrome||Te.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""})),this.markedForComposition.forEach((t=>t.flags&=-9));let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof Xe&&t.widget instanceof Qe&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let r,o,h,l,{fromA:a,toA:c,fromB:u,toB:f}=e;if(i&&i.range.fromB<f&&i.range.toB>u){let t=Ze.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=Ze.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,h=t.openStart,l=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),r=t.content.concat(n).concat(e.content)}else({content:r,breakAtStart:o,openStart:h,openEnd:l}=Ze.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:g}=s.findPos(c,1),{i:p,off:m}=s.findPos(a,-1);me(this,p,m,d,g,r,o,h,l)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(Ii)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new Ee(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new Re(i,[e],e.length);let i=new Ye;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some((t=>7&t.flags))?1:0),this.markedForComposition.add(e);let i=de.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&!(this.view.state.facet(Vi)||this.dom.tabIndex>-1)&&jt(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,h=this.moveToLine(this.domAtPos(o.anchor)),l=o.empty?h:this.moveToLine(this.domAtPos(o.head));if(Te.gecko&&o.empty&&!this.hasComposition&&(1==(a=h).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>h.node.insertBefore(t,h.node.childNodes[h.offset]||null))),h=l=new ue(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&(Gt(h.node,h.offset,c.anchorNode,c.anchorOffset)&&Gt(l.node,l.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{Te.android&&Te.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=qt(this.view.root);if(t)if(o.empty){if(Te.gecko){let t=(e=h.node,n=h.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=(1==t?ae:ce)(h.node,h.offset);e&&(h=new ue(e.node,e.offset))}}t.collapse(h.node,h.offset),null!=o.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=o.bidiLevel)}else if(t.extend){t.collapse(h.node,h.offset);try{t.extend(l.node,l.offset)}catch(t){}}else{let e=document.createRange();o.anchor>o.head&&([h,l]=[l,h]),e.setEnd(l.node,l.offset),e.setStart(h.node,h.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(h,l)),this.impreciseAnchor=h.precise?null:new ue(c.anchorNode,c.anchorOffset),this.impreciseHead=l.precise?null:new ue(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&Gt(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=qt(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=Ye.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let h=this.coordsAt(e.head,-1),l=this.coordsAt(e.head,1);if(!h||!l||h.bottom>l.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=de.get(i.childNodes[n]);t instanceof Ye&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=de.get(i.childNodes[n]);t instanceof Ye&&(e=t.domAtPos(t.length))}return e?new ue(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=de.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof Ye)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,r=this.children.length-1;r>=0;r--){let o=this.children[r],h=s-o.breakAfter,l=h-o.length;if(h<t)break;if(l<=t&&(l<t||o.covers(-1))&&(h>t||o.covers(1))&&(!i||o instanceof Ye&&!(i instanceof Ye&&e>=0)))i=o,n=l;else if(i&&l==t&&h==t&&o instanceof Xe&&Math.abs(e)<2){if(o.deco.startSide<0)break;r&&(i=null)}s=l}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof Ye))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof Ee))return null;let s=g(n.text,i);if(s==i)return null;let r=re(n.dom,i,s).getClientRects();for(let t=0;t<r.length;t++){let e=r[t];if(t==r.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,r=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,h=this.view.textDirection==ii.LTR;for(let t=0,l=0;l<this.children.length;l++){let a=this.children[l],c=t+a.length;if(c>n)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?$t(e):[];if(n.length){let e=n[n.length-1],r=h?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?ii.RTL:ii.LTR}measureTextSize(){for(let t of this.children)if(t instanceof Ye){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(n);let s=$t(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()})),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new pe(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],r=s?s.from-1:this.length;if(r>i){let n=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(Ke.replace({widget:new Qe(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return Ke.set(t)}updateDeco(){let t=1,e=this.view.state.facet(ji).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet($i).map(((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t}));for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(kt.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(Pi))try{if(e(this.view,t.range,t))return!0}catch(t){Hi(this.view.state,t,"scroll handler")}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=Xi(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:h}=this.view.scrollDOM;!function(t,e,i,n,s,r,o,h){let l=t.ownerDocument,a=l.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==l.body,d=1,g=1;if(f)t=Zt(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:g}=te(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*g}}let p=0,m=0;if("nearest"==s)e.top<t.top?(m=-(t.top-e.top+o),i>0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m<t.top&&(m=-(t.top+m-e.top+o)));else{let n=e.bottom-e.top,r=t.bottom-t.top;m=("center"==s&&n<=r?e.top+n/2-r/2:"start"==s||"center"==s&&i<0?e.top-o:e.bottom-r+o)-t.top}if("nearest"==n?e.left<t.left?(p=-(t.left-e.left+r),i>0&&e.right>t.right+p&&(p=e.right-t.right+p+r)):e.right>t.right&&(p=e.right-t.right+r,i<0&&e.left<t.left+p&&(p=-(t.left+p-e.left+r))):p=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==h?e.left-r:e.right-(t.right-t.left)+r)-t.left,p||m)if(f)a.scrollBy(p,m);else{let t=0,i=0;if(m){let t=c.scrollTop;c.scrollTop+=m/g,i=(c.scrollTop-t)*g}if(p){let e=c.scrollLeft;c.scrollLeft+=p/d,t=(c.scrollLeft-e)*d}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-p)<1&&(n="nearest"),i&&Math.abs(i-m)<1&&(s="nearest")}if(f)break;c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,r,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,o),-o),Math.max(Math.min(t.yMargin,h),-h),this.view.textDirection==ii.LTR)}}function nn(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=ae(i.focusNode,i.focusOffset),s=ce(i.focusNode,i.focusOffset),r=n||s;if(s&&n&&s.node!=n.node){let e=de.get(s.node);if(!e||e instanceof Ee&&e.text!=s.node.nodeValue)r=s;else if(t.docView.lastCompositionAfterCursor){let t=de.get(n.node);!t||t instanceof Ee&&t.text!=n.node.nodeValue||(r=s)}}if(t.docView.lastCompositionAfterCursor=r!=n,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}let sn=class{constructor(){this.changes=[]}compareRange(t,e){Ue(t,e,this.changes)}comparePoint(t,e){Ue(t,e,this.changes)}boundChange(t){Ue(t,t,this.changes)}};function rn(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function on(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function hn(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function ln(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function an(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function cn(t,e,i){let n,s,r,o,h,l,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=$t(f);for(let d=0;d<t.length;d++){let g=t[d];s&&hn(s,g)&&(g=ln(an(g,s.bottom),s.top));let p=rn(e,g),m=on(i,g);if(0==p&&0==m)return 3==f.nodeType?un(f,e,i):cn(f,e,i);if(!n||o>m||o==m&&r>p){n=f,s=g,r=p,o=m;let h=m?i<g.top?-1:1:p?e<g.left?-1:1:0;u=!h||(h>0?d<t.length-1:d>0)}0==p?i>g.bottom&&(!a||a.bottom<g.bottom)?(h=f,a=g):i<g.top&&(!c||c.top>g.top)&&(l=f,c=g):a&&hn(a,g)?a=an(a,g.bottom):c&&hn(c,g)&&(c=ln(c,g.top))}}if(a&&a.bottom>=i?(n=h,s=a):c&&c.top<=i&&(n=l,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?un(n,f,i):u&&"false"!=n.contentEditable?cn(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function un(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let h=0;h<n;h++){let n=re(t,h,h+1).getClientRects();for(let l=0;l<n.length;l++){let a=n[l];if(a.top==a.bottom)continue;o||(o=e-a.left);let c=(a.top>i?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c<r){let i=e>=(a.left+a.right)/2,n=i;if(Te.chrome||Te.gecko){re(t,h).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:h+(n?1:0)};s=h+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function fn(t,e,i,n=-1){var s,r;let o,h=t.contentDOM.getBoundingClientRect(),l=h.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-l;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=qe.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=l+f;let d=o.from;if(d<t.viewport.from)return 0==t.viewport.from?0:i?null:dn(t,h,o,c,u);if(d>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:dn(t,h,o,c,u);let g=t.dom.ownerDocument,p=t.root.elementFromPoint?t.root:g,m=p.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(h.left+1,Math.min(h.right-1,c)),m=p.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let w,v=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable)){if(g.caretPositionFromPoint){let t=g.caretPositionFromPoint(c,u);t&&({offsetNode:w,offset:v}=t)}else if(g.caretRangeFromPoint){let e=g.caretRangeFromPoint(c,u);e&&(({startContainer:w,startOffset:v}=e),(!t.contentDOM.contains(w)||Te.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return re(t,n-1,n).getBoundingClientRect().left>i}(w,v,c)||Te.chrome&&function(t,e,i){if(0!=e)return!1;for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():re(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0))}w&&(v=Math.min(Xt(w),v))}if(!w||!t.docView.dom.contains(w)){let e=Ye.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:w,offset:v}=cn(e.dom,c,u))}let y=t.docView.nearest(w);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?y.posAtStart:y.posAtEnd}return y.localPosFromDOM(w,v)+y.posAtStart}function dn(t,e,i,n,s){let r=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+Nt(o,r,t.state.tabSize)}function gn(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==qe.Text))return t;return i}function pn(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let h=e,l=null;;){let e=bi(s,r,o,h,i),a=yi;if(!e){if(s.number==(i?t.state.doc.lines:1))return h;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(l){if(!l(a))return h}else{if(!n)return e;l=n(a)}h=e}}function mn(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&e<s){let r=n||i||(e-t<s-e?-1:1);e=r<0?t:s,n=r}}));if(!n)return e}}function wn(t,e,i){let n=mn(t.state.facet(Gi).map((e=>e(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:C.cursor(n,n<i.from?1:-1)}const vn="";class yn{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(wt.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=vn}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let r=de.get(n),o=de.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:Ut(n))||Ut(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=de.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(bn(t,i.node,i.offset)?e:0))}}function bn(t,e,i){for(;;){if(!e||i<Xt(e))return!1;if(e==t)return!0;i=Jt(e)+1,e=e.parentNode}}class xn{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Sn{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:r}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new xn(i,n)),s==i&&r==n||e.push(new xn(s,r)));return e}(t),i=new yn(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?C.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!Kt(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!Kt(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((Te.ios||Te.chrome)&&t.state.selection.main.empty&&i!=n&&(o.from>0||o.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),r=o.from-e,h=o.to-s;0!=r&&1!=r&&0!=e||0!=h&&-1!=h&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}this.newSel=C.single(n,i)}}}function kn(t,e){let i,{newSel:n}=e,r=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:h}=e.bounds,l=r.from,a=null;(8===o||Te.android&&e.text.length<h-n)&&(l=r.to,a="end");let c=function(t,e,i,n){let s=Math.min(t.length,e.length),r=0;for(;r<s&&t.charCodeAt(r)==e.charCodeAt(r);)r++;if(r==s&&t.length==e.length)return null;let o=t.length,h=e.length;for(;o>0&&h>0&&t.charCodeAt(o-1)==e.charCodeAt(h-1);)o--,h--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,h))-r}if(o<r&&t.length<e.length){r-=i<=r&&i>=o?r-i:0,h=r+(h-o),o=r}else if(h<r){r-=i<=r&&i>=h?r-i:0,o=r+(o-h),h=r}return{from:r,toA:o,toB:h}}(t.state.doc.sliceString(n,h,vn),e.text,l-n,a);c&&(Te.chrome&&13==o&&c.toB==c.from+2&&e.text.slice(c.from,c.toB)==vn+vn&&c.toB--,i={from:n+c.from,to:n+c.toA,insert:s.of(e.text.slice(c.from,c.toB).split(vn))})}else n&&(!t.hasFocus&&t.state.facet(Vi)||n.main.eq(r))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!r.empty&&n&&n.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(Te.mac||Te.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=C.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:s.of([" "])}):Te.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=C.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:s.of([" "])}),i)return An(t,i,n,o);if(n&&!n.main.eq(r)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function An(t,e,i,n=-1){if(Te.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Te.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&oe(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&oe(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&oe(t.contentDOM,"Delete",46)))return!0;let r,o=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let h=()=>r||(r=function(t,e,i){let n,s=t.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.from<e.from?s.sliceDoc(r.from,e.from):"",o=r.to>e.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=s.changes(e),h=i&&i.main.to<=o.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let l,a=t.state.sliceDoc(e.from,e.to),c=i&&nn(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);l={from:c.from,to:c.to-t}}else l=t.state.doc.lineAt(r.head);let u=r.to-e.to,f=r.to-r.from;n=s.changeByRange((i=>{if(i.from==r.from&&i.to==r.to)return{changes:o,range:h||i.map(o)};let n=i.to-u,c=n-a.length;if(i.to-i.from!=f||t.state.sliceDoc(c,n)!=a||i.to>=l.from&&i.from<=l.to)return{range:i};let d=s.changes({from:c,to:n,insert:e.insert}),g=i.to-r.to;return{changes:d,range:h?C.range(Math.max(0,h.anchor+g),Math.max(0,h.head+g)):i.map(d)}}))}else n={changes:o,selection:h&&s.selection.replaceRange(h)}}let o="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:o,scrollIntoView:!0})}(t,e,i));return t.state.facet(Oi).some((i=>i(t,e.from,e.to,o,h)))||t.dispatch(h()),!0}class Mn{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){var e;this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,Te.safari&&t.contentDOM.addEventListener("input",(()=>null)),Te.gecko&&(e=t.contentDOM.ownerDocument,Xn.has(e)||(Xn.add(e),e.addEventListener("copy",(()=>{})),e.addEventListener("cut",(()=>{}))))}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=de.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||this.runHandlers(t.type,t))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=function(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let s=t.domEventHandlers[n];s&&i(n).handlers.push(Cn(e.value,s))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let s=t.domEventObservers[n];s&&i(n).observers.push(Cn(e.value,s))}}for(let t in Bn)i(t).handlers.push(Bn[t]);for(let t in Pn)i(t).observers.push(Pn[t]);return e}(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,r=i[t];r&&s!=!r.handlers.length&&(n.removeEventListener(t,this.handleEvent),r=null),r||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&Tn.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),Te.android&&Te.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!Te.ios||t.synthetic||t.altKey||t.metaKey||!((e=On.find((e=>e.keyCode==t.keyCode)))&&!t.ctrlKey||Dn.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout((()=>this.flushIOSKey()),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,oe(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!!/^key/.test(t.type)&&(this.composing>0||!!(Te.safari&&!Te.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Cn(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){Hi(i.state,t)}}}const On=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Dn="dthko",Tn=[16,17,18,20,91,92,224,225];function En(t){return.7*Math.max(0,t)+8}class Rn{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,n=t.ownerDocument;for(let s=t.parentNode;s&&!(s==n.body||e&&i);)if(1==s.nodeType)!i&&s.scrollHeight>s.clientHeight&&(i=s),!e&&s.scrollWidth>s.clientWidth&&(e=s),s=s.assignedSlot||s.parentNode;else{if(11!=s.nodeType)break;s=s.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(Gi).map((e=>e(t)));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(wt.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Si);return i.length?i[0](e):Te.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=qt(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=jn(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let n=0,s=0,r=0,o=0,h=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:h}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Xi(this.view);t.clientX-a.left<=r+6?n=-En(r-t.clientX):t.clientX+a.right>=h-6&&(n=En(t.clientX-h)),t.clientY-a.top<=o+6?s=-En(o-t.clientY):t.clientY+a.bottom>=l-6&&(s=En(t.clientY-l)),this.setScrollSpeed(n,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval((()=>this.scroll()),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;i<t.ranges.length;i++){let n=t.ranges[i],s=null;if(n.empty){let t=mn(this.atoms,n.from,0);t!=n.from&&(s=C.cursor(t,-1))}else{let t=mn(this.atoms,n.from,-1),e=mn(this.atoms,n.to,1);t==n.from&&e==n.to||(s=C.range(n.from==n.anchor?t:e,n.from==n.head?t:e))}s&&(e||(e=t.ranges.slice()),e[i]=s)}return e?C.create(e,t.mainIndex):t}select(t){let{view:e}=this,i=this.skipAtoms(this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some((t=>t.isUserEvent("input.type")))?this.destroy():this.style.update(t)&&setTimeout((()=>this.select(this.lastEvent)),20)}}const Bn=Object.create(null),Pn=Object.create(null),Ln=Te.ie&&Te.ie_version<15||Te.ios&&Te.webkit_version<604;function Nn(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function In(t,e){e=Nn(t.state,Ti,e);let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Gn&&n.selection.ranges.every((t=>t.empty))&&Gn==r.toString()){let t=-1;i=n.changeByRange((i=>{let h=n.doc.lineAt(i.from);if(h.from==t)return{range:i};t=h.from;let l=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:l},range:C.cursor(i.from+l.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:C.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Hn(t,e,i,n){if(1==n)return C.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return C.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,h=r;i<0?o=g(s.text,r,!1):h=g(s.text,r);let l=n(s.text.slice(o,h));for(;o>0;){let t=g(s.text,o,!1);if(n(s.text.slice(t,o))!=l)break;o=t}for(;h<s.length;){let t=g(s.text,h);if(n(s.text.slice(h,t))!=l)break;h=t}return C.range(o+s.from,h+s.from)}(t.state,e,i);{let i=Ye.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,r=i?i.posAtEnd:n.to;return r<t.state.doc.length&&r==n.to&&r++,C.range(s,r)}}Pn.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Bn.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),Pn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Pn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Bn.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(Ai))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Fn(t,e),n=jn(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let h,l=Fn(t,e),a=Hn(t,l.pos,l.bias,n);if(i.pos!=l.pos&&!r){let e=Hn(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s<a.from?C.range(s,r):C.range(r,s)}return r?s.replaceRange(s.main.extend(a.from,a.to)):o&&1==n&&s.ranges.length>1&&(h=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return C.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,l.pos))?h:o?s.addRange(a):C.create([a])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Rn(t,e,i,n)),n&&t.observer.ignore((()=>{se(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()}));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let Vn=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function Wn(t,e,i,n){let s=Ye.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&Vn(i,n,o))return-1;let h=s.coordsAt(r,1);return h&&Vn(i,n,h)?1:o&&o.bottom>=n?-1:1}function Fn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Wn(t,i,e.clientX,e.clientY)}}const zn=Te.ie&&Te.ie_version<=11;let _n=null,qn=0,Kn=0;function jn(t){if(!zn)return t.detail;let e=_n,i=Kn;return _n=t,Kn=Date.now(),qn=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(qn+1)%3:1}function $n(t,e,i,n){if(!(i=Nn(t.state,Ti,i)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&function(t,e){let i=t.state.facet(ki);return i.length?i[0](e):Te.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.from,to:r.to}:null,h={from:s,insert:i},l=t.state.changes(o?[o,h]:h);t.focus(),t.dispatch({changes:l,selection:{anchor:l.mapPos(s,-1),head:l.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Bn.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=C.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Nn(t.state,Ei,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Bn.dragend=t=>(t.inputState.draggedContent=null,!1),Bn.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,r=()=>{++s==i.length&&$n(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=r,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return $n(t,e,i,!0),!0}return!1},Bn.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Ln?null:e.clipboardData;return i?(In(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{t.focus(),i.remove(),In(t,i.value)}),50)}(t),!1)};let Gn=null;Bn.copy=Bn.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:Nn(t,Ei,e.join(t.lineBreak)),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;Gn=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ln?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout((()=>{n.remove(),t.focus()}),50)}(t,i),!1)};const Jn=it.define();function Un(t,e){let i=[];for(let n of t.facet(Di)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Jn.of(!0)}):null}function Yn(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Un(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Pn.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Yn(t)},Pn.blur=t=>{t.observer.clearSelectionRange(),Yn(t)},Pn.compositionstart=Pn.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},Pn.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Te.chrome&&Te.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50))},Pn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Bn.beforeinput=(t,e)=>{var i,n;if("insertReplacementText"==e.inputType&&t.observer.editContext){let n=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),s=e.getTargetRanges();if(n&&s.length){let e=s[0],i=t.posAtDOM(e.startContainer,e.startOffset),r=t.posAtDOM(e.endContainer,e.endOffset);return An(t,{from:i,to:r,insert:t.state.toText(n)},null),!0}}let s;if(Te.chrome&&Te.android&&(s=On.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let e=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return Te.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),Te.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>Pn.compositionend(t,e)),20),!1};const Xn=new Set;const Qn=["pre-wrap","normal","pre-line","break-spaces"];let Zn=!1;function ts(){Zn=!1}class es{constructor(t){this.lineWrapping=t,this.doc=s.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Qn.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,r){let o=Qn.indexOf(t)>-1,h=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,h){this.heightSamples={};for(let t=0;t<r.length;t++){let e=r[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return h}}class is{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class ns{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?qe.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ge?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new ns(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var ss=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(ss||(ss={}));const rs=.001;class os{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>rs&&(Zn=!0),this.height=t)}replace(t,e,i){return os.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:h,toA:l,fromB:a,toB:c}=n[o],u=s.lineAt(h,ss.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=l?u:s.lineAt(l,ss.ByPosNoHeight,i,0,0);for(c+=f.to-l,l=f.to;o>0&&u.from<=n[o-1].toA;)h=n[o-1].fromA,a=n[o-1].fromB,o--,h<u.from&&(u=s.lineAt(h,ss.ByPosNoHeight,i,0,0));a+=u.from-h,h=u.from;let d=ds.build(i.setDoc(r),t,a,c);s=hs(s,s.replace(h,l,d))}return s.updateHeight(i,0)}static empty(){return new as(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let r=0;return null==t[e-1]?(r=1,e--):null==t[e]&&(r=1,i++),new us(os.of(t.slice(0,e)),r,os.of(t.slice(i)))}}function hs(t,e){return t==e?t:(t.constructor!=e.constructor&&(Zn=!0),e)}os.prototype.size=1;class ls extends os{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new ns(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,r){t<=s+this.length&&e>=s&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class as extends ls{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new ns(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof as||n instanceof cs&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof cs?n=new as(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):os.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class cs extends os{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),r=e.doc.lineAt(s),l=o+r.length*h,a=Math.max(i,t-l/2);return new ns(r.from,r.length,a,l,0)}{let n=Math.max(0,Math.min(r-s,Math.floor((t-i)/o))),{from:h,length:l}=e.doc.line(s+n);return new ns(h,l,i+o*n,o,0)}}lineAt(t,e,i,n,s){if(e==ss.ByHeight)return this.blockAt(t,i,n,s);if(e==ss.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new ns(e,n-e,0,0,0)}let{firstLine:r,perLine:o,perChar:h}=this.heightMetrics(i,s),l=i.doc.lineAt(t),a=o+l.length*h,c=l.number-r,u=n+o*c+h*(l.from-s-c);return new ns(l.from,l.length,Math.max(n,Math.min(u,n+this.height-a)),a,0)}forEachLine(t,e,i,n,s,r){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:o,perLine:h,perChar:l}=this.heightMetrics(i,s);for(let a=t,c=n;a<=e;){let e=i.doc.lineAt(a);if(a==t){let i=e.number-o;c+=h*i+l*(t-s-i)}let n=h+l*e.length;r(new ns(e.from,e.length,c,n,0)),c+=n,a=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof cs?i[i.length-1]=new cs(t.length+n):i.push(null,new cs(n-1))}if(t>0){let e=i[0];e instanceof cs?i[0]=new cs(t+e.length):i.unshift(new cs(t-1),null)}return os.of(i)}decomposeLeft(t,e){e.push(new cs(t-1),null)}decomposeRight(t,e){e.push(null,new cs(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new cs(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=rs&&(o=-2);let h=new as(e,s);h.outdated=!1,i.push(h),r+=e+1}r<=s&&i.push(null,new cs(s-r).updateHeight(t,r));let h=os.of(i);return(o<0||Math.abs(h.height-this.height)>=rs||Math.abs(o-this.heightMetrics(t,e).perLine)>=rs)&&(Zn=!0),hs(this,h)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class us extends os{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let r=n+this.left.height,o=s+this.left.length+this.break,h=e==ss.ByHeight?t<r:t<o,l=h?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,r,o);if(this.break||(h?l.to<o:l.from>o))return l;let a=e==ss.ByPosNoHeight?ss.ByPosNoHeight:ss.ByPos;return h?l.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(l)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,h=s+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,s,r),e>=h&&this.right.forEachLine(t,e,i,o,h,r);else{let l=this.lineAt(h,ss.ByPos,i,n,s);t<l.from&&this.left.forEachLine(t,l.from-1,i,n,s,r),l.to>=t&&l.from<=e&&r(l),e>l.to&&this.right.forEachLine(l.to+1,e,i,o,h,r)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&fs(s,r-1),e<this.length){let t=s.length;this.decomposeRight(e,s),fs(s,t)}return os.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?os.of(this.break?[t,null,e]:[t,e]):(this.left=hs(this.left,t),this.right=hs(this.right,e),this.setHeight(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)}updateHeight(t,e=0,i=!1,n){let{left:s,right:r}=this,o=e+s.length+this.break,h=null;return n&&n.from<=e+s.length&&n.more?h=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=o+r.length&&n.more?h=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),h?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function fs(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof cs&&(n=t[e+1])instanceof cs&&t.splice(e-1,3,new cs(i.length+1+n.length))}class ds{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof as?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new as(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new ls(r,n,i)):(r||s||n>=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new as(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new cs(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof as)return t;let e=new as(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof as||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new as(0,-1));let i=t;for(let t of this.nodes)t instanceof as&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new ds(i,t);return kt.spans(e,i,n,s,0),s.finish(i)}}class gs{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Ue(t,e,this.changes,5)}}function ps(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,r=Math.max(0,i.left),o=Math.min(s.innerWidth,i.right),h=Math.max(0,i.top),l=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),h=Math.max(h,n.top),l=Math.min(e==t.parentNode?s.innerHeight:l,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:h-(i.top+e),bottom:Math.max(h,l)-(i.top+e)}}function ms(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ws{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return Ke.replace({widget:new vs(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class vs extends _e{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let 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}get estimatedHeight(){return this.vertical?this.size:-1}}class ys{constructor(t){this.state=t,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.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=ks,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=ii.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(Ki).some((t=>"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new es(e),this.stateDeco=t.facet(ji).filter((t=>"function"!=typeof t)),this.heightMap=os.empty().applyChanges(this.stateDeco,s.empty,this.heightOracle.setDoc(t.doc),[new Zi(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ke.set(this.lineGaps.map((t=>t.draw(this,!1)))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some((({from:t,to:e})=>n>=t&&n<=e))){let{from:e,to:i}=this.lineBlockAt(n);t.push(new bs(e,i))}}return this.viewports=t.sort(((t,e)=>t.from-e.from)),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?ks:new As(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(Ms(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ji).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=Zi.extendWithRanges(n,function(t,e,i){let n=new gs;return kt.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:v.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);ts(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=r||Zn)&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let h=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<h.from||e.range.head>h.to)||!this.viewportIsAppropriate(h))&&(h=this.getViewport(0,e));let l=h.from!=this.viewport.from||h.to!=this.viewport.to;this.viewport=h,t.flags|=this.updateForViewport(),(l||!t.changes.empty||2&t.flags)&&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(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Bi)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?ii.RTL:ii.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),h=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let a=0,c=0;if(h.width&&h.height){let{scaleX:t,scaleY:i}=te(e,h);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=16,o=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=le(t.scrollDOM);let g=(this.printing?ms:ps)(e,this.paddingTop),p=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let w=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(w!=this.inView&&(this.inView=w,w&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let v=h.width;if(this.contentDOMWidth==v&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=h.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(v-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:s,textHeight:h}=t.docView.measureTextSize();o=i>0&&n.refresh(r,i,s,h,v/s,e),o&&(t.docView.minWidth=0,a|=16)}p>0&&m>0?c=Math.max(p,m):p<0&&m<0&&(c=Math.min(p,m)),ts();for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?os.empty().applyChanges(this.stateDeco,s.empty,this.heightOracle,[new Zi(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new is(i.from,r))}Zn&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),a|=this.updateForViewport()),(2&a||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,h=new bs(n.lineAt(r-1e3*i,ss.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),ss.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<h.from||t>h.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,ss.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t<h.from?o.top:o.bottom-r,h=new bs(n.lineAt(i-500,ss.ByHeight,s,0,0).from,n.lineAt(i+r+500,ss.ByHeight,s,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new bs(this.heightMap.lineAt(i,ss.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,ss.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,ss.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,ss.ByPos,this.heightOracle,0,0),{visibleTop:r,visibleBottom:o}=this;return(0==t||n<=r-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s<o+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new ws(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,r=n<<1;if(this.defaultTextDirection!=ii.LTR&&!i)return[];let o=[],h=(n,r,l,a)=>{if(r-n<s)return;let c=this.state.selection.main,u=[c.from];c.empty||u.push(c.to);for(let t of u)if(t>n&&t<r)return h(n,t-10,l,a),void h(t+10,r,l,a);let f=function(t,e){for(let i of t)if(e(i))return i;return}(t,(t=>t.from>=l.from&&t.to<=l.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-r)<s&&!u.some((e=>t.from<e&&t.to>e))));if(!f){if(r<l.to&&e&&i&&e.visibleRanges.some((t=>t.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(C.cursor(r),!1,!0).head;t>n&&(r=t)}let t=this.gapSize(l,n,r,a);f=new ws(n,r,t,i||t<2e6?t:2e6)}o.push(f)},l=e=>{if(e.length<r||e.type!=qe.Text)return;let s=function(t,e,i){let n=[],s=t,r=0;kt.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),r+=e-s);return{total:r,ranges:n}}(e.from,e.to,this.stateDeco);if(s.total<r)return;let o,l,a=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,r=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=a){let n=Ss(s,a),o=((this.visibleBottom-this.visibleTop)/2+r)/e.height;t=n-o,i=n+o}else t=(this.visibleTop-e.top-r)/e.height,i=(this.visibleBottom-e.top+r)/e.height;o=xs(s,t),l=xs(s,i)}else{let i=s.total*this.heightOracle.charWidth,r=n*this.heightOracle.charWidth,h=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+h<this.pixelViewport.left&&(h=i.size-i.displaySize);let c,u,f=this.pixelViewport.left+h,d=this.pixelViewport.right+h;if(null!=a){let t=Ss(s,a),e=((d-f)/2+r)/i;c=t-e,u=t+e}else c=(f-r)/i,u=(d+r)/i;o=xs(s,c),l=xs(s,u)}o>e.from&&h(e.from,o,e,s),l<e.to&&h(l,e.to,e,s)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(l):l(t);return o}gapSize(t,e,i,n){let s=Ss(n,i)-Ss(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){ws.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=Ke.set(t.map((t=>t.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];kt.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let e=0;e<i.length&&!(8&n);e++){let s=this.visibleRanges[e],r=i[e];s.from==r.from&&s.to==r.to||(n|=4,t&&t.mapPos(s.from,-1)==r.from&&t.mapPos(s.to,1)==r.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Ms(this.heightMap.lineAt(t,ss.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find((e=>e.top<=t&&e.bottom>=t))||Ms(this.heightMap.lineAt(this.scaler.fromDOM(t),ss.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Ms(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class bs{constructor(t,e){this.from=t,this.to=e}}function xs({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],r=s-i;if(n<=r)return i+n;n-=r}}function Ss(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const ks={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class As{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,ss.ByPos,t,0,0).top,o=e.lineAt(s,ss.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof As&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every(((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to)))}}function Ms(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new ns(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map((t=>Ms(t,e))):t._content)}const Cs=T.define({combine:t=>t.join(" ")}),Os=T.define({combine:t=>t.indexOf(!0)>-1}),Ds=Wt.newName(),Ts=Wt.newName(),Es=Wt.newName(),Rs={"&light":"."+Ts,"&dark":"."+Es};function Bs(t,e,i){return new Wt(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,(e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]})):t+" "+e})}const Ps=Bs("."+Ds,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",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"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&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"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},Rs),Ls={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ns=Te.ie&&Te.ie_version<=11;class Is{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new ee,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver((e=>{for(let t of e)this.queue.push(t);(Te.ie&&Te.ie_version<=11||Te.ios&&t.composing)&&e.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),!window.EditContext||!1===t.constructor.EDIT_CONTEXT||Te.chrome&&Te.chrome_version<126||(this.editContext=new Ws(t),t.state.facet(Vi)&&(t.contentDOM.editContext=this.editContext.editContext)),Ns&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver((()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()})),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver((t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some(((e,i)=>e!=t[i])))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Vi)?i.root.activeElement!=this.dom:!jt(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(Te.ie&&Te.ie_version<=11||Te.android&&Te.chrome)&&!i.state.selection.main.empty&&n.focusNode&&Gt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=qt(t.root);if(!e)return!1;let i=Te.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Vs(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?Vs(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=jt(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,Xt(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=Xt(i))}else{if(i==t)return!0;n=Jt(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Ls),Ns&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Ns&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&oe(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame((()=>{this.delayedFlush=-1,this.flush()})))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&jt(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Sn(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=kn(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=Hs(e,t.previousSibling||t.target.previousSibling,-1),n=Hs(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Vi)!=t.state.facet(Vi)&&(t.view.contentDOM.editContext=t.state.facet(Vi)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Hs(t,e,i){for(;e;){let n=de.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function Vs(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return Gt(o.node,o.offset,s,r)&&([i,n,s,r]=[s,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}}class Ws{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=e=>{let{anchor:i}=t.state.selection.main,n=this.toEditorPos(e.updateRangeStart),r=this.toEditorPos(e.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:e.updateRangeStart,editorBase:n,drifted:!1});let o={from:n,to:r,insert:s.of(e.text.split("\n"))};if(o.from==this.from&&i<this.from?o.from=i:o.to==this.to&&i>this.to&&(o.to=i),o.from!=o.to||o.insert.length){if(this.pendingContextChange=o,!t.state.readOnly){let i=this.to-this.from+(o.to-o.from+o.insert.length);An(t,o,C.single(this.toEditorPos(e.selectionStart,i),this.toEditorPos(e.selectionEnd,i)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))}},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),r=this.toEditorPos(i.rangeEnd);e<r;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if("None"!=e&&"None"!=n){let s=this.toEditorPos(t.rangeStart),r=this.toEditorPos(t.rangeEnd);if(s<r){let t=`text-decoration: underline ${"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${"Thin"==n?1:2}px`;i.push(Ke.mark({attributes:{style:t}}).range(s,r))}}}t.dispatch({effects:Ii.of(Ke.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=qt(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges(((s,r,o,h,l)=>{if(i)return;let a=l.length-(r-s);if(n&&r>=n.to){if(n.from==s&&n.to==r&&n.insert.eq(l))return n=this.pendingContextChange=null,e+=a,void(this.to+=a);n=null,this.revertPending(t.state)}if(s+=e,(r+=e)<=this.from)this.from+=a,this.to+=a;else if(s<this.to){if(s<this.from||r>this.to||this.to-this.from+l.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(r),l.toString()),this.to+=a}e+=a})),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange;this.composing&&(this.composing.drifted||t.transactions.some((t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to))))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class Fs{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var e;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach((t=>i(t,this))))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new ys(t.state||wt.create(t)),t.scrollTo&&t.scrollTo.is(Ni)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Fi).map((t=>new _i(t)));for(let t of this.plugins)t.update(this);this.observer=new Is(this),this.inputState=new Mn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new en(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then((()=>this.requestMeasure()))}dispatch(...t){let e=1==t.length&&t[0]instanceof ot?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let r=this.hasFocus,o=0,h=null;t.some((t=>t.annotation(Jn)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,h=Un(s,r),h||(o=1));let l=this.observer.delayedAndroidKey,a=null;if(l?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(s);e=tn.create(this,s,t),e.flags|=o;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new Li(t.empty?t:C.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Ni)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=qs.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(Qi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some((t=>t.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(e.startState.facet(Cs)!=e.state.facet(Cs)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(Ci))try{t(e)}catch(t){Hi(this.state,t,"update listener")}(h||a)&&Promise.resolve().then((()=>{h&&this.state==h.startState&&this.dispatch(h),a&&!kn(this,a)&&l.force&&oe(this.contentDOM,l.key,l.keyCode)}))}setState(t){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new ys(t),this.plugins=t.facet(Fi).map((t=>new _i(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new en(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Fi),i=t.state.facet(Fi);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new _i(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){Hi(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(le(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];4&o||([this.measureRequests,h]=[h,this.measureRequests]);let l=h.map((t=>{try{return t.read(this)}catch(t){return Hi(this.state,t),_s}})),a=tn.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),c=this.docView.update(a),c&&this.docViewUpdate());for(let t=0;t<h.length;t++)if(l[t]!=_s)try{let e=h[t];e.write&&e.write(l[t],this)}catch(t){Hi(this.state,t)}if(c&&this.docView.updateSelection(!0),!a.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,r=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-r;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Ci))t(e)}get themeClasses(){return Ds+" "+(this.state.facet(Os)?Es:Ts)+" "+this.state.facet(Cs)}updateAttrs(){let t=Ks(this,qi,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Vi)?"true":"false",class:"cm-content",style:`${Te.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Ks(this,Ki,e);let i=this.observer.ignore((()=>{let i=Fe(this.contentDOM,this.contentAttrs,e),n=Fe(this.dom,this.editorAttrs,t);return i||n}));return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(Fs.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Qi);let t=this.state.facet(Fs.cspNonce);Wt.mount(this.root,this.styleModules.concat(Ps).reverse(),t?{nonce:t}:void 0)}readMeasured(){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)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame((()=>this.measure()))),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find((e=>e.spec==t))||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return wn(this,t,pn(this,t,e,i))}moveByGroup(t,e){return wn(this,t,pn(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==dt.Space&&(s=e),s==e}}(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return C.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=gn(t,e.head),r=n&&s.type==qe.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==ii.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return C.cursor(o,i?-1:1)}return C.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return wn(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return C.cursor(s,e.assoc);let o,h=e.goalColumn,l=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s,e.assoc||-1),c=t.documentTop;if(a)null==h&&(h=a.left-l.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==h&&(h=Math.min(l.right-l.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=l.left+h,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(f+e)*r,n=fn(t,{x:u,y:i},!1,r);if(i<l.top||i>l.bottom||(r<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return C.cursor(n,s,void 0,h)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),fn(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return Qt(i,s[fi.find(s,t-n.from,-1,e)].dir==ii.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(Ri)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>zs)return vi(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||di(n.isolates,e=Ui(this,t))))return n.order;e||(e=Ui(this,t));let n=wi(t.text,i,e);return this.bidiCache.push(new qs(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Te.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{se(this.contentDOM),this.docView.updateSelection()}))}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Ni.of(new Li("number"==typeof t?C.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Ni.of(new Li(C.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return zi.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return zi.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=Wt.newName(),n=[Cs.of(i),Qi.of(Bs(`.${i}`,t))];return e&&e.dark&&n.push(Os.of(!0)),n}static baseTheme(t){return _.lowest(Qi.of(Bs("."+Ds,t,Rs)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&de.get(i)||de.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}Fs.styleModule=Qi,Fs.inputHandler=Oi,Fs.clipboardInputFilter=Ti,Fs.clipboardOutputFilter=Ei,Fs.scrollHandler=Pi,Fs.focusChangeEffect=Di,Fs.perLineTextDirection=Ri,Fs.exceptionSink=Mi,Fs.updateListener=Ci,Fs.editable=Vi,Fs.mouseSelectionStyle=Ai,Fs.dragMovesSelection=ki,Fs.clickAddsSelectionRange=Si,Fs.decorations=ji,Fs.outerDecorations=$i,Fs.atomicRanges=Gi,Fs.bidiIsolatedRanges=Ji,Fs.scrollMargins=Yi,Fs.darkTheme=Os,Fs.cspNonce=T.define({combine:t=>t.length?t[0]:""}),Fs.contentAttributes=Ki,Fs.editorAttributes=qi,Fs.lineWrapping=Fs.contentAttributes.of({class:"cm-lineWrapping"}),Fs.announce=rt.define();const zs=4096,_s={};class qs{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:ii.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let r=t[s];r.dir!=n||e.touchesRange(r.from,r.to)||i.push(new qs(e.mapPos(r.from,1),e.mapPos(r.to,-1),r.dir,r.isolates,!1,r.order))}return i}}function Ks(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&He(r,i)}return i}const js=Te.mac?"mac":Te.windows?"win":Te.linux?"linux":"key";function $s(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const Gs=T.define({enables:_.default(Fs.domEventHandlers({keydown:(t,e)=>Zs(Us(e.state),t,e,"editor")}))}),Js=new WeakMap;function Us(t){let e=t.facet(Gs),i=Js.get(e);return i||Js.set(e,i=function(t,e=js){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},r=(t,n,r,o,h)=>{var l,a;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,h=i[i.length-1];"Space"==h&&(h=" ");for(let t=0;t<i.length-1;++t){const h=i[t];if(/^(cmd|meta|m)$/i.test(h))o=!0;else if(/^a(lt)?$/i.test(h))n=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))r=!0;else{if(!/^mod$/i.test(h))throw new Error("Unrecognized modifier name: "+h);"mac"==e?o=!0:s=!0}}return n&&(h="Alt-"+h),s&&(h="Ctrl-"+h),o&&(h="Meta-"+h),r&&(h="Shift-"+h),h}(t,e)));for(let e=1;e<u.length;e++){let i=u.slice(0,e).join(" ");s(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=Ys={view:e,prefix:i,scope:t};return setTimeout((()=>{Ys==n&&(Ys=null)}),Xs),!0}]})}let f=u.join(" ");s(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(l=c._any)||void 0===l?void 0:l.run)||void 0===a?void 0:a.slice())||[]});r&&d.run.push(r),o&&(d.preventDefault=!0),h&&(d.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:s}=n;for(let e in t)t[e].run.push((t=>s(t,Qs)))}let s=n[e]||n.key;if(s)for(let e of t)r(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&r(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let Ys=null;const Xs=4e3;let Qs=null;function Zs(t,e,i,n){Qs=e;let s=(0,_t.YG)(e),r=function(t,e){let i=t.charCodeAt(e);if(n=i,!(n>=55296&&n<56320&&e+1!=t.length))return i;var n;let s=t.charCodeAt(e+1);return function(t){return t>=56320&&t<57344}(s)?s-56320+(i-55296<<10)+65536:i}(s,0),o=(r<65536?1:2)==s.length&&" "!=s;let h="",l=!1,a=!1,c=!1;Ys&&Ys.view==i&&Ys.scope==n&&(h=Ys.prefix+" ",Tn.indexOf(e.keyCode)<0&&(a=!0,Ys=null));let u,f,d=new Set,g=t=>{if(t){for(let e of t.run)if(!d.has(e)&&(d.add(e),e(i)))return t.stopPropagation&&(c=!0),!0;t.preventDefault&&(t.stopPropagation&&(c=!0),a=!0)}return!1},p=t[n];return p&&(g(p[h+$s(s,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Te.windows&&e.ctrlKey&&e.altKey)&&(u=_t.ue[e.keyCode])&&u!=s?(g(p[h+$s(u,e,!0)])||e.shiftKey&&(f=_t.uY[e.keyCode])!=s&&f!=u&&g(p[h+$s(f,e,!1)]))&&(l=!0):o&&e.shiftKey&&g(p[h+$s(s,e,!0)])&&(l=!0),!l&&g(p._any)&&(l=!0)),a&&(l=!0),l&&c&&e.stopPropagation(),Qs=null,l}class tr{constructor(t,e,i,n,s){this.className=t,this.left=e,this.top=i,this.width=n,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let n=t.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=er(t);return[new tr(e,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let n=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),r=t.textDirection==ii.LTR,o=t.contentDOM,h=o.getBoundingClientRect(),l=er(t),a=o.querySelector(".cm-line"),c=a&&window.getComputedStyle(a),u=h.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=h.right-(c?parseInt(c.paddingRight):0),d=gn(t,n),g=gn(t,s),p=d.type==qe.Text?d:null,m=g.type==qe.Text?g:null;p&&(t.lineWrapping||d.widgetLineBreaks)&&(p=ir(t,n,1,p));m&&(t.lineWrapping||g.widgetLineBreaks)&&(m=ir(t,s,-1,m));if(p&&m&&p.from==m.from&&p.to==m.to)return v(y(i.from,i.to,p));{let e=p?y(i.from,null,p):b(d,!1),n=m?y(null,i.to,m):b(g,!0),s=[];return(p||d).to<(m||g).from-(p&&m?1:0)||d.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<n.top?s.push(w(u,e.bottom,f,n.top)):e.bottom<n.top&&t.elementAtHeight((e.bottom+n.top)/2).type==qe.Text&&(e.bottom=n.top=(e.bottom+n.top)/2),v(e).concat(s).concat(v(n))}function w(t,i,n,s){return new tr(e,t-l.left,i-l.top,n-t,s-i)}function v({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(w(i[s],t,i[s+1],e));return n}function y(e,i,n){let s=1e9,o=-1e9,h=[];function l(e,i,l,a,c){let d=t.coordsAtPos(e,e==n.to?-2:2),g=t.coordsAtPos(l,l==n.from?2:-2);d&&g&&(s=Math.min(d.top,g.top,s),o=Math.max(d.bottom,g.bottom,o),c==ii.LTR?h.push(r&&i?u:d.left,r&&a?f:g.right):h.push(!r&&a?u:g.left,!r&&i?f:d.right))}let a=null!=e?e:n.from,c=null!=i?i:n.to;for(let n of t.visibleRanges)if(n.to>a&&n.from<c)for(let s=Math.max(n.from,a),r=Math.min(n.to,c);;){let n=t.state.doc.lineAt(s);for(let o of t.bidiSpans(n)){let t=o.from+n.from,h=o.to+n.from;if(t>=r)break;h>s&&l(Math.max(t,s),null==e&&t<=a,Math.min(h,r),null==i&&h>=c,o.dir)}if(s=n.to+1,s>=r)break}return 0==h.length&&l(a,null==e,c,null==i,t.textDirection),{top:s,bottom:o,horizontal:h}}function b(t,e){let i=h.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function er(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==ii.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function ir(t,e,i,n){let s=t.coordsAtPos(e,2*i);if(!s)return n;let r=t.dom.getBoundingClientRect(),o=(s.top+s.bottom)/2,h=t.posAtCoords({x:r.left+1,y:o}),l=t.posAtCoords({x:r.right-1,y:o});return null==h||null==l?n:{from:Math.max(n.from,Math.min(h,l)),to:Math.min(n.to,Math.max(h,l))}}class nr{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(sr)!=t.state.facet(sr)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(sr);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;t==this.scaleX&&e==this.scaleY||(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some(((t,e)=>{return i=t,n=this.drawn[e],!(i.constructor==n.constructor&&i.eq(n));var i,n}))){let e=this.dom.firstChild,i=0;for(let n of t)n.update&&e&&n.constructor&&this.drawn[i].constructor&&n.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(n.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const sr=T.define();function rr(t){return[zi.define((e=>new nr(e,t))),sr.of(t)]}const or=!(Te.ios&&Te.webkit&&Te.webkit_version<534),hr=T.define({combine:t=>vt(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function lr(t={}){return[hr.of(t),cr,fr,gr,Bi.of(!0)]}function ar(t){return t.startState.facet(hr)!=t.state.facet(hr)}const cr=rr({above:!0,markers(t){let{state:e}=t,i=e.facet(hr),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty?!r||or:i.drawRangeCursor){let e=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:C.cursor(s.head,s.head>s.anchor?-1:1);for(let s of tr.forRange(t,e,i))n.push(s)}}return n},update(t,e){t.transactions.some((t=>t.selection))&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=ar(t);return i&&ur(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){ur(e.state,t)},class:"cm-cursorLayer"});function ur(t,e){e.style.animationDuration=t.facet(hr).cursorBlinkRate+"ms"}const fr=rr({above:!1,markers:t=>t.state.selection.ranges.map((e=>e.empty?[]:tr.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e))),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||ar(t),class:"cm-selectionLayer"}),dr={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};or&&(dr[".cm-line"].caretColor=dr[".cm-content"].caretColor="transparent !important");const gr=_.highest(Fs.theme(dr));function pr(){return wr}const mr=Ke.line({class:"cm-activeLine"}),wr=zi.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,i=[];for(let n of t.state.selection.ranges){let s=t.lineBlockAt(n.head);s.from>e&&(i.push(mr.range(s.from)),e=s.from)}return Ke.set(i)}},{decorations:t=>t.decorations});const vr=2e3;function yr(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),s=i-n.from,r=s>vr?-1:s==n.length?function(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):function(t,e,i=t.length){let n=0;for(let s=0;s<i&&s<t.length;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=g(t,s));return n}(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:r,off:s}}function br(t,e){let i=yr(t,e),n=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},n=n.map(t.changes)}},get(e,s,r){let o=yr(t,e);if(!o)return n;let h=function(t,e,i){let n=Math.min(e.line,i.line),s=Math.max(e.line,i.line),r=[];if(e.off>vr||i.off>vr||e.col<0||i.col<0){let o=Math.min(e.off,i.off),h=Math.max(e.off,i.off);for(let e=n;e<=s;e++){let i=t.doc.line(e);i.length<=h&&r.push(C.range(i.from+o,i.to+h))}}else{let o=Math.min(e.col,i.col),h=Math.max(e.col,i.col);for(let e=n;e<=s;e++){let i=t.doc.line(e),n=Nt(i.text,o,t.tabSize,!0);if(n<0)r.push(C.cursor(i.to));else{let e=Nt(i.text,h,t.tabSize);r.push(C.range(i.from+n,i.from+e))}}}return r}(t.state,i,o);return h.length?r?C.create(h.concat(n.ranges)):C.create(h):n}}:null}function xr(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return Fs.mouseSelectionStyle.of(((t,i)=>e(i)?br(t,i):null))}const Sr={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},kr={style:"cursor: crosshair"};function Ar(t={}){let[e,i]=Sr[t.key||"Alt"],n=zi.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[n,Fs.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?kr:null}))]}class Mr extends yt{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Mr.prototype.elementClass="",Mr.prototype.toDOM=void 0,Mr.prototype.mapMode=m.TrackBefore,Mr.prototype.startSide=Mr.prototype.endSide=-1,Mr.prototype.point=!0;const Cr=T.define(),Or=T.define(),Dr=T.define();const Tr=T.define({combine:t=>t.some((t=>t))});function Er(t){let e=[Rr];return t&&!1===t.fixed&&e.push(Tr.of(!0)),e}const Rr=zi.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Dr).map((e=>new Nr(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(Tr),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(Tr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=kt.iter(this.view.state.facet(Cr),this.view.viewport.from),n=[],s=this.gutters.map((t=>new Lr(t,this.view.viewport,-this.view.documentPadding.top)));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let r of t.type)if(r.type==qe.Text&&e){Pr(i,n,r.from);for(let t of s)t.line(this.view,r,n);e=!1}else if(r.widget)for(let t of s)t.widget(this.view,r)}else if(t.type==qe.Text){Pr(i,n,t.from);for(let e of s)e.line(this.view,t,n)}else if(t.widget)for(let e of s)e.widget(this.view,t);for(let t of s)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(Dr),i=t.state.facet(Dr),n=t.docChanged||t.heightChanged||t.viewportChanged||!kt.eq(t.startState.facet(Cr),t.state.facet(Cr),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new Nr(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>Fs.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==ii.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function Br(t){return Array.isArray(t)?t:[t]}function Pr(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class Lr{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=kt.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,r=e.height/t.scaleY;if(this.i==n.elements.length){let e=new Ir(t,r,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,r,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];Pr(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let r=this.gutter;(0!=n.length||r.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let i of t.state.facet(Or)){let s=i(t,e.widget,e);s&&(n||(n=[])).push(s)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class Nr{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,(n=>{let s,r=n.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=Br(e.markers(t)),e.initialSpacer&&(this.spacer=new Ir(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=Br(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!kt.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class Ir{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,r=0;;){let o=r,h=s<e.length?e[s++]:null,l=!1;if(h){let t=h.elementClass;t&&(i+=" "+t);for(let t=r;t<this.markers.length;t++)if(this.markers[t].compare(h)){o=t,l=!0;break}}else o=this.markers.length;for(;r<o;){let t=this.markers[r++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!h)break;h.toDOM&&(l?n=n.nextSibling:this.dom.insertBefore(h.toDOM(t),n)),l&&r++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const Hr=T.define(),Vr=T.define(),Wr=T.define({combine:t=>vt(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],s=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||s(t,e,i):s}return i}})});class Fr extends Mr{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function zr(t,e){return t.state.facet(Wr).formatNumber(e,t.state)}const _r=Dr.compute([Wr],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(Hr),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new Fr(zr(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let n of t.state.facet(Vr)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Wr)!=t.state.facet(Wr),initialSpacer:t=>new Fr(zr(t,Kr(t.state.doc.lines))),updateSpacer(t,e){let i=zr(e.view,Kr(e.view.state.doc.lines));return i==t.number?t:new Fr(i)},domEventHandlers:t.facet(Wr).domEventHandlers})));function qr(t={}){return[Wr.of(t),Er(),_r]}function Kr(t){let e=9;for(;e<t;)e=10*e+9;return e}},70585:function(t,e,i){i.d(e,{Jq:function(){return l},Lj:function(){return a},_b:function(){return E},i9:function(){return T},md:function(){return o},mp:function(){return d},vj:function(){return f}});i(92745),i(84283),i(26200),i(25754),i(22246),i(32517),i(71375),i(15524),i(20267),i(22139),i(39527),i(67670),i(13334),i(36993);const n=1024;let s=0;class r{constructor(t,e){this.from=t,this.to=e}}class o{constructor(t={}){this.id=s++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=l.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}o.closedBy=new o({deserialize:t=>t.split(" ")}),o.openedBy=new o({deserialize:t=>t.split(" ")}),o.group=new o({deserialize:t=>t.split(" ")}),o.contextHash=new o({perNode:!0}),o.lookAhead=new o({perNode:!0}),o.mounted=new o({perNode:!0});const h=Object.create(null);class l{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):h,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new l(t.name||"",e,t.id,i);if(t.props)for(let i of t.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(o.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(o.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}l.none=new l("",Object.create(null),0,8);class a{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);t&&(n||(n=Object.assign({},i.props)),n[t[0].id]=t[1])}e.push(n?new l(i.name,n,i.id,i.flags):i)}return new a(e)}}const c=new WeakMap,u=new WeakMap;var f;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(f||(f={}));class d{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=this.prop(o.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new A(this.topNode,t)}cursorAt(t,e=0,i=0){let n=c.get(this)||this.topNode,s=new A(n);return s.moveTo(t,e),c.set(this,s._tree),s}get topNode(){return new y(this,0,0,null)}resolve(t,e=0){let i=v(c.get(this)||this.topNode,t,e,!1);return c.set(this,i),i}resolveInner(t,e=0){let i=v(u.get(this)||this.topNode,t,e,!0);return u.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&f.IncludeAnonymous)>0;for(let t=this.cursor(r|f.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:D(l.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new d(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new d(l.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:s,maxBufferLength:r=n,reused:h=[],minRepeatType:l=s.types.length}=t,a=Array.isArray(i)?new g(i,i.length):i,c=s.types,u=0,f=0;function m(t,e,i,n,o){let{id:d,start:g,end:S,size:k}=a,A=f;for(;k<0;){if(a.next(),-1==k){let e=h[d];return i.push(e),void n.push(g-t)}if(-3==k)return void(u=d);if(-4==k)return void(f=d);throw new RangeError(`Unrecognized record size: ${k}`)}let M,C,O=c[d],T=g-t;if(S-g<=r&&(C=b(a.pos-e,o))){let e=new Uint16Array(C.size-C.skip),i=a.pos-C.size,n=e.length;for(;a.pos>i;)n=x(C.start,e,n);M=new p(e,S-C.start,s),T=C.start-t}else{let t=a.pos-k;a.next();let e=[],i=[],n=d>=l?d:-1,s=0,o=S;for(;a.pos>t;)n>=0&&a.id==n&&a.size>=0?(a.end<=o-r&&(v(e,i,g,s,a.end,o,n,A),s=e.length,o=a.end),a.next()):m(g,t,e,i,n);if(n>=0&&s>0&&s<e.length&&v(e,i,g,s,g,o,n,A),e.reverse(),i.reverse(),n>-1&&s>0){let t=w(O);M=D(O,e,i,0,e.length,0,S-g,t,t)}else M=y(O,e,i,S-g,A-S)}i.push(M),n.push(T)}function w(t){return(e,i,n)=>{let s,r,h=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof d){if(!l&&s.type==t&&s.length==n)return s;(r=s.prop(o.lookAhead))&&(h=i[l]+s.length+r)}return y(t,e,i,n,h)}}function v(t,e,i,n,r,o,h,l){let a=[],c=[];for(;t.length>n;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(y(s.types[h],a,c,o-r,l-o)),e.push(r-i)}function y(t,e,i,n,s=0,r){if(u){let t=[o.contextHash,u];r=r?[t].concat(r):[t]}if(s>25){let t=[o.lookAhead,s];r=r?[t].concat(r):[t]}return new d(t,e,i,n,r)}function b(t,e){let i=a.fork(),n=0,s=0,o=0,h=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=o,o+=4,n+=4,i.next();continue}let a=i.pos-t;if(t<0||a<r||i.start<h)break;let u=i.id>=l?4:0,f=i.start;for(i.next();i.pos>a;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=l&&(u+=4);i.next()}s=f,n+=t,o+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=o),c.size>4?c:void 0}function x(t,e,i){let{id:n,start:s,end:r,size:o}=a;if(a.next(),o>=0&&n<l){let h=i;if(o>4){let n=a.pos-(o-4);for(;a.pos>n;)i=x(t,e,i)}e[--i]=h,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==o?u=n:-4==o&&(f=n);return i}let S=[],k=[];for(;a.pos>0;)m(t.start||0,t.bufferStart||0,S,k,-1);let A=null!==(e=t.length)&&void 0!==e?e:S.length?k[0]+S[0].length:0;return new d(c[t.topID],S.reverse(),k.reverse(),A)}(t)}}d.empty=new d(l.none,[],[],0);class g{constructor(t,e){this.buffer=t,this.index=e}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new g(this.buffer,this.index)}}class p{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return l.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let r=[];for(;t<i;)r.push(this.childString(t)),t=this.buffer[t+3];return s+"("+r.join(",")+")"}findChild(t,e,i,n,s){let{buffer:r}=this,o=-1;for(let h=t;h!=e&&!(m(s,n,r[h+1],r[h+2])&&(o=h,i>0));h=r[h+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,h=0;o<e;){s[h++]=n[o++],s[h++]=n[o++]-i;let e=s[h++]=n[o++]-i;s[h++]=n[o++]-t,r=Math.max(r,e)}return new p(s,r,this.set)}}function m(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function w(t,e){let i=t.childBefore(e);for(;i;){let e=i.lastChild;if(!e||e.to!=i.to)break;e.type.isError&&e.from==e.to?(t=i,i=e.prevSibling):i=e}return t}function v(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof y&&t.index<0?null:t.parent;if(!e)return t;t=e}let r=n?0:f.IgnoreOverlays;if(n)for(let n=t,o=n.parent;o;n=o,o=n.parent)n instanceof y&&n.index<0&&(null===(s=o.enter(e,i,r))||void 0===s?void 0:s.from)!=n.from&&(t=o);for(;;){let n=t.enter(e,i,r);if(!n)return t;t=n}}class y{constructor(t,e,i,n){this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let r=this;;){for(let{children:h,positions:l}=r._tree,a=e>0?h.length:-1;t!=a;t+=e){let a=h[t],c=l[t]+r.from;if(m(n,i,c,c+a.length))if(a instanceof p){if(s&f.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,e,i-c,n);if(o>-1)return new k(new S(r,a,t,c),null,o)}else if(s&f.IncludeAnonymous||!a.type.isAnonymous||M(a)){let h;if(!(s&f.IgnoreMounts)&&a.props&&(h=a.prop(o.mounted))&&!h.overlay)return new y(h.tree,c,t,r);let l=new y(a,c,t,r);return s&f.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?a.children.length-1:0,e,i,n)}}if(s&f.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,e,i=0){let n;if(!(i&f.IgnoreOverlays)&&(n=this._tree.prop(o.mounted))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new y(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(t=0){return new A(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return v(this,t,e,!1)}resolveInner(t,e=0){return v(this,t,e,!0)}enterUnfinishedNodesBefore(t){return w(this,t)}getChild(t,e=null,i=null){let n=b(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return b(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return x(this,t)}}function b(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(;!s.type.is(i);)if(!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function x(t,e,i=e.length-1){for(let n=t.parent;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class S{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class k{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,e,i){this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new k(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,e,i=0){if(i&f.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new k(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new k(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new k(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new A(this,t)}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new d(this.type,t,e,this.to-this.from)}resolve(t,e=0){return v(this,t,e,!1)}resolveInner(t,e=0){return v(this,t,e,!0)}enterUnfinishedNodesBefore(t){return w(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=b(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return b(this,t,e,i)}get node(){return this}matchContext(t){return x(this,t)}}class A{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof y)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof y?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&f.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&f.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&f.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(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));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&f.IncludeAnonymous||t instanceof p||!t.type.isAnonymous||M(t))return!1}return!0}move(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}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(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}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new k(this.buffer,e,this.stack[t]);return this.bufferNode=new k(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;n&&e&&e(this),n=this.type.isAnonymous,!this.nextSibling();){if(!i)return;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return x(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return x(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function M(t){return t.children.some((t=>t instanceof p||!t.type.isAnonymous||M(t)))}const C=new WeakMap;function O(t,e){if(!t.isAnonymous||e instanceof p||e.type!=t)return 1;let i=C.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof d)){i=1;break}i+=O(t,n)}C.set(e,i)}return i}function D(t,e,i,n,s,r,o,h,l){let a=0;for(let i=n;i<s;i++)a+=O(t,e[i]);let c=Math.ceil(1.5*a/8),u=[],f=[];return function e(i,n,s,o,h){for(let a=s;a<o;){let s=a,d=n[a],g=O(t,i[a]);for(a++;a<o;a++){let e=O(t,i[a]);if(g+e>=c)break;g+=e}if(a==s+1){if(g>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+h);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(D(t,i,n,s,a,d,e,null,l))}f.push(d+h-r)}}(e,i,n,s,0),(h||l)(u,f,o)}class T{constructor(t,e,i,n,s=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(r?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new T(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,r=t.length?t[0]:null;for(let o=0,h=0,l=0;;o++){let a=o<e.length?e[o]:null,c=a?a.fromA:1e9;if(c-h>=i)for(;r&&r.from<c;){let e=r;if(h>=e.from||c<=e.to||l){let t=Math.max(e.from,h)-l,i=Math.min(e.to,c)-l;e=t>=i?null:new T(t,i,e.tree,e.offset+l,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=s<t.length?t[s++]:null}if(!a)break;h=a.toA,l=a.toA-a.toB}return n}}class E{startParse(t,e,i){return"string"==typeof t&&(t=new R(t)),i=i?i.length?i.map((t=>new r(t.from,t.to))):[new r(0,0)]:[new r(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class R{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}new o({perNode:!0})},13419:function(t,e,i){i.d(e,{pJ:function(){return A}});i(92745),i(39527),i(92181),i(99790),i(67670),i(88972);var n=i(70585);let s=0;class r{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=s++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof r&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let n=new r(i,[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new h(t);return t=>t.modified.indexOf(e)>-1?t:h.get(t.base||t,t.modified.concat(e).sort(((t,e)=>t.id-e.id)))}}let o=0;class h{constructor(t){this.name=t,this.instances=[],this.id=o++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every(((t,e)=>t==s[e])));var n,s}));if(i)return i;let n=[],s=new r(t.name,n,t,e);for(let t of e)t.instances.push(s);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort(((t,e)=>e.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)n.push(h.get(e,t));return s}}new n.md;class l{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}l.empty=new l([],2,null);const a=r.define,c=a(),u=a(),f=a(u),d=a(u),g=a(),p=a(g),m=a(g),w=a(),v=a(w),y=a(),b=a(),x=a(),S=a(x),k=a(),A={comment:c,lineComment:a(c),blockComment:a(c),docComment:a(c),name:u,variableName:a(u),typeName:f,tagName:a(f),propertyName:d,attributeName:a(d),className:a(u),labelName:a(u),namespace:a(u),macroName:a(u),literal:g,string:p,docString:a(p),character:a(p),attributeValue:a(p),number:m,integer:a(m),float:a(m),bool:a(g),regexp:a(g),escape:a(g),color:a(g),url:a(g),keyword:y,self:a(y),null:a(y),atom:a(y),unit:a(y),modifier:a(y),operatorKeyword:a(y),controlKeyword:a(y),definitionKeyword:a(y),moduleKeyword:a(y),operator:b,derefOperator:a(b),arithmeticOperator:a(b),logicOperator:a(b),bitwiseOperator:a(b),compareOperator:a(b),updateOperator:a(b),definitionOperator:a(b),typeOperator:a(b),controlOperator:a(b),punctuation:x,separator:a(x),bracket:S,angleBracket:a(S),squareBracket:a(S),paren:a(S),brace:a(S),content:w,heading:v,heading1:a(v),heading2:a(v),heading3:a(v),heading4:a(v),heading5:a(v),heading6:a(v),contentSeparator:a(w),list:a(w),quote:a(w),emphasis:a(w),strong:a(w),link:a(w),monospace:a(w),strikethrough:a(w),inserted:a(),deleted:a(),changed:a(),invalid:a(),meta:k,documentMeta:a(k),annotation:a(k),processingInstruction:a(k),definition:r.defineModifier("definition"),constant:r.defineModifier("constant"),function:r.defineModifier("function"),standard:r.defineModifier("standard"),local:r.defineModifier("local"),special:r.defineModifier("special")};for(let t in A){let e=A[t];e instanceof r&&(e.name=t)}!function(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{}}([{tag:A.link,class:"tok-link"},{tag:A.heading,class:"tok-heading"},{tag:A.emphasis,class:"tok-emphasis"},{tag:A.strong,class:"tok-strong"},{tag:A.keyword,class:"tok-keyword"},{tag:A.atom,class:"tok-atom"},{tag:A.bool,class:"tok-bool"},{tag:A.url,class:"tok-url"},{tag:A.labelName,class:"tok-labelName"},{tag:A.inserted,class:"tok-inserted"},{tag:A.deleted,class:"tok-deleted"},{tag:A.literal,class:"tok-literal"},{tag:A.string,class:"tok-string"},{tag:A.number,class:"tok-number"},{tag:[A.regexp,A.escape,A.special(A.string)],class:"tok-string2"},{tag:A.variableName,class:"tok-variableName"},{tag:A.local(A.variableName),class:"tok-variableName tok-local"},{tag:A.definition(A.variableName),class:"tok-variableName tok-definition"},{tag:A.special(A.variableName),class:"tok-variableName2"},{tag:A.definition(A.propertyName),class:"tok-propertyName tok-definition"},{tag:A.typeName,class:"tok-typeName"},{tag:A.namespace,class:"tok-namespace"},{tag:A.className,class:"tok-className"},{tag:A.macroName,class:"tok-macroName"},{tag:A.propertyName,class:"tok-propertyName"},{tag:A.operator,class:"tok-operator"},{tag:A.comment,class:"tok-comment"},{tag:A.meta,class:"tok-meta"},{tag:A.invalid,class:"tok-invalid"},{tag:A.punctuation,class:"tok-punctuation"}])},23618:function(t,e,i){i.d(e,{c:function(){return l}});i(92745),i(13334);let n=[],s=[];function r(t){if(t<768)return!1;for(let e=0,i=n.length;;){let r=e+i>>1;if(t<n[r])i=r;else{if(!(t>=s[r]))return!0;e=r+1}if(e==i)return!1}}function o(t){return t>=127462&&t<=127487}(()=>{let t="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((t=>t?parseInt(t,36):1));for(let e=0,i=0;e<t.length;e++)(e%2?s:n).push(i+=t[e])})();const h=8205;function l(t,e,i=!0,n=!0){return(i?a:c)(t,e,n)}function a(t,e,i){if(e==t.length)return e;e&&f(t.charCodeAt(e))&&d(t.charCodeAt(e-1))&&e--;let n=u(t,e);for(e+=g(n);e<t.length;){let s=u(t,e);if(n==h||s==h||i&&r(s))e+=g(s),n=s;else{if(!o(s))break;{let i=0,n=e-2;for(;n>=0&&o(u(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function c(t,e,i){for(;e>0;){let n=a(t,e-2,i);if(n<e)return n;e--}return 0}function u(t,e){let i=t.charCodeAt(e);if(!d(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return f(n)?n-56320+(i-55296<<10)+65536:i}function f(t){return t>=56320&&t<57344}function d(t){return t>=55296&&t<56320}function g(t){return t<65536?1:2}},74092:function(t,e,i){i.d(e,{C:function(){return g}});i(92745),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(13334);var n=i(65424),s=i(96381),r=i(84478);function o(t){const e=t.selection.main.head;return t.doc.lineAt(e)}function h(t,e){let i=0;t:for(let n=0;n<t.length;n++)switch(t[n]){case" ":case" ":i+=1;continue t;case"\t":i+=e-i%e;continue t;case"\r":continue t;default:break t}return i}const l=s.r$.define({combine:t=>(0,s.BO)(t,{highlightActiveBlock:!0,hideFirstIndent:!1,markerType:"fullScope",thickness:1})});class a{constructor(t,e,i,n){this.lines=t,this.state=e,this.map=new Map,this.unitWidth=i,this.markerType=n;for(const t of this.lines)this.add(t);this.state.facet(l).highlightActiveBlock&&this.findAndSetActiveLines()}has(t){return this.map.has("number"==typeof t?t:t.number)}get(t){const e=this.map.get("number"==typeof t?t:t.number);if(!e)throw new Error("Line not found in indentation map");return e}set(t,e,i){const n=!t.text.trim().length,s={line:t,col:e,level:i,empty:n};return this.map.set(s.line.number,s),s}add(t){if(this.has(t))return this.get(t);if(!t.length||!t.text.trim().length){if(1===t.number)return this.set(t,0,0);if(t.number===this.state.doc.lines){const e=this.closestNonEmpty(t,-1);return this.set(t,0,e.level)}const e=this.closestNonEmpty(t,-1),i=this.closestNonEmpty(t,1);return e.level>=i.level&&"codeOnly"!==this.markerType?this.set(t,0,e.level):e.empty&&0===e.level&&0!==i.level?this.set(t,0,0):i.level>e.level?this.set(t,0,e.level+1):this.set(t,0,i.level)}const e=h(t.text,this.state.tabSize),i=Math.floor(e/this.unitWidth);return this.set(t,e,i)}closestNonEmpty(t,e){let i=t.number+e;for(;-1===e?i>=1:i<=this.state.doc.lines;){if(this.has(i)){const t=this.get(i);if(!t.empty)return t}const t=this.state.doc.line(i);if(t.text.trim().length){const e=h(t.text,this.state.tabSize),i=Math.floor(e/this.unitWidth);return this.set(t,e,i)}i+=e}const n=this.state.doc.line(-1===e?1:this.state.doc.lines);return this.set(n,0,0)}findAndSetActiveLines(){const t=o(this.state);if(!this.has(t))return;let e,i,n=this.get(t);if(this.has(n.line.number+1)){const t=this.get(n.line.number+1);t.level>n.level&&(n=t)}if(this.has(n.line.number-1)){const t=this.get(n.line.number-1);t.level>n.level&&(n=t)}if(0!==n.level){for(n.active=n.level,e=n.line.number;e>1;e--){if(!this.has(e-1))continue;const t=this.get(e-1);if(t.level<n.level)break;t.active=n.level}for(i=n.line.number;i<this.state.doc.lines;i++){if(!this.has(i+1))continue;const t=this.get(i+1);if(t.level<n.level)break;t.active=n.level}}}}function c(t){const e={light:"#F0F1F2",dark:"#2B3245",activeLight:"#E4E5E6",activeDark:"#3C445C"};let i=e;return t&&(i=Object.assign(Object.assign({},e),t)),r.tk.baseTheme({"&light":{"--indent-marker-bg-color":i.light,"--indent-marker-active-bg-color":i.activeLight},"&dark":{"--indent-marker-bg-color":i.dark,"--indent-marker-active-bg-color":i.activeDark},".cm-line":{position:"relative"},".cm-indent-markers::before":{content:'""',position:"absolute",top:0,left:"2px",right:0,bottom:0,background:"var(--indent-markers)",pointerEvents:"none",zIndex:"-1"}})}function u(t,e,i,n,s){return`${`repeating-linear-gradient(to right, var(${t}) 0 ${e}px, transparent ${e}px ${i}ch)`} ${n*i}.5ch/calc(${i*s}ch - 1px) no-repeat`}function f(t,e,i,n,s){const{level:r,active:o}=t;if(s=null!=s?s:n,i&&0===r)return[];const h=i?1:0,l=[];if(void 0!==o){const t=o-h-1;t>0&&l.push(u("--indent-marker-bg-color",n,e,h,t)),l.push(u("--indent-marker-active-bg-color",s,e,o-1,1)),o!==r&&l.push(u("--indent-marker-bg-color",n,e,o,r-o))}else l.push(u("--indent-marker-bg-color",n,e,h,r-h));return l.join(",")}class d{constructor(t){this.view=t,this.unitWidth=(0,n.y1)(t.state),this.currentLineNumber=o(t.state).number,this.generate(t.state)}update(t){const e=(0,n.y1)(t.state),i=e!==this.unitWidth;i&&(this.unitWidth=e);const s=o(t.state).number,r=s!==this.currentLineNumber;this.currentLineNumber=s;const h=t.state.facet(l).highlightActiveBlock&&r;(t.docChanged||t.viewportChanged||i||h)&&this.generate(t.state)}generate(t){const e=new s.f_,i=function(t,e=t.state){const i=new Set;for(const{from:n,to:s}of t.visibleRanges){let t=n;for(;t<=s;){const n=e.doc.lineAt(t);i.has(n)||i.add(n),t=n.to+1}}return i}(this.view,t),{hideFirstIndent:n,markerType:o,thickness:h,activeThickness:c}=t.facet(l),u=new a(i,t,this.unitWidth,o);for(const t of i){const i=u.get(t.number);if(!(null==i?void 0:i.level))continue;const s=f(i,this.unitWidth,n,h,c);e.add(t.from,t.from,r.p.line({class:"cm-indent-markers",attributes:{style:`--indent-markers: ${s}`}}))}this.decorations=e.finish()}}function g(t={}){return[l.of(t),c(t.colors),r.lg.fromClass(d,{decorations:t=>t.decorations})]}},29933:function(t,e,i){i.d(e,{V:function(){return o}});i(92745),i(39527),i(13334),i(34595);const n="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),s="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class o{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let h=[],l=/^@(\w+)\b/.exec(t[0]),a=l&&"keyframes"==l[1];if(l&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!l)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,h,a)}else null!=o&&h.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(h.length||a)&&r.push((!i||l||o?t:t.map(i)).join(", ")+" {"+h.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=r[n]||1;return r[n]=t+1,"ͼ"+t.toString(36)}static mount(t,e){(t[s]||new l(t)).mount(Array.isArray(e)?e:[e])}}let h=new Map;class l{constructor(t){let e=t.ownerDocument||t,i=e.defaultView;if(!t.head&&t.adoptedStyleSheets&&i.CSSStyleSheet){let n=h.get(e);if(n)return t.adoptedStyleSheets=[n.sheet,...t.adoptedStyleSheets],t[s]=n;this.sheet=new i.CSSStyleSheet,t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets],h.set(e,this)}else{this.styleTag=e.createElement("style");let i=t.head||t;i.insertBefore(this.styleTag,i.firstChild)}this.modules=[],t[s]=this}mount(t){let e=this.sheet,i=0,n=0;for(let s=0;s<t.length;s++){let r=t[s],o=this.modules.indexOf(r);if(o<n&&o>-1&&(this.modules.splice(o,1),n--,o=-1),-1==o){if(this.modules.splice(n++,0,r),e)for(let t=0;t<r.rules.length;t++)e.insertRule(r.rules[t],i++)}else{for(;n<o;)i+=this.modules[n++].rules.length;i+=r.rules.length,n++}}if(!e){let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t}}}},96318:function(t,e,i){i.d(e,{YG:function(){return a},uY:function(){return s},ue:function(){return n}});for(var n={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:"'"},s={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},r="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),o="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),h=0;h<10;h++)n[48+h]=n[96+h]=String(h);for(h=1;h<=24;h++)n[h+111]="F"+h;for(h=65;h<=90;h++)n[h]=String.fromCharCode(h+32),s[h]=String.fromCharCode(h);for(var l in n)s.hasOwnProperty(l)||(s[l]=n[l]);function a(t){var e=!(r&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||o&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?s:n)[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}}};
|
||
//# sourceMappingURL=1117.4a5305eb6e7fdca3.js.map |