spacetime-studio 0.0.2 → 0.0.3

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.
@@ -0,0 +1,54 @@
1
+ import{n as e}from"../chunks/chunk-mZKhtkdl.js";import{A as t,At as n,Bt as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,Ft as u,Ht as d,It as f,Lt as p,M as m,Mt as h,N as g,Nt as _,O as v,Ot as y,Pt as b,Rt as x,T as S,Tt as C,Ut as w,Vt as T,Wt as E,_t as D,bt as ee,c as O,d as te,f as k,ft as ne,gt as A,ht as j,j as re,k as ie,kt as ae,l as oe,lt as se,mt as ce,n as M,s as le,t as ue,u as de,vt as N,w as fe,xt as pe,yt as me,zt as he}from"../chunks/chunk-D5ho-8Wh.js";import"../chunks/chunk-9U2RGXGQ.js";import{d as ge,f as _e,l as ve,p as ye,u as be}from"../chunks/chunk-CLzc1euR.js";/* empty css *//* empty css */import{n as xe,t as Se}from"../chunks/chunk-CFncNr_j.js";import{i as Ce,n as we,r as Te,t as Ee}from"../chunks/chunk-yx3zcEsC.js";var De=C(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M20 6L9 17l-5-5">`),Oe=C(`<div class="flex h-full flex-col items-center justify-center p-4"><div class="flex items-start gap-3 border border-destructive/30 bg-destructive/10 p-4 text-destructive"><svg xmlns=http://www.w3.org/2000/svg width=18 height=18 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class="mt-0.5 shrink-0"><circle cx=12 cy=12 r=10></circle><line x1=12 y1=8 x2=12 y2=12></line><line x1=12 y1=16 x2=12.01 y2=16></line></svg><div class="min-w-0 flex-1"><p class="font-medium text-sm">Query Error</p><p class="mt-1 break-words font-mono text-sm opacity-90">`),ke=C(`<div class="flex items-center gap-2">`),Ae=C(`<div class="flex h-full items-center justify-center"><div class="flex flex-col items-center gap-3"><div class=relative><div class="size-6 animate-spin border-2 border-border border-t-primary"></div></div><span class="text-muted-foreground text-sm">Executing query...`),je=C(`<div class=h-full><div class="flex h-full flex-col items-center justify-center text-muted-foreground"><svg xmlns=http://www.w3.org/2000/svg width=32 height=32 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round class="mb-3 opacity-40"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg><p class=text-sm>Run a query to see results</p><p class="mt-1 text-xs opacity-60">Press ⌘ + ⏎ or click Run`),Me=C(`<span class="font-mono text-muted-foreground text-xs"><!$><!/> rows`),P=C(`<span class="flex items-center gap-1 text-emerald-500"><!$><!/>Copied`),Ne=C(`<div class="flex h-full flex-col"><div class="flex shrink-0 items-center justify-between border-border border-b bg-muted/20 px-3 py-1.5"><span class="max-w-[50%] cursor-pointer truncate font-mono text-muted-foreground text-xs hover:text-foreground"role=button tabindex=0></span><div class="flex items-center gap-2"></div></div><div class="flex-1 overflow-auto">`),Pe=C(`<span class="size-1.5 rounded-full bg-emerald-500">`),Fe=C(`<span class="flex items-center gap-1.5"><!$><!/><!$><!/>`),Ie=C(`<span class="size-1.5 rounded-full bg-red-500">`),F=C(`<span class="rounded bg-emerald-500/10 px-1.5 py-0.5 font-mono text-[10px] text-emerald-400">Success`),Le=C(`<div class="flex h-full flex-col"><div class="flex shrink-0 items-center justify-between border-border border-b bg-muted/20 px-3 py-1.5"><div class="flex min-w-0 flex-1 items-center gap-2"><!$><!/><span class="max-w-[300px] cursor-pointer truncate font-mono text-muted-foreground text-xs hover:text-foreground"role=button tabindex=0></span></div><div class="flex items-center gap-2"></div></div><div class="flex-1 overflow-auto">`),I=C(`<span class="rounded bg-red-500/10 px-1.5 py-0.5 font-mono text-[10px] text-red-400">Error`),Re=e=>(()=>{var t=A(De);return u(()=>pe(t,`class`,e.class)),t})();function ze(e){let t=e.trim(),n=t.split(`
2
+ `)[0]?.trim()??t;return(n.length>40?`${n.slice(0,40)}...`:n).replace(/;$/,``)}var Be=e=>{let t=()=>e.results&&e.results.length>0,r=()=>e.results&&e.results.length>1,i=ie(),a=ie(),o=e=>{let t=e.data;if(!t)return;let n=t.columns,r=t.rows,a=[n.join(`,`),...r.map(e=>n.map(t=>{let n=e[t];if(n==null)return``;let r=String(n);return r.includes(`,`)||r.includes(`"`)||r.includes(`
3
+ `)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))].join(`
4
+ `);i.copy(a)},c=e=>{a.copy(e),m.success(`SQL copied to clipboard`)},l=t=>n(y,{get when(){return me(()=>!!t.success)()&&t.data},get fallback(){return(()=>{var e=A(Oe),n=e.firstChild.firstChild.nextSibling.firstChild.nextSibling;return N(n,()=>t.error||`An unknown error occurred`),e})()},get children(){return n(xe,{get columns(){return t.data.columns},get rows(){return t.data.rows},get tableName(){return e.tableName},get primaryKeyColumns(){return e.primaryKeyColumns},get onSave(){return e.onSave}})}});return n(ve,{class:`m-0 flex h-full flex-1 flex-col overflow-hidden border-0 border-border bg-card`,get children(){return[n(ge,{class:`flex h-[33px] shrink-0 flex-row items-center justify-between border-border border-b bg-muted/30 px-3 py-2`,get children(){return[n(_e,{class:`mb-0 font-medium text-muted-foreground text-xs uppercase tracking-wider`,children:`Results`}),(()=>{var r=A(ke);return N(r,n(y,{get when(){return me(()=>!!t())()&&!e.isLoading},get children(){return n(g,{variant:`ghost`,size:`xs`,type:`button`,get onClick(){return e.onClear},class:`h-6 px-2 text-muted-foreground hover:text-foreground`,children:`Clear`})}})),r})()]}}),n(be,{class:`flex h-full flex-1 flex-col overflow-auto p-0`,get children(){return[n(y,{get when(){return e.isLoading},get children(){return A(Ae)}}),n(y,{get when(){return me(()=>!e.isLoading)()&&!t()},get children(){return A(je)}}),n(y,{get when(){return me(()=>!e.isLoading)()&&t()},get children(){return n(y,{get when(){return r()},get fallback(){let t=()=>e.results?.[0];return n(y,{get when(){return t()},children:e=>(()=>{var t=A(Ne),r=t.firstChild,a=r.firstChild,s=a.nextSibling,u=r.nextSibling;return a.$$keyup=t=>t.key===`Enter`&&c(e().statement),a.$$click=()=>c(e().statement),N(a,()=>ze(e().statement)),N(s,n(y,{get when(){return me(()=>!!e().success)()&&e().data},get children(){return[(()=>{var t=A(Me),n=t.firstChild,[r,i]=D(n.nextSibling);return r.nextSibling,N(t,()=>e().data?.numRows??0,r,i),t})(),n(g,{variant:`ghost`,size:`xs`,onClick:()=>o(e()),class:`h-5 px-1.5 text-[10px] text-muted-foreground hover:text-foreground`,get children(){return n(y,{get when(){return i.copied()},fallback:`Copy CSV`,get children(){var e=A(P),t=e.firstChild,[r,i]=D(t.nextSibling);return r.nextSibling,N(e,n(Re,{class:`size-3`}),r,i),e}})}})]}})),N(u,()=>l(e())),ee(),t})()})},get children(){return n(Ee,{defaultValue:`0`,class:`flex h-full flex-col`,get children(){return[n(Te,{class:`w-full justify-start`,get children(){return n(s,{get each(){return e.results},children:(e,t)=>n(Ce,{get value(){return String(t())},get children(){var t=A(Fe),r=t.firstChild,[i,a]=D(r.nextSibling),o=i.nextSibling,[s,c]=D(o.nextSibling);return N(t,n(y,{get when(){return e.success},get fallback(){return A(Ie)},get children(){return A(Pe)}}),i,a),N(t,()=>ze(e.statement),s,c),t}})})}}),n(s,{get each(){return e.results},children:(e,t)=>n(we,{get value(){return String(t())},class:`flex-1 overflow-auto`,get children(){var t=A(Le),r=t.firstChild,a=r.firstChild,s=a.firstChild,[u,d]=D(s.nextSibling),f=u.nextSibling,p=a.nextSibling,m=r.nextSibling;return N(a,n(y,{get when(){return e.success},get fallback(){return A(I)},get children(){return A(F)}}),u,d),f.$$keyup=t=>t.key===`Enter`&&c(e.statement),f.$$click=()=>c(e.statement),N(f,()=>ze(e.statement)),N(p,n(y,{get when(){return me(()=>!!e.success)()&&e.data},get children(){return[(()=>{var t=A(Me),n=t.firstChild,[r,i]=D(n.nextSibling);return r.nextSibling,N(t,()=>e.data?.numRows??0,r,i),t})(),n(g,{variant:`ghost`,size:`xs`,onClick:()=>o(e),class:`h-5 px-1.5 text-[10px] text-muted-foreground hover:text-foreground`,get children(){return n(y,{get when(){return i.copied()},fallback:`Copy CSV`,get children(){var e=A(P),t=e.firstChild,[r,i]=D(t.nextSibling);return r.nextSibling,N(e,n(Re,{class:`size-3`}),r,i),e}})}})]}})),N(m,()=>l(e)),ee(),t}})})]}})}})}})]}})]}})};j([`click`,`keyup`]);var Ve=[],He=[];(()=>{let e=`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(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?He:Ve).push(n+=e[t])})();function Ue(e){if(e<768)return!1;for(let t=0,n=Ve.length;;){let r=t+n>>1;if(e<Ve[r])n=r;else if(e>=He[r])t=r+1;else return!0;if(t==n)return!1}}function We(e){return e>=127462&&e<=127487}var Ge=8205;function Ke(e,t,n=!0,r=!0){return(n?qe:Je)(e,t,r)}function qe(e,t,n){if(t==e.length)return t;t&&Xe(e.charCodeAt(t))&&Ze(e.charCodeAt(t-1))&&t--;let r=Ye(e,t);for(t+=Qe(r);t<e.length;){let i=Ye(e,t);if(r==Ge||i==Ge||n&&Ue(i))t+=Qe(i),r=i;else if(We(i)){let n=0,r=t-2;for(;r>=0&&We(Ye(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Je(e,t,n){for(;t>0;){let r=qe(e,t-2,n);if(r<t)return r;t--}return 0}function Ye(e,t){let n=e.charCodeAt(t);if(!Ze(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Xe(r)?(n-55296<<10)+(r-56320)+65536:n}function Xe(e){return e>=56320&&e<57344}function Ze(e){return e>=55296&&e<56320}function Qe(e){return e<65536?1:2}var L=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=ct(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),et.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ct(this,e,t);let n=[];return this.decompose(e,t,n,0),et.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new it(this),i=new it(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new it(this,e)}iterRange(e,t=this.length){return new at(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ot(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new $e(t):et.from($e.split(t,[]))}},$e=class e extends L{constructor(e,t=tt(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new st(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(rt(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=nt(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=ct(this,t,n);let i=nt(this.text,nt(r.text,rt(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):et.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
5
+ `){[e,t]=ct(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},et=class e extends L{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&((a<=e?1:0)|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=ct(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
6
+ `){[e,t]=ct(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new $e(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof $e&&c&&(n=u[u.length-1])instanceof $e&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new $e(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};L.empty=new $e([``],0);function tt(e){let t=-1;for(let n of e)t+=n.length+1;return t}function nt(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function rt(e,t,n){return nt(e,[``],t,n)}var it=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof $e?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof $e?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
7
+ `,this;e--}else if(r instanceof $e){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof $e?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},at=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new it(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},ot=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(L.prototype[Symbol.iterator]=function(){return this.iter()},it.prototype[Symbol.iterator]=at.prototype[Symbol.iterator]=ot.prototype[Symbol.iterator]=function(){return this});var st=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function ct(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function lt(e,t,n=!0,r=!0){return Ke(e,t,n,r)}function ut(e){return e>=56320&&e<57344}function dt(e){return e>=55296&&e<56320}function ft(e,t){let n=e.charCodeAt(t);if(!dt(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ut(r)?(n-55296<<10)+(r-56320)+65536:n}function pt(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function mt(e){return e<65536?1:2}var ht=/\r\n?|\n/,gt=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(gt||={}),_t=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){xt(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:Ct(this,e)}mapDesc(e,t=!1){return e.empty?this:St(this,e,t)}mapPos(e,t=-1,n=gt.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=gt.Simple&&c>=e&&(n==gt.TrackDel&&r<e&&c>e||n==gt.TrackBefore&&r<e||n==gt.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},vt=class e extends _t{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return xt(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return St(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(L.empty);r.push(a?t.slice(i,i+a):L.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Ct(this,e,!0)}map(e,t=!1){return e.empty?this:St(this,e,t,!0)}iterChanges(e,t=!1){xt(this,e,t)}get desc(){return _t.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new wt(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);yt(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;yt(n,e,t),t>0&&bt(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);yt(n,e,-1),yt(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:_t.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&yt(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?L.of(l.split(r||ht)):l:L.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&yt(i,e-o,-1),yt(i,s-e,d),bt(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(L.empty);r[e]=L.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function yt(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function bt(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(L.empty);e.push(n)}}function xt(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=L.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function St(e,t,n,r=!1){let i=[],a=r?[]:null,o=new wt(e),s=new wt(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);yt(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(yt(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(yt(i,0,o.ins),a&&bt(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;yt(i,t,e<o.i?o.ins:0),a&&e<o.i&&bt(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?vt.createSet(i,a):_t.create(i);else throw Error(`Mismatched change set lengths`)}function Ct(e,t,n=!1){let r=[],i=n?[]:null,a=new wt(e),o=new wt(t);for(let e=!1;;)if(a.done&&o.done)return i?vt.createSet(r,i):_t.create(r);else if(a.ins==0)yt(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)yt(r,0,o.ins,e),i&&bt(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;yt(r,t,n,e),i&&n&&bt(i,r,o.text)}else o.ins==-1?(yt(r,a.off?0:a.len,t,e),i&&bt(i,r,a.textBit(t))):(yt(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&bt(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var wt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[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:e}=this.set,t=this.i-2>>1;return t>=e.length?L.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?L.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Tt=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return R.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return R.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return R.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},R=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Tt.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Tt.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?Tt.create(t,e,48|a):Tt.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Et(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Dt=0,z=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Dt++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Ot),!!t.static,t.enables)}of(e){return new kt([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new kt(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new kt(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Ot(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var kt=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Dt++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||jt(e,c)){let r=t(e);if(a?!At(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Ut(o,c);if(this.dependencies.every(t=>t instanceof z?o.facet(t)===e.facet(t):t instanceof Nt?o.field(t,!1)==e.field(t,!1):!0)||(a?At(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function At(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function jt(e,t){let n=!1;for(let r of t)Ht(e,r)&1&&(n=!0);return n}function Mt(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Ut(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)Ht(e,t);return e.values[o]=s(e),1},update(e,n){if(!jt(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=jt(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Ot(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var B=z.define({static:!0}),Nt=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(Dt++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(B).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(B),i=n.facet(B),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,B.of({field:this,create:e})]}get extension(){return this}},Pt={lowest:4,low:3,default:2,high:1,highest:0};function Ft(e){return t=>new Lt(t,e)}var It={highest:Ft(Pt.highest),high:Ft(Pt.high),default:Ft(Pt.default),low:Ft(Pt.low),lowest:Ft(Pt.lowest)},Lt=class{constructor(e,t){this.inner=e,this.prec=t}},Rt=class e{of(e){return new zt(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},zt=class{constructor(e,t){this.compartment=e,this.inner=t}},Bt=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Vt(t,n,o))e instanceof Nt?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,Ot(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Mt(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function Vt(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof zt&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof zt){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Lt)a(e.inner,e.prec);else if(e instanceof Nt)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof kt)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Pt.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Pt.default),r.reduce((e,t)=>e.concat(t))}function Ht(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Ut(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Wt=z.define(),Gt=z.define({combine:e=>e.some(e=>e),static:!0}),Kt=z.define({combine:e=>e.length?e[0]:void 0,static:!0}),qt=z.define(),Jt=z.define(),Yt=z.define(),Xt=z.define({combine:e=>e.length?e[0]:!1}),Zt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Qt}},Qt=class{of(e){return new Zt(this,e)}},$t=class{constructor(e){this.map=e}of(e){return new V(this,e)}},V=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new $t(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};V.reconfigure=V.define(),V.appendConfig=V.define();var en=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Et(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return 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(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};en.time=Zt.define(),en.userEvent=Zt.define(),en.addToHistory=Zt.define(),en.remote=Zt.define();function tn(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function nn(e,t,n){let r,i,a;return n?(r=t.changes,i=vt.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:V.mapEffects(e.effects,r).concat(V.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function rn(e,t,n){let r=t.selection,i=ln(t.annotations);return t.userEvent&&(i=i.concat(en.userEvent.of(t.userEvent))),{changes:t.changes instanceof vt?t.changes:vt.of(t.changes||[],n,e.facet(Kt)),selection:r&&(r instanceof R?r:R.single(r.anchor,r.head)),effects:ln(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function an(e,t,n){let r=rn(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=nn(r,rn(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=en.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return sn(n?on(i):i)}function on(e){let t=e.startState,n=!0;for(let r of t.facet(qt)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:tn(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=vt.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=en.create(t,r,e.selection&&e.selection.map(i),V.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Jt);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof en?i:Array.isArray(i)&&i.length==1&&i[0]instanceof en?i[0]:an(t,ln(i),!1)}return e}function sn(e){let t=e.startState,n=t.facet(Yt),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=nn(r,rn(t,a,e.changes.newLength),!0))}return r==e?e:en.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var cn=[];function ln(e){return e==null?cn:Array.isArray(e)?e:[e]}var un=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(un||={}),dn=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,fn;try{fn=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function pn(e){if(fn)return fn.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||dn.test(n)))return!0}return!1}function mn(e){return t=>{if(!/\S/.test(t))return un.Space;if(pn(t))return un.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return un.Word;return un.Other}}var H=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)Ht(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return Ht(this,n),Ut(this,n)}update(...e){return an(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Rt.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(V.reconfigure)?(n=null,r=e.value):e.is(V.appendConfig)&&(n=null,r=ln(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Bt.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Gt)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:R.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=ln(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=V.mapEffects(a,c).concat(V.mapEffects(ln(o.effects),l))}return{changes:r,selection:R.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof vt?t:vt.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return L.of(t.split(this.facet(e.lineSeparator)||ht))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Ht(this,t),Ut(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Nt&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:R.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Bt.resolve(t.extensions||[],new Map),r=t.doc instanceof L?t.doc:L.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||ht)),i=t.selection?t.selection instanceof R?t.selection:R.single(t.selection.anchor,t.selection.head):R.single(0);return Et(i,r.length),n.staticFacet(Gt)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
8
+ `}get readOnly(){return this.facet(Xt)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(Wt))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return mn(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=lt(t,a,!1);if(i(t.slice(e,a))!=un.Word)break;a=e}for(;o<r;){let e=lt(t,o);if(i(t.slice(o,e))!=un.Word)break;o=e}return a==o?null:R.range(a+n,o+n)}};H.allowMultipleSelections=Gt,H.tabSize=z.define({combine:e=>e.length?e[0]:4}),H.lineSeparator=Kt,H.readOnly=Xt,H.phrases=z.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),H.languageData=Wt,H.changeFilter=qt,H.transactionFilter=Jt,H.transactionExtender=Yt,Rt.reconfigure=V.define();function hn(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(!(a===i||i===void 0))if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var gn=class{eq(e){return this==e}range(e,t=e){return vn.create(e,t,this)}};gn.prototype.startSide=gn.prototype.endSide=0,gn.prototype.point=!1,gn.prototype.mapMode=gt.TrackDel;function _n(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var vn=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function yn(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var bn=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(t,n){let r=[],i=[],a=[],o=-1,s=-1;for(let e=0;e<this.value.length;e++){let c=this.value[e],l=this.from[e]+t,u=this.to[e]+t,d,f;if(l==u){let e=n.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=n.mapPos(l,c.endSide),f<d)))continue}else if(d=n.mapPos(l,c.startSide),f=n.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(s=Math.max(s,f-d)),r.push(c),i.push(d-o),a.push(f-o))}return{mapped:r.length?new e(i,a,r,s):null,pos:o}}},xn=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(yn)),this.isEmpty)return n.length?e.of(n):this;let s=new Tn(this,null,-1).goto(0),c=0,l=[],u=new Cn;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value)||l.push(vn.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],o=this.chunk[e],s=t.touchesRange(a,a+o.length);if(s===!1)i=Math.max(i,o.maxPoint),n.push(o),r.push(t.mapPos(a));else if(s===!0){let{mapped:e,pos:s}=o.map(a,t);e&&(i=Math.max(i,e.maxPoint),n.push(e),r.push(s))}}let a=this.nextLayer.map(t);return n.length==0?a:new e(r,n,a||e.empty,i)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return En.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return En.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=wn(a,o,n),c=new On(a,s,i),l=new On(o,s,i);n.iterGaps((e,t,n)=>kn(c,e,l,t,n,r)),n.empty&&n.length==0&&kn(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=999999999;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=wn(i,a),s=new On(i,o,0).goto(n),c=new On(a,o,0).goto(n);for(;;){if(s.to!=c.to||!An(s.active,c.active)||s.point&&(!c.point||!_n(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new On(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new Cn;for(let r of e instanceof vn?[e]:t?Sn(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};xn.empty=new xn([],[],null,-1);function Sn(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(yn(t,r)>0)return e.slice().sort(yn);t=r}return e}xn.empty.nextLayer=xn.empty;var Cn=class e{finishChunk(e){this.chunks.push(new bn(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,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,r){this.addInner(t,n,r)||(this.nextLayer||=new e).add(t,n,r)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(xn.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=xn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function wn(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!n?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var Tn=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex];if(this.from=e+t.from[this.rangeIndex],this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==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=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},En=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new Tn(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Dn(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Dn(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Dn(this.heap,0)}}};function Dn(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var On=class{constructor(e,t,n){this.minPoint=n,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=En.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){jn(this.active,e),jn(this.activeTo,e),jn(this.activeRank,e),this.minActive=Nn(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;Mn(this.active,t,n),Mn(this.activeTo,t,r),Mn(this.activeRank,t,i),e&&Mn(e,t,this.cursor.from),this.minActive=Nn(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&jn(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function kn(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&_n(e.point,n.point)&&An(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!An(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function An(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!_n(e[n],t[n]))return!1;return!0}function jn(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function Mn(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function Nn(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Pn(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=lt(e,i));return r}function Fn(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=lt(e,r)}return r===!0?-1:e.length}for(var In=`ͼ`,Ln=typeof Symbol>`u`?`__`+In:Symbol.for(In),Rn=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),zn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},Bn=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
9
+ `)}static newName(){let e=zn[Ln]||1;return zn[Ln]=e+1,In+e.toString(36)}static mount(e,t,n){let r=e[Rn],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Hn(e,i),r.mount(Array.isArray(t)?t:[t],e)}},Vn=new Map,Hn=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Vn.get(n);if(t)return e[Rn]=t;this.sheet=new r.CSSStyleSheet,Vn.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[Rn]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t],o=this.modules.indexOf(a);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),o==-1){if(this.modules.splice(i++,0,a),n)for(let e=0;e<a.rules.length;e++)n.insertRule(a.rules[e],r++)}else{for(;i<o;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
10
+ `;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},Un={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:`'`},Wn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Gn=typeof navigator<`u`&&/Mac/.test(navigator.platform),Kn=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),qn=0;qn<10;qn++)Un[48+qn]=Un[96+qn]=String(qn);for(var qn=1;qn<=24;qn++)Un[qn+111]=`F`+qn;for(var qn=65;qn<=90;qn++)Un[qn]=String.fromCharCode(qn+32),Wn[qn]=String.fromCharCode(qn);for(var Jn in Un)Wn.hasOwnProperty(Jn)||(Wn[Jn]=Un[Jn]);function Yn(e){var t=!(Gn&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Kn&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Wn:Un)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var Xn=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},Zn=typeof document<`u`?document:{documentElement:{style:{}}},Qn=/Edge\/(\d+)/.exec(Xn.userAgent),$n=/MSIE \d/.test(Xn.userAgent),er=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xn.userAgent),tr=!!($n||er||Qn),nr=!tr&&/gecko\/(\d+)/i.test(Xn.userAgent),rr=!tr&&/Chrome\/(\d+)/.exec(Xn.userAgent),ir=`webkitFontSmoothing`in Zn.documentElement.style,ar=!tr&&/Apple Computer/.test(Xn.vendor),or=ar&&(/Mobile\/\w+/.test(Xn.userAgent)||Xn.maxTouchPoints>2),U={mac:or||/Mac/.test(Xn.platform),windows:/Win/.test(Xn.platform),linux:/Linux|X11/.test(Xn.platform),ie:tr,ie_version:$n?Zn.documentMode||6:er?+er[1]:Qn?+Qn[1]:0,gecko:nr,gecko_version:nr?+(/Firefox\/(\d+)/.exec(Xn.userAgent)||[0,0])[1]:0,chrome:!!rr,chrome_version:rr?+rr[1]:0,ios:or,android:/Android\b/.test(Xn.userAgent),webkit:ir,webkit_version:ir?+(/\bAppleWebKit\/(\d+)/.exec(Xn.userAgent)||[0,0])[1]:0,safari:ar,safari_version:ar?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Xn.userAgent)||[0,0])[1]:0,tabSize:Zn.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function sr(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var cr=Object.create(null);function lr(e,t,n){if(e==t)return!0;e||=cr,t||=cr;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function ur(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function dr(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function fr(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var pr=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},mr=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(mr||={}),W=class extends gn{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new hr(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new _r(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=vr(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new _r(e,n,r,t,e.widget||null,!0)}static line(e){return new gr(e)}static set(e,t=!1){return xn.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};W.none=xn.empty;var hr=class e extends W{constructor(e){let{start:t,end:n}=vr(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?sr(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||cr}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&lr(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};hr.prototype.point=!1;var gr=class e extends W{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&lr(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};gr.prototype.mapMode=gt.TrackBefore,gr.prototype.point=!0;var _r=class e extends W{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?gt.TrackBefore:gt.TrackAfter:gt.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?mr.WidgetBefore:mr.WidgetAfter:mr.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&yr(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};_r.prototype.point=!0;function vr(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function yr(e,t){return e==t||!!(e&&t&&e.compare(t))}function br(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var xr=class e extends gn{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&lr(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||cr)}static set(e,t=!1){return xn.of(e,t)}};xr.prototype.startSide=xr.prototype.endSide=-1;function Sr(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Cr(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function wr(e,t){if(!t.anchorNode)return!1;try{return Cr(e,t.anchorNode)}catch{return!1}}function Tr(e){return e.nodeType==3?Br(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Er(e,t,n,r){return n?kr(e,t,n,r,-1)||kr(e,t,n,r,1):!1}function Dr(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function Or(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function kr(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ar(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=Dr(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?Ar(e):0}else return!1}}function Ar(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function jr(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Mr(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Nr(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function Pr(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=Mr(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=Nr(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g)if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Fr(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var Ir=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Ar(t):0),n,Math.min(e.focusOffset,n?Ar(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},Lr=null;U.safari&&U.safari_version>=26&&(Lr=!1);function Rr(e){if(e.setActive)return e.setActive();if(Lr)return e.focus(Lr);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(Lr==null?{get preventScroll(){return Lr={preventScroll:!0},!0}}:void 0),!Lr){Lr=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var zr;function Br(e,t,n=t){let r=zr||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function Vr(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function Hr(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function Ur(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Ar(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=Ar(n))}else if(n==e)return!0;else r=Dr(n),n=n.parentNode}function Wr(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Gr(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=Ar(n)}else if(n.parentNode&&!Or(n))r=Dr(n),n=n.parentNode;else return null}function Kr(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!Or(n))r=Dr(n)+1,n=n.parentNode;else return null}var qr=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,Dr(t),n)}static after(t,n){return new e(t.parentNode,Dr(t)+1,n)}},Jr=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(Jr||={}),Yr=Jr.LTR,Xr=Jr.RTL;function Zr(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var Qr=Zr(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),$r=Zr(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),ei=Object.create(null),ti=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);ei[t]=n,ei[n]=-t}function ni(e){return e<=247?Qr[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?$r[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var ri=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,ii=class{get dir(){return this.level%2?Xr:Yr}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function ai(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!ai(r.inner,i.inner))return!1}return!0}var G=[];function oi(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=ni(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),G[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=G[e];if(i==128)e<s-1&&t==G[e+1]&&t&24?i=G[e]=t:G[e]=256;else if(i==64){let i=e+1;for(;i<s&&G[i]==64;)i++;let a=e&&t==8||i<n&&G[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)G[t]=a;e=i-1}else i==8&&r==1&&(G[e]=1);t=i,i&7&&(r=i)}}}function si(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=ei[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if(ti[e+1]==-r){let n=ti[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(G[t]=G[ti[e]]=r),s=e;break}}else if(ti.length==189)break;else ti[s++]=t,ti[s++]=n,ti[s++]=c;else if((o=G[t])==2||o==1){let e=o==i;c=e?0:1;for(let t=s-3;t>=0;t-=3){let n=ti[t+2];if(n&2)break;if(e)ti[t+2]|=2;else{if(n&4)break;ti[t+2]|=4}}}}}function ci(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=G[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(G[o]==256)o++;else break;let l=a==1,u=l==((o<t?G[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),G[--t]=u;c=o}else a=o,c++}}}function li(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=G[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(G[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new ii(c,m.from,f)),ui(e,m.direction==Yr==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?G[p]!=s:G[p]==s))break;else p++;d?li(e,c,p,r+1,i,d,o):c<p&&o.push(new ii(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=G[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(G[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new ii(m.to,c,f)),ui(e,m.direction==Yr==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?G[p-1]!=s:G[p-1]==s))break;else p--;d?li(e,p,c,r+1,i,d,o):p<c&&o.push(new ii(p,c,f)),c=p}}function ui(e,t,n,r,i,a,o){let s=t%2?2:1;oi(e,i,a,r,s),si(e,i,a,r,s),ci(i,a,r,s),li(e,i,a,t,n,r,o)}function di(e,t,n){if(!e)return[new ii(0,0,t==Xr?1:0)];if(t==Yr&&!n.length&&!ri.test(e))return fi(e.length);if(n.length)for(;e.length>G.length;)G[G.length]=256;let r=[],i=t==Yr?0:1;return ui(e,i,i,n,0,e.length,r),r}function fi(e){return[new ii(0,e,0)]}var pi=``;function mi(e,t,n,r,i){let a=r.head-e.from,o=ii.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=lt(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),pi=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+(i?0:1)<s.level?R.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):R.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function hi(e,t,n){for(let r=t;r<n;r++){let t=ni(e.charCodeAt(r));if(t==1)return Yr;if(t==2||t==4)return Xr}return Yr}var gi=z.define(),_i=z.define(),vi=z.define(),yi=z.define(),bi=z.define(),xi=z.define(),Si=z.define(),Ci=z.define(),wi=z.define(),Ti=z.define({combine:e=>e.some(e=>e)}),Ei=z.define({combine:e=>e.some(e=>e)}),Di=z.define(),Oi=class e{constructor(e,t=`nearest`,n=`nearest`,r=5,i=5,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(R.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ki=V.define({map:(e,t)=>e.map(t)}),Ai=V.define();function ji(e,t,n){let r=e.facet(yi);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var Mi=z.define({combine:e=>e.length?e[0]:!0}),Ni=0,Pi=z.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),Fi=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(Pi.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Pi.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(Ni++,t,r,i,e=>{let t=[];return o&&t.push(zi.of(t=>{let n=t.plugin(e);return n?o(n):W.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Ii=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){ji(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(ji(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){ji(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},Li=z.define(),Ri=z.define(),zi=z.define(),Bi=z.define(),Vi=z.define(),Hi=z.define(),Ui=z.define();function Wi(e,t){let n=e.state.facet(Ui);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return xn.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=hi(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var Gi=z.define();function Ki(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(Gi)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var qi=z.define(),Ji=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(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(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},Yi=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=vt.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new Ji(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Xi=[],K=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Xi}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&ur(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Dr(this.dom),r=this.length?e>0:t>0;return new qr(this.parent.dom,n+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof $i)return e;return null}static get(e){return e.cmTile}},Zi=class extends K{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=Qi(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=Qi(r);this.length=a}};function Qi(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var $i=class extends Zi{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=K.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof ea)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},ea=class e extends Zi{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},ta=class e extends Zi{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0||n&&ra(a,d)))&&(f>c||d.flags&32)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):na(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new qr(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new qr(e.dom,0);e==n.tile&&(a=!0)}}return new qr(this.dom,0)}};function na(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Tr(t);return n[n.length-1]||null}function ra(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var ia=class e extends Zi{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},aa=class e extends K{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,a=0;e==0&&t<0||e==n&&t>=0?U.chrome||U.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=Br(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return U.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?jr(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},oa=class e extends K{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return jr(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return jr(n,!r)}}get overrideDOMText(){if(!this.length)return L.empty;let{root:e}=this;if(!e)return L.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},sa=class extends K{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return L.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},ca=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite())if(i==r.length)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(e){let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}else break;else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},la=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},ua=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new aa(a.dom,a.text+e);t.parent=i}else i.append(r||aa.of(e,this.cache.find(aa)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?ba(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof ia&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(ba(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=K.get(n.dom);e&&e.setDOM(ba(n.dom))}let e=ia.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=K.get(e.text);i&&this.cache.reused.set(i,2);let a=new aa(e.text,e.text.nodeValue);a.flags|=8,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=_a;let n=ta.start(e,t||this.cache.find(ta)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof ia&&a.mark.eq(i))n=a,t--;else{let e=ia.of(i,this.cache.find(ia,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!ha(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(U.ios&&ha(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Sa,0,32)||new oa(Sa.toDOM(),0,Sa,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new la(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof ea&&n.wrapper.eq(t.wrapper))e=n;else{let n=ea.of(t.wrapper,this.cache.find(ea,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(sa,void 0,1);return n&&(n.flags=t),n||new sa(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},da=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},fa=[oa,ta,aa,ia,sa,ea,$i];for(let e=0;e<fa.length;e++)fa[e].bucket=e;var pa=class{constructor(e){this.view=e,this.buckets=fa.map(()=>[]),this.index=fa.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=i.length-1;e>=0;e--){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new oa(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},ma=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new pa(e),this.text=new da(e.state.doc),this.builder=new ua(this.cache,new $i(e,e.contentDOM),xn.iter(n)),this.cache.reused.set(t,2),this.old=new ca(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=ya(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?oa.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof sa)this.cache.add(e);else if(e instanceof ia)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof ia&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof ia&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,a=xn.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof _r){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?xa.block:xa.inline),c=ga(a),l=this.cache.findWidget(i,t-e,c)||oa.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=va(n,a);t>e&&this.text.skip(t-e)},span:(e,t,i,a)=>{for(let o=e;o<t;){let s=this.text.next(Math.min(512,t-o));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),o++):(r.ensureLine(n),r.addText(s,i,o==e?a:i.length),o+=s.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=a>i,this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=K.get(r);if(r==this.view.contentDOM)break;e instanceof ia?t.push(e):e?.isLine()?n=e:e instanceof ea||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new ta(r,_a):n||t.push(ia.of(new hr({tagName:r.nodeName.toLowerCase(),attributes:fr(r)}),r)))}return{line:n,marks:t}}};function ha(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function ga(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var _a={class:`cm-line`};function va(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&sr(n,e),r&&(e.class+=` `+r),e)}function ya(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof ia&&t.push(r.mark)}return t}function ba(e){let t=K.get(e);return t&&t.setDOM(e.cloneNode()),e}var xa=class extends pr{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};xa.inline=new xa(`span`),xa.block=new xa(`div`);var Sa=new class extends pr{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},Ca=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=W.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new $i(e,e.contentDOM),this.updateInner([new Ji(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!Pa(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Da(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new Ji(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(U.ie||U.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=Aa(i,this.decorations,e.changes);o.length&&(t=Ji.extendWithRanges(t,o));let s=Ma(a,this.blockWrappers,e.changes);return s.length&&(t=Ji.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new ma(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&K.get(t.text)&&r.cache.reused.set(K.get(t.text),2),this.tile=r.run(e,t),wa(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=U.chrome||U.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof Fa&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(Ai)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(Mi)||n.tabIndex>-1)&&wr(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),U.gecko&&s.empty&&!this.hasComposition&&Ta(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new qr(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!Er(c.node,c.offset,u.anchorNode,u.anchorOffset)||!Er(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{U.android&&U.chrome&&n.contains(u.focusNode)&&Na(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=Sr(this.view.root);if(e)if(s.empty){if(U.gecko){let e=Oa(c.node,c.offset);if(e&&e!=3){let t=(e==1?Gr:Kr)(c.node,c.offset);t&&(c=new qr(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new qr(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new qr(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Er(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Sr(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=Ar(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!K.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof Fa?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=lt(e.text,t);if(n==t)return null;let r=Br(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==Jr.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof ea)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?Tr(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?Jr.RTL:Jr.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=Tr(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=Tr(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(W.replace({widget:new Fa(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return W.set(e)}updateDeco(){let e=1,t=this.view.state.facet(zi).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(Vi).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(xn.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(Bi).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(Di))try{if(t(this.view,e.range,e))return!0}catch(e){ji(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc??(t.empty?0:t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=Ki(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(Pr(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==Jr.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);e&&e.dom.scrollIntoView({block:`nearest`})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){wa(this.tile)}};function wa(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)wa(n,t)}}function Ta(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function Ea(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Gr(n.focusNode,n.focusOffset),i=Kr(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=K.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=K.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function Da(e,t,n){let r=Ea(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new Ji(c.mapPos(a),c.mapPos(o),a,o),text:i}}function Oa(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var ka=class{constructor(){this.changes=[]}compareRange(e,t){br(e,t,this.changes)}comparePoint(e,t){br(e,t,this.changes)}boundChange(e){br(e,e,this.changes)}};function Aa(e,t,n){let r=new ka;return xn.compare(e,t,n,r),r.changes}var ja=class{constructor(){this.changes=[]}compareRange(e,t){br(e,t,this.changes)}comparePoint(){}boundChange(e){br(e,e,this.changes)}};function Ma(e,t,n){let r=new ja;return xn.compare(e,t,n,r),r.changes}function Na(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function Pa(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var Fa=class extends pr{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Ia(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return R.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=lt(i.text,a,!1):s=lt(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=lt(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=lt(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return R.range(o+i.from,s+i.from)}function La(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Fn(o,a,e.state.tabSize)}function Ra(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==mr.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function za(e,t,n,r){let i=Ra(e,t.head,t.assoc||-1),a=!r||i.type!=mr.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==Jr.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return R.cursor(o,n?-1:1)}return R.cursor(n?i.to:i.from,n?-1:1)}function Ba(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=mi(i,a,o,s,n),l=pi;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
11
+ `,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function Va(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==un.Space&&(i=t),i==t}}function Ha(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return R.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=qa(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return R.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return R.cursor(i.pos,i.assoc,void 0,o)}}function Ua(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function Wa(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=Ua(e,i.from,0);t!=i.from&&(a=R.cursor(t,-1))}else{let t=Ua(e,i.from,-1),n=Ua(e,i.to,1);(t!=i.from||n!=i.to)&&(a=R.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?R.create(n,t.mainIndex):t}function Ga(e,t,n){let r=Ua(e.state.facet(Hi).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:R.cursor(r,r<n.from?1:-1)}var Ka=class{constructor(e,t){this.pos=e,this.assoc=t}};function qa(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new Ka(0,1);if(c>e.viewState.docHeight)return new Ka(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==mr.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==mr.Text){let t=La(e,i,l,o,s);return new Ka(t,t==l.from?1:-1)}}if(l.type!=mr.Text)return c<(l.top+l.bottom)/2?new Ka(l.from,1):new Ka(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new Ja(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var Ja=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[ii.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[ii.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t){let n=0,r=e.length-1,i=new Set,a=this.bidiIn(e[0],e[r]),o,s,c=-1,l=1e9,u;search:for(;n<r;){let d=r-n,f=n+r>>1;adjust:if(i.has(f)){let e=n+Math.floor(Math.random()*d);for(let t=0;t<d;t++){if(!i.has(e)){f=e;break adjust}e++,e==r&&(e=n)}break search}i.add(f);let p=t(f);if(p)for(let t=0;t<p.length;t++){let i=p[t],d=0;if(!(i.width==0&&p.length>1)){if(i.bottom<this.y)(!o||o.bottom<i.bottom)&&(o=i),d=1;else if(i.top>this.y)(!s||s.top>i.top)&&(s=i),d=-1;else{let e=i.left>this.x?this.x-i.left:i.right<this.x?this.x-i.right:0,t=Math.abs(e);t<l&&(c=f,l=t,u=i),e&&(d=e<0==(this.baseDir==Jr.LTR)?-1:1)}d==-1&&(!a||this.baseDirAt(e[f],1))?r=f:d==1&&(!a||this.baseDirAt(e[f+1],-1))&&(n=f+1)}}}if(!u){let n=o&&(!s||this.y-o.bottom<s.top-this.y)?o:s;return this.y=(n.top+n.bottom)/2,this.scan(e,t)}let d=(a?this.dirAt(e[c],1):this.baseDir)==Jr.LTR;return{i:c,after:this.x>(u.left+u.right)/2==d}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=lt(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return Br(e.dom,i,a).getClientRects()});return r.after?new Ka(n[r.i+1],-1):new Ka(n[r.i],1)}scanTile(e,t){if(!e.length)return new Ka(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:Br(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new Ka(n[r.i+1],-1):new Ka(a,1)}},Ya=`￿`,Xa=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(H.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ya}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=K.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=K.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:Or(r))||Or(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!Qa(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=K.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Za(e,n.node,n.offset)?t:0))}};function Za(e,t,n){for(;;){if(!t||n<Ar(t))return!1;if(t==e)return!0;n=Dr(t)+1,t=t.parentNode}}function Qa(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=K.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var $a=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},eo=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=to(e.docView.tile,t,n,0))){let t=i||a?[]:oo(e),n=new Xa(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=so(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!Cr(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!Cr(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((U.ios||U.chrome)&&o.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(R.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=R.create([R.cursor(n,r)])}else this.newSel=R.single(r,n)}}};function to(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return to(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}else if(e.isText())return{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling};else return null}function no(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||U.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,Ya),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:L.of(t.text.slice(a.from-e,u).split(Ya))}:(d=ao(l,t.text,s-e,c))&&(U.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==Ya+Ya&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:L.of(t.text.slice(d.from,d.toB).split(Ya))})}else r&&(!e.hasFocus&&i.facet(Mi)||co(r,a))&&(r=null);if(!n&&!r)return!1;if((U.mac||U.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=R.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:L.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:U.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
12
+ `&&e.lineWrapping&&(r&&=R.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:L.of([` `])}),n)return ro(e,n,r,o);if(r&&!co(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=Wa(i.facet(Hi).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function ro(e,t,n,r=-1){if(U.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(U.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&Vr(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&Vr(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&Vr(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=io(e,t,n);return e.state.facet(xi).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function io(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=Ua(i.facet(Hi).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:R.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&Ea(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?R.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function ao(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function oo(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new $a(n,r)),(i!=n||a!=r)&&t.push(new $a(i,a))),t}function so(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?R.single(n+t,r+t):null}function co(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var lo=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,U.safari&&e.contentDOM.addEventListener(`input`,()=>null),U.gecko&&Ko(e.contentDOM.ownerDocument)}handleEvent(e){!Co(this.view,e)||this.ignoreDuringComposition(e)||e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=fo(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&ho.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),U.android&&U.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return U.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=po.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||mo.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Vr(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:U.safari&&!U.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function uo(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){ji(n.state,e)}}}function fo(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(uo(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(uo(t.value,r))}}for(let e in wo)n(e).handlers.push(wo[e]);for(let e in To)n(e).observers.push(To[e]);return t}var po=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],mo=`dthko`,ho=[16,17,18,20,91,92,224,225],go=6;function _o(e){return Math.max(0,e)*.7+8}function vo(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var yo=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Fr(e.contentDOM),this.atoms=e.state.facet(Hi).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(H.allowMultipleSelections)&&bo(e,t),this.dragging=So(e,t)&&Fo(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&vo(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=Ki(this.view);e.clientX-s.left<=r+go?t=-_o(r-e.clientX):e.clientX+s.right>=a-go&&(t=_o(e.clientX-a)),e.clientY-s.top<=i+go?n=-_o(i-e.clientY):e.clientY+s.bottom>=o-go&&(n=_o(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=Wa(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function bo(e,t){let n=e.state.facet(gi);return n.length?n[0](t):U.mac?t.metaKey:t.ctrlKey}function xo(e,t){let n=e.state.facet(_i);return n.length?n[0](t):U.mac?!t.altKey:!t.ctrlKey}function So(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Sr(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function Co(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=K.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var wo=Object.create(null),To=Object.create(null),Eo=U.ie&&U.ie_version<15||U.ios&&U.webkit_version<604;function Do(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),ko(e,n.value)},50)}function Oo(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function ko(e,t){t=Oo(e.state,Ci,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(Vo!=null&&n.selection.ranges.every(e=>e.empty)&&Vo==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:R.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:R.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}To.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},To.wheel=To.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},wo.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),To.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},To.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},wo.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(vi))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=Io(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new yo(e,t,n,r)),r&&e.observer.ignore(()=>{Rr(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function Ao(e,t,n,r){if(r==1)return R.cursor(t,n);if(r==2)return Ia(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,R.range(a,o)}}var jo=U.ie&&U.ie_version<=11,Mo=null,No=0,Po=0;function Fo(e){if(!jo)return e.detail;let t=Mo,n=Po;return Mo=e,Po=Date.now(),No=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(No+1)%3:1}function Io(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Fo(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=Ao(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=Ao(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?R.range(i,a,l.assoc):R.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=Lo(i,s.pos))?c:o?i.addRange(l):R.create([l])}}}function Lo(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return R.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}wo.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=R.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,Oo(e.state,wi,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},wo.dragend=e=>(e.inputState.draggedContent=null,!1);function Ro(e,t,n,r){if(n=Oo(e.state,Ci,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&xo(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}wo.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&Ro(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}else{let n=t.dataTransfer.getData(`Text`);if(n)return Ro(e,t,n,!0),!0}return!1},wo.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Eo?null:t.clipboardData;return n?(ko(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(Do(e),!1)};function zo(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function Bo(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:Oo(e,wi,t.join(e.lineBreak)),ranges:n,linewise:r}}var Vo=null;wo.copy=wo.cut=(e,t)=>{if(!wr(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=Bo(e.state);if(!n&&!i)return!1;Vo=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=Eo?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(zo(e,n),!1)};var Ho=Zt.define();function Uo(e,t){let n=[];for(let r of e.facet(Si)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Ho.of(!0)}):null}function Wo(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Uo(e.state,t);n?e.dispatch(n):e.update([])}},10)}To.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Wo(e)},To.blur=e=>{e.observer.clearSelectionRange(),Wo(e)},To.compositionstart=To.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},To.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,U.chrome&&U.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},To.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},wo.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return ro(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(U.chrome&&U.android&&(n=po.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return U.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),U.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>To.compositionend(e,t),20),!1};var Go=new Set;function Ko(e){Go.has(e)||(Go.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var qo=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],Jo=!1;function Yo(){Jo=!1}var Xo=class{constructor(e){this.lineWrapping=e,this.doc=L.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return qo.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=qo.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},Zo=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Qo=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?mr.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof _r?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},q=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(q||={}),$o=.001,es=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>$o&&(Jo=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,q.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,q.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,q.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=ls.build(n.setDoc(a),e,l,u);i=ts(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new is(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r)if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break;else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new os(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function ts(e,t){return e==t?e:(e.constructor!=t.constructor&&(Jo=!0),t)}es.prototype.size=1;var ns=W.replace({}),rs=class extends es{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Qo(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Qo(r,0,n,this.spaceAbove,ns):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,q.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},is=class e extends rs{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new Qo(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof as&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof as?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):es.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},as=class e extends es{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new Qo(a.from,a.length,l,c,0)}else{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new Qo(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==q.ByHeight)return this.blockAt(e,n,r,i);if(t==q.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new Qo(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new Qo(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new Qo(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return es.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=$o&&(s=-2);let c=new is(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=es.of(r);return(s<0||Math.abs(c.height-this.height)>=$o||Math.abs(s-this.heightMetrics(t,n).perLine)>=$o)&&(Jo=!0),ts(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},os=class extends es{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==q.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==q.ByPosNoHeight?q.ByPosNoHeight:q.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,q.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&ss(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),ss(i,e)}return es.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?es.of(this.break?[e,null,t]:[e,t]):(this.left=ts(this.left,e),this.right=ts(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function ss(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof as&&(r=e[t+1])instanceof as&&e.splice(t-1,3,new as(n.length+1+r.length))}var cs=5,ls=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof is?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new is(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new rs(a,r,n)):(a||i||r>=cs)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new is(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new as(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof is)return e;let t=new is(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof is)&&!this.isCovered?this.nodes.push(new is(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof is&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return xn.spans(n,r,i,a,0),a.finish(r)}};function us(e,t,n){let r=new ds;return xn.compare(e,t,n,r,0),r.changes}var ds=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&br(e,t,this.changes,5)}};function fs(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function ps(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function ms(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var hs=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return W.replace({widget:new gs(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},gs=class extends pr{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},_s=class{constructor(e,t){this.view=e,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.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Cs,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=Jr.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1,this.heightOracle=new Xo(t.facet(Ri).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`)),this.stateDeco=ws(t),this.heightMap=es.empty().applyChanges(this.stateDeco,L.empty,this.heightOracle.setDoc(t.doc),[new Ji(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=W.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new vs(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Cs:new Ts(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Es(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=ws(this.state);let r=e.changedRanges,i=Ji.extendWithRanges(r,us(n,this.stateDeco,e?e.changes:vt.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Yo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||Jo)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ei)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?Jr.RTL:Jr.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=Nr(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=Fr(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Wr(this.scrollParent||e.win);let m=(this.printing?ms:fs)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!ps(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),Yo();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?es.empty().applyChanges(this.stateDeco,L.empty,this.heightOracle,[new Ji(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new Zo(n.from,i))}Jo&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new vs(r.lineAt(a-n*1e3,q.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,q.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,q.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new vs(r.lineAt(o-1e3/2,q.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,q.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new vs(this.heightMap.lineAt(n,q.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,q.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,q.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,q.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2*1e3&&i<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new hs(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=Jr.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=Ss(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(R.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new hs(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=mr.Text)return;let i=ys(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=xs(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=bs(i,n),l=bs(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=xs(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=bs(i,f),l=bs(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=xs(r,n)-xs(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){hs.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=W.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];xn.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Es(this.heightMap.lineAt(e,q.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Es(this.heightMap.lineAt(this.scaler.fromDOM(e),q.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Es(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},vs=class{constructor(e,t){this.from=e,this.to=t}};function ys(e,t,n){let r=[],i=e,a=0;return xn.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function bs({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function xs(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function Ss(e,t){for(let n of e)if(t(n))return n}var Cs={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function ws(e){let t=e.facet(zi).filter(e=>typeof e!=`function`),n=e.facet(Vi).filter(e=>typeof e!=`function`);return n.length&&t.push(xn.join(n)),t}var Ts=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,q.ByPos,e,0,0).top,o=t.lineAt(i,q.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}};function Es(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Qo(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Es(e,t)):e._content)}var Ds=z.define({combine:e=>e.join(` `)}),Os=z.define({combine:e=>e.indexOf(!0)>-1}),ks=Bn.newName(),As=Bn.newName(),js=Bn.newName(),Ms={"&light":`.`+As,"&dark":`.`+js};function Ns(e,t,n){return new Bn(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Ps=Ns(`.`+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,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".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`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},Ms),Fs={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Is=U.ie&&U.ie_version<=11,Ls=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Ir,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(U.ie&&U.ie_version<=11||U.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&U.android&&e.constructor.EDIT_CONTEXT!==!1&&!(U.chrome&&U.chrome_version<126)&&(this.editContext=new Vs(e),e.state.facet(Mi)&&(e.contentDOM.editContext=this.editContext.editContext)),Is&&(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),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.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`)))},{threshold:[0,.001]}),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(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type==`change`||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Mi)?n.root.activeElement!=this.dom:!wr(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(U.ie&&U.ie_version<=11||U.android&&U.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Er(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Sr(e.root);if(!t)return!1;let n=U.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Bs(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=wr(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Ur(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,Fs),Is&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Is&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){this.delayedAndroidKey||(this.flushingAndroidKey=this.view.win.requestAnimationFrame(()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Vr(this.dom,e.key,e.keyCode))})),(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&wr(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new eo(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=no(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!co(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=Rs(t,e.previousSibling||e.target.previousSibling,-1),r=Rs(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else if(e.type==`characterData`)return{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue};else return null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Mi)!=e.state.facet(Mi)&&(e.view.contentDOM.editContext=e.state.facet(Mi)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Rs(e,t,n){for(;t;){let r=K.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function zs(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return Er(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Bs(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return zs(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?zs(e,n):null}var Vs=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=ao(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=R.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));co(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:L.of(n.text.slice(l.from,l.toB).split(`
13
+ `))};if((U.mac||U.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:L.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);ro(e,u,R.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(W.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:Ai.of(W.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=Sr(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},J=class e{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Hr(e.parent)||document,this.viewState=new _s(this,e.state||H.create(e)),e.scrollTo&&e.scrollTo.is(ki)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Pi).map(e=>new Ii(e));for(let e of this.plugins)e.update(this);this.observer=new Ls(this),this.inputState=new lo(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ca(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof en?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let t=!1,n=!1,r,i=this.state;for(let t of e){if(t.startState!=i)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);i=t.state}if(this.destroyed){this.viewState.state=i;return}let a=this.hasFocus,o=0,s=null;e.some(e=>e.annotation(Ho))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,s=Uo(i,a),s||(o=1));let c=this.observer.delayedAndroidKey,l=null;if(c?(this.observer.clearDelayedAndroidKey(),l=this.observer.readChange(),(l&&!this.state.doc.eq(i.doc)||!this.state.selection.eq(i.selection))&&(l=null)):this.observer.clear(),i.facet(H.phrases)!=this.state.facet(H.phrases))return this.setState(i);r=Yi.create(this,i,e),r.flags|=o;let u=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(u&&=u.map(t.changes),t.scrollIntoView){let{main:e}=t.state.selection;u=new Oi(e.empty?e:R.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(ki)&&(u=e.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Ws.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(qi)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(r.startState.facet(Ds)!=r.state.facet(Ds)&&(this.viewState.mustMeasureContent=!0),(t||n||u||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let e of this.state.facet(bi))try{e(r)}catch(e){ji(this.state,e,`update listener`)}(s||l)&&Promise.resolve().then(()=>{s&&this.state==s.startState&&this.dispatch(s),l&&!no(this,l)&&c.force&&Vr(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new _s(this,e),this.plugins=e.facet(Pi).map(e=>new Ii(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Ca(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Pi),n=e.state.facet(Pi);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Ii(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){ji(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(Wr(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return ji(this.state,e),Us}}),l=Yi.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=Us)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){ji(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(bi))e(t)}get themeClasses(){return ks+` `+(this.state.facet(Os)?js:As)+` `+this.state.facet(Ds)}updateAttrs(){let e=Gs(this,Li,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Mi)?`true`:`false`,class:`cm-content`,style:`${U.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),Gs(this,Ri,t);let n=this.observer.ignore(()=>{let n=dr(this.contentDOM,this.contentAttrs,t),r=dr(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(qi);let t=this.state.facet(e.cspNonce);Bn.mount(this.root,this.styleModules.concat(Ps).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return Ga(this,e,Ba(this,e,t,n))}moveByGroup(e,t){return Ga(this,e,Ba(this,e,t,t=>Va(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return R.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return za(this,e,t,n)}moveVertically(e,t,n){return Ga(this,e,Ha(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=qa(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),qa(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[ii.find(i,e-r.from,-1,t)];return jr(n,a.dir==Jr.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Ti)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Hs)return fi(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||ai(r.isolates,n=Wi(this,e))))return r.order;n||=Wi(this,e);let r=di(e.text,t,n);return this.bidiCache.push(new Ws(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||U.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Rr(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return ki.of(new Oi(typeof e==`number`?R.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return ki.of(new Oi(R.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Fi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Fi.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Bn.newName(),r=[Ds.of(n),qi.of(Ns(`.${n}`,e))];return t&&t.dark&&r.push(Os.of(!0)),r}static baseTheme(e){return It.lowest(qi.of(Ns(`.`+ks,e,Ms)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&K.get(t)||K.get(e))?.root?.view||null}};J.styleModule=qi,J.inputHandler=xi,J.clipboardInputFilter=Ci,J.clipboardOutputFilter=wi,J.scrollHandler=Di,J.focusChangeEffect=Si,J.perLineTextDirection=Ti,J.exceptionSink=yi,J.updateListener=bi,J.editable=Mi,J.mouseSelectionStyle=vi,J.dragMovesSelection=_i,J.clickAddsSelectionRange=gi,J.decorations=zi,J.blockWrappers=Bi,J.outerDecorations=Vi,J.atomicRanges=Hi,J.bidiIsolatedRanges=Ui,J.scrollMargins=Gi,J.darkTheme=Os,J.cspNonce=z.define({combine:e=>e.length?e[0]:``}),J.contentAttributes=Ri,J.editorAttributes=Li,J.lineWrapping=J.contentAttributes.of({class:`cm-lineWrapping`}),J.announce=V.define();var Hs=4096,Us={},Ws=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:Jr.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function Gs(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&sr(a,n)}return n}var Ks=U.mac?`mac`:U.windows?`win`:U.linux?`linux`:`key`;function qs(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function Js(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var Ys=It.default(J.domEventHandlers({keydown(e,t){return ic(Qs(t.state),e,t,`editor`)}})),Xs=z.define({enables:Ys}),Zs=new WeakMap;function Qs(e){let t=e.facet(Xs),n=Zs.get(t);return n||Zs.set(t,n=nc(t.reduce((e,t)=>e.concat(t),[]))),n}function $s(e,t,n){return ic(Qs(e.state),t,e,n)}var ec=null,tc=4e3;function nc(e,t=Ks){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>qs(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=ec={view:t,prefix:n,scope:e};return setTimeout(()=>{ec==r&&(ec=null)},tc),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,rc))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var rc=null;function ic(e,t,n,r){rc=t;let i=Yn(t),a=mt(ft(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;ec&&ec.view==n&&ec.scope==r&&(o=ec.prefix+` `,ho.indexOf(t.keyCode)<0&&(c=!0,ec=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+Js(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(U.windows&&t.ctrlKey&&t.altKey)&&!(U.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Un[t.keyCode])&&p!=i?(d(f[o+Js(p,t,!0)])||t.shiftKey&&(m=Wn[t.keyCode])!=i&&m!=p&&d(f[o+Js(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+Js(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),rc=null,s}var ac=z.define({combine(e){return hn(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function oc(e){return e.facet(ac)}/x/.unicode;var sc=z.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}}),cc=Fi.fromClass(class{constructor(e){this.input=e.state.facet(dc),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(sc);this.top=new lc(e,!0,t.topContainer),this.bottom=new lc(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(sc);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new lc(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new lc(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(dc);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>J.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),lc=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`,this.dom.style[this.top?`top`:`bottom`]=`0`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=uc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=uc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function uc(e){let t=e.nextSibling;return e.remove(),t}var dc=z.define({enables:cc}),fc=class extends gn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};fc.prototype.elementClass=``,fc.prototype.toDOM=void 0,fc.prototype.mapMode=gt.TrackBefore,fc.prototype.startSide=fc.prototype.endSide=-1,fc.prototype.point=!0;var pc=1024,mc=0,hc=class{constructor(e,t){this.from=e,this.to=t}},Y=class{constructor(e={}){this.id=mc++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=vc.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Y.closedBy=new Y({deserialize:e=>e.split(` `)}),Y.openedBy=new Y({deserialize:e=>e.split(` `)}),Y.group=new Y({deserialize:e=>e.split(` `)}),Y.isolate=new Y({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),Y.contextHash=new Y({perNode:!0}),Y.lookAhead=new Y({perNode:!0}),Y.mounted=new Y({perNode:!0});var gc=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Y.mounted.id]}},_c=Object.create(null),vc=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):_c,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.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(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(Y.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(Y.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};vc.none=new vc(``,Object.create(null),0,8);var yc=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new vc(e.name,r,e.id,e.flags):e)}return new e(n)}},bc=new WeakMap,xc=new WeakMap,Sc;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(Sc||={});var Cc=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=gc.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new Lc(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new Lc(bc.get(this)||this.topNode);return r.moveTo(e,t),bc.set(this,r._tree),r}get topNode(){return new kc(this,0,0,null)}resolve(e,t=0){let n=Dc(bc.get(this)||this.topNode,e,t,!1);return bc.set(this,n),n}resolveInner(e,t=0){let n=Dc(xc.get(this)||this.topNode,e,t,!0);return xc.set(this,n),n}resolveStack(e,t=0){return Ic(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&Sc.IncludeAnonymous)>0;for(let e=this.cursor(a|Sc.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:Hc(vc.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(vc.none,t,n,r)))}static build(e){return zc(e)}};Cc.empty=new Cc(vc.none,[],[],0);var wc=class e{constructor(e,t){this.buffer=e,this.index=t}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 e(this.buffer,this.index)}},Tc=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return vc.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(Ec(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function Ec(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Dc(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof kc&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:Sc.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof kc&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var Oc=class{cursor(e=0){return new Lc(this,e)}getChild(e,t=null,n=null){let r=Ac(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Ac(this,e,t,n)}resolve(e,t=0){return Dc(this,e,t,!1)}resolveInner(e,t=0){return Dc(this,e,t,!0)}matchContext(e){return jc(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},kc=class e extends Oc{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&Sc.EnterBracketed&&l instanceof Cc&&(d=gc.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!Ec(i,r,u,u+l.length))){if(l instanceof Tc){if(a&Sc.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new Nc(new Mc(o,l,t,u),null,e)}else if(a&Sc.IncludeAnonymous||!l.type.isAnonymous||Rc(l)){let s;if(!(a&Sc.IgnoreMounts)&&(s=gc.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&Sc.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&Sc.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<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(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&Sc.IgnoreOverlays)&&(i=gc.get(this._tree))&&i.overlay){let a=t-this.from,o=r&Sc.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Ac(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function jc(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Mc=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Nc=class e extends Oc{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(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&Sc.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new Cc(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Pc(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof kc&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new Fc(i,n)}var Fc=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Pc(this.heads)}};function Ic(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof kc?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=gc.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new kc(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(Dc(o,t,n,!1))}}return i?Pc(i):r}var Lc=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Sc.EnterBracketed,e instanceof kc)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof kc?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Sc.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Sc.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Sc.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&Sc.IncludeAnonymous||e instanceof Tc||!e.type.isAnonymous||Rc(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new Nc(this.buffer,t,this.stack[e]);return this.bufferNode=new Nc(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return jc(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return jc(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function Rc(e){return e.children.some(e=>e instanceof Tc||!e.type.isAnonymous||Rc(e))}function zc(e){let{buffer:t,nodeSet:n,maxBufferLength:r=pc,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new wc(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0)if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(w==-3){c=x;return}else if(w==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${w}`);let D=s[x],ee,O,te=S-e;if(C-S<=r&&(O=h(o.pos-t,y))){let t=new Uint16Array(O.size-O.skip),r=o.pos-O.size,i=t.length;for(;o.pos>r;)i=g(O.start,t,i);ee=new Tc(t,C-O.start,n),te=O.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);ee=Hc(D,t,n,0,t.length,0,C-S,e,e)}else ee=m(D,t,n,C-S,T-C,E)}_.push(ee),v.push(te)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new Tc(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof Cc){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(Y.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[Y.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[Y.lookAhead,i];o=o?[e].concat(o):[e]}return new Cc(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new Cc(s[e.topID],_.reverse(),v.reverse(),y)}var Bc=new WeakMap;function Vc(e,t){if(!e.isAnonymous||t instanceof Tc||t.type!=e)return 1;let n=Bc.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Cc)){n=1;break}n+=Vc(e,r)}Bc.set(t,n)}return n}function Hc(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=Vc(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=Vc(e,t[s]);for(s++;s<i;s++){let n=Vc(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(Hc(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var Uc=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},Wc=class{startParse(e,t,n){return typeof e==`string`&&(e=new Gc(e)),n=n?n.length?n.map(e=>new hc(e.from,e.to)):[new hc(0,0)]:[new hc(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},Gc=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new Y({perNode:!0});var Kc=0,qc=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Kc++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new Yc(e);return e=>e.modified.indexOf(t)>-1?e:Yc.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Jc=0,Yc=class e{constructor(e){this.name=e,this.instances=[],this.id=Jc++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Xc(n,e.modified));if(r)return r;let i=[],a=new qc(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=Zc(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Xc(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function Zc(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function Qc(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new el(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return $c.add(t)}var $c=new Y({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new el(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),el=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};el.empty=new el([],2,null);function tl(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function nl(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function rl(e,t,n,r=0,i=e.length){let a=new il(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var il=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=al(e)||el.empty,u=nl(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(Y.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function al(e){let t=e.type.prop($c);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=qc.define,ol=X(),sl=X(),cl=X(sl),ll=X(sl),ul=X(),dl=X(ul),fl=X(ul),pl=X(),ml=X(pl),hl=X(),gl=X(),_l=X(),vl=X(_l),yl=X(),Z={comment:ol,lineComment:X(ol),blockComment:X(ol),docComment:X(ol),name:sl,variableName:X(sl),typeName:cl,tagName:X(cl),propertyName:ll,attributeName:X(ll),className:X(sl),labelName:X(sl),namespace:X(sl),macroName:X(sl),literal:ul,string:dl,docString:X(dl),character:X(dl),attributeValue:X(dl),number:fl,integer:X(fl),float:X(fl),bool:X(ul),regexp:X(ul),escape:X(ul),color:X(ul),url:X(ul),keyword:hl,self:X(hl),null:X(hl),atom:X(hl),unit:X(hl),modifier:X(hl),operatorKeyword:X(hl),controlKeyword:X(hl),definitionKeyword:X(hl),moduleKeyword:X(hl),operator:gl,derefOperator:X(gl),arithmeticOperator:X(gl),logicOperator:X(gl),bitwiseOperator:X(gl),compareOperator:X(gl),updateOperator:X(gl),definitionOperator:X(gl),typeOperator:X(gl),controlOperator:X(gl),punctuation:_l,separator:X(_l),bracket:vl,angleBracket:X(vl),squareBracket:X(vl),paren:X(vl),brace:X(vl),content:pl,heading:ml,heading1:X(ml),heading2:X(ml),heading3:X(ml),heading4:X(ml),heading5:X(ml),heading6:X(ml),contentSeparator:X(pl),list:X(pl),quote:X(pl),emphasis:X(pl),strong:X(pl),link:X(pl),monospace:X(pl),strikethrough:X(pl),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:yl,documentMeta:X(yl),annotation:X(yl),processingInstruction:X(yl),definition:qc.defineModifier(`definition`),constant:qc.defineModifier(`constant`),function:qc.defineModifier(`function`),standard:qc.defineModifier(`standard`),local:qc.defineModifier(`local`),special:qc.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof qc&&(t.name=e)}tl([{tag:Z.link,class:`tok-link`},{tag:Z.heading,class:`tok-heading`},{tag:Z.emphasis,class:`tok-emphasis`},{tag:Z.strong,class:`tok-strong`},{tag:Z.keyword,class:`tok-keyword`},{tag:Z.atom,class:`tok-atom`},{tag:Z.bool,class:`tok-bool`},{tag:Z.url,class:`tok-url`},{tag:Z.labelName,class:`tok-labelName`},{tag:Z.inserted,class:`tok-inserted`},{tag:Z.deleted,class:`tok-deleted`},{tag:Z.literal,class:`tok-literal`},{tag:Z.string,class:`tok-string`},{tag:Z.number,class:`tok-number`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:`tok-string2`},{tag:Z.variableName,class:`tok-variableName`},{tag:Z.local(Z.variableName),class:`tok-variableName tok-local`},{tag:Z.definition(Z.variableName),class:`tok-variableName tok-definition`},{tag:Z.special(Z.variableName),class:`tok-variableName2`},{tag:Z.definition(Z.propertyName),class:`tok-propertyName tok-definition`},{tag:Z.typeName,class:`tok-typeName`},{tag:Z.namespace,class:`tok-namespace`},{tag:Z.className,class:`tok-className`},{tag:Z.macroName,class:`tok-macroName`},{tag:Z.propertyName,class:`tok-propertyName`},{tag:Z.operator,class:`tok-operator`},{tag:Z.comment,class:`tok-comment`},{tag:Z.meta,class:`tok-meta`},{tag:Z.invalid,class:`tok-invalid`},{tag:Z.punctuation,class:`tok-punctuation`}]);var bl=new Y;function xl(e){return z.define({combine:e?t=>t.concat(e):void 0})}var Sl=new Y,Cl=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,H.prototype.hasOwnProperty(`tree`)||Object.defineProperty(H.prototype,`tree`,{get(){return El(this)}}),this.parser=t,this.extension=[Il.of(this),H.languageData.of((e,t,n)=>{let r=wl(e,t,n),i=r.type.prop(bl);if(!i)return[];let a=e.facet(i),o=r.type.prop(Sl);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return wl(e,t,n).type.prop(bl)==this.data}findRegions(e){let t=e.facet(Il);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(bl)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(Y.mounted);if(i){if(i.tree.prop(bl)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof Cc&&r(i,e.positions[n]+t)}};return r(El(e),0),n}get allowsNesting(){return!0}};Cl.setState=V.define();function wl(e,t,n){let r=e.facet(Il),i=El(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,Sc.ExcludeBuffers|Sc.EnterBracketed))e.type.isTop&&(i=e);return i}var Tl=class e extends Cl{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=xl(t.languageData);return new e(n,t.parser.configure({props:[bl.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function El(e){let t=e.field(Cl.state,!1);return t?t.tree:Cc.empty}function Dl(e,t,n=50){let r=e.field(Cl.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}var Ol=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},kl=null,Al=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],Cc.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Ol(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Cc.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(Uc.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Uc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=kl;kl=this;try{return e()}finally{kl=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=jl(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=Uc.applyChanges(r,e),i=Cc.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=jl(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Wc{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=kl;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new Cc(vc.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return kl}};function jl(e,t,n){return Uc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Ml=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Al.create(t.facet(Il).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};Cl.state=Nt.define({create:Ml.init,update(e,t){for(let e of t.effects)if(e.is(Cl.setState))return e.value;return t.startState.facet(Il)==t.state.facet(Il)?e.apply(t):Ml.init(t.state)}});var Nl=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Nl=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Pl=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,Fl=Fi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Cl.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Cl.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Nl(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(Cl.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Pl?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>Pl&&Pl()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Cl.setState.of(new Ml(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>ji(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Il=z.define({combine(e){return e.length?e[0]:null},enables:e=>[Cl.state,Fl,J.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Ll=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Rl=z.define(),zl=z.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function Bl(e){let t=e.facet(zl);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Vl(e,t){let n=``,r=e.tabSize,i=e.facet(zl)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function Hl(e,t){e instanceof H&&(e=new Ul(e));for(let n of e.state.facet(Rl)){let r=n(e,t);if(r!==void 0)return r}let n=El(e.state);return n.length>=t?Gl(e,n,t):null}var Ul=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Bl(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Pn(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},Wl=new Y;function Gl(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return Kl(r,e,n)}function Kl(e,t,n){for(let r=e;r;r=r.next){let e=Jl(r.node);if(e)return e(Xl.create(t,n,r))}return 0}function ql(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Jl(e){let t=e.type.prop(Wl);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Y.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>$l(e,!0,1,void 0,n&&!ql(e)?t.from:void 0)}return e.parent==null?Yl:null}function Yl(){return 0}var Xl=class e extends Ul{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Zl(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Kl(this.context.next,this.base,this.pos)}};function Zl(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Ql(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function $l(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?Ql(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function eu({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var tu=z.define(),nu=new Y;function ru(e,t,n){let r=El(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(nu);if(s&&(i.to<r.length-50||r.length==e.doc.length||!iu(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function iu(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function au(e,t,n){for(let r of e.facet(tu)){let i=r(e,t,n);if(i)return i}return ru(e,t,n)}function ou(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var su=V.define({map:ou}),cu=V.define({map:ou});function lu(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var uu=Nt.define({create(){return W.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=du(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(su)&&!pu(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(vu),i=r?W.replace({widget:new Su(r(t.state,n.value))}):xu;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(cu)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=du(e,t.selection.main.head)),e},provide:e=>J.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(xu.range(r,i))}return W.set(t,!0)}});function du(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function fu(e,t,n){var r;let i=null;return(r=e.field(uu,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function pu(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function mu(e,t){return e.field(uu,!1)?t:t.concat(V.appendConfig.of(yu()))}var hu=e=>{for(let t of lu(e)){let n=au(e.state,t.from,t.to);if(n)return e.dispatch({effects:mu(e.state,[su.of(n),gu(e,n)])}),!0}return!1};function gu(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return J.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var _u={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},vu=z.define({combine(e){return hn(e,_u)}});function yu(e){let t=[uu,Cu];return e&&t.push(vu.of(e)),t}function bu(e,t){let{state:n}=e,r=n.facet(vu),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=fu(e.state,n.from,n.to);r&&e.dispatch({effects:cu.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var xu=W.replace({widget:new class extends pr{toDOM(e){return bu(e,null)}}}),Su=class extends pr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return bu(e,this.value)}},Cu=J.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),wu=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=Bn.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof Cl?e=>e.prop(bl)==a.data:a?e=>e==a:void 0,this.style=tl(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Bn(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},Tu=z.define(),Eu=z.define({combine(e){return e.length?[e[0]]:null}});function Du(e){let t=e.facet(Tu);return t.length?t:e.facet(Eu)}function Ou(e,t){let n=[Au],r;return e instanceof wu&&(e.module&&n.push(J.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Eu.of(e)):r?n.push(Tu.computeN([J.darkTheme],t=>t.facet(J.darkTheme)==(r==`dark`)?[e]:[])):n.push(Tu.of(e)),n}var ku=class{constructor(e){this.markCache=Object.create(null),this.tree=El(e.state),this.decorations=this.buildDeco(e,Du(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=El(e.state),n=Du(e.state),r=n!=Du(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return W.none;let n=new Cn;for(let{from:r,to:i}of e.visibleRanges)rl(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=W.mark({class:r})))},r,i);return n.finish()}},Au=It.high(Fi.fromClass(ku,{decorations:e=>e.decorations}));wu.define([{tag:Z.meta,color:`#404740`},{tag:Z.link,textDecoration:`underline`},{tag:Z.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strong,fontWeight:`bold`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.keyword,color:`#708`},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:`#219`},{tag:[Z.literal,Z.inserted],color:`#164`},{tag:[Z.string,Z.deleted],color:`#a11`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:`#e40`},{tag:Z.definition(Z.variableName),color:`#00f`},{tag:Z.local(Z.variableName),color:`#30a`},{tag:[Z.typeName,Z.namespace],color:`#085`},{tag:Z.className,color:`#167`},{tag:[Z.special(Z.variableName),Z.macroName],color:`#256`},{tag:Z.definition(Z.propertyName),color:`#00c`},{tag:Z.comment,color:`#940`},{tag:Z.invalid,color:`#f00`}]);var ju=1e4,Mu=`()[]{}`,Nu=new Y;function Pu(e,t,n){let r=e.prop(t<0?Y.openedBy:Y.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function Fu(e){let t=e.type.prop(Nu);return t?t(e.node):e}function Iu(e,t,n,r={}){let i=r.maxScanDistance||ju,a=r.brackets||Mu,o=El(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=Pu(r.type,n,a);if(i&&r.from<r.to){let o=Fu(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Lu(e,t,n,r,o,i,a)}}return Ru(e,t,n,o,s.type,i,a)}function Lu(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=Fu(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(Pu(u.type,n,o))l++;else if(Pu(u.type,-n,o)){if(l==0){let e=Fu(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Ru(e,t,n,r,i,a,o){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function zu(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var Bu=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=zu(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??zu(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}},Vu=Object.create(null),Hu=[vc.none],Uu=[],Wu=Object.create(null),Gu=Object.create(null);for(let[e,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`]])Gu[e]=qu(Vu,t);function Ku(e,t){Uu.indexOf(e)>-1||(Uu.push(e),console.warn(t))}function qu(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Z[n];r?typeof r==`function`?t.length?t=t.map(r):Ku(n,`Modifier ${n} used at start of tag`):t.length?Ku(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Ku(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=Wu[i];if(a)return a.id;let o=Wu[i]=vc.define({id:Hu.length,name:r,props:[Qc({[r]:n})]});return Hu.push(o),o.id}W.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`rtl`},bidiIsolate:Jr.RTL}),W.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`ltr`},bidiIsolate:Jr.LTR}),W.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`auto`},bidiIsolate:null});function Ju(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Yu=Ju(Zu,0);function Xu(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}function Zu(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Xu(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Qu=Zt.define(),$u=Zt.define(),ed=z.define(),td=z.define({combine(e){return hn(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),nd=Nt.define({create(){return xd.empty},update(e,t){let n=t.state.facet(td),r=t.annotation(Qu);if(r){let i=ld.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?ud(o,o.length,n.minDepth,i):gd(o,t.startState.selection),new xd(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation($u);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(en.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=ld.fromTransaction(t),o=t.annotation(en.time),s=t.annotation(en.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new xd(e.done.map(ld.fromJSON),e.undone.map(ld.fromJSON))}});function rd(e={}){return[nd,td.of(e),J.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ad:e.inputType==`historyRedo`?od:null;return n?(e.preventDefault(),n(t)):!1}})]}function id(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(nd,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ad=id(0,!1),od=id(1,!1),sd=id(0,!0),cd=id(1,!0),ld=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&vt.fromJSON(t.changes),[],t.mapped&&_t.fromJSON(t.mapped),t.startSelection&&R.fromJSON(t.startSelection),t.selectionsAfter.map(R.fromJSON))}static fromTransaction(t,n){let r=md;for(let e of t.startState.facet(ed)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,md)}static selection(t){return new e(void 0,md,void 0,void 0,t)}};function ud(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function dd(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function fd(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function pd(e,t){return e.length?t.length?e.concat(t):e:t}var md=[],hd=200;function gd(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-hd));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),ud(e,e.length-1,1e9,n.setSelAfter(r)))}else return[ld.selection([t])]}function _d(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function vd(e,t){if(!e.length)return e;let n=e.length,r=md;for(;n;){let i=yd(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[ld.selection(r)]:md}function yd(e,t,n){let r=pd(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):md,n);if(!e.changes)return ld.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new ld(i,V.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var bd=/^(input\.type|delete)($|\.)/,xd=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||bd.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,dd(s.changes,t.changes))||r==`input.type.compose`)?ud(o,o.length-1,i.minDepth,new ld(t.changes.compose(s.changes),pd(V.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,md)):ud(o,o.length,i.minDepth,t),new e(o,md,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:md;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&fd(a[a.length-1],t)?this:new e(gd(this.done,t),this.undone,n,r)}addMapping(t){return new e(vd(this.done,t),vd(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Qu.of({side:e,rest:_d(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?md:r.slice(0,r.length-1);return i.mapped&&(n=vd(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Qu.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};xd.empty=new xd(md,md);var Sd=[{key:`Mod-z`,run:ad,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:od,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:od,preventDefault:!0},{key:`Mod-u`,run:sd,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:cd,preventDefault:!0}];function Cd(e,t){return R.create(e.ranges.map(t),e.mainIndex)}function wd(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function Td({state:e,dispatch:t},n){let r=Cd(e.selection,n);return r.eq(e.selection,!0)?!1:(t(wd(e,r)),!0)}function Ed(e,t){return R.cursor(t?e.to:e.from)}function Dd(e,t){return Td(e,n=>n.empty?e.moveByChar(n,t):Ed(n,t))}function Od(e){return e.textDirectionAt(e.state.selection.main.head)==Jr.LTR}var kd=e=>Dd(e,!Od(e)),Ad=e=>Dd(e,!1);typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function jd(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=R.cursor(r.from+n))}return i}var Md=e=>Td(e,t=>jd(e,t,!0)),Nd=e=>Td(e,t=>jd(e,t,!1));function Pd(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=El(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Y.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Fd=Id(!1);function Id(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Pd(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new Ul(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Hl(s,r);for(c??=Pn(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Vl(t,c)];return o&&l.push(Vl(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:L.of(l)},range:R.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Ld(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:R.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Rd=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ul(e,{overrideIndentation:e=>n[e]??-1}),i=Ld(e,(t,i,a)=>{let o=Hl(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Vl(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},zd=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Ld(e,(t,n)=>{n.push({from:t.from,insert:e.facet(zl)})}),{userEvent:`input.indent`})),!0),Bd=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Ld(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Pn(r,e.tabSize),a=0,o=Vl(e,Math.max(0,i-Bl(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Vd=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new Hd(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from,c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,r=this.buffer.length;if(r==0&&e.parent&&(r=e.bufferBase-e.parent.bufferBase,e=e.parent),r>0&&e.buffer[r-4]==0&&e.buffer[r-1]>-1){if(t==n)return;if(e.buffer[r-2]>=t){e.buffer[r-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(;n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Ud(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216))if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}})};return n(this.state,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:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Hd(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},Hd=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},Ud=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3,this.state=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0)}},Wd=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.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 e(this.stack,this.pos,this.index)}};function Gd(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var Kd=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},qd=new Kd,Jd=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=qd,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos);this.chunk=this.pos+e.length>this.range.to?e.slice(0,this.range.to-this.pos):e,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(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,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(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=qd,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},Yd=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Qd(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};Yd.prototype.contextual=Yd.prototype.fallback=Yd.prototype.extend=!1;var Xd=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?Gd(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(Qd(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};Xd.prototype.contextual=Yd.prototype.fallback=Yd.prototype.extend=!1;var Zd=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function Qd(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||ef(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function $d(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function ef(e,t,n,r){let i=$d(n,r,t);return i<0||$d(n,r,e)<i}var tf=typeof process<`u`&&/\bparse\b/.test({}.LOG),nf=null;function rf(e,t,n){let r=e.cursor(Sc.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var af=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?rf(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?rf(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof Cc){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(Y.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},of=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new Kd)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if(!(n&&!c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new Kd,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Kd,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535)if(o[s+1]==1)s=df(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(df(o,s+2),t,n,r));break}o[s]==t&&(r=this.putAction(df(o,s+1),t,n,r))}return r}},sf=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,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 Jd(t,r),this.tokens=new of(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[Vd.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new af(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&ff(r);if(e)return tf&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw tf&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return tf&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=tf?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(Y.contextHash)||0)==n))return e.useNode(o,r),tf&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof Cc)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof Cc&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),tf&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),tf&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return cf(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=tf?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),tf&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(tf&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)tf&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))tf&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),tf&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),cf(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),Cc.build({buffer:Wd.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(nf||=new WeakMap).get(e);return t||nf.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function cf(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var lf=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},uf=class e extends Wc{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=Y[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new yc(t.map((t,i)=>vc.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=pc;let a=Gd(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(pf),this.states=Gd(e.states,Uint32Array),this.data=Gd(e.stateData),this.goto=Gd(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new Yd(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new sf(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535)if(n[i+1]==1)a=n[i=df(n,i+2)];else if(n[i+1]==2)return df(n,i+2);else break;if(a==t||a==0)return df(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=df(this.data,n+2);else break;r=t(df(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=df(this.data,n+2);else break;if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=pf(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new lf(e,n,r)}static deserialize(t){return new e(t)}};function df(e,t){return e[t]|e[t+1]<<16}function ff(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function pf(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}function mf(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function hf(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=mf(t)+mf(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function gf(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:hf(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function _f(e,t){return n=>{for(let t=El(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}typeof navigator==`object`&&/Win/.test(navigator.platform);var vf=new class extends gn{};vf.startSide=1,vf.endSide=-1,typeof navigator==`object`&&/Android\b/.test(navigator.userAgent);var yf=36,bf=1,xf=2,Sf=3,Cf=4,wf=5,Tf=6,Ef=7,Df=8,Of=9,kf=10,Af=11,jf=12,Mf=13,Nf=14,Pf=15,Ff=16,If=17,Lf=18,Rf=19,zf=20,Bf=21,Vf=22,Hf=23,Uf=24;function Wf(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function Gf(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Kf(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function qf(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue scan;e.advance()}if(e.next==36){e.advance();return}}else e.advance()}}function Jf(e,t){let n=`[{<(`.indexOf(String.fromCharCode(t)),r=n<0?t:`]}>)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function Yf(e,t){for(;!(e.next!=95&&!Wf(e.next));)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Xf(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),Kf(e,t,!1)}else Yf(e)}function Zf(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function Qf(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function $f(e){for(;!(e.next<0||e.next==10);)e.advance()}function ep(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var tp=` \r
14
+ `;function np(e,t,n){let r=Object.create(null);r.true=r.false=wf,r.null=r.unknown=Tf;for(let t of e.split(` `))t&&(r[t]=zf);for(let e of t.split(` `))e&&(r[e]=Bf);for(let e of(n||``).split(` `))e&&(r[e]=Uf);return r}var rp=`array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying `,ip=`absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone `,ap={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:`*+-%<>!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:np(ip,rp)};function op(e,t,n,r){let i={};for(let t in ap)i[t]=(e.hasOwnProperty(t)?e:ap)[t];return t&&(i.words=np(t,n||``,r)),i}function sp(e){return new Zd(t=>{let{next:n}=t;if(t.advance(),ep(n,tp)){for(;ep(t.next,tp);)t.advance();t.acceptToken(yf)}else if(n==36&&e.doubleDollarQuotedStrings){let e=Yf(t,``);t.next==36&&(t.advance(),qf(t,e),t.acceptToken(Sf))}else if(n==39||n==34&&e.doubleQuotedStrings)Kf(t,n,e.backslashEscapes),t.acceptToken(Sf);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)$f(t),t.acceptToken(bf);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))$f(t),t.acceptToken(bf);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(xf)}else if((n==101||n==69)&&t.next==39)t.advance(),Kf(t,39,!0),t.acceptToken(Sf);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),Kf(t,39,e.backslashEscapes),t.acceptToken(Sf);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),Kf(t,39,e.backslashEscapes),t.acceptToken(Sf);break}if(!Wf(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!ep(t.peek(1),tp)){let e=t.peek(1);t.advance(2),Jf(t,e),t.acceptToken(Sf)}else if(ep(n,e.identifierQuotes))Kf(t,n==91?93:n,!1),t.acceptToken(Rf);else if(n==40)t.acceptToken(Ef);else if(n==41)t.acceptToken(Df);else if(n==123)t.acceptToken(Of);else if(n==125)t.acceptToken(kf);else if(n==91)t.acceptToken(Af);else if(n==93)t.acceptToken(jf);else if(n==59)t.acceptToken(Mf);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),Zf(t),t.acceptToken(Vf);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(Kf(t,n,e.backslashEscapes),t.acceptToken(Hf)):(Zf(t,n),t.acceptToken(Vf))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();Gf(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(Cf)}else if(n==46&&t.next>=48&&t.next<=57)Qf(t,!0),t.acceptToken(Cf);else if(n==46)t.acceptToken(Nf);else if(n>=48&&n<=57)Qf(t,!1),t.acceptToken(Cf);else if(ep(n,e.operatorChars)){for(;ep(t.next,e.operatorChars);)t.advance();t.acceptToken(Pf)}else if(ep(n,e.specialVar))t.next==n&&t.advance(),Xf(t),t.acceptToken(If);else if(n==58||n==44)t.acceptToken(Ff);else if(Wf(n)){let r=Yf(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?Lf:e.words[r.toLowerCase()]??Lf)}})}var cp=sp(ap),lp=uf.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,cp],topRules:{Script:[0,25]},tokenPrec:0});function up(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function dp(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function fp(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function pp(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)fp(r)&&n.push(dp(e,r));return n}return[dp(e,t)]}function mp(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=up(t);if(!fp(r))return n;n.unshift(dp(e,r)),t=up(r)}}function hp(e,t){let n=El(e).resolveInner(t,-1),r=_p(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:mp(e.doc,up(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:mp(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var gp=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function _p(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&fp(t.nextSibling))o=dp(e,t.nextSibling);else if(n&&gp.has(n))break;else a&&fp(t)&&(o=dp(e,t));o&&(r||=Object.create(null),r[o]=pp(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function vp(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var yp=/^\w*$/,bp=/^[`'"\[]?\w*[`'"\]]?$/;function xp(e){return e.self&&typeof e.self.label==`string`}var Sp=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(Cp(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?Cp(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):xp(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;xp(n)&&(r=n.self,n=n.children);for(let e=0;e<i.length;e++)r&&e==i.length-1&&a.addCompletion(r),a=a.child(i[e].replace(/\\\./g,`.`));a.addNamespace(n)}}};function Cp(e,t,n,r){return RegExp(`^[a-z_][a-z_\\d]*$`,r?`i`:``).test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+wp(n)}}function wp(e){return e===`[`?`]`:e}function Tp(e,t,n,r,i,a){let o=new Sp(a?.spec.identifierQuotes?.[0]||`"`,!!a?.spec.caseInsensitiveIdentifiers),s=i?o.child(i):null;return o.addNamespace(e),t&&(s||o).addCompletions(t),n&&o.addCompletions(n),s&&o.addCompletions(s.list),r&&o.addCompletions((s||o).child(r).list),e=>{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=hp(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=wp(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:vp(t,r,u),validFor:bp}}else return{from:n,options:u,validFor:yp}}}function Ep(e){return e==Bf?`type`:e==zf?`keyword`:`variable`}function Dp(e,t,n){return _f([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],gf(Object.keys(e).map(r=>n(t?r.toUpperCase():r,Ep(e[r])))))}var Op=lp.configure({props:[Wl.add({Statement:eu()}),nu.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),Qc({Keyword:Z.keyword,Type:Z.typeName,Builtin:Z.standard(Z.name),Bits:Z.number,Bytes:Z.string,Bool:Z.bool,Null:Z.null,Number:Z.number,String:Z.string,Identifier:Z.name,QuotedIdentifier:Z.special(Z.string),SpecialVar:Z.special(Z.name),LineComment:Z.lineComment,BlockComment:Z.blockComment,Operator:Z.operator,"Semi Punctuation":Z.punctuation,"( )":Z.paren,"{ }":Z.brace,"[ ]":Z.squareBracket})]}),kp=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=op(t,t.keywords,t.types,t.builtin);return new e(n,Tl.define({name:`sql`,parser:Op.configure({tokenizers:[{from:cp,to:sp(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}}),t)}};function Ap(e,t){return{label:e,type:t,boost:-1}}function jp(e,t=!1,n){return Dp(e.dialect.words,t,n||Ap)}function Mp(e){return e.schema?Tp(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||Fp):()=>null}function Np(e){return e.schema?(e.dialect||Fp).language.data.of({autocomplete:Mp(e)}):[]}function Pp(e={}){let t=e.dialect||Fp;return new Ll(t.language,[Np(e),t.language.data.of({autocomplete:jp(t,e.upperCaseKeywords,e.keywordCompletion)})])}var Fp=kp.define({});kp.define({charSetCasts:!0,doubleDollarQuotedStrings:!0,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:``,keywords:ip+`abort abs absent access according ada admin aggregate alias also always analyse analyze array_agg array_max_cardinality asensitive assert assignment asymmetric atomic attach attribute attributes avg backward base64 begin_frame begin_partition bernoulli bit_length blocked bom cache called cardinality catalog_name ceil ceiling chain char_length character_length character_set_catalog character_set_name character_set_schema characteristics characters checkpoint class class_origin cluster coalesce cobol collation_catalog collation_name collation_schema collect column_name columns command_function command_function_code comment comments committed concurrently condition_number configuration conflict connection_name constant constraint_catalog constraint_name constraint_schema contains content control conversion convert copy corr cost covar_pop covar_samp csv cume_dist current_catalog current_row current_schema cursor_name database datalink datatype datetime_interval_code datetime_interval_precision db debug defaults defined definer degree delimiter delimiters dense_rank depends derived detach detail dictionary disable discard dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue document dump dynamic_function dynamic_function_code element elsif empty enable encoding encrypted end_frame end_partition endexec enforced enum errcode error event every exclude excluding exclusive exp explain expression extension extract family file filter final first_value flag floor following force foreach fortran forward frame_row freeze fs functions fusion generated granted greatest groups handler header hex hierarchy hint id ignore ilike immediately immutable implementation implicit import include including increment indent index indexes info inherit inherits inline insensitive instance instantiable instead integrity intersection invoker isnull key_member key_type label lag last_value lead leakproof least length library like_regex link listen ln load location lock locked log logged lower mapping matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text min minvalue mod mode more move multiset mumps name namespace nfc nfd nfkc nfkd nil normalize normalized nothing notice notify notnull nowait nth_value ntile nullable nullif nulls number occurrences_regex octet_length octets off offset oids operator options ordering others over overlay overriding owned owner parallel parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partition pascal passing passthrough password percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding prepared print_strict_params procedural procedures program publication query quote raise range rank reassign recheck recovery refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex rename repeatable replace replica requiring reset respect restart restore result_oid returned_cardinality returned_length returned_octet_length returned_sqlstate returning reverse routine_catalog routine_name routine_schema routines row_count row_number rowtype rule scale schema_name schemas scope scope_catalog scope_name scope_schema security selective self sensitive sequence sequences serializable server server_name setof share show simple skip slice snapshot source specific_name sqlcode sqlerror sqrt stable stacked standalone statement statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time table_name tables tablesample tablespace temp template ties token top_level_count transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex trigger_catalog trigger_name trigger_schema trim trim_array truncate trusted type types uescape unbounded uncommitted unencrypted unlink unlisten unlogged unnamed untyped upper uri use_column use_variable user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema vacuum valid validate validator value_of var_pop var_samp varbinary variable_conflict variadic verbose version versioning views volatile warning whitespace width_bucket window within wrapper xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate yes`,types:rp+`bigint int8 bigserial serial8 varbit bool box bytea cidr circle precision float8 inet int4 json jsonb line lseg macaddr macaddr8 money numeric pg_lsn point polygon float4 int2 smallserial serial2 serial serial4 text timetz timestamptz tsquery tsvector txid_snapshot uuid xml`});var Ip=rp+`bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int1 int2 int3 int4 int8 float4 float8 varbinary varcharacter precision datetime unsigned signed`,Lp=`charset clear edit ego help nopager notee nowarning pager print prompt quit rehash source status system tee`;kp.define({operatorChars:`*+-%<>!=&|^`,charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:`@?`,identifierQuotes:"`",keywords:ip+`group_concat accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill`,types:Ip,builtin:Lp}),kp.define({operatorChars:`*+-%<>!=&|^`,charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:`@?`,identifierQuotes:"`",keywords:ip+`always generated groupby_concat hard persistent shutdown soft virtual accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill`,types:Ip,builtin:Lp}),kp.define({keywords:ip+`add external procedure all fetch public alter file raiserror and fillfactor read any for readtext as foreign reconfigure asc freetext references authorization freetexttable replication backup from restore begin full restrict between function return break goto revert browse grant revoke bulk group right by having rollback cascade holdlock rowcount case identity rowguidcol check identity_insert rule checkpoint identitycol save close if schema clustered in securityaudit coalesce index select collate inner semantickeyphrasetable column insert semanticsimilaritydetailstable commit intersect semanticsimilaritytable compute into session_user constraint is set contains join setuser containstable key shutdown continue kill some convert left statistics create like system_user cross lineno table current load tablesample current_date merge textsize current_time national then current_timestamp nocheck to current_user nonclustered top cursor not tran database null transaction dbcc nullif trigger deallocate of truncate declare off try_convert default offsets tsequal delete on union deny open unique desc opendatasource unpivot disk openquery update distinct openrowset updatetext distributed openxml use double option user drop or values dump order varying else outer view end over waitfor errlvl percent when escape pivot where except plan while exec precision with execute primary within group exists print writetext exit proc noexpand index forceseek forcescan holdlock nolock nowait paglock readcommitted readcommittedlock readpast readuncommitted repeatableread rowlock serializable snapshot spatial_window_max_cells tablock tablockx updlock xlock keepidentity keepdefaults ignore_constraints ignore_triggers`,types:rp+`smalldatetime datetimeoffset datetime2 datetime bigint smallint smallmoney tinyint money real text nvarchar ntext varbinary image hierarchyid uniqueidentifier sql_variant xml`,builtin:`approx_count_distinct approx_percentile_cont approx_percentile_disc avg checksum_agg count count_big grouping grouping_id max min product stdev stdevp sum var varp ai_generate_embeddings ai_generate_chunks cume_dist first_value lag last_value lead percentile_cont percentile_disc percent_rank left_shift right_shift bit_count get_bit set_bit collationproperty tertiary_weights @@datefirst @@dbts @@langid @@language @@lock_timeout @@max_connections @@max_precision @@nestlevel @@options @@remserver @@servername @@servicename @@spid @@textsize @@version cast convert parse try_cast try_convert try_parse asymkey_id asymkeyproperty certproperty cert_id crypt_gen_random decryptbyasymkey decryptbycert decryptbykey decryptbykeyautoasymkey decryptbykeyautocert decryptbypassphrase encryptbyasymkey encryptbycert encryptbykey encryptbypassphrase hashbytes is_objectsigned key_guid key_id key_name signbyasymkey signbycert symkeyproperty verifysignedbycert verifysignedbyasymkey @@cursor_rows @@fetch_status cursor_status datalength ident_current ident_incr ident_seed identity sql_variant_property @@datefirst current_timestamp current_timezone current_timezone_id date_bucket dateadd datediff datediff_big datefromparts datename datepart datetime2fromparts datetimefromparts datetimeoffsetfromparts datetrunc day eomonth getdate getutcdate isdate month smalldatetimefromparts switchoffset sysdatetime sysdatetimeoffset sysutcdatetime timefromparts todatetimeoffset year edit_distance edit_distance_similarity jaro_winkler_distance jaro_winkler_similarity edge_id_from_parts graph_id_from_edge_id graph_id_from_node_id node_id_from_parts object_id_from_edge_id object_id_from_node_id json isjson json_array json_contains json_modify json_object json_path_exists json_query json_value regexp_like regexp_replace regexp_substr regexp_instr regexp_count regexp_matches regexp_split_to_table abs acos asin atan atn2 ceiling cos cot degrees exp floor log log10 pi power radians rand round sign sin sqrt square tan choose greatest iif least @@procid app_name applock_mode applock_test assemblyproperty col_length col_name columnproperty databasepropertyex db_id db_name file_id file_idex file_name filegroup_id filegroup_name filegroupproperty fileproperty filepropertyex fulltextcatalogproperty fulltextserviceproperty index_col indexkey_property indexproperty next value for object_definition object_id object_name object_schema_name objectproperty objectpropertyex original_db_name parsename schema_id schema_name scope_identity serverproperty stats_date type_id type_name typeproperty dense_rank ntile rank row_number publishingservername certenclosed certprivatekey current_user database_principal_id has_dbaccess has_perms_by_name is_member is_rolemember is_srvrolemember loginproperty original_login permissions pwdencrypt pwdcompare session_user sessionproperty suser_id suser_name suser_sid suser_sname system_user user user_id user_name ascii char charindex concat concat_ws difference format left len lower ltrim nchar patindex quotename replace replicate reverse right rtrim soundex space str string_agg string_escape stuff substring translate trim unicode upper $partition @@error @@identity @@pack_received @@rowcount @@trancount binary_checksum checksum compress connectionproperty context_info current_request_id current_transaction_id decompress error_line error_message error_number error_procedure error_severity error_state formatmessage get_filestream_transaction_context getansinull host_id host_name isnull isnumeric min_active_rowversion newid newsequentialid rowcount_big session_context xact_state @@connections @@cpu_busy @@idle @@io_busy @@pack_sent @@packet_errors @@timeticks @@total_errors @@total_read @@total_write textptr textvalid columns_updated eventdata trigger_nestlevel vector_distance vectorproperty vector_search generate_series opendatasource openjson openquery openrowset openxml predict string_split coalesce nullif apply catch filter force include keep keepfixed modify optimize parameterization parameters partition recompile sequence set`,operatorChars:`*+-%<>!=^&|/`,specialVar:`@`,identifierQuotes:`"[`}),kp.define({keywords:ip+`abort analyze attach autoincrement conflict database detach exclusive fail glob ignore index indexed instead isnull notnull offset plan pragma query raise regexp reindex rename replace temp vacuum virtual`,types:rp+`bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int2 int8 unsigned signed real`,builtin:`auth backup bail changes clone databases dbinfo dump echo eqp explain fullschema headers help import imposter indexes iotrace lint load log mode nullvalue once print prompt quit restore save scanstats separator shell show stats system tables testcase timeout timer trace vfsinfo vfslist vfsname width`,operatorChars:`*+-%<>!=&|/~`,identifierQuotes:'`"',specialVar:`@:?$`}),kp.define({keywords:`add all allow alter and any apply as asc authorize batch begin by clustering columnfamily compact consistency count create custom delete desc distinct drop each_quorum exists filtering from grant if in index insert into key keyspace keyspaces level limit local_one local_quorum modify nan norecursive nosuperuser not of on one order password permission permissions primary quorum rename revoke schema select set storage superuser table three to token truncate ttl two type unlogged update use user users using values where with writetime infinity NaN`,types:rp+`ascii bigint blob counter frozen inet list map static text timeuuid tuple uuid varint`,slashComments:!0}),kp.define({keywords:ip+`abort accept access add all alter and any arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body by case cast char_base check close cluster clusters colauth column comment commit compress connected constant constraint crash create current currval cursor data_base database dba deallocate debugoff debugon declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry exception exception_init exchange exclusive exists external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base of off offline on online only option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw rebuild record ref references refresh rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work`,builtin:`appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define echo editfile embedded feedback flagger flush heading headsep instance linesize lno loboffset logsource longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar repfooter repheader serveroutput shiftinout show showmode spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout timing trimout trimspool ttitle underline verify version wrap`,types:rp+`ascii bfile bfilename bigserial bit blob dec long number nvarchar nvarchar2 serial smallint string text uid varchar2 xml`,operatorChars:`*/+-%<>!=~`,doubleQuotedStrings:!0,charSetCasts:!0,plsqlQuotingMechanism:!0});var Rp=`#e5c07b`,zp=`#e06c75`,Bp=`#56b6c2`,Vp=`#ffffff`,Hp=`#abb2bf`,Up=`#7d8799`,Wp=`#61afef`,Gp=`#98c379`,Kp=`#d19a66`,qp=`#c678dd`,Jp=`#21252b`,Yp=`#2c313a`,Xp=`#282c34`,Zp=`#353a42`,Qp=`#3E4451`,$p=`#528bff`,em=[J.theme({"&":{color:Hp,backgroundColor:Xp},".cm-content":{caretColor:$p},".cm-cursor, .cm-dropCursor":{borderLeftColor:$p},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Qp},".cm-panels":{backgroundColor:Jp,color:Hp},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:Xp,color:Up,border:`none`},".cm-activeLineGutter":{backgroundColor:Yp},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:Zp},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Zp,borderBottomColor:Zp},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Yp,color:Hp}}},{dark:!0}),Ou(wu.define([{tag:Z.keyword,color:qp},{tag:[Z.name,Z.deleted,Z.character,Z.propertyName,Z.macroName],color:zp},{tag:[Z.function(Z.variableName),Z.labelName],color:Wp},{tag:[Z.color,Z.constant(Z.name),Z.standard(Z.name)],color:Kp},{tag:[Z.definition(Z.name),Z.separator],color:Hp},{tag:[Z.typeName,Z.className,Z.number,Z.changed,Z.annotation,Z.modifier,Z.self,Z.namespace],color:Rp},{tag:[Z.operator,Z.operatorKeyword,Z.url,Z.escape,Z.regexp,Z.link,Z.special(Z.string)],color:Bp},{tag:[Z.meta,Z.comment],color:Up},{tag:Z.strong,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.link,color:Up,textDecoration:`underline`},{tag:Z.heading,fontWeight:`bold`,color:zp},{tag:[Z.atom,Z.bool,Z.special(Z.variableName)],color:Kp},{tag:[Z.processingInstruction,Z.string,Z.inserted],color:Gp},{tag:Z.invalid,color:Vp}]))],tm=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,nm=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(tm(e)):tm,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ft(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=pt(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=mt(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(nm.prototype[Symbol.iterator]=function(){return this});var rm={from:-1,to:-1,match:/.*/.exec(``)},im=`gm`+(/x/.unicode==null?``:`u`),am=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=rm,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new cm(e,t,n,r,i);this.re=new RegExp(t,im+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=um(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=um(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},om=new WeakMap,sm=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=om.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return om.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),om.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},cm=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=rm,this.matchPos=um(e,r),this.re=new RegExp(t,im+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=sm.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=um(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=sm.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(am.prototype[Symbol.iterator]=cm.prototype[Symbol.iterator]=function(){return this});function lm(e){try{return new RegExp(e,im),!0}catch{return!1}}function um(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var dm=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||lm(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
15
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Sm(this):new gm(this)}getCursor(e,t=0,n){let r=e.doc?e:H.create({doc:e});return n??=r.doc.length,this.regexp?vm(this,r,t,n):mm(this,r,t,n)}},fm=class{constructor(e){this.spec=e}};function pm(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function mm(e,t,n,r){let i;return e.wholeWord&&(i=hm(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=pm(e.test,t,i)),new nm(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function hm(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(ym(i,n-a))!=un.Word||t(bm(i,n-a))!=un.Word)&&(t(bm(i,r-a))!=un.Word||t(ym(i,r-a))!=un.Word))}var gm=class extends fm{constructor(e){super(e)}nextMatch(e,t,n){let r=mm(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=mm(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=mm(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=mm(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=mm(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function _m(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function vm(e,t,n,r){let i;return e.wholeWord&&(i=xm(t.charCategorizer(t.selection.main.head))),e.test&&(i=_m(e.test,t,i)),new am(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function ym(e,t){return e.slice(lt(e,t,!1),t)}function bm(e,t){return e.slice(t,lt(e,t))}function xm(e){return(t,n,r)=>!r[0].length||(e(ym(r.input,r.index))!=un.Word||e(bm(r.input,r.index))!=un.Word)&&(e(bm(r.input,r.index+r[0].length))!=un.Word||e(ym(r.input,r.index+r[0].length))!=un.Word)}var Sm=class extends fm{nextMatch(e,t,n){let r=vm(this.spec,e,n,e.doc.length).next();return r.done&&(r=vm(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=vm(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=vm(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=vm(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Cm=V.define();function wm(e){var t=e.Pos;function n(e,t,n){if(t.line===n.line&&t.ch>=n.ch-1){var r=e.getLine(t.line).charCodeAt(t.ch);55296<=r&&r<=55551&&(n.ch+=1)}return{start:t,end:n}}var r=[{keys:`<Left>`,type:`keyToKey`,toKeys:`h`},{keys:`<Right>`,type:`keyToKey`,toKeys:`l`},{keys:`<Up>`,type:`keyToKey`,toKeys:`k`},{keys:`<Down>`,type:`keyToKey`,toKeys:`j`},{keys:`g<Up>`,type:`keyToKey`,toKeys:`gk`},{keys:`g<Down>`,type:`keyToKey`,toKeys:`gj`},{keys:`<Space>`,type:`keyToKey`,toKeys:`l`},{keys:`<BS>`,type:`keyToKey`,toKeys:`h`},{keys:`<Del>`,type:`keyToKey`,toKeys:`x`},{keys:`<C-Space>`,type:`keyToKey`,toKeys:`W`},{keys:`<C-BS>`,type:`keyToKey`,toKeys:`B`},{keys:`<S-Space>`,type:`keyToKey`,toKeys:`w`},{keys:`<S-BS>`,type:`keyToKey`,toKeys:`b`},{keys:`<C-n>`,type:`keyToKey`,toKeys:`j`},{keys:`<C-p>`,type:`keyToKey`,toKeys:`k`},{keys:`<C-[>`,type:`keyToKey`,toKeys:`<Esc>`},{keys:`<C-c>`,type:`keyToKey`,toKeys:`<Esc>`},{keys:`<C-[>`,type:`keyToKey`,toKeys:`<Esc>`,context:`insert`},{keys:`<C-c>`,type:`keyToKey`,toKeys:`<Esc>`,context:`insert`},{keys:`<C-Esc>`,type:`keyToKey`,toKeys:`<Esc>`},{keys:`<C-Esc>`,type:`keyToKey`,toKeys:`<Esc>`,context:`insert`},{keys:`s`,type:`keyToKey`,toKeys:`cl`,context:`normal`},{keys:`s`,type:`keyToKey`,toKeys:`c`,context:`visual`},{keys:`S`,type:`keyToKey`,toKeys:`cc`,context:`normal`},{keys:`S`,type:`keyToKey`,toKeys:`VdO`,context:`visual`},{keys:`<Home>`,type:`keyToKey`,toKeys:`0`},{keys:`<End>`,type:`keyToKey`,toKeys:`$`},{keys:`<PageUp>`,type:`keyToKey`,toKeys:`<C-b>`},{keys:`<PageDown>`,type:`keyToKey`,toKeys:`<C-f>`},{keys:`<CR>`,type:`keyToKey`,toKeys:`j^`,context:`normal`},{keys:`<Ins>`,type:`keyToKey`,toKeys:`i`,context:`normal`},{keys:`<Ins>`,type:`action`,action:`toggleOverwrite`,context:`insert`},{keys:`H`,type:`motion`,motion:`moveToTopLine`,motionArgs:{linewise:!0,toJumplist:!0}},{keys:`M`,type:`motion`,motion:`moveToMiddleLine`,motionArgs:{linewise:!0,toJumplist:!0}},{keys:`L`,type:`motion`,motion:`moveToBottomLine`,motionArgs:{linewise:!0,toJumplist:!0}},{keys:`h`,type:`motion`,motion:`moveByCharacters`,motionArgs:{forward:!1}},{keys:`l`,type:`motion`,motion:`moveByCharacters`,motionArgs:{forward:!0}},{keys:`j`,type:`motion`,motion:`moveByLines`,motionArgs:{forward:!0,linewise:!0}},{keys:`k`,type:`motion`,motion:`moveByLines`,motionArgs:{forward:!1,linewise:!0}},{keys:`gj`,type:`motion`,motion:`moveByDisplayLines`,motionArgs:{forward:!0}},{keys:`gk`,type:`motion`,motion:`moveByDisplayLines`,motionArgs:{forward:!1}},{keys:`w`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!0,wordEnd:!1}},{keys:`W`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:`e`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:`E`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:`b`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!1,wordEnd:!1}},{keys:`B`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:`ge`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:`gE`,type:`motion`,motion:`moveByWords`,motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:`{`,type:`motion`,motion:`moveByParagraph`,motionArgs:{forward:!1,toJumplist:!0}},{keys:`}`,type:`motion`,motion:`moveByParagraph`,motionArgs:{forward:!0,toJumplist:!0}},{keys:`(`,type:`motion`,motion:`moveBySentence`,motionArgs:{forward:!1}},{keys:`)`,type:`motion`,motion:`moveBySentence`,motionArgs:{forward:!0}},{keys:`<C-f>`,type:`motion`,motion:`moveByPage`,motionArgs:{forward:!0}},{keys:`<C-b>`,type:`motion`,motion:`moveByPage`,motionArgs:{forward:!1}},{keys:`<C-d>`,type:`motion`,motion:`moveByScroll`,motionArgs:{forward:!0,explicitRepeat:!0}},{keys:`<C-u>`,type:`motion`,motion:`moveByScroll`,motionArgs:{forward:!1,explicitRepeat:!0}},{keys:`gg`,type:`motion`,motion:`moveToLineOrEdgeOfDocument`,motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:`G`,type:`motion`,motion:`moveToLineOrEdgeOfDocument`,motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:`g$`,type:`motion`,motion:`moveToEndOfDisplayLine`},{keys:`g^`,type:`motion`,motion:`moveToStartOfDisplayLine`},{keys:`g0`,type:`motion`,motion:`moveToStartOfDisplayLine`},{keys:`0`,type:`motion`,motion:`moveToStartOfLine`},{keys:`^`,type:`motion`,motion:`moveToFirstNonWhiteSpaceCharacter`},{keys:`+`,type:`motion`,motion:`moveByLines`,motionArgs:{forward:!0,toFirstChar:!0}},{keys:`-`,type:`motion`,motion:`moveByLines`,motionArgs:{forward:!1,toFirstChar:!0}},{keys:`_`,type:`motion`,motion:`moveByLines`,motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:`$`,type:`motion`,motion:`moveToEol`,motionArgs:{inclusive:!0}},{keys:`%`,type:`motion`,motion:`moveToMatchedSymbol`,motionArgs:{inclusive:!0,toJumplist:!0}},{keys:`f<character>`,type:`motion`,motion:`moveToCharacter`,motionArgs:{forward:!0,inclusive:!0}},{keys:`F<character>`,type:`motion`,motion:`moveToCharacter`,motionArgs:{forward:!1}},{keys:`t<character>`,type:`motion`,motion:`moveTillCharacter`,motionArgs:{forward:!0,inclusive:!0}},{keys:`T<character>`,type:`motion`,motion:`moveTillCharacter`,motionArgs:{forward:!1}},{keys:`;`,type:`motion`,motion:`repeatLastCharacterSearch`,motionArgs:{forward:!0}},{keys:`,`,type:`motion`,motion:`repeatLastCharacterSearch`,motionArgs:{forward:!1}},{keys:`'<register>`,type:`motion`,motion:`goToMark`,motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:`motion`,motion:`goToMark`,motionArgs:{toJumplist:!0}},{keys:"]`",type:`motion`,motion:`jumpToMark`,motionArgs:{forward:!0}},{keys:"[`",type:`motion`,motion:`jumpToMark`,motionArgs:{forward:!1}},{keys:`]'`,type:`motion`,motion:`jumpToMark`,motionArgs:{forward:!0,linewise:!0}},{keys:`['`,type:`motion`,motion:`jumpToMark`,motionArgs:{forward:!1,linewise:!0}},{keys:`]p`,type:`action`,action:`paste`,isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:`[p`,type:`action`,action:`paste`,isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:`]<character>`,type:`motion`,motion:`moveToSymbol`,motionArgs:{forward:!0,toJumplist:!0}},{keys:`[<character>`,type:`motion`,motion:`moveToSymbol`,motionArgs:{forward:!1,toJumplist:!0}},{keys:`|`,type:`motion`,motion:`moveToColumn`},{keys:`o`,type:`motion`,motion:`moveToOtherHighlightedEnd`,context:`visual`},{keys:`O`,type:`motion`,motion:`moveToOtherHighlightedEnd`,motionArgs:{sameLine:!0},context:`visual`},{keys:`d`,type:`operator`,operator:`delete`},{keys:`y`,type:`operator`,operator:`yank`},{keys:`c`,type:`operator`,operator:`change`},{keys:`=`,type:`operator`,operator:`indentAuto`},{keys:`>`,type:`operator`,operator:`indent`,operatorArgs:{indentRight:!0}},{keys:`<`,type:`operator`,operator:`indent`,operatorArgs:{indentRight:!1}},{keys:`g~`,type:`operator`,operator:`changeCase`},{keys:`gu`,type:`operator`,operator:`changeCase`,operatorArgs:{toLower:!0},isEdit:!0},{keys:`gU`,type:`operator`,operator:`changeCase`,operatorArgs:{toLower:!1},isEdit:!0},{keys:`n`,type:`motion`,motion:`findNext`,motionArgs:{forward:!0,toJumplist:!0}},{keys:`N`,type:`motion`,motion:`findNext`,motionArgs:{forward:!1,toJumplist:!0}},{keys:`gn`,type:`motion`,motion:`findAndSelectNextInclusive`,motionArgs:{forward:!0}},{keys:`gN`,type:`motion`,motion:`findAndSelectNextInclusive`,motionArgs:{forward:!1}},{keys:`gq`,type:`operator`,operator:`hardWrap`},{keys:`gw`,type:`operator`,operator:`hardWrap`,operatorArgs:{keepCursor:!0}},{keys:`g?`,type:`operator`,operator:`rot13`},{keys:`x`,type:`operatorMotion`,operator:`delete`,motion:`moveByCharacters`,motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:`X`,type:`operatorMotion`,operator:`delete`,motion:`moveByCharacters`,motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:`D`,type:`operatorMotion`,operator:`delete`,motion:`moveToEol`,motionArgs:{inclusive:!0},context:`normal`},{keys:`D`,type:`operator`,operator:`delete`,operatorArgs:{linewise:!0},context:`visual`},{keys:`Y`,type:`operatorMotion`,operator:`yank`,motion:`expandToLine`,motionArgs:{linewise:!0},context:`normal`},{keys:`Y`,type:`operator`,operator:`yank`,operatorArgs:{linewise:!0},context:`visual`},{keys:`C`,type:`operatorMotion`,operator:`change`,motion:`moveToEol`,motionArgs:{inclusive:!0},context:`normal`},{keys:`C`,type:`operator`,operator:`change`,operatorArgs:{linewise:!0},context:`visual`},{keys:`~`,type:`operatorMotion`,operator:`changeCase`,motion:`moveByCharacters`,motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:`normal`},{keys:`~`,type:`operator`,operator:`changeCase`,context:`visual`},{keys:`<C-u>`,type:`operatorMotion`,operator:`delete`,motion:`moveToStartOfLine`,context:`insert`},{keys:`<C-w>`,type:`operatorMotion`,operator:`delete`,motion:`moveByWords`,motionArgs:{forward:!1,wordEnd:!1},context:`insert`},{keys:`<C-w>`,type:`idle`,context:`normal`},{keys:`<C-i>`,type:`action`,action:`jumpListWalk`,actionArgs:{forward:!0}},{keys:`<C-o>`,type:`action`,action:`jumpListWalk`,actionArgs:{forward:!1}},{keys:`<C-e>`,type:`action`,action:`scroll`,actionArgs:{forward:!0,linewise:!0}},{keys:`<C-y>`,type:`action`,action:`scroll`,actionArgs:{forward:!1,linewise:!0}},{keys:`a`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`charAfter`},context:`normal`},{keys:`A`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`eol`},context:`normal`},{keys:`A`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`endOfSelectedArea`},context:`visual`},{keys:`i`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`inplace`},context:`normal`},{keys:`gi`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`lastEdit`},context:`normal`},{keys:`I`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`firstNonBlank`},context:`normal`},{keys:`gI`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`bol`},context:`normal`},{keys:`I`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{insertAt:`startOfSelectedArea`},context:`visual`},{keys:`o`,type:`action`,action:`newLineAndEnterInsertMode`,isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:`normal`},{keys:`O`,type:`action`,action:`newLineAndEnterInsertMode`,isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:`normal`},{keys:`v`,type:`action`,action:`toggleVisualMode`},{keys:`V`,type:`action`,action:`toggleVisualMode`,actionArgs:{linewise:!0}},{keys:`<C-v>`,type:`action`,action:`toggleVisualMode`,actionArgs:{blockwise:!0}},{keys:`<C-q>`,type:`action`,action:`toggleVisualMode`,actionArgs:{blockwise:!0}},{keys:`gv`,type:`action`,action:`reselectLastSelection`},{keys:`J`,type:`action`,action:`joinLines`,isEdit:!0},{keys:`gJ`,type:`action`,action:`joinLines`,actionArgs:{keepSpaces:!0},isEdit:!0},{keys:`p`,type:`action`,action:`paste`,isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:`P`,type:`action`,action:`paste`,isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:`r<character>`,type:`action`,action:`replace`,isEdit:!0},{keys:`@<register>`,type:`action`,action:`replayMacro`},{keys:`q<register>`,type:`action`,action:`enterMacroRecordMode`},{keys:`R`,type:`action`,action:`enterInsertMode`,isEdit:!0,actionArgs:{replace:!0},context:`normal`},{keys:`R`,type:`operator`,operator:`change`,operatorArgs:{linewise:!0,fullLine:!0},context:`visual`,exitVisualBlock:!0},{keys:`u`,type:`action`,action:`undo`,context:`normal`},{keys:`u`,type:`operator`,operator:`changeCase`,operatorArgs:{toLower:!0},context:`visual`,isEdit:!0},{keys:`U`,type:`operator`,operator:`changeCase`,operatorArgs:{toLower:!1},context:`visual`,isEdit:!0},{keys:`<C-r>`,type:`action`,action:`redo`},{keys:`m<register>`,type:`action`,action:`setMark`},{keys:`"<register>`,type:`action`,action:`setRegister`},{keys:`<C-r><register>`,type:`action`,action:`insertRegister`,context:`insert`,isEdit:!0},{keys:`<C-o>`,type:`action`,action:`oneNormalCommand`,context:`insert`},{keys:`zz`,type:`action`,action:`scrollToCursor`,actionArgs:{position:`center`}},{keys:`z.`,type:`action`,action:`scrollToCursor`,actionArgs:{position:`center`},motion:`moveToFirstNonWhiteSpaceCharacter`},{keys:`zt`,type:`action`,action:`scrollToCursor`,actionArgs:{position:`top`}},{keys:`z<CR>`,type:`action`,action:`scrollToCursor`,actionArgs:{position:`top`},motion:`moveToFirstNonWhiteSpaceCharacter`},{keys:`zb`,type:`action`,action:`scrollToCursor`,actionArgs:{position:`bottom`}},{keys:`z-`,type:`action`,action:`scrollToCursor`,actionArgs:{position:`bottom`},motion:`moveToFirstNonWhiteSpaceCharacter`},{keys:`.`,type:`action`,action:`repeatLastEdit`},{keys:`<C-a>`,type:`action`,action:`incrementNumberToken`,isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:`<C-x>`,type:`action`,action:`incrementNumberToken`,isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:`<C-t>`,type:`action`,action:`indent`,actionArgs:{indentRight:!0},context:`insert`},{keys:`<C-d>`,type:`action`,action:`indent`,actionArgs:{indentRight:!1},context:`insert`},{keys:`a<register>`,type:`motion`,motion:`textObjectManipulation`},{keys:`i<register>`,type:`motion`,motion:`textObjectManipulation`,motionArgs:{textObjectInner:!0}},{keys:`/`,type:`search`,searchArgs:{forward:!0,querySrc:`prompt`,toJumplist:!0}},{keys:`?`,type:`search`,searchArgs:{forward:!1,querySrc:`prompt`,toJumplist:!0}},{keys:`*`,type:`search`,searchArgs:{forward:!0,querySrc:`wordUnderCursor`,wholeWordOnly:!0,toJumplist:!0}},{keys:`#`,type:`search`,searchArgs:{forward:!1,querySrc:`wordUnderCursor`,wholeWordOnly:!0,toJumplist:!0}},{keys:`g*`,type:`search`,searchArgs:{forward:!0,querySrc:`wordUnderCursor`,toJumplist:!0}},{keys:`g#`,type:`search`,searchArgs:{forward:!1,querySrc:`wordUnderCursor`,toJumplist:!0}},{keys:`:`,type:`ex`}],i=Object.create(null),a=r.length,o=[{name:`colorscheme`,shortName:`colo`},{name:`map`},{name:`imap`,shortName:`im`},{name:`nmap`,shortName:`nm`},{name:`vmap`,shortName:`vm`},{name:`omap`,shortName:`om`},{name:`noremap`,shortName:`no`},{name:`nnoremap`,shortName:`nn`},{name:`vnoremap`,shortName:`vn`},{name:`inoremap`,shortName:`ino`},{name:`onoremap`,shortName:`ono`},{name:`unmap`},{name:`mapclear`,shortName:`mapc`},{name:`nmapclear`,shortName:`nmapc`},{name:`vmapclear`,shortName:`vmapc`},{name:`imapclear`,shortName:`imapc`},{name:`omapclear`,shortName:`omapc`},{name:`write`,shortName:`w`},{name:`undo`,shortName:`u`},{name:`redo`,shortName:`red`},{name:`set`,shortName:`se`},{name:`setlocal`,shortName:`setl`},{name:`setglobal`,shortName:`setg`},{name:`sort`,shortName:`sor`},{name:`substitute`,shortName:`s`,possiblyAsync:!0},{name:`startinsert`,shortName:`start`},{name:`nohlsearch`,shortName:`noh`},{name:`yank`,shortName:`y`},{name:`delmarks`,shortName:`delm`},{name:`marks`,excludeFromCommandHistory:!0},{name:`registers`,shortName:`reg`,excludeFromCommandHistory:!0},{name:`vglobal`,shortName:`v`},{name:`delete`,shortName:`d`},{name:`join`,shortName:`j`},{name:`normal`,shortName:`norm`},{name:`global`,shortName:`g`}],s=he(``);function c(t){t.setOption(`disableInput`,!0),t.setOption(`showCursorWhenSelecting`,!1),e.signal(t,`vim-mode-change`,{mode:`normal`}),t.on(`cursorActivity`,sn),A(t),e.on(t.getInputField(),`paste`,u(t))}function l(t){t.setOption(`disableInput`,!1),t.off(`cursorActivity`,sn),e.off(t.getInputField(),`paste`,u(t)),t.state.vim=null,Rt&&clearTimeout(Rt)}function u(e){var t=e.state.vim;return t.onPasteFn||=function(){t.insertMode||(e.setCursor(P(e.getCursor(),0,1)),ke.enterInsertMode(e,{},t))},t.onPasteFn}var d=/[\d]/,f=[e.isWordChar,function(t){return t&&!e.isWordChar(t)&&!/\s/.test(t)}],p=[function(e){return/\S/.test(e)}],m=[`<`,`>`],h=[`-`,`"`,`.`,`:`,`_`,`/`,`+`],g=/^\w$/,_=/^[A-Z]$/;try{_=RegExp(`^[\\p{Lu}]$`,`u`)}catch{}function v(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function y(e){return/^[a-z]$/.test(e)}function b(e){return`()[]{}`.indexOf(e)!=-1}function x(e){return d.test(e)}function S(e){return _.test(e)}function C(e){return/^\s*$/.test(e)}function w(e){return`.?!`.indexOf(e)!=-1}function T(e,t){for(var n=0;n<t.length;n++)if(t[n]==e)return!0;return!1}var E={};function D(e,t,n,r,i){if(t===void 0&&!i)throw Error(`defaultValue is required unless callback is provided`);if(n||=`string`,E[e]={type:n,defaultValue:t,callback:i},r)for(var a=0;a<r.length;a++)E[r[a]]=E[e];t&&ee(e,t)}function ee(e,t,n,r){var i=E[e];r||={};var a=r.scope;if(!i)return Error(`Unknown option: `+e);if(i.type==`boolean`){if(t&&t!==!0)return Error(`Invalid argument: `+e+`=`+t);t!==!1&&(t=!0)}i.callback?(a!==`local`&&i.callback(t,void 0),a!==`global`&&n&&i.callback(t,n)):(a!==`local`&&(i.value=i.type==`boolean`?!!t:t),a!==`global`&&n&&(n.state.vim.options[e]={value:t}))}function O(e,t,n){var r=E[e];n||={};var i=n.scope;if(!r)return Error(`Unknown option: `+e);if(r.callback){let e=t&&r.callback(void 0,t);return i!==`global`&&e!==void 0?e:i===`local`?void 0:r.callback()}else return(i!==`global`&&t&&t.state.vim.options[e]||i!==`local`&&r||{}).value}D(`filetype`,void 0,`string`,[`ft`],function(e,t){if(t!==void 0)if(e===void 0){let e=t.getOption(`mode`);return e==`null`?``:e}else{let n=e==``?`null`:e;t.setOption(`mode`,n)}}),D(`textwidth`,80,`number`,[`tw`],function(e,t){if(t!==void 0){if(e===void 0)return t.getOption(`textwidth`);var n=Math.round(e);n>1&&t.setOption(`textwidth`,n)}});var te=function(){var e=100,t=-1,n=0,r=0,i=Array(e);function a(a,o,s){var c=i[t%e];function l(n){var r=++t%e,o=i[r];o&&o.clear(),i[r]=a.setBookmark(n)}if(c){var u=c.find();u&&!Le(u,o)&&l(o)}else l(o);l(s),n=t,r=t-e+1,r<0&&(r=0)}function o(a,o){t+=o,t>n?t=n:t<r&&(t=r);var s=i[(e+t)%e];if(s&&!s.find()){var c=o>0?1:-1,l,u=a.getCursor();do if(t+=c,s=i[(e+t)%e],s&&(l=s.find())&&!Le(u,l))break;while(t<n&&t>r)}return s}function s(e,n){var r=t,i=o(e,n);return t=r,i&&i.find()}return{cachedCursor:void 0,add:a,find:s,move:o}},k=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class ne{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=k()}exitMacroRecordMode(){var e=j.macroModeState;e.onRecordingDone&&e.onRecordingDone(),e.onRecordingDone=void 0,e.isRecording=!1}enterMacroRecordMode(e,t){var n=j.registerController.getRegister(t);if(n){if(n.clear(),this.latestRegister=t,e.openDialog){var r=Mt(`span`,{class:`cm-vim-message`},`recording @`+t);this.onRecordingDone=e.openDialog(r,function(){},{bottom:!0})}this.isRecording=!0}}}function A(e){return e.state.vim||(e.state.vim={inputState:new ge,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new t(0,0),head:new t(0,0)},options:{},expectLiteralNext:!1,status:``}),e.state.vim}var j;function re(){for(var e in j={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:te(),macroModeState:new ne,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:``},registerController:new xe({}),searchHistoryController:new Se,exCommandHistoryController:new Se},E){var t=E[e];t.value=t.defaultValue}}class ie{constructor(e,t){this.keyName=e,this.key=t.key,this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.shiftKey=t.shiftKey}}var ae,oe={enterVimMode:c,leaveVimMode:l,buildKeyMap:function(){},getRegisterController:function(){return j.registerController},resetVimGlobalState_:re,getVimGlobalState_:function(){return j},maybeInitVimState_:A,suppressErrorLogging:!1,InsertModeKey:ie,map:function(e,t,n){Yt.map(e,t,n)},unmap:function(e,t){return Yt.unmap(e,t)},noremap:function(e,t,n){Yt.map(e,t,n,!0)},mapclear:function(e){var t=r.length,n=a,i=r.slice(0,t-n);if(r=r.slice(t-n),e)for(var o=i.length-1;o>=0;o--){var s=i[o];if(e!==s.context)if(s.context)this._mapCommand(s);else{var c=[`normal`,`insert`,`visual`];for(var l in c)if(c[l]!==e){var u=Object.assign({},s);u.context=c[l],this._mapCommand(u)}}}},langmap:me,vimKeyFromEvent:pe,setOption:ee,getOption:O,defineOption:D,defineEx:function(e,t,n){if(!t)t=e;else if(e.indexOf(t)!==0)throw Error(`(Vim.defineEx) "`+t+`" is not a prefix of "`+e+`", command not registered`);Jt[e]=n,Yt.commandMap_[t]={name:e,shortName:t,type:`api`}},handleKey:function(e,t,n){var r=this.findKey(e,t,n);if(typeof r==`function`)return r()},multiSelectHandleKey:mn,findKey:function(t,n,i){var a=A(t),o=t;function s(){var e=j.macroModeState;if(e.isRecording){if(n==`q`)return e.exitMacroRecordMode(),_e(o),!0;i!=`mapping`&&nn(e,n)}}function c(){if(n==`<Esc>`){if(a.visualMode)$e(o);else if(a.insertMode)Zt(o);else return;return _e(o),!0}}function l(){if(c())return!0;a.inputState.keyBuffer.push(n);var e=a.inputState.keyBuffer.join(``),t=n.length==1,i=Ce.matchCommand(e,r,a.inputState,`insert`),s=a.inputState.changeQueue;if(i.type==`none`)return _e(o),!1;if(i.type==`partial`){if(i.expectLiteralNext&&(a.expectLiteralNext=!0),ae&&window.clearTimeout(ae),ae=t&&window.setTimeout(function(){a.insertMode&&a.inputState.keyBuffer.length&&_e(o)},O(`insertModeEscKeysTimeout`)),t){var l=o.listSelections();(!s||s.removed.length!=l.length)&&(s=a.inputState.changeQueue=new ve),s.inserted+=n;for(var u=0;u<l.length;u++){var d=Re(l[u].anchor,l[u].head),f=ze(l[u].anchor,l[u].head),p=o.getRange(d,o.state.overwrite?P(f,0,1):f);s.removed[u]=(s.removed[u]||``)+p}}return!t}else i.type==`full`&&(a.inputState.keyBuffer.length=0);if(a.expectLiteralNext=!1,ae&&window.clearTimeout(ae),i.command&&s){for(var l=o.listSelections(),u=0;u<l.length;u++){var m=l[u].head;o.replaceRange(s.removed[u]||``,P(m,0,-s.inserted.length),m,`+input`)}j.macroModeState.lastInsertModeChanges.changes.pop()}return i.command||_e(o),i.command}function u(){if(s()||c())return!0;a.inputState.keyBuffer.push(n);var e=a.inputState.keyBuffer.join(``);if(/^[1-9]\d*$/.test(e))return!0;var t=/^(\d*)(.*)$/.exec(e);if(!t)return _e(o),!1;var i=a.visualMode?`visual`:`normal`,l=t[2]||t[1];a.inputState.operatorShortcut&&a.inputState.operatorShortcut.slice(-1)==l&&(l=a.inputState.operatorShortcut);var u=Ce.matchCommand(l,r,a.inputState,i);return u.type==`none`?(_e(o),!1):u.type==`partial`?(u.expectLiteralNext&&(a.expectLiteralNext=!0),!0):u.type==`clear`?(_e(o),!0):(a.expectLiteralNext=!1,a.inputState.keyBuffer.length=0,t=/^(\d*)(.*)$/.exec(e),t&&t[1]&&t[1]!=`0`&&a.inputState.pushRepeatDigit(t[1]),u.command)}var d=a.insertMode?l():u();if(d===!1)return!a.insertMode&&(n.length===1||e.isMac&&/<A-.>/.test(n))?function(){return!0}:void 0;if(d===!0)return function(){return!0};if(d)return function(){return o.operation(function(){o.curOp.isVimOp=!0;try{if(typeof d!=`object`)return;d.type==`keyToKey`?ue(o,d.toKeys,d):Ce.processCommand(o,a,d)}catch(e){throw o.state.vim=void 0,A(o),oe.suppressErrorLogging||console.log(e),e}return!0})}},handleEx:function(e,t){Yt.processCommand(e,t)},defineMotion:Te,defineAction:Ae,defineOperator:Oe,mapCommand:en,_mapCommand:Qt,defineRegister:be,exitVisualMode:$e,exitInsertMode:Zt},se=[],ce=!1,M;function le(e){if(!M)throw Error(`No prompt to send key to`);if(e[0]==`<`){var t=e.toLowerCase().slice(1,-1);if(t=t.split(`-`).pop()||``,t==`lt`)e=`<`;else if(t==`space`)e=` `;else if(t==`cr`)e=`
16
+ `;else if(fe[t]){var n=M.value||``,r={key:fe[t],target:{value:n,selectionEnd:n.length,selectionStart:n.length}};M.onKeyDown&&M.onKeyDown(r,M.value,a),M&&M.onKeyUp&&M.onKeyUp(r,M.value,a);return}}if(e==`
17
+ `){var i=M;M=null,i.onClose&&i.onClose(i.value)}else M.value=(M.value||``)+e;function a(e){M&&(typeof e==`string`?M.value=e:M=null)}}function ue(e,t,n){var r=ce;if(n){if(se.indexOf(n)!=-1)return;se.push(n),ce=n.noremap!=0}try{for(var i=A(e),a=/<(?:[CSMA]-)*\w+>|./gi,o;o=a.exec(t);){var s=o[0],c=i.insertMode;if(M){le(s);continue}if(!oe.handleKey(e,s,`mapping`)&&c&&i.insertMode){if(s[0]==`<`){var l=s.toLowerCase().slice(1,-1);if(l=l.split(`-`).pop()||``,l==`lt`)s=`<`;else if(l==`space`)s=` `;else if(l==`cr`)s=`
18
+ `;else if(fe.hasOwnProperty(l)){s=fe[l],dn(e,s);continue}else s=s[0],a.lastIndex=o.index+1}e.replaceSelection(s)}}}finally{if(se.pop(),ce=se.length?r:!1,!se.length&&M){var u=M;M=null,Pt(e,u)}}}var de={Return:`CR`,Backspace:`BS`,Delete:`Del`,Escape:`Esc`,Insert:`Ins`,ArrowLeft:`Left`,ArrowRight:`Right`,ArrowUp:`Up`,ArrowDown:`Down`,Enter:`CR`," ":`Space`},N={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},fe={};`Left|Right|Up|Down|End|Home`.split(`|`).concat(Object.keys(de)).forEach(function(e){fe[(de[e]||``).toLowerCase()]=fe[e.toLowerCase()]=e});function pe(t,n){var r=t.key;if(!N[r]){r.length>1&&r[0]==`n`&&(r=r.replace(`Numpad`,``)),r=de[r]||r;var a=``;if(t.ctrlKey&&(a+=`C-`),t.altKey&&(a+=`A-`),t.metaKey&&(a+=`M-`),e.isMac&&a==`A-`&&r.length==1&&(a=a.slice(2)),(a||r.length>1)&&t.shiftKey&&(a+=`S-`),n&&!n.expectLiteralNext&&r.length==1){if(s.keymap&&r in s.keymap)(s.remapCtrl!=0||!a)&&(r=s.keymap[r]);else if(r.charCodeAt(0)>128&&!i[r]){var o=t.code?.slice(-1)||``;t.shiftKey||(o=o.toLowerCase()),o&&(r=o,!a&&t.altKey&&(a=`A-`))}}return a+=r,a.length>1&&(a=`<`+a+`>`),a}}function me(e,t){s.string!==e&&(s=he(e)),s.remapCtrl=t}function he(e){let t={};if(!e)return{keymap:t,string:``};function n(e){return e.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(e=>{if(!e)return;let r=e.split(/((?:[^\\;]|\\.)+);/);if(r.length==3){let e=n(r[1]),i=n(r[2]);if(e.length!==i.length)return;for(let n=0;n<e.length;++n)t[e[n]]=i[n]}else if(r.length==1){let r=n(e);if(r.length%2!=0)return;for(let e=0;e<r.length;e+=2)t[r[e]]=r[e+1]}}),{keymap:t,string:e}}D(`langmap`,void 0,`string`,[`lmap`],function(e,t){if(e===void 0)return s.string;me(e)});class ge{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(e){this.operator?this.motionRepeat=this.motionRepeat.concat(e):this.prefixRepeat=this.prefixRepeat.concat(e)}getRepeat(){var e=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(e=1,this.prefixRepeat.length>0&&(e*=parseInt(this.prefixRepeat.join(``),10)),this.motionRepeat.length>0&&(e*=parseInt(this.motionRepeat.join(``),10))),e}}function _e(t,n){t.state.vim.inputState=new ge,t.state.vim.expectLiteralNext=!1,e.signal(t,`vim-command-done`,n)}function ve(){this.removed=[],this.inserted=``}class ye{constructor(e,t,n){this.clear(),this.keyBuffer=[e||``],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!t,this.blockwise=!!n}setText(e,t,n){this.keyBuffer=[e||``],this.linewise=!!t,this.blockwise=!!n}pushText(e,t){t&&(this.linewise||this.keyBuffer.push(`
19
+ `),this.linewise=!0),this.keyBuffer.push(e)}pushInsertModeChanges(e){this.insertModeChanges.push(k(e))}pushSearchQuery(e){this.searchQueries.push(e)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join(``)}}function be(e,t){var n=j.registerController.registers;if(!e||e.length!=1)throw Error(`Register name must be 1 character`);if(n[e])throw Error(`Register already defined `+e);n[e]=t,h.push(e)}class xe{constructor(e){this.registers=e,this.unnamedRegister=e[`"`]=new ye,e[`.`]=new ye,e[`:`]=new ye,e[`/`]=new ye,e[`+`]=new ye}pushText(e,t,n,r,i){if(e!==`_`){r&&n.charAt(n.length-1)!==`
20
+ `&&(n+=`
21
+ `);var a=this.isValidRegister(e)?this.getRegister(e):null;if(!a||!e){switch(t){case`yank`:this.registers[0]=new ye(n,r,i);break;case`delete`:case`change`:n.indexOf(`
22
+ `)==-1?this.registers[`-`]=new ye(n,r):(this.shiftNumericRegisters_(),this.registers[1]=new ye(n,r));break}this.unnamedRegister.setText(n,r,i);return}S(e)?a.pushText(n,r):a.setText(n,r,i),e===`+`&&navigator.clipboard.writeText(n),this.unnamedRegister.setText(a.toString(),r)}}getRegister(e){return this.isValidRegister(e)?(e=e.toLowerCase(),this.registers[e]||(this.registers[e]=new ye),this.registers[e]):this.unnamedRegister}isValidRegister(e){return e&&(T(e,h)||g.test(e))}shiftNumericRegisters_(){for(var e=9;e>=2;e--)this.registers[e]=this.getRegister(``+(e-1))}}class Se{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(e,t){var n=this.historyBuffer,r=t?-1:1;this.initialPrefix===null&&(this.initialPrefix=e);for(var i=this.iterator+r;t?i>=0:i<n.length;i+=r)for(var a=n[i],o=0;o<=a.length;o++)if(this.initialPrefix==a.substring(0,o))return this.iterator=i,a;if(i>=n.length)return this.iterator=n.length,this.initialPrefix;if(i<0)return e}pushInput(e){var t=this.historyBuffer.indexOf(e);t>-1&&this.historyBuffer.splice(t,1),e.length&&this.historyBuffer.push(e)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var Ce={matchCommand:function(e,t,n,r){var i=Ne(e,t,r,n),a=i.full[0];if(!a)return i.partial.length?{type:`partial`,expectLiteralNext:i.partial.length==1&&i.partial[0].keys.slice(-11)==`<character>`}:{type:`none`};if(a.keys.slice(-11)==`<character>`||a.keys.slice(-10)==`<register>`){var o=Fe(e);if(!o||o.length>1)return{type:`clear`};n.selectedCharacter=o}return{type:`full`,command:a}},processCommand:function(e,t,n){switch(t.inputState.repeatOverride=n.repeatOverride,n.type){case`motion`:this.processMotion(e,t,n);break;case`operator`:this.processOperator(e,t,n);break;case`operatorMotion`:this.processOperatorMotion(e,t,n);break;case`action`:this.processAction(e,t,n);break;case`search`:this.processSearch(e,t,n);break;case`ex`:case`keyToEx`:this.processEx(e,t,n);break}},processMotion:function(e,t,n){t.inputState.motion=n.motion,t.inputState.motionArgs=Me(n.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,n){var r=t.inputState;if(r.operator)if(r.operator==n.operator){r.motion=`expandToLine`,r.motionArgs={linewise:!0,repeat:1},this.evalInput(e,t);return}else _e(e);r.operator=n.operator,r.operatorArgs=Me(n.operatorArgs),n.keys.length>1&&(r.operatorShortcut=n.keys),n.exitVisualBlock&&(t.visualBlock=!1,Ze(e)),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,n){var r=t.visualMode,i=Me(n.operatorMotionArgs);i&&r&&i.visualLine&&(t.visualLine=!0),this.processOperator(e,t,n),r||this.processMotion(e,t,n)},processAction:function(e,t,n){var r=t.inputState,i=r.getRepeat(),a=!!i,o=Me(n.actionArgs)||{repeat:1};r.selectedCharacter&&(o.selectedCharacter=r.selectedCharacter),n.operator&&this.processOperator(e,t,n),n.motion&&this.processMotion(e,t,n),(n.motion||n.operator)&&this.evalInput(e,t),o.repeat=i||1,o.repeatIsExplicit=a,o.registerName=r.registerName,_e(e),t.lastMotion=null,n.isEdit&&this.recordLastEdit(t,r,n),ke[n.action](e,o,t)},processSearch:function(t,n,r){if(!t.getSearchCursor)return;var i=r.searchArgs.forward,a=r.searchArgs.wholeWordOnly;Ct(t).setReversed(!i);var o=i?`/`:`?`,s=Ct(t).getQuery(),c=t.getScrollInfo(),l=``;function u(e,i,a){j.searchHistoryController.pushInput(e),j.searchHistoryController.reset();try{It(t,e,i,a)}catch{B(t,`Invalid regex: `+e),_e(t);return}Ce.processMotion(t,n,{keys:``,type:`motion`,motion:`findNext`,motionArgs:{forward:!0,toJumplist:r.searchArgs.toJumplist}})}function d(e){t.scrollTo(c.left,c.top),u(e,!0,!0);var n=j.macroModeState;n.isRecording&&an(n,e)}function f(){return O(`pcre`)?`(JavaScript regexp: set pcre)`:`(Vim regexp: set nopcre)`}function p(e,t,n){var r=pe(e),i,a;r==`<Up>`||r==`<Down>`?(i=r==`<Up>`,a=e.target?e.target.selectionEnd:0,t=j.searchHistoryController.nextMatch(t,i)||``,n(t),a&&e.target&&(e.target.selectionEnd=e.target.selectionStart=Math.min(a,e.target.value.length))):r&&r!=`<Left>`&&r!=`<Right>`&&j.searchHistoryController.reset(),l=t,m()}function m(){var e;try{e=It(t,l,!0,!0)}catch{}e?t.scrollIntoView(Bt(t,!i,e),30):(Ht(t),t.scrollTo(c.left,c.top))}function h(n,r,i){var a=pe(n);a==`<Esc>`||a==`<C-c>`||a==`<C-[>`||a==`<BS>`&&r==``?(j.searchHistoryController.pushInput(r),j.searchHistoryController.reset(),It(t,s?.source||``),Ht(t),t.scrollTo(c.left,c.top),e.e_stop(n),_e(t),i(),t.focus()):a==`<Up>`||a==`<Down>`?e.e_stop(n):a==`<C-u>`&&(e.e_stop(n),i(``))}switch(r.searchArgs.querySrc){case`prompt`:var g=j.macroModeState;g.isPlaying?u(g.replaySearchQueries.shift()||``,!0,!1):Pt(t,{onClose:d,prefix:o,desc:Mt(`span`,{$cursor:`pointer`,onmousedown:function(e){e.preventDefault(),ee(`pcre`,!O(`pcre`)),this.textContent=f(),m()}},f()),onKeyUp:p,onKeyDown:h});break;case`wordUnderCursor`:var _=rt(t,{noSymbol:!0}),v=!0;if(_||(_=rt(t,{noSymbol:!1}),v=!1),!_){B(t,`No word under cursor`),_e(t);return}let e=t.getLine(_.start.line).substring(_.start.ch,_.end.ch);e=v&&a?`\\b`+e+`\\b`:Ue(e),j.jumpList.cachedCursor=t.getCursor(),t.setCursor(_.start),u(e,!0,!1);break}},processEx:function(t,n,r){function i(e){j.exCommandHistoryController.pushInput(e),j.exCommandHistoryController.reset(),Yt.processCommand(t,e),t.state.vim&&_e(t),Ht(t)}function a(n,r,i){var a=pe(n),o,s;(a==`<Esc>`||a==`<C-c>`||a==`<C-[>`||a==`<BS>`&&r==``)&&(j.exCommandHistoryController.pushInput(r),j.exCommandHistoryController.reset(),e.e_stop(n),_e(t),Ht(t),i(),t.focus()),a==`<Up>`||a==`<Down>`?(e.e_stop(n),o=a==`<Up>`,s=n.target?n.target.selectionEnd:0,r=j.exCommandHistoryController.nextMatch(r,o)||``,i(r),s&&n.target&&(n.target.selectionEnd=n.target.selectionStart=Math.min(s,n.target.value.length))):a==`<C-u>`?(e.e_stop(n),i(``)):a&&a!=`<Left>`&&a!=`<Right>`&&j.exCommandHistoryController.reset()}function o(n,r){var i=new e.StringStream(r),a={};try{if(Yt.parseInput_(t,i,a),a.commandName!=`s`){Ht(t);return}var o=Yt.matchCommand_(a.commandName);if(!o||(Yt.parseCommandArgs_(i,a,o),!a.argString))return;var s=jt(a.argString.slice(1),!0,!0);s&&zt(t,s)}catch{}}if(r.type==`keyToEx`)Yt.processCommand(t,r.exArgs.input);else{var s={onClose:i,onKeyDown:a,onKeyUp:o,prefix:`:`};n.visualMode&&(s.value=`'<,'>`,s.selectValueOnOpen=!1),Pt(t,s)}},evalInput:function(e,r){var i=r.inputState,a=i.motion,o=i.motionArgs||{repeat:1},s=i.operator,c=i.operatorArgs||{},l=i.registerName,u=r.sel,d=F(r.visualMode?je(e,u.head):e.getCursor(`head`)),f=F(r.visualMode?je(e,u.anchor):e.getCursor(`anchor`)),p=F(d),m=F(f),h,g,_;if(s&&this.recordLastEdit(r,i),_=i.repeatOverride===void 0?i.getRepeat():i.repeatOverride,_>0&&o.explicitRepeat?o.repeatIsExplicit=!0:(o.noRepeat||!o.explicitRepeat&&_===0)&&(_=1,o.repeatIsExplicit=!1),i.selectedCharacter&&(o.selectedCharacter=c.selectedCharacter=i.selectedCharacter),o.repeat=_,_e(e),a){var v=we[a](e,d,o,r,i);if(r.lastMotion=we[a],!v)return;if(o.toJumplist){var y=j.jumpList,b=y.cachedCursor;b?(at(e,b,v),delete y.cachedCursor):at(e,d,v)}v instanceof Array?(g=v[0],h=v[1]):h=v,h||=F(d),r.visualMode?(r.visualBlock&&h.ch===1/0||(h=je(e,h,p)),g&&=je(e,g),g||=m,u.anchor=g,u.head=h,Ze(e),ht(e,r,`<`,I(g,h)?g:h),ht(e,r,`>`,I(g,h)?h:g)):s||(h=je(e,h,p),e.setCursor(h.line,h.ch))}if(s){if(c.lastSel){g=m;var x=c.lastSel,S=Math.abs(x.head.line-x.anchor.line),C=Math.abs(x.head.ch-x.anchor.ch);h=x.visualLine?new t(m.line+S,m.ch):x.visualBlock?new t(m.line+S,m.ch+C):x.head.line==x.anchor.line?new t(m.line,m.ch+C):new t(m.line+S,m.ch),r.visualMode=!0,r.visualLine=x.visualLine,r.visualBlock=x.visualBlock,u=r.sel={anchor:g,head:h},Ze(e)}else r.visualMode&&(c.lastSel={anchor:F(u.anchor),head:F(u.head),visualBlock:r.visualBlock,visualLine:r.visualLine});var w,T,E,D,ee;if(r.visualMode){w=Re(u.head,u.anchor),T=ze(u.head,u.anchor),E=r.visualLine||c.linewise,D=r.visualBlock?`block`:E?`line`:`char`;var O=n(e,w,T);if(ee=Qe(e,{anchor:O.start,head:O.end},D),E){var te=ee.ranges;if(D==`block`)for(var k=0;k<te.length;k++)te[k].head.ch=Ve(e,te[k].head.line);else D==`line`&&(te[0].head=new t(te[0].head.line+1,0))}}else{if(w=F(g||m),T=F(h||p),I(T,w)){var ne=w;w=T,T=ne}E=o.linewise||c.linewise,E?tt(e,w,T):o.forward&&et(e,w,T),D=`char`;var A=!o.inclusive||E,O=n(e,w,T);ee=Qe(e,{anchor:O.start,head:O.end},D,A)}e.setSelections(ee.ranges,ee.primary),r.lastMotion=null,c.repeat=_,c.registerName=l,c.linewise=E;var re=De[s](e,c,ee.ranges,m,h);r.visualMode&&$e(e,re!=null),re&&e.setCursor(re)}},recordLastEdit:function(e,t,n){var r=j.macroModeState;r.isPlaying||(e.lastEditInputState=t,e.lastEditActionCommand=n,r.lastInsertModeChanges.changes=[],r.lastInsertModeChanges.expectCursorActivityForChange=!1,r.lastInsertModeChanges.visualBlock=e.visualBlock?e.sel.head.line-e.sel.anchor.line:0)}},we={moveToTopLine:function(e,n,r){var i=Wt(e).top+r.repeat-1;return new t(i,nt(e.getLine(i)))},moveToMiddleLine:function(e){var n=Wt(e),r=Math.floor((n.top+n.bottom)*.5);return new t(r,nt(e.getLine(r)))},moveToBottomLine:function(e,n,r){var i=Wt(e).bottom-r.repeat+1;return new t(i,nt(e.getLine(i)))},expandToLine:function(e,n,r){return new t(n.line+r.repeat-1,1/0)},findNext:function(e,t,n){var r=Ct(e),i=r.getQuery();if(i){var a=!n.forward;a=r.isReversed()?!a:a,zt(e,i);var o=Bt(e,a,i,n.repeat);return o||B(e,`No match found `+i+(O(`pcre`)?` (set nopcre to use Vim regexps)`:``)),o}},findAndSelectNextInclusive:function(n,r,i,a,o){var s=Ct(n),c=s.getQuery();if(c){var l=!i.forward;l=s.isReversed()?!l:l;var u=Vt(n,l,c,i.repeat,a);if(u){if(o.operator)return u;var d=u[0],f=new t(u[1].line,u[1].ch-1);if(a.visualMode){(a.visualLine||a.visualBlock)&&(a.visualLine=!1,a.visualBlock=!1,e.signal(n,`vim-mode-change`,{mode:`visual`,subMode:``}));var p=a.sel.anchor;if(p)return s.isReversed()?i.forward?[p,d]:[p,f]:i.forward?[p,f]:[p,d]}else a.visualMode=!0,a.visualLine=!1,a.visualBlock=!1,e.signal(n,`vim-mode-change`,{mode:`visual`,subMode:``});return l?[f,d]:[d,f]}}},goToMark:function(e,t,n,r){var i=Gt(e,r,n.selectedCharacter||``);return i?n.linewise?{line:i.line,ch:nt(e.getLine(i.line))}:i:null},moveToOtherHighlightedEnd:function(e,n,r,i){var a=i.sel;return i.visualBlock&&r.sameLine?[je(e,new t(a.anchor.line,a.head.ch)),je(e,new t(a.head.line,a.anchor.ch))]:[a.head,a.anchor]},jumpToMark:function(e,n,r,i){for(var a=n,o=0;o<r.repeat;o++){var s=a;for(var c in i.marks)if(y(c)){var l=i.marks[c].find();if(!(r.forward?I(l,s):I(s,l))&&!(r.linewise&&l.line==s.line)){var u=Le(s,a),d=r.forward?Be(s,l,a):Be(a,l,s);(u||d)&&(a=l)}}}return r.linewise&&(a=new t(a.line,nt(e.getLine(a.line)))),a},moveByCharacters:function(e,n,r){var i=n,a=r.repeat,o=r.forward?i.ch+a:i.ch-a;return new t(i.line,o)},moveByLines:function(e,n,r,i){var a=n,o=a.ch;switch(i.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:o=i.lastHPos;break;default:i.lastHPos=o}var s=r.repeat+(r.repeatOffset||0),c=r.forward?a.line+s:a.line-s,l=e.firstLine(),u=e.lastLine(),d=e.findPosV(a,r.forward?s:-s,`line`,i.lastHSPos);return(r.forward?d.line>c:d.line<c)&&(c=d.line,o=d.ch),c<l&&a.line==l?this.moveToStartOfLine(e,n,r,i):c>u&&a.line==u?ft(e,n,r,i,!0):(r.toFirstChar&&(o=nt(e.getLine(c)),i.lastHPos=o),i.lastHSPos=e.charCoords(new t(c,o),`div`).left,new t(c,o))},moveByDisplayLines:function(e,n,r,i){var a=n;switch(i.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:i.lastHSPos=e.charCoords(a,`div`).left}var o=r.repeat,s=e.findPosV(a,r.forward?o:-o,`line`,i.lastHSPos);if(s.hitSide)if(r.forward){var c={top:e.charCoords(s,`div`).top+8,left:i.lastHSPos};s=e.coordsChar(c,`div`)}else{var l=e.charCoords(new t(e.firstLine(),0),`div`);l.left=i.lastHSPos,s=e.coordsChar(l,`div`)}return i.lastHPos=s.ch,s},moveByPage:function(e,t,n){var r=t,i=n.repeat;return e.findPosV(r,n.forward?i:-i,`page`)},moveByParagraph:function(e,t,n){var r=n.forward?1:-1;return _t(e,t,n.repeat,r).start},moveBySentence:function(e,t,n){var r=n.forward?1:-1;return yt(e,t,n.repeat,r)},moveByScroll:function(e,t,n,r){var i=e.getScrollInfo(),a=null,o=n.repeat;o||=i.clientHeight/(2*e.defaultTextHeight());var s=e.charCoords(t,`local`);if(n.repeat=o,a=we.moveByDisplayLines(e,t,n,r),!a)return null;var c=e.charCoords(a,`local`);return e.scrollTo(null,i.top+c.top-s.top),a},moveByWords:function(e,t,n){return dt(e,t,n.repeat,!!n.forward,!!n.wordEnd,!!n.bigWord)},moveTillCharacter:function(e,t,n){var r=n.repeat,i=pt(e,r,n.forward,n.selectedCharacter,t),a=n.forward?-1:1;return ot(a,n),i?(i.ch+=a,i):null},moveToCharacter:function(e,t,n){var r=n.repeat;return ot(0,n),pt(e,r,n.forward,n.selectedCharacter,t)||t},moveToSymbol:function(e,t,n){var r=n.repeat;return n.selectedCharacter&&lt(e,r,n.forward,n.selectedCharacter)||t},moveToColumn:function(e,t,n,r){var i=n.repeat;return r.lastHPos=i-1,r.lastHSPos=e.charCoords(t,`div`).left,mt(e,i)},moveToEol:function(e,t,n,r){return ft(e,t,n,r,!1)},moveToFirstNonWhiteSpaceCharacter:function(e,n){var r=n;return new t(r.line,nt(e.getLine(r.line)))},moveToMatchedSymbol:function(e,n){for(var r=n,i=r.line,a=r.ch,o=e.getLine(i),s;a<o.length;a++)if(s=o.charAt(a),s&&b(s)){var c=e.getTokenTypeAt(new t(i,a+1));if(c!==`string`&&c!==`comment`)break}if(a<o.length){var l=s===`<`||s===`>`?/[(){}[\]<>]/:/[(){}[\]]/;return e.findMatchingBracket(new t(i,a),{bracketRegex:l}).to}else return r},moveToStartOfLine:function(e,n){return new t(n.line,0)},moveToLineOrEdgeOfDocument:function(e,n,r){var i=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(i=r.repeat-e.getOption(`firstLineNumber`)),new t(i,nt(e.getLine(i)))},moveToStartOfDisplayLine:function(e){return e.execCommand(`goLineLeft`),e.getCursor()},moveToEndOfDisplayLine:function(e){e.execCommand(`goLineRight`);var t=e.getCursor();return t.sticky==`before`&&t.ch--,t},textObjectManipulation:function(e,t,n,r){var i={"(":`)`,")":`(`,"{":`}`,"}":`{`,"[":`]`,"]":`[`,"<":`>`,">":`<`},a={"'":!0,'"':!0,"`":!0},o=n.selectedCharacter||``;o==`b`?o=`(`:o==`B`&&(o=`{`);var s=!n.textObjectInner,c,l;if(i[o]){if(l=!0,c=bt(e,t,o,s),!c){var u=e.getSearchCursor(RegExp(`\\`+o,`g`),t);u.find()&&(c=bt(e,u.from(),o,s))}}else if(a[o])l=!0,c=xt(e,t,o,s);else if(o===`W`||o===`w`)for(var d=n.repeat||1;d-- >0;){var f=rt(e,{inclusive:s,innerWord:!s,bigWord:o===`W`,noSymbol:o===`W`,multiline:!0},c&&c.end);f&&(c||=f,c.end=f.end)}else if(o===`p`)if(c=_t(e,t,n.repeat,0,s),n.linewise=!0,r.visualMode)r.visualLine||=!0;else{var p=r.inputState.operatorArgs;p&&(p.linewise=!0),c.end.line--}else if(o===`t`)c=it(e,t,s);else if(o===`s`){var m=e.getLine(t.line);t.ch>0&&w(m[t.ch])&&--t.ch;var h=vt(e,t,n.repeat,1,s),g=vt(e,t,n.repeat,-1,s);C(e.getLine(g.line)[g.ch])&&C(e.getLine(h.line)[h.ch-1])&&(g={line:g.line,ch:g.ch+1}),c={start:g,end:h}}return c?e.state.vim.visualMode?Xe(e,c.start,c.end,l):[c.start,c.end]:null},repeatLastCharacterSearch:function(e,t,n){var r=j.lastCharacterSearch,i=n.repeat,a=n.forward===r.forward,o=(r.increment?1:0)*(a?-1:1);e.moveH(-o,`char`),n.inclusive=!!a;var s=pt(e,i,a,r.selectedCharacter);return s?(s.ch+=o,s):(e.moveH(o,`char`),t)}};function Te(e,t){we[e]=t}function Ee(e,t){for(var n=[],r=0;r<t;r++)n.push(e);return n}var De={change:function(e,n,r){var i,a,o=e.state.vim,s=r[0].anchor,c=r[0].head;if(!o.visualMode){a=e.getRange(s,c);var l=o.lastEditInputState;if(l?.motion==`moveByWords`&&!C(a)){var u=/\s+$/.exec(a);u&&l.motionArgs&&l.motionArgs.forward&&(c=P(c,0,-u[0].length),a=a.slice(0,-u[0].length))}n.linewise&&(s=new t(s.line,nt(e.getLine(s.line))),c.line>s.line&&(c=new t(c.line-1,Number.MAX_VALUE))),e.replaceRange(``,s,c),i=s}else if(n.fullLine)c.ch=Number.MAX_VALUE,c.line--,e.setSelection(s,c),a=e.getSelection(),e.replaceSelection(``),i=s;else{a=e.getSelection();var d=Ee(``,r.length);e.replaceSelections(d),i=Re(r[0].head,r[0].anchor)}j.registerController.pushText(n.registerName,`change`,a,n.linewise,r.length>1),ke.enterInsertMode(e,{head:i},e.state.vim)},delete:function(e,n,r){var i,a,o=e.state.vim;if(o.visualBlock){a=e.getSelection();var s=Ee(``,r.length);e.replaceSelections(s),i=Re(r[0].head,r[0].anchor)}else{var c=r[0].anchor,l=r[0].head;n.linewise&&l.line!=e.firstLine()&&c.line==e.lastLine()&&c.line==l.line-1&&(c.line==e.firstLine()?c.ch=0:c=new t(c.line-1,Ve(e,c.line-1))),a=e.getRange(c,l),e.replaceRange(``,c,l),i=c,n.linewise&&(i=we.moveToFirstNonWhiteSpaceCharacter(e,c))}return j.registerController.pushText(n.registerName,`delete`,a,n.linewise,o.visualBlock),je(e,i)},indent:function(e,t,n){var r=e.state.vim,i=r.visualMode&&t.repeat||1;if(r.visualBlock){for(var a=e.getOption(`tabSize`),o=e.getOption(`indentWithTabs`)?` `:` `.repeat(a),s,c=n.length-1;c>=0;c--)if(s=Re(n[c].anchor,n[c].head),t.indentRight)e.replaceRange(o.repeat(i),s,s);else{for(var l=e.getLine(s.line),u=0,d=0;d<i;d++){var f=l[s.ch+u];if(f==` `)u++;else if(f==` `){u++;for(var p=1;p<o.length&&(f=l[s.ch+u],f===` `);p++)u++}else break}e.replaceRange(``,s,P(s,0,u))}return s}else if(e.indentMore)for(var d=0;d<i;d++)t.indentRight?e.indentMore():e.indentLess();else{var m=n[0].anchor.line,h=r.visualBlock?n[n.length-1].anchor.line:n[0].head.line;t.linewise&&h--;for(var c=m;c<=h;c++)for(var d=0;d<i;d++)e.indentLine(c,t.indentRight)}return we.moveToFirstNonWhiteSpaceCharacter(e,n[0].anchor)},indentAuto:function(e,t,n){return e.execCommand(`indentAuto`),we.moveToFirstNonWhiteSpaceCharacter(e,n[0].anchor)},hardWrap:function(e,n,r,i){if(e.hardWrap){var a=r[0].anchor.line,o=r[0].head.line;n.linewise&&o--;var s=e.hardWrap({from:a,to:o});return s>a&&n.linewise&&s--,n.keepCursor?i:new t(s,0)}},changeCase:function(e,t,n,r,i){for(var a=e.getSelections(),o=[],s=t.toLower,c=0;c<a.length;c++){var l=a[c],u=``;if(s===!0)u=l.toLowerCase();else if(s===!1)u=l.toUpperCase();else for(var d=0;d<l.length;d++){var f=l.charAt(d);u+=S(f)?f.toLowerCase():f.toUpperCase()}o.push(u)}return e.replaceSelections(o),t.shouldMoveCursor?i:!e.state.vim.visualMode&&t.linewise&&n[0].anchor.line+1==n[0].head.line?we.moveToFirstNonWhiteSpaceCharacter(e,r):t.linewise?r:Re(n[0].anchor,n[0].head)},yank:function(e,t,n,r){var i=e.state.vim,a=e.getSelection(),o=i.visualMode?Re(i.sel.anchor,i.sel.head,n[0].head,n[0].anchor):r;return j.registerController.pushText(t.registerName,`yank`,a,t.linewise,i.visualBlock),o},rot13:function(e,t,n,r,i){for(var a=e.getSelections(),o=[],s=0;s<a.length;s++){let e=a[s].split(``).map(e=>{let t=e.charCodeAt(0);return t>=65&&t<=90?String.fromCharCode(65+(t-65+13)%26):t>=97&&t<=122?String.fromCharCode(97+(t-97+13)%26):e}).join(``);o.push(e)}return e.replaceSelections(o),t.shouldMoveCursor?i:!e.state.vim.visualMode&&t.linewise&&n[0].anchor.line+1==n[0].head.line?we.moveToFirstNonWhiteSpaceCharacter(e,r):t.linewise?r:Re(n[0].anchor,n[0].head)}};function Oe(e,t){De[e]=t}var ke={jumpListWalk:function(e,t,n){if(!n.visualMode){var r=t.repeat||1,i=t.forward,a=j.jumpList.move(e,i?r:-r),o=a?a.find():void 0;o||=e.getCursor(),e.setCursor(o)}},scroll:function(e,t,n){if(!n.visualMode){var r=t.repeat||1,i=e.defaultTextHeight(),a=e.getScrollInfo().top,o=i*r,s=t.forward?a+o:a-o,c=F(e.getCursor()),l=e.charCoords(c,`local`);if(t.forward)s>l.top?(c.line+=(s-l.top)/i,c.line=Math.ceil(c.line),e.setCursor(c),l=e.charCoords(c,`local`),e.scrollTo(null,l.top)):e.scrollTo(null,s);else{var u=s+e.getScrollInfo().clientHeight;u<l.bottom?(c.line-=(l.bottom-u)/i,c.line=Math.floor(c.line),e.setCursor(c),l=e.charCoords(c,`local`),e.scrollTo(null,l.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,s)}}},scrollToCursor:function(e,n){var r=e.getCursor().line,i=e.charCoords(new t(r,0),`local`),a=e.getScrollInfo().clientHeight,o=i.top;switch(n.position){case`center`:o=i.bottom-a/2;break;case`bottom`:var s=new t(r,e.getLine(r).length-1),c=e.charCoords(s,`local`).bottom-o;o=o-a+c;break}e.scrollTo(null,o)},replayMacro:function(e,t,n){var r=t.selectedCharacter||``,i=t.repeat||1,a=j.macroModeState;for(r==`@`?r=a.latestRegister||``:a.latestRegister=r;i--;)tn(e,n,a,r)},enterMacroRecordMode:function(e,t){var n=j.macroModeState,r=t.selectedCharacter;j.registerController.isValidRegister(r)&&n.enterMacroRecordMode(e,r)},toggleOverwrite:function(t){t.state.overwrite?(t.toggleOverwrite(!1),t.setOption(`keyMap`,`vim-insert`),e.signal(t,`vim-mode-change`,{mode:`insert`})):(t.toggleOverwrite(!0),t.setOption(`keyMap`,`vim-replace`),e.signal(t,`vim-mode-change`,{mode:`replace`}))},enterInsertMode:function(r,i,a){if(!r.getOption(`readOnly`)){a.insertMode=!0,a.insertModeRepeat=i&&i.repeat||1;var o=i?i.insertAt:null,s=a.sel,c=i.head||r.getCursor(`head`),l=r.listSelections().length;if(o==`eol`)c=new t(c.line,Ve(r,c.line));else if(o==`bol`)c=new t(c.line,0);else if(o==`charAfter`){var u=n(r,c,P(c,0,1));c=u.end}else if(o==`firstNonBlank`){var u=n(r,c,we.moveToFirstNonWhiteSpaceCharacter(r,c));c=u.end}else if(o==`startOfSelectedArea`){if(!a.visualMode)return;a.visualBlock?(c=new t(Math.min(s.head.line,s.anchor.line),Math.min(s.head.ch,s.anchor.ch)),l=Math.abs(s.head.line-s.anchor.line)+1):c=s.head.line<s.anchor.line?s.head:new t(s.anchor.line,0)}else if(o==`endOfSelectedArea`){if(!a.visualMode)return;a.visualBlock?(c=new t(Math.min(s.head.line,s.anchor.line),Math.max(s.head.ch,s.anchor.ch)+1),l=Math.abs(s.head.line-s.anchor.line)+1):c=s.head.line>=s.anchor.line?P(s.head,0,1):new t(s.anchor.line,0)}else if(o==`inplace`){if(a.visualMode)return}else o==`lastEdit`&&(c=Kt(r)||c);r.setOption(`disableInput`,!1),i&&i.replace?(r.toggleOverwrite(!0),r.setOption(`keyMap`,`vim-replace`),e.signal(r,`vim-mode-change`,{mode:`replace`})):(r.toggleOverwrite(!1),r.setOption(`keyMap`,`vim-insert`),e.signal(r,`vim-mode-change`,{mode:`insert`})),j.macroModeState.isPlaying||(r.on(`change`,on),a.insertEnd&&a.insertEnd.clear(),a.insertEnd=r.setBookmark(c,{insertLeft:!0}),e.on(r.getInputField(),`keydown`,ln)),a.visualMode&&$e(r),Ke(r,c,l)}},toggleVisualMode:function(r,i,a){var o=i.repeat,s=r.getCursor(),c;if(a.visualMode)a.visualLine!=!!i.linewise||a.visualBlock!=!!i.blockwise?(a.visualLine=!!i.linewise,a.visualBlock=!!i.blockwise,e.signal(r,`vim-mode-change`,{mode:`visual`,subMode:a.visualLine?`linewise`:a.visualBlock?`blockwise`:``}),Ze(r)):$e(r);else{a.visualMode=!0,a.visualLine=!!i.linewise,a.visualBlock=!!i.blockwise,c=je(r,new t(s.line,s.ch+o-1));var l=n(r,s,c);a.sel={anchor:l.start,head:l.end},e.signal(r,`vim-mode-change`,{mode:`visual`,subMode:a.visualLine?`linewise`:a.visualBlock?`blockwise`:``}),Ze(r),ht(r,a,`<`,Re(s,c)),ht(r,a,`>`,ze(s,c))}},reselectLastSelection:function(t,n,r){var i=r.lastSelection;if(r.visualMode&&Ye(t,r),i){var a=i.anchorMark.find(),o=i.headMark.find();if(!a||!o)return;r.sel={anchor:a,head:o},r.visualMode=!0,r.visualLine=i.visualLine,r.visualBlock=i.visualBlock,Ze(t),ht(t,r,`<`,Re(a,o)),ht(t,r,`>`,ze(a,o)),e.signal(t,`vim-mode-change`,{mode:`visual`,subMode:r.visualLine?`linewise`:r.visualBlock?`blockwise`:``})}},joinLines:function(e,n,r){var i,a;if(r.visualMode){if(i=e.getCursor(`anchor`),a=e.getCursor(`head`),I(a,i)){var o=a;a=i,i=o}a.ch=Ve(e,a.line)-1}else{var s=Math.max(n.repeat,2);i=e.getCursor(),a=je(e,new t(i.line+s-1,1/0))}for(var c=0,l=i.line;l<a.line;l++){c=Ve(e,i.line);var u=``,d=0;if(!n.keepSpaces){var f=e.getLine(i.line+1);d=f.search(/\S/),d==-1?d=f.length:u=` `}e.replaceRange(u,new t(i.line,c),new t(i.line+1,d))}var p=je(e,new t(i.line,c));r.visualMode&&$e(e,!1),e.setCursor(p)},newLineAndEnterInsertMode:function(n,r,i){i.insertMode=!0;var a=F(n.getCursor());a.line===n.firstLine()&&!r.after?(n.replaceRange(`
23
+ `,new t(n.firstLine(),0)),n.setCursor(n.firstLine(),0)):(a.line=r.after?a.line:a.line-1,a.ch=Ve(n,a.line),n.setCursor(a),(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(n)),this.enterInsertMode(n,{repeat:r.repeat},i)},paste:function(e,t,n){var r=j.registerController.getRegister(t.registerName);if(t.registerName===`+`)navigator.clipboard.readText().then(i=>{this.continuePaste(e,t,n,i,r)});else{var i=r.toString();this.continuePaste(e,t,n,i,r)}},continuePaste:function(e,n,r,i,a){var o=F(e.getCursor());if(i){if(n.matchIndent){var s=e.getOption(`tabSize`),c=function(e){var t=e.split(` `).length-1,n=e.split(` `).length-1;return t*s+n*1},l=c(e.getLine(e.getCursor().line).match(/^\s*/)[0]),u=i.replace(/\n$/,``),d=i!==u,f=c(i.match(/^\s*/)[0]),i=u.replace(/^\s*/gm,function(t){var n=l+(c(t)-f);if(n<0)return``;if(e.getOption(`indentWithTabs`)){var r=Math.floor(n/s);return Array(r+1).join(` `)}else return Array(n+1).join(` `)});i+=d?`
24
+ `:``}n.repeat>1&&(i=Array(n.repeat+1).join(i));var p=a.linewise,m=a.blockwise,h=m?i.split(`
25
+ `):void 0;if(h){p&&h.pop();for(var g=0;g<h.length;g++)h[g]=h[g]==``?` `:h[g];o.ch+=n.after?1:0,o.ch=Math.min(Ve(e,o.line),o.ch)}else p?r.visualMode?i=r.visualLine?i.slice(0,-1):`
26
+ `+i.slice(0,i.length-1)+`
27
+ `:n.after?(i=`
28
+ `+i.slice(0,i.length-1),o.ch=Ve(e,o.line)):o.ch=0:o.ch+=n.after?1:0;var _;if(r.visualMode){r.lastPastedText=i;var v,y=Je(e),b=y[0],x=y[1],S=e.getSelection(),C=e.listSelections(),w=Array(C.length).join(`1`).split(`1`);r.lastSelection&&(v=r.lastSelection.headMark.find()),j.registerController.unnamedRegister.setText(S),m?(e.replaceSelections(w),x=new t(b.line+i.length-1,b.ch),e.setCursor(b),Ge(e,x),e.replaceSelections(i),_=b):r.visualBlock?(e.replaceSelections(w),e.setCursor(b),e.replaceRange(i,b,b),_=b):(e.replaceRange(i,b,x),_=e.posFromIndex(e.indexFromPos(b)+i.length-1)),v&&(r.lastSelection.headMark=e.setBookmark(v)),p&&(_.ch=0)}else if(m&&h){e.setCursor(o);for(var g=0;g<h.length;g++){var T=o.line+g;T>e.lastLine()&&e.replaceRange(`
29
+ `,new t(T,0)),Ve(e,T)<o.ch&&We(e,T,o.ch)}e.setCursor(o),Ge(e,new t(o.line+h.length-1,o.ch)),e.replaceSelections(h),_=o}else if(e.replaceRange(i,o),p){var T=n.after?o.line+1:o.line;_=new t(T,nt(e.getLine(T)))}else _=F(o),/\n/.test(i)||(_.ch+=i.length-(n.after?1:0));r.visualMode&&$e(e,!1),e.setCursor(_)}},undo:function(t,n){t.operation(function(){Ie(t,e.commands.undo,n.repeat)(),t.setCursor(je(t,t.getCursor(`start`)))})},redo:function(t,n){Ie(t,e.commands.redo,n.repeat)()},setRegister:function(e,t,n){n.inputState.registerName=t.selectedCharacter},insertRegister:function(e,t,n){var r=t.selectedCharacter,i=j.registerController.getRegister(r),a=i&&i.toString();a&&e.replaceSelection(a)},oneNormalCommand:function(t,n,r){Zt(t,!0),r.insertModeReturn=!0,e.on(t,`vim-command-done`,function n(){r.visualMode||(r.insertModeReturn&&(r.insertModeReturn=!1,r.insertMode||ke.enterInsertMode(t,{},r)),e.off(t,`vim-command-done`,n))})},setMark:function(e,t,n){var r=t.selectedCharacter;r&&ht(e,n,r,e.getCursor())},replace:function(r,i,a){var o=i.selectedCharacter||``,s=r.getCursor(),c,l,u=r.listSelections();if(a.visualMode)s=r.getCursor(`start`),l=r.getCursor(`end`);else{var d=r.getLine(s.line);c=s.ch+i.repeat,c>d.length&&(c=d.length),l=new t(s.line,c)}var f=n(r,s,l);if(s=f.start,l=f.end,o==`
30
+ `)a.visualMode||r.replaceRange(``,s,l),(e.commands.newlineAndIndentContinueComment||e.commands.newlineAndIndent)(r);else{var p=r.getRange(s,l);if(p=p.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,o),p=p.replace(/[^\n]/g,o),a.visualBlock){var m=Array(r.getOption(`tabSize`)+1).join(` `);p=r.getSelection(),p=p.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,o);var h=p.replace(/\t/g,m).replace(/[^\n]/g,o).split(`
31
+ `);r.replaceSelections(h)}else r.replaceRange(p,s,l);a.visualMode?(s=I(u[0].anchor,u[0].head)?u[0].anchor:u[0].head,r.setCursor(s),$e(r,!1)):r.setCursor(P(l,0,-1))}},incrementNumberToken:function(e,n){for(var r=e.getCursor(),i=e.getLine(r.line),a=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,o,s,c,l;(o=a.exec(i))!==null&&(s=o.index,c=s+o[0].length,!(r.ch<c)););if(!(!n.backtrack&&c<=r.ch)){if(o){var u=o[2]||o[4],d=o[3]||o[5],f=n.increase?1:-1,p={"0b":2,0:8,"":10,"0x":16}[u.toLowerCase()];l=(parseInt(o[1]+d,p)+f*n.repeat).toString(p);var m=u?Array(d.length-l.length+1+o[1].length).join(`0`):``;l=l.charAt(0)===`-`?`-`+u+m+l.substr(1):u+m+l;var h=new t(r.line,s),g=new t(r.line,c);e.replaceRange(l,h,g)}else return;e.setCursor(new t(r.line,s+l.length-1))}},repeatLastEdit:function(e,t,n){var r=n.lastEditInputState;if(r){var i=t.repeat;i&&t.repeatIsExplicit?r.repeatOverride=i:i=r.repeatOverride||i,un(e,n,i,!1)}},indent:function(e,t){e.indentLine(e.getCursor().line,t.indentRight)},exitInsertMode:function(e,t){Zt(e)}};function Ae(e,t){ke[e]=t}function je(e,n,r){var i=e.state.vim,a=i.insertMode||i.visualMode,o=Math.min(Math.max(e.firstLine(),n.line),e.lastLine()),s=e.getLine(o),c=s.length-1+Number(!!a),l=Math.min(Math.max(0,n.ch),c),u=s.charCodeAt(l);if(56320<=u&&u<=57343){var d=1;r&&r.line==o&&r.ch>l&&(d=-1),l+=d,l>c&&(l-=2)}return new t(o,l)}function Me(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}function P(e,n,r){return typeof n==`object`&&(r=n.ch,n=n.line),new t(e.line+n,e.ch+r)}function Ne(e,t,n,r){r.operator&&(n=`operatorPending`);for(var i,o=[],s=[],c=ce?t.length-a:0;c<t.length;c++){var l=t[c];n==`insert`&&l.context!=`insert`||l.context&&l.context!=n||r.operator&&l.type==`action`||!(i=Pe(e,l.keys))||(i==`partial`&&o.push(l),i==`full`&&s.push(l))}return{partial:o,full:s}}function Pe(e,t){let n=t.slice(-11)==`<character>`,r=t.slice(-10)==`<register>`;if(n||r){var i=t.length-(n?11:10),a=e.slice(0,i),o=t.slice(0,i);return a==o&&e.length>i?`full`:o.indexOf(a)==0?`partial`:!1}else return e==t?`full`:t.indexOf(e)==0?`partial`:!1}function Fe(e){var t=/^.*(<[^>]+>)$/.exec(e),n=t?t[1]:e.slice(-1);if(n.length>1)switch(n){case`<CR>`:case`<S-CR>`:n=`
32
+ `;break;case`<Space>`:case`<S-Space>`:n=` `;break;default:n=``;break}return n}function Ie(e,t,n){return function(){for(var r=0;r<n;r++)t(e)}}function F(e){return new t(e.line,e.ch)}function Le(e,t){return e.ch==t.ch&&e.line==t.line}function I(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function Re(e,t){return arguments.length>2&&(t=Re.apply(void 0,Array.prototype.slice.call(arguments,1))),I(e,t)?e:t}function ze(e,t){return arguments.length>2&&(t=ze.apply(void 0,Array.prototype.slice.call(arguments,1))),I(e,t)?t:e}function Be(e,t,n){var r=I(e,t),i=I(t,n);return r&&i}function Ve(e,t){return e.getLine(t).length}function He(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,``)}function Ue(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,`\\$1`)}function We(e,n,r){var i=Ve(e,n),a=Array(r-i+1).join(` `);e.setCursor(new t(n,i)),e.replaceRange(a,e.getCursor())}function Ge(e,n){var r=[],i=e.listSelections(),a=F(e.clipPos(n)),o=!Le(n,a),s=qe(i,e.getCursor(`head`)),c=Le(i[s].head,i[s].anchor),l=i.length-1,u=l-s>s?l:0,d=i[u].anchor,f=Math.min(d.line,a.line),p=Math.max(d.line,a.line),m=d.ch,h=a.ch,g=i[u].head.ch-m,_=h-m;g>0&&_<=0?(m++,o||h--):g<0&&_>=0?(m--,c||h++):g<0&&_==-1&&(m--,h++);for(var v=f;v<=p;v++){var y={anchor:new t(v,m),head:new t(v,h)};r.push(y)}return e.setSelections(r),n.ch=h,d.ch=m,d}function Ke(e,t,n){for(var r=[],i=0;i<n;i++){var a=P(t,i,0);r.push({anchor:a,head:a})}e.setSelections(r,0)}function qe(e,t,n){for(var r=0;r<e.length;r++){var i=Le(e[r].anchor,t),a=Le(e[r].head,t);if(i||a)return r}return-1}function Je(e,t){var n=e.listSelections(),r=n[0],i=n[n.length-1];return[I(r.anchor,r.head)?r.anchor:r.head,I(i.anchor,i.head)?i.head:i.anchor]}function Ye(e,t){var n=t.sel.anchor,r=t.sel.head;t.lastPastedText&&=(r=e.posFromIndex(e.indexFromPos(n)+t.lastPastedText.length),void 0),t.lastSelection={anchorMark:e.setBookmark(n),headMark:e.setBookmark(r),anchor:F(n),head:F(r),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function Xe(e,n,r,i){var a=e.state.vim.sel,o=i?n:a.head,s=i?n:a.anchor,c;return I(r,n)&&(c=r,r=n,n=c),I(o,s)?(o=Re(n,o),s=ze(s,r)):(s=Re(n,s),o=ze(o,r),o=P(o,0,-1),o.ch==-1&&o.line!=e.firstLine()&&(o=new t(o.line-1,Ve(e,o.line-1)))),[s,o]}function Ze(e,t,n){var r=e.state.vim;t||=r.sel,n||=r.visualLine?`line`:r.visualBlock?`block`:`char`;var i=Qe(e,t,n);e.setSelections(i.ranges,i.primary)}function Qe(e,n,r,i){var a=F(n.head),o=F(n.anchor);if(r==`char`){var s=!i&&!I(n.head,n.anchor)?1:0,c=I(n.head,n.anchor)?1:0;return a=P(n.head,0,s),o=P(n.anchor,0,c),{ranges:[{anchor:o,head:a}],primary:0}}else if(r==`line`){if(I(n.head,n.anchor))a.ch=0,o.ch=Ve(e,o.line);else{o.ch=0;var l=e.lastLine();a.line>l&&(a.line=l),a.ch=Ve(e,a.line)}return{ranges:[{anchor:o,head:a}],primary:0}}else if(r==`block`){var u=Math.min(o.line,a.line),d=o.ch,f=Math.max(o.line,a.line),p=a.ch;d<p?p+=1:d+=1;for(var m=f-u+1,h=a.line==u?0:m-1,g=[],_=0;_<m;_++)g.push({anchor:new t(u+_,d),head:new t(u+_,p)});return{ranges:g,primary:h}}throw`never happens`}function L(e){var t=e.getCursor(`head`);return e.getSelection().length==1&&(t=Re(t,e.getCursor(`anchor`))),t}function $e(t,n){var r=t.state.vim;n!==!1&&t.setCursor(je(t,r.sel.head)),Ye(t,r),r.visualMode=!1,r.visualLine=!1,r.visualBlock=!1,r.insertMode||e.signal(t,`vim-mode-change`,{mode:`normal`})}function et(e,t,n){var r=e.getRange(t,n);if(/\n\s*$/.test(r)){var i=r.split(`
33
+ `);i.pop();for(var a=i.pop();i.length>0&&a&&C(a);a=i.pop())n.line--,n.ch=0;a?(n.line--,n.ch=Ve(e,n.line)):n.ch=0}}function tt(e,t,n){t.ch=0,n.ch=0,n.line++}function nt(e){if(!e)return 0;var t=e.search(/\S/);return t==-1?e.length:t}function rt(e,{inclusive:n,innerWord:r,bigWord:i,noSymbol:a,multiline:o},s){var c=s||L(e),l=e.getLine(c.line),u=l,d=c.line,m=d,h=c.ch,g,_=a?f[0]:p[0];if(r&&/\s/.test(l.charAt(h)))_=function(e){return/\s/.test(e)};else{for(;!_(l.charAt(h));)if(h++,h>=l.length){if(!o)return null;h--,g=ut(e,c,!0,i,!0);break}i?_=p[0]:(_=f[0],_(l.charAt(h))||(_=f[1]))}for(var v=h,y=h;_(l.charAt(y))&&y>=0;)y--;if(y++,g)v=g.to,m=g.line,u=e.getLine(m),!u&&v==0&&v++;else for(;_(l.charAt(v))&&v<l.length;)v++;if(n){var b=v,x=c.ch<=y&&/\s/.test(l.charAt(c.ch));if(!x)for(;/\s/.test(u.charAt(v))&&v<u.length;)v++;if(b==v||x){for(var S=y;/\s/.test(l.charAt(y-1))&&y>0;)y--;!y&&!x&&(y=S)}}return{start:new t(d,y),end:new t(m,v)}}function it(t,n,r){var i=n;if(!e.findMatchingTag||!e.findEnclosingTag)return{start:i,end:i};var a=e.findMatchingTag(t,n)||e.findEnclosingTag(t,n);return!a||!a.open||!a.close?{start:i,end:i}:r?{start:a.open.from,end:a.close.to}:{start:a.open.to,end:a.close.from}}function at(e,t,n){Le(t,n)||j.jumpList.add(e,t,n)}function ot(e,t){j.lastCharacterSearch.increment=e,j.lastCharacterSearch.forward=t.forward,j.lastCharacterSearch.selectedCharacter=t.selectedCharacter}var st={"(":`bracket`,")":`bracket`,"{":`bracket`,"}":`bracket`,"[":`section`,"]":`section`,"*":`comment`,"/":`comment`,m:`method`,M:`method`,"#":`preprocess`},ct={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(e.depth++,e.depth>=1)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?`]`:`[`)===e.symb?`{`:`}`},isComplete:function(e){return e.index===0&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t=e.lastCh===`*`&&e.nextCh===`/`;return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb=e.symb===`m`?`{`:`}`,e.reverseSymb=e.symb===`{`?`}`:`{`},isComplete:function(e){return e.nextCh===e.symb}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if(e.nextCh===`#`){var t=e.lineText.match(/^#(\w+)/)?.[1];if(t===`endif`){if(e.forward&&e.depth===0)return!0;e.depth++}else if(t===`if`){if(!e.forward&&e.depth===0)return!0;e.depth--}if(t===`else`&&e.depth===0)return!0}return!1}}};function lt(e,n,r,i){var a=F(e.getCursor()),o=r?1:-1,s=r?e.lineCount():-1,c=a.ch,l=a.line,u=e.getLine(l),d={lineText:u,nextCh:u.charAt(c),lastCh:null,index:c,symb:i,reverseSymb:(r?{")":`(`,"}":`{`}:{"(":`)`,"{":`}`})[i],forward:r,depth:0,curMoveThrough:!1},f=st[i];if(!f)return a;var p=ct[f].init,m=ct[f].isComplete;for(p&&p(d);l!==s&&n;){if(d.index+=o,d.nextCh=d.lineText.charAt(d.index),!d.nextCh){if(l+=o,d.lineText=e.getLine(l)||``,o>0)d.index=0;else{var h=d.lineText.length;d.index=h>0?h-1:0}d.nextCh=d.lineText.charAt(d.index)}m(d)&&(a.line=l,a.ch=d.index,n--)}return d.nextCh||d.curMoveThrough?new t(l,d.index):a}function ut(e,t,n,r,i){var a=t.line,o=t.ch,s=e.getLine(a),c=n?1:-1,l=r?p:f;if(i&&s==``){if(a+=c,s=e.getLine(a),!v(e,a))return null;o=n?0:s.length}for(;;){if(i&&s==``)return{from:0,to:0,line:a};for(var u=c>0?s.length:-1,d=u,m=u;o!=u;){for(var h=!1,g=0;g<l.length&&!h;++g)if(l[g](s.charAt(o))){for(d=o;o!=u&&l[g](s.charAt(o));)o+=c;if(m=o,h=d!=m,d==t.ch&&a==t.line&&m==d+c)continue;return{from:Math.min(d,m+1),to:Math.max(d,m),line:a}}h||(o+=c)}if(a+=c,!v(e,a))return null;s=e.getLine(a),o=c>0?0:s.length}}function dt(e,n,r,i,a,o){var s=F(n),c=[];(i&&!a||!i&&a)&&r++;for(var l=!(i&&a),u=0;u<r;u++){var d=ut(e,n,i,o,l);if(!d){var f=Ve(e,e.lastLine());c.push(i?{line:e.lastLine(),from:f,to:f}:{line:0,from:0,to:0});break}c.push(d),n=new t(d.line,i?d.to-1:d.from)}var p=c.length!=r,m=c[0],h=c.pop();return i&&!a?(!p&&(m.from!=s.ch||m.line!=s.line)&&(h=c.pop()),h&&new t(h.line,h.from)):i&&a?h&&new t(h.line,h.to-1):!i&&a?(!p&&(m.to!=s.ch||m.line!=s.line)&&(h=c.pop()),h&&new t(h.line,h.to)):h&&new t(h.line,h.from)}function ft(e,n,r,i,a){var o=new t(n.line+r.repeat-1,1/0),s=e.clipPos(o);return s.ch--,a||(i.lastHPos=1/0,i.lastHSPos=e.charCoords(s,`div`).left),o}function pt(e,n,r,i,a){if(i){for(var o=a||e.getCursor(),s=o.ch,c,l=0;l<n;l++){var u=e.getLine(o.line);if(c=gt(s,u,i,r),c==-1)return;s=c}if(c!=null)return new t(e.getCursor().line,c)}}function mt(e,n){var r=e.getCursor().line;return je(e,new t(r,n-1))}function ht(e,t,n,r){!T(n,m)&&!g.test(n)||(t.marks[n]&&t.marks[n].clear(),t.marks[n]=e.setBookmark(r))}function gt(e,t,n,r,i){return r?t.indexOf(n,e+1):t.lastIndexOf(n,e-1)}function _t(e,n,r,i,a){var o=n.line,s=e.firstLine(),c=e.lastLine(),l,u,d=o;function f(t){return!e.getLine(t)}function p(e,t,n){return n?f(e)!=f(e+t):!f(e)&&f(e+t)}if(i){for(;s<=d&&d<=c&&r>0;)p(d,i)&&r--,d+=i;return{start:new t(d,0),end:n}}var m=e.state.vim;if(m.visualLine&&p(o,1,!0)){var h=m.sel.anchor;p(h.line,-1,!0)&&(!a||h.line!=o)&&(o+=1)}var g=f(o);for(d=o;d<=c&&r;d++)p(d,1,!0)&&(!a||f(d)!=g)&&r--;for(u=new t(d,0),d>c&&!g?g=!0:a=!1,d=o;d>s&&!((!a||f(d)==g||d==o)&&p(d,-1,!0));d--);return l=new t(d,0),{start:l,end:u}}function vt(e,n,r,i,a){function o(e){e.line!==null&&(e.pos+e.dir<0||e.pos+e.dir>=e.line.length?e.line=null:e.pos+=e.dir)}function s(e,t,n,r){var i={line:e.getLine(t),ln:t,pos:n,dir:r};if(i.line===``)return{ln:i.ln,pos:i.pos};var s=i.pos;for(o(i);i.line!==null;){if(s=i.pos,w(i.line[i.pos]))if(a){for(o(i);i.line!==null&&C(i.line[i.pos]);)s=i.pos,o(i);return{ln:i.ln,pos:s+1}}else return{ln:i.ln,pos:i.pos+1};o(i)}return{ln:i.ln,pos:s+1}}function c(e,t,n,r){var i=e.getLine(t),s={line:i,ln:t,pos:n,dir:r};if(s.line===``)return{ln:s.ln,pos:s.pos};var c=s.pos;for(o(s);s.line!==null;){if(!C(s.line[s.pos])&&!w(s.line[s.pos]))c=s.pos;else if(w(s.line[s.pos]))return a&&C(s.line[s.pos+1])?{ln:s.ln,pos:s.pos+1}:{ln:s.ln,pos:c};o(s)}return s.line=i,a&&C(s.line[s.pos])?{ln:s.ln,pos:s.pos}:{ln:s.ln,pos:c}}for(var l={ln:n.line,pos:n.ch};r>0;)l=i<0?c(e,l.ln,l.pos,i):s(e,l.ln,l.pos,i),r--;return new t(l.ln,l.pos)}function yt(e,n,r,i){function a(e,t){if(t.line!==null)if(t.pos+t.dir<0||t.pos+t.dir>=t.line.length){if(t.ln+=t.dir,!v(e,t.ln)){t.line=null;return}t.line=e.getLine(t.ln),t.pos=t.dir>0?0:t.line.length-1}else t.pos+=t.dir}function o(e,t,n,r){var i=e.getLine(t),o=i===``,s={line:i,ln:t,pos:n,dir:r},c={ln:s.ln,pos:s.pos},l=s.line===``;for(a(e,s);s.line!==null;){if(c.ln=s.ln,c.pos=s.pos,s.line===``&&!l||o&&s.line!==``&&!C(s.line[s.pos]))return{ln:s.ln,pos:s.pos};w(s.line[s.pos])&&!o&&(s.pos===s.line.length-1||C(s.line[s.pos+1]))&&(o=!0),a(e,s)}var i=e.getLine(c.ln);c.pos=0;for(var u=i.length-1;u>=0;--u)if(!C(i[u])){c.pos=u;break}return c}function s(e,t,n,r){var i=e.getLine(t),o={line:i,ln:t,pos:n,dir:r},s=o.ln,c=null,l=o.line===``;for(a(e,o);o.line!==null;){if(o.line===``&&!l)return c===null?{ln:o.ln,pos:o.pos}:{ln:s,pos:c};if(w(o.line[o.pos])&&c!==null&&!(o.ln===s&&o.pos+1===c))return{ln:s,pos:c};o.line!==``&&!C(o.line[o.pos])&&(l=!1,s=o.ln,c=o.pos),a(e,o)}var i=e.getLine(s);c=0;for(var u=0;u<i.length;++u)if(!C(i[u])){c=u;break}return{ln:s,pos:c}}for(var c={ln:n.line,pos:n.ch};r>0;)c=i<0?s(e,c.ln,c.pos,i):o(e,c.ln,c.pos,i),r--;return new t(c.ln,c.pos)}function bt(e,n,r,i){var a=n,o={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[r],s={"(":`(`,")":`(`,"[":`[`,"]":`[`,"{":`{`,"}":`{`,"<":`<`,">":`<`}[r],c=e.getLine(a.line).charAt(a.ch)===s?1:0,l=e.scanForBracket(new t(a.line,a.ch+c),-1,void 0,{bracketRegex:o}),u=e.scanForBracket(new t(a.line,a.ch+c),1,void 0,{bracketRegex:o});if(!l||!u)return null;var d=l.pos,f=u.pos;if(d.line==f.line&&d.ch>f.ch||d.line>f.line){var p=d;d=f,f=p}return i?f.ch+=1:d.ch+=1,{start:d,end:f}}function xt(e,n,r,i){var a=F(n),o=e.getLine(a.line).split(``),s,c,l,u,d=o.indexOf(r);if(a.ch<d)a.ch=d;else if(d<a.ch&&o[a.ch]==r){var f=/string/.test(e.getTokenTypeAt(P(n,0,1))),p=/string/.test(e.getTokenTypeAt(n));f&&!p||(c=a.ch,--a.ch)}if(o[a.ch]==r&&!c)s=a.ch+1;else for(l=a.ch;l>-1&&!s;l--)o[l]==r&&(s=l+1);if(s&&!c)for(l=s,u=o.length;l<u&&!c;l++)o[l]==r&&(c=l);return!s||!c?{start:a,end:a}:(i&&(--s,++c),{start:new t(a.line,s),end:new t(a.line,c)})}D(`pcre`,!0,`boolean`);class St{constructor(){this.highlightTimeout}getQuery(){return j.query}setQuery(e){j.query=e}getOverlay(){return this.searchOverlay}setOverlay(e){this.searchOverlay=e}isReversed(){return j.isReversed}setReversed(e){j.isReversed=e}getScrollbarAnnotate(){return this.annotate}setScrollbarAnnotate(e){this.annotate=e}}function Ct(e){var t=e.state.vim;return t.searchState_||=new St}function wt(e){return R(e,`/`)}function Tt(e){return Et(e,`/`)}function R(e,t){var n=Et(e,t)||[];if(!n.length)return[];var r=[];if(n[0]===0){for(var i=0;i<n.length;i++)typeof n[i]==`number`&&r.push(e.substring(n[i]+1,n[i+1]));return r}}function Et(e,t){t||=`/`;for(var n=!1,r=[],i=0;i<e.length;i++){var a=e.charAt(i);!n&&a==t&&r.push(i),n=!n&&a==`\\`}return r}function Dt(e){var t={V:`|(){+?*.[$^`,M:`|(){+?*.[`,m:`|(){+?`,v:`<>`},n={">":`(?<=[\\w])(?=[^\\w]|$)`,"<":`(?<=[^\\w]|^)(?=[\\w])`},r=t.m,i=e.replace(/\\.|[\[|(){+*?.$^<>]/g,function(e){if(e[0]===`\\`){var i=e[1];return i===`}`||r.indexOf(i)!=-1?i:i in t?(r=t[i],``):i in n?n[i]:e}else return r.indexOf(e)==-1?e:n[e]||`\\`+e}),a=i.indexOf(`\\zs`);return a!=-1&&(i=`(?<=`+i.slice(0,a)+`)`+i.slice(a+3)),a=i.indexOf(`\\ze`),a!=-1&&(i=i.slice(0,a)+`(?=`+i.slice(a+3)+`)`),i}var z={"\\n":`
34
+ `,"\\r":`\r`,"\\t":` `};function Ot(e){for(var t=!1,n=[],r=-1;r<e.length;r++){var i=e.charAt(r)||``,a=e.charAt(r+1)||``;z[i+a]?(n.push(z[i+a]),r++):t?(n.push(i),t=!1):i===`\\`?(t=!0,x(a)||a===`$`?n.push(`$`):a!==`/`&&a!==`\\`&&n.push(`\\`)):(i===`$`&&n.push(`$`),n.push(i),a===`/`&&n.push(`\\`))}return n.join(``)}var kt={"\\/":`/`,"\\\\":`\\`,"\\n":`
35
+ `,"\\r":`\r`,"\\t":` `,"\\&":`&`};function At(t){for(var n=new e.StringStream(t),r=[];!n.eol();){for(;n.peek()&&n.peek()!=`\\`;)r.push(n.next());var i=!1;for(var a in kt)if(n.match(a,!0)){i=!0,r.push(kt[a]);break}i||r.push(n.next())}return r.join(``)}function jt(e,t,n){j.registerController.getRegister(`/`).setText(e);var r=Tt(e),i,a;return r.length?(i=e.substring(0,r[0]),a=e.substring(r[0]).indexOf(`i`)!=-1):i=e,i?(O(`pcre`)||(i=Dt(i)),n&&(t=/^[^A-Z]*$/.test(i)),new RegExp(i,t||a?`im`:`m`)):null}function Mt(e){typeof e==`string`&&(e=document.createElement(e));for(var t=1;t<arguments.length;t++){var n=arguments[t];if(n)if(typeof n!=`object`&&(n=document.createTextNode(n)),n.nodeType)e.appendChild(n);else for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(r[0]===`$`?e.style[r.slice(1)]=n[r]:typeof n[r]==`function`?e[r]=n[r]:e.setAttribute(r,n[r]))}return e}function B(e,t,n){var r=Mt(`div`,{$color:`red`,$whiteSpace:`pre`,class:`cm-vim-message`},t);e.openNotification?n?(r=Mt(`div`,{},r,Mt(`div`,{},`Press ENTER or type command to continue`)),e.state.closeVimNotification&&e.state.closeVimNotification(),e.state.closeVimNotification=e.openNotification(r,{bottom:!0,duration:0})):e.openNotification(r,{bottom:!0,duration:15e3}):alert(r.innerText)}function Nt(e,t){return Mt(`div`,{$display:`flex`,$flex:1},Mt(`span`,{$fontFamily:`monospace`,$whiteSpace:`pre`,$flex:1,$display:`flex`},e,Mt(`input`,{type:`text`,autocorrect:`off`,autocapitalize:`off`,spellcheck:`false`,$flex:1})),t&&Mt(`span`,{$color:`#888`},t))}function Pt(e,t){if(se.length){t.value||=``,M=t;return}var n=Nt(t.prefix,t.desc);if(e.openDialog)e.openDialog(n,t.onClose,{onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:t.value});else{var r=``;typeof t.prefix!=`string`&&t.prefix&&(r+=t.prefix.textContent),t.desc&&(r+=` `+t.desc),t.onClose?.(prompt(r,``))}}function Ft(e,t){return e instanceof RegExp&&t instanceof RegExp?e.flags==t.flags&&e.source==t.source:!1}function It(e,t,n,r){if(t){var i=Ct(e),a=jt(t,!!n,!!r);if(a)return zt(e,a),Ft(a,i.getQuery())||i.setQuery(a),a}}function Lt(e){if(e.source.charAt(0)==`^`)var t=!0;return{token:function(n){if(t&&!n.sol()){n.skipToEnd();return}var r=n.match(e,!1);if(r)return r[0].length==0?(n.next(),`searching`):!n.sol()&&(n.backUp(1),!e.exec(n.next()+r[0]))?(n.next(),null):(n.match(e),`searching`);for(;!n.eol()&&(n.next(),!n.match(e,!1)););},query:e}}var Rt=0;function zt(e,t){clearTimeout(Rt);var n=Ct(e);n.highlightTimeout=Rt,Rt=setTimeout(function(){if(e.state.vim){var n=Ct(e);n.highlightTimeout=void 0;var r=n.getOverlay();(!r||t!=r.query)&&(r&&e.removeOverlay(r),r=Lt(t),e.addOverlay(r),e.showMatchesOnScrollbar&&(n.getScrollbarAnnotate()&&n.getScrollbarAnnotate().clear(),n.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))),n.setOverlay(r))}},50)}function Bt(e,n,r,i){return e.operation(function(){i===void 0&&(i=1);for(var a=e.getCursor(),o=e.getSearchCursor(r,a),s=0;s<i;s++){var c=o.find(n);if(s==0&&c&&Le(o.from(),a)){var l=n?o.from():o.to();c=o.find(n),c&&!c[0]&&Le(o.from(),l)&&e.getLine(l.line).length==l.ch&&(c=o.find(n))}if(!c&&(o=e.getSearchCursor(r,n?new t(e.lastLine()):new t(e.firstLine(),0)),!o.find(n)))return}return o.from()})}function Vt(e,n,r,i,a){return e.operation(function(){i===void 0&&(i=1);var o=e.getCursor(),s=e.getSearchCursor(r,o),c=s.find(!n);!a.visualMode&&c&&Le(s.from(),o)&&s.find(!n);for(var l=0;l<i;l++)if(c=s.find(n),!c&&(s=e.getSearchCursor(r,n?new t(e.lastLine()):new t(e.firstLine(),0)),!s.find(n)))return;var u=s.from(),d=s.to();return u&&d&&[u,d]})}function Ht(e){var t=Ct(e);t.highlightTimeout&&=(clearTimeout(t.highlightTimeout),void 0),e.removeOverlay(Ct(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function Ut(e,t,n){return typeof e!=`number`&&(e=e.line),t instanceof Array?T(e,t):typeof n==`number`?e>=t&&e<=n:e==t}function Wt(e){var t=e.getScrollInfo(),n=6,r=10,i=e.coordsChar({left:0,top:n+t.top},`local`),a=t.clientHeight-r+t.top,o=e.coordsChar({left:0,top:a},`local`);return{top:i.line,bottom:o.line}}function Gt(e,n,r){if(r==`'`||r=="`")return j.jumpList.find(e,-1)||new t(0,0);if(r==`.`)return Kt(e);var i=n.marks[r];return i&&i.find()}function Kt(e){if(e.getLastEditEnd)return e.getLastEditEnd();for(var t=e.doc.history.done,n=t.length;n--;)if(t[n].changes)return F(t[n].changes[0].to)}class qt{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(e,t,n){var r=this;e.operation(function(){e.curOp&&(e.curOp.isVimOp=!0),r._processCommand(e,t,n)})}_processCommand(t,n,r){var i=t.state.vim,a=j.registerController.getRegister(`:`),o=a.toString(),s=new e.StringStream(n);a.setText(n);var c=r||{};c.input=n;try{this.parseInput_(t,s,c)}catch(e){throw B(t,e+``),e}i.visualMode&&$e(t);var l,u;if(!c.commandName)c.line!==void 0&&(u=`move`);else if(l=this.matchCommand_(c.commandName),l){if(u=l.name,l.excludeFromCommandHistory&&a.setText(o),this.parseCommandArgs_(s,c,l),l.type==`exToKey`){ue(t,l.toKeys||``,l);return}else if(l.type==`exToEx`){this.processCommand(t,l.toInput||``);return}}if(!u){B(t,`Not an editor command ":`+n+`"`);return}try{Jt[u](t,c),(!l||!l.possiblyAsync)&&c.callback&&c.callback()}catch(e){throw B(t,e+``),e}}parseInput_(e,t,n){t.eatWhile(`:`),t.eat(`%`)?(n.line=e.firstLine(),n.lineEnd=e.lastLine()):(n.line=this.parseLineSpec_(e,t),n.line!==void 0&&t.eat(`,`)&&(n.lineEnd=this.parseLineSpec_(e,t))),n.line==null?e.state.vim.visualMode?(n.selectionLine=Gt(e,e.state.vim,`<`)?.line,n.selectionLineEnd=Gt(e,e.state.vim,`>`)?.line):n.selectionLine=e.getCursor().line:(n.selectionLine=n.line,n.selectionLineEnd=n.lineEnd);var r=t.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return r?n.commandName=r[1]:n.commandName=(t.match(/.*/)||[``])[0],n}parseLineSpec_(e,t){var n=t.match(/^(\d+)/);if(n)return parseInt(n[1],10)-1;switch(t.next()){case`.`:return this.parseLineSpecOffset_(t,e.getCursor().line);case`$`:return this.parseLineSpecOffset_(t,e.lastLine());case`'`:var r=t.next()||``,i=Gt(e,e.state.vim,r);if(!i)throw Error(`Mark not set`);return this.parseLineSpecOffset_(t,i.line);case`-`:case`+`:return t.backUp(1),this.parseLineSpecOffset_(t,e.getCursor().line);default:t.backUp(1);return}}parseLineSpecOffset_(e,t){var n=e.match(/^([+-])?(\d+)/);if(n){var r=parseInt(n[2],10);n[1]==`-`?t-=r:t+=r}return t}parseCommandArgs_(e,t,n){if(!e.eol()){t.argString=e.match(/.*/)?.[0];var r=n.argDelimiter||/\s+/,i=He(t.argString||``).split(r);i.length&&i[0]&&(t.args=i)}}matchCommand_(e){for(var t=e.length;t>0;t--){var n=e.substring(0,t);if(this.commandMap_[n]){var r=this.commandMap_[n];if(r.name.indexOf(e)===0)return r}}}buildCommandMap_(){this.commandMap_={};for(var e=0;e<o.length;e++){var t=o[e],n=t.shortName||t.name;this.commandMap_[n]=t}}map(e,t,n,r){if(e!=`:`&&e.charAt(0)==`:`){if(n)throw Error(`Mode not supported for ex mappings`);var i=e.substring(1);t!=`:`&&t.charAt(0)==`:`?this.commandMap_[i]={name:i,type:`exToEx`,toInput:t.substring(1),user:!0}:this.commandMap_[i]={name:i,type:`exToKey`,toKeys:t,user:!0}}else{var a={keys:e,type:`keyToKey`,toKeys:t,noremap:!!r};n&&(a.context=n),Qt(a)}}unmap(e,t){if(e!=`:`&&e.charAt(0)==`:`){if(t)throw Error(`Mode not supported for ex mappings`);var n=e.substring(1);if(this.commandMap_[n]&&this.commandMap_[n].user)return delete this.commandMap_[n],!0}else for(var i=e,a=0;a<r.length;a++)if(i==r[a].keys&&r[a].context===t)return r.splice(a,1),V(i),!0}}var Jt={colorscheme:function(e,t){if(!t.args||t.args.length<1){B(e,e.getOption(`theme`));return}e.setOption(`theme`,t.args[0])},map:function(e,t,n,r){var i=t.args;if(!i||i.length<2){e&&B(e,`Invalid mapping: `+t.input);return}Yt.map(i[0],i[1],n,r)},imap:function(e,t){this.map(e,t,`insert`)},nmap:function(e,t){this.map(e,t,`normal`)},vmap:function(e,t){this.map(e,t,`visual`)},omap:function(e,t){this.map(e,t,`operatorPending`)},noremap:function(e,t){this.map(e,t,void 0,!0)},inoremap:function(e,t){this.map(e,t,`insert`,!0)},nnoremap:function(e,t){this.map(e,t,`normal`,!0)},vnoremap:function(e,t){this.map(e,t,`visual`,!0)},onoremap:function(e,t){this.map(e,t,`operatorPending`,!0)},unmap:function(e,t,n){var r=t.args;(!r||r.length<1||!Yt.unmap(r[0],n))&&e&&B(e,`No such mapping: `+t.input)},mapclear:function(e,t){oe.mapclear()},imapclear:function(e,t){oe.mapclear(`insert`)},nmapclear:function(e,t){oe.mapclear(`normal`)},vmapclear:function(e,t){oe.mapclear(`visual`)},omapclear:function(e,t){oe.mapclear(`operatorPending`)},move:function(e,t){Ce.processCommand(e,e.state.vim,{keys:``,type:`motion`,motion:`moveToLineOrEdgeOfDocument`,motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:t.line+1})},set:function(e,t){var n=t.args,r=t.setCfg||{};if(!n||n.length<1){e&&B(e,`Invalid mapping: `+t.input);return}var i=n[0].split(`=`),a=i.shift()||``,o=i.length>0?i.join(`=`):void 0,s=!1,c=!1;if(a.charAt(a.length-1)==`?`){if(o)throw Error(`Trailing characters: `+t.argString);a=a.substring(0,a.length-1),s=!0}else a.charAt(a.length-1)==`!`&&(a=a.substring(0,a.length-1),c=!0);o===void 0&&a.substring(0,2)==`no`&&(a=a.substring(2),o=!1);var l=E[a]&&E[a].type==`boolean`;if(l&&(c?o=!O(a,e,r):o??=!0),!l&&o===void 0||s){var u=O(a,e,r);u instanceof Error?B(e,u.message):u===!0||u===!1?B(e,` `+(u?``:`no`)+a):B(e,` `+a+`=`+u)}else{var d=ee(a,o,e,r);d instanceof Error&&B(e,d.message)}},setlocal:function(e,t){t.setCfg={scope:`local`},this.set(e,t)},setglobal:function(e,t){t.setCfg={scope:`global`},this.set(e,t)},registers:function(e,t){var n=t.args,r=j.registerController.registers,i=`----------Registers----------
36
+
37
+ `;if(n)for(var a=n.join(``),o=0;o<a.length;o++){var s=a.charAt(o);if(j.registerController.isValidRegister(s)){var c=r[s]||new ye;i+=`"`+s+` `+c.toString()+`
38
+ `}}else for(var s in r){var l=r[s].toString();l.length&&(i+=`"`+s+` `+l+`
39
+ `)}B(e,i,!0)},marks:function(e,t){var n=t.args,r=e.state.vim.marks,i=`-----------Marks-----------
40
+ mark line col
41
+
42
+ `;if(n)for(var a=n.join(``),o=0;o<a.length;o++){var s=a.charAt(o),c=r[s]&&r[s].find();c&&(i+=s+` `+c.line+` `+c.ch+`
43
+ `)}else for(var s in r){var c=r[s]&&r[s].find();c&&(i+=s+` `+c.line+` `+c.ch+`
44
+ `)}B(e,i,!0)},sort:function(n,r){var i,a,o,s,c;function l(){if(r.argString){var t=new e.StringStream(r.argString);if(t.eat(`!`)&&(i=!0),t.eol())return;if(!t.eatSpace())return`Invalid arguments`;var n=t.match(/([dinuox]+)?\s*(\/.+\/)?\s*/);if(!n||!t.eol())return`Invalid arguments`;if(n[1]){a=n[1].indexOf(`i`)!=-1,o=n[1].indexOf(`u`)!=-1;var l=n[1].indexOf(`d`)!=-1||n[1].indexOf(`n`)!=-1,u=n[1].indexOf(`x`)!=-1,d=n[1].indexOf(`o`)!=-1;if(Number(l)+Number(u)+Number(d)>1)return`Invalid arguments`;s=l&&`decimal`||u&&`hex`||d&&`octal`}n[2]&&(c=new RegExp(n[2].substr(1,n[2].length-2),a?`i`:``))}}var u=l();if(u){B(n,u+`: `+r.argString);return}var d=r.line||n.firstLine(),f=r.lineEnd||r.line||n.lastLine();if(d==f)return;var p=new t(d,0),m=new t(f,Ve(n,f)),h=n.getRange(p,m).split(`
45
+ `),g=s==`decimal`?/(-?)([\d]+)/:s==`hex`?/(-?)(?:0x)?([0-9a-f]+)/i:s==`octal`?/([0-7]+)/:null,_=s==`decimal`?10:s==`hex`?16:s==`octal`?8:void 0,v=[],y=[];if(s||c)for(var b=0;b<h.length;b++){var x=c?h[b].match(c):null;x&&x[0]!=``?v.push(x):g&&g.exec(h[b])?v.push(h[b]):y.push(h[b])}else y=h;function S(e,t){if(i){var n=e;e=t,t=n}a&&(e=e.toLowerCase(),t=t.toLowerCase());var r=g&&g.exec(e),o=g&&g.exec(t);return!r||!o?e<t?-1:1:parseInt((r[1]+r[2]).toLowerCase(),_)-parseInt((o[1]+o[2]).toLowerCase(),_)}function C(e,t){if(i){var n=e;e=t,t=n}return a&&(e[0]=e[0].toLowerCase(),t[0]=t[0].toLowerCase()),e[0]<t[0]?-1:1}if(v.sort(c?C:S),c)for(var b=0;b<v.length;b++)v[b]=v[b].input;else s||y.sort(S);if(h=i?v.concat(y):y.concat(v),o){var w=h,T;h=[];for(var b=0;b<w.length;b++)w[b]!=T&&h.push(w[b]),T=w[b]}n.replaceRange(h.join(`
46
+ `),p,m)},vglobal:function(e,t){this.global(e,t)},normal:function(e,t){var n=!1,r=t.argString;if(r&&r[0]==`!`&&(r=r.slice(1),n=!0),r=r.trimStart(),!r){B(e,`Argument is required.`);return}var i=t.line;if(typeof i==`number`)for(var a=isNaN(t.lineEnd)?i:t.lineEnd,o=i;o<=a;o++)e.setCursor(o,0),ue(e,t.argString.trimStart(),{noremap:n}),e.state.vim.insertMode&&Zt(e,!0);else ue(e,t.argString.trimStart(),{noremap:n}),e.state.vim.insertMode&&Zt(e,!0)},global:function(e,t){var n=t.argString;if(!n){B(e,`Regular Expression missing from global`);return}var r=t.commandName[0]===`v`;n[0]===`!`&&t.commandName[0]===`g`&&(r=!0,n=n.slice(1));var i=t.line===void 0?e.firstLine():t.line,a=t.lineEnd||t.line||e.lastLine(),o=wt(n),s=n,c=``;if(o&&o.length&&(s=o[0],c=o.slice(1,o.length).join(`/`)),s)try{It(e,s,!0,!0)}catch{B(e,`Invalid regex: `+s);return}for(var l=Ct(e).getQuery(),u=[],d=i;d<=a;d++){var f=e.getLine(d);l.test(f)!==r&&u.push(c?e.getLineHandle(d):f)}if(!c){B(e,u.join(`
47
+ `));return}var p=0,m=function(){if(p<u.length){var t=u[p++],n=e.getLineNumber(t);if(n==null){m();return}var r=n+1+c;Yt.processCommand(e,r,{callback:m})}else e.releaseLineHandles&&e.releaseLineHandles()};m()},substitute:function(e,n){if(!e.getSearchCursor)throw Error(`Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.`);var r=n.argString,i=r?R(r,r[0]):[],a=``,o=``,s,c,l,u=!1,d=!1;if(i&&i.length)a=i[0],O(`pcre`)&&a!==``&&(a=new RegExp(a).source),o=i[1],o!==void 0&&(o=O(`pcre`)?At(o.replace(/([^\\])&/g,`$1$$&`)):Ot(o),j.lastSubstituteReplacePart=o),s=i[2]?i[2].split(` `):[];else if(r&&r.length){B(e,`Substitutions should be of the form :s/pattern/replace/`);return}if(s&&(c=s[0],l=parseInt(s[1]),c&&(c.indexOf(`c`)!=-1&&(u=!0),c.indexOf(`g`)!=-1&&(d=!0),a=O(`pcre`)?a+`/`+c:a.replace(/\//g,`\\/`)+`/`+c)),a)try{It(e,a,!0,!0)}catch{B(e,`Invalid regex: `+a);return}if(o||=j.lastSubstituteReplacePart,o===void 0){B(e,`No previous substitute regular expression`);return}var f=Ct(e).getQuery(),p=n.line===void 0?e.getCursor().line:n.line,m=n.lineEnd||p;p==e.firstLine()&&m==e.lastLine()&&(m=1/0),l&&(p=m,m=p+l-1);var h=je(e,new t(p,0)),g=e.getSearchCursor(f,h);Xt(e,u,d,p,m,g,f,o,n.callback)},startinsert:function(e,t){ue(e,t.argString==`!`?`A`:`i`,{})},redo:e.commands.redo,undo:e.commands.undo,write:function(t){e.commands.save?e.commands.save(t):t.save&&t.save()},nohlsearch:function(e){Ht(e)},yank:function(e){var t=F(e.getCursor()).line,n=e.getLine(t);j.registerController.pushText(`0`,`yank`,n,!0,!0)},delete:function(e,n){var r=n.selectionLine,i=isNaN(n.selectionLineEnd)?r:n.selectionLineEnd;De.delete(e,{linewise:!0},[{anchor:new t(r,0),head:new t(i+1,0)}])},join:function(e,n){var r=n.selectionLine,i=isNaN(n.selectionLineEnd)?r:n.selectionLineEnd;e.setCursor(new t(r,0)),ke.joinLines(e,{repeat:i-r},e.state.vim)},delmarks:function(t,n){if(!n.argString||!He(n.argString)){B(t,`Argument required`);return}for(var r=t.state.vim,i=new e.StringStream(He(n.argString));!i.eol();){i.eatSpace();var a=i.pos;if(!i.match(/[a-zA-Z]/,!1)){B(t,`Invalid argument: `+n.argString.substring(a));return}var o=i.next();if(i.match(`-`,!0)){if(!i.match(/[a-zA-Z]/,!1)){B(t,`Invalid argument: `+n.argString.substring(a));return}var s=o,c=i.next();if(s&&c&&y(s)==y(c)){var l=s.charCodeAt(0),u=c.charCodeAt(0);if(l>=u){B(t,`Invalid argument: `+n.argString.substring(a));return}for(var d=0;d<=u-l;d++){var f=String.fromCharCode(l+d);delete r.marks[f]}}else{B(t,`Invalid argument: `+s+`-`);return}}else o&&delete r.marks[o]}}},Yt=new qt;oe.defineEx(`version`,`ve`,e=>{B(e,`Codemirror-vim version: 6.3.0`)});function Xt(t,n,r,i,a,o,s,c,l){t.state.vim.exMode=!0;var u=!1,d=0,f,p,m;function h(){t.operation(function(){for(;!u;)g(),v();y()})}function g(){var e=``,n=o.match||o.pos&&o.pos.match;e=n?c.replace(/\$(\d{1,3}|[$&])/g,function(e,t){if(t==`$`)return`$`;if(t==`&`)return n[0];for(var r=t;parseInt(r)>=n.length&&r.length>0;)r=r.slice(0,r.length-1);return r?n[r]+t.slice(r.length,t.length):e}):t.getRange(o.from(),o.to()).replace(s,c);var r=o.to().line;o.replace(e),p=o.to().line,a+=p-r,m=p<r}function _(){var e=f&&F(o.to()),t=o.findNext();return t&&!t[0]&&e&&Le(o.from(),e)&&(t=o.findNext()),t&&d++,t}function v(){for(;_()&&Ut(o.from(),i,a);)if(!(!r&&o.from().line==p&&!m)){t.scrollIntoView(o.from(),30),t.setSelection(o.from(),o.to()),f=o.from(),u=!1;return}u=!0}function y(e){if(e&&e(),t.focus(),f){t.setCursor(f);var n=t.state.vim;n.exMode=!1,n.lastHPos=n.lastHSPos=f.ch}l?l():u&&B(t,(d?`Found `+d+` matches`:`No matches found`)+` for pattern: `+s+(O(`pcre`)?` (set nopcre to use Vim regexps)`:``))}function b(n,r,i){switch(e.e_stop(n),pe(n)){case`y`:g(),v();break;case`n`:v();break;case`a`:var a=l;l=void 0,t.operation(h),l=a;break;case`l`:g();case`q`:case`<Esc>`:case`<C-c>`:case`<C-[>`:y(i);break}return u&&y(i),!0}if(v(),u){B(t,`No matches for `+s+(O(`pcre`)?` (set nopcre to use vim regexps)`:``));return}if(!n){h(),l&&l();return}Pt(t,{prefix:Mt(`span`,`replace with `,Mt(`strong`,c),` (y/n/a/q/l)`),onKeyDown:b})}function Zt(t,n){var r=t.state.vim,i=j.macroModeState,a=j.registerController.getRegister(`.`),o=i.isPlaying,s=i.lastInsertModeChanges;o||(t.off(`change`,on),r.insertEnd&&r.insertEnd.clear(),r.insertEnd=void 0,e.off(t.getInputField(),`keydown`,ln)),!o&&r.insertModeRepeat&&r.insertModeRepeat>1&&(un(t,r,r.insertModeRepeat-1,!0),r.lastEditInputState.repeatOverride=r.insertModeRepeat),delete r.insertModeRepeat,r.insertMode=!1,n||t.setCursor(t.getCursor().line,t.getCursor().ch-1),t.setOption(`keyMap`,`vim`),t.setOption(`disableInput`,!0),t.toggleOverwrite(!1),a.setText(s.changes.join(``)),e.signal(t,`vim-mode-change`,{mode:`normal`}),i.isRecording&&rn(i)}function Qt(e){r.unshift(e),e.keys&&$t(e.keys)}function $t(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(e){e&&(i[e]||(i[e]=0),i[e]++)})}function V(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(e){i[e]&&i[e]--})}function en(e,t,n,r,i){var a={keys:e,type:t};for(var o in a[t]=n,a[t+`Args`]=r,i)a[o]=i[o];Qt(a)}D(`insertModeEscKeysTimeout`,200,`number`);function tn(e,t,n,r){var i=j.registerController.getRegister(r);if(r==`:`){i.keyBuffer[0]&&Yt.processCommand(e,i.keyBuffer[0]),n.isPlaying=!1;return}var a=i.keyBuffer,o=0;n.isPlaying=!0,n.replaySearchQueries=i.searchQueries.slice(0);for(var s=0;s<a.length;s++)for(var c=a[s],l,u,d=/<(?:[CSMA]-)*\w+>|./gi;l=d.exec(c);)if(u=l[0],oe.handleKey(e,u,`macro`),t.insertMode){var f=i.insertModeChanges[o++].changes;j.macroModeState.lastInsertModeChanges.changes=f,fn(e,f,1),Zt(e)}n.isPlaying=!1}function nn(e,t){if(!e.isPlaying){var n=e.latestRegister,r=j.registerController.getRegister(n);r&&r.pushText(t)}}function rn(e){if(!e.isPlaying){var t=e.latestRegister,n=j.registerController.getRegister(t);n&&n.pushInsertModeChanges&&n.pushInsertModeChanges(e.lastInsertModeChanges)}}function an(e,t){if(!e.isPlaying){var n=e.latestRegister,r=j.registerController.getRegister(n);r&&r.pushSearchQuery&&r.pushSearchQuery(t)}}function on(e,t){var n=j.macroModeState,r=n.lastInsertModeChanges;if(!n.isPlaying)for(var i=e.state.vim;t;){if(r.expectCursorActivityForChange=!0,r.ignoreCount>1)r.ignoreCount--;else if(t.origin==`+input`||t.origin==`paste`||t.origin===void 0){var a=e.listSelections().length;a>1&&(r.ignoreCount=a);var o=t.text.join(`
48
+ `);if(r.maybeReset&&=(r.changes=[],!1),o)if(e.state.overwrite&&!/\n/.test(o))r.changes.push([o]);else{if(o.length>1){var s=i&&i.insertEnd&&i.insertEnd.find(),c=e.getCursor();if(s&&s.line==c.line){var l=s.ch-c.ch;l>0&&l<o.length&&(r.changes.push([o,l]),o=``)}}o&&r.changes.push(o)}}t=t.next}}function sn(e){var t=e.state.vim;if(t.insertMode){var n=j.macroModeState;if(n.isPlaying)return;var r=n.lastInsertModeChanges;r.expectCursorActivityForChange?r.expectCursorActivityForChange=!1:(r.maybeReset=!0,t.insertEnd&&t.insertEnd.clear(),t.insertEnd=e.setBookmark(e.getCursor(),{insertLeft:!0}))}else e.curOp?.isVimOp||cn(e,t)}function cn(t,n){var r=t.getCursor(`anchor`),i=t.getCursor(`head`);if(n.visualMode&&!t.somethingSelected()?$e(t,!1):!n.visualMode&&!n.insertMode&&t.somethingSelected()&&(n.visualMode=!0,n.visualLine=!1,e.signal(t,`vim-mode-change`,{mode:`visual`})),n.visualMode){var a=I(i,r)?0:-1,o=I(i,r)?-1:0;i=P(i,0,a),r=P(r,0,o),n.sel={anchor:r,head:i},ht(t,n,`<`,Re(i,r)),ht(t,n,`>`,ze(i,r))}else n.insertMode||(n.lastHPos=t.getCursor().ch)}function ln(t){var n=j.macroModeState.lastInsertModeChanges,r=e.keyName?e.keyName(t):t.key;r&&(r.indexOf(`Delete`)!=-1||r.indexOf(`Backspace`)!=-1)&&(n.maybeReset&&=(n.changes=[],!1),n.changes.push(new ie(r,t)))}function un(e,t,n,r){var i=j.macroModeState;i.isPlaying=!0;var a=t.lastEditActionCommand,o=t.inputState;function s(){a?Ce.processAction(e,t,a):Ce.evalInput(e,t)}function c(n){if(i.lastInsertModeChanges.changes.length>0){n=t.lastEditActionCommand?n:1;var r=i.lastInsertModeChanges;fn(e,r.changes,n)}}if(t.inputState=t.lastEditInputState,a&&a.interlaceInsertRepeat)for(var l=0;l<n;l++)s(),c(1);else r||s(),c(n);t.inputState=o,t.insertMode&&!r&&Zt(e),i.isPlaying=!1}function dn(t,n){e.lookupKey(n,`vim-insert`,function(n){return typeof n==`string`?e.commands[n](t):n(t),!0})}function fn(e,t,n){var r=e.getCursor(`head`),i=j.macroModeState.lastInsertModeChanges.visualBlock;i&&(Ke(e,r,i+1),n=e.listSelections().length,e.setCursor(r));for(var a=0;a<n;a++){i&&e.setCursor(P(r,a,0));for(var o=0;o<t.length;o++){var s=t[o];if(s instanceof ie)dn(e,s.keyName);else if(typeof s==`string`)e.replaceSelection(s);else{var c=e.getCursor(),l=P(c,0,s[0].length-(s[1]||0));e.replaceRange(s[0],c,s[1]?c:l),e.setCursor(l)}}}i&&e.setCursor(P(r,0,1))}function pn(e){var t=new e.constructor;return Object.keys(e).forEach(function(n){if(n!=`insertEnd`){var r=e[n];Array.isArray(r)?r=r.slice():r&&typeof r==`object`&&r.constructor!=Object&&(r=pn(r)),t[n]=r}}),e.sel&&(t.sel={head:e.sel.head&&F(e.sel.head),anchor:e.sel.anchor&&F(e.sel.anchor)}),t}function mn(e,t,n){var r=A(e),i=e,a=!1,r=oe.maybeInitVimState_(i),o=r.visualBlock||r.wasInVisualBlock;if(i.state.closeVimNotification){var s=i.state.closeVimNotification;if(i.state.closeVimNotification=null,s(),t==`<CR>`)return _e(i),!0}var c=i.isInMultiSelectMode();if(r.wasInVisualBlock&&!c?r.wasInVisualBlock=!1:c&&r.visualBlock&&(r.wasInVisualBlock=!0),t==`<Esc>`&&!r.insertMode&&!r.visualMode&&c&&r.status==`<Esc>`)_e(i);else if(o||!c||i.inVirtualSelectionMode)a=oe.handleKey(i,t,n);else{var l=pn(r),u=r.inputState.changeQueueList||[];i.operation(function(){i.curOp&&(i.curOp.isVimOp=!0);var e=0;i.forEachSelection(function(){i.state.vim.inputState.changeQueue=u[e];var r=i.getCursor(`head`),o=i.getCursor(`anchor`),s=I(r,o)?0:-1,c=I(r,o)?-1:0;r=P(r,0,s),o=P(o,0,c),i.state.vim.sel.head=r,i.state.vim.sel.anchor=o,a=oe.handleKey(i,t,n),i.virtualSelection&&(u[e]=i.state.vim.inputState.changeQueue,i.state.vim=pn(l)),e++}),i.curOp?.cursorActivity&&!a&&(i.curOp.cursorActivity=!1),i.state.vim=r,r.inputState.changeQueueList=u,r.inputState.changeQueue=null},!0)}return a&&!r.visualMode&&!r.insertMode&&r.visualMode!=i.somethingSelected()&&cn(i,r),a}return re(),oe}function Tm(e,t){var n=t.ch,r=t.line+1;r<1&&(r=1,n=0),r>e.lines&&(r=e.lines,n=Number.MAX_VALUE);var i=e.line(r);return Math.min(i.from+Math.max(0,n),i.to)}function Em(e,t){let n=e.lineAt(t);return{line:n.number-1,ch:t-n.from}}var Dm=class{constructor(e,t){this.line=e,this.ch=t}};function Om(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else{var r=e._handlers||={};r[t]=(r[t]||[]).concat(n)}}function km(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else{var r=e._handlers,i=r&&r[t];if(i){var a=i.indexOf(n);a>-1&&(r[t]=i.slice(0,a).concat(i.slice(a+1)))}}}function Am(e,t,...n){var r=e._handlers?.[t];if(r)for(var i=0;i<r.length;++i)r[i](...n)}function jm(e,...t){if(e)for(var n=0;n<e.length;++n)e[n](...t)}var Mm;try{Mm=RegExp(`[\\w\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{Mm=/[\w]/}function Nm(e,t){var n=e.cm6;if(!n.state.readOnly){var r=`input.type.compose`;if(e.curOp&&(e.curOp.lastChange||(r=`input.type.compose.start`)),t.annotations)try{t.annotations.some(function(e){e.value==`input`&&(e.value=r)})}catch(e){console.error(e)}else t.userEvent=r;return n.dispatch(t)}}function Pm(e,t){e.curOp&&(e.curOp.$changeStart=void 0),(t?ad:od)(e.cm6);let n=e.curOp?.$changeStart;n!=null&&e.cm6.dispatch({selection:{anchor:n}})}var Fm={Left:e=>$s(e.cm6,{key:`Left`},`editor`),Right:e=>$s(e.cm6,{key:`Right`},`editor`),Up:e=>$s(e.cm6,{key:`Up`},`editor`),Down:e=>$s(e.cm6,{key:`Down`},`editor`),Backspace:e=>$s(e.cm6,{key:`Backspace`},`editor`),Delete:e=>$s(e.cm6,{key:`Delete`},`editor`)},Q=class e{openDialog(e,t,n){return Vm(this,e,t,n)}openNotification(e,t){return Rm(this,e,t)}constructor(e){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=e,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(e,t){Om(this,e,t)}off(e,t){km(this,e,t)}signal(e,t,n){Am(this,e,t,n)}indexFromPos(e){return Tm(this.cm6.state.doc,e)}posFromIndex(e){return Em(this.cm6.state.doc,e)}foldCode(e){let t=this.cm6,n=t.state.selection.ranges,r=this.cm6.state.doc,i=Tm(r,e),a=R.create([R.range(i,i)],0).ranges;t.state.selection.ranges=a,hu(t),t.state.selection.ranges=n}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(e,t){typeof e==`object`&&(t=e.ch,e=e.line);var n=Tm(this.cm6.state.doc,{line:e,ch:t||0});this.cm6.dispatch({selection:{anchor:n}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(e){var t=this.cm6.state.selection.main,n=e==`head`||!e?t.head:e==`anchor`?t.anchor:e==`start`?t.from:e==`end`?t.to:null;if(n==null)throw Error(`Invalid cursor type`);return this.posFromIndex(n)}listSelections(){var e=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(t=>({anchor:Em(e,t.anchor),head:Em(e,t.head)}))}setSelections(e,t){var n=this.cm6.state.doc,r=e.map(e=>{var t=Tm(n,e.head),r=Tm(n,e.anchor);return t==r?R.cursor(t,1):R.range(r,t)});this.cm6.dispatch({selection:R.create(r,t)})}setSelection(e,t,n){this.setSelections([{anchor:e,head:t}],0),n&&n.origin==`*mouse`&&this.onBeforeEndOperation()}getLine(e){var t=this.cm6.state.doc;return e<0||e>=t.lines?``:this.cm6.state.doc.line(e+1).text}getLineHandle(e){return this.$lineHandleChanges||=[],{row:e,index:this.indexFromPos(new Dm(e,0))}}getLineNumber(e){var t=this.$lineHandleChanges;if(!t)return null;for(var n=e.index,r=0;r<t.length;r++)if(n=t[r].changes.mapPos(n,1,gt.TrackAfter),n==null)return null;var i=this.posFromIndex(n);return i.ch==0?i.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(e,t){var n=this.cm6.state.doc;return this.cm6.state.sliceDoc(Tm(n,e),Tm(n,t))}replaceRange(e,t,n,r){n||=t;var i=this.cm6.state.doc,a=Tm(i,t),o=Tm(i,n);Nm(this,{changes:{from:a,to:o,insert:e}})}replaceSelection(e){Nm(this,this.cm6.state.replaceSelection(e))}replaceSelections(e){var t=this.cm6.state.selection.ranges.map((t,n)=>({from:t.from,to:t.to,insert:e[n]||``}));Nm(this,{changes:t})}getSelection(){return this.getSelections().join(`
49
+ `)}getSelections(){var e=this.cm6;return e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(e=>!e.empty)}getInputField(){return this.cm6.contentDOM}clipPos(e){var t=this.cm6.state.doc,n=e.ch,r=e.line+1;r<1&&(r=1,n=0),r>t.lines&&(r=t.lines,n=Number.MAX_VALUE);var i=t.line(r);return n=Math.min(Math.max(0,n),i.to-i.from),new Dm(r-1,n)}getValue(){return this.cm6.state.doc.toString()}setValue(e){var t=this.cm6;return t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e},selection:R.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(e,t){var n=this.cm6.state,r=Tm(n.doc,e),i=Iu(n,r+1,-1);return i&&i.end||(i=Iu(n,r,1),i&&i.end)?{to:Em(n.doc,i.end.from)}:{to:void 0}}scanForBracket(e,t,n,r){return Wm(this,e,t,n,r)}indentLine(e,t){t?this.indentMore():this.indentLess()}indentMore(){zd(this.cm6)}indentLess(){Bd(this.cm6)}execCommand(t){if(t==`indentAuto`)e.commands.indentAuto(this);else if(t==`goLineLeft`)Nd(this.cm6);else if(t==`goLineRight`){Md(this.cm6);let e=this.cm6.state,t=e.selection.main.head;t<e.doc.length&&e.sliceDoc(t,t+1)!==`
50
+ `&&Ad(this.cm6)}else console.log(t+` is not implemented`)}setBookmark(e,t){var n=t?.insertLeft?1:-1,r=this.indexFromPos(e);return new Jm(this,r,n)}addOverlay({query:e}){let t=new dm({regexp:!0,search:e.source,caseSensitive:!/i/.test(e.flags)});if(t.valid){t.forVim=!0,this.cm6Query=t;let e=Cm.of(t);return this.cm6.dispatch({effects:e}),t}}removeOverlay(e){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let t=Cm.of(this.cm6Query);this.cm6.dispatch({effects:t})}getSearchCursor(e,t){var n=this,r=null,i=null,a=!1;t.ch??=Number.MAX_VALUE;var o=Tm(n.cm6.state.doc,t),s=e.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(e,t){return t||`\\`+e});function c(t,n=0,r=t.length){return new am(t,s,{ignoreCase:e.ignoreCase},n,r)}function l(e){var t=n.cm6.state.doc;if(e>t.length)return null;let r=c(t,e).next();return r.done?null:r.value}var u=1e4;function d(e,t){var r=n.cm6.state.doc;for(let n=1;;n++){let i=Math.max(e,t-n*u),a=c(r,i,t),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==e||o.from>i+10))return o;if(i==e)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){var t=n.cm6.state.doc;return r=e?d(0,r?a?r.to-1:r.from:o):l(r?a?r.to+1:r.to:o),i=r&&{from:Em(t,r.from),to:Em(t,r.to),match:r.match},a=r?r.from==r.to:!1,r&&r.match},from:function(){return i?.from},to:function(){return i?.to},replace:function(e){r&&(Nm(n,{changes:{from:r.from,to:r.to,insert:e}}),r.to=r.from+e.length,i&&(i.to=Em(n.cm6.state.doc,r.to)))},get match(){return i&&i.match}}}findPosV(e,t,n,r){let{cm6:i}=this,a=i.state.doc,o=n==`page`?i.dom.clientHeight:0,s=Tm(a,e),c=R.cursor(s,1,void 0,r),l=Math.round(Math.abs(t));for(let e=0;e<l;e++)n==`page`?c=i.moveVertically(c,t>0,o):n==`line`&&(c=i.moveVertically(c,t>0));let u=Em(a,c.head);return(t<0&&c.head==0&&r!=0&&e.line==0&&e.ch!=0||t>0&&c.head==a.length&&u.ch!=r&&e.line==u.line)&&(u.hitSide=!0),u}charCoords(e,t){var n=this.cm6.contentDOM.getBoundingClientRect(),r=Tm(this.cm6.state.doc,e),i=this.cm6.coordsAtPos(r),a=-n.top;return{left:(i?.left||0)-n.left,top:(i?.top||0)+a,bottom:(i?.bottom||0)+a}}coordsChar(e,t){var n=this.cm6.contentDOM.getBoundingClientRect(),r=this.cm6.posAtCoords({x:e.left+n.left,y:e.top+n.top})||0;return Em(this.cm6.state.doc,r)}getScrollInfo(){var e=this.cm6.scrollDOM;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight,width:e.scrollWidth,clientHeight:e.clientHeight,clientWidth:e.clientWidth}}scrollTo(e,t){e!=null&&(this.cm6.scrollDOM.scrollLeft=e),t!=null&&(this.cm6.scrollDOM.scrollTop=t)}scrollIntoView(e,t){if(e){var n=this.indexFromPos(e);this.cm6.dispatch({effects:J.scrollIntoView(n)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:`scroll`})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption(`mode`)}}setSize(e,t){this.cm6.dom.style.width=e+4+`px`,this.cm6.dom.style.height=t+`px`,this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(e){this.$lineHandleChanges&&this.$lineHandleChanges.push(e);for(let t in this.marks)this.marks[t].update(e.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(t=>t.map(e.changes)));var t=this.curOp=this.curOp||{};e.changes.iterChanges((e,n,r,i,a)=>{(t.$changeStart==null||t.$changeStart>r)&&(t.$changeStart=r),this.$lastChangeEndOffset=i;var o={text:a.toJSON()};t.lastChange?t.lastChange.next=t.lastChange=o:t.lastChange=t.change=o},!0),t.changeHandlers||=this._handlers.change&&this._handlers.change.slice()}onSelectionChange(){var e=this.curOp=this.curOp||{};e.cursorActivityHandlers||=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice(),this.curOp.cursorActivity=!0}operation(e,t){this.curOp||={$d:0},this.curOp.$d++;try{var n=e()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return n}onBeforeEndOperation(){var e=this.curOp,t=!1;e&&(e.change&&jm(e.changeHandlers,this,e.change),e&&e.cursorActivity&&(jm(e.cursorActivityHandlers,this,null),e.isVimOp&&(t=!0)),this.curOp=null),t&&this.scrollIntoView()}moveH(e,t){if(t==`char`){var n=this.getCursor();this.setCursor(n.line,n.ch+e)}}setOption(e,t){switch(e){case`keyMap`:this.state.keyMap=t;break;case`textwidth`:this.state.textwidth=t;break}}getOption(e){switch(e){case`firstLineNumber`:return 1;case`tabSize`:return this.cm6.state.tabSize||4;case`readOnly`:return this.cm6.state.readOnly;case`indentWithTabs`:return this.cm6.state.facet(zl)==` `;case`indentUnit`:return this.cm6.state.facet(zl).length||2;case`textwidth`:return this.state.textwidth;case`keyMap`:return this.state.keyMap||`vim`}}toggleOverwrite(e){this.state.overwrite=e}getTokenTypeAt(e){var t=this.indexFromPos(e),n=(Dl(this.cm6.state,t)?.resolve(t))?.type?.name||``;return/comment/i.test(n)?`comment`:/string/i.test(n)?`string`:``}overWriteSelection(e){var t=this.cm6.state.doc,n=this.cm6.state.selection,r=n.ranges.map(e=>{if(e.empty){var n=e.to<t.length?t.sliceString(e.from,e.to+1):``;if(n&&!/\n/.test(n))return R.range(e.from,e.to+1)}return e});this.cm6.dispatch({selection:R.create(r,n.mainIndex)}),this.replaceSelection(e)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(e){var t=this.cm6.state.selection;this.virtualSelection=R.create(t.ranges,t.mainIndex);for(var n=0;n<this.virtualSelection.ranges.length;n++){var r=this.virtualSelection.ranges[n];r&&(this.cm6.dispatch({selection:R.create([r])}),e(),this.virtualSelection.ranges[n]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(e){return Ym(this,e)}};Q.isMac=typeof navigator<`u`&&/Mac/.test(navigator.platform),Q.Pos=Dm,Q.StringStream=Bu,Q.commands={cursorCharLeft:function(e){kd(e.cm6)},redo:function(e){Pm(e,!1)},undo:function(e){Pm(e,!0)},newlineAndIndent:function(e){Fd({state:e.cm6.state,dispatch:t=>Nm(e,t)})},indentAuto:function(e){Rd(e.cm6)},newlineAndIndentContinueComment:void 0,save:void 0},Q.isWordChar=function(e){return Mm.test(e)},Q.keys=Fm,Q.addClass=function(e,t){},Q.rmClass=function(e,t){},Q.e_preventDefault=function(e){e.preventDefault()},Q.e_stop=function(e){var t,n;(t=e?.stopPropagation)==null||t.call(e),(n=e?.preventDefault)==null||n.call(e)},Q.lookupKey=function(e,t,n){var r=Q.keys[e];!r&&/^Arrow/.test(e)&&(r=Q.keys[e.slice(5)]),r&&n(r)},Q.on=Om,Q.off=km,Q.signal=Am,Q.findMatchingTag=Gm,Q.findEnclosingTag=Km,Q.keyName=void 0;function Im(e,t,n){var r=document.createElement(`div`);return r.appendChild(t),r}function Lm(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}function Rm(e,t,n){Lm(e,s);var r=Im(e,t,n&&n.bottom),i=!1,a,o=n&&n.duration!==void 0?n.duration:5e3;function s(){i||(i=!0,clearTimeout(a),r.remove(),Bm(e,r))}return r.onclick=function(e){e.preventDefault(),s()},zm(e,r),o&&(a=setTimeout(s,o)),s}function zm(e,t){var n=e.state.dialog;e.state.dialog=t,t.style.flex=`1`,t&&n!==t&&(n&&n.contains(document.activeElement)&&e.focus(),n&&n.parentElement?n.parentElement.replaceChild(t,n):n&&n.remove(),Q.signal(e,`dialog`))}function Bm(e,t){e.state.dialog==t&&(e.state.dialog=null,Q.signal(e,`dialog`))}function Vm(e,t,n,r){r||={},Lm(e,void 0);var i=Im(e,t,r.bottom),a=!1;zm(e,i);function o(t){if(typeof t==`string`)s.value=t;else{if(a)return;a=!0,Bm(e,i),e.state.dialog||e.focus(),r.onClose&&r.onClose(i)}}var s=i.getElementsByTagName(`input`)[0];return s&&(r.value&&(s.value=r.value,r.selectValueOnOpen!==!1&&s.select()),r.onInput&&Q.on(s,`input`,function(e){r.onInput(e,s.value,o)}),r.onKeyUp&&Q.on(s,`keyup`,function(e){r.onKeyUp(e,s.value,o)}),Q.on(s,`keydown`,function(e){r&&r.onKeyDown&&r.onKeyDown(e,s.value,o)||(e.keyCode==13&&n&&n(s.value),(e.keyCode==27||r.closeOnEnter!==!1&&e.keyCode==13)&&(s.blur(),Q.e_stop(e),o()))}),r.closeOnBlur!==!1&&Q.on(s,`blur`,function(){setTimeout(function(){document.activeElement!==s&&o()})}),s.focus()),o}var Hm={"(":`)>`,")":`(<`,"[":`]>`,"]":`[<`,"{":`}>`,"}":`{<`,"<":`>>`,">":`<<`};function Um(e){return e&&e.bracketRegex||/[(){}[\]]/}function Wm(e,t,n,r,i){for(var a=i&&i.maxScanLineLength||1e4,o=i&&i.maxScanLines||1e3,s=[],c=Um(i),l=n>0?Math.min(t.line+o,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-o),u=t.line;u!=l;u+=n){var d=e.getLine(u);if(d){var f=n>0?0:d.length-1,p=n>0?d.length:-1;if(!(d.length>a))for(u==t.line&&(f=t.ch-(n<0?1:0));f!=p;f+=n){var m=d.charAt(f);if(c.test(m)){var h=Hm[m];if(h&&h.charAt(1)==`>`==n>0)s.push(m);else if(s.length)s.pop();else return{pos:new Dm(u,f),ch:m}}}}}return u-n==(n>0?e.lastLine():e.firstLine())?!1:null}function Gm(e,t){return null}function Km(e,t){var n=e.cm6.state,r=e.indexFromPos(t);r<n.doc.length&&n.sliceDoc(r,r+1)==`<`&&r++;for(var i=Dl(n,r)?.resolve(r)||null;i;){if(i.firstChild?.type.name==`OpenTag`&&i.lastChild?.type.name==`CloseTag`)return{open:qm(n.doc,i.firstChild),close:qm(n.doc,i.lastChild)};i=i.parent}}function qm(e,t){return{from:Em(e,t.from),to:Em(e,t.to)}}var Jm=class{constructor(e,t,n){this.cm=e,this.id=e.$mid++,this.offset=t,this.assoc=n,e.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(e){this.offset!=null&&(this.offset=e.mapPos(this.offset,this.assoc,gt.TrackDel))}};function Ym(e,t){for(var n=t.column||e.getOption(`textwidth`)||80,r=t.allowMerge!=0,i=Math.min(t.from,t.to),a=Math.max(t.from,t.to);i<=a;){var o=e.getLine(i);if(o.length>n){var s=p(o,n,5);if(s){var c=/^\s*/.exec(o)?.[0];e.replaceRange(`
51
+ `+c,new Dm(i,s.start),new Dm(i,s.end))}a++}else if(r&&/\S/.test(o)&&i!=a){var l=e.getLine(i+1);if(l&&/\S/.test(l)){var u=o.replace(/\s+$/,``),d=l.replace(/^\s+/,``),f=u+` `+d,s=p(f,n,5);s&&s.start>u.length||f.length<n?(e.replaceRange(` `,new Dm(i,u.length),new Dm(i+1,l.length-d.length)),i--,a--):u.length<o.length&&e.replaceRange(``,new Dm(i,u.length),new Dm(i,o.length))}}i++}return i;function p(e,t,n){if(!(e.length<t)){var r=e.slice(0,t),i=e.slice(t),a=/^(?:(\s+)|(\S+)(\s+))/.exec(i),o=/(?:(\s+)|(\s+)(\S+))$/.exec(r),s=0,c=0;if(o&&!o[2]&&(s=t-o[1].length,c=t),a&&!a[2]&&(s||=t,c=t+a[1].length),s)return{start:s,end:c};if(o&&o[2]&&o.index>n)return{start:o.index,end:o.index+o[2].length};if(a&&a[2])return s=t+a[2].length,{start:s,end:s+a[3].length}}}}var Xm=oc||function(){let e={cursorBlinkRate:1200};return function(){return e}}(),Zm=class{constructor(e,t,n,r,i,a,o,s,c,l){this.left=e,this.top=t,this.height=n,this.fontFamily=r,this.fontSize=i,this.fontWeight=a,this.color=o,this.className=s,this.letter=c,this.partial=l}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,e.style.height=this.height+`px`,e.style.lineHeight=this.height+`px`,e.style.fontFamily=this.fontFamily,e.style.fontSize=this.fontSize,e.style.fontWeight=this.fontWeight,e.style.color=this.partial?`transparent`:this.color,e.className=this.className,e.textContent=this.letter}eq(e){return this.left==e.left&&this.top==e.top&&this.height==e.height&&this.fontFamily==e.fontFamily&&this.fontSize==e.fontSize&&this.fontWeight==e.fontWeight&&this.color==e.color&&this.className==e.className&&this.letter==e.letter}},Qm=class{constructor(e,t){this.view=e,this.rangePieces=[],this.cursors=[],this.cm=t,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=e.scrollDOM.appendChild(document.createElement(`div`)),this.cursorLayer.className=`cm-cursorLayer cm-vimCursorLayer`,this.cursorLayer.setAttribute(`aria-hidden`,`true`),e.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let e=Xm(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=e+`ms`}update(e){(e.selectionSet||e.geometryChanged||e.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`),$m(e)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:e}=this.view,t=[];for(let n of e.selection.ranges){let r=n==e.selection.main,i=nh(this.cm,this.view,n,r);i&&t.push(i)}return{cursors:t}}drawSel({cursors:e}){if(e.length!=this.cursors.length||e.some((e,t)=>!e.eq(this.cursors[t]))){let t=this.cursorLayer.children;if(t.length!==e.length){this.cursorLayer.textContent=``;for(let t of e)this.cursorLayer.appendChild(t.draw())}else e.forEach((e,n)=>e.adjust(t[n]));this.cursors=e}}destroy(){this.cursorLayer.remove()}};function $m(e){return Xm(e.startState)!=Xm(e.state)}var eh=It.highest(J.theme({".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:`transparent !important`},"&::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-fat-cursor":{position:`absolute`,background:`#ff9696`,border:`none`,whiteSpace:`pre`},"&:not(.cm-focused) .cm-fat-cursor":{background:`none`,outline:`solid 1px #ff9696`,color:`transparent !important`}}));function th(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Jr.LTR?t.left:t.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function nh(e,t,n,r){var i;let a=n.head,o=!1,s=1,c=e.state.vim;if(c&&(!c.insertMode||e.state.overwrite)){if(o=!0,c.visualBlock&&!r)return null;n.anchor<n.head&&(a<t.state.doc.length&&t.state.sliceDoc(a,a+1))!=`
52
+ `&&a--,e.state.overwrite?s=.2:c.status&&(s=.5)}if(o){let e=a<t.state.doc.length&&t.state.sliceDoc(a,a+1);e&&/[\uDC00-\uDFFF]/.test(e)&&a>1&&(a--,e=t.state.sliceDoc(a,a+1));let n=t.coordsAtPos(a,1);if(!n)return null;let o=th(t),c=t.domAtPos(a),u=c?c.node:t.contentDOM;for(u instanceof Text&&c.offset>=u.data.length&&u.parentElement?.nextSibling&&(u=u.parentElement?.nextSibling,c={node:u,offset:0});c&&c.node instanceof HTMLElement;)u=c.node,c={node:c.node.childNodes[c.offset],offset:0};if(!(u instanceof HTMLElement)){if(!u.parentNode)return null;u=u.parentNode}let d=getComputedStyle(u),f=n.left,p=(i=t).coordsForChar?.call(i,a);if(p&&(f=p.left),!e||e==`
53
+ `||e==`\r`)e=`\xA0`;else if(e==` `){e=`\xA0`;var l=t.coordsAtPos(a+1,-1);l&&(f=l.left-(l.left-n.left)/parseInt(d.tabSize))}else /[\uD800-\uDBFF]/.test(e)&&a<t.state.doc.length-1&&(e+=t.state.sliceDoc(a+1,a+2));let m=n.bottom-n.top;return new Zm((f-o.left)/t.scaleX,(n.top-o.top+m*(1-s))/t.scaleY,m*s/t.scaleY,d.fontFamily,d.fontSize,d.fontWeight,d.color,r?`cm-fat-cursor cm-cursor-primary`:`cm-fat-cursor cm-cursor-secondary`,e,s!=1)}else return null}var rh=typeof navigator<`u`&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent),ih=wm(Q),ah=250,oh=J.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:`none`},".cm-vim-panel":{padding:`0px 10px`,fontFamily:`monospace`,minHeight:`1.3em`,display:`flex`},".cm-vim-panel input":{border:`none`,outline:`none`,backgroundColor:`inherit`},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`}}),sh=Fi.fromClass(class{constructor(e){this.status=``,this.query=null,this.decorations=W.none,this.waitForCopy=!1,this.lastKeydown=``,this.useNextTextInput=!1,this.compositionText=``,this.view=e;let t=this.cm=new Q(e);ih.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new Qm(e,t),this.updateClass(),this.cm.on(`vim-command-done`,()=>{t.state.vim&&(t.state.vim.status=``),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on(`vim-mode-change`,e=>{t.state.vim&&(t.state.vim.mode=e.mode,e.subMode&&(t.state.vim.mode+=` block`),t.state.vim.status=``,this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on(`dialog`,()=>{this.cm.state.statusbar?this.updateStatus():e.dispatch({effects:uh.of(!!this.cm.state.dialog)})}),this.dom=document.createElement(`span`),this.spacer=document.createElement(`span`),this.spacer.style.flex=`1`,this.statusButton=document.createElement(`span`),this.statusButton.onclick=e=>{ih.handleKey(this.cm,`<Esc>`,`user`),this.cm.focus()},this.statusButton.style.cssText=`cursor: pointer`}update(e){if((e.viewportChanged||e.docChanged)&&this.query&&this.highlight(this.query),e.docChanged&&this.cm.onChange(e),e.selectionSet&&this.cm.onSelectionChange(),e.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),e.transactions){for(let t of e.transactions)for(let e of t.effects)if(e.is(Cm))if(!e.value?.forVim)this.highlight(null);else{let t=e.value.create();this.highlight(t)}}this.blockCursor.update(e)}updateClass(){let e=this.cm.state;!e.vim||e.vim.insertMode&&!e.overwrite?this.view.scrollDOM.classList.remove(`cm-vimMode`):this.view.scrollDOM.classList.add(`cm-vimMode`)}updateStatus(){let e=this.cm.state.statusbar,t=this.cm.state.vim;if(!e||!t)return;let n=this.cm.state.dialog;if(n)n.parentElement!=e&&(e.textContent=``,e.appendChild(n));else{e.textContent=``;var r=(t.mode||`normal`).toUpperCase();t.insertModeReturn&&(r+=`(C-O)`),this.statusButton.textContent=`--${r}--`,e.appendChild(this.statusButton),e.appendChild(this.spacer)}this.dom.textContent=t.status,e.appendChild(this.dom)}destroy(){ih.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(e){if(this.query=e,!e)return this.decorations=W.none;let{view:t}=this,n=new Cn;for(let r=0,i=t.visibleRanges,a=i.length;r<a;r++){let{from:o,to:s}=i[r];for(;r<a-1&&s>i[r+1].from-2*ah;)s=i[++r].to;e.highlight(t.state,o,s,(e,t)=>{n.add(e,t,lh)})}return this.decorations=n.finish()}handleKey(e,t){let n=this.cm,r=n.state.vim;if(!r)return;let i=ih.vimKeyFromEvent(e,r);if(Q.signal(this.cm,`inputEvent`,{type:`handleKey`,key:i}),!i)return;if(i==`<Esc>`&&!r.insertMode&&!r.visualMode&&this.query){let e=r.searchState_;e&&(n.removeOverlay(e.getOverlay()),e.setOverlay(null))}if(i===`<C-c>`&&!Q.isMac&&n.somethingSelected())return this.waitForCopy=!0,!0;r.status=(r.status||``)+i;let a=ih.multiSelectHandleKey(n,i,`user`);return r=ih.maybeInitVimState_(n),!a&&r.insertMode&&n.state.overwrite&&(e.key&&e.key.length==1&&!/\n/.test(e.key)?(a=!0,n.overWriteSelection(e.key)):e.key==`Backspace`&&(a=!0,Q.commands.cursorCharLeft(n))),a&&(Q.signal(this.cm,`vim-keypress`,i),e.preventDefault(),e.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!a}},{eventHandlers:{copy:function(e,t){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var e=this.cm,t=e.state.vim;t&&(t.insertMode?e.setSelection(e.getCursor(),e.getCursor()):e.operation(()=>{e.curOp&&(e.curOp.isVimOp=!0),ih.handleKey(e,`<Esc>`,`user`)}))}))},compositionstart:function(e,t){this.useNextTextInput=!0,Q.signal(this.cm,`inputEvent`,e)},compositionupdate:function(e,t){Q.signal(this.cm,`inputEvent`,e)},compositionend:function(e,t){Q.signal(this.cm,`inputEvent`,e)},keypress:function(e,t){Q.signal(this.cm,`inputEvent`,e),this.lastKeydown==`Dead`&&this.handleKey(e,t)},keydown:function(e,t){Q.signal(this.cm,`inputEvent`,e),this.lastKeydown=e.key,this.lastKeydown==`Unidentified`||this.lastKeydown==`Process`||this.lastKeydown==`Dead`?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(e,t))}},provide:()=>[J.inputHandler.of((e,t,n,r)=>{var i=hh(e);if(!i)return!1;var a=i.state?.vim,o=i.state.vimPlugin;if(a&&!a.insertMode&&!i.curOp?.isVimOp){if(r===`\0\0`)return!0;if(Q.signal(i,`inputEvent`,{type:`text`,text:r,from:t,to:n}),r.length==1&&o.useNextTextInput){if(a.expectLiteralNext&&e.composing)return o.compositionText=r,!1;if(o.compositionText){var s=o.compositionText;o.compositionText=``;var c=e.state.selection.main.head;if(s===e.state.sliceDoc(c-s.length,c)){var l=i.getCursor();i.replaceRange(``,i.posFromIndex(c-s.length),l)}}return o.handleKey({key:r,preventDefault:()=>{},stopPropagation:()=>{}}),ch(e),!0}}return!1})],decorations:e=>e.decorations});function ch(e){var t=e.scrollDOM.parentElement;if(t){if(rh){e.contentDOM.textContent=`\0\0`,e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`));return}var n=e.scrollDOM.nextSibling,r=window.getSelection(),i=r&&{anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset};e.scrollDOM.remove(),t.insertBefore(e.scrollDOM,n);try{i&&r&&(r.setPosition(i.anchorNode,i.anchorOffset),i.focusNode&&r.extend(i.focusNode,i.focusOffset))}catch(e){console.error(e)}e.focus(),e.contentDOM.dispatchEvent(new CustomEvent(`compositionend`))}}var lh=W.mark({class:`cm-searchMatch`}),uh=V.define(),dh=Nt.define({create:()=>!1,update(e,t){for(let n of t.effects)n.is(uh)&&(e=n.value);return e},provide:e=>dc.from(e,e=>e?fh:null)});function fh(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.dialog&&t.appendChild(n.state.dialog),{top:!1,dom:t}}function ph(e){let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=e.cm;return n.state.statusbar=t,n.state.vimPlugin.updateStatus(),{dom:t}}function mh(e={}){return[oh,sh,eh,e.status?dc.of(ph):dh]}function hh(e){return e.cm||null}var gh=C(`<div>`),_h=W.line({attributes:{class:`cm-selected-line`}});function vh(){return Fi.fromClass(class{decorations;constructor(e){this.decorations=this.computeDecorations(e)}update(e){(e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.computeDecorations(e.view))}computeDecorations(e){let t=new Cn,n=e.state.selection.main;if(!n.empty){let r=e.state.doc.lineAt(n.from).number,i=e.state.doc.lineAt(n.to).number;if(r!==i)for(let n=r;n<=i;n++){let r=e.state.doc.line(n).from;t.add(r,r,_h)}else{let i=e.state.doc.line(r);n.from<=i.from&&n.to>=i.to-1&&t.add(i.from,i.from,_h)}}return t.finish()}},{decorations:e=>e.decorations})}var yh={zIndex:`10`},bh=J.theme({"&":{height:`100%`,display:`flex`,flexDirection:`column`},".cm-scroller":{overflow:`auto`,flex:`1`},".cm-content":{padding:`12px`},"&.cm-focused .cm-cursor":{borderLeftColor:`#fff`},"&.cm-focused .cm-selectionBackground":{background:`rgba(134, 239, 172, 0.25) !important`},".cm-selectionBackground":{background:`rgba(134, 239, 172, 0.2) !important`},".cm-selected-line":{backgroundColor:`rgba(134, 239, 172, 0.15) !important`},".cm-vim-panel":{fontFamily:`"Source Code Pro", monospace`,fontSize:`12px`,padding:`4px 8px`,backgroundColor:`#1a1a1a`,borderTop:`1px solid #262626`,color:`#a3a3a3`,...yh},".cm-panels":yh}),xh=J.theme({"&":{height:`100%`,display:`flex`,flexDirection:`column`,backgroundColor:`#fafafa`},".cm-scroller":{overflow:`auto`,flex:`1`},".cm-content":{padding:`12px`,color:`#1a1a1a`},".cm-gutters":{backgroundColor:`#fafafa`,color:`#737373`,border:`none`},".cm-activeLineGutter":{backgroundColor:`#f5f5f5`},"&.cm-focused .cm-cursor":{borderLeftColor:`#1a1a1a`},"&.cm-focused .cm-selectionBackground":{background:`rgba(34, 197, 94, 0.25) !important`},".cm-selectionBackground":{background:`rgba(34, 197, 94, 0.2) !important`},".cm-selected-line":{backgroundColor:`rgba(34, 197, 94, 0.15) !important`},".cm-vim-panel":{fontFamily:`"Source Code Pro", monospace`,fontSize:`12px`,padding:`4px 8px`,backgroundColor:`#f5f5f5`,borderTop:`1px solid #e5e5e5`,color:`#525252`,...yh},".cm-panels":yh}),Sh=wu.define([{tag:Z.keyword,color:`#7c3aed`},{tag:Z.string,color:`#059669`},{tag:Z.number,color:`#0284c7`},{tag:Z.comment,color:`#737373`,fontStyle:`italic`},{tag:Z.variableName,color:`#1a1a1a`},{tag:Z.propertyName,color:`#171717`},{tag:Z.typeName,color:`#0369a1`},{tag:Z.definition(Z.variableName),color:`#171717`},{tag:Z.punctuation,color:`#525252`},{tag:Z.bracket,color:`#525252`}]),Ch=It.highest(J.theme({".cm-vimMode .cm-line::selection":{background:`rgba(134, 239, 172, 0.3) !important`},".cm-vimMode .cm-line ::selection":{background:`rgba(134, 239, 172, 0.3) !important`},".cm-vimMode .cm-selectionLayer .cm-selectionBackground":{background:`rgba(134, 239, 172, 0.3) !important`}})),wh=It.highest(J.theme({".cm-vimMode .cm-line::selection":{background:`rgba(34, 197, 94, 0.3) !important`},".cm-vimMode .cm-line ::selection":{background:`rgba(34, 197, 94, 0.3) !important`},".cm-vimMode .cm-selectionLayer .cm-selectionBackground":{background:`rgba(34, 197, 94, 0.3) !important`}}));function Th(e){let{vimModeEnabled:t}=de(),{inferredTheme:n}=te(),r,i,a=(t,n)=>{let r=[Pp({dialect:Fp}),...n?[em,bh]:[xh,Ou(Sh)],rd(),Xs.of([{key:`Mod-Enter`,run:()=>(e.onExecute(),!0)},{key:`Mod-/`,run:Yu},...Sd]),J.updateListener.of(t=>{if(t.docChanged&&e.onChange(t.state.doc.toString()),t.selectionSet){let n=t.state.selection.main;if(n.empty)e.onSelectionChange?.(null);else{let r=t.state.doc.toString(),i=t.state.sliceDoc(n.from,n.to).trim();if(!i){e.onSelectionChange?.(null);return}let a=r.slice(0,n.from),o=r.slice(n.to),s=a.lastIndexOf(`;`),c=o.indexOf(`;`),l=s>=0?s+1:0,u=n.to;i.endsWith(`;`)||(u=c>=0?n.to+c+1:r.length);let d=r.slice(l,u).trim(),f=d.split(`;`).map(e=>e.trim()).filter(e=>e.length>0).length;e.onSelectionChange?.({text:d,statementCount:f})}}}),J.lineWrapping,H.readOnly.of(e.readOnly??!1),vh()];return t&&(r.push(mh({status:!0})),r.push(n?Ch:wh)),r};return T(()=>{r&&(i=new J({state:H.create({doc:e.value,extensions:a(t(),n()===`dark`)}),parent:r}))}),_(he([t,n],([e,t])=>{if(!i)return;let n=H.create({doc:i.state.doc.toString(),extensions:a(e,t===`dark`)});i.setState(n)})),_(he(()=>e.value,e=>{i&&e!==i.state.doc.toString()&&i.dispatch({changes:{from:0,to:i.state.doc.length,insert:e}})})),(()=>{var t=A(gh),n=r;return typeof n==`function`?l(n,t):r=t,u(()=>ce(t,`h-full w-full border border-border ${e.class||``}`)),t})()}var Eh=new Map,Dh=(e,t)=>{if(Eh.has(e))return Eh.get(e);let n=h(t);return Eh.set(e,n),n},Oh=e=>{let t=Eh.get(e);if(t)return E(t)},kh=e=>typeof e==`function`&&e.length>0,Ah=e=>e?``:void 0,jh=e=>{let[t,r]=d(e,[`as`]),i=b(()=>t.as??`div`);return b(()=>{let e=i();switch(typeof e){case`function`:return w(()=>e(r));case`string`:return n(ne,x({component:e},r))}})},Mh=e=>{let t,n=!1;return()=>n?t:(n=!0,t=b(e))};function Nh(e){let[t,n]=f(e.initialValue),r=()=>e.value?.()!==void 0,i=()=>r()?e.value?.():t();return[i,t=>w(()=>{let a;return a=typeof t==`function`?t(i()):t,Object.is(a,i())||(r()||n(a),e.onChange?.(a)),a})]}var Ph=Nh,Fh=e=>{let[t,n]=f(0);_(()=>{let t=c(e.element);if(!t)return;a(t);let n=new ResizeObserver(i);n.observe(t),r(()=>{n.disconnect()})});let i=([e])=>{a(e.target)},a=t=>{switch(c(e.dimension)){case`width`:n(t.offsetWidth);break;case`height`:n(t.offsetHeight);break}};return t},Ih=C(`<div data-corvu-resizable-handle-start-intersection style="position:absolute;aspect-ratio:1 / 1;top:0;left:0;z-index:1">`),Lh=C(`<div data-corvu-resizable-handle-end-intersection style="position:absolute;aspect-ratio:1 / 1;bottom:0;right:0;z-index:1">`),Rh=h(),zh=e=>e===void 0?Rh:Dh(`resizable-${e}`),Bh=e=>{if(e===void 0){let e=E(Rh);if(!e)throw Error(`[corvu]: Resizable context not found. Make sure to wrap Resizable components in <Resizable.Root>`);return e}let t=Oh(`resizable-${e}`);if(!t)throw Error(`[corvu]: Resizable context with id "${e}" not found. Make sure to wrap Resizable components in <Resizable.Root contextId="${e}">`);return t},Vh=h(),Hh=e=>e===void 0?Vh:Dh(`resizable-internal-${e}`),Uh=e=>{if(e===void 0){let e=E(Vh);if(!e)throw Error(`[corvu]: Resizable context not found. Make sure to wrap Resizable components in <Resizable.Root>`);return e}let t=Oh(`resizable-internal-${e}`);if(!t)throw Error(`[corvu]: Resizable context with id "${e}" not found. Make sure to wrap Resizable components in <Resizable.Root contextId="${e}">`);return t},$=(e,t)=>{if(typeof e==`number`)return e;if(!e.endsWith(`px`))throw Error(`[corvu] Sizes must be a number or a string ending with 'px'. Got ${e}`);return Kh(parseFloat(e)/t)},Wh=e=>[e.panels.filter(t=>!!(e.focusedElement.compareDocumentPosition(t.data.element)&Node.DOCUMENT_POSITION_PRECEDING)),e.panels.filter(t=>!!(e.focusedElement.compareDocumentPosition(t.data.element)&Node.DOCUMENT_POSITION_FOLLOWING))],Gh=6,Kh=e=>parseFloat(e.toFixed(Gh)),qh=null,Jh=null,Yh=0,Xh={1:`e-resize`,2:`w-resize`,3:`ew-resize`,4:`s-resize`,8:`n-resize`,12:`ns-resize`,5:`se-resize`,9:`ne-resize`,6:`sw-resize`,10:`nw-resize`},Zh=null,Qh=()=>{if(!qh){Jh&&=(Zh=null,Jh.remove(),null);return}let e=Xh[Yh]??null;if(e===null)switch(qh){case`horizontal`:e=`col-resize`;break;case`vertical`:e=`row-resize`;break;case`both`:e=`move`;break}e!==Zh&&(Zh=e,Jh||(Jh=document.createElement(`style`),document.head.appendChild(Jh)),Jh.innerHTML=`*{cursor: ${e}!important;}`)},$h=(e,t)=>{switch(e){case`horizontal`:t===1?(Yh|=1,Yh&=-3):t===2?(Yh|=2,Yh&=-2):t===3?Yh|=3:Yh&=-4;break;case`vertical`:t===1?(Yh|=4,Yh&=-9):t===2?(Yh|=8,Yh&=-5):t===3?Yh|=12:Yh&=-13;break}Qh()},eg=()=>{Yh=0,Qh()},tg=e=>{qh=e,Qh()},ng=e=>{if(Kh(e.distributablePercentage)!==Kh(e.desiredPercentage)){let t=null;t=e.betweenCollapse===!0?3:e.desiredPercentage<e.distributablePercentage&&e.revertConstraints!==!0||e.desiredPercentage>e.distributablePercentage&&e.revertConstraints===!0?1:2,$h(e.orientation,t)}else $h(e.orientation,0)},rg=[],ig=null,ag=null,og=1,sg=(e,t)=>Math.abs(e-t)<=og,cg=e=>{rg.push(e);for(let e of rg)for(let t of rg){if(e.orientation===t.orientation||e.element===t.element)continue;let n=e.element.getBoundingClientRect(),r=t.element.getBoundingClientRect();if(e.orientation===`horizontal`&&(n.left>r.right||n.right<r.left)||e.orientation===`vertical`&&(n.top>r.bottom||n.bottom<r.top))continue;let i=e.orientation===`horizontal`?sg(n.top,r.bottom):sg(n.left,r.right),a=e.orientation===`horizontal`?sg(n.bottom,r.top):sg(n.right,r.left);i&&e.startIntersection.setHandle(t),a&&e.endIntersection.setHandle(t)}return{onDragStart:(t,n)=>ug(e,t,n),onHoveredChange:t=>{ag=t;let n=!!ig,r=null;ae(()=>{switch(t){case`handle`:{let t=e.startIntersection.handle(),i=e.endIntersection.handle();n||(e.setActive(!0),t?.setActive(!1),i?.setActive(!1)),t?.setHoveredAsIntersection(!1),i?.setHoveredAsIntersection(!1),r=e.orientation;break}case`startIntersection`:{let t=e.startIntersection.handle();n||t?.setActive(!0),t?.setHoveredAsIntersection(!0),r=`both`;break}case`endIntersection`:{let t=e.endIntersection.handle();n||t?.setActive(!0),t?.setHoveredAsIntersection(!0),r=`both`;break}case null:{let t=e.startIntersection.handle(),i=e.endIntersection.handle();!n&&!e.focused()&&(e.setActive(!1),t?.setActive(!1),i?.setActive(!1)),t?.setHoveredAsIntersection(!1),i?.setHoveredAsIntersection(!1),r=null;break}}!n&&e.handleCursorStyle()&&tg(r)})}}},lg=e=>{rg.splice(rg.indexOf(e),1)},ug=(e,t,n)=>{ig={x:t.clientX,y:t.clientY},ae(()=>{e.setDragging(!0),n===`startIntersection`&&e.startIntersection.handle()?.setDragging(!0),n===`endIntersection`&&e.endIntersection.handle()?.setDragging(!0)}),window.addEventListener(`pointermove`,dg),window.addEventListener(`touchmove`,fg),window.addEventListener(`pointerup`,hg),window.addEventListener(`touchend`,hg),window.addEventListener(`contextmenu`,hg)},dg=e=>mg(e.clientX,e.clientY,e.altKey),fg=e=>{e.touches[0]&&mg(e.touches[0].clientX,e.touches[0].clientY,e.altKey)},pg=!1,mg=(e,t,n)=>{if(ig){rg.some(e=>e.dragging()&&e.altKey===`only`)&&(n=!0),rg.some(e=>e.dragging()&&e.altKey===!1)&&(n=!1),pg!==n&&(ig={x:e,y:t},pg=n);for(let r of rg)r.dragging()&&r.onDrag(r.orientation===`horizontal`?e-ig.x:t-ig.y,n)}},hg=e=>{ae(()=>{for(let t of rg)t.dragging()?(t.setDragging(!1),t.onDragEnd(e),!t.hovered()&&!t.hoveredAsIntersection()&&t.setActive(!1),!ag&&t.handleCursorStyle()&&tg(null)):v(t.hovered,t.focused,t.hoveredAsIntersection)&&(t.setActive(!0),t.handleCursorStyle()&&tg(t.orientation))}),eg(),ig=null,window.removeEventListener(`pointermove`,dg),window.removeEventListener(`touchmove`,fg),window.removeEventListener(`pointerup`,hg),window.removeEventListener(`touchend`,hg),window.removeEventListener(`contextmenu`,hg)},gg=e=>{let[t,s]=d(x({startIntersection:!0,endIntersection:!0,altKey:!0},e),[`startIntersection`,`endIntersection`,`altKey`,`onHandleDragStart`,`onHandleDrag`,`onHandleDragEnd`,`contextId`,`ref`,`style`,`disabled`,`children`,`onMouseEnter`,`onMouseLeave`,`onKeyDown`,`onKeyUp`,`onFocus`,`onBlur`,`onPointerDown`]),[c,l]=f(null),[p,m]=f(!1),[h,g]=f(null),[v,S]=f(!1),[C,w]=f(!1),[T,E]=f(!1),[D,ee]=f(null),[O,te]=f(null),k=b(()=>Uh(t.contextId)),ne=b(()=>{let e=c();if(!e)return;let[t,n]=Wh({panels:k().panels(),focusedElement:e}),r=t[t.length-1]?.data.id,i=n.reduce((e,t)=>e-$(t.data.minSize,k().rootSize()),1),a=t.reduce((e,t)=>e+$(t.data.minSize,k().rootSize()),0),o=t.reduce((e,t)=>e+$(t.size(),k().rootSize()),0);return{ariaControls:r,ariaValueMax:Kh(i),ariaValueMin:Kh(a),ariaValueNow:Kh(o)}}),j=null;return _(()=>{if(t.disabled===!0)return;let e=c();if(!e)return;let n={element:e,orientation:k().orientation(),handleCursorStyle:k().handleCursorStyle,altKey:t.altKey,startIntersection:{handle:D,setHandle:e=>{t.startIntersection===!0&&ee(e)}},endIntersection:{handle:O,setHandle:e=>{t.endIntersection===!0&&te(e)}},hovered:h,focused:v,hoveredAsIntersection:p,setHoveredAsIntersection:m,active:C,setActive:w,dragging:T,setDragging:E,onDrag:(n,r)=>{if(t.onHandleDrag!==void 0){let e=new CustomEvent(`drag`,{cancelable:!0});if(t.onHandleDrag(e),e.defaultPrevented)return}k().onDrag(e,n,r)},onDragEnd:e=>{t.onHandleDragEnd?.(e),k().onDragEnd()}};j=cg(n),r(()=>{lg(n),j=null})}),_(he(h,()=>{j?.onHoveredChange(h())})),n(jh,x({as:`button`,ref(e){var n=o(l,t.ref);typeof n==`function`&&n(e)},get style(){return fe({position:`relative`,cursor:k().handleCursorStyle()?`inherit`:void 0,"touch-action":`none`,"flex-shrink":0},t.style)},get disabled(){return t.disabled},onBlur:e=>{i(t.onBlur,e)||(S(!1),!h()&&w(!1))},onFocus:e=>{i(t.onFocus,e)||h()||(S(!0),w(!0))},onKeyDown:e=>{if(i(t.onKeyDown,e)||T())return;let n=c();if(!n)return;let r=t.altKey===`only`||t.altKey!==!1&&e.altKey;k().onKeyDown(n,e,r)},onKeyUp:e=>{i(t.onKeyUp,e)||e.key!==`Tab`||S(!0)},onMouseEnter:e=>{i(t.onMouseEnter,e)||t.disabled===!0||g(`handle`)},onMouseLeave:e=>{i(t.onMouseLeave,e)||g(null)},onPointerDown:e=>{if(i(t.onPointerDown,e)||i(t.onHandleDragStart,e))return;let n=e.target;n.setPointerCapture(e.pointerId);let r=`handle`;n.hasAttribute(`data-corvu-resizable-handle-start-intersection`)&&(r=`startIntersection`),n.hasAttribute(`data-corvu-resizable-handle-end-intersection`)&&(r=`endIntersection`),j?.onDragStart(e,r)},role:`separator`,get"aria-controls"(){return ne()?.ariaControls},get"aria-orientation"(){return k().orientation()},get"aria-valuemax"(){return ne()?.ariaValueMax},get"aria-valuemin"(){return ne()?.ariaValueMin},get"aria-valuenow"(){return ne()?.ariaValueNow},get"data-active"(){return Ah(C())},get"data-dragging"(){return Ah(T())},get"data-orientation"(){return k().orientation()},"data-corvu-resizable-handle":``},s,{get children(){return[n(y,{get when(){return D()},get children(){var e=A(Ih);return e.addEventListener(`mouseleave`,e=>{c()?.contains(e.relatedTarget)===!0?g(`handle`):g(null)}),e.addEventListener(`mouseenter`,()=>g(`startIntersection`)),u(t=>{var n=k().orientation()===`horizontal`?void 0:`100%`,r=k().orientation()===`horizontal`?`100%`:void 0,i=k().orientation()===`horizontal`?`translate3d(0, -100%, 0)`:`translate3d(-100%, 0, 0)`;return n!==t.e&&a(e,`height`,t.e=n),r!==t.t&&a(e,`width`,t.t=r),i!==t.a&&a(e,`transform`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),me(()=>t.children),n(y,{get when(){return O()},get children(){var e=A(Lh);return e.addEventListener(`mouseleave`,e=>{c()?.contains(e.relatedTarget)===!0?g(`handle`):g(null)}),e.addEventListener(`mouseenter`,()=>g(`endIntersection`)),u(t=>{var n=k().orientation()===`horizontal`?void 0:`100%`,r=k().orientation()===`horizontal`?`100%`:void 0,i=k().orientation()===`horizontal`?`translate3d(0, 100%, 0)`:`translate3d(100%, 0, 0)`;return n!==t.e&&a(e,`height`,t.e=n),r!==t.t&&a(e,`width`,t.t=r),i!==t.a&&a(e,`transform`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}})]}}))},_g=h(),vg=e=>e===void 0?_g:Dh(`resizable-panel-${e}`),yg=e=>{if(e===void 0){let e=E(_g);if(!e)throw Error(`[corvu]: Resizable panel context not found. Make sure to call usePanelContext under <Resizable.Panel>`);return e}let t=Oh(`resizable-panel-${e}`);if(!t)throw Error(`[corvu]: Resizable context with id "${e}" not found. Make sure to call usePanelContext under <Resizable.Panel contextId="${e}">`);return t},bg=e=>{let[t,i]=d(x({initialSize:null,minSize:0,maxSize:1,collapsible:!1,collapsedSize:0,collapseThreshold:.05,panelId:p()},e),[`initialSize`,`minSize`,`maxSize`,`collapsible`,`collapsedSize`,`collapseThreshold`,`onResize`,`onCollapse`,`onExpand`,`contextId`,`panelId`,`ref`,`style`,`children`]),[a,s]=f(null),c=b(()=>Uh(t.contextId)),[l,u]=f(null);_(()=>{let e=a();if(!e)return;let n=c(),i=w(()=>n.registerPanel({id:t.panelId,element:e,initialSize:t.initialSize,minSize:t.minSize,maxSize:t.maxSize,collapsible:t.collapsible,collapsedSize:t.collapsedSize,collapseThreshold:t.collapseThreshold,onResize:t.onResize}));u(i),r(()=>{n.unregisterPanel(i.data.id)})});let m=()=>{let e=l();return e?e.size():typeof t.initialSize==`number`?t.initialSize:1},h=b(e=>{let n=l();if(t.collapsible!==!0)return!1;let r=n?n.size()===$(t.collapsedSize,c().rootSize()):!1;return n&&e!==r&&(r&&t.onCollapse!==void 0?t.onCollapse(n.size()):!r&&t.onExpand!==void 0&&t.onExpand(n.size())),r}),g=(e,t)=>{let n=l();n&&n.resize(e,t??`both`)},v=e=>{let t=l();t&&t.collapse(e??`both`)},y=e=>{let t=l();t&&t.expand(e??`both`)},S={get size(){return m()},get minSize(){return t.minSize},get maxSize(){return t.maxSize},get collapsible(){return t.collapsible},get collapsedSize(){return t.collapsedSize},get collapseThreshold(){return t.collapseThreshold},get collapsed(){return h()},resize:g,collapse:v,expand:y,get panelId(){return t.panelId}},C=Mh(()=>t.children),T=()=>{let e=C()();return kh(e)?e(S):e};return b(()=>n(vg(t.contextId).Provider,{value:{size:m,minSize:()=>t.minSize,maxSize:()=>t.maxSize,collapsible:()=>t.collapsible,collapsedSize:()=>t.collapsedSize,collapseThreshold:()=>t.collapseThreshold,collapsed:h,resize:g,collapse:v,expand:y,panelId:()=>t.panelId},get children(){return n(jh,x({as:`div`,ref(e){var n=o(s,t.ref);typeof n==`function`&&n(e)},get style(){return fe({"flex-basis":m()*100+`%`},t.style)},get id(){return t.panelId},get"data-collapsed"(){return Ah(h())},get"data-expanded"(){return Ah(t.collapsible===!0&&!h())},get"data-orientation"(){return c().orientation()},"data-corvu-resizable-panel":``},i,{get children(){return w(()=>T())}}))}}))},xg=e=>{let t=e.desiredPercentage>=0?1/0:-1/0,n=e.initialSizes;for(let r of e.resizeActions){let i=r.negate===!0?-e.desiredPercentage:e.desiredPercentage,[a,o,s]=Sg({desiredPercentage:i,side:`preceding`,panels:r.precedingPanels,initialSizes:n,initialSizesStartIndex:0,collapsible:e.collapsible,rootSize:e.resizableData.rootSize}),[c,l,u]=Sg({desiredPercentage:i,side:`following`,panels:r.followingPanels,initialSizes:n,initialSizesStartIndex:r.precedingPanels.length,collapsible:e.collapsible,rootSize:e.resizableData.rootSize});r.negate===!0&&(a=-a,c=-c),s&&(c=a),u&&(a=c),t=e.desiredPercentage>=0?Math.min(t,Math.min(a,c)):Math.max(t,Math.max(a,c)),n=[...o,...l]}return t},Sg=e=>{e.desiredPercentage=Kh(e.desiredPercentage);let t=Cg({side:e.side,desiredPercentage:e.desiredPercentage}),n=0,r=e.initialSizes.slice(e.initialSizesStartIndex,e.initialSizesStartIndex+e.panels.length);for(let i=e.side===`preceding`?e.panels.length-1:0;e.side===`preceding`?i>=0:i<e.panels.length;e.side===`preceding`?i--:i++){let a=e.panels[i],o=e.initialSizes[i+e.initialSizesStartIndex],s=$(a.data.collapsedSize??0,e.rootSize);if(a.data.collapsible&&o===s)continue;let c=Kh(e.desiredPercentage-n);if(c===0)break;switch(t){case`precedingDecreasing`:{let t=$(a.data.minSize,e.rootSize);r[i]=Math.max(t,o+c),n+=r[i]-o;break}case`followingDecreasing`:{let t=$(a.data.minSize,e.rootSize);r[i]=Math.max(t,o-c),n-=r[i]-o;break}case`precedingIncreasing`:{let t=$(a.data.maxSize,e.rootSize);r[i]=Math.min(t,o+c),n+=r[i]-o;break}case`followingIncreasing`:{let t=$(a.data.maxSize,e.rootSize);r[i]=Math.min(t,o-c),n-=r[i]-o;break}}}if(n=Kh(n),!e.collapsible||n===e.desiredPercentage)return[n,r,!1];let i=e.side===`preceding`?e.panels.length-1:0,a=e.panels[i];if(!a.data.collapsible)return[n,r,!1];let o=Kh(e.desiredPercentage-n),s=!1,c=e.initialSizes[i+e.initialSizesStartIndex],l=$(a.data.minSize,e.rootSize),u=$(a.data.collapsedSize??0,e.rootSize),d=Math.min($(a.data.collapseThreshold??0,e.rootSize),l-u),f=c===u;if(t===`precedingDecreasing`&&!f&&Math.abs(o)>=d)n-=r[i]-c,r[i]=u,n+=r[i]-c,s=!0;else if(t===`precedingIncreasing`&&f&&Math.abs(o)>=d){let t=$(a.data.minSize,e.rootSize);if(r[i]=t,Math.abs(o)>=t-u){let t=$(a.data.maxSize,e.rootSize);r[i]=Math.min(t,c+o)}else s=!0;n+=r[i]-c}else if(t===`followingDecreasing`&&!f&&Math.abs(o)>=d)n+=r[i]-c,r[i]=u,n-=r[i]-c,s=!0;else if(t===`followingIncreasing`&&f&&Math.abs(o)>=d){let t=$(a.data.minSize,e.rootSize);if(r[i]=t,Math.abs(o)>=t-u){let t=$(a.data.maxSize,e.rootSize);r[i]=Math.min(t,c-o)}else s=!0;n-=r[i]-c}return[n,r,s]},Cg=e=>{switch(e.side){case`preceding`:return e.desiredPercentage>=0?`precedingIncreasing`:`precedingDecreasing`;case`following`:return e.desiredPercentage>=0?`followingDecreasing`:`followingIncreasing`}},wg=e=>{let t=e.initialSizes;for(let n of e.resizeActions){let[,r]=Sg({desiredPercentage:n.deltaPercentage,side:`preceding`,panels:n.precedingPanels,initialSizes:t,initialSizesStartIndex:0,collapsible:e.collapsible,rootSize:e.resizableData.rootSize}),[,i]=Sg({desiredPercentage:n.deltaPercentage,side:`following`,panels:n.followingPanels,initialSizes:t,initialSizesStartIndex:n.precedingPanels.length,collapsible:e.collapsible,rootSize:e.resizableData.rootSize});t=[...r,...i]}t=t.map(Kh);let n=t.reduce((e,t)=>e+t,0);if(n!==1){let e=(n-1)/t.length;t=t.map(t=>t-e)}e.resizableData.setSizes(t.map(Kh))},Tg=e=>{let[t,n]=Wh({panels:e.panels,focusedElement:e.panel.data.element}),r=e.panels.indexOf(e.panel);if(r===0?e.strategy=`following`:r===e.panels.length-1&&(e.strategy=`preceding`),e.strategy===`both`){let r=[...t,e.panel],i=[e.panel,...n],a=xg({desiredPercentage:e.deltaPercentage/2,initialSizes:e.initialSizes,collapsible:!0,resizeActions:[{precedingPanels:r,followingPanels:n},{precedingPanels:t,followingPanels:i,negate:!0}],resizableData:{rootSize:e.resizableData.rootSize}});wg({initialSizes:e.initialSizes,collapsible:!0,resizeActions:[{precedingPanels:r,followingPanels:n,deltaPercentage:a},{precedingPanels:t,followingPanels:i,deltaPercentage:-a}],resizableData:e.resizableData})}else{t=e.strategy===`preceding`?t:[...t,e.panel],n=e.strategy===`following`?n:[e.panel,...n],e.strategy===`preceding`&&(e.deltaPercentage=-e.deltaPercentage);let r=xg({desiredPercentage:e.deltaPercentage,initialSizes:e.initialSizes,collapsible:e.collapsible,resizeActions:[{precedingPanels:t,followingPanels:n}],resizableData:{rootSize:e.resizableData.rootSize}});wg({initialSizes:e.initialSizes,collapsible:!0,resizeActions:[{precedingPanels:t,followingPanels:n,deltaPercentage:r}],resizableData:e.resizableData})}},Eg=e=>{if(e.altKey&&e.panels.length>2){let t=e.panels.filter(t=>!!(e.handle.compareDocumentPosition(t.data.element)&Node.DOCUMENT_POSITION_PRECEDING)).length-1,n=t===0;n&&(t++,e.deltaPercentage=-e.deltaPercentage);let r=e.panels[t],i=e.initialSizes[t],a=$(r.data.minSize,e.resizableData.rootSize)-i,o=$(r.data.maxSize,e.resizableData.rootSize)-i,s=Math.max(a,Math.min(e.deltaPercentage*2,o))/2,[c,l]=Wh({panels:e.panels,focusedElement:r.data.element}),u=[...c,r],d=[r,...l],f=xg({desiredPercentage:s,initialSizes:e.initialSizes,collapsible:!1,resizeActions:[{precedingPanels:u,followingPanels:l},{precedingPanels:c,followingPanels:d,negate:!0}],resizableData:{rootSize:e.resizableData.rootSize}});e.resizableData.handleCursorStyle===!0&&ng({orientation:e.resizableData.orientation,desiredPercentage:e.deltaPercentage,distributablePercentage:f,revertConstraints:n}),wg({initialSizes:e.initialSizes,collapsible:!1,resizeActions:[{precedingPanels:u,followingPanels:l,deltaPercentage:f},{precedingPanels:c,followingPanels:d,deltaPercentage:-f}],resizableData:e.resizableData})}else{let[t,n]=Wh({panels:e.panels,focusedElement:e.handle}),r=xg({desiredPercentage:e.deltaPercentage,initialSizes:e.initialSizes,collapsible:!0,resizeActions:[{precedingPanels:t,followingPanels:n}],resizableData:{rootSize:e.resizableData.rootSize}});if(wg({initialSizes:e.initialSizes,collapsible:!0,resizeActions:[{precedingPanels:t,followingPanels:n,deltaPercentage:r}],resizableData:e.resizableData}),e.resizableData.handleCursorStyle){let i=Kh(e.deltaPercentage),a=Kh(r),o=!1,s=t[t.length-1];if(s.data.collapsible){let t=$(s.data.collapsedSize??0,e.resizableData.rootSize);(s.size()===t&&i>a||s.size()!==t&&i<a)&&(o=!0)}let c=n[0];if(c.data.collapsible){let t=$(c.data.collapsedSize??0,e.resizableData.rootSize);(c.size()===t&&i<a||c.size()!==t&&i>a)&&(o=!0)}ng({orientation:e.resizableData.orientation,desiredPercentage:e.deltaPercentage,distributablePercentage:r,betweenCollapse:o})}}},Dg=Object.assign(e=>{let[t,r]=d(x({orientation:`horizontal`,initialSizes:[],keyboardDelta:.1,handleCursorStyle:!0},e),[`orientation`,`sizes`,`onSizesChange`,`initialSizes`,`keyboardDelta`,`handleCursorStyle`,`contextId`,`ref`,`style`,`children`]),[i,a]=Ph({value:()=>t.sizes,initialValue:[],onChange:t.onSizesChange}),[s,c]=f(null),l=Fh({element:s,dimension:()=>t.orientation===`horizontal`?`width`:`height`}),[u,p]=f([]),m=[],h=e=>{let n=u().filter(t=>!!(e.element.compareDocumentPosition(t.data.element)&Node.DOCUMENT_POSITION_PRECEDING)).length,r=m[n]===void 0||m[n]===e.id,o=i()[n]!==void 0,s=null;e.initialSize===null?t.initialSizes[n]!==void 0&&r&&(s=$(t.initialSizes[n],l())):s=$(e.initialSize,l()),s??=.5,a(t=>{let i=[...t],a=i.reduce((e,t)=>e+t,0);if((r&&!o||!r)&&a===1){let e=s/i.length;i=i.map(t=>t-e)}return r?(o||(i[n]=s),m[n]=e.id):(i.splice(n,0,s),m.splice(n,0,e.id)),i});let c=b(()=>{let t=m.indexOf(e.id);return i()[t]});_(()=>e.onResize?.(c()));let d={data:e,size:c,resize:(t,n)=>v(m.indexOf(e.id),t,n),collapse:t=>y(m.indexOf(e.id),t),expand:t=>C(m.indexOf(e.id),t)};return p(e=>{let t=[...e];return t.push(d),t.sort((e,t)=>S(e.data.element,t.data.element)),t}),d},g=e=>{p(t=>t.filter(t=>t.data.id!==e));let t=m.indexOf(e);m.splice(t,1),a(e=>{let n=[...e];n.splice(t,1);let r=(n.reduce((e,t)=>e+t,0)-1)/n.length;return n=n.map(e=>e+r),n})};_(()=>{t.onSizesChange!==void 0&&t.onSizesChange(i())});let v=(e,n,r)=>{w(()=>{let o=u()[e];if(!o)return;let s=$(o.data.minSize,l()),c=$(o.data.maxSize,l()),d=$(n,l());Tg({deltaPercentage:Math.max(s,Math.min(d,c))-i()[e],strategy:r??`both`,panel:o,panels:u(),initialSizes:u().map(e=>e.size()),collapsible:!1,resizableData:{rootSize:l(),orientation:t.orientation,setSizes:a}})})},y=(e,n)=>{w(()=>{let r=u()[e];if(!r)return;let o=i()[e],s=$(r.data.collapsedSize??0,l());!r.data.collapsible||o===s||Tg({deltaPercentage:s-o,strategy:n??`both`,panel:r,panels:u(),initialSizes:u().map(e=>e.size()),collapsible:!0,resizableData:{rootSize:l(),orientation:t.orientation,setSizes:a}})})},C=(e,n)=>{w(()=>{let r=u()[e];if(!r)return;let o=i()[e],s=$(r.data.collapsedSize??0,l());!r.data.collapsible||o!==s||Tg({deltaPercentage:$(r.data.minSize,l())-o,strategy:n??`both`,panel:r,panels:u(),initialSizes:u().map(e=>e.size()),collapsible:!0,resizableData:{rootSize:l(),orientation:t.orientation,setSizes:a}})})},T=null,E=!1,D=(e,n,r)=>{(T===null||E!==r)&&(T=u().map(e=>e.size()),E=r),Eg({deltaPercentage:n/l(),altKey:r,handle:e,panels:u(),initialSizes:T,resizableData:{rootSize:l(),handleCursorStyle:t.handleCursorStyle,orientation:t.orientation,setSizes:a}})},ee=(e,n,r)=>{if(n.key===`Enter`){let[t,n]=Wh({panels:u(),focusedElement:e}),r=t[t.length-1];if((!r||!r.data.collapsible)&&(r=n[0],!r||!r.data.collapsible))return;r.size()===$(r.data.collapsedSize??0,l())?r.expand(`following`):r.collapse(`following`);return}let i=null;if(t.orientation===`horizontal`&&n.key===`ArrowLeft`||t.orientation===`vertical`&&n.key===`ArrowUp`||n.key===`Home`?i=n.shiftKey||n.key===`Home`?-1:-$(t.keyboardDelta,l()):(t.orientation===`horizontal`&&n.key===`ArrowRight`||t.orientation===`vertical`&&n.key===`ArrowDown`||n.key===`End`)&&(i=n.shiftKey||n.key===`End`?1:$(t.keyboardDelta,l())),i===null)return;n.preventDefault();let o=u().map(e=>e.size());Eg({deltaPercentage:i,altKey:r,handle:e,panels:u(),initialSizes:o,resizableData:{rootSize:l(),handleCursorStyle:!1,orientation:t.orientation,setSizes:a}})},O={get sizes(){return i()},setSizes:a,get orientation(){return t.orientation},get keyboardDelta(){return t.keyboardDelta},get handleCursorStyle(){return t.handleCursorStyle},resize:v,collapse:y,expand:C},te=Mh(()=>t.children),k=()=>{let e=te()();return kh(e)?e(O):e};return b(()=>{let e=zh(t.contextId),s=Hh(t.contextId);return n(e.Provider,{value:{sizes:i,setSizes:a,orientation:()=>t.orientation,keyboardDelta:()=>t.keyboardDelta,handleCursorStyle:()=>t.handleCursorStyle,resize:v,collapse:y,expand:C},get children(){return n(s.Provider,{value:{sizes:i,setSizes:a,orientation:()=>t.orientation,keyboardDelta:()=>t.keyboardDelta,handleCursorStyle:()=>t.handleCursorStyle,rootSize:l,panels:u,registerPanel:h,unregisterPanel:g,onDrag:D,onDragEnd:()=>T=null,onKeyDown:ee,resize:v,collapse:y,expand:C},get children(){return n(jh,x({as:`div`,ref(e){var n=o(c,t.ref);typeof n==`function`&&n(e)},get style(){return fe({display:`flex`,"flex-direction":t.orientation===`horizontal`?`row`:`column`},t.style)},get"data-orientation"(){return t.orientation},"data-corvu-resizable-root":``},r,{get children(){return w(()=>k())}}))}})}})})},{Panel:bg,Handle:gg,useContext:Bh,usePanelContext:yg}),Og=C(`<div class="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border"><svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round class=size-2.5><path d="M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0">`),kg=e=>{let[,t]=d(e,[`class`]);return n(Dg,x({get class(){return k(`flex size-full data-[orientation=vertical]:flex-col`,e.class)}},t))},Ag=Dg.Panel,jg=e=>{let[,t]=d(e,[`class`,`withHandle`]);return n(Dg.Handle,x({get class(){return k(`relative flex w-px shrink-0 items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:after:left-0 data-[orientation=vertical]:after:h-1 data-[orientation=vertical]:after:w-full data-[orientation=vertical]:after:translate-x-0 data-[orientation=vertical]:after:-translate-y-1/2 [&[data-orientation=vertical]>div]:rotate-90`,e.class)}},t,{get children(){return n(y,{get when(){return e.withHandle},get children(){return A(Og)}})}}))},Mg=e({default:()=>Yg}),Ng=C(`<div class="flex flex-col gap-1"><span>Executing update...</span><button type=button class="cursor-default text-left text-muted-foreground text-xs">`),Pg=C(`<button type=button class="cursor-pointer text-left text-muted-foreground text-xs underline decoration-dotted hover:text-foreground">`),Fg=C(`<div class="flex flex-col gap-1"><span>Row updated successfully</span><!$><!/>`),Ig=C(`<code class="whitespace-pre-wrap text-xs">`),Lg=C(`<svg class="size-3.5 animate-spin"xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 24 24"><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">`),Rg=C(`<span class="hidden items-center gap-0.5 font-medium text-[11px] text-primary-foreground/50 sm:inline-flex"><span>⌘</span><span>⏎`),zg=C(`<div class="flex items-center gap-2"><!$><!/><!$><!/>`),Bg=C(`<div class="h-full flex-1 overflow-hidden">`),Vg=C(`<span>Last run: <!$><!/>`),Hg=C(`<span class=font-mono><!$><!/>ms`),Ug=C(`<span class=font-mono><!$><!/> rows`),Wg=C(`<div class="flex h-full flex-col overflow-hidden bg-background"><!$><!/><div class="flex flex-1 flex-col overflow-hidden"></div><footer class="flex shrink-0 items-center justify-between border-border border-t bg-card px-4 py-1.5 text-xs"><div class="flex items-center gap-4 text-muted-foreground"></div><div class="flex items-center gap-4 text-muted-foreground"><!$><!/><!$><!/>`),Gg=C(`<span class="hidden items-center gap-0.5 font-medium text-[11px] text-muted-foreground/60 sm:inline-flex"><span>⌘</span><span>⏎`),Kg=C(`<svg xmlns=http://www.w3.org/2000/svg width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><polygon points="5 3 19 12 5 21 5 3">`);function qg(e){let t=e.trim().toLowerCase().match(/(?:from|join)\s+([`"]?[\w]+[`"]?)/i);return t?.[1]?t[1].replace(/[`"]/g,``):null}function Jg(e){return e==null?`NULL`:typeof e==`string`?`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`''`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\t/g,`\\t`)}'`:typeof e==`boolean`?e?`true`:`false`:typeof e==`number`?String(e):`'${String(e).replace(/\\/g,`\\\\`).replace(/'/g,`''`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\t/g,`\\t`)}'`}function Yg(){re({title:M(`SQL Editor`)});let{database:e,setDatabase:r,loading:i}=O(),[a,o]=t({key:`sql-editor-content`,defaultValue:{value:`-- Write your SQL query here
54
+ SELECT * FROM person LIMIT 10;`}}),s=()=>a.value,c=e=>o({value:e}),[l,u]=f({results:null,isLoading:!1,executionTime:0,lastExecutedAt:null}),d=Se(()=>e()??void 0),[p,h]=f(null),_=b(()=>qg(s())),v=b(()=>{let e=_();return e?d().get(e)?.primaryKeyColumns??[]:[]}),x=e=>{r(e);let t=new URL(window.location.href);t.searchParams.set(`db`,e),window.history.replaceState({},``,t)},S=async t=>{if(!e()){u({results:[{statement:``,success:!1,data:null,error:`No database selected. Add ?db=<database> to the URL.`}],isLoading:!1,executionTime:0,lastExecutedAt:new Date});return}let n=t??s(),r=performance.now();u(e=>({...e,isLoading:!0,results:null}));try{u({results:(await(await le.spacetime.sql.$post({json:{sql:n,database:e()}})).json()).results,isLoading:!1,executionTime:Math.round(performance.now()-r),lastExecutedAt:new Date})}catch(e){u({results:[{statement:``,success:!1,data:null,error:e instanceof Error?e.message:`Failed to execute query`}],isLoading:!1,executionTime:Math.round(performance.now()-r),lastExecutedAt:new Date})}},C=()=>{u({results:null,isLoading:!1,executionTime:0,lastExecutedAt:null})},w=async t=>{let{tableName:r,primaryKeyColumns:i,columnId:a,newValue:o,row:s}=t;if(!r||i.length===0){m.error(`Cannot save: No primary key found for this table`);return}let c=`UPDATE ${r} SET ${`${a} = ${Jg(o)}`} WHERE ${i.map(e=>`${e} = ${Jg(s[e])}`).join(` AND `)};`,l=async()=>{try{await navigator.clipboard.writeText(c),m.success(`SQL copied to clipboard`)}catch{m.error(`Failed to copy`)}},u=m.loading((()=>{var e=A(Ng),t=e.firstChild.nextSibling;return N(t,(()=>{var e=me(()=>c.length>50);return()=>e()?`${c.slice(0,50)}...`:c})()),e})());try{let t=await(await le.spacetime.sql.$post({json:{sql:c,database:e()}})).json();if(t.results?.[0]?.success)m.success((()=>{var e=A(Fg),t=e.firstChild.nextSibling,[r,i]=D(t.nextSibling);return N(e,n(oe,{get content(){return(()=>{var e=A(Ig);return N(e,c),e})()},props:{placement:`bottom`,zIndex:9999999999},get children(){var e=A(Pg);return e.$$click=l,N(e,(()=>{var e=me(()=>c.length>50);return()=>e()?`${c.slice(0,50)}...`:c})()),ee(),e}}),r,i),e})(),{id:u}),await S();else{let e=t.results?.[0]?.error||`Update failed`;m.error(`Failed to update: ${e}`,{id:u})}}catch(e){let t=e instanceof Error?e.message:`Failed to execute update`;m.error(t,{id:u})}};return(()=>{var t=A(Wg),r=t.firstChild,[a,o]=D(r.nextSibling),u=a.nextSibling,d=u.nextSibling.firstChild,f=d.nextSibling,m=f.firstChild,[b,T]=D(m.nextSibling),E=b.nextSibling,[ee,O]=D(E.nextSibling);return N(t,n(ye,{title:`SpacetimeDB Studio`,get database(){return e()},get loading(){return i()},onDatabaseChange:x,get children(){var e=A(zg),t=e.firstChild,[r,i]=D(t.nextSibling),a=r.nextSibling,[o,s]=D(a.nextSibling);return N(e,n(y,{get when(){return p()},keyed:!0,children:e=>n(g,{variant:`ghost`,size:`sm`,onClick:()=>S(e.text),get disabled(){return l().isLoading},class:`gap-1.5`,get children(){return[`Run Selected (`,me(()=>e.statementCount),`)`,A(Gg)]}})}),r,i),N(e,n(g,{variant:`default`,size:`sm`,onClick:()=>S(),get disabled(){return l().isLoading},class:`gap-1.5`,get children(){return[n(y,{get when(){return l().isLoading},get fallback(){return A(Kg)},get children(){return A(Lg)}}),n(y,{get when(){return!p()},children:`Run`}),n(y,{get when(){return p()},children:`Run All`}),n(y,{get when(){return!p()},get children(){return A(Rg)}})]}}),o,s),e}}),a,o),N(u,n(kg,{orientation:`vertical`,class:`h-full`,get children(){return[n(Ag,{initialSize:.5,minSize:.2,class:`overflow-hidden`,get children(){return n(ve,{class:`m-0 flex h-full flex-1 flex-col overflow-hidden border-0 border-border`,get children(){return[n(ge,{class:`flex h-[33px] shrink-0 flex-row items-center justify-between border-border border-b bg-muted/30 px-3 py-2`,get children(){return n(_e,{class:`mb-0 font-medium text-muted-foreground text-xs uppercase tracking-wider`,children:`Editor`})}}),(()=>{var e=A(Bg);return N(e,n(Th,{get value(){return s()},onChange:c,onExecute:()=>{let e=p();e?S(e.text):S()},onSelectionChange:h,class:`border-0 bg-[#282C34] focus:outline-0 focus:ring-0`})),e})()]}})}}),n(jg,{}),n(Ag,{initialSize:.5,minSize:.2,class:`overflow-hidden`,get children(){return n(Be,{get results(){return l().results},get isLoading(){return l().isLoading},get executionTime(){return l().executionTime},onClear:C,get tableName(){return _()},get primaryKeyColumns(){return v()},onSave:w})}})]}})),N(d,n(y,{get when(){return l().lastExecutedAt},get children(){var e=A(Vg),t=e.firstChild.nextSibling,[n,r]=D(t.nextSibling);return N(e,()=>l().lastExecutedAt?.toLocaleTimeString(),n,r),e}})),N(f,n(y,{get when(){return l().executionTime>0},get children(){var e=A(Hg),t=e.firstChild,[n,r]=D(t.nextSibling);return n.nextSibling,N(e,()=>l().executionTime,n,r),e}}),b,T),N(f,n(y,{get when(){return me(()=>!!l().results)()&&l().results.length>0},get children(){var e=A(Ug),t=e.firstChild,[n,r]=D(t.nextSibling);return n.nextSibling,N(e,()=>l().results?.reduce((e,t)=>e+(t.data?.numRows??0),0)??0,n,r),e}}),ee,O),t})()}j([`click`]);var Xg={hasServerOnlyHook:{type:`computed`,definedAtData:null,valueSerialized:{type:`js-serialized`,value:!1}},isClientRuntimeLoaded:{type:`computed`,definedAtData:null,valueSerialized:{type:`js-serialized`,value:!0}},onBeforeRenderEnv:{type:`computed`,definedAtData:null,valueSerialized:{type:`js-serialized`,value:null}},dataEnv:{type:`computed`,definedAtData:null,valueSerialized:{type:`js-serialized`,value:null}},guardEnv:{type:`computed`,definedAtData:null,valueSerialized:{type:`js-serialized`,value:null}},onRenderClient:{type:`standard`,definedAtData:{filePathToShowToUser:`vike-solid/__internal/integration/onRenderClient`,fileExportPathToShowToUser:[]},valueSerialized:{type:`pointer-import`,value:se}},Page:{type:`standard`,definedAtData:{filePathToShowToUser:`/src/pages/index/+Page.tsx`,fileExportPathToShowToUser:[]},valueSerialized:{type:`plus-file`,exportValues:Mg}},hydrationCanBeAborted:{type:`standard`,definedAtData:{filePathToShowToUser:`vike-solid/config`,fileExportPathToShowToUser:[`default`,`hydrationCanBeAborted`]},valueSerialized:{type:`js-serialized`,value:!0}},Layout:{type:`cumulative`,definedAtData:[{filePathToShowToUser:`/src/pages/+Layout.tsx`,fileExportPathToShowToUser:[]}],valueSerialized:[{type:`plus-file`,exportValues:ue}]}};export{Xg as configValuesSerialized};