@hienlh/ppm 0.9.66 → 0.9.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/web/assets/chat-tab-onkz52iv.js +10 -0
- package/dist/web/assets/code-editor-BixOXePn.js +8 -0
- package/dist/web/assets/database-viewer-DfLe8ewt.js +2 -0
- package/dist/web/assets/{diff-viewer-p2tGGtgk.js → diff-viewer-eFO08m_L.js} +1 -1
- package/dist/web/assets/dist-DIV6WgAG.js +41 -0
- package/dist/web/assets/{extension-webview-CUMHM0dE.js → extension-webview-4CL9kCKR.js} +1 -1
- package/dist/web/assets/git-graph-BqeE_o17.js +1 -0
- package/dist/web/assets/index-BWLy2h18.css +2 -0
- package/dist/web/assets/index-DwrCg0TN.js +30 -0
- package/dist/web/assets/keybindings-store-BNBONtSd.js +1 -0
- package/dist/web/assets/{markdown-renderer-NhtCBdv0.js → markdown-renderer-BUqab2os.js} +1 -1
- package/dist/web/assets/{port-forwarding-tab-DCeyw77P.js → port-forwarding-tab-CfO-UJ84.js} +1 -1
- package/dist/web/assets/{postgres-viewer-DSxa4fF1.js → postgres-viewer-BVJZ44eU.js} +2 -2
- package/dist/web/assets/settings-tab-C6hdJujW.js +1 -0
- package/dist/web/assets/{sql-query-editor-CMcXl1UJ.js → sql-query-editor-OhZa4Z9F.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-DLBgkBb1.js → sqlite-viewer-C8p1_jz4.js} +1 -1
- package/dist/web/assets/{terminal-tab-XuU6mUdf.js → terminal-tab-CaO0WnIo.js} +1 -1
- package/dist/web/assets/{use-monaco-theme-BWw-hkx4.js → use-monaco-theme-U9ZhfvHB.js} +1 -1
- package/dist/web/assets/x-D2_KzIET.js +1 -0
- package/dist/web/index.html +6 -6
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/web/components/database/data-grid.tsx +13 -93
- package/src/web/components/editor/code-editor.tsx +48 -4
- package/dist/web/assets/chat-tab-BSExiIao.js +0 -10
- package/dist/web/assets/code-editor-BiGbDwge.js +0 -5
- package/dist/web/assets/database-viewer-NyjI--ui.js +0 -7
- package/dist/web/assets/dist-CbZVY8RS.js +0 -1
- package/dist/web/assets/es2015-CFSGWybX.js +0 -41
- package/dist/web/assets/git-graph-mKama5oa.js +0 -1
- package/dist/web/assets/index-BoNuMDkJ.css +0 -2
- package/dist/web/assets/index-KxgzhD-N.js +0 -30
- package/dist/web/assets/keybindings-store-BqfuJQDT.js +0 -1
- package/dist/web/assets/settings-tab-9NIbwd-q.js +0 -1
- /package/dist/web/assets/{chevron-right-5HgK6l7K.js → chevron-right-4zq1jPv6.js} +0 -0
- /package/dist/web/assets/{columns-2-cEVJHYd7.js → columns-2-BoZAN-iw.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./chevron-right-
|
|
1
|
+
import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";import{t as n}from"./chevron-right-4zq1jPv6.js";import{t as r}from"./table-DFevCOMd.js";import{t as i}from"./jsx-runtime-kMwlnEGE.js";import{t as a}from"./api-client-BfBM3I7n.js";import{Et as o,Nt as s,at as c,jt as l,pt as u,rt as d}from"./index-DwrCg0TN.js";import{n as f,r as p,t as m}from"./lib-DurwGtQO.js";var h=e(t());function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},g.apply(null,arguments)}function _(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var v=[],y=[];(()=>{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?y:v).push(n+=e[t])})();function ee(e){if(e<768)return!1;for(let t=0,n=v.length;;){let r=t+n>>1;if(e<v[r])n=r;else if(e>=y[r])t=r+1;else return!0;if(t==n)return!1}}function b(e){return e>=127462&&e<=127487}var x=8205;function te(e,t,n=!0,r=!0){return(n?ne:re)(e,t,r)}function ne(e,t,n){if(t==e.length)return t;t&&ie(e.charCodeAt(t))&&ae(e.charCodeAt(t-1))&&t--;let r=S(e,t);for(t+=C(r);t<e.length;){let i=S(e,t);if(r==x||i==x||n&&ee(i))t+=C(i),r=i;else if(b(i)){let n=0,r=t-2;for(;r>=0&&b(S(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function re(e,t,n){for(;t>0;){let r=ne(e,t-2,n);if(r<t)return r;t--}return 0}function S(e,t){let n=e.charCodeAt(t);if(!ae(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ie(r)?(n-55296<<10)+(r-56320)+65536:n}function ie(e){return e>=56320&&e<57344}function ae(e){return e>=55296&&e<56320}function C(e){return e<65536?1:2}var w=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]=me(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),oe.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]=me(this,e,t);let n=[];return this.decompose(e,t,n,0),oe.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 ue(this),i=new ue(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 ue(this,e)}iterRange(e,t=this.length){return new de(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 fe(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 T(t):oe.from(T.split(t,[]))}},T=class e extends w{constructor(e,t=se(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 pe(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(le(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=ce(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]=me(this,t,n);let i=ce(this.text,ce(r.text,le(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):oe.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
2
2
|
`){[e,t]=me(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}},oe=class e extends w{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]=me(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=`
|
|
3
3
|
`){[e,t]=me(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 T(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 T&&c&&(n=u[u.length-1])instanceof T&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new T(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)}};w.empty=new T([``],0);function se(e){let t=-1;for(let n of e)t+=n.length+1;return t}function ce(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 le(e,t,n){return ce(e,[``],t,n)}var ue=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 T?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 T?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=`
|
|
4
4
|
`,this;e--}else if(r instanceof T){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 T?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)}},de=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new ue(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!=``}},fe=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`&&(w.prototype[Symbol.iterator]=function(){return this.iter()},ue.prototype[Symbol.iterator]=de.prototype[Symbol.iterator]=fe.prototype[Symbol.iterator]=function(){return this});var pe=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 me(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function E(e,t,n=!0,r=!0){return te(e,t,n,r)}function he(e){return e>=56320&&e<57344}function ge(e){return e>=55296&&e<56320}function _e(e,t){let n=e.charCodeAt(t);if(!ge(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return he(r)?(n-55296<<10)+(r-56320)+65536:n}function ve(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function ye(e){return e<65536?1:2}var be=/\r\n?|\n/,xe=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(xe||={}),Se=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){Te(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:De(this,e)}mapDesc(e,t=!1){return e.empty?this:Ee(this,e,t)}mapPos(e,t=-1,n=xe.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!=xe.Simple&&c>=e&&(n==xe.TrackDel&&r<e&&c>e||n==xe.TrackBefore&&r<e||n==xe.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)}},Ce=class e extends Se{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 Te(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return Ee(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(w.empty);r.push(a?t.slice(i,i+a):w.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:De(this,e,!0)}map(e,t=!1){return e.empty?this:Ee(this,e,t,!0)}iterChanges(e,t=!1){Te(this,e,t)}get desc(){return Se.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new Oe(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);D(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;D(n,e,t),t>0&&we(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);D(n,e,-1),D(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:Se.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&&D(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`?w.of(l.split(r||be)):l:w.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&D(i,e-o,-1),D(i,s-e,d),we(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(w.empty);r[e]=w.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 D(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 we(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(w.empty);e.push(n)}}function Te(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=w.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 Ee(e,t,n,r=!1){let i=[],a=r?[]:null,o=new Oe(e),s=new Oe(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);D(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(D(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(D(i,0,o.ins),a&&we(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;D(i,t,e<o.i?o.ins:0),a&&e<o.i&&we(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?Ce.createSet(i,a):Se.create(i);else throw Error(`Mismatched change set lengths`)}function De(e,t,n=!1){let r=[],i=n?[]:null,a=new Oe(e),o=new Oe(t);for(let e=!1;;)if(a.done&&o.done)return i?Ce.createSet(r,i):Se.create(r);else if(a.ins==0)D(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)D(r,0,o.ins,e),i&&we(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;D(r,t,n,e),i&&n&&we(i,r,o.text)}else o.ins==-1?(D(r,a.off?0:a.len,t,e),i&&we(i,r,a.textBit(t))):(D(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&we(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 Oe=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?w.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?w.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)}},ke=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 O.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return O.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 O.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},O=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=>ke.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 ke.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?ke.create(t,e,48|a):ke.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 Ae(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var je=0,k=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=je++,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:Me),!!t.static,t.enables)}of(e){return new Ne([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Ne(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Ne(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Me(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Ne=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=je++}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)||Fe(e,c)){let r=t(e);if(a?!Pe(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=Je(o,c);if(this.dependencies.every(t=>t instanceof k?o.facet(t)===e.facet(t):t instanceof Re?o.field(t,!1)==e.field(t,!1):!0)||(a?Pe(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 Pe(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 Fe(e,t){let n=!1;for(let r of t)qe(e,r)&1&&(n=!0);return n}function Ie(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=Je(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)qe(e,t);return e.values[o]=s(e),1},update(e,n){if(!Fe(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=Fe(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Me(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 Le=k.define({static:!0}),Re=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(je++,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(Le).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(Le),i=n.facet(Le),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,Le.of({field:this,create:e})]}get extension(){return this}},ze={lowest:4,low:3,default:2,high:1,highest:0};function Be(e){return t=>new He(t,e)}var Ve={highest:Be(ze.highest),high:Be(ze.high),default:Be(ze.default),low:Be(ze.low),lowest:Be(ze.lowest)},He=class{constructor(e,t){this.inner=e,this.prec=t}},Ue=class e{of(e){return new We(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},We=class{constructor(e,t){this.compartment=e,this.inner=t}},Ge=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 Ke(t,n,o))e instanceof Re?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,Me(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=>Ie(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function Ke(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 We&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof We){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 He)a(e.inner,e.prec);else if(e instanceof Re)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Ne)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,ze.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,ze.default),r.reduce((e,t)=>e.concat(t))}function qe(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 Je(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Ye=k.define(),Xe=k.define({combine:e=>e.some(e=>e),static:!0}),Ze=k.define({combine:e=>e.length?e[0]:void 0,static:!0}),Qe=k.define(),$e=k.define(),et=k.define(),tt=k.define({combine:e=>e.length?e[0]:!1}),nt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new rt}},rt=class{of(e){return new nt(this,e)}},it=class{constructor(e){this.map=e}of(e){return new A(this,e)}},A=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 it(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}};A.reconfigure=A.define(),A.appendConfig=A.define();var at=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&&Ae(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]==`.`))}};at.time=nt.define(),at.userEvent=nt.define(),at.addToHistory=nt.define(),at.remote=nt.define();function ot(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 st(e,t,n){let r,i,a;return n?(r=t.changes,i=Ce.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:A.mapEffects(e.effects,r).concat(A.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function ct(e,t,n){let r=t.selection,i=pt(t.annotations);return t.userEvent&&(i=i.concat(at.userEvent.of(t.userEvent))),{changes:t.changes instanceof Ce?t.changes:Ce.of(t.changes||[],n,e.facet(Ze)),selection:r&&(r instanceof O?r:O.single(r.anchor,r.head)),effects:pt(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function lt(e,t,n){let r=ct(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=st(r,ct(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=at.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return dt(n?ut(i):i)}function ut(e){let t=e.startState,n=!0;for(let r of t.facet(Qe)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:ot(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=Ce.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=at.create(t,r,e.selection&&e.selection.map(i),A.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet($e);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof at?i:Array.isArray(i)&&i.length==1&&i[0]instanceof at?i[0]:lt(t,pt(i),!1)}return e}function dt(e){let t=e.startState,n=t.facet(et),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=st(r,ct(t,a,e.changes.newLength),!0))}return r==e?e:at.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var ft=[];function pt(e){return e==null?ft:Array.isArray(e)?e:[e]}var j=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(j||={}),mt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ht;try{ht=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function gt(e){if(ht)return ht.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||mt.test(n)))return!0}return!1}function _t(e){return t=>{if(!/\S/.test(t))return j.Space;if(gt(t))return j.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return j.Word;return j.Other}}var M=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++)qe(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 qe(this,n),Je(this,n)}update(...e){return lt(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Ue.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(A.reconfigure)?(n=null,r=e.value):e.is(A.appendConfig)&&(n=null,r=pt(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Ge.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(Xe)?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:O.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=pt(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=A.mapEffects(a,c).concat(A.mapEffects(pt(o.effects),l))}return{changes:r,selection:O.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof Ce?t:Ce.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return w.of(t.split(this.facet(e.lineSeparator)||be))}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:(qe(this,t),Je(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 Re&&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:O.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Ge.resolve(t.extensions||[],new Map),r=t.doc instanceof w?t.doc:w.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||be)),i=t.selection?t.selection instanceof O?t.selection:O.single(t.selection.anchor,t.selection.head):O.single(0);return Ae(i,r.length),n.staticFacet(Xe)||(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)||`
|
|
@@ -10,4 +10,4 @@ import{o as e}from"./chunk-CFjPhJqf.js";import{t}from"./react-nm2Ru1Pt.js";impor
|
|
|
10
10
|
`))};if((I.mac||I.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:w.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);ra(e,u,O.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(R.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:jr.of(R.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=wn(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])}},W=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||Wn(e.parent)||document,this.viewState=new _o(this,e.state||M.create(e)),e.scrollTo&&e.scrollTo.is(Ar)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Fr).map(e=>new Ir(e));for(let e of this.plugins)e.update(this);this.observer=new Lo(this),this.inputState=new la(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Ci(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 at?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(Va))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,s=Ha(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(M.phrases)!=this.state.facet(M.phrases))return this.setState(i);r=Yr.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 kr(e.empty?e:O.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(Ar)&&(u=e.value.clip(this.state))}this.viewState.update(r,u),this.bidiCache=Wo.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(qr)!=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(Do)!=r.state.facet(Do)&&(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(xr))try{e(r)}catch(e){Mr(this.state,e,`update listener`)}(s||l)&&Promise.resolve().then(()=>{s&&this.state==s.startState&&this.dispatch(s),l&&!na(this,l)&&c.force&&Un(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 _o(this,e),this.plugins=e.facet(Fr).map(e=>new Ir(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Ci(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(Fr),n=e.state.facet(Fr);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Ir(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){Mr(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(Kn(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 Mr(this.state,e),Uo}}),l=Yr.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]!=Uo)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){Mr(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(xr))e(t)}get themeClasses(){return ko+` `+(this.state.facet(Oo)?jo:Ao)+` `+this.state.facet(Do)}updateAttrs(){let e=Go(this,Lr,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Nr)?`true`:`false`,class:`cm-content`,style:`${I.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),Go(this,Rr,t);let n=this.observer.ignore(()=>{let n=mn(this.contentDOM,this.contentAttrs,t),r=mn(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(qr);let t=this.state.facet(e.cspNonce);Ht.mount(this.root,this.styleModules.concat(Po).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 Gi(this,e,Bi(this,e,t,n))}moveByGroup(e,t){return Gi(this,e,Bi(this,e,t,t=>Vi(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 O.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return zi(this,e,t,n)}moveVertically(e,t,n){return Gi(this,e,Hi(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=qi(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),qi(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[ar.find(i,e-r.from,-1,t)];return Nn(n,a.dir==z.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(Er)||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>Ho)return pr(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||or(r.isolates,n=Wr(this,e))))return r.order;n||=Wr(this,e);let r=fr(e.text,t,n);return this.bidiCache.push(new Wo(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||I.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Bn(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 Ar.of(new kr(typeof e==`number`?O.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 Ar.of(new kr(O.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 V.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return V.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Ht.newName(),r=[Do.of(n),qr.of(No(`.${n}`,e))];return t&&t.dark&&r.push(Oo.of(!0)),r}static baseTheme(e){return Ve.lowest(qr.of(No(`.`+ko,e,Mo)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&H.get(t)||H.get(e))?.root?.view||null}};W.styleModule=qr,W.inputHandler=Sr,W.clipboardInputFilter=wr,W.clipboardOutputFilter=Tr,W.scrollHandler=Or,W.focusChangeEffect=Cr,W.perLineTextDirection=Er,W.exceptionSink=br,W.updateListener=xr,W.editable=Nr,W.mouseSelectionStyle=yr,W.dragMovesSelection=vr,W.clickAddsSelectionRange=_r,W.decorations=zr,W.blockWrappers=Br,W.outerDecorations=Vr,W.atomicRanges=Hr,W.bidiIsolatedRanges=Ur,W.scrollMargins=Gr,W.darkTheme=Oo,W.cspNonce=k.define({combine:e=>e.length?e[0]:``}),W.contentAttributes=Rr,W.editorAttributes=Lr,W.lineWrapping=W.contentAttributes.of({class:`cm-lineWrapping`}),W.announce=A.define();var Ho=4096,Uo={},Wo=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:z.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 Go(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&&un(a,n)}return n}var Ko=I.mac?`mac`:I.windows?`win`:I.linux?`linux`:`key`;function qo(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 Jo(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 Yo=Ve.default(W.domEventHandlers({keydown(e,t){return is(Qo(t.state),e,t,`editor`)}})),Xo=k.define({enables:Yo}),Zo=new WeakMap;function Qo(e){let t=e.facet(Xo),n=Zo.get(t);return n||Zo.set(t,n=ns(t.reduce((e,t)=>e.concat(t),[]))),n}function $o(e,t,n){return is(Qo(e.state),t,e,n)}var es=null,ts=4e3;function ns(e,t=Ko){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=>qo(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=es={view:t,prefix:n,scope:e};return setTimeout(()=>{es==r&&(es=null)},ts),!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,rs))}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 rs=null;function is(e,t,n,r){rs=t;let i=Zt(t),a=ye(_e(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;es&&es.view==n&&es.scope==r&&(o=es.prefix+` `,ma.indexOf(t.keyCode)<0&&(c=!0,es=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+Jo(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(I.windows&&t.ctrlKey&&t.altKey)&&!(I.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Gt[t.keyCode])&&p!=i?(d(f[o+Jo(p,t,!0)])||t.shiftKey&&(m=Kt[t.keyCode])!=i&&m!=p&&d(f[o+Jo(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+Jo(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),rs=null,s}var as=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className?(this.adjust(e),!0):!1}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=os(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return cs(t,n,r)}};function os(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==z.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function ss(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function cs(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==z.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=os(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=Ri(e,r,1),m=Ri(e,i,-1),h=p.type==L.Text?p:null,g=m.type==L.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=ss(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=ss(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):ee(p,!1),r=g?y(null,n.to,g):ee(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==L.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new as(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==z.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function ee(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function ls(e,t){return e.constructor==t.constructor&&e.eq(t)}var us=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(ds)!=e.state.facet(ds)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(ds);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!ls(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,I.safari&&I.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},ds=k.define();function fs(e){return[V.define(t=>new us(t,e)),ds.of(e)]}var ps=k.define({combine(e){return vt(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function ms(e={}){return[ps.of(e),gs,vs,ys,Dr.of(!0)]}function hs(e){return e.startState.facet(ps)!=e.state.facet(ps)}var gs=fs({above:!0,markers(e){let{state:t}=e,n=t.facet(ps),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&I.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:O.cursor(i.head,i.assoc);for(let i of as.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=hs(e);return n&&_s(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){_s(t.state,e)},class:`cm-cursorLayer`});function _s(e,t){t.style.animationDuration=e.facet(ps).cursorBlinkRate+`ms`}var vs=fs({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of as.forRange(e,`cm-selectionBackground`,n))t.push(r);if(I.ios&&!n.empty&&e.state.facet(ps).iosSelectionHandles){for(let r of as.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,O.cursor(n.from,1)))t.push(r);for(let r of as.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,O.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||hs(e)},class:`cm-selectionLayer`}),ys=Ve.highest(W.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`transparent !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}})),bs=A.define({map(e,t){return e==null?null:t.mapPos(e)}}),xs=Re.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(bs)?t.value:e,e)}}),Ss=V.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(xs);n==null?this.cursor!=null&&((t=this.cursor)==null||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.cursor.className=`cm-dropCursor`),(e.startState.field(xs)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(xs),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+`px`,this.cursor.style.top=e.top/n+`px`,this.cursor.style.height=e.height/n+`px`):this.cursor.style.left=`-100000px`}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(xs)!=e&&this.view.dispatch({effects:bs.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Cs(){return[xs,Ss]}function ws(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),o=n,s;!a.next().done;o+=a.value.length)if(!a.lineBreak)for(;s=t.exec(a.value);)i(o+s.index,s)}function Ts(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:a}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),a=Math.min(e.state.doc.lineAt(a).to,a+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=a:r.push({from:i,to:a});return r}var Es=class{constructor(e){let{regexp:t,decoration:n,decorate:r,boundary:i,maxLength:a=1e3}=e;if(!t.global)throw RangeError(`The regular expression given to MatchDecorator should have its 'g' flag set`);if(this.regexp=t,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if(typeof n==`function`)this.addMatch=(e,t,r,i)=>{let a=n(e,t,r);a&&i(r,r+e[0].length,a)};else if(n)this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n);else throw RangeError(`Either 'decorate' or 'decoration' should be provided to MatchDecorator`);this.boundary=i,this.maxLength=a}createDeco(e){let t=new Tt,n=t.add.bind(t);for(let{from:t,to:r}of Ts(e,this.maxLength))ws(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,a,o)=>{o>=e.view.viewport.from&&a<=e.view.viewport.to&&(n=Math.min(a,n),r=Math.max(o,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let a=Math.max(i.from,n),o=Math.min(i.to,r);if(o>=a){let n=e.state.doc.lineAt(a),r=n.to<o?e.state.doc.lineAt(o):n,s=Math.max(i.from,n.from),c=Math.min(i.to,r.to);if(this.boundary){for(;a>n.from;a--)if(this.boundary.test(n.text[a-1-n.from])){s=a;break}for(;o<r.to;o++)if(this.boundary.test(r.text[o-r.from])){c=o;break}}let l=[],u,d=(e,t,n)=>l.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=s-n.from;(u=this.regexp.exec(n.text))&&u.index<c-n.from;)this.addMatch(u,e,u.index+n.from,d);else ws(e.state.doc,this.regexp,s,c,(t,n)=>this.addMatch(n,e,t,d));t=t.update({filterFrom:s,filterTo:c,filter:(e,t)=>e<s||t>c,add:l})}}return t}},Ds=/x/.unicode==null?`g`:`gu`,Os=RegExp(`[\0-\b
|
|
11
11
|
--\u2028\u2029-]`,Ds),ks={0:`null`,7:`bell`,8:`backspace`,10:`newline`,11:`vertical tab`,13:`carriage return`,27:`escape`,8203:`zero width space`,8204:`zero width non-joiner`,8205:`zero width joiner`,8206:`left-to-right mark`,8207:`right-to-left mark`,8232:`line separator`,8237:`left-to-right override`,8238:`right-to-left override`,8294:`left-to-right isolate`,8295:`right-to-left isolate`,8297:`pop directional isolate`,8233:`paragraph separator`,65279:`zero width no-break space`,65532:`object replacement`},As=null;function js(){if(As==null&&typeof document<`u`&&document.body){let e=document.body.style;As=(e.tabSize??e.MozTabSize)!=null}return As||!1}var Ms=k.define({combine(e){let t=vt(e,{render:null,specialChars:Os,addSpecialChars:null});return(t.replaceTabs=!js())&&(t.specialChars=RegExp(` |`+t.specialChars.source,Ds)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+`|`+t.addSpecialChars.source,Ds)),t}});function Ns(e={}){return[Ms.of(e),Fs()]}var Ps=null;function Fs(){return Ps||=V.fromClass(class{constructor(e){this.view=e,this.decorations=R.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Ms)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Es({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=_e(t[0],0);if(a==9){let e=i.lineAt(r),t=n.state.tabSize,a=It(e.text,t,r-e.from);return R.replace({widget:new zs((t-a%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=R.replace({widget:new Rs(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Ms);e.startState.facet(Ms)==t?this.decorations=this.decorator.updateDeco(e,this.decorations):(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view))}},{decorations:e=>e.decorations})}var Is=`•`;function Ls(e){return e>=32?Is:e==10?``:String.fromCharCode(9216+e)}var Rs=class extends gn{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Ls(this.code),n=e.state.phrase(`Control character`)+` `+(ks[this.code]||`0x`+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement(`span`);return i.textContent=t,i.title=n,i.setAttribute(`aria-label`,n),i.className=`cm-specialChar`,i}ignoreEvent(){return!1}},zs=class extends gn{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement(`span`);return e.textContent=` `,e.className=`cm-tab`,e.style.width=this.width+`px`,e}ignoreEvent(){return!1}};function Bs(){return Hs}var Vs=R.line({class:`cm-activeLine`}),Hs=V.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Vs.range(i.from)),t=i.from)}return R.set(n)}},{decorations:e=>e.decorations}),Us=class extends gn{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?Dn(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Nn(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function Ws(e){let t=V.fromClass(class{constructor(t){this.view=t,this.placeholder=e?R.set([R.widget({widget:new Us(e),side:1}).range(0)]):R.none}get decorations(){return this.view.state.doc.length?R.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,W.contentAttributes.of({"aria-placeholder":e})]:t}var Gs=2e3;function Ks(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>Gs||n.off>Gs||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(O.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=Lt(n.text,o,e.tabSize,!0);if(r<0)a.push(O.cursor(n.to));else{let t=Lt(n.text,s,e.tabSize);a.push(O.range(n.from+r,n.from+t))}}}return a}function qs(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function Js(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>Gs?-1:i==r.length?qs(e,t.clientX):It(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function Ys(e,t){let n=Js(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=Js(e,t);if(!o)return r;let s=Ks(e.state,n,o);return s.length?a?O.create(s.concat(r.ranges)):O.create(s):r}}:null}function Xs(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return W.mouseSelectionStyle.of((e,n)=>t(n)?Ys(e,n):null)}var Zs={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Qs={style:`cursor: crosshair`};function $s(e={}){let[t,n]=Zs[e.key||`Alt`],r=V.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,W.contentAttributes.of(e=>e.plugin(r)?.isDown?Qs:null)]}var ec=`-10000px`,tc=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function nc(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var rc=k.define({combine:e=>({position:I.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||nc})}),ic=new WeakMap,ac=V.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(rc);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new tc(e,lc,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(rc);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=ec,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(I.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Kr(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(rc).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=ec;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=ic.get(c)??d.bottom-d.top,g=c.offset||cc,_=this.view.textDirection==z.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let ee=(y?u.top-n.top:n.bottom-u.bottom)-p;if(ee<h&&c.resize!==!1){if(ee<this.view.defaultLineHeight){l.style.top=ec;continue}ic.set(c,h),l.style.height=(h=ee)/i+`px`}else l.style.height&&(l.style.height=``);let b=y?u.top-h-p-g.y:u.bottom+p+g.y,x=v+m;if(c.overlap!==!0)for(let e of a)e.left<x&&e.right>v&&e.top<b+h&&e.bottom>b&&(b=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(b-e.parent.top)/i+`px`,oc(l,(v-e.parent.left)/r)):(l.style.top=b/i+`px`,oc(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:b,right:x,bottom:b+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=ec}},{eventObservers:{scroll(){this.maybeMeasure()}}});function oc(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var sc=W.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),cc={x:0,y:0},lc=k.define({enables:[ac,sc]}),uc=k.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),dc=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new tc(e,uc,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},fc=lc.compute([uc],e=>{let t=e.facet(uc);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:dc.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),pc=class{constructor(e,t,n,r,i){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener(`mouseleave`,this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener(`mousemove`,this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==z.RTL?-1:1;i=t.x<n.left?-o:o}let a=this.source(e,r,i);if(a?.then){let t=this.pending={pos:r};a.then(n=>{this.pending==t&&(this.pending=null,n&&!(Array.isArray(n)&&!n.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>Mr(e.state,t,`hover tooltip`))}else a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let e=this.view.plugin(ac),t=e?e.manager.tooltips.findIndex(e=>e.create==dc.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:t,tooltip:n}=this;if(t.length&&n&&!hc(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!gc(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},mc=4;function hc(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-mc&&t.clientX<=r+mc&&t.clientY>=i-mc&&t.clientY<=a+mc}function gc(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let c=e.posAtCoords({x:r,y:i},!1);return c>=t&&c<=n}function _c(e,t={}){let n=A.define(),r=Re.define({create(){return[]},update(e,r){if(e.length&&(t.hideOnChange&&(r.docChanged||r.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(r,e))),r.docChanged)){let t=[];for(let n of e){let e=r.changes.mapPos(n.pos,-1,xe.TrackDel);if(e!=null){let i=Object.assign(Object.create(null),n);i.pos=e,i.end!=null&&(i.end=r.changes.mapPos(i.end)),t.push(i)}}e=t}for(let t of r.effects)t.is(n)&&(e=t.value),t.is(yc)&&(e=[]);return e},provide:e=>uc.from(e)});return{active:r,extension:[r,V.define(i=>new pc(i,e,r,n,t.hoverTime||300)),fc]}}function vc(e,t){let n=e.plugin(ac);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var yc=A.define(),bc=k.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function xc(e,t){let n=e.plugin(Sc),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var Sc=V.fromClass(class{constructor(e){this.input=e.state.facet(Tc),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(bc);this.top=new Cc(e,!0,t.topContainer),this.bottom=new Cc(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(bc);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Cc(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Cc(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Tc);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=>W.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),Cc=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=wc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=wc(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 wc(e){let t=e.nextSibling;return e.remove(),t}var Tc=k.define({enables:Sc});function Ec(e,t){let n,r=new Promise(e=>n=e),i=e=>Ac(e,t,n);e.state.field(Dc,!1)?e.dispatch({effects:Oc.of(i)}):e.dispatch({effects:A.appendConfig.of(Dc.init(()=>[i]))});let a=kc.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(Dc).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var Dc=Re.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(Oc)?e=[n.value].concat(e):n.is(kc)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>Tc.computeN([e],t=>t.field(e))}),Oc=A.define(),kc=A.define();function Ac(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=P(`form`),t.input){let e=P(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(P(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(P(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=P(`div`,r,P(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var jc=class extends yt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};jc.prototype.elementClass=``,jc.prototype.toDOM=void 0,jc.prototype.mapMode=xe.TrackBefore,jc.prototype.startSide=jc.prototype.endSide=-1,jc.prototype.point=!0;var Mc=k.define(),Nc=k.define(),Pc={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>N.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},Fc=k.define();function Ic(e){return[Rc(),Fc.of({...Pc,...e})]}var Lc=k.define({combine:e=>e.some(e=>e)});function Rc(e){let t=[zc];return e&&e.fixed===!1&&t.push(Lc.of(!0)),t}var zc=V.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(Fc).map(t=>new Uc(e,t)),this.fixed=!e.state.facet(Lc);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Lc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=N.iter(this.view.state.facet(Mc),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Hc(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==L.Text&&t){Vc(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==L.Text){Vc(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Fc),n=e.state.facet(Fc),r=e.docChanged||e.heightChanged||e.viewportChanged||!N.eq(e.startState.facet(Mc),e.state.facet(Mc),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new Uc(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>W.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==z.LTR?{left:r,right:i}:{right:r,left:i}})});function Bc(e){return Array.isArray(e)?e:[e]}function Vc(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var Hc=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=N.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Wc(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Vc(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(Nc)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Uc=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=Bc(t.markers(e)),t.initialSpacer&&(this.spacer=new Wc(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=Bc(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!N.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Wc=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),Gc(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function Gc(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var Kc=k.define(),qc=k.define(),Jc=k.define({combine(e){return vt(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),Yc=class extends jc{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Xc(e,t){return e.state.facet(Jc).formatNumber(t,e.state)}var Zc=Fc.compute([Jc],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Kc)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Yc(Xc(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(qc)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Jc)!=e.state.facet(Jc),initialSpacer(e){return new Yc(Xc(e,$c(e.state.doc.lines)))},updateSpacer(e,t){let n=Xc(t.view,$c(t.view.state.doc.lines));return n==e.number?e:new Yc(n)},domEventHandlers:e.facet(Jc).domEventHandlers,side:`before`}));function Qc(e={}){return[Jc.of(e),Rc(),Zc]}function $c(e){let t=9;for(;t<e;)t=t*10+9;return t}var el=new class extends jc{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},tl=Mc.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(el.range(i)))}return N.of(t)});function nl(){return tl}var rl=1024,il=0,al=class{constructor(e,t){this.from=e,this.to=t}},G=class{constructor(e={}){this.id=il++,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=cl.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};G.closedBy=new G({deserialize:e=>e.split(` `)}),G.openedBy=new G({deserialize:e=>e.split(` `)}),G.group=new G({deserialize:e=>e.split(` `)}),G.isolate=new G({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),G.contextHash=new G({perNode:!0}),G.lookAhead=new G({perNode:!0}),G.mounted=new G({perNode:!0});var ol=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[G.mounted.id]}},sl=Object.create(null),cl=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):sl,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(G.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(G.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};cl.none=new cl(``,Object.create(null),0,8);var ll=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 cl(e.name,r,e.id,e.flags):e)}return new e(n)}},ul=new WeakMap,dl=new WeakMap,K;(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`})(K||={});var q=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=ol.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 Tl(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new Tl(ul.get(this)||this.topNode);return r.moveTo(e,t),ul.set(this,r._tree),r}get topNode(){return new _l(this,0,0,null)}resolve(e,t=0){let n=hl(ul.get(this)||this.topNode,e,t,!1);return ul.set(this,n),n}resolveInner(e,t=0){let n=hl(dl.get(this)||this.topNode,e,t,!0);return dl.set(this,n),n}resolveStack(e,t=0){return wl(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&K.IncludeAnonymous)>0;for(let e=this.cursor(a|K.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:Al(cl.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(cl.none,t,n,r)))}static build(e){return Dl(e)}};q.empty=new q(cl.none,[],[],0);var fl=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)}},pl=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return cl.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&&!(ml(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 ml(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 hl(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 _l&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:K.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof _l&&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 gl=class{cursor(e=0){return new Tl(this,e)}getChild(e,t=null,n=null){let r=vl(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return vl(this,e,t,n)}resolve(e,t=0){return hl(this,e,t,!1)}resolveInner(e,t=0){return hl(this,e,t,!0)}matchContext(e){return yl(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}},_l=class e extends gl{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&K.EnterBracketed&&l instanceof q&&(d=ol.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!ml(i,r,u,u+l.length))){if(l instanceof pl){if(a&K.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new xl(new bl(o,l,t,u),null,e)}else if(a&K.IncludeAnonymous||!l.type.isAnonymous||El(l)){let s;if(!(a&K.IgnoreMounts)&&(s=ol.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&K.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&K.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&K.IgnoreOverlays)&&(i=ol.get(this._tree))&&i.overlay){let a=t-this.from,o=r&K.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 vl(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 yl(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 bl=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},xl=class e extends gl{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&K.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 q(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function Sl(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 _l&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new Cl(i,n)}var Cl=class{constructor(e,t){this.heads=e,this.node=t}get next(){return Sl(this.heads)}};function wl(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof _l?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=ol.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new _l(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(hl(o,t,n,!1))}}return i?Sl(i):r}var Tl=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&~K.EnterBracketed,e instanceof _l)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 _l?(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&K.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&K.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&K.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&K.IncludeAnonymous||e instanceof pl||!e.type.isAnonymous||El(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 xl(this.buffer,t,this.stack[e]);return this.bufferNode=new xl(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 yl(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 yl(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 El(e){return e.children.some(e=>e instanceof pl||!e.type.isAnonymous||El(e))}function Dl(e){let{buffer:t,nodeSet:n,maxBufferLength:r=rl,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new fl(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,ee){let{id:b,start:x,end:te,size:ne}=o,re=l,S=c;if(ne<0)if(o.next(),ne==-1){let t=i[b];_.push(t),v.push(x-e);return}else if(ne==-3){c=b;return}else if(ne==-4){l=b;return}else throw RangeError(`Unrecognized record size: ${ne}`);let ie=s[b],ae,C,w=x-e;if(te-x<=r&&(C=h(o.pos-t,y))){let t=new Uint16Array(C.size-C.skip),r=o.pos-C.size,i=t.length;for(;o.pos>r;)i=g(C.start,t,i);ae=new pl(t,te-C.start,n),w=C.start-e}else{let e=o.pos-ne;o.next();let t=[],n=[],i=b>=a?b:-1,s=0,c=te;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,x,s,o.end,c,i,re,S),s=t.length,c=o.end),o.next()):ee>2500?d(x,e,t,n):u(x,e,t,n,i,ee+1);if(i>=0&&s>0&&s<t.length&&p(t,n,x,s,x,c,i,re,S),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(ie,S);ae=Al(ie,t,n,0,t.length,0,te-x,e,e)}else ae=m(ie,t,n,te-x,re-te,S)}_.push(ae),v.push(w)}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 pl(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 q){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(G.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=[G.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[G.lookAhead,i];o=o?[e].concat(o):[e]}return new q(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 q(s[e.topID],_.reverse(),v.reverse(),y)}var Ol=new WeakMap;function kl(e,t){if(!e.isAnonymous||t instanceof pl||t.type!=e)return 1;let n=Ol.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof q)){n=1;break}n+=kl(e,r)}Ol.set(t,n)}return n}function Al(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=kl(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=kl(e,t[s]);for(s++;s<i;s++){let n=kl(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(Al(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 jl=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}},Ml=class{startParse(e,t,n){return typeof e==`string`&&(e=new Nl(e)),n=n?n.length?n.map(e=>new al(e.from,e.to)):[new al(0,0)]:[new al(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}}},Nl=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 G({perNode:!0});var Pl=0,Fl=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Pl++}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 Ll(e);return e=>e.modified.indexOf(t)>-1?e:Ll.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Il=0,Ll=class e{constructor(e){this.name=e,this.instances=[],this.id=Il++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Rl(n,e.modified));if(r)return r;let i=[],a=new Fl(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=zl(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 Rl(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function zl(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 Bl(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 Hl(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Vl.add(t)}var Vl=new G({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 Hl(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),Hl=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}};Hl.empty=new Hl([],2,null);function Ul(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 Wl(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function Gl(e,t,n,r=0,i=e.length){let a=new Kl(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Kl=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=ql(e)||Hl.empty,u=Wl(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(G.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 ql(e){let t=e.type.prop(Vl);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var J=Fl.define,Jl=J(),Yl=J(),Xl=J(Yl),Zl=J(Yl),Ql=J(),$l=J(Ql),eu=J(Ql),tu=J(),nu=J(tu),ru=J(),iu=J(),au=J(),ou=J(au),su=J(),Y={comment:Jl,lineComment:J(Jl),blockComment:J(Jl),docComment:J(Jl),name:Yl,variableName:J(Yl),typeName:Xl,tagName:J(Xl),propertyName:Zl,attributeName:J(Zl),className:J(Yl),labelName:J(Yl),namespace:J(Yl),macroName:J(Yl),literal:Ql,string:$l,docString:J($l),character:J($l),attributeValue:J($l),number:eu,integer:J(eu),float:J(eu),bool:J(Ql),regexp:J(Ql),escape:J(Ql),color:J(Ql),url:J(Ql),keyword:ru,self:J(ru),null:J(ru),atom:J(ru),unit:J(ru),modifier:J(ru),operatorKeyword:J(ru),controlKeyword:J(ru),definitionKeyword:J(ru),moduleKeyword:J(ru),operator:iu,derefOperator:J(iu),arithmeticOperator:J(iu),logicOperator:J(iu),bitwiseOperator:J(iu),compareOperator:J(iu),updateOperator:J(iu),definitionOperator:J(iu),typeOperator:J(iu),controlOperator:J(iu),punctuation:au,separator:J(au),bracket:ou,angleBracket:J(ou),squareBracket:J(ou),paren:J(ou),brace:J(ou),content:tu,heading:nu,heading1:J(nu),heading2:J(nu),heading3:J(nu),heading4:J(nu),heading5:J(nu),heading6:J(nu),contentSeparator:J(tu),list:J(tu),quote:J(tu),emphasis:J(tu),strong:J(tu),link:J(tu),monospace:J(tu),strikethrough:J(tu),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:su,documentMeta:J(su),annotation:J(su),processingInstruction:J(su),definition:Fl.defineModifier(`definition`),constant:Fl.defineModifier(`constant`),function:Fl.defineModifier(`function`),standard:Fl.defineModifier(`standard`),local:Fl.defineModifier(`local`),special:Fl.defineModifier(`special`)};for(let e in Y){let t=Y[e];t instanceof Fl&&(t.name=e)}Ul([{tag:Y.link,class:`tok-link`},{tag:Y.heading,class:`tok-heading`},{tag:Y.emphasis,class:`tok-emphasis`},{tag:Y.strong,class:`tok-strong`},{tag:Y.keyword,class:`tok-keyword`},{tag:Y.atom,class:`tok-atom`},{tag:Y.bool,class:`tok-bool`},{tag:Y.url,class:`tok-url`},{tag:Y.labelName,class:`tok-labelName`},{tag:Y.inserted,class:`tok-inserted`},{tag:Y.deleted,class:`tok-deleted`},{tag:Y.literal,class:`tok-literal`},{tag:Y.string,class:`tok-string`},{tag:Y.number,class:`tok-number`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:`tok-string2`},{tag:Y.variableName,class:`tok-variableName`},{tag:Y.local(Y.variableName),class:`tok-variableName tok-local`},{tag:Y.definition(Y.variableName),class:`tok-variableName tok-definition`},{tag:Y.special(Y.variableName),class:`tok-variableName2`},{tag:Y.definition(Y.propertyName),class:`tok-propertyName tok-definition`},{tag:Y.typeName,class:`tok-typeName`},{tag:Y.namespace,class:`tok-namespace`},{tag:Y.className,class:`tok-className`},{tag:Y.macroName,class:`tok-macroName`},{tag:Y.propertyName,class:`tok-propertyName`},{tag:Y.operator,class:`tok-operator`},{tag:Y.comment,class:`tok-comment`},{tag:Y.meta,class:`tok-meta`},{tag:Y.invalid,class:`tok-invalid`},{tag:Y.punctuation,class:`tok-punctuation`}]);var cu=new G;function lu(e){return k.define({combine:e?t=>t.concat(e):void 0})}var uu=new G,du=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,M.prototype.hasOwnProperty(`tree`)||Object.defineProperty(M.prototype,`tree`,{get(){return X(this)}}),this.parser=t,this.extension=[Su.of(this),M.languageData.of((e,t,n)=>{let r=fu(e,t,n),i=r.type.prop(cu);if(!i)return[];let a=e.facet(i),o=r.type.prop(uu);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 fu(e,t,n).type.prop(cu)==this.data}findRegions(e){let t=e.facet(Su);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(cu)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(G.mounted);if(i){if(i.tree.prop(cu)==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 q&&r(i,e.positions[n]+t)}};return r(X(e),0),n}get allowsNesting(){return!0}};du.setState=A.define();function fu(e,t,n){let r=e.facet(Su),i=X(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,K.ExcludeBuffers|K.EnterBracketed))e.type.isTop&&(i=e);return i}var pu=class e extends du{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=lu(t.languageData);return new e(n,t.parser.configure({props:[cu.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 X(e){let t=e.field(du.state,!1);return t?t.tree:q.empty}var mu=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)}},hu=null,gu=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,[],q.empty,0,r,[],null)}startParse(){return this.parser.startParse(new mu(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=q.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(jl.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(jl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=hu;hu=this;try{return e()}finally{hu=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=_u(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=jl.applyChanges(r,e),i=q.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=_u(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 Ml{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=hu;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 q(cl.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 hu}};function _u(e,t,n){return jl.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var vu=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=gu.create(t.facet(Su).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};du.state=Re.define({create:vu.init,update(e,t){for(let e of t.effects)if(e.is(du.setState))return e.value;return t.startState.facet(Su)==t.state.facet(Su)?e.apply(t):vu.init(t.state)}});var yu=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(yu=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var bu=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,xu=V.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(du.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(du.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=yu(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(du.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!bu?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>bu&&bu()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:du.setState.of(new vu(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=>Mr(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Su=k.define({combine(e){return e.length?e[0]:null},enables:e=>[du.state,xu,W.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Cu=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},wu=k.define(),Tu=k.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 Eu(e){let t=e.facet(Tu);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Du(e,t){let n=``,r=e.tabSize,i=e.facet(Tu)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function Ou(e,t){e instanceof M&&(e=new ku(e));for(let n of e.state.facet(wu)){let r=n(e,t);if(r!==void 0)return r}let n=X(e.state);return n.length>=t?ju(e,n,t):null}var ku=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Eu(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 It(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}},Au=new G;function ju(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 Mu(r,e,n)}function Mu(e,t,n){for(let r=e;r;r=r.next){let e=Pu(r.node);if(e)return e(Iu.create(t,n,r))}return 0}function Nu(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Pu(e){let t=e.type.prop(Au);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(G.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>zu(e,!0,1,void 0,n&&!Nu(e)?t.from:void 0)}return e.parent==null?Fu:null}function Fu(){return 0}var Iu=class e extends ku{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(Lu(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Mu(this.context.next,this.base,this.pos)}};function Lu(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Ru(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 zu(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?Ru(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function Bu({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Vu=200;function Hu(){return M.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+Vu)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=Ou(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=Du(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var Uu=k.define(),Wu=new G;function Gu(e,t,n){let r=X(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(Wu);if(s&&(i.to<r.length-50||r.length==e.doc.length||!Ku(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Ku(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function qu(e,t,n){for(let r of e.facet(Uu)){let i=r(e,t,n);if(i)return i}return Gu(e,t,n)}function Ju(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 Yu=A.define({map:Ju}),Xu=A.define({map:Ju});function Zu(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 Qu=Re.define({create(){return R.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=$u(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(Yu)&&!td(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(cd),i=r?R.replace({widget:new fd(r(t.state,n.value))}):dd;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Xu)&&(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=$u(e,t.selection.main.head)),e},provide:e=>W.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(dd.range(r,i))}return R.set(t,!0)}});function $u(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 ed(e,t,n){var r;let i=null;return(r=e.field(Qu,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function td(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function nd(e,t){return e.field(Qu,!1)?t:t.concat(A.appendConfig.of(ld()))}var rd=e=>{for(let t of Zu(e)){let n=qu(e.state,t.from,t.to);if(n)return e.dispatch({effects:nd(e.state,[Yu.of(n),ad(e,n)])}),!0}return!1},id=e=>{if(!e.state.field(Qu,!1))return!1;let t=[];for(let n of Zu(e)){let r=ed(e.state,n.from,n.to);r&&t.push(Xu.of(r),ad(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function ad(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return W.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var od=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:rd},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:id},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=qu(t,i.from,i.to);a&&n.push(Yu.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:nd(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(Qu,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(Xu.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],sd={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},cd=k.define({combine(e){return vt(e,sd)}});function ld(e){let t=[Qu,gd];return e&&t.push(cd.of(e)),t}function ud(e,t){let{state:n}=e,r=n.facet(cd),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=ed(e.state,n.from,n.to);r&&e.dispatch({effects:Xu.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 dd=R.replace({widget:new class extends gn{toDOM(e){return ud(e,null)}}}),fd=class extends gn{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return ud(e,this.value)}},pd={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},md=class extends jc{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function hd(e={}){let t={...pd,...e},n=new md(t,!0),r=new md(t,!1),i=V.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(Su)!=e.state.facet(Su)||e.startState.field(Qu,!1)!=e.state.field(Qu,!1)||X(e.startState)!=X(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new Tt;for(let i of e.viewportLineBlocks){let a=ed(e.state,i.from,i.to)?r:qu(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,Ic({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||N.empty},initialSpacer(){return new md(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=ed(e.state,t.from,t.to);if(r)return e.dispatch({effects:Xu.of(r)}),!0;let i=qu(e.state,t.from,t.to);return i?(e.dispatch({effects:Yu.of(i)}),!0):!1}}}),ld()]}var gd=W.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`}}),_d=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=Ht.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 du?e=>e.prop(cu)==a.data:a?e=>e==a:void 0,this.style=Ul(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Ht(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},vd=k.define(),yd=k.define({combine(e){return e.length?[e[0]]:null}});function bd(e){let t=e.facet(vd);return t.length?t:e.facet(yd)}function xd(e,t){let n=[Cd],r;return e instanceof _d&&(e.module&&n.push(W.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(yd.of(e)):r?n.push(vd.computeN([W.darkTheme],t=>t.facet(W.darkTheme)==(r==`dark`)?[e]:[])):n.push(vd.of(e)),n}var Sd=class{constructor(e){this.markCache=Object.create(null),this.tree=X(e.state),this.decorations=this.buildDeco(e,bd(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=X(e.state),n=bd(e.state),r=n!=bd(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 R.none;let n=new Tt;for(let{from:r,to:i}of e.visibleRanges)Gl(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=R.mark({class:r})))},r,i);return n.finish()}},Cd=Ve.high(V.fromClass(Sd,{decorations:e=>e.decorations})),wd=_d.define([{tag:Y.meta,color:`#404740`},{tag:Y.link,textDecoration:`underline`},{tag:Y.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Y.emphasis,fontStyle:`italic`},{tag:Y.strong,fontWeight:`bold`},{tag:Y.strikethrough,textDecoration:`line-through`},{tag:Y.keyword,color:`#708`},{tag:[Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName],color:`#219`},{tag:[Y.literal,Y.inserted],color:`#164`},{tag:[Y.string,Y.deleted],color:`#a11`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],color:`#e40`},{tag:Y.definition(Y.variableName),color:`#00f`},{tag:Y.local(Y.variableName),color:`#30a`},{tag:[Y.typeName,Y.namespace],color:`#085`},{tag:Y.className,color:`#167`},{tag:[Y.special(Y.variableName),Y.macroName],color:`#256`},{tag:Y.definition(Y.propertyName),color:`#00c`},{tag:Y.comment,color:`#940`},{tag:Y.invalid,color:`#f00`}]),Td=W.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),Ed=1e4,Dd=`()[]{}`,Od=k.define({combine(e){return vt(e,{afterCursor:!0,brackets:Dd,maxScanDistance:Ed,renderMatch:jd})}}),kd=R.mark({class:`cm-matchingBracket`}),Ad=R.mark({class:`cm-nonmatchingBracket`});function jd(e){let t=[],n=e.matched?kd:Ad;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function Md(e){let t=[],n=e.facet(Od);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Rd(e,r.head,-1,n)||r.head>0&&Rd(e,r.head-1,1,n)||n.afterCursor&&(Rd(e,r.head,1,n)||r.head<e.doc.length&&Rd(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return R.set(t,!0)}var Nd=[V.fromClass(class{constructor(e){this.paused=!1,this.decorations=Md(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=Md(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),Td];function Pd(e={}){return[Od.of(e),Nd]}var Fd=new G;function Id(e,t,n){let r=e.prop(t<0?G.openedBy:G.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 Ld(e){let t=e.type.prop(Fd);return t?t(e.node):e}function Rd(e,t,n,r={}){let i=r.maxScanDistance||Ed,a=r.brackets||Dd,o=X(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=Id(r.type,n,a);if(i&&r.from<r.to){let o=Ld(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return zd(e,t,n,r,o,i,a)}}return Bd(e,t,n,o,s.type,i,a)}function zd(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=Ld(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(Id(u.type,n,o))l++;else if(Id(u.type,-n,o)){if(l==0){let e=Ld(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 Bd(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}var Vd=Object.create(null),Hd=[cl.none],Ud=[],Wd=Object.create(null),Gd=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`]])Gd[e]=qd(Vd,t);function Kd(e,t){Ud.indexOf(e)>-1||(Ud.push(e),console.warn(t))}function qd(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Y[n];r?typeof r==`function`?t.length?t=t.map(r):Kd(n,`Modifier ${n} used at start of tag`):t.length?Kd(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Kd(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=Wd[i];if(a)return a.id;let o=Wd[i]=cl.define({id:Hd.length,name:r,props:[Bl({[r]:n})]});return Hd.push(o),o.id}R.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`rtl`},bidiIsolate:z.RTL}),R.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`ltr`},bidiIsolate:z.LTR}),R.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`auto`},bidiIsolate:null});var Jd=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=$d(e.state,n.from);return r.line?Xd(e):r.block?Qd(e):!1};function Yd(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 Xd=Yd(af,0),Zd=Yd(rf,0),Qd=Yd((e,t)=>rf(e,t,nf(t)),0);function $d(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var ef=50;function tf(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-ef,r),o=e.sliceDoc(i,i+ef),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*ef?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+ef),d=e.sliceDoc(i-ef,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function nf(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function rf(e,t,n=t.selection.ranges){let r=n.map(e=>$d(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>tf(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function af(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=$d(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 of=nt.define(),sf=nt.define(),cf=k.define(),lf=k.define({combine(e){return vt(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)})}}),uf=Re.define({create(){return kf.empty},update(e,t){let n=t.state.facet(lf),r=t.annotation(of);if(r){let i=_f.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?vf(o,o.length,n.minDepth,i):wf(o,t.startState.selection),new kf(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(sf);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(at.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=_f.fromTransaction(t),o=t.annotation(at.time),s=t.annotation(at.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 kf(e.done.map(_f.fromJSON),e.undone.map(_f.fromJSON))}});function df(e={}){return[uf,lf.of(e),W.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?pf:e.inputType==`historyRedo`?mf:null;return n?(e.preventDefault(),n(t)):!1}})]}function ff(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(uf,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var pf=ff(0,!1),mf=ff(1,!1),hf=ff(0,!0),gf=ff(1,!0),_f=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&&Ce.fromJSON(t.changes),[],t.mapped&&Se.fromJSON(t.mapped),t.startSelection&&O.fromJSON(t.startSelection),t.selectionsAfter.map(O.fromJSON))}static fromTransaction(t,n){let r=Sf;for(let e of t.startState.facet(cf)){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,Sf)}static selection(t){return new e(void 0,Sf,void 0,void 0,t)}};function vf(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 yf(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 bf(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function xf(e,t){return e.length?t.length?e.concat(t):e:t}var Sf=[],Cf=200;function wf(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Cf));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),vf(e,e.length-1,1e9,n.setSelAfter(r)))}else return[_f.selection([t])]}function Tf(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 Ef(e,t){if(!e.length)return e;let n=e.length,r=Sf;for(;n;){let i=Df(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?[_f.selection(r)]:Sf}function Df(e,t,n){let r=xf(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Sf,n);if(!e.changes)return _f.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new _f(i,A.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Of=/^(input\.type|delete)($|\.)/,kf=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||Of.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,yf(s.changes,t.changes))||r==`input.type.compose`)?vf(o,o.length-1,i.minDepth,new _f(t.changes.compose(s.changes),xf(A.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,Sf)):vf(o,o.length,i.minDepth,t),new e(o,Sf,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:Sf;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&bf(a[a.length-1],t)?this:new e(wf(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ef(this.done,t),Ef(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:of.of({side:e,rest:Tf(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?Sf:r.slice(0,r.length-1);return i.mapped&&(n=Ef(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:of.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};kf.empty=new kf(Sf,Sf);var Af=[{key:`Mod-z`,run:pf,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:mf,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:mf,preventDefault:!0},{key:`Mod-u`,run:hf,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:gf,preventDefault:!0}];function jf(e,t){return O.create(e.ranges.map(t),e.mainIndex)}function Mf(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function Nf({state:e,dispatch:t},n){let r=jf(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Mf(e,r)),!0)}function Pf(e,t){return O.cursor(t?e.to:e.from)}function Ff(e,t){return Nf(e,n=>n.empty?e.moveByChar(n,t):Pf(n,t))}function Z(e){return e.textDirectionAt(e.state.selection.main.head)==z.LTR}var If=e=>Ff(e,!Z(e)),Lf=e=>Ff(e,Z(e));function Rf(e,t){return Nf(e,n=>n.empty?e.moveByGroup(n,t):Pf(n,t))}var zf=e=>Rf(e,!Z(e)),Bf=e=>Rf(e,Z(e));typeof Intl<`u`&&Intl.Segmenter&&new Intl.Segmenter(void 0,{granularity:`word`});function Vf(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Hf(e,t,n){let r=X(e).resolveInner(t.head),i=n?G.closedBy:G.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Vf(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?Rd(e,r.from,1):Rd(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,O.cursor(s,n?-1:1)}var Uf=e=>Nf(e,t=>Hf(e.state,t,!Z(e))),Wf=e=>Nf(e,t=>Hf(e.state,t,Z(e)));function Gf(e,t){return Nf(e,n=>{if(!n.empty)return Pf(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Kf=e=>Gf(e,!1),qf=e=>Gf(e,!0);function Jf(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(W.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Yf(e,t){let n=Jf(e),{state:r}=e,i=jf(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Pf(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=W.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(Mf(r,i),{effects:a}),!0}var Xf=e=>Yf(e,!1),Zf=e=>Yf(e,!0);function Qf(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=O.cursor(r.from+n))}return i}var $f=e=>Nf(e,t=>Qf(e,t,!0)),ep=e=>Nf(e,t=>Qf(e,t,!1)),tp=e=>Nf(e,t=>Qf(e,t,!Z(e))),np=e=>Nf(e,t=>Qf(e,t,Z(e))),rp=e=>Nf(e,t=>O.cursor(e.lineBlockAt(t.head).from,1)),ip=e=>Nf(e,t=>O.cursor(e.lineBlockAt(t.head).to,-1));function ap(e,t,n){let r=!1,i=jf(e.selection,t=>{let i=Rd(e,t.head,-1)||Rd(e,t.head,1)||t.head>0&&Rd(e,t.head-1,1)||t.head<e.doc.length&&Rd(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?O.range(t.anchor,a):O.cursor(a)});return r?(t(Mf(e,i)),!0):!1}var op=({state:e,dispatch:t})=>ap(e,t,!1);function sp(e,t){let n=jf(e.state.selection,e=>{let n=t(e);return O.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(Mf(e.state,n)),!0)}function cp(e,t){return sp(e,n=>e.moveByChar(n,t))}var lp=e=>cp(e,!Z(e)),up=e=>cp(e,Z(e));function dp(e,t){return sp(e,n=>e.moveByGroup(n,t))}var fp=e=>dp(e,!Z(e)),pp=e=>dp(e,Z(e)),mp=e=>sp(e,t=>Hf(e.state,t,!Z(e))),hp=e=>sp(e,t=>Hf(e.state,t,Z(e)));function gp(e,t){return sp(e,n=>e.moveVertically(n,t))}var _p=e=>gp(e,!1),vp=e=>gp(e,!0);function yp(e,t){return sp(e,n=>e.moveVertically(n,t,Jf(e).height))}var bp=e=>yp(e,!1),xp=e=>yp(e,!0),Sp=e=>sp(e,t=>Qf(e,t,!0)),Cp=e=>sp(e,t=>Qf(e,t,!1)),wp=e=>sp(e,t=>Qf(e,t,!Z(e))),Tp=e=>sp(e,t=>Qf(e,t,Z(e))),Ep=e=>sp(e,t=>O.cursor(e.lineBlockAt(t.head).from)),Dp=e=>sp(e,t=>O.cursor(e.lineBlockAt(t.head).to)),Op=({state:e,dispatch:t})=>(t(Mf(e,{anchor:0})),!0),kp=({state:e,dispatch:t})=>(t(Mf(e,{anchor:e.doc.length})),!0),Ap=({state:e,dispatch:t})=>(t(Mf(e,{anchor:e.selection.main.anchor,head:0})),!0),jp=({state:e,dispatch:t})=>(t(Mf(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Mp=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Np=({state:e,dispatch:t})=>{let n=Qp(e).map(({from:t,to:n})=>O.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:O.create(n),userEvent:`select`})),!0},Pp=({state:e,dispatch:t})=>{let n=jf(e.selection,t=>{let n=X(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return O.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(Mf(e,n)),!0)};function Fp(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(Mf(n,O.create(i,i.length-1))),!0)}var Ip=e=>Fp(e,!1),Lp=e=>Fp(e,!0),Rp=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=O.create([n.main]):n.main.empty||(r=O.create([O.cursor(n.main.head)])),r?(t(Mf(e,r)),!0):!1};function zp(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Bp(e,o,!1)):o>i&&(n=`delete.forward`,o=Bp(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Bp(e,i,!1),a=Bp(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:O.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?W.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Bp(e,t,n){if(e instanceof W)for(let r of e.state.facet(W.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Vp=(e,t,n)=>zp(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=It(s,a.tabSize)%Eu(a)||Eu(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=E(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=E(o.text,c-o.from,!1,!1)+o.from);return c}),Hp=e=>Vp(e,!1,!0),Up=e=>Vp(e,!0,!1),Wp=(e,t)=>zp(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=E(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Gp=e=>Wp(e,!1),Kp=e=>Wp(e,!0),qp=e=>zp(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Jp=e=>zp(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Yp=e=>zp(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Xp=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:w.of([``,``])},range:O.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Zp=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:E(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:E(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:O.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Qp(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function $p(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Qp(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(O.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(O.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:O.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var em=({state:e,dispatch:t})=>$p(e,t,!1),tm=({state:e,dispatch:t})=>$p(e,t,!0);function nm(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Qp(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var rm=({state:e,dispatch:t})=>nm(e,t,!1),im=({state:e,dispatch:t})=>nm(e,t,!0),am=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Qp(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=jf(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function om(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=X(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(G.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 sm=lm(!1),cm=lm(!0);function lm(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&&om(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new ku(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Ou(s,r);for(c??=It(/^\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=[``,Du(t,c)];return o&&l.push(Du(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:w.of(l)},range:O.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function um(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:O.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var dm=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new ku(e,{overrideIndentation:e=>n[e]??-1}),i=um(e,(t,i,a)=>{let o=Ou(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Du(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},fm=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(um(e,(t,n)=>{n.push({from:t.from,insert:e.facet(Tu)})}),{userEvent:`input.indent`})),!0),pm=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(um(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=It(r,e.tabSize),a=0,o=Du(e,Math.max(0,i-Eu(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),mm=e=>(e.setTabFocusMode(),!0),hm=[{key:`Ctrl-b`,run:If,shift:lp,preventDefault:!0},{key:`Ctrl-f`,run:Lf,shift:up},{key:`Ctrl-p`,run:Kf,shift:_p},{key:`Ctrl-n`,run:qf,shift:vp},{key:`Ctrl-a`,run:rp,shift:Ep},{key:`Ctrl-e`,run:ip,shift:Dp},{key:`Ctrl-d`,run:Up},{key:`Ctrl-h`,run:Hp},{key:`Ctrl-k`,run:qp},{key:`Ctrl-Alt-h`,run:Gp},{key:`Ctrl-o`,run:Xp},{key:`Ctrl-t`,run:Zp},{key:`Ctrl-v`,run:Zf}],gm=[{key:`ArrowLeft`,run:If,shift:lp,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:zf,shift:fp,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:tp,shift:wp,preventDefault:!0},{key:`ArrowRight`,run:Lf,shift:up,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Bf,shift:pp,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:np,shift:Tp,preventDefault:!0},{key:`ArrowUp`,run:Kf,shift:_p,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Op,shift:Ap},{mac:`Ctrl-ArrowUp`,run:Xf,shift:bp},{key:`ArrowDown`,run:qf,shift:vp,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:kp,shift:jp},{mac:`Ctrl-ArrowDown`,run:Zf,shift:xp},{key:`PageUp`,run:Xf,shift:bp},{key:`PageDown`,run:Zf,shift:xp},{key:`Home`,run:ep,shift:Cp,preventDefault:!0},{key:`Mod-Home`,run:Op,shift:Ap},{key:`End`,run:$f,shift:Sp,preventDefault:!0},{key:`Mod-End`,run:kp,shift:jp},{key:`Enter`,run:sm,shift:sm},{key:`Mod-a`,run:Mp},{key:`Backspace`,run:Hp,shift:Hp,preventDefault:!0},{key:`Delete`,run:Up,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Gp,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Kp,preventDefault:!0},{mac:`Mod-Backspace`,run:Jp,preventDefault:!0},{mac:`Mod-Delete`,run:Yp,preventDefault:!0}].concat(hm.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),_m=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Uf,shift:mp},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Wf,shift:hp},{key:`Alt-ArrowUp`,run:em},{key:`Shift-Alt-ArrowUp`,run:rm},{key:`Alt-ArrowDown`,run:tm},{key:`Shift-Alt-ArrowDown`,run:im},{key:`Mod-Alt-ArrowUp`,run:Ip},{key:`Mod-Alt-ArrowDown`,run:Lp},{key:`Escape`,run:Rp},{key:`Mod-Enter`,run:cm},{key:`Alt-l`,mac:`Ctrl-l`,run:Np},{key:`Mod-i`,run:Pp,preventDefault:!0},{key:`Mod-[`,run:pm},{key:`Mod-]`,run:fm},{key:`Mod-Alt-\\`,run:dm},{key:`Shift-Mod-k`,run:am},{key:`Shift-Mod-\\`,run:op},{key:`Mod-/`,run:Jd},{key:`Alt-A`,run:Zd},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:mm}].concat(gm),vm={key:`Tab`,run:fm,shift:pm},ym=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,bm=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(ym(e)):ym,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 _e(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=ve(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ye(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`&&(bm.prototype[Symbol.iterator]=function(){return this});var xm={from:-1,to:-1,match:/.*/.exec(``)},Sm=`gm`+(/x/.unicode==null?``:`u`),Cm=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=xm,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Em(e,t,n,r,i);this.re=new RegExp(t,Sm+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=Om(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=Om(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}}},wm=new WeakMap,Tm=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=wm.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return wm.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)),wm.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Em=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=xm,this.matchPos=Om(e,r),this.re=new RegExp(t,Sm+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Tm.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=Om(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Tm.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Cm.prototype[Symbol.iterator]=Em.prototype[Symbol.iterator]=function(){return this});function Dm(e){try{return new RegExp(e,Sm),!0}catch{return!1}}function Om(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 km=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=Ec(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=O.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,W.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Am={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},jm=k.define({combine(e){return vt(e,Am,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Mm(e){let t=[Rm,Lm];return e&&t.push(jm.of(e)),t}var Nm=R.mark({class:`cm-selectionMatch`}),Pm=R.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Fm(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=j.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=j.Word)}function Im(e,t,n,r){return e(t.sliceDoc(n,n+1))==j.Word&&e(t.sliceDoc(r-1,r))==j.Word}var Lm=V.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(jm),{state:n}=e,r=n.selection;if(r.ranges.length>1)return R.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return R.none;let e=n.wordAt(i.head);if(!e)return R.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return R.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Fm(o,n,i.from,i.to)&&Im(o,n,i.from,i.to)))return R.none}else if(a=n.sliceDoc(i.from,i.to),!a)return R.none}let s=[];for(let r of e.visibleRanges){let e=new bm(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Fm(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Pm.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Nm.range(r,a)),s.length>t.maxMatches))return R.none}}return R.set(s)}},{decorations:e=>e.decorations}),Rm=W.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),zm=({state:e,dispatch:t})=>{let{selection:n}=e,r=O.create(n.ranges.map(t=>e.wordAt(t.head)||O.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Bm(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new bm(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new bm(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Vm=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return zm({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Bm(e,r);return i?(t(e.update({selection:e.selection.addRange(O.range(i.from,i.to),!1),effects:W.scrollIntoView(i.to)})),!0):!1},Hm=k.define({combine(e){return vt(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Sh(e),scrollToMatch:e=>W.scrollIntoView(e)})}}),Um=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||Dm(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`?`
|
|
12
12
|
`: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 eh(this):new Jm(this)}getCursor(e,t=0,n){let r=e.doc?e:M.create({doc:e});return n??=r.doc.length,this.regexp?Xm(this,r,t,n):Km(this,r,t,n)}},Wm=class{constructor(e){this.spec=e}};function Gm(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 Km(e,t,n,r){let i;return e.wholeWord&&(i=qm(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Gm(e.test,t,i)),new bm(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function qm(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(Zm(i,n-a))!=j.Word||t(Qm(i,n-a))!=j.Word)&&(t(Qm(i,r-a))!=j.Word||t(Zm(i,r-a))!=j.Word))}var Jm=class extends Wm{constructor(e){super(e)}nextMatch(e,t,n){let r=Km(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=Km(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=Km(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=Km(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=Km(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 Ym(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function Xm(e,t,n,r){let i;return e.wholeWord&&(i=$m(t.charCategorizer(t.selection.main.head))),e.test&&(i=Ym(e.test,t,i)),new Cm(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Zm(e,t){return e.slice(E(e,t,!1),t)}function Qm(e,t){return e.slice(t,E(e,t))}function $m(e){return(t,n,r)=>!r[0].length||(e(Zm(r.input,r.index))!=j.Word||e(Qm(r.input,r.index))!=j.Word)&&(e(Qm(r.input,r.index+r[0].length))!=j.Word||e(Zm(r.input,r.index+r[0].length))!=j.Word)}var eh=class extends Wm{nextMatch(e,t,n){let r=Xm(this.spec,e,n,e.doc.length).next();return r.done&&(r=Xm(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=Xm(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=Xm(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=Xm(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)}},th=A.define(),nh=A.define(),rh=Re.define({create(e){return new ih(gh(e).create(),null)},update(e,t){for(let n of t.effects)n.is(th)?e=new ih(n.value.create(),e.panel):n.is(nh)&&(e=new ih(e.query,n.value?hh:null));return e},provide:e=>Tc.from(e,e=>e.panel)}),ih=class{constructor(e,t){this.query=e,this.panel=t}},ah=R.mark({class:`cm-searchMatch`}),oh=R.mark({class:`cm-searchMatch cm-searchMatch-selected`}),sh=V.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(rh))}update(e){let t=e.state.field(rh);(t!=e.startState.field(rh)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return R.none;let{view:n}=this,r=new Tt;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?oh:ah)})}return r.finish()}},{decorations:e=>e.decorations});function ch(e){return t=>{let n=t.state.field(rh,!1);return n&&n.query.spec.valid?e(t,n):yh(t)}}var lh=ch((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=O.single(r.from,r.to),a=e.state.facet(Hm);return e.dispatch({selection:i,effects:[Eh(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),vh(e),!0}),uh=ch((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=O.single(i.from,i.to),o=e.state.facet(Hm);return e.dispatch({selection:a,effects:[Eh(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),vh(e),!0}),dh=ch((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:O.create(n.map(e=>O.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),fh=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new bm(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(O.range(t.value.from,t.value.to))}return t(e.update({selection:O.create(a,o),userEvent:`select.search.matches`})),!0},ph=ch((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(W.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=O.single(o.from,o.to).map(d),u.push(Eh(e,o)),u.push(n.facet(Hm).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),mh=ch((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:W.announce.of(r),userEvent:`input.replace.all`}),!0});function hh(e){return e.state.facet(Hm).createPanel(e)}function gh(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(Hm);return new Um({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function _h(e){let t=xc(e,hh);return t&&t.dom.querySelector(`[main-field]`)}function vh(e){let t=_h(e);t&&t==e.root.activeElement&&t.select()}var yh=e=>{let t=e.state.field(rh,!1);if(t&&t.panel){let n=_h(e);if(n&&n!=e.root.activeElement){let r=gh(e.state,t.query.spec);r.valid&&e.dispatch({effects:th.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[nh.of(!0),t?th.of(gh(e.state,t.query.spec)):A.appendConfig.of(Oh)]});return!0},bh=e=>{let t=e.state.field(rh,!1);if(!t||!t.panel)return!1;let n=xc(e,hh);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:nh.of(!1)}),!0},xh=[{key:`Mod-f`,run:yh,scope:`editor search-panel`},{key:`F3`,run:lh,shift:uh,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:lh,shift:uh,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:bh,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:fh},{key:`Mod-Alt-g`,run:km},{key:`Mod-d`,run:Vm,preventDefault:!0}],Sh=class{constructor(e){this.view=e;let t=this.query=e.state.field(rh).query.spec;this.commit=this.commit.bind(this),this.searchField=P(`input`,{value:t.search,placeholder:Ch(e,`Find`),"aria-label":Ch(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=P(`input`,{value:t.replace,placeholder:Ch(e,`Replace`),"aria-label":Ch(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=P(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=P(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=P(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return P(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=P(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>lh(e),[Ch(e,`next`)]),n(`prev`,()=>uh(e),[Ch(e,`previous`)]),n(`select`,()=>dh(e),[Ch(e,`all`)]),P(`label`,null,[this.caseField,Ch(e,`match case`)]),P(`label`,null,[this.reField,Ch(e,`regexp`)]),P(`label`,null,[this.wordField,Ch(e,`by word`)]),...e.state.readOnly?[]:[P(`br`),this.replaceField,n(`replace`,()=>ph(e),[Ch(e,`replace`)]),n(`replaceAll`,()=>mh(e),[Ch(e,`replace all`)])],P(`button`,{name:`close`,onclick:()=>bh(e),"aria-label":Ch(e,`close`),type:`button`},[`×`])])}commit(){let e=new Um({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:th.of(e)}))}keydown(e){$o(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?uh:lh)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ph(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(th)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Hm).top}};function Ch(e,t){return e.state.phrase(t)}var wh=30,Th=/[\s\.,:;?!]/;function Eh(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-wh),o=Math.min(i,n+wh),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<wh;e++)if(!Th.test(s[e+1])&&Th.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-wh;e--)if(!Th.test(s[e-1])&&Th.test(s[e])){s=s.slice(0,e);break}}return W.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Dh=W.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Oh=[rh,Ve.low(sh),Dh],kh=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=X(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(Ih(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function Ah(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 jh(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=Ah(t)+Ah(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function Mh(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:jh(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Nh(e,t){return n=>{for(let t=X(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)}}var Ph=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Fh(e){return e.selection.main.from}function Ih(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var Lh=nt.define();function Rh(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:O.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var zh=new WeakMap;function Bh(e){if(!Array.isArray(e))return e;let t=zh.get(e);return t||zh.set(e,t=Mh(e)),t}var Vh=A.define(),Hh=A.define(),Uh=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=_e(e,t),r=ye(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(_e(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=_e(e,0),i=ye(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=_e(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=ye(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=_e(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:c>=65&&c<=90?1:0:(v=ve(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=ye(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?ye(_e(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},Wh=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},Q=k.define({combine(e){return vt(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Kh,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Gh(e(n),t(n)),optionClass:(e,t)=>n=>Gh(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Gh(e,t){return e?t?e+` `+t:e:t}function Kh(e,t,n,r,i,a){let o=e.textDirection==z.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var qh=A.define();function Jh(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function Yh(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}var Xh=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(Q);this.optionContent=Jh(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Yh(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:qh.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(Q).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Hh.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=Yh(r.length,i,e.state.facet(Q).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Yh(t.options.length,t.selected,this.view.state.facet(Q).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>Mr(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Qh(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(Q).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function Zh(e,t){return n=>new Xh(n,e,t)}function Qh(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function $h(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function eg(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(Q);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Ph(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Wh(n):new Uh(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Ph(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):$h(e.completion)>$h(c)&&(s[s.length-1]=e),c=e.completion}return s}var tg=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,og(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=eg(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(Q).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,og(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:hg,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},ng=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(sg,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Q),i=(r.override||n.languageDataAt(`autocomplete`,Fh(n)).map(Bh)).map(e=>(this.active.find(t=>t.source==e)||new lg(e,this.active.some(e=>e.state!=0)?1:0)).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(fg));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!rg(i,this.active)||o?a=tg.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new lg(e.source,0):e));for(let e of t.effects)e.is(qh)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ig:ag}};function rg(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var ig={"aria-autocomplete":`list`},ag={};function og(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var sg=[];function cg(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(Lh);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var lg=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=cg(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(Vh))i=new e(i.source,1,n.value);else if(n.is(Hh))i=new e(i.source,0);else if(n.is(fg))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Fh(e.state))}},ug=class e extends lg{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Fh(t.state);if(o>a||!r||n&2&&(Fh(t.startState)==this.from||o<this.limit))return new lg(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return dg(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new kh(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??Fh(t.state)):new lg(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new lg(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function dg(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):Ih(e,!0).test(i)}var fg=A.define({map(e,t){return e.map(e=>e.map(t))}}),pg=Re.define({create(){return ng.start()},update(e,t){return e.update(t)},provide:e=>[lc.from(e,e=>e.tooltip),W.contentAttributes.from(e,e=>e.attrs)]});function mg(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(pg).active.find(e=>e.source==t.source);return r instanceof ug?(typeof n==`string`?e.dispatch({...Rh(e.state,n,r.from,r.to),annotations:Lh.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var hg=Zh(pg,mg);function gg(e,t=`option`){return n=>{let r=n.state.field(pg,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Q).interactionDelay)return!1;let i=1,a;t==`page`&&(a=vc(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:qh.of(s)}),!0}}var _g=e=>{let t=e.state.field(pg,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Q).interactionDelay?!1:mg(e,t.open.options[t.open.selected])},vg=e=>e.state.field(pg,!1)?(e.dispatch({effects:Vh.of(!0)}),!0):!1,yg=e=>{let t=e.state.field(pg,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:Hh.of(null)}),!0)},bg=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},xg=50,Sg=1e3,Cg=V.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(pg).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(pg),n=e.state.facet(Q);if(!e.selectionSet&&!e.docChanged&&e.startState.field(pg)==t)return;let r=e.transactions.some(e=>{let t=cg(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>xg&&Date.now()-n.time>Sg){for(let e of n.context.abortListeners)try{e()}catch(e){Mr(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(Vh)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(pg);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Q).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new kh(t,Fh(t),e.explicit,this.view),r=new bg(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Hh.of(null)}),Mr(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Q).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Q),n=this.view.state.field(pg);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=Fh(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+(i.active.explicit?0:1)),a=new ug(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new lg(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:fg.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(pg,!1);if(t&&t.tooltip&&this.view.state.facet(Q).closeOnBlur){let n=t.open&&vc(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Hh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Vh.of(!1)}),20),this.composing=0}}}),wg=typeof navigator==`object`&&/Win/.test(navigator.platform),Tg=Ve.highest(W.domEventHandlers({keydown(e,t){let n=t.state.field(pg,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(wg&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&mg(t,r),!1}})),Eg=W.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Dg={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},Og=A.define({map(e,t){return t.mapPos(e,-1,xe.TrackAfter)??void 0}}),kg=new class extends yt{};kg.startSide=1,kg.endSide=-1;var Ag=Re.define({create(){return N.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(Og)&&(e=e.update({add:[kg.range(n.value,n.value+1)]}));return e}});function jg(){return[Ig,Ag]}var Mg=`()[]{}<>«»»«[]{}`;function Ng(e){for(let t=0;t<16;t+=2)if(Mg.charCodeAt(t)==e)return Mg.charAt(t+1);return ve(e<128?e:e+1)}function Pg(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||Dg}var Fg=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),Ig=W.inputHandler.of((e,t,n,r)=>{if((Fg?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&ye(_e(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Rg(e.state,r);return a?(e.dispatch(a),!0):!1}),Lg=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Pg(e,e.selection.main.head).brackets||Dg.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=Vg(e.doc,t.head);for(let i of n)if(i==r&&Bg(e.doc,t.head)==Ng(_e(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:O.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function Rg(e,t){let n=Pg(e,e.selection.main.head),r=n.brackets||Dg.brackets;for(let i of r){let a=Ng(_e(i,0));if(t==i)return a==i?Wg(e,i,r.indexOf(i+i+i)>-1,n):Hg(e,i,a,n.before||Dg.before);if(t==a&&zg(e,e.selection.main.from))return Ug(e,i,a)}return null}function zg(e,t){let n=!1;return e.field(Ag).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function Bg(e,t){let n=e.sliceString(t,t+2);return n.slice(0,ye(_e(n,0)))}function Vg(e,t){let n=e.sliceString(t-2,t);return ye(_e(n,0))==n.length?n:n.slice(1)}function Hg(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:Og.of(a.to+t.length),range:O.range(a.anchor+t.length,a.head+t.length)};let o=Bg(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:Og.of(a.head+t.length),range:O.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function Ug(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&Bg(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:O.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function Wg(e,t,n,r){let i=r.stringPrefixes||Dg.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:Og.of(r.to+t.length),range:O.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=Bg(e.doc,o),c;if(s==t){if(Gg(e,o))return{changes:{insert:t+t,from:o},effects:Og.of(o+t.length),range:O.cursor(o+t.length)};if(zg(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:O.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=qg(e,o-2*t.length,i))>-1&&Gg(e,c))return{changes:{insert:t+t+t+t,from:o},effects:Og.of(o+t.length),range:O.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=j.Word&&qg(e,o,i)>-1&&!Kg(e,o,t,i))return{changes:{insert:t+t,from:o},effects:Og.of(o+t.length),range:O.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function Gg(e,t){let n=X(e).resolveInner(t+1);return n.parent&&n.from==t}function Kg(e,t,n,r){let i=X(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function qg(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=j.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=j.Word)return n}return-1}function Jg(e={}){return[Tg,pg,Q.of(e),Cg,Xg,Eg]}var Yg=[{key:`Ctrl-Space`,run:vg},{mac:"Alt-`",run:vg},{mac:`Alt-i`,run:vg},{key:`Escape`,run:yg},{key:`ArrowDown`,run:gg(!0)},{key:`ArrowUp`,run:gg(!1)},{key:`PageDown`,run:gg(!0,`page`)},{key:`PageUp`,run:gg(!1,`page`)},{key:`Enter`,run:_g}],Xg=Ve.highest(Xo.computeN([Q],e=>e.facet(Q).defaultKeymap?[Yg]:[])),Zg=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Qg=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(f_).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Tt,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=C_(s);if(i)o.add(n,n,R.widget({widget:new g_(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,R.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,$g(f))}};function $g(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Zg(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Zg(r.from,n,r.diagnostic)}),r}function e_(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(f_).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(n_))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function t_(e,t){return e.field(a_,!1)?t:t.concat(A.appendConfig.of(w_))}var n_=A.define(),r_=A.define(),i_=A.define(),a_=Re.define({create(){return new Qg(R.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=$g(n,e.selected.diagnostic,i)||$g(n,null,i)}!n.size&&i&&t.state.facet(f_).autoPanel&&(i=null),e=new Qg(n,i,r)}for(let n of t.effects)if(n.is(n_)){let r=t.state.facet(f_).autoPanel?n.value.length?v_.open:null:e.panel;e=Qg.init(n.value,r,t.state)}else n.is(r_)?e=new Qg(e.diagnostics,n.value?v_.open:null,e.selected):n.is(i_)&&(e=new Qg(e.diagnostics,e.panel,n.value));return e},provide:e=>[Tc.from(e,e=>e.panel),W.decorations.from(e,e=>e.diagnostics)]}),o_=R.mark({class:`cm-lintRange cm-lintRange-active`});function s_(e,t,n){let{diagnostics:r}=e.state.field(a_),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(f_).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:c_(e,i)}}}:null}function c_(e,t){return P(`ul`,{class:`cm-tooltip-lint`},t.map(t=>h_(e,t,!1)))}var l_=e=>{let t=e.state.field(a_,!1);(!t||!t.panel)&&e.dispatch({effects:t_(e.state,[r_.of(!0)])});let n=xc(e,v_.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},u_=e=>{let t=e.state.field(a_,!1);return!t||!t.panel?!1:(e.dispatch({effects:r_.of(!1)}),!0)},d_=[{key:`Mod-Shift-m`,run:l_,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(a_,!1);if(!t)return!1;let n=e.state.selection.main,r=$g(t.diagnostics,null,n.to+1);return!r&&(r=$g(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],f_=k.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...vt(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:p_,tooltipFilter:p_,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function p_(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function m_(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function h_(e,t,n){let r=n?m_(t.actions):[];return P(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},P(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=$g(e.state.field(a_).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),P(`u`,s.slice(c,c+1)),s.slice(c+1)];return P(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&P(`div`,{class:`cm-diagnosticSource`},t.source))}var g_=class extends gn{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return P(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},__=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=h_(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},v_=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)u_(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=m_(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=$g(this.view.state.field(a_).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=P(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=P(`div`,{class:`cm-panel-lint`},this.list,P(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>u_(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(a_).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(a_),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new __(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new __(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=$g(this.view.state.field(a_).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:i_.of(t)})}static open(t){return new e(t)}};function y_(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function b_(e){return y_(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var x_=W.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:b_(`#d11`)},".cm-lintRange-warning":{backgroundImage:b_(`orange`)},".cm-lintRange-info":{backgroundImage:b_(`#999`)},".cm-lintRange-hint":{backgroundImage:b_(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function S_(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function C_(e){let t=`hint`,n=1;for(let r of e){let e=S_(r.severity);e>n&&(n=e,t=r.severity)}return t}var w_=[a_,W.decorations.compute([a_],e=>{let{selected:t,panel:n}=e.field(a_);return!t||!n||t.from==t.to?R.none:R.set([o_.range(t.from,t.to)])}),_c(s_,{hideOn:e_}),x_],T_=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(Lg)),e.defaultKeymap!==!1&&(n=n.concat(_m)),e.searchKeymap!==!1&&(n=n.concat(xh)),e.historyKeymap!==!1&&(n=n.concat(Af)),e.foldKeymap!==!1&&(n=n.concat(od)),e.completionKeymap!==!1&&(n=n.concat(Yg)),e.lintKeymap!==!1&&(n=n.concat(d_));var r=[];return e.lineNumbers!==!1&&r.push(Qc()),e.highlightActiveLineGutter!==!1&&r.push(nl()),e.highlightSpecialChars!==!1&&r.push(Ns()),e.history!==!1&&r.push(df()),e.foldGutter!==!1&&r.push(hd()),e.drawSelection!==!1&&r.push(ms()),e.dropCursor!==!1&&r.push(Cs()),e.allowMultipleSelections!==!1&&r.push(M.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(Hu()),e.syntaxHighlighting!==!1&&r.push(xd(wd,{fallback:!0})),e.bracketMatching!==!1&&r.push(Pd()),e.closeBrackets!==!1&&r.push(jg()),e.autocompletion!==!1&&r.push(Jg()),e.rectangularSelection!==!1&&r.push(Xs()),t!==!1&&r.push($s()),e.highlightActiveLine!==!1&&r.push(Bs()),e.highlightSelectionMatches!==!1&&r.push(Mm()),e.tabSize&&typeof e.tabSize==`number`&&r.push(Tu.of(` `.repeat(e.tabSize))),r.concat([Xo.of(n.flat())]).filter(Boolean)},E_=`#e5c07b`,D_=`#e06c75`,O_=`#56b6c2`,k_=`#ffffff`,A_=`#abb2bf`,j_=`#7d8799`,M_=`#61afef`,N_=`#98c379`,P_=`#d19a66`,F_=`#c678dd`,I_=`#21252b`,L_=`#2c313a`,R_=`#282c34`,z_=`#353a42`,B_=`#3E4451`,V_=`#528bff`,H_=[W.theme({"&":{color:A_,backgroundColor:R_},".cm-content":{caretColor:V_},".cm-cursor, .cm-dropCursor":{borderLeftColor:V_},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:B_},".cm-panels":{backgroundColor:I_,color:A_},".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:R_,color:j_,border:`none`},".cm-activeLineGutter":{backgroundColor:L_},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:z_},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:z_,borderBottomColor:z_},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:L_,color:A_}}},{dark:!0}),xd(_d.define([{tag:Y.keyword,color:F_},{tag:[Y.name,Y.deleted,Y.character,Y.propertyName,Y.macroName],color:D_},{tag:[Y.function(Y.variableName),Y.labelName],color:M_},{tag:[Y.color,Y.constant(Y.name),Y.standard(Y.name)],color:P_},{tag:[Y.definition(Y.name),Y.separator],color:A_},{tag:[Y.typeName,Y.className,Y.number,Y.changed,Y.annotation,Y.modifier,Y.self,Y.namespace],color:E_},{tag:[Y.operator,Y.operatorKeyword,Y.url,Y.escape,Y.regexp,Y.link,Y.special(Y.string)],color:O_},{tag:[Y.meta,Y.comment],color:j_},{tag:Y.strong,fontWeight:`bold`},{tag:Y.emphasis,fontStyle:`italic`},{tag:Y.strikethrough,textDecoration:`line-through`},{tag:Y.link,color:j_,textDecoration:`underline`},{tag:Y.heading,fontWeight:`bold`,color:D_},{tag:[Y.atom,Y.bool,Y.special(Y.variableName)],color:P_},{tag:[Y.processingInstruction,Y.string,Y.inserted],color:N_},{tag:Y.invalid,color:k_}]))],U_=W.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),W_=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(Xo.of([vm])),o&&(typeof o==`boolean`?s.unshift(T_()):s.unshift(T_(o))),a&&s.unshift(Ws(a)),i){case`light`:s.push(U_);break;case`dark`:s.push(H_);break;case`none`:break;default:s.push(i);break}return n===!1&&s.push(W.editable.of(!1)),r&&s.push(M.readOnly.of(!0)),[...s]},G_=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),K_=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},q_=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},J_=null,Y_=()=>typeof window>`u`?new q_:(J_||=new q_,J_),X_=nt.define(),Z_=200,Q_=[];function $_(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:o,extensions:s=Q_,autoFocus:c,theme:l=`light`,height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:_=``,editable:v=!0,readOnly:y=!1,indentWithTab:ee=!0,basicSetup:b=!0,root:x,initialState:te}=e,[ne,re]=(0,h.useState)(),[S,ie]=(0,h.useState)(),[ae,C]=(0,h.useState)(),w=(0,h.useState)(()=>({current:null}))[0],T=(0,h.useState)(()=>({current:null}))[0],oe=W.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:`100% !important`}}),se=[W.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(X_))&&(w.current?w.current.reset():(w.current=new K_(()=>{if(T.current){var e=T.current;T.current=null,e()}w.current=null},Z_),Y_().add(w.current)),r(e.state.doc.toString(),e)),i&&i(G_(e))}),oe,...W_({theme:l,editable:v,readOnly:y,placeholder:_,indentWithTab:ee,basicSetup:b})];return o&&typeof o==`function`&&se.push(W.updateListener.of(o)),se=se.concat(s),(0,h.useLayoutEffect)(()=>{if(ne&&!ae){var e={doc:t,selection:n,extensions:se},r=te?M.fromJSON(te.json,e,te.fields):M.create(e);if(C(r),!S){var i=new W({state:r,parent:ne,root:x});ie(i),a&&a(i,r)}}return()=>{S&&(C(void 0),ie(void 0))}},[ne,ae]),(0,h.useEffect)(()=>{e.container&&re(e.container)},[e.container]),(0,h.useEffect)(()=>()=>{S&&(S.destroy(),ie(void 0)),w.current&&=(w.current.cancel(),null)},[S]),(0,h.useEffect)(()=>{c&&S&&S.focus()},[c,S]),(0,h.useEffect)(()=>{S&&S.dispatch({effects:A.reconfigure.of(se)})},[l,s,u,d,f,p,m,g,_,v,y,ee,b,r,o]),(0,h.useEffect)(()=>{if(t!==void 0){var e=S?S.state.doc.toString():``;if(S&&t!==e){var n=w.current&&!w.current.isDone,r=()=>{S&&t!==S.state.doc.toString()&&S.dispatch({changes:{from:0,to:S.state.doc.toString().length,insert:t||``},annotations:[X_.of(!0)]})};n?T.current=r:r()}}},[t,S]),{state:ae,setState:C,view:S,setView:ie,container:ne,setContainer:re}}var $=i(),ev=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],tv=(0,h.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:v,minWidth:y,maxWidth:ee,basicSetup:b,placeholder:x,indentWithTab:te,editable:ne,readOnly:re,root:S,initialState:ie}=e,ae=_(e,ev),C=(0,h.useRef)(null),{state:w,view:T,container:oe,setContainer:se}=$_({root:S,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:v,minWidth:y,maxWidth:ee,basicSetup:b,placeholder:x,indentWithTab:te,editable:ne,readOnly:re,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:ie});(0,h.useImperativeHandle)(t,()=>({editor:C.current,state:w,view:T}),[C,oe,w,T]);var ce=(0,h.useCallback)(e=>{C.current=e,se(e)},[se]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);return(0,$.jsx)(`div`,g({ref:ce,className:(typeof d==`string`?`cm-theme-`+d:`cm-theme`)+(n?` `+n:``)},ae))});tv.displayName=`CodeMirror`;var nv=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 rv(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 iv(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 rv(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()}},rv=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},iv=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)}},av=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 ov(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 sv=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},cv=new sv,lv=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=cv,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=cv,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}},uv=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;pv(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};uv.prototype.contextual=uv.prototype.fallback=uv.prototype.extend=!1;var dv=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?ov(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(pv(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))}};dv.prototype.contextual=uv.prototype.fallback=uv.prototype.extend=!1;var fv=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function pv(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||hv(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 mv(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function hv(e,t,n,r){let i=mv(n,r,t);return i<0||mv(n,r,e)<i}var gv=typeof process<`u`&&/\bparse\b/.test({}.LOG),_v=null;function vv(e,t,n){let r=e.cursor(K.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 yv=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?vv(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?vv(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 q){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(G.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}}},bv=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new sv)}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 sv,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 sv,{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=Tv(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(Tv(o,s+2),t,n,r));break}o[s]==t&&(r=this.putAction(Tv(o,s+1),t,n,r))}return r}},xv=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 lv(t,r),this.tokens=new bv(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[nv.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new yv(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&&Ev(r);if(e)return gv&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw gv&&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 gv&&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=gv?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(G.contextHash)||0)==n))return e.useNode(o,r),gv&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof q)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof q&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),gv&&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),gv&&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 Sv(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=gv?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),gv&&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()&&(gv&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)gv&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))gv&&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),gv&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),Sv(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),q.build({buffer:av.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=(_v||=new WeakMap).get(e);return t||_v.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Sv(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 Cv=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},wv=class e extends Ml{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=G[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 ll(t.map((t,i)=>cl.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=rl;let a=ov(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(Dv),this.states=ov(e.states,Uint32Array),this.data=ov(e.stateData),this.goto=ov(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new uv(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 xv(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=Tv(n,i+2)];else if(n[i+1]==2)return Tv(n,i+2);else break;if(a==t||a==0)return Tv(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=Tv(this.data,n+2);else break;r=t(Tv(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=Tv(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]=Dv(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 Cv(e,n,r)}static deserialize(t){return new e(t)}};function Tv(e,t){return e[t]|e[t+1]<<16}function Ev(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 Dv(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}var Ov=36,kv=1,Av=2,jv=3,Mv=4,Nv=5,Pv=6,Fv=7,Iv=8,Lv=9,Rv=10,zv=11,Bv=12,Vv=13,Hv=14,Uv=15,Wv=16,Gv=17,Kv=18,qv=19,Jv=20,Yv=21,Xv=22,Zv=23,Qv=24;function $v(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function ey(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function ty(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 ny(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 ry(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 iy(e,t){for(;!(e.next!=95&&!$v(e.next));)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function ay(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),ty(e,t,!1)}else iy(e)}function oy(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function sy(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 cy(e){for(;!(e.next<0||e.next==10);)e.advance()}function ly(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var uy=` \r
|
|
13
|
-
`;function dy(e,t,n){let r=Object.create(null);r.true=r.false=Nv,r.null=r.unknown=Pv;for(let t of e.split(` `))t&&(r[t]=Jv);for(let e of t.split(` `))e&&(r[e]=Yv);for(let e of(n||``).split(` `))e&&(r[e]=Qv);return r}var fy=`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 `,py=`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 `,my={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:dy(py,fy)};function hy(e,t,n,r){let i={};for(let t in my)i[t]=(e.hasOwnProperty(t)?e:my)[t];return t&&(i.words=dy(t,n||``,r)),i}function gy(e){return new fv(t=>{let{next:n}=t;if(t.advance(),ly(n,uy)){for(;ly(t.next,uy);)t.advance();t.acceptToken(Ov)}else if(n==36&&e.doubleDollarQuotedStrings){let e=iy(t,``);t.next==36&&(t.advance(),ny(t,e),t.acceptToken(jv))}else if(n==39||n==34&&e.doubleQuotedStrings)ty(t,n,e.backslashEscapes),t.acceptToken(jv);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)cy(t),t.acceptToken(kv);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))cy(t),t.acceptToken(kv);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(Av)}else if((n==101||n==69)&&t.next==39)t.advance(),ty(t,39,!0),t.acceptToken(jv);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),ty(t,39,e.backslashEscapes),t.acceptToken(jv);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),ty(t,39,e.backslashEscapes),t.acceptToken(jv);break}if(!$v(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!ly(t.peek(1),uy)){let e=t.peek(1);t.advance(2),ry(t,e),t.acceptToken(jv)}else if(ly(n,e.identifierQuotes))ty(t,n==91?93:n,!1),t.acceptToken(qv);else if(n==40)t.acceptToken(Fv);else if(n==41)t.acceptToken(Iv);else if(n==123)t.acceptToken(Lv);else if(n==125)t.acceptToken(Rv);else if(n==91)t.acceptToken(zv);else if(n==93)t.acceptToken(Bv);else if(n==59)t.acceptToken(Vv);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),oy(t),t.acceptToken(Xv);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(ty(t,n,e.backslashEscapes),t.acceptToken(Zv)):(oy(t,n),t.acceptToken(Xv))}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();ey(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(Mv)}else if(n==46&&t.next>=48&&t.next<=57)sy(t,!0),t.acceptToken(Mv);else if(n==46)t.acceptToken(Hv);else if(n>=48&&n<=57)sy(t,!1),t.acceptToken(Mv);else if(ly(n,e.operatorChars)){for(;ly(t.next,e.operatorChars);)t.advance();t.acceptToken(Uv)}else if(ly(n,e.specialVar))t.next==n&&t.advance(),ay(t),t.acceptToken(Gv);else if(n==58||n==44)t.acceptToken(Wv);else if($v(n)){let r=iy(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?Kv:e.words[r.toLowerCase()]??Kv)}})}var _y=gy(my),vy=wv.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,_y],topRules:{Script:[0,25]},tokenPrec:0});function yy(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function by(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function xy(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function Sy(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)xy(r)&&n.push(by(e,r));return n}return[by(e,t)]}function Cy(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=yy(t);if(!xy(r))return n;n.unshift(by(e,r)),t=yy(r)}}function wy(e,t){let n=X(e).resolveInner(t,-1),r=Ey(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:Cy(e.doc,yy(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:Cy(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var Ty=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function Ey(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&&xy(t.nextSibling))o=by(e,t.nextSibling);else if(n&&Ty.has(n))break;else a&&xy(t)&&(o=by(e,t));o&&(r||=Object.create(null),r[o]=Sy(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function Dy(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var Oy=/^\w*$/,ky=/^[`'"\[]?\w*[`'"\]]?$/;function Ay(e){return e.self&&typeof e.self.label==`string`}var jy=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(My(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`?My(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):Ay(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;Ay(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 My(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+Ny(n)}}function Ny(e){return e===`[`?`]`:e}function Py(e,t,n,r,i,a){let o=new jy(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}=wy(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=Ny(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:Dy(t,r,u),validFor:ky}}else return{from:n,options:u,validFor:Oy}}}function Fy(e){return e==Yv?`type`:e==Jv?`keyword`:`variable`}function Iy(e,t,n){return Nh([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],Mh(Object.keys(e).map(r=>n(t?r.toUpperCase():r,Fy(e[r])))))}var Ly=vy.configure({props:[Au.add({Statement:Bu()}),Wu.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}}}),Bl({Keyword:Y.keyword,Type:Y.typeName,Builtin:Y.standard(Y.name),Bits:Y.number,Bytes:Y.string,Bool:Y.bool,Null:Y.null,Number:Y.number,String:Y.string,Identifier:Y.name,QuotedIdentifier:Y.special(Y.string),SpecialVar:Y.special(Y.name),LineComment:Y.lineComment,BlockComment:Y.blockComment,Operator:Y.operator,"Semi Punctuation":Y.punctuation,"( )":Y.paren,"{ }":Y.brace,"[ ]":Y.squareBracket})]}),Ry=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=hy(t,t.keywords,t.types,t.builtin);return new e(n,pu.define({name:`sql`,parser:Ly.configure({tokenizers:[{from:_y,to:gy(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}}),t)}};function zy(e,t){return{label:e,type:t,boost:-1}}function By(e,t=!1,n){return Iy(e.dialect.words,t,n||zy)}function Vy(e){return e.schema?Py(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||Wy):()=>null}function Hy(e){return e.schema?(e.dialect||Wy).language.data.of({autocomplete:Vy(e)}):[]}function Uy(e={}){let t=e.dialect||Wy;return new Cu(t.language,[Hy(e),t.language.data.of({autocomplete:By(t,e.upperCaseKeywords,e.keywordCompletion)})])}var Wy=Ry.define({}),Gy=Ry.define({charSetCasts:!0,doubleDollarQuotedStrings:!0,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:``,keywords:py+`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:fy+`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`}),Ky=fy+`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`,qy=`charset clear edit ego help nopager notee nowarning pager print prompt quit rehash source status system tee`;Ry.define({operatorChars:`*+-%<>!=&|^`,charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:`@?`,identifierQuotes:"`",keywords:py+`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:Ky,builtin:qy}),Ry.define({operatorChars:`*+-%<>!=&|^`,charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:`@?`,identifierQuotes:"`",keywords:py+`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:Ky,builtin:qy}),Ry.define({keywords:py+`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:fy+`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:`"[`}),Ry.define({keywords:py+`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:fy+`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:`@:?$`}),Ry.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:fy+`ascii bigint blob counter frozen inet list map static text timeuuid tuple uuid varint`,slashComments:!0}),Ry.define({keywords:py+`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:fy+`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 Jy=`/api/postgres`;function Yy(e){let[t,n]=(0,h.useState)(``),[r,i]=(0,h.useState)(!1),o=e?`/api/db/connections/${e}`:null,[s,c]=(0,h.useState)([]),[l,u]=(0,h.useState)(null),[d,f]=(0,h.useState)(`public`),[p,m]=(0,h.useState)(null),[g,_]=(0,h.useState)([]),[v,y]=(0,h.useState)(!1),[ee,b]=(0,h.useState)(null),[x,te]=(0,h.useState)(1),[ne,re]=(0,h.useState)(null),[S,ie]=(0,h.useState)(null),[ae,C]=(0,h.useState)(!1),w=(0,h.useCallback)(async e=>{y(!0),b(null);try{let t=await a.post(`${Jy}/test`,{connectionString:e});if(!t.ok){b(t.error??`Connection failed`);return}n(e),i(!0);let r=await a.post(`${Jy}/tables`,{connectionString:e});c(r),r.length>0&&(u(r[0].name),f(r[0].schema))}catch(e){b(e.message)}finally{y(!1)}},[]),T=(0,h.useCallback)(async()=>{if(o){y(!0);try{c(await a.get(`${o}/tables?cached=1`))}catch(e){b(e.message)}finally{y(!1)}return}if(t){y(!0);try{c(await a.post(`${Jy}/tables`,{connectionString:t}))}catch(e){b(e.message)}finally{y(!1)}}},[o,t,l]);(0,h.useEffect)(()=>{o&&(i(!0),T())},[o]);let oe=(0,h.useCallback)(async(e,n,r)=>{let i=e??l,s=n??d;if(i){y(!0);try{if(o){let[e,t]=await Promise.all([a.get(`${o}/data?table=${encodeURIComponent(i)}&schema=${s}&page=${r??x}&limit=100`),a.get(`${o}/schema?table=${encodeURIComponent(i)}&schema=${s}`)]);m(e),_(t)}else{if(!t)return;let[e,n]=await Promise.all([a.post(`${Jy}/data`,{connectionString:t,table:i,schema:s,page:r??x,limit:100}),a.post(`${Jy}/schema`,{connectionString:t,table:i,schema:s})]);m(e),_(n)}}catch(e){b(e.message)}finally{y(!1)}}},[o,t,l,d,x]);return{connectionString:t,connected:r,connect:w,tables:s,selectedTable:l,selectTable:(0,h.useCallback)((e,t=`public`)=>{u(e),f(t),te(1),re(null),oe(e,t,1)},[oe]),tableData:p,schema:g,loading:v,error:ee,page:x,setPage:(0,h.useCallback)(e=>{te(e),oe(void 0,void 0,e)},[oe]),queryResult:ne,queryError:S,queryLoading:ae,executeQuery:(0,h.useCallback)(async e=>{if(!(!o&&!t)){C(!0),ie(null);try{let n=o?await a.post(`${o}/query`,{sql:e}):await a.post(`${Jy}/query`,{connectionString:t,sql:e});re(n),n.changeType===`modify`&&oe()}catch(e){ie(e.message)}finally{C(!1)}}},[o,t,oe]),updateCell:(0,h.useCallback)(async(e,n,r,i)=>{if(l)try{if(o)await a.put(`${o}/cell`,{table:l,schema:d,pkColumn:e,pkValue:n,column:r,value:i});else{if(!t)return;await a.post(`${Jy}/cell`,{connectionString:t,table:l,schema:d,pkColumn:e,pkValue:n,column:r,value:i})}oe()}catch(e){b(e.message)}},[o,t,l,d,oe]),refreshTables:T,refreshData:oe}}function Xy({metadata:e}){let t=e?.connectionString??``,n=e?.connectionId,r=Yy(n);return r.connected?(0,$.jsx)(Qy,{pg:r,initialTable:e?.tableName,hideTableList:!!n,connectionName:e?.connectionName}):(0,$.jsx)(Zy,{initialValue:t,onConnect:r.connect,loading:r.loading,error:r.error})}function Zy({initialValue:e,onConnect:t,loading:n,error:r}){let[i,a]=(0,h.useState)(e);return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 w-full max-w-lg px-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(o,{className:`size-4`}),` Connect to PostgreSQL`]}),(0,$.jsx)(`input`,{className:`w-full px-3 py-2 rounded border border-border bg-background text-sm font-mono outline-none focus:border-primary`,placeholder:`postgresql://user:pass@host:5432/db`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i.trim()&&t(i.trim())}}),r&&(0,$.jsxs)(`p`,{className:`text-xs text-destructive flex items-center gap-1`,children:[(0,$.jsx)(l,{className:`size-3`}),r]}),(0,$.jsx)(`button`,{type:`button`,disabled:n||!i.trim(),onClick:()=>t(i.trim()),className:`px-4 py-2 rounded bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:n?(0,$.jsx)(u,{className:`size-4 animate-spin mx-auto`}):`Connect`})]})})}function Qy({pg:e,initialTable:t,hideTableList:n,connectionName:i}){let[a,s]=(0,h.useState)(!1),l=(0,h.useRef)(!1);return(0,h.useEffect)(()=>{if(!(!t||l.current)){if(n&&e.connected)l.current=!0,e.selectTable(t);else if(e.tables.length>0){let n=e.tables.find(e=>e.name===t);n&&(l.current=!0,e.selectTable(n.name,n.schema))}}},[t,e.connected,e.tables]),(0,$.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden`,children:[!n&&(0,$.jsxs)(`div`,{className:`w-48 shrink-0 flex flex-col bg-background overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Tables`}),(0,$.jsx)(`button`,{type:`button`,onClick:e.refreshTables,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Refresh`,children:(0,$.jsx)(c,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.tables.map(t=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>e.selectTable(t.name,t.schema),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors ${e.selectedTable===t.name?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[(0,$.jsx)(r,{className:`size-3 shrink-0`}),(0,$.jsxs)(`span`,{className:`truncate flex-1`,children:[t.schema===`public`?``:`${t.schema}.`,t.name]}),(0,$.jsx)(`span`,{className:`text-[10px] opacity-60`,children:t.rowCount})]},`${t.schema}.${t.name}`)),e.tables.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No tables found`})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden ${n?``:`border-l border-border`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,$.jsx)(o,{className:`size-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:i??`PostgreSQL`}),e.selectedTable&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,e.selectedTable]}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`px-2 py-1 rounded text-xs transition-colors ${a?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:`SQL`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden ${a?`max-h-[60%]`:``}`,children:(0,$.jsx)($y,{tableData:e.tableData,schema:e.schema,loading:e.loading,page:e.page,onPageChange:e.setPage,onCellUpdate:e.updateCell})}),a&&(0,$.jsx)(`div`,{className:`border-t border-border h-[40%] shrink-0`,children:(0,$.jsx)(eb,{onExecute:e.executeQuery,result:e.queryResult,error:e.queryError,loading:e.queryLoading})})]})]})}function $y({tableData:e,schema:t,loading:r,page:i,onPageChange:a,onCellUpdate:o}){let[c,l]=(0,h.useState)(null),[d,g]=(0,h.useState)(``),_=(0,h.useMemo)(()=>t.find(e=>e.pk)?.name??null,[t]),v=(0,h.useCallback)((e,t,n)=>{l({rowIdx:e,col:t}),g(n==null?``:String(n))},[]),y=(0,h.useCallback)(()=>{if(!c||!e||!_)return;let t=e.rows[c.rowIdx];if(!t)return;let n=t[c.col];String(n??``)!==d&&o(_,t[_],c.col,d===``?null:d),l(null)},[c,d,e,_,o]),ee=(0,h.useCallback)(()=>l(null),[]),b=(0,h.useMemo)(()=>(e?.columns??[]).map(e=>({id:e,accessorFn:t=>t[e],header:()=>(0,$.jsx)(`span`,{className:t.find(t=>t.name===e)?.pk?`font-bold`:``,children:e}),cell:({row:t,getValue:n})=>{let r=c?.rowIdx===t.index&&c?.col===e,i=n();return r?(0,$.jsx)(`input`,{autoFocus:!0,className:`w-full bg-transparent border border-primary/50 rounded px-1 py-0 text-xs outline-none`,value:d,onChange:e=>g(e.target.value),onBlur:y,onKeyDown:e=>{e.key===`Enter`&&y(),e.key===`Escape`&&ee()}}):(0,$.jsx)(`span`,{className:`cursor-pointer truncate block ${i==null?`text-muted-foreground/40 italic`:``}`,onDoubleClick:()=>_&&v(t.index,e,i),title:i==null?`NULL`:String(i),children:i==null?`NULL`:String(i)})}})),[e?.columns,t,c,d,y,ee,v,_]),x=f({data:e?.rows??[],columns:b,getCoreRowModel:p()});if(!e)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:r?(0,$.jsx)(u,{className:`size-4 animate-spin`}):`Select a table`});let te=Math.ceil(e.total/e.limit)||1;return(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:x.getHeaderGroups().map(e=>(0,$.jsx)(`tr`,{children:e.headers.map(e=>(0,$.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:m(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,$.jsxs)(`tbody`,{children:[x.getRowModel().rows.map(e=>(0,$.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:e.getVisibleCells().map(e=>(0,$.jsx)(`td`,{className:`px-2 py-1 max-w-[300px]`,children:m(e.column.columnDef.cell,e.getContext())},e.id))},e.id)),e.rows.length===0&&(0,$.jsx)(`tr`,{children:(0,$.jsx)(`td`,{colSpan:e.columns.length,className:`px-2 py-8 text-center text-muted-foreground`,children:`No data`})})]})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-t border-border bg-background shrink-0 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[e.total.toLocaleString(),` rows`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:i<=1,onClick:()=>a(i-1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,$.jsx)(s,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{children:[i,` / `,te]}),(0,$.jsx)(`button`,{type:`button`,disabled:i>=te,onClick:()=>a(i+1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,$.jsx)(n,{className:`size-3.5`})})]})]})]})}function eb({onExecute:e,result:t,error:n,loading:r}){let[i,a]=(0,h.useState)(`SELECT * FROM `),o=(0,h.useCallback)(()=>{let t=i.trim();t&&e(t)},[i,e]);return(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-1 border-b border-border bg-background`,onKeyDown:(0,h.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),o())},[o]),children:[(0,$.jsx)(`div`,{className:`flex-1 max-h-[120px] overflow-auto`,children:(0,$.jsx)(tv,{value:i,onChange:a,extensions:[Uy({dialect:Gy})],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1},className:`text-xs [&_.cm-editor]:!outline-none [&_.cm-scroller]:!overflow-auto`})}),(0,$.jsx)(`button`,{type:`button`,onClick:o,disabled:r,title:`Execute (Cmd+Enter)`,className:`shrink-0 m-1 p-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:r?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):(0,$.jsx)(d,{className:`size-3.5`})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-auto text-xs`,children:[n&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5`,children:n}),t?.changeType===`modify`&&(0,$.jsxs)(`div`,{className:`px-3 py-2 text-green-500`,children:[`Query executed. `,t.rowsAffected,` row(s) affected.`]}),t?.changeType===`select`&&t.rows.length>0&&(0,$.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,$.jsx)(`tr`,{children:t.columns.map(e=>(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:e},e))})}),(0,$.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,$.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:t.columns.map(t=>(0,$.jsx)(`td`,{className:`px-2 py-1 max-w-[300px] truncate`,title:e[t]==null?`NULL`:String(e[t]),children:e[t]==null?(0,$.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`NULL`}):String(e[t])},t))},n))})]}),t?.changeType===`select`&&t.rows.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-muted-foreground`,children:`No results`})]})]})}export{Xy as PostgresViewer};
|
|
13
|
+
`;function dy(e,t,n){let r=Object.create(null);r.true=r.false=Nv,r.null=r.unknown=Pv;for(let t of e.split(` `))t&&(r[t]=Jv);for(let e of t.split(` `))e&&(r[e]=Yv);for(let e of(n||``).split(` `))e&&(r[e]=Qv);return r}var fy=`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 `,py=`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 `,my={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:dy(py,fy)};function hy(e,t,n,r){let i={};for(let t in my)i[t]=(e.hasOwnProperty(t)?e:my)[t];return t&&(i.words=dy(t,n||``,r)),i}function gy(e){return new fv(t=>{let{next:n}=t;if(t.advance(),ly(n,uy)){for(;ly(t.next,uy);)t.advance();t.acceptToken(Ov)}else if(n==36&&e.doubleDollarQuotedStrings){let e=iy(t,``);t.next==36&&(t.advance(),ny(t,e),t.acceptToken(jv))}else if(n==39||n==34&&e.doubleQuotedStrings)ty(t,n,e.backslashEscapes),t.acceptToken(jv);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)cy(t),t.acceptToken(kv);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))cy(t),t.acceptToken(kv);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(Av)}else if((n==101||n==69)&&t.next==39)t.advance(),ty(t,39,!0),t.acceptToken(jv);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),ty(t,39,e.backslashEscapes),t.acceptToken(jv);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),ty(t,39,e.backslashEscapes),t.acceptToken(jv);break}if(!$v(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!ly(t.peek(1),uy)){let e=t.peek(1);t.advance(2),ry(t,e),t.acceptToken(jv)}else if(ly(n,e.identifierQuotes))ty(t,n==91?93:n,!1),t.acceptToken(qv);else if(n==40)t.acceptToken(Fv);else if(n==41)t.acceptToken(Iv);else if(n==123)t.acceptToken(Lv);else if(n==125)t.acceptToken(Rv);else if(n==91)t.acceptToken(zv);else if(n==93)t.acceptToken(Bv);else if(n==59)t.acceptToken(Vv);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),oy(t),t.acceptToken(Xv);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(ty(t,n,e.backslashEscapes),t.acceptToken(Zv)):(oy(t,n),t.acceptToken(Xv))}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();ey(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(Mv)}else if(n==46&&t.next>=48&&t.next<=57)sy(t,!0),t.acceptToken(Mv);else if(n==46)t.acceptToken(Hv);else if(n>=48&&n<=57)sy(t,!1),t.acceptToken(Mv);else if(ly(n,e.operatorChars)){for(;ly(t.next,e.operatorChars);)t.advance();t.acceptToken(Uv)}else if(ly(n,e.specialVar))t.next==n&&t.advance(),ay(t),t.acceptToken(Gv);else if(n==58||n==44)t.acceptToken(Wv);else if($v(n)){let r=iy(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?Kv:e.words[r.toLowerCase()]??Kv)}})}var _y=gy(my),vy=wv.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,_y],topRules:{Script:[0,25]},tokenPrec:0});function yy(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function by(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function xy(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function Sy(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)xy(r)&&n.push(by(e,r));return n}return[by(e,t)]}function Cy(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=yy(t);if(!xy(r))return n;n.unshift(by(e,r)),t=yy(r)}}function wy(e,t){let n=X(e).resolveInner(t,-1),r=Ey(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:Cy(e.doc,yy(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:Cy(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var Ty=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function Ey(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&&xy(t.nextSibling))o=by(e,t.nextSibling);else if(n&&Ty.has(n))break;else a&&xy(t)&&(o=by(e,t));o&&(r||=Object.create(null),r[o]=Sy(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function Dy(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var Oy=/^\w*$/,ky=/^[`'"\[]?\w*[`'"\]]?$/;function Ay(e){return e.self&&typeof e.self.label==`string`}var jy=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(My(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`?My(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):Ay(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;Ay(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 My(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+Ny(n)}}function Ny(e){return e===`[`?`]`:e}function Py(e,t,n,r,i,a){let o=new jy(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}=wy(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=Ny(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:Dy(t,r,u),validFor:ky}}else return{from:n,options:u,validFor:Oy}}}function Fy(e){return e==Yv?`type`:e==Jv?`keyword`:`variable`}function Iy(e,t,n){return Nh([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],Mh(Object.keys(e).map(r=>n(t?r.toUpperCase():r,Fy(e[r])))))}var Ly=vy.configure({props:[Au.add({Statement:Bu()}),Wu.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}}}),Bl({Keyword:Y.keyword,Type:Y.typeName,Builtin:Y.standard(Y.name),Bits:Y.number,Bytes:Y.string,Bool:Y.bool,Null:Y.null,Number:Y.number,String:Y.string,Identifier:Y.name,QuotedIdentifier:Y.special(Y.string),SpecialVar:Y.special(Y.name),LineComment:Y.lineComment,BlockComment:Y.blockComment,Operator:Y.operator,"Semi Punctuation":Y.punctuation,"( )":Y.paren,"{ }":Y.brace,"[ ]":Y.squareBracket})]}),Ry=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=hy(t,t.keywords,t.types,t.builtin);return new e(n,pu.define({name:`sql`,parser:Ly.configure({tokenizers:[{from:_y,to:gy(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}}),t)}};function zy(e,t){return{label:e,type:t,boost:-1}}function By(e,t=!1,n){return Iy(e.dialect.words,t,n||zy)}function Vy(e){return e.schema?Py(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||Wy):()=>null}function Hy(e){return e.schema?(e.dialect||Wy).language.data.of({autocomplete:Vy(e)}):[]}function Uy(e={}){let t=e.dialect||Wy;return new Cu(t.language,[Hy(e),t.language.data.of({autocomplete:By(t,e.upperCaseKeywords,e.keywordCompletion)})])}var Wy=Ry.define({}),Gy=Ry.define({charSetCasts:!0,doubleDollarQuotedStrings:!0,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:``,keywords:py+`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:fy+`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`}),Ky=fy+`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`,qy=`charset clear edit ego help nopager notee nowarning pager print prompt quit rehash source status system tee`;Ry.define({operatorChars:`*+-%<>!=&|^`,charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:`@?`,identifierQuotes:"`",keywords:py+`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:Ky,builtin:qy}),Ry.define({operatorChars:`*+-%<>!=&|^`,charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:`@?`,identifierQuotes:"`",keywords:py+`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:Ky,builtin:qy}),Ry.define({keywords:py+`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:fy+`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:`"[`}),Ry.define({keywords:py+`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:fy+`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:`@:?$`}),Ry.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:fy+`ascii bigint blob counter frozen inet list map static text timeuuid tuple uuid varint`,slashComments:!0}),Ry.define({keywords:py+`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:fy+`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 Jy=`/api/postgres`;function Yy(e){let[t,n]=(0,h.useState)(``),[r,i]=(0,h.useState)(!1),o=e?`/api/db/connections/${e}`:null,[s,c]=(0,h.useState)([]),[l,u]=(0,h.useState)(null),[d,f]=(0,h.useState)(`public`),[p,m]=(0,h.useState)(null),[g,_]=(0,h.useState)([]),[v,y]=(0,h.useState)(!1),[ee,b]=(0,h.useState)(null),[x,te]=(0,h.useState)(1),[ne,re]=(0,h.useState)(null),[S,ie]=(0,h.useState)(null),[ae,C]=(0,h.useState)(!1),w=(0,h.useCallback)(async e=>{y(!0),b(null);try{let t=await a.post(`${Jy}/test`,{connectionString:e});if(!t.ok){b(t.error??`Connection failed`);return}n(e),i(!0);let r=await a.post(`${Jy}/tables`,{connectionString:e});c(r),r.length>0&&(u(r[0].name),f(r[0].schema))}catch(e){b(e.message)}finally{y(!1)}},[]),T=(0,h.useCallback)(async()=>{if(o){y(!0);try{c(await a.get(`${o}/tables?cached=1`))}catch(e){b(e.message)}finally{y(!1)}return}if(t){y(!0);try{c(await a.post(`${Jy}/tables`,{connectionString:t}))}catch(e){b(e.message)}finally{y(!1)}}},[o,t,l]);(0,h.useEffect)(()=>{o&&(i(!0),T())},[o]);let oe=(0,h.useCallback)(async(e,n,r)=>{let i=e??l,s=n??d;if(i){y(!0);try{if(o){let[e,t]=await Promise.all([a.get(`${o}/data?table=${encodeURIComponent(i)}&schema=${s}&page=${r??x}&limit=100`),a.get(`${o}/schema?table=${encodeURIComponent(i)}&schema=${s}`)]);m(e),_(t)}else{if(!t)return;let[e,n]=await Promise.all([a.post(`${Jy}/data`,{connectionString:t,table:i,schema:s,page:r??x,limit:100}),a.post(`${Jy}/schema`,{connectionString:t,table:i,schema:s})]);m(e),_(n)}}catch(e){b(e.message)}finally{y(!1)}}},[o,t,l,d,x]);return{connectionString:t,connected:r,connect:w,tables:s,selectedTable:l,selectTable:(0,h.useCallback)((e,t=`public`)=>{u(e),f(t),te(1),re(null),oe(e,t,1)},[oe]),tableData:p,schema:g,loading:v,error:ee,page:x,setPage:(0,h.useCallback)(e=>{te(e),oe(void 0,void 0,e)},[oe]),queryResult:ne,queryError:S,queryLoading:ae,executeQuery:(0,h.useCallback)(async e=>{if(!(!o&&!t)){C(!0),ie(null);try{let n=o?await a.post(`${o}/query`,{sql:e}):await a.post(`${Jy}/query`,{connectionString:t,sql:e});re(n),n.changeType===`modify`&&oe()}catch(e){ie(e.message)}finally{C(!1)}}},[o,t,oe]),updateCell:(0,h.useCallback)(async(e,n,r,i)=>{if(l)try{if(o)await a.put(`${o}/cell`,{table:l,schema:d,pkColumn:e,pkValue:n,column:r,value:i});else{if(!t)return;await a.post(`${Jy}/cell`,{connectionString:t,table:l,schema:d,pkColumn:e,pkValue:n,column:r,value:i})}oe()}catch(e){b(e.message)}},[o,t,l,d,oe]),refreshTables:T,refreshData:oe}}function Xy({metadata:e}){let t=e?.connectionString??``,n=e?.connectionId,r=Yy(n);return r.connected?(0,$.jsx)(Qy,{pg:r,initialTable:e?.tableName,hideTableList:!!n,connectionName:e?.connectionName}):(0,$.jsx)(Zy,{initialValue:t,onConnect:r.connect,loading:r.loading,error:r.error})}function Zy({initialValue:e,onConnect:t,loading:n,error:r}){let[i,a]=(0,h.useState)(e);return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 w-full max-w-lg px-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(o,{className:`size-4`}),` Connect to PostgreSQL`]}),(0,$.jsx)(`input`,{className:`w-full px-3 py-2 rounded border border-border bg-background text-sm font-mono outline-none focus:border-primary`,placeholder:`postgresql://user:pass@host:5432/db`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i.trim()&&t(i.trim())}}),r&&(0,$.jsxs)(`p`,{className:`text-xs text-destructive flex items-center gap-1`,children:[(0,$.jsx)(l,{className:`size-3`}),r]}),(0,$.jsx)(`button`,{type:`button`,disabled:n||!i.trim(),onClick:()=>t(i.trim()),className:`px-4 py-2 rounded bg-primary text-primary-foreground text-sm hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:n?(0,$.jsx)(u,{className:`size-4 animate-spin mx-auto`}):`Connect`})]})})}function Qy({pg:e,initialTable:t,hideTableList:n,connectionName:i}){let[a,s]=(0,h.useState)(!1),c=(0,h.useRef)(!1);return(0,h.useEffect)(()=>{if(!(!t||c.current)){if(n&&e.connected)c.current=!0,e.selectTable(t);else if(e.tables.length>0){let n=e.tables.find(e=>e.name===t);n&&(c.current=!0,e.selectTable(n.name,n.schema))}}},[t,e.connected,e.tables]),(0,$.jsxs)(`div`,{className:`flex h-full w-full overflow-hidden`,children:[!n&&(0,$.jsxs)(`div`,{className:`w-48 shrink-0 flex flex-col bg-background overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Tables`}),(0,$.jsx)(`button`,{type:`button`,onClick:e.refreshTables,className:`text-muted-foreground hover:text-foreground transition-colors`,title:`Refresh`,children:(0,$.jsx)(d,{className:`size-3`})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[e.tables.map(t=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>e.selectTable(t.name,t.schema),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors ${e.selectedTable===t.name?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[(0,$.jsx)(r,{className:`size-3 shrink-0`}),(0,$.jsxs)(`span`,{className:`truncate flex-1`,children:[t.schema===`public`?``:`${t.schema}.`,t.name]}),(0,$.jsx)(`span`,{className:`text-[10px] opacity-60`,children:t.rowCount})]},`${t.schema}.${t.name}`)),e.tables.length===0&&(0,$.jsx)(`p`,{className:`px-3 py-4 text-xs text-muted-foreground text-center`,children:`No tables found`})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden ${n?``:`border-l border-border`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border bg-background shrink-0`,children:[(0,$.jsx)(o,{className:`size-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:i??`PostgreSQL`}),e.selectedTable&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,e.selectedTable]}),(0,$.jsx)(`div`,{className:`ml-auto`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`px-2 py-1 rounded text-xs transition-colors ${a?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:`SQL`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden ${a?`max-h-[60%]`:``}`,children:(0,$.jsx)($y,{tableData:e.tableData,schema:e.schema,loading:e.loading,page:e.page,onPageChange:e.setPage,onCellUpdate:e.updateCell})}),a&&(0,$.jsx)(`div`,{className:`border-t border-border h-[40%] shrink-0`,children:(0,$.jsx)(eb,{onExecute:e.executeQuery,result:e.queryResult,error:e.queryError,loading:e.queryLoading})})]})]})}function $y({tableData:e,schema:t,loading:r,page:i,onPageChange:a,onCellUpdate:o}){let[c,l]=(0,h.useState)(null),[d,g]=(0,h.useState)(``),_=(0,h.useMemo)(()=>t.find(e=>e.pk)?.name??null,[t]),v=(0,h.useCallback)((e,t,n)=>{l({rowIdx:e,col:t}),g(n==null?``:String(n))},[]),y=(0,h.useCallback)(()=>{if(!c||!e||!_)return;let t=e.rows[c.rowIdx];if(!t)return;let n=t[c.col];String(n??``)!==d&&o(_,t[_],c.col,d===``?null:d),l(null)},[c,d,e,_,o]),ee=(0,h.useCallback)(()=>l(null),[]),b=(0,h.useMemo)(()=>(e?.columns??[]).map(e=>({id:e,accessorFn:t=>t[e],header:()=>(0,$.jsx)(`span`,{className:t.find(t=>t.name===e)?.pk?`font-bold`:``,children:e}),cell:({row:t,getValue:n})=>{let r=c?.rowIdx===t.index&&c?.col===e,i=n();return r?(0,$.jsx)(`input`,{autoFocus:!0,className:`w-full bg-transparent border border-primary/50 rounded px-1 py-0 text-xs outline-none`,value:d,onChange:e=>g(e.target.value),onBlur:y,onKeyDown:e=>{e.key===`Enter`&&y(),e.key===`Escape`&&ee()}}):(0,$.jsx)(`span`,{className:`cursor-pointer truncate block ${i==null?`text-muted-foreground/40 italic`:``}`,onDoubleClick:()=>_&&v(t.index,e,i),title:i==null?`NULL`:String(i),children:i==null?`NULL`:String(i)})}})),[e?.columns,t,c,d,y,ee,v,_]),x=f({data:e?.rows??[],columns:b,getCoreRowModel:p()});if(!e)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full text-xs text-muted-foreground`,children:r?(0,$.jsx)(u,{className:`size-4 animate-spin`}):`Select a table`});let te=Math.ceil(e.total/e.limit)||1;return(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-xs border-collapse`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:x.getHeaderGroups().map(e=>(0,$.jsx)(`tr`,{children:e.headers.map(e=>(0,$.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:m(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,$.jsxs)(`tbody`,{children:[x.getRowModel().rows.map(e=>(0,$.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:e.getVisibleCells().map(e=>(0,$.jsx)(`td`,{className:`px-2 py-1 max-w-[300px]`,children:m(e.column.columnDef.cell,e.getContext())},e.id))},e.id)),e.rows.length===0&&(0,$.jsx)(`tr`,{children:(0,$.jsx)(`td`,{colSpan:e.columns.length,className:`px-2 py-8 text-center text-muted-foreground`,children:`No data`})})]})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-t border-border bg-background shrink-0 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[e.total.toLocaleString(),` rows`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:i<=1,onClick:()=>a(i-1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,$.jsx)(s,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{children:[i,` / `,te]}),(0,$.jsx)(`button`,{type:`button`,disabled:i>=te,onClick:()=>a(i+1),className:`p-0.5 rounded hover:bg-muted disabled:opacity-30`,children:(0,$.jsx)(n,{className:`size-3.5`})})]})]})]})}function eb({onExecute:e,result:t,error:n,loading:r}){let[i,a]=(0,h.useState)(`SELECT * FROM `),o=(0,h.useCallback)(()=>{let t=i.trim();t&&e(t)},[i,e]);return(0,$.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-1 border-b border-border bg-background`,onKeyDown:(0,h.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),o())},[o]),children:[(0,$.jsx)(`div`,{className:`flex-1 max-h-[120px] overflow-auto`,children:(0,$.jsx)(tv,{value:i,onChange:a,extensions:[Uy({dialect:Gy})],basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1},className:`text-xs [&_.cm-editor]:!outline-none [&_.cm-scroller]:!overflow-auto`})}),(0,$.jsx)(`button`,{type:`button`,onClick:o,disabled:r,title:`Execute (Cmd+Enter)`,className:`shrink-0 m-1 p-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:r?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):(0,$.jsx)(c,{className:`size-3.5`})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-auto text-xs`,children:[n&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-destructive bg-destructive/5`,children:n}),t?.changeType===`modify`&&(0,$.jsxs)(`div`,{className:`px-3 py-2 text-green-500`,children:[`Query executed. `,t.rowsAffected,` row(s) affected.`]}),t?.changeType===`select`&&t.rows.length>0&&(0,$.jsxs)(`table`,{className:`w-full border-collapse`,children:[(0,$.jsx)(`thead`,{className:`sticky top-0 bg-muted`,children:(0,$.jsx)(`tr`,{children:t.columns.map(e=>(0,$.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-muted-foreground border-b border-border whitespace-nowrap`,children:e},e))})}),(0,$.jsx)(`tbody`,{children:t.rows.map((e,n)=>(0,$.jsx)(`tr`,{className:`hover:bg-muted/30 border-b border-border/50`,children:t.columns.map(t=>(0,$.jsx)(`td`,{className:`px-2 py-1 max-w-[300px] truncate`,title:e[t]==null?`NULL`:String(e[t]),children:e[t]==null?(0,$.jsx)(`span`,{className:`text-muted-foreground/40 italic`,children:`NULL`}):String(e[t])},t))},n))})]}),t?.changeType===`select`&&t.rows.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-muted-foreground`,children:`No results`})]})]})}export{Xy as PostgresViewer};
|