jotbus 0.1.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/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/index.js +91 -0
- package/package.json +15 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jotbus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# jotbus
|
|
2
|
+
|
|
3
|
+
**A shared scratchpad for your coding agents.** Claude Code on your laptop, Codex on your desktop, any MCP client
|
|
4
|
+
anywhere else: connect them to one private Jotbus workspace and they can leave notes, hand off work, and ask each
|
|
5
|
+
other for reviews.
|
|
6
|
+
|
|
7
|
+
This package is the local MCP client. It exposes the Jotbus tools (`list_workspaces`, `read_workspace`,
|
|
8
|
+
`write_workspace`, `listen_workspace`) over stdio and **encrypts and decrypts messages on your machine** for
|
|
9
|
+
end-to-end encrypted workspaces. The server stores only ciphertext, and your workspace key never leaves your machines.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Mint a token in the Jotbus dashboard. It shows this command with everything filled in:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
claude mcp add --scope user jotbus -e JOTBUS_TOKEN=<connection string> -- npx -y jotbus@latest --url <endpoint>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Codex: `codex mcp add jotbus --env JOTBUS_TOKEN=<connection string> -- npx -y jotbus@latest --url <endpoint>`
|
|
20
|
+
|
|
21
|
+
Then just prompt your agents, for example: *"Ask Codex on my desktop to review the auth change."*
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
| | |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `JOTBUS_TOKEN` | Connection string from the dashboard: `jb_live_<token>.<key>`. Only the token part before the `.` is sent to the server. |
|
|
28
|
+
| `--url` / `JOTBUS_URL` | Jotbus MCP endpoint |
|
|
29
|
+
| `--help`, `--version` | |
|
|
30
|
+
|
|
31
|
+
## Security
|
|
32
|
+
|
|
33
|
+
AES-256-GCM with HKDF-derived keys; each ciphertext is bound to its workspace. The server rejects plaintext in
|
|
34
|
+
encrypted workspaces. It can see author labels, timestamps and message sizes, but not content. Your model provider
|
|
35
|
+
still sees what your agents read and write.
|
|
36
|
+
|
|
37
|
+
Requires Node 20+.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
+
var Pb=Object.create;var oa=Object.defineProperty;var Eb=Object.getOwnPropertyDescriptor;var Tb=Object.getOwnPropertyNames;var Ob=Object.getPrototypeOf,Rb=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},sa=(e,t)=>{for(var r in t)oa(e,r,{get:t[r],enumerable:!0})},Ab=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tb(t))!Rb.call(e,o)&&o!==r&&oa(e,o,{get:()=>t[o],enumerable:!(n=Eb(t,o))||n.enumerable});return e};var ia=(e,t,r)=>(r=e!=null?Pb(Ob(e)):{},Ab(t||!e||!e.__esModule?oa(r,"default",{value:e,enumerable:!0}):r,e));var qn=k(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.regexpCode=H.getEsmExportName=H.getProperty=H.safeStringify=H.stringify=H.strConcat=H.addCodeArg=H.str=H._=H.nil=H._Code=H.Name=H.IDENTIFIER=H._CodeOrName=void 0;var Ln=class{};H._CodeOrName=Ln;H.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var rr=class extends Ln{constructor(t){if(super(),!H.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};H.Name=rr;var Be=class extends Ln{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof rr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};H._Code=Be;H.nil=new Be("");function Tg(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Hc(r,t[n]),r.push(e[++n]);return new Be(r)}H._=Tg;var Bc=new Be("+");function Og(e,...t){let r=[Un(e[0])],n=0;for(;n<t.length;)r.push(Bc),Hc(r,t[n]),r.push(Bc,Un(e[++n]));return E$(r),new Be(r)}H.str=Og;function Hc(e,t){t instanceof Be?e.push(...t._items):t instanceof rr?e.push(t):e.push(R$(t))}H.addCodeArg=Hc;function E$(e){let t=1;for(;t<e.length-1;){if(e[t]===Bc){let r=T$(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function T$(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof rr||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof rr))return`"${e}${t.slice(1)}`}function O$(e,t){return t.emptyStr()?e:e.emptyStr()?t:Og`${e}${t}`}H.strConcat=O$;function R$(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Un(Array.isArray(e)?e.join(","):e)}function A$(e){return new Be(Un(e))}H.stringify=A$;function Un(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}H.safeStringify=Un;function I$(e){return typeof e=="string"&&H.IDENTIFIER.test(e)?new Be(`.${e}`):Tg`[${e}]`}H.getProperty=I$;function C$(e){if(typeof e=="string"&&H.IDENTIFIER.test(e))return new Be(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}H.getEsmExportName=C$;function N$(e){return new Be(e.toString())}H.regexpCode=N$});var Wc=k(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.ValueScope=Ne.ValueScopeName=Ne.Scope=Ne.varKinds=Ne.UsedValueState=void 0;var Ce=qn(),Kc=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Vs;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Vs||(Ne.UsedValueState=Vs={}));Ne.varKinds={const:new Ce.Name("const"),let:new Ce.Name("let"),var:new Ce.Name("var")};var Bs=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ce.Name?t:this.name(t)}name(t){return new Ce.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Ne.Scope=Bs;var Hs=class extends Ce.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ce._)`.${new Ce.Name(r)}[${n}]`}};Ne.ValueScopeName=Hs;var j$=(0,Ce._)`\n`,Jc=class extends Bs{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?j$:Ce.nil}}get(){return this._scope}name(t){return new Hs(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ce._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ce.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Vs.Started);let l=r(u);if(l){let d=this.opts.es5?Ne.varKinds.var:Ne.varKinds.const;s=(0,Ce._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ce._)`${s}${l}${this.opts._n}`;else throw new Kc(u);c.set(u,Vs.Completed)})}return s}};Ne.ValueScope=Jc});var M=k(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var U=qn(),Qe=Wc(),Lt=qn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Lt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Lt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Lt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Lt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Lt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Lt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Lt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Lt.Name}});var Gs=Wc();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Gs.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Gs.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Gs.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Gs.varKinds}});D.operators={GT:new U._Code(">"),GTE:new U._Code(">="),LT:new U._Code("<"),LTE:new U._Code("<="),EQ:new U._Code("==="),NEQ:new U._Code("!=="),NOT:new U._Code("!"),OR:new U._Code("||"),AND:new U._Code("&&"),ADD:new U._Code("+")};var vt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Gc=class extends vt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Qe.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Fr(this.rhs,t,r)),this}get names(){return this.rhs instanceof U._CodeOrName?this.rhs.names:{}}},Ks=class extends vt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof U.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Fr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof U.Name?{}:{...this.lhs.names};return Ws(t,this.rhs)}},Xc=class extends Ks{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Yc=class extends vt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Qc=class extends vt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},eu=class extends vt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},tu=class extends vt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Fr(this.code,t,r),this}get names(){return this.code instanceof U._CodeOrName?this.code.names:{}}},Fn=class extends vt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(Z$(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>sr(t,r.names),{})}},$t=class extends Fn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},ru=class extends Fn{},qr=class extends $t{};qr.kind="else";var nr=class e extends $t{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new qr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Rg(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Fr(this.condition,t,r),this}get names(){let t=super.names;return Ws(t,this.condition),this.else&&sr(t,this.else.names),t}};nr.kind="if";var or=class extends $t{};or.kind="for";var nu=class extends or{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Fr(this.iteration,t,r),this}get names(){return sr(super.names,this.iteration.names)}},ou=class extends or{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?Qe.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Ws(super.names,this.from);return Ws(t,this.to)}},Js=class extends or{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Fr(this.iterable,t,r),this}get names(){return sr(super.names,this.iterable.names)}},Vn=class extends $t{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Vn.kind="func";var Bn=class extends Fn{render(t){return"return "+super.render(t)}};Bn.kind="return";var su=class extends $t{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&sr(t,this.catch.names),this.finally&&sr(t,this.finally.names),t}},Hn=class extends $t{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Hn.kind="catch";var Kn=class extends $t{render(t){return"finally"+super.render(t)}};Kn.kind="finally";var iu=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
+
`:""},this._extScope=t,this._scope=new Qe.Scope({parent:t}),this._nodes=[new ru]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Gc(t,s,n)),s}const(t,r,n){return this._def(Qe.varKinds.const,t,r,n)}let(t,r,n){return this._def(Qe.varKinds.let,t,r,n)}var(t,r,n){return this._def(Qe.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Ks(t,r,n))}add(t,r){return this._leafNode(new Xc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==U.nil&&this._leafNode(new tu(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,U.addCodeArg)(r,o));return r.push("}"),new U._Code(r)}if(t,r,n){if(this._blockNode(new nr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new nr(t))}else(){return this._elseNode(new qr)}endIf(){return this._endBlockNode(nr,qr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new nu(t),r)}forRange(t,r,n,o,s=this.opts.es5?Qe.varKinds.var:Qe.varKinds.let){let i=this._scope.toName(t);return this._for(new ou(s,i,r,n),()=>o(i))}forOf(t,r,n,o=Qe.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof U.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,U._)`${i}.length`,a=>{this.var(s,(0,U._)`${i}[${a}]`),n(s)})}return this._for(new Js("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,U._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Js("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(or)}label(t){return this._leafNode(new Yc(t))}break(t){return this._leafNode(new Qc(t))}return(t){let r=new Bn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Bn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new su;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Hn(s),r(s)}return n&&(this._currNode=o.finally=new Kn,this.code(n)),this._endBlockNode(Hn,Kn)}throw(t){return this._leafNode(new eu(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=U.nil,n,o){return this._blockNode(new Vn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Vn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof nr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=iu;function sr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Ws(e,t){return t instanceof U._CodeOrName?sr(e,t.names):e}function Fr(e,t,r){if(e instanceof U.Name)return n(e);if(!o(e))return e;return new U._Code(e._items.reduce((s,i)=>(i instanceof U.Name&&(i=n(i)),i instanceof U._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof U._Code&&s._items.some(i=>i instanceof U.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function Z$(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Rg(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,U._)`!${au(e)}`}D.not=Rg;var M$=Ag(D.operators.AND);function D$(...e){return e.reduce(M$)}D.and=D$;var L$=Ag(D.operators.OR);function U$(...e){return e.reduce(L$)}D.or=U$;function Ag(e){return(t,r)=>t===U.nil?r:r===U.nil?t:(0,U._)`${au(t)} ${e} ${au(r)}`}function au(e){return e instanceof U.Name?e:(0,U._)`(${e})`}});var q=k(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.checkStrictMode=L.getErrorPath=L.Type=L.useFunc=L.setEvaluated=L.evaluatedPropsToName=L.mergeEvaluated=L.eachItem=L.unescapeJsonPointer=L.escapeJsonPointer=L.escapeFragment=L.unescapeFragment=L.schemaRefOrVal=L.schemaHasRulesButRef=L.schemaHasRules=L.checkUnknownRules=L.alwaysValidSchema=L.toHash=void 0;var Y=M(),q$=qn();function F$(e){let t={};for(let r of e)t[r]=!0;return t}L.toHash=F$;function V$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Ng(e,t),!jg(t,e.self.RULES.all))}L.alwaysValidSchema=V$;function Ng(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Dg(e,`unknown keyword: "${s}"`)}L.checkUnknownRules=Ng;function jg(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}L.schemaHasRules=jg;function B$(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}L.schemaHasRulesButRef=B$;function H$({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Y._)`${r}`}return(0,Y._)`${e}${t}${(0,Y.getProperty)(n)}`}L.schemaRefOrVal=H$;function K$(e){return Zg(decodeURIComponent(e))}L.unescapeFragment=K$;function J$(e){return encodeURIComponent(uu(e))}L.escapeFragment=J$;function uu(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}L.escapeJsonPointer=uu;function Zg(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}L.unescapeJsonPointer=Zg;function W$(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}L.eachItem=W$;function Ig({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof Y.Name?(s instanceof Y.Name?e(o,s,i):t(o,s,i),i):s instanceof Y.Name?(t(o,i,s),s):r(s,i);return a===Y.Name&&!(c instanceof Y.Name)?n(o,c):c}}L.mergeEvaluated={props:Ig({mergeNames:(e,t,r)=>e.if((0,Y._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,Y._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,Y._)`${r} || {}`).code((0,Y._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,Y._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,Y._)`${r} || {}`),lu(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Mg}),items:Ig({mergeNames:(e,t,r)=>e.if((0,Y._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,Y._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,Y._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,Y._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Mg(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,Y._)`{}`);return t!==void 0&&lu(e,r,t),r}L.evaluatedPropsToName=Mg;function lu(e,t,r){Object.keys(r).forEach(n=>e.assign((0,Y._)`${t}${(0,Y.getProperty)(n)}`,!0))}L.setEvaluated=lu;var Cg={};function G$(e,t){return e.scopeValue("func",{ref:t,code:Cg[t.code]||(Cg[t.code]=new q$._Code(t.code))})}L.useFunc=G$;var cu;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(cu||(L.Type=cu={}));function X$(e,t,r){if(e instanceof Y.Name){let n=t===cu.Num;return r?n?(0,Y._)`"[" + ${e} + "]"`:(0,Y._)`"['" + ${e} + "']"`:n?(0,Y._)`"/" + ${e}`:(0,Y._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Y.getProperty)(e).toString():"/"+uu(e)}L.getErrorPath=X$;function Dg(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}L.checkStrictMode=Dg});var St=k(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var $e=M(),Y$={data:new $e.Name("data"),valCxt:new $e.Name("valCxt"),instancePath:new $e.Name("instancePath"),parentData:new $e.Name("parentData"),parentDataProperty:new $e.Name("parentDataProperty"),rootData:new $e.Name("rootData"),dynamicAnchors:new $e.Name("dynamicAnchors"),vErrors:new $e.Name("vErrors"),errors:new $e.Name("errors"),this:new $e.Name("this"),self:new $e.Name("self"),scope:new $e.Name("scope"),json:new $e.Name("json"),jsonPos:new $e.Name("jsonPos"),jsonLen:new $e.Name("jsonLen"),jsonPart:new $e.Name("jsonPart")};du.default=Y$});var Jn=k(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.extendErrors=Se.resetErrorsCount=Se.reportExtraError=Se.reportError=Se.keyword$DataError=Se.keywordError=void 0;var F=M(),Xs=q(),Te=St();Se.keywordError={message:({keyword:e})=>(0,F.str)`must pass "${e}" keyword validation`};Se.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,F.str)`"${e}" keyword must be ${t} ($data)`:(0,F.str)`"${e}" keyword is invalid ($data)`};function Q$(e,t=Se.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=qg(e,t,r);n??(i||a)?Lg(s,c):Ug(o,(0,F._)`[${c}]`)}Se.reportError=Q$;function eS(e,t=Se.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=qg(e,t,r);Lg(o,a),s||i||Ug(n,Te.default.vErrors)}Se.reportExtraError=eS;function tS(e,t){e.assign(Te.default.errors,t),e.if((0,F._)`${Te.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,F._)`${Te.default.vErrors}.length`,t),()=>e.assign(Te.default.vErrors,null)))}Se.resetErrorsCount=tS;function rS({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Te.default.errors,a=>{e.const(i,(0,F._)`${Te.default.vErrors}[${a}]`),e.if((0,F._)`${i}.instancePath === undefined`,()=>e.assign((0,F._)`${i}.instancePath`,(0,F.strConcat)(Te.default.instancePath,s.errorPath))),e.assign((0,F._)`${i}.schemaPath`,(0,F.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,F._)`${i}.schema`,r),e.assign((0,F._)`${i}.data`,n))})}Se.extendErrors=rS;function Lg(e,t){let r=e.const("err",t);e.if((0,F._)`${Te.default.vErrors} === null`,()=>e.assign(Te.default.vErrors,(0,F._)`[${r}]`),(0,F._)`${Te.default.vErrors}.push(${r})`),e.code((0,F._)`${Te.default.errors}++`)}function Ug(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,F._)`new ${e.ValidationError}(${t})`):(r.assign((0,F._)`${n}.errors`,t),r.return(!1))}var ir={keyword:new F.Name("keyword"),schemaPath:new F.Name("schemaPath"),params:new F.Name("params"),propertyName:new F.Name("propertyName"),message:new F.Name("message"),schema:new F.Name("schema"),parentSchema:new F.Name("parentSchema")};function qg(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,F._)`{}`:nS(e,t,r)}function nS(e,t,r={}){let{gen:n,it:o}=e,s=[oS(o,r),sS(e,r)];return iS(e,t,s),n.object(...s)}function oS({errorPath:e},{instancePath:t}){let r=t?(0,F.str)`${e}${(0,Xs.getErrorPath)(t,Xs.Type.Str)}`:e;return[Te.default.instancePath,(0,F.strConcat)(Te.default.instancePath,r)]}function sS({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,F.str)`${t}/${e}`;return r&&(o=(0,F.str)`${o}${(0,Xs.getErrorPath)(r,Xs.Type.Str)}`),[ir.schemaPath,o]}function iS(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([ir.keyword,o],[ir.params,typeof t=="function"?t(e):t||(0,F._)`{}`]),c.messages&&n.push([ir.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([ir.schema,i],[ir.parentSchema,(0,F._)`${l}${d}`],[Te.default.data,s]),u&&n.push([ir.propertyName,u])}});var Vg=k(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.boolOrEmptySchema=Vr.topBoolOrEmptySchema=void 0;var aS=Jn(),cS=M(),uS=St(),lS={message:"boolean schema is false"};function dS(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Fg(e,!1):typeof r=="object"&&r.$async===!0?t.return(uS.default.data):(t.assign((0,cS._)`${n}.errors`,null),t.return(!0))}Vr.topBoolOrEmptySchema=dS;function fS(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Fg(e)):r.var(t,!0)}Vr.boolOrEmptySchema=fS;function Fg(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,aS.reportError)(o,lS,void 0,t)}});var fu=k(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.getRules=Br.isJSONType=void 0;var pS=["string","number","integer","boolean","null","object","array"],hS=new Set(pS);function mS(e){return typeof e=="string"&&hS.has(e)}Br.isJSONType=mS;function gS(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Br.getRules=gS});var pu=k(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.shouldUseRule=Ut.shouldUseGroup=Ut.schemaHasRulesForType=void 0;function yS({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Bg(e,n)}Ut.schemaHasRulesForType=yS;function Bg(e,t){return t.rules.some(r=>Hg(e,r))}Ut.shouldUseGroup=Bg;function Hg(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Ut.shouldUseRule=Hg});var Wn=k(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.reportTypeError=ze.checkDataTypes=ze.checkDataType=ze.coerceAndCheckDataType=ze.getJSONTypes=ze.getSchemaTypes=ze.DataType=void 0;var _S=fu(),bS=pu(),wS=Jn(),j=M(),Kg=q(),Hr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Hr||(ze.DataType=Hr={}));function xS(e){let t=Jg(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}ze.getSchemaTypes=xS;function Jg(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(_S.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ze.getJSONTypes=Jg;function vS(e,t){let{gen:r,data:n,opts:o}=e,s=$S(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,bS.schemaHasRulesForType)(e,t[0]));if(i){let a=mu(t,n,o.strictNumbers,Hr.Wrong);r.if(a,()=>{s.length?SS(e,t,s):gu(e)})}return i}ze.coerceAndCheckDataType=vS;var Wg=new Set(["string","number","integer","boolean","null"]);function $S(e,t){return t?e.filter(r=>Wg.has(r)||t==="array"&&r==="array"):[]}function SS(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,j._)`typeof ${o}`),a=n.let("coerced",(0,j._)`undefined`);s.coerceTypes==="array"&&n.if((0,j._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,j._)`${o}[0]`).assign(i,(0,j._)`typeof ${o}`).if(mu(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,j._)`${a} !== undefined`);for(let u of r)(Wg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),gu(e),n.endIf(),n.if((0,j._)`${a} !== undefined`,()=>{n.assign(o,a),zS(e,a)});function c(u){switch(u){case"string":n.elseIf((0,j._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,j._)`"" + ${o}`).elseIf((0,j._)`${o} === null`).assign(a,(0,j._)`""`);return;case"number":n.elseIf((0,j._)`${i} == "boolean" || ${o} === null
|
|
5
|
+
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,j._)`+${o}`);return;case"integer":n.elseIf((0,j._)`${i} === "boolean" || ${o} === null
|
|
6
|
+
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,j._)`+${o}`);return;case"boolean":n.elseIf((0,j._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,j._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,j._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,j._)`${i} === "string" || ${i} === "number"
|
|
7
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,j._)`[${o}]`)}}}function zS({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,j._)`${t} !== undefined`,()=>e.assign((0,j._)`${t}[${r}]`,n))}function hu(e,t,r,n=Hr.Correct){let o=n===Hr.Correct?j.operators.EQ:j.operators.NEQ,s;switch(e){case"null":return(0,j._)`${t} ${o} null`;case"array":s=(0,j._)`Array.isArray(${t})`;break;case"object":s=(0,j._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,j._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,j._)`typeof ${t} ${o} ${e}`}return n===Hr.Correct?s:(0,j.not)(s);function i(a=j.nil){return(0,j.and)((0,j._)`typeof ${t} == "number"`,a,r?(0,j._)`isFinite(${t})`:j.nil)}}ze.checkDataType=hu;function mu(e,t,r,n){if(e.length===1)return hu(e[0],t,r,n);let o,s=(0,Kg.toHash)(e);if(s.array&&s.object){let i=(0,j._)`typeof ${t} != "object"`;o=s.null?i:(0,j._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=j.nil;s.number&&delete s.integer;for(let i in s)o=(0,j.and)(o,hu(i,t,r,n));return o}ze.checkDataTypes=mu;var kS={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,j._)`{type: ${e}}`:(0,j._)`{type: ${t}}`};function gu(e){let t=PS(e);(0,wS.reportError)(t,kS)}ze.reportTypeError=gu;function PS(e){let{gen:t,data:r,schema:n}=e,o=(0,Kg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Xg=k(Ys=>{"use strict";Object.defineProperty(Ys,"__esModule",{value:!0});Ys.assignDefaults=void 0;var Kr=M(),ES=q();function TS(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Gg(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Gg(e,s,o.default))}Ys.assignDefaults=TS;function Gg(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Kr._)`${s}${(0,Kr.getProperty)(t)}`;if(o){(0,ES.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Kr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Kr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Kr._)`${a} = ${(0,Kr.stringify)(r)}`)}});var He=k(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.validateUnion=W.validateArray=W.usePattern=W.callValidateCode=W.schemaProperties=W.allSchemaProperties=W.noPropertyInData=W.propertyInData=W.isOwnProperty=W.hasPropFunc=W.reportMissingProp=W.checkMissingProp=W.checkReportMissingProp=void 0;var re=M(),yu=q(),qt=St(),OS=q();function RS(e,t){let{gen:r,data:n,it:o}=e;r.if(bu(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,re._)`${t}`},!0),e.error()})}W.checkReportMissingProp=RS;function AS({gen:e,data:t,it:{opts:r}},n,o){return(0,re.or)(...n.map(s=>(0,re.and)(bu(e,t,s,r.ownProperties),(0,re._)`${o} = ${s}`)))}W.checkMissingProp=AS;function IS(e,t){e.setParams({missingProperty:t},!0),e.error()}W.reportMissingProp=IS;function Yg(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,re._)`Object.prototype.hasOwnProperty`})}W.hasPropFunc=Yg;function _u(e,t,r){return(0,re._)`${Yg(e)}.call(${t}, ${r})`}W.isOwnProperty=_u;function CS(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} !== undefined`;return n?(0,re._)`${o} && ${_u(e,t,r)}`:o}W.propertyInData=CS;function bu(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} === undefined`;return n?(0,re.or)(o,(0,re.not)(_u(e,t,r))):o}W.noPropertyInData=bu;function Qg(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}W.allSchemaProperties=Qg;function NS(e,t){return Qg(t).filter(r=>!(0,yu.alwaysValidSchema)(e,t[r]))}W.schemaProperties=NS;function jS({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,re._)`${e}, ${t}, ${n}${o}`:t,d=[[qt.default.instancePath,(0,re.strConcat)(qt.default.instancePath,s)],[qt.default.parentData,i.parentData],[qt.default.parentDataProperty,i.parentDataProperty],[qt.default.rootData,qt.default.rootData]];i.opts.dynamicRef&&d.push([qt.default.dynamicAnchors,qt.default.dynamicAnchors]);let p=(0,re._)`${l}, ${r.object(...d)}`;return c!==re.nil?(0,re._)`${a}.call(${c}, ${p})`:(0,re._)`${a}(${p})`}W.callValidateCode=jS;var ZS=(0,re._)`new RegExp`;function MS({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,re._)`${o.code==="new RegExp"?ZS:(0,OS.useFunc)(e,o)}(${r}, ${n})`})}W.usePattern=MS;function DS(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,re._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:yu.Type.Num},s),t.if((0,re.not)(s),a)})}}W.validateArray=DS;function LS(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,yu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,re._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,re.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}W.validateUnion=LS});var ry=k(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.validateKeywordUsage=st.validSchemaType=st.funcKeywordCode=st.macroKeywordCode=void 0;var Oe=M(),ar=St(),US=He(),qS=Jn();function FS(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=ty(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Oe.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}st.macroKeywordCode=FS;function VS(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;HS(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=ty(n,o,u),d=n.let("valid");e.block$data(d,p),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function p(){if(t.errors===!1)m(),t.modifying&&ey(e),y(()=>e.error());else{let w=t.async?f():h();t.modifying&&ey(e),y(()=>BS(e,w))}}function f(){let w=n.let("ruleErrs",null);return n.try(()=>m((0,Oe._)`await `),v=>n.assign(d,!1).if((0,Oe._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(w,(0,Oe._)`${v}.errors`),()=>n.throw(v))),w}function h(){let w=(0,Oe._)`${l}.errors`;return n.assign(w,null),m(Oe.nil),w}function m(w=t.async?(0,Oe._)`await `:Oe.nil){let v=c.opts.passContext?ar.default.this:ar.default.self,z=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Oe._)`${w}${(0,US.callValidateCode)(e,l,v,z)}`,t.modifying)}function y(w){var v;n.if((0,Oe.not)((v=t.valid)!==null&&v!==void 0?v:d),w)}}st.funcKeywordCode=VS;function ey(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Oe._)`${n.parentData}[${n.parentDataProperty}]`))}function BS(e,t){let{gen:r}=e;r.if((0,Oe._)`Array.isArray(${t})`,()=>{r.assign(ar.default.vErrors,(0,Oe._)`${ar.default.vErrors} === null ? ${t} : ${ar.default.vErrors}.concat(${t})`).assign(ar.default.errors,(0,Oe._)`${ar.default.vErrors}.length`),(0,qS.extendErrors)(e)},()=>e.error())}function HS({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function ty(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Oe.stringify)(r)})}function KS(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}st.validSchemaType=KS;function JS({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}st.validateKeywordUsage=JS});var oy=k(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.extendSubschemaMode=Ft.extendSubschemaData=Ft.getSubschema=void 0;var it=M(),ny=q();function WS(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,it._)`${e.schemaPath}${(0,it.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,it._)`${e.schemaPath}${(0,it.getProperty)(t)}${(0,it.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,ny.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Ft.getSubschema=WS;function GS(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,p=a.let("data",(0,it._)`${t.data}${(0,it.getProperty)(r)}`,!0);c(p),e.errorPath=(0,it.str)`${u}${(0,ny.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,it._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof it.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Ft.extendSubschemaData=GS;function XS(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Ft.extendSubschemaMode=XS});var wu=k((KN,sy)=>{"use strict";sy.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var ay=k((JN,iy)=>{"use strict";var Vt=iy.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Qs(t,n,o,e,"",e)};Vt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Vt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Vt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Vt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Qs(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Vt.arrayKeywords)for(var p=0;p<d.length;p++)Qs(e,t,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Vt.propsKeywords){if(d&&typeof d=="object")for(var f in d)Qs(e,t,r,d[f],o+"/"+l+"/"+YS(f),s,o,l,n,f)}else(l in Vt.keywords||e.allKeys&&!(l in Vt.skipKeywords))&&Qs(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function YS(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Gn=k(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.getSchemaRefs=je.resolveUrl=je.normalizeId=je._getFullPath=je.getFullPath=je.inlineRef=void 0;var QS=q(),ez=wu(),tz=ay(),rz=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function nz(e,t=!0){return typeof e=="boolean"?!0:t===!0?!xu(e):t?cy(e)<=t:!1}je.inlineRef=nz;var oz=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function xu(e){for(let t in e){if(oz.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(xu)||typeof r=="object"&&xu(r))return!0}return!1}function cy(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!rz.has(r)&&(typeof e[r]=="object"&&(0,QS.eachItem)(e[r],n=>t+=cy(n)),t===1/0))return 1/0}return t}function uy(e,t="",r){r!==!1&&(t=Jr(t));let n=e.parse(t);return ly(e,n)}je.getFullPath=uy;function ly(e,t){return e.serialize(t).split("#")[0]+"#"}je._getFullPath=ly;var sz=/#\/?$/;function Jr(e){return e?e.replace(sz,""):""}je.normalizeId=Jr;function iz(e,t,r){return r=Jr(r),e.resolve(t,r)}je.resolveUrl=iz;var az=/^[a-z_][-a-z0-9._]*$/i;function cz(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Jr(e[r]||t),s={"":o},i=uy(n,o,!1),a={},c=new Set;return tz(e,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let m=i+p,y=s[h];typeof d[r]=="string"&&(y=w.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[p]=y;function w(z){let A=this.opts.uriResolver.resolve;if(z=Jr(y?A(y,z):z),c.has(z))throw l(z);c.add(z);let b=this.refs[z];return typeof b=="string"&&(b=this.refs[b]),typeof b=="object"?u(d,b.schema,z):z!==Jr(m)&&(z[0]==="#"?(u(d,a[z],z),a[z]=d):this.refs[z]=m),z}function v(z){if(typeof z=="string"){if(!az.test(z))throw new Error(`invalid anchor "${z}"`);w.call(this,`#${z}`)}}}),a;function u(d,p,f){if(p!==void 0&&!ez(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}je.getSchemaRefs=cz});var Qn=k(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.getData=Bt.KeywordCxt=Bt.validateFunctionCode=void 0;var my=Vg(),dy=Wn(),$u=pu(),ei=Wn(),uz=Xg(),Yn=ry(),vu=oy(),O=M(),N=St(),lz=Gn(),zt=q(),Xn=Jn();function dz(e){if(_y(e)&&(by(e),yy(e))){hz(e);return}gy(e,()=>(0,my.topBoolOrEmptySchema)(e))}Bt.validateFunctionCode=dz;function gy({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,O._)`${N.default.data}, ${N.default.valCxt}`,n.$async,()=>{e.code((0,O._)`"use strict"; ${fy(r,o)}`),pz(e,o),e.code(s)}):e.func(t,(0,O._)`${N.default.data}, ${fz(o)}`,n.$async,()=>e.code(fy(r,o)).code(s))}function fz(e){return(0,O._)`{${N.default.instancePath}="", ${N.default.parentData}, ${N.default.parentDataProperty}, ${N.default.rootData}=${N.default.data}${e.dynamicRef?(0,O._)`, ${N.default.dynamicAnchors}={}`:O.nil}}={}`}function pz(e,t){e.if(N.default.valCxt,()=>{e.var(N.default.instancePath,(0,O._)`${N.default.valCxt}.${N.default.instancePath}`),e.var(N.default.parentData,(0,O._)`${N.default.valCxt}.${N.default.parentData}`),e.var(N.default.parentDataProperty,(0,O._)`${N.default.valCxt}.${N.default.parentDataProperty}`),e.var(N.default.rootData,(0,O._)`${N.default.valCxt}.${N.default.rootData}`),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,O._)`${N.default.valCxt}.${N.default.dynamicAnchors}`)},()=>{e.var(N.default.instancePath,(0,O._)`""`),e.var(N.default.parentData,(0,O._)`undefined`),e.var(N.default.parentDataProperty,(0,O._)`undefined`),e.var(N.default.rootData,N.default.data),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,O._)`{}`)})}function hz(e){let{schema:t,opts:r,gen:n}=e;gy(e,()=>{r.$comment&&t.$comment&&xy(e),bz(e),n.let(N.default.vErrors,null),n.let(N.default.errors,0),r.unevaluated&&mz(e),wy(e),vz(e)})}function mz(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,O._)`${r}.evaluated`),t.if((0,O._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,O._)`${e.evaluated}.props`,(0,O._)`undefined`)),t.if((0,O._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,O._)`${e.evaluated}.items`,(0,O._)`undefined`))}function fy(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,O._)`/*# sourceURL=${r} */`:O.nil}function gz(e,t){if(_y(e)&&(by(e),yy(e))){yz(e,t);return}(0,my.boolOrEmptySchema)(e,t)}function yy({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function _y(e){return typeof e.schema!="boolean"}function yz(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&xy(e),wz(e),xz(e);let s=n.const("_errs",N.default.errors);wy(e,s),n.var(t,(0,O._)`${s} === ${N.default.errors}`)}function by(e){(0,zt.checkUnknownRules)(e),_z(e)}function wy(e,t){if(e.opts.jtd)return py(e,[],!1,t);let r=(0,dy.getSchemaTypes)(e.schema),n=(0,dy.coerceAndCheckDataType)(e,r);py(e,r,!n,t)}function _z(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,zt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function bz(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,zt.checkStrictMode)(e,"default is ignored in the schema root")}function wz(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,lz.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function xz(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function xy({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,O._)`${N.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,O.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,O._)`${N.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function vz(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,O._)`${N.default.errors} === 0`,()=>t.return(N.default.data),()=>t.throw((0,O._)`new ${o}(${N.default.vErrors})`)):(t.assign((0,O._)`${n}.errors`,N.default.vErrors),s.unevaluated&&$z(e),t.return((0,O._)`${N.default.errors} === 0`))}function $z({gen:e,evaluated:t,props:r,items:n}){r instanceof O.Name&&e.assign((0,O._)`${t}.props`,r),n instanceof O.Name&&e.assign((0,O._)`${t}.items`,n)}function py(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,zt.schemaHasRulesButRef)(s,l))){o.block(()=>$y(e,"$ref",l.all.$ref.definition));return}c.jtd||Sz(e,t),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,$u.shouldUseGroup)(s,p)&&(p.type?(o.if((0,ei.checkDataType)(p.type,i,c.strictNumbers)),hy(e,p),t.length===1&&t[0]===p.type&&r&&(o.else(),(0,ei.reportTypeError)(e)),o.endIf()):hy(e,p),a||o.if((0,O._)`${N.default.errors} === ${n||0}`))}}function hy(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,uz.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,$u.shouldUseRule)(n,s)&&$y(e,s.keyword,s.definition,t.type)})}function Sz(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(zz(e,t),e.opts.allowUnionTypes||kz(e,t),Pz(e,e.dataTypes))}function zz(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{vy(e.dataTypes,r)||Su(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Tz(e,t)}}function kz(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Su(e,"use allowUnionTypes to allow union type keyword")}function Pz(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,$u.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Ez(t,i))&&Su(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Ez(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function vy(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Tz(e,t){let r=[];for(let n of e.dataTypes)vy(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Su(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,zt.checkStrictMode)(e,t,e.opts.strictTypes)}var ti=class{constructor(t,r,n){if((0,Yn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,zt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Sy(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Yn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",N.default.errors))}result(t,r,n){this.failResult((0,O.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,O.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,O._)`${r} !== undefined && (${(0,O.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Xn.reportExtraError:Xn.reportError)(this,this.def.error,r)}$dataError(){(0,Xn.reportError)(this,this.def.$dataError||Xn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Xn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=O.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=O.nil,r=O.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,O.or)((0,O._)`${o} === undefined`,r)),t!==O.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==O.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,O.or)(i(),a());function i(){if(n.length){if(!(r instanceof O.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,O._)`${(0,ei.checkDataTypes)(c,r,s.opts.strictNumbers,ei.DataType.Wrong)}`}return O.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,O._)`!${c}(${r})`}return O.nil}}subschema(t,r){let n=(0,vu.getSubschema)(this.it,t);(0,vu.extendSubschemaData)(n,this.it,t),(0,vu.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return gz(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=zt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=zt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,O.Name)),!0}};Bt.KeywordCxt=ti;function $y(e,t,r,n){let o=new ti(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Yn.funcKeywordCode)(o,r):"macro"in r?(0,Yn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Yn.funcKeywordCode)(o,r)}var Oz=/^\/(?:[^~]|~0|~1)*$/,Rz=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Sy(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return N.default.rootData;if(e[0]==="/"){if(!Oz.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=N.default.rootData}else{let u=Rz.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,O._)`${s}${(0,O.getProperty)((0,zt.unescapeJsonPointer)(u))}`,i=(0,O._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Bt.getData=Sy});var ri=k(ku=>{"use strict";Object.defineProperty(ku,"__esModule",{value:!0});var zu=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};ku.default=zu});var eo=k(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});var Pu=Gn(),Eu=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Pu.resolveUrl)(t,r,n),this.missingSchema=(0,Pu.normalizeId)((0,Pu.getFullPath)(t,this.missingRef))}};Tu.default=Eu});var oi=k(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.resolveSchema=Ke.getCompilingSchema=Ke.resolveRef=Ke.compileSchema=Ke.SchemaEnv=void 0;var et=M(),Az=ri(),cr=St(),tt=Gn(),zy=q(),Iz=Qn(),Wr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,tt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Ke.SchemaEnv=Wr;function Ru(e){let t=ky.call(this,e);if(t)return t;let r=(0,tt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new et.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:Az.default,code:(0,et._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:cr.default.data,parentData:cr.default.parentData,parentDataProperty:cr.default.parentDataProperty,dataNames:[cr.default.data],dataPathArr:[et.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,et.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:et.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,et._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,Iz.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(cr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${cr.default.self}`,`${cr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:m}=u;f.evaluated={props:h instanceof et.Name?void 0:h,items:m instanceof et.Name?void 0:m,dynamicProps:h instanceof et.Name,dynamicItems:m instanceof et.Name},f.source&&(f.source.evaluated=(0,et.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}Ke.compileSchema=Ru;function Cz(e,t,r){var n;r=(0,tt.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=Zz.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Wr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=Nz.call(this,s)}Ke.resolveRef=Cz;function Nz(e){return(0,tt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ru.call(this,e)}function ky(e){for(let t of this._compilations)if(jz(t,e))return t}Ke.getCompilingSchema=ky;function jz(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Zz(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||ni.call(this,e,t)}function ni(e,t){let r=this.opts.uriResolver.parse(t),n=(0,tt._getFullPath)(this.opts.uriResolver,r),o=(0,tt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Ou.call(this,r,e);let s=(0,tt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=ni.call(this,e,i);return typeof a?.schema!="object"?void 0:Ou.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ru.call(this,i),s===(0,tt.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,tt.resolveUrl)(this.opts.uriResolver,o,u)),new Wr({schema:a,schemaId:c,root:e,baseId:o})}return Ou.call(this,r,i)}}Ke.resolveSchema=ni;var Mz=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ou(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,zy.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Mz.has(a)&&u&&(t=(0,tt.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,zy.schemaHasRulesButRef)(r,this.RULES)){let a=(0,tt.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=ni.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Wr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var Py=k((e4,Dz)=>{Dz.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Zu=k((t4,Cy)=>{"use strict";var Lz=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Iu=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Uz=RegExp.prototype.test.bind(/^\d*$/u),ur=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Cu=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ty=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Nu=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),qz=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ze=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ze[t]="%"+e[t>>4]+e[t&15]}function ke(e){return e<2048?Ze[192|e>>6]+Ze[128|e&63]:e<65536?Ze[224|e>>12]+Ze[128|e>>6&63]+Ze[128|e&63]:Ze[240|e>>18]+Ze[128|e>>12&63]+Ze[128|e>>6&63]+Ze[128|e&63]}function Fz(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var Vz=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),Bz=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),Hz=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),Kz=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Jz(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!Hz(e[t])){if(e[t]==="%"&&t+2<e.length&&ur(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Ey(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function Wz(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!Iu(c))return;s+=2;continue}if(!Vz(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Ey(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return Ey(i)}function Au(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&Bz(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(Gz(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!Jz(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=Wz(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function Gz(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Xz(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var Yz={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Qz=/[@/?#:]/g,ek=/[@/?#]/g;function Oy(e,t){let r=t?ek:Qz;return r.lastIndex=0,e.replace(r,n=>Yz[n])}function Ry(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Cu(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function tk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&Cu(i)?t+=i:t+="%"+s,r+=2;continue}}if(Ty(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Iy(o)?n:Ze[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function rk(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(ur(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Ty(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Ze[i];else if(i<55296||i>57343)r+=ke(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=ke(65536+(i-55296<<10)+(a-56320)),o++):r+=ke(65533)}else r+=ke(65533)}}return r}function ju(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(ur(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ze[s];else if(s<55296||s>57343)r+=ke(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=ke(65536+(s-55296<<10)+(i-56320)),n++):r+=ke(65533)}else r+=ke(65533)}}return r}function Ay(e){return ju(e,qz)}function nk(e){return ju(e,Nu)}function ok(e){return ju(e,Nu)}function Iy(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function sk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));Cu(i)?t+=i:t+="%"+s,r+=2;continue}}if(Nu(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Iy(o)?n:Ze[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function ik(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(ur(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function ak(e){let t=[];if(e.userinfo!==void 0&&(t.push(Ay(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!Iu(r)){let n=Au(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Ry(r,!0),n=Au(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Oy(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!Uz(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Cy.exports={nonSimpleDomain:Kz,recomposeAuthority:ak,reescapeHostDelimiters:Oy,normalizePercentEncoding:Ry,normalizePathEncoding:tk,serializePathEncoding:rk,normalizeQueryFragmentEncoding:sk,encodeUserinfo:Ay,encodeQuery:nk,encodeFragment:ok,escapePreservingEscapes:ik,removeDotSegments:Xz,isIPv4:Iu,isUUID:Lz,normalizeIPv6:Au,stringArrayToHexStripped:Fz}});var Dy=k((r4,My)=>{"use strict";var{isUUID:ck}=Zu(),uk=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,lk=["http","https","ws","wss","urn","urn:uuid"];function dk(e){return lk.indexOf(e)!==-1}function Mu(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Ny(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function jy(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function fk(e){return e.secure=Mu(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function pk(e){if((e.port===(Mu(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function hk(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(uk);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Du(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function mk(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=Du(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function gk(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!ck(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function yk(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Zy={scheme:"http",domainHost:!0,parse:Ny,serialize:jy},_k={scheme:"https",domainHost:Zy.domainHost,parse:Ny,serialize:jy},si={scheme:"ws",domainHost:!0,parse:fk,serialize:pk},bk={scheme:"wss",domainHost:si.domainHost,parse:si.parse,serialize:si.serialize},wk={scheme:"urn",parse:hk,serialize:mk,skipNormalize:!0},xk={scheme:"urn:uuid",parse:gk,serialize:yk,skipNormalize:!0},ii={http:Zy,https:_k,ws:si,wss:bk,urn:wk,"urn:uuid":xk};Object.setPrototypeOf(ii,null);function Du(e){return e&&(ii[e]||ii[e.toLowerCase()])||void 0}My.exports={wsIsSecure:Mu,SCHEMES:ii,isValidSchemeName:dk,getSchemeHandler:Du}});var Yy=k((n4,ui)=>{"use strict";var{normalizeIPv6:Vy,removeDotSegments:ro,recomposeAuthority:vk,normalizePercentEncoding:Lu,normalizePathEncoding:$k,serializePathEncoding:Ly,normalizeQueryFragmentEncoding:Uy,encodeQuery:Sk,encodeFragment:zk,reescapeHostDelimiters:kk,isIPv4:By,nonSimpleDomain:Pk}=Zu(),{SCHEMES:Hy,getSchemeHandler:Uu}=Dy(),Ky=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Jy="URI scheme is malformed.";function qy(e){let t=unescape(String(e));if(!Ky.test(t))throw new TypeError(Jy);return t}function Ek(e,t){return typeof e=="string"?e=jk(e,t):typeof e=="object"&&(e=ci(lr(e,t),t)),e}function Tk(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ai(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:p,malformedSchemeSpecific:f,malformedHost:h,malformedScheme:m}=ai(t,n);if(s||d||i||p||a||f||c||h||u||m)throw new Error(o.error||l.error||"URI is malformed.");let y=Wy(o,l,n,!0),w=Uu(r&&r.scheme||y.scheme),v=y.host,z=v!==void 0&&v!==""&&(By(v)||Vy(v).isIPV6);Gy(y,r||{},w,z);let A=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(y.error&&!A)throw new Error(y.error);return n.skipEscape=!0,lr(y,n)}function Wy(e,t,r,n){let o={};return n||(e=ci(lr(e,r),r),t=ci(lr(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=ro(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=ro(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=ro(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=ro(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function Ok(e,t,r){let n=Fy(e,r),o=Fy(t,r);return n!==void 0&&o!==void 0&&n===o}function lr(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=qy(r.scheme));let s=Uu(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=Lu(r.path):r.path=Ly(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=qy(r.scheme),o.push(r.scheme,":"));let c=vk(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=ro(u)),a&&(u=Ly(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",Sk(r.query)),r.fragment!==void 0&&o.push("#",zk(r.fragment)),o.join("")}var Rk=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,Ak=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,Ik=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function Ck(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function to(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function qu(e){return e[0]==="["&&e[e.length-1]==="]"}function Nk(e){let t=e[4];return to(e[3])||t!==void 0&&!qu(t)&&to(t)||to(e[6])||to(e[7])||to(e[8])}function Gy(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!qu(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&Pk(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ai(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(Ak);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let p=e.match(Ik);if(p!==null){let h=p[1],m=h.replace(/[\t\n\r]/g,"");m.length>=2&&(m.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):h.length!==m.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let f=e.match(Rk);if(f){if(n.scheme=f[1],n.userinfo=f[3],n.host=f[4],n.port=parseInt(f[5],10),n.path=f[6]||"",n.query=f[7],n.fragment=f[8],n.scheme!==void 0){let y=unescape(n.scheme);Ky.test(y)?n.scheme=y.toLowerCase():(n.error=n.error||Jy,u=!0)}s=Nk(f),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=f[5]);let h=Ck(n,f);if(h!==void 0&&(n.error=n.error||h,o=!0),n.host)if(By(n.host)===!1){let w=qu(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,z=Vy(n.host);l=z.isIPV6||z.isIPVFuture===!0,c=v&&(!w||z.error===!0),n.host=l?z.host:z.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let m=Uu(r.scheme||n.scheme);if(c||(a=Gy(n,r,m,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let y=l?n.host:Lu(n.host,!0);l||(y=Lu(y.toLowerCase())),n.host=kk(y,l)}(!m||m&&!m.skipNormalize)&&(n.path&&(n.path=$k(n.path)),n.query&&(n.query=Uy(n.query)),n.fragment&&(n.fragment=Uy(n.fragment))),m&&m.parse&&(m.parse(n,r),m===Hy.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function ci(e,t){return ai(e,t).parsed}function jk(e,t){return Xy(e,t).normalized}function Xy(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ai(e,t);return{normalized:n||o||s||i||a?e:lr(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Fy(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:lr(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=Xy(r,t);return o||s||i||a||c?void 0:n}var Fu={SCHEMES:Hy,normalize:Ek,resolve:Tk,resolveComponent:Wy,equal:Ok,serialize:lr,parse:ci};ui.exports=Fu;ui.exports.default=Fu;ui.exports.fastUri=Fu});var e_=k(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});var Qy=Yy();Qy.code='require("ajv/dist/runtime/uri").default';Vu.default=Qy});var c_=k(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.CodeGen=we.Name=we.nil=we.stringify=we.str=we._=we.KeywordCxt=void 0;var Zk=Qn();Object.defineProperty(we,"KeywordCxt",{enumerable:!0,get:function(){return Zk.KeywordCxt}});var Gr=M();Object.defineProperty(we,"_",{enumerable:!0,get:function(){return Gr._}});Object.defineProperty(we,"str",{enumerable:!0,get:function(){return Gr.str}});Object.defineProperty(we,"stringify",{enumerable:!0,get:function(){return Gr.stringify}});Object.defineProperty(we,"nil",{enumerable:!0,get:function(){return Gr.nil}});Object.defineProperty(we,"Name",{enumerable:!0,get:function(){return Gr.Name}});Object.defineProperty(we,"CodeGen",{enumerable:!0,get:function(){return Gr.CodeGen}});var Mk=ri(),s_=eo(),Dk=fu(),no=oi(),Lk=M(),oo=Gn(),li=Wn(),Hu=q(),t_=Py(),Uk=e_(),i_=(e,t)=>new RegExp(e,t);i_.code="new RegExp";var qk=["removeAdditional","useDefaults","coerceTypes"],Fk=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Vk={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},Bk={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},r_=200;function Hk(e){var t,r,n,o,s,i,a,c,u,l,d,p,f,h,m,y,w,v,z,A,b,x,T,K,Z;let oe=e.strict,ft=(t=e.code)===null||t===void 0?void 0:t.optimize,Xt=ft===!0||ft===void 0?1:ft||0,xr=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:i_,Tt=(o=e.uriResolver)!==null&&o!==void 0?o:Uk.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:oe)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:oe)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:oe)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:oe)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=e.strictRequired)!==null&&f!==void 0?f:oe)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:Xt,regExp:xr}:{optimize:Xt,regExp:xr},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:r_,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:r_,meta:(w=e.meta)!==null&&w!==void 0?w:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(z=e.inlineRefs)!==null&&z!==void 0?z:!0,schemaId:(A=e.schemaId)!==null&&A!==void 0?A:"$id",addUsedSchema:(b=e.addUsedSchema)!==null&&b!==void 0?b:!0,validateSchema:(x=e.validateSchema)!==null&&x!==void 0?x:!0,validateFormats:(T=e.validateFormats)!==null&&T!==void 0?T:!0,unicodeRegExp:(K=e.unicodeRegExp)!==null&&K!==void 0?K:!0,int32range:(Z=e.int32range)!==null&&Z!==void 0?Z:!0,uriResolver:Tt}}var so=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Hk(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Lk.ValueScope({scope:{},prefixes:Fk,es5:r,lines:n}),this.logger=Yk(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,Dk.getRules)(),n_.call(this,Vk,t,"NOT SUPPORTED"),n_.call(this,Bk,t,"DEPRECATED","warn"),this._metaOpts=Gk.call(this),t.formats&&Jk.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Wk.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Kk.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=t_;n==="id"&&(o={...t_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof s_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,oo.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=o_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new no.SchemaEnv({schema:{},schemaId:n});if(r=no.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=o_.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,oo.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(e1.call(this,n,r),!r)return(0,Hu.eachItem)(n,s=>Bu.call(this,s)),this;r1.call(this,r);let o={...r,type:(0,li.getJSONTypes)(r.type),schemaType:(0,li.getJSONTypes)(r.schemaType)};return(0,Hu.eachItem)(n,o.type.length===0?s=>Bu.call(this,s,o):s=>o.type.forEach(i=>Bu.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=a_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,oo.normalizeId)(i||n);let u=oo.getSchemaRefs.call(this,t,n);return c=new no.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):no.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{no.compileSchema.call(this,t)}finally{this.opts=r}}};so.ValidationError=Mk.default;so.MissingRefError=s_.default;we.default=so;function n_(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function o_(e){return e=(0,oo.normalizeId)(e),this.schemas[e]||this.refs[e]}function Kk(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function Jk(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Wk(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function Gk(){let e={...this.opts};for(let t of qk)delete e[t];return e}var Xk={log(){},warn(){},error(){}};function Yk(e){if(e===!1)return Xk;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var Qk=/^[a-z_$][a-z0-9_$:-]*$/i;function e1(e,t){let{RULES:r}=this;if((0,Hu.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Qk.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function Bu(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,li.getJSONTypes)(t.type),schemaType:(0,li.getJSONTypes)(t.schemaType)}};t.before?t1.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function t1(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function r1(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=a_(t)),e.validateSchema=this.compile(t,!0))}var n1={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function a_(e){return{anyOf:[e,n1]}}});var u_=k(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});var o1={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ku.default=o1});var p_=k(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.callRef=dr.getValidate=void 0;var s1=eo(),l_=He(),Me=M(),Xr=St(),d_=oi(),di=q(),i1={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=d_.resolveRef.call(c,u,o,r);if(l===void 0)throw new s1.default(n.opts.uriResolver,o,r);if(l instanceof d_.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return fi(e,i,s,s.$async);let h=t.scopeValue("root",{ref:u});return fi(e,(0,Me._)`${h}.validate`,u,u.$async)}function p(h){let m=f_(e,h);fi(e,m,h,h.$async)}function f(h){let m=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Me.stringify)(h)}:{ref:h}),y=t.name("valid"),w=e.subschema({schema:h,dataTypes:[],schemaPath:Me.nil,topSchemaRef:m,errSchemaPath:r},y);e.mergeEvaluated(w),e.ok(y)}}};function f_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Me._)`${r.scopeValue("wrapper",{ref:t})}.validate`}dr.getValidate=f_;function fi(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Xr.default.this:Me.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,Me._)`await ${(0,l_.callValidateCode)(e,t,u)}`),f(t),i||o.assign(h,!0)},m=>{o.if((0,Me._)`!(${m} instanceof ${s.ValidationError})`,()=>o.throw(m)),p(m),i||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,l_.callValidateCode)(e,t,u),()=>f(t),()=>p(t))}function p(h){let m=(0,Me._)`${h}.errors`;o.assign(Xr.default.vErrors,(0,Me._)`${Xr.default.vErrors} === null ? ${m} : ${Xr.default.vErrors}.concat(${m})`),o.assign(Xr.default.errors,(0,Me._)`${Xr.default.vErrors}.length`)}function f(h){var m;if(!s.opts.unevaluated)return;let y=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=di.mergeEvaluated.props(o,y.props,s.props));else{let w=o.var("props",(0,Me._)`${h}.evaluated.props`);s.props=di.mergeEvaluated.props(o,w,s.props,Me.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=di.mergeEvaluated.items(o,y.items,s.items));else{let w=o.var("items",(0,Me._)`${h}.evaluated.items`);s.items=di.mergeEvaluated.items(o,w,s.items,Me.Name)}}}dr.callRef=fi;dr.default=i1});var h_=k(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var a1=u_(),c1=p_(),u1=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",a1.default,c1.default];Ju.default=u1});var m_=k(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var pi=M(),Ht=pi.operators,hi={maximum:{okStr:"<=",ok:Ht.LTE,fail:Ht.GT},minimum:{okStr:">=",ok:Ht.GTE,fail:Ht.LT},exclusiveMaximum:{okStr:"<",ok:Ht.LT,fail:Ht.GTE},exclusiveMinimum:{okStr:">",ok:Ht.GT,fail:Ht.LTE}},l1={message:({keyword:e,schemaCode:t})=>(0,pi.str)`must be ${hi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,pi._)`{comparison: ${hi[e].okStr}, limit: ${t}}`},d1={keyword:Object.keys(hi),type:"number",schemaType:"number",$data:!0,error:l1,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,pi._)`${r} ${hi[t].fail} ${n} || isNaN(${r})`)}};Wu.default=d1});var g_=k(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});var io=M(),f1={message:({schemaCode:e})=>(0,io.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,io._)`{multipleOf: ${e}}`},p1={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:f1,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,io._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,io._)`${i} !== parseInt(${i})`;e.fail$data((0,io._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Gu.default=p1});var __=k(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});function y_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}Xu.default=y_;y_.code='require("ajv/dist/runtime/ucs2length").default'});var b_=k(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});var fr=M(),h1=q(),m1=__(),g1={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,fr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,fr._)`{limit: ${e}}`},y1={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:g1,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?fr.operators.GT:fr.operators.LT,i=o.opts.unicode===!1?(0,fr._)`${r}.length`:(0,fr._)`${(0,h1.useFunc)(e.gen,m1.default)}(${r})`;e.fail$data((0,fr._)`${i} ${s} ${n}`)}};Yu.default=y1});var w_=k(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var _1=He(),b1=q(),Yr=M(),w1={message:({schemaCode:e})=>(0,Yr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Yr._)`{pattern: ${e}}`},x1={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:w1,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Yr._)`new RegExp`:(0,b1.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Yr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Yr._)`!${l}`)}else{let c=(0,_1.usePattern)(e,o);e.fail$data((0,Yr._)`!${c}.test(${r})`)}}};Qu.default=x1});var x_=k(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});var ao=M(),v1={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,ao.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,ao._)`{limit: ${e}}`},$1={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:v1,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?ao.operators.GT:ao.operators.LT;e.fail$data((0,ao._)`Object.keys(${r}).length ${o} ${n}`)}};el.default=$1});var v_=k(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});var co=He(),uo=M(),S1=q(),z1={message:({params:{missingProperty:e}})=>(0,uo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,uo._)`{missingProperty: ${e}}`},k1={keyword:"required",type:"object",schemaType:"array",$data:!0,error:z1,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:h}=e.it;for(let m of r)if(f?.[m]===void 0&&!h.has(m)){let y=i.schemaEnv.baseId+i.errSchemaPath,w=`required property "${m}" is not defined at "${y}" (strictRequired)`;(0,S1.checkStrictMode)(i,w,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(uo.nil,d);else for(let f of r)(0,co.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(c||s){let h=t.let("valid",!0);e.block$data(h,()=>p(f,h)),e.ok(h)}else t.if((0,co.checkMissingProp)(e,r,f)),(0,co.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,co.noPropertyInData)(t,o,f,a.ownProperties),()=>e.error())})}function p(f,h){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(h,(0,co.propertyInData)(t,o,f,a.ownProperties)),t.if((0,uo.not)(h),()=>{e.error(),t.break()})},uo.nil)}}};tl.default=k1});var $_=k(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});var lo=M(),P1={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,lo.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,lo._)`{limit: ${e}}`},E1={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:P1,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?lo.operators.GT:lo.operators.LT;e.fail$data((0,lo._)`${r}.length ${o} ${n}`)}};rl.default=E1});var mi=k(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});var S_=wu();S_.code='require("ajv/dist/runtime/equal").default';nl.default=S_});var z_=k(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});var ol=Wn(),xe=M(),T1=q(),O1=mi(),R1={message:({params:{i:e,j:t}})=>(0,xe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,xe._)`{i: ${e}, j: ${t}}`},A1={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:R1,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,ol.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,xe._)`${i} === false`),e.ok(c);function l(){let h=t.let("i",(0,xe._)`${r}.length`),m=t.let("j");e.setParams({i:h,j:m}),t.assign(c,!0),t.if((0,xe._)`${h} > 1`,()=>(d()?p:f)(h,m))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function p(h,m){let y=t.name("item"),w=(0,ol.checkDataTypes)(u,y,a.opts.strictNumbers,ol.DataType.Wrong),v=t.const("indices",(0,xe._)`{}`);t.for((0,xe._)`;${h}--;`,()=>{t.let(y,(0,xe._)`${r}[${h}]`),t.if(w,(0,xe._)`continue`),u.length>1&&t.if((0,xe._)`typeof ${y} == "string"`,(0,xe._)`${y} += "_"`),t.if((0,xe._)`typeof ${v}[${y}] == "number"`,()=>{t.assign(m,(0,xe._)`${v}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,xe._)`${v}[${y}] = ${h}`)})}function f(h,m){let y=(0,T1.useFunc)(t,O1.default),w=t.name("outer");t.label(w).for((0,xe._)`;${h}--;`,()=>t.for((0,xe._)`${m} = ${h}; ${m}--;`,()=>t.if((0,xe._)`${y}(${r}[${h}], ${r}[${m}])`,()=>{e.error(),t.assign(c,!1).break(w)})))}}};sl.default=A1});var k_=k(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});var il=M(),I1=q(),C1=mi(),N1={message:"must be equal to constant",params:({schemaCode:e})=>(0,il._)`{allowedValue: ${e}}`},j1={keyword:"const",$data:!0,error:N1,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,il._)`!${(0,I1.useFunc)(t,C1.default)}(${r}, ${o})`):e.fail((0,il._)`${s} !== ${r}`)}};al.default=j1});var P_=k(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var fo=M(),Z1=q(),M1=mi(),D1={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,fo._)`{allowedValues: ${e}}`},L1={keyword:"enum",schemaType:"array",$data:!0,error:D1,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,Z1.useFunc)(t,M1.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=t.const("vSchema",s);l=(0,fo.or)(...o.map((h,m)=>p(f,m)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,f=>t.if((0,fo._)`${u()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function p(f,h){let m=o[h];return typeof m=="object"&&m!==null?(0,fo._)`${u()}(${r}, ${f}[${h}])`:(0,fo._)`${r} === ${m}`}}};cl.default=L1});var E_=k(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});var U1=m_(),q1=g_(),F1=b_(),V1=w_(),B1=x_(),H1=v_(),K1=$_(),J1=z_(),W1=k_(),G1=P_(),X1=[U1.default,q1.default,F1.default,V1.default,B1.default,H1.default,K1.default,J1.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},W1.default,G1.default];ul.default=X1});var dl=k(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.validateAdditionalItems=void 0;var pr=M(),ll=q(),Y1={message:({params:{len:e}})=>(0,pr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,pr._)`{limit: ${e}}`},Q1={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Y1,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,ll.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}T_(e,n)}};function T_(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,pr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,pr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,ll.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,pr._)`${a} <= ${t.length}`);r.if((0,pr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:ll.Type.Num},u),i.allErrors||r.if((0,pr.not)(u),()=>r.break())})}}po.validateAdditionalItems=T_;po.default=Q1});var fl=k(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.validateTuple=void 0;var O_=M(),gi=q(),eP=He(),tP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return R_(e,"additionalItems",t);r.items=!0,!(0,gi.alwaysValidSchema)(r,t)&&e.ok((0,eP.validateArray)(e))}};function R_(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=gi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,O_._)`${s}.length`);r.forEach((d,p)=>{(0,gi.alwaysValidSchema)(a,d)||(n.if((0,O_._)`${u} > ${p}`,()=>e.subschema({keyword:i,schemaProp:p,dataProp:p},c)),e.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(p.strictTuples&&!m){let y=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,gi.checkStrictMode)(a,y,p.strictTuples)}}}ho.validateTuple=R_;ho.default=tP});var A_=k(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});var rP=fl(),nP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,rP.validateTuple)(e,"items")};pl.default=nP});var C_=k(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});var I_=M(),oP=q(),sP=He(),iP=dl(),aP={message:({params:{len:e}})=>(0,I_.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,I_._)`{limit: ${e}}`},cP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:aP,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,oP.alwaysValidSchema)(n,t)&&(o?(0,iP.validateAdditionalItems)(e,o):e.ok((0,sP.validateArray)(e)))}};hl.default=cP});var N_=k(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var Je=M(),yi=q(),uP={message:({params:{min:e,max:t}})=>t===void 0?(0,Je.str)`must contain at least ${e} valid item(s)`:(0,Je.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Je._)`{minContains: ${e}}`:(0,Je._)`{minContains: ${e}, maxContains: ${t}}`},lP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:uP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,Je._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,yi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,yi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,yi.alwaysValidSchema)(s,r)){let m=(0,Je._)`${l} >= ${i}`;a!==void 0&&(m=(0,Je._)`${m} && ${l} <= ${a}`),e.pass(m);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?f(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,Je._)`${o}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let m=t.name("_valid"),y=t.let("count",0);f(m,()=>t.if(m,()=>h(y)))}function f(m,y){t.forRange("i",0,l,w=>{e.subschema({keyword:"contains",dataProp:w,dataPropType:yi.Type.Num,compositeRule:!0},m),y()})}function h(m){t.code((0,Je._)`${m}++`),a===void 0?t.if((0,Je._)`${m} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,Je._)`${m} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,Je._)`${m} >= ${i}`,()=>t.assign(d,!0)))}}};ml.default=lP});var M_=k(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.validateSchemaDeps=at.validatePropertyDeps=at.error=void 0;var gl=M(),dP=q(),mo=He();at.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,gl.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,gl._)`{property: ${e},
|
|
8
|
+
missingProperty: ${n},
|
|
9
|
+
depsCount: ${t},
|
|
10
|
+
deps: ${r}}`};var fP={keyword:"dependencies",type:"object",schemaType:"object",error:at.error,code(e){let[t,r]=pP(e);j_(e,t),Z_(e,r)}};function pP({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function j_(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,mo.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,mo.checkReportMissingProp)(e,u)}):(r.if((0,gl._)`${c} && (${(0,mo.checkMissingProp)(e,a,s)})`),(0,mo.reportMissingProp)(e,s),r.else())}}at.validatePropertyDeps=j_;function Z_(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,dP.alwaysValidSchema)(s,t[a])||(r.if((0,mo.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}at.validateSchemaDeps=Z_;at.default=fP});var L_=k(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});var D_=M(),hP=q(),mP={message:"property name must be valid",params:({params:e})=>(0,D_._)`{propertyName: ${e.propertyName}}`},gP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:mP,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,hP.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,D_.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};yl.default=gP});var bl=k(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});var _i=He(),rt=M(),yP=St(),bi=q(),_P={message:"must NOT have additional properties",params:({params:e})=>(0,rt._)`{additionalProperty: ${e.additionalProperty}}`},bP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:_P,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,bi.alwaysValidSchema)(i,r))return;let u=(0,_i.allSchemaProperties)(n.properties),l=(0,_i.allSchemaProperties)(n.patternProperties);d(),e.ok((0,rt._)`${s} === ${yP.default.errors}`);function d(){t.forIn("key",o,y=>{!u.length&&!l.length?h(y):t.if(p(y),()=>h(y))})}function p(y){let w;if(u.length>8){let v=(0,bi.schemaRefOrVal)(i,n.properties,"properties");w=(0,_i.isOwnProperty)(t,v,y)}else u.length?w=(0,rt.or)(...u.map(v=>(0,rt._)`${y} === ${v}`)):w=rt.nil;return l.length&&(w=(0,rt.or)(w,...l.map(v=>(0,rt._)`${(0,_i.usePattern)(e,v)}.test(${y})`))),(0,rt.not)(w)}function f(y){t.code((0,rt._)`delete ${o}[${y}]`)}function h(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,bi.alwaysValidSchema)(i,r)){let w=t.name("valid");c.removeAdditional==="failing"?(m(y,w,!1),t.if((0,rt.not)(w),()=>{e.reset(),f(y)})):(m(y,w),a||t.if((0,rt.not)(w),()=>t.break()))}}function m(y,w,v){let z={keyword:"additionalProperties",dataProp:y,dataPropType:bi.Type.Str};v===!1&&Object.assign(z,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(z,w)}}};_l.default=bP});var F_=k(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});var wP=Qn(),U_=He(),wl=q(),q_=bl(),xP={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&q_.default.code(new wP.KeywordCxt(s,q_.default,"additionalProperties"));let i=(0,U_.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=wl.mergeEvaluated.props(t,(0,wl.toHash)(i),s.props));let a=i.filter(d=>!(0,wl.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,U_.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};xl.default=xP});var K_=k(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});var V_=He(),wi=M(),B_=q(),H_=q(),vP={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,V_.allSchemaProperties)(r),c=a.filter(m=>(0,B_.alwaysValidSchema)(s,r[m]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof wi.Name)&&(s.props=(0,H_.evaluatedPropsToName)(t,s.props));let{props:d}=s;p();function p(){for(let m of a)u&&f(m),s.allErrors?h(m):(t.var(l,!0),h(m),t.if(l))}function f(m){for(let y in u)new RegExp(m).test(y)&&(0,B_.checkStrictMode)(s,`property ${y} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){t.forIn("key",n,y=>{t.if((0,wi._)`${(0,V_.usePattern)(e,m)}.test(${y})`,()=>{let w=c.includes(m);w||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:y,dataPropType:H_.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,wi._)`${d}[${y}]`,!0):!w&&!s.allErrors&&t.if((0,wi.not)(l),()=>t.break())})})}}};vl.default=vP});var J_=k($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});var $P=q(),SP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,$P.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};$l.default=SP});var W_=k(Sl=>{"use strict";Object.defineProperty(Sl,"__esModule",{value:!0});var zP=He(),kP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:zP.validateUnion,error:{message:"must match a schema in anyOf"}};Sl.default=kP});var G_=k(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});var xi=M(),PP=q(),EP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,xi._)`{passingSchemas: ${e.passing}}`},TP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:EP,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let p;(0,PP.alwaysValidSchema)(o,l)?t.var(c,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,xi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,xi._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),p&&e.mergeEvaluated(p,xi.Name)})})}}};zl.default=TP});var X_=k(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});var OP=q(),RP={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,OP.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};kl.default=RP});var e0=k(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});var vi=M(),Q_=q(),AP={message:({params:e})=>(0,vi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,vi._)`{failingKeyword: ${e.ifClause}}`},IP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:AP,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Q_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Y_(n,"then"),s=Y_(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,vi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let p=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(p,i),d?t.assign(d,(0,vi._)`${l}`):e.setParams({ifClause:l})}}}};function Y_(e,t){let r=e.schema[t];return r!==void 0&&!(0,Q_.alwaysValidSchema)(e,r)}Pl.default=IP});var t0=k(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});var CP=q(),NP={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,CP.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};El.default=NP});var r0=k(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});var jP=dl(),ZP=A_(),MP=fl(),DP=C_(),LP=N_(),UP=M_(),qP=L_(),FP=bl(),VP=F_(),BP=K_(),HP=J_(),KP=W_(),JP=G_(),WP=X_(),GP=e0(),XP=t0();function YP(e=!1){let t=[HP.default,KP.default,JP.default,WP.default,GP.default,XP.default,qP.default,FP.default,UP.default,VP.default,BP.default];return e?t.push(ZP.default,DP.default):t.push(jP.default,MP.default),t.push(LP.default),t}Tl.default=YP});var n0=k(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});var le=M(),QP={message:({schemaCode:e})=>(0,le.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,le._)`{format: ${e}}`},eE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:QP,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),m=r.const("fDef",(0,le._)`${h}[${i}]`),y=r.let("fType"),w=r.let("format");r.if((0,le._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(y,(0,le._)`${m}.type || "string"`).assign(w,(0,le._)`${m}.validate`),()=>r.assign(y,(0,le._)`"string"`).assign(w,m)),e.fail$data((0,le.or)(v(),z()));function v(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${w}`}function z(){let A=l.$async?(0,le._)`(${m}.async ? await ${w}(${n}) : ${w}(${n}))`:(0,le._)`${w}(${n})`,b=(0,le._)`(typeof ${w} == "function" ? ${A} : ${w}.test(${n}))`;return(0,le._)`${w} && ${w} !== true && ${y} === ${t} && !${b}`}}function f(){let h=d.formats[s];if(!h){v();return}if(h===!0)return;let[m,y,w]=z(h);m===t&&e.pass(A());function v(){if(c.strictSchema===!1){d.logger.warn(b());return}throw new Error(b());function b(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function z(b){let x=b instanceof RegExp?(0,le.regexpCode)(b):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(s)}`:void 0,T=r.scopeValue("formats",{key:s,ref:b,code:x});return typeof b=="object"&&!(b instanceof RegExp)?[b.type||"string",b.validate,(0,le._)`${T}.validate`]:["string",b,T]}function A(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,le._)`await ${w}(${n})`}return typeof y=="function"?(0,le._)`${w}(${n})`:(0,le._)`${w}.test(${n})`}}}};Ol.default=eE});var o0=k(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});var tE=n0(),rE=[tE.default];Rl.default=rE});var s0=k(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Qr.contentVocabulary=Qr.metadataVocabulary=void 0;Qr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Qr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var a0=k(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});var nE=h_(),oE=E_(),sE=r0(),iE=o0(),i0=s0(),aE=[nE.default,oE.default,(0,sE.default)(),iE.default,i0.metadataVocabulary,i0.contentVocabulary];Al.default=aE});var u0=k($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.DiscrError=void 0;var c0;(function(e){e.Tag="tag",e.Mapping="mapping"})(c0||($i.DiscrError=c0={}))});var d0=k(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});var en=M(),Il=u0(),l0=oi(),cE=eo(),uE=q(),lE={message:({params:{discrError:e,tagName:t}})=>e===Il.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,en._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},dE={keyword:"discriminator",type:"object",schemaType:"object",error:lE,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,en._)`${r}${(0,en.getProperty)(a)}`);t.if((0,en._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Il.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let f=p();t.if(!1);for(let h in f)t.elseIf((0,en._)`${u} === ${h}`),t.assign(c,d(f[h]));t.else(),e.error(!1,{discrError:Il.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(f){let h=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:f},h);return e.mergeEvaluated(m,en.Name),h}function p(){var f;let h={},m=w(o),y=!0;for(let A=0;A<i.length;A++){let b=i[A];if(b?.$ref&&!(0,uE.schemaHasRulesButRef)(b,s.self.RULES)){let T=b.$ref;if(b=l0.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,T),b instanceof l0.SchemaEnv&&(b=b.schema),b===void 0)throw new cE.default(s.opts.uriResolver,s.baseId,T)}let x=(f=b?.properties)===null||f===void 0?void 0:f[a];if(typeof x!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(m||w(b)),v(x,A)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return h;function w({required:A}){return Array.isArray(A)&&A.includes(a)}function v(A,b){if(A.const)z(A.const,b);else if(A.enum)for(let x of A.enum)z(x,b);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function z(A,b){if(typeof A!="string"||A in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[A]=b}}}};Cl.default=dE});var f0=k((B4,fE)=>{fE.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var jl=k((ne,Nl)=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.MissingRefError=ne.ValidationError=ne.CodeGen=ne.Name=ne.nil=ne.stringify=ne.str=ne._=ne.KeywordCxt=ne.Ajv=void 0;var pE=c_(),hE=a0(),mE=d0(),p0=f0(),gE=["/properties"],Si="http://json-schema.org/draft-07/schema",tn=class extends pE.default{_addVocabularies(){super._addVocabularies(),hE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(mE.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(p0,gE):p0;this.addMetaSchema(t,Si,!1),this.refs["http://json-schema.org/schema"]=Si}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Si)?Si:void 0)}};ne.Ajv=tn;Nl.exports=ne=tn;Nl.exports.Ajv=tn;Object.defineProperty(ne,"__esModule",{value:!0});ne.default=tn;var yE=Qn();Object.defineProperty(ne,"KeywordCxt",{enumerable:!0,get:function(){return yE.KeywordCxt}});var rn=M();Object.defineProperty(ne,"_",{enumerable:!0,get:function(){return rn._}});Object.defineProperty(ne,"str",{enumerable:!0,get:function(){return rn.str}});Object.defineProperty(ne,"stringify",{enumerable:!0,get:function(){return rn.stringify}});Object.defineProperty(ne,"nil",{enumerable:!0,get:function(){return rn.nil}});Object.defineProperty(ne,"Name",{enumerable:!0,get:function(){return rn.Name}});Object.defineProperty(ne,"CodeGen",{enumerable:!0,get:function(){return rn.CodeGen}});var _E=ri();Object.defineProperty(ne,"ValidationError",{enumerable:!0,get:function(){return _E.default}});var bE=eo();Object.defineProperty(ne,"MissingRefError",{enumerable:!0,get:function(){return bE.default}})});var x0=k(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.formatNames=ut.fastFormats=ut.fullFormats=void 0;function ct(e,t){return{validate:e,compare:t}}ut.fullFormats={date:ct(y0,Ll),time:ct(Ml(!0),Ul),"date-time":ct(h0(!0),b0),"iso-time":ct(Ml(),_0),"iso-date-time":ct(h0(),w0),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:zE,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:AE,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:kE,int32:{type:"number",validate:TE},int64:{type:"number",validate:OE},float:{type:"number",validate:g0},double:{type:"number",validate:g0},password:!0,binary:!0};ut.fastFormats={...ut.fullFormats,date:ct(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Ll),time:ct(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ul),"date-time":ct(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,b0),"iso-time":ct(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,_0),"iso-date-time":ct(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,w0),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};ut.formatNames=Object.keys(ut.fullFormats);function wE(e){return e%4===0&&(e%100!==0||e%400===0)}var xE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,vE=[0,31,28,31,30,31,30,31,31,30,31,30,31];function y0(e){let t=xE.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&wE(r)?29:vE[n])}function Ll(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Zl=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Ml(e){return function(r){let n=Zl.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function Ul(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function _0(e,t){if(!(e&&t))return;let r=Zl.exec(e),n=Zl.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var Dl=/t|\s/i;function h0(e){let t=Ml(e);return function(n){let o=n.split(Dl);return o.length===2&&y0(o[0])&&t(o[1])}}function b0(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function w0(e,t){if(!(e&&t))return;let[r,n]=e.split(Dl),[o,s]=t.split(Dl),i=Ll(r,o);if(i!==void 0)return i||Ul(n,s)}var $E=/\/|:/,SE=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function zE(e){return $E.test(e)&&SE.test(e)}var m0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function kE(e){return m0.lastIndex=0,m0.test(e)}var PE=-(2**31),EE=2**31-1;function TE(e){return Number.isInteger(e)&&e<=EE&&e>=PE}function OE(e){return Number.isInteger(e)}function g0(){return!0}var RE=/[^\\]\\Z/;function AE(e){if(RE.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var v0=k(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.formatLimitDefinition=void 0;var IE=jl(),nt=M(),Kt=nt.operators,zi={formatMaximum:{okStr:"<=",ok:Kt.LTE,fail:Kt.GT},formatMinimum:{okStr:">=",ok:Kt.GTE,fail:Kt.LT},formatExclusiveMaximum:{okStr:"<",ok:Kt.LT,fail:Kt.GTE},formatExclusiveMinimum:{okStr:">",ok:Kt.GT,fail:Kt.LTE}},CE={message:({keyword:e,schemaCode:t})=>(0,nt.str)`should be ${zi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,nt._)`{comparison: ${zi[e].okStr}, limit: ${t}}`};nn.formatLimitDefinition={keyword:Object.keys(zi),type:"string",schemaType:"string",$data:!0,error:CE,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new IE.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=t.const("fmt",(0,nt._)`${p}[${c.schemaCode}]`);e.fail$data((0,nt.or)((0,nt._)`typeof ${f} != "object"`,(0,nt._)`${f} instanceof RegExp`,(0,nt._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let h=t.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,nt._)`${i.code.formats}${(0,nt.getProperty)(p)}`:void 0});e.fail$data(d(h))}function d(p){return(0,nt._)`${p}.compare(${r}, ${n}) ${zi[o].fail} 0`}},dependencies:["format"]};var NE=e=>(e.addKeyword(nn.formatLimitDefinition),e);nn.default=NE});var k0=k((go,z0)=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var on=x0(),jE=v0(),ql=M(),$0=new ql.Name("fullFormats"),ZE=new ql.Name("fastFormats"),Fl=(e,t={keywords:!0})=>{if(Array.isArray(t))return S0(e,t,on.fullFormats,$0),e;let[r,n]=t.mode==="fast"?[on.fastFormats,ZE]:[on.fullFormats,$0],o=t.formats||on.formatNames;return S0(e,o,r,n),t.keywords&&(0,jE.default)(e),e};Fl.get=(e,t="full")=>{let n=(t==="fast"?on.fastFormats:on.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function S0(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,ql._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}z0.exports=go=Fl;Object.defineProperty(go,"__esModule",{value:!0});go.default=Fl});var A0=k(Vl=>{"use strict";var T0=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,LE=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,O0=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,UE=/\\([\u000b\u0020-\u00ff])/g,qE=/([\\"])/g,R0=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Vl.format=FE;Vl.parse=VE;function FE(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R0.test(r))throw new TypeError("invalid type");var n=r;if(t&&typeof t=="object")for(var o,s=Object.keys(t).sort(),i=0;i<s.length;i++){if(o=s[i],!O0.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+HE(t[o])}return n}function VE(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?BE(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=r!==-1?t.slice(0,r).trim():t.trim();if(!R0.test(n))throw new TypeError("invalid media type");var o=new KE(n.toLowerCase());if(r!==-1){var s,i,a;for(T0.lastIndex=r;i=T0.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,s=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(UE,"$1"))),o.parameters[s]=a}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}function BE(e){var t;if(typeof e.getHeader=="function"?t=e.getHeader("content-type"):typeof e.headers=="object"&&(t=e.headers&&e.headers["content-type"]),typeof t!="string")throw new TypeError("content-type header is missing from object");return t}function HE(e){var t=String(e);if(O0.test(t))return t;if(t.length>0&&!LE.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(qE,"\\$1")+'"'}function KE(e){this.parameters=Object.create(null),this.type=e}});import{webcrypto as YT}from"node:crypto";import{parseArgs as QT}from"node:util";var C={};sa(C,{BIGINT_FORMAT_RANGES:()=>Ho,CONSTANT_CATCH:()=>jd,Class:()=>ua,NUMBER_FORMAT_RANGES:()=>pn,aborted:()=>We,allowsEval:()=>ha,assert:()=>Zb,assertEqual:()=>Ib,assertIs:()=>Nb,assertNever:()=>jb,assertNotEqual:()=>Cb,assignProp:()=>De,attachSchema:()=>Jo,base64ToUint8Array:()=>Cd,base64urlToUint8Array:()=>rw,cached:()=>zr,captureStackTrace:()=>Vo,cleanEnum:()=>tw,cleanRegex:()=>fn,clone:()=>qe,cloneDef:()=>Lb,codePointLength:()=>hn,constantCatch:()=>Zd,createTransparentProxy:()=>Hb,defineLazy:()=>Pd,defineLazyInternal:()=>V,derived:()=>iw,esc:()=>fa,escapeRegex:()=>mt,explicitlyAborted:()=>ya,extend:()=>Wb,finalizeIssue:()=>Ge,floatSafeRemainder:()=>da,getElementAtPath:()=>Ub,getEnumValues:()=>$r,getLengthableOrigin:()=>mn,getParsedType:()=>Bb,getSizableOrigin:()=>Id,hexToUint8Array:()=>ow,hide:()=>Wo,installLazyProp:()=>lw,isObject:()=>Qt,isPlainObject:()=>At,issue:()=>Pr,joinValues:()=>Fo,jsonStringifyReplacer:()=>Sr,members:()=>ba,merge:()=>Xb,mergeDefs:()=>ht,normalizeParams:()=>R,nullish:()=>la,numKeys:()=>Vb,objectClone:()=>Mb,omit:()=>Jb,optionalKeys:()=>ga,own:()=>Rt,parsedType:()=>_a,partial:()=>Yb,pick:()=>Kb,prefixIssues:()=>gt,primitiveTypes:()=>Rd,promiseAllObject:()=>qb,propertyKeyTypes:()=>ma,randomString:()=>Fb,rawShape:()=>kr,required:()=>Qb,safeExtend:()=>Gb,shallowClone:()=>Od,slugify:()=>pa,stringifyPrimitive:()=>Bo,toZod:()=>kd,uint8ArrayToBase64:()=>Nd,uint8ArrayToBase64url:()=>nw,uint8ArrayToHex:()=>sw,unwrapMessage:()=>vr});function Ib(e){return e}function Cb(e){return e}function kd(){return e=>e}function Nb(e){}function jb(e){throw new Error("Unexpected value in exhaustive check")}function Zb(e){}function $r(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Fo(e,t="|"){return e.map(r=>Bo(r)).join(t)}function Sr(e,t){return typeof t=="bigint"?t.toString():t}var ca=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function zr(e){return new ca(e)}function la(e){return e==null}function fn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function da(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var zd=Symbol("evaluating");function Pd(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==zd)return n===void 0&&(n=zd,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Mb(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function De(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function kr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function pt(e){return kr(e._zod.def)??e._zod.def.shape}function Ed(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return De(this,t,n),n},enumerable:!0,configurable:!0})}function Td(e,t,r){t in e?De(e,t,r):e[t]=r}function Yt(e,t,r,n){let o=pt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?Ed(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):Td(e,s,n?n(i.value,s):i.value))}}function Db(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?Ed(e,r,()=>t[r]):Td(e,r,n.value))}}function ht(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Lb(e){return ht(e._zod.def)}function Ub(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function qb(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function Fb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function fa(e){return JSON.stringify(e)}function pa(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Vo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Qt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ha=zr(()=>{if(Re.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function At(e){if(Qt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Qt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Od(e){return At(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Vb(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Bb=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ma=new Set(["string","number","symbol"]),Rd=new Set(["string","number","bigint","boolean","symbol","undefined"]);function mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qe(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function R(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Hb(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function Bo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ga(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var pn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ho={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Kb(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return Yt(s,e,Ko(e,t)),qe(e,ht(r,{shape:s,checks:[]}))}function Ko(e,t){let r=pt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function Jb(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Ko(e,t)),i={};return Yt(i,e,Reflect.ownKeys(pt(e)).filter(a=>!s.has(a))),qe(e,ht(r,{shape:i,checks:[]}))}function Wb(e,t){if(!At(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=pt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qe(e,ht(e._zod.def,{shape:Ad(e,t)}))}function Ad(e,t){let r={};return Yt(r,e,Reflect.ownKeys(pt(e))),Db(r,t),r}function Gb(e,t){if(!At(t))throw new Error("Invalid input to safeExtend: expected a plain object");return qe(e,ht(e._zod.def,{shape:Ad(e,t)}))}function Xb(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Yt(r,e,Reflect.ownKeys(pt(e))),Yt(r,t,Reflect.ownKeys(pt(t)));let n=ht(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return qe(e,n)}function Yb(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Ko(t,r)):void 0,c={};return Yt(c,t,Reflect.ownKeys(pt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),qe(t,ht(t._zod.def,{shape:c,checks:[]}))}function Qb(e,t,r){let n=r?new Set(Ko(t,r)):void 0,o={};return Yt(o,t,Reflect.ownKeys(pt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),qe(t,ht(t._zod.def,{shape:o}))}function We(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ya(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function gt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function vr(e){return typeof e=="string"?e:e?.message}function Jo(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Ge(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:vr(e.inst?._zod.def?.error?.(e))??vr(s?.(e))??vr(t?.error?.(e))??vr(r.customError?.(e))??vr(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Id(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var ew=/[\uD800-\uDBFF]/;function hn(e){let t=e.length;if(!ew.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function mn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function _a(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Pr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function tw(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Cd(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Nd(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function rw(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Cd(t+r)}function nw(e){return Nd(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ow(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function sw(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ua=class{constructor(...t){}};function ba(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):aw(e,r,n.value)}}function Rt(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Wo(e,t,r){return Rt(e,t,r,!1)}function iw(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Rt(this,r,n(this))},set(o){Rt(this,r,o)}})}return t}function aw(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Rt(this,t,r.bind(this))},set(n){Rt(this,t,n)}})}function cw(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var aa,Ot=!1,uw={configurable:!0,get(){Ot=!0}};function V(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&aa!==e._zod){aa=void 0;return}aa=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,uw);let o=Ot;Ot=!1;try{let s=r(this);return Ot?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Ot=Ot||o,s}catch(s){throw delete this[t],Ot=Ot||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function lw(e,t,r,n){let o=cw(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var jd="~constantCatch";function Zd(e){let t=()=>e;return t[jd]=!0,t}var Md,xa=Object.freeze({status:"aborted"}),wa={value:void 0,enumerable:!1},Dd="captureStackTrace"in Error?Error:null;function dw(e){let t=Dd;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Dd=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function _(e,t,r,n){let o={};function s(p){this.def=p,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(p,f){if(p._zod){if(p._zod.traits.has(e))return}else{wa.value=new s(f);try{Object.defineProperty(p,"_zod",wa)}finally{wa.value=void 0}}if(p._zod.traits.add(e),t(p,f),a){let m=Object.getPrototypeOf(p),y=p._zod.constr.prototype,w=m;for(;w&&w!==y;)w=Object.getPrototypeOf(w);let v=w??m;a.has(v)||(a.add(v),ba(v,i))}let h=d.prototype;for(let m in h)Object.prototype.hasOwnProperty.call(h,m)&&(m in p||(p[m]=h[m].bind(p)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(p){let f=n?.Parent?dw(l):this;c(f,p);let h=f._zod.deferred;if(h){for(let y of h)y();f._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(f),f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>n?.Parent&&p instanceof n.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Xe=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Er=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Md=globalThis).__zod_globalConfig??(Md.__zod_globalConfig={});var Re=globalThis.__zod_globalConfig;function Ae(e){return e&&Object.assign(Re,e),Re}function fw(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Sr,2)),e.message}function pw(e){this._zod.message=e}var hw={get:fw,set:pw,enumerable:!0,configurable:!0},$a={value:void 0,enumerable:!1},Ld=new WeakSet([Object.prototype,Error.prototype]),Ud=(e,t)=>{e.name="$ZodError",$a.value=t,Object.defineProperty(e,"issues",$a),$a.value=void 0,Object.defineProperty(e,"message",hw);let r=Object.getPrototypeOf(e);Ld.has(r)||(Ld.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},qd=_("$ZodError",Ud),Fd=_("$ZodError",Ud,void 0,{Parent:Error});function mw(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Sa(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?mw(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function za(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=c[l];d&&p._errors.push(t(i)),c=p,u++}}}};return n(e),r}function Go(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Xo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Xe;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw Vo(c,s?.callee??t),c}return a.value};return t};var Yo=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw Vo(c,s?.callee??t),c}return a.value};return t};var gn=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Xe;return s.issues.length?Vd(e,s.issues,o):{success:!0,data:s.value}},ka=gn(Fd);function Vd(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>Ge(o,r,Ae()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Qo=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Vd(e,s.issues,o):{success:!0,data:s.value}};var yw=Symbol.for("zod.compile.invalid"),_w=Symbol.for("zod.compile.fallback"),es=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==yw)return!0;if(n.definite===!0&&r===void 0)return!1}return bw(e,t,r)});function bw(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[_w]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new Xe;return s.issues.length===0}var ts=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Bd=e=>{let t=Xo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Go(r,i))};return r};var Hd=e=>{let t=Xo(e),r=(n,o,s,i)=>t(n,o,s,Go(r,i));return r};var Kd=e=>{let t=Yo(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Go(r,i))};return r};var Jd=e=>{let t=Yo(e),r=async(n,o,s,i)=>await t(n,o,s,Go(r,i));return r};var Wd=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return gn(e)(t,r,o)};var Gd=e=>(t,r,n)=>gn(e)(t,r,n);var Xd=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Qo(e)(t,r,o)};var Yd=e=>async(t,r,n)=>Qo(e)(t,r,n);var Qd=/^[cC][0-9a-z]{6,}$/,ef=/^[0-9a-z]+$/,tf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,rf=/^[0-9a-vA-V]{20}$/,nf=/^[A-Za-z0-9]{27}$/,of=/^[a-zA-Z0-9_-]{21}$/;function sf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var af=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var cf=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ea=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var uf=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var ww="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function lf(){return new RegExp(ww,"u")}var df=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ff=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var pf=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,gf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var yf=/^https?$/,_f=/^\+[1-9]\d{6,14}$/;var bf="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function xw(e){return new RegExp(`^${e}$`)}var wf=xw(bf);function Pa(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function xf(e){return new RegExp(`^${Pa(e)}$`)}function vf(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Pa({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Pa({precision:e.precision})}`:r;return new RegExp(`^${bf}T(?:${n})$`)}var $f=/^[\s\S]{0,}$/;var Sf=/^-?\d+n?$/,Ta=/^-?\d+$/,yn=/^-?\d+(?:\.\d+)?$/,zf=/^(?:true|false)$/i,kf=/^null$/i;var Pf=/^[^A-Z]*$/,Ef=/^[^a-z]*$/;var me=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Oa=e=>{let t=e.value;return!la(t)&&t.length!==void 0},rs={number:"number",bigint:"bigint",object:"date"},Ra=_("$ZodCheckLessThan",(e,t)=>{me.init(e,t);let r=rs[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:rs[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Aa=_("$ZodCheckGreaterThan",(e,t)=>{me.init(e,t);let r=rs[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:rs[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Tf=_("$ZodCheckMultipleOf",(e,t)=>{me.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):da(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Of=_("$ZodCheckNumberFormat",(e,t)=>{me.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=pn[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Rf=_("$ZodCheckMaxLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Oa),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?hn(o):s)<=t.maximum)return;let a=mn(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Af=_("$ZodCheckMinLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Oa),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?hn(o):s)>=t.minimum)return;let a=mn(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),If=_("$ZodCheckLengthEquals",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Oa),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?hn(o):s;if(i===t.length)return;let a=mn(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),_n=_("$ZodCheckStringFormat",(e,t)=>{var r,n;me.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Cf=_("$ZodCheckRegex",(e,t)=>{_n.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Nf=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pf),_n.init(e,t)}),jf=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ef),_n.init(e,t)}),Zf=_("$ZodCheckIncludes",(e,t)=>{me.init(e,t);let r=mt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Mf=_("$ZodCheckStartsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`^${mt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Df=_("$ZodCheckEndsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`.*${mt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Lf=_("$ZodCheckOverwrite",(e,t)=>{me.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ns=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
11
|
+
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
12
|
+
${r.join(`
|
|
13
|
+
`)}
|
|
14
|
+
};`)(...Object.values(this.closed))}};var qf={major:4,minor:6,patch:5};var J=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qf;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=We(a),d;for(let p of c){if(p._zod.def.when){if(ya(a)||!p._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,h=p._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new Xe;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==f&&(Jo(a.issues,f,e),l||(l=We(a,f)))});else{if(a.issues.length===f)continue;Jo(a.issues,f,e),l||(l=We(a,f))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(We(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new Xe;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Xe;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return Wo(this,"~standard",Ca(this))},set"~standard"(e){Rt(this,"~standard",e)}}),Qf=(e,t)=>e.issues.length?{issues:e.issues.map(r=>Ge(r,t,Ae()))}:{value:e.value};async function vw(e,t){let r={async:!0};return Qf(await e._zod.run({value:t,issues:[]},r),r)}function Ca(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Qf(n,r)}catch{}return vw(e,t)},vendor:"zod",version:1}}var as=_("$ZodString",(e,t)=>{J.init(e,t),e._zod.pattern=t.pattern??$f,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ee=_("$ZodStringFormat",(e,t)=>{_n.init(e,t),as.init(e,t)}),ep=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=cf),ee.init(e,t)}),tp=_("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ea(n))}else t.pattern??(t.pattern=Ea());ee.init(e,t)}),rp=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=uf),ee.init(e,t)}),np=1,ss=2;function op(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function $w(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?op(e)||ss:Sw(e,t)}function Sw(e,t){if(!t.normalize&&t.protocol?.source===yf.source&&!/^https?:\/\//i.test(e))return np;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??ss}return new URL(e)}catch{return ss}}var zw=/[\t\n\r]/g;function Ff(e){return e.replace(zw,"")}function kw(e,t){return t.lastIndex=0,t.test(e.hostname)}function Pw(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var sp=_("$ZodURL",(e,t)=>{ee.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=$w(n,t);if(o===np){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===ss){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ff(n);return}t.hostname&&!kw(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!Pw(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Ff(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ip=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=lf()),ee.init(e,t)}),ap=_("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?of:sf(t.length)),ee.init(e,t)}),cp=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Qd),ee.init(e,t)}),up=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ef),ee.init(e,t)}),lp=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=tf),ee.init(e,t)}),dp=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=rf),ee.init(e,t)}),fp=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=nf),ee.init(e,t)}),pp=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=vf(t)),ee.init(e,t)}),hp=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=wf),ee.init(e,t)}),mp=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xf(t)),ee.init(e,t)}),gp=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=af),ee.init(e,t)}),yp=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=df),ee.init(e,t)}),Ew=/^[0-9a-fA-F:.]+$/;function _p(e){return Ew.test(e)?op(`http://[${e}]`):!1}var bp=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ff),ee.init(e,t),e._zod.check=r=>{_p(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var wp=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=pf),ee.init(e,t)});function Tw(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:_p(r)}var xp=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=hf),ee.init(e,t),e._zod.check=r=>{Tw(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function vp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Na=/^[0-9a-zA-Z+/]*={0,2}$/,$p=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Na),ee.init(e,t),e._zod.check=r=>{vp(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),cs=/^[A-Za-z0-9_-]*$/;function Ow(e){if(!cs.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return vp(r)}var Sp=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=cs),ee.init(e,t),e._zod.check=r=>{Ow(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),zp=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_f),ee.init(e,t)});function Rw(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var kp=_("$ZodJWT",(e,t)=>{ee.init(e,t),e._zod.check=r=>{Rw(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ja=_("$ZodNumber",(e,t)=>{J.init(e,t),e._zod.pattern=yn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Pp=_("$ZodNumberFormat",(e,t)=>{Of.init(e,t),ja.init(e,t)}),Ep=_("$ZodBoolean",(e,t)=>{J.init(e,t),e._zod.pattern=zf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),Tp=_("$ZodBigInt",(e,t)=>{J.init(e,t),e._zod.pattern=Sf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var Op=_("$ZodNull",(e,t)=>{J.init(e,t),e._zod.pattern=kf,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),Rp=_("$ZodAny",(e,t)=>{J.init(e,t),e._zod.parse=r=>r}),Ap=_("$ZodUnknown",(e,t)=>{J.init(e,t),e._zod.parse=r=>r}),Ip=_("$ZodNever",(e,t)=>{J.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var Cp=_("$ZodDate",(e,t)=>{J.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,s=o instanceof Date;return s&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Vf(e,t,r){e.issues.length&&t.issues.push(...gt(r,e.issues)),t.value[r]=e.value}var Np=_("$ZodArray",(e,t)=>{J.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Vf(d,n,c)));else if(Vf(l,n,c),a&&l.issues.length!==0&&We(l))break}return i.length?Promise.all(i).then(()=>n):n}});function is(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...gt(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Aw=[];function jp(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Aw,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=ga(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Zp(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,p=u.optout,f=0;for(let h in t){if(i&&r.issues.length!==f){if(We(r,f))break;f=r.issues.length}if(c.has(h))continue;if(h==="__proto__"){l==="never"&&a.push(h);continue}if(l==="never"){a.push(h);continue}let m=u.run({value:t[h],issues:[]},n);m instanceof Promise?e.push(m.then(y=>is(y,r,h,t,d,p))):is(m,r,h,t,d,p)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Iw=_("$ZodObject",(e,t)=>{J.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=zr(()=>jp(t));V(e,"propValues",u=>{let l=u.def.shape,d={};for(let p in l){let f=l[p]._zod;if(f.values){Object.prototype.hasOwnProperty.call(d,p)||De(d,p,new Set);for(let h of f.values)d[p].add(h);f.optin!==void 0&&d[p].add(void 0)}}return d});let s=Qt,i=t.catchall,a,c=Re.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let p=[],f=a.shape,h=l?.abortEarly,m=u.issues.length;for(let y of a.allKeys){if(h&&u.issues.length!==m){if(We(u,m))break;m=u.issues.length}if(y==="__proto__")continue;let w=f[y],v=w._zod.optin,z=w._zod.optout,A=w._zod.run({value:d[y],issues:[]},l);A instanceof Promise?p.push(A.then(b=>is(b,u,y,d,v,z))):is(A,u,y,d,v,z)}return i?Zp(p,d,u,l,o.value,e,h===!0):p.length?Promise.all(p).then(()=>u):u}}),Mp=_("$ZodObjectJIT",(e,t)=>{Iw.init(e,t);let r=e._zod.parse,n=zr(()=>jp(t)),o=Re.memoizer,s=f=>{let h=n.value,m=h.symbolKeys,y=new ns(["payload","ctx"],{shape:f,inst:e,memo:o,syms:m}),w=b=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,v=(b,x)=>`
|
|
15
|
+
let ${b}_ab = false;
|
|
16
|
+
for (let i = 0; i < ${b}.issues.length; i++) {
|
|
17
|
+
const iss = ${b}.issues[i];
|
|
18
|
+
iss.path = iss.path ? [${x}, ...iss.path] : [${x}];
|
|
19
|
+
payload.issues.push(iss);
|
|
20
|
+
if (iss.continue !== true) ${b}_ab = true;
|
|
21
|
+
}
|
|
22
|
+
if (${b}_ab && ctx && ctx.abortEarly) {
|
|
23
|
+
payload.value = newResult;
|
|
24
|
+
return payload;
|
|
25
|
+
}`;y.write("const input = payload.value;");let z=Object.create(null),A=0;for(let b of h.allKeys)z[b]=`key_${A++}`;y.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let b of h.allKeys){if(b==="__proto__")continue;let x=z[b],T=typeof b=="symbol"?`syms[${m.indexOf(b)}]`:fa(b),K=`${T} in input`,Z=f[b],oe=Z?._zod?.optin,ft=oe!==void 0,Xt=Z?._zod?.optout==="optional";if(y.write(`const ${x} = ${w(T)};`),ft&&Xt){let xr=oe==="optional"?`${x}_present`:`${x}.value !== undefined || ${x}_present`;y.write(`
|
|
26
|
+
const ${x}_present = ${K};
|
|
27
|
+
if (!${x}.issues.length || ${x}_present) {
|
|
28
|
+
if (${x}.issues.length) {${v(x,T)}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (${xr}) {
|
|
32
|
+
newResult[${T}] = ${x}.value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
`)}else ft?(y.write(`
|
|
37
|
+
if (${x}.issues.length) {${v(x,T)}
|
|
38
|
+
}
|
|
39
|
+
`),oe==="defaulted"?y.write(`newResult[${T}] = ${x}.value;`):y.write(`
|
|
40
|
+
if (${x}.value !== undefined || ${K}) {
|
|
41
|
+
newResult[${T}] = ${x}.value;
|
|
42
|
+
}
|
|
43
|
+
`)):y.write(`
|
|
44
|
+
const ${x}_present = ${K};
|
|
45
|
+
if (${x}.issues.length) {${v(x,T)}
|
|
46
|
+
}
|
|
47
|
+
if (!${x}_present && !${x}.issues.length) {
|
|
48
|
+
payload.issues.push({
|
|
49
|
+
code: "invalid_type",
|
|
50
|
+
expected: "nonoptional",
|
|
51
|
+
input: undefined,
|
|
52
|
+
path: [${T}]
|
|
53
|
+
});
|
|
54
|
+
if (ctx && ctx.abortEarly) {
|
|
55
|
+
payload.value = newResult;
|
|
56
|
+
return payload;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (${x}_present) {
|
|
61
|
+
newResult[${T}] = ${x}.value;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},i,a=Qt,c=!Re.jitless,l=c&&ha.value,d=t.catchall,p;e._zod.parse=(f,h)=>{p??(p=n.value);let m=f.value;return a(m)?c&&l&&h?.async===!1&&h.jitless!==!0?(i||(i=s(t.shape)),f=i(f,h),d?Zp([],m,f,h,p,e,h?.abortEarly===!0):f):r(f,h):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function Bf(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!We(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>Ge(i,n,Ae())))}),t)}var Za=_("$ZodUnion",(e,t)=>{J.init(e,t),V(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),V(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),V(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),V(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>fn(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>Bf(a,n,e,o)):Bf(i,n,e,o)}});function Cw(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Dp=_("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Za.init(e,t);let r=e._zod.parse;V(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||De(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=kr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=zr(()=>Cw(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Qt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Lp=_("$ZodIntersection",(e,t)=>{J.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Hf(r,c,u)):Hf(r,s,i)}});function Ia(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(At(e)&&At(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Ia(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Ia(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Hf(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);s.has(p)||s.set(p,u),d=[p]}else return!1;for(let p of d)n.has(p)||n.set(p,{}),n.get(p)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Ia(t.value,r.value);if(!c.valid){if(We(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Up=_("$ZodRecord",(e,t)=>{J.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!At(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>Ge(h,o,Ae())),input:l,path:[l],inst:e});continue}let p=d.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},o);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...gt(l,h.issues)),n.value[p]=h.value})):(f.issues.length&&n.issues.push(...gt(l,f.issues)),n.value[p]=f.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&yn.test(u)&&l.issues.length){let h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>Ge(h,o,Ae())),input:u,path:[u],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},o);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...gt(u,h.issues)),n.value[p]=h.value})):(f.issues.length&&n.issues.push(...gt(u,f.issues)),n.value[p]=f.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var qp=_("$ZodEnum",(e,t)=>{J.init(e,t);let r=$r(t.entries),n=new Set(r);e._zod.values=n,V(e,"pattern",o=>{let s=$r(o.def.entries).filter(i=>ma.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>mt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Fp=_("$ZodLiteral",(e,t)=>{J.init(e,t);let r=new Set(t.values);e._zod.values=r,V(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?mt(s):s?mt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Vp=_("$ZodTransform",(e,t)=>{J.init(e,t),e._zod.optin="optional",Re.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Er(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new Xe;return r.value=o,r}});function Kf(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ma=_("$ZodOptional",(e,t)=>{J.init(e,t),V(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",V(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),V(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${fn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Kf(r,s)):Kf(r,o)}return t.innerType._zod.run(r,n)}}),Bp=_("$ZodExactOptional",(e,t)=>{Ma.init(e,t),V(e,"values",r=>r.def.innerType._zod.values),V(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Hp=_("$ZodNullable",(e,t)=>{J.init(e,t),V(e,"optin",r=>r.def.innerType._zod.optin),V(e,"optout",r=>r.def.innerType._zod.optout),V(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${fn(n.source)}|null)$`):void 0}),V(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Kp=_("$ZodDefault",(e,t)=>{J.init(e,t),e._zod.optin="defaulted",V(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Jf(s,t)):Jf(o,t)}});function Jf(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Jp=_("$ZodPrefault",(e,t)=>{J.init(e,t),e._zod.optin="defaulted",V(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Wp=_("$ZodNonOptional",(e,t)=>{J.init(e,t),V(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Wf(s,e)):Wf(o,e)}});function Wf(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Gf(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Ge(o,n,Ae()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Gp=_("$ZodCatch",(e,t)=>{J.init(e,t),V(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),V(e,"optout",r=>r.def.innerType._zod.optout),V(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Gf(r,s,t,n)):Gf(r,o,t,n)}});var Da=_("$ZodPipe",(e,t)=>{J.init(e,t),V(e,"values",r=>r.def.in._zod.values),V(e,"optin",r=>r.def.in._zod.optin),V(e,"optout",r=>r.def.out._zod.optout),V(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>os(i,t.in,n)):os(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>os(s,t.out,n)):os(o,t.out,n)}});function os(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Xp=_("$ZodPreprocess",(e,t)=>{Da.init(e,t)}),Yp=_("$ZodReadonly",(e,t)=>{J.init(e,t),V(e,"propValues",r=>r.def.innerType._zod.propValues),V(e,"values",r=>r.def.innerType._zod.values),V(e,"optin",r=>r.def.innerType?._zod?.optin),V(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Xf):Xf(o)}});function Xf(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Qp=_("$ZodCustom",(e,t)=>{me.init(e,t),J.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Yf(s,r,n,e));Yf(o,r,n,e)}});function Yf(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Pr(o))}}var Ua=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},qa="~memo",eh=[];function th(e){return e!==null&&typeof e=="object"}function La(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var rh=new WeakMap,bn=0,ds=1,wn=2;function fs(e,t,r){let n=rh.get(e);if(n!==void 0)return n?wn:bn;if(t.has(e))return wn;t.add(e);let o=bn,s=l=>{if(o!==wn&&l?._zod){let d=fs(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let p=bn;for(let f of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,f);if(d&&!h.enumerable)continue;let m=h.get?ds:h.value?._zod?fs(h.value,t,r):bn;m>p&&(p=m)}return p},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=kr(c);a(l?i(l,!0):ds),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?fs(l,t,!1):ds);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let p=d.value;if(!(!p||typeof p!="object")){if(p._zod)s(p);else if(Array.isArray(p))for(let f of p)s(f)}}}return t.delete(e),Nw(e,o)}function Nw(e,t){return t!==ds&&rh.set(e,t===wn),t}function jw(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var us,ls=[],Zw={alloc(e,t,r){let n=us;if(!n)return r;us=void 0;let o={value:r,issues:null};return n.set(t.value,o),ls.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Mw(s,o.value))throw new Ua;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let w=fs(e,new Set,!1);if(w===bn)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);w===wn||n?r=!0:n=!0}let l=c.value;if(!th(l))return i(c,u);let d=u[qa];d||(d={buckets:new WeakMap,backEdges:void 0},u[qa]=d);let p;o===u?p=s:(p=jw(d,e),o=u,s=p);let f=p.get(l);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...La(f.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value)),c;us=p;let h=ls.length,m=i(c,u);us=void 0;let y=ls.length>h?ls.pop():void 0;return m instanceof Promise?m.then(w=>(y&&(y.issues=w.issues.length?La(w.issues):eh),w)):(y&&(y.issues=m.issues.length?La(m.issues):eh),m)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Fa(){return Zw}function Mw(e,t){let r=e[qa]?.backEdges;return r!==void 0&&th(t)&&r.has(t)}var Dw=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=_a(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${Bo(s.values[0])}`:`Invalid option: expected one of ${Fo(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Fo(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function nh(){return{localeError:Dw()}}var oh;var Va=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function sh(){return new Va}(oh=globalThis).__zod_globalRegistry??(oh.__zod_globalRegistry=sh());var It=globalThis.__zod_globalRegistry;function ps(e){return e.checks&&(e.checks=[...e.checks]),e}function ih(e,t){return new e(ps({type:"string",...R(t)}))}function ah(e,t){return new e(ps({type:"string",coerce:!0,...R(t)}))}function ch(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...R(t)})}function uh(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...R(t)})}function lh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...R(t)})}function dh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...R(t)})}function fh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...R(t)})}function ph(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...R(t)})}function Ba(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...R(t)})}function hh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...R(t)})}function mh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...R(t)})}function gh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...R(t)})}function yh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...R(t)})}function _h(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...R(t)})}function bh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...R(t)})}function wh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...R(t)})}function xh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...R(t)})}function vh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...R(t)})}function $h(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...R(t)})}function Sh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...R(t)})}function zh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...R(t)})}function kh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...R(t)})}function Ph(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...R(t)})}function Eh(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...R(t)})}function hs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...R(t)})}function ms(e,t){return new e({type:"string",format:"date",check:"string_format",...R(t)})}function gs(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...R(t)})}function ys(e,t){return new e({type:"string",format:"duration",check:"string_format",...R(t)})}function Th(e,t){return new e(ps({type:"number",checks:[],...R(t)}))}function Oh(e,t){return new e(ps({type:"number",coerce:!0,checks:[],...R(t)}))}function Rh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...R(t)})}function Ah(e,t){return new e({type:"boolean",...R(t)})}function Ih(e,t){return new e({type:"boolean",coerce:!0,...R(t)})}function Ch(e,t){return new e({type:"bigint",coerce:!0,...R(t)})}function Nh(e,t){return new e({type:"null",...R(t)})}function jh(e){return new e({type:"any"})}function Zh(e){return new e({type:"unknown"})}function Mh(e,t){return new e({type:"never",...R(t)})}function Dh(e,t){return new e({type:"date",coerce:!0,...R(t)})}function Or(e,t){return new Ra({check:"less_than",...R(t),value:e,inclusive:!1})}function yt(e,t){return new Ra({check:"less_than",...R(t),value:e,inclusive:!0})}function Rr(e,t){return new Aa({check:"greater_than",...R(t),value:e,inclusive:!1})}function _t(e,t){return new Aa({check:"greater_than",...R(t),value:e,inclusive:!0})}function xn(e,t){return new Tf({check:"multiple_of",...R(t),value:e})}function _s(e,t){return new Rf({check:"max_length",...R(t),maximum:e})}function Ar(e,t){return new Af({check:"min_length",...R(t),minimum:e})}function bs(e,t){return new If({check:"length_equals",...R(t),length:e})}function Ha(e,t){return new Cf({check:"string_format",format:"regex",...R(t),pattern:e})}function Ka(e){return new Nf({check:"string_format",format:"lowercase",...R(e)})}function Ja(e){return new jf({check:"string_format",format:"uppercase",...R(e)})}function Wa(e,t){return new Zf({check:"string_format",format:"includes",...R(t),includes:e})}function Ga(e,t){return new Mf({check:"string_format",format:"starts_with",...R(t),prefix:e})}function Xa(e,t){return new Df({check:"string_format",format:"ends_with",...R(t),suffix:e})}function Ct(e){return new Lf({check:"overwrite",tx:e})}function Ya(e){return Ct(t=>t.normalize(e))}function Qa(){return Ct(e=>e.trim())}function ec(){return Ct(e=>e.toLowerCase())}function tc(){return Ct(e=>e.toUpperCase())}function rc(){return Ct(e=>pa(e))}function Lh(e,t,r){return new e({type:"array",element:t,...R(r)})}function Uh(e,t,r){let n=R(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function qh(e,t,r){return new e({type:"custom",check:"custom",fn:t,...R(r)})}function Fh(e,t){let r=Lw(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Pr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Pr(s))}},e(n.value,n)),t);return r}function Lw(e,t){let r=new me({check:"custom",...R(t)});return r._zod.check=e,r}function vn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&De(e,n,r[n]);return e}function oc(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??It,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ye(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ue(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let p=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ue(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&vn(i.schema,c),t.io==="input"&&Pe(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Vh(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function sc(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,p=e.external.uri??(h=>h);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${Vh(f)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Vh(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
65
|
+
|
|
66
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Kh(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Kh(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Jh=new Set(["type","properties","required","additionalProperties"]),Bh=["oneOf","anyOf"];function Hh(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function nc(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Jh.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Hh(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:nc(a)??{allOf:a};De(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Hh(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function Uw(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Jh)if(o in e)return;let r=t.filter(o=>Bh.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=nc(t);else{let o=r[0],s=Bh.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>nc([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,vn(e,n))}function ic(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let f=e.seen.get(d),h=f.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):vn(u,h),vn(u,l),a._zod.parent===d)for(let y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(h.$ref&&f.def)for(let y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=e.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let h in u)h==="$ref"||h==="allOf"||h in f.def&&JSON.stringify(u[h])===JSON.stringify(f.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Kh(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Uw(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}vn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,De(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:$n(t,"input",e.processors),output:$n(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Pe(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Pe(n.element,r);if(n.type==="set")return Pe(n.valueType,r);if(n.type==="lazy")return Pe(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Pe(n.innerType,r);if(n.type==="intersection")return Pe(n.left,r)||Pe(n.right,r);if(n.type==="record"||n.type==="map")return Pe(n.keyType,r)||Pe(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Pe(n.in,r)||Pe(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Pe(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Pe(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Pe(o,r))return!0;return!!(n.rest&&Pe(n.rest,r))}return!1}var Wh=(e,t={})=>r=>{let n=oc({...r,processors:t});return ue(e,n),sc(n,e),ic(n,e)},$n=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=oc({...o??{},target:s,io:t,processors:r});return ue(e,i),sc(i,e),ic(i,e)};var Ir=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Cr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Gh=(e,t)=>{Ir(e,"minimum",t),Cr(e,"maximum",t)},em=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},tm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},rm=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},nm=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Xh=(e,t)=>Ir(e,"minimum",t.minimum),Yh=(e,t)=>Cr(e,"maximum",t.maximum),Qh=e=>(t,r)=>{nm(t,r.format);let[n,o]=e[r.format];Ir(t,"minimum",n),Cr(t,"maximum",o)},qw={greater_than:(e,t)=>Ir(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Cr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>em(e,t.value),number_format:Qh(pn),bigint_format:Qh(Ho),min_length:Xh,max_length:Yh,length_equals:(e,t)=>Gh(e,t.length),min_size:Xh,max_size:Yh,size_equals:(e,t)=>Gh(e,t.size),string_format:(e,t)=>{nm(e,t.format),t.pattern&&tm(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>rm(e,t.mime)};function ge(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)qw[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&Ir(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Ir(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Cr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Cr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&em(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&rm(t,o.mime);for(let s of o.patterns??[])tm(t,s);return t}var Fw={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vw=new Map([[Na,mf],[cs,gf]]),om=e=>Vw.get(e)??e,sm=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ge(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Fw[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(om);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},im=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ge(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),p=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d?f?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let h=new Set;for(let w of a)Number.isFinite(w)&&w!==0?h.add(Math.abs(w)):Ye(e,t,o,n,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[m,...y]=h;m!==void 0&&(o.multipleOf=m),y.length&&(o.allOf=[...o.allOf??[],...y.map(w=>({multipleOf:w}))])}},am=(e,t,r,n)=>{r.type="boolean"},cm=(e,t,r,n)=>{Ye(e,t,r,n,"BigInt cannot be represented in JSON Schema")};var um=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var lm=(e,t,r,n)=>{r.not={}},dm=(e,t,r,n)=>{},fm=(e,t,r,n)=>{},pm=(e,t,r,n)=>{Ye(e,t,r,n,"Date cannot be represented in JSON Schema")},hm=(e,t,r,n)=>{let o=e._zod.def,s=$r(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},mm=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Ye(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Ye(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var gm=(e,t,r,n)=>{Ye(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var ym=(e,t,r,n)=>{Ye(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var _m=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ge(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ue(s.element,t,{...n,path:[...n.path,"items"]})};function ws(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ws(t.out):t.type==="catch"?ws(t.innerType):e._zod.optin}var bm=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ye(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)De(o.properties,u,ue(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?ws(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ue(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},wm=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ue(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},xm=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ue(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function ac(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let m=ac(e,h,r);return m===h?t:m}for(let h of["anyOf","oneOf"]){let m=t[h];if(!Array.isArray(m))continue;let y=m.map(w=>ac(e,w,r));y.some((w,v)=>w!==m[v])&&(t={...t,[h]:y})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(h=>h==="number"||h==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(h=>typeof h=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:p,...f}=t;return f.enum?f.enum=f.enum.map(h=>typeof h=="number"?String(h):h):typeof f.const=="number"&&(f.const=String(f.const)),o&&(f.type="string",s||(f.pattern=(n.includes("number")?yn:Ta).source)),f}var cc=new WeakMap;function Bw(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of cc.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=ac(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var vm=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ge(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ue(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)De(o.patternProperties,om(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ue(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=cc.get(t);l||(l=[],cc.set(t,l),t.deferred.push(()=>Bw(t))),l.push(e)}o.additionalProperties=ue(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&ws(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},$m=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},Sm=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},uc=Symbol();function zm(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Ye(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),uc):JSON.parse(i)}var km=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=zm(o.defaultValue,e,t,r,n);i!==uc&&(r.default=i)},Pm=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=zm(o.defaultValue,e,t,r,n);i!==uc&&(r._prefault=i)},Em=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ye(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Tm=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ue(i,t,n);let a=t.seen.get(e);a.ref=i},Om=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var lc=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function xs(e){return!!e._zod}function Ee(e,t){return xs(e)?ka(e,t):e.safeParse(t)}function jr(e){if(!e)return;let t;if(xs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Zr(e){if(xs(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var Rm=new WeakSet([Object.prototype,Error.prototype]);function vs(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var tx=(e,t)=>{qd.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Rm.has(r)||(Rm.add(r),vs(r,"format",n=>o=>za(n,o)),vs(r,"flatten",n=>o=>Sa(n,o)),vs(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Sr,2)}),vs(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Sr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Le=_("ZodError",tx,void 0,{Parent:Error});var Am=Xo(Le),Im=Yo(Le),Cm=gn(Le),Nm=Qo(Le),jm=Bd(Le),Zm=Hd(Le),Mm=Kd(Le),Dm=Jd(Le),Lm=Wd(Le),Um=Gd(Le),qm=Xd(Le),Fm=Yd(Le);function nx(){Re.localeError||Ae(nh())}function Ss(){Re.memoizer||Ae({memoizer:Fa()})}var G=_("ZodType",(e,t)=>(nx(),J.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(C.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return qe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Vx(e,t))},superRefine(e,t){return this.check(Bx(e,t))},overwrite(e){return this.check(Ct(e))},optional(){return ie(this)},exactOptional(){return Ax(this)},nullable(){return Hm(this)},nullish(){return ie(Hm(this))},nonoptional(e){return Mx(this,e)},array(){return $(this)},or(e){return te([this,e])},and(e){return ks(this,e)},transform(e){return Km(this,ng(e))},default(e){return Nx(this,e)},prefault(e){return Zx(this,e)},catch(e){return Lx(this,e)},pipe(e){return Km(this,e)},readonly(){return Fx(this)},describe(e){let t=this.clone();return It.add(t,{description:e}),t},meta(...e){if(e.length===0)return It.get(this);let t=this.clone();return It.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return C.hide(this,"~standard",{...Ca(this),jsonSchema:{input:$n(this,"input"),output:$n(this,"output")}})},set"~standard"(e){C.own(this,"~standard",e)},parse:function e(t,r){return Am(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Im(this,t,r,{callee:e})},safeParse(e,t){return Cm(this,e,t)},async safeParseAsync(e,t){return Nm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){C.own(this,"spa",e)},validate(e,t){return es(this,e,t)},validateAsync(e,t){return ts(this,e,t)},encode:function e(t,r){return jm(this,t,r,{callee:e})},decode:function e(t,r){return Zm(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Mm(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Dm(this,t,r,{callee:e})},safeEncode(e,t){return Lm(this,e,t)},safeDecode(e,t){return Um(this,e,t)},async safeEncodeAsync(e,t){return qm(this,e,t)},async safeDecodeAsync(e,t){return Fm(this,e,t)},toJSONSchema(e){return Wh(this,{})(e)},get description(){return It.get(this)?.description},get _def(){return this._zod.def}}),Jm=_("_ZodString",(e,t)=>{as.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sm(e,r,n,o)},C.derived({format:e=>ge(e).format??null,minLength:e=>ge(e).minimum??null,maxLength:e=>ge(e).maximum??null},{regex(...e){return this.check(Ha(...e))},includes(...e){return this.check(Wa(...e))},startsWith(...e){return this.check(Ga(...e))},endsWith(...e){return this.check(Xa(...e))},min(...e){return this.check(Ar(...e))},max(...e){return this.check(_s(...e))},length(...e){return this.check(bs(...e))},nonempty(...e){return this.check(Ar(1,...e))},lowercase(e){return this.check(Ka(e))},uppercase(e){return this.check(Ja(e))},trim(){return this.check(Qa())},normalize(...e){return this.check(Ya(...e))},toLowerCase(){return this.check(ec())},toUpperCase(){return this.check(tc())},slugify(){return this.check(rc())}})),fc=_("ZodString",(e,t)=>{as.init(e,t),Jm.init(e,t)},{email(e){return this.check(ch(ox,e))},url(e){return this.check(Ba(Wm,e))},jwt(e){return this.check(Eh(wx,e))},emoji(e){return this.check(hh(ix,e))},guid(e){return this.check(uh(sx,e))},uuid(e){return this.check(lh($s,e))},uuidv4(e){return this.check(dh($s,e))},uuidv6(e){return this.check(fh($s,e))},uuidv7(e){return this.check(ph($s,e))},nanoid(e){return this.check(mh(ax,e))},cuid(e){return this.check(gh(cx,e))},cuid2(e){return this.check(yh(ux,e))},ulid(e){return this.check(_h(lx,e))},base64(e){return this.check(zh(yx,e))},base64url(e){return this.check(kh(_x,e))},xid(e){return this.check(bh(dx,e))},ksuid(e){return this.check(wh(fx,e))},ipv4(e){return this.check(xh(px,e))},ipv6(e){return this.check(vh(hx,e))},cidrv4(e){return this.check($h(mx,e))},cidrv6(e){return this.check(Sh(gx,e))},e164(e){return this.check(Ph(bx,e))},datetime(e){return this.check(hs(Sn,e))},date(e){return this.check(ms(zn,e))},time(e){return this.check(gs(kn,e))},duration(e){return this.check(ys(Pn,e))}});function g(e){return ih(fc,e)}var ae=_("ZodStringFormat",(e,t)=>{ee.init(e,t),Jm.init(e,t)}),Sn=_("ZodISODateTime",(e,t)=>{pp.init(e,t),ae.init(e,t)}),zn=_("ZodISODate",(e,t)=>{hp.init(e,t),ae.init(e,t)}),kn=_("ZodISOTime",(e,t)=>{mp.init(e,t),ae.init(e,t)}),Pn=_("ZodISODuration",(e,t)=>{gp.init(e,t),ae.init(e,t)}),ox=_("ZodEmail",(e,t)=>{rp.init(e,t),ae.init(e,t)});var sx=_("ZodGUID",(e,t)=>{ep.init(e,t),ae.init(e,t)});var $s=_("ZodUUID",(e,t)=>{tp.init(e,t),ae.init(e,t)});var Wm=_("ZodURL",(e,t)=>{sp.init(e,t),ae.init(e,t)});function Gm(e){return Ba(Wm,e)}var ix=_("ZodEmoji",(e,t)=>{ip.init(e,t),ae.init(e,t)});var ax=_("ZodNanoID",(e,t)=>{ap.init(e,t),ae.init(e,t)});var cx=_("ZodCUID",(e,t)=>{cp.init(e,t),ae.init(e,t)});var ux=_("ZodCUID2",(e,t)=>{up.init(e,t),ae.init(e,t)});var lx=_("ZodULID",(e,t)=>{lp.init(e,t),ae.init(e,t)});var dx=_("ZodXID",(e,t)=>{dp.init(e,t),ae.init(e,t)});var fx=_("ZodKSUID",(e,t)=>{fp.init(e,t),ae.init(e,t)});var px=_("ZodIPv4",(e,t)=>{yp.init(e,t),ae.init(e,t)});var hx=_("ZodIPv6",(e,t)=>{bp.init(e,t),ae.init(e,t)});var mx=_("ZodCIDRv4",(e,t)=>{wp.init(e,t),ae.init(e,t)});var gx=_("ZodCIDRv6",(e,t)=>{xp.init(e,t),ae.init(e,t)});var yx=_("ZodBase64",(e,t)=>{$p.init(e,t),ae.init(e,t)});var _x=_("ZodBase64URL",(e,t)=>{Sp.init(e,t),ae.init(e,t)});var bx=_("ZodE164",(e,t)=>{zp.init(e,t),ae.init(e,t)});var wx=_("ZodJWT",(e,t)=>{kp.init(e,t),ae.init(e,t)});var zs=_("ZodNumber",(e,t)=>{ja.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>im(e,r,n,o),e.isFinite=!0},C.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ge(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ge(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=ge(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ge(e).format??null},{gt(e,t){return this.check(Rr(e,t))},gte(e,t){return this.check(_t(e,t))},min(e,t){return this.check(_t(e,t))},lt(e,t){return this.check(Or(e,t))},lte(e,t){return this.check(yt(e,t))},max(e,t){return this.check(yt(e,t))},int(e){return this.check(Vm(e))},safe(e){return this.check(Vm(e))},positive(e){return this.check(Rr(0,e))},nonnegative(e){return this.check(_t(0,e))},negative(e){return this.check(Or(0,e))},nonpositive(e){return this.check(yt(0,e))},multipleOf(e,t){return this.check(xn(e,t))},step(e,t){return this.check(xn(e,t))},finite(){return this}}));function B(e){return Th(zs,e)}var xx=_("ZodNumberFormat",(e,t)=>{Pp.init(e,t),zs.init(e,t)});function Vm(e){return Rh(xx,e)}var pc=_("ZodBoolean",(e,t)=>{Ep.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>am(e,r,n,o)});function X(e){return Ah(pc,e)}var Xm=_("ZodBigInt",(e,t)=>{Tp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cm(e,r,n,o)},C.derived({minValue:e=>ge(e).minimum??null,maxValue:e=>ge(e).maximum??null,format:e=>ge(e).format??null},{gte(e,t){return this.check(_t(e,t))},min(e,t){return this.check(_t(e,t))},gt(e,t){return this.check(Rr(e,t))},lt(e,t){return this.check(Or(e,t))},lte(e,t){return this.check(yt(e,t))},max(e,t){return this.check(yt(e,t))},positive(e){return this.check(Rr(BigInt(0),e))},negative(e){return this.check(Or(BigInt(0),e))},nonpositive(e){return this.check(yt(BigInt(0),e))},nonnegative(e){return this.check(_t(BigInt(0),e))},multipleOf(e,t){return this.check(xn(e,t))}}));var vx=_("ZodNull",(e,t)=>{Op.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>um(e,r,n,o)});function Ym(e){return Nh(vx,e)}var $x=_("ZodAny",(e,t)=>{Rp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dm(e,r,n,o)});function Qm(){return jh($x)}var Sx=_("ZodUnknown",(e,t)=>{Ap.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fm(e,r,n,o)});function se(){return Zh(Sx)}var zx=_("ZodNever",(e,t)=>{Ip.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lm(e,r,n,o)});function kx(e){return Mh(zx,e)}var eg=_("ZodDate",(e,t)=>{Cp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pm(e,r,n,o),e.min=(r,n)=>e.check(_t(r,n)),e.max=(r,n)=>e.check(yt(r,n))},C.derived({minDate:e=>{let{minimum:t}=ge(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=ge(e);return t?new Date(t):null}},{}));var Px=_("ZodArray",(e,t)=>{Ss(),Np.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_m(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Ar(e,t))},nonempty(e){return this.check(Ar(1,e))},max(e,t){return this.check(_s(e,t))},length(e,t){return this.check(bs(e,t))},unwrap(){return this.element}});function $(e,t){return Lh(Px,e,t)}var tg=_("ZodObject",(e,t)=>{Ss(),Mp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bm(e,r,n,o),C.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Ie(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(C.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(C.mergeDefs(this._zod.def,{catchall:se()}))},loose(){return this.clone(C.mergeDefs(this._zod.def,{catchall:se()}))},strict(){return this.clone(C.mergeDefs(this._zod.def,{catchall:kx()}))},strip(){return this.clone(C.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return C.extend(this,e)},safeExtend(e){return C.safeExtend(this,e)},merge(e){return C.merge(this,e)},pick(e){return C.pick(this,e)},omit(e){return C.omit(this,e)},partial(...e){return C.partial(og,this,e[0])},exactPartial(...e){return C.partial(sg,this,e[0],"exactPartial")},required(...e){return C.required(ig,this,e[0])}});function S(e,t){let r={type:"object",shape:e??{},...C.normalizeParams(t)};return new tg(r)}function fe(e,t){return new tg({type:"object",shape:e,catchall:se(),...C.normalizeParams(t)})}var rg=_("ZodUnion",(e,t)=>{Za.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wm(e,r,n,o),e.options=t.options});function te(e,t){return new rg({type:"union",options:e,...C.normalizeParams(t)})}var Ex=_("ZodDiscriminatedUnion",(e,t)=>{rg.init(e,t),Dp.init(e,t)});function hc(e,t,r){return new Ex({type:"union",options:t,discriminator:e,...C.normalizeParams(r)})}var Tx=_("ZodIntersection",(e,t)=>{Lp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xm(e,r,n,o)});function ks(e,t){return new Tx({type:"intersection",left:e,right:t})}var Bm=_("ZodRecord",(e,t)=>{Ss(),Up.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vm(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Q(e,t,r){return!t||!t._zod?new Bm({type:"record",keyType:g(),valueType:e,...C.normalizeParams(t)}):new Bm({type:"record",keyType:e,valueType:t,...C.normalizeParams(r)})}var dc=_("ZodEnum",(e,t)=>{qp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(n,o,s)=>hm(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new dc({...t,checks:[],...C.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new dc({...t,checks:[],...C.normalizeParams(o),entries:s})}});function Ie(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new dc({type:"enum",entries:r,...C.normalizeParams(t)})}var Ox=_("ZodLiteral",(e,t)=>{Fp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mm(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function P(e,t){return new Ox({type:"literal",values:Array.isArray(e)?e:[e],...C.normalizeParams(t)})}var Rx=_("ZodTransform",(e,t)=>{Ss(),Vp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ym(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Er(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(C.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(C.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function ng(e){return new Rx({type:"transform",transform:e})}var og=_("ZodOptional",(e,t)=>{Ma.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ie(e){return new og({type:"optional",innerType:e})}var sg=_("ZodExactOptional",(e,t)=>{Bp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ax(e){return new sg({type:"optional",innerType:e})}var Ix=_("ZodNullable",(e,t)=>{Hp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$m(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Hm(e){return new Ix({type:"nullable",innerType:e})}var Cx=_("ZodDefault",(e,t)=>{Kp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>km(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Nx(e,t){return new Cx({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():C.shallowClone(t)}})}var jx=_("ZodPrefault",(e,t)=>{Jp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Zx(e,t){return new jx({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():C.shallowClone(t)}})}var ig=_("ZodNonOptional",(e,t)=>{Wp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Mx(e,t){return new ig({type:"nonoptional",innerType:e,...C.normalizeParams(t)})}var Dx=_("ZodCatch",(e,t)=>{Gp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Em(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Lx(e,t){return new Dx({type:"catch",innerType:e,catchValue:typeof t=="function"?t:C.constantCatch(t)})}var ag=_("ZodPipe",(e,t)=>{Da.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tm(e,r,n,o),e.in=t.in,e.out=t.out});function Km(e,t){return new ag({type:"pipe",in:e,out:t})}var Ux=_("ZodPreprocess",(e,t)=>{ag.init(e,t),Xp.init(e,t)}),qx=_("ZodReadonly",(e,t)=>{Yp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Om(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Fx(e){return new qx({type:"readonly",innerType:e})}var cg=_("ZodCustom",(e,t)=>{Qp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gm(e,r,n,o)});function ug(e,t){return Uh(cg,e??(()=>!0),t)}function Vx(e,t={}){return qh(cg,e,t)}function Bx(e,t){return Fh(e,t)}function mc(e,t){return new Ux({type:"pipe",in:ng(e),out:t})}var dg={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var lg;lg||(lg={});var Ps={};sa(Ps,{ZodISODate:()=>zn,ZodISODateTime:()=>Sn,ZodISODuration:()=>Pn,ZodISOTime:()=>kn,date:()=>Jx,datetime:()=>Kx,duration:()=>Gx,time:()=>Wx});function Kx(e){return hs(Sn,e)}function Jx(e){return ms(zn,e)}function Wx(e){return gs(kn,e)}function Gx(e){return ys(Pn,e)}var Es={};sa(Es,{bigint:()=>ev,boolean:()=>Qx,date:()=>tv,number:()=>Yx,string:()=>Xx});function Xx(e){return ah(fc,e)}function Yx(e){return Oh(zs,e)}function Qx(e){return Ih(pc,e)}function ev(e){return Ch(Xm,e)}function tv(e){return Dh(eg,e)}var Nt="2025-11-25";var Os=[Nt,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],jt="io.modelcontextprotocol/related-task",Rs="2.0",pe=ug(e=>e!==null&&(typeof e=="object"||typeof e=="function")),fg=te([g(),B().int()]),pg=g(),HA=fe({ttl:B().optional(),pollInterval:B().optional()}),nv=S({ttl:B().optional()}),ov=S({taskId:g()}),yc=fe({progressToken:fg.optional(),[jt]:ov.optional()}),Ue=S({_meta:yc.optional()}),En=Ue.extend({task:nv.optional()}),hg=e=>En.safeParse(e).success,ye=S({method:g(),params:Ue.loose().optional()}),Fe=S({_meta:yc.optional()}),Ve=S({method:g(),params:Fe.loose().optional()}),_e=fe({_meta:yc.optional()}),As=te([g(),B().int()]),mg=S({jsonrpc:P(Rs),id:As,...ye.shape}).strict(),Tn=e=>mg.safeParse(e).success,gg=S({jsonrpc:P(Rs),...Ve.shape}).strict(),yg=e=>gg.safeParse(e).success,_c=S({jsonrpc:P(Rs),id:As,result:_e}).strict(),er=e=>_c.safeParse(e).success;var I;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(I||(I={}));var bc=S({jsonrpc:P(Rs),id:As.optional(),error:S({code:B().int(),message:g(),data:se().optional()})}).strict();var _g=e=>bc.safeParse(e).success;var Dr=te([mg,gg,_c,bc]),KA=te([_c,bc]),bt=_e.strict(),sv=Fe.extend({requestId:As.optional(),reason:g().optional()}),Is=Ve.extend({method:P("notifications/cancelled"),params:sv}),iv=S({src:g(),mimeType:g().optional(),sizes:$(g()).optional(),theme:Ie(["light","dark"]).optional()}),On=S({icons:$(iv).optional()}),Mr=S({name:g(),title:g().optional()}),bg=Mr.extend({...Mr.shape,...On.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),av=ks(S({applyDefaults:X().optional()}),Q(g(),se())),cv=mc(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ks(S({form:av.optional(),url:pe.optional()}),Q(g(),se()).optional())),uv=fe({list:pe.optional(),cancel:pe.optional(),requests:fe({sampling:fe({createMessage:pe.optional()}).optional(),elicitation:fe({create:pe.optional()}).optional()}).optional()}),lv=fe({list:pe.optional(),cancel:pe.optional(),requests:fe({tools:fe({call:pe.optional()}).optional()}).optional()}),dv=S({experimental:Q(g(),pe).optional(),sampling:S({context:pe.optional(),tools:pe.optional()}).optional(),elicitation:cv.optional(),roots:S({listChanged:X().optional()}).optional(),tasks:uv.optional(),extensions:Q(g(),pe).optional()}),fv=Ue.extend({protocolVersion:g(),capabilities:dv,clientInfo:bg}),wc=ye.extend({method:P("initialize"),params:fv});var pv=S({experimental:Q(g(),pe).optional(),logging:pe.optional(),completions:pe.optional(),prompts:S({listChanged:X().optional()}).optional(),resources:S({subscribe:X().optional(),listChanged:X().optional()}).optional(),tools:S({listChanged:X().optional()}).optional(),tasks:lv.optional(),extensions:Q(g(),pe).optional()}),xc=_e.extend({protocolVersion:g(),capabilities:pv,serverInfo:bg,instructions:g().optional()}),Cs=Ve.extend({method:P("notifications/initialized"),params:Fe.optional()}),wg=e=>Cs.safeParse(e).success,Ns=ye.extend({method:P("ping"),params:Ue.optional()}),hv=S({progress:B(),total:ie(B()),message:ie(g())}),mv=S({...Fe.shape,...hv.shape,progressToken:fg}),js=Ve.extend({method:P("notifications/progress"),params:mv}),gv=Ue.extend({cursor:pg.optional()}),Rn=ye.extend({params:gv.optional()}),An=_e.extend({nextCursor:pg.optional()}),yv=Ie(["working","input_required","completed","failed","cancelled"]),In=S({taskId:g(),status:yv,ttl:te([B(),Ym()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:ie(B()),statusMessage:ie(g())}),wt=_e.extend({task:In}),_v=Fe.merge(In),Cn=Ve.extend({method:P("notifications/tasks/status"),params:_v}),Zs=ye.extend({method:P("tasks/get"),params:Ue.extend({taskId:g()})}),Ms=_e.merge(In),Ds=ye.extend({method:P("tasks/result"),params:Ue.extend({taskId:g()})}),JA=_e.loose(),Ls=Rn.extend({method:P("tasks/list")}),Us=An.extend({tasks:$(In)}),qs=ye.extend({method:P("tasks/cancel"),params:Ue.extend({taskId:g()})}),xg=_e.merge(In),vg=S({uri:g(),mimeType:ie(g()),_meta:Q(g(),se()).optional()}),$g=vg.extend({text:g()}),vc=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Sg=vg.extend({blob:vc}),Nn=Ie(["user","assistant"]),Lr=S({audience:$(Nn).optional(),priority:B().min(0).max(1).optional(),lastModified:Ps.datetime({offset:!0}).optional()}),zg=S({...Mr.shape,...On.shape,uri:g(),description:ie(g()),mimeType:ie(g()),size:ie(B()),annotations:Lr.optional(),_meta:ie(fe({}))}),bv=S({...Mr.shape,...On.shape,uriTemplate:g(),description:ie(g()),mimeType:ie(g()),annotations:Lr.optional(),_meta:ie(fe({}))}),wv=Rn.extend({method:P("resources/list")}),$c=An.extend({resources:$(zg)}),xv=Rn.extend({method:P("resources/templates/list")}),Sc=An.extend({resourceTemplates:$(bv)}),zc=Ue.extend({uri:g()}),vv=zc,$v=ye.extend({method:P("resources/read"),params:vv}),kc=_e.extend({contents:$(te([$g,Sg]))}),Pc=Ve.extend({method:P("notifications/resources/list_changed"),params:Fe.optional()}),Sv=zc,zv=ye.extend({method:P("resources/subscribe"),params:Sv}),kv=zc,Pv=ye.extend({method:P("resources/unsubscribe"),params:kv}),Ev=Fe.extend({uri:g()}),Tv=Ve.extend({method:P("notifications/resources/updated"),params:Ev}),Ov=S({name:g(),description:ie(g()),required:ie(X())}),Rv=S({...Mr.shape,...On.shape,description:ie(g()),arguments:ie($(Ov)),_meta:ie(fe({}))}),Av=Rn.extend({method:P("prompts/list")}),Ec=An.extend({prompts:$(Rv)}),Iv=Ue.extend({name:g(),arguments:Q(g(),g()).optional()}),Cv=ye.extend({method:P("prompts/get"),params:Iv}),Tc=S({type:P("text"),text:g(),annotations:Lr.optional(),_meta:Q(g(),se()).optional()}),Oc=S({type:P("image"),data:vc,mimeType:g(),annotations:Lr.optional(),_meta:Q(g(),se()).optional()}),Rc=S({type:P("audio"),data:vc,mimeType:g(),annotations:Lr.optional(),_meta:Q(g(),se()).optional()}),Nv=S({type:P("tool_use"),name:g(),id:g(),input:Q(g(),se()),_meta:Q(g(),se()).optional()}),jv=S({type:P("resource"),resource:te([$g,Sg]),annotations:Lr.optional(),_meta:Q(g(),se()).optional()}),Zv=zg.extend({type:P("resource_link")}),Ac=te([Tc,Oc,Rc,Zv,jv]),Mv=S({role:Nn,content:Ac}),Ic=_e.extend({description:g().optional(),messages:$(Mv)}),Cc=Ve.extend({method:P("notifications/prompts/list_changed"),params:Fe.optional()}),Dv=S({title:g().optional(),readOnlyHint:X().optional(),destructiveHint:X().optional(),idempotentHint:X().optional(),openWorldHint:X().optional()}),Lv=S({taskSupport:Ie(["required","optional","forbidden"]).optional()}),kg=S({...Mr.shape,...On.shape,description:g().optional(),inputSchema:S({type:P("object"),properties:Q(g(),pe).optional(),required:$(g()).optional()}).catchall(se()),outputSchema:S({type:P("object"),properties:Q(g(),pe).optional(),required:$(g()).optional()}).catchall(se()).optional(),annotations:Dv.optional(),execution:Lv.optional(),_meta:Q(g(),se()).optional()}),Nc=Rn.extend({method:P("tools/list")}),jc=An.extend({tools:$(kg)}),Zt=_e.extend({content:$(Ac).default([]),structuredContent:Q(g(),se()).optional(),isError:X().optional()}),WA=Zt.or(_e.extend({toolResult:se()})),Uv=En.extend({name:g(),arguments:Q(g(),se()).optional()}),jn=ye.extend({method:P("tools/call"),params:Uv}),Zc=Ve.extend({method:P("notifications/tools/list_changed"),params:Fe.optional()}),Pg=S({autoRefresh:X().default(!0),debounceMs:B().int().nonnegative().default(300)}),Zn=Ie(["debug","info","notice","warning","error","critical","alert","emergency"]),qv=Ue.extend({level:Zn}),Mc=ye.extend({method:P("logging/setLevel"),params:qv}),Fv=Fe.extend({level:Zn,logger:g().optional(),data:se()}),Vv=Ve.extend({method:P("notifications/message"),params:Fv}),Bv=S({name:g().optional()}),Hv=S({hints:$(Bv).optional(),costPriority:B().min(0).max(1).optional(),speedPriority:B().min(0).max(1).optional(),intelligencePriority:B().min(0).max(1).optional()}),Kv=S({mode:Ie(["auto","required","none"]).optional()}),Jv=S({type:P("tool_result"),toolUseId:g().describe("The unique identifier for the corresponding tool call."),content:$(Ac).default([]),structuredContent:S({}).loose().optional(),isError:X().optional(),_meta:Q(g(),se()).optional()}),Wv=hc("type",[Tc,Oc,Rc]),Ts=hc("type",[Tc,Oc,Rc,Nv,Jv]),Gv=S({role:Nn,content:te([Ts,$(Ts)]),_meta:Q(g(),se()).optional()}),Xv=En.extend({messages:$(Gv),modelPreferences:Hv.optional(),systemPrompt:g().optional(),includeContext:Ie(["none","thisServer","allServers"]).optional(),temperature:B().optional(),maxTokens:B().int(),stopSequences:$(g()).optional(),metadata:pe.optional(),tools:$(kg).optional(),toolChoice:Kv.optional()}),Dc=ye.extend({method:P("sampling/createMessage"),params:Xv}),tr=_e.extend({model:g(),stopReason:ie(Ie(["endTurn","stopSequence","maxTokens"]).or(g())),role:Nn,content:Wv}),Mn=_e.extend({model:g(),stopReason:ie(Ie(["endTurn","stopSequence","maxTokens","toolUse"]).or(g())),role:Nn,content:te([Ts,$(Ts)])}),Yv=S({type:P("boolean"),title:g().optional(),description:g().optional(),default:X().optional()}),Qv=S({type:P("string"),title:g().optional(),description:g().optional(),minLength:B().optional(),maxLength:B().optional(),format:Ie(["email","uri","date","date-time"]).optional(),default:g().optional()}),e$=S({type:Ie(["number","integer"]),title:g().optional(),description:g().optional(),minimum:B().optional(),maximum:B().optional(),default:B().optional()}),t$=S({type:P("string"),title:g().optional(),description:g().optional(),enum:$(g()),default:g().optional()}),r$=S({type:P("string"),title:g().optional(),description:g().optional(),oneOf:$(S({const:g(),title:g()})),default:g().optional()}),n$=S({type:P("string"),title:g().optional(),description:g().optional(),enum:$(g()),enumNames:$(g()).optional(),default:g().optional()}),o$=te([t$,r$]),s$=S({type:P("array"),title:g().optional(),description:g().optional(),minItems:B().optional(),maxItems:B().optional(),items:S({type:P("string"),enum:$(g())}),default:$(g()).optional()}),i$=S({type:P("array"),title:g().optional(),description:g().optional(),minItems:B().optional(),maxItems:B().optional(),items:S({anyOf:$(S({const:g(),title:g()}))}),default:$(g()).optional()}),a$=te([s$,i$]),c$=te([n$,o$,a$]),u$=te([c$,Yv,Qv,e$]),l$=En.extend({mode:P("form").optional(),message:g(),requestedSchema:S({type:P("object"),properties:Q(g(),u$),required:$(g()).optional()})}),d$=En.extend({mode:P("url"),message:g(),elicitationId:g(),url:g().url()}),f$=te([l$,d$]),Lc=ye.extend({method:P("elicitation/create"),params:f$}),p$=Fe.extend({elicitationId:g()}),h$=Ve.extend({method:P("notifications/elicitation/complete"),params:p$}),Mt=_e.extend({action:Ie(["accept","decline","cancel"]),content:mc(e=>e===null?void 0:e,Q(g(),te([g(),B(),X(),$(g())])).optional())}),m$=S({type:P("ref/resource"),uri:g()});var g$=S({type:P("ref/prompt"),name:g()}),y$=Ue.extend({ref:te([g$,m$]),argument:S({name:g(),value:g()}),context:S({arguments:Q(g(),g()).optional()}).optional()}),_$=ye.extend({method:P("completion/complete"),params:y$});var Uc=_e.extend({completion:fe({values:$(g()).max(100),total:ie(B().int()),hasMore:ie(X())})}),b$=S({uri:g().startsWith("file://"),name:g().optional(),_meta:Q(g(),se()).optional()}),w$=ye.extend({method:P("roots/list"),params:Ue.optional()}),qc=_e.extend({roots:$(b$)}),x$=Ve.extend({method:P("notifications/roots/list_changed"),params:Fe.optional()}),GA=te([Ns,wc,_$,Mc,Cv,Av,wv,xv,$v,zv,Pv,jn,Nc,Zs,Ds,Ls,qs]),XA=te([Is,js,Cs,x$,Cn]),YA=te([bt,tr,Mn,Mt,qc,Ms,Us,wt]),QA=te([Ns,Dc,Lc,w$,Zs,Ds,Ls,qs]),eI=te([Is,js,Vv,Tv,Pc,Zc,Cc,Cn,h$]),tI=te([bt,xc,Uc,Ic,Ec,$c,Sc,kc,Zt,jc,Ms,Us,wt]),E=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===I.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new gc(o.elicitations,r)}return new e(t,r,n)}},gc=class extends E{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(I.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Dt(e){return e==="completed"||e==="failed"||e==="cancelled"}var CI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Fc(e){let r=jr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Zr(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Vc(e,t){let r=Ee(e,t);if(!r.success)throw r.error;return r.data}var P$=6e4,Ur=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Is,r=>{this._oncancel(r)}),this.setNotificationHandler(js,r=>{this._onprogress(r)}),this.setRequestHandler(Ns,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Zs,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new E(I.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Ds,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new E(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new E(I.InvalidParams,`Task not found: ${s}`);if(!Dt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Dt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[jt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Ls,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new E(I.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(qs,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new E(I.InvalidParams,`Task not found: ${r.params.taskId}`);if(Dt(o.status))throw new E(I.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new E(I.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof E?o:new E(I.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),E.fromError(I.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),er(s)||_g(s)?this._onresponse(s):Tn(s)?this._onrequest(s,i):yg(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=E.fromError(I.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[jt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:I.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);let a=hg(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new E(I.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:t.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let h=f.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:I.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),er(t))n(t);else{let i=new E(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(er(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),er(t))o(t);else{let i=E.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof E?i:new E(I.InternalError,String(i))}}return}let s;try{let i=await this.request(t,wt,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new E(I.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Dt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new E(I.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new E(I.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof E?i:new E(I.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[jt]:c}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(A=>this._onerror(new Error(`Failed to send cancellation: ${A}`)));let z=v instanceof E?v:new E(I.RequestTimeout,String(v));l(z)};this._responseHandlers.set(p,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let z=Ee(r,v.result);z.success?u(z.data):l(z.error)}catch(z){l(z)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let m=n?.timeout??P$,y=()=>h(E.fromError(I.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(p,m,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let v=z=>{let A=this._responseHandlers.get(p);A?A(z):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(w,{type:"request",message:f,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(p),l(z)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(p),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Ms,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Us,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},xg,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[jt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[jt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[jt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Fc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Vc(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=Fc(t);this._notificationHandlers.set(n,o=>{let s=Vc(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&Tn(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new E(I.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new E(I.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new E(I.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new E(I.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=Cn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Dt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new E(I.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Dt(a.status))throw new E(I.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=Cn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Dt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Eg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Fs(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];Eg(i)&&Eg(s)?r[o]={...i,...s}:r[o]=s}return r}var P0=ia(jl(),1),E0=ia(k0(),1);function ME(){let e=new P0.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,E0.default)(e),e}var sn=class{constructor(t){this._ajv=t??ME()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var ki=class{constructor(t){this._client=t}async*callToolStream(t,r=Zt,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(t.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:t},r,s),a=o.getToolOutputValidator(t.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new E(I.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new E(I.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof E){yield{type:"error",error:l};return}yield{type:"error",error:new E(I.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}};function Pi(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Ei(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function Ti(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,n=e.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&Ti(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&Ti(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&Ti(r,t)}}function DE(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}var Oi=class extends Ur{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new sn,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Zc,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Cc,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Pc,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new ki(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Fs(this._capabilities,t)}setRequestHandler(t,r){let o=jr(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Zr(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Ee(Lc,c);if(!l.success){let v=l.error instanceof Error?l.error.message:String(l.error);throw new E(I.InvalidParams,`Invalid elicitation request: ${v}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:p,supportsUrlMode:f}=DE(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new E(I.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!f)throw new E(I.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let v=Ee(wt,h);if(!v.success){let z=v.error instanceof Error?v.error.message:String(v.error);throw new E(I.InvalidParams,`Invalid task creation result: ${z}`)}return v.data}let m=Ee(Mt,h);if(!m.success){let v=m.error instanceof Error?m.error.message:String(m.error);throw new E(I.InvalidParams,`Invalid elicitation result: ${v}`)}let y=m.data,w=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&y.action==="accept"&&y.content&&w&&this._capabilities.elicitation?.form?.applyDefaults)try{Ti(w,y.content)}catch{}return y};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ee(Dc,c);if(!l.success){let y=l.error instanceof Error?l.error.message:String(l.error);throw new E(I.InvalidParams,`Invalid sampling request: ${y}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let y=Ee(wt,p);if(!y.success){let w=y.error instanceof Error?y.error.message:String(y.error);throw new E(I.InvalidParams,`Invalid task creation result: ${w}`)}return y.data}let h=d.tools||d.toolChoice?Mn:tr,m=Ee(h,p);if(!m.success){let y=m.error instanceof Error?m.error.message:String(m.error);throw new E(I.InvalidParams,`Invalid sampling result: ${y}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:Nt,capabilities:this._capabilities,clientInfo:this._clientInfo}},xc,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!Os.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${t})`);break;case"ping":break}}assertTaskCapability(t){Pi(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&Ei(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},bt,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},Uc,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},bt,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Ic,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Ec,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},$c,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Sc,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},kc,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},bt,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},bt,r)}async callTool(t,r=Zt,n){if(this.isToolTaskRequired(t.name))throw new E(I.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:t},r,n),s=this.getToolOutputValidator(t.name);if(s){if(!o.structuredContent&&!o.isError)throw new E(I.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new E(I.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof E?i:new E(I.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(t){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of t){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let n=await this.request({method:"tools/list",params:t},jc,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=Pg.safeParse(n);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(t,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var I0=ia(A0(),1);function C0(e){if(e)try{return I0.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Ri(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function N0(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...Ri(t.headers),...Ri(n.headers)}:t.headers};return e(r,o)}:e}var Bl;Bl=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function JE(e){return(await Bl).getRandomValues(new Uint8Array(e))}async function WE(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await JE(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function GE(e){return await WE(e)}async function XE(e){let t=await(await Bl).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Hl(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await GE(e),r=await XE(t);return{code_verifier:t,code_challenge:r}}var ve=Gm().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:dg.custom,message:"URL must be parseable",fatal:!0}),xa}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Z0=fe({resource:g().url(),authorization_servers:$(ve).optional(),jwks_uri:g().url().optional(),scopes_supported:$(g()).optional(),bearer_methods_supported:$(g()).optional(),resource_signing_alg_values_supported:$(g()).optional(),resource_name:g().optional(),resource_documentation:g().optional(),resource_policy_uri:g().url().optional(),resource_tos_uri:g().url().optional(),tls_client_certificate_bound_access_tokens:X().optional(),authorization_details_types_supported:$(g()).optional(),dpop_signing_alg_values_supported:$(g()).optional(),dpop_bound_access_tokens_required:X().optional()}),Kl=fe({issuer:g(),authorization_endpoint:ve,token_endpoint:ve,registration_endpoint:ve.optional(),scopes_supported:$(g()).optional(),response_types_supported:$(g()),response_modes_supported:$(g()).optional(),grant_types_supported:$(g()).optional(),token_endpoint_auth_methods_supported:$(g()).optional(),token_endpoint_auth_signing_alg_values_supported:$(g()).optional(),service_documentation:ve.optional(),revocation_endpoint:ve.optional(),revocation_endpoint_auth_methods_supported:$(g()).optional(),revocation_endpoint_auth_signing_alg_values_supported:$(g()).optional(),introspection_endpoint:g().optional(),introspection_endpoint_auth_methods_supported:$(g()).optional(),introspection_endpoint_auth_signing_alg_values_supported:$(g()).optional(),code_challenge_methods_supported:$(g()).optional(),client_id_metadata_document_supported:X().optional()}),YE=fe({issuer:g(),authorization_endpoint:ve,token_endpoint:ve,userinfo_endpoint:ve.optional(),jwks_uri:ve,registration_endpoint:ve.optional(),scopes_supported:$(g()).optional(),response_types_supported:$(g()),response_modes_supported:$(g()).optional(),grant_types_supported:$(g()).optional(),acr_values_supported:$(g()).optional(),subject_types_supported:$(g()),id_token_signing_alg_values_supported:$(g()),id_token_encryption_alg_values_supported:$(g()).optional(),id_token_encryption_enc_values_supported:$(g()).optional(),userinfo_signing_alg_values_supported:$(g()).optional(),userinfo_encryption_alg_values_supported:$(g()).optional(),userinfo_encryption_enc_values_supported:$(g()).optional(),request_object_signing_alg_values_supported:$(g()).optional(),request_object_encryption_alg_values_supported:$(g()).optional(),request_object_encryption_enc_values_supported:$(g()).optional(),token_endpoint_auth_methods_supported:$(g()).optional(),token_endpoint_auth_signing_alg_values_supported:$(g()).optional(),display_values_supported:$(g()).optional(),claim_types_supported:$(g()).optional(),claims_supported:$(g()).optional(),service_documentation:g().optional(),claims_locales_supported:$(g()).optional(),ui_locales_supported:$(g()).optional(),claims_parameter_supported:X().optional(),request_parameter_supported:X().optional(),request_uri_parameter_supported:X().optional(),require_request_uri_registration:X().optional(),op_policy_uri:ve.optional(),op_tos_uri:ve.optional(),client_id_metadata_document_supported:X().optional()}),M0=S({...YE.shape,...Kl.pick({code_challenge_methods_supported:!0}).shape}),D0=S({access_token:g(),id_token:g().optional(),token_type:g(),expires_in:Es.number().optional(),scope:g().optional(),refresh_token:g().optional(),issuer:g().optional().catch(void 0)}).strip(),L0=S({error:g(),error_description:g().optional(),error_uri:g().optional()}),j0=ve.optional().or(P("").transform(()=>{})),QE=S({redirect_uris:$(ve),token_endpoint_auth_method:g().optional(),grant_types:$(g()).optional(),response_types:$(g()).optional(),client_name:g().optional(),client_uri:ve.optional(),logo_uri:j0,scope:g().optional(),contacts:$(g()).optional(),tos_uri:j0,policy_uri:g().optional(),jwks_uri:ve.optional(),jwks:Qm().optional(),software_id:g().optional(),software_version:g().optional(),software_statement:g().optional()}).strip(),eT=S({client_id:g(),client_secret:g().optional(),client_id_issued_at:B().optional(),client_secret_expires_at:B().optional(),issuer:g().optional().catch(void 0)}).strip(),U0=QE.merge(eT),uj=S({error:g(),error_description:g().optional()}).strip(),lj=S({token:g(),token_type_hint:g().optional()}).strip();function q0(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function F0({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}var de=class extends Error{constructor(t,r){super(t),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let t={error:this.errorCode,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}get errorCode(){return this.constructor.errorCode}},yo=class extends de{};yo.errorCode="invalid_request";var hr=class extends de{};hr.errorCode="invalid_client";var mr=class extends de{};mr.errorCode="invalid_grant";var gr=class extends de{};gr.errorCode="unauthorized_client";var _o=class extends de{};_o.errorCode="unsupported_grant_type";var bo=class extends de{};bo.errorCode="invalid_scope";var wo=class extends de{};wo.errorCode="access_denied";var kt=class extends de{};kt.errorCode="server_error";var xo=class extends de{};xo.errorCode="temporarily_unavailable";var vo=class extends de{};vo.errorCode="unsupported_response_type";var $o=class extends de{};$o.errorCode="unsupported_token_type";var So=class extends de{};So.errorCode="invalid_token";var zo=class extends de{};zo.errorCode="method_not_allowed";var ko=class extends de{};ko.errorCode="too_many_requests";var yr=class extends de{};yr.errorCode="invalid_client_metadata";var Po=class extends de{};Po.errorCode="insufficient_scope";var Eo=class extends de{};Eo.errorCode="invalid_target";var V0={[yo.errorCode]:yo,[hr.errorCode]:hr,[mr.errorCode]:mr,[gr.errorCode]:gr,[_o.errorCode]:_o,[bo.errorCode]:bo,[wo.errorCode]:wo,[kt.errorCode]:kt,[xo.errorCode]:xo,[vo.errorCode]:vo,[$o.errorCode]:$o,[So.errorCode]:So,[zo.errorCode]:zo,[ko.errorCode]:ko,[yr.errorCode]:yr,[Po.errorCode]:Po,[Eo.errorCode]:Eo};var Pt=class extends Error{constructor(t){super(t??"Unauthorized")}};function tT(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var Jl="code",Wl="S256";function rT(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&tT(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function nT(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":oT(o,s,r);return;case"client_secret_post":sT(o,s,n);return;case"none":iT(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function oT(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}function sT(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function iT(e,t){t.set("client_id",e)}async function H0(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let n=L0.parse(JSON.parse(r)),{error:o,error_description:s,error_uri:i}=n,a=V0[o]||kt;return new a(s||"",i)}catch(n){let o=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new kt(o)}}function aT(e,t){let[r,n]=[e,t];try{[r,n]=[new URL(e).href,new URL(t).href]}catch{}return r===n||r.endsWith("/")&&r.slice(0,-1)===n||n.endsWith("/")&&n.slice(0,-1)===r}function Yl(e,t){if(e)return typeof e.issuer!="string"?e.issuer==null?e:{...e,issuer:void 0}:aT(e.issuer,t)?e:void 0}var cT=D0.omit({issuer:!0}),uT=U0.omit({issuer:!0});function K0(e,t){return new Error(`OAuth client information is bound to authorization server ${e.issuer} and is not presented to ${t}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}async function To(e,t){try{return await Gl(e,t)}catch(r){if(r instanceof hr||r instanceof gr)return await e.invalidateCredentials?.("all"),await Gl(e,t);if(r instanceof mr)return await e.invalidateCredentials?.("tokens"),await Gl(e,t);throw r}}async function Gl(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let i=await e.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await W0(c,{fetchFn:s}),!a)try{a=await J0(t,{resourceMetadataUrl:l},s)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let Z=await gT(t,{resourceMetadataUrl:l,fetchFn:s});c=Z.authorizationServerUrl,u=Z.authorizationServerMetadata,a=Z.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=String(c),p=await dT(t,e,a),f=p&&a&&!e.validateResourceURL?a.resource:p,h=n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,m=await Promise.resolve(e.clientInformation()),y=Yl(m,d),w=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(m&&!y&&!w)throw K0(m,d);let v=y?.issuer==null?y:void 0,z=async()=>{try{v&&await e.saveClientInformation?.({...v,issuer:d})}catch{}};if(!y){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let Z=u?.client_id_metadata_document_supported===!0,oe=e.clientMetadataUrl;if(oe&&!lT(oe))throw new yr(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${oe}`);if(Z&&oe)y={client_id:oe,issuer:d},await e.saveClientInformation?.(y);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");y={...await xT(c,{metadata:u,clientMetadata:e.clientMetadata,scope:h,fetchFn:s}),issuer:d},await e.saveClientInformation(y)}}let A=!e.redirectUrl;if(r!==void 0||A){let Z=await wT(e,c,{metadata:u,resource:f,authorizationCode:r,fetchFn:s});return await z(),await e.saveTokens({...Z,issuer:d}),"AUTHORIZED"}let b=Yl(await e.tokens(),d);if(b?.refresh_token&&b.issuer==null&&console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged."),b?.refresh_token)try{let Z=await bT(c,{metadata:u,clientInformation:y,refreshToken:b.refresh_token,resource:f,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await z(),await e.saveTokens({...Z,issuer:d}),"AUTHORIZED"}catch(Z){if(!(!(Z instanceof de)||Z instanceof kt))throw Z}let x=e.state?await e.state():void 0,{authorizationUrl:T,codeVerifier:K}=await yT(c,{metadata:u,clientInformation:y,state:x,redirectUrl:e.redirectUrl,scope:h,resource:f});return await e.saveCodeVerifier(K),await e.redirectToAuthorization(T),"REDIRECT"}function lT(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function dT(e,t,r){let n=q0(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!F0({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function Ql(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=Xl(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=Xl(e,"scope")||void 0,a=Xl(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function Xl(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function J0(e,t,r=fetch){let n=await hT(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||n.status===404)throw await n?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return Z0.parse(await n.json())}async function ed(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?ed(e,void 0,r):void 0;throw n}}function fT(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function B0(e,t,r=fetch){return await ed(e,{"MCP-Protocol-Version":t},r)}function pT(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function hT(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??Nt,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=fT(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await B0(i,s,r);if(!n?.metadataUrl&&pT(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await B0(c,s,r)}return a}function mT(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function W0(e,{fetchFn:t=fetch,protocolVersion:r=Nt}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=mT(e);for(let{url:s,type:i}of o){let a=await ed(s,n,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}return i==="oauth"?Kl.parse(await a.json()):M0.parse(await a.json())}}}async function gT(e,t){let r,n;try{r=await J0(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));let o=await W0(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}function G0(e){return typeof e=="string"?e:e.href}async function yT(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Jl))throw new Error(`Incompatible auth server: does not support response type ${Jl}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(Wl))throw new Error(`Incompatible auth server: does not support code challenge method ${Wl}`)}else a=new URL("/authorize",e);let c=await Hl(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",Jl),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",Wl),a.searchParams.set("redirect_uri",String(n)),s&&a.searchParams.set("state",s),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",G0(i)),{authorizationUrl:a,codeVerifier:u}}function _T(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function X0(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:i}){let a=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",G0(s)),o)await o(c,r,a,t);else if(n){let l=t?.token_endpoint_auth_methods_supported??[],d=rT(n,l);nT(d,n,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await H0(u);return cT.parse(await u.json())}async function bT(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await X0(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:i});return{refresh_token:n,...c}}async function wT(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){let i=async()=>{let l=await e.clientInformation(),d=Yl(l,String(t));if(l&&!d)throw K0(l,String(t));return d},a=await i(),c=e.clientMetadata.scope,u;if(e.prepareTokenRequest&&(u=await e.prepareTokenRequest(c)),!u){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let l=await e.codeVerifier();u=_T(o,l,e.redirectUrl)}return a??(a=await i()),X0(t,{metadata:r,tokenRequestParams:u,clientInformation:a,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}async function xT(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:o}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i=await(o??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!i.ok)throw await H0(i);return uT.parse(await i.json())}var Oo=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},Y0=10,vT=13,_r=32;function td(e){}function tb(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=td,onError:r=td,onRetry:n=td,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,u,l="",d=0,p,f=!1;function h(b){if(f)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,b.charCodeAt(0)===239&&b.charCodeAt(1)===187&&b.charCodeAt(2)===191&&(b=b.slice(3))),i.length===0){let K=y(b);K!==""&&(i.push(K),a=K.length),m();return}if(b.indexOf(`
|
|
67
|
+
`)===-1&&b.indexOf("\r")===-1){i.push(b),a+=b.length,m();return}i.push(b);let x=i.join("");i.length=0,a=0;let T=y(x);T!==""&&(i.push(T),a=T.length),m()}function m(){s!==void 0&&(a+l.length<=s||(f=!0,i.length=0,a=0,u=void 0,l="",d=0,p=void 0,r(new Oo(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function y(b){let x=0;if(b.indexOf("\r")===-1){let T=b.indexOf(`
|
|
68
|
+
`,x);for(;T!==-1;){if(x===T){d>0&&t({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0,x=T+1,T=b.indexOf(`
|
|
69
|
+
`,x);continue}let K=b.charCodeAt(x);if(Q0(b,x,K)){let Z=b.charCodeAt(x+5)===_r?x+6:x+5,oe=b.slice(Z,T);if(d===0&&b.charCodeAt(T+1)===Y0){t({id:u,event:p,data:oe}),u=void 0,l="",p=void 0,x=T+2,T=b.indexOf(`
|
|
70
|
+
`,x);continue}l=d===0?oe:`${l}
|
|
71
|
+
${oe}`,d++}else eb(b,x,K)?p=b.slice(b.charCodeAt(x+6)===_r?x+7:x+6,T)||void 0:w(b,x,T);x=T+1,T=b.indexOf(`
|
|
72
|
+
`,x)}return b.slice(x)}for(;x<b.length;){let T=b.indexOf("\r",x),K=b.indexOf(`
|
|
73
|
+
`,x),Z=-1;if(T!==-1&&K!==-1?Z=T<K?T:K:T!==-1?T===b.length-1?Z=-1:Z=T:K!==-1&&(Z=K),Z===-1)break;w(b,x,Z),x=Z+1,b.charCodeAt(x-1)===vT&&b.charCodeAt(x)===Y0&&x++}return b.slice(x)}function w(b,x,T){if(x===T){z();return}let K=b.charCodeAt(x);if(Q0(b,x,K)){let Tt=b.charCodeAt(x+5)===_r?x+6:x+5,Sd=b.slice(Tt,T);l=d===0?Sd:`${l}
|
|
74
|
+
${Sd}`,d++;return}if(eb(b,x,K)){p=b.slice(b.charCodeAt(x+6)===_r?x+7:x+6,T)||void 0;return}if(K===105&&b.charCodeAt(x+1)===100&&b.charCodeAt(x+2)===58){let Tt=b.slice(b.charCodeAt(x+3)===_r?x+4:x+3,T);Tt.includes("\0")||(u=Tt);return}if(K===58){if(o){let Tt=b.slice(x,T);o(Tt.slice(b.charCodeAt(x+1)===_r?2:1))}return}let Z=b.slice(x,T),oe=Z.indexOf(":");if(oe===-1){v(Z,"",Z);return}let ft=Z.slice(0,oe),Xt=Z.charCodeAt(oe+1)===_r?2:1,xr=Z.slice(oe+Xt);v(ft,xr,Z)}function v(b,x,T){switch(b){case"event":p=x||void 0;break;case"data":l=d===0?x:`${l}
|
|
75
|
+
${x}`,d++;break;case"id":x.includes("\0")||(u=x);break;case"retry":/^\d+$/.test(x)?n(parseInt(x,10)):r(new Oo(`Invalid \`retry\` value: "${x}"`,{type:"invalid-retry",value:x,line:T}));break;default:r(new Oo(`Unknown field "${b.length>20?`${b.slice(0,20)}\u2026`:b}"`,{type:"unknown-field",field:b,value:x,line:T}));break}}function z(){d>0&&t({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0}function A(b={}){if(b.consume&&i.length>0){let x=i.join("");w(x,0,x.length)}c=!0,u=void 0,l="",d=0,p=void 0,i.length=0,a=0,f=!1}return{feed:h,reset:A}}function Q0(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function eb(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Ai=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=tb({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:n,maxBufferSize:o})},transform(i){s.feed(i)}})}};var $T={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Jt=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Ii=class{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=N0(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??$T}async _authThenStart(){if(!this._authProvider)throw new Pt("No auth provider");let t;try{t=await To(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new Pt;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(t.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=Ri(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:n,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new Jt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,t,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),o)}_scheduleReconnection(t,r=0){let n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},o)}_handleSseStream(t,r,n){if(!t)return;let{onresumptiontoken:o,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let l=t.pipeThrough(new TextDecoderStream).pipeThrough(new Ai({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){let{value:f,done:h}=await l.read();if(h)break;if(f.id&&(i=f.id,a=!0,o?.(f.id)),!!f.data&&(!f.event||f.event==="message"))try{let m=Dr.parse(JSON.parse(f.data));er(m)&&(c=!0,s!==void 0&&(m.id=s)),this.onmessage?.(m)}catch(m){this.onerror?.(m)}}(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(f){this.onerror?.(new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new Pt("No auth provider");if(await To(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Pt("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,r){try{let{resumptionToken:n,onresumptiontoken:o}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:Tn(t)?t.id:void 0}).catch(f=>this.onerror?.(f));return}let s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let f=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Jt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:h,scope:m}=Ql(a);if(this._resourceMetadataUrl=h,this._scope=m,await To(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Pt;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:h,scope:m,error:y}=Ql(a);if(y==="insufficient_scope"){let w=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new Jt(403,"Server returned 403 after trying upscoping");if(m&&(this._scope=m),h&&(this._resourceMetadataUrl=h),this._lastUpscopingHeader=w??void 0,await To(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Pt;return this.send(t)}}throw new Jt(a.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),wg(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}let l=(Array.isArray(t)?t:[t]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,d=a.headers.get("content-type"),p=C0(d);if(l)if(p==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(p==="application/json"){let f=await a.json(),h=Array.isArray(f)?f.map(m=>Dr.parse(m)):[Dr.parse(f)];for(let m of h)this.onmessage?.(m)}else throw await a.body?.cancel(),new Jt(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Jt(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};var Ci=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},tr,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Mt,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};var Ni=class extends Ur{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Zn.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new sn,this.setRequestHandler(wc,n=>this._oninitialize(n)),this.setNotificationHandler(Cs,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Mc,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Zn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ci(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Fs(this._capabilities,t)}setRequestHandler(t,r){let o=jr(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Zr(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Ee(jn,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new E(I.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let h=Ee(wt,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new E(I.InvalidParams,`Invalid task creation result: ${m}`)}return h.data}let f=Ee(Zt,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new E(I.InvalidParams,`Invalid tools/call result: ${h}`)}return f.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Ei(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Pi(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:Os.includes(r)?r:Nt,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},bt)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},Mn,r):this.request({method:"sampling/createMessage",params:t},tr,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Mt,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Mt,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new E(I.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof E?i:new E(I.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},qc,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import nb from"node:process";var ST=10*1024*1024,ji=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??ST}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
76
|
+
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),zT(r)}clear(){this._buffer=void 0}};function zT(e){return Dr.parse(JSON.parse(e))}function rb(e){return JSON.stringify(e)+`
|
|
77
|
+
`}var Zi=class{constructor(t=nb.stdin,r=nb.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new ji({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=rb(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function rd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var Mi=e=>e?`"${e}" `:"";function kT(e,t=""){if(typeof e!="boolean")throw new TypeError(Mi(t)+"expected boolean, got type="+typeof e);return e}function Di(e,t=""){if(typeof e!="number")throw new TypeError(Mi(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(Mi(t)+"expected integer >= 0, got "+e);return e}function he(e,t,r=""){if(rd(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Di(t,"length");let n=rd(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=Mi(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Li(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function PT(e,t){he(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function nd(e,t){if(PT(e,t),!un(e))throw new Error("invalid output, must be aligned")}function ob(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Et(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function lt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function an(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var cn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function od(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}var ce=cn?e=>e:e=>od(e)>>>0;function ET(e){for(let t=0;t<e.length;t++)e[t]=od(e[t]);return e}var Ro=cn?e=>e:ET;function sb(e,t){if(e=he(e),t=he(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function sd(e,t,r){let n=t,o=r||(()=>[]),s=(a,c)=>n(c,...o(a)).update(a).digest(),i=n(new Uint8Array(e),...o(new Uint8Array(0)));return s.outputLen=i.outputLen,s.blockLen=i.blockLen,s.create=(a,...c)=>n(a,...c),s}var ib=(e,t)=>{function r(n,...o){if(he(n,void 0,"key"),e.nonceLength!==void 0){let d=o[0];he(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let s=e.tagLength,i=e.nonceLength!==void 0?1:0;if(!e.withAAD){for(let d=i;d<o.length;d++)if(rd(o[d]))throw new Error("AAD not supported")}e.withAAD&&o[i]!==void 0&&he(o[i],void 0,"AAD");let a=t(n,...o),c=(d,p)=>{if(p!==void 0){if(d!==2)throw new Error("cipher output not supported");he(p,void 0,"output")}},u=!1;return{encrypt(d,p){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,he(d,void 0,"data"),c(a.encrypt.length,p),a.encrypt(d,p)},decrypt(d,p){if(he(d,void 0,"data"),s&&d.length<s)throw new Error('"ciphertext" expected length >= tagLength='+s);return c(a.decrypt.length,p),a.decrypt(d,p)}}}return Object.assign(r,e),r};function ab(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(he(t,e,"output"),r&&!un(t))throw new Error("invalid output, must be aligned");return t}function cb(e,t,r){Di(e),Di(t),kT(r);let n=new Uint8Array(16),o=an(n);return o.setBigUint64(0,BigInt(t),r),o.setBigUint64(8,BigInt(e),r),n}function un(e){return e.byteOffset%4===0}function br(e){return Uint8Array.from(he(e))}var wr=16,ub=new Uint8Array(16),Ao=Et(ub),TT=225,OT=(e,t,r,n)=>{let o=n&1;return{s3:r<<31|n>>>1,s2:t<<31|r>>>1,s1:e<<31|t>>>1,s0:e>>>1^TT<<24&-(o&1)}},Ui=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;var RT=e=>e>64*1024?8:e>1024?4:2,id=class{blockLen=wr;outputLen=wr;s0=0;s1=0;s2=0;s3=0;finished=!1;destroyed=!1;t;W;windowSize;constructor(t,r){he(t,16,"key"),t=br(t);let n=an(t),o=n.getUint32(0,!1),s=n.getUint32(4,!1),i=n.getUint32(8,!1),a=n.getUint32(12,!1),c=[];for(let h=0;h<128;h++)c.push({s0:Ui(o),s1:Ui(s),s2:Ui(i),s3:Ui(a)}),{s0:o,s1:s,s2:i,s3:a}=OT(o,s,i,a);let u=RT(r||1024);if(![1,2,4,8].includes(u))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=u;let d=128/u,p=this.windowSize=2**u,f=[];for(let h=0;h<d;h++)for(let m=0;m<p;m++){let y=0,w=0,v=0,z=0;for(let A=0;A<u;A++){if(!(m>>>u-A-1&1))continue;let{s0:x,s1:T,s2:K,s3:Z}=c[u*h+A];y^=x,w^=T,v^=K,z^=Z}f.push({s0:y,s1:w,s2:v,s3:z})}this.t=f}_updateBlock(t,r,n,o){t^=this.s0,r^=this.s1,n^=this.s2,o^=this.s3;let{W:s,t:i,windowSize:a}=this,c=0,u=0,l=0,d=0,p=(1<<s)-1,f=0;for(let h of[t,r,n,o])for(let m=0;m<4;m++){let y=h>>>8*m&255;for(let w=8/s-1;w>=0;w--){let v=y>>>s*w&p,{s0:z,s1:A,s2:b,s3:x}=i[f*a+v];c^=z,u^=A,l^=b,d^=x,f+=1}}this.s0=c,this.s1=u,this.s2=l,this.s3=d}update(t){Li(this),he(t),t=br(t);let r=Et(t),n=Math.floor(t.length/wr),o=t.length%wr;for(let s=0;s<n;s++)this._updateBlock(ce(r[s*4+0]),ce(r[s*4+1]),ce(r[s*4+2]),ce(r[s*4+3]));return o&&(ub.set(t.subarray(n*wr)),this._updateBlock(ce(Ao[0]),ce(Ao[1]),ce(Ao[2]),ce(Ao[3])),lt(Ao)),this}destroy(){this.destroyed=!0;let{t}=this;for(let r of t)r.s0=0,r.s1=0,r.s2=0,r.s3=0}digestInto(t){Li(this),nd(t,this),this.finished=!0;let{s0:r,s1:n,s2:o,s3:s}=this,i=Et(t);i[0]=r,i[1]=n,i[2]=o,i[3]=s,cn||Ro(i.subarray(0,wr/4))}digest(){let t=new Uint8Array(wr);return this.digestInto(t),this.destroy(),t}};var ad=sd(16,(e,t)=>new id(e,t),e=>[e.length]);var ud=16,AT=4,qi=new Uint8Array(ud);var IT=283;function CT(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}function ld(e){return e<<1^IT&-(e>>7)}function lb(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(t&1),e=ld(e);return r}var NT=(()=>{let e=new Uint8Array(256);for(let r=0,n=1;r<256;r++,n^=ld(n))e[r]=n;let t=new Uint8Array(256);t[0]=99;for(let r=0;r<255;r++){let n=e[255-r];n|=n<<8,t[e[r]]=(n^n>>4^n>>5^n>>6^n>>7^99)&255}return lt(e),t})();var jT=e=>e<<24|e>>>8,cd=e=>e<<8|e>>>24;function ZT(e,t){if(e.length!==256)throw new Error("wrong sbox length");let r=new Uint32Array(256).map((u,l)=>t(e[l])),n=r.map(cd),o=n.map(cd),s=o.map(cd),i=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let u=0;u<256;u++)for(let l=0;l<256;l++){let d=u*256+l;i[d]=r[u]^n[l],a[d]=o[u]^s[l],c[d]=e[u]<<8|e[l]}return{sbox:e,sbox2:c,T0:r,T1:n,T2:o,T3:s,T01:i,T23:a}}var fb=ZT(NT,e=>lb(e,3)<<24|e<<16|e<<8|lb(e,2));var MT=(()=>{let e=new Uint8Array(16);for(let t=0,r=1;t<16;t++,r=ld(r))e[t]=r;return e})();function DT(e){he(e);let t=e.length;CT(e);let{sbox2:r}=fb,n=[];(!cn||!un(e))&&n.push(e=br(e));let o=Ro(Et(e)),s=o.length,i=c=>Io(r,c,c,c,c),a=new Uint32Array(t+28);a.set(o);for(let c=s;c<a.length;c++){let u=a[c-1];c%s===0?u=i(jT(u))^MT[c/s-1]:s>6&&c%s===4&&(u=i(u)),a[c]=a[c-s]^u}return lt(...n),a}function Fi(e,t,r,n,o,s){return e[r<<8&65280|n>>>8&255]^t[o>>>8&65280|s>>>24&255]}function Io(e,t,r,n,o){return e[t&255|r&65280]|e[n>>>16&255|o>>>16&65280]<<16}function db(e,t,r,n,o){let{sbox2:s,T01:i,T23:a}=fb,c=0;t^=e[c++],r^=e[c++],n^=e[c++],o^=e[c++];let u=e.length/4-2;for(let h=0;h<u;h++){let m=e[c++]^Fi(i,a,t,r,n,o),y=e[c++]^Fi(i,a,r,n,o,t),w=e[c++]^Fi(i,a,n,o,t,r),v=e[c++]^Fi(i,a,o,t,r,n);t=m,r=y,n=w,o=v}let l=e[c++]^Io(s,t,r,n,o),d=e[c++]^Io(s,r,n,o,t),p=e[c++]^Io(s,n,o,t,r),f=e[c++]^Io(s,o,t,r,n);return{s0:l,s1:d,s2:p,s3:f}}function Vi(e,t,r,n,o){he(r,ud,"nonce"),he(n),o=ab(n.length,o);let s=r,i=Et(s),a=an(s),c=Et(n),u=Et(o),l=t?0:12,d=n.length,p=a.getUint32(l,t);for(let h=0;h+4<=c.length;h+=4){let{s0:m,s1:y,s2:w,s3:v}=db(e,ce(i[0]),ce(i[1]),ce(i[2]),ce(i[3]));u[h+0]=c[h+0]^ce(m),u[h+1]=c[h+1]^ce(y),u[h+2]=c[h+2]^ce(w),u[h+3]=c[h+3]^ce(v),p=p+1>>>0,a.setUint32(l,p,t)}let f=ud*Math.floor(c.length/AT);if(f<d){let{s0:h,s1:m,s2:y,s3:w}=db(e,ce(i[0]),ce(i[1]),ce(i[2]),ce(i[3])),v=new Uint32Array([h,m,y,w]);Ro(v);let z=ob(v);for(let A=f,b=0;A<d;A++,b++)o[A]=n[A]^z[b];lt(v)}return o}function LT(e,t,r,n,o){let s=o?o.length:0,i=e.create(r,n.length+s);o&&i.update(o);let a=cb(8*n.length,8*s,t);i.update(n),i.update(a);let c=i.digest();return lt(a),c}var dd=ib({blockSize:16,nonceLength:12,tagLength:16,withAAD:!0,varSizeNonce:!0},function(t,r,n){if(r.length<8)throw new Error("aes/gcm: invalid nonce length");let o=16;function s(a,c,u){let l=LT(ad,!1,a,u,n);for(let d=0;d<c.length;d++)l[d]^=c[d];return l}function i(){let a=DT(t),c=qi.slice(),u=qi.slice();if(Vi(a,!1,u,u,c),r.length===12)u.set(r);else{let d=qi.slice();an(d).setBigUint64(8,BigInt(r.length*8),!1);let f=ad.create(c).update(r).update(d);f.digestInto(u),f.destroy()}let l=Vi(a,!1,u,qi);return{xk:a,authKey:c,counter:u,tagMask:l}}return{encrypt(a){let{xk:c,authKey:u,counter:l,tagMask:d}=i(),p=new Uint8Array(a.length+o),f=[c,u,l,d];un(a)||f.push(a=br(a)),Vi(c,!1,l,a,p.subarray(0,a.length));let h=s(u,d,p.subarray(0,p.length-o));return f.push(h),p.set(h,a.length),lt(...f),p},decrypt(a){let{xk:c,authKey:u,counter:l,tagMask:d}=i(),p=[c,u,d,l];un(a)||p.push(a=br(a));let f=a.subarray(0,-o),h=a.subarray(-o),m=s(u,d,f);if(p.push(m),!sb(m,h))throw lt(...p),new Error("aes-gcm: invalid tag");let y=Vi(c,!1,l,f);return lt(...p),y}}});function pb(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var fd=e=>e?`"${e}" `:"";function Co(e,t=""){if(typeof e!="number")throw new TypeError(fd(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(fd(t)+"expected integer >= 0, got "+e);return e}function Wt(e,t,r=""){if(pb(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Co(t,"length");let n=pb(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=fd(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function No(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Co(e.outputLen),Co(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var UT=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},hb=(e,t)=>{UT(e,t);let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function ln(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Bi(e,t){Wt(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function dt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Hi(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ot(e,t){return e<<32-t|e>>>t}function qT(e,t,r="opts"){return hb(e,"defaults"),t!==void 0&&hb(t,r),Object.assign(Object.create(null),e,t)}function mb(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=qT({},t,"info");let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}var gb=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var Ki=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(No(t),Wt(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),dt(o)}update(t){return ln(this),this.iHash.update(t),this}digestInto(t){ln(this),Bi(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a,canXOF:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.canXOF=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},jo=(()=>{let e=((t,r,n)=>new Ki(t,r).update(n).digest());return e.create=(t,r)=>new Ki(t,r),e})();var Zo=Uint8Array.of(0),FT=Uint8Array.of();function VT(e,t,r,n=32,o){No(e),Co(n,"length"),Wt(t,void 0,"prk");let s=e.outputLen;if(t.length<s)throw new Error('"prk" must be at least HashLen octets');if(n>255*s)throw new Error("Length must be <= 255*HashLen");let i=Math.ceil(n/s);if(r===void 0?r=FT:Wt(r,void 0,"info"),!i)return o&&dt(t),new Uint8Array;let a=o&&i===1?t:new Uint8Array(i*s),{iHash:c,oHash:u}=jo.create(e,t),l=o?t:new Uint8Array(s),d=i>1?o?.iHash||e.create():void 0;for(let f=0;f<i-1;f++){Zo[0]=f+1;let h=c._cloneInto(d);f&&h.update(l),h.update(r).update(Zo).digestInto(l),u._cloneInto(d).update(l).digestInto(l),a.set(l,s*f)}if(Zo[0]=i,i>1&&c.update(l),c.update(r).update(Zo).digestInto(l),u.update(l).digestInto(l),a.set(l,s*(i-1)),c.destroy(),u.destroy(),d?.destroy(),l!==a&&dt(l),dt(Zo),n===a.length)return a;let p=a.slice(0,n);return dt(a),p}var pd=(e,t,r,n,o)=>{No(e),r===void 0&&(r=new Uint8Array(e.outputLen));let s=jo.create(e,r).update(t);return VT(e,s.digest(),n,o,s)};var BT=e=>e/2**32|0,HT=e=>e>>>0;function yb(e,t,r,n){let o=BT(r),s=HT(r);e.setUint32(t,n?s:o,n),e.setUint32(t+4,n?o:s,n)}function _b(e,t,r){return e&t^~e&r}function bb(e,t,r){return e&t^e&r^t&r}var Ji=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Hi(this.buffer)}update(t){ln(this),Wt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let u=Hi(t);for(;o<=s-a;a+=o)this.process(u,a);i=!0;continue}n.set(a===0&&c===s?t:t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){ln(this),Bi(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),yb(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let a=t===r?n:Hi(t),c=this.outputLen,u=c/4,l=this.get();if(c%4||u>l.length)throw new Error("invalid outputLen");for(let d=0;d<u;d++)a.setUint32(4*d,l[d],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(r),t}clone(){return this._cloneInto()}},wb=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var KT=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gt=new Uint32Array(64),hd=class extends Ji{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,r){super(64,t,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let d=0;d<16;d++,r+=4)Gt[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){let p=Gt[d-15],f=Gt[d-2],h=ot(p,7)^ot(p,18)^p>>>3,m=ot(f,17)^ot(f,19)^f>>>10;Gt[d]=m+Gt[d-7]+h+Gt[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){let p=ot(a,6)^ot(a,11)^ot(a,25),f=l+p+_b(a,c,u)+KT[d]+Gt[d]|0,m=(ot(n,2)^ot(n,13)^ot(n,22))+bb(n,o,s)|0;l=u,u=c,c=a,a=i+f|0,i=s,s=o,o=n,n=f+m|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,a,c,u,l)}roundClean(){dt(Gt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),dt(this.buffer)}},md=class extends hd{constructor(){super(32,wb)}};var Wi=mb(()=>new md,gb(1));var Mo=new TextEncoder,JT=new TextDecoder,WT="ape1",xb=/^ape1\.([A-Za-z0-9_-]{16})\.([A-Za-z0-9_-]+)$/,GT=/^[A-Za-z0-9_-]{43}$/,XT=/^jb_live_[A-Za-z0-9]{40}$/;function gd(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function yd(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4)),r=new Uint8Array(new ArrayBuffer(t.length));for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}var _d=e=>GT.test(e),vb=e=>typeof e=="string"&&xb.test(e);function $b(e){let t=e.trim();if(_d(t))return{token:null,key:t};let[r,n,...o]=t.split(".");if(!XT.test(r)||o.length||n!==void 0&&!_d(n))throw new Error("Not a valid Jotbus token or connection string");return{token:r,key:n??null}}async function Sb(e){if(!_d(e))throw new Error("Invalid workspace key");let t=yd(e),r=new Uint8Array(32),n=pd(Wi,t,r,Mo.encode("agentpad/v1/enc"),32),o=pd(Wi,t,r,Mo.encode("agentpad/v1/check"),32),s=gd(jo(Wi,o,Mo.encode("agentpad/v1/key-check"))),i=a=>Mo.encode(`agentpad/v1/${a}`);return{check:s,async encrypt(a,c){let u=globalThis.crypto.getRandomValues(new Uint8Array(12)),l=dd(n,u,i(a)).encrypt(Mo.encode(JSON.stringify(c)));return`${WT}.${gd(u)}.${gd(l)}`},async decrypt(a,c){let u=xb.exec(c);if(!u)throw new Error("Not an encrypted message");let l=dd(n,yd(u[1]),i(a)).decrypt(yd(u[2])),d=JSON.parse(JT.decode(l));if(typeof d?.c!="string")throw new Error("Malformed message");return d}}}var Uo="0.1.0",eO=64*1024;globalThis.crypto||(globalThis.crypto=YT);var Xi=e=>process.stderr.write(`[jotbus] ${e}
|
|
78
|
+
`);function ta(e){Xi(e),process.exit(1)}var{values:wd}=QT({options:{url:{type:"string"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}},strict:!1});wd.version&&(process.stdout.write(`${Uo}
|
|
79
|
+
`),process.exit(0));wd.help&&(process.stdout.write(`jotbus ${Uo}: shared scratchpad for coding agents (local MCP client, stdio)
|
|
80
|
+
|
|
81
|
+
Usage: JOTBUS_TOKEN=<connection string> npx -y jotbus@latest --url <endpoint>
|
|
82
|
+
|
|
83
|
+
JOTBUS_TOKEN token or connection string (jb_live_<token>.<key>) from the Jotbus dashboard
|
|
84
|
+
--url MCP endpoint (or JOTBUS_URL)
|
|
85
|
+
-h, --help show this help
|
|
86
|
+
-v, --version print the version
|
|
87
|
+
|
|
88
|
+
Usually launched by your agent: claude mcp add --scope user jotbus -e JOTBUS_TOKEN=... -- npx -y jotbus@latest --url ...
|
|
89
|
+
`),process.exit(0));var xd=wd.url??process.env.JOTBUS_URL;xd||ta("Missing endpoint: pass --url <mcp url> or set JOTBUS_URL. The dashboard install command includes it.");var zb=process.env.JOTBUS_TOKEN;zb||ta("Missing JOTBUS_TOKEN. Copy the connection string from the dashboard when you mint a token.");var qo;try{qo=$b(zb)}catch{ta("JOTBUS_TOKEN is not a valid Jotbus token or connection string.")}qo.token||ta("JOTBUS_TOKEN contains only a key; use the full connection string from the dashboard.");var tO=qo.token,dn=qo.key?await Sb(qo.key):null,Yi=null;async function vd(){if(Yi)return Yi;let e=new Oi({name:"jotbus",version:Uo});return await e.connect(new Ii(new URL(xd),{requestInit:{headers:{Authorization:`Bearer ${tO}`,"x-jotbus-e2e":"1","User-Agent":`jotbus/${Uo}`}}})),Yi=e,e}async function Do(e,t){try{return await(await vd()).callTool({name:e,arguments:t})}catch(r){throw Yi=null,r}}var bd=e=>e.content?.[0]?.type==="text"?e.content[0].text:"",kb=e=>({content:[{type:"text",text:JSON.stringify(e,null,2)}]}),Lo=e=>({isError:!0,content:[{type:"text",text:e}]}),Gi=null;async function ra(e=!1){if(Gi&&!e)return Gi;let t=await Do("list_workspaces",{});if(t.isError)throw new Error(bd(t));return Gi=JSON.parse(bd(t)),Gi}async function rO(e){let t=await ra();if(e==null||e==="")return t.length===1?t[0]:void 0;let r=String(e).trim();return t.find(n=>n.id===r)??t.find(n=>n.name===r.toLowerCase())}function Qi(e){return e.encrypted?dn?dn.check!==e.key_check?`The encryption key in JOTBUS_TOKEN doesn't match workspace "${e.name}". Mint a new token from a browser where the workspace is unlocked.`:null:`Workspace "${e.name}" is end-to-end encrypted, but JOTBUS_TOKEN has no key. Use the full connection string (token.key) shown when the token was minted.`:null}async function nO(e){if(e.isError)return e;let t=JSON.parse(bd(e));if(!t.encrypted)return e;let r=(await ra()).find(o=>o.id===t.workspace_id),n=r?Qi(r):"Unknown workspace";return n?Lo(n):(t.messages=await Promise.all(t.messages.map(async o=>{if(!vb(o.content))return{...o,content:"[unreadable: not an encrypted message]"};try{let s=await dn.decrypt(t.workspace_id,o.content);return{...o,content:s.c,metadata:s.m??null}}catch{return{...o,content:"[unreadable: could not decrypt with this key]"}}})),delete t.workspace_id,kb(t))}async function oO(e,t){switch(e){case"list_workspaces":{let r=await ra(!0);return kb(r.map(({key_check:n,...o},s)=>({...o,...o.encrypted?{key_ok:!Qi(r[s])}:{}})))}case"write_workspace":{let r=await rO(t.workspace);if(!r?.encrypted)return Do(e,t);let n=Qi(r);if(n)return Lo(n);let o=String(t.content??"");if(!o.trim())return Lo("content must be a non-empty string");if(Buffer.byteLength(o)>eO)return Lo("Message is too large; the maximum is 64 KB of text.");let s=t.metadata,i=await dn.encrypt(r.id,s?{c:o,m:s}:{c:o}),{metadata:a,...c}=t;return Do(e,{...c,workspace:r.id,content:i})}case"read_workspace":case"listen_workspace":return nO(await Do(e,t));default:return Do(e,t)}}var ea="Shared scratchpad for coding agents (Jotbus).";try{ea=(await vd()).getInstructions()??ea;let t=await ra();for(let r of t){let n=Qi(r);n&&Xi(n)}Xi(`connected: ${t.length} workspace(s)${t.some(r=>r.encrypted)?", end-to-end encrypted":""}`)}catch(e){Xi(`could not reach ${xd} yet (${e.message}); will retry on first use`)}dn&&(ea+=`
|
|
90
|
+
|
|
91
|
+
Messages in encrypted workspaces are encrypted and decrypted on this machine; the server only stores ciphertext. Still never post secrets.`);var na=new Ni({name:"jotbus",version:Uo},{capabilities:{tools:{}},instructions:ea});na.setRequestHandler(Nc,async()=>{let{tools:e}=await(await vd()).listTools();return{tools:e.map(t=>t.name==="write_workspace"&&dn?{...t,description:`${t.description} In encrypted workspaces the text is encrypted on this machine before upload.`}:t)}});na.setRequestHandler(jn,async e=>{try{return await oO(e.params.name,e.params.arguments??{})}catch(t){return Lo(`Jotbus request failed: ${t.message}`)}});var $d=()=>process.exit(0);process.stdin.on("end",$d);process.stdin.on("close",$d);na.onclose=$d;await na.connect(new Zi);
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jotbus",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared scratchpad for coding agents. Local MCP client with end-to-end encryption for Claude Code, Codex, Cursor and any MCP client.",
|
|
5
|
+
"keywords": ["mcp", "model-context-protocol", "claude-code", "codex", "cursor", "ai-agents", "coding-agents", "e2e-encryption"],
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": { "jotbus": "dist/index.js" },
|
|
8
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
9
|
+
"engines": { "node": ">=20" },
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "node build.mjs",
|
|
13
|
+
"prepublishOnly": "node build.mjs"
|
|
14
|
+
}
|
|
15
|
+
}
|