@vuu-ui/vuu-codemirror 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/cjs/index.js +11 -0
- package/cjs/index.js.map +7 -0
- package/esm/index.js +11 -0
- package/esm/index.js.map +7 -0
- package/package.json +26 -0
package/cjs/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";var Jn=Object.defineProperty;var Ea=Object.getOwnPropertyDescriptor;var La=Object.getOwnPropertyNames;var Ia=Object.prototype.hasOwnProperty;var Na=(s,t)=>{for(var e in t)Jn(s,e,{get:t[e],enumerable:!0})},Fa=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of La(t))!Ia.call(s,n)&&n!==e&&Jn(s,n,{get:()=>t[n],enumerable:!(i=Ea(t,n))||i.enumerable});return s};var Va=s=>Fa(Jn({},"__esModule",{value:!0}),s);var jd={};Na(jd,{EditorState:()=>E,EditorView:()=>T,HighlightStyle:()=>we,LRLanguage:()=>Ne,LRParser:()=>We,LanguageSupport:()=>Ln,autocompletion:()=>Nh,closeBrackets:()=>Lh,defaultHighlightStyle:()=>wh,defaultKeymap:()=>Sa,drawSelection:()=>Yl,ensureSyntaxTree:()=>ph,highlightSpecialChars:()=>Ql,history:()=>Gh,historyKeymap:()=>Xh,keymap:()=>Ri,startCompletion:()=>Pr,styleTags:()=>En,syntaxHighlighting:()=>bh,syntaxTree:()=>ht,tags:()=>k});module.exports=Va(jd);var B=class{constructor(){}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),Dt.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),Dt.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 De(this),r=new De(t);for(let o=e,l=e;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(t=1){return new De(this,t)}iterRange(t,e=this.length){return new Gi(this,t,e)}iterLines(t,e){let i;if(t==null)i=this.iter();else{e==null&&(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 Ji(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?B.empty:t.length<=32?new $(t):Dt.from($.split(t,[]))}},$=class extends B{constructor(t,e=za(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 r=0;;r++){let o=this.text[r],l=n+o.length;if((e?i:l)>=t)return new Yn(n,l,i,o);n=l+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new $(Xr(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(n&1){let o=i.pop(),l=Ui(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new $(l,o.length+r.length));else{let h=l.length>>1;i.push(new $(l.slice(0,h)),new $(l.slice(h)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof $))return super.replace(t,e,i);let n=Ui(this.text,Ui(i.text,Xr(this.text,0,t)),e),r=this.length+i.length-(e-t);return n.length<=32?new $(n,r):Dt.from($.split(n,[]),r)}sliceString(t,e=this.length,i=`
|
|
2
|
+
`){let n="";for(let r=0,o=0;r<=e&&o<this.text.length;o++){let l=this.text[o],h=r+l.length;r>t&&o&&(n+=i),t<h&&e>r&&(n+=l.slice(Math.max(0,t-r),e-r)),r=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,i.length==32&&(e.push(new $(i,n)),i=[],n=-1);return n>-1&&e.push(new $(i,n)),e}},Dt=class extends B{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let i of t)this.lines+=i.lines}lineInner(t,e,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,h=i+o.lines-1;if((e?h:l)>=t)return o.lineInner(t,e,i,n);n=l+1,i=h+1}}decompose(t,e,i,n){for(let r=0,o=0;o<=e&&r<this.children.length;r++){let l=this.children[r],h=o+l.length;if(t<=h&&e>=o){let a=n&((o<=t?1:0)|(h>=e?2:0));o>=t&&h<=e&&!a?i.push(l):l.decompose(t-o,e-o,i,a)}o=h+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],l=r+o.length;if(t>=r&&e<=l){let h=o.replace(t-r,e-r,i),a=this.lines-o.lines+h.lines;if(h.lines<a>>5-1&&h.lines>a>>5+1){let f=this.children.slice();return f[n]=h,new Dt(f,this.length-(e-t)+i.length)}return super.replace(r,l,h)}r=l+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i=`
|
|
3
|
+
`){let n="";for(let r=0,o=0;r<this.children.length&&o<=e;r++){let l=this.children[r],h=o+l.length;o>t&&r&&(n+=i),t<h&&e>o&&(n+=l.sliceString(t-o,e-o,i)),o=h+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof Dt))return 0;let i=0,[n,r,o,l]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,r+=e){if(n==o||r==l)return i;let h=this.children[n],a=t.children[r];if(h!=a)return i+h.scanIdentical(a,e);i+=h.length+1}}static from(t,e=t.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of t)i+=d.lines;if(i<32){let d=[];for(let p of t)p.flatten(d);return new $(d,e)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],h=0,a=-1,f=[];function c(d){let p;if(d.lines>r&&d instanceof Dt)for(let m of d.children)c(m);else d.lines>o&&(h>o||!h)?(u(),l.push(d)):d instanceof $&&h&&(p=f[f.length-1])instanceof $&&d.lines+p.lines<=32?(h+=d.lines,a+=d.length+1,f[f.length-1]=new $(p.text.concat(d.text),p.length+1+d.length)):(h+d.lines>n&&u(),h+=d.lines,a+=d.length+1,f.push(d))}function u(){h!=0&&(l.push(f.length==1?f[0]:Dt.from(f,a)),a=-1,h=f.length=0)}for(let d of t)c(d);return u(),l.length==1?l[0]:new Dt(l,e)}};B.empty=new $([""],0);function za(s){let t=-1;for(let e of s)t+=e.length+1;return t}function Ui(s,t,e=0,i=1e9){for(let n=0,r=0,o=!0;r<s.length&&n<=i;r++){let l=s[r],h=n+l.length;h>=e&&(h>i&&(l=l.slice(0,i-n)),n<e&&(l=l.slice(e-n)),o?(t[t.length-1]+=l,o=!1):t.push(l)),n=h+1}return t}function Xr(s,t,e){return Ui(s,[""],t,e)}var De=class{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 $?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,l=n instanceof $?n.text.length:n.children.length;if(o==(e>0?l:0)){if(i==0)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(e>0?0:1)){if(this.offsets[i]+=e,t==0)return this.lineBreak=!0,this.value=`
|
|
4
|
+
`,this;t--}else if(n instanceof $){let h=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,h.length>Math.max(0,t))return this.value=t==0?h:e>0?h.slice(t):h.slice(0,h.length-t),this;t-=h.length}else{let h=n.children[o+(e<0?-1:0)];t>h.length?(t-=h.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(h),this.offsets.push(e>0?1:(h instanceof $?h.text.length:h.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}},Gi=class{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new De(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!=""}},Ji=class{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}};typeof Symbol<"u"&&(B.prototype[Symbol.iterator]=function(){return this.iter()},De.prototype[Symbol.iterator]=Gi.prototype[Symbol.iterator]=Ji.prototype[Symbol.iterator]=function(){return this});var Yn=class{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}},qe="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(s=>s?parseInt(s,36):1);for(let s=1;s<qe.length;s++)qe[s]+=qe[s-1];function Ha(s){for(let t=1;t<qe.length;t+=2)if(qe[t]>s)return qe[t-1]<=s;return!1}function Zr(s){return s>=127462&&s<=127487}var Qr=8205;function wt(s,t,e=!0,i=!0){return(e?ro:Wa)(s,t,i)}function ro(s,t,e){if(t==s.length)return t;t&&oo(s.charCodeAt(t))&&lo(s.charCodeAt(t-1))&&t--;let i=ct(s,t);for(t+=Tt(i);t<s.length;){let n=ct(s,t);if(i==Qr||n==Qr||e&&Ha(n))t+=Tt(n),i=n;else if(Zr(n)){let r=0,o=t-2;for(;o>=0&&Zr(ct(s,o));)r++,o-=2;if(r%2==0)break;t+=2}else break}return t}function Wa(s,t,e){for(;t>0;){let i=ro(s,t-2,e);if(i<t)return i;t--}return 0}function oo(s){return s>=56320&&s<57344}function lo(s){return s>=55296&&s<56320}function ct(s,t){let e=s.charCodeAt(t);if(!lo(e)||t+1==s.length)return e;let i=s.charCodeAt(t+1);return oo(i)?(e-55296<<10)+(i-56320)+65536:e}function ls(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}function Tt(s){return s<65536?1:2}var Xn=/\r\n?|\n/,ft=function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s}(ft||(ft={})),Ct=class{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 this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let r=this.sections[e++],o=this.sections[e++];o<0?(t(i,n,r),n+=r):n+=o,i+=r}}iterChangedRanges(t,e=!1){Zn(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 Ct(t)}composeDesc(t){return this.empty?t:t.empty?this:ho(this,t)}mapDesc(t,e=!1){return t.empty?this:Qn(this,t,e)}mapPos(t,e=-1,i=ft.Simple){let n=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],h=this.sections[o++],a=n+l;if(h<0){if(a>t)return r+(t-n);r+=l}else{if(i!=ft.Simple&&a>=t&&(i==ft.TrackDel&&n<t&&a>t||i==ft.TrackBefore&&n<t||i==ft.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!l)return t==n||e<0?r:r+h;r+=h}n=a}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return r}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let r=this.sections[i++],o=this.sections[i++],l=n+r;if(o>=0&&n<=e&&l>=t)return n<t&&l>e?"cover":!0;n=l}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(e=>typeof e!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ct(t)}static create(t){return new Ct(t)}},K=class extends Ct{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 Zn(this,(e,i,n,r,o)=>t=t.replace(n,n+(i-e),o),!1),t}mapDesc(t,e=!1){return Qn(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],l=e[n+1];if(l>=0){e[n]=l,e[n+1]=o;let h=n>>1;for(;i.length<h;)i.push(B.empty);i.push(o?t.slice(r,r+o):B.empty)}r+=o}return new K(e,i)}compose(t){return this.empty?t:t.empty?this:ho(this,t,!0)}map(t,e=!1){return t.empty?this:Qn(this,t,e,!0)}iterChanges(t,e=!1){Zn(this,t,e)}get desc(){return Ct.create(this.sections)}filter(t){let e=[],i=[],n=[],r=new Te(this);t:for(let o=0,l=0;;){let h=o==t.length?1e9:t[o++];for(;l<h||l==h&&r.len==0;){if(r.done)break t;let f=Math.min(r.len,h-l);at(n,f,-1);let c=r.ins==-1?-1:r.off==0?r.ins:0;at(e,f,c),c>0&&ae(i,e,r.text),r.forward(f),l+=f}let a=t[o++];for(;l<a;){if(r.done)break t;let f=Math.min(r.len,a-l);at(e,f,-1),at(n,f,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(f),l+=f}}return{changes:new K(e,i),filtered:Ct.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):n==0?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],r=[],o=0,l=null;function h(f=!1){if(!f&&!n.length)return;o<e&&at(n,e-o,-1);let c=new K(n,r);l=l?l.compose(c.map(l)):c,n=[],r=[],o=0}function a(f){if(Array.isArray(f))for(let c of f)a(c);else if(f instanceof K){if(f.length!=e)throw new RangeError(`Mismatched change set length (got ${f.length}, expected ${e})`);h(),l=l?l.compose(f.map(l)):f}else{let{from:c,to:u=c,insert:d}=f;if(c>u||c<0||u>e)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${e})`);let p=d?typeof d=="string"?B.of(d.split(i||Xn)):d:B.empty,m=p.length;if(c==u&&m==0)return;c<o&&h(),c>o&&at(n,c-o,-1),at(n,u-c,m),ae(r,n,p),o=u}}return a(t),h(!l),l}static empty(t){return new K(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(typeof r=="number")e.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)e.push(r[0],0);else{for(;i.length<n;)i.push(B.empty);i[n]=B.of(r.slice(1)),e.push(r[0],i[n].length)}}}return new K(e,i)}static createSet(t,e){return new K(t,e)}};function at(s,t,e,i=!1){if(t==0&&e<=0)return;let n=s.length-2;n>=0&&e<=0&&e==s[n+1]?s[n]+=t:t==0&&s[n]==0?s[n+1]+=e:i?(s[n]+=t,s[n+1]+=e):s.push(t,e)}function ae(s,t,e){if(e.length==0)return;let i=t.length-2>>1;if(i<s.length)s[s.length-1]=s[s.length-1].append(e);else{for(;s.length<i;)s.push(B.empty);s.push(e)}}function Zn(s,t,e){let i=s.inserted;for(let n=0,r=0,o=0;o<s.sections.length;){let l=s.sections[o++],h=s.sections[o++];if(h<0)n+=l,r+=l;else{let a=n,f=r,c=B.empty;for(;a+=l,f+=h,h&&i&&(c=c.append(i[o-2>>1])),!(e||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],h=s.sections[o++];t(n,a,r,f,c),n=a,r=f}}}function Qn(s,t,e,i=!1){let n=[],r=i?[]:null,o=new Te(s),l=new Te(t);for(let h=-1;;)if(o.ins==-1&&l.ins==-1){let a=Math.min(o.len,l.len);at(n,a,-1),o.forward(a),l.forward(a)}else if(l.ins>=0&&(o.ins<0||h==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!e))){let a=l.len;for(at(n,l.ins,-1);a;){let f=Math.min(o.len,a);o.ins>=0&&h<o.i&&o.len<=f&&(at(n,0,o.ins),r&&ae(r,n,o.text),h=o.i),o.forward(f),a-=f}l.next()}else if(o.ins>=0){let a=0,f=o.len;for(;f;)if(l.ins==-1){let c=Math.min(f,l.len);a+=c,f-=c,l.forward(c)}else if(l.ins==0&&l.len<f)f-=l.len,l.next();else break;at(n,a,h<o.i?o.ins:0),r&&h<o.i&&ae(r,n,o.text),h=o.i,o.forward(o.len-f)}else{if(o.done&&l.done)return r?K.createSet(n,r):Ct.create(n);throw new Error("Mismatched change set lengths")}}function ho(s,t,e=!1){let i=[],n=e?[]:null,r=new Te(s),o=new Te(t);for(let l=!1;;){if(r.done&&o.done)return n?K.createSet(i,n):Ct.create(i);if(r.ins==0)at(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)at(i,0,o.ins,l),n&&ae(n,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let h=Math.min(r.len2,o.len),a=i.length;if(r.ins==-1){let f=o.ins==-1?-1:o.off?0:o.ins;at(i,h,f,l),n&&f&&ae(n,i,o.text)}else o.ins==-1?(at(i,r.off?0:r.len,h,l),n&&ae(n,i,r.textBit(h))):(at(i,r.off?0:r.len,o.off?0:o.ins,l),n&&!o.off&&ae(n,i,o.text));l=(r.ins>h||o.ins>=0&&o.len>h)&&(l||i.length>a),r.forward2(h),o.forward(h)}}}}var Te=class{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 this.ins==-2}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?B.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?B.empty:e[i].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}},ee=class{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let t=this.flags&3;return t==3?null:t}get goalColumn(){let t=this.flags>>5;return t==33554431?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 ee(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return b.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return b.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||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(t.anchor,t.head)}static create(t,e,i){return new ee(t,e,i)}},b=class{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:b.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 this.ranges.length==1?this:new b([this.main],0)}addRange(t,e=!0){return b.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,b.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)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(t.ranges.map(e=>ee.fromJSON(e)),t.main)}static single(t,e=t){return new b([b.range(t,e)],0)}static create(t,e=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let r=t[n];if(r.empty?r.from<=i:r.from<i)return b.normalized(t.slice(),e);i=r.to}return new b(t,e)}static cursor(t,e=0,i,n){return ee.create(t,t,(e==0?0:e<0?4:8)|(i==null?3:Math.min(2,i))|(n!=null?n:33554431)<<5)}static range(t,e,i,n){let r=(i!=null?i:33554431)<<5|(n==null?3:Math.min(2,n));return e<t?ee.create(e,t,24|r):ee.create(t,e,(e>t?4:0)|r)}static normalized(t,e=0){let i=t[e];t.sort((n,r)=>n.from-r.from),e=t.indexOf(i);for(let n=1;n<t.length;n++){let r=t[n],o=t[n-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,h=Math.max(r.to,o.to);n<=e&&e--,t.splice(--n,2,r.anchor>r.head?b.range(h,l):b.range(l,h))}}return new b(t,e)}};function ao(s,t){for(let e of s.ranges)if(e.to>t)throw new RangeError("Selection points outside of document")}var hs=0,D=class{constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=hs++,this.default=t([]),this.extensions=typeof r=="function"?r(this):r}static define(t={}){return new D(t.combine||(e=>e),t.compareInput||((e,i)=>e===i),t.compare||(t.combine?(e,i)=>e===i:as),!!t.static,t.enables)}of(t){return new $e([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new $e(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new $e(t,this,2,e)}from(t,e){return e||(e=i=>i),this.compute([t],i=>e(i.field(t)))}};function as(s,t){return s==t||s.length==t.length&&s.every((e,i)=>e===t[i])}var $e=class{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=hs++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,r=this.id,o=t[r]>>1,l=this.type==2,h=!1,a=!1,f=[];for(let c of this.dependencies)c=="doc"?h=!0:c=="selection"?a=!0:((e=t[c.id])!==null&&e!==void 0?e:1)&1||f.push(t[c.id]);return{create(c){return c.values[o]=i(c),1},update(c,u){if(h&&u.docChanged||a&&(u.docChanged||u.selection)||ts(c,f)){let d=i(c);if(l?!to(d,c.values[o],n):!n(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,u)=>{let d,p=u.config.address[r];if(p!=null){let m=Yi(u,p);if(this.dependencies.every(g=>g instanceof D?u.facet(g)===c.facet(g):g instanceof ut?u.field(g,!1)==c.field(g,!1):!0)||(l?to(d=i(c),m,n):n(d=i(c),m)))return c.values[o]=m,0}else d=i(c);return c.values[o]=d,1}}}};function to(s,t,e){if(s.length!=t.length)return!1;for(let i=0;i<s.length;i++)if(!e(s[i],t[i]))return!1;return!0}function ts(s,t){let e=!1;for(let i of t)bi(s,i)&1&&(e=!0);return e}function ja(s,t,e){let i=e.map(h=>s[h.id]),n=e.map(h=>h.type),r=i.filter(h=>!(h&1)),o=s[t.id]>>1;function l(h){let a=[];for(let f=0;f<i.length;f++){let c=Yi(h,i[f]);if(n[f]==2)for(let u of c)a.push(u);else a.push(c)}return t.combine(a)}return{create(h){for(let a of i)bi(h,a);return h.values[o]=l(h),1},update(h,a){if(!ts(h,r))return 0;let f=l(h);return t.compare(f,h.values[o])?0:(h.values[o]=f,1)},reconfigure(h,a){let f=ts(h,i),c=a.config.facets[t.id],u=a.facet(t);if(c&&!f&&as(e,c))return h.values[o]=u,0;let d=l(h);return t.compare(d,u)?(h.values[o]=u,0):(h.values[o]=d,1)}}}var eo=D.define({static:!0}),ut=class{constructor(t,e,i,n,r){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(t){let e=new ut(hs++,t.create,t.update,t.compare||((i,n)=>i===n),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(eo).find(i=>i.field==this);return((e==null?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:i=>(i.values[e]=this.create(i),1),update:(i,n)=>{let r=i.values[e],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[e]=o,1)},reconfigure:(i,n)=>n.config.address[this.id]!=null?(i.values[e]=n.field(this),0):(i.values[e]=this.create(i),1)}}init(t){return[this,eo.of({field:this,create:t})]}get extension(){return this}},Ae={lowest:4,low:3,default:2,high:1,highest:0};function yi(s){return t=>new _i(t,s)}var fe={highest:yi(Ae.highest),high:yi(Ae.high),default:yi(Ae.default),low:yi(Ae.low),lowest:yi(Ae.lowest)},_i=class{constructor(t,e){this.inner=t,this.prec=e}},Ue=class{of(t){return new wi(this,t)}reconfigure(t){return Ue.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}},wi=class{constructor(t,e){this.compartment=t,this.inner=e}},Ge=class{constructor(t,e,i,n,r,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return e==null?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],r=Object.create(null),o=new Map;for(let u of qa(t,e,o))u instanceof ut?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),h=[],a=[];for(let u of n)l[u.id]=a.length<<1,a.push(d=>u.slot(d));let f=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=f&&f[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=h.length<<1|1,as(m,d))h.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));h.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=h.length<<1|1,h.push(g.value)):(l[g.id]=a.length<<1,a.push(y=>g.dynamicSlot(y)));l[p.id]=a.length<<1,a.push(g=>ja(g,p,d))}}let c=a.map(u=>u(l));return new Ge(t,o,c,l,h,r)}};function qa(s,t,e){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let h=n.get(o);if(h!=null){if(h<=l)return;let a=i[h].indexOf(o);a>-1&&i[h].splice(a,1),o instanceof wi&&e.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let a of o)r(a,l);else if(o instanceof wi){if(e.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let a=t.get(o.compartment)||o.inner;e.set(o.compartment,a),r(a,l)}else if(o instanceof _i)r(o.inner,o.prec);else if(o instanceof ut)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof $e)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Ae.default);else{let a=o.extension;if(!a)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(a,l)}}return r(s,Ae.default),i.reduce((o,l)=>o.concat(l))}function bi(s,t){if(t&1)return 2;let e=t>>1,i=s.status[e];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[e]=4;let n=s.computeSlot(s,s.config.dynamicSlots[e]);return s.status[e]=2|n}function Yi(s,t){return t&1?s.config.staticValues[t>>1]:s.values[t>>1]}var fo=D.define(),co=D.define({combine:s=>s.some(t=>t),static:!0}),uo=D.define({combine:s=>s.length?s[0]:void 0,static:!0}),po=D.define(),mo=D.define(),go=D.define(),yo=D.define({combine:s=>s.length?s[0]:!1}),kt=class{constructor(t,e){this.type=t,this.value=e}static define(){return new es}},es=class{of(t){return new kt(this,t)}},is=class{constructor(t){this.map=t}of(t){return new I(this,t)}},I=class{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return e===void 0?void 0:e==this.value?this:new I(this.type,e)}is(t){return this.type==t}static define(t={}){return new is(t.map||(e=>e))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let r=n.map(e);r&&i.push(r)}return i}};I.reconfigure=I.define();I.appendConfig=I.define();var U=class{constructor(t,e,i,n,r,o){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&ao(i,e.newLength),r.some(l=>l.type==U.time)||(this.annotations=r.concat(U.time.of(Date.now())))}static create(t,e,i,n,r,o){return new U(t,e,i,n,r,o)}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(U.userEvent);return!!(e&&(e==t||e.length>t.length&&e.slice(0,t.length)==t&&e[t.length]=="."))}};U.time=kt.define();U.userEvent=kt.define();U.addToHistory=kt.define();U.remote=kt.define();function $a(s,t){let e=[];for(let i=0,n=0;;){let r,o;if(i<s.length&&(n==t.length||t[n]>=s[i]))r=s[i++],o=s[i++];else if(n<t.length)r=t[n++],o=t[n++];else return e;!e.length||e[e.length-1]<r?e.push(r,o):e[e.length-1]<o&&(e[e.length-1]=o)}}function bo(s,t,e){var i;let n,r,o;return e?(n=t.changes,r=K.empty(t.changes.length),o=s.changes.compose(t.changes)):(n=t.changes.map(s.changes),r=s.changes.mapDesc(t.changes,!0),o=s.changes.compose(n)),{changes:o,selection:t.selection?t.selection.map(r):(i=s.selection)===null||i===void 0?void 0:i.map(n),effects:I.mapEffects(s.effects,n).concat(I.mapEffects(t.effects,r)),annotations:s.annotations.length?s.annotations.concat(t.annotations):t.annotations,scrollIntoView:s.scrollIntoView||t.scrollIntoView}}function ns(s,t,e){let i=t.selection,n=Ke(t.annotations);return t.userEvent&&(n=n.concat(U.userEvent.of(t.userEvent))),{changes:t.changes instanceof K?t.changes:K.of(t.changes||[],e,s.facet(uo)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:Ke(t.effects),annotations:n,scrollIntoView:!!t.scrollIntoView}}function wo(s,t,e){let i=ns(s,t.length?t[0]:{},s.doc.length);t.length&&t[0].filter===!1&&(e=!1);for(let r=1;r<t.length;r++){t[r].filter===!1&&(e=!1);let o=!!t[r].sequential;i=bo(i,ns(s,t[r],o?i.changes.newLength:s.doc.length),o)}let n=U.create(s,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Ua(e?Ka(n):n)}function Ka(s){let t=s.startState,e=!0;for(let n of t.facet(po)){let r=n(s);if(r===!1){e=!1;break}Array.isArray(r)&&(e=e===!0?r:$a(e,r))}if(e!==!0){let n,r;if(e===!1)r=s.changes.invertedDesc,n=K.empty(t.doc.length);else{let o=s.changes.filter(e);n=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}s=U.create(t,n,s.selection&&s.selection.map(r),I.mapEffects(s.effects,r),s.annotations,s.scrollIntoView)}let i=t.facet(mo);for(let n=i.length-1;n>=0;n--){let r=i[n](s);r instanceof U?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof U?s=r[0]:s=wo(t,Ke(r),!1)}return s}function Ua(s){let t=s.startState,e=t.facet(go),i=s;for(let n=e.length-1;n>=0;n--){let r=e[n](s);r&&Object.keys(r).length&&(i=bo(i,ns(t,r,s.changes.newLength),!0))}return i==s?s:U.create(t,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}var Ga=[];function Ke(s){return s==null?Ga:Array.isArray(s)?s:[s]}var bt=function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s}(bt||(bt={})),Ja=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ss;try{ss=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function _a(s){if(ss)return ss.test(s);for(let t=0;t<s.length;t++){let e=s[t];if(/\w/.test(e)||e>"\x80"&&(e.toUpperCase()!=e.toLowerCase()||Ja.test(e)))return!0}return!1}function Ya(s){return t=>{if(!/\S/.test(t))return bt.Space;if(_a(t))return bt.Word;for(let e=0;e<s.length;e++)if(t.indexOf(s[e])>-1)return bt.Word;return bt.Other}}var E=class{constructor(t,e,i,n,r,o){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)bi(this,l<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(i==null){if(e)throw new RangeError("Field is not present in this state");return}return bi(this,i),Yi(this,i)}update(...t){return wo(this,t,!0)}applyTransaction(t){let e=this.config,{base:i,compartments:n}=e;for(let o of t.effects)o.is(Ue.reconfigure)?(e&&(n=new Map,e.compartments.forEach((l,h)=>n.set(h,l)),e=null),n.set(o.value.compartment,o.value.extension)):o.is(I.reconfigure)?(e=null,i=o.value):o.is(I.appendConfig)&&(e=null,i=Ke(i).concat(o.value));let r;e?r=t.startState.values.slice():(e=Ge.resolve(i,n,this),r=new E(e,this.doc,this.selection,e.dynamicSlots.map(()=>null),(l,h)=>h.reconfigure(l,this),null).values),new E(e,t.newDoc,t.newSelection,r,(o,l)=>l.update(o,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:b.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),r=[i.range],o=Ke(i.effects);for(let l=1;l<e.ranges.length;l++){let h=t(e.ranges[l]),a=this.changes(h.changes),f=a.map(n);for(let u=0;u<l;u++)r[u]=r[u].map(f);let c=n.mapDesc(a,!0);r.push(h.range.map(c)),n=n.compose(f),o=I.mapEffects(o,f).concat(I.mapEffects(Ke(h.effects),c))}return{changes:n,selection:b.create(r,e.mainIndex),effects:o}}changes(t=[]){return t instanceof K?t:K.of(t,this.doc.length,this.facet(E.lineSeparator))}toText(t){return B.of(t.split(this.facet(E.lineSeparator)||Xn))}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 e==null?t.default:(bi(this,e),Yi(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 ut&&this.config.address[n.id]!=null&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(t,r)){let o=i[r],l=t[r];n.push(o.init(h=>o.spec.fromJSON(l,h)))}}return E.create({doc:t.doc,selection:b.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Ge.resolve(t.extensions||[],new Map),i=t.doc instanceof B?t.doc:B.of((t.doc||"").split(e.staticFacet(E.lineSeparator)||Xn)),n=t.selection?t.selection instanceof b?t.selection:b.single(t.selection.anchor,t.selection.head):b.single(0);return ao(n,i.length),e.staticFacet(co)||(n=n.asSingle()),new E(e,i,n,e.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(E.tabSize)}get lineBreak(){return this.facet(E.lineSeparator)||`
|
|
5
|
+
`}get readOnly(){return this.facet(yo)}phrase(t,...e){for(let i of this.facet(E.phrases))if(Object.prototype.hasOwnProperty.call(i,t)){t=i[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(i,n)=>{if(n=="$")return"$";let r=+(n||1);return!r||r>e.length?i:e[r-1]})),t}languageDataAt(t,e,i=-1){let n=[];for(let r of this.facet(fo))for(let o of r(this,e,i))Object.prototype.hasOwnProperty.call(o,t)&&n.push(o[t]);return n}charCategorizer(t){return Ya(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),r=this.charCategorizer(t),o=t-i,l=t-i;for(;o>0;){let h=wt(e,o,!1);if(r(e.slice(h,o))!=bt.Word)break;o=h}for(;l<n;){let h=wt(e,l);if(r(e.slice(l,h))!=bt.Word)break;l=h}return o==l?null:b.range(o+i,l+i)}};E.allowMultipleSelections=co;E.tabSize=D.define({combine:s=>s.length?s[0]:4});E.lineSeparator=uo;E.readOnly=yo;E.phrases=D.define({compare(s,t){let e=Object.keys(s),i=Object.keys(t);return e.length==i.length&&e.every(n=>s[n]==t[n])}});E.languageData=fo;E.changeFilter=po;E.transactionFilter=mo;E.transactionExtender=go;Ue.reconfigure=I.define();function ce(s,t,e={}){let i={};for(let n of s)for(let r of Object.keys(n)){let o=n[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(e,r))i[r]=e[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let n in t)i[n]===void 0&&(i[n]=t[n]);return i}var Vt=class{eq(t){return this==t}range(t,e=t){return Oe.create(t,e,this)}};Vt.prototype.startSide=Vt.prototype.endSide=0;Vt.prototype.point=!1;Vt.prototype.mapMode=ft.TrackDel;var Oe=class{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Oe(t,e,i)}};function rs(s,t){return s.from-t.from||s.value.startSide-t.value.startSide}var xi=class{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 r=i?this.to:this.from;for(let o=n,l=r.length;;){if(o==l)return o;let h=o+l>>1,a=r[h]-t||(i?this.value[h].endSide:this.value[h].startSide)-e;if(h==o)return a>=0?o:l;a>=0?l=h:o=h+1}}between(t,e,i,n){for(let r=this.findIndex(e,-1e9,!0),o=this.findIndex(i,1e9,!1,r);r<o;r++)if(n(this.from[r]+t,this.to[r]+t,this.value[r])===!1)return!1}map(t,e){let i=[],n=[],r=[],o=-1,l=-1;for(let h=0;h<this.value.length;h++){let a=this.value[h],f=this.from[h]+t,c=this.to[h]+t,u,d;if(f==c){let p=e.mapPos(f,a.startSide,a.mapMode);if(p==null||(u=d=p,a.startSide!=a.endSide&&(d=e.mapPos(f,a.endSide),d<u)))continue}else if(u=e.mapPos(f,a.startSide),d=e.mapPos(c,a.endSide),u>d||u==d&&a.startSide>0&&a.endSide<=0)continue;(d-u||a.endSide-a.startSide)<0||(o<0&&(o=u),a.point&&(l=Math.max(l,d-u)),i.push(a),n.push(u-o),r.push(d-o))}return{mapped:i.length?new xi(n,r,i,l):null,pos:o}}},F=class{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 F(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:r=this.length}=t,o=t.filter;if(e.length==0&&!o)return this;if(i&&(e=e.slice().sort(rs)),this.isEmpty)return e.length?F.of(e):this;let l=new Xi(this,null,-1).goto(0),h=0,a=[],f=new qt;for(;l.value||h<e.length;)if(h<e.length&&(l.from-e[h].from||l.startSide-e[h].value.startSide)>=0){let c=e[h++];f.addInner(c.from,c.to,c.value)||a.push(c)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(h==e.length||this.chunkEnd(l.chunkIndex)<e[h].from)&&(!o||n>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&f.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||n>l.to||r<l.from||o(l.from,l.to,l.value))&&(f.addInner(l.from,l.to,l.value)||a.push(Oe.create(l.from,l.to,l.value))),l.next());return f.finishInner(this.nextLayer.isEmpty&&!a.length?F.empty:this.nextLayer.update({add:a,filter:o,filterFrom:n,filterTo:r}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],h=this.chunk[o],a=t.touchesRange(l,l+h.length);if(a===!1)n=Math.max(n,h.maxPoint),e.push(h),i.push(t.mapPos(l));else if(a===!0){let{mapped:f,pos:c}=h.map(l,t);f&&(n=Math.max(n,f.maxPoint),e.push(f),i.push(c))}}let r=this.nextLayer.map(t);return e.length==0?r:new F(i,e,r||F.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let r=this.chunkPos[n],o=this.chunk[n];if(e>=r&&t<=r+o.length&&o.between(r,t-r,e-r,i)===!1)return}this.nextLayer.between(t,e,i)}}iter(t=0){return Pe.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Pe.from(t).goto(e)}static compare(t,e,i,n,r=-1){let o=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),l=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),h=io(o,l,i),a=new Me(o,h,r),f=new Me(l,h,r);i.iterGaps((c,u,d)=>no(a,c,f,u,d,n)),i.empty&&i.length==0&&no(a,0,f,0,0,n)}static eq(t,e,i=0,n){n==null&&(n=1e9-1);let r=t.filter(f=>!f.isEmpty&&e.indexOf(f)<0),o=e.filter(f=>!f.isEmpty&&t.indexOf(f)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=io(r,o),h=new Me(r,l,0).goto(i),a=new Me(o,l,0).goto(i);for(;;){if(h.to!=a.to||!os(h.active,a.active)||h.point&&(!a.point||!h.point.eq(a.point)))return!1;if(h.to>n)return!0;h.next(),a.next()}}static spans(t,e,i,n,r=-1){let o=new Me(t,null,r).goto(e),l=e,h=o.openStart;for(;;){let a=Math.min(o.to,i);if(o.point){let f=o.activeForPoint(o.to),c=o.pointFrom<e?f.length+1:Math.min(f.length,h);n.point(l,a,o.point,f,c,o.pointRank),h=Math.min(o.openEnd(a),f.length)}else a>l&&(n.span(l,a,o.active,h),h=o.openEnd(a));if(o.to>i)return h+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(t,e=!1){let i=new qt;for(let n of t instanceof Oe?[t]:e?Xa(t):t)i.add(n.from,n.to,n.value);return i.finish()}};F.empty=new F([],[],null,-1);function Xa(s){if(s.length>1)for(let t=s[0],e=1;e<s.length;e++){let i=s[e];if(rs(t,i)>0)return s.slice().sort(rs);t=i}return s}F.empty.nextLayer=F.empty;var qt=class{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}finishChunk(t){this.chunks.push(new xi(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=[])}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new qt)).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?!1:(this.from.length==250&&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(F.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let e=F.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}};function io(s,t,e){let i=new Map;for(let r of s)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&i.set(r.chunk[o],r.chunkPos[o]);let n=new Set;for(let r of t)for(let o=0;o<r.chunk.length;o++){let l=i.get(r.chunk[o]);l!=null&&(e?e.mapPos(l):l)==r.chunkPos[o]&&!(e!=null&&e.touchesRange(l,l+r.chunk[o].length))&&n.add(r.chunk[o])}return n}var Xi=class{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 n=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(n)||this.layer.chunkEnd(this.chunkIndex)<t||n.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}else{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}},Pe=class{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let r=0;r<t.length;r++)for(let o=t[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new Xi(o,e,i,r));return n.length==1?n[0]:new Pe(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 i=this.heap.length>>1;i>=0;i--)_n(this.heap,i);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let i=this.heap.length>>1;i>=0;i--)_n(this.heap,i);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(this.heap.length==0)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(),_n(this.heap,0)}}};function _n(s,t){for(let e=s[t];;){let i=(t<<1)+1;if(i>=s.length)break;let n=s[i];if(i+1<s.length&&n.compare(s[i+1])>=0&&(n=s[i+1],i++),e.compare(n)<0)break;s[i]=e,s[t]=n,t=i}}var Me=class{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=Pe.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){$i(this.active,t),$i(this.activeTo,t),$i(this.activeRank,t),this.minActive=so(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:r}=this.cursor;for(;e<this.activeRank.length&&this.activeRank[e]<=r;)e++;Ki(this.active,e,i),Ki(this.activeTo,e,n),Ki(this.activeRank,e,r),t&&Ki(t,e,this.cursor.from),this.minActive=so(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&&$i(i,n)}else if(this.cursor.value)if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let n=i.length-1;n>=0&&i[n]<t;n--)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 no(s,t,e,i,n,r){s.goto(t),e.goto(i);let o=i+n,l=i,h=i-t;for(;;){let a=s.to+h-e.to||s.endSide-e.endSide,f=a<0?s.to+h:e.to,c=Math.min(f,o);if(s.point||e.point?s.point&&e.point&&(s.point==e.point||s.point.eq(e.point))&&os(s.activeForPoint(s.to+h),e.activeForPoint(e.to))||r.comparePoint(l,c,s.point,e.point):c>l&&!os(s.active,e.active)&&r.compareRange(l,c,s.active,e.active),f>o)break;l=f,a<=0&&s.next(),a>=0&&e.next()}}function os(s,t){if(s.length!=t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!=t[e]&&!s[e].eq(t[e]))return!1;return!0}function $i(s,t){for(let e=t,i=s.length-1;e<i;e++)s[e]=s[e+1];s.pop()}function Ki(s,t,e){for(let i=s.length-1;i>=t;i--)s[i+1]=s[i];s[t]=e}function so(s,t){let e=-1,i=1e9;for(let n=0;n<t.length;n++)(t[n]-i||s[n].endSide-s[e].endSide)<0&&(e=n,i=t[n]);return e}function Be(s,t,e=s.length){let i=0;for(let n=0;n<e;)s.charCodeAt(n)==9?(i+=t-i%t,n++):(i++,n=wt(s,n));return i}function xo(s,t,e,i){for(let n=0,r=0;;){if(r>=t)return n;if(n==s.length)break;r+=s.charCodeAt(n)==9?e-r%e:1,n=wt(s,n)}return i===!0?-1:s.length}var fs="\u037C",ko=typeof Symbol>"u"?"__"+fs:Symbol.for(fs),cs=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),vo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Ot=class{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,h,a){let f=[],c=/^@(\w+)\b/.exec(o[0]),u=c&&c[1]=="keyframes";if(c&&l==null)return h.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,h);else if(p&&typeof p=="object"){if(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(n(d),p,f,u)}else p!=null&&f.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(f.length||u)&&h.push((i&&!c&&!a?o.map(i):o).join(", ")+" {"+f.join(" ")+"}")}for(let o in t)r(n(o),t[o],this.rules)}getRules(){return this.rules.join(`
|
|
6
|
+
`)}static newName(){let t=vo[ko]||1;return vo[ko]=t+1,fs+t.toString(36)}static mount(t,e){(t[cs]||new us(t)).mount(Array.isArray(e)?e:[e])}},Zi=null,us=class{constructor(t){if(!t.head&&t.adoptedStyleSheets&&typeof CSSStyleSheet<"u"){if(Zi)return t.adoptedStyleSheets=[Zi.sheet].concat(t.adoptedStyleSheets),t[cs]=Zi;this.sheet=new CSSStyleSheet,t.adoptedStyleSheets=[this.sheet].concat(t.adoptedStyleSheets),Zi=this}else{this.styleTag=(t.ownerDocument||t).createElement("style");let e=t.head||t;e.insertBefore(this.styleTag,e.firstChild)}this.modules=[],t[cs]=this}mount(t){let e=this.sheet,i=0,n=0;for(let r=0;r<t.length;r++){let o=t[r],l=this.modules.indexOf(o);if(l<n&&l>-1&&(this.modules.splice(l,1),n--,l=-1),l==-1){if(this.modules.splice(n++,0,o),e)for(let h=0;h<o.rules.length;h++)e.insertRule(o.rules[h],i++)}else{for(;n<l;)i+=this.modules[n++].rules.length;i+=o.rules.length,n++}}if(!e){let r="";for(let o=0;o<this.modules.length;o++)r+=this.modules[o].getRules()+`
|
|
7
|
+
`;this.styleTag.textContent=r}}};var ie={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:"'"},Je={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},So=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Ud=typeof navigator<"u"&&/Gecko\/\d+/.test(navigator.userAgent),Za=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qa=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),tf=Za||So&&+So[1]<57;for(Y=0;Y<10;Y++)ie[48+Y]=ie[96+Y]=String(Y);var Y;for(Y=1;Y<=24;Y++)ie[Y+111]="F"+Y;var Y;for(Y=65;Y<=90;Y++)ie[Y]=String.fromCharCode(Y+32),Je[Y]=String.fromCharCode(Y);var Y;for(Qi in ie)Je.hasOwnProperty(Qi)||(Je[Qi]=ie[Qi]);var Qi;function Co(s){var t=tf&&(s.ctrlKey||s.altKey||s.metaKey)||Qa&&s.shiftKey&&s.key&&s.key.length==1||s.key=="Unidentified",e=!t&&s.key||(s.shiftKey?Je:ie)[s.keyCode]||s.key||"Unidentified";return e=="Esc"&&(e="Escape"),e=="Del"&&(e="Delete"),e=="Left"&&(e="ArrowLeft"),e=="Up"&&(e="ArrowUp"),e=="Right"&&(e="ArrowRight"),e=="Down"&&(e="ArrowDown"),e}function un(s){let t;return s.nodeType==11?t=s.getSelection?s:s.ownerDocument:t=s,t.getSelection()}function Ze(s,t){return t?s==t||s.contains(t.nodeType!=1?t.parentNode:t):!1}function ef(s){let t=s.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function hn(s,t){if(!t.anchorNode)return!1;try{return Ze(s,t.anchorNode)}catch{return!1}}function Mi(s){return s.nodeType==3?Qe(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function dn(s,t,e,i){return e?Ao(s,t,e,i,-1)||Ao(s,t,e,i,1):!1}function pn(s){for(var t=0;;t++)if(s=s.previousSibling,!s)return t}function Ao(s,t,e,i,n){for(;;){if(s==e&&t==i)return!0;if(t==(n<0?0:Di(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;t=pn(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[t+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;t=n<0?Di(s):0}else return!1}}function Di(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}var rl={left:0,right:0,top:0,bottom:0};function er(s,t){let e=t?s.left:s.right;return{left:e,right:e,top:s.top,bottom:s.bottom}}function nf(s){return{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function sf(s,t,e,i,n,r,o,l){let h=s.ownerDocument,a=h.defaultView||window;for(let f=s;f;)if(f.nodeType==1){let c,u=f==h.body;if(u)c=nf(a);else{if(f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let m=f.getBoundingClientRect();c={left:m.left,right:m.left+f.clientWidth,top:m.top,bottom:m.top+f.clientHeight}}let d=0,p=0;if(n=="nearest")t.top<c.top?(p=-(c.top-t.top+o),e>0&&t.bottom>c.bottom+p&&(p=t.bottom-c.bottom+p+o)):t.bottom>c.bottom&&(p=t.bottom-c.bottom+o,e<0&&t.top-p<c.top&&(p=-(c.top+p-t.top+o)));else{let m=t.bottom-t.top,g=c.bottom-c.top;p=(n=="center"&&m<=g?t.top+m/2-g/2:n=="start"||n=="center"&&e<0?t.top-o:t.bottom-g+o)-c.top}if(i=="nearest"?t.left<c.left?(d=-(c.left-t.left+r),e>0&&t.right>c.right+d&&(d=t.right-c.right+d+r)):t.right>c.right&&(d=t.right-c.right+r,e<0&&t.left<c.left+d&&(d=-(c.left+d-t.left+r))):d=(i=="center"?t.left+(t.right-t.left)/2-(c.right-c.left)/2:i=="start"==l?t.left-r:t.right-(c.right-c.left)+r)-c.left,d||p)if(u)a.scrollBy(d,p);else{let m=0,g=0;if(p){let y=f.scrollTop;f.scrollTop+=p,g=f.scrollTop-y}if(d){let y=f.scrollLeft;f.scrollLeft+=d,m=f.scrollLeft-y}t={left:t.left-m,top:t.top-g,right:t.right-m,bottom:t.bottom-g},m&&Math.abs(m-d)<1&&(i="nearest"),g&&Math.abs(g-p)<1&&(n="nearest")}if(u)break;f=f.assignedSlot||f.parentNode}else if(f.nodeType==11)f=f.host;else break}function rf(s){let t=s.ownerDocument;for(let e=s.parentNode;e&&e!=t.body;)if(e.nodeType==1){if(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)return e;e=e.assignedSlot||e.parentNode}else if(e.nodeType==11)e=e.host;else break;return null}var ws=class{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){this.set(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}},_e=null;function ol(s){if(s.setActive)return s.setActive();if(_e)return s.focus(_e);let t=[];for(let e=s;e&&(t.push(e,e.scrollTop,e.scrollLeft),e!=e.ownerDocument);e=e.parentNode);if(s.focus(_e==null?{get preventScroll(){return _e={preventScroll:!0},!0}}:void 0),!_e){_e=!1;for(let e=0;e<t.length;){let i=t[e++],n=t[e++],r=t[e++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=r&&(i.scrollLeft=r)}}}var Mo;function Qe(s,t,e=t){let i=Mo||(Mo=document.createRange());return i.setEnd(s,e),i.setStart(s,t),i}function Xe(s,t,e){let i={key:t,code:t,keyCode:e,which:e,cancelable:!0},n=new KeyboardEvent("keydown",i);n.synthetic=!0,s.dispatchEvent(n);let r=new KeyboardEvent("keyup",i);return r.synthetic=!0,s.dispatchEvent(r),n.defaultPrevented||r.defaultPrevented}function of(s){for(;s;){if(s&&(s.nodeType==9||s.nodeType==11&&s.host))return s;s=s.assignedSlot||s.parentNode}return null}function ll(s){for(;s.attributes.length;)s.removeAttributeNode(s.attributes[0])}function lf(s,t){let e=t.focusNode,i=t.focusOffset;if(!e||t.anchorNode!=e||t.anchorOffset!=i)return!1;for(;;)if(i){if(e.nodeType!=1)return!1;let n=e.childNodes[i-1];n.contentEditable=="false"?i--:(e=n,i=Di(e))}else{if(e==s)return!0;i=pn(e),e=e.parentNode}}var it=class{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new it(t.parentNode,pn(t),e)}static after(t,e){return new it(t.parentNode,pn(t)+1,e)}},ir=[],V=class{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}coordsAt(t,e){return null}sync(t,e){if(this.dirty&2){let i=this.dom,n=null,r;for(let o of this.children){if(o.dirty){if(!o.dom&&(r=n?n.nextSibling:i.firstChild)){let l=V.get(r);(!l||!l.parent&&l.canReuseDOM(o))&&o.reuseDOM(r)}o.sync(t,e),o.dirty=0}if(r=n?n.nextSibling:i.firstChild,e&&!e.written&&e.node==i&&r!=o.dom&&(e.written=!0),o.dom.parentNode==i)for(;r&&r!=o.dom;)r=Do(r);else i.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:i.firstChild,r&&e&&e.node==i&&(e.written=!0);r;)r=Do(r)}else if(this.dirty&1)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=Di(t)==0?0:e==0?-1:1;for(;;){let r=t.parentNode;if(r==this.dom)break;n==0&&r.firstChild!=r.lastChild&&(t==r.firstChild?n=-1:n=1),t=r}n<0?i=t:i=t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!V.get(i);)i=i.nextSibling;if(!i)return this.length;for(let n=0,r=0;;n++){let o=this.children[n];if(o.dom==i)return r;r+=o.length+o.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,r=-1,o=-1,l=-1;for(let h=0,a=i,f=i;h<this.children.length;h++){let c=this.children[h],u=a+c.length;if(a<t&&u>e)return c.domBoundsAround(t,e,a);if(u>=t&&n==-1&&(n=h,r=a),a>e&&c.dom.parentNode==this.dom){o=h,l=f;break}f=u,a=u+c.breakAfter}return{from:r,to:l<0?i+this.length:l,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].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),e.dirty&1)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=ir){this.markDirty();for(let n=t;n<e;n++){let r=this.children[n];r.parent==this&&r.destroy()}this.children.splice(t,e-t,...i);for(let n=0;n<i.length;n++)i[n].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new mn(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?"["+(t=="Text"?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}merge(t,e,i,n,r,o){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}};V.prototype.breakAfter=0;function Do(s){let t=s.nextSibling;return s.parentNode.removeChild(s),t}var mn=class{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||this.i==0||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 hl(s,t,e,i,n,r,o,l,h){let{children:a}=s,f=a.length?a[t]:null,c=r.length?r[r.length-1]:null,u=c?c.breakAfter:o;if(!(t==i&&f&&!o&&!u&&r.length<2&&f.merge(e,n,r.length?c:null,e==0,l,h))){if(i<a.length){let d=a[i];d&&n<d.length?(t==i&&(d=d.split(n),n=0),!u&&c&&d.merge(0,n,c,!0,0,h)?r[r.length-1]=d:(n&&d.merge(0,n,null,!1,0,h),r.push(d))):d!=null&&d.breakAfter&&(c?c.breakAfter=1:o=1),i++}for(f&&(f.breakAfter=o,e>0&&(!o&&r.length&&f.merge(e,f.length,r[0],!1,l,0)?f.breakAfter=r.shift().breakAfter:(e<f.length||f.children.length&&f.children[f.children.length-1].length==0)&&f.merge(e,f.length,null,!1,l,0),t++));t<i&&r.length;)if(a[i-1].become(r[r.length-1]))i--,r.pop(),h=r.length?0:l;else if(a[t].become(r[0]))t++,r.shift(),l=r.length?0:h;else break;!r.length&&t&&i<a.length&&!a[t-1].breakAfter&&a[i].merge(0,0,a[t-1],!1,l,h)&&t--,(t<i||r.length)&&s.replaceChildren(t,i,r)}}function al(s,t,e,i,n,r){let o=s.childCursor(),{i:l,off:h}=o.findPos(e,1),{i:a,off:f}=o.findPos(t,-1),c=t-e;for(let u of i)c+=u.length;s.length+=c,hl(s,a,f,l,h,i,0,n,r)}var At=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},xs=typeof document<"u"?document:{documentElement:{style:{}}},ks=/Edge\/(\d+)/.exec(At.userAgent),fl=/MSIE \d/.test(At.userAgent),vs=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(At.userAgent),Cn=!!(fl||vs||ks),To=!Cn&&/gecko\/(\d+)/i.test(At.userAgent),ds=!Cn&&/Chrome\/(\d+)/.exec(At.userAgent),Oo="webkitFontSmoothing"in xs.documentElement.style,cl=!Cn&&/Apple Computer/.test(At.vendor),Po=cl&&(/Mobile\/\w+/.test(At.userAgent)||At.maxTouchPoints>2),M={mac:Po||/Mac/.test(At.platform),windows:/Win/.test(At.platform),linux:/Linux|X11/.test(At.platform),ie:Cn,ie_version:fl?xs.documentMode||6:vs?+vs[1]:ks?+ks[1]:0,gecko:To,gecko_version:To?+(/Firefox\/(\d+)/.exec(At.userAgent)||[0,0])[1]:0,chrome:!!ds,chrome_version:ds?+ds[1]:0,ios:Po,android:/Android\b/.test(At.userAgent),webkit:Oo,safari:cl,webkit_version:Oo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:xs.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},hf=256,Ut=class extends V{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){t.nodeType==3&&this.createDOM(t)}merge(t,e,i){return i&&(!(i instanceof Ut)||this.length-(e-t)+i.length>hf)?!1:(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new Ut(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 it(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 Ss(this.dom,t,e)}},Bt=class extends V{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let n of e)n.setParent(this)}setAttrs(t){if(ll(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?this.dirty&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,r,o){return i&&(!(i instanceof Bt&&i.mark.eq(this.mark))||t&&r<=0||e<this.length&&o<=0)?!1:(al(this,t,e,i?i.children:[],r-1,o-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,r=0;for(let l of this.children){let h=i+l.length;h>t&&e.push(i<t?l.split(t-i):l),n<0&&i>=t&&(n=r),i=h,r++}let o=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Bt(this.mark,e,o)}domAtPos(t){return dl(this,t)}coordsAt(t,e){return ml(this,t,e)}};function Ss(s,t,e){let i=s.nodeValue.length;t>i&&(t=i);let n=t,r=t,o=0;t==0&&e<0||t==i&&e>=0?M.chrome||M.gecko||(t?(n--,o=1):r<i&&(r++,o=-1)):e<0?n--:r<i&&r++;let l=Qe(s,n,r).getClientRects();if(!l.length)return rl;let h=l[(o?o<0:e>=0)?0:l.length-1];return M.safari&&!o&&h.width==0&&(h=Array.prototype.find.call(l,a=>a.width)||h),o?er(h,o<0):h||null}var Kt=class extends V{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||Kt)(t,e,i)}split(t){let e=Kt.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,r,o){return i&&(!(i instanceof Kt)||!this.widget.compare(i.widget)||t>0&&r<=0||e<this.length&&o<=0)?!1:(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t.length==this.length&&t instanceof Kt&&t.side==this.side&&this.widget.constructor==t.widget.constructor?(this.widget.eq(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,!0):!1}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(this.length==0)return B.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):B.empty}domAtPos(t){return t==0?it.before(this.dom):it.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.dom.getClientRects(),n=null;if(!i.length)return rl;for(let r=t>0?i.length-1:0;n=i[r],!(t>0?r==0:r==i.length-1||n.top<n.bottom);r+=t>0?-1:1);return this.length?n:er(n,this.side>0)}get isEditable(){return!1}get isWidget(){return!0}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},gn=class extends Kt{domAtPos(t){let{topView:e,text:i}=this.widget;return e?Cs(t,0,e,i,(n,r)=>n.domAtPos(r),n=>new it(i,Math.min(n,i.nodeValue.length))):new it(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?ul(t,e,i,n):Math.min(e,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(t,e){let{topView:i,text:n}=this.widget;return i?Cs(t,e,i,n,(r,o,l)=>r.coordsAt(o,l),(r,o)=>Ss(n,r,o)):Ss(n,t,e)}destroy(){var t;super.destroy(),(t=this.widget.topView)===null||t===void 0||t.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}};function Cs(s,t,e,i,n,r){if(e instanceof Bt){for(let o=e.dom.firstChild;o;o=o.nextSibling){let l=V.get(o);if(!l)return r(s,t);let h=Ze(o,i),a=l.length+(h?i.nodeValue.length:0);if(s<a||s==a&&l.getSide()<=0)return h?Cs(s,t,l,i,n,r):n(l,s,t);s-=a}return n(e,e.length,-1)}else return e.dom==i?r(s,t):n(e,s,t)}function ul(s,t,e,i){if(e instanceof Bt)for(let n of e.children){let r=0,o=Ze(n.dom,i);if(Ze(n.dom,s))return r+(o?ul(s,t,n,i):n.localPosFromDOM(s,t));r+=o?i.nodeValue.length:n.length}else if(e.dom==i)return Math.min(t,i.nodeValue.length);return e.localPosFromDOM(s,t)}var me=class extends V{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof me&&t.side==this.side}split(){return new me(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 it.before(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){let e=this.dom.getBoundingClientRect(),i=af(this,this.side>0?-1:1);return i&&i.top<e.bottom&&i.bottom>e.top?{left:e.left,right:e.right,top:i.top,bottom:i.bottom}:e}get overrideDOMText(){return B.empty}};Ut.prototype.children=Kt.prototype.children=me.prototype.children=ir;function af(s,t){let e=s.parent,i=e?e.children.indexOf(s):-1;for(;e&&i>=0;)if(t<0?i>0:i<e.children.length){let n=e.children[i+t];if(n instanceof Ut){let r=n.coordsAt(t<0?n.length:0,t);if(r)return r}i+=t}else if(e instanceof Bt&&e.parent)i=e.parent.children.indexOf(e)+(t<0?0:1),e=e.parent;else{let n=e.dom.lastChild;if(n&&n.nodeName=="BR")return n.getClientRects()[0];break}}function dl(s,t){let e=s.dom,{children:i}=s,n=0;for(let r=0;n<i.length;n++){let o=i[n],l=r+o.length;if(!(l==r&&o.getSide()<=0)){if(t>r&&t<l&&o.dom.parentNode==e)return o.domAtPos(t-r);if(t<=r)break;r=l}}for(let r=n;r>0;r--){let o=i[r-1];if(o.dom.parentNode==e)return o.domAtPos(o.length)}for(let r=n;r<i.length;r++){let o=i[r];if(o.dom.parentNode==e)return o.domAtPos(0)}return new it(e,0)}function pl(s,t,e){let i,{children:n}=s;e>0&&t instanceof Bt&&n.length&&(i=n[n.length-1])instanceof Bt&&i.mark.eq(t.mark)?pl(i,t.children[0],e-1):(n.push(t),t.setParent(s)),s.length+=t.length}function ml(s,t,e){let i=null,n=-1,r=null,o=-1;function l(a,f){for(let c=0,u=0;c<a.children.length&&u<=f;c++){let d=a.children[c],p=u+d.length;p>=f&&(d.children.length?l(d,f-u):!r&&(p>f||u==p&&d.getSide()>0)?(r=d,o=f-u):(u<f||u==p&&d.getSide()<0)&&(i=d,n=f-u)),u=p}}l(s,t);let h=(e<0?i:r)||i||r;return h?h.coordsAt(Math.max(0,h==i?n:o),e):ff(s)}function ff(s){let t=s.dom.lastChild;if(!t)return s.dom.getBoundingClientRect();let e=Mi(t);return e[e.length-1]||null}function As(s,t){for(let e in s)e=="class"&&t.class?t.class+=" "+s.class:e=="style"&&t.style?t.style+=";"+s.style:t[e]=s[e];return t}function nr(s,t){if(s==t)return!0;if(!s||!t)return!1;let e=Object.keys(s),i=Object.keys(t);if(e.length!=i.length)return!1;for(let n of e)if(i.indexOf(n)==-1||s[n]!==t[n])return!1;return!0}function Ms(s,t,e){let i=null;if(t)for(let n in t)e&&n in e||s.removeAttribute(i=n);if(e)for(let n in e)t&&t[n]==e[n]||s.setAttribute(i=n,e[n]);return!!i}var Gt=class{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}ignoreEvent(t){return!0}get customView(){return null}destroy(t){}},j=function(s){return s[s.Text=0]="Text",s[s.WidgetBefore=1]="WidgetBefore",s[s.WidgetAfter=2]="WidgetAfter",s[s.WidgetRange=3]="WidgetRange",s}(j||(j={})),H=class extends Vt{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 ti(t)}static widget(t){let e=t.side||0,i=!!t.block;return e+=i?e>0?3e8:-4e8:e>0?1e8:-1e8,new se(t,e,e,i,t.widget||null,!1)}static replace(t){let e=!!t.block,i,n;if(t.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:o}=gl(t,e);i=(r?e?-3e8:-1:5e8)-1,n=(o?e?2e8:1:-6e8)+1}return new se(t,i,n,e,t.widget||null,!0)}static line(t){return new Re(t)}static set(t,e=!1){return F.of(t,e)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};H.none=F.empty;var ti=class extends H{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 ti&&this.tagName==t.tagName&&this.class==t.class&&nr(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)}};ti.prototype.point=!1;var Re=class extends H{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof Re&&this.spec.class==t.spec.class&&nr(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)}};Re.prototype.mapMode=ft.TrackBefore;Re.prototype.point=!0;var se=class extends H{constructor(t,e,i,n,r,o){super(e,i,r,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?ft.TrackBefore:ft.TrackAfter:ft.TrackDel}get type(){return this.startSide<this.endSide?j.WidgetRange:this.startSide<=0?j.WidgetBefore:j.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&this.widget.estimatedHeight>=5}eq(t){return t instanceof se&&cf(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}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)}};se.prototype.point=!0;function gl(s,t=!1){let{inclusiveStart:e,inclusiveEnd:i}=s;return e==null&&(e=s.inclusive),i==null&&(i=s.inclusive),{start:e!=null?e:t,end:i!=null?i:t}}function cf(s,t){return s==t||!!(s&&t&&s.compare(t))}function Ds(s,t,e,i=0){let n=e.length-1;n>=0&&e[n]+i>=s?e[n]=Math.max(e[n],t):e.push(s,t)}var ot=class extends V{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,r,o){if(i){if(!(i instanceof ot))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),al(this,t,e,i?i.children:[],r,o),!0}split(t){let e=new ot;if(e.breakAfter=this.breakAfter,this.length==0)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 r=i;r<this.children.length;r++)e.append(this.children[r],0);for(;i>0&&this.children[i-1].length==0;)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=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){nr(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){pl(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=As(e,this.attrs||{})),i&&(this.attrs=As({class:i},this.attrs||{}))}domAtPos(t){return dl(this,t)}reuseDOM(t){t.nodeName=="DIV"&&(this.setDOM(t),this.dirty|=6)}sync(t,e){var i;this.dom?this.dirty&4&&(ll(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),this.prevAttrs!==void 0&&(Ms(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&&V.get(n)instanceof Bt;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((i=V.get(n))===null||i===void 0?void 0:i.isEditable)==!1&&(!M.ios||!this.children.some(r=>r instanceof Ut))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let t=0;for(let e of this.children){if(!(e instanceof Ut)||/[^ -~]/.test(e.text))return null;let i=Mi(e.dom);if(i.length!=1)return null;t+=i[0].width}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length}:null}coordsAt(t,e){return ml(this,t,e)}become(t){return!1}get type(){return j.Text}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let r=t.children[i],o=n+r.length;if(o>=e){if(r instanceof ot)return r;if(o>e)break}n=o+r.breakAfter}return null}},ne=class extends V{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,r,o){return i&&(!(i instanceof ne)||!this.widget.compare(i.widget)||t>0&&r<=0||e<this.length&&o<=0)?!1:(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return t==0?it.before(this.dom):it.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new ne(this.widget,e,this.type);return i.breakAfter=this.breakAfter,i}get children(){return ir}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):B.empty}domBoundsAround(){return null}become(t){return t instanceof ne&&t.type==this.type&&t.widget.constructor==this.widget.constructor?(t.widget.eq(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.breakAfter=t.breakAfter,!0):!1}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}},Ti=class{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(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!t.breakAfter&&!(t instanceof ne&&t.type==j.WidgetBefore)}getLine(){return this.curLine||(this.content.push(this.curLine=new ot),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(tn(new me(-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:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,t--;continue}else this.text=r,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(tn(new Ut(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,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof se){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 l=e-t;if(i instanceof se)if(i.block){let{type:h}=i;h==j.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ne(i.widget||new yn("div"),l,h))}else{let h=Kt.create(i.widget||new yn("span"),l,l?0:i.startSide),a=this.atCursorPos&&!h.isEditable&&r<=n.length&&(t<e||i.startSide>0),f=!h.isEditable&&(t<e||r>n.length||i.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!a&&(this.pendingBuffer=0),this.flushBuffer(n),a&&(c.append(tn(new me(1),n),r),r=n.length+Math.max(0,r-n.length)),c.append(tn(h,n),r),this.atCursorPos=f,this.pendingBuffer=f?t<e||r>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=r)}static build(t,e,i,n,r){let o=new Ti(t,e,i,r);return o.openEnd=F.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function tn(s,t){for(let e of t)s=new Bt(e,[s],s.length);return s}var yn=class extends Gt{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}},yl=D.define(),bl=D.define(),wl=D.define(),xl=D.define(),Ts=D.define(),kl=D.define(),vl=D.define(),Sl=D.define({combine:s=>s.some(t=>t)}),Cl=D.define({combine:s=>s.some(t=>t)}),ei=class{constructor(t,e="nearest",i="nearest",n=5,r=5){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=r}map(t){return t.empty?this:new ei(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin)}},Bo=I.define({map:(s,t)=>s.map(t)});function Mt(s,t,e){let i=s.facet(xl);i.length?i[0](t):window.onerror?window.onerror(String(t),e,void 0,void 0,t):e?console.error(e+":",t):console.error(t)}var An=D.define({combine:s=>s.length?s[0]:!0}),uf=0,ki=D.define(),vt=class{constructor(t,e,i,n){this.id=t,this.create=e,this.domEventHandlers=i,this.extension=n(this)}static define(t,e){let{eventHandlers:i,provide:n,decorations:r}=e||{};return new vt(uf++,t,i,o=>{let l=[ki.of(o)];return r&&l.push(Oi.of(h=>{let a=h.plugin(o);return a?r(a):H.none})),n&&l.push(n(o)),l})}static fromClass(t,e){return vt.define(i=>new t(i),e)}},Ci=class{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}update(t){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(i){if(Mt(e.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(t)}catch(e){Mt(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(!((e=this.value)===null||e===void 0)&&e.destroy)try{this.value.destroy()}catch(i){Mt(t.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Al=D.define(),sr=D.define(),Oi=D.define(),Ml=D.define(),Dl=D.define(),vi=D.define(),Pt=class{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new Pt(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(e.length==0)return t;let i=[];for(let n=0,r=0,o=0,l=0;;n++){let h=n==t.length?null:t[n],a=o-l,f=h?h.fromB:1e9;for(;r<e.length&&e[r]<f;){let c=e[r],u=e[r+1],d=Math.max(l,c),p=Math.min(f,u);if(d<=p&&new Pt(d+a,p+a,d,p).addToSet(i),u>f)break;r+=2}if(!h)return i;new Pt(h.fromA,h.toA,h.fromB,h.toB).addToSet(i),o=h.toA,l=h.toB}}},ii=class{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=K.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,h)=>n.push(new Pt(r,o,l,h))),this.changedRanges=n}static create(t,e,i){return new ii(t,e,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},J=function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s}(J||(J={})),Os=J.LTR,df=J.RTL;function Tl(s){let t=[];for(let e=0;e<s.length;e++)t.push(1<<+s[e]);return t}var pf=Tl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),mf=Tl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),Ps=Object.create(null),$t=[];for(let s of["()","[]","{}"]){let t=s.charCodeAt(0),e=s.charCodeAt(1);Ps[t]=e,Ps[e]=-t}function gf(s){return s<=247?pf[s]:1424<=s&&s<=1524?2:1536<=s&&s<=1785?mf[s-1536]:1774<=s&&s<=2220?4:8192<=s&&s<=8203?256:64336<=s&&s<=65023?4:s==8204?256:1}var yf=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,pe=class{constructor(t,e,i){this.from=t,this.to=e,this.level=i}get dir(){return this.level%2?df:Os}side(t,e){return this.dir==e==t?this.to:this.from}static find(t,e,i,n){let r=-1;for(let o=0;o<t.length;o++){let l=t[o];if(l.from<=e&&l.to>=e){if(l.level==i)return o;(r<0||(n!=0?n<0?l.from<e:l.to>e:t[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}},G=[];function bf(s,t){let e=s.length,i=t==Os?1:2,n=t==Os?2:1;if(!s||i==1&&!yf.test(s))return Ol(e);for(let o=0,l=i,h=i;o<e;o++){let a=gf(s.charCodeAt(o));a==512?a=l:a==8&&h==4&&(a=16),G[o]=a==4?2:a,a&7&&(h=a),l=a}for(let o=0,l=i,h=i;o<e;o++){let a=G[o];if(a==128)o<e-1&&l==G[o+1]&&l&24?a=G[o]=l:G[o]=256;else if(a==64){let f=o+1;for(;f<e&&G[f]==64;)f++;let c=o&&l==8||f<e&&G[f]==8?h==1?1:8:256;for(let u=o;u<f;u++)G[u]=c;o=f-1}else a==8&&h==1&&(G[o]=1);l=a,a&7&&(h=a)}for(let o=0,l=0,h=0,a,f,c;o<e;o++)if(f=Ps[a=s.charCodeAt(o)])if(f<0){for(let u=l-3;u>=0;u-=3)if($t[u+1]==-f){let d=$t[u+2],p=d&2?i:d&4?d&1?n:i:0;p&&(G[o]=G[$t[u]]=p),l=u;break}}else{if($t.length==189)break;$t[l++]=o,$t[l++]=a,$t[l++]=h}else if((c=G[o])==2||c==1){let u=c==i;h=u?0:1;for(let d=l-3;d>=0;d-=3){let p=$t[d+2];if(p&2)break;if(u)$t[d+2]|=2;else{if(p&4)break;$t[d+2]|=4}}}for(let o=0;o<e;o++)if(G[o]==256){let l=o+1;for(;l<e&&G[l]==256;)l++;let h=(o?G[o-1]:i)==1,a=(l<e?G[l]:i)==1,f=h==a?h?1:2:i;for(let c=o;c<l;c++)G[c]=f;o=l-1}let r=[];if(i==1)for(let o=0;o<e;){let l=o,h=G[o++]!=1;for(;o<e&&h==(G[o]!=1);)o++;if(h)for(let a=o;a>l;){let f=a,c=G[--a]!=2;for(;a>l&&c==(G[a-1]!=2);)a--;r.push(new pe(a,f,c?2:1))}else r.push(new pe(l,o,0))}else for(let o=0;o<e;){let l=o,h=G[o++]==2;for(;o<e&&h==(G[o]==2);)o++;r.push(new pe(l,o,h?1:2))}return r}function Ol(s){return[new pe(0,s,0)]}var Pl="";function wf(s,t,e,i,n){var r;let o=i.head-s.from,l=-1;if(o==0){if(!n||!s.length)return null;t[0].level!=e&&(o=t[0].side(!1,e),l=0)}else if(o==s.length){if(n)return null;let u=t[t.length-1];u.level!=e&&(o=u.side(!0,e),l=t.length-1)}l<0&&(l=pe.find(t,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc));let h=t[l];o==h.side(n,e)&&(h=t[l+=n?1:-1],o=h.side(!n,e));let a=n==(h.dir==e),f=wt(s.text,o,a);if(Pl=s.text.slice(Math.min(o,f),Math.max(o,f)),f!=h.side(n,e))return b.cursor(f+s.from,a?-1:1,h.level);let c=l==(n?t.length-1:0)?null:t[l+(n?1:-1)];return!c&&h.level!=e?b.cursor(n?s.to:s.from,n?-1:1,e):c&&c.level<h.level?b.cursor(c.side(!n,e)+s.from,n?1:-1,c.level):b.cursor(f+s.from,n?-1:1,h.level)}var de="\uFFFF",bn=class{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(E.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=de}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n),this.readNode(n);let r=n.nextSibling;if(r==e)break;let o=V.get(n),l=V.get(r);(o&&l?o.breakAfter:(o?o.breakAfter:Ro(n))||Ro(r)&&(n.nodeName!="BR"||n.cmIgnore))&&this.lineBreak(),n=r}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 r=-1,o=1,l;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(e))&&(r=l.index,o=l[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let h of this.points)h.node==t&&h.pos>this.text.length&&(h.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=V.get(t),i=e&&e.overrideDOMText;if(i!=null){this.findPointInside(t,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else t.nodeType==3?this.readTextNode(t):t.nodeName=="BR"?t.nextSibling&&this.lineBreak():t.nodeType==1&&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)(t.nodeType==3?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+Math.min(e,i.offset))}};function Ro(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(s.nodeName)}var wn=class{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}},xn=class extends V{constructor(t){super(),this.view=t,this.compositionDeco=H.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 ot],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Pt(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:o,toA:l})=>l<this.minWidthFrom||o>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=H.none:(t.transactions.length||this.dirty)&&(this.compositionDeco=kf(this.view,t.changes)),(M.ie||M.chrome)&&!this.compositionDeco.size&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,n=this.updateDeco(),r=Sf(i,n,t.changes);return e=Pt.extendWithRanges(e,r),this.dirty==0&&e.length==0?!1:(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 r=M.chrome||M.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,r),this.dirty=0,r&&(r.written||i.selectionRange.focusNode!=r.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 r of this.children)r instanceof ne&&r.widget instanceof kn&&n.push(r.dom);i.updateGaps(n)}updateChildren(t,e){let i=this.childCursor(e);for(let n=t.length-1;;n--){let r=n>=0?t[n]:null;if(!r)break;let{fromA:o,toA:l,fromB:h,toB:a}=r,{content:f,breakAtStart:c,openStart:u,openEnd:d}=Ti.build(this.view.state.doc,h,a,this.decorations,this.dynamicDecorationMap),{i:p,off:m}=i.findPos(l,1),{i:g,off:y}=i.findPos(o,-1);hl(this,g,y,p,m,f,c,u,d)}}updateSelection(t=!1,e=!1){if((t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange(),!(e||this.mayControlSelection()))return;let i=this.forceSelection;this.forceSelection=!1;let n=this.view.state.selection.main,r=this.domAtPos(n.anchor),o=n.empty?r:this.domAtPos(n.head);if(M.gecko&&n.empty&&xf(r)){let h=document.createTextNode("");this.view.observer.ignore(()=>r.node.insertBefore(h,r.node.childNodes[r.offset]||null)),r=o=new it(h,0),i=!0}let l=this.view.observer.selectionRange;(i||!l.focusNode||!dn(r.node,r.offset,l.anchorNode,l.anchorOffset)||!dn(o.node,o.offset,l.focusNode,l.focusOffset))&&(this.view.observer.ignore(()=>{M.android&&M.chrome&&this.dom.contains(l.focusNode)&&Cf(l.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let h=un(this.view.root);if(h)if(n.empty){if(M.gecko){let a=vf(r.node,r.offset);if(a&&a!=3){let f=Rl(r.node,r.offset,a==1?1:-1);f&&(r=new it(f,a==1?0:f.nodeValue.length))}}h.collapse(r.node,r.offset),n.bidiLevel!=null&&l.cursorBidiLevel!=null&&(l.cursorBidiLevel=n.bidiLevel)}else if(h.extend){h.collapse(r.node,r.offset);try{h.extend(o.node,o.offset)}catch{}}else{let a=document.createRange();n.anchor>n.head&&([r,o]=[o,r]),a.setEnd(o.node,o.offset),a.setStart(r.node,r.offset),h.removeAllRanges(),h.addRange(a)}}),this.view.observer.setSelectionRange(r,o)),this.impreciseAnchor=r.precise?null:new it(l.anchorNode,l.anchorOffset),this.impreciseHead=o.precise?null:new it(l.focusNode,l.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:t}=this,e=t.state.selection.main,i=un(t.root),{anchorNode:n,anchorOffset:r}=t.observer.selectionRange;if(!i||!e.empty||!e.assoc||!i.modify)return;let o=ot.find(this,e.head);if(!o)return;let l=o.posAtStart;if(e.head==l||e.head==l+o.length)return;let h=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!h||!a||h.bottom>a.top)return;let f=this.domAtPos(e.head+e.assoc);i.collapse(f.node,f.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,r)}mayControlSelection(){let t=this.view.root.activeElement;return t==this.dom||hn(this.dom,this.view.observer.selectionRange)&&!(t&&this.dom.contains(t))}nearest(t){for(let e=t;e;){let i=V.get(e);if(i&&i.rootView==this)return i;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 n=this.children[e];if(i<n.length||n instanceof ot)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 r=this.children[n],o=i-r.breakAfter-r.length;if(t>o||t==o&&r.type!=j.WidgetBefore&&r.type!=j.WidgetAfter&&(!n||e==2||this.children[n-1].breakAfter||this.children[n-1].type==j.WidgetBefore&&e>-2))return r.coordsAt(t-o,e);i=o}}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,h=this.view.textDirection==J.LTR;for(let a=0,f=0;f<this.children.length;f++){let c=this.children[f],u=a+c.length;if(u>n)break;if(a>=i){let d=c.dom.getBoundingClientRect();if(e.push(d.height),o){let p=c.dom.lastChild,m=p?Mi(p):[];if(m.length){let g=m[m.length-1],y=h?g.right-d.left:d.right-g.left;y>l&&(l=y,this.minWidth=r,this.minWidthFrom=a,this.minWidthTo=u)}}}a=u+c.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return getComputedStyle(this.children[e].dom).direction=="rtl"?J.RTL:J.LTR}measureTextSize(){for(let n of this.children)if(n instanceof ot){let r=n.measureTextSize();if(r)return r}let t=document.createElement("div"),e,i;return t.className="cm-line",t.style.width="99999px",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(t);let n=Mi(t.firstChild)[0];e=t.getBoundingClientRect().height,i=n?n.width/27:7,t.remove()}),{lineHeight:e,charWidth:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new mn(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let r=n==e.viewports.length?null:e.viewports[n],o=r?r.from-1:this.length;if(o>i){let l=e.lineBlockAt(o).bottom-e.lineBlockAt(i).top;t.push(H.replace({widget:new kn(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return H.set(t)}updateDeco(){let t=this.view.state.facet(Oi).map((e,i)=>(this.dynamicDecorationMap[i]=typeof e=="function")?e(this.view):e);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{range:e}=t,i=this.coordsAt(e.head,e.empty?e.assoc:e.head>e.anchor?-1:1),n;if(!i)return;!e.empty&&(n=this.coordsAt(e.anchor,e.anchor>e.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=0,o=0,l=0,h=0;for(let f of this.view.state.facet(Dl).map(c=>c(this.view)))if(f){let{left:c,right:u,top:d,bottom:p}=f;c!=null&&(r=Math.max(r,c)),u!=null&&(o=Math.max(o,u)),d!=null&&(l=Math.max(l,d)),p!=null&&(h=Math.max(h,p))}let a={left:i.left-r,top:i.top-l,right:i.right+o,bottom:i.bottom+h};sf(this.view.scrollDOM,a,e.head<e.anchor?-1:1,t.x,t.y,t.xMargin,t.yMargin,this.view.textDirection==J.LTR)}};function xf(s){return s.node.nodeType==1&&s.node.firstChild&&(s.offset==0||s.node.childNodes[s.offset-1].contentEditable=="false")&&(s.offset==s.node.childNodes.length||s.node.childNodes[s.offset].contentEditable=="false")}var kn=class extends Gt{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 Bl(s){let t=s.observer.selectionRange,e=t.focusNode&&Rl(t.focusNode,t.focusOffset,0);if(!e)return null;let i=s.docView.nearest(e);if(!i)return null;if(i instanceof ot){let n=e;for(;n.parentNode!=i.dom;)n=n.parentNode;let r=n.previousSibling;for(;r&&!V.get(r);)r=r.previousSibling;let o=r?V.get(r).posAtEnd:i.posAtStart;return{from:o,to:o,node:n,text:e}}else{for(;;){let{parent:r}=i;if(!r)return null;if(r instanceof ot)break;i=r}let n=i.posAtStart;return{from:n,to:n+i.length,node:i.dom,text:e}}}function kf(s,t){let e=Bl(s);if(!e)return H.none;let{from:i,to:n,node:r,text:o}=e,l=t.mapPos(i,1),h=Math.max(l,t.mapPos(n,-1)),{state:a}=s,f=r.nodeType==3?r.nodeValue:new bn([],a).readRange(r.firstChild,null).text;if(h-l<f.length)if(a.doc.sliceString(l,Math.min(a.doc.length,l+f.length),de)==f)h=l+f.length;else if(a.doc.sliceString(Math.max(0,h-f.length),h,de)==f)l=h-f.length;else return H.none;else if(a.doc.sliceString(l,h,de)!=f)return H.none;let c=V.get(r);return c instanceof gn?c=c.widget.topView:c&&(c.parent=null),H.set(H.replace({widget:new Bs(r,o,c),inclusive:!0}).range(l,h))}var Bs=class extends Gt{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 gn}};function Rl(s,t,e){for(;;){if(s.nodeType==3)return s;if(s.nodeType==1&&t>0&&e<=0)s=s.childNodes[t-1],t=Di(s);else if(s.nodeType==1&&t<s.childNodes.length&&e>=0)s=s.childNodes[t],t=0;else return null}}function vf(s,t){return s.nodeType!=1?0:(t&&s.childNodes[t-1].contentEditable=="false"?1:0)|(t<s.childNodes.length&&s.childNodes[t].contentEditable=="false"?2:0)}var Rs=class{constructor(){this.changes=[]}compareRange(t,e){Ds(t,e,this.changes)}comparePoint(t,e){Ds(t,e,this.changes)}};function Sf(s,t,e){let i=new Rs;return F.compare(s,t,e,i),i.changes}function Cf(s,t){for(let e=s;e&&e!=t;e=e.assignedSlot||e.parentNode)if(e.nodeType==1&&e.contentEditable=="false")return!0;return!1}function Af(s,t,e=1){let i=s.charCategorizer(t),n=s.doc.lineAt(t),r=t-n.from;if(n.length==0)return b.cursor(t);r==0?e=1:r==n.length&&(e=-1);let o=r,l=r;e<0?o=wt(n.text,r,!1):l=wt(n.text,r);let h=i(n.text.slice(o,l));for(;o>0;){let a=wt(n.text,o,!1);if(i(n.text.slice(a,o))!=h)break;o=a}for(;l<n.length;){let a=wt(n.text,l);if(i(n.text.slice(l,a))!=h)break;l=a}return b.range(o+n.from,l+n.from)}function Mf(s,t){return t.left>s?t.left-s:Math.max(0,s-t.right)}function Df(s,t){return t.top>s?t.top-s:Math.max(0,s-t.bottom)}function ps(s,t){return s.top<t.bottom-1&&s.bottom>t.top+1}function Eo(s,t){return t<s.top?{top:t,left:s.left,right:s.right,bottom:s.bottom}:s}function Lo(s,t){return t>s.bottom?{top:s.top,left:s.left,right:s.right,bottom:t}:s}function Es(s,t,e){let i,n,r,o,l=!1,h,a,f,c;for(let p=s.firstChild;p;p=p.nextSibling){let m=Mi(p);for(let g=0;g<m.length;g++){let y=m[g];n&&ps(n,y)&&(y=Eo(Lo(y,n.bottom),n.top));let v=Mf(t,y),A=Df(e,y);if(v==0&&A==0)return p.nodeType==3?Io(p,t,e):Es(p,t,e);if(!i||o>A||o==A&&r>v){i=p,n=y,r=v,o=A;let w=A?e<y.top?-1:1:v?t<y.left?-1:1:0;l=!w||(w>0?g<m.length-1:g>0)}v==0?e>y.bottom&&(!f||f.bottom<y.bottom)?(h=p,f=y):e<y.top&&(!c||c.top>y.top)&&(a=p,c=y):f&&ps(f,y)?f=Lo(f,y.bottom):c&&ps(c,y)&&(c=Eo(c,y.top))}}if(f&&f.bottom>=e?(i=h,n=f):c&&c.top<=e&&(i=a,n=c),!i)return{node:s,offset:0};let u=Math.max(n.left,Math.min(n.right,t));if(i.nodeType==3)return Io(i,u,e);if(l&&i.contentEditable!="false")return Es(i,u,e);let d=Array.prototype.indexOf.call(s.childNodes,i)+(t>=(n.left+n.right)/2?1:0);return{node:s,offset:d}}function Io(s,t,e){let i=s.nodeValue.length,n=-1,r=1e9,o=0;for(let l=0;l<i;l++){let h=Qe(s,l,l+1).getClientRects();for(let a=0;a<h.length;a++){let f=h[a];if(f.top==f.bottom)continue;o||(o=t-f.left);let c=(f.top>e?f.top-e:e-f.bottom)-1;if(f.left-1<=t&&f.right+1>=t&&c<r){let u=t>=(f.left+f.right)/2,d=u;if((M.chrome||M.gecko)&&Qe(s,l).getBoundingClientRect().left==f.right&&(d=!u),c<=0)return{node:s,offset:l+(d?1:0)};n=l+(d?1:0),r=c}}}return{node:s,offset:n>-1?n:o>0?s.nodeValue.length:0}}function El(s,t,e,i=-1){var n;let r=s.contentDOM.getBoundingClientRect(),o=r.top+s.viewState.paddingTop,l,{docHeight:h}=s.viewState,{x:a,y:f}=t,c=f-o;if(c<0)return 0;if(c>h)return s.state.doc.length;for(let A=s.defaultLineHeight/2,w=!1;l=s.elementAtHeight(c),l.type!=j.Text;)for(;c=i>0?l.bottom+A:l.top-A,!(c>=0&&c<=h);){if(w)return e?null:0;w=!0,i=-i}f=o+c;let u=l.from;if(u<s.viewport.from)return s.viewport.from==0?0:e?null:No(s,r,l,a,f);if(u>s.viewport.to)return s.viewport.to==s.state.doc.length?s.state.doc.length:e?null:No(s,r,l,a,f);let d=s.dom.ownerDocument,p=s.root.elementFromPoint?s.root:d,m=p.elementFromPoint(a,f);m&&!s.contentDOM.contains(m)&&(m=null),m||(a=Math.max(r.left+1,Math.min(r.right-1,a)),m=p.elementFromPoint(a,f),m&&!s.contentDOM.contains(m)&&(m=null));let g,y=-1;if(m&&((n=s.docView.nearest(m))===null||n===void 0?void 0:n.isEditable)!=!1){if(d.caretPositionFromPoint){let A=d.caretPositionFromPoint(a,f);A&&({offsetNode:g,offset:y}=A)}else if(d.caretRangeFromPoint){let A=d.caretRangeFromPoint(a,f);A&&({startContainer:g,startOffset:y}=A,(!s.contentDOM.contains(g)||M.safari&&Tf(g,y,a)||M.chrome&&Of(g,y,a))&&(g=void 0))}}if(!g||!s.docView.dom.contains(g)){let A=ot.find(s.docView,u);if(!A)return c>l.top+l.height/2?l.to:l.from;({node:g,offset:y}=Es(A.dom,a,f))}let v=s.docView.nearest(g);if(!v)return null;if(v.isWidget){let A=v.dom.getBoundingClientRect();return t.y<A.top||t.y<=A.bottom&&t.x<=(A.left+A.right)/2?v.posAtStart:v.posAtEnd}else return v.localPosFromDOM(g,y)+v.posAtStart}function No(s,t,e,i,n){let r=Math.round((i-t.left)*s.defaultCharacterWidth);if(s.lineWrapping&&e.height>s.defaultLineHeight*1.5){let l=Math.floor((n-e.top)/s.defaultLineHeight);r+=l*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(e.from,e.to);return e.from+xo(o,r,s.state.tabSize)}function Tf(s,t,e){let i;if(s.nodeType!=3||t!=(i=s.nodeValue.length))return!1;for(let n=s.nextSibling;n;n=n.nextSibling)if(n.nodeType!=1||n.nodeName!="BR")return!1;return Qe(s,i-1,i).getBoundingClientRect().left>e}function Of(s,t,e){if(t!=0)return!1;for(let n=s;;){let r=n.parentNode;if(!r||r.nodeType!=1||r.firstChild!=n)return!1;if(r.classList.contains("cm-line"))break;n=r}let i=s.nodeType==1?s.getBoundingClientRect():Qe(s,0,Math.max(s.nodeValue.length,1)).getBoundingClientRect();return e-i.left>5}function Pf(s,t,e,i){let n=s.state.doc.lineAt(t.head),r=!i||!s.lineWrapping?null:s.coordsAtPos(t.assoc<0&&t.head>n.from?t.head-1:t.head);if(r){let h=s.dom.getBoundingClientRect(),a=s.textDirectionAt(n.from),f=s.posAtCoords({x:e==(a==J.LTR)?h.right-1:h.left+1,y:(r.top+r.bottom)/2});if(f!=null)return b.cursor(f,e?-1:1)}let o=ot.find(s.docView,t.head),l=o?e?o.posAtEnd:o.posAtStart:e?n.to:n.from;return b.cursor(l,e?-1:1)}function Fo(s,t,e,i){let n=s.state.doc.lineAt(t.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=t,h=null;;){let a=wf(n,r,o,l,e),f=Pl;if(!a){if(n.number==(e?s.state.doc.lines:1))return l;f=`
|
|
8
|
+
`,n=s.state.doc.line(n.number+(e?1:-1)),r=s.bidiSpans(n),a=b.cursor(e?n.from:n.to)}if(h){if(!h(f))return l}else{if(!i)return a;h=i(f)}l=a}}function Bf(s,t,e){let i=s.state.charCategorizer(t),n=i(e);return r=>{let o=i(r);return n==bt.Space&&(n=o),n==o}}function Rf(s,t,e,i){let n=t.head,r=e?1:-1;if(n==(e?s.state.doc.length:0))return b.cursor(n,t.assoc);let o=t.goalColumn,l,h=s.contentDOM.getBoundingClientRect(),a=s.coordsAtPos(n),f=s.documentTop;if(a)o==null&&(o=a.left-h.left),l=r<0?a.top:a.bottom;else{let d=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(h.right-h.left,s.defaultCharacterWidth*(n-d.from))),l=(r<0?d.top:d.bottom)+f}let c=h.left+o,u=i!=null?i:s.defaultLineHeight>>1;for(let d=0;;d+=10){let p=l+(u+d)*r,m=El(s,{x:c,y:p},!1,r);if(p<h.top||p>h.bottom||(r<0?m<n:m>n))return b.cursor(m,t.assoc,void 0,o)}}function ms(s,t,e){let i=s.state.facet(Ml).map(n=>n(s));for(;;){let n=!1;for(let r of i)r.between(e.from-1,e.from+1,(o,l,h)=>{e.from>o&&e.from<l&&(e=t.head>e.from?b.cursor(o,1):b.cursor(l,-1),n=!0)});if(!n)return e}}var Ls=class{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.mouseSelection=null;let e=(i,n)=>{this.ignoreDuringComposition(n)||n.type=="keydown"&&this.keydown(t,n)||(this.mustFlushObserver(n)&&t.observer.forceFlush(),this.runCustomHandlers(n.type,t,n)?n.preventDefault():i(t,n))};for(let i in tt){let n=tt[i];t.contentDOM.addEventListener(i,r=>{Vo(t,r)&&e(n,r)},Ns[i]),this.registeredEvents.push(i)}t.scrollDOM.addEventListener("mousedown",i=>{i.target==t.scrollDOM&&i.clientY>t.contentDOM.getBoundingClientRect().bottom&&e(tt.mousedown,i)}),M.chrome&&M.chrome_version==102&&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,M.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 r of e)if(n=(i=r.update(t).spec)===null||i===void 0?void 0:i.domEventHandlers){this.customHandlers.push({plugin:r.value,handlers:n});for(let o in n)this.registeredEvents.indexOf(o)<0&&o!="scroll"&&(this.registeredEvents.push(o),t.contentDOM.addEventListener(o,l=>{Vo(t,l)&&this.runCustomHandlers(o,t,l)&&l.preventDefault()}))}}runCustomHandlers(t,e,i){for(let n of this.customHandlers){let r=n.handlers[t];if(r)try{if(r.call(n.plugin,i,e)||i.defaultPrevented)return!0}catch(o){Mt(e.state,o)}}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(r){Mt(t.state,r)}}}keydown(t,e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()<this.lastEscPress+2e3)return!0;if(M.android&&M.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return t.observer.delayAndroidKey(e.key,e.keyCode),!0;let i;return M.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((i=Ll.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||Ef.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=i||e,setTimeout(()=>this.flushIOSKey(t),250),!0):!1}flushIOSKey(t){let e=this.pendingIOSKey;return e?(this.pendingIOSKey=void 0,Xe(t.contentDOM,e.key,e.keyCode)):!1}ignoreDuringComposition(t){return/^key/.test(t.type)?this.composing>0?!0:M.safari&&!M.ios&&Date.now()-this.compositionEndedAt<100?(this.compositionEndedAt=0,!0):!1:!1}mustFlushObserver(t){return t.type=="keydown"&&t.keyCode!=229}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()}},Ll=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Ef="dthko",Il=[16,17,18,20,91,92,224,225];function en(s){return s*.7+8}var Is=class{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=rf(t.contentDOM);let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(E.allowMultipleSelections)&&Lf(t,e),this.dragMove=If(t,e),this.dragging=Nf(t,e)&&zl(e)==1?null:!1}start(t){this.dragging===!1&&(t.preventDefault(),this.select(t))}move(t){var e;if(t.buttons==0)return this.destroy();if(this.dragging!==!1)return;this.select(this.lastEvent=t);let i=0,n=0,r=((e=this.scrollParent)===null||e===void 0?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight};t.clientX<=r.left?i=-en(r.left-t.clientX):t.clientX>=r.right&&(i=en(t.clientX-r.right)),t.clientY<=r.top?n=-en(r.top-t.clientY):t.clientY>=r.bottom&&(n=en(t.clientY-r.bottom)),this.setScrollSpeed(i,n)}up(t){this.dragging==null&&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),this.dragging===!1&&this.select(this.lastEvent)}select(t){let e=this.style.get(t,this.extend,this.multiple);(this.mustSelect||!e.eq(this.view.state.selection)||e.main.assoc!=this.view.state.selection.main.assoc)&&this.view.dispatch({selection:e,userEvent:"select.pointer"}),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 Lf(s,t){let e=s.state.facet(yl);return e.length?e[0](t):M.mac?t.metaKey:t.ctrlKey}function If(s,t){let e=s.state.facet(bl);return e.length?e[0](t):M.mac?!t.altKey:!t.ctrlKey}function Nf(s,t){let{main:e}=s.state.selection;if(e.empty)return!1;let i=un(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r<n.length;r++){let o=n[r];if(o.left<=t.clientX&&o.right>=t.clientX&&o.top<=t.clientY&&o.bottom>=t.clientY)return!0}return!1}function Vo(s,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let e=t.target,i;e!=s.contentDOM;e=e.parentNode)if(!e||e.nodeType==11||(i=V.get(e))&&i.ignoreEvent(t))return!1;return!0}var tt=Object.create(null),Ns=Object.create(null),Nl=M.ie&&M.ie_version<15||M.ios&&M.webkit_version<604;function Ff(s){let t=s.dom.parentNode;if(!t)return;let e=t.appendChild(document.createElement("textarea"));e.style.cssText="position: fixed; left: -10000px; top: 10px",e.focus(),setTimeout(()=>{s.focus(),e.remove(),Fl(s,e.value)},50)}function Fl(s,t){let{state:e}=s,i,n=1,r=e.toText(t),o=r.lines==e.selection.ranges.length;if(Fs!=null&&e.selection.ranges.every(h=>h.empty)&&Fs==r.toString()){let h=-1;i=e.changeByRange(a=>{let f=e.doc.lineAt(a.from);if(f.from==h)return{range:a};h=f.from;let c=e.toText((o?r.line(n++).text:t)+e.lineBreak);return{changes:{from:f.from,insert:c},range:b.cursor(a.from+c.length)}})}else o?i=e.changeByRange(h=>{let a=r.line(n++);return{changes:{from:h.from,to:h.to,insert:a.text},range:b.cursor(h.from+a.length)}}):i=e.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}tt.keydown=(s,t)=>{s.inputState.setSelectionOrigin("select"),t.keyCode==27?s.inputState.lastEscPress=Date.now():Il.indexOf(t.keyCode)<0&&(s.inputState.lastEscPress=0)};tt.touchstart=(s,t)=>{s.inputState.lastTouchTime=Date.now(),s.inputState.setSelectionOrigin("select.pointer")};tt.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};Ns.touchstart=Ns.touchmove={passive:!0};tt.mousedown=(s,t)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return;let e=null;for(let i of s.state.facet(wl))if(e=i(s,t),e)break;if(!e&&t.button==0&&(e=Hf(s,t)),e){let i=s.root.activeElement!=s.contentDOM;s.inputState.startMouseSelection(new Is(s,t,e,i)),i&&s.observer.ignore(()=>ol(s.contentDOM)),s.inputState.mouseSelection&&s.inputState.mouseSelection.start(t)}};function zo(s,t,e,i){if(i==1)return b.cursor(t,e);if(i==2)return Af(s.state,t,e);{let n=ot.find(s.docView,t),r=s.state.doc.lineAt(n?n.posAtEnd:t),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return l<s.state.doc.length&&l==r.to&&l++,b.range(o,l)}}var Vl=(s,t)=>s>=t.top&&s<=t.bottom,Ho=(s,t,e)=>Vl(t,e)&&s>=e.left&&s<=e.right;function Vf(s,t,e,i){let n=ot.find(s.docView,t);if(!n)return 1;let r=t-n.posAtStart;if(r==0)return 1;if(r==n.length)return-1;let o=n.coordsAt(r,-1);if(o&&Ho(e,i,o))return-1;let l=n.coordsAt(r,1);return l&&Ho(e,i,l)?1:o&&Vl(i,o)?-1:1}function Wo(s,t){let e=s.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:e,bias:Vf(s,e,t.clientX,t.clientY)}}var zf=M.ie&&M.ie_version<=11,jo=null,qo=0,$o=0;function zl(s){if(!zf)return s.detail;let t=jo,e=$o;return jo=s,$o=Date.now(),qo=!t||e>Date.now()-400&&Math.abs(t.clientX-s.clientX)<2&&Math.abs(t.clientY-s.clientY)<2?(qo+1)%3:1}function Hf(s,t){let e=Wo(s,t),i=zl(t),n=s.state.selection;return{update(r){r.docChanged&&(e.pos=r.changes.mapPos(e.pos),n=n.map(r.changes))},get(r,o,l){let h=Wo(s,r),a=zo(s,h.pos,h.bias,i);if(e.pos!=h.pos&&!o){let f=zo(s,e.pos,e.bias,i),c=Math.min(f.from,a.from),u=Math.max(f.to,a.to);a=c<a.from?b.range(c,u):b.range(u,c)}return o?n.replaceRange(n.main.extend(a.from,a.to)):l&&n.ranges.length>1&&n.ranges.some(f=>f.eq(a))?Wf(n,a):l?n.addRange(a):b.create([a])}}}function Wf(s,t){for(let e=0;;e++)if(s.ranges[e].eq(t))return b.create(s.ranges.slice(0,e).concat(s.ranges.slice(e+1)),s.mainIndex==e?0:s.mainIndex-(s.mainIndex>e?1:0))}tt.dragstart=(s,t)=>{let{selection:{main:e}}=s.state,{mouseSelection:i}=s.inputState;i&&(i.dragging=e),t.dataTransfer&&(t.dataTransfer.setData("Text",s.state.sliceDoc(e.from,e.to)),t.dataTransfer.effectAllowed="copyMove")};function Ko(s,t,e,i){if(!e)return;let n=s.posAtCoords({x:t.clientX,y:t.clientY},!1);t.preventDefault();let{mouseSelection:r}=s.inputState,o=i&&r&&r.dragging&&r.dragMove?{from:r.dragging.from,to:r.dragging.to}:null,l={from:n,insert:e},h=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:h,selection:{anchor:h.mapPos(n,-1),head:h.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"})}tt.drop=(s,t)=>{if(!t.dataTransfer)return;if(s.state.readOnly)return t.preventDefault();let e=t.dataTransfer.files;if(e&&e.length){t.preventDefault();let i=Array(e.length),n=0,r=()=>{++n==e.length&&Ko(s,t,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o<e.length;o++){let l=new FileReader;l.onerror=r,l.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(e[o])}}else Ko(s,t,t.dataTransfer.getData("Text"),!0)};tt.paste=(s,t)=>{if(s.state.readOnly)return t.preventDefault();s.observer.flush();let e=Nl?null:t.clipboardData;e?(Fl(s,e.getData("text/plain")),t.preventDefault()):Ff(s)};function jf(s,t){let e=s.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function qf(s){let t=[],e=[],i=!1;for(let n of s.selection.ranges)n.empty||(t.push(s.sliceDoc(n.from,n.to)),e.push(n));if(!t.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(t.push(o.text),e.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:t.join(s.lineBreak),ranges:e,linewise:i}}var Fs=null;tt.copy=tt.cut=(s,t)=>{let{text:e,ranges:i,linewise:n}=qf(s.state);if(!e&&!n)return;Fs=n?e:null;let r=Nl?null:t.clipboardData;r?(t.preventDefault(),r.clearData(),r.setData("text/plain",e)):jf(s,e),t.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"})};var Hl=kt.define();function Wl(s,t){let e=[];for(let i of s.facet(vl)){let n=i(s,t);n&&e.push(n)}return e?s.update({effects:e,annotations:Hl.of(!0)}):null}function jl(s){setTimeout(()=>{let t=s.hasFocus;if(t!=s.inputState.notifiedFocused){let e=Wl(s.state,t);e?s.dispatch(e):s.update([])}},10)}tt.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),jl(s)};tt.blur=s=>{s.observer.clearSelectionRange(),jl(s)};tt.compositionstart=tt.compositionupdate=s=>{s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0)};tt.compositionend=s=>{s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionFirstChange=null,M.chrome&&M.android&&s.observer.flushSoon(),setTimeout(()=>{s.inputState.composing<0&&s.docView.compositionDeco.size&&s.update([])},50)};tt.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};tt.beforeinput=(s,t)=>{var e;let i;if(M.chrome&&M.android&&(i=Ll.find(n=>n.inputType==t.inputType))&&(s.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let n=((e=window.visualViewport)===null||e===void 0?void 0:e.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>n+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}};var Uo=["pre-wrap","normal","pre-line","break-spaces"],Vs=class{constructor(t){this.lineWrapping=t,this.doc=B.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,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){return this.lineWrapping?(1+Math.max(0,Math.ceil((t-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return Uo.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(n*10)]||(e=!0,this.heightSamples[Math.floor(n*10)]=!0)}return e}refresh(t,e,i,n,r){let o=Uo.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.lineLength=n,l){this.heightSamples={};for(let h=0;h<r.length;h++){let a=r[h];a<0?h++:this.heightSamples[Math.floor(a*10)]=!0}}return l}},zs=class{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}},zt=class{constructor(t,e,i,n,r){this.from=t,this.length=e,this.top=i,this.height=n,this.type=r}get to(){return this.from+this.length}get bottom(){return this.top+this.height}join(t){let e=(Array.isArray(this.type)?this.type:[this]).concat(Array.isArray(t.type)?t.type:[t]);return new zt(this.from,this.length+t.length,this.top,this.height+t.height,e)}},W=function(s){return s[s.ByPos=0]="ByPos",s[s.ByHeight=1]="ByHeight",s[s.ByPosNoHeight=2]="ByPosNoHeight",s}(W||(W={})),an=.001,lt=class{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>an&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return lt.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:h,toA:a,fromB:f,toB:c}=n[l],u=r.lineAt(h,W.ByPosNoHeight,i.setDoc(e),0,0),d=u.to>=a?u:r.lineAt(a,W.ByPosNoHeight,i,0,0);for(c+=d.to-a,a=d.to;l>0&&u.from<=n[l-1].toA;)h=n[l-1].fromA,f=n[l-1].fromB,l--,h<u.from&&(u=r.lineAt(h,W.ByPosNoHeight,i,0,0));f+=u.from-h,h=u.from;let p=Pi.build(i.setDoc(o),t,f,c);r=r.replace(h,a,p)}return r.updateHeight(i,0)}static empty(){return new xt(0,0)}static of(t){if(t.length==1)return t[0];let e=0,i=t.length,n=0,r=0;for(;;)if(e==i)if(n>r*2){let l=t[e-1];l.break?t.splice(--e,1,l.left,null,l.right):t.splice(--e,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=t[i];l.break?t.splice(i,1,l.left,null,l.right):t.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n<r){let l=t[e++];l&&(n+=l.size)}else{let l=t[--i];l&&(r+=l.size)}let o=0;return t[e-1]==null?(o=1,e--):t[e]==null&&(o=1,i++),new Hs(lt.of(t.slice(0,e)),o,lt.of(t.slice(i)))}};lt.prototype.size=1;var vn=class extends lt{constructor(t,e,i){super(t,e),this.type=i}blockAt(t,e,i,n){return new zt(n,this.length,i,this.height,this.type)}lineAt(t,e,i,n,r){return this.blockAt(0,i,n,r)}forEachLine(t,e,i,n,r,o){t<=r+this.length&&e>=r&&o(this.blockAt(0,i,n,r))}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})`}},xt=class extends vn{constructor(t,e){super(t,e,j.Text),this.collapsed=0,this.widgetHeight=0}replace(t,e,i){let n=i[0];return i.length==1&&(n instanceof xt||n instanceof Q&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof Q?n=new xt(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):lt.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.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},Q=class extends lt{constructor(t){super(t,0)}heightMetrics(t,e){let i=t.doc.lineAt(e).number,n=t.doc.lineAt(e+this.length).number,r=n-i+1,o,l=0;if(t.lineWrapping){let h=Math.min(this.height,t.lineHeight*r);o=h/r,l=(this.height-h)/(this.length-r-1)}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(t,e,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:h}=this.heightMetrics(e,n);if(e.lineWrapping){let a=n+Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length),f=e.doc.lineAt(a),c=l+f.length*h,u=Math.max(i,t-c/2);return new zt(f.from,f.length,u,c,j.Text)}else{let a=Math.max(0,Math.min(o-r,Math.floor((t-i)/l))),{from:f,length:c}=e.doc.line(r+a);return new zt(f,c,i+l*a,l,j.Text)}}lineAt(t,e,i,n,r){if(e==W.ByHeight)return this.blockAt(t,i,n,r);if(e==W.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(t);return new zt(d,p-d,0,0,j.Text)}let{firstLine:o,perLine:l,perChar:h}=this.heightMetrics(i,r),a=i.doc.lineAt(t),f=l+a.length*h,c=a.number-o,u=n+l*c+h*(a.from-r-c);return new zt(a.from,a.length,Math.max(n,Math.min(u,n+this.height-f)),f,j.Text)}forEachLine(t,e,i,n,r,o){t=Math.max(t,r),e=Math.min(e,r+this.length);let{firstLine:l,perLine:h,perChar:a}=this.heightMetrics(i,r);for(let f=t,c=n;f<=e;){let u=i.doc.lineAt(f);if(f==t){let p=u.number-l;c+=h*p+a*(t-r-p)}let d=h+a*u.length;o(new zt(u.from,u.length,c,d,j.Text)),c+=d,f=u.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let r=i[i.length-1];r instanceof Q?i[i.length-1]=new Q(r.length+n):i.push(null,new Q(n-1))}if(t>0){let r=i[0];r instanceof Q?i[0]=new Q(t+r.length):i.unshift(new Q(t-1),null)}return lt.of(i)}decomposeLeft(t,e){e.push(new Q(t-1),null)}decomposeRight(t,e){e.push(null,new Q(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let r=e+this.length;if(n&&n.from<=e+this.length&&n.more){let o=[],l=Math.max(e,n.from),h=-1;for(n.from>e&&o.push(new Q(n.from-e-1).updateHeight(t,e));l<=r&&n.more;){let f=t.doc.lineAt(l).length;o.length&&o.push(null);let c=n.heights[n.index++];h==-1?h=c:Math.abs(c-h)>=an&&(h=-2);let u=new xt(f,c);u.outdated=!1,o.push(u),l+=f+1}l<=r&&o.push(null,new Q(r-l).updateHeight(t,l));let a=lt.of(o);return(h<0||Math.abs(a.height-this.height)>=an||Math.abs(h-this.heightMetrics(t,e).perLine)>=an)&&(t.heightChanged=!0),a}else(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Hs=class extends lt{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 this.flags&1}blockAt(t,e,i,n){let r=i+this.left.height;return t<r?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,r,n+this.left.length+this.break)}lineAt(t,e,i,n,r){let o=n+this.left.height,l=r+this.left.length+this.break,h=e==W.ByHeight?t<o:t<l,a=h?this.left.lineAt(t,e,i,n,r):this.right.lineAt(t,e,i,o,l);if(this.break||(h?a.to<l:a.from>l))return a;let f=e==W.ByPosNoHeight?W.ByPosNoHeight:W.ByPos;return h?a.join(this.right.lineAt(l,f,i,o,l)):this.left.lineAt(l,f,i,n,r).join(a)}forEachLine(t,e,i,n,r,o){let l=n+this.left.height,h=r+this.left.length+this.break;if(this.break)t<h&&this.left.forEachLine(t,e,i,n,r,o),e>=h&&this.right.forEachLine(t,e,i,l,h,o);else{let a=this.lineAt(h,W.ByPos,i,n,r);t<a.from&&this.left.forEachLine(t,a.from-1,i,n,r,o),a.to>=t&&a.from<=e&&o(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,l,h,o)}}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 r=[];t>0&&this.decomposeLeft(t,r);let o=r.length;for(let l of i)r.push(l);if(t>0&&Go(r,o-1),e<this.length){let l=r.length;this.decomposeRight(e,r),Go(r,l)}return lt.of(r)}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?lt.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:r,right:o}=this,l=e+r.length+this.break,h=null;return n&&n.from<=e+r.length&&n.more?h=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=l+o.length&&n.more?h=o=o.updateHeight(t,l,i,n):o.updateHeight(t,l,i),h?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Go(s,t){let e,i;s[t]==null&&(e=s[t-1])instanceof Q&&(i=s[t+1])instanceof Q&&s.splice(t-1,3,new Q(e.length+1+i.length))}var $f=5,Pi=class{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 i=Math.min(e,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof xt?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new xt(i-this.pos,-1)),this.writtenTo=i,e>i&&(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;n<0&&(n=this.oracle.lineHeight);let r=e-t;i.block?this.addBlock(new vn(r,n,i.type)):(r||n>=$f)&&this.addLineDeco(n,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||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new xt(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new Q(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 xt)return t;let e=new xt(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine(),t.type==j.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,t.type!=j.WidgetBefore&&(this.covering=t)}addLineDeco(t,e){let i=this.ensureLine();i.length+=e,i.collapsed+=e,i.widgetHeight=Math.max(i.widgetHeight,t),this.writtenTo=this.pos=this.pos+e}finish(t){let e=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(e instanceof xt)&&!this.isCovered?this.nodes.push(new xt(0,-1)):(this.writtenTo<this.pos||e==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=t;for(let n of this.nodes)n instanceof xt&&n.updateHeight(this.oracle,i),i+=n?n.length:1;return this.nodes}static build(t,e,i,n){let r=new Pi(i,t);return F.spans(e,i,n,r,0),r.finish(i)}};function Kf(s,t,e){let i=new Ws;return F.compare(s,t,e,i,0),i.changes}var Ws=class{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&Ds(t,e,this.changes,5)}};function Uf(s,t){let e=s.getBoundingClientRect(),i=s.ownerDocument,n=i.defaultView||window,r=Math.max(0,e.left),o=Math.min(n.innerWidth,e.right),l=Math.max(0,e.top),h=Math.min(n.innerHeight,e.bottom);for(let a=s.parentNode;a&&a!=i.body;)if(a.nodeType==1){let f=a,c=window.getComputedStyle(f);if((f.scrollHeight>f.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),h=a==s.parentNode?u.bottom:Math.min(h,u.bottom)}a=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(a.nodeType==11)a=a.host;else break;return{left:r-e.left,right:Math.max(r,o)-e.left,top:l-(e.top+t),bottom:Math.max(l,h)-(e.top+t)}}function Gf(s,t){let e=s.getBoundingClientRect();return{left:0,right:e.right-e.left,top:t,bottom:e.bottom-(e.top+t)}}var Ai=class{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],r=e[i];if(n.from!=r.from||n.to!=r.to||n.size!=r.size)return!1}return!0}draw(t){return H.replace({widget:new js(this.size,t)}).range(this.from,this.to)}},js=class extends Gt{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}},Sn=class{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.scaler=Jo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=J.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(sr).some(i=>typeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new Vs(e),this.stateDeco=t.facet(Oi).filter(i=>typeof i!="function"),this.heightMap=lt.empty().applyChanges(this.stateDeco,B.empty,this.heightOracle.setDoc(t.doc),[new Pt(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=H.set(this.lineGaps.map(i=>i.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:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);t.push(new Ye(r,o))}}this.viewports=t.sort((i,n)=>i.from-n.from),this.scaler=this.heightMap.height<=7e6?Jo:new qs(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(this.scaler.scale==1?t:Si(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Oi).filter(a=>typeof a!="function");let n=t.changedRanges,r=Pt.extendWithRanges(n,Kf(i,this.stateDeco,t?t.changes:K.empty(this.state.doc.length))),o=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(t.flags|=2);let l=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let h=!t.changes.empty||t.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),h&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&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(Cl)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?J.RTL:J.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=e.getBoundingClientRect(),h=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let a=0,f=0,c=parseInt(i.paddingTop)||0,u=parseInt(i.paddingBottom)||0;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,a|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(h=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=8);let d=(this.printing?Gf:Uf)(e,this.paddingTop),p=d.top-this.pixelViewport.top,m=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let y=l.width;if((this.contentDOMWidth!=y||this.editorHeight!=t.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=t.scrollDOM.clientHeight,a|=8),h){let A=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(A)&&(o=!0),o||n.lineWrapping&&Math.abs(y-this.contentDOMWidth)>n.charWidth){let{lineHeight:w,charWidth:S}=t.docView.measureTextSize();o=w>0&&n.refresh(r,w,S,y/S,A),o&&(t.docView.minWidth=0,a|=8)}p>0&&m>0?f=Math.max(p,m):p<0&&m<0&&(f=Math.min(p,m)),n.heightChanged=!1;for(let w of this.viewports){let S=w.from==this.viewport.from?A:t.docView.measureVisibleLineHeights(w);this.heightMap=(o?lt.empty().applyChanges(this.stateDeco,B.empty,this.heightOracle,[new Pt(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new zs(w.from,S))}n.heightChanged&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(this.viewport=this.getViewport(f,this.scrollTarget)),this.updateForViewport(),(a&2||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>2e3<<1)&&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,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,h=new Ye(n.lineAt(o-i*1e3,W.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,W.ByHeight,r,0,0).to);if(e){let{head:a}=e.range;if(a<h.from||a>h.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=n.lineAt(a,W.ByPos,r,0,0),u;e.y=="center"?u=(c.top+c.bottom)/2-f/2:e.y=="start"||e.y=="nearest"&&a<h.from?u=c.top:u=c.bottom-f,h=new Ye(n.lineAt(u-1e3/2,W.ByHeight,r,0,0).from,n.lineAt(u+f+1e3/2,W.ByHeight,r,0,0).to)}}return h}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new Ye(this.heightMap.lineAt(i,W.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,W.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,W.ByPos,this.heightOracle,0,0),{bottom:r}=this.heightMap.lineAt(e,W.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(t==0||n<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||r>=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r<l+2*1e3}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 Ai(e.mapPos(n.from),e.mapPos(n.to),n.size));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,r=n>>1,o=n<<1;if(this.defaultTextDirection!=J.LTR&&!i)return[];let l=[],h=(a,f,c,u)=>{if(f-a<r)return;let d=this.state.selection.main,p=[d.from];d.empty||p.push(d.to);for(let g of p)if(g>a&&g<f){h(a,g-10,c,u),h(g+10,f,c,u);return}let m=_f(t,g=>g.from>=c.from&&g.to<=c.to&&Math.abs(g.from-a)<r&&Math.abs(g.to-f)<r&&!p.some(y=>g.from<y&&g.to>y));if(!m){if(f<c.to&&e&&i&&e.visibleRanges.some(g=>g.from<=f&&g.to>=f)){let g=e.moveToLineBoundary(b.cursor(f),!1,!0).head;g>a&&(f=g)}m=new Ai(a,f,this.gapSize(c,a,f,u))}l.push(m)};for(let a of this.viewportLines){if(a.length<o)continue;let f=Jf(a.from,a.to,this.stateDeco);if(f.total<o)continue;let c=this.scrollTarget?this.scrollTarget.range.head:null,u,d;if(i){let p=n/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,g;if(c!=null){let y=sn(f,c),v=((this.visibleBottom-this.visibleTop)/2+p)/a.height;m=y-v,g=y+v}else m=(this.visibleTop-a.top-p)/a.height,g=(this.visibleBottom-a.top+p)/a.height;u=nn(f,m),d=nn(f,g)}else{let p=f.total*this.heightOracle.charWidth,m=n*this.heightOracle.charWidth,g,y;if(c!=null){let v=sn(f,c),A=((this.pixelViewport.right-this.pixelViewport.left)/2+m)/p;g=v-A,y=v+A}else g=(this.pixelViewport.left-m)/p,y=(this.pixelViewport.right+m)/p;u=nn(f,g),d=nn(f,y)}u>a.from&&h(a.from,u,a,f),d<a.to&&h(d,a.to,a,f)}return l}gapSize(t,e,i,n){let r=sn(n,i)-sn(n,e);return this.heightOracle.lineWrapping?t.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(t){Ai.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=H.set(t.map(e=>e.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];F.spans(t,this.viewport.from,this.viewport.to,{span(n,r){e.push({from:n,to:r})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some((n,r)=>n.from!=e[r].from||n.to!=e[r].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)||Si(this.heightMap.lineAt(t,W.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return Si(this.heightMap.lineAt(this.scaler.fromDOM(t),W.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(t){return Si(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}},Ye=class{constructor(t,e){this.from=t,this.to=e}};function Jf(s,t,e){let i=[],n=s,r=0;return F.spans(e,s,t,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n<t&&(i.push({from:n,to:t}),r+=t-n),{total:r,ranges:i}}function nn({total:s,ranges:t},e){if(e<=0)return t[0].from;if(e>=1)return t[t.length-1].to;let i=Math.floor(s*e);for(let n=0;;n++){let{from:r,to:o}=t[n],l=o-r;if(i<=l)return r+i;i-=l}}function sn(s,t){let e=0;for(let{from:i,to:n}of s.ranges){if(t<=n){e+=t-i;break}e+=n-i}return e/s.total}function _f(s,t){for(let e of s)if(t(e))return e}var Jo={toDOM(s){return s},fromDOM(s){return s},scale:1},qs=class{constructor(t,e,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:h})=>{let a=e.lineAt(l,W.ByPos,t,0,0).top,f=e.lineAt(h,W.ByPos,t,0,0).bottom;return n+=f-a,{from:l,to:h,top:a,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.top)return n+(t-i)*this.scale;if(t<=r.bottom)return r.domTop+(t-r.top);i=r.bottom,n=r.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let r=e<this.viewports.length?this.viewports[e]:null;if(!r||t<r.domTop)return i+(t-n)/this.scale;if(t<=r.domBottom)return r.top+(t-r.domTop);i=r.bottom,n=r.domBottom}}};function Si(s,t){if(t.scale==1)return s;let e=t.toDOM(s.top),i=t.toDOM(s.bottom);return new zt(s.from,s.length,e,i-e,Array.isArray(s.type)?s.type.map(n=>Si(n,t)):s.type)}var rn=D.define({combine:s=>s.join(" ")}),$s=D.define({combine:s=>s.indexOf(!0)>-1}),Ks=Ot.newName(),ql=Ot.newName(),$l=Ot.newName(),Kl={"&light":"."+ql,"&dark":"."+$l};function Us(s,t,e){return new Ot(t,{finish(i){return/&/.test(i)?i.replace(/&\w*/,n=>{if(n=="&")return s;if(!e||!e[n])throw new RangeError(`Unsupported selector: ${n}`);return e[n]}):s+" "+i}})}var Yf=Us("."+Ks,{"&":{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":{contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused .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-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"}},Kl),Gs=class{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="";let{impreciseHead:r,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let l=r||o?[]:Zf(t),h=new bn(l,t.state);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=Qf(l,this.bounds.from)}else{let l=t.observer.selectionRange,h=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Ze(t.contentDOM,l.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(l.focusNode,l.focusOffset),a=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Ze(t.contentDOM,l.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=b.single(a,h)}}};function Ul(s,t){let e,{newSel:i}=t,n=s.state.selection.main;if(t.bounds){let{from:r,to:o}=t.bounds,l=n.from,h=null;(s.inputState.lastKeyCode===8&&s.inputState.lastKeyTime>Date.now()-100||M.android&&t.text.length<o-r)&&(l=n.to,h="end");let a=Xf(s.state.doc.sliceString(r,o,de),t.text,l-r,h);a&&(M.chrome&&s.inputState.lastKeyCode==13&&a.toB==a.from+2&&t.text.slice(a.from,a.toB)==de+de&&a.toB--,e={from:r+a.from,to:r+a.toA,insert:B.of(t.text.slice(a.from,a.toB).split(de))})}else i&&(!s.hasFocus&&s.state.facet(An)||i.main.eq(n))&&(i=null);if(!e&&!i)return!1;if(!e&&t.typeOver&&!n.empty&&i&&i.main.empty?e={from:n.from,to:n.to,insert:s.state.doc.slice(n.from,n.to)}:e&&e.from>=n.from&&e.to<=n.to&&(e.from!=n.from||e.to!=n.to)&&n.to-n.from-(e.to-e.from)<=4?e={from:n.from,to:n.to,insert:s.state.doc.slice(n.from,e.from).append(e.insert).append(s.state.doc.slice(e.to,n.to))}:(M.mac||M.android)&&e&&e.from==e.to&&e.from==n.head-1&&/^\. ?$/.test(e.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&e.insert.length==2&&(i=b.single(i.main.anchor-1,i.main.head-1)),e={from:n.from,to:n.to,insert:B.of([" "])}):M.chrome&&e&&e.from==e.to&&e.from==n.head&&e.insert.toString()==`
|
|
9
|
+
`&&s.lineWrapping&&(i&&(i=b.single(i.main.anchor-1,i.main.head-1)),e={from:n.from,to:n.to,insert:B.of([" "])}),e){let r=s.state;if(M.ios&&s.inputState.flushIOSKey(s)||M.android&&(e.from==n.from&&e.to==n.to&&e.insert.length==1&&e.insert.lines==2&&Xe(s.contentDOM,"Enter",13)||e.from==n.from-1&&e.to==n.to&&e.insert.length==0&&Xe(s.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&Xe(s.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();if(s.state.facet(kl).some(a=>a(s,e.from,e.to,o)))return!0;s.inputState.composing>=0&&s.inputState.composing++;let l;if(e.from>=n.from&&e.to<=n.to&&e.to-e.from>=(n.to-n.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let a=n.from<e.from?r.sliceDoc(n.from,e.from):"",f=n.to>e.to?r.sliceDoc(e.to,n.to):"";l=r.replaceSelection(s.state.toText(a+e.insert.sliceString(0,void 0,s.state.lineBreak)+f))}else{let a=r.changes(e),f=i&&!r.selection.main.eq(i.main)&&i.main.to<=a.newLength?i.main:void 0;if(r.selection.ranges.length>1&&s.inputState.composing>=0&&e.to<=n.to&&e.to>=n.to-10){let c=s.state.sliceDoc(e.from,e.to),u=Bl(s)||s.state.doc.lineAt(n.head),d=n.to-e.to,p=n.to-n.from;l=r.changeByRange(m=>{if(m.from==n.from&&m.to==n.to)return{changes:a,range:f||m.map(a)};let g=m.to-d,y=g-c.length;if(m.to-m.from!=p||s.state.sliceDoc(y,g)!=c||u&&m.to>=u.from&&m.from<=u.to)return{range:m};let v=r.changes({from:y,to:g,insert:e.insert}),A=m.to-n.to;return{changes:v,range:f?b.range(Math.max(0,f.anchor+A),Math.max(0,f.head+A)):m.map(v)}})}else l={changes:a,selection:f&&r.selection.replaceRange(f)}}let h="input.type";return s.composing&&(h+=".compose",s.inputState.compositionFirstChange&&(h+=".start",s.inputState.compositionFirstChange=!1)),s.dispatch(l,{scrollIntoView:!0,userEvent:h}),!0}else if(i&&!i.main.eq(n)){let r=!1,o="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(r=!0),o=s.inputState.lastSelectionOrigin),s.dispatch({selection:i,scrollIntoView:r,userEvent:o}),!0}else return!1}function Xf(s,t,e,i){let n=Math.min(s.length,t.length),r=0;for(;r<n&&s.charCodeAt(r)==t.charCodeAt(r);)r++;if(r==n&&s.length==t.length)return null;let o=s.length,l=t.length;for(;o>0&&l>0&&s.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if(i=="end"){let h=Math.max(0,r-Math.min(o,l));e-=o+h-r}if(o<r&&s.length<t.length){let h=e<=r&&e>=o?r-e:0;r-=h,l=r+(l-o),o=r}else if(l<r){let h=e<=r&&e>=l?r-e:0;r-=h,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Zf(s){let t=[];if(s.root.activeElement!=s.contentDOM)return t;let{anchorNode:e,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return e&&(t.push(new wn(e,i)),(n!=e||r!=i)&&t.push(new wn(n,r))),t}function Qf(s,t){if(s.length==0)return null;let e=s[0].pos,i=s.length==2?s[1].pos:e;return e>-1&&i>-1?b.single(e+t,i+t):null}var tc={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},gs=M.ie&&M.ie_version<=11,Js=class{constructor(t){this.view=t,this.active=!1,this.selectionRange=new ws,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 i of e)this.queue.push(i);(M.ie&&M.ie_version<=11||M.ios&&t.composing)&&e.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),gs&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var e;((e=this.view.docView)===null||e===void 0?void 0:e.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(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.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(An)?i.root.activeElement!=this.dom:!hn(i.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);if(r&&r.ignoreEvent(t)){e||(this.selectionChanged=!1);return}(M.ie&&M.ie_version<=11||M.android&&M.chrome)&&!i.state.selection.main.empty&&n.focusNode&&dn(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=M.safari&&t.root.nodeType==11&&ef(this.dom.ownerDocument)==this.dom&&ec(this.view)||un(t.root);if(!e||this.selectionRange.eq(e))return!1;let i=hn(this.dom,e);return i&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&lf(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(i.nodeType==1)!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(i.nodeType==11)i=i.host;else break;if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=e)i.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,tc),gs&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),gs&&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 n=()=>{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),!this.flush()&&r.force&&Xe(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||t=="Enter")&&(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||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()}processRecords(){let t=this.queue;for(let r of this.observer.takeRecords())t.push(r);t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let r of t){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),e==-1?{from:e,to:i}=o:(e=Math.min(o.from,e),i=Math.max(o.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&hn(this.dom,this.selectionRange);return t<0&&!n?null:(t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new Gs(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=Ul(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(t.type=="attributes"),t.type=="attributes"&&(e.dirty|=4),t.type=="childList"){let i=_o(e,t.previousSibling||t.target.previousSibling,-1),n=_o(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}else return t.type=="characterData"?{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(),(t=this.intersection)===null||t===void 0||t.disconnect(),(e=this.gapIntersection)===null||e===void 0||e.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect(),(n=this.resizeContent)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.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 _o(s,t,e){for(;t;){let i=V.get(t);if(i&&i.parent==s)return i;let n=t.parentNode;t=n!=s.dom?n:e>0?t.nextSibling:t.previousSibling}return null}function ec(s){let t=null;function e(h){h.preventDefault(),h.stopImmediatePropagation(),t=h.getTargetRanges()[0]}if(s.contentDOM.addEventListener("beforeinput",e,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",e,!0),!t)return null;let i=t.startContainer,n=t.startOffset,r=t.endContainer,o=t.endOffset,l=s.docView.domAtPos(s.state.selection.main.anchor);return dn(l.node,l.offset,r,o)&&([i,n,r,o]=[r,o,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:o}}var T=class{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||(e=>this.update([e])),this.dispatch=this.dispatch.bind(this),this._root=t.root||of(t.parent)||document,this.viewState=new Sn(t.state||E.create(t)),this.plugins=this.state.facet(ki).map(e=>new Ci(e));for(let e of this.plugins)e.update(this);this.observer=new Js(this),this.inputState=new Ls(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new xn(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){this._dispatch(t.length==1&&t[0]instanceof U?t[0]:this.state.update(...t))}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e=!1,i=!1,n,r=this.state;for(let u of t){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,h=null;t.some(u=>u.annotation(Hl))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,h=Wl(r,o),h||(l=1));let a=this.observer.delayedAndroidKey,f=null;if(a?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(E.phrases)!=this.state.facet(E.phrases))return this.setState(r);n=ii.create(this,r,t),n.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of t){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;c=new ei(d.empty?d:b.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Bo)&&(c=d.value)}this.viewState.update(n,c),this.bidiCache=ni.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),e=this.docView.update(n),this.state.facet(vi)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(e,t.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(rn)!=n.state.facet(rn)&&(this.viewState.mustMeasureContent=!0),(e||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!n.empty)for(let u of this.state.facet(Ts))u(n);(h||f)&&Promise.resolve().then(()=>{h&&this.state==h.startState&&this.dispatch(h),f&&!Ul(this,f)&&a.force&&Xe(this.contentDOM,a.key,a.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let e=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Sn(t),this.plugins=t.facet(ki).map(i=>new Ci(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView=new xn(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(ki),i=t.state.facet(ki);if(e!=i){let n=[];for(let r of i){let o=e.indexOf(r);if(o<0)n.push(new Ci(r));else{let l=this.plugins[o];l.mustUpdate=t,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=t&&r.destroy(this);this.plugins=n,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let n of this.plugins)n.mustUpdate=t;for(let n=0;n<this.plugins.length;n++)this.plugins[n].update(this)}measure(t=!0){if(this.destroyed)return;this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,{scrollHeight:i,scrollTop:n,clientHeight:r}=this.scrollDOM,o=n>i-r-4?i:n;try{for(let l=0;;l++){this.updateState=1;let h=this.viewport,a=this.viewState.lineBlockAtHeight(o),f=this.viewState.measure(this);if(!f&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];f&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(g=>{try{return g.read(this)}catch(y){return Mt(this.state,y),Yo}}),d=ii.create(this,this.state,[]),p=!1,m=!1;d.flags|=f,e?e.flags|=f:e=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),p=this.docView.update(d));for(let g=0;g<c.length;g++)if(u[g]!=Yo)try{let y=c[g];y.write&&y.write(u[g],this)}catch(y){Mt(this.state,y)}if(this.viewState.editorHeight)if(this.viewState.scrollTarget)this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,m=!0;else{let g=this.viewState.lineBlockAt(a.from).top-a.top;(g>1||g<-1)&&(this.scrollDOM.scrollTop+=g,m=!0)}if(p&&this.docView.updateSelection(!0),this.viewport.from==h.from&&this.viewport.to==h.to&&!m&&this.measureRequests.length==0)break}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let l of this.state.facet(Ts))l(e)}get themeClasses(){return Ks+" "+(this.state.facet($s)?$l:ql)+" "+this.state.facet(rn)}updateAttrs(){let t=Xo(this,Al,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(An)?"true":"false",class:"cm-content",style:`${M.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Xo(this,sr,e);let i=this.observer.ignore(()=>{let n=Ms(this.contentDOM,this.contentAttrs,e),r=Ms(this.dom,this.editorAttrs,t);return n||r});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let n of i.effects)if(n.is(T.announce)){e&&(this.announceDOM.textContent=""),e=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(vi),Ot.mount(this.root,this.styleModules.concat(Yf).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&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(t.key!=null){for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key){this.measureRequests[e]=t;return}}this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(e===void 0||e&&e.spec!=t)&&this.pluginMap.set(t,e=this.plugins.find(i=>i.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 ms(this,t,Fo(this,t,e,i))}moveByGroup(t,e){return ms(this,t,Fo(this,t,e,i=>Bf(this,t.head,i)))}moveToLineBoundary(t,e,i=!0){return Pf(this,t,e,i)}moveVertically(t,e,i){return ms(this,t,Rf(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(),El(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),r=this.bidiSpans(n),o=r[pe.find(r,t-n.from,-1,e)];return er(i,o.dir==J.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(Sl)||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>ic)return Ol(t.length);let e=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==e)return n.order;let i=bf(t.text,e);return this.bidiCache.push(new ni(t.from,t.to,e,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||M.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ol(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?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&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Bo.of(new ei(typeof t=="number"?b.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}static domEventHandlers(t){return vt.define(()=>({}),{eventHandlers:t})}static theme(t,e){let i=Ot.newName(),n=[rn.of(i),vi.of(Us(`.${i}`,t))];return e&&e.dark&&n.push($s.of(!0)),n}static baseTheme(t){return fe.lowest(vi.of(Us("."+Ks,t,Kl)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&V.get(i)||V.get(t);return((e=n==null?void 0:n.rootView)===null||e===void 0?void 0:e.view)||null}};T.styleModule=vi;T.inputHandler=kl;T.focusChangeEffect=vl;T.perLineTextDirection=Sl;T.exceptionSink=xl;T.updateListener=Ts;T.editable=An;T.mouseSelectionStyle=wl;T.dragMovesSelection=bl;T.clickAddsSelectionRange=yl;T.decorations=Oi;T.atomicRanges=Ml;T.scrollMargins=Dl;T.darkTheme=$s;T.contentAttributes=sr;T.editorAttributes=Al;T.lineWrapping=T.contentAttributes.of({class:"cm-lineWrapping"});T.announce=I.define();var ic=4096,Yo={},ni=class{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:J.LTR;for(let r=Math.max(0,t.length-10);r<t.length;r++){let o=t[r];o.dir==n&&!e.touchesRange(o.from,o.to)&&i.push(new ni(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.order))}return i}};function Xo(s,t,e){for(let i=s.state.facet(t),n=i.length-1;n>=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&As(o,e)}return e}var nc=M.mac?"mac":M.windows?"win":M.linux?"linux":"key";function sc(s,t){let e=s.split(/-(?!$)/),i=e[e.length-1];i=="Space"&&(i=" ");let n,r,o,l;for(let h=0;h<e.length-1;++h){let a=e[h];if(/^(cmd|meta|m)$/i.test(a))l=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))t=="mac"?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(i="Alt-"+i),r&&(i="Ctrl-"+i),l&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function on(s,t,e){return t.altKey&&(s="Alt-"+s),t.ctrlKey&&(s="Ctrl-"+s),t.metaKey&&(s="Meta-"+s),e!==!1&&t.shiftKey&&(s="Shift-"+s),s}var rc=fe.default(T.domEventHandlers({keydown(s,t){return ac(oc(t.state),s,t,"editor")}})),Ri=D.define({enables:rc}),Zo=new WeakMap;function oc(s){let t=s.facet(Ri),e=Zo.get(t);return e||Zo.set(t,e=hc(t.reduce((i,n)=>i.concat(n),[]))),e}var ue=null,lc=4e3;function hc(s,t=nc){let e=Object.create(null),i=Object.create(null),n=(o,l)=>{let h=i[o];if(h==null)i[o]=l;else if(h!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,h,a)=>{var f,c;let u=e[o]||(e[o]=Object.create(null)),d=l.split(/ (?!$)/).map(g=>sc(g,t));for(let g=1;g<d.length;g++){let y=d.slice(0,g).join(" ");n(y,!0),u[y]||(u[y]={preventDefault:!0,run:[v=>{let A=ue={view:v,prefix:y,scope:o};return setTimeout(()=>{ue==A&&(ue=null)},lc),!0}]})}let p=d.join(" ");n(p,!1);let m=u[p]||(u[p]={preventDefault:!1,run:((c=(f=u._any)===null||f===void 0?void 0:f.run)===null||c===void 0?void 0:c.slice())||[]});h&&m.run.push(h),a&&(m.preventDefault=!0)};for(let o of s){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let a of l){let f=e[a]||(e[a]=Object.create(null));f._any||(f._any={preventDefault:!1,run:[]});for(let c in f)f[c].run.push(o.any)}let h=o[t]||o.key;if(h)for(let a of l)r(a,h,o.run,o.preventDefault),o.shift&&r(a,"Shift-"+h,o.shift,o.preventDefault)}return e}function ac(s,t,e,i){let n=Co(t),r=ct(n,0),o=Tt(r)==n.length&&n!=" ",l="",h=!1;ue&&ue.view==e&&ue.scope==i&&(l=ue.prefix+" ",(h=Il.indexOf(t.keyCode)<0)&&(ue=null));let a=new Set,f=p=>{if(p){for(let m of p.run)if(!a.has(m)&&(a.add(m),m(e,t)))return!0;p.preventDefault&&(h=!0)}return!1},c=s[i],u,d;if(c){if(f(c[l+on(n,t,!o)]))return!0;if(o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(M.windows&&t.ctrlKey&&t.altKey)&&(u=ie[t.keyCode])&&u!=n){if(f(c[l+on(u,t,!0)]))return!0;if(t.shiftKey&&(d=Je[t.keyCode])!=n&&d!=u&&f(c[l+on(d,t,!1)]))return!0}else if(o&&t.shiftKey&&f(c[l+on(n,t,!0)]))return!0;if(f(c._any))return!0}return h}var Ee=class{constructor(t,e,i,n,r){this.className=t,this.left=e,this.top=i,this.width=n,this.height=r}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(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 r=Gl(t);return[new Ee(e,n.left-r.left,n.top-r.top,null,n.bottom-n.top)]}else return fc(t,e,i)}};function Gl(s){let t=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==J.LTR?t.left:t.right-s.scrollDOM.clientWidth)-s.scrollDOM.scrollLeft,top:t.top-s.scrollDOM.scrollTop}}function Qo(s,t,e){let i=b.cursor(t);return{from:Math.max(e.from,s.moveToLineBoundary(i,!1,!0).from),to:Math.min(e.to,s.moveToLineBoundary(i,!0,!0).from),type:j.Text}}function tl(s,t){let e=s.lineBlockAt(t);if(Array.isArray(e.type)){for(let i of e.type)if(i.to>t||i.to==t&&(i.to==e.to||i.type==j.Text))return i}return e}function fc(s,t,e){if(e.to<=s.viewport.from||e.from>=s.viewport.to)return[];let i=Math.max(e.from,s.viewport.from),n=Math.min(e.to,s.viewport.to),r=s.textDirection==J.LTR,o=s.contentDOM,l=o.getBoundingClientRect(),h=Gl(s),a=window.getComputedStyle(o.firstChild),f=l.left+parseInt(a.paddingLeft)+Math.min(0,parseInt(a.textIndent)),c=l.right-parseInt(a.paddingRight),u=tl(s,i),d=tl(s,n),p=u.type==j.Text?u:null,m=d.type==j.Text?d:null;if(s.lineWrapping&&(p&&(p=Qo(s,i,p)),m&&(m=Qo(s,n,m))),p&&m&&p.from==m.from)return y(v(e.from,e.to,p));{let w=p?v(e.from,null,p):A(u,!1),S=m?v(null,e.to,m):A(d,!0),C=[];return(p||u).to<(m||d).from-1?C.push(g(f,w.bottom,c,S.top)):w.bottom<S.top&&s.elementAtHeight((w.bottom+S.top)/2).type==j.Text&&(w.bottom=S.top=(w.bottom+S.top)/2),y(w).concat(C).concat(y(S))}function g(w,S,C,P){return new Ee(t,w-h.left,S-h.top-.01,C-w,P-S+.01)}function y({top:w,bottom:S,horizontal:C}){let P=[];for(let z=0;z<C.length;z+=2)P.push(g(C[z],w,C[z+1],S));return P}function v(w,S,C){let P=1e9,z=-1e9,L=[];function R(Z,gt,yt,st,he){let rt=s.coordsAtPos(Z,Z==C.to?-2:2),_=s.coordsAtPos(yt,yt==C.from?2:-2);P=Math.min(rt.top,_.top,P),z=Math.max(rt.bottom,_.bottom,z),he==J.LTR?L.push(r&>?f:rt.left,r&&st?c:_.right):L.push(!r&&st?f:_.left,!r&>?c:rt.right)}let N=w!=null?w:C.from,X=S!=null?S:C.to;for(let Z of s.visibleRanges)if(Z.to>N&&Z.from<X)for(let gt=Math.max(Z.from,N),yt=Math.min(Z.to,X);;){let st=s.state.doc.lineAt(gt);for(let he of s.bidiSpans(st)){let rt=he.from+st.from,_=he.to+st.from;if(rt>=yt)break;_>gt&&R(Math.max(rt,gt),w==null&&rt<=N,Math.min(_,yt),S==null&&_>=X,he.dir)}if(gt=st.to+1,gt>=yt)break}return L.length==0&&R(N,w==null,X,S==null,s.textDirection),{top:P,bottom:z,horizontal:L}}function A(w,S){let C=l.top+(S?w.top:w.bottom);return{top:C,bottom:C,horizontal:[]}}}function cc(s,t){return s.constructor==t.constructor&&s.eq(t)}var _s=class{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],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.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(fn)!=t.state.facet(fn)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&t.view.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(fn);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)}draw(t){if(t.length!=this.drawn.length||t.some((e,i)=>!cc(e,this.drawn[i]))){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 n=e.nextSibling;e.remove(),e=n}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},fn=D.define();function Jl(s){return[vt.define(t=>new _s(t,s)),fn.of(s)]}var _l=!M.ios,Bi=D.define({combine(s){return ce(s,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})}});function Yl(s={}){return[Bi.of(s),uc,dc,pc,Cl.of(!0)]}function Xl(s){return s.startState.facet(Bi)!=s.state.facet(Bi)}var uc=Jl({above:!0,markers(s){let{state:t}=s,e=t.facet(Bi),i=[];for(let n of t.selection.ranges){let r=n==t.selection.main;if(n.empty?!r||_l:e.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=n.empty?n:b.cursor(n.head,n.head>n.anchor?-1:1);for(let h of Ee.forRange(s,o,l))i.push(h)}}return i},update(s,t){s.transactions.some(i=>i.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let e=Xl(s);return e&&el(s.state,t),s.docChanged||s.selectionSet||e},mount(s,t){el(t.state,s)},class:"cm-cursorLayer"});function el(s,t){t.style.animationDuration=s.facet(Bi).cursorBlinkRate+"ms"}var dc=Jl({above:!1,markers(s){return s.state.selection.ranges.map(t=>t.empty?[]:Ee.forRange(s,"cm-selectionBackground",t)).reduce((t,e)=>t.concat(e))},update(s,t){return s.docChanged||s.selectionSet||s.viewportChanged||Xl(s)},class:"cm-selectionLayer"}),Zl={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};_l&&(Zl[".cm-line"].caretColor="transparent !important");var pc=fe.highest(T.theme(Zl));function il(s,t,e,i,n){t.lastIndex=0;for(let r=s.iterRange(e,i),o=e,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=t.exec(r.value);)n(o+l.index,l)}function mc(s,t){let e=s.visibleRanges;if(e.length==1&&e[0].from==s.viewport.from&&e[0].to==s.viewport.to)return e;let i=[];for(let{from:n,to:r}of e)n=Math.max(s.state.doc.lineAt(n).from,n-t),r=Math.min(s.state.doc.lineAt(r).to,r+t),i.length&&i[i.length-1].to>=n?i[i.length-1].to=r:i.push({from:n,to:r});return i}var Ys=class{constructor(t){let{regexp:e,decoration:i,decorate:n,boundary:r,maxLength:o=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(l,h,a,f)=>n(f,a,a+l[0].length,l,h);else if(typeof i=="function")this.addMatch=(l,h,a,f)=>{let c=i(l,h,a);c&&f(a,a+l[0].length,c)};else if(i)this.addMatch=(l,h,a,f)=>f(a,a+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(t){let e=new qt,i=e.add.bind(e);for(let{from:n,to:r}of mc(t,this.maxLength))il(t.state.doc,this.regexp,n,r,(o,l)=>this.addMatch(l,t,o,i));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges((r,o,l,h)=>{h>t.view.viewport.from&&l<t.view.viewport.to&&(i=Math.min(l,i),n=Math.max(h,n))}),t.viewportChanged||n-i>1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let r of t.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,n);if(l>o){let h=t.state.doc.lineAt(o),a=h.to<l?t.state.doc.lineAt(l):h,f=Math.max(r.from,h.from),c=Math.min(r.to,a.to);if(this.boundary){for(;o>h.from;o--)if(this.boundary.test(h.text[o-1-h.from])){f=o;break}for(;l<a.to;l++)if(this.boundary.test(a.text[l-a.from])){c=l;break}}let u=[],d,p=(m,g,y)=>u.push(y.range(m,g));if(h==a)for(this.regexp.lastIndex=f-h.from;(d=this.regexp.exec(h.text))&&d.index<c-h.from;)this.addMatch(d,t,d.index+h.from,p);else il(t.state.doc,this.regexp,f,c,(m,g)=>this.addMatch(g,t,m,p));e=e.update({filterFrom:f,filterTo:c,filter:(m,g)=>m<f||g>c,add:u})}}return e}},Xs=/x/.unicode!=null?"gu":"g",gc=new RegExp(`[\0-\b
|
|
10
|
+
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,Xs),yc={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},ys=null;function bc(){var s;if(ys==null&&typeof document<"u"&&document.body){let t=document.body.style;ys=((s=t.tabSize)!==null&&s!==void 0?s:t.MozTabSize)!=null}return ys||!1}var cn=D.define({combine(s){let t=ce(s,{render:null,specialChars:gc,addSpecialChars:null});return(t.replaceTabs=!bc())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,Xs)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Xs)),t}});function Ql(s={}){return[cn.of(s),wc()]}var nl=null;function wc(){return nl||(nl=vt.fromClass(class{constructor(s){this.view=s,this.decorations=H.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(s.state.facet(cn)),this.decorations=this.decorator.createDeco(s)}makeDecorator(s){return new Ys({regexp:s.specialChars,decoration:(t,e,i)=>{let{doc:n}=e.state,r=ct(t[0],0);if(r==9){let o=n.lineAt(i),l=e.state.tabSize,h=Be(o.text,l,i-o.from);return H.replace({widget:new Qs((l-h%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[r]||(this.decorationCache[r]=H.replace({widget:new Zs(s,r)}))},boundary:s.replaceTabs?void 0:/[^]/})}update(s){let t=s.state.facet(cn);s.startState.facet(cn)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(s.view)):this.decorations=this.decorator.updateDeco(s,this.decorations)}},{decorations:s=>s.decorations}))}var xc="\u2022";function kc(s){return s>=32?xc:s==10?"\u2424":String.fromCharCode(9216+s)}var Zs=class extends Gt{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=kc(this.code),i=t.state.phrase("Control character")+" "+(yc[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let r=document.createElement("span");return r.textContent=e,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}},Qs=class extends Gt{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}};var ln="-10000px",tr=class{constructor(t,e,i){this.facet=e,this.createTooltipView=i,this.input=t.state.facet(e),this.tooltips=this.input.filter(n=>n),this.tooltipViews=this.tooltips.map(i)}update(t){var e;let i=t.state.facet(this.facet),n=i.filter(o=>o);if(i===this.input){for(let o of this.tooltipViews)o.update&&o.update(t);return!1}let r=[];for(let o=0;o<n.length;o++){let l=n[o],h=-1;if(l){for(let a=0;a<this.tooltips.length;a++){let f=this.tooltips[a];f&&f.create==l.create&&(h=a)}if(h<0)r[o]=this.createTooltipView(l);else{let a=r[o]=this.tooltipViews[h];a.update&&a.update(t)}}}for(let o of this.tooltipViews)r.indexOf(o)<0&&(o.dom.remove(),(e=o.destroy)===null||e===void 0||e.call(o));return this.input=i,this.tooltips=n,this.tooltipViews=r,!0}};function vc(s){let{win:t}=s;return{top:0,left:0,bottom:t.innerHeight,right:t.innerWidth}}var bs=D.define({combine:s=>{var t,e,i;return{position:M.ios?"absolute":((t=s.find(n=>n.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((e=s.find(n=>n.parent))===null||e===void 0?void 0:e.parent)||null,tooltipSpace:((i=s.find(n=>n.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||vc}}}),sl=new WeakMap,th=vt.fromClass(class{constructor(s){this.view=s,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let t=s.state.facet(bs);this.position=t.position,this.parent=t.parent,this.classes=s.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new tr(s,rr,e=>this.createTooltip(e)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),s.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 s of this.manager.tooltipViews)this.intersectionObserver.observe(s.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(s){s.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(s);t&&this.observeIntersection();let e=t||s.geometryChanged,i=s.state.facet(bs);if(i.position!=this.position){this.position=i.position;for(let n of this.manager.tooltipViews)n.dom.style.position=this.position;e=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let n of this.manager.tooltipViews)this.container.appendChild(n.dom);e=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);e&&this.maybeMeasure()}createTooltip(s){let t=s.create(this.view);if(t.dom.classList.add("cm-tooltip"),s.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let e=document.createElement("div");e.className="cm-tooltip-arrow",t.dom.appendChild(e)}return t.dom.style.position=this.position,t.dom.style.top=ln,this.container.appendChild(t.dom),t.mount&&t.mount(this.view),t}destroy(){var s,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),(s=e.destroy)===null||s===void 0||s.call(e);(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let s=this.view.dom.getBoundingClientRect();return{editor:s,parent:this.parent?this.container.getBoundingClientRect():s,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(bs).tooltipSpace(this.view)}}writeMeasure(s){var t;let{editor:e,space:i}=s,n=[];for(let r=0;r<this.manager.tooltips.length;r++){let o=this.manager.tooltips[r],l=this.manager.tooltipViews[r],{dom:h}=l,a=s.pos[r],f=s.size[r];if(!a||a.bottom<=Math.max(e.top,i.top)||a.top>=Math.min(e.bottom,i.bottom)||a.right<Math.max(e.left,i.left)-.1||a.left>Math.min(e.right,i.right)+.1){h.style.top=ln;continue}let c=o.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,u=c?7:0,d=f.right-f.left,p=(t=sl.get(l))!==null&&t!==void 0?t:f.bottom-f.top,m=l.offset||Cc,g=this.view.textDirection==J.LTR,y=f.width>i.right-i.left?g?i.left:i.right-f.width:g?Math.min(a.left-(c?14:0)+m.x,i.right-d):Math.max(i.left,a.left-d+(c?14:0)-m.x),v=!!o.above;!o.strictSide&&(v?a.top-(f.bottom-f.top)-m.y<i.top:a.bottom+(f.bottom-f.top)+m.y>i.bottom)&&v==i.bottom-a.bottom>a.top-i.top&&(v=!v);let A=(v?a.top-i.top:i.bottom-a.bottom)-u;if(A<p&&l.resize!==!1){if(A<this.view.defaultLineHeight){h.style.top=ln;continue}sl.set(l,p),h.style.height=(p=A)+"px"}else h.style.height&&(h.style.height="");let w=v?a.top-p-u-m.y:a.bottom+u+m.y,S=y+d;if(l.overlap!==!0)for(let C of n)C.left<S&&C.right>y&&C.top<w+p&&C.bottom>w&&(w=v?C.top-p-2-u:C.bottom+u+2);this.position=="absolute"?(h.style.top=w-s.parent.top+"px",h.style.left=y-s.parent.left+"px"):(h.style.top=w+"px",h.style.left=y+"px"),c&&(c.style.left=`${a.left+(g?m.x:-m.x)-(y+14-7)}px`),l.overlap!==!0&&n.push({left:y,top:w,right:S,bottom:w+p}),h.classList.toggle("cm-tooltip-above",v),h.classList.toggle("cm-tooltip-below",!v),l.positioned&&l.positioned(s.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 s of this.manager.tooltipViews)s.dom.style.top=ln}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),Sc=T.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:`${7*2}px`,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"}}}),Cc={x:0,y:0},rr=D.define({enables:[th,Sc]});function eh(s,t){let e=s.plugin(th);if(!e)return null;let i=e.manager.tooltips.indexOf(t);return i<0?null:e.manager.tooltipViews[i]}var re=class extends Vt{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}};re.prototype.elementClass="";re.prototype.toDOM=void 0;re.prototype.mapMode=ft.TrackBefore;re.prototype.startSide=re.prototype.endSide=-1;re.prototype.point=!0;var Ac=0,Ei=class{constructor(t,e){this.from=t,this.to=e}},O=class{constructor(t={}){this.id=Ac++,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 typeof t!="function"&&(t=nt.match(t)),e=>{let i=t(e);return i===void 0?null:[this,i]}}};O.closedBy=new O({deserialize:s=>s.split(" ")});O.openedBy=new O({deserialize:s=>s.split(" ")});O.group=new O({deserialize:s=>s.split(" ")});O.contextHash=new O({perNode:!0});O.lookAhead=new O({perNode:!0});O.mounted=new O({perNode:!0});var Mc=Object.create(null),nt=class{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):Mc,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),n=new nt(t.name||"",e,t.id,i);if(t.props){for(let r of t.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");e[r[0].id]=r[1]}}return n}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let e=this.prop(O.group);return e?e.indexOf(t)>-1:!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 i=>{for(let n=i.prop(O.group),r=-1;r<(n?n.length:0);r++){let o=e[r<0?i.name:n[r]];if(o)return o}}}};nt.none=new nt("",Object.create(null),0,8);var Le=class{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 r of t){let o=r(i);o&&(n||(n=Object.assign({},i.props)),n[o[0].id]=o[1])}e.push(n?new nt(i.name,n,i.id,i.flags):i)}return new Le(e)}},Mn=new WeakMap,ih=new WeakMap,et;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays"})(et||(et={}));var q=class{constructor(t,e,i,n,r){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let t=this.prop(O.mounted);if(t&&!t.overlay)return t.tree.toString();let e="";for(let i of this.children){let n=i.toString();n&&(e&&(e+=","),e+=n)}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 ri(this.topNode,t)}cursorAt(t,e=0,i=0){let n=Mn.get(this)||this.topNode,r=new ri(n);return r.moveTo(t,e),Mn.set(this,r._tree),r}get topNode(){return new Ht(this,0,0,null)}resolve(t,e=0){let i=si(Mn.get(this)||this.topNode,t,e,!1);return Mn.set(this,i),i}resolveInner(t,e=0){let i=si(ih.get(this)||this.topNode,t,e,!0);return ih.set(this,i),i}iterate(t){let{enter:e,leave:i,from:n=0,to:r=this.length}=t;for(let o=this.cursor((t.mode||0)|et.IncludeAnonymous);;){let l=!1;if(o.from<=r&&o.to>=n&&(o.type.isAnonymous||e(o)!==!1)){if(o.firstChild())continue;l=!0}for(;l&&i&&!o.type.isAnonymous&&i(o),!o.nextSibling();){if(!o.parent())return;l=!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:ar(nt.none,this.children,this.positions,0,this.children.length,0,this.length,(e,i,n)=>new q(this.type,e,i,n,this.propValues),t.makeTree||((e,i,n)=>new q(nt.none,e,i,n)))}static build(t){return Dc(t)}};q.empty=new q(nt.none,[],[],0);var Li=class{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 Li(this.buffer,this.index)}},oe=class{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return nt.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],r=n.name;if(/\W/.test(r)&&!n.isError&&(r=JSON.stringify(r)),t+=4,i==t)return r;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return r+"("+o.join(",")+")"}findChild(t,e,i,n,r){let{buffer:o}=this,l=-1;for(let h=t;h!=e&&!(sh(r,n,o[h+1],o[h+2])&&(l=h,i>0));h=o[h+3]);return l}slice(t,e,i){let n=this.buffer,r=new Uint16Array(e-t),o=0;for(let l=t,h=0;l<e;){r[h++]=n[l++],r[h++]=n[l++]-i;let a=r[h++]=n[l++]-i;r[h++]=n[l++]-t,o=Math.max(o,a)}return new oe(r,o,this.set)}};function sh(s,t,e,i){switch(s){case-2:return e<t;case-1:return i>=t&&e<t;case 0:return e<t&&i>t;case 1:return e<=t&&i>t;case 2:return i>t;case 4:return!0}}function rh(s,t){let e=s.childBefore(t);for(;e;){let i=e.lastChild;if(!i||i.to!=e.to)break;i.type.isError&&i.from==i.to?(s=e,e=i.prevSibling):e=i}return s}function si(s,t,e,i){for(var n;s.from==s.to||(e<1?s.from>=t:s.from>t)||(e>-1?s.to<=t:s.to<t);){let o=!i&&s instanceof Ht&&s.index<0?null:s.parent;if(!o)return s;s=o}let r=i?0:et.IgnoreOverlays;if(i)for(let o=s,l=o.parent;l;o=l,l=o.parent)o instanceof Ht&&o.index<0&&((n=l.enter(t,e,r))===null||n===void 0?void 0:n.from)!=o.from&&(s=l);for(;;){let o=s.enter(t,e,r);if(!o)return s;s=o}}var Ht=class{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,r=0){for(let o=this;;){for(let{children:l,positions:h}=o._tree,a=e>0?l.length:-1;t!=a;t+=e){let f=l[t],c=h[t]+o.from;if(sh(n,i,c,c+f.length)){if(f instanceof oe){if(r&et.ExcludeBuffers)continue;let u=f.findChild(0,f.buffer.length,e,i-c,n);if(u>-1)return new Jt(new or(o,f,t,c),null,u)}else if(r&et.IncludeAnonymous||!f.type.isAnonymous||hr(f)){let u;if(!(r&et.IgnoreMounts)&&f.props&&(u=f.prop(O.mounted))&&!u.overlay)return new Ht(u.tree,c,t,o);let d=new Ht(f,c,t,o);return r&et.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(e<0?f.children.length-1:0,e,i,n)}}}if(r&et.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?t=o.index+e:t=e<0?-1:o._parent._tree.children.length,o=o._parent,!o))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&et.IgnoreOverlays)&&(n=this._tree.prop(O.mounted))&&n.overlay){let r=t-this.from;for(let{from:o,to:l}of n.overlay)if((e>0?o<=r:o<r)&&(e<0?l>=r:l>r))return new Ht(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 ri(this,t)}get tree(){return this._tree}toTree(){return this._tree}resolve(t,e=0){return si(this,t,e,!1)}resolveInner(t,e=0){return si(this,t,e,!0)}enterUnfinishedNodesBefore(t){return rh(this,t)}getChild(t,e=null,i=null){let n=Tn(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Tn(this,t,e,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(t){return On(this,t)}};function Tn(s,t,e,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(e!=null){for(;!n.type.is(e);)if(!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(t)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function On(s,t,e=t.length-1){for(let i=s.parent;e>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[e]&&t[e]!=i.name)return!1;e--}}return!0}var or=class{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}},Jt=class{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,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new Jt(this.context,this,r)}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&et.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new Jt(this.context,this,r)}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 Jt(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 Jt(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}cursor(t=0){return new ri(this,t)}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];t.push(i.slice(n,r,o)),e.push(0)}return new q(this.type,t,e,this.to-this.from)}resolve(t,e=0){return si(this,t,e,!1)}resolveInner(t,e=0){return si(this,t,e,!0)}enterUnfinishedNodesBefore(t){return rh(this,t)}toString(){return this.context.buffer.childString(this.index)}getChild(t,e=null,i=null){let n=Tn(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return Tn(this,t,e,i)}get node(){return this}matchContext(t){return On(this,t)}},ri=class{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 Ht)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let i=t._parent;i;i=i._parent)this.stack.unshift(i.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):!1}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 Ht?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}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,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}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&et.ExcludeBuffers?!1:this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&et.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&et.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)):!1;let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(e.findChild(n,this.index,-1,0,4))}else{let n=e.buffer[this.index+3];if(n<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}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 r=0;r<this.index;r++)if(n.buffer.buffer[r+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 r=e+t,o=t<0?-1:i._tree.children.length;r!=o;r+=t){let l=i._tree.children[r];if(this.mode&et.IncludeAnonymous||l instanceof oe||!l.type.isAnonymous||hr(l))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,r=this.stack.length;r>=0;){for(let o=t;o;o=o._parent)if(o.index==n){if(n==this.index)return o;e=o,i=r+1;break t}n=this.stack[--r]}}for(let n=i;n<this.stack.length;n++)e=new Jt(this.buffer,e,this.stack[n]);return this.bufferNode=new Jt(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||t(this)!==!1){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 On(this.node,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,r=this.stack.length-1;n>=0;r--){if(r<0)return On(this.node,t,n);let o=i[e.buffer[this.stack[r]]];if(!o.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}};function hr(s){return s.children.some(t=>t instanceof oe||!t.type.isAnonymous||hr(t))}function Dc(s){var t;let{buffer:e,nodeSet:i,maxBufferLength:n=1024,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(e)?new Li(e,e.length):e,h=i.types,a=0,f=0;function c(w,S,C,P,z){let{id:L,start:R,end:N,size:X}=l,Z=f;for(;X<0;)if(l.next(),X==-1){let rt=r[L];C.push(rt),P.push(R-w);return}else if(X==-3){a=L;return}else if(X==-4){f=L;return}else throw new RangeError(`Unrecognized record size: ${X}`);let gt=h[L],yt,st,he=R-w;if(N-R<=n&&(st=m(l.pos-S,z))){let rt=new Uint16Array(st.size-st.skip),_=l.pos-st.size,te=rt.length;for(;l.pos>_;)te=g(st.start,rt,te);yt=new oe(rt,N-st.start,i),he=st.start-w}else{let rt=l.pos-X;l.next();let _=[],te=[],Ce=L>=o?L:-1,je=0,qi=N;for(;l.pos>rt;)Ce>=0&&l.id==Ce&&l.size>=0?(l.end<=qi-n&&(d(_,te,R,je,l.end,qi,Ce,Z),je=_.length,qi=l.end),l.next()):c(R,rt,_,te,Ce);if(Ce>=0&&je>0&&je<_.length&&d(_,te,R,je,R,qi,Ce,Z),_.reverse(),te.reverse(),Ce>-1&&je>0){let Yr=u(gt);yt=ar(gt,_,te,0,_.length,0,N-R,Yr,Yr)}else yt=p(gt,_,te,N-R,Z-N)}C.push(yt),P.push(he)}function u(w){return(S,C,P)=>{let z=0,L=S.length-1,R,N;if(L>=0&&(R=S[L])instanceof q){if(!L&&R.type==w&&R.length==P)return R;(N=R.prop(O.lookAhead))&&(z=C[L]+R.length+N)}return p(w,S,C,P,z)}}function d(w,S,C,P,z,L,R,N){let X=[],Z=[];for(;w.length>P;)X.push(w.pop()),Z.push(S.pop()+C-z);w.push(p(i.types[R],X,Z,L-z,N-L)),S.push(z-C)}function p(w,S,C,P,z=0,L){if(a){let R=[O.contextHash,a];L=L?[R].concat(L):[R]}if(z>25){let R=[O.lookAhead,z];L=L?[R].concat(L):[R]}return new q(w,S,C,P,L)}function m(w,S){let C=l.fork(),P=0,z=0,L=0,R=C.end-n,N={size:0,start:0,skip:0};t:for(let X=C.pos-w;C.pos>X;){let Z=C.size;if(C.id==S&&Z>=0){N.size=P,N.start=z,N.skip=L,L+=4,P+=4,C.next();continue}let gt=C.pos-Z;if(Z<0||gt<X||C.start<R)break;let yt=C.id>=o?4:0,st=C.start;for(C.next();C.pos>gt;){if(C.size<0)if(C.size==-3)yt+=4;else break t;else C.id>=o&&(yt+=4);C.next()}z=st,P+=Z,L+=yt}return(S<0||P==w)&&(N.size=P,N.start=z,N.skip=L),N.size>4?N:void 0}function g(w,S,C){let{id:P,start:z,end:L,size:R}=l;if(l.next(),R>=0&&P<o){let N=C;if(R>4){let X=l.pos-(R-4);for(;l.pos>X;)C=g(w,S,C)}S[--C]=N,S[--C]=L-w,S[--C]=z-w,S[--C]=P}else R==-3?a=P:R==-4&&(f=P);return C}let y=[],v=[];for(;l.pos>0;)c(s.start||0,s.bufferStart||0,y,v,-1);let A=(t=s.length)!==null&&t!==void 0?t:y.length?v[0]+y[0].length:0;return new q(h[s.topID],y.reverse(),v.reverse(),A)}var nh=new WeakMap;function Dn(s,t){if(!s.isAnonymous||t instanceof oe||t.type!=s)return 1;let e=nh.get(t);if(e==null){e=1;for(let i of t.children){if(i.type!=s||!(i instanceof q)){e=1;break}e+=Dn(s,i)}nh.set(t,e)}return e}function ar(s,t,e,i,n,r,o,l,h){let a=0;for(let p=i;p<n;p++)a+=Dn(s,t[p]);let f=Math.ceil(a*1.5/8),c=[],u=[];function d(p,m,g,y,v){for(let A=g;A<y;){let w=A,S=m[A],C=Dn(s,p[A]);for(A++;A<y;A++){let P=Dn(s,p[A]);if(C+P>=f)break;C+=P}if(A==w+1){if(C>f){let P=p[w];d(P.children,P.positions,0,P.children.length,m[w]+v);continue}c.push(p[w])}else{let P=m[A-1]+p[A-1].length-S;c.push(ar(s,p,m,w,A,S,P,null,h))}u.push(S+v-r)}}return d(t,e,i,n,0),(l||h)(c,u,o)}var _t=class{constructor(t,e,i,n,r=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,e=[],i=!1){let n=[new _t(0,t.length,t,0,!1,i)];for(let r of e)r.to>t.length&&n.push(r);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],r=1,o=t.length?t[0]:null;for(let l=0,h=0,a=0;;l++){let f=l<e.length?e[l]:null,c=f?f.fromA:1e9;if(c-h>=i)for(;o&&o.from<c;){let u=o;if(h>=u.from||c<=u.to||a){let d=Math.max(u.from,h)-a,p=Math.min(u.to,c)-a;u=d>=p?null:new _t(d,p,u.tree,u.offset+a,l>0,!!f)}if(u&&n.push(u),o.to>c)break;o=r<t.length?t[r++]:null}if(!f)break;h=f.toA,a=f.toA-f.toB}return n}},oi=class{startParse(t,e,i){return typeof t=="string"&&(t=new lr(t)),i=i?i.length?i.map(n=>new Ei(n.from,n.to)):[new Ei(0,0)]:[new Ei(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let r=n.advance();if(r)return r}}},lr=class{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)}};var tp=new O({perNode:!0});var Tc=0,Rt=class{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=Tc++}static define(t){if(t!=null&&t.base)throw new Error("Can not derive from a modified tag");let e=new Rt([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new li;return e=>e.modified.indexOf(t)>-1?e:li.get(e.base||e,e.modified.concat(t).sort((i,n)=>i.id-n.id))}},Oc=0,li=class{constructor(){this.instances=[],this.id=Oc++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(l=>l.base==t&&Pc(e,l.modified));if(i)return i;let n=[],r=new Rt(n,t,e);for(let l of e)l.instances.push(r);let o=Bc(e);for(let l of t.set)if(!l.modified.length)for(let h of o)n.push(li.get(l,h));return r}};function Pc(s,t){return s.length==t.length&&s.every((e,i)=>e==t[i])}function Bc(s){let t=[[]];for(let e=0;e<s.length;e++)for(let i=0,n=t.length;i<n;i++)t.push(t[i].concat(s[e]));return t.sort((e,i)=>i.length-e.length)}function En(s){let t=Object.create(null);for(let e in s){let i=s[e];Array.isArray(i)||(i=[i]);for(let n of e.split(" "))if(n){let r=[],o=2,l=n;for(let c=0;;){if(l=="..."&&c>0&&c+3==n.length){o=1;break}let u=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(r.push(u[0]=="*"?"":u[0][0]=='"'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==n.length)break;let d=n[c++];if(c==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(c)}let h=r.length-1,a=r[h];if(!a)throw new RangeError("Invalid path: "+n);let f=new hi(i,o,h>0?r.slice(0,h):null);t[a]=f.sort(t[a])}}return hh.add(t)}var hh=new O,hi=class{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}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}};hi.empty=new hi([],2,null);function dr(s,t){let e=Object.create(null);for(let r of s)if(!Array.isArray(r.tag))e[r.tag.id]=r.class;else for(let o of r.tag)e[o.id]=r.class;let{scope:i,all:n=null}=t||{};return{style:r=>{let o=n;for(let l of r)for(let h of l.set){let a=e[h.id];if(a){o=o?o+" "+a:a;break}}return o},scope:i}}function Rc(s,t){let e=null;for(let i of s){let n=i.style(t);n&&(e=e?e+" "+n:n)}return e}function ah(s,t,e,i=0,n=s.length){let r=new cr(i,Array.isArray(t)?t:[t],e);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}var cr=class{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,r){let{type:o,from:l,to:h}=t;if(l>=i||h<=e)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let a=n,f=Ec(t)||hi.empty,c=Rc(r,f.tags);if(c&&(a&&(a+=" "),a+=c,f.mode==1&&(n+=(n?" ":"")+c)),this.startSpan(t.from,a),f.opaque)return;let u=t.tree&&t.tree.prop(O.mounted);if(u&&u.overlay){let d=t.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=t.firstChild();for(let g=0,y=l;;g++){let v=g<u.overlay.length?u.overlay[g]:null,A=v?v.from+l:h,w=Math.max(e,y),S=Math.min(i,A);if(w<S&&m)for(;t.from<S&&(this.highlightRange(t,w,S,n,r),this.startSpan(Math.min(S,t.to),a),!(t.to>=A||!t.nextSibling())););if(!v||A>i)break;y=v.to+l,y>e&&(this.highlightRange(d.cursor(),Math.max(e,v.from+l),Math.min(i,y),n,p),this.startSpan(y,a))}m&&t.parent()}else if(t.firstChild()){do if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),a)}while(t.nextSibling());t.parent()}}};function Ec(s){let t=s.type.prop(hh);for(;t&&t.context&&!s.matchContext(t.context);)t=t.next;return t||null}var x=Rt.define,Pn=x(),ge=x(),oh=x(ge),lh=x(ge),ye=x(),Bn=x(ye),fr=x(ye),Zt=x(),Ie=x(Zt),Yt=x(),Xt=x(),ur=x(),Ii=x(ur),Rn=x(),k={comment:Pn,lineComment:x(Pn),blockComment:x(Pn),docComment:x(Pn),name:ge,variableName:x(ge),typeName:oh,tagName:x(oh),propertyName:lh,attributeName:x(lh),className:x(ge),labelName:x(ge),namespace:x(ge),macroName:x(ge),literal:ye,string:Bn,docString:x(Bn),character:x(Bn),attributeValue:x(Bn),number:fr,integer:x(fr),float:x(fr),bool:x(ye),regexp:x(ye),escape:x(ye),color:x(ye),url:x(ye),keyword:Yt,self:x(Yt),null:x(Yt),atom:x(Yt),unit:x(Yt),modifier:x(Yt),operatorKeyword:x(Yt),controlKeyword:x(Yt),definitionKeyword:x(Yt),moduleKeyword:x(Yt),operator:Xt,derefOperator:x(Xt),arithmeticOperator:x(Xt),logicOperator:x(Xt),bitwiseOperator:x(Xt),compareOperator:x(Xt),updateOperator:x(Xt),definitionOperator:x(Xt),typeOperator:x(Xt),controlOperator:x(Xt),punctuation:ur,separator:x(ur),bracket:Ii,angleBracket:x(Ii),squareBracket:x(Ii),paren:x(Ii),brace:x(Ii),content:Zt,heading:Ie,heading1:x(Ie),heading2:x(Ie),heading3:x(Ie),heading4:x(Ie),heading5:x(Ie),heading6:x(Ie),contentSeparator:x(Zt),list:x(Zt),quote:x(Zt),emphasis:x(Zt),strong:x(Zt),link:x(Zt),monospace:x(Zt),strikethrough:x(Zt),inserted:x(),deleted:x(),changed:x(),invalid:x(),meta:Rn,documentMeta:x(Rn),annotation:x(Rn),processingInstruction:x(Rn),definition:Rt.defineModifier(),constant:Rt.defineModifier(),function:Rt.defineModifier(),standard:Rt.defineModifier(),local:Rt.defineModifier(),special:Rt.defineModifier()},np=dr([{tag:k.link,class:"tok-link"},{tag:k.heading,class:"tok-heading"},{tag:k.emphasis,class:"tok-emphasis"},{tag:k.strong,class:"tok-strong"},{tag:k.keyword,class:"tok-keyword"},{tag:k.atom,class:"tok-atom"},{tag:k.bool,class:"tok-bool"},{tag:k.url,class:"tok-url"},{tag:k.labelName,class:"tok-labelName"},{tag:k.inserted,class:"tok-inserted"},{tag:k.deleted,class:"tok-deleted"},{tag:k.literal,class:"tok-literal"},{tag:k.string,class:"tok-string"},{tag:k.number,class:"tok-number"},{tag:[k.regexp,k.escape,k.special(k.string)],class:"tok-string2"},{tag:k.variableName,class:"tok-variableName"},{tag:k.local(k.variableName),class:"tok-variableName tok-local"},{tag:k.definition(k.variableName),class:"tok-variableName tok-definition"},{tag:k.special(k.variableName),class:"tok-variableName2"},{tag:k.definition(k.propertyName),class:"tok-propertyName tok-definition"},{tag:k.typeName,class:"tok-typeName"},{tag:k.namespace,class:"tok-namespace"},{tag:k.className,class:"tok-className"},{tag:k.macroName,class:"tok-macroName"},{tag:k.propertyName,class:"tok-propertyName"},{tag:k.operator,class:"tok-operator"},{tag:k.comment,class:"tok-comment"},{tag:k.meta,class:"tok-meta"},{tag:k.invalid,class:"tok-invalid"},{tag:k.punctuation,class:"tok-punctuation"}]);var pr,ai=new O;function Lc(s){return D.define({combine:s?t=>t.concat(s):void 0})}var Ic=new O,St=class{constructor(t,e,i=[],n=""){this.data=t,this.name=n,E.prototype.hasOwnProperty("tree")||Object.defineProperty(E.prototype,"tree",{get(){return ht(this)}}),this.parser=e,this.extension=[ci.of(this),E.languageData.of((r,o,l)=>{let h=fh(r,o,l),a=h.type.prop(ai);if(!a)return[];let f=r.facet(a),c=h.type.prop(Ic);if(c){let u=h.resolve(o-h.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(t,e,i=-1){return fh(t,e,i).type.prop(ai)==this.data}findRegions(t){let e=t.facet(ci);if((e==null?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(ai)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(O.mounted);if(l){if(l.tree.prop(ai)==this.data){if(l.overlay)for(let h of l.overlay)i.push({from:h.from+o,to:h.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let h=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>h)return}}for(let h=0;h<r.children.length;h++){let a=r.children[h];a instanceof q&&n(a,r.positions[h]+o)}};return n(ht(t),0),i}get allowsNesting(){return!0}};St.setState=I.define();function fh(s,t,e){let i=s.facet(ci),n=ht(s).topNode;if(!i||i.allowsNesting)for(let r=n;r;r=r.enter(t,e,et.ExcludeBuffers))r.type.isTop&&(n=r);return n}var Ne=class extends St{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Lc(t.languageData);return new Ne(e,t.parser.configure({props:[ai.add(i=>i.isTop?e:void 0)]}),t.name)}configure(t,e){return new Ne(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function ht(s){let t=s.field(St.state,!1);return t?t.tree:q.empty}function ph(s,t,e=50){var i;let n=(i=s.field(St.state,!1))===null||i===void 0?void 0:i.context;if(!n)return null;let r=n.viewport;n.updateViewport({from:0,to:t});let o=n.isDone(t)||n.work(e,t)?n.tree:null;return n.updateViewport(r),o}var br=class{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)}},Ni=null,fi=class{constructor(t,e,i=[],n,r,o,l,h){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=h,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new fi(t,e,[],q.empty,0,i,[],null)}startParse(){return this.parser.startParse(new br(this.state.doc),this.fragments)}work(t,e){return e!=null&&e>=this.state.doc.length&&(e=void 0),this.tree!=q.empty&&this.isDone(e!=null?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof t=="number"){let n=Date.now()+t;t=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),e!=null&&(this.parse.stoppedAt==null||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(_t.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(e!=null?e:this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||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(_t.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Ni;Ni=this;try{return t()}finally{Ni=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ch(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!t.empty){let h=[];if(t.iterChangedRanges((a,f,c,u)=>h.push({fromA:a,toA:f,fromB:c,toB:u})),i=_t.applyChanges(i,h),n=q.empty,r=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){l=[];for(let a of this.skipped){let f=t.mapPos(a.from,1),c=t.mapPos(a.to,-1);f<c&&l.push({from:f,to:c})}}}return new fi(this.parser,e,i,n,r,o,l,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 i=0;i<this.skipped.length;i++){let{from:n,to:r}=this.skipped[i];n<t.to&&r>t.from&&(this.fragments=ch(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=e?!1:(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 oi{createParse(e,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let h=Ni;if(h){for(let a of n)h.tempSkipped.push(a);t&&(h.scheduleOn=h.scheduleOn?Promise.all([h.scheduleOn,t]):t)}return this.parsedPos=o,new q(nt.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&e[0].from==0&&e[0].to>=t}static get(){return Ni}};function ch(s,t,e){return _t.applyChanges(s,[{fromA:t,toA:e,fromB:t,toB:e}])}var be=class{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 be(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=fi.create(t.facet(ci).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new be(i)}};St.state=ut.define({create:be.init,update(s,t){for(let e of t.effects)if(e.is(St.setState))return e.value;return t.startState.facet(ci)!=t.state.facet(ci)?be.init(t.state):s.apply(t)}});var mh=s=>{let t=setTimeout(()=>s(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(mh=s=>{let t=-1,e=setTimeout(()=>{t=requestIdleCallback(s,{timeout:500-100})},100);return()=>t<0?clearTimeout(e):cancelIdleCallback(t)});var mr=typeof navigator<"u"&&(!((pr=navigator.scheduling)===null||pr===void 0)&&pr.isInputPending)?()=>navigator.scheduling.isInputPending():null,Nc=vt.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(St.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(St.state);(e.tree!=e.context.tree||!e.context.isDone(t.doc.length))&&(this.working=mh(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,r=i.field(St.state);if(r.tree==r.context.tree&&r.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!mr?Math.max(25,t.timeRemaining()-5):1e9),l=r.context.treeLen<n&&i.doc.length>n+1e3,h=r.context.work(()=>mr&&mr()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-e,(h||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:St.setState.of(new be(r.context))})),this.chunkBudget>0&&!(h&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Mt(this.view.state,e)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),ci=D.define({combine(s){return s.length?s[0]:null},enables:s=>[St.state,Nc,T.contentAttributes.compute([s],t=>{let e=t.facet(s);return e&&e.name?{"data-language":e.name}:{}})]}),Ln=class{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}};var Fc=D.define(),Vi=D.define({combine:s=>{if(!s.length)return" ";let t=s[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(s[0]));return t}});function zi(s){let t=s.facet(Vi);return t.charCodeAt(0)==9?s.tabSize*t.length:t.length}function Hi(s,t){let e="",i=s.tabSize,n=s.facet(Vi)[0];if(n==" "){for(;t>=i;)e+=" ",t-=i;n=" "}for(let r=0;r<t;r++)e+=n;return e}function Sr(s,t){s instanceof E&&(s=new Fe(s));for(let i of s.state.facet(Fc)){let n=i(s,t);if(n!==void 0)return n}let e=ht(s.state);return e?zc(s,e,t):null}var Fe=class{constructor(t,e={}){this.state=t,this.options=e,this.unit=zi(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return n!=null&&n>=i.from&&n<=i.to?r&&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),r=this.countColumn(i,t-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return Be(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let o=r(n);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Vc=new O;function zc(s,t,e){return gh(t.resolveInner(e).enterUnfinishedNodesBefore(e),e,s)}function Hc(s){return s.pos==s.options.simulateBreak&&s.options.simulateDoubleBreak}function Wc(s){let t=s.type.prop(Vc);if(t)return t;let e=s.firstChild,i;if(e&&(i=e.type.prop(O.closedBy))){let n=s.lastChild,r=n&&i.indexOf(n.name)>-1;return o=>Kc(o,!0,1,void 0,r&&!Hc(o)?n.from:void 0)}return s.parent==null?jc:null}function gh(s,t,e){for(;s;s=s.parent){let i=Wc(s);if(i)return i(Fi.create(e,t,s))}return null}function jc(){return 0}var Fi=class extends Fe{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 Fi(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let t=this.state.doc.lineAt(this.node.from);for(;;){let e=this.node.resolve(t.from);for(;e.parent&&e.parent.from==e.from;)e=e.parent;if(qc(e,this.node))break;t=this.state.doc.lineAt(e.from)}return this.lineIndent(t.from)}continue(){let t=this.node.parent;return t?gh(t,this.pos,this.base):0}};function qc(s,t){for(let e=t;e;e=e.parent)if(s==e)return!0;return!1}function $c(s){let t=s.node,e=t.childAfter(t.from),i=t.lastChild;if(!e)return null;let n=s.options.simulateBreak,r=s.state.doc.lineAt(e.from),o=n==null||n<=r.from?r.to:Math.min(r.to,n);for(let l=e.to;;){let h=t.childAfter(l);if(!h||h==i)return null;if(!h.type.isSkipped)return h.from<o?e:null;l=h.to}}function Kc(s,t,e,i,n){let r=s.textAfter,o=r.match(/^\s*/)[0].length,l=i&&r.slice(o,o+i.length)==i||n==s.pos+o,h=t?$c(s):null;return h?l?s.column(h.from):s.column(h.to):s.baseIndent+(l?0:s.unit*e)}var we=class{constructor(t,e){this.specs=t;let i;function n(l){let h=Ot.newName();return(i||(i=Object.create(null)))["."+h]=l,h}let r=typeof e.all=="string"?e.all:e.all?n(e.all):void 0,o=e.scope;this.scope=o instanceof St?l=>l.prop(ai)==o.data:o?l=>l==o:void 0,this.style=dr(t.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new Ot(i):null,this.themeType=e.themeType}static define(t,e){return new we(t,e||{})}},wr=D.define(),yh=D.define({combine(s){return s.length?[s[0]]:null}});function gr(s){let t=s.facet(wr);return t.length?t:s.facet(yh)}function bh(s,t){let e=[Uc],i;return s instanceof we&&(s.module&&e.push(T.styleModule.of(s.module)),i=s.themeType),t!=null&&t.fallback?e.push(yh.of(s)):i?e.push(wr.computeN([T.darkTheme],n=>n.facet(T.darkTheme)==(i=="dark")?[s]:[])):e.push(wr.of(s)),e}var xr=class{constructor(t){this.markCache=Object.create(null),this.tree=ht(t.state),this.decorations=this.buildDeco(t,gr(t.state))}update(t){let e=ht(t.state),i=gr(t.state),n=i!=gr(t.startState);e.length<t.view.viewport.to&&!n&&e.type==this.tree.type?this.decorations=this.decorations.map(t.changes):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i))}buildDeco(t,e){if(!e||!this.tree.length)return H.none;let i=new qt;for(let{from:n,to:r}of t.visibleRanges)ah(this.tree,e,(o,l,h)=>{i.add(o,l,this.markCache[h]||(this.markCache[h]=H.mark({class:h})))},n,r);return i.finish()}},Uc=fe.high(vt.fromClass(xr,{decorations:s=>s.decorations})),wh=we.define([{tag:k.meta,color:"#404740"},{tag:k.link,textDecoration:"underline"},{tag:k.heading,textDecoration:"underline",fontWeight:"bold"},{tag:k.emphasis,fontStyle:"italic"},{tag:k.strong,fontWeight:"bold"},{tag:k.strikethrough,textDecoration:"line-through"},{tag:k.keyword,color:"#708"},{tag:[k.atom,k.bool,k.url,k.contentSeparator,k.labelName],color:"#219"},{tag:[k.literal,k.inserted],color:"#164"},{tag:[k.string,k.deleted],color:"#a11"},{tag:[k.regexp,k.escape,k.special(k.string)],color:"#e40"},{tag:k.definition(k.variableName),color:"#00f"},{tag:k.local(k.variableName),color:"#30a"},{tag:[k.typeName,k.namespace],color:"#085"},{tag:k.className,color:"#167"},{tag:[k.special(k.variableName),k.macroName],color:"#256"},{tag:k.definition(k.propertyName),color:"#00c"},{tag:k.comment,color:"#940"},{tag:k.invalid,color:"#f00"}]);var Gc=1e4,Jc="()[]{}";var _c=new O;function kr(s,t,e){let i=s.prop(t<0?O.openedBy:O.closedBy);if(i)return i;if(s.name.length==1){let n=e.indexOf(s.name);if(n>-1&&n%2==(t<0?1:0))return[e[n+t]]}return null}function vr(s){let t=s.type.prop(_c);return t?t(s.node):s}function Ve(s,t,e,i={}){let n=i.maxScanDistance||Gc,r=i.brackets||Jc,o=ht(s),l=o.resolveInner(t,e);for(let h=l;h;h=h.parent){let a=kr(h.type,e,r);if(a&&h.from<h.to){let f=vr(h);if(f&&(e>0?t>=f.from&&t<f.to:t>f.from&&t<=f.to))return Yc(s,t,e,h,f,a,r)}}return Xc(s,t,e,o,l.type,n,r)}function Yc(s,t,e,i,n,r,o){let l=i.parent,h={from:n.from,to:n.to},a=0,f=l==null?void 0:l.cursor();if(f&&(e<0?f.childBefore(i.from):f.childAfter(i.to)))do if(e<0?f.to<=i.from:f.from>=i.to){if(a==0&&r.indexOf(f.type.name)>-1&&f.from<f.to){let c=vr(f);return{start:h,end:c?{from:c.from,to:c.to}:void 0,matched:!0}}else if(kr(f.type,e,o))a++;else if(kr(f.type,-e,o)){if(a==0){let c=vr(f);return{start:h,end:c&&c.from<c.to?{from:c.from,to:c.to}:void 0,matched:!1}}a--}}while(e<0?f.prevSibling():f.nextSibling());return{start:h,matched:!1}}function Xc(s,t,e,i,n,r,o){let l=e<0?s.sliceDoc(t-1,t):s.sliceDoc(t,t+1),h=o.indexOf(l);if(h<0||h%2==0!=e>0)return null;let a={from:e<0?t-1:t,to:e>0?t+1:t},f=s.doc.iterRange(t,e>0?s.doc.length:0),c=0;for(let u=0;!f.next().done&&u<=r;){let d=f.value;e<0&&(u+=d.length);let p=t+u*e;for(let m=e>0?0:d.length-1,g=e>0?d.length:-1;m!=g;m+=e){let y=o.indexOf(d[m]);if(!(y<0||i.resolveInner(p+m,1).type!=n))if(y%2==0==e>0)c++;else{if(c==1)return{start:a,end:{from:p+m,to:p+m+1},matched:y>>1==h>>1};c--}}e>0&&(u+=d.length)}return f.done?{start:a,matched:!1}:null}var Zc=Object.create(null),uh=[nt.none];var dh=[],Qc=Object.create(null);for(let[s,t]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"]])Qc[s]=tu(Zc,t);function yr(s,t){dh.indexOf(s)>-1||(dh.push(s),console.warn(t))}function tu(s,t){let e=null;for(let r of t.split(".")){let o=s[r]||k[r];o?typeof o=="function"?e?e=o(e):yr(r,`Modifier ${r} used at start of tag`):e?yr(r,`Tag ${r} used as modifier`):e=o:yr(r,`Unknown highlighting tag ${r}`)}if(!e)return 0;let i=t.replace(/ /g,"_"),n=nt.define({id:uh.length,name:i,props:[En({[i]:e})]});return uh.push(n),n.id}var Nn=class{constructor(t,e,i){this.state=t,this.pos=e,this.explicit=i,this.abortListeners=[]}tokenBefore(t){let e=ht(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),r=n.search(Oh(t,!1));return r<0?null:{from:i+r,to:this.pos,text:n.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(t,e){t=="abort"&&this.abortListeners&&this.abortListeners.push(e)}};function xh(s){let t=Object.keys(s).join(""),e=/\w/.test(t);return e&&(t=t.replace(/\w/g,"")),`[${e?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function eu(s){let t=Object.create(null),e=Object.create(null);for(let{label:n}of s){t[n[0]]=!0;for(let r=1;r<n.length;r++)e[n[r]]=!0}let i=xh(t)+xh(e)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function iu(s){let t=s.map(n=>typeof n=="string"?{label:n}:n),[e,i]=t.every(n=>/^\w+$/.test(n.label))?[/\w*$/,/\w+$/]:eu(t);return n=>{let r=n.matchBefore(i);return r||n.explicit?{from:r?r.from:n.pos,options:t,validFor:e}:null}}var Fn=class{constructor(t,e,i){this.completion=t,this.source=e,this.match=i}};function ke(s){return s.selection.main.head}function Oh(s,t){var e;let{source:i}=s,n=t&&i[0]!="^",r=i[i.length-1]!="$";return!n&&!r?s:new RegExp(`${n?"^":""}(?:${i})${r?"$":""}`,(e=s.flags)!==null&&e!==void 0?e:s.ignoreCase?"i":"")}var nu=kt.define();function su(s,t,e,i){return Object.assign(Object.assign({},s.changeByRange(n=>{if(n==s.selection.main)return{changes:{from:e,to:i,insert:t},range:b.cursor(e+t.length)};let r=i-e;return!n.empty||r&&s.sliceDoc(n.from-r,n.from)!=s.sliceDoc(e,i)?{range:n}:{changes:{from:n.from-r,to:n.from,insert:t},range:b.cursor(n.from-r+t.length)}})),{userEvent:"input.complete"})}function Ph(s,t){let e=t.completion.apply||t.completion.label,i=t.source;typeof e=="string"?s.dispatch(Object.assign(Object.assign({},su(s.state,e,i.from,i.to)),{annotations:nu.of(t.completion)})):e(s,t.completion,i.from,i.to)}var kh=new WeakMap;function ru(s){if(!Array.isArray(s))return s;let t=kh.get(s);return t||kh.set(s,t=iu(s)),t}var Ar=class{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let e=0;e<t.length;){let i=ct(t,e),n=Tt(i);this.chars.push(i);let r=t.slice(e,e+n),o=r.toUpperCase();this.folded.push(ct(o==r?r.toLowerCase():o,0)),e+=n}this.astral=t.length!=this.chars.length}match(t){if(this.pattern.length==0)return[0];if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:r,byWord:o}=this;if(e.length==1){let v=ct(t,0),A=Tt(v),w=A==t.length?0:-100;if(v!=e[0])if(v==i[0])w+=-200;else return null;return[w,0,A]}let l=t.indexOf(this.pattern);if(l==0)return[t.length==this.pattern.length?0:-100,0,this.pattern.length];let h=e.length,a=0;if(l<0){for(let v=0,A=Math.min(t.length,200);v<A&&a<h;){let w=ct(t,v);(w==e[a]||w==i[a])&&(n[a++]=v),v+=Tt(w)}if(a<h)return null}let f=0,c=0,u=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,A=Math.min(t.length,200),w=0;v<A&&c<h;){let S=ct(t,v);l<0&&(f<h&&S==e[f]&&(r[f++]=v),d<h&&(S==e[d]||S==i[d]?(d==0&&(p=v),m=v+1,d++):d=0));let C,P=S<255?S>=48&&S<=57||S>=97&&S<=122?2:S>=65&&S<=90?1:0:(C=ls(S))!=C.toLowerCase()?1:C!=C.toUpperCase()?2:0;(!v||P==1&&g||w==0&&P!=0)&&(e[c]==S||i[c]==S&&(u=!0)?o[c++]=v:o.length&&(y=!1)),w=P,v+=Tt(S)}return c==h&&o[0]==0&&y?this.result(-100+(u?-200:0),o,t):d==h&&p==0?[-200-t.length+(m==t.length?0:-100),0,m]:l>-1?[-700-t.length,l,l+this.pattern.length]:d==h?[-200+-700-t.length,p,m]:c==h?this.result(-100+(u?-200:0)+-700+(y?0:-1100),o,t):e.length==2?null:this.result((n[0]?-700:0)+-200+-1100,n,t)}result(t,e,i){let n=[t-i.length],r=1;for(let o of e){let l=o+(this.astral?Tt(ct(i,o)):1);r>1&&n[r-1]==o?n[r-1]=l:(n[r++]=o,n[r++]=l)}return n}},Lt=D.define({combine(s){return ce(s,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>vh(t(i),e(i)),optionClass:(t,e)=>i=>vh(t(i),e(i)),addToOptions:(t,e)=>t.concat(e)})}});function vh(s,t){return s?t?s+" "+t:s:t}function ou(s){let t=s.addToOptions.slice();return s.icons&&t.push({render(e){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),e.type&&i.classList.add(...e.type.split(/\s+/g).map(n=>"cm-completionIcon-"+n)),i.setAttribute("aria-hidden","true"),i},position:20}),t.push({render(e,i,n){let r=document.createElement("span");r.className="cm-completionLabel";let{label:o}=e,l=0;for(let h=1;h<n.length;){let a=n[h++],f=n[h++];a>l&&r.appendChild(document.createTextNode(o.slice(l,a)));let c=r.appendChild(document.createElement("span"));c.appendChild(document.createTextNode(o.slice(a,f))),c.className="cm-completionMatchedText",l=f}return l<o.length&&r.appendChild(document.createTextNode(o.slice(l))),r},position:50},{render(e){if(!e.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=e.detail,i},position:80}),t.sort((e,i)=>e.position-i.position).map(e=>e.render)}function Sh(s,t,e){if(s<=e)return{from:0,to:s};if(t<0&&(t=0),t<=s>>1){let n=Math.floor(t/e);return{from:n*e,to:(n+1)*e}}let i=Math.floor((s-t)/e);return{from:s-(i+1)*e,to:s-i*e}}var Mr=class{constructor(t,e){this.view=t,this.stateField=e,this.info=null,this.placeInfo={read:()=>this.measureInfo(),write:l=>this.positionInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(e),{options:n,selected:r}=i.open,o=t.state.facet(Lt);this.optionContent=ou(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Sh(n.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{for(let h=l.target,a;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(a=/-(\d+)$/.exec(h.id))&&+a[1]<n.length){Ph(t,n[+a[1]]),l.preventDefault();return}}),this.list=this.dom.appendChild(this.createListBox(n,i.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})}mount(){this.updateSel()}update(t){var e,i,n;let r=t.state.field(this.stateField),o=t.startState.field(this.stateField);this.updateTooltipClass(t.state),r!=o&&(this.updateSel(),((e=r.open)===null||e===void 0?void 0:e.disabled)!=((i=o.open)===null||i===void 0?void 0:i.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(!((n=r.open)===null||n===void 0)&&n.disabled)))}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of e.split(" "))i&&this.dom.classList.add(i);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfo)}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=Sh(e.options.length,e.selected,this.view.state.facet(Lt).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e.options,t.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfo)})),this.updateSelectedOption(e.selected)){this.info&&(this.info.remove(),this.info=null);let{completion:i}=e.options[e.selected],{info:n}=i;if(!n)return;let r=typeof n=="string"?document.createTextNode(n):n(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o)}).catch(o=>Mt(this.view.state,o,"completion info")):this.addInfoPane(r)}}addInfoPane(t){let e=this.info=document.createElement("div");e.className="cm-tooltip cm-completionInfo",e.appendChild(t),this.dom.appendChild(e),this.view.requestMeasure(this.placeInfo)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return e&&hu(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(),r=this.space;if(!r){let p=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:p.innerWidth,bottom:p.innerHeight}}if(n.top>Math.min(r.bottom,e.bottom)-10||n.bottom<Math.max(r.top,e.top)+10)return null;let o=this.view.textDirection==J.RTL,l=o,h=!1,a,f="",c="",u=e.left-r.left,d=r.right-e.right;if(l&&u<Math.min(i.width,d)?l=!1:!l&&d<Math.min(i.width,u)&&(l=!0),i.width<=(l?u:d))f=Math.max(r.top,Math.min(n.top,r.bottom-i.height))-e.top+"px",a=Math.min(400,l?u:d)+"px";else{h=!0,a=Math.min(400,(o?e.right:r.right-e.left)-30)+"px";let p=r.bottom-e.bottom;p>=i.height||p>e.top?f=n.bottom-e.top+"px":c=e.bottom-n.top+"px"}return{top:f,bottom:c,maxWidth:a,class:h?o?"left-narrow":"right-narrow":l?"left":"right"}}positionInfo(t){this.info&&(t?(this.info.style.top=t.top,this.info.style.bottom=t.bottom,this.info.style.maxWidth=t.maxWidth,this.info.className="cm-tooltip cm-completionInfo cm-completionInfo-"+t.class):this.info.style.top="-1e6px")}createListBox(t,e,i){let 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"));for(let r=i.from;r<i.to;r++){let{completion:o,match:l}=t[r],h=n.appendChild(document.createElement("li"));h.id=e+"-"+r,h.setAttribute("role","option");let a=this.optionClass(o);a&&(h.className=a);for(let f of this.optionContent){let c=f(o,this.view.state,l);c&&h.appendChild(c)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}};function lu(s){return t=>new Mr(t,s)}function hu(s,t){let e=s.getBoundingClientRect(),i=t.getBoundingClientRect();i.top<e.top?s.scrollTop-=e.top-i.top:i.bottom>e.bottom&&(s.scrollTop+=i.bottom-e.bottom)}function Ch(s){return(s.boost||0)*100+(s.apply?10:0)+(s.info?5:0)+(s.type?1:0)}function au(s,t){let e=[],i=0;for(let l of s)if(l.hasResult())if(l.result.filter===!1){let h=l.result.getMatch;for(let a of l.result.options){let f=[1e9-i++];if(h)for(let c of h(a))f.push(c);e.push(new Fn(a,l,f))}}else{let h=new Ar(t.sliceDoc(l.from,l.to)),a;for(let f of l.result.options)(a=h.match(f.label))&&(f.boost!=null&&(a[0]+=f.boost),e.push(new Fn(f,l,a)))}let n=[],r=null,o=t.facet(Lt).compareCompletions;for(let l of e.sort((h,a)=>a.match[0]-h.match[0]||o(h.completion,a.completion)))!r||r.label!=l.completion.label||r.detail!=l.completion.detail||r.type!=null&&l.completion.type!=null&&r.type!=l.completion.type||r.apply!=l.completion.apply?n.push(l):Ch(l.completion)>Ch(r)&&(n[n.length-1]=l),r=l.completion;return n}var xe=class{constructor(t,e,i,n,r,o){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=r,this.disabled=o}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new xe(this.options,Ah(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,r){let o=au(t,e);if(!o.length)return n&&t.some(h=>h.state==1)?new xe(n.options,n.attrs,n.tooltip,n.timestamp,n.selected,!0):null;let l=e.facet(Lt).selectOnOpen?0:-1;if(n&&n.selected!=l&&n.selected!=-1){let h=n.options[n.selected].completion;for(let a=0;a<o.length;a++)if(o[a].completion==h){l=a;break}}return new xe(o,Ah(i,l),{pos:t.reduce((h,a)=>a.hasResult()?Math.min(h,a.from):h,1e8),create:lu(Et),above:r.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(t){return new xe(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},ui=class{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new ui(uu,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:e}=t,i=e.facet(Lt),r=(i.override||e.languageDataAt("autocomplete",ke(e)).map(ru)).map(l=>(this.active.find(a=>a.source==l)||new dt(l,this.active.some(a=>a.state!=0)?1:0)).update(t,i));r.length==this.active.length&&r.every((l,h)=>l==this.active[h])&&(r=this.active);let o=this.open;o&&t.docChanged&&(o=o.map(t.changes)),t.selection||r.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!fu(r,this.active)?o=xe.build(r,e,this.id,o,i):o&&o.disabled&&!r.some(l=>l.state==1)&&(o=null),!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new dt(l.source,0):l));for(let l of t.effects)l.is(Rh)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new ui(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:cu}};function fu(s,t){if(s==t)return!0;for(let e=0,i=0;;){for(;e<s.length&&!s[e].hasResult;)e++;for(;i<t.length&&!t[i].hasResult;)i++;let n=e==s.length,r=i==t.length;if(n||r)return n==r;if(s[e++].result!=t[i++].result)return!1}}var cu={"aria-autocomplete":"list"};function Ah(s,t){let e={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":s};return t>-1&&(e["aria-activedescendant"]=s+"-"+t),e}var uu=[];function Dr(s){return s.isUserEvent("input.type")?"input":s.isUserEvent("delete.backward")?"delete":null}var dt=class{constructor(t,e,i=-1){this.source=t,this.state=e,this.explicitPos=i}hasResult(){return!1}update(t,e){let i=Dr(t),n=this;i?n=n.handleUserEvent(t,i,e):t.docChanged?n=n.handleChange(t):t.selection&&n.state!=0&&(n=new dt(n.source,0));for(let r of t.effects)if(r.is(Or))n=new dt(n.source,1,r.value?ke(t.state):-1);else if(r.is(Vn))n=new dt(n.source,0);else if(r.is(Bh))for(let o of r.value)o.source==n.source&&(n=o);return n}handleUserEvent(t,e,i){return e=="delete"||!i.activateOnTyping?this.map(t.changes):new dt(this.source,1)}handleChange(t){return t.changes.touchesRange(ke(t.startState))?new dt(this.source,0):this.map(t.changes)}map(t){return t.empty||this.explicitPos<0?this:new dt(this.source,this.state,t.mapPos(this.explicitPos))}},He=class extends dt{constructor(t,e,i,n,r){super(t,2,e),this.result=i,this.from=n,this.to=r}hasResult(){return!0}handleUserEvent(t,e,i){var n;let r=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),l=ke(t.state);if((this.explicitPos<0?l<=r:l<this.from)||l>o||e=="delete"&&ke(t.startState)==this.from)return new dt(this.source,e=="input"&&i.activateOnTyping?1:0);let h=this.explicitPos<0?-1:t.changes.mapPos(this.explicitPos),a;return du(this.result.validFor,t.state,r,o)?new He(this.source,h,this.result,r,o):this.result.update&&(a=this.result.update(this.result,r,o,new Nn(t.state,l,h>=0)))?new He(this.source,h,a,a.from,(n=a.to)!==null&&n!==void 0?n:ke(t.state)):new dt(this.source,1,h)}handleChange(t){return t.changes.touchesRange(this.from,this.to)?new dt(this.source,0):this.map(t.changes)}map(t){return t.empty?this:new He(this.source,this.explicitPos<0?-1:t.mapPos(this.explicitPos),this.result,t.mapPos(this.from),t.mapPos(this.to,1))}};function du(s,t,e,i){if(!s)return!1;let n=t.sliceDoc(e,i);return typeof s=="function"?s(n,e,i,t):Oh(s,!0).test(n)}var Or=I.define(),Vn=I.define(),Bh=I.define({map(s,t){return s.map(e=>e.map(t))}}),Rh=I.define(),Et=ut.define({create(){return ui.start()},update(s,t){return s.update(t)},provide:s=>[rr.from(s,t=>t.tooltip),T.contentAttributes.from(s,t=>t.attrs)]});function In(s,t="option"){return e=>{let i=e.state.field(Et,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<e.state.facet(Lt).interactionDelay)return!1;let n=1,r;t=="page"&&(r=eh(e,i.open.tooltip))&&(n=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+n*(s?1:-1):s?0:o-1;return l<0?l=t=="page"?0:o-1:l>=o&&(l=t=="page"?o-1:0),e.dispatch({effects:Rh.of(l)}),!0}}var pu=s=>{let t=s.state.field(Et,!1);return s.state.readOnly||!t||!t.open||t.open.selected<0||Date.now()-t.open.timestamp<s.state.facet(Lt).interactionDelay?!1:(t.open.disabled||Ph(s,t.open.options[t.open.selected]),!0)},Pr=s=>s.state.field(Et,!1)?(s.dispatch({effects:Or.of(!0)}),!0):!1,mu=s=>{let t=s.state.field(Et,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(s.dispatch({effects:Vn.of(null)}),!0)},Tr=class{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}},Mh=50,gu=50,yu=1e3,bu=vt.fromClass(class{constructor(s){this.view=s,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let t of s.state.field(Et).active)t.state==1&&this.startQuery(t)}update(s){let t=s.state.field(Et);if(!s.selectionSet&&!s.docChanged&&s.startState.field(Et)==t)return;let e=s.transactions.some(i=>(i.selection||i.docChanged)&&!Dr(i));for(let i=0;i<this.running.length;i++){let n=this.running[i];if(e||n.updates.length+s.transactions.length>gu&&Date.now()-n.time>yu){for(let r of n.context.abortListeners)try{r()}catch(o){Mt(this.view.state,o)}n.context.abortListeners=null,this.running.splice(i--,1)}else n.updates.push(...s.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=t.active.some(i=>i.state==1&&!this.running.some(n=>n.active.source==i.source))?setTimeout(()=>this.startUpdate(),Mh):-1,this.composing!=0)for(let i of s.transactions)Dr(i)=="input"?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:s}=this.view,t=s.field(Et);for(let e of t.active)e.state==1&&!this.running.some(i=>i.active.source==e.source)&&this.startQuery(e)}startQuery(s){let{state:t}=this.view,e=ke(t),i=new Nn(t,e,s.explicitPos==e),n=new Tr(s,i);this.running.push(n),Promise.resolve(s.source(i)).then(r=>{n.context.aborted||(n.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:Vn.of(null)}),Mt(this.view.state,r)})}scheduleAccept(){this.running.every(s=>s.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),Mh))}accept(){var s;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],e=this.view.state.facet(Lt);for(let i=0;i<this.running.length;i++){let n=this.running[i];if(n.done===void 0)continue;if(this.running.splice(i--,1),n.done){let o=new He(n.active.source,n.active.explicitPos,n.done,n.done.from,(s=n.done.to)!==null&&s!==void 0?s:ke(n.updates.length?n.updates[0].startState:this.view.state));for(let l of n.updates)o=o.update(l,e);if(o.hasResult()){t.push(o);continue}}let r=this.view.state.field(Et).active.find(o=>o.source==n.active.source);if(r&&r.state==1)if(n.done==null){let o=new dt(n.active.source,0);for(let l of n.updates)o=o.update(l,e);o.state!=1&&t.push(o)}else this.startQuery(r)}t.length&&this.view.dispatch({effects:Bh.of(t)})}},{eventHandlers:{blur(){let s=this.view.state.field(Et,!1);s&&s.tooltip&&this.view.state.facet(Lt).closeOnBlur&&this.view.dispatch({effects:Vn.of(null)})},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Or.of(!1)}),20),this.composing=0}}}),wu=T.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":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer",padding:"1px 3px",lineHeight:1.2}}},"&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:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".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:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var zn={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},ze=I.define({map(s,t){let e=t.mapPos(s,-1,ft.TrackAfter);return e==null?void 0:e}}),Br=I.define({map(s,t){return t.mapPos(s)}}),Rr=new class extends Vt{};Rr.startSide=1;Rr.endSide=-1;var Eh=ut.define({create(){return F.empty},update(s,t){if(t.selection){let e=t.state.doc.lineAt(t.selection.main.head).from,i=t.startState.doc.lineAt(t.startState.selection.main.head).from;e!=t.changes.mapPos(i,-1)&&(s=F.empty)}s=s.map(t.changes);for(let e of t.effects)e.is(ze)?s=s.update({add:[Rr.range(e.value,e.value+1)]}):e.is(Br)&&(s=s.update({filter:i=>i!=e.value}));return s}});function Lh(){return[Su,Eh]}var Cr="()[]{}<>";function xu(s){for(let t=0;t<Cr.length;t+=2)if(Cr.charCodeAt(t)==s)return Cr.charAt(t+1);return ls(s<128?s:s+1)}function ku(s,t){return s.languageDataAt("closeBrackets",t)[0]||zn}var vu=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Su=T.inputHandler.of((s,t,e,i)=>{if((vu?s.composing:s.compositionStarted)||s.state.readOnly)return!1;let n=s.state.selection.main;if(i.length>2||i.length==2&&Tt(ct(i,0))==1||t!=n.from||e!=n.to)return!1;let r=Cu(s.state,i);return r?(s.dispatch(r),!0):!1});function Cu(s,t){let e=ku(s,s.selection.main.head),i=e.brackets||zn.brackets;for(let n of i){let r=xu(ct(n,0));if(t==n)return r==n?Du(s,n,i.indexOf(n+n+n)>-1,e):Au(s,n,r,e.before||zn.before);if(t==r&&Ih(s,s.selection.main.from))return Mu(s,n,r)}return null}function Ih(s,t){let e=!1;return s.field(Eh).between(0,s.doc.length,i=>{i==t&&(e=!0)}),e}function Er(s,t){let e=s.sliceString(t,t+2);return e.slice(0,Tt(ct(e,0)))}function Au(s,t,e,i){let n=null,r=s.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:e,from:o.to}],effects:ze.of(o.to+t.length),range:b.range(o.anchor+t.length,o.head+t.length)};let l=Er(s.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:t+e,from:o.head},effects:ze.of(o.head+t.length),range:b.cursor(o.head+t.length)}:{range:n=o}});return n?null:s.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Mu(s,t,e){let i=null,n=s.selection.ranges.map(r=>r.empty&&Er(s.doc,r.head)==e?b.cursor(r.head+e.length):i=r);return i?null:s.update({selection:b.create(n,s.selection.mainIndex),scrollIntoView:!0,effects:s.selection.ranges.map(({from:r})=>Br.of(r))})}function Du(s,t,e,i){let n=i.stringPrefixes||zn.stringPrefixes,r=null,o=s.changeByRange(l=>{if(!l.empty)return{changes:[{insert:t,from:l.from},{insert:t,from:l.to}],effects:ze.of(l.to+t.length),range:b.range(l.anchor+t.length,l.head+t.length)};let h=l.head,a=Er(s.doc,h),f;if(a==t){if(Dh(s,h))return{changes:{insert:t+t,from:h},effects:ze.of(h+t.length),range:b.cursor(h+t.length)};if(Ih(s,h)){let c=e&&s.sliceDoc(h,h+t.length*3)==t+t+t;return{range:b.cursor(h+t.length*(c?3:1)),effects:Br.of(h)}}}else{if(e&&s.sliceDoc(h-2*t.length,h)==t+t&&(f=Th(s,h-2*t.length,n))>-1&&Dh(s,f))return{changes:{insert:t+t+t+t,from:h},effects:ze.of(h+t.length),range:b.cursor(h+t.length)};if(s.charCategorizer(h)(a)!=bt.Word&&Th(s,h,n)>-1&&!Tu(s,h,t,n))return{changes:{insert:t+t,from:h},effects:ze.of(h+t.length),range:b.cursor(h+t.length)}}return{range:r=l}});return r?null:s.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Dh(s,t){let e=ht(s).resolveInner(t+1);return e.parent&&e.from==t}function Tu(s,t,e,i){let n=ht(s).resolveInner(t,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=s.sliceDoc(n.from,Math.min(n.to,n.from+e.length+r)),h=l.indexOf(e);if(!h||h>-1&&i.indexOf(l.slice(0,h))>-1){let f=n.firstChild;for(;f&&f.from==n.from&&f.to-f.from>e.length+h;){if(s.sliceDoc(f.to-e.length,f.to)==e)return!1;f=f.firstChild}return!0}let a=n.to==t&&n.parent;if(!a)break;n=a}return!1}function Th(s,t,e){let i=s.charCategorizer(t);if(i(s.sliceDoc(t-1,t))!=bt.Word)return t;for(let n of e){let r=t-n.length;if(s.sliceDoc(r,t)==n&&i(s.sliceDoc(r-1,r))!=bt.Word)return r}return-1}function Nh(s={}){return[Et,Lt.of(s),bu,Pu,wu]}var Ou=[{key:"Ctrl-Space",run:Pr},{key:"Escape",run:mu},{key:"ArrowDown",run:In(!0)},{key:"ArrowUp",run:In(!1)},{key:"PageDown",run:In(!0,"page")},{key:"PageUp",run:In(!1,"page")},{key:"Enter",run:pu}],Pu=fe.highest(Ri.computeN([Lt],s=>s.facet(Lt).defaultKeymap?[Ou]:[]));var Bu=s=>{let{state:t}=s,e=t.doc.lineAt(t.selection.main.head),i=Hr(s.state,e.from);return i.line?Ru(s):i.block?Lu(s):!1};function zr(s,t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=s(t,e);return n?(i(e.update(n)),!0):!1}}var Ru=zr(Fu,0);var Eu=zr($h,0);var Lu=zr((s,t)=>$h(s,t,Nu(t)),0);function Hr(s,t){let e=s.languageDataAt("commentTokens",t);return e.length?e[0]:{}}var Wi=50;function Iu(s,{open:t,close:e},i,n){let r=s.sliceDoc(i-Wi,i),o=s.sliceDoc(n,n+Wi),l=/\s*$/.exec(r)[0].length,h=/^\s*/.exec(o)[0].length,a=r.length-l;if(r.slice(a-t.length,a)==t&&o.slice(h,h+e.length)==e)return{open:{pos:i-l,margin:l&&1},close:{pos:n+h,margin:h&&1}};let f,c;n-i<=2*Wi?f=c=s.sliceDoc(i,n):(f=s.sliceDoc(i,i+Wi),c=s.sliceDoc(n-Wi,n));let u=/^\s*/.exec(f)[0].length,d=/\s*$/.exec(c)[0].length,p=c.length-d-e.length;return f.slice(u,u+t.length)==t&&c.slice(p,p+e.length)==e?{open:{pos:i+u+t.length,margin:/\s/.test(f.charAt(u+t.length))?1:0},close:{pos:n-d-e.length,margin:/\s/.test(c.charAt(p-1))?1:0}}:null}function Nu(s){let t=[];for(let e of s.selection.ranges){let i=s.doc.lineAt(e.from),n=e.to<=i.to?i:s.doc.lineAt(e.to),r=t.length-1;r>=0&&t[r].to>i.from?t[r].to=n.to:t.push({from:i.from,to:n.to})}return t}function $h(s,t,e=t.selection.ranges){let i=e.map(r=>Hr(t,r.from).block);if(!i.every(r=>r))return null;let n=e.map((r,o)=>Iu(t,i[o],r.from,r.to));if(s!=2&&!n.every(r=>r))return{changes:t.changes(e.map((r,o)=>n[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(s!=1&&n.some(r=>r)){let r=[];for(let o=0,l;o<n.length;o++)if(l=n[o]){let h=i[o],{open:a,close:f}=l;r.push({from:a.pos-h.open.length,to:a.pos+a.margin},{from:f.pos-f.margin,to:f.pos+h.close.length})}return{changes:r}}return null}function Fu(s,t,e=t.selection.ranges){let i=[],n=-1;for(let{from:r,to:o}of e){let l=i.length,h=1e9;for(let a=r;a<=o;){let f=t.doc.lineAt(a);if(f.from>n&&(r==o||o>f.from)){n=f.from;let c=Hr(t,f.from).line;if(!c)continue;let u=/^\s*/.exec(f.text)[0].length,d=u==f.length,p=f.text.slice(u,u+c.length)==c?u:-1;u<f.text.length&&u<h&&(h=u),i.push({line:f,comment:p,token:c,indent:u,empty:d,single:!1})}a=f.to+1}if(h<1e9)for(let a=l;a<i.length;a++)i[a].indent<i[a].line.text.length&&(i[a].indent=h);i.length==l+1&&(i[l].single=!0)}if(s!=2&&i.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:h,indent:a,empty:f,single:c}of i)(c||!f)&&r.push({from:l.from+a,insert:h+" "});let o=t.changes(r);return{changes:o,selection:t.selection.map(o,1)}}else if(s!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:h}of i)if(l>=0){let a=o.from+l,f=a+h.length;o.text[f-o.from]==" "&&f++,r.push({from:a,to:f})}return{changes:r}}return null}var Ir=kt.define(),Vu=kt.define(),zu=D.define(),Kh=D.define({combine(s){return ce(s,{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)})}});function Hu(s){let t=0;return s.iterChangedRanges((e,i)=>t=i),t}var Uh=ut.define({create(){return Nt.empty},update(s,t){let e=t.state.facet(Kh),i=t.annotation(Ir);if(i){let h=t.docChanged?b.single(Hu(t.changes)):void 0,a=pt.fromTransaction(t,h),f=i.side,c=f==0?s.undone:s.done;return a?c=Wn(c,c.length,e.minDepth,a):c=Yh(c,t.startState.selection),new Nt(f==0?i.rest:c,f==0?c:i.rest)}let n=t.annotation(Vu);if((n=="full"||n=="before")&&(s=s.isolate()),t.annotation(U.addToHistory)===!1)return t.changes.empty?s:s.addMapping(t.changes.desc);let r=pt.fromTransaction(t),o=t.annotation(U.time),l=t.annotation(U.userEvent);return r?s=s.addChanges(r,o,l,e,t):t.selection&&(s=s.addSelection(t.startState.selection,o,l,e.newGroupDelay)),(n=="full"||n=="after")&&(s=s.isolate()),s},toJSON(s){return{done:s.done.map(t=>t.toJSON()),undone:s.undone.map(t=>t.toJSON())}},fromJSON(s){return new Nt(s.done.map(pt.fromJSON),s.undone.map(pt.fromJSON))}});function Gh(s={}){return[Uh,Kh.of(s),T.domEventHandlers({beforeinput(t,e){let i=t.inputType=="historyUndo"?Jh:t.inputType=="historyRedo"?Nr:null;return i?(t.preventDefault(),i(e)):!1}})]}function jn(s,t){return function({state:e,dispatch:i}){if(!t&&e.readOnly)return!1;let n=e.field(Uh,!1);if(!n)return!1;let r=n.pop(s,e,t);return r?(i(r),!0):!1}}var Jh=jn(0,!1),Nr=jn(1,!1),Wu=jn(0,!0),ju=jn(1,!0);var pt=class{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new pt(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(e=this.mapped)===null||e===void 0?void 0:e.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(n=>n.toJSON())}}static fromJSON(t){return new pt(t.changes&&K.fromJSON(t.changes),[],t.mapped&&Ct.fromJSON(t.mapped),t.startSelection&&b.fromJSON(t.startSelection),t.selectionsAfter.map(b.fromJSON))}static fromTransaction(t,e){let i=It;for(let n of t.startState.facet(zu)){let r=n(t);r.length&&(i=i.concat(r))}return!i.length&&t.changes.empty?null:new pt(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,It)}static selection(t){return new pt(void 0,It,void 0,void 0,t)}};function Wn(s,t,e,i){let n=t+1>e+20?t-e-1:0,r=s.slice(n,t);return r.push(i),r}function qu(s,t){let e=[],i=!1;return s.iterChangedRanges((n,r)=>e.push(n,r)),t.iterChangedRanges((n,r,o,l)=>{for(let h=0;h<e.length;){let a=e[h++],f=e[h++];l>=a&&o<=f&&(i=!0)}}),i}function $u(s,t){return s.ranges.length==t.ranges.length&&s.ranges.filter((e,i)=>e.empty!=t.ranges[i].empty).length===0}function _h(s,t){return s.length?t.length?s.concat(t):s:t}var It=[],Ku=200;function Yh(s,t){if(s.length){let e=s[s.length-1],i=e.selectionsAfter.slice(Math.max(0,e.selectionsAfter.length-Ku));return i.length&&i[i.length-1].eq(t)?s:(i.push(t),Wn(s,s.length-1,1e9,e.setSelAfter(i)))}else return[pt.selection([t])]}function Uu(s){let t=s[s.length-1],e=s.slice();return e[s.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),e}function Lr(s,t){if(!s.length)return s;let e=s.length,i=It;for(;e;){let n=Gu(s[e-1],t,i);if(n.changes&&!n.changes.empty||n.effects.length){let r=s.slice(0,e);return r[e-1]=n,r}else t=n.mapped,e--,i=n.selectionsAfter}return i.length?[pt.selection(i)]:It}function Gu(s,t,e){let i=_h(s.selectionsAfter.length?s.selectionsAfter.map(l=>l.map(t)):It,e);if(!s.changes)return pt.selection(i);let n=s.changes.map(t),r=t.mapDesc(s.changes,!0),o=s.mapped?s.mapped.composeDesc(r):r;return new pt(n,I.mapEffects(s.effects,t),o,s.startSelection.map(r),i)}var Ju=/^(input\.type|delete)($|\.)/,Nt=class{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 Nt(this.done,this.undone):this}addChanges(t,e,i,n,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!i||Ju.test(i))&&(!l.selectionsAfter.length&&e-this.prevTime<n.newGroupDelay&&n.joinToEvent(r,qu(l.changes,t.changes))||i=="input.type.compose")?o=Wn(o,o.length-1,n.minDepth,new pt(t.changes.compose(l.changes),_h(t.effects,l.effects),l.mapped,l.startSelection,It)):o=Wn(o,o.length,n.minDepth,t),new Nt(o,It,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:It;return r.length>0&&e-this.prevTime<n&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&$u(r[r.length-1],t)?this:new Nt(Yh(this.done,t),this.undone,e,i)}addMapping(t){return new Nt(Lr(this.done,t),Lr(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=t==0?this.done:this.undone;if(n.length==0)return null;let r=n[n.length-1];if(i&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:Ir.of({side:t,rest:Uu(n)}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let o=n.length==1?It:n.slice(0,n.length-1);return r.mapped&&(o=Lr(o,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:Ir.of({side:t,rest:o}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};Nt.empty=new Nt(It,It);var Xh=[{key:"Mod-z",run:Jh,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Nr,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Nr,preventDefault:!0},{key:"Mod-u",run:Wu,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ju,preventDefault:!0}];function di(s,t){return b.create(s.ranges.map(t),s.mainIndex)}function Qt(s,t){return s.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Wt({state:s,dispatch:t},e){let i=di(s.selection,e);return i.eq(s.selection)?!1:(t(Qt(s,i)),!0)}function qn(s,t){return b.cursor(t?s.to:s.from)}function Zh(s,t){return Wt(s,e=>e.empty?s.moveByChar(e,t):qn(e,t))}function mt(s){return s.textDirectionAt(s.state.selection.main.head)==J.LTR}var Qh=s=>Zh(s,!mt(s)),ta=s=>Zh(s,mt(s));function ea(s,t){return Wt(s,e=>e.empty?s.moveByGroup(e,t):qn(e,t))}var _u=s=>ea(s,!mt(s)),Yu=s=>ea(s,mt(s));function Xu(s,t,e){if(t.type.prop(e))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(s.sliceDoc(t.from,t.to)))||t.firstChild}function $n(s,t,e){let i=ht(s).resolveInner(t.head),n=e?O.closedBy:O.openedBy;for(let h=t.head;;){let a=e?i.childAfter(h):i.childBefore(h);if(!a)break;Xu(s,a,n)?i=a:h=e?a.to:a.from}let r=i.type.prop(n),o,l;return r&&(o=e?Ve(s,i.from,1):Ve(s,i.to,-1))&&o.matched?l=e?o.end.to:o.end.from:l=e?i.to:i.from,b.cursor(l,e?-1:1)}var Zu=s=>Wt(s,t=>$n(s.state,t,!mt(s))),Qu=s=>Wt(s,t=>$n(s.state,t,mt(s)));function ia(s,t){return Wt(s,e=>{if(!e.empty)return qn(e,t);let i=s.moveVertically(e,t);return i.head!=e.head?i:s.moveToLineBoundary(e,t)})}var na=s=>ia(s,!1),sa=s=>ia(s,!0);function ra(s){let t=s.scrollDOM.clientHeight<s.scrollDOM.scrollHeight-2,e=0,i=0,n;if(t){for(let r of s.state.facet(T.scrollMargins)){let o=r(s);o!=null&&o.top&&(e=Math.max(o==null?void 0:o.top,e)),o!=null&&o.bottom&&(i=Math.max(o==null?void 0:o.bottom,i))}n=s.scrollDOM.clientHeight-e-i}else n=(s.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:e,marginBottom:i,selfScroll:t,height:Math.max(s.defaultLineHeight,n-5)}}function oa(s,t){let e=ra(s),{state:i}=s,n=di(i.selection,o=>o.empty?s.moveVertically(o,t,e.height):qn(o,t));if(n.eq(i.selection))return!1;let r;if(e.selfScroll){let o=s.coordsAtPos(i.selection.main.head),l=s.scrollDOM.getBoundingClientRect(),h=l.top+e.marginTop,a=l.bottom-e.marginBottom;o&&o.top>h&&o.bottom<a&&(r=T.scrollIntoView(n.main.head,{y:"start",yMargin:o.top-h}))}return s.dispatch(Qt(i,n),{effects:r}),!0}var Fh=s=>oa(s,!1),Fr=s=>oa(s,!0);function ve(s,t,e){let i=s.lineBlockAt(t.head),n=s.moveToLineBoundary(t,e);if(n.head==t.head&&n.head!=(e?i.to:i.from)&&(n=s.moveToLineBoundary(t,e,!1)),!e&&n.head==i.from&&i.length){let r=/^\s*/.exec(s.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&t.head!=i.from+r&&(n=b.cursor(i.from+r))}return n}var td=s=>Wt(s,t=>ve(s,t,!0)),ed=s=>Wt(s,t=>ve(s,t,!1)),id=s=>Wt(s,t=>ve(s,t,!mt(s))),nd=s=>Wt(s,t=>ve(s,t,mt(s))),sd=s=>Wt(s,t=>b.cursor(s.lineBlockAt(t.head).from,1)),rd=s=>Wt(s,t=>b.cursor(s.lineBlockAt(t.head).to,-1));function od(s,t,e){let i=!1,n=di(s.selection,r=>{let o=Ve(s,r.head,-1)||Ve(s,r.head,1)||r.head>0&&Ve(s,r.head-1,1)||r.head<s.doc.length&&Ve(s,r.head+1,-1);if(!o||!o.end)return r;i=!0;let l=o.start.from==r.head?o.end.to:o.end.from;return e?b.range(r.anchor,l):b.cursor(l)});return i?(t(Qt(s,n)),!0):!1}var ld=({state:s,dispatch:t})=>od(s,t,!1);function Ft(s,t){let e=di(s.state.selection,i=>{let n=t(i);return b.range(i.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return e.eq(s.state.selection)?!1:(s.dispatch(Qt(s.state,e)),!0)}function la(s,t){return Ft(s,e=>s.moveByChar(e,t))}var ha=s=>la(s,!mt(s)),aa=s=>la(s,mt(s));function fa(s,t){return Ft(s,e=>s.moveByGroup(e,t))}var hd=s=>fa(s,!mt(s)),ad=s=>fa(s,mt(s));var fd=s=>Ft(s,t=>$n(s.state,t,!mt(s))),cd=s=>Ft(s,t=>$n(s.state,t,mt(s)));function ca(s,t){return Ft(s,e=>s.moveVertically(e,t))}var ua=s=>ca(s,!1),da=s=>ca(s,!0);function pa(s,t){return Ft(s,e=>s.moveVertically(e,t,ra(s).height))}var Vh=s=>pa(s,!1),zh=s=>pa(s,!0),ud=s=>Ft(s,t=>ve(s,t,!0)),dd=s=>Ft(s,t=>ve(s,t,!1)),pd=s=>Ft(s,t=>ve(s,t,!mt(s))),md=s=>Ft(s,t=>ve(s,t,mt(s))),gd=s=>Ft(s,t=>b.cursor(s.lineBlockAt(t.head).from)),yd=s=>Ft(s,t=>b.cursor(s.lineBlockAt(t.head).to)),Hh=({state:s,dispatch:t})=>(t(Qt(s,{anchor:0})),!0),Wh=({state:s,dispatch:t})=>(t(Qt(s,{anchor:s.doc.length})),!0),jh=({state:s,dispatch:t})=>(t(Qt(s,{anchor:s.selection.main.anchor,head:0})),!0),qh=({state:s,dispatch:t})=>(t(Qt(s,{anchor:s.selection.main.anchor,head:s.doc.length})),!0),bd=({state:s,dispatch:t})=>(t(s.update({selection:{anchor:0,head:s.doc.length},userEvent:"select"})),!0),wd=({state:s,dispatch:t})=>{let e=Un(s).map(({from:i,to:n})=>b.range(i,Math.min(n+1,s.doc.length)));return t(s.update({selection:b.create(e),userEvent:"select"})),!0},xd=({state:s,dispatch:t})=>{let e=di(s.selection,i=>{var n;let r=ht(s).resolveInner(i.head,1);for(;!(r.from<i.from&&r.to>=i.to||r.to>i.to&&r.from<=i.from||!(!((n=r.parent)===null||n===void 0)&&n.parent));)r=r.parent;return b.range(r.to,r.from)});return t(Qt(s,e)),!0},kd=({state:s,dispatch:t})=>{let e=s.selection,i=null;return e.ranges.length>1?i=b.create([e.main]):e.main.empty||(i=b.create([b.cursor(e.main.head)])),i?(t(Qt(s,i)),!0):!1};function Kn(s,t){if(s.state.readOnly)return!1;let e="delete.selection",{state:i}=s,n=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let h=t(o);h<o?(e="delete.backward",h=Hn(s,h,!1)):h>o&&(e="delete.forward",h=Hn(s,h,!0)),o=Math.min(o,h),l=Math.max(l,h)}else o=Hn(s,o,!1),l=Hn(s,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:b.cursor(o)}});return n.changes.empty?!1:(s.dispatch(i.update(n,{scrollIntoView:!0,userEvent:e,effects:e=="delete.selection"?T.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Hn(s,t,e){if(s instanceof T)for(let i of s.state.facet(T.atomicRanges).map(n=>n(s)))i.between(t,t,(n,r)=>{n<t&&r>t&&(t=e?r:n)});return t}var ma=(s,t)=>Kn(s,e=>{let{state:i}=s,n=i.doc.lineAt(e),r,o;if(!t&&e>n.from&&e<n.from+200&&!/[^ \t]/.test(r=n.text.slice(0,e-n.from))){if(r[r.length-1]==" ")return e-1;let l=Be(r,i.tabSize),h=l%zi(i)||zi(i);for(let a=0;a<h&&r[r.length-1-a]==" ";a++)e--;o=e}else o=wt(n.text,e-n.from,t,t)+n.from,o==e&&n.number!=(t?i.doc.lines:1)&&(o+=t?1:-1);return o}),Vr=s=>ma(s,!1),ga=s=>ma(s,!0),ya=(s,t)=>Kn(s,e=>{let i=e,{state:n}=s,r=n.doc.lineAt(i),o=n.charCategorizer(i);for(let l=null;;){if(i==(t?r.to:r.from)){i==e&&r.number!=(t?n.doc.lines:1)&&(i+=t?1:-1);break}let h=wt(r.text,i-r.from,t)+r.from,a=r.text.slice(Math.min(i,h)-r.from,Math.max(i,h)-r.from),f=o(a);if(l!=null&&f!=l)break;(a!=" "||i!=e)&&(l=f),i=h}return i}),ba=s=>ya(s,!1),vd=s=>ya(s,!0),wa=s=>Kn(s,t=>{let e=s.lineBlockAt(t).to;return t<e?e:Math.min(s.state.doc.length,t+1)}),Sd=s=>Kn(s,t=>{let e=s.lineBlockAt(t).from;return t>e?e:Math.max(0,t-1)});var Cd=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:B.of(["",""])},range:b.cursor(i.from)}));return t(s.update(e,{scrollIntoView:!0,userEvent:"input"})),!0},Ad=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=s.changeByRange(i=>{if(!i.empty||i.from==0||i.from==s.doc.length)return{range:i};let n=i.from,r=s.doc.lineAt(n),o=n==r.from?n-1:wt(r.text,n-r.from,!1)+r.from,l=n==r.to?n+1:wt(r.text,n-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:s.doc.slice(n,l).append(s.doc.slice(o,n))},range:b.cursor(l)}});return e.changes.empty?!1:(t(s.update(e,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Un(s){let t=[],e=-1;for(let i of s.selection.ranges){let n=s.doc.lineAt(i.from),r=s.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=s.doc.lineAt(i.to-1)),e>=n.number){let o=t[t.length-1];o.to=r.to,o.ranges.push(i)}else t.push({from:n.from,to:r.to,ranges:[i]});e=r.number+1}return t}function xa(s,t,e){if(s.readOnly)return!1;let i=[],n=[];for(let r of Un(s)){if(e?r.to==s.doc.length:r.from==0)continue;let o=s.doc.lineAt(e?r.to+1:r.from-1),l=o.length+1;if(e){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+s.lineBreak});for(let h of r.ranges)n.push(b.range(Math.min(s.doc.length,h.anchor+l),Math.min(s.doc.length,h.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:s.lineBreak+o.text});for(let h of r.ranges)n.push(b.range(h.anchor-l,h.head-l))}}return i.length?(t(s.update({changes:i,scrollIntoView:!0,selection:b.create(n,s.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Md=({state:s,dispatch:t})=>xa(s,t,!1),Dd=({state:s,dispatch:t})=>xa(s,t,!0);function ka(s,t,e){if(s.readOnly)return!1;let i=[];for(let n of Un(s))e?i.push({from:n.from,insert:s.doc.slice(n.from,n.to)+s.lineBreak}):i.push({from:n.to,insert:s.lineBreak+s.doc.slice(n.from,n.to)});return t(s.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Td=({state:s,dispatch:t})=>ka(s,t,!1),Od=({state:s,dispatch:t})=>ka(s,t,!0),Pd=s=>{if(s.state.readOnly)return!1;let{state:t}=s,e=t.changes(Un(t).map(({from:n,to:r})=>(n>0?n--:r<t.doc.length&&r++,{from:n,to:r}))),i=di(t.selection,n=>s.moveVertically(n,!0)).map(e);return s.dispatch({changes:e,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Bd(s,t){if(/\(\)|\[\]|\{\}/.test(s.sliceDoc(t-1,t+1)))return{from:t,to:t};let e=ht(s).resolveInner(t),i=e.childBefore(t),n=e.childAfter(t),r;return i&&n&&i.to<=t&&n.from>=t&&(r=i.type.prop(O.closedBy))&&r.indexOf(n.name)>-1&&s.doc.lineAt(i.to).from==s.doc.lineAt(n.from).from?{from:i.to,to:n.from}:null}var Rd=va(!1),Ed=va(!0);function va(s){return({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange(n=>{let{from:r,to:o}=n,l=t.doc.lineAt(r),h=!s&&r==o&&Bd(t,r);s&&(r=o=(o<=l.to?l:t.doc.lineAt(o)).to);let a=new Fe(t,{simulateBreak:r,simulateDoubleBreak:!!h}),f=Sr(a,r);for(f==null&&(f=/^\s*/.exec(t.doc.lineAt(r).text)[0].length);o<l.to&&/\s/.test(l.text[o-l.from]);)o++;h?{from:r,to:o}=h:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let c=["",Hi(t,f)];return h&&c.push(Hi(t,a.lineIndent(l.from,-1))),{changes:{from:r,to:o,insert:B.of(c)},range:b.cursor(r+1+c[1].length)}});return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function Wr(s,t){let e=-1;return s.changeByRange(i=>{let n=[];for(let o=i.from;o<=i.to;){let l=s.doc.lineAt(o);l.number>e&&(i.empty||i.to>l.from)&&(t(l,n,i),e=l.number),o=l.to+1}let r=s.changes(n);return{changes:n,range:b.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}var Ld=({state:s,dispatch:t})=>{if(s.readOnly)return!1;let e=Object.create(null),i=new Fe(s,{overrideIndentation:r=>{let o=e[r];return o==null?-1:o}}),n=Wr(s,(r,o,l)=>{let h=Sr(i,r.from);if(h==null)return;/\S/.test(r.text)||(h=0);let a=/^\s*/.exec(r.text)[0],f=Hi(s,h);(a!=f||l.from<r.from+a.length)&&(e[r.from]=h,o.push({from:r.from,to:r.from+a.length,insert:f}))});return n.changes.empty||t(s.update(n,{userEvent:"indent"})),!0},Id=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Wr(s,(e,i)=>{i.push({from:e.from,insert:s.facet(Vi)})}),{userEvent:"input.indent"})),!0),Nd=({state:s,dispatch:t})=>s.readOnly?!1:(t(s.update(Wr(s,(e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Be(n,s.tabSize),o=0,l=Hi(s,Math.max(0,r-zi(s)));for(;o<n.length&&o<l.length&&n.charCodeAt(o)==l.charCodeAt(o);)o++;i.push({from:e.from+o,to:e.from+n.length,insert:l.slice(o)})}),{userEvent:"delete.dedent"})),!0);var Fd=[{key:"Ctrl-b",run:Qh,shift:ha,preventDefault:!0},{key:"Ctrl-f",run:ta,shift:aa},{key:"Ctrl-p",run:na,shift:ua},{key:"Ctrl-n",run:sa,shift:da},{key:"Ctrl-a",run:sd,shift:gd},{key:"Ctrl-e",run:rd,shift:yd},{key:"Ctrl-d",run:ga},{key:"Ctrl-h",run:Vr},{key:"Ctrl-k",run:wa},{key:"Ctrl-Alt-h",run:ba},{key:"Ctrl-o",run:Cd},{key:"Ctrl-t",run:Ad},{key:"Ctrl-v",run:Fr}],Vd=[{key:"ArrowLeft",run:Qh,shift:ha,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:_u,shift:hd,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:id,shift:pd,preventDefault:!0},{key:"ArrowRight",run:ta,shift:aa,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Yu,shift:ad,preventDefault:!0},{mac:"Cmd-ArrowRight",run:nd,shift:md,preventDefault:!0},{key:"ArrowUp",run:na,shift:ua,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Hh,shift:jh},{mac:"Ctrl-ArrowUp",run:Fh,shift:Vh},{key:"ArrowDown",run:sa,shift:da,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Wh,shift:qh},{mac:"Ctrl-ArrowDown",run:Fr,shift:zh},{key:"PageUp",run:Fh,shift:Vh},{key:"PageDown",run:Fr,shift:zh},{key:"Home",run:ed,shift:dd,preventDefault:!0},{key:"Mod-Home",run:Hh,shift:jh},{key:"End",run:td,shift:ud,preventDefault:!0},{key:"Mod-End",run:Wh,shift:qh},{key:"Enter",run:Rd},{key:"Mod-a",run:bd},{key:"Backspace",run:Vr,shift:Vr},{key:"Delete",run:ga},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ba},{key:"Mod-Delete",mac:"Alt-Delete",run:vd},{mac:"Mod-Backspace",run:Sd},{mac:"Mod-Delete",run:wa}].concat(Fd.map(s=>({mac:s.key,run:s.run,shift:s.shift}))),Sa=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Zu,shift:fd},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Qu,shift:cd},{key:"Alt-ArrowUp",run:Md},{key:"Shift-Alt-ArrowUp",run:Td},{key:"Alt-ArrowDown",run:Dd},{key:"Shift-Alt-ArrowDown",run:Od},{key:"Escape",run:kd},{key:"Mod-Enter",run:Ed},{key:"Alt-l",mac:"Ctrl-l",run:wd},{key:"Mod-i",run:xd,preventDefault:!0},{key:"Mod-[",run:Nd},{key:"Mod-]",run:Id},{key:"Mod-Alt-\\",run:Ld},{key:"Shift-Mod-k",run:Pd},{key:"Shift-Mod-\\",run:ld},{key:"Mod-/",run:Bu},{key:"Alt-A",run:Eu}].concat(Vd);var mi=class{constructor(t,e,i,n,r,o,l,h,a,f=0,c){this.p=t,this.stack=e,this.state=i,this.reducePos=n,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=h,this.curContext=a,this.lookAhead=f,this.parent=c}toString(){return`[${this.stack.filter((t,e)=>e%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,e,i=0){let n=t.parser.context;return new mi(t,[],e,i,i,0,[],0,n?new Gn(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,e){this.stack.push(this.state,e,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var e;let i=t>>19,n=t&65535,{parser:r}=this.p,o=r.dynamicPrecedence(n);if(o&&(this.score+=o),i==0){this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,4,!0),this.reduceContext(n,this.reducePos);return}let l=this.stack.length-(i-1)*3-(t&262144?6:0),h=l?this.stack[l-2]:this.p.ranges[0].from,a=this.reducePos-h;a>=2e3&&!(!((e=this.p.parser.nodeSet.types[n])===null||e===void 0)&&e.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=a):this.p.lastBigReductionSize<a&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=a));let f=l?this.stack[l-1]:0,c=this.bufferBase+this.buffer.length-f;if(n<r.minRepeatTerm||t&131072){let u=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,h,u,c+4,!0)}if(t&262144)this.state=this.stack[l];else{let u=this.stack[l-3];this.state=r.getGoto(u,n,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(n,h)}storeNode(t,e,i,n=4,r=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,l=this.buffer.length;if(l==0&&o.parent&&(l=o.bufferBase-o.parent.bufferBase,o=o.parent),l>0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(e==i)return;if(o.buffer[l-2]>=e){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(t,e,i,n);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,n>4&&(n-=4);this.buffer[o]=t,this.buffer[o+1]=e,this.buffer[o+2]=i,this.buffer[o+3]=n}}shift(t,e,i){let n=this.pos;if(t&131072)this.pushState(t&65535,this.pos);else if(t&262144)this.pos=i,this.shiftContext(e,n),e<=this.p.parser.maxNode&&this.buffer.push(e,n,i,4);else{let r=t,{parser:o}=this.p;(i>this.pos||e<=o.maxNode)&&(this.pos=i,o.stateFlag(r,1)||(this.reducePos=i)),this.pushState(r,n),this.shiftContext(e,n),e<=o.maxNode&&this.buffer.push(e,n,i,4)}}apply(t,e,i){t&65536?this.reduce(t):this.shift(t,e,i)}useNode(t,e){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=t)&&(this.p.reused.push(t),i++);let n=this.pos;this.reducePos=this.pos=n+t.length,this.pushState(e,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,e=t.buffer.length;for(;e>0&&t.buffer[e-2]>t.reducePos;)e-=4;let i=t.buffer.slice(e),n=t.bufferBase+e;for(;t&&n==t.bufferBase;)t=t.parent;return new mi(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,t)}recoverByDelete(t,e){let i=t<=this.p.parser.maxNode;i&&this.storeNode(t,this.pos,e,4),this.storeNode(0,this.pos,e,i?8:4),this.pos=this.reducePos=e,this.score-=190}canShift(t){for(let e=new qr(this);;){let i=this.p.parser.stateSlot(e.state,4)||this.p.parser.hasAction(e.state,t);if(i==0)return!1;if(!(i&65536))return!0;e.reduce(i)}}recoverByInsert(t){if(this.stack.length>=300)return[];let e=this.p.parser.nextStates(this.state);if(e.length>4<<1||this.stack.length>=120){let n=[];for(let r=0,o;r<e.length;r+=2)(o=e[r+1])!=this.state&&this.p.parser.hasAction(o,t)&&n.push(e[r],o);if(this.stack.length<120)for(let r=0;n.length<4<<1&&r<e.length;r+=2){let o=e[r+1];n.some((l,h)=>h&1&&l==o)||n.push(e[r],o)}e=n}let i=[];for(let n=0;n<e.length&&i.length<4;n+=2){let r=e[n+1];if(r==this.state)continue;let o=this.split();o.pushState(r,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(e[n],this.pos),o.score-=200,i.push(o)}return i}forceReduce(){let t=this.p.parser.stateSlot(this.state,5);if(!(t&65536))return!1;let{parser:e}=this.p;if(!e.validAction(this.state,t)){let i=t>>19,n=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],n,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let e=0;e<this.stack.length;e+=3)if(this.stack[e]!=t.stack[e])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(e)))}reduceContext(t,e){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(e)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.reducePos,this.reducePos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.reducePos,this.reducePos,-4)}updateContext(t){if(t!=this.curContext.context){let e=new Gn(this.curContext.tracker,t);e.hash!=this.curContext.hash&&this.emitContext(),this.curContext=e}}setLookAhead(t){t>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=t)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},Gn=class{constructor(t,e){this.tracker=t,this.context=e,this.hash=t.strict?t.hash(e):0}},Ca;(function(s){s[s.Insert=200]="Insert",s[s.Delete=190]="Delete",s[s.Reduce=100]="Reduce",s[s.MaxNext=4]="MaxNext",s[s.MaxInsertStackDepth=300]="MaxInsertStackDepth",s[s.DampenInsertStackDepth=120]="DampenInsertStackDepth",s[s.MinBigReduction=2e3]="MinBigReduction"})(Ca||(Ca={}));var qr=class{constructor(t){this.start=t,this.state=t.state,this.stack=t.stack,this.base=this.stack.length}reduce(t){let e=t&65535,i=t>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],e,!0);this.state=n}},gi=class{constructor(t,e,i){this.stack=t,this.pos=e,this.index=i,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,e=t.bufferBase+t.buffer.length){return new gi(t,e,e-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new gi(this.stack,this.pos,this.index)}};function ji(s,t=Uint16Array){if(typeof s!="string")return s;let e=null;for(let i=0,n=0;i<s.length;){let r=0;for(;;){let o=s.charCodeAt(i++),l=!1;if(o==126){r=65535;break}o>=92&&o--,o>=34&&o--;let h=o-32;if(h>=46&&(h-=46,l=!0),r+=h,l)break;r*=46}e?e[n++]=r:e=new t(r)}return e}var pi=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Aa=new pi,$r=class{constructor(t,e){this.input=t,this.ranges=e,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Aa,this.rangeIndex=0,this.pos=this.chunkPos=e[0].from,this.range=e[0],this.end=e[e.length-1].to,this.readNext()}resolveOffset(t,e){let i=this.range,n=this.rangeIndex,r=this.pos+t;for(;r<i.from;){if(!n)return null;let o=this.ranges[--n];r-=i.from-o.to,i=o}for(;e<0?r>i.to:r>=i.to;){if(n==this.ranges.length-1)return null;let o=this.ranges[++n];r+=o.from-i.to,i=o}return r}clipPos(t){if(t>=this.range.from&&t<this.range.to)return t;for(let e of this.ranges)if(e.to>t)return Math.max(t,e.from);return this.end}peek(t){let e=this.chunkOff+t,i,n;if(e>=0&&e<this.chunk.length)i=this.pos+t,n=this.chunk.charCodeAt(e);else{let r=this.resolveOffset(t,1);if(r==null)return-1;if(i=r,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)n=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,l=this.range;for(;l.to<=i;)l=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),n=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),n}acceptToken(t,e=0){let i=e?this.resolveOffset(e,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=t,this.token.end=i}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:t,chunkPos:e}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=t,this.chunk2Pos=e,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let t=this.input.chunk(this.pos),e=this.pos+t.length;this.chunk=e>this.range.to?t.slice(0,this.range.to-this.pos):t,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(t=1){for(this.chunkOff+=t;this.pos+t>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();t-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=t,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(t,e){if(e?(this.token=e,e.start=t,e.lookAhead=t+1,e.value=e.extended=-1):this.token=Aa,this.pos!=t){if(this.pos=t,t==this.end)return this.setDone(),this;for(;t<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;t>=this.range.to;)this.range=this.ranges[++this.rangeIndex];t>=this.chunkPos&&t<this.chunkPos+this.chunk.length?this.chunkOff=t-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(t,e){if(t>=this.chunkPos&&e<=this.chunkPos+this.chunk.length)return this.chunk.slice(t-this.chunkPos,e-this.chunkPos);if(t>=this.chunk2Pos&&e<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(t-this.chunk2Pos,e-this.chunk2Pos);if(t>=this.range.from&&e<=this.range.to)return this.input.read(t,e);let i="";for(let n of this.ranges){if(n.from>=e)break;n.to>t&&(i+=this.input.read(Math.max(n.from,t),Math.min(n.to,e)))}return i}},Se=class{constructor(t,e){this.data=t,this.id=e}token(t,e){let{parser:i}=e.p;Ra(this.data,t,e,this.id,i.data,i.tokenPrecTable)}};Se.prototype.contextual=Se.prototype.fallback=Se.prototype.extend=!1;var Kr=class{constructor(t,e,i){this.precTable=e,this.elseToken=i,this.data=typeof t=="string"?ji(t):t}token(t,e){let i=t.pos,n;for(;n=t.pos,Ra(this.data,t,e,0,this.data,this.precTable),!(t.token.value>-1);){if(this.elseToken==null)return;if(t.next<0)break;t.advance(),t.reset(n+1,t.token)}n>i&&(t.reset(i,t.token),t.acceptToken(this.elseToken,n-i))}};Kr.prototype.contextual=Se.prototype.fallback=Se.prototype.extend=!1;function Ra(s,t,e,i,n,r){let o=0,l=1<<i,{dialect:h}=e.p.parser;t:for(;l&s[o];){let a=s[o+1];for(let d=o+3;d<a;d+=2)if((s[d+1]&l)>0){let p=s[d];if(h.allows(p)&&(t.token.value==-1||t.token.value==p||Hd(p,t.token.value,n,r))){t.acceptToken(p);break}}let f=t.next,c=0,u=s[o+2];if(t.next<0&&u>c&&s[a+u*3-3]==65535&&s[a+u*3-3]==65535){o=s[a+u*3-1];continue t}for(;c<u;){let d=c+u>>1,p=a+d+(d<<1),m=s[p],g=s[p+1]||65536;if(f<m)u=d;else if(f>=g)c=d+1;else{o=s[p+2],t.advance();continue t}}break}}function Ma(s,t,e){for(let i=t,n;(n=s[i])!=65535;i++)if(n==e)return i-t;return-1}function Hd(s,t,e,i){let n=Ma(e,i,t);return n<0||Ma(e,i,s)<n}var jt=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),jr=null,Da;(function(s){s[s.Margin=25]="Margin"})(Da||(Da={}));function Ta(s,t,e){let i=s.cursor(et.IncludeAnonymous);for(i.moveTo(t);;)if(!(e<0?i.childBefore(t):i.childAfter(t)))for(;;){if((e<0?i.to<t:i.from>t)&&!i.type.isError)return e<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(s.length,Math.max(i.from+1,t+25));if(e<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return e<0?0:s.length}}var Ur=class{constructor(t,e){this.fragments=t,this.nodeSet=e,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let t=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(t){for(this.safeFrom=t.openStart?Ta(t.tree,t.from+t.offset,1)-t.offset:t.from,this.safeTo=t.openEnd?Ta(t.tree,t.to+t.offset,-1)-t.offset:t.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(t.tree),this.start.push(-t.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(t){if(t<this.nextStart)return null;for(;this.fragment&&this.safeTo<=t;)this.nextFragment();if(!this.fragment)return null;for(;;){let e=this.trees.length-1;if(e<0)return this.nextFragment(),null;let i=this.trees[e],n=this.index[e];if(n==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=i.children[n],o=this.start[e]+i.positions[n];if(o>t)return this.nextStart=o,null;if(r instanceof q){if(o==t){if(o<this.safeFrom)return null;let l=o+r.length;if(l<=this.safeTo){let h=r.prop(O.lookAhead);if(!h||l+h<this.fragment.to)return r}}this.index[e]++,o+r.length>=Math.max(this.safeFrom,t)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[e]++,this.nextStart=o+r.length}}},Gr=class{constructor(t,e){this.stream=e,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=t.tokenizers.map(i=>new pi)}getActions(t){let e=0,i=null,{parser:n}=t.p,{tokenizers:r}=n,o=n.stateSlot(t.state,3),l=t.curContext?t.curContext.hash:0,h=0;for(let a=0;a<r.length;a++){if(!(1<<a&o))continue;let f=r[a],c=this.tokens[a];if(!(i&&!f.fallback)&&((f.contextual||c.start!=t.pos||c.mask!=o||c.context!=l)&&(this.updateCachedToken(c,f,t),c.mask=o,c.context=l),c.lookAhead>c.end+25&&(h=Math.max(c.lookAhead,h)),c.value!=0)){let u=e;if(c.extended>-1&&(e=this.addActions(t,c.extended,c.end,e)),e=this.addActions(t,c.value,c.end,e),!f.extend&&(i=c,e>u))break}}for(;this.actions.length>e;)this.actions.pop();return h&&t.setLookAhead(h),!i&&t.pos==this.stream.end&&(i=new pi,i.value=t.p.parser.eofTerm,i.start=i.end=t.pos,e=this.addActions(t,i.value,i.end,e)),this.mainToken=i,this.actions}getMainToken(t){if(this.mainToken)return this.mainToken;let e=new pi,{pos:i,p:n}=t;return e.start=i,e.end=Math.min(i+1,n.stream.end),e.value=i==n.stream.end?n.parser.eofTerm:0,e}updateCachedToken(t,e,i){let n=this.stream.clipPos(i.pos);if(e.token(this.stream.reset(n,t),i),t.value>-1){let{parser:r}=i.p;for(let o=0;o<r.specialized.length;o++)if(r.specialized[o]==t.value){let l=r.specializers[o](this.stream.read(t.start,t.end),i);if(l>=0&&i.p.parser.dialect.allows(l>>1)){l&1?t.extended=l>>1:t.value=l>>1;break}}}else t.value=0,t.end=this.stream.clipPos(n+1)}putAction(t,e,i,n){for(let r=0;r<n;r+=3)if(this.actions[r]==t)return n;return this.actions[n++]=t,this.actions[n++]=e,this.actions[n++]=i,n}addActions(t,e,i,n){let{state:r}=t,{parser:o}=t.p,{data:l}=o;for(let h=0;h<2;h++)for(let a=o.stateSlot(r,h?2:1);;a+=3){if(l[a]==65535)if(l[a+1]==1)a=le(l,a+2);else{n==0&&l[a+1]==2&&(n=this.putAction(le(l,a+2),e,i,n));break}l[a]==e&&(n=this.putAction(le(l,a+1),e,i,n))}return n}},Oa;(function(s){s[s.Distance=5]="Distance",s[s.MaxRemainingPerStep=3]="MaxRemainingPerStep",s[s.MinBufferLengthPrune=500]="MinBufferLengthPrune",s[s.ForceReduceLimit=10]="ForceReduceLimit",s[s.CutDepth=15e3]="CutDepth",s[s.CutTo=9e3]="CutTo",s[s.MaxLeftAssociativeReductionCount=300]="MaxLeftAssociativeReductionCount",s[s.MaxStackCount=12]="MaxStackCount"})(Oa||(Oa={}));var Jr=class{constructor(t,e,i,n){this.parser=t,this.input=e,this.ranges=n,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new $r(e,n),this.tokens=new Gr(t,this.stream),this.topTerm=t.top[1];let{from:r}=n[0];this.stacks=[mi.start(this,t.top[0],r)],this.fragments=i.length&&this.stream.end-r>t.bufferLength*4?new Ur(i,t.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let t=this.stacks,e=this.minStackPos,i=this.stacks=[],n,r;if(this.bigReductionCount>300&&t.length==1){let[o]=t;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<t.length;o++){let l=t[o];for(;;){if(this.tokens.mainToken=null,l.pos>e)i.push(l);else{if(this.advanceStack(l,i,t))continue;{n||(n=[],r=[]),n.push(l);let h=this.tokens.getMainToken(l);r.push(h.value,h.end)}}break}}if(!i.length){let o=n&&Wd(n);if(o)return this.stackToTree(o);if(this.parser.strict)throw jt&&n&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+e);this.recovering||(this.recovering=5)}if(this.recovering&&n){let o=this.stoppedAt!=null&&n[0].pos>this.stoppedAt?n[0]:this.runRecovery(n,r,i);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,h)=>h.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>e)&&this.recovering--}else if(i.length>1){t:for(let o=0;o<i.length-1;o++){let l=i[o];for(let h=o+1;h<i.length;h++){let a=i[h];if(l.sameState(a)||l.buffer.length>500&&a.buffer.length>500)if((l.score-a.score||l.buffer.length-a.buffer.length)>0)i.splice(h--,1);else{i.splice(o--,1);continue t}}}i.length>12&&i.splice(12,i.length-12)}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}advanceStack(t,e,i){let n=t.pos,{parser:r}=this,o=jt?this.stackID(t)+" -> ":"";if(this.stoppedAt!=null&&n>this.stoppedAt)return t.forceReduce()?t:null;if(this.fragments){let a=t.curContext&&t.curContext.tracker.strict,f=a?t.curContext.hash:0;for(let c=this.fragments.nodeAt(n);c;){let u=this.parser.nodeSet.types[c.type.id]==c.type?r.getGoto(t.state,c.type.id):-1;if(u>-1&&c.length&&(!a||(c.prop(O.contextHash)||0)==f))return t.useNode(c,u),jt&&console.log(o+this.stackID(t)+` (via reuse of ${r.getName(c.type.id)})`),!0;if(!(c instanceof q)||c.children.length==0||c.positions[0]>0)break;let d=c.children[0];if(d instanceof q&&c.positions[0]==0)c=d;else break}}let l=r.stateSlot(t.state,4);if(l>0)return t.reduce(l),jt&&console.log(o+this.stackID(t)+` (via always-reduce ${r.getName(l&65535)})`),!0;if(t.stack.length>=15e3)for(;t.stack.length>9e3&&t.forceReduce(););let h=this.tokens.getActions(t);for(let a=0;a<h.length;){let f=h[a++],c=h[a++],u=h[a++],d=a==h.length||!i,p=d?t:t.split();if(p.apply(f,c,u),jt&&console.log(o+this.stackID(p)+` (via ${f&65536?`reduce of ${r.getName(f&65535)}`:"shift"} for ${r.getName(c)} @ ${n}${p==t?"":", split"})`),d)return!0;p.pos>n?e.push(p):i.push(p)}return!1}advanceFully(t,e){let i=t.pos;for(;;){if(!this.advanceStack(t,null,null))return!1;if(t.pos>i)return Pa(t,e),!0}}runRecovery(t,e,i){let n=null,r=!1;for(let o=0;o<t.length;o++){let l=t[o],h=e[o<<1],a=e[(o<<1)+1],f=jt?this.stackID(l)+" -> ":"";if(l.deadEnd&&(r||(r=!0,l.restart(),jt&&console.log(f+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let c=l.split(),u=f;for(let d=0;c.forceReduce()&&d<10&&(jt&&console.log(u+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,i));d++)jt&&(u=this.stackID(c)+" -> ");for(let d of l.recoverByInsert(h))jt&&console.log(f+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>l.pos?(a==l.pos&&(a++,h=0),l.recoverByDelete(h,a),jt&&console.log(f+this.stackID(l)+` (via recover-delete ${this.parser.getName(h)})`),Pa(l,i)):(!n||n.score<l.score)&&(n=l)}return n}stackToTree(t){return t.close(),q.build({buffer:gi.create(t),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:t.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(t){let e=(jr||(jr=new WeakMap)).get(t);return e||jr.set(t,e=String.fromCodePoint(this.nextStackID++)),e+t}};function Pa(s,t){for(let e=0;e<t.length;e++){let i=t[e];if(i.pos==s.pos&&i.sameState(s)){t[e].score<s.score&&(t[e]=s);return}}t.push(s)}var _r=class{constructor(t,e,i){this.source=t,this.flags=e,this.disabled=i}allows(t){return!this.disabled||this.disabled[t]==0}};var We=class extends oi{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let e=t.nodeNames.split(" ");this.minRepeatTerm=e.length;for(let l=0;l<t.repeatNodeCount;l++)e.push("");let i=Object.keys(t.topRules).map(l=>t.topRules[l][1]),n=[];for(let l=0;l<e.length;l++)n.push([]);function r(l,h,a){n[l].push([h,h.deserialize(String(a))])}if(t.nodeProps)for(let l of t.nodeProps){let h=l[0];typeof h=="string"&&(h=O[h]);for(let a=1;a<l.length;){let f=l[a++];if(f>=0)r(f,h,l[a++]);else{let c=l[a+-f];for(let u=-f;u>0;u--)r(l[a++],h,c);a++}}}this.nodeSet=new Le(e.map((l,h)=>nt.define({name:h>=this.minRepeatTerm?void 0:l,id:h,props:n[h],top:i.indexOf(h)>-1,error:h==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(h)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=1024;let o=ji(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(Ba),this.states=ji(t.states,Uint32Array),this.data=ji(t.stateData),this.goto=ji(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(l=>typeof l=="number"?new Se(o,l):l),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,e,i){let n=new Jr(this,t,e,i);for(let r of this.wrappers)n=r(n,t,e,i);return n}getGoto(t,e,i=!1){let n=this.goto;if(e>=n[0])return-1;for(let r=n[e+1];;){let o=n[r++],l=o&1,h=n[r++];if(l&&i)return h;for(let a=r+(o>>1);r<a;r++)if(n[r]==t)return h;if(l)return-1}}hasAction(t,e){let i=this.data;for(let n=0;n<2;n++)for(let r=this.stateSlot(t,n?2:1),o;;r+=3){if((o=i[r])==65535)if(i[r+1]==1)o=i[r=le(i,r+2)];else{if(i[r+1]==2)return le(i,r+2);break}if(o==e||o==0)return le(i,r+1)}return 0}stateSlot(t,e){return this.states[t*6+e]}stateFlag(t,e){return(this.stateSlot(t,0)&e)>0}validAction(t,e){if(e==this.stateSlot(t,4))return!0;for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=le(this.data,i+2);else return!1;if(e==le(this.data,i+1))return!0}}nextStates(t){let e=[];for(let i=this.stateSlot(t,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=le(this.data,i+2);else break;if(!(this.data[i+2]&1)){let n=this.data[i+1];e.some((r,o)=>o&1&&r==n)||e.push(this.data[i],n)}}return e}configure(t){let e=Object.assign(Object.create(We.prototype),this);if(t.props&&(e.nodeSet=this.nodeSet.extend(...t.props)),t.top){let i=this.topRules[t.top];if(!i)throw new RangeError(`Invalid top rule name ${t.top}`);e.top=i}return t.tokenizers&&(e.tokenizers=this.tokenizers.map(i=>{let n=t.tokenizers.find(r=>r.from==i);return n?n.to:i})),t.specializers&&(e.specializers=this.specializers.slice(),e.specializerSpecs=this.specializerSpecs.map((i,n)=>{let r=t.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return e.specializers[n]=Ba(o),o})),t.contextTracker&&(e.context=t.contextTracker),t.dialect&&(e.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(e.strict=t.strict),t.wrap&&(e.wrappers=e.wrappers.concat(t.wrap)),t.bufferLength!=null&&(e.bufferLength=t.bufferLength),e}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let e=this.dynamicPrecedences;return e==null?0:e[t]||0}parseDialect(t){let e=Object.keys(this.dialects),i=e.map(()=>!1);if(t)for(let r of t.split(" ")){let o=e.indexOf(r);o>=0&&(i[o]=!0)}let n=null;for(let r=0;r<e.length;r++)if(!i[r])for(let o=this.dialects[e[r]],l;(l=this.data[o++])!=65535;)(n||(n=new Uint8Array(this.maxTerm+1)))[l]=1;return new _r(t,i,n)}static deserialize(t){return new We(t)}};function le(s,t){return s[t]|s[t+1]<<16}function Wd(s){let t=null;for(let e of s){let i=e.p.stoppedAt;(e.pos==e.p.stream.end||i!=null&&e.pos>i)&&e.p.parser.stateFlag(e.state,2)&&(!t||t.score<e.score)&&(t=e)}return t}function Ba(s){if(s.external){let t=s.extend?1:0;return(e,i)=>s.external(e,i)<<1|t}return s.get}
|
|
11
|
+
//# sourceMappingURL=index.js.map
|