mulmoclaude 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,7 +29,8 @@ Your browser opens to `http://localhost:3001`. That's it.
29
29
  | "Schedule a daily news digest" | Recurring task that runs automatically |
30
30
  | "Generate an image of a sunset" | AI-generated image (Gemini) |
31
31
  | "Make slides on …" | Marp-rendered slide deck with PDF export |
32
- | "Add this to my calendar" | Event in your Google Calendar (local OAuth link) |
32
+ | "Add this to my calendar" | Event in your Google Calendar (sign in, no setup) |
33
+ | "Put that on my task list" | Task in Google Tasks, with notes and a due date |
33
34
  | "Subscribe to this RSS feed" | Data feed on `/feeds`, fetched on a schedule |
34
35
 
35
36
  **Pages you can visit directly**: `/wiki` (browse + lint), `/feeds` (data feeds), `/collections` (data apps — Discover tab to import community collections, Contribute to share your own), `/automations` (recurring tasks), `/files`, `/skills`, `/roles`. Each page has its own chat composer that spawns a fresh chat already aware of the page context.
@@ -124,7 +125,7 @@ Recommended: ≥ 32 characters of random data (shorter values trigger a startup
124
125
  - **Marp slides** — `marp: true` frontmatter on any markdown file renders a slide deck in the canvas with PDF export. Custom themes via `config/marp-themes/<name>.css`.
125
126
  - **Auto memory** — the agent maintains a typed memory layout (`conversations/memory/<type>/<topic>.md`) and reads it ambient-style.
126
127
  - **Web Push on task finish** — enable in Settings → Notifications to get a push on your phone when the answer to a question you asked is ready, even with the browser closed. Requires the RemoteHost connection + a registered device (see [`docs/remote-host.md`](https://github.com/receptron/mulmoclaude/blob/main/docs/remote-host.md#web-push-on-task-finish-2086)).
127
- - **Google Calendar (local OAuth)** — link your Google account in Settings → Plugins → Google; the agent gets a `google` tool to list / create events, and the phone remote can trigger the same commands. The refresh token stays on your machine (`~/.config/mulmoclaude/`) — no Google credential ever reaches a cloud. One-time setup: place an OAuth *desktop-app* client JSON from the Google Cloud Console in `~/.secrets/` (see [`docs/remote-host.md`](https://github.com/receptron/mulmoclaude/blob/main/docs/remote-host.md)).
128
+ - **Google (Calendar / Tasks / Drive)** — link your Google account in Settings → Plugins → Google and consent in the browser; no Google Cloud setup needed. The agent then gets a `google` tool (list / create events, tasks, and files it creates in your Drive), and the phone remote can trigger the same commands. **The refresh token stays on your machine** (`~/.config/mulmo/`) — the sign-in service applies the OAuth client secret Google requires and keeps nothing. Prefer your own OAuth client? Drop a *desktop-app* client JSON in `~/.secrets/` and the whole flow stays local (see [`docs/remote-host.md`](https://github.com/receptron/mulmoclaude/blob/main/docs/remote-host.md)).
128
129
 
129
130
  ## Plugin authoring (`--dev-plugin`)
130
131
 
@@ -1,4 +1,4 @@
1
- import{Ft as e,Gt as t,X as n,Zn as r,at as i,bn as a,q as o,sr as s,wt as c,zn as l,zt as u}from"./vue.runtime.esm-bundler-D9nG8JAr.js";import{n as d}from"./vue-i18n-DMHgtTtA.js";import{t as f}from"./_plugin-vue_export-helper-BDNMzG2s.js";var p=[],m=[];(()=>{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?m:p).push(n+=e[t])})();function h(e){if(e<768)return!1;for(let t=0,n=p.length;;){let r=t+n>>1;if(e<p[r])n=r;else if(e>=m[r])t=r+1;else return!0;if(t==n)return!1}}function g(e){return e>=127462&&e<=127487}var _=8205;function v(e,t,n=!0,r=!0){return(n?y:ee)(e,t,r)}function y(e,t,n){if(t==e.length)return t;t&&x(e.charCodeAt(t))&&te(e.charCodeAt(t-1))&&t--;let r=b(e,t);for(t+=ne(r);t<e.length;){let i=b(e,t);if(r==_||i==_||n&&h(i))t+=ne(i),r=i;else if(g(i)){let n=0,r=t-2;for(;r>=0&&g(b(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function ee(e,t,n){for(;t>0;){let r=y(e,t-2,n);if(r<t)return r;t--}return 0}function b(e,t){let n=e.charCodeAt(t);if(!te(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return x(r)?(n-55296<<10)+(r-56320)+65536:n}function x(e){return e>=56320&&e<57344}function te(e){return e>=55296&&e<56320}function ne(e){return e<65536?1:2}var S=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]=de(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),re.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]=de(this,e,t);let n=[];return this.decompose(e,t,n,0),re.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 se(this),i=new se(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 se(this,e)}iterRange(e,t=this.length){return new ce(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 le(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 C(t):re.from(C.split(t,[]))}},C=class e extends S{constructor(e,t=ie(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 ue(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(oe(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=ae(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]=de(this,t,n);let i=ae(this.text,ae(r.text,oe(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):re.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
1
+ import{Ft as e,Gt as t,X as n,Zn as r,at as i,bn as a,q as o,sr as s,wt as c,zn as l,zt as u}from"./vue.runtime.esm-bundler-DQ_ijuEl.js";import{n as d}from"./vue-i18n-CSwCKaug.js";import{t as f}from"./_plugin-vue_export-helper-BDNMzG2s.js";var p=[],m=[];(()=>{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?m:p).push(n+=e[t])})();function h(e){if(e<768)return!1;for(let t=0,n=p.length;;){let r=t+n>>1;if(e<p[r])n=r;else if(e>=m[r])t=r+1;else return!0;if(t==n)return!1}}function g(e){return e>=127462&&e<=127487}var _=8205;function v(e,t,n=!0,r=!0){return(n?y:ee)(e,t,r)}function y(e,t,n){if(t==e.length)return t;t&&x(e.charCodeAt(t))&&te(e.charCodeAt(t-1))&&t--;let r=b(e,t);for(t+=ne(r);t<e.length;){let i=b(e,t);if(r==_||i==_||n&&h(i))t+=ne(i),r=i;else if(g(i)){let n=0,r=t-2;for(;r>=0&&g(b(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function ee(e,t,n){for(;t>0;){let r=y(e,t-2,n);if(r<t)return r;t--}return 0}function b(e,t){let n=e.charCodeAt(t);if(!te(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return x(r)?(n-55296<<10)+(r-56320)+65536:n}function x(e){return e>=56320&&e<57344}function te(e){return e>=55296&&e<56320}function ne(e){return e<65536?1:2}var S=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]=de(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),re.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]=de(this,e,t);let n=[];return this.decompose(e,t,n,0),re.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 se(this),i=new se(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 se(this,e)}iterRange(e,t=this.length){return new ce(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 le(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 C(t):re.from(C.split(t,[]))}},C=class e extends S{constructor(e,t=ie(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 ue(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(oe(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=ae(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]=de(this,t,n);let i=ae(this.text,ae(r.text,oe(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):re.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
2
2
  `){[e,t]=de(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}},re=class e extends S{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|(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]=de(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]=de(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 C(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 C&&c&&(n=u[u.length-1])instanceof C&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new C(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)}};S.empty=new C([``],0);function ie(e){let t=-1;for(let n of e)t+=n.length+1;return t}function ae(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 oe(e,t,n){return ae(e,[``],t,n)}var se=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 C?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 C?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 C){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 C?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)}},ce=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new se(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!=``}},le=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`&&(S.prototype[Symbol.iterator]=function(){return this.iter()},se.prototype[Symbol.iterator]=ce.prototype[Symbol.iterator]=le.prototype[Symbol.iterator]=function(){return this});var ue=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 de(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function w(e,t,n=!0,r=!0){return v(e,t,n,r)}function fe(e){return e>=56320&&e<57344}function pe(e){return e>=55296&&e<56320}function me(e,t){let n=e.charCodeAt(t);if(!pe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return fe(r)?(n-55296<<10)+(r-56320)+65536:n}function he(e){return e<65536?1:2}var ge=/\r\n?|\n/,T=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(T||={}),_e=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){be(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:Se(this,e)}mapDesc(e,t=!1){return e.empty?this:xe(this,e,t)}mapPos(e,t=-1,n=T.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!=T.Simple&&c>=e&&(n==T.TrackDel&&r<e&&c>e||n==T.TrackBefore&&r<e||n==T.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)}},ve=class e extends _e{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 be(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return xe(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(S.empty);r.push(a?t.slice(i,i+a):S.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Se(this,e,!0)}map(e,t=!1){return e.empty?this:xe(this,e,t,!0)}iterChanges(e,t=!1){be(this,e,t)}get desc(){return _e.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new Ce(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);E(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;E(n,e,t),t>0&&ye(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);E(n,e,-1),E(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:_e.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&&E(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`?S.of(l.split(r||ge)):l:S.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&E(i,e-o,-1),E(i,s-e,d),ye(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(S.empty);r[e]=S.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 E(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 ye(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(S.empty);e.push(n)}}function be(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=S.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 xe(e,t,n,r=!1){let i=[],a=r?[]:null,o=new Ce(e),s=new Ce(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);E(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(E(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(E(i,0,o.ins),a&&ye(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;E(i,t,e<o.i?o.ins:0),a&&e<o.i&&ye(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?ve.createSet(i,a):_e.create(i);else throw Error(`Mismatched change set lengths`)}function Se(e,t,n=!1){let r=[],i=n?[]:null,a=new Ce(e),o=new Ce(t);for(let e=!1;;)if(a.done&&o.done)return i?ve.createSet(r,i):_e.create(r);else if(a.ins==0)E(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)E(r,0,o.ins,e),i&&ye(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;E(r,t,n,e),i&&n&&ye(i,r,o.text)}else o.ins==-1?(E(r,a.off?0:a.len,t,e),i&&ye(i,r,a.textBit(t))):(E(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&ye(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 Ce=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?S.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?S.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)}},we=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}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 undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null: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,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return D.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return D.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 D.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},D=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=>we.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 we.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?we.create(t,e,a|32,n):we.create(e,t,a,n)}static undirectionalRange(e,t){return we.create(e,t,64,void 0)}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 Te(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Ee=0,O=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Ee++,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:De),!!t.static,t.enables)}of(e){return new Oe([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Oe(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Oe(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function De(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Oe=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Ee++}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)||Ae(e,c)){let r=t(e);if(a?!ke(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=Ue(o,c);if(this.dependencies.every(t=>t instanceof O?o.facet(t)===e.facet(t):t instanceof Ne?o.field(t,!1)==e.field(t,!1):!0)||(a?ke(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}}}get extension(){return this}};function ke(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 Ae(e,t){let n=!1;for(let r of t)He(e,r)&1&&(n=!0);return n}function je(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=Ue(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)He(e,t);return e.values[o]=s(e),1},update(e,n){if(!Ae(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=Ae(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&De(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 Me=O.define({static:!0}),Ne=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(Ee++,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(Me).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(Me),i=n.facet(Me),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,Me.of({field:this,create:e})]}get extension(){return this}},Pe={lowest:4,low:3,default:2,high:1,highest:0};function Fe(e){return t=>new Le(t,e)}var Ie={highest:Fe(Pe.highest),high:Fe(Pe.high),default:Fe(Pe.default),low:Fe(Pe.low),lowest:Fe(Pe.lowest)},Le=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},Re=class e{of(e){return new ze(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},ze=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Be=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 Ve(t,n,o))e instanceof Ne?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,De(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=>je(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function Ve(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 ze&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof ze){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 Le)a(e.inner,e.prec);else if(e instanceof Ne)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Oe)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Pe.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)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,Pe.default),r.reduce((e,t)=>e.concat(t))}function He(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 Ue(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var We=O.define(),Ge=O.define({combine:e=>e.some(e=>e),static:!0}),Ke=O.define({combine:e=>e.length?e[0]:void 0,static:!0}),qe=O.define(),Je=O.define(),Ye=O.define(),Xe=O.define({combine:e=>e.length?e[0]:!1}),Ze=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Qe}},Qe=class{of(e){return new Ze(this,e)}},$e=class{constructor(e){this.map=e}of(e){return new k(this,e)}},k=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 $e(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}};k.reconfigure=k.define(),k.appendConfig=k.define();var A=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&&Te(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]==`.`))}};A.time=Ze.define(),A.userEvent=Ze.define(),A.addToHistory=Ze.define(),A.remote=Ze.define();function et(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 tt(e,t,n){let r,i,a;return n?(r=t.changes,i=ve.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:k.mapEffects(e.effects,r).concat(k.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function nt(e,t,n){let r=t.selection,i=st(t.annotations);return t.userEvent&&(i=i.concat(A.userEvent.of(t.userEvent))),{changes:t.changes instanceof ve?t.changes:ve.of(t.changes||[],n,e.facet(Ke)),selection:r&&(r instanceof D?r:D.single(r.anchor,r.head)),effects:st(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function rt(e,t,n){let r=nt(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=tt(r,nt(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=A.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return at(n?it(i):i)}function it(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:et(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=ve.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=A.create(t,r,e.selection&&e.selection.map(i),k.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Je);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof A?i:Array.isArray(i)&&i.length==1&&i[0]instanceof A?i[0]:rt(t,st(i),!1)}return e}function at(e){let t=e.startState,n=t.facet(Ye),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=tt(r,nt(t,a,e.changes.newLength),!0))}return r==e?e:A.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var ot=[];function st(e){return e==null?ot:Array.isArray(e)?e:[e]}var ct=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(ct||={}),lt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ut;try{ut=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function dt(e){if(ut)return ut.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||lt.test(n)))return!0}return!1}function ft(e){return t=>{if(!/\S/.test(t))return ct.Space;if(dt(t))return ct.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ct.Word;return ct.Other}}var j=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++)He(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 He(this,n),Ue(this,n)}update(...e){return rt(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Re.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(k.reconfigure)?(n=null,r=e.value):e.is(k.appendConfig)&&(n=null,r=st(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Be.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(Ge)?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:D.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=st(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=k.mapEffects(a,c).concat(k.mapEffects(st(o.effects),l))}return{changes:r,selection:D.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof ve?t:ve.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return S.of(t.split(this.facet(e.lineSeparator)||ge))}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:(He(this,t),Ue(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 Ne&&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:D.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Be.resolve(t.extensions||[],new Map),r=t.doc instanceof S?t.doc:S.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||ge)),i=t.selection?t.selection instanceof D?t.selection:D.single(t.selection.anchor,t.selection.head):D.single(0);return Te(i,r.length),n.staticFacet(Ge)||(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)||`
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-CNC7AqOf.js";import{Gt as t,K as n,Nr as r,Qt as i,Rt as a,X as o,Y as s,Zn as c,at as l,hr as u,q as d,qt as ee,sr as f,wt as p,zn as m}from"./vue.runtime.esm-bundler-D9nG8JAr.js";import{n as te}from"./vue-i18n-DMHgtTtA.js";import{t as ne}from"./vue-CU5-3-x4.js";function h(e,t){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let t=e;if(typeof t.details==`string`&&t.details)return t.details;if(typeof t.message==`string`&&t.message)return t.message}return t===void 0?String(e):t}function g(e,t){return e instanceof Error?e:Error(t??h(e))}function re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ie(e){return typeof e==`object`&&!!e}function ae(e){return typeof e==`string`&&e.trim().length>0}function oe(e,t){return re(e)&&typeof e[t]==`string`}m();var _=c(!0),se=c(null);function ce(e){return typeof DOMException<`u`&&e instanceof DOMException&&e.name===`AbortError`||typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`}var v=null;function le(e){v=e}function ue(e){if(!e)return``;let t=[];for(let[n,r]of Object.entries(e))r!==void 0&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`);return t.length===0?``:`?${t.join(`&`)}`}function de(e,t){let n={...e.headers??{}};return t&&n[`Content-Type`]===void 0&&(n[`Content-Type`]=`application/json`),v&&n.Authorization===void 0&&(n.Authorization=`Bearer ${v}`),n}async function fe(e){let{status:t}=e;try{let n=await e.clone().json();if(oe(n,`error`))return{error:n.error,status:t}}catch{}return{error:e.statusText||`Request failed (${t})`,status:t}}async function y(e,t={}){let n=t.method??`GET`,r=t.body!==void 0,i=`${e}${ue(t.query)}`,a={method:n,headers:de(t,r),signal:t.signal};r&&(a.body=JSON.stringify(t.body));let o;try{o=await fetch(i,a)}catch(e){let t=h(e);return ce(e)||(_.value=!1,se.value=t),{ok:!1,error:t,status:0}}if(_.value||(_.value=!0,se.value=null),!o.ok){let{error:e,status:t}=await fe(o);return{ok:!1,error:e,status:t}}try{return{ok:!0,data:await o.json()}}catch(e){return{ok:!1,error:`Invalid JSON response: ${h(e)}`,status:o.status}}}function pe(e,t,n={}){return y(e,{...n,method:`GET`,query:t})}function me(e,t,n={}){return y(e,{...n,method:`POST`,body:t})}function he(e,t,n={}){return y(e,{...n,method:`PUT`,body:t})}function ge(e,t,n={}){return y(e,{...n,method:`DELETE`,body:t})}async function _e(e,t={}){let n=`${e}${ue(t.query)}`,r={method:t.method??`GET`,headers:de(t,!1),body:t.body,signal:t.signal};return fetch(n,r)}var b=Object.create(null);b.open=`0`,b.close=`1`,b.ping=`2`,b.pong=`3`,b.message=`4`,b.upgrade=`5`,b.noop=`6`;var x=Object.create(null);Object.keys(b).forEach(e=>{x[b[e]]=e});var S={type:`error`,data:`parser error`},ve=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,ye=typeof ArrayBuffer==`function`,be=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,xe=({type:e,data:t},n,r)=>ve&&t instanceof Blob?n?r(t):Se(t,r):ye&&(t instanceof ArrayBuffer||be(t))?n?r(t):Se(new Blob([t]),r):r(b[e]+(t||``)),Se=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function Ce(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var we;function Te(e,t){if(ve&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ce).then(t);if(ye&&(e.data instanceof ArrayBuffer||be(e.data)))return t(Ce(e.data));xe(e,!1,e=>{we||=new TextEncoder,t(we.encode(e))})}var Ee=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,C=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)C[Ee.charCodeAt(e)]=e;var De=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=C[e.charCodeAt(r)],o=C[e.charCodeAt(r+1)],s=C[e.charCodeAt(r+2)],c=C[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},Oe=typeof ArrayBuffer==`function`,w=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:Ae(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:ke(e.substring(1),t)}:x[n]?e.length>1?{type:x[n],data:e.substring(1)}:{type:x[n]}:S},ke=(e,t)=>Oe?Ae(De(e),t):{base64:!0,data:e},Ae=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},je=``,Me=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{xe(e,!1,e=>{r[a]=e,++i===n&&t(r.join(je))})})},Ne=(e,t)=>{let n=e.split(je),r=[];for(let e=0;e<n.length;e++){let i=w(n[e],t);if(r.push(i),i.type===`error`)break}return r};function Pe(){return new TransformStream({transform(e,t){Te(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var Fe;function T(e){return e.reduce((e,t)=>e+t.length,0)}function E(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Ie(e,t){Fe||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(T(n)<1)break;let e=E(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(T(n)<2)break;let e=E(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(T(n)<8)break;let e=E(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(S);break}i=a*2**32+t.getUint32(4),r=3}else{if(T(n)<i)break;let e=E(n,i);s.enqueue(w(a?e:Fe.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(S);break}}}})}function D(e){if(e)return Le(e)}function Le(e){for(var t in D.prototype)e[t]=D.prototype[t];return e}D.prototype.on=D.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},D.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},D.prototype.off=D.prototype.removeListener=D.prototype.removeAllListeners=D.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},D.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},D.prototype.emitReserved=D.prototype.emit,D.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},D.prototype.hasListeners=function(e){return!!this.listeners(e).length};var O=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),k=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),Re=`arraybuffer`;function ze(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var Be=k.setTimeout,Ve=k.clearTimeout;function A(e,t){t.useNativeTimers?(e.setTimeoutFn=Be.bind(k),e.clearTimeoutFn=Ve.bind(k)):(e.setTimeoutFn=k.setTimeout.bind(k),e.clearTimeoutFn=k.clearTimeout.bind(k))}var He=1.33;function Ue(e){return typeof e==`string`?We(e):Math.ceil((e.byteLength||e.size)*He)}function We(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Ge(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Ke(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function qe(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var Je=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},j=class extends D{constructor(e){super(),this.writable=!1,A(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new Je(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=w(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=Ke(e);return t.length?`?`+t:``}},Ye=class extends j{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){Ne(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,Me(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ge()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Xe=!1;try{Xe=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Ze=Xe;function Qe(){}var $e=class extends Ye{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},M=class e extends D{constructor(e,t,n){super(),this.createRequest=e,A(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=ze(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=Qe,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(M.requestsCount=0,M.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,et);else if(typeof addEventListener==`function`){let e=`onpagehide`in k?`pagehide`:`unload`;addEventListener(e,et,!1)}}function et(){for(let e in M.requests)M.requests.hasOwnProperty(e)&&M.requests[e].abort()}var tt=(function(){let e=rt({xdomain:!1});return e&&e.responseType!==null})(),nt=class extends $e{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=tt&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new M(rt,this.uri(),e)}};function rt(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Ze))return new XMLHttpRequest}catch{}if(!t)try{return new k[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var it=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,at=class extends j{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=it?{}:ze(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;xe(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&O(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ge()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},ot=k.WebSocket||k.MozWebSocket,st={websocket:class extends at{createSocket(e,t,n){return it?new ot(e,t,n):t?new ot(e,t):new ot(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends j{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=Ie(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=Pe();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&O(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:nt},ct=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,lt=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function N(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=ct.exec(e||``),a={},o=14;for(;o--;)a[lt[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=ut(a,a.path),a.queryKey=dt(a,a.query),a}function ut(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function dt(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var P=typeof addEventListener==`function`&&typeof removeEventListener==`function`,F=[];P&&addEventListener(`offline`,()=>{F.forEach(e=>e())},!1);var I=class e extends D{constructor(e,t){if(super(),this.binaryType=Re,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=N(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=N(t.host).host);A(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=qe(this.opts.query)),P&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},F.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=Ue(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,O(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),P&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=F.indexOf(this._offlineEventListener);e!==-1&&F.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};I.protocol=4;var ft=class extends I{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;I.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;I.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},pt=class extends ft{constructor(e,t={}){let n=typeof e==`object`,r=n?{...e}:{...t};(!r.transports||r.transports&&typeof r.transports[0]==`string`)&&(r.transports=(r.transports||[`polling`,`websocket`,`webtransport`]).map(e=>st[e]).filter(e=>!!e)),super(n?r:e,r)}};pt.protocol;function mt(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=N(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var ht=typeof ArrayBuffer==`function`,gt=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,_t=Object.prototype.toString,vt=typeof Blob==`function`||typeof Blob<`u`&&_t.call(Blob)===`[object BlobConstructor]`,yt=typeof File==`function`||typeof File<`u`&&_t.call(File)===`[object FileConstructor]`;function L(e){return ht&&(e instanceof ArrayBuffer||gt(e))||vt&&e instanceof Blob||yt&&e instanceof File}function R(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(R(e[t]))return!0;return!1}if(L(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return R(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&R(e[t]))return!0;return!1}function bt(e){let t=[],n=e.data,r=e;return r.data=z(n,t),r.attachments=t.length,{packet:r,buffers:t}}function z(e,t){if(!e)return e;if(L(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=z(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=z(e[r],t));return n}return e}function xt(e,t){return e.data=St(e.data,t),delete e.attachments,e}function St(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=St(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=St(e[n],t));return e}var Ct=e({Decoder:()=>Et,Encoder:()=>Tt,PacketType:()=>B,isPacketValid:()=>Mt,protocol:()=>5}),wt=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],B;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(B||={});var Tt=class{constructor(e){this.replacer=e}encode(e){return(e.type===B.EVENT||e.type===B.ACK)&&R(e)?this.encodeAsBinary({type:e.type===B.EVENT?B.BINARY_EVENT:B.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===B.BINARY_EVENT||e.type===B.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=bt(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Et=class e extends D{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===B.BINARY_EVENT;n||t.type===B.BINARY_ACK?(t.type=n?B.EVENT:B.ACK,this.reconstructor=new Dt(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(L(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(B[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===B.BINARY_EVENT||r.type===B.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!kt(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case B.CONNECT:return V(t);case B.DISCONNECT:return t===void 0;case B.CONNECT_ERROR:return typeof t==`string`||V(t);case B.EVENT:case B.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&wt.indexOf(t[0])===-1);case B.ACK:case B.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},Dt=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=xt(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Ot(e){return typeof e==`string`}var kt=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function At(e){return e===void 0||kt(e)}function V(e){return Object.prototype.toString.call(e)===`[object Object]`}function jt(e,t){switch(e){case B.CONNECT:return t===void 0||V(t);case B.DISCONNECT:return t===void 0;case B.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&wt.indexOf(t[0])===-1);case B.ACK:return Array.isArray(t);case B.CONNECT_ERROR:return typeof t==`string`||V(t);default:return!1}}function Mt(e){return Ot(e.nsp)&&At(e.id)&&jt(e.type,e.data)}function H(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Nt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Pt=class extends D{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[H(e,`open`,this.onopen.bind(this)),H(e,`packet`,this.onpacket.bind(this)),H(e,`error`,this.onerror.bind(this)),H(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(Nt.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:B.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:B.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case B.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case B.EVENT:case B.BINARY_EVENT:this.onevent(e);break;case B.ACK:case B.BINARY_ACK:this.onack(e);break;case B.DISCONNECT:this.ondisconnect();break;case B.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:B.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:B.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function U(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}U.prototype.duration=function(){var e=this.ms*this.factor**+this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},U.prototype.reset=function(){this.attempts=0},U.prototype.setMin=function(e){this.ms=e},U.prototype.setMax=function(e){this.max=e},U.prototype.setJitter=function(e){this.jitter=e};var W=class extends D{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,A(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new U({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||Ct;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new pt(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=H(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=H(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(H(e,`ping`,this.onping.bind(this)),H(e,`data`,this.ondata.bind(this)),H(e,`error`,this.onerror.bind(this)),H(e,`close`,this.onclose.bind(this)),H(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){O(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Pt(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},G={};function K(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=mt(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=G[i]&&a in G[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new W(r,t):(G[i]||(G[i]=new W(r,t)),c=G[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(K,{Manager:W,Socket:Pt,io:K,connect:K});var q=null,J=new Map,Y=new Set,X=!1;function Ft(e){for(let t of J.keys())e.emit(`subscribe`,t)}function It(){for(let e of Y)try{e()}catch(e){console.error(`[usePubSub] reconnect handler threw:`,e)}}function Lt(){if(q)return q;let e=K({path:`/ws/pubsub`,transports:[`websocket`]});return e.on(`connect`,()=>{Ft(e),X?It():X=!0}),e.on(`data`,e=>{let t=J.get(e.channel);if(t)for(let n of t)n(e.data)}),q=e,e}function Rt(){J.size>0||q&&(q.disconnect(),q=null,X=!1)}function zt(){function e(e,t){let n=J.get(e);n||(n=new Set,J.set(e,n)),n.add(t);let r=Lt();return r.connected&&r.emit(`subscribe`,e),()=>{let n=J.get(e);n&&(n.delete(t),n.size===0&&(J.delete(e),q?.connected&&q.emit(`unsubscribe`,e)),Rt())}}function t(e){return Y.add(e),()=>{Y.delete(e)}}return{subscribe:e,onReconnect:t}}function Z(e){return e}function Bt(e,t){if(!t)return e.url;let{url:n}=e;for(let[e,r]of Object.entries(t)){let t=`:${e}`;n.includes(t)&&(n=n.split(t).join(encodeURIComponent(String(r))))}return n}var Vt={openBook:`openBook`,getBooks:`getBooks`,createBook:`createBook`,updateBook:`updateBook`,deleteBook:`deleteBook`,getAccounts:`getAccounts`,upsertAccount:`upsertAccount`,addEntries:`addEntries`,voidEntry:`voidEntry`,getJournalEntries:`getJournalEntries`,getOpeningBalances:`getOpeningBalances`,setOpeningBalances:`setOpeningBalances`,getReport:`getReport`,getTimeSeries:`getTimeSeries`,rebuildSnapshots:`rebuildSnapshots`},Ht={dispatch:{path:`/api/accounting`,method:`POST`}};function Ut(e){return`accounting:${e}`}var Wt=`accounting:books`;function Gt(e,t){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let t=e;if(typeof t.details==`string`&&t.details)return t.details;if(typeof t.message==`string`&&t.message)return t.message}return t===void 0?String(e):t}var Kt={accounting:`data/accounting`,accountingBooks:`data/accounting/books`},qt=[1,2,3,4,5,6,7,8,9,10,11,12],Jt={Q1:3,Q2:6,Q3:9,Q4:12};function Yt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=12}function Xt(e){return Yt(e)?e:typeof e==`string`&&Object.hasOwn(Jt,e)?Jt[e]:12}function Zt(e){return Xt(e)}function Qt(e,t){let n=new Date(Date.UTC(2001,e,0));try{return new Intl.DateTimeFormat(t,{month:`long`,day:`numeric`,timeZone:`UTC`}).format(n)}catch{return String(e)}}function $t(e){return String(e).padStart(2,`0`)}function en(e,t){return new Date(e,t+1,0).getDate()}function tn(e,t,n){return`${e}-${$t(t)}-${$t(n)}`}function nn(e,t){let n=Zt(e),r=(t.getMonth()+1-n-1+12)%12;return Math.floor(r/3)}function rn(e,t,n){let r=Zt(e),i=t.getMonth()+1,a=t.getFullYear(),o=r%12+1,s=i>=o?a:a-1,c=o+n*3;return{year:s+Math.floor((c-1)/12),month:(c-1)%12+1}}function Q(e,t,n){let r=rn(e,t,n),i=r.month-1+2,a=r.year+Math.floor(i/12),o=i%12+1,s=en(a,o-1);return{from:tn(r.year,r.month,1),to:tn(a,o,s)}}function an(e,t=new Date){return Q(e,t,nn(e,t))}function on(e,t=new Date){let n=nn(e,t);return n>0?Q(e,t,n-1):Q(e,new Date(t.getFullYear(),t.getMonth()-3,1),3)}function sn(e,t=new Date){let n=Q(e,t,0),r=Q(e,t,3);return{from:n.from,to:r.to}}function cn(e,t=new Date){return sn(e,new Date(t.getFullYear()-1,t.getMonth(),t.getDate()))}var ln=`US.JP.GB.CA.AU.NZ.DE.FR.IT.ES.NL.BE.AT.IE.PT.FI.SE.DK.PL.CH.NO.CN.KR.TW.HK.SG.IN.BR.MX`.split(`.`);function un(e,t){try{return new Intl.DisplayNames([t],{type:`region`}).of(e)??e}catch{return e}}function dn(e){return typeof e==`string`&&ln.includes(e)}var fn={warnMissingTaxRegistrationId:new Set([`JP`,`GB`,`DE`,`FR`,`IT`,`ES`,`NL`,`BE`,`AT`,`IE`,`PT`,`FI`,`SE`,`DK`,`PL`,`IN`,`AU`,`NZ`,`CA`])};function pn(e,t){return t?fn[e].has(t):!1}var mn=[`USD`,`EUR`,`JPY`,`GBP`,`CNY`,`KRW`,`TWD`,`HKD`,`SGD`,`AUD`,`CAD`,`CHF`,`INR`,`BRL`,`MXN`],hn=2;function gn(e,t){try{return new Intl.DisplayNames([t],{type:`currency`}).of(e)??e}catch{return e}}function _n(e){try{return new Intl.NumberFormat(`en`,{style:`currency`,currency:e}).resolvedOptions().maximumFractionDigits??hn}catch{return hn}}function vn(e){let t=_n(e);return t===0?`1`:(1/10**t).toFixed(t)}function yn(e,t,n){try{return new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e)}catch{return e.toFixed(_n(t))}}function bn(e,t=2,n){return e.toLocaleString(n,{minimumFractionDigits:t,maximumFractionDigits:t})}function $(e){return String(e).padStart(2,`0`)}function xn(e=new Date){return`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`}function Sn(e=new Date){return`${e.getFullYear()}-${$(e.getMonth()+1)}`}function Cn(e=new Date){let t=new Date(e.getFullYear(),e.getMonth()-1,1);return`${t.getFullYear()}-${$(t.getMonth()+1)}`}function wn(e=new Date){let t=Math.floor(e.getMonth()/3)*3,n=new Date(e.getFullYear(),t-1,1);return`${n.getFullYear()}-${$(n.getMonth()+1)}`}function Tn(e=new Date){return`${e.getFullYear()-1}-12`}var En=[`revenue`,`expense`,`netIncome`,`accountBalance`],Dn=[`month`,`quarter`,`year`],On=Z({toolName:`manageAccounting`,apiNamespace:`accounting`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`,workspaceDirs:{accounting:Kt.accounting,accountingBooks:Kt.accountingBooks},staticChannels:{accountingBooks:`accounting:books`}}),kn=Z({toolName:`openCanvas`,apiNamespace:`canvas`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`}),An=Z({toolName:`presentChart`,apiNamespace:`chart`,apiRoutes:{create:{method:`POST`,path:``}},mcpDispatch:`create`}),jn=Z({toolName:`editImages`}),Mn=Z({toolName:`generateImage`}),Nn=Z({toolName:`manageSkills`,apiNamespace:`skills`,apiRoutes:{list:{method:`GET`,path:``},detail:{method:`GET`,path:`/:name`},create:{method:`POST`,path:``},update:{method:`PUT`,path:`/:name`},remove:{method:`DELETE`,path:`/:name`},catalogList:{method:`GET`,path:`/catalog`},catalogStar:{method:`POST`,path:`/catalog/star`},catalogPreview:{method:`GET`,path:`/catalog/preview`},externalSuggestions:{method:`GET`,path:`/external/suggestions`},externalReposList:{method:`GET`,path:`/external/repos`},externalReposInstall:{method:`POST`,path:`/external/repos`},externalReposRemove:{method:`DELETE`,path:`/external/repos/:repoId`}},mcpDispatch:`create`}),Pn=Z({toolName:`presentDocument`,apiNamespace:`markdown`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),Fn=Z({toolName:`managePhotoLocations`,apiNamespace:`photoLocations`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`,staticChannels:{locationsChanged:`photoLocations:locations-changed`}}),In=Z({toolName:`presentCollection`,apiNamespace:`presentCollection`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`}),Ln=Z({toolName:`presentForm`,apiNamespace:`form`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`}),Rn=Z({toolName:`presentHtml`,apiNamespace:`html`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),zn=Z({toolName:`presentMulmoScript`,apiNamespace:`mulmoScript`,apiRoutes:{save:{method:`POST`,path:`/save`},updateBeat:{method:`POST`,path:`/update-beat`},updateScript:{method:`POST`,path:`/update-script`},beatImage:{method:`GET`,path:`/beat-image`},beatAudio:{method:`GET`,path:`/beat-audio`},beatMovie:{method:`GET`,path:`/beat-movie`},generateBeatAudio:{method:`POST`,path:`/generate-beat-audio`},renderBeat:{method:`POST`,path:`/render-beat`},uploadBeatImage:{method:`POST`,path:`/upload-beat-image`},characterImage:{method:`GET`,path:`/character-image`},renderCharacter:{method:`POST`,path:`/render-character`},uploadCharacterImage:{method:`POST`,path:`/upload-character-image`},movieStatus:{method:`GET`,path:`/movie-status`},generateMovie:{method:`POST`,path:`/generate-movie`},downloadMovie:{method:`GET`,path:`/download-movie`},pdfStatus:{method:`GET`,path:`/pdf-status`},generatePdf:{method:`POST`,path:`/generate-pdf`},downloadPdf:{method:`GET`,path:`/download-pdf`}},mcpDispatch:`save`,requires:[`ffmpeg`]}),Bn=Z({toolName:`presentSVG`,apiNamespace:`svg`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),Vn=Z({toolName:`manageAutomations`,apiNamespace:`scheduler`,apiRoutes:{list:{method:`GET`,path:``},dispatch:{method:`POST`,path:``},tasksList:{method:`GET`,path:`/tasks`},tasksCreate:{method:`POST`,path:`/tasks`},taskUpdate:{method:`PUT`,path:`/tasks/:id`},taskDelete:{method:`DELETE`,path:`/tasks/:id`},taskRun:{method:`POST`,path:`/tasks/:id/run`},logs:{method:`GET`,path:`/logs`}},mcpDispatch:`dispatch`}),Hn=Z({toolName:`presentSpreadsheet`,apiNamespace:`spreadsheet`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),Un=[On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Z({toolName:`manageWiki`})];function Wn(e,t,n){let r={},i={},a=[];for(let o of e){let e=t(o);if(e)for(let[t,s]of Object.entries(e)){let e=i[t];if(e!==void 0){a.push({dimension:n,key:t,plugins:[e,o.toolName]});continue}r[t]=s,i[t]=o.toolName}}return{aggregate:r,owner:i,collisions:a}}function Gn(e,t,n,r){let i={},a=[];for(let[o,s]of Object.entries(n)){if(t.has(o)){a.push({label:e,key:o,plugin:r[o]??``});continue}i[o]=s}return{cleaned:i,dropped:a}}function Kn(e,t){let{aggregate:n,owner:r,collisions:i}=Wn(e,t.extract,t.dimension),a=new Set(Object.keys(t.hostRecord));if(t.additionalReservedKeys)for(let e of t.additionalReservedKeys)a.add(e);let{cleaned:o,dropped:s}=Gn(t.label,a,n,r);return{merged:{...t.hostRecord,...o},hostCollisions:s,intraCollisions:i}}var qn={message:`/api/transports/:transportId/chats/:externalChatId`,connect:`/api/transports/:transportId/chats/:externalChatId/connect`};function Jn(e,t){let n={};for(let[r,i]of Object.entries(t))n[r]={method:i.method,url:`/api/${e}${i.path}`};return n}var Yn=Kn(Un,{label:`API_ROUTES`,hostRecord:{health:`/api/health`,sandbox:`/api/sandbox`,shortcuts:`/api/shortcuts`,dashboard:`/api/dashboard`,agent:{run:`/api/agent`,cancel:`/api/agent/cancel`,internal:{toolResult:`/api/internal/tool-result`}},chatIndex:{rebuild:`/api/chat-index/rebuild`},chatService:qn,config:{base:`/api/config`,settings:`/api/config/settings`,mcp:`/api/config/mcp`,workspaceDirs:`/api/config/workspace-dirs`,referenceDirs:`/api/config/reference-dirs`,schedulerOverrides:`/api/config/scheduler-overrides`,refresh:`/api/config/refresh`,connectors:`/api/config/connectors`},files:{tree:`/api/files/tree`,dir:`/api/files/dir`,content:`/api/files/content`,create:`/api/files/create`,raw:`/api/files/raw`,refRoots:`/api/files/ref-roots`,open:`/api/files/open`,reveal:`/api/files/reveal`},image:{generate:`/api/generate-image`,edit:`/api/edit-image`,upload:`/api/images`,update:`/api/images/update`},attachments:{upload:`/api/attachments`},share:{pack:`/api/share/pack`,packMarkdown:`/api/share/pack-markdown`},remoteHost:{connect:`/api/remote-host/connect`,reconnect:`/api/remote-host/reconnect`,disconnect:`/api/remote-host/disconnect`,status:`/api/remote-host/status`},google:{status:`/api/google/status`,authorize:`/api/google/authorize`,unlink:`/api/google/unlink`},mcpTools:{list:`/api/mcp-tools`,invoke:`/api/mcp-tools/:tool`},notifier:{dispatch:`/api/notifier`},journal:{latestDaily:`/api/journal/latest-daily`},pdf:{markdown:`/api/pdf/markdown`},translation:{translate:`/api/translation`},transcribe:{run:`/api/transcribe`,model:`/api/transcribe/model`,modelDownload:`/api/transcribe/model/download`},plugins:{mindmap:`/api/mindmap`,quiz:`/api/quiz`,present3d:`/api/present3d`,googleMap:`/api/google-map`,runtimeList:`/api/plugins/runtime/list`,runtimeDispatch:`/api/plugins/runtime/:pkg/dispatch`,runtimeOauthCallback:`/api/plugins/runtime/oauth-callback/:alias`,diagnostics:`/api/plugins/diagnostics`,runtimeAsset:`/api/plugins/runtime/:pkg/:version/{*splat}`},roles:{list:`/api/roles`,manage:`/api/roles/manage`},marpThemes:{list:`/api/marp-themes`},collections:{list:`/api/collections`,detail:`/api/collections/:slug`,items:`/api/collections/:slug/items`,item:`/api/collections/:slug/items/:itemId`,itemAction:`/api/collections/:slug/items/:itemId/actions/:actionId`,collectionAction:`/api/collections/:slug/actions/:actionId`,refresh:`/api/collections/:slug/refresh`,viewFile:`/api/collections/:slug/view-file`,remoteView:`/api/collections/:slug/remote-view`,remoteViewMutate:`/api/collections/:slug/remote-view/:viewId/mutate`,remoteViewItems:`/api/collections/:slug/remote-view/:viewId/items`,viewI18n:`/api/collections/:slug/view-i18n`,viewToken:`/api/collections/:slug/view-token`,viewData:`/api/collections/:slug/view-data`,viewDataAction:`/api/collections/:slug/view-data/actions/:actionId`,viewDelete:`/api/collections/:slug/views/:viewId`},collectionsRegistry:{list:`/api/collections-registry`,preview:`/api/collections-registry/preview`,import:`/api/collections-registry/import`,export:`/api/collections-registry/export`},sessions:{list:`/api/sessions`,detail:`/api/sessions/:id`,markRead:`/api/sessions/:id/mark-read`,bookmark:`/api/sessions/:id/bookmark`},feeds:{list:`/api/feeds`,detail:`/api/feeds/:slug`},hooks:{log:`/api/hooks/log`},wiki:{base:`/api/wiki`,pageHistory:`/api/wiki/pages/:slug/history`,pageHistorySnapshot:`/api/wiki/pages/:slug/history/:stamp`,pageHistoryRestore:`/api/wiki/pages/:slug/history/:stamp/restore`,internalSnapshot:`/api/wiki/internal/snapshot`}},extract:e=>{if(e.apiRoutes===void 0)return;let t=e.apiNamespace??e.toolName;return{[t]:Jn(t,e.apiRoutes)}},dimension:`apiNamespace`});Yn.hostCollisions,Yn.intraCollisions;var Xn=Yn.merged;p();function Zn(e,t){return`plugin:${e}:${t}`}function Qn(e){let{subscribe:t}=zt();return{subscribe(n,r){return t(Zn(e,n),r)}}}function $n(e){let t=`[plugin/${e}]`;return{debug:(e,n)=>console.debug(t,e,n),info:(e,n)=>console.info(t,e,n),warn:(e,n)=>console.warn(t,e,n),error:(e,n)=>console.error(t,e,n)}}var er=new Set([`http:`,`https:`]);function tr(e){return t=>{let n;try{n=new URL(t)}catch{console.warn(`[plugin/${e}] openUrl rejected unparseable URL`,{url:t});return}if(!er.has(n.protocol)){console.warn(`[plugin/${e}] openUrl rejected non-http(s) scheme`,{scheme:n.protocol});return}window.open(t,`_blank`,`noopener,noreferrer`)||console.warn(`[plugin/${e}] window.open returned null`,{url:t})}}function nr(e){let t=Xn.plugins.runtimeDispatch.replace(`:pkg`,encodeURIComponent(e));return async n=>{let r=await me(t,n);if(!r.ok)throw Error(`plugin/${e} dispatch failed (${r.status}): ${r.error}`);return r.data}}function rr(e){let{pkgName:t,endpoints:r}=e,{locale:i}=te(),a=n(()=>String(i.value));return{pubsub:Qn(t),locale:a,log:$n(t),openUrl:tr(t),dispatch:nr(t),endpoints:r}}p(),m();function ir(e){let t=c(null),r=c(!1),i=c(0),a=n(()=>{if(!t.value)return``;let e=t.value.message||String(t.value),n=t.value.stack??``;return n?`${e}\n\n${n}`:e});function o(n){let r=g(n);console.error(`[plugin/${e}] uncaught error`,r),t.value=r}function s(){t.value=null,r.value=!1,i.value+=1}return{error:t,showDetails:r,mountKey:i,errorDetails:a,captureError:o,retry:s}}p(),m(),u();var ar={key:0,class:`rounded border border-red-200 bg-red-50 p-3 text-sm`,"data-testid":`plugin-error-boundary`,role:`alert`},or={class:`flex items-center gap-2 mb-1`},sr={class:`font-medium text-red-800`},cr={class:`text-red-700 mb-2`},lr={class:`flex items-center gap-3`},ur={key:0,class:`mt-2 text-xs text-red-900 bg-red-100 p-2 rounded overflow-auto max-h-40 whitespace-pre-wrap break-words`},dr=l({__name:`PluginScopedRoot`,props:{pkgName:{},endpoints:{}},setup(e){let n=e,{t:c}=te();ee(ne,rr({pkgName:n.pkgName,endpoints:n.endpoints}));let{error:l,showDetails:u,mountKey:p,errorDetails:m,captureError:h,retry:g}=ir(n.pkgName);return a(e=>(h(e),!1)),(n,a)=>f(l)?(t(),o(`div`,ar,[d(`div`,or,[a[2]||=d(`span`,{class:`material-icons text-red-500`,"aria-hidden":`true`},`error_outline`,-1),d(`span`,sr,r(f(c)(`pluginErrorBoundary.title`,{pkg:e.pkgName})),1)]),d(`p`,cr,r(f(c)(`pluginErrorBoundary.subtitle`)),1),d(`div`,lr,[d(`button`,{type:`button`,class:`text-xs text-red-600 hover:underline`,"data-testid":`plugin-error-toggle-details`,onClick:a[0]||=e=>u.value=!f(u)},r(f(u)?f(c)(`pluginErrorBoundary.hideDetails`):f(c)(`pluginErrorBoundary.showDetails`)),1),d(`button`,{type:`button`,class:`text-xs text-red-600 hover:underline`,"data-testid":`plugin-error-retry`,onClick:a[1]||=(...e)=>f(g)&&f(g)(...e)},r(f(c)(`pluginErrorBoundary.retry`)),1)]),f(u)?(t(),o(`pre`,ur,r(f(m)),1)):s(``,!0)])):i(n.$slots,`default`,{key:f(p)})}}),fr=e({default:()=>pr}),pr=dr;export{_ as $,Gt as A,gn as B,Dn as C,sn as D,pn as E,dn as F,Bt as G,Cn as H,wn as I,ge as J,zt as K,xn as L,yn as M,bn as N,an as O,vn as P,he as Q,Sn as R,mn as S,Ut as T,on as U,cn as V,Xt as W,pe as X,_e as Y,me as Z,Vt as _,Kn as a,h as at,qt as b,zn as c,In as d,se as et,Fn as f,On as g,kn as h,Un as i,re as it,Qt as j,Tn as k,Rn as l,An as m,fr as n,ae as nt,Hn as o,g as ot,Nn as p,y as q,Xn as r,ie as rt,Bn as s,pr as t,le as tt,Ln as u,Ht as v,En as w,ln as x,Wt as y,un as z};
1
+ import{r as e}from"./rolldown-runtime-CNC7AqOf.js";import{Gt as t,K as n,Nr as r,Qt as i,Rt as a,X as o,Y as s,Zn as c,at as l,hr as u,q as d,qt as ee,sr as f,wt as p,zn as m}from"./vue.runtime.esm-bundler-DQ_ijuEl.js";import{n as te}from"./vue-i18n-CSwCKaug.js";import{t as ne}from"./vue-BDAhqvzw.js";function h(e,t){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let t=e;if(typeof t.details==`string`&&t.details)return t.details;if(typeof t.message==`string`&&t.message)return t.message}return t===void 0?String(e):t}function g(e,t){return e instanceof Error?e:Error(t??h(e))}function re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ie(e){return typeof e==`object`&&!!e}function ae(e){return typeof e==`string`&&e.trim().length>0}function oe(e,t){return re(e)&&typeof e[t]==`string`}m();var _=c(!0),se=c(null);function ce(e){return typeof DOMException<`u`&&e instanceof DOMException&&e.name===`AbortError`||typeof e==`object`&&!!e&&`name`in e&&e.name===`AbortError`}var v=null;function le(e){v=e}function ue(e){if(!e)return``;let t=[];for(let[n,r]of Object.entries(e))r!==void 0&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(String(r))}`);return t.length===0?``:`?${t.join(`&`)}`}function de(e,t){let n={...e.headers??{}};return t&&n[`Content-Type`]===void 0&&(n[`Content-Type`]=`application/json`),v&&n.Authorization===void 0&&(n.Authorization=`Bearer ${v}`),n}async function fe(e){let{status:t}=e;try{let n=await e.clone().json();if(oe(n,`error`))return{error:n.error,status:t}}catch{}return{error:e.statusText||`Request failed (${t})`,status:t}}async function y(e,t={}){let n=t.method??`GET`,r=t.body!==void 0,i=`${e}${ue(t.query)}`,a={method:n,headers:de(t,r),signal:t.signal};r&&(a.body=JSON.stringify(t.body));let o;try{o=await fetch(i,a)}catch(e){let t=h(e);return ce(e)||(_.value=!1,se.value=t),{ok:!1,error:t,status:0}}if(_.value||(_.value=!0,se.value=null),!o.ok){let{error:e,status:t}=await fe(o);return{ok:!1,error:e,status:t}}try{return{ok:!0,data:await o.json()}}catch(e){return{ok:!1,error:`Invalid JSON response: ${h(e)}`,status:o.status}}}function pe(e,t,n={}){return y(e,{...n,method:`GET`,query:t})}function me(e,t,n={}){return y(e,{...n,method:`POST`,body:t})}function he(e,t,n={}){return y(e,{...n,method:`PUT`,body:t})}function ge(e,t,n={}){return y(e,{...n,method:`DELETE`,body:t})}async function _e(e,t={}){let n=`${e}${ue(t.query)}`,r={method:t.method??`GET`,headers:de(t,!1),body:t.body,signal:t.signal};return fetch(n,r)}var b=Object.create(null);b.open=`0`,b.close=`1`,b.ping=`2`,b.pong=`3`,b.message=`4`,b.upgrade=`5`,b.noop=`6`;var x=Object.create(null);Object.keys(b).forEach(e=>{x[b[e]]=e});var S={type:`error`,data:`parser error`},ve=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,ye=typeof ArrayBuffer==`function`,be=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,xe=({type:e,data:t},n,r)=>ve&&t instanceof Blob?n?r(t):Se(t,r):ye&&(t instanceof ArrayBuffer||be(t))?n?r(t):Se(new Blob([t]),r):r(b[e]+(t||``)),Se=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function Ce(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var we;function Te(e,t){if(ve&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ce).then(t);if(ye&&(e.data instanceof ArrayBuffer||be(e.data)))return t(Ce(e.data));xe(e,!1,e=>{we||=new TextEncoder,t(we.encode(e))})}var Ee=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,C=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)C[Ee.charCodeAt(e)]=e;var De=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=C[e.charCodeAt(r)],o=C[e.charCodeAt(r+1)],s=C[e.charCodeAt(r+2)],c=C[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},Oe=typeof ArrayBuffer==`function`,w=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:Ae(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:ke(e.substring(1),t)}:x[n]?e.length>1?{type:x[n],data:e.substring(1)}:{type:x[n]}:S},ke=(e,t)=>Oe?Ae(De(e),t):{base64:!0,data:e},Ae=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},je=``,Me=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{xe(e,!1,e=>{r[a]=e,++i===n&&t(r.join(je))})})},Ne=(e,t)=>{let n=e.split(je),r=[];for(let e=0;e<n.length;e++){let i=w(n[e],t);if(r.push(i),i.type===`error`)break}return r};function Pe(){return new TransformStream({transform(e,t){Te(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var Fe;function T(e){return e.reduce((e,t)=>e+t.length,0)}function E(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Ie(e,t){Fe||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(T(n)<1)break;let e=E(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(T(n)<2)break;let e=E(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(T(n)<8)break;let e=E(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(S);break}i=a*2**32+t.getUint32(4),r=3}else{if(T(n)<i)break;let e=E(n,i);s.enqueue(w(a?e:Fe.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(S);break}}}})}function D(e){if(e)return Le(e)}function Le(e){for(var t in D.prototype)e[t]=D.prototype[t];return e}D.prototype.on=D.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},D.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},D.prototype.off=D.prototype.removeListener=D.prototype.removeAllListeners=D.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},D.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},D.prototype.emitReserved=D.prototype.emit,D.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},D.prototype.hasListeners=function(e){return!!this.listeners(e).length};var O=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),k=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),Re=`arraybuffer`;function ze(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var Be=k.setTimeout,Ve=k.clearTimeout;function A(e,t){t.useNativeTimers?(e.setTimeoutFn=Be.bind(k),e.clearTimeoutFn=Ve.bind(k)):(e.setTimeoutFn=k.setTimeout.bind(k),e.clearTimeoutFn=k.clearTimeout.bind(k))}var He=1.33;function Ue(e){return typeof e==`string`?We(e):Math.ceil((e.byteLength||e.size)*He)}function We(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Ge(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Ke(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function qe(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var Je=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},j=class extends D{constructor(e){super(),this.writable=!1,A(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new Je(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=w(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=Ke(e);return t.length?`?`+t:``}},Ye=class extends j{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){Ne(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,Me(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ge()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Xe=!1;try{Xe=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Ze=Xe;function Qe(){}var $e=class extends Ye{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},M=class e extends D{constructor(e,t,n){super(),this.createRequest=e,A(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=ze(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=Qe,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(M.requestsCount=0,M.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,et);else if(typeof addEventListener==`function`){let e=`onpagehide`in k?`pagehide`:`unload`;addEventListener(e,et,!1)}}function et(){for(let e in M.requests)M.requests.hasOwnProperty(e)&&M.requests[e].abort()}var tt=(function(){let e=rt({xdomain:!1});return e&&e.responseType!==null})(),nt=class extends $e{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=tt&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new M(rt,this.uri(),e)}};function rt(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Ze))return new XMLHttpRequest}catch{}if(!t)try{return new k[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var it=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,at=class extends j{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=it?{}:ze(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;xe(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&O(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Ge()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},ot=k.WebSocket||k.MozWebSocket,st={websocket:class extends at{createSocket(e,t,n){return it?new ot(e,t,n):t?new ot(e,t):new ot(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends j{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=Ie(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=Pe();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&O(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:nt},ct=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,lt=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function N(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=ct.exec(e||``),a={},o=14;for(;o--;)a[lt[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=ut(a,a.path),a.queryKey=dt(a,a.query),a}function ut(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function dt(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var P=typeof addEventListener==`function`&&typeof removeEventListener==`function`,F=[];P&&addEventListener(`offline`,()=>{F.forEach(e=>e())},!1);var I=class e extends D{constructor(e,t){if(super(),this.binaryType=Re,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=N(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=N(t.host).host);A(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=qe(this.opts.query)),P&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},F.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=Ue(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,O(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),P&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=F.indexOf(this._offlineEventListener);e!==-1&&F.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};I.protocol=4;var ft=class extends I{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;I.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;I.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},pt=class extends ft{constructor(e,t={}){let n=typeof e==`object`,r=n?{...e}:{...t};(!r.transports||r.transports&&typeof r.transports[0]==`string`)&&(r.transports=(r.transports||[`polling`,`websocket`,`webtransport`]).map(e=>st[e]).filter(e=>!!e)),super(n?r:e,r)}};pt.protocol;function mt(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=N(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var ht=typeof ArrayBuffer==`function`,gt=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,_t=Object.prototype.toString,vt=typeof Blob==`function`||typeof Blob<`u`&&_t.call(Blob)===`[object BlobConstructor]`,yt=typeof File==`function`||typeof File<`u`&&_t.call(File)===`[object FileConstructor]`;function L(e){return ht&&(e instanceof ArrayBuffer||gt(e))||vt&&e instanceof Blob||yt&&e instanceof File}function R(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(R(e[t]))return!0;return!1}if(L(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return R(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&R(e[t]))return!0;return!1}function bt(e){let t=[],n=e.data,r=e;return r.data=z(n,t),r.attachments=t.length,{packet:r,buffers:t}}function z(e,t){if(!e)return e;if(L(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=z(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=z(e[r],t));return n}return e}function xt(e,t){return e.data=St(e.data,t),delete e.attachments,e}function St(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=St(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=St(e[n],t));return e}var Ct=e({Decoder:()=>Et,Encoder:()=>Tt,PacketType:()=>B,isPacketValid:()=>Mt,protocol:()=>5}),wt=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],B;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(B||={});var Tt=class{constructor(e){this.replacer=e}encode(e){return(e.type===B.EVENT||e.type===B.ACK)&&R(e)?this.encodeAsBinary({type:e.type===B.EVENT?B.BINARY_EVENT:B.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===B.BINARY_EVENT||e.type===B.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=bt(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Et=class e extends D{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===B.BINARY_EVENT;n||t.type===B.BINARY_ACK?(t.type=n?B.EVENT:B.ACK,this.reconstructor=new Dt(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(L(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(B[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===B.BINARY_EVENT||r.type===B.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!kt(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case B.CONNECT:return V(t);case B.DISCONNECT:return t===void 0;case B.CONNECT_ERROR:return typeof t==`string`||V(t);case B.EVENT:case B.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&wt.indexOf(t[0])===-1);case B.ACK:case B.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},Dt=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=xt(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Ot(e){return typeof e==`string`}var kt=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function At(e){return e===void 0||kt(e)}function V(e){return Object.prototype.toString.call(e)===`[object Object]`}function jt(e,t){switch(e){case B.CONNECT:return t===void 0||V(t);case B.DISCONNECT:return t===void 0;case B.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&wt.indexOf(t[0])===-1);case B.ACK:return Array.isArray(t);case B.CONNECT_ERROR:return typeof t==`string`||V(t);default:return!1}}function Mt(e){return Ot(e.nsp)&&At(e.id)&&jt(e.type,e.data)}function H(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Nt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Pt=class extends D{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[H(e,`open`,this.onopen.bind(this)),H(e,`packet`,this.onpacket.bind(this)),H(e,`error`,this.onerror.bind(this)),H(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(Nt.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:B.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:B.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case B.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case B.EVENT:case B.BINARY_EVENT:this.onevent(e);break;case B.ACK:case B.BINARY_ACK:this.onack(e);break;case B.DISCONNECT:this.ondisconnect();break;case B.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:B.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:B.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function U(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}U.prototype.duration=function(){var e=this.ms*this.factor**+this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},U.prototype.reset=function(){this.attempts=0},U.prototype.setMin=function(e){this.ms=e},U.prototype.setMax=function(e){this.max=e},U.prototype.setJitter=function(e){this.jitter=e};var W=class extends D{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,A(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new U({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||Ct;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new pt(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=H(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=H(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(H(e,`ping`,this.onping.bind(this)),H(e,`data`,this.ondata.bind(this)),H(e,`error`,this.onerror.bind(this)),H(e,`close`,this.onclose.bind(this)),H(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){O(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Pt(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},G={};function K(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=mt(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=G[i]&&a in G[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new W(r,t):(G[i]||(G[i]=new W(r,t)),c=G[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(K,{Manager:W,Socket:Pt,io:K,connect:K});var q=null,J=new Map,Y=new Set,X=!1;function Ft(e){for(let t of J.keys())e.emit(`subscribe`,t)}function It(){for(let e of Y)try{e()}catch(e){console.error(`[usePubSub] reconnect handler threw:`,e)}}function Lt(){if(q)return q;let e=K({path:`/ws/pubsub`,transports:[`websocket`]});return e.on(`connect`,()=>{Ft(e),X?It():X=!0}),e.on(`data`,e=>{let t=J.get(e.channel);if(t)for(let n of t)n(e.data)}),q=e,e}function Rt(){J.size>0||q&&(q.disconnect(),q=null,X=!1)}function zt(){function e(e,t){let n=J.get(e);n||(n=new Set,J.set(e,n)),n.add(t);let r=Lt();return r.connected&&r.emit(`subscribe`,e),()=>{let n=J.get(e);n&&(n.delete(t),n.size===0&&(J.delete(e),q?.connected&&q.emit(`unsubscribe`,e)),Rt())}}function t(e){return Y.add(e),()=>{Y.delete(e)}}return{subscribe:e,onReconnect:t}}function Z(e){return e}function Bt(e,t){if(!t)return e.url;let{url:n}=e;for(let[e,r]of Object.entries(t)){let t=`:${e}`;n.includes(t)&&(n=n.split(t).join(encodeURIComponent(String(r))))}return n}var Vt={openBook:`openBook`,getBooks:`getBooks`,createBook:`createBook`,updateBook:`updateBook`,deleteBook:`deleteBook`,getAccounts:`getAccounts`,upsertAccount:`upsertAccount`,addEntries:`addEntries`,voidEntry:`voidEntry`,getJournalEntries:`getJournalEntries`,getOpeningBalances:`getOpeningBalances`,setOpeningBalances:`setOpeningBalances`,getReport:`getReport`,getTimeSeries:`getTimeSeries`,rebuildSnapshots:`rebuildSnapshots`},Ht={dispatch:{path:`/api/accounting`,method:`POST`}};function Ut(e){return`accounting:${e}`}var Wt=`accounting:books`;function Gt(e,t){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let t=e;if(typeof t.details==`string`&&t.details)return t.details;if(typeof t.message==`string`&&t.message)return t.message}return t===void 0?String(e):t}var Kt={accounting:`data/accounting`,accountingBooks:`data/accounting/books`},qt=[1,2,3,4,5,6,7,8,9,10,11,12],Jt={Q1:3,Q2:6,Q3:9,Q4:12};function Yt(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=12}function Xt(e){return Yt(e)?e:typeof e==`string`&&Object.hasOwn(Jt,e)?Jt[e]:12}function Zt(e){return Xt(e)}function Qt(e,t){let n=new Date(Date.UTC(2001,e,0));try{return new Intl.DateTimeFormat(t,{month:`long`,day:`numeric`,timeZone:`UTC`}).format(n)}catch{return String(e)}}function $t(e){return String(e).padStart(2,`0`)}function en(e,t){return new Date(e,t+1,0).getDate()}function tn(e,t,n){return`${e}-${$t(t)}-${$t(n)}`}function nn(e,t){let n=Zt(e),r=(t.getMonth()+1-n-1+12)%12;return Math.floor(r/3)}function rn(e,t,n){let r=Zt(e),i=t.getMonth()+1,a=t.getFullYear(),o=r%12+1,s=i>=o?a:a-1,c=o+n*3;return{year:s+Math.floor((c-1)/12),month:(c-1)%12+1}}function Q(e,t,n){let r=rn(e,t,n),i=r.month-1+2,a=r.year+Math.floor(i/12),o=i%12+1,s=en(a,o-1);return{from:tn(r.year,r.month,1),to:tn(a,o,s)}}function an(e,t=new Date){return Q(e,t,nn(e,t))}function on(e,t=new Date){let n=nn(e,t);return n>0?Q(e,t,n-1):Q(e,new Date(t.getFullYear(),t.getMonth()-3,1),3)}function sn(e,t=new Date){let n=Q(e,t,0),r=Q(e,t,3);return{from:n.from,to:r.to}}function cn(e,t=new Date){return sn(e,new Date(t.getFullYear()-1,t.getMonth(),t.getDate()))}var ln=`US.JP.GB.CA.AU.NZ.DE.FR.IT.ES.NL.BE.AT.IE.PT.FI.SE.DK.PL.CH.NO.CN.KR.TW.HK.SG.IN.BR.MX`.split(`.`);function un(e,t){try{return new Intl.DisplayNames([t],{type:`region`}).of(e)??e}catch{return e}}function dn(e){return typeof e==`string`&&ln.includes(e)}var fn={warnMissingTaxRegistrationId:new Set([`JP`,`GB`,`DE`,`FR`,`IT`,`ES`,`NL`,`BE`,`AT`,`IE`,`PT`,`FI`,`SE`,`DK`,`PL`,`IN`,`AU`,`NZ`,`CA`])};function pn(e,t){return t?fn[e].has(t):!1}var mn=[`USD`,`EUR`,`JPY`,`GBP`,`CNY`,`KRW`,`TWD`,`HKD`,`SGD`,`AUD`,`CAD`,`CHF`,`INR`,`BRL`,`MXN`],hn=2;function gn(e,t){try{return new Intl.DisplayNames([t],{type:`currency`}).of(e)??e}catch{return e}}function _n(e){try{return new Intl.NumberFormat(`en`,{style:`currency`,currency:e}).resolvedOptions().maximumFractionDigits??hn}catch{return hn}}function vn(e){let t=_n(e);return t===0?`1`:(1/10**t).toFixed(t)}function yn(e,t,n){try{return new Intl.NumberFormat(n,{style:`currency`,currency:t}).format(e)}catch{return e.toFixed(_n(t))}}function bn(e,t=2,n){return e.toLocaleString(n,{minimumFractionDigits:t,maximumFractionDigits:t})}function $(e){return String(e).padStart(2,`0`)}function xn(e=new Date){return`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`}function Sn(e=new Date){return`${e.getFullYear()}-${$(e.getMonth()+1)}`}function Cn(e=new Date){let t=new Date(e.getFullYear(),e.getMonth()-1,1);return`${t.getFullYear()}-${$(t.getMonth()+1)}`}function wn(e=new Date){let t=Math.floor(e.getMonth()/3)*3,n=new Date(e.getFullYear(),t-1,1);return`${n.getFullYear()}-${$(n.getMonth()+1)}`}function Tn(e=new Date){return`${e.getFullYear()-1}-12`}var En=[`revenue`,`expense`,`netIncome`,`accountBalance`],Dn=[`month`,`quarter`,`year`],On=Z({toolName:`manageAccounting`,apiNamespace:`accounting`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`,workspaceDirs:{accounting:Kt.accounting,accountingBooks:Kt.accountingBooks},staticChannels:{accountingBooks:`accounting:books`}}),kn=Z({toolName:`openCanvas`,apiNamespace:`canvas`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`}),An=Z({toolName:`presentChart`,apiNamespace:`chart`,apiRoutes:{create:{method:`POST`,path:``}},mcpDispatch:`create`}),jn=Z({toolName:`editImages`}),Mn=Z({toolName:`generateImage`}),Nn=Z({toolName:`manageSkills`,apiNamespace:`skills`,apiRoutes:{list:{method:`GET`,path:``},detail:{method:`GET`,path:`/:name`},create:{method:`POST`,path:``},update:{method:`PUT`,path:`/:name`},remove:{method:`DELETE`,path:`/:name`},catalogList:{method:`GET`,path:`/catalog`},catalogStar:{method:`POST`,path:`/catalog/star`},catalogPreview:{method:`GET`,path:`/catalog/preview`},externalSuggestions:{method:`GET`,path:`/external/suggestions`},externalReposList:{method:`GET`,path:`/external/repos`},externalReposInstall:{method:`POST`,path:`/external/repos`},externalReposRemove:{method:`DELETE`,path:`/external/repos/:repoId`}},mcpDispatch:`create`}),Pn=Z({toolName:`presentDocument`,apiNamespace:`markdown`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),Fn=Z({toolName:`managePhotoLocations`,apiNamespace:`photoLocations`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`,staticChannels:{locationsChanged:`photoLocations:locations-changed`}}),In=Z({toolName:`presentCollection`,apiNamespace:`presentCollection`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`}),Ln=Z({toolName:`presentForm`,apiNamespace:`form`,apiRoutes:{dispatch:{method:`POST`,path:``}},mcpDispatch:`dispatch`}),Rn=Z({toolName:`presentHtml`,apiNamespace:`html`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),zn=Z({toolName:`presentMulmoScript`,apiNamespace:`mulmoScript`,apiRoutes:{save:{method:`POST`,path:`/save`},updateBeat:{method:`POST`,path:`/update-beat`},updateScript:{method:`POST`,path:`/update-script`},beatImage:{method:`GET`,path:`/beat-image`},beatAudio:{method:`GET`,path:`/beat-audio`},beatMovie:{method:`GET`,path:`/beat-movie`},generateBeatAudio:{method:`POST`,path:`/generate-beat-audio`},renderBeat:{method:`POST`,path:`/render-beat`},uploadBeatImage:{method:`POST`,path:`/upload-beat-image`},characterImage:{method:`GET`,path:`/character-image`},renderCharacter:{method:`POST`,path:`/render-character`},uploadCharacterImage:{method:`POST`,path:`/upload-character-image`},movieStatus:{method:`GET`,path:`/movie-status`},generateMovie:{method:`POST`,path:`/generate-movie`},downloadMovie:{method:`GET`,path:`/download-movie`},pdfStatus:{method:`GET`,path:`/pdf-status`},generatePdf:{method:`POST`,path:`/generate-pdf`},downloadPdf:{method:`GET`,path:`/download-pdf`}},mcpDispatch:`save`,requires:[`ffmpeg`]}),Bn=Z({toolName:`presentSVG`,apiNamespace:`svg`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),Vn=Z({toolName:`manageAutomations`,apiNamespace:`scheduler`,apiRoutes:{list:{method:`GET`,path:``},dispatch:{method:`POST`,path:``},tasksList:{method:`GET`,path:`/tasks`},tasksCreate:{method:`POST`,path:`/tasks`},taskUpdate:{method:`PUT`,path:`/tasks/:id`},taskDelete:{method:`DELETE`,path:`/tasks/:id`},taskRun:{method:`POST`,path:`/tasks/:id/run`},logs:{method:`GET`,path:`/logs`}},mcpDispatch:`dispatch`}),Hn=Z({toolName:`presentSpreadsheet`,apiNamespace:`spreadsheet`,apiRoutes:{create:{method:`POST`,path:``},update:{method:`PUT`,path:`/update`}},mcpDispatch:`create`}),Un=[On,kn,An,jn,Mn,Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn,Hn,Z({toolName:`manageWiki`})];function Wn(e,t,n){let r={},i={},a=[];for(let o of e){let e=t(o);if(e)for(let[t,s]of Object.entries(e)){let e=i[t];if(e!==void 0){a.push({dimension:n,key:t,plugins:[e,o.toolName]});continue}r[t]=s,i[t]=o.toolName}}return{aggregate:r,owner:i,collisions:a}}function Gn(e,t,n,r){let i={},a=[];for(let[o,s]of Object.entries(n)){if(t.has(o)){a.push({label:e,key:o,plugin:r[o]??``});continue}i[o]=s}return{cleaned:i,dropped:a}}function Kn(e,t){let{aggregate:n,owner:r,collisions:i}=Wn(e,t.extract,t.dimension),a=new Set(Object.keys(t.hostRecord));if(t.additionalReservedKeys)for(let e of t.additionalReservedKeys)a.add(e);let{cleaned:o,dropped:s}=Gn(t.label,a,n,r);return{merged:{...t.hostRecord,...o},hostCollisions:s,intraCollisions:i}}var qn={message:`/api/transports/:transportId/chats/:externalChatId`,connect:`/api/transports/:transportId/chats/:externalChatId/connect`};function Jn(e,t){let n={};for(let[r,i]of Object.entries(t))n[r]={method:i.method,url:`/api/${e}${i.path}`};return n}var Yn=Kn(Un,{label:`API_ROUTES`,hostRecord:{health:`/api/health`,sandbox:`/api/sandbox`,shortcuts:`/api/shortcuts`,dashboard:`/api/dashboard`,agent:{run:`/api/agent`,cancel:`/api/agent/cancel`,internal:{toolResult:`/api/internal/tool-result`}},chatIndex:{rebuild:`/api/chat-index/rebuild`},chatService:qn,config:{base:`/api/config`,settings:`/api/config/settings`,mcp:`/api/config/mcp`,workspaceDirs:`/api/config/workspace-dirs`,referenceDirs:`/api/config/reference-dirs`,schedulerOverrides:`/api/config/scheduler-overrides`,refresh:`/api/config/refresh`,connectors:`/api/config/connectors`},files:{tree:`/api/files/tree`,dir:`/api/files/dir`,content:`/api/files/content`,create:`/api/files/create`,raw:`/api/files/raw`,refRoots:`/api/files/ref-roots`,open:`/api/files/open`,reveal:`/api/files/reveal`},image:{generate:`/api/generate-image`,edit:`/api/edit-image`,upload:`/api/images`,update:`/api/images/update`},attachments:{upload:`/api/attachments`},share:{pack:`/api/share/pack`,packMarkdown:`/api/share/pack-markdown`},remoteHost:{connect:`/api/remote-host/connect`,reconnect:`/api/remote-host/reconnect`,disconnect:`/api/remote-host/disconnect`,status:`/api/remote-host/status`},google:{status:`/api/google/status`,authorize:`/api/google/authorize`,unlink:`/api/google/unlink`},mcpTools:{list:`/api/mcp-tools`,invoke:`/api/mcp-tools/:tool`},notifier:{dispatch:`/api/notifier`},journal:{latestDaily:`/api/journal/latest-daily`},pdf:{markdown:`/api/pdf/markdown`},translation:{translate:`/api/translation`},transcribe:{run:`/api/transcribe`,model:`/api/transcribe/model`,modelDownload:`/api/transcribe/model/download`},plugins:{mindmap:`/api/mindmap`,quiz:`/api/quiz`,present3d:`/api/present3d`,googleMap:`/api/google-map`,runtimeList:`/api/plugins/runtime/list`,runtimeDispatch:`/api/plugins/runtime/:pkg/dispatch`,runtimeOauthCallback:`/api/plugins/runtime/oauth-callback/:alias`,diagnostics:`/api/plugins/diagnostics`,runtimeAsset:`/api/plugins/runtime/:pkg/:version/{*splat}`},roles:{list:`/api/roles`,manage:`/api/roles/manage`},marpThemes:{list:`/api/marp-themes`},collections:{list:`/api/collections`,detail:`/api/collections/:slug`,items:`/api/collections/:slug/items`,item:`/api/collections/:slug/items/:itemId`,itemAction:`/api/collections/:slug/items/:itemId/actions/:actionId`,collectionAction:`/api/collections/:slug/actions/:actionId`,refresh:`/api/collections/:slug/refresh`,viewFile:`/api/collections/:slug/view-file`,remoteView:`/api/collections/:slug/remote-view`,remoteViewMutate:`/api/collections/:slug/remote-view/:viewId/mutate`,remoteViewItems:`/api/collections/:slug/remote-view/:viewId/items`,viewI18n:`/api/collections/:slug/view-i18n`,viewToken:`/api/collections/:slug/view-token`,viewData:`/api/collections/:slug/view-data`,viewDataAction:`/api/collections/:slug/view-data/actions/:actionId`,viewDelete:`/api/collections/:slug/views/:viewId`},collectionsRegistry:{list:`/api/collections-registry`,preview:`/api/collections-registry/preview`,import:`/api/collections-registry/import`,export:`/api/collections-registry/export`},sessions:{list:`/api/sessions`,detail:`/api/sessions/:id`,markRead:`/api/sessions/:id/mark-read`,bookmark:`/api/sessions/:id/bookmark`},feeds:{list:`/api/feeds`,detail:`/api/feeds/:slug`},hooks:{log:`/api/hooks/log`},wiki:{base:`/api/wiki`,pageHistory:`/api/wiki/pages/:slug/history`,pageHistorySnapshot:`/api/wiki/pages/:slug/history/:stamp`,pageHistoryRestore:`/api/wiki/pages/:slug/history/:stamp/restore`,internalSnapshot:`/api/wiki/internal/snapshot`}},extract:e=>{if(e.apiRoutes===void 0)return;let t=e.apiNamespace??e.toolName;return{[t]:Jn(t,e.apiRoutes)}},dimension:`apiNamespace`});Yn.hostCollisions,Yn.intraCollisions;var Xn=Yn.merged;p();function Zn(e,t){return`plugin:${e}:${t}`}function Qn(e){let{subscribe:t}=zt();return{subscribe(n,r){return t(Zn(e,n),r)}}}function $n(e){let t=`[plugin/${e}]`;return{debug:(e,n)=>console.debug(t,e,n),info:(e,n)=>console.info(t,e,n),warn:(e,n)=>console.warn(t,e,n),error:(e,n)=>console.error(t,e,n)}}var er=new Set([`http:`,`https:`]);function tr(e){return t=>{let n;try{n=new URL(t)}catch{console.warn(`[plugin/${e}] openUrl rejected unparseable URL`,{url:t});return}if(!er.has(n.protocol)){console.warn(`[plugin/${e}] openUrl rejected non-http(s) scheme`,{scheme:n.protocol});return}window.open(t,`_blank`,`noopener,noreferrer`)||console.warn(`[plugin/${e}] window.open returned null`,{url:t})}}function nr(e){let t=Xn.plugins.runtimeDispatch.replace(`:pkg`,encodeURIComponent(e));return async n=>{let r=await me(t,n);if(!r.ok)throw Error(`plugin/${e} dispatch failed (${r.status}): ${r.error}`);return r.data}}function rr(e){let{pkgName:t,endpoints:r}=e,{locale:i}=te(),a=n(()=>String(i.value));return{pubsub:Qn(t),locale:a,log:$n(t),openUrl:tr(t),dispatch:nr(t),endpoints:r}}p(),m();function ir(e){let t=c(null),r=c(!1),i=c(0),a=n(()=>{if(!t.value)return``;let e=t.value.message||String(t.value),n=t.value.stack??``;return n?`${e}\n\n${n}`:e});function o(n){let r=g(n);console.error(`[plugin/${e}] uncaught error`,r),t.value=r}function s(){t.value=null,r.value=!1,i.value+=1}return{error:t,showDetails:r,mountKey:i,errorDetails:a,captureError:o,retry:s}}p(),m(),u();var ar={key:0,class:`rounded border border-red-200 bg-red-50 p-3 text-sm`,"data-testid":`plugin-error-boundary`,role:`alert`},or={class:`flex items-center gap-2 mb-1`},sr={class:`font-medium text-red-800`},cr={class:`text-red-700 mb-2`},lr={class:`flex items-center gap-3`},ur={key:0,class:`mt-2 text-xs text-red-900 bg-red-100 p-2 rounded overflow-auto max-h-40 whitespace-pre-wrap break-words`},dr=l({__name:`PluginScopedRoot`,props:{pkgName:{},endpoints:{}},setup(e){let n=e,{t:c}=te();ee(ne,rr({pkgName:n.pkgName,endpoints:n.endpoints}));let{error:l,showDetails:u,mountKey:p,errorDetails:m,captureError:h,retry:g}=ir(n.pkgName);return a(e=>(h(e),!1)),(n,a)=>f(l)?(t(),o(`div`,ar,[d(`div`,or,[a[2]||=d(`span`,{class:`material-icons text-red-500`,"aria-hidden":`true`},`error_outline`,-1),d(`span`,sr,r(f(c)(`pluginErrorBoundary.title`,{pkg:e.pkgName})),1)]),d(`p`,cr,r(f(c)(`pluginErrorBoundary.subtitle`)),1),d(`div`,lr,[d(`button`,{type:`button`,class:`text-xs text-red-600 hover:underline`,"data-testid":`plugin-error-toggle-details`,onClick:a[0]||=e=>u.value=!f(u)},r(f(u)?f(c)(`pluginErrorBoundary.hideDetails`):f(c)(`pluginErrorBoundary.showDetails`)),1),d(`button`,{type:`button`,class:`text-xs text-red-600 hover:underline`,"data-testid":`plugin-error-retry`,onClick:a[1]||=(...e)=>f(g)&&f(g)(...e)},r(f(c)(`pluginErrorBoundary.retry`)),1)]),f(u)?(t(),o(`pre`,ur,r(f(m)),1)):s(``,!0)])):i(n.$slots,`default`,{key:f(p)})}}),fr=e({default:()=>pr}),pr=dr;export{_ as $,Gt as A,gn as B,Dn as C,sn as D,pn as E,dn as F,Bt as G,Cn as H,wn as I,ge as J,zt as K,xn as L,yn as M,bn as N,an as O,vn as P,he as Q,Sn as R,mn as S,Ut as T,on as U,cn as V,Xt as W,pe as X,_e as Y,me as Z,Vt as _,Kn as a,h as at,qt as b,zn as c,In as d,se as et,Fn as f,On as g,kn as h,Un as i,re as it,Qt as j,Tn as k,Rn as l,An as m,fr as n,ae as nt,Hn as o,g as ot,Nn as p,y as q,Xn as r,ie as rt,Bn as s,pr as t,le as tt,Ln as u,Ht as v,En as w,ln as x,Wt as y,un as z};