@opentiny/next-sdk 0.4.0 → 0.4.1
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/agent/AgentModelProvider.ts +78 -81
- package/agent/type.ts +6 -9
- package/agent/utils/getAISDKTools.ts +0 -1
- package/agent/utils/getBuiltinMcpTools.ts +7 -7
- package/core.ts +0 -3
- package/dist/SimulatorMask-BHVXyogh-iNUb4dyF.js +361 -0
- package/dist/agent/type.d.ts +4 -12
- package/dist/agent/utils/getBuiltinMcpTools.d.ts +3 -3
- package/dist/core.d.ts +0 -1
- package/dist/core.js +16 -17
- package/dist/index-CXK8CcKq.js +6076 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +57 -4969
- package/dist/{initialize-builtin-WebMCP-HgObT902.js → initialize-builtin-WebMCP-rALfqS-o.js} +1166 -1056
- package/dist/page-tools/a11y/build.d.ts +11 -0
- package/dist/page-tools/a11y/constants.d.ts +9 -0
- package/dist/page-tools/a11y/search.d.ts +17 -0
- package/dist/page-tools/a11y/types.d.ts +104 -0
- package/dist/page-tools/a11y/utils.d.ts +34 -0
- package/dist/page-tools/a11y/vnode.d.ts +37 -0
- package/dist/page-tools/a11y-tree.d.ts +8 -99
- package/dist/page-tools/constants.d.ts +22 -0
- package/dist/page-tools/context.d.ts +28 -0
- package/dist/page-tools/handlers/browserState.d.ts +8 -0
- package/dist/page-tools/handlers/click.d.ts +8 -0
- package/dist/page-tools/handlers/executeJavascript.d.ts +8 -0
- package/dist/page-tools/handlers/fill.d.ts +8 -0
- package/dist/page-tools/handlers/scroll.d.ts +8 -0
- package/dist/page-tools/handlers/searchTree.d.ts +8 -0
- package/dist/page-tools/handlers/select.d.ts +8 -0
- package/dist/page-tools/page-agent-highlight/index.d.ts +9 -0
- package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +14 -0
- package/dist/page-tools/page-agent-mask/checkDarkMode.d.ts +5 -0
- package/dist/page-tools/page-agent-tool.d.ts +3 -8
- package/dist/page-tools/schema.d.ts +43 -0
- package/dist/page-tools/utils/dom.d.ts +6 -0
- package/dist/page-tools/utils/scroll.d.ts +15 -0
- package/dist/runtime.d.ts +4 -0
- package/dist/runtime.js +744 -0
- package/dist/utils/builtinProxy.d.ts +1 -1
- package/index.ts +0 -5
- package/package.json +6 -17
- package/page-tools/a11y/build.ts +70 -0
- package/page-tools/a11y/constants.ts +110 -0
- package/page-tools/a11y/search.ts +129 -0
- package/page-tools/a11y/types.ts +108 -0
- package/page-tools/a11y/utils.ts +266 -0
- package/page-tools/a11y/vnode.ts +229 -0
- package/page-tools/a11y-tree.ts +8 -527
- package/page-tools/bridge.ts +1 -1
- package/page-tools/constants.ts +72 -0
- package/page-tools/context.ts +13 -0
- package/page-tools/handlers/browserState.ts +12 -0
- package/page-tools/handlers/click.ts +26 -0
- package/page-tools/handlers/executeJavascript.ts +22 -0
- package/page-tools/handlers/fill.ts +60 -0
- package/page-tools/handlers/scroll.ts +66 -0
- package/page-tools/handlers/searchTree.ts +30 -0
- package/page-tools/handlers/select.ts +34 -0
- package/page-tools/page-agent-highlight/index.ts +198 -0
- package/page-tools/page-agent-mask/SimulatorMask.module.css +14 -0
- package/page-tools/page-agent-mask/SimulatorMask.ts +279 -0
- package/page-tools/page-agent-mask/checkDarkMode.ts +181 -0
- package/page-tools/page-agent-mask/cursor-border.svg +3 -0
- package/page-tools/page-agent-mask/cursor-fill.svg +5 -0
- package/page-tools/page-agent-mask/cursor.module.css +70 -0
- package/page-tools/page-agent-prompt.md +34 -18
- package/page-tools/page-agent-tool.ts +104 -152
- package/page-tools/schema.ts +51 -0
- package/page-tools/utils/dom.ts +155 -0
- package/page-tools/utils/scroll.ts +58 -0
- package/runtime.ts +13 -0
- package/utils/builtinProxy.ts +45 -13
- package/vite.config.runtime.ts +22 -0
- package/vite.config.ts +52 -8
- package/McpSdk.ts +0 -14
- package/WebAgent.ts +0 -5
- package/WebMcp.ts +0 -26
- package/Zod.ts +0 -1
- package/dist/McpSdk.d.ts +0 -14
- package/dist/SimulatorMask-BHVXyogh-BFEGpD5S.js +0 -1048
- package/dist/SimulatorMask-BHVXyogh-CCYbrb84.js +0 -801
- package/dist/WebAgent.d.ts +0 -5
- package/dist/WebMcp.d.ts +0 -23
- package/dist/Zod.d.ts +0 -1
- package/dist/index.es.dev.js +0 -59017
- package/dist/index.es.js +0 -46795
- package/dist/index.umd.dev.js +0 -60355
- package/dist/index.umd.js +0 -1248
- package/dist/mcpsdk@1.25.3.dev.js +0 -22780
- package/dist/mcpsdk@1.25.3.es.dev.js +0 -22778
- package/dist/mcpsdk@1.25.3.es.js +0 -16960
- package/dist/mcpsdk@1.25.3.js +0 -48
- package/dist/transport/ExtensionClientTransport.d.ts +0 -24
- package/dist/transport/ExtensionContentServerTransport.d.ts +0 -39
- package/dist/transport/ExtensionPageServerTransport.d.ts +0 -36
- package/dist/transport/messages.d.ts +0 -9
- package/dist/vite.config.mcpSdk.d.ts +0 -2
- package/dist/vite.config.webAgent.d.ts +0 -2
- package/dist/vite.config.webMcp.d.ts +0 -2
- package/dist/vite.config.webMcpFull.d.ts +0 -2
- package/dist/vite.config.zod.d.ts +0 -2
- package/dist/webagent.dev.js +0 -49360
- package/dist/webagent.es.dev.js +0 -49071
- package/dist/webagent.es.js +0 -39219
- package/dist/webagent.js +0 -642
- package/dist/webmcp-full.dev.js +0 -31336
- package/dist/webmcp-full.es.dev.js +0 -30283
- package/dist/webmcp-full.es.js +0 -22889
- package/dist/webmcp-full.js +0 -645
- package/dist/webmcp.dev.js +0 -9572
- package/dist/webmcp.es.dev.js +0 -8518
- package/dist/webmcp.es.js +0 -6727
- package/dist/webmcp.js +0 -602
- package/dist/zod@3.25.76.dev.js +0 -4037
- package/dist/zod@3.25.76.es.dev.js +0 -4033
- package/dist/zod@3.25.76.es.js +0 -2945
- package/dist/zod@3.25.76.js +0 -1
- package/transport/ExtensionClientTransport.ts +0 -100
- package/transport/ExtensionContentServerTransport.ts +0 -162
- package/transport/ExtensionPageServerTransport.ts +0 -149
- package/transport/messages.ts +0 -63
- package/vite-build-tsc.ts +0 -63
- package/vite-env.d.ts +0 -10
- package/vite.config.mcpSdk.ts +0 -28
- package/vite.config.webAgent.ts +0 -19
- package/vite.config.webMcp.ts +0 -40
- package/vite.config.webMcpFull.ts +0 -19
- package/vite.config.zod.ts +0 -23
- /package/dist/{vite-build-tsc.d.ts → vite.config.runtime.d.ts} +0 -0
package/dist/mcpsdk@1.25.3.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
(function($,Xt){typeof exports=="object"&&typeof module<"u"?Xt(exports):typeof define=="function"&&define.amd?define(["exports"],Xt):($=typeof globalThis<"u"?globalThis:$||self,Xt($.MCPSDK={}))})(this,(function($){"use strict";function Xt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rn={exports:{}},Hs={},yt={},Zt={},Ws={},Ks={},Js={},Bi;function nn(){return Bi||(Bi=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(p){if(super(),!t.IDENTIFIER.test(p))throw new Error("CodeGen: name must be a valid identifier");this.str=p}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(p){super(),this._items=typeof p=="string"?[p]:p}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const p=this._items[0];return p===""||p==='""'}get str(){var p;return(p=this._str)!==null&&p!==void 0?p:this._str=this._items.reduce((y,R)=>`${y}${R}`,"")}get names(){var p;return(p=this._names)!==null&&p!==void 0?p:this._names=this._items.reduce((y,R)=>(R instanceof r&&(y[R.str]=(y[R.str]||0)+1),y),{})}}t._Code=n,t.nil=new n("");function s(S,...p){const y=[S[0]];let R=0;for(;R<p.length;)o(y,p[R]),y.push(S[++R]);return new n(y)}t._=s;const a=new n("+");function i(S,...p){const y=[v(S[0])];let R=0;for(;R<p.length;)y.push(a),o(y,p[R]),y.push(a,v(S[++R]));return c(y),new n(y)}t.str=i;function o(S,p){p instanceof n?S.push(...p._items):p instanceof r?S.push(p):S.push(f(p))}t.addCodeArg=o;function c(S){let p=1;for(;p<S.length-1;){if(S[p]===a){const y=u(S[p-1],S[p+1]);if(y!==void 0){S.splice(p-1,3,y);continue}S[p++]="+"}p++}}function u(S,p){if(p==='""')return S;if(S==='""')return p;if(typeof S=="string")return p instanceof r||S[S.length-1]!=='"'?void 0:typeof p!="string"?`${S.slice(0,-1)}${p}"`:p[0]==='"'?S.slice(0,-1)+p.slice(1):void 0;if(typeof p=="string"&&p[0]==='"'&&!(S instanceof r))return`"${S}${p.slice(1)}`}function l(S,p){return p.emptyStr()?S:S.emptyStr()?p:i`${S}${p}`}t.strConcat=l;function f(S){return typeof S=="number"||typeof S=="boolean"||S===null?S:v(Array.isArray(S)?S.join(","):S)}function b(S){return new n(v(S))}t.stringify=b;function v(S){return JSON.stringify(S).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=v;function g(S){return typeof S=="string"&&t.IDENTIFIER.test(S)?new n(`.${S}`):s`[${S}]`}t.getProperty=g;function w(S){if(typeof S=="string"&&t.IDENTIFIER.test(S))return new n(`${S}`);throw new Error(`CodeGen: invalid export name: ${S}, use explicit $id name mapping`)}t.getEsmExportName=w;function m(S){return new n(S.toString())}t.regexpCode=m})(Js)),Js}var Bs={},Gi;function Yi(){return Gi||(Gi=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=nn();class r extends Error{constructor(u){super(`CodeGen: "code" for ${u} not defined`),this.value=u.value}}var n;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(n||(t.UsedValueState=n={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class s{constructor({prefixes:u,parent:l}={}){this._names={},this._prefixes=u,this._parent=l}toName(u){return u instanceof e.Name?u:this.name(u)}name(u){return new e.Name(this._newName(u))}_newName(u){const l=this._names[u]||this._nameGroup(u);return`${u}${l.index++}`}_nameGroup(u){var l,f;if(!((f=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||f===void 0)&&f.has(u)||this._prefixes&&!this._prefixes.has(u))throw new Error(`CodeGen: prefix "${u}" is not allowed in this scope`);return this._names[u]={prefix:u,index:0}}}t.Scope=s;class a extends e.Name{constructor(u,l){super(l),this.prefix=u}setValue(u,{property:l,itemIndex:f}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(l)}[${f}]`}}t.ValueScopeName=a;const i=(0,e._)`\n`;class o extends s{constructor(u){super(u),this._values={},this._scope=u.scope,this.opts={...u,_n:u.lines?i:e.nil}}get(){return this._scope}name(u){return new a(u,this._newName(u))}value(u,l){var f;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const b=this.toName(u),{prefix:v}=b,g=(f=l.key)!==null&&f!==void 0?f:l.ref;let w=this._values[v];if(w){const p=w.get(g);if(p)return p}else w=this._values[v]=new Map;w.set(g,b);const m=this._scope[v]||(this._scope[v]=[]),S=m.length;return m[S]=l.ref,b.setValue(l,{property:v,itemIndex:S}),b}getValue(u,l){const f=this._values[u];if(f)return f.get(l)}scopeRefs(u,l=this._values){return this._reduceValues(l,f=>{if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,e._)`${u}${f.scopePath}`})}scopeCode(u=this._values,l,f){return this._reduceValues(u,b=>{if(b.value===void 0)throw new Error(`CodeGen: name "${b}" has no value`);return b.value.code},l,f)}_reduceValues(u,l,f={},b){let v=e.nil;for(const g in u){const w=u[g];if(!w)continue;const m=f[g]=f[g]||new Map;w.forEach(S=>{if(m.has(S))return;m.set(S,n.Started);let p=l(S);if(p){const y=this.opts.es5?t.varKinds.var:t.varKinds.const;v=(0,e._)`${v}${y} ${S} = ${p};${this.opts._n}`}else if(p=b?.(S))v=(0,e._)`${v}${p}${this.opts._n}`;else throw new r(S);m.set(S,n.Completed)})}return v}}t.ValueScope=o})(Bs)),Bs}var Qi;function ie(){return Qi||(Qi=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=nn(),r=Yi();var n=nn();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}});var s=Yi();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class a{optimizeNodes(){return this}optimizeNames(k,P){return this}}class i extends a{constructor(k,P,Z){super(),this.varKind=k,this.name=P,this.rhs=Z}render({es5:k,_n:P}){const Z=k?r.varKinds.var:this.varKind,ee=this.rhs===void 0?"":` = ${this.rhs}`;return`${Z} ${this.name}${ee};`+P}optimizeNames(k,P){if(k[this.name.str])return this.rhs&&(this.rhs=D(this.rhs,k,P)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class o extends a{constructor(k,P,Z){super(),this.lhs=k,this.rhs=P,this.sideEffects=Z}render({_n:k}){return`${this.lhs} = ${this.rhs};`+k}optimizeNames(k,P){if(!(this.lhs instanceof e.Name&&!k[this.lhs.str]&&!this.sideEffects))return this.rhs=D(this.rhs,k,P),this}get names(){const k=this.lhs instanceof e.Name?{}:{...this.lhs.names};return F(k,this.rhs)}}class c extends o{constructor(k,P,Z,ee){super(k,Z,ee),this.op=P}render({_n:k}){return`${this.lhs} ${this.op}= ${this.rhs};`+k}}class u extends a{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`${this.label}:`+k}}class l extends a{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`break${this.label?` ${this.label}`:""};`+k}}class f extends a{constructor(k){super(),this.error=k}render({_n:k}){return`throw ${this.error};`+k}get names(){return this.error.names}}class b extends a{constructor(k){super(),this.code=k}render({_n:k}){return`${this.code};`+k}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(k,P){return this.code=D(this.code,k,P),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class v extends a{constructor(k=[]){super(),this.nodes=k}render(k){return this.nodes.reduce((P,Z)=>P+Z.render(k),"")}optimizeNodes(){const{nodes:k}=this;let P=k.length;for(;P--;){const Z=k[P].optimizeNodes();Array.isArray(Z)?k.splice(P,1,...Z):Z?k[P]=Z:k.splice(P,1)}return k.length>0?this:void 0}optimizeNames(k,P){const{nodes:Z}=this;let ee=Z.length;for(;ee--;){const ne=Z[ee];ne.optimizeNames(k,P)||(ae(k,ne.names),Z.splice(ee,1))}return Z.length>0?this:void 0}get names(){return this.nodes.reduce((k,P)=>M(k,P.names),{})}}class g extends v{render(k){return"{"+k._n+super.render(k)+"}"+k._n}}class w extends v{}class m extends g{}m.kind="else";class S extends g{constructor(k,P){super(P),this.condition=k}render(k){let P=`if(${this.condition})`+super.render(k);return this.else&&(P+="else "+this.else.render(k)),P}optimizeNodes(){super.optimizeNodes();const k=this.condition;if(k===!0)return this.nodes;let P=this.else;if(P){const Z=P.optimizeNodes();P=this.else=Array.isArray(Z)?new m(Z):Z}if(P)return k===!1?P instanceof S?P:P.nodes:this.nodes.length?this:new S($e(k),P instanceof S?[P]:P.nodes);if(!(k===!1||!this.nodes.length))return this}optimizeNames(k,P){var Z;if(this.else=(Z=this.else)===null||Z===void 0?void 0:Z.optimizeNames(k,P),!!(super.optimizeNames(k,P)||this.else))return this.condition=D(this.condition,k,P),this}get names(){const k=super.names;return F(k,this.condition),this.else&&M(k,this.else.names),k}}S.kind="if";class p extends g{}p.kind="for";class y extends p{constructor(k){super(),this.iteration=k}render(k){return`for(${this.iteration})`+super.render(k)}optimizeNames(k,P){if(super.optimizeNames(k,P))return this.iteration=D(this.iteration,k,P),this}get names(){return M(super.names,this.iteration.names)}}class R extends p{constructor(k,P,Z,ee){super(),this.varKind=k,this.name=P,this.from=Z,this.to=ee}render(k){const P=k.es5?r.varKinds.var:this.varKind,{name:Z,from:ee,to:ne}=this;return`for(${P} ${Z}=${ee}; ${Z}<${ne}; ${Z}++)`+super.render(k)}get names(){const k=F(super.names,this.from);return F(k,this.to)}}class d extends p{constructor(k,P,Z,ee){super(),this.loop=k,this.varKind=P,this.name=Z,this.iterable=ee}render(k){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(k)}optimizeNames(k,P){if(super.optimizeNames(k,P))return this.iterable=D(this.iterable,k,P),this}get names(){return M(super.names,this.iterable.names)}}class h extends g{constructor(k,P,Z){super(),this.name=k,this.args=P,this.async=Z}render(k){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(k)}}h.kind="func";class _ extends v{render(k){return"return "+super.render(k)}}_.kind="return";class E extends g{render(k){let P="try"+super.render(k);return this.catch&&(P+=this.catch.render(k)),this.finally&&(P+=this.finally.render(k)),P}optimizeNodes(){var k,P;return super.optimizeNodes(),(k=this.catch)===null||k===void 0||k.optimizeNodes(),(P=this.finally)===null||P===void 0||P.optimizeNodes(),this}optimizeNames(k,P){var Z,ee;return super.optimizeNames(k,P),(Z=this.catch)===null||Z===void 0||Z.optimizeNames(k,P),(ee=this.finally)===null||ee===void 0||ee.optimizeNames(k,P),this}get names(){const k=super.names;return this.catch&&M(k,this.catch.names),this.finally&&M(k,this.finally.names),k}}class I extends g{constructor(k){super(),this.error=k}render(k){return`catch(${this.error})`+super.render(k)}}I.kind="catch";class j extends g{render(k){return"finally"+super.render(k)}}j.kind="finally";class C{constructor(k,P={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...P,_n:P.lines?`
|
|
2
|
-
`:""},this._extScope=k,this._scope=new r.Scope({parent:k}),this._nodes=[new w]}toString(){return this._root.render(this.opts)}name(k){return this._scope.name(k)}scopeName(k){return this._extScope.name(k)}scopeValue(k,P){const Z=this._extScope.value(k,P);return(this._values[Z.prefix]||(this._values[Z.prefix]=new Set)).add(Z),Z}getScopeValue(k,P){return this._extScope.getValue(k,P)}scopeRefs(k){return this._extScope.scopeRefs(k,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(k,P,Z,ee){const ne=this._scope.toName(P);return Z!==void 0&&ee&&(this._constants[ne.str]=Z),this._leafNode(new i(k,ne,Z)),ne}const(k,P,Z){return this._def(r.varKinds.const,k,P,Z)}let(k,P,Z){return this._def(r.varKinds.let,k,P,Z)}var(k,P,Z){return this._def(r.varKinds.var,k,P,Z)}assign(k,P,Z){return this._leafNode(new o(k,P,Z))}add(k,P){return this._leafNode(new c(k,t.operators.ADD,P))}code(k){return typeof k=="function"?k():k!==e.nil&&this._leafNode(new b(k)),this}object(...k){const P=["{"];for(const[Z,ee]of k)P.length>1&&P.push(","),P.push(Z),(Z!==ee||this.opts.es5)&&(P.push(":"),(0,e.addCodeArg)(P,ee));return P.push("}"),new e._Code(P)}if(k,P,Z){if(this._blockNode(new S(k)),P&&Z)this.code(P).else().code(Z).endIf();else if(P)this.code(P).endIf();else if(Z)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(k){return this._elseNode(new S(k))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(S,m)}_for(k,P){return this._blockNode(k),P&&this.code(P).endFor(),this}for(k,P){return this._for(new y(k),P)}forRange(k,P,Z,ee,ne=this.opts.es5?r.varKinds.var:r.varKinds.let){const _e=this._scope.toName(k);return this._for(new R(ne,_e,P,Z),()=>ee(_e))}forOf(k,P,Z,ee=r.varKinds.const){const ne=this._scope.toName(k);if(this.opts.es5){const _e=P instanceof e.Name?P:this.var("_arr",P);return this.forRange("_i",0,(0,e._)`${_e}.length`,de=>{this.var(ne,(0,e._)`${_e}[${de}]`),Z(ne)})}return this._for(new d("of",ee,ne,P),()=>Z(ne))}forIn(k,P,Z,ee=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(k,(0,e._)`Object.keys(${P})`,Z);const ne=this._scope.toName(k);return this._for(new d("in",ee,ne,P),()=>Z(ne))}endFor(){return this._endBlockNode(p)}label(k){return this._leafNode(new u(k))}break(k){return this._leafNode(new l(k))}return(k){const P=new _;if(this._blockNode(P),this.code(k),P.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(_)}try(k,P,Z){if(!P&&!Z)throw new Error('CodeGen: "try" without "catch" and "finally"');const ee=new E;if(this._blockNode(ee),this.code(k),P){const ne=this.name("e");this._currNode=ee.catch=new I(ne),P(ne)}return Z&&(this._currNode=ee.finally=new j,this.code(Z)),this._endBlockNode(I,j)}throw(k){return this._leafNode(new f(k))}block(k,P){return this._blockStarts.push(this._nodes.length),k&&this.code(k).endBlock(P),this}endBlock(k){const P=this._blockStarts.pop();if(P===void 0)throw new Error("CodeGen: not in self-balancing block");const Z=this._nodes.length-P;if(Z<0||k!==void 0&&Z!==k)throw new Error(`CodeGen: wrong number of nodes: ${Z} vs ${k} expected`);return this._nodes.length=P,this}func(k,P=e.nil,Z,ee){return this._blockNode(new h(k,P,Z)),ee&&this.code(ee).endFunc(),this}endFunc(){return this._endBlockNode(h)}optimize(k=1){for(;k-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(k){return this._currNode.nodes.push(k),this}_blockNode(k){this._currNode.nodes.push(k),this._nodes.push(k)}_endBlockNode(k,P){const Z=this._currNode;if(Z instanceof k||P&&Z instanceof P)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${P?`${k.kind}/${P.kind}`:k.kind}"`)}_elseNode(k){const P=this._currNode;if(!(P instanceof S))throw new Error('CodeGen: "else" without "if"');return this._currNode=P.else=k,this}get _root(){return this._nodes[0]}get _currNode(){const k=this._nodes;return k[k.length-1]}set _currNode(k){const P=this._nodes;P[P.length-1]=k}}t.CodeGen=C;function M(z,k){for(const P in k)z[P]=(z[P]||0)+(k[P]||0);return z}function F(z,k){return k instanceof e._CodeOrName?M(z,k.names):z}function D(z,k,P){if(z instanceof e.Name)return Z(z);if(!ee(z))return z;return new e._Code(z._items.reduce((ne,_e)=>(_e instanceof e.Name&&(_e=Z(_e)),_e instanceof e._Code?ne.push(..._e._items):ne.push(_e),ne),[]));function Z(ne){const _e=P[ne.str];return _e===void 0||k[ne.str]!==1?ne:(delete k[ne.str],_e)}function ee(ne){return ne instanceof e._Code&&ne._items.some(_e=>_e instanceof e.Name&&k[_e.str]===1&&P[_e.str]!==void 0)}}function ae(z,k){for(const P in k)z[P]=(z[P]||0)-(k[P]||0)}function $e(z){return typeof z=="boolean"||typeof z=="number"||z===null?!z:(0,e._)`!${L(z)}`}t.not=$e;const xe=N(t.operators.AND);function ge(...z){return z.reduce(xe)}t.and=ge;const mt=N(t.operators.OR);function H(...z){return z.reduce(mt)}t.or=H;function N(z){return(k,P)=>k===e.nil?P:P===e.nil?k:(0,e._)`${L(k)} ${z} ${L(P)}`}function L(z){return z instanceof e.Name?z:(0,e._)`(${z})`}})(Ks)),Ks}var oe={},Xi;function fe(){if(Xi)return oe;Xi=1,Object.defineProperty(oe,"__esModule",{value:!0}),oe.checkStrictMode=oe.getErrorPath=oe.Type=oe.useFunc=oe.setEvaluated=oe.evaluatedPropsToName=oe.mergeEvaluated=oe.eachItem=oe.unescapeJsonPointer=oe.escapeJsonPointer=oe.escapeFragment=oe.unescapeFragment=oe.schemaRefOrVal=oe.schemaHasRulesButRef=oe.schemaHasRules=oe.checkUnknownRules=oe.alwaysValidSchema=oe.toHash=void 0;const t=ie(),e=nn();function r(d){const h={};for(const _ of d)h[_]=!0;return h}oe.toHash=r;function n(d,h){return typeof h=="boolean"?h:Object.keys(h).length===0?!0:(s(d,h),!a(h,d.self.RULES.all))}oe.alwaysValidSchema=n;function s(d,h=d.schema){const{opts:_,self:E}=d;if(!_.strictSchema||typeof h=="boolean")return;const I=E.RULES.keywords;for(const j in h)I[j]||R(d,`unknown keyword: "${j}"`)}oe.checkUnknownRules=s;function a(d,h){if(typeof d=="boolean")return!d;for(const _ in d)if(h[_])return!0;return!1}oe.schemaHasRules=a;function i(d,h){if(typeof d=="boolean")return!d;for(const _ in d)if(_!=="$ref"&&h.all[_])return!0;return!1}oe.schemaHasRulesButRef=i;function o({topSchemaRef:d,schemaPath:h},_,E,I){if(!I){if(typeof _=="number"||typeof _=="boolean")return _;if(typeof _=="string")return(0,t._)`${_}`}return(0,t._)`${d}${h}${(0,t.getProperty)(E)}`}oe.schemaRefOrVal=o;function c(d){return f(decodeURIComponent(d))}oe.unescapeFragment=c;function u(d){return encodeURIComponent(l(d))}oe.escapeFragment=u;function l(d){return typeof d=="number"?`${d}`:d.replace(/~/g,"~0").replace(/\//g,"~1")}oe.escapeJsonPointer=l;function f(d){return d.replace(/~1/g,"/").replace(/~0/g,"~")}oe.unescapeJsonPointer=f;function b(d,h){if(Array.isArray(d))for(const _ of d)h(_);else h(d)}oe.eachItem=b;function v({mergeNames:d,mergeToName:h,mergeValues:_,resultToName:E}){return(I,j,C,M)=>{const F=C===void 0?j:C instanceof t.Name?(j instanceof t.Name?d(I,j,C):h(I,j,C),C):j instanceof t.Name?(h(I,C,j),j):_(j,C);return M===t.Name&&!(F instanceof t.Name)?E(I,F):F}}oe.mergeEvaluated={props:v({mergeNames:(d,h,_)=>d.if((0,t._)`${_} !== true && ${h} !== undefined`,()=>{d.if((0,t._)`${h} === true`,()=>d.assign(_,!0),()=>d.assign(_,(0,t._)`${_} || {}`).code((0,t._)`Object.assign(${_}, ${h})`))}),mergeToName:(d,h,_)=>d.if((0,t._)`${_} !== true`,()=>{h===!0?d.assign(_,!0):(d.assign(_,(0,t._)`${_} || {}`),w(d,_,h))}),mergeValues:(d,h)=>d===!0?!0:{...d,...h},resultToName:g}),items:v({mergeNames:(d,h,_)=>d.if((0,t._)`${_} !== true && ${h} !== undefined`,()=>d.assign(_,(0,t._)`${h} === true ? true : ${_} > ${h} ? ${_} : ${h}`)),mergeToName:(d,h,_)=>d.if((0,t._)`${_} !== true`,()=>d.assign(_,h===!0?!0:(0,t._)`${_} > ${h} ? ${_} : ${h}`)),mergeValues:(d,h)=>d===!0?!0:Math.max(d,h),resultToName:(d,h)=>d.var("items",h)})};function g(d,h){if(h===!0)return d.var("props",!0);const _=d.var("props",(0,t._)`{}`);return h!==void 0&&w(d,_,h),_}oe.evaluatedPropsToName=g;function w(d,h,_){Object.keys(_).forEach(E=>d.assign((0,t._)`${h}${(0,t.getProperty)(E)}`,!0))}oe.setEvaluated=w;const m={};function S(d,h){return d.scopeValue("func",{ref:h,code:m[h.code]||(m[h.code]=new e._Code(h.code))})}oe.useFunc=S;var p;(function(d){d[d.Num=0]="Num",d[d.Str=1]="Str"})(p||(oe.Type=p={}));function y(d,h,_){if(d instanceof t.Name){const E=h===p.Num;return _?E?(0,t._)`"[" + ${d} + "]"`:(0,t._)`"['" + ${d} + "']"`:E?(0,t._)`"/" + ${d}`:(0,t._)`"/" + ${d}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return _?(0,t.getProperty)(d).toString():"/"+l(d)}oe.getErrorPath=y;function R(d,h,_=d.opts.strictSchema){if(_){if(h=`strict mode: ${h}`,_===!0)throw new Error(h);d.self.logger.warn(h)}}return oe.checkStrictMode=R,oe}var sn={},eo;function Et(){if(eo)return sn;eo=1,Object.defineProperty(sn,"__esModule",{value:!0});const t=ie(),e={data:new t.Name("data"),valCxt:new t.Name("valCxt"),instancePath:new t.Name("instancePath"),parentData:new t.Name("parentData"),parentDataProperty:new t.Name("parentDataProperty"),rootData:new t.Name("rootData"),dynamicAnchors:new t.Name("dynamicAnchors"),vErrors:new t.Name("vErrors"),errors:new t.Name("errors"),this:new t.Name("this"),self:new t.Name("self"),scope:new t.Name("scope"),json:new t.Name("json"),jsonPos:new t.Name("jsonPos"),jsonLen:new t.Name("jsonLen"),jsonPart:new t.Name("jsonPart")};return sn.default=e,sn}var to;function an(){return to||(to=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const e=ie(),r=fe(),n=Et();t.keywordError={message:({keyword:m})=>(0,e.str)`must pass "${m}" keyword validation`},t.keyword$DataError={message:({keyword:m,schemaType:S})=>S?(0,e.str)`"${m}" keyword must be ${S} ($data)`:(0,e.str)`"${m}" keyword is invalid ($data)`};function s(m,S=t.keywordError,p,y){const{it:R}=m,{gen:d,compositeRule:h,allErrors:_}=R,E=f(m,S,p);y??(h||_)?c(d,E):u(R,(0,e._)`[${E}]`)}t.reportError=s;function a(m,S=t.keywordError,p){const{it:y}=m,{gen:R,compositeRule:d,allErrors:h}=y,_=f(m,S,p);c(R,_),d||h||u(y,n.default.vErrors)}t.reportExtraError=a;function i(m,S){m.assign(n.default.errors,S),m.if((0,e._)`${n.default.vErrors} !== null`,()=>m.if(S,()=>m.assign((0,e._)`${n.default.vErrors}.length`,S),()=>m.assign(n.default.vErrors,null)))}t.resetErrorsCount=i;function o({gen:m,keyword:S,schemaValue:p,data:y,errsCount:R,it:d}){if(R===void 0)throw new Error("ajv implementation error");const h=m.name("err");m.forRange("i",R,n.default.errors,_=>{m.const(h,(0,e._)`${n.default.vErrors}[${_}]`),m.if((0,e._)`${h}.instancePath === undefined`,()=>m.assign((0,e._)`${h}.instancePath`,(0,e.strConcat)(n.default.instancePath,d.errorPath))),m.assign((0,e._)`${h}.schemaPath`,(0,e.str)`${d.errSchemaPath}/${S}`),d.opts.verbose&&(m.assign((0,e._)`${h}.schema`,p),m.assign((0,e._)`${h}.data`,y))})}t.extendErrors=o;function c(m,S){const p=m.const("err",S);m.if((0,e._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,e._)`[${p}]`),(0,e._)`${n.default.vErrors}.push(${p})`),m.code((0,e._)`${n.default.errors}++`)}function u(m,S){const{gen:p,validateName:y,schemaEnv:R}=m;R.$async?p.throw((0,e._)`new ${m.ValidationError}(${S})`):(p.assign((0,e._)`${y}.errors`,S),p.return(!1))}const l={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function f(m,S,p){const{createErrors:y}=m.it;return y===!1?(0,e._)`{}`:b(m,S,p)}function b(m,S,p={}){const{gen:y,it:R}=m,d=[v(R,p),g(m,p)];return w(m,S,d),y.object(...d)}function v({errorPath:m},{instancePath:S}){const p=S?(0,e.str)`${m}${(0,r.getErrorPath)(S,r.Type.Str)}`:m;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,p)]}function g({keyword:m,it:{errSchemaPath:S}},{schemaPath:p,parentSchema:y}){let R=y?S:(0,e.str)`${S}/${m}`;return p&&(R=(0,e.str)`${R}${(0,r.getErrorPath)(p,r.Type.Str)}`),[l.schemaPath,R]}function w(m,{params:S,message:p},y){const{keyword:R,data:d,schemaValue:h,it:_}=m,{opts:E,propertyName:I,topSchemaRef:j,schemaPath:C}=_;y.push([l.keyword,R],[l.params,typeof S=="function"?S(m):S||(0,e._)`{}`]),E.messages&&y.push([l.message,typeof p=="function"?p(m):p]),E.verbose&&y.push([l.schema,h],[l.parentSchema,(0,e._)`${j}${C}`],[n.default.data,d]),I&&y.push([l.propertyName,I])}})(Ws)),Ws}var ro;function ef(){if(ro)return Zt;ro=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.boolOrEmptySchema=Zt.topBoolOrEmptySchema=void 0;const t=an(),e=ie(),r=Et(),n={message:"boolean schema is false"};function s(o){const{gen:c,schema:u,validateName:l}=o;u===!1?i(o,!1):typeof u=="object"&&u.$async===!0?c.return(r.default.data):(c.assign((0,e._)`${l}.errors`,null),c.return(!0))}Zt.topBoolOrEmptySchema=s;function a(o,c){const{gen:u,schema:l}=o;l===!1?(u.var(c,!1),i(o)):u.var(c,!0)}Zt.boolOrEmptySchema=a;function i(o,c){const{gen:u,data:l}=o,f={gen:u,keyword:"false schema",data:l,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:o};(0,t.reportError)(f,n,void 0,c)}return Zt}var Le={},xt={},no;function so(){if(no)return xt;no=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.getRules=xt.isJSONType=void 0;const t=["string","number","integer","boolean","null","object","array"],e=new Set(t);function r(s){return typeof s=="string"&&e.has(s)}xt.isJSONType=r;function n(){const s={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...s,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},s.number,s.string,s.array,s.object],post:{rules:[]},all:{},keywords:{}}}return xt.getRules=n,xt}var vt={},ao;function io(){if(ao)return vt;ao=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.shouldUseRule=vt.shouldUseGroup=vt.schemaHasRulesForType=void 0;function t({schema:n,self:s},a){const i=s.RULES.types[a];return i&&i!==!0&&e(n,i)}vt.schemaHasRulesForType=t;function e(n,s){return s.rules.some(a=>r(n,a))}vt.shouldUseGroup=e;function r(n,s){var a;return n[s.keyword]!==void 0||((a=s.definition.implements)===null||a===void 0?void 0:a.some(i=>n[i]!==void 0))}return vt.shouldUseRule=r,vt}var oo;function on(){if(oo)return Le;oo=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.reportTypeError=Le.checkDataTypes=Le.checkDataType=Le.coerceAndCheckDataType=Le.getJSONTypes=Le.getSchemaTypes=Le.DataType=void 0;const t=so(),e=io(),r=an(),n=ie(),s=fe();var a;(function(p){p[p.Correct=0]="Correct",p[p.Wrong=1]="Wrong"})(a||(Le.DataType=a={}));function i(p){const y=o(p.type);if(y.includes("null")){if(p.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!y.length&&p.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');p.nullable===!0&&y.push("null")}return y}Le.getSchemaTypes=i;function o(p){const y=Array.isArray(p)?p:p?[p]:[];if(y.every(t.isJSONType))return y;throw new Error("type must be JSONType or JSONType[]: "+y.join(","))}Le.getJSONTypes=o;function c(p,y){const{gen:R,data:d,opts:h}=p,_=l(y,h.coerceTypes),E=y.length>0&&!(_.length===0&&y.length===1&&(0,e.schemaHasRulesForType)(p,y[0]));if(E){const I=g(y,d,h.strictNumbers,a.Wrong);R.if(I,()=>{_.length?f(p,y,_):m(p)})}return E}Le.coerceAndCheckDataType=c;const u=new Set(["string","number","integer","boolean","null"]);function l(p,y){return y?p.filter(R=>u.has(R)||y==="array"&&R==="array"):[]}function f(p,y,R){const{gen:d,data:h,opts:_}=p,E=d.let("dataType",(0,n._)`typeof ${h}`),I=d.let("coerced",(0,n._)`undefined`);_.coerceTypes==="array"&&d.if((0,n._)`${E} == 'object' && Array.isArray(${h}) && ${h}.length == 1`,()=>d.assign(h,(0,n._)`${h}[0]`).assign(E,(0,n._)`typeof ${h}`).if(g(y,h,_.strictNumbers),()=>d.assign(I,h))),d.if((0,n._)`${I} !== undefined`);for(const C of R)(u.has(C)||C==="array"&&_.coerceTypes==="array")&&j(C);d.else(),m(p),d.endIf(),d.if((0,n._)`${I} !== undefined`,()=>{d.assign(h,I),b(p,I)});function j(C){switch(C){case"string":d.elseIf((0,n._)`${E} == "number" || ${E} == "boolean"`).assign(I,(0,n._)`"" + ${h}`).elseIf((0,n._)`${h} === null`).assign(I,(0,n._)`""`);return;case"number":d.elseIf((0,n._)`${E} == "boolean" || ${h} === null
|
|
3
|
-
|| (${E} == "string" && ${h} && ${h} == +${h})`).assign(I,(0,n._)`+${h}`);return;case"integer":d.elseIf((0,n._)`${E} === "boolean" || ${h} === null
|
|
4
|
-
|| (${E} === "string" && ${h} && ${h} == +${h} && !(${h} % 1))`).assign(I,(0,n._)`+${h}`);return;case"boolean":d.elseIf((0,n._)`${h} === "false" || ${h} === 0 || ${h} === null`).assign(I,!1).elseIf((0,n._)`${h} === "true" || ${h} === 1`).assign(I,!0);return;case"null":d.elseIf((0,n._)`${h} === "" || ${h} === 0 || ${h} === false`),d.assign(I,null);return;case"array":d.elseIf((0,n._)`${E} === "string" || ${E} === "number"
|
|
5
|
-
|| ${E} === "boolean" || ${h} === null`).assign(I,(0,n._)`[${h}]`)}}}function b({gen:p,parentData:y,parentDataProperty:R},d){p.if((0,n._)`${y} !== undefined`,()=>p.assign((0,n._)`${y}[${R}]`,d))}function v(p,y,R,d=a.Correct){const h=d===a.Correct?n.operators.EQ:n.operators.NEQ;let _;switch(p){case"null":return(0,n._)`${y} ${h} null`;case"array":_=(0,n._)`Array.isArray(${y})`;break;case"object":_=(0,n._)`${y} && typeof ${y} == "object" && !Array.isArray(${y})`;break;case"integer":_=E((0,n._)`!(${y} % 1) && !isNaN(${y})`);break;case"number":_=E();break;default:return(0,n._)`typeof ${y} ${h} ${p}`}return d===a.Correct?_:(0,n.not)(_);function E(I=n.nil){return(0,n.and)((0,n._)`typeof ${y} == "number"`,I,R?(0,n._)`isFinite(${y})`:n.nil)}}Le.checkDataType=v;function g(p,y,R,d){if(p.length===1)return v(p[0],y,R,d);let h;const _=(0,s.toHash)(p);if(_.array&&_.object){const E=(0,n._)`typeof ${y} != "object"`;h=_.null?E:(0,n._)`!${y} || ${E}`,delete _.null,delete _.array,delete _.object}else h=n.nil;_.number&&delete _.integer;for(const E in _)h=(0,n.and)(h,v(E,y,R,d));return h}Le.checkDataTypes=g;const w={message:({schema:p})=>`must be ${p}`,params:({schema:p,schemaValue:y})=>typeof p=="string"?(0,n._)`{type: ${p}}`:(0,n._)`{type: ${y}}`};function m(p){const y=S(p);(0,r.reportError)(y,w)}Le.reportTypeError=m;function S(p){const{gen:y,data:R,schema:d}=p,h=(0,s.schemaRefOrVal)(p,d,"type");return{gen:y,keyword:"type",data:R,schema:d.type,schemaCode:h,schemaValue:h,parentSchema:d,params:{},it:p}}return Le}var $r={},co;function tf(){if(co)return $r;co=1,Object.defineProperty($r,"__esModule",{value:!0}),$r.assignDefaults=void 0;const t=ie(),e=fe();function r(s,a){const{properties:i,items:o}=s.schema;if(a==="object"&&i)for(const c in i)n(s,c,i[c].default);else a==="array"&&Array.isArray(o)&&o.forEach((c,u)=>n(s,u,c.default))}$r.assignDefaults=r;function n(s,a,i){const{gen:o,compositeRule:c,data:u,opts:l}=s;if(i===void 0)return;const f=(0,t._)`${u}${(0,t.getProperty)(a)}`;if(c){(0,e.checkStrictMode)(s,`default is ignored for: ${f}`);return}let b=(0,t._)`${f} === undefined`;l.useDefaults==="empty"&&(b=(0,t._)`${b} || ${f} === null || ${f} === ""`),o.if(b,(0,t._)`${f} = ${(0,t.stringify)(i)}`)}return $r}var ct={},ve={},uo;function ut(){if(uo)return ve;uo=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.validateUnion=ve.validateArray=ve.usePattern=ve.callValidateCode=ve.schemaProperties=ve.allSchemaProperties=ve.noPropertyInData=ve.propertyInData=ve.isOwnProperty=ve.hasPropFunc=ve.reportMissingProp=ve.checkMissingProp=ve.checkReportMissingProp=void 0;const t=ie(),e=fe(),r=Et(),n=fe();function s(p,y){const{gen:R,data:d,it:h}=p;R.if(l(R,d,y,h.opts.ownProperties),()=>{p.setParams({missingProperty:(0,t._)`${y}`},!0),p.error()})}ve.checkReportMissingProp=s;function a({gen:p,data:y,it:{opts:R}},d,h){return(0,t.or)(...d.map(_=>(0,t.and)(l(p,y,_,R.ownProperties),(0,t._)`${h} = ${_}`)))}ve.checkMissingProp=a;function i(p,y){p.setParams({missingProperty:y},!0),p.error()}ve.reportMissingProp=i;function o(p){return p.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}ve.hasPropFunc=o;function c(p,y,R){return(0,t._)`${o(p)}.call(${y}, ${R})`}ve.isOwnProperty=c;function u(p,y,R,d){const h=(0,t._)`${y}${(0,t.getProperty)(R)} !== undefined`;return d?(0,t._)`${h} && ${c(p,y,R)}`:h}ve.propertyInData=u;function l(p,y,R,d){const h=(0,t._)`${y}${(0,t.getProperty)(R)} === undefined`;return d?(0,t.or)(h,(0,t.not)(c(p,y,R))):h}ve.noPropertyInData=l;function f(p){return p?Object.keys(p).filter(y=>y!=="__proto__"):[]}ve.allSchemaProperties=f;function b(p,y){return f(y).filter(R=>!(0,e.alwaysValidSchema)(p,y[R]))}ve.schemaProperties=b;function v({schemaCode:p,data:y,it:{gen:R,topSchemaRef:d,schemaPath:h,errorPath:_},it:E},I,j,C){const M=C?(0,t._)`${p}, ${y}, ${d}${h}`:y,F=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,_)],[r.default.parentData,E.parentData],[r.default.parentDataProperty,E.parentDataProperty],[r.default.rootData,r.default.rootData]];E.opts.dynamicRef&&F.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const D=(0,t._)`${M}, ${R.object(...F)}`;return j!==t.nil?(0,t._)`${I}.call(${j}, ${D})`:(0,t._)`${I}(${D})`}ve.callValidateCode=v;const g=(0,t._)`new RegExp`;function w({gen:p,it:{opts:y}},R){const d=y.unicodeRegExp?"u":"",{regExp:h}=y.code,_=h(R,d);return p.scopeValue("pattern",{key:_.toString(),ref:_,code:(0,t._)`${h.code==="new RegExp"?g:(0,n.useFunc)(p,h)}(${R}, ${d})`})}ve.usePattern=w;function m(p){const{gen:y,data:R,keyword:d,it:h}=p,_=y.name("valid");if(h.allErrors){const I=y.let("valid",!0);return E(()=>y.assign(I,!1)),I}return y.var(_,!0),E(()=>y.break()),_;function E(I){const j=y.const("len",(0,t._)`${R}.length`);y.forRange("i",0,j,C=>{p.subschema({keyword:d,dataProp:C,dataPropType:e.Type.Num},_),y.if((0,t.not)(_),I)})}}ve.validateArray=m;function S(p){const{gen:y,schema:R,keyword:d,it:h}=p;if(!Array.isArray(R))throw new Error("ajv implementation error");if(R.some(j=>(0,e.alwaysValidSchema)(h,j))&&!h.opts.unevaluated)return;const E=y.let("valid",!1),I=y.name("_valid");y.block(()=>R.forEach((j,C)=>{const M=p.subschema({keyword:d,schemaProp:C,compositeRule:!0},I);y.assign(E,(0,t._)`${E} || ${I}`),p.mergeValidEvaluated(M,I)||y.if((0,t.not)(E))})),p.result(E,()=>p.reset(),()=>p.error(!0))}return ve.validateUnion=S,ve}var lo;function rf(){if(lo)return ct;lo=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.validateKeywordUsage=ct.validSchemaType=ct.funcKeywordCode=ct.macroKeywordCode=void 0;const t=ie(),e=Et(),r=ut(),n=an();function s(b,v){const{gen:g,keyword:w,schema:m,parentSchema:S,it:p}=b,y=v.macro.call(p.self,m,S,p),R=u(g,w,y);p.opts.validateSchema!==!1&&p.self.validateSchema(y,!0);const d=g.name("valid");b.subschema({schema:y,schemaPath:t.nil,errSchemaPath:`${p.errSchemaPath}/${w}`,topSchemaRef:R,compositeRule:!0},d),b.pass(d,()=>b.error(!0))}ct.macroKeywordCode=s;function a(b,v){var g;const{gen:w,keyword:m,schema:S,parentSchema:p,$data:y,it:R}=b;c(R,v);const d=!y&&v.compile?v.compile.call(R.self,S,p,R):v.validate,h=u(w,m,d),_=w.let("valid");b.block$data(_,E),b.ok((g=v.valid)!==null&&g!==void 0?g:_);function E(){if(v.errors===!1)C(),v.modifying&&i(b),M(()=>b.error());else{const F=v.async?I():j();v.modifying&&i(b),M(()=>o(b,F))}}function I(){const F=w.let("ruleErrs",null);return w.try(()=>C((0,t._)`await `),D=>w.assign(_,!1).if((0,t._)`${D} instanceof ${R.ValidationError}`,()=>w.assign(F,(0,t._)`${D}.errors`),()=>w.throw(D))),F}function j(){const F=(0,t._)`${h}.errors`;return w.assign(F,null),C(t.nil),F}function C(F=v.async?(0,t._)`await `:t.nil){const D=R.opts.passContext?e.default.this:e.default.self,ae=!("compile"in v&&!y||v.schema===!1);w.assign(_,(0,t._)`${F}${(0,r.callValidateCode)(b,h,D,ae)}`,v.modifying)}function M(F){var D;w.if((0,t.not)((D=v.valid)!==null&&D!==void 0?D:_),F)}}ct.funcKeywordCode=a;function i(b){const{gen:v,data:g,it:w}=b;v.if(w.parentData,()=>v.assign(g,(0,t._)`${w.parentData}[${w.parentDataProperty}]`))}function o(b,v){const{gen:g}=b;g.if((0,t._)`Array.isArray(${v})`,()=>{g.assign(e.default.vErrors,(0,t._)`${e.default.vErrors} === null ? ${v} : ${e.default.vErrors}.concat(${v})`).assign(e.default.errors,(0,t._)`${e.default.vErrors}.length`),(0,n.extendErrors)(b)},()=>b.error())}function c({schemaEnv:b},v){if(v.async&&!b.$async)throw new Error("async keyword in sync schema")}function u(b,v,g){if(g===void 0)throw new Error(`keyword "${v}" failed to compile`);return b.scopeValue("keyword",typeof g=="function"?{ref:g}:{ref:g,code:(0,t.stringify)(g)})}function l(b,v,g=!1){return!v.length||v.some(w=>w==="array"?Array.isArray(b):w==="object"?b&&typeof b=="object"&&!Array.isArray(b):typeof b==w||g&&typeof b>"u")}ct.validSchemaType=l;function f({schema:b,opts:v,self:g,errSchemaPath:w},m,S){if(Array.isArray(m.keyword)?!m.keyword.includes(S):m.keyword!==S)throw new Error("ajv implementation error");const p=m.dependencies;if(p?.some(y=>!Object.prototype.hasOwnProperty.call(b,y)))throw new Error(`parent schema must have dependencies of ${S}: ${p.join(",")}`);if(m.validateSchema&&!m.validateSchema(b[S])){const R=`keyword "${S}" value is invalid at path "${w}": `+g.errorsText(m.validateSchema.errors);if(v.validateSchema==="log")g.logger.error(R);else throw new Error(R)}}return ct.validateKeywordUsage=f,ct}var wt={},fo;function nf(){if(fo)return wt;fo=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.extendSubschemaMode=wt.extendSubschemaData=wt.getSubschema=void 0;const t=ie(),e=fe();function r(a,{keyword:i,schemaProp:o,schema:c,schemaPath:u,errSchemaPath:l,topSchemaRef:f}){if(i!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(i!==void 0){const b=a.schema[i];return o===void 0?{schema:b,schemaPath:(0,t._)`${a.schemaPath}${(0,t.getProperty)(i)}`,errSchemaPath:`${a.errSchemaPath}/${i}`}:{schema:b[o],schemaPath:(0,t._)`${a.schemaPath}${(0,t.getProperty)(i)}${(0,t.getProperty)(o)}`,errSchemaPath:`${a.errSchemaPath}/${i}/${(0,e.escapeFragment)(o)}`}}if(c!==void 0){if(u===void 0||l===void 0||f===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:u,topSchemaRef:f,errSchemaPath:l}}throw new Error('either "keyword" or "schema" must be passed')}wt.getSubschema=r;function n(a,i,{dataProp:o,dataPropType:c,data:u,dataTypes:l,propertyName:f}){if(u!==void 0&&o!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:b}=i;if(o!==void 0){const{errorPath:g,dataPathArr:w,opts:m}=i,S=b.let("data",(0,t._)`${i.data}${(0,t.getProperty)(o)}`,!0);v(S),a.errorPath=(0,t.str)`${g}${(0,e.getErrorPath)(o,c,m.jsPropertySyntax)}`,a.parentDataProperty=(0,t._)`${o}`,a.dataPathArr=[...w,a.parentDataProperty]}if(u!==void 0){const g=u instanceof t.Name?u:b.let("data",u,!0);v(g),f!==void 0&&(a.propertyName=f)}l&&(a.dataTypes=l);function v(g){a.data=g,a.dataLevel=i.dataLevel+1,a.dataTypes=[],i.definedProperties=new Set,a.parentData=i.data,a.dataNames=[...i.dataNames,g]}}wt.extendSubschemaData=n;function s(a,{jtdDiscriminator:i,jtdMetadata:o,compositeRule:c,createErrors:u,allErrors:l}){c!==void 0&&(a.compositeRule=c),u!==void 0&&(a.createErrors=u),l!==void 0&&(a.allErrors=l),a.jtdDiscriminator=i,a.jtdMetadata=o}return wt.extendSubschemaMode=s,wt}var We={},Gs,ho;function po(){return ho||(ho=1,Gs=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,a;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(a=Object.keys(e),n=a.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,a[s]))return!1;for(s=n;s--!==0;){var i=a[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}),Gs}var Ys={exports:{}},mo;function sf(){if(mo)return Ys.exports;mo=1;var t=Ys.exports=function(n,s,a){typeof s=="function"&&(a=s,s={}),a=s.cb||a;var i=typeof a=="function"?a:a.pre||function(){},o=a.post||function(){};e(s,i,o,n,"",n)};t.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},t.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},t.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},t.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 e(n,s,a,i,o,c,u,l,f,b){if(i&&typeof i=="object"&&!Array.isArray(i)){s(i,o,c,u,l,f,b);for(var v in i){var g=i[v];if(Array.isArray(g)){if(v in t.arrayKeywords)for(var w=0;w<g.length;w++)e(n,s,a,g[w],o+"/"+v+"/"+w,c,o,v,i,w)}else if(v in t.propsKeywords){if(g&&typeof g=="object")for(var m in g)e(n,s,a,g[m],o+"/"+v+"/"+r(m),c,o,v,i,m)}else(v in t.keywords||n.allKeys&&!(v in t.skipKeywords))&&e(n,s,a,g,o+"/"+v,c,o,v,i)}a(i,o,c,u,l,f,b)}}function r(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}return Ys.exports}var go;function cn(){if(go)return We;go=1,Object.defineProperty(We,"__esModule",{value:!0}),We.getSchemaRefs=We.resolveUrl=We.normalizeId=We._getFullPath=We.getFullPath=We.inlineRef=void 0;const t=fe(),e=po(),r=sf(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function s(w,m=!0){return typeof w=="boolean"?!0:m===!0?!i(w):m?o(w)<=m:!1}We.inlineRef=s;const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function i(w){for(const m in w){if(a.has(m))return!0;const S=w[m];if(Array.isArray(S)&&S.some(i)||typeof S=="object"&&i(S))return!0}return!1}function o(w){let m=0;for(const S in w){if(S==="$ref")return 1/0;if(m++,!n.has(S)&&(typeof w[S]=="object"&&(0,t.eachItem)(w[S],p=>m+=o(p)),m===1/0))return 1/0}return m}function c(w,m="",S){S!==!1&&(m=f(m));const p=w.parse(m);return u(w,p)}We.getFullPath=c;function u(w,m){return w.serialize(m).split("#")[0]+"#"}We._getFullPath=u;const l=/#\/?$/;function f(w){return w?w.replace(l,""):""}We.normalizeId=f;function b(w,m,S){return S=f(S),w.resolve(m,S)}We.resolveUrl=b;const v=/^[a-z_][-a-z0-9._]*$/i;function g(w,m){if(typeof w=="boolean")return{};const{schemaId:S,uriResolver:p}=this.opts,y=f(w[S]||m),R={"":y},d=c(p,y,!1),h={},_=new Set;return r(w,{allKeys:!0},(j,C,M,F)=>{if(F===void 0)return;const D=d+C;let ae=R[F];typeof j[S]=="string"&&(ae=$e.call(this,j[S])),xe.call(this,j.$anchor),xe.call(this,j.$dynamicAnchor),R[C]=ae;function $e(ge){const mt=this.opts.uriResolver.resolve;if(ge=f(ae?mt(ae,ge):ge),_.has(ge))throw I(ge);_.add(ge);let H=this.refs[ge];return typeof H=="string"&&(H=this.refs[H]),typeof H=="object"?E(j,H.schema,ge):ge!==f(D)&&(ge[0]==="#"?(E(j,h[ge],ge),h[ge]=j):this.refs[ge]=D),ge}function xe(ge){if(typeof ge=="string"){if(!v.test(ge))throw new Error(`invalid anchor "${ge}"`);$e.call(this,`#${ge}`)}}}),h;function E(j,C,M){if(C!==void 0&&!e(j,C))throw I(M)}function I(j){return new Error(`reference "${j}" resolves to more than one schema`)}}return We.getSchemaRefs=g,We}var _o;function un(){if(_o)return yt;_o=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.getData=yt.KeywordCxt=yt.validateFunctionCode=void 0;const t=ef(),e=on(),r=io(),n=on(),s=tf(),a=rf(),i=nf(),o=ie(),c=Et(),u=cn(),l=fe(),f=an();function b(O){if(d(O)&&(_(O),R(O))){m(O);return}v(O,()=>(0,t.topBoolOrEmptySchema)(O))}yt.validateFunctionCode=b;function v({gen:O,validateName:A,schema:x,schemaEnv:W,opts:re},ue){re.code.es5?O.func(A,(0,o._)`${c.default.data}, ${c.default.valCxt}`,W.$async,()=>{O.code((0,o._)`"use strict"; ${p(x,re)}`),w(O,re),O.code(ue)}):O.func(A,(0,o._)`${c.default.data}, ${g(re)}`,W.$async,()=>O.code(p(x,re)).code(ue))}function g(O){return(0,o._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${O.dynamicRef?(0,o._)`, ${c.default.dynamicAnchors}={}`:o.nil}}={}`}function w(O,A){O.if(c.default.valCxt,()=>{O.var(c.default.instancePath,(0,o._)`${c.default.valCxt}.${c.default.instancePath}`),O.var(c.default.parentData,(0,o._)`${c.default.valCxt}.${c.default.parentData}`),O.var(c.default.parentDataProperty,(0,o._)`${c.default.valCxt}.${c.default.parentDataProperty}`),O.var(c.default.rootData,(0,o._)`${c.default.valCxt}.${c.default.rootData}`),A.dynamicRef&&O.var(c.default.dynamicAnchors,(0,o._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{O.var(c.default.instancePath,(0,o._)`""`),O.var(c.default.parentData,(0,o._)`undefined`),O.var(c.default.parentDataProperty,(0,o._)`undefined`),O.var(c.default.rootData,c.default.data),A.dynamicRef&&O.var(c.default.dynamicAnchors,(0,o._)`{}`)})}function m(O){const{schema:A,opts:x,gen:W}=O;v(O,()=>{x.$comment&&A.$comment&&F(O),j(O),W.let(c.default.vErrors,null),W.let(c.default.errors,0),x.unevaluated&&S(O),E(O),D(O)})}function S(O){const{gen:A,validateName:x}=O;O.evaluated=A.const("evaluated",(0,o._)`${x}.evaluated`),A.if((0,o._)`${O.evaluated}.dynamicProps`,()=>A.assign((0,o._)`${O.evaluated}.props`,(0,o._)`undefined`)),A.if((0,o._)`${O.evaluated}.dynamicItems`,()=>A.assign((0,o._)`${O.evaluated}.items`,(0,o._)`undefined`))}function p(O,A){const x=typeof O=="object"&&O[A.schemaId];return x&&(A.code.source||A.code.process)?(0,o._)`/*# sourceURL=${x} */`:o.nil}function y(O,A){if(d(O)&&(_(O),R(O))){h(O,A);return}(0,t.boolOrEmptySchema)(O,A)}function R({schema:O,self:A}){if(typeof O=="boolean")return!O;for(const x in O)if(A.RULES.all[x])return!0;return!1}function d(O){return typeof O.schema!="boolean"}function h(O,A){const{schema:x,gen:W,opts:re}=O;re.$comment&&x.$comment&&F(O),C(O),M(O);const ue=W.const("_errs",c.default.errors);E(O,ue),W.var(A,(0,o._)`${ue} === ${c.default.errors}`)}function _(O){(0,l.checkUnknownRules)(O),I(O)}function E(O,A){if(O.opts.jtd)return $e(O,[],!1,A);const x=(0,e.getSchemaTypes)(O.schema),W=(0,e.coerceAndCheckDataType)(O,x);$e(O,x,!W,A)}function I(O){const{schema:A,errSchemaPath:x,opts:W,self:re}=O;A.$ref&&W.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(A,re.RULES)&&re.logger.warn(`$ref: keywords ignored in schema at path "${x}"`)}function j(O){const{schema:A,opts:x}=O;A.default!==void 0&&x.useDefaults&&x.strictSchema&&(0,l.checkStrictMode)(O,"default is ignored in the schema root")}function C(O){const A=O.schema[O.opts.schemaId];A&&(O.baseId=(0,u.resolveUrl)(O.opts.uriResolver,O.baseId,A))}function M(O){if(O.schema.$async&&!O.schemaEnv.$async)throw new Error("async schema in sync schema")}function F({gen:O,schemaEnv:A,schema:x,errSchemaPath:W,opts:re}){const ue=x.$comment;if(re.$comment===!0)O.code((0,o._)`${c.default.self}.logger.log(${ue})`);else if(typeof re.$comment=="function"){const Fe=(0,o.str)`${W}/$comment`,gt=O.scopeValue("root",{ref:A.root});O.code((0,o._)`${c.default.self}.opts.$comment(${ue}, ${Fe}, ${gt}.schema)`)}}function D(O){const{gen:A,schemaEnv:x,validateName:W,ValidationError:re,opts:ue}=O;x.$async?A.if((0,o._)`${c.default.errors} === 0`,()=>A.return(c.default.data),()=>A.throw((0,o._)`new ${re}(${c.default.vErrors})`)):(A.assign((0,o._)`${W}.errors`,c.default.vErrors),ue.unevaluated&&ae(O),A.return((0,o._)`${c.default.errors} === 0`))}function ae({gen:O,evaluated:A,props:x,items:W}){x instanceof o.Name&&O.assign((0,o._)`${A}.props`,x),W instanceof o.Name&&O.assign((0,o._)`${A}.items`,W)}function $e(O,A,x,W){const{gen:re,schema:ue,data:Fe,allErrors:gt,opts:Ye,self:Qe}=O,{RULES:He}=Qe;if(ue.$ref&&(Ye.ignoreKeywordsWithRef||!(0,l.schemaHasRulesButRef)(ue,He))){re.block(()=>ee(O,"$ref",He.all.$ref.definition));return}Ye.jtd||ge(O,A),re.block(()=>{for(const ot of He.rules)Sr(ot);Sr(He.post)});function Sr(ot){(0,r.shouldUseGroup)(ue,ot)&&(ot.type?(re.if((0,n.checkDataType)(ot.type,Fe,Ye.strictNumbers)),xe(O,ot),A.length===1&&A[0]===ot.type&&x&&(re.else(),(0,n.reportTypeError)(O)),re.endIf()):xe(O,ot),gt||re.if((0,o._)`${c.default.errors} === ${W||0}`))}}function xe(O,A){const{gen:x,schema:W,opts:{useDefaults:re}}=O;re&&(0,s.assignDefaults)(O,A.type),x.block(()=>{for(const ue of A.rules)(0,r.shouldUseRule)(W,ue)&&ee(O,ue.keyword,ue.definition,A.type)})}function ge(O,A){O.schemaEnv.meta||!O.opts.strictTypes||(mt(O,A),O.opts.allowUnionTypes||H(O,A),N(O,O.dataTypes))}function mt(O,A){if(A.length){if(!O.dataTypes.length){O.dataTypes=A;return}A.forEach(x=>{z(O.dataTypes,x)||P(O,`type "${x}" not allowed by context "${O.dataTypes.join(",")}"`)}),k(O,A)}}function H(O,A){A.length>1&&!(A.length===2&&A.includes("null"))&&P(O,"use allowUnionTypes to allow union type keyword")}function N(O,A){const x=O.self.RULES.all;for(const W in x){const re=x[W];if(typeof re=="object"&&(0,r.shouldUseRule)(O.schema,re)){const{type:ue}=re.definition;ue.length&&!ue.some(Fe=>L(A,Fe))&&P(O,`missing type "${ue.join(",")}" for keyword "${W}"`)}}}function L(O,A){return O.includes(A)||A==="number"&&O.includes("integer")}function z(O,A){return O.includes(A)||A==="integer"&&O.includes("number")}function k(O,A){const x=[];for(const W of O.dataTypes)z(A,W)?x.push(W):A.includes("integer")&&W==="number"&&x.push("integer");O.dataTypes=x}function P(O,A){const x=O.schemaEnv.baseId+O.errSchemaPath;A+=` at "${x}" (strictTypes)`,(0,l.checkStrictMode)(O,A,O.opts.strictTypes)}class Z{constructor(A,x,W){if((0,a.validateKeywordUsage)(A,x,W),this.gen=A.gen,this.allErrors=A.allErrors,this.keyword=W,this.data=A.data,this.schema=A.schema[W],this.$data=x.$data&&A.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(A,this.schema,W,this.$data),this.schemaType=x.schemaType,this.parentSchema=A.schema,this.params={},this.it=A,this.def=x,this.$data)this.schemaCode=A.gen.const("vSchema",de(this.$data,A));else if(this.schemaCode=this.schemaValue,!(0,a.validSchemaType)(this.schema,x.schemaType,x.allowUndefined))throw new Error(`${W} value must be ${JSON.stringify(x.schemaType)}`);("code"in x?x.trackErrors:x.errors!==!1)&&(this.errsCount=A.gen.const("_errs",c.default.errors))}result(A,x,W){this.failResult((0,o.not)(A),x,W)}failResult(A,x,W){this.gen.if(A),W?W():this.error(),x?(this.gen.else(),x(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(A,x){this.failResult((0,o.not)(A),void 0,x)}fail(A){if(A===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(A),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(A){if(!this.$data)return this.fail(A);const{schemaCode:x}=this;this.fail((0,o._)`${x} !== undefined && (${(0,o.or)(this.invalid$data(),A)})`)}error(A,x,W){if(x){this.setParams(x),this._error(A,W),this.setParams({});return}this._error(A,W)}_error(A,x){(A?f.reportExtraError:f.reportError)(this,this.def.error,x)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(A){this.allErrors||this.gen.if(A)}setParams(A,x){x?Object.assign(this.params,A):this.params=A}block$data(A,x,W=o.nil){this.gen.block(()=>{this.check$data(A,W),x()})}check$data(A=o.nil,x=o.nil){if(!this.$data)return;const{gen:W,schemaCode:re,schemaType:ue,def:Fe}=this;W.if((0,o.or)((0,o._)`${re} === undefined`,x)),A!==o.nil&&W.assign(A,!0),(ue.length||Fe.validateSchema)&&(W.elseIf(this.invalid$data()),this.$dataError(),A!==o.nil&&W.assign(A,!1)),W.else()}invalid$data(){const{gen:A,schemaCode:x,schemaType:W,def:re,it:ue}=this;return(0,o.or)(Fe(),gt());function Fe(){if(W.length){if(!(x instanceof o.Name))throw new Error("ajv implementation error");const Ye=Array.isArray(W)?W:[W];return(0,o._)`${(0,n.checkDataTypes)(Ye,x,ue.opts.strictNumbers,n.DataType.Wrong)}`}return o.nil}function gt(){if(re.validateSchema){const Ye=A.scopeValue("validate$data",{ref:re.validateSchema});return(0,o._)`!${Ye}(${x})`}return o.nil}}subschema(A,x){const W=(0,i.getSubschema)(this.it,A);(0,i.extendSubschemaData)(W,this.it,A),(0,i.extendSubschemaMode)(W,A);const re={...this.it,...W,items:void 0,props:void 0};return y(re,x),re}mergeEvaluated(A,x){const{it:W,gen:re}=this;W.opts.unevaluated&&(W.props!==!0&&A.props!==void 0&&(W.props=l.mergeEvaluated.props(re,A.props,W.props,x)),W.items!==!0&&A.items!==void 0&&(W.items=l.mergeEvaluated.items(re,A.items,W.items,x)))}mergeValidEvaluated(A,x){const{it:W,gen:re}=this;if(W.opts.unevaluated&&(W.props!==!0||W.items!==!0))return re.if(x,()=>this.mergeEvaluated(A,o.Name)),!0}}yt.KeywordCxt=Z;function ee(O,A,x,W){const re=new Z(O,x,A);"code"in x?x.code(re,W):re.$data&&x.validate?(0,a.funcKeywordCode)(re,x):"macro"in x?(0,a.macroKeywordCode)(re,x):(x.compile||x.validate)&&(0,a.funcKeywordCode)(re,x)}const ne=/^\/(?:[^~]|~0|~1)*$/,_e=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function de(O,{dataLevel:A,dataNames:x,dataPathArr:W}){let re,ue;if(O==="")return c.default.rootData;if(O[0]==="/"){if(!ne.test(O))throw new Error(`Invalid JSON-pointer: ${O}`);re=O,ue=c.default.rootData}else{const Qe=_e.exec(O);if(!Qe)throw new Error(`Invalid JSON-pointer: ${O}`);const He=+Qe[1];if(re=Qe[2],re==="#"){if(He>=A)throw new Error(Ye("property/index",He));return W[A-He]}if(He>A)throw new Error(Ye("data",He));if(ue=x[A-He],!re)return ue}let Fe=ue;const gt=re.split("/");for(const Qe of gt)Qe&&(ue=(0,o._)`${ue}${(0,o.getProperty)((0,l.unescapeJsonPointer)(Qe))}`,Fe=(0,o._)`${Fe} && ${ue}`);return Fe;function Ye(Qe,He){return`Cannot access ${Qe} ${He} levels up, current level is ${A}`}}return yt.getData=de,yt}var ln={},yo;function Qs(){if(yo)return ln;yo=1,Object.defineProperty(ln,"__esModule",{value:!0});class t extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return ln.default=t,ln}var dn={},vo;function fn(){if(vo)return dn;vo=1,Object.defineProperty(dn,"__esModule",{value:!0});const t=cn();class e extends Error{constructor(n,s,a,i){super(i||`can't resolve reference ${a} from id ${s}`),this.missingRef=(0,t.resolveUrl)(n,s,a),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(n,this.missingRef))}}return dn.default=e,dn}var Xe={},wo;function Xs(){if(wo)return Xe;wo=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.resolveSchema=Xe.getCompilingSchema=Xe.resolveRef=Xe.compileSchema=Xe.SchemaEnv=void 0;const t=ie(),e=Qs(),r=Et(),n=cn(),s=fe(),a=un();class i{constructor(S){var p;this.refs={},this.dynamicAnchors={};let y;typeof S.schema=="object"&&(y=S.schema),this.schema=S.schema,this.schemaId=S.schemaId,this.root=S.root||this,this.baseId=(p=S.baseId)!==null&&p!==void 0?p:(0,n.normalizeId)(y?.[S.schemaId||"$id"]),this.schemaPath=S.schemaPath,this.localRefs=S.localRefs,this.meta=S.meta,this.$async=y?.$async,this.refs={}}}Xe.SchemaEnv=i;function o(m){const S=l.call(this,m);if(S)return S;const p=(0,n.getFullPath)(this.opts.uriResolver,m.root.baseId),{es5:y,lines:R}=this.opts.code,{ownProperties:d}=this.opts,h=new t.CodeGen(this.scope,{es5:y,lines:R,ownProperties:d});let _;m.$async&&(_=h.scopeValue("Error",{ref:e.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));const E=h.scopeName("validate");m.validateName=E;const I={gen:h,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:h.scopeValue("schema",this.opts.code.source===!0?{ref:m.schema,code:(0,t.stringify)(m.schema)}:{ref:m.schema}),validateName:E,ValidationError:_,schema:m.schema,schemaEnv:m,rootId:p,baseId:m.baseId||p,schemaPath:t.nil,errSchemaPath:m.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this};let j;try{this._compilations.add(m),(0,a.validateFunctionCode)(I),h.optimize(this.opts.code.optimize);const C=h.toString();j=`${h.scopeRefs(r.default.scope)}return ${C}`,this.opts.code.process&&(j=this.opts.code.process(j,m));const F=new Function(`${r.default.self}`,`${r.default.scope}`,j)(this,this.scope.get());if(this.scope.value(E,{ref:F}),F.errors=null,F.schema=m.schema,F.schemaEnv=m,m.$async&&(F.$async=!0),this.opts.code.source===!0&&(F.source={validateName:E,validateCode:C,scopeValues:h._values}),this.opts.unevaluated){const{props:D,items:ae}=I;F.evaluated={props:D instanceof t.Name?void 0:D,items:ae instanceof t.Name?void 0:ae,dynamicProps:D instanceof t.Name,dynamicItems:ae instanceof t.Name},F.source&&(F.source.evaluated=(0,t.stringify)(F.evaluated))}return m.validate=F,m}catch(C){throw delete m.validate,delete m.validateName,j&&this.logger.error("Error compiling schema, function code:",j),C}finally{this._compilations.delete(m)}}Xe.compileSchema=o;function c(m,S,p){var y;p=(0,n.resolveUrl)(this.opts.uriResolver,S,p);const R=m.refs[p];if(R)return R;let d=b.call(this,m,p);if(d===void 0){const h=(y=m.localRefs)===null||y===void 0?void 0:y[p],{schemaId:_}=this.opts;h&&(d=new i({schema:h,schemaId:_,root:m,baseId:S}))}if(d!==void 0)return m.refs[p]=u.call(this,d)}Xe.resolveRef=c;function u(m){return(0,n.inlineRef)(m.schema,this.opts.inlineRefs)?m.schema:m.validate?m:o.call(this,m)}function l(m){for(const S of this._compilations)if(f(S,m))return S}Xe.getCompilingSchema=l;function f(m,S){return m.schema===S.schema&&m.root===S.root&&m.baseId===S.baseId}function b(m,S){let p;for(;typeof(p=this.refs[S])=="string";)S=p;return p||this.schemas[S]||v.call(this,m,S)}function v(m,S){const p=this.opts.uriResolver.parse(S),y=(0,n._getFullPath)(this.opts.uriResolver,p);let R=(0,n.getFullPath)(this.opts.uriResolver,m.baseId,void 0);if(Object.keys(m.schema).length>0&&y===R)return w.call(this,p,m);const d=(0,n.normalizeId)(y),h=this.refs[d]||this.schemas[d];if(typeof h=="string"){const _=v.call(this,m,h);return typeof _?.schema!="object"?void 0:w.call(this,p,_)}if(typeof h?.schema=="object"){if(h.validate||o.call(this,h),d===(0,n.normalizeId)(S)){const{schema:_}=h,{schemaId:E}=this.opts,I=_[E];return I&&(R=(0,n.resolveUrl)(this.opts.uriResolver,R,I)),new i({schema:_,schemaId:E,root:m,baseId:R})}return w.call(this,p,h)}}Xe.resolveSchema=v;const g=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function w(m,{baseId:S,schema:p,root:y}){var R;if(((R=m.fragment)===null||R===void 0?void 0:R[0])!=="/")return;for(const _ of m.fragment.slice(1).split("/")){if(typeof p=="boolean")return;const E=p[(0,s.unescapeFragment)(_)];if(E===void 0)return;p=E;const I=typeof p=="object"&&p[this.opts.schemaId];!g.has(_)&&I&&(S=(0,n.resolveUrl)(this.opts.uriResolver,S,I))}let d;if(typeof p!="boolean"&&p.$ref&&!(0,s.schemaHasRulesButRef)(p,this.RULES)){const _=(0,n.resolveUrl)(this.opts.uriResolver,S,p.$ref);d=v.call(this,y,_)}const{schemaId:h}=this.opts;if(d=d||new i({schema:p,schemaId:h,root:y,baseId:S}),d.schema!==d.root.schema)return d}return Xe}const af={$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 hn={},kr={exports:{}},ea,bo;function So(){if(bo)return ea;bo=1;const t=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),e=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),r=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),n=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),s=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function a(d){let h="",_=0,E=0;for(E=0;E<d.length;E++)if(_=d[E].charCodeAt(0),_!==48){if(!(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102))return"";h+=d[E];break}for(E+=1;E<d.length;E++){if(_=d[E].charCodeAt(0),!(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102))return"";h+=d[E]}return h}const i=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(d){return d.length=0,!0}function c(d,h,_){if(d.length){const E=a(d);if(E!=="")h.push(E);else return _.error=!0,!1;d.length=0}return!0}function u(d){let h=0;const _={error:!1,address:"",zone:""},E=[],I=[];let j=!1,C=!1,M=c;for(let F=0;F<d.length;F++){const D=d[F];if(!(D==="["||D==="]"))if(D===":"){if(j===!0&&(C=!0),!M(I,E,_))break;if(++h>7){_.error=!0;break}F>0&&d[F-1]===":"&&(j=!0),E.push(":");continue}else if(D==="%"){if(!M(I,E,_))break;M=o}else{I.push(D);continue}}return I.length&&(M===o?_.zone=I.join(""):C?E.push(I.join("")):E.push(a(I))),_.address=E.join(""),_}function l(d){if(f(d,":")<2)return{host:d,isIPV6:!1};const h=u(d);if(h.error)return{host:d,isIPV6:!1};{let _=h.address,E=h.address;return h.zone&&(_+="%"+h.zone,E+="%25"+h.zone),{host:_,isIPV6:!0,escapedHost:E}}}function f(d,h){let _=0;for(let E=0;E<d.length;E++)d[E]===h&&_++;return _}function b(d){let h=d;const _=[];let E=-1,I=0;for(;I=h.length;){if(I===1){if(h===".")break;if(h==="/"){_.push("/");break}else{_.push(h);break}}else if(I===2){if(h[0]==="."){if(h[1]===".")break;if(h[1]==="/"){h=h.slice(2);continue}}else if(h[0]==="/"&&(h[1]==="."||h[1]==="/")){_.push("/");break}}else if(I===3&&h==="/.."){_.length!==0&&_.pop(),_.push("/");break}if(h[0]==="."){if(h[1]==="."){if(h[2]==="/"){h=h.slice(3);continue}}else if(h[1]==="/"){h=h.slice(2);continue}}else if(h[0]==="/"&&h[1]==="."){if(h[2]==="/"){h=h.slice(2);continue}else if(h[2]==="."&&h[3]==="/"){h=h.slice(3),_.length!==0&&_.pop();continue}}if((E=h.indexOf("/",1))===-1){_.push(h);break}else _.push(h.slice(0,E)),h=h.slice(E)}return _.join("")}const v={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},g=/[@/?#:]/g,w=/[@/?#]/g;function m(d,h){const _=h?w:g;return _.lastIndex=0,d.replace(_,E=>v[E])}function S(d,h=!1){if(d.indexOf("%")===-1)return d;let _="";for(let E=0;E<d.length;E++){if(d[E]==="%"&&E+2<d.length){const I=d.slice(E+1,E+3);if(r(I)){const j=I.toUpperCase(),C=String.fromCharCode(parseInt(j,16));h&&n(C)?_+=C:_+="%"+j,E+=2;continue}}_+=d[E]}return _}function p(d){let h="";for(let _=0;_<d.length;_++){if(d[_]==="%"&&_+2<d.length){const E=d.slice(_+1,_+3);if(r(E)){const I=E.toUpperCase(),j=String.fromCharCode(parseInt(I,16));j!=="."&&n(j)?h+=j:h+="%"+I,_+=2;continue}}s(d[_])?h+=d[_]:h+=escape(d[_])}return h}function y(d){let h="";for(let _=0;_<d.length;_++){if(d[_]==="%"&&_+2<d.length){const E=d.slice(_+1,_+3);if(r(E)){h+="%"+E.toUpperCase(),_+=2;continue}}h+=escape(d[_])}return h}function R(d){const h=[];if(d.userinfo!==void 0&&(h.push(d.userinfo),h.push("@")),d.host!==void 0){let _=unescape(d.host);if(!e(_)){const E=l(_);E.isIPV6===!0?_=`[${E.escapedHost}]`:_=m(_,!1)}h.push(_)}return(typeof d.port=="number"||typeof d.port=="string")&&(h.push(":"),h.push(String(d.port))),h.length?h.join(""):void 0}return ea={nonSimpleDomain:i,recomposeAuthority:R,reescapeHostDelimiters:m,normalizePercentEncoding:S,normalizePathEncoding:p,escapePreservingEscapes:y,removeDotSegments:b,isIPv4:e,isUUID:t,normalizeIPv6:l,stringArrayToHexStripped:a},ea}var ta,$o;function of(){if($o)return ta;$o=1;const{isUUID:t}=So(),e=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(d){return r.indexOf(d)!==-1}function s(d){return d.secure===!0?!0:d.secure===!1?!1:d.scheme?d.scheme.length===3&&(d.scheme[0]==="w"||d.scheme[0]==="W")&&(d.scheme[1]==="s"||d.scheme[1]==="S")&&(d.scheme[2]==="s"||d.scheme[2]==="S"):!1}function a(d){return d.host||(d.error=d.error||"HTTP URIs must have a host."),d}function i(d){const h=String(d.scheme).toLowerCase()==="https";return(d.port===(h?443:80)||d.port==="")&&(d.port=void 0),d.path||(d.path="/"),d}function o(d){return d.secure=s(d),d.resourceName=(d.path||"/")+(d.query?"?"+d.query:""),d.path=void 0,d.query=void 0,d}function c(d){if((d.port===(s(d)?443:80)||d.port==="")&&(d.port=void 0),typeof d.secure=="boolean"&&(d.scheme=d.secure?"wss":"ws",d.secure=void 0),d.resourceName){const[h,_]=d.resourceName.split("?");d.path=h&&h!=="/"?h:void 0,d.query=_,d.resourceName=void 0}return d.fragment=void 0,d}function u(d,h){if(!d.path)return d.error="URN can not be parsed",d;const _=d.path.match(e);if(_){const E=h.scheme||d.scheme||"urn";d.nid=_[1].toLowerCase(),d.nss=_[2];const I=`${E}:${h.nid||d.nid}`,j=R(I);d.path=void 0,j&&(d=j.parse(d,h))}else d.error=d.error||"URN can not be parsed.";return d}function l(d,h){if(d.nid===void 0)throw new Error("URN without nid cannot be serialized");const _=h.scheme||d.scheme||"urn",E=d.nid.toLowerCase(),I=`${_}:${h.nid||E}`,j=R(I);j&&(d=j.serialize(d,h));const C=d,M=d.nss;return C.path=`${E||h.nid}:${M}`,h.skipEscape=!0,C}function f(d,h){const _=d;return _.uuid=_.nss,_.nss=void 0,!h.tolerant&&(!_.uuid||!t(_.uuid))&&(_.error=_.error||"UUID is not valid."),_}function b(d){const h=d;return h.nss=(d.uuid||"").toLowerCase(),h}const v={scheme:"http",domainHost:!0,parse:a,serialize:i},g={scheme:"https",domainHost:v.domainHost,parse:a,serialize:i},w={scheme:"ws",domainHost:!0,parse:o,serialize:c},m={scheme:"wss",domainHost:w.domainHost,parse:w.parse,serialize:w.serialize},y={http:v,https:g,ws:w,wss:m,urn:{scheme:"urn",parse:u,serialize:l,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:f,serialize:b,skipNormalize:!0}};Object.setPrototypeOf(y,null);function R(d){return d&&(y[d]||y[d.toLowerCase()])||void 0}return ta={wsIsSecure:s,SCHEMES:y,isValidSchemeName:n,getSchemeHandler:R},ta}var ko;function cf(){if(ko)return kr.exports;ko=1;const{normalizeIPv6:t,removeDotSegments:e,recomposeAuthority:r,normalizePercentEncoding:n,normalizePathEncoding:s,escapePreservingEscapes:a,reescapeHostDelimiters:i,isIPv4:o,nonSimpleDomain:c}=So(),{SCHEMES:u,getSchemeHandler:l}=of();function f(E,I){return typeof E=="string"?E=R(E,I):typeof E=="object"&&(E=y(w(E,I),I)),E}function b(E,I,j){const C=j?Object.assign({scheme:"null"},j):{scheme:"null"},M=v(y(E,C),y(I,C),C,!0);return C.skipEscape=!0,w(M,C)}function v(E,I,j,C){const M={};return C||(E=y(w(E,j),j),I=y(w(I,j),j)),j=j||{},!j.tolerant&&I.scheme?(M.scheme=I.scheme,M.userinfo=I.userinfo,M.host=I.host,M.port=I.port,M.path=e(I.path||""),M.query=I.query):(I.userinfo!==void 0||I.host!==void 0||I.port!==void 0?(M.userinfo=I.userinfo,M.host=I.host,M.port=I.port,M.path=e(I.path||""),M.query=I.query):(I.path?(I.path[0]==="/"?M.path=e(I.path):((E.userinfo!==void 0||E.host!==void 0||E.port!==void 0)&&!E.path?M.path="/"+I.path:E.path?M.path=E.path.slice(0,E.path.lastIndexOf("/")+1)+I.path:M.path=I.path,M.path=e(M.path)),M.query=I.query):(M.path=E.path,I.query!==void 0?M.query=I.query:M.query=E.query),M.userinfo=E.userinfo,M.host=E.host,M.port=E.port),M.scheme=E.scheme),M.fragment=I.fragment,M}function g(E,I,j){const C=h(E,j),M=h(I,j);return C!==void 0&&M!==void 0&&C.toLowerCase()===M.toLowerCase()}function w(E,I){const j={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:""},C=Object.assign({},I),M=[],F=l(C.scheme||j.scheme);F&&F.serialize&&F.serialize(j,C),j.path!==void 0&&(C.skipEscape?j.path=n(j.path):(j.path=a(j.path),j.scheme!==void 0&&(j.path=j.path.split("%3A").join(":")))),C.reference!=="suffix"&&j.scheme&&M.push(j.scheme,":");const D=r(j);if(D!==void 0&&(C.reference!=="suffix"&&M.push("//"),M.push(D),j.path&&j.path[0]!=="/"&&M.push("/")),j.path!==void 0){let ae=j.path;!C.absolutePath&&(!F||!F.absolutePath)&&(ae=e(ae)),D===void 0&&ae[0]==="/"&&ae[1]==="/"&&(ae="/%2F"+ae.slice(2)),M.push(ae)}return j.query!==void 0&&M.push("?",j.query),j.fragment!==void 0&&M.push("#",j.fragment),M.join("")}const m=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function S(E,I){if(I[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 p(E,I){const j=Object.assign({},I),C={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let M=!1,F=!1;j.reference==="suffix"&&(j.scheme?E=j.scheme+":"+E:E="//"+E);const D=E.match(m);if(D){C.scheme=D[1],C.userinfo=D[3],C.host=D[4],C.port=parseInt(D[5],10),C.path=D[6]||"",C.query=D[7],C.fragment=D[8],isNaN(C.port)&&(C.port=D[5]);const ae=S(C,D);if(ae!==void 0&&(C.error=C.error||ae,M=!0),C.host)if(o(C.host)===!1){const ge=t(C.host);C.host=ge.host.toLowerCase(),F=ge.isIPV6}else F=!0;C.scheme===void 0&&C.userinfo===void 0&&C.host===void 0&&C.port===void 0&&C.query===void 0&&!C.path?C.reference="same-document":C.scheme===void 0?C.reference="relative":C.fragment===void 0?C.reference="absolute":C.reference="uri",j.reference&&j.reference!=="suffix"&&j.reference!==C.reference&&(C.error=C.error||"URI is not a "+j.reference+" reference.");const $e=l(j.scheme||C.scheme);if(!j.unicodeSupport&&(!$e||!$e.unicodeSupport)&&C.host&&(j.domainHost||$e&&$e.domainHost)&&F===!1&&c(C.host))try{C.host=new URL("http://"+C.host).hostname}catch(xe){C.error=C.error||"Host's domain name can not be converted to ASCII: "+xe}if((!$e||$e&&!$e.skipNormalize)&&(E.indexOf("%")!==-1&&(C.scheme!==void 0&&(C.scheme=unescape(C.scheme)),C.host!==void 0&&(C.host=i(unescape(C.host),F))),C.path&&(C.path=s(C.path)),C.fragment))try{C.fragment=encodeURI(decodeURIComponent(C.fragment))}catch{C.error=C.error||"URI malformed"}$e&&$e.parse&&$e.parse(C,j)}else C.error=C.error||"URI can not be parsed.";return{parsed:C,malformedAuthorityOrPort:M}}function y(E,I){return p(E,I).parsed}function R(E,I){return d(E,I).normalized}function d(E,I){const{parsed:j,malformedAuthorityOrPort:C}=p(E,I);return{normalized:C?E:w(j,I),malformedAuthorityOrPort:C}}function h(E,I){if(typeof E=="string"){const{normalized:j,malformedAuthorityOrPort:C}=d(E,I);return C?void 0:j}if(typeof E=="object")return w(E,I)}const _={SCHEMES:u,normalize:f,resolve:b,resolveComponent:v,equal:g,serialize:w,parse:y};return kr.exports=_,kr.exports.default=_,kr.exports.fastUri=_,kr.exports}var Eo;function uf(){if(Eo)return hn;Eo=1,Object.defineProperty(hn,"__esModule",{value:!0});const t=cf();return t.code='require("ajv/dist/runtime/uri").default',hn.default=t,hn}var Ro;function lf(){return Ro||(Ro=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=void 0;var e=un();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var r=ie();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Qs(),s=fn(),a=so(),i=Xs(),o=ie(),c=cn(),u=on(),l=fe(),f=af,b=uf(),v=(H,N)=>new RegExp(H,N);v.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],w=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={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."},S={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},p=200;function y(H){var N,L,z,k,P,Z,ee,ne,_e,de,O,A,x,W,re,ue,Fe,gt,Ye,Qe,He,Sr,ot,Wi,Ki;const tn=H.strict,Ji=(N=H.code)===null||N===void 0?void 0:N.optimize,Qd=Ji===!0||Ji===void 0?1:Ji||0,Xd=(z=(L=H.code)===null||L===void 0?void 0:L.regExp)!==null&&z!==void 0?z:v,Pv=(k=H.uriResolver)!==null&&k!==void 0?k:b.default;return{strictSchema:(Z=(P=H.strictSchema)!==null&&P!==void 0?P:tn)!==null&&Z!==void 0?Z:!0,strictNumbers:(ne=(ee=H.strictNumbers)!==null&&ee!==void 0?ee:tn)!==null&&ne!==void 0?ne:!0,strictTypes:(de=(_e=H.strictTypes)!==null&&_e!==void 0?_e:tn)!==null&&de!==void 0?de:"log",strictTuples:(A=(O=H.strictTuples)!==null&&O!==void 0?O:tn)!==null&&A!==void 0?A:"log",strictRequired:(W=(x=H.strictRequired)!==null&&x!==void 0?x:tn)!==null&&W!==void 0?W:!1,code:H.code?{...H.code,optimize:Qd,regExp:Xd}:{optimize:Qd,regExp:Xd},loopRequired:(re=H.loopRequired)!==null&&re!==void 0?re:p,loopEnum:(ue=H.loopEnum)!==null&&ue!==void 0?ue:p,meta:(Fe=H.meta)!==null&&Fe!==void 0?Fe:!0,messages:(gt=H.messages)!==null&>!==void 0?gt:!0,inlineRefs:(Ye=H.inlineRefs)!==null&&Ye!==void 0?Ye:!0,schemaId:(Qe=H.schemaId)!==null&&Qe!==void 0?Qe:"$id",addUsedSchema:(He=H.addUsedSchema)!==null&&He!==void 0?He:!0,validateSchema:(Sr=H.validateSchema)!==null&&Sr!==void 0?Sr:!0,validateFormats:(ot=H.validateFormats)!==null&&ot!==void 0?ot:!0,unicodeRegExp:(Wi=H.unicodeRegExp)!==null&&Wi!==void 0?Wi:!0,int32range:(Ki=H.int32range)!==null&&Ki!==void 0?Ki:!0,uriResolver:Pv}}class R{constructor(N={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,N=this.opts={...N,...y(N)};const{es5:L,lines:z}=this.opts.code;this.scope=new o.ValueScope({scope:{},prefixes:w,es5:L,lines:z}),this.logger=M(N.logger);const k=N.validateFormats;N.validateFormats=!1,this.RULES=(0,a.getRules)(),d.call(this,m,N,"NOT SUPPORTED"),d.call(this,S,N,"DEPRECATED","warn"),this._metaOpts=j.call(this),N.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),N.keywords&&I.call(this,N.keywords),typeof N.meta=="object"&&this.addMetaSchema(N.meta),_.call(this),N.validateFormats=k}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:N,meta:L,schemaId:z}=this.opts;let k=f;z==="id"&&(k={...f},k.id=k.$id,delete k.$id),L&&N&&this.addMetaSchema(k,k[z],!1)}defaultMeta(){const{meta:N,schemaId:L}=this.opts;return this.opts.defaultMeta=typeof N=="object"?N[L]||N:void 0}validate(N,L){let z;if(typeof N=="string"){if(z=this.getSchema(N),!z)throw new Error(`no schema with key or ref "${N}"`)}else z=this.compile(N);const k=z(L);return"$async"in z||(this.errors=z.errors),k}compile(N,L){const z=this._addSchema(N,L);return z.validate||this._compileSchemaEnv(z)}compileAsync(N,L){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:z}=this.opts;return k.call(this,N,L);async function k(de,O){await P.call(this,de.$schema);const A=this._addSchema(de,O);return A.validate||Z.call(this,A)}async function P(de){de&&!this.getSchema(de)&&await k.call(this,{$ref:de},!0)}async function Z(de){try{return this._compileSchemaEnv(de)}catch(O){if(!(O instanceof s.default))throw O;return ee.call(this,O),await ne.call(this,O.missingSchema),Z.call(this,de)}}function ee({missingSchema:de,missingRef:O}){if(this.refs[de])throw new Error(`AnySchema ${de} is loaded but ${O} cannot be resolved`)}async function ne(de){const O=await _e.call(this,de);this.refs[de]||await P.call(this,O.$schema),this.refs[de]||this.addSchema(O,de,L)}async function _e(de){const O=this._loading[de];if(O)return O;try{return await(this._loading[de]=z(de))}finally{delete this._loading[de]}}}addSchema(N,L,z,k=this.opts.validateSchema){if(Array.isArray(N)){for(const Z of N)this.addSchema(Z,void 0,z,k);return this}let P;if(typeof N=="object"){const{schemaId:Z}=this.opts;if(P=N[Z],P!==void 0&&typeof P!="string")throw new Error(`schema ${Z} must be string`)}return L=(0,c.normalizeId)(L||P),this._checkUnique(L),this.schemas[L]=this._addSchema(N,z,L,k,!0),this}addMetaSchema(N,L,z=this.opts.validateSchema){return this.addSchema(N,L,!0,z),this}validateSchema(N,L){if(typeof N=="boolean")return!0;let z;if(z=N.$schema,z!==void 0&&typeof z!="string")throw new Error("$schema must be a string");if(z=z||this.opts.defaultMeta||this.defaultMeta(),!z)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const k=this.validate(z,N);if(!k&&L){const P="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(P);else throw new Error(P)}return k}getSchema(N){let L;for(;typeof(L=h.call(this,N))=="string";)N=L;if(L===void 0){const{schemaId:z}=this.opts,k=new i.SchemaEnv({schema:{},schemaId:z});if(L=i.resolveSchema.call(this,k,N),!L)return;this.refs[N]=L}return L.validate||this._compileSchemaEnv(L)}removeSchema(N){if(N instanceof RegExp)return this._removeAllSchemas(this.schemas,N),this._removeAllSchemas(this.refs,N),this;switch(typeof N){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const L=h.call(this,N);return typeof L=="object"&&this._cache.delete(L.schema),delete this.schemas[N],delete this.refs[N],this}case"object":{const L=N;this._cache.delete(L);let z=N[this.opts.schemaId];return z&&(z=(0,c.normalizeId)(z),delete this.schemas[z],delete this.refs[z]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(N){for(const L of N)this.addKeyword(L);return this}addKeyword(N,L){let z;if(typeof N=="string")z=N,typeof L=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),L.keyword=z);else if(typeof N=="object"&&L===void 0){if(L=N,z=L.keyword,Array.isArray(z)&&!z.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(D.call(this,z,L),!L)return(0,l.eachItem)(z,P=>ae.call(this,P)),this;xe.call(this,L);const k={...L,type:(0,u.getJSONTypes)(L.type),schemaType:(0,u.getJSONTypes)(L.schemaType)};return(0,l.eachItem)(z,k.type.length===0?P=>ae.call(this,P,k):P=>k.type.forEach(Z=>ae.call(this,P,k,Z))),this}getKeyword(N){const L=this.RULES.all[N];return typeof L=="object"?L.definition:!!L}removeKeyword(N){const{RULES:L}=this;delete L.keywords[N],delete L.all[N];for(const z of L.rules){const k=z.rules.findIndex(P=>P.keyword===N);k>=0&&z.rules.splice(k,1)}return this}addFormat(N,L){return typeof L=="string"&&(L=new RegExp(L)),this.formats[N]=L,this}errorsText(N=this.errors,{separator:L=", ",dataVar:z="data"}={}){return!N||N.length===0?"No errors":N.map(k=>`${z}${k.instancePath} ${k.message}`).reduce((k,P)=>k+L+P)}$dataMetaSchema(N,L){const z=this.RULES.all;N=JSON.parse(JSON.stringify(N));for(const k of L){const P=k.split("/").slice(1);let Z=N;for(const ee of P)Z=Z[ee];for(const ee in z){const ne=z[ee];if(typeof ne!="object")continue;const{$data:_e}=ne.definition,de=Z[ee];_e&&de&&(Z[ee]=mt(de))}}return N}_removeAllSchemas(N,L){for(const z in N){const k=N[z];(!L||L.test(z))&&(typeof k=="string"?delete N[z]:k&&!k.meta&&(this._cache.delete(k.schema),delete N[z]))}}_addSchema(N,L,z,k=this.opts.validateSchema,P=this.opts.addUsedSchema){let Z;const{schemaId:ee}=this.opts;if(typeof N=="object")Z=N[ee];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof N!="boolean")throw new Error("schema must be object or boolean")}let ne=this._cache.get(N);if(ne!==void 0)return ne;z=(0,c.normalizeId)(Z||z);const _e=c.getSchemaRefs.call(this,N,z);return ne=new i.SchemaEnv({schema:N,schemaId:ee,meta:L,baseId:z,localRefs:_e}),this._cache.set(ne.schema,ne),P&&!z.startsWith("#")&&(z&&this._checkUnique(z),this.refs[z]=ne),k&&this.validateSchema(N,!0),ne}_checkUnique(N){if(this.schemas[N]||this.refs[N])throw new Error(`schema with key or id "${N}" already exists`)}_compileSchemaEnv(N){if(N.meta?this._compileMetaSchema(N):i.compileSchema.call(this,N),!N.validate)throw new Error("ajv implementation error");return N.validate}_compileMetaSchema(N){const L=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,N)}finally{this.opts=L}}}R.ValidationError=n.default,R.MissingRefError=s.default,t.default=R;function d(H,N,L,z="error"){for(const k in H){const P=k;P in N&&this.logger[z](`${L}: option ${k}. ${H[P]}`)}}function h(H){return H=(0,c.normalizeId)(H),this.schemas[H]||this.refs[H]}function _(){const H=this.opts.schemas;if(H)if(Array.isArray(H))this.addSchema(H);else for(const N in H)this.addSchema(H[N],N)}function E(){for(const H in this.opts.formats){const N=this.opts.formats[H];N&&this.addFormat(H,N)}}function I(H){if(Array.isArray(H)){this.addVocabulary(H);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const N in H){const L=H[N];L.keyword||(L.keyword=N),this.addKeyword(L)}}function j(){const H={...this.opts};for(const N of g)delete H[N];return H}const C={log(){},warn(){},error(){}};function M(H){if(H===!1)return C;if(H===void 0)return console;if(H.log&&H.warn&&H.error)return H;throw new Error("logger must implement log, warn and error methods")}const F=/^[a-z_$][a-z0-9_$:-]*$/i;function D(H,N){const{RULES:L}=this;if((0,l.eachItem)(H,z=>{if(L.keywords[z])throw new Error(`Keyword ${z} is already defined`);if(!F.test(z))throw new Error(`Keyword ${z} has invalid name`)}),!!N&&N.$data&&!("code"in N||"validate"in N))throw new Error('$data keyword must have "code" or "validate" function')}function ae(H,N,L){var z;const k=N?.post;if(L&&k)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:P}=this;let Z=k?P.post:P.rules.find(({type:ne})=>ne===L);if(Z||(Z={type:L,rules:[]},P.rules.push(Z)),P.keywords[H]=!0,!N)return;const ee={keyword:H,definition:{...N,type:(0,u.getJSONTypes)(N.type),schemaType:(0,u.getJSONTypes)(N.schemaType)}};N.before?$e.call(this,Z,ee,N.before):Z.rules.push(ee),P.all[H]=ee,(z=N.implements)===null||z===void 0||z.forEach(ne=>this.addKeyword(ne))}function $e(H,N,L){const z=H.rules.findIndex(k=>k.keyword===L);z>=0?H.rules.splice(z,0,N):(H.rules.push(N),this.logger.warn(`rule ${L} is not defined`))}function xe(H){let{metaSchema:N}=H;N!==void 0&&(H.$data&&this.opts.$data&&(N=mt(N)),H.validateSchema=this.compile(N,!0))}const ge={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function mt(H){return{anyOf:[H,ge]}}})(Hs)),Hs}var pn={},mn={},gn={},To;function df(){if(To)return gn;To=1,Object.defineProperty(gn,"__esModule",{value:!0});const t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return gn.default=t,gn}var Rt={},Po;function ff(){if(Po)return Rt;Po=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.callRef=Rt.getValidate=void 0;const t=fn(),e=ut(),r=ie(),n=Et(),s=Xs(),a=fe(),i={keyword:"$ref",schemaType:"string",code(u){const{gen:l,schema:f,it:b}=u,{baseId:v,schemaEnv:g,validateName:w,opts:m,self:S}=b,{root:p}=g;if((f==="#"||f==="#/")&&v===p.baseId)return R();const y=s.resolveRef.call(S,p,v,f);if(y===void 0)throw new t.default(b.opts.uriResolver,v,f);if(y instanceof s.SchemaEnv)return d(y);return h(y);function R(){if(g===p)return c(u,w,g,g.$async);const _=l.scopeValue("root",{ref:p});return c(u,(0,r._)`${_}.validate`,p,p.$async)}function d(_){const E=o(u,_);c(u,E,_,_.$async)}function h(_){const E=l.scopeValue("schema",m.code.source===!0?{ref:_,code:(0,r.stringify)(_)}:{ref:_}),I=l.name("valid"),j=u.subschema({schema:_,dataTypes:[],schemaPath:r.nil,topSchemaRef:E,errSchemaPath:f},I);u.mergeEvaluated(j),u.ok(I)}}};function o(u,l){const{gen:f}=u;return l.validate?f.scopeValue("validate",{ref:l.validate}):(0,r._)`${f.scopeValue("wrapper",{ref:l})}.validate`}Rt.getValidate=o;function c(u,l,f,b){const{gen:v,it:g}=u,{allErrors:w,schemaEnv:m,opts:S}=g,p=S.passContext?n.default.this:r.nil;b?y():R();function y(){if(!m.$async)throw new Error("async schema referenced by sync schema");const _=v.let("valid");v.try(()=>{v.code((0,r._)`await ${(0,e.callValidateCode)(u,l,p)}`),h(l),w||v.assign(_,!0)},E=>{v.if((0,r._)`!(${E} instanceof ${g.ValidationError})`,()=>v.throw(E)),d(E),w||v.assign(_,!1)}),u.ok(_)}function R(){u.result((0,e.callValidateCode)(u,l,p),()=>h(l),()=>d(l))}function d(_){const E=(0,r._)`${_}.errors`;v.assign(n.default.vErrors,(0,r._)`${n.default.vErrors} === null ? ${E} : ${n.default.vErrors}.concat(${E})`),v.assign(n.default.errors,(0,r._)`${n.default.vErrors}.length`)}function h(_){var E;if(!g.opts.unevaluated)return;const I=(E=f?.validate)===null||E===void 0?void 0:E.evaluated;if(g.props!==!0)if(I&&!I.dynamicProps)I.props!==void 0&&(g.props=a.mergeEvaluated.props(v,I.props,g.props));else{const j=v.var("props",(0,r._)`${_}.evaluated.props`);g.props=a.mergeEvaluated.props(v,j,g.props,r.Name)}if(g.items!==!0)if(I&&!I.dynamicItems)I.items!==void 0&&(g.items=a.mergeEvaluated.items(v,I.items,g.items));else{const j=v.var("items",(0,r._)`${_}.evaluated.items`);g.items=a.mergeEvaluated.items(v,j,g.items,r.Name)}}}return Rt.callRef=c,Rt.default=i,Rt}var Co;function hf(){if(Co)return mn;Co=1,Object.defineProperty(mn,"__esModule",{value:!0});const t=df(),e=ff(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,e.default];return mn.default=r,mn}var _n={},yn={},Io;function pf(){if(Io)return yn;Io=1,Object.defineProperty(yn,"__esModule",{value:!0});const t=ie(),e=t.operators,r={maximum:{okStr:"<=",ok:e.LTE,fail:e.GT},minimum:{okStr:">=",ok:e.GTE,fail:e.LT},exclusiveMaximum:{okStr:"<",ok:e.LT,fail:e.GTE},exclusiveMinimum:{okStr:">",ok:e.GT,fail:e.LTE}},n={message:({keyword:a,schemaCode:i})=>(0,t.str)`must be ${r[a].okStr} ${i}`,params:({keyword:a,schemaCode:i})=>(0,t._)`{comparison: ${r[a].okStr}, limit: ${i}}`},s={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:n,code(a){const{keyword:i,data:o,schemaCode:c}=a;a.fail$data((0,t._)`${o} ${r[i].fail} ${c} || isNaN(${o})`)}};return yn.default=s,yn}var vn={},Oo;function mf(){if(Oo)return vn;Oo=1,Object.defineProperty(vn,"__esModule",{value:!0});const t=ie(),r={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:n})=>(0,t.str)`must be multiple of ${n}`,params:({schemaCode:n})=>(0,t._)`{multipleOf: ${n}}`},code(n){const{gen:s,data:a,schemaCode:i,it:o}=n,c=o.opts.multipleOfPrecision,u=s.let("res"),l=c?(0,t._)`Math.abs(Math.round(${u}) - ${u}) > 1e-${c}`:(0,t._)`${u} !== parseInt(${u})`;n.fail$data((0,t._)`(${i} === 0 || (${u} = ${a}/${i}, ${l}))`)}};return vn.default=r,vn}var wn={},bn={},No;function gf(){if(No)return bn;No=1,Object.defineProperty(bn,"__esModule",{value:!0});function t(e){const r=e.length;let n=0,s=0,a;for(;s<r;)n++,a=e.charCodeAt(s++),a>=55296&&a<=56319&&s<r&&(a=e.charCodeAt(s),(a&64512)===56320&&s++);return n}return bn.default=t,t.code='require("ajv/dist/runtime/ucs2length").default',bn}var Ao;function _f(){if(Ao)return wn;Ao=1,Object.defineProperty(wn,"__esModule",{value:!0});const t=ie(),e=fe(),r=gf(),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:a,schemaCode:i}){const o=a==="maxLength"?"more":"fewer";return(0,t.str)`must NOT have ${o} than ${i} characters`},params:({schemaCode:a})=>(0,t._)`{limit: ${a}}`},code(a){const{keyword:i,data:o,schemaCode:c,it:u}=a,l=i==="maxLength"?t.operators.GT:t.operators.LT,f=u.opts.unicode===!1?(0,t._)`${o}.length`:(0,t._)`${(0,e.useFunc)(a.gen,r.default)}(${o})`;a.fail$data((0,t._)`${f} ${l} ${c}`)}};return wn.default=s,wn}var Sn={},zo;function yf(){if(zo)return Sn;zo=1,Object.defineProperty(Sn,"__esModule",{value:!0});const t=ut(),e=fe(),r=ie(),s={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:a})=>(0,r.str)`must match pattern "${a}"`,params:({schemaCode:a})=>(0,r._)`{pattern: ${a}}`},code(a){const{gen:i,data:o,$data:c,schema:u,schemaCode:l,it:f}=a,b=f.opts.unicodeRegExp?"u":"";if(c){const{regExp:v}=f.opts.code,g=v.code==="new RegExp"?(0,r._)`new RegExp`:(0,e.useFunc)(i,v),w=i.let("valid");i.try(()=>i.assign(w,(0,r._)`${g}(${l}, ${b}).test(${o})`),()=>i.assign(w,!1)),a.fail$data((0,r._)`!${w}`)}else{const v=(0,t.usePattern)(a,u);a.fail$data((0,r._)`!${v}.test(${o})`)}}};return Sn.default=s,Sn}var $n={},jo;function vf(){if(jo)return $n;jo=1,Object.defineProperty($n,"__esModule",{value:!0});const t=ie(),r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:n,schemaCode:s}){const a=n==="maxProperties"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${s} properties`},params:({schemaCode:n})=>(0,t._)`{limit: ${n}}`},code(n){const{keyword:s,data:a,schemaCode:i}=n,o=s==="maxProperties"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`Object.keys(${a}).length ${o} ${i}`)}};return $n.default=r,$n}var kn={},Mo;function wf(){if(Mo)return kn;Mo=1,Object.defineProperty(kn,"__esModule",{value:!0});const t=ut(),e=ie(),r=fe(),s={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:a}})=>(0,e.str)`must have required property '${a}'`,params:({params:{missingProperty:a}})=>(0,e._)`{missingProperty: ${a}}`},code(a){const{gen:i,schema:o,schemaCode:c,data:u,$data:l,it:f}=a,{opts:b}=f;if(!l&&o.length===0)return;const v=o.length>=b.loopRequired;if(f.allErrors?g():w(),b.strictRequired){const p=a.parentSchema.properties,{definedProperties:y}=a.it;for(const R of o)if(p?.[R]===void 0&&!y.has(R)){const d=f.schemaEnv.baseId+f.errSchemaPath,h=`required property "${R}" is not defined at "${d}" (strictRequired)`;(0,r.checkStrictMode)(f,h,f.opts.strictRequired)}}function g(){if(v||l)a.block$data(e.nil,m);else for(const p of o)(0,t.checkReportMissingProp)(a,p)}function w(){const p=i.let("missing");if(v||l){const y=i.let("valid",!0);a.block$data(y,()=>S(p,y)),a.ok(y)}else i.if((0,t.checkMissingProp)(a,o,p)),(0,t.reportMissingProp)(a,p),i.else()}function m(){i.forOf("prop",c,p=>{a.setParams({missingProperty:p}),i.if((0,t.noPropertyInData)(i,u,p,b.ownProperties),()=>a.error())})}function S(p,y){a.setParams({missingProperty:p}),i.forOf(p,c,()=>{i.assign(y,(0,t.propertyInData)(i,u,p,b.ownProperties)),i.if((0,e.not)(y),()=>{a.error(),i.break()})},e.nil)}}};return kn.default=s,kn}var En={},qo;function bf(){if(qo)return En;qo=1,Object.defineProperty(En,"__esModule",{value:!0});const t=ie(),r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:n,schemaCode:s}){const a=n==="maxItems"?"more":"fewer";return(0,t.str)`must NOT have ${a} than ${s} items`},params:({schemaCode:n})=>(0,t._)`{limit: ${n}}`},code(n){const{keyword:s,data:a,schemaCode:i}=n,o=s==="maxItems"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`${a}.length ${o} ${i}`)}};return En.default=r,En}var Rn={},Tn={},Zo;function ra(){if(Zo)return Tn;Zo=1,Object.defineProperty(Tn,"__esModule",{value:!0});const t=po();return t.code='require("ajv/dist/runtime/equal").default',Tn.default=t,Tn}var xo;function Sf(){if(xo)return Rn;xo=1,Object.defineProperty(Rn,"__esModule",{value:!0});const t=on(),e=ie(),r=fe(),n=ra(),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i,j:o}})=>(0,e.str)`must NOT have duplicate items (items ## ${o} and ${i} are identical)`,params:({params:{i,j:o}})=>(0,e._)`{i: ${i}, j: ${o}}`},code(i){const{gen:o,data:c,$data:u,schema:l,parentSchema:f,schemaCode:b,it:v}=i;if(!u&&!l)return;const g=o.let("valid"),w=f.items?(0,t.getSchemaTypes)(f.items):[];i.block$data(g,m,(0,e._)`${b} === false`),i.ok(g);function m(){const R=o.let("i",(0,e._)`${c}.length`),d=o.let("j");i.setParams({i:R,j:d}),o.assign(g,!0),o.if((0,e._)`${R} > 1`,()=>(S()?p:y)(R,d))}function S(){return w.length>0&&!w.some(R=>R==="object"||R==="array")}function p(R,d){const h=o.name("item"),_=(0,t.checkDataTypes)(w,h,v.opts.strictNumbers,t.DataType.Wrong),E=o.const("indices",(0,e._)`{}`);o.for((0,e._)`;${R}--;`,()=>{o.let(h,(0,e._)`${c}[${R}]`),o.if(_,(0,e._)`continue`),w.length>1&&o.if((0,e._)`typeof ${h} == "string"`,(0,e._)`${h} += "_"`),o.if((0,e._)`typeof ${E}[${h}] == "number"`,()=>{o.assign(d,(0,e._)`${E}[${h}]`),i.error(),o.assign(g,!1).break()}).code((0,e._)`${E}[${h}] = ${R}`)})}function y(R,d){const h=(0,r.useFunc)(o,n.default),_=o.name("outer");o.label(_).for((0,e._)`;${R}--;`,()=>o.for((0,e._)`${d} = ${R}; ${d}--;`,()=>o.if((0,e._)`${h}(${c}[${R}], ${c}[${d}])`,()=>{i.error(),o.assign(g,!1).break(_)})))}}};return Rn.default=a,Rn}var Pn={},Lo;function $f(){if(Lo)return Pn;Lo=1,Object.defineProperty(Pn,"__esModule",{value:!0});const t=ie(),e=fe(),r=ra(),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:a})=>(0,t._)`{allowedValue: ${a}}`},code(a){const{gen:i,data:o,$data:c,schemaCode:u,schema:l}=a;c||l&&typeof l=="object"?a.fail$data((0,t._)`!${(0,e.useFunc)(i,r.default)}(${o}, ${u})`):a.fail((0,t._)`${l} !== ${o}`)}};return Pn.default=s,Pn}var Cn={},Do;function kf(){if(Do)return Cn;Do=1,Object.defineProperty(Cn,"__esModule",{value:!0});const t=ie(),e=fe(),r=ra(),s={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:a})=>(0,t._)`{allowedValues: ${a}}`},code(a){const{gen:i,data:o,$data:c,schema:u,schemaCode:l,it:f}=a;if(!c&&u.length===0)throw new Error("enum must have non-empty array");const b=u.length>=f.opts.loopEnum;let v;const g=()=>v??(v=(0,e.useFunc)(i,r.default));let w;if(b||c)w=i.let("valid"),a.block$data(w,m);else{if(!Array.isArray(u))throw new Error("ajv implementation error");const p=i.const("vSchema",l);w=(0,t.or)(...u.map((y,R)=>S(p,R)))}a.pass(w);function m(){i.assign(w,!1),i.forOf("v",l,p=>i.if((0,t._)`${g()}(${o}, ${p})`,()=>i.assign(w,!0).break()))}function S(p,y){const R=u[y];return typeof R=="object"&&R!==null?(0,t._)`${g()}(${o}, ${p}[${y}])`:(0,t._)`${o} === ${R}`}}};return Cn.default=s,Cn}var Uo;function Ef(){if(Uo)return _n;Uo=1,Object.defineProperty(_n,"__esModule",{value:!0});const t=pf(),e=mf(),r=_f(),n=yf(),s=vf(),a=wf(),i=bf(),o=Sf(),c=$f(),u=kf(),l=[t.default,e.default,r.default,n.default,s.default,a.default,i.default,o.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,u.default];return _n.default=l,_n}var In={},er={},Vo;function Fo(){if(Vo)return er;Vo=1,Object.defineProperty(er,"__esModule",{value:!0}),er.validateAdditionalItems=void 0;const t=ie(),e=fe(),n={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:a}})=>(0,t.str)`must NOT have more than ${a} items`,params:({params:{len:a}})=>(0,t._)`{limit: ${a}}`},code(a){const{parentSchema:i,it:o}=a,{items:c}=i;if(!Array.isArray(c)){(0,e.checkStrictMode)(o,'"additionalItems" is ignored when "items" is not an array of schemas');return}s(a,c)}};function s(a,i){const{gen:o,schema:c,data:u,keyword:l,it:f}=a;f.items=!0;const b=o.const("len",(0,t._)`${u}.length`);if(c===!1)a.setParams({len:i.length}),a.pass((0,t._)`${b} <= ${i.length}`);else if(typeof c=="object"&&!(0,e.alwaysValidSchema)(f,c)){const g=o.var("valid",(0,t._)`${b} <= ${i.length}`);o.if((0,t.not)(g),()=>v(g)),a.ok(g)}function v(g){o.forRange("i",i.length,b,w=>{a.subschema({keyword:l,dataProp:w,dataPropType:e.Type.Num},g),f.allErrors||o.if((0,t.not)(g),()=>o.break())})}}return er.validateAdditionalItems=s,er.default=n,er}var On={},tr={},Ho;function Wo(){if(Ho)return tr;Ho=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.validateTuple=void 0;const t=ie(),e=fe(),r=ut(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(a){const{schema:i,it:o}=a;if(Array.isArray(i))return s(a,"additionalItems",i);o.items=!0,!(0,e.alwaysValidSchema)(o,i)&&a.ok((0,r.validateArray)(a))}};function s(a,i,o=a.schema){const{gen:c,parentSchema:u,data:l,keyword:f,it:b}=a;w(u),b.opts.unevaluated&&o.length&&b.items!==!0&&(b.items=e.mergeEvaluated.items(c,o.length,b.items));const v=c.name("valid"),g=c.const("len",(0,t._)`${l}.length`);o.forEach((m,S)=>{(0,e.alwaysValidSchema)(b,m)||(c.if((0,t._)`${g} > ${S}`,()=>a.subschema({keyword:f,schemaProp:S,dataProp:S},v)),a.ok(v))});function w(m){const{opts:S,errSchemaPath:p}=b,y=o.length,R=y===m.minItems&&(y===m.maxItems||m[i]===!1);if(S.strictTuples&&!R){const d=`"${f}" is ${y}-tuple, but minItems or maxItems/${i} are not specified or different at path "${p}"`;(0,e.checkStrictMode)(b,d,S.strictTuples)}}}return tr.validateTuple=s,tr.default=n,tr}var Ko;function Rf(){if(Ko)return On;Ko=1,Object.defineProperty(On,"__esModule",{value:!0});const t=Wo(),e={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:r=>(0,t.validateTuple)(r,"items")};return On.default=e,On}var Nn={},Jo;function Tf(){if(Jo)return Nn;Jo=1,Object.defineProperty(Nn,"__esModule",{value:!0});const t=ie(),e=fe(),r=ut(),n=Fo(),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:i}})=>(0,t.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,t._)`{limit: ${i}}`},code(i){const{schema:o,parentSchema:c,it:u}=i,{prefixItems:l}=c;u.items=!0,!(0,e.alwaysValidSchema)(u,o)&&(l?(0,n.validateAdditionalItems)(i,l):i.ok((0,r.validateArray)(i)))}};return Nn.default=a,Nn}var An={},Bo;function Pf(){if(Bo)return An;Bo=1,Object.defineProperty(An,"__esModule",{value:!0});const t=ie(),e=fe(),n={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:s,max:a}})=>a===void 0?(0,t.str)`must contain at least ${s} valid item(s)`:(0,t.str)`must contain at least ${s} and no more than ${a} valid item(s)`,params:({params:{min:s,max:a}})=>a===void 0?(0,t._)`{minContains: ${s}}`:(0,t._)`{minContains: ${s}, maxContains: ${a}}`},code(s){const{gen:a,schema:i,parentSchema:o,data:c,it:u}=s;let l,f;const{minContains:b,maxContains:v}=o;u.opts.next?(l=b===void 0?1:b,f=v):l=1;const g=a.const("len",(0,t._)`${c}.length`);if(s.setParams({min:l,max:f}),f===void 0&&l===0){(0,e.checkStrictMode)(u,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(f!==void 0&&l>f){(0,e.checkStrictMode)(u,'"minContains" > "maxContains" is always invalid'),s.fail();return}if((0,e.alwaysValidSchema)(u,i)){let y=(0,t._)`${g} >= ${l}`;f!==void 0&&(y=(0,t._)`${y} && ${g} <= ${f}`),s.pass(y);return}u.items=!0;const w=a.name("valid");f===void 0&&l===1?S(w,()=>a.if(w,()=>a.break())):l===0?(a.let(w,!0),f!==void 0&&a.if((0,t._)`${c}.length > 0`,m)):(a.let(w,!1),m()),s.result(w,()=>s.reset());function m(){const y=a.name("_valid"),R=a.let("count",0);S(y,()=>a.if(y,()=>p(R)))}function S(y,R){a.forRange("i",0,g,d=>{s.subschema({keyword:"contains",dataProp:d,dataPropType:e.Type.Num,compositeRule:!0},y),R()})}function p(y){a.code((0,t._)`${y}++`),f===void 0?a.if((0,t._)`${y} >= ${l}`,()=>a.assign(w,!0).break()):(a.if((0,t._)`${y} > ${f}`,()=>a.assign(w,!1).break()),l===1?a.assign(w,!0):a.if((0,t._)`${y} >= ${l}`,()=>a.assign(w,!0)))}}};return An.default=n,An}var na={},Go;function Cf(){return Go||(Go=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=ie(),r=fe(),n=ut();t.error={message:({params:{property:c,depsCount:u,deps:l}})=>{const f=u===1?"property":"properties";return(0,e.str)`must have ${f} ${l} when property ${c} is present`},params:({params:{property:c,depsCount:u,deps:l,missingProperty:f}})=>(0,e._)`{property: ${c},
|
|
6
|
-
missingProperty: ${f},
|
|
7
|
-
depsCount: ${u},
|
|
8
|
-
deps: ${l}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[u,l]=a(c);i(c,u),o(c,l)}};function a({schema:c}){const u={},l={};for(const f in c){if(f==="__proto__")continue;const b=Array.isArray(c[f])?u:l;b[f]=c[f]}return[u,l]}function i(c,u=c.schema){const{gen:l,data:f,it:b}=c;if(Object.keys(u).length===0)return;const v=l.let("missing");for(const g in u){const w=u[g];if(w.length===0)continue;const m=(0,n.propertyInData)(l,f,g,b.opts.ownProperties);c.setParams({property:g,depsCount:w.length,deps:w.join(", ")}),b.allErrors?l.if(m,()=>{for(const S of w)(0,n.checkReportMissingProp)(c,S)}):(l.if((0,e._)`${m} && (${(0,n.checkMissingProp)(c,w,v)})`),(0,n.reportMissingProp)(c,v),l.else())}}t.validatePropertyDeps=i;function o(c,u=c.schema){const{gen:l,data:f,keyword:b,it:v}=c,g=l.name("valid");for(const w in u)(0,r.alwaysValidSchema)(v,u[w])||(l.if((0,n.propertyInData)(l,f,w,v.opts.ownProperties),()=>{const m=c.subschema({keyword:b,schemaProp:w},g);c.mergeValidEvaluated(m,g)},()=>l.var(g,!0)),c.ok(g))}t.validateSchemaDeps=o,t.default=s})(na)),na}var zn={},Yo;function If(){if(Yo)return zn;Yo=1,Object.defineProperty(zn,"__esModule",{value:!0});const t=ie(),e=fe(),n={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:s})=>(0,t._)`{propertyName: ${s.propertyName}}`},code(s){const{gen:a,schema:i,data:o,it:c}=s;if((0,e.alwaysValidSchema)(c,i))return;const u=a.name("valid");a.forIn("key",o,l=>{s.setParams({propertyName:l}),s.subschema({keyword:"propertyNames",data:l,dataTypes:["string"],propertyName:l,compositeRule:!0},u),a.if((0,t.not)(u),()=>{s.error(!0),c.allErrors||a.break()})}),s.ok(u)}};return zn.default=n,zn}var jn={},Qo;function Xo(){if(Qo)return jn;Qo=1,Object.defineProperty(jn,"__esModule",{value:!0});const t=ut(),e=ie(),r=Et(),n=fe(),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:i})=>(0,e._)`{additionalProperty: ${i.additionalProperty}}`},code(i){const{gen:o,schema:c,parentSchema:u,data:l,errsCount:f,it:b}=i;if(!f)throw new Error("ajv implementation error");const{allErrors:v,opts:g}=b;if(b.props=!0,g.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(b,c))return;const w=(0,t.allSchemaProperties)(u.properties),m=(0,t.allSchemaProperties)(u.patternProperties);S(),i.ok((0,e._)`${f} === ${r.default.errors}`);function S(){o.forIn("key",l,h=>{!w.length&&!m.length?R(h):o.if(p(h),()=>R(h))})}function p(h){let _;if(w.length>8){const E=(0,n.schemaRefOrVal)(b,u.properties,"properties");_=(0,t.isOwnProperty)(o,E,h)}else w.length?_=(0,e.or)(...w.map(E=>(0,e._)`${h} === ${E}`)):_=e.nil;return m.length&&(_=(0,e.or)(_,...m.map(E=>(0,e._)`${(0,t.usePattern)(i,E)}.test(${h})`))),(0,e.not)(_)}function y(h){o.code((0,e._)`delete ${l}[${h}]`)}function R(h){if(g.removeAdditional==="all"||g.removeAdditional&&c===!1){y(h);return}if(c===!1){i.setParams({additionalProperty:h}),i.error(),v||o.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(b,c)){const _=o.name("valid");g.removeAdditional==="failing"?(d(h,_,!1),o.if((0,e.not)(_),()=>{i.reset(),y(h)})):(d(h,_),v||o.if((0,e.not)(_),()=>o.break()))}}function d(h,_,E){const I={keyword:"additionalProperties",dataProp:h,dataPropType:n.Type.Str};E===!1&&Object.assign(I,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(I,_)}}};return jn.default=a,jn}var Mn={},ec;function Of(){if(ec)return Mn;ec=1,Object.defineProperty(Mn,"__esModule",{value:!0});const t=un(),e=ut(),r=fe(),n=Xo(),s={keyword:"properties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,parentSchema:c,data:u,it:l}=a;l.opts.removeAdditional==="all"&&c.additionalProperties===void 0&&n.default.code(new t.KeywordCxt(l,n.default,"additionalProperties"));const f=(0,e.allSchemaProperties)(o);for(const m of f)l.definedProperties.add(m);l.opts.unevaluated&&f.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(i,(0,r.toHash)(f),l.props));const b=f.filter(m=>!(0,r.alwaysValidSchema)(l,o[m]));if(b.length===0)return;const v=i.name("valid");for(const m of b)g(m)?w(m):(i.if((0,e.propertyInData)(i,u,m,l.opts.ownProperties)),w(m),l.allErrors||i.else().var(v,!0),i.endIf()),a.it.definedProperties.add(m),a.ok(v);function g(m){return l.opts.useDefaults&&!l.compositeRule&&o[m].default!==void 0}function w(m){a.subschema({keyword:"properties",schemaProp:m,dataProp:m},v)}}};return Mn.default=s,Mn}var qn={},tc;function Nf(){if(tc)return qn;tc=1,Object.defineProperty(qn,"__esModule",{value:!0});const t=ut(),e=ie(),r=fe(),n=fe(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,data:c,parentSchema:u,it:l}=a,{opts:f}=l,b=(0,t.allSchemaProperties)(o),v=b.filter(R=>(0,r.alwaysValidSchema)(l,o[R]));if(b.length===0||v.length===b.length&&(!l.opts.unevaluated||l.props===!0))return;const g=f.strictSchema&&!f.allowMatchingProperties&&u.properties,w=i.name("valid");l.props!==!0&&!(l.props instanceof e.Name)&&(l.props=(0,n.evaluatedPropsToName)(i,l.props));const{props:m}=l;S();function S(){for(const R of b)g&&p(R),l.allErrors?y(R):(i.var(w,!0),y(R),i.if(w))}function p(R){for(const d in g)new RegExp(R).test(d)&&(0,r.checkStrictMode)(l,`property ${d} matches pattern ${R} (use allowMatchingProperties)`)}function y(R){i.forIn("key",c,d=>{i.if((0,e._)`${(0,t.usePattern)(a,R)}.test(${d})`,()=>{const h=v.includes(R);h||a.subschema({keyword:"patternProperties",schemaProp:R,dataProp:d,dataPropType:n.Type.Str},w),l.opts.unevaluated&&m!==!0?i.assign((0,e._)`${m}[${d}]`,!0):!h&&!l.allErrors&&i.if((0,e.not)(w),()=>i.break())})})}}};return qn.default=s,qn}var Zn={},rc;function Af(){if(rc)return Zn;rc=1,Object.defineProperty(Zn,"__esModule",{value:!0});const t=fe(),e={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(r){const{gen:n,schema:s,it:a}=r;if((0,t.alwaysValidSchema)(a,s)){r.fail();return}const i=n.name("valid");r.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),r.failResult(i,()=>r.reset(),()=>r.error())},error:{message:"must NOT be valid"}};return Zn.default=e,Zn}var xn={},nc;function zf(){if(nc)return xn;nc=1,Object.defineProperty(xn,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ut().validateUnion,error:{message:"must match a schema in anyOf"}};return xn.default=e,xn}var Ln={},sc;function jf(){if(sc)return Ln;sc=1,Object.defineProperty(Ln,"__esModule",{value:!0});const t=ie(),e=fe(),n={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:s})=>(0,t._)`{passingSchemas: ${s.passing}}`},code(s){const{gen:a,schema:i,parentSchema:o,it:c}=s;if(!Array.isArray(i))throw new Error("ajv implementation error");if(c.opts.discriminator&&o.discriminator)return;const u=i,l=a.let("valid",!1),f=a.let("passing",null),b=a.name("_valid");s.setParams({passing:f}),a.block(v),s.result(l,()=>s.reset(),()=>s.error(!0));function v(){u.forEach((g,w)=>{let m;(0,e.alwaysValidSchema)(c,g)?a.var(b,!0):m=s.subschema({keyword:"oneOf",schemaProp:w,compositeRule:!0},b),w>0&&a.if((0,t._)`${b} && ${l}`).assign(l,!1).assign(f,(0,t._)`[${f}, ${w}]`).else(),a.if(b,()=>{a.assign(l,!0),a.assign(f,w),m&&s.mergeEvaluated(m,t.Name)})})}}};return Ln.default=n,Ln}var Dn={},ac;function Mf(){if(ac)return Dn;ac=1,Object.defineProperty(Dn,"__esModule",{value:!0});const t=fe(),e={keyword:"allOf",schemaType:"array",code(r){const{gen:n,schema:s,it:a}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");const i=n.name("valid");s.forEach((o,c)=>{if((0,t.alwaysValidSchema)(a,o))return;const u=r.subschema({keyword:"allOf",schemaProp:c},i);r.ok(i),r.mergeEvaluated(u)})}};return Dn.default=e,Dn}var Un={},ic;function qf(){if(ic)return Un;ic=1,Object.defineProperty(Un,"__esModule",{value:!0});const t=ie(),e=fe(),n={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:a})=>(0,t.str)`must match "${a.ifClause}" schema`,params:({params:a})=>(0,t._)`{failingKeyword: ${a.ifClause}}`},code(a){const{gen:i,parentSchema:o,it:c}=a;o.then===void 0&&o.else===void 0&&(0,e.checkStrictMode)(c,'"if" without "then" and "else" is ignored');const u=s(c,"then"),l=s(c,"else");if(!u&&!l)return;const f=i.let("valid",!0),b=i.name("_valid");if(v(),a.reset(),u&&l){const w=i.let("ifClause");a.setParams({ifClause:w}),i.if(b,g("then",w),g("else",w))}else u?i.if(b,g("then")):i.if((0,t.not)(b),g("else"));a.pass(f,()=>a.error(!0));function v(){const w=a.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},b);a.mergeEvaluated(w)}function g(w,m){return()=>{const S=a.subschema({keyword:w},b);i.assign(f,b),a.mergeValidEvaluated(S,f),m?i.assign(m,(0,t._)`${w}`):a.setParams({ifClause:w})}}}};function s(a,i){const o=a.schema[i];return o!==void 0&&!(0,e.alwaysValidSchema)(a,o)}return Un.default=n,Un}var Vn={},oc;function Zf(){if(oc)return Vn;oc=1,Object.defineProperty(Vn,"__esModule",{value:!0});const t=fe(),e={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:r,parentSchema:n,it:s}){n.if===void 0&&(0,t.checkStrictMode)(s,`"${r}" without "if" is ignored`)}};return Vn.default=e,Vn}var cc;function xf(){if(cc)return In;cc=1,Object.defineProperty(In,"__esModule",{value:!0});const t=Fo(),e=Rf(),r=Wo(),n=Tf(),s=Pf(),a=Cf(),i=If(),o=Xo(),c=Of(),u=Nf(),l=Af(),f=zf(),b=jf(),v=Mf(),g=qf(),w=Zf();function m(S=!1){const p=[l.default,f.default,b.default,v.default,g.default,w.default,i.default,o.default,a.default,c.default,u.default];return S?p.push(e.default,n.default):p.push(t.default,r.default),p.push(s.default),p}return In.default=m,In}var Fn={},Hn={},uc;function Lf(){if(uc)return Hn;uc=1,Object.defineProperty(Hn,"__esModule",{value:!0});const t=ie(),r={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:n})=>(0,t.str)`must match format "${n}"`,params:({schemaCode:n})=>(0,t._)`{format: ${n}}`},code(n,s){const{gen:a,data:i,$data:o,schema:c,schemaCode:u,it:l}=n,{opts:f,errSchemaPath:b,schemaEnv:v,self:g}=l;if(!f.validateFormats)return;o?w():m();function w(){const S=a.scopeValue("formats",{ref:g.formats,code:f.code.formats}),p=a.const("fDef",(0,t._)`${S}[${u}]`),y=a.let("fType"),R=a.let("format");a.if((0,t._)`typeof ${p} == "object" && !(${p} instanceof RegExp)`,()=>a.assign(y,(0,t._)`${p}.type || "string"`).assign(R,(0,t._)`${p}.validate`),()=>a.assign(y,(0,t._)`"string"`).assign(R,p)),n.fail$data((0,t.or)(d(),h()));function d(){return f.strictSchema===!1?t.nil:(0,t._)`${u} && !${R}`}function h(){const _=v.$async?(0,t._)`(${p}.async ? await ${R}(${i}) : ${R}(${i}))`:(0,t._)`${R}(${i})`,E=(0,t._)`(typeof ${R} == "function" ? ${_} : ${R}.test(${i}))`;return(0,t._)`${R} && ${R} !== true && ${y} === ${s} && !${E}`}}function m(){const S=g.formats[c];if(!S){d();return}if(S===!0)return;const[p,y,R]=h(S);p===s&&n.pass(_());function d(){if(f.strictSchema===!1){g.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${c}" ignored in schema at path "${b}"`}}function h(E){const I=E instanceof RegExp?(0,t.regexpCode)(E):f.code.formats?(0,t._)`${f.code.formats}${(0,t.getProperty)(c)}`:void 0,j=a.scopeValue("formats",{key:c,ref:E,code:I});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,t._)`${j}.validate`]:["string",E,j]}function _(){if(typeof S=="object"&&!(S instanceof RegExp)&&S.async){if(!v.$async)throw new Error("async format in sync schema");return(0,t._)`await ${R}(${i})`}return typeof y=="function"?(0,t._)`${R}(${i})`:(0,t._)`${R}.test(${i})`}}}};return Hn.default=r,Hn}var lc;function Df(){if(lc)return Fn;lc=1,Object.defineProperty(Fn,"__esModule",{value:!0});const e=[Lf().default];return Fn.default=e,Fn}var Lt={},dc;function Uf(){return dc||(dc=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.contentVocabulary=Lt.metadataVocabulary=void 0,Lt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Lt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),Lt}var fc;function Vf(){if(fc)return pn;fc=1,Object.defineProperty(pn,"__esModule",{value:!0});const t=hf(),e=Ef(),r=xf(),n=Df(),s=Uf(),a=[t.default,e.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return pn.default=a,pn}var Wn={},Er={},hc;function Ff(){if(hc)return Er;hc=1,Object.defineProperty(Er,"__esModule",{value:!0}),Er.DiscrError=void 0;var t;return(function(e){e.Tag="tag",e.Mapping="mapping"})(t||(Er.DiscrError=t={})),Er}var pc;function Hf(){if(pc)return Wn;pc=1,Object.defineProperty(Wn,"__esModule",{value:!0});const t=ie(),e=Ff(),r=Xs(),n=fn(),s=fe(),i={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:o,tagName:c}})=>o===e.DiscrError.Tag?`tag "${c}" must be string`:`value of tag "${c}" must be in oneOf`,params:({params:{discrError:o,tag:c,tagName:u}})=>(0,t._)`{error: ${o}, tag: ${u}, tagValue: ${c}}`},code(o){const{gen:c,data:u,schema:l,parentSchema:f,it:b}=o,{oneOf:v}=f;if(!b.opts.discriminator)throw new Error("discriminator: requires discriminator option");const g=l.propertyName;if(typeof g!="string")throw new Error("discriminator: requires propertyName");if(l.mapping)throw new Error("discriminator: mapping is not supported");if(!v)throw new Error("discriminator: requires oneOf keyword");const w=c.let("valid",!1),m=c.const("tag",(0,t._)`${u}${(0,t.getProperty)(g)}`);c.if((0,t._)`typeof ${m} == "string"`,()=>S(),()=>o.error(!1,{discrError:e.DiscrError.Tag,tag:m,tagName:g})),o.ok(w);function S(){const R=y();c.if(!1);for(const d in R)c.elseIf((0,t._)`${m} === ${d}`),c.assign(w,p(R[d]));c.else(),o.error(!1,{discrError:e.DiscrError.Mapping,tag:m,tagName:g}),c.endIf()}function p(R){const d=c.name("valid"),h=o.subschema({keyword:"oneOf",schemaProp:R},d);return o.mergeEvaluated(h,t.Name),d}function y(){var R;const d={},h=E(f);let _=!0;for(let C=0;C<v.length;C++){let M=v[C];if(M?.$ref&&!(0,s.schemaHasRulesButRef)(M,b.self.RULES)){const D=M.$ref;if(M=r.resolveRef.call(b.self,b.schemaEnv.root,b.baseId,D),M instanceof r.SchemaEnv&&(M=M.schema),M===void 0)throw new n.default(b.opts.uriResolver,b.baseId,D)}const F=(R=M?.properties)===null||R===void 0?void 0:R[g];if(typeof F!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${g}"`);_=_&&(h||E(M)),I(F,C)}if(!_)throw new Error(`discriminator: "${g}" must be required`);return d;function E({required:C}){return Array.isArray(C)&&C.includes(g)}function I(C,M){if(C.const)j(C.const,M);else if(C.enum)for(const F of C.enum)j(F,M);else throw new Error(`discriminator: "properties/${g}" must have "const" or "enum"`)}function j(C,M){if(typeof C!="string"||C in d)throw new Error(`discriminator: "${g}" values must be unique strings`);d[C]=M}}}};return Wn.default=i,Wn}const Wf={$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 mc;function gc(){return mc||(mc=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;const r=lf(),n=Vf(),s=Hf(),a=Wf,i=["/properties"],o="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(g=>this.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(a,i):a;this.addMetaSchema(g,o,!1),this.refs["http://json-schema.org/schema"]=o}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var u=un();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=ie();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var f=Qs();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var b=fn();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return b.default}})})(rn,rn.exports)),rn.exports}var Kf=gc();const _c=Xt(Kf),Jf=Object.freeze({status:"aborted"});function q(t,e,r){function n(o,c){var u;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(u=o._zod).traits??(u.traits=new Set),o._zod.traits.add(t),e(o,c);for(const l in i.prototype)l in o||Object.defineProperty(o,l,{value:i.prototype[l].bind(o)});o._zod.constr=i,o._zod.def=c}const s=r?.Parent??Object;class a extends s{}Object.defineProperty(a,"name",{value:t});function i(o){var c;const u=r?.Parent?new a:this;n(u,o),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:o=>r?.Parent&&o instanceof r.Parent?!0:o?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}class Rr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const yc={};function Tt(t){return yc}function vc(t){const e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function Bf(t,e){return typeof e=="bigint"?e.toString():e}function sa(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function aa(t){return t==null}function ia(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Gf(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}function Se(t,e,r){Object.defineProperty(t,e,{get(){{const n=r();return t[e]=n,n}},set(n){Object.defineProperty(t,e,{value:n})},configurable:!0})}function Tr(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Pr(t){return JSON.stringify(t)}const wc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Kn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Yf=sa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Jn(t){if(Kn(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(Kn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const Qf=new Set(["string","number","symbol"]);function Cr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pt(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function Q(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Xf(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const eh={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]};function th(t,e){const r={},n=t._zod.def;for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return Pt(t,{...t._zod.def,shape:r,checks:[]})}function rh(t,e){const r={...t._zod.def.shape},n=t._zod.def;for(const s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return Pt(t,{...t._zod.def,shape:r,checks:[]})}function nh(t,e){if(!Jn(e))throw new Error("Invalid input to extend: expected a plain object");const r={...t._zod.def,get shape(){const n={...t._zod.def.shape,...e};return Tr(this,"shape",n),n},checks:[]};return Pt(t,r)}function sh(t,e){return Pt(t,{...t._zod.def,get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Tr(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function ah(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const a in r){if(!(a in n))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(s[a]=t?new t({type:"optional",innerType:n[a]}):n[a])}else for(const a in n)s[a]=t?new t({type:"optional",innerType:n[a]}):n[a];return Pt(e,{...e._zod.def,shape:s,checks:[]})}function ih(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const a in r){if(!(a in s))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(s[a]=new t({type:"nonoptional",innerType:n[a]}))}else for(const a in n)s[a]=new t({type:"nonoptional",innerType:n[a]});return Pt(e,{...e._zod.def,shape:s,checks:[]})}function Ir(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Dt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Bn(t){return typeof t=="string"?t:t?.message}function Ct(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Bn(t.inst?._zod.def?.error?.(t))??Bn(e?.error?.(t))??Bn(r.customError?.(t))??Bn(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function oa(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Or(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const bc=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,Bf,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Sc=q("$ZodError",bc),Gn=q("$ZodError",bc,{Parent:Error});function oh(t,e=r=>r.message){const r={},n=[];for(const s of t.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}function ch(t,e){const r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>s({issues:o}));else if(i.code==="invalid_key")s({issues:i.issues});else if(i.code==="invalid_element")s({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(t),n}const $c=t=>(e,r,n,s)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Rr;if(i.issues.length){const o=new(s?.Err??t)(i.issues.map(c=>Ct(c,a,Tt())));throw wc(o,s?.callee),o}return i.value},uh=$c(Gn),kc=t=>async(e,r,n,s)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const o=new(s?.Err??t)(i.issues.map(c=>Ct(c,a,Tt())));throw wc(o,s?.callee),o}return i.value},lh=kc(Gn),Ec=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},a=e._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Rr;return a.issues.length?{success:!1,error:new(t??Sc)(a.issues.map(i=>Ct(i,s,Tt())))}:{success:!0,data:a.value}},ca=Ec(Gn),Rc=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let a=e._zod.run({value:r,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new t(a.issues.map(i=>Ct(i,s,Tt())))}:{success:!0,data:a.value}},ua=Rc(Gn),dh=/^[cC][^\s-]{8,}$/,fh=/^[0-9a-z]+$/,hh=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ph=/^[0-9a-vA-V]{20}$/,mh=/^[A-Za-z0-9]{27}$/,gh=/^[a-zA-Z0-9_-]{21}$/,_h=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yh=/^([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})$/,Tc=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,vh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function bh(){return new RegExp(wh,"u")}const Sh=/^(?:(?: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])$/,$h=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,kh=/^((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])$/,Eh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pc=/^[A-Za-z0-9_-]*$/,Th=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Ph=/^\+(?:[0-9]){6,14}[0-9]$/,Cc="(?:(?:\\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])))",Ch=new RegExp(`^${Cc}$`);function Ic(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ih(t){return new RegExp(`^${Ic(t)}$`)}function Oh(t){const e=Ic({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Cc}T(?:${n})$`)}const Nh=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Ah=/^\d+$/,zh=/^-?\d+(?:\.\d+)?/i,jh=/true|false/i,Mh=/null/i,qh=/^[^A-Z]*$/,Zh=/^[^a-z]*$/,Je=q("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Oc={number:"number",bigint:"bigint",object:"date"},Nc=q("$ZodCheckLessThan",(t,e)=>{Je.init(t,e);const r=Oc[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,a=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<a&&(e.inclusive?s.maximum=e.value:s.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Ac=q("$ZodCheckGreaterThan",(t,e)=>{Je.init(t,e);const r=Oc[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,a=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>a&&(e.inclusive?s.minimum=e.value:s.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),xh=q("$ZodCheckMultipleOf",(t,e)=>{Je.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):Gf(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Lh=q("$ZodCheckNumberFormat",(t,e)=>{Je.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,a]=eh[e.format];t._zod.onattach.push(i=>{const o=i._zod.bag;o.format=e.format,o.minimum=s,o.maximum=a,r&&(o.pattern=Ah)}),t._zod.check=i=>{const o=i.value;if(r){if(!Number.isInteger(o)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:o,inst:t});return}if(!Number.isSafeInteger(o)){o>0?i.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}o<s&&i.issues.push({origin:"number",input:o,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),o>a&&i.issues.push({origin:"number",input:o,code:"too_big",maximum:a,inst:t})}}),Dh=q("$ZodCheckMaxLength",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!aa(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<s&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{const s=n.value;if(s.length<=e.maximum)return;const i=oa(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Uh=q("$ZodCheckMinLength",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!aa(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>s&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{const s=n.value;if(s.length>=e.minimum)return;const i=oa(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Vh=q("$ZodCheckLengthEquals",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!aa(s)&&s.length!==void 0}),t._zod.onattach.push(n=>{const s=n._zod.bag;s.minimum=e.length,s.maximum=e.length,s.length=e.length}),t._zod.check=n=>{const s=n.value,a=s.length;if(a===e.length)return;const i=oa(s),o=a>e.length;n.issues.push({origin:i,...o?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Yn=q("$ZodCheckStringFormat",(t,e)=>{var r,n;Je.init(t,e),t._zod.onattach.push(s=>{const a=s._zod.bag;a.format=e.format,e.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Fh=q("$ZodCheckRegex",(t,e)=>{Yn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Hh=q("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=qh),Yn.init(t,e)}),Wh=q("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Zh),Yn.init(t,e)}),Kh=q("$ZodCheckIncludes",(t,e)=>{Je.init(t,e);const r=Cr(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const a=s._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),Jh=q("$ZodCheckStartsWith",(t,e)=>{Je.init(t,e);const r=new RegExp(`^${Cr(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Bh=q("$ZodCheckEndsWith",(t,e)=>{Je.init(t,e);const r=new RegExp(`.*${Cr(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{const s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),Gh=q("$ZodCheckOverwrite",(t,e)=>{Je.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class Yh{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const n=e.split(`
|
|
9
|
-
`).filter(i=>i),s=Math.min(...n.map(i=>i.length-i.trimStart().length)),a=n.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of a)this.content.push(i)}compile(){const e=Function,r=this?.args,s=[...(this?.content??[""]).map(a=>` ${a}`)];return new e(...r,s.join(`
|
|
10
|
-
`))}}const Qh={major:4,minor:0,patch:0},be=q("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Qh;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const s of n)for(const a of s._zod.onattach)a(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const s=(a,i,o)=>{let c=Ir(a),u;for(const l of i){if(l._zod.def.when){if(!l._zod.def.when(a))continue}else if(c)continue;const f=a.issues.length,b=l._zod.check(a);if(b instanceof Promise&&o?.async===!1)throw new Rr;if(u||b instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await b,a.issues.length!==f&&(c||(c=Ir(a,f)))});else{if(a.issues.length===f)continue;c||(c=Ir(a,f))}}return u?u.then(()=>a):a};t._zod.run=(a,i)=>{const o=t._zod.parse(a,i);if(o instanceof Promise){if(i.async===!1)throw new Rr;return o.then(c=>s(c,n,i))}return s(o,n,i)}}t["~standard"]={validate:s=>{try{const a=ca(t,s);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return ua(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),la=q("$ZodString",(t,e)=>{be.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Nh(t._zod.bag),t._zod.parse=(r,n)=>{if(e.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:t}),r}}),Re=q("$ZodStringFormat",(t,e)=>{Yn.init(t,e),la.init(t,e)}),Xh=q("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=yh),Re.init(t,e)}),ep=q("$ZodUUID",(t,e)=>{if(e.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Tc(n))}else e.pattern??(e.pattern=Tc());Re.init(t,e)}),tp=q("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=vh),Re.init(t,e)}),rp=q("$ZodURL",(t,e)=>{Re.init(t,e),t._zod.check=r=>{try{const n=r.value,s=new URL(n),a=s.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Th.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&a.endsWith("/")?r.value=a.slice(0,-1):r.value=a;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),np=q("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=bh()),Re.init(t,e)}),sp=q("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=gh),Re.init(t,e)}),ap=q("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=dh),Re.init(t,e)}),ip=q("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=fh),Re.init(t,e)}),op=q("$ZodULID",(t,e)=>{e.pattern??(e.pattern=hh),Re.init(t,e)}),cp=q("$ZodXID",(t,e)=>{e.pattern??(e.pattern=ph),Re.init(t,e)}),up=q("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=mh),Re.init(t,e)}),lp=q("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Oh(e)),Re.init(t,e)}),dp=q("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Ch),Re.init(t,e)}),fp=q("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Ih(e)),Re.init(t,e)}),hp=q("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=_h),Re.init(t,e)}),pp=q("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Sh),Re.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),mp=q("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=$h),Re.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),gp=q("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=kh),Re.init(t,e)}),_p=q("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Eh),Re.init(t,e),t._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function zc(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const yp=q("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Rh),Re.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{zc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function vp(t){if(!Pc.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return zc(r)}const wp=q("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Pc),Re.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{vp(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),bp=q("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Ph),Re.init(t,e)});function Sp(t,e=null){try{const r=t.split(".");if(r.length!==3)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const $p=q("$ZodJWT",(t,e)=>{Re.init(t,e),t._zod.check=r=>{Sp(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),jc=q("$ZodNumber",(t,e)=>{be.init(t,e),t._zod.pattern=t._zod.bag.pattern??zh,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}const s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;const a=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...a?{received:a}:{}}),r}}),kp=q("$ZodNumber",(t,e)=>{Lh.init(t,e),jc.init(t,e)}),Ep=q("$ZodBoolean",(t,e)=>{be.init(t,e),t._zod.pattern=jh,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}const s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),Rp=q("$ZodNull",(t,e)=>{be.init(t,e),t._zod.pattern=Mh,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{const s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:t}),r}}),Tp=q("$ZodAny",(t,e)=>{be.init(t,e),t._zod.parse=r=>r}),Pp=q("$ZodUnknown",(t,e)=>{be.init(t,e),t._zod.parse=r=>r}),Cp=q("$ZodNever",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Mc(t,e,r){t.issues.length&&e.issues.push(...Dt(r,t.issues)),e.value[r]=t.value}const Ip=q("$ZodArray",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:t}),r;r.value=Array(s.length);const a=[];for(let i=0;i<s.length;i++){const o=s[i],c=e.element._zod.run({value:o,issues:[]},n);c instanceof Promise?a.push(c.then(u=>Mc(u,r,i))):Mc(c,r,i)}return a.length?Promise.all(a).then(()=>r):r}});function Qn(t,e,r){t.issues.length&&e.issues.push(...Dt(r,t.issues)),e.value[r]=t.value}function qc(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...Dt(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}const Zc=q("$ZodObject",(t,e)=>{be.init(t,e);const r=sa(()=>{const f=Object.keys(e.shape);for(const v of f)if(!(e.shape[v]instanceof be))throw new Error(`Invalid element at key "${v}": expected a Zod schema`);const b=Xf(e.shape);return{shape:e.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(b)}});Se(t._zod,"propValues",()=>{const f=e.shape,b={};for(const v in f){const g=f[v]._zod;if(g.values){b[v]??(b[v]=new Set);for(const w of g.values)b[v].add(w)}}return b});const n=f=>{const b=new Yh(["shape","payload","ctx"]),v=r.value,g=p=>{const y=Pr(p);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};b.write("const input = payload.value;");const w=Object.create(null);let m=0;for(const p of v.keys)w[p]=`key_${m++}`;b.write("const newResult = {}");for(const p of v.keys)if(v.optionalKeys.has(p)){const y=w[p];b.write(`const ${y} = ${g(p)};`);const R=Pr(p);b.write(`
|
|
11
|
-
if (${y}.issues.length) {
|
|
12
|
-
if (input[${R}] === undefined) {
|
|
13
|
-
if (${R} in input) {
|
|
14
|
-
newResult[${R}] = undefined;
|
|
15
|
-
}
|
|
16
|
-
} else {
|
|
17
|
-
payload.issues = payload.issues.concat(
|
|
18
|
-
${y}.issues.map((iss) => ({
|
|
19
|
-
...iss,
|
|
20
|
-
path: iss.path ? [${R}, ...iss.path] : [${R}],
|
|
21
|
-
}))
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
} else if (${y}.value === undefined) {
|
|
25
|
-
if (${R} in input) newResult[${R}] = undefined;
|
|
26
|
-
} else {
|
|
27
|
-
newResult[${R}] = ${y}.value;
|
|
28
|
-
}
|
|
29
|
-
`)}else{const y=w[p];b.write(`const ${y} = ${g(p)};`),b.write(`
|
|
30
|
-
if (${y}.issues.length) payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
|
|
31
|
-
...iss,
|
|
32
|
-
path: iss.path ? [${Pr(p)}, ...iss.path] : [${Pr(p)}]
|
|
33
|
-
})));`),b.write(`newResult[${Pr(p)}] = ${y}.value`)}b.write("payload.value = newResult;"),b.write("return payload;");const S=b.compile();return(p,y)=>S(f,p,y)};let s;const a=Kn,i=!yc.jitless,c=i&&Yf.value,u=e.catchall;let l;t._zod.parse=(f,b)=>{l??(l=r.value);const v=f.value;if(!a(v))return f.issues.push({expected:"object",code:"invalid_type",input:v,inst:t}),f;const g=[];if(i&&c&&b?.async===!1&&b.jitless!==!0)s||(s=n(e.shape)),f=s(f,b);else{f.value={};const y=l.shape;for(const R of l.keys){const d=y[R],h=d._zod.run({value:v[R],issues:[]},b),_=d._zod.optin==="optional"&&d._zod.optout==="optional";h instanceof Promise?g.push(h.then(E=>_?qc(E,f,R,v):Qn(E,f,R))):_?qc(h,f,R,v):Qn(h,f,R)}}if(!u)return g.length?Promise.all(g).then(()=>f):f;const w=[],m=l.keySet,S=u._zod,p=S.def.type;for(const y of Object.keys(v)){if(m.has(y))continue;if(p==="never"){w.push(y);continue}const R=S.run({value:v[y],issues:[]},b);R instanceof Promise?g.push(R.then(d=>Qn(d,f,y))):Qn(R,f,y)}return w.length&&f.issues.push({code:"unrecognized_keys",keys:w,input:v,inst:t}),g.length?Promise.all(g).then(()=>f):f}});function xc(t,e,r,n){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(a=>Ct(a,n,Tt())))}),e}const Lc=q("$ZodUnion",(t,e)=>{be.init(t,e),Se(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Se(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Se(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),Se(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){const r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>ia(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1;const a=[];for(const i of e.options){const o=i._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)a.push(o),s=!0;else{if(o.issues.length===0)return o;a.push(o)}}return s?Promise.all(a).then(i=>xc(i,r,t,n)):xc(a,r,t,n)}}),Op=q("$ZodDiscriminatedUnion",(t,e)=>{Lc.init(t,e);const r=t._zod.parse;Se(t._zod,"propValues",()=>{const s={};for(const a of e.options){const i=a._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(a)}"`);for(const[o,c]of Object.entries(i)){s[o]||(s[o]=new Set);for(const u of c)s[o].add(u)}}return s});const n=sa(()=>{const s=e.options,a=new Map;for(const i of s){const o=i._zod.propValues[e.discriminator];if(!o||o.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(const c of o){if(a.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);a.set(c,i)}}return a});t._zod.parse=(s,a)=>{const i=s.value;if(!Kn(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),s;const o=n.value.get(i?.[e.discriminator]);return o?o._zod.run(s,a):e.unionFallback?r(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),s)}}),Np=q("$ZodIntersection",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,a=e.left._zod.run({value:s,issues:[]},n),i=e.right._zod.run({value:s,issues:[]},n);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([c,u])=>Dc(r,c,u)):Dc(r,a,i)}});function da(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Jn(t)&&Jn(e)){const r=Object.keys(e),n=Object.keys(t).filter(a=>r.indexOf(a)!==-1),s={...t,...e};for(const a of n){const i=da(t[a],e[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};s[a]=i.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<t.length;n++){const s=t[n],a=e[n],i=da(s,a);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Dc(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ir(t))return t;const n=da(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}const Ap=q("$ZodRecord",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Jn(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;const a=[];if(e.keyType._zod.values){const i=e.keyType._zod.values;r.value={};for(const c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const u=e.valueType._zod.run({value:s[c],issues:[]},n);u instanceof Promise?a.push(u.then(l=>{l.issues.length&&r.issues.push(...Dt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Dt(c,u.issues)),r.value[c]=u.value)}let o;for(const c in s)i.has(c)||(o=o??[],o.push(c));o&&o.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:o})}else{r.value={};for(const i of Reflect.ownKeys(s)){if(i==="__proto__")continue;const o=e.keyType._zod.run({value:i,issues:[]},n);if(o instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(o.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:o.issues.map(u=>Ct(u,n,Tt())),input:i,path:[i],inst:t}),r.value[o.value]=o.value;continue}const c=e.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?a.push(c.then(u=>{u.issues.length&&r.issues.push(...Dt(i,u.issues)),r.value[o.value]=u.value})):(c.issues.length&&r.issues.push(...Dt(i,c.issues)),r.value[o.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),zp=q("$ZodEnum",(t,e)=>{be.init(t,e);const r=vc(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>Qf.has(typeof n)).map(n=>typeof n=="string"?Cr(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{const a=n.value;return t._zod.values.has(a)||n.issues.push({code:"invalid_value",values:r,input:a,inst:t}),n}}),jp=q("$ZodLiteral",(t,e)=>{be.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Cr(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{const s=r.value;return t._zod.values.has(s)||r.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),r}}),Mp=q("$ZodTransform",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>{const s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new Rr;return r.value=s,r}}),qp=q("$ZodOptional",(t,e)=>{be.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Se(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Se(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ia(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),Zp=q("$ZodNullable",(t,e)=>{be.init(t,e),Se(t._zod,"optin",()=>e.innerType._zod.optin),Se(t._zod,"optout",()=>e.innerType._zod.optout),Se(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ia(r.source)}|null)$`):void 0}),Se(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),xp=q("$ZodDefault",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(a=>Uc(a,e)):Uc(s,e)}});function Uc(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const Lp=q("$ZodPrefault",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Dp=q("$ZodNonOptional",(t,e)=>{be.init(t,e),Se(t._zod,"values",()=>{const r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(a=>Vc(a,t)):Vc(s,t)}});function Vc(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const Up=q("$ZodCatch",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(t._zod,"optout",()=>e.innerType._zod.optout),Se(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(a=>(r.value=a.value,a.issues.length&&(r.value=e.catchValue({...r,error:{issues:a.issues.map(i=>Ct(i,n,Tt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(a=>Ct(a,n,Tt()))},input:r.value}),r.issues=[]),r)}}),Vp=q("$ZodPipe",(t,e)=>{be.init(t,e),Se(t._zod,"values",()=>e.in._zod.values),Se(t._zod,"optin",()=>e.in._zod.optin),Se(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{const s=e.in._zod.run(r,n);return s instanceof Promise?s.then(a=>Fc(a,e,n)):Fc(s,e,n)}});function Fc(t,e,r){return Ir(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}const Fp=q("$ZodReadonly",(t,e)=>{be.init(t,e),Se(t._zod,"propValues",()=>e.innerType._zod.propValues),Se(t._zod,"values",()=>e.innerType._zod.values),Se(t._zod,"optin",()=>e.innerType._zod.optin),Se(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{const s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(Hc):Hc(s)}});function Hc(t){return t.value=Object.freeze(t.value),t}const Hp=q("$ZodCustom",(t,e)=>{Je.init(t,e),be.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{const n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(a=>Wc(a,r,n,t));Wc(s,r,n,t)}});function Wc(t,e,r,n){if(!t){const s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(Or(s))}}class Kc{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){const n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){const r=e._zod.parent;if(r){const n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Wp(){return new Kc}const Nr=Wp();function Kp(t,e){return new t({type:"string",...Q(e)})}function Jp(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Q(e)})}function Jc(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Q(e)})}function Bp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Q(e)})}function Gp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Q(e)})}function Yp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Q(e)})}function Qp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Q(e)})}function Bc(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Q(e)})}function Xp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Q(e)})}function em(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Q(e)})}function tm(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Q(e)})}function rm(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Q(e)})}function nm(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Q(e)})}function sm(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Q(e)})}function am(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Q(e)})}function im(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Q(e)})}function om(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Q(e)})}function cm(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Q(e)})}function um(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Q(e)})}function lm(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Q(e)})}function dm(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Q(e)})}function fm(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Q(e)})}function hm(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Q(e)})}function pm(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Q(e)})}function mm(t,e){return new t({type:"string",format:"date",check:"string_format",...Q(e)})}function gm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Q(e)})}function _m(t,e){return new t({type:"string",format:"duration",check:"string_format",...Q(e)})}function ym(t,e){return new t({type:"number",checks:[],...Q(e)})}function vm(t,e){return new t({type:"number",coerce:!0,checks:[],...Q(e)})}function wm(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Q(e)})}function bm(t,e){return new t({type:"boolean",...Q(e)})}function Sm(t,e){return new t({type:"null",...Q(e)})}function $m(t){return new t({type:"any"})}function km(t){return new t({type:"unknown"})}function Em(t,e){return new t({type:"never",...Q(e)})}function Gc(t,e){return new Nc({check:"less_than",...Q(e),value:t,inclusive:!1})}function fa(t,e){return new Nc({check:"less_than",...Q(e),value:t,inclusive:!0})}function Yc(t,e){return new Ac({check:"greater_than",...Q(e),value:t,inclusive:!1})}function ha(t,e){return new Ac({check:"greater_than",...Q(e),value:t,inclusive:!0})}function Qc(t,e){return new xh({check:"multiple_of",...Q(e),value:t})}function Xc(t,e){return new Dh({check:"max_length",...Q(e),maximum:t})}function Xn(t,e){return new Uh({check:"min_length",...Q(e),minimum:t})}function eu(t,e){return new Vh({check:"length_equals",...Q(e),length:t})}function Rm(t,e){return new Fh({check:"string_format",format:"regex",...Q(e),pattern:t})}function Tm(t){return new Hh({check:"string_format",format:"lowercase",...Q(t)})}function Pm(t){return new Wh({check:"string_format",format:"uppercase",...Q(t)})}function Cm(t,e){return new Kh({check:"string_format",format:"includes",...Q(e),includes:t})}function Im(t,e){return new Jh({check:"string_format",format:"starts_with",...Q(e),prefix:t})}function Om(t,e){return new Bh({check:"string_format",format:"ends_with",...Q(e),suffix:t})}function Ar(t){return new Gh({check:"overwrite",tx:t})}function Nm(t){return Ar(e=>e.normalize(t))}function Am(){return Ar(t=>t.trim())}function zm(){return Ar(t=>t.toLowerCase())}function jm(){return Ar(t=>t.toUpperCase())}function Mm(t,e,r){return new t({type:"array",element:e,...Q(r)})}function qm(t,e,r){const n=Q(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Zm(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Q(r)})}class tu{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Nr,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;const s=e._zod.def,a={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const o={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,o);const c=e._zod.toJSONSchema?.();if(c)o.schema=c;else{const f={...r,schemaPath:[...r.schemaPath,e],path:r.path},b=e._zod.parent;if(b)o.ref=b,this.process(b,f),this.seen.get(b).isParent=!0;else{const v=o.schema;switch(s.type){case"string":{const g=v;g.type="string";const{minimum:w,maximum:m,format:S,patterns:p,contentEncoding:y}=e._zod.bag;if(typeof w=="number"&&(g.minLength=w),typeof m=="number"&&(g.maxLength=m),S&&(g.format=a[S]??S,g.format===""&&delete g.format),y&&(g.contentEncoding=y),p&&p.size>0){const R=[...p];R.length===1?g.pattern=R[0].source:R.length>1&&(o.schema.allOf=[...R.map(d=>({...this.target==="draft-7"?{type:"string"}:{},pattern:d.source}))])}break}case"number":{const g=v,{minimum:w,maximum:m,format:S,multipleOf:p,exclusiveMaximum:y,exclusiveMinimum:R}=e._zod.bag;typeof S=="string"&&S.includes("int")?g.type="integer":g.type="number",typeof R=="number"&&(g.exclusiveMinimum=R),typeof w=="number"&&(g.minimum=w,typeof R=="number"&&(R>=w?delete g.minimum:delete g.exclusiveMinimum)),typeof y=="number"&&(g.exclusiveMaximum=y),typeof m=="number"&&(g.maximum=m,typeof y=="number"&&(y<=m?delete g.maximum:delete g.exclusiveMaximum)),typeof p=="number"&&(g.multipleOf=p);break}case"boolean":{const g=v;g.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{v.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{v.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const g=v,{minimum:w,maximum:m}=e._zod.bag;typeof w=="number"&&(g.minItems=w),typeof m=="number"&&(g.maxItems=m),g.type="array",g.items=this.process(s.element,{...f,path:[...f.path,"items"]});break}case"object":{const g=v;g.type="object",g.properties={};const w=s.shape;for(const p in w)g.properties[p]=this.process(w[p],{...f,path:[...f.path,"properties",p]});const m=new Set(Object.keys(w)),S=new Set([...m].filter(p=>{const y=s.shape[p]._zod;return this.io==="input"?y.optin===void 0:y.optout===void 0}));S.size>0&&(g.required=Array.from(S)),s.catchall?._zod.def.type==="never"?g.additionalProperties=!1:s.catchall?s.catchall&&(g.additionalProperties=this.process(s.catchall,{...f,path:[...f.path,"additionalProperties"]})):this.io==="output"&&(g.additionalProperties=!1);break}case"union":{const g=v;g.anyOf=s.options.map((w,m)=>this.process(w,{...f,path:[...f.path,"anyOf",m]}));break}case"intersection":{const g=v,w=this.process(s.left,{...f,path:[...f.path,"allOf",0]}),m=this.process(s.right,{...f,path:[...f.path,"allOf",1]}),S=y=>"allOf"in y&&Object.keys(y).length===1,p=[...S(w)?w.allOf:[w],...S(m)?m.allOf:[m]];g.allOf=p;break}case"tuple":{const g=v;g.type="array";const w=s.items.map((p,y)=>this.process(p,{...f,path:[...f.path,"prefixItems",y]}));if(this.target==="draft-2020-12"?g.prefixItems=w:g.items=w,s.rest){const p=this.process(s.rest,{...f,path:[...f.path,"items"]});this.target==="draft-2020-12"?g.items=p:g.additionalItems=p}s.rest&&(g.items=this.process(s.rest,{...f,path:[...f.path,"items"]}));const{minimum:m,maximum:S}=e._zod.bag;typeof m=="number"&&(g.minItems=m),typeof S=="number"&&(g.maxItems=S);break}case"record":{const g=v;g.type="object",g.propertyNames=this.process(s.keyType,{...f,path:[...f.path,"propertyNames"]}),g.additionalProperties=this.process(s.valueType,{...f,path:[...f.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const g=v,w=vc(s.entries);w.every(m=>typeof m=="number")&&(g.type="number"),w.every(m=>typeof m=="string")&&(g.type="string"),g.enum=w;break}case"literal":{const g=v,w=[];for(const m of s.values)if(m===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");w.push(Number(m))}else w.push(m);if(w.length!==0)if(w.length===1){const m=w[0];g.type=m===null?"null":typeof m,g.const=m}else w.every(m=>typeof m=="number")&&(g.type="number"),w.every(m=>typeof m=="string")&&(g.type="string"),w.every(m=>typeof m=="boolean")&&(g.type="string"),w.every(m=>m===null)&&(g.type="null"),g.enum=w;break}case"file":{const g=v,w={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:S,mime:p}=e._zod.bag;m!==void 0&&(w.minLength=m),S!==void 0&&(w.maxLength=S),p?p.length===1?(w.contentMediaType=p[0],Object.assign(g,w)):g.anyOf=p.map(y=>({...w,contentMediaType:y})):Object.assign(g,w);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const g=this.process(s.innerType,f);v.anyOf=[g,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,f),o.ref=s.innerType;break}case"success":{const g=v;g.type="boolean";break}case"default":{this.process(s.innerType,f),o.ref=s.innerType,v.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,f),o.ref=s.innerType,this.io==="input"&&(v._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,f),o.ref=s.innerType;let g;try{g=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}v.default=g;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const g=v,w=e._zod.pattern;if(!w)throw new Error("Pattern not found in template literal");g.type="string",g.pattern=w.source;break}case"pipe":{const g=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(g,f),o.ref=g;break}case"readonly":{this.process(s.innerType,f),o.ref=s.innerType,v.readOnly=!0;break}case"promise":{this.process(s.innerType,f),o.ref=s.innerType;break}case"optional":{this.process(s.innerType,f),o.ref=s.innerType;break}case"lazy":{const g=e._zod.innerType;this.process(g,f),o.ref=g;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const u=this.metadataRegistry.get(e);return u&&Object.assign(o.schema,u),this.io==="input"&&ze(e)&&(delete o.schema.examples,delete o.schema.default),this.io==="input"&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,this.seen.get(e).schema}emit(e,r){const n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=l=>{const f=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const w=n.external.registry.get(l[0])?.id,m=n.external.uri??(p=>p);if(w)return{ref:m(w)};const S=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=S,{defId:S,ref:`${m("__shared")}#/${f}/${S}`}}if(l[1]===s)return{ref:"#"};const v=`#/${f}/`,g=l[1].schema.id??`__schema${this.counter++}`;return{defId:g,ref:v+g}},i=l=>{if(l[1].schema.$ref)return;const f=l[1],{ref:b,defId:v}=a(l);f.def={...f.schema},v&&(f.defId=v);const g=f.schema;for(const w in g)delete g[w];g.$ref=b};if(n.cycles==="throw")for(const l of this.seen.entries()){const f=l[1];if(f.cycle)throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
|
|
34
|
-
|
|
35
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of this.seen.entries()){const f=l[1];if(e===l[0]){i(l);continue}if(n.external){const v=n.external.registry.get(l[0])?.id;if(e!==l[0]&&v){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(f.cycle){i(l);continue}if(f.count>1&&n.reused==="ref"){i(l);continue}}const o=(l,f)=>{const b=this.seen.get(l),v=b.def??b.schema,g={...v};if(b.ref===null)return;const w=b.ref;if(b.ref=null,w){o(w,f);const m=this.seen.get(w).schema;m.$ref&&f.target==="draft-7"?(v.allOf=v.allOf??[],v.allOf.push(m)):(Object.assign(v,m),Object.assign(v,g))}b.isParent||this.override({zodSchema:l,jsonSchema:v,path:b.path??[]})};for(const l of[...this.seen.entries()].reverse())o(l[0],{target:this.target});const c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){const l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,s.def);const u=n.external?.defs??{};for(const l of this.seen.entries()){const f=l[1];f.def&&f.defId&&(u[f.defId]=f.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}}function xm(t,e){if(t instanceof Kc){const n=new tu(e),s={};for(const o of t._idmap.entries()){const[c,u]=o;n.process(u)}const a={},i={registry:t,uri:e?.uri,defs:s};for(const o of t._idmap.entries()){const[c,u]=o;a[c]=n.emit(u,{...e,external:i})}if(Object.keys(s).length>0){const o=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[o]:s}}return{schemas:a}}const r=new tu(e);return r.process(t),r.emit(t,e)}function ze(t,e){const r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);const s=t._zod.def;switch(s.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return ze(s.element,r);case"object":{for(const a in s.shape)if(ze(s.shape[a],r))return!0;return!1}case"union":{for(const a of s.options)if(ze(a,r))return!0;return!1}case"intersection":return ze(s.left,r)||ze(s.right,r);case"tuple":{for(const a of s.items)if(ze(a,r))return!0;return!!(s.rest&&ze(s.rest,r))}case"record":return ze(s.keyType,r)||ze(s.valueType,r);case"map":return ze(s.keyType,r)||ze(s.valueType,r);case"set":return ze(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return ze(s.innerType,r);case"lazy":return ze(s.getter(),r);case"default":return ze(s.innerType,r);case"prefault":return ze(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return ze(s.in,r)||ze(s.out,r);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}const Lm=q("ZodISODateTime",(t,e)=>{lp.init(t,e),Ce.init(t,e)});function ru(t){return pm(Lm,t)}const Dm=q("ZodISODate",(t,e)=>{dp.init(t,e),Ce.init(t,e)});function Um(t){return mm(Dm,t)}const Vm=q("ZodISOTime",(t,e)=>{fp.init(t,e),Ce.init(t,e)});function Fm(t){return gm(Vm,t)}const Hm=q("ZodISODuration",(t,e)=>{hp.init(t,e),Ce.init(t,e)});function Wm(t){return _m(Hm,t)}const es=q("ZodError",(t,e)=>{Sc.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ch(t,r)},flatten:{value:r=>oh(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},{Parent:Error}),Km=$c(es),Jm=kc(es),Bm=Ec(es),Gm=Rc(es),Te=q("ZodType",(t,e)=>(be.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Pt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Km(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Bm(t,r,n),t.parseAsync=async(r,n)=>Jm(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Gm(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Ug(r,n)),t.superRefine=r=>t.check(Vg(r)),t.overwrite=r=>t.check(Ar(r)),t.optional=()=>Ne(t),t.nullable=()=>hu(t),t.nullish=()=>Ne(hu(t)),t.nonoptional=r=>zg(t,r),t.array=()=>K(t),t.or=r=>Ee([t,r]),t.and=r=>ma(t,r),t.transform=r=>_a(t,du(r)),t.default=r=>Og(t,r),t.prefault=r=>Ag(t,r),t.catch=r=>Mg(t,r),t.pipe=r=>_a(t,r),t.readonly=()=>xg(t),t.describe=r=>{const n=t.clone();return Nr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Nr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Nr.get(t);const n=t.clone();return Nr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),nu=q("_ZodString",(t,e)=>{la.init(t,e),Te.init(t,e);const r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Rm(...n)),t.includes=(...n)=>t.check(Cm(...n)),t.startsWith=(...n)=>t.check(Im(...n)),t.endsWith=(...n)=>t.check(Om(...n)),t.min=(...n)=>t.check(Xn(...n)),t.max=(...n)=>t.check(Xc(...n)),t.length=(...n)=>t.check(eu(...n)),t.nonempty=(...n)=>t.check(Xn(1,...n)),t.lowercase=n=>t.check(Tm(n)),t.uppercase=n=>t.check(Pm(n)),t.trim=()=>t.check(Am()),t.normalize=(...n)=>t.check(Nm(...n)),t.toLowerCase=()=>t.check(zm()),t.toUpperCase=()=>t.check(jm())}),Ym=q("ZodString",(t,e)=>{la.init(t,e),nu.init(t,e),t.email=r=>t.check(Jp(Qm,r)),t.url=r=>t.check(Bc(au,r)),t.jwt=r=>t.check(hm(pg,r)),t.emoji=r=>t.check(Xp(eg,r)),t.guid=r=>t.check(Jc(su,r)),t.uuid=r=>t.check(Bp(ts,r)),t.uuidv4=r=>t.check(Gp(ts,r)),t.uuidv6=r=>t.check(Yp(ts,r)),t.uuidv7=r=>t.check(Qp(ts,r)),t.nanoid=r=>t.check(em(tg,r)),t.guid=r=>t.check(Jc(su,r)),t.cuid=r=>t.check(tm(rg,r)),t.cuid2=r=>t.check(rm(ng,r)),t.ulid=r=>t.check(nm(sg,r)),t.base64=r=>t.check(lm(dg,r)),t.base64url=r=>t.check(dm(fg,r)),t.xid=r=>t.check(sm(ag,r)),t.ksuid=r=>t.check(am(ig,r)),t.ipv4=r=>t.check(im(og,r)),t.ipv6=r=>t.check(om(cg,r)),t.cidrv4=r=>t.check(cm(ug,r)),t.cidrv6=r=>t.check(um(lg,r)),t.e164=r=>t.check(fm(hg,r)),t.datetime=r=>t.check(ru(r)),t.date=r=>t.check(Um(r)),t.time=r=>t.check(Fm(r)),t.duration=r=>t.check(Wm(r))});function T(t){return Kp(Ym,t)}const Ce=q("ZodStringFormat",(t,e)=>{Re.init(t,e),nu.init(t,e)}),Qm=q("ZodEmail",(t,e)=>{tp.init(t,e),Ce.init(t,e)}),su=q("ZodGUID",(t,e)=>{Xh.init(t,e),Ce.init(t,e)}),ts=q("ZodUUID",(t,e)=>{ep.init(t,e),Ce.init(t,e)}),au=q("ZodURL",(t,e)=>{rp.init(t,e),Ce.init(t,e)});function Xm(t){return Bc(au,t)}const eg=q("ZodEmoji",(t,e)=>{np.init(t,e),Ce.init(t,e)}),tg=q("ZodNanoID",(t,e)=>{sp.init(t,e),Ce.init(t,e)}),rg=q("ZodCUID",(t,e)=>{ap.init(t,e),Ce.init(t,e)}),ng=q("ZodCUID2",(t,e)=>{ip.init(t,e),Ce.init(t,e)}),sg=q("ZodULID",(t,e)=>{op.init(t,e),Ce.init(t,e)}),ag=q("ZodXID",(t,e)=>{cp.init(t,e),Ce.init(t,e)}),ig=q("ZodKSUID",(t,e)=>{up.init(t,e),Ce.init(t,e)}),og=q("ZodIPv4",(t,e)=>{pp.init(t,e),Ce.init(t,e)}),cg=q("ZodIPv6",(t,e)=>{mp.init(t,e),Ce.init(t,e)}),ug=q("ZodCIDRv4",(t,e)=>{gp.init(t,e),Ce.init(t,e)}),lg=q("ZodCIDRv6",(t,e)=>{_p.init(t,e),Ce.init(t,e)}),dg=q("ZodBase64",(t,e)=>{yp.init(t,e),Ce.init(t,e)}),fg=q("ZodBase64URL",(t,e)=>{wp.init(t,e),Ce.init(t,e)}),hg=q("ZodE164",(t,e)=>{bp.init(t,e),Ce.init(t,e)}),pg=q("ZodJWT",(t,e)=>{$p.init(t,e),Ce.init(t,e)}),pa=q("ZodNumber",(t,e)=>{jc.init(t,e),Te.init(t,e),t.gt=(n,s)=>t.check(Yc(n,s)),t.gte=(n,s)=>t.check(ha(n,s)),t.min=(n,s)=>t.check(ha(n,s)),t.lt=(n,s)=>t.check(Gc(n,s)),t.lte=(n,s)=>t.check(fa(n,s)),t.max=(n,s)=>t.check(fa(n,s)),t.int=n=>t.check(iu(n)),t.safe=n=>t.check(iu(n)),t.positive=n=>t.check(Yc(0,n)),t.nonnegative=n=>t.check(ha(0,n)),t.negative=n=>t.check(Gc(0,n)),t.nonpositive=n=>t.check(fa(0,n)),t.multipleOf=(n,s)=>t.check(Qc(n,s)),t.step=(n,s)=>t.check(Qc(n,s)),t.finite=()=>t;const r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function ye(t){return ym(pa,t)}const mg=q("ZodNumberFormat",(t,e)=>{kp.init(t,e),pa.init(t,e)});function iu(t){return wm(mg,t)}const gg=q("ZodBoolean",(t,e)=>{Ep.init(t,e),Te.init(t,e)});function ke(t){return bm(gg,t)}const _g=q("ZodNull",(t,e)=>{Rp.init(t,e),Te.init(t,e)});function ou(t){return Sm(_g,t)}const yg=q("ZodAny",(t,e)=>{Tp.init(t,e),Te.init(t,e)});function vg(){return $m(yg)}const wg=q("ZodUnknown",(t,e)=>{Pp.init(t,e),Te.init(t,e)});function Ie(){return km(wg)}const bg=q("ZodNever",(t,e)=>{Cp.init(t,e),Te.init(t,e)});function Sg(t){return Em(bg,t)}const $g=q("ZodArray",(t,e)=>{Ip.init(t,e),Te.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Xn(r,n)),t.nonempty=r=>t.check(Xn(1,r)),t.max=(r,n)=>t.check(Xc(r,n)),t.length=(r,n)=>t.check(eu(r,n)),t.unwrap=()=>t.element});function K(t,e){return Mm($g,t,e)}const cu=q("ZodObject",(t,e)=>{Zc.init(t,e),Te.init(t,e),Se(t,"shape",()=>e.shape),t.keyof=()=>et(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ie()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ie()}),t.strict=()=>t.clone({...t._zod.def,catchall:Sg()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>nh(t,r),t.merge=r=>sh(t,r),t.pick=r=>th(t,r),t.omit=r=>rh(t,r),t.partial=(...r)=>ah(fu,t,r[0]),t.required=(...r)=>ih(pu,t,r[0])});function J(t,e){const r={type:"object",get shape(){return Tr(this,"shape",{...t}),this.shape},...Q(e)};return new cu(r)}function De(t,e){return new cu({type:"object",get shape(){return Tr(this,"shape",{...t}),this.shape},catchall:Ie(),...Q(e)})}const uu=q("ZodUnion",(t,e)=>{Lc.init(t,e),Te.init(t,e),t.options=e.options});function Ee(t,e){return new uu({type:"union",options:t,...Q(e)})}const kg=q("ZodDiscriminatedUnion",(t,e)=>{uu.init(t,e),Op.init(t,e)});function lu(t,e,r){return new kg({type:"union",options:e,discriminator:t,...Q(r)})}const Eg=q("ZodIntersection",(t,e)=>{Np.init(t,e),Te.init(t,e)});function ma(t,e){return new Eg({type:"intersection",left:t,right:e})}const Rg=q("ZodRecord",(t,e)=>{Ap.init(t,e),Te.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Oe(t,e,r){return new Rg({type:"record",keyType:t,valueType:e,...Q(r)})}const ga=q("ZodEnum",(t,e)=>{zp.init(t,e),Te.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);const r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{const a={};for(const i of n)if(r.has(i))a[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ga({...e,checks:[],...Q(s),entries:a})},t.exclude=(n,s)=>{const a={...e.entries};for(const i of n)if(r.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new ga({...e,checks:[],...Q(s),entries:a})}});function et(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ga({type:"enum",entries:r,...Q(e)})}const Tg=q("ZodLiteral",(t,e)=>{jp.init(t,e),Te.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function te(t,e){return new Tg({type:"literal",values:Array.isArray(t)?t:[t],...Q(e)})}const Pg=q("ZodTransform",(t,e)=>{Mp.init(t,e),Te.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=a=>{if(typeof a=="string")r.issues.push(Or(a,r.value,e));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(Or(i))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(a=>(r.value=a,r)):(r.value=s,r)}});function du(t){return new Pg({type:"transform",transform:t})}const fu=q("ZodOptional",(t,e)=>{qp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ne(t){return new fu({type:"optional",innerType:t})}const Cg=q("ZodNullable",(t,e)=>{Zp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function hu(t){return new Cg({type:"nullable",innerType:t})}const Ig=q("ZodDefault",(t,e)=>{xp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Og(t,e){return new Ig({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const Ng=q("ZodPrefault",(t,e)=>{Lp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ag(t,e){return new Ng({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const pu=q("ZodNonOptional",(t,e)=>{Dp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function zg(t,e){return new pu({type:"nonoptional",innerType:t,...Q(e)})}const jg=q("ZodCatch",(t,e)=>{Up.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Mg(t,e){return new jg({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const qg=q("ZodPipe",(t,e)=>{Vp.init(t,e),Te.init(t,e),t.in=e.in,t.out=e.out});function _a(t,e){return new qg({type:"pipe",in:t,out:e})}const Zg=q("ZodReadonly",(t,e)=>{Fp.init(t,e),Te.init(t,e)});function xg(t){return new Zg({type:"readonly",innerType:t})}const mu=q("ZodCustom",(t,e)=>{Hp.init(t,e),Te.init(t,e)});function Lg(t){const e=new Je({check:"custom"});return e._zod.check=t,e}function Dg(t,e){return qm(mu,t??(()=>!0),e)}function Ug(t,e={}){return Zm(mu,t,e)}function Vg(t){const e=Lg(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Or(n,r.value,e._zod.def));else{const s=n;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),s.continue??(s.continue=!e._zod.def.abort),r.issues.push(Or(s))}},t(r.value,r)));return e}function gu(t,e){return _a(du(t),e)}const Fg={custom:"custom"};function Hg(t){return vm(pa,t)}const Ut="2025-11-25",Wg="2025-03-26",ya=[Ut,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],It="io.modelcontextprotocol/related-task",zr="2.0",Ue=Dg(t=>t!==null&&(typeof t=="object"||typeof t=="function")),va=Ee([T(),ye().int()]),wa=T(),Kg=De({ttl:Ee([ye(),ou()]).optional(),pollInterval:ye().optional()}),_u=J({ttl:ye().optional()}),yu=J({taskId:T()}),ba=De({progressToken:va.optional(),[It]:yu.optional()}),tt=J({_meta:ba.optional()}),rr=tt.extend({task:_u.optional()}),vu=t=>rr.safeParse(t).success,Me=J({method:T(),params:tt.loose().optional()}),st=J({_meta:ba.optional()}),rt=J({method:T(),params:st.loose().optional()}),qe=De({_meta:ba.optional()}),jr=Ee([T(),ye().int()]),Sa=J({jsonrpc:te(zr),id:jr,...Me.shape}).strict(),rs=t=>Sa.safeParse(t).success,$a=J({jsonrpc:te(zr),...rt.shape}).strict(),wu=t=>$a.safeParse(t).success,ns=J({jsonrpc:te(zr),id:jr,result:qe}).strict(),Vt=t=>ns.safeParse(t).success,Jg=Vt;$.ErrorCode=void 0,(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})($.ErrorCode||($.ErrorCode={}));const Mr=J({jsonrpc:te(zr),id:jr.optional(),error:J({code:ye().int(),message:T(),data:Ie().optional()})}).strict(),Bg=Mr,ka=t=>Mr.safeParse(t).success,Gg=ka,qr=Ee([Sa,$a,ns,Mr]),Yg=Ee([ns,Mr]),Ot=qe.strict(),bu=st.extend({requestId:jr.optional(),reason:T().optional()}),ss=rt.extend({method:te("notifications/cancelled"),params:bu}),Su=J({src:T(),mimeType:T().optional(),sizes:K(T()).optional(),theme:et(["light","dark"]).optional()}),nr=J({icons:K(Su).optional()}),Ft=J({name:T(),title:T().optional()}),Ea=Ft.extend({...Ft.shape,...nr.shape,version:T(),websiteUrl:T().optional(),description:T().optional()}),Qg=ma(J({applyDefaults:ke().optional()}),Oe(T(),Ie())),Xg=gu(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ma(J({form:Qg.optional(),url:Ue.optional()}),Oe(T(),Ie()).optional())),$u=De({list:Ue.optional(),cancel:Ue.optional(),requests:De({sampling:De({createMessage:Ue.optional()}).optional(),elicitation:De({create:Ue.optional()}).optional()}).optional()}),ku=De({list:Ue.optional(),cancel:Ue.optional(),requests:De({tools:De({call:Ue.optional()}).optional()}).optional()}),Eu=J({experimental:Oe(T(),Ue).optional(),sampling:J({context:Ue.optional(),tools:Ue.optional()}).optional(),elicitation:Xg.optional(),roots:J({listChanged:ke().optional()}).optional(),tasks:$u.optional()}),Ru=tt.extend({protocolVersion:T(),capabilities:Eu,clientInfo:Ea}),as=Me.extend({method:te("initialize"),params:Ru}),e_=t=>as.safeParse(t).success,Tu=J({experimental:Oe(T(),Ue).optional(),logging:Ue.optional(),completions:Ue.optional(),prompts:J({listChanged:ke().optional()}).optional(),resources:J({subscribe:ke().optional(),listChanged:ke().optional()}).optional(),tools:J({listChanged:ke().optional()}).optional(),tasks:ku.optional()}),Ra=qe.extend({protocolVersion:T(),capabilities:Tu,serverInfo:Ea,instructions:T().optional()}),is=rt.extend({method:te("notifications/initialized"),params:st.optional()}),Pu=t=>is.safeParse(t).success,os=Me.extend({method:te("ping"),params:tt.optional()}),Cu=J({progress:ye(),total:Ne(ye()),message:Ne(T())}),Iu=J({...st.shape,...Cu.shape,progressToken:va}),cs=rt.extend({method:te("notifications/progress"),params:Iu}),Ou=tt.extend({cursor:wa.optional()}),sr=Me.extend({params:Ou.optional()}),ar=qe.extend({nextCursor:wa.optional()}),Nu=et(["working","input_required","completed","failed","cancelled"]),ir=J({taskId:T(),status:Nu,ttl:Ee([ye(),ou()]),createdAt:T(),lastUpdatedAt:T(),pollInterval:Ne(ye()),statusMessage:Ne(T())}),Ht=qe.extend({task:ir}),Au=st.merge(ir),Zr=rt.extend({method:te("notifications/tasks/status"),params:Au}),us=Me.extend({method:te("tasks/get"),params:tt.extend({taskId:T()})}),ls=qe.merge(ir),ds=Me.extend({method:te("tasks/result"),params:tt.extend({taskId:T()})}),t_=qe.loose(),fs=sr.extend({method:te("tasks/list")}),hs=ar.extend({tasks:K(ir)}),ps=Me.extend({method:te("tasks/cancel"),params:tt.extend({taskId:T()})}),zu=qe.merge(ir),Ta=J({uri:T(),mimeType:Ne(T()),_meta:Oe(T(),Ie()).optional()}),Pa=Ta.extend({text:T()}),Ca=T().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ia=Ta.extend({blob:Ca}),or=et(["user","assistant"]),Wt=J({audience:K(or).optional(),priority:ye().min(0).max(1).optional(),lastModified:ru({offset:!0}).optional()}),Oa=J({...Ft.shape,...nr.shape,uri:T(),description:Ne(T()),mimeType:Ne(T()),annotations:Wt.optional(),_meta:Ne(De({}))}),ju=J({...Ft.shape,...nr.shape,uriTemplate:T(),description:Ne(T()),mimeType:Ne(T()),annotations:Wt.optional(),_meta:Ne(De({}))}),ms=sr.extend({method:te("resources/list")}),Na=ar.extend({resources:K(Oa)}),gs=sr.extend({method:te("resources/templates/list")}),Aa=ar.extend({resourceTemplates:K(ju)}),_s=tt.extend({uri:T()}),Mu=_s,ys=Me.extend({method:te("resources/read"),params:Mu}),za=qe.extend({contents:K(Ee([Pa,Ia]))}),ja=rt.extend({method:te("notifications/resources/list_changed"),params:st.optional()}),qu=_s,Zu=Me.extend({method:te("resources/subscribe"),params:qu}),xu=_s,Lu=Me.extend({method:te("resources/unsubscribe"),params:xu}),Du=st.extend({uri:T()}),Uu=rt.extend({method:te("notifications/resources/updated"),params:Du}),Vu=J({name:T(),description:Ne(T()),required:Ne(ke())}),Fu=J({...Ft.shape,...nr.shape,description:Ne(T()),arguments:Ne(K(Vu)),_meta:Ne(De({}))}),vs=sr.extend({method:te("prompts/list")}),Ma=ar.extend({prompts:K(Fu)}),Hu=tt.extend({name:T(),arguments:Oe(T(),T()).optional()}),ws=Me.extend({method:te("prompts/get"),params:Hu}),bs=J({type:te("text"),text:T(),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),Ss=J({type:te("image"),data:Ca,mimeType:T(),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),$s=J({type:te("audio"),data:Ca,mimeType:T(),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),Wu=J({type:te("tool_use"),name:T(),id:T(),input:Oe(T(),Ie()),_meta:Oe(T(),Ie()).optional()}),Ku=J({type:te("resource"),resource:Ee([Pa,Ia]),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),Ju=Oa.extend({type:te("resource_link")}),ks=Ee([bs,Ss,$s,Ju,Ku]),Bu=J({role:or,content:ks}),qa=qe.extend({description:T().optional(),messages:K(Bu)}),Za=rt.extend({method:te("notifications/prompts/list_changed"),params:st.optional()}),Gu=J({title:T().optional(),readOnlyHint:ke().optional(),destructiveHint:ke().optional(),idempotentHint:ke().optional(),openWorldHint:ke().optional()}),Yu=J({taskSupport:et(["required","optional","forbidden"]).optional()}),xa=J({...Ft.shape,...nr.shape,description:T().optional(),inputSchema:J({type:te("object"),properties:Oe(T(),Ue).optional(),required:K(T()).optional()}).catchall(Ie()),outputSchema:J({type:te("object"),properties:Oe(T(),Ue).optional(),required:K(T()).optional()}).catchall(Ie()).optional(),annotations:Gu.optional(),execution:Yu.optional(),_meta:Oe(T(),Ie()).optional()}),Es=sr.extend({method:te("tools/list")}),La=ar.extend({tools:K(xa)}),cr=qe.extend({content:K(ks).default([]),structuredContent:Oe(T(),Ie()).optional(),isError:ke().optional()}),r_=cr.or(qe.extend({toolResult:Ie()})),Qu=rr.extend({name:T(),arguments:Oe(T(),Ie()).optional()}),xr=Me.extend({method:te("tools/call"),params:Qu}),Da=rt.extend({method:te("notifications/tools/list_changed"),params:st.optional()}),Xu=J({autoRefresh:ke().default(!0),debounceMs:ye().int().nonnegative().default(300)}),Lr=et(["debug","info","notice","warning","error","critical","alert","emergency"]),el=tt.extend({level:Lr}),Ua=Me.extend({method:te("logging/setLevel"),params:el}),tl=st.extend({level:Lr,logger:T().optional(),data:Ie()}),rl=rt.extend({method:te("notifications/message"),params:tl}),nl=J({name:T().optional()}),sl=J({hints:K(nl).optional(),costPriority:ye().min(0).max(1).optional(),speedPriority:ye().min(0).max(1).optional(),intelligencePriority:ye().min(0).max(1).optional()}),al=J({mode:et(["auto","required","none"]).optional()}),il=J({type:te("tool_result"),toolUseId:T().describe("The unique identifier for the corresponding tool call."),content:K(ks).default([]),structuredContent:J({}).loose().optional(),isError:ke().optional(),_meta:Oe(T(),Ie()).optional()}),ol=lu("type",[bs,Ss,$s]),Dr=lu("type",[bs,Ss,$s,Wu,il]),cl=J({role:or,content:Ee([Dr,K(Dr)]),_meta:Oe(T(),Ie()).optional()}),ul=rr.extend({messages:K(cl),modelPreferences:sl.optional(),systemPrompt:T().optional(),includeContext:et(["none","thisServer","allServers"]).optional(),temperature:ye().optional(),maxTokens:ye().int(),stopSequences:K(T()).optional(),metadata:Ue.optional(),tools:K(xa).optional(),toolChoice:al.optional()}),Va=Me.extend({method:te("sampling/createMessage"),params:ul}),Rs=qe.extend({model:T(),stopReason:Ne(et(["endTurn","stopSequence","maxTokens"]).or(T())),role:or,content:ol}),Ts=qe.extend({model:T(),stopReason:Ne(et(["endTurn","stopSequence","maxTokens","toolUse"]).or(T())),role:or,content:Ee([Dr,K(Dr)])}),ll=J({type:te("boolean"),title:T().optional(),description:T().optional(),default:ke().optional()}),dl=J({type:te("string"),title:T().optional(),description:T().optional(),minLength:ye().optional(),maxLength:ye().optional(),format:et(["email","uri","date","date-time"]).optional(),default:T().optional()}),fl=J({type:et(["number","integer"]),title:T().optional(),description:T().optional(),minimum:ye().optional(),maximum:ye().optional(),default:ye().optional()}),hl=J({type:te("string"),title:T().optional(),description:T().optional(),enum:K(T()),default:T().optional()}),pl=J({type:te("string"),title:T().optional(),description:T().optional(),oneOf:K(J({const:T(),title:T()})),default:T().optional()}),ml=J({type:te("string"),title:T().optional(),description:T().optional(),enum:K(T()),enumNames:K(T()).optional(),default:T().optional()}),gl=Ee([hl,pl]),_l=J({type:te("array"),title:T().optional(),description:T().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:J({type:te("string"),enum:K(T())}),default:K(T()).optional()}),yl=J({type:te("array"),title:T().optional(),description:T().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:J({anyOf:K(J({const:T(),title:T()}))}),default:K(T()).optional()}),vl=Ee([_l,yl]),wl=Ee([ml,gl,vl]),bl=Ee([wl,ll,dl,fl]),Sl=rr.extend({mode:te("form").optional(),message:T(),requestedSchema:J({type:te("object"),properties:Oe(T(),bl),required:K(T()).optional()})}),$l=rr.extend({mode:te("url"),message:T(),elicitationId:T(),url:T().url()}),kl=Ee([Sl,$l]),Fa=Me.extend({method:te("elicitation/create"),params:kl}),El=st.extend({elicitationId:T()}),Rl=rt.extend({method:te("notifications/elicitation/complete"),params:El}),Ur=qe.extend({action:et(["accept","decline","cancel"]),content:gu(t=>t===null?void 0:t,Oe(T(),Ee([T(),ye(),ke(),K(T())])).optional())}),Ha=J({type:te("ref/resource"),uri:T()}),n_=Ha,Tl=J({type:te("ref/prompt"),name:T()}),Pl=tt.extend({ref:Ee([Tl,Ha]),argument:J({name:T(),value:T()}),context:J({arguments:Oe(T(),T()).optional()}).optional()}),Ps=Me.extend({method:te("completion/complete"),params:Pl});function Cl(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Il(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}const Wa=qe.extend({completion:De({values:K(T()).max(100),total:Ne(ye().int()),hasMore:Ne(ke())})}),Ol=J({uri:T().startsWith("file://"),name:T().optional(),_meta:Oe(T(),Ie()).optional()}),Nl=Me.extend({method:te("roots/list"),params:tt.optional()}),Ka=qe.extend({roots:K(Ol)}),Al=rt.extend({method:te("notifications/roots/list_changed"),params:st.optional()}),s_=Ee([os,as,Ps,Ua,ws,vs,ms,gs,ys,Zu,Lu,xr,Es,us,ds,fs,ps]),a_=Ee([ss,cs,is,Al,Zr]),i_=Ee([Ot,Rs,Ts,Ur,Ka,ls,hs,Ht]),o_=Ee([os,Va,Fa,Nl,us,ds,fs,ps]),c_=Ee([ss,cs,rl,Uu,ja,Da,Za,Zr,Rl]),u_=Ee([Ot,Ra,Wa,qa,Ma,Na,Aa,za,cr,La,ls,hs,Ht]);class B extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===$.ErrorCode.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new zl(s.elicitations,r)}return new B(e,r,n)}}class zl extends B{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super($.ErrorCode.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}const jl=1e6,Ja=1e6,Ml=1e4,l_=1e6;class bt{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){bt.validateLength(e,jl,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){const r=[];let n="",s=0,a=0;for(;s<e.length;)if(e[s]==="{"){n&&(r.push(n),n="");const i=e.indexOf("}",s);if(i===-1)throw new Error("Unclosed template expression");if(a++,a>Ml)throw new Error(`Template contains too many expressions (max ${Ml})`);const o=e.slice(s+1,i),c=this.getOperator(o),u=o.includes("*"),l=this.getNames(o),f=l[0];for(const b of l)bt.validateLength(b,Ja,"Variable name");r.push({name:f,operator:c,names:l,exploded:u}),s=i+1}else n+=e[s],s++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){const r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return bt.validateLength(e,Ja,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){const i=e.names.map(c=>{const u=r[c];if(u===void 0)return"";const l=Array.isArray(u)?u.map(f=>this.encodeValue(f,e.operator)).join(","):this.encodeValue(u.toString(),e.operator);return`${c}=${l}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){const i=e.names.map(o=>r[o]).filter(o=>o!==void 0);return i.length===0?"":i.map(o=>Array.isArray(o)?o[0]:o).join(",")}const n=r[e.name];if(n===void 0)return"";const a=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return a.join(",");case"+":return a.join(",");case"#":return"#"+a.join(",");case".":return"."+a.join(".");case"/":return"/"+a.join("/");default:return a.join(",")}}expand(e){let r="",n=!1;for(const s of this.parts){if(typeof s=="string"){r+=s;continue}const a=this.expandPart(s,e);a&&((s.operator==="?"||s.operator==="&")&&n?r+=a.replace("?","&"):r+=a,(s.operator==="?"||s.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){const r=[];for(const a of e.names)bt.validateLength(a,Ja,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let a=0;a<e.names.length;a++){const i=e.names[a],o=a===0?"\\"+e.operator:"&";r.push({pattern:o+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n;const s=e.name;switch(e.operator){case"":n=e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:s}),r}match(e){bt.validateLength(e,jl,"URI");let r="^";const n=[];for(const o of this.parts)if(typeof o=="string")r+=this.escapeRegExp(o);else{const c=this.partToRegExp(o);for(const{pattern:u,name:l}of c)r+=u,n.push({name:l,exploded:o.exploded})}r+="$",bt.validateLength(r,l_,"Generated regex pattern");const s=new RegExp(r),a=e.match(s);if(!a)return null;const i={};for(let o=0;o<n.length;o++){const{name:c,exploded:u}=n[o],l=a[o+1],f=c.replace("*","");u&&l.includes(",")?i[f]=l.split(","):i[f]=l}return i}}const Cs=Symbol.for("mcp.completable");function d_(t,e){return Object.defineProperty(t,Cs,{value:{complete:e},enumerable:!1,writable:!1,configurable:!1}),t}function Ba(t){return!!t&&typeof t=="object"&&Cs in t}function ql(t){return t[Cs]?.complete}function f_(t){return t}$.McpZodTypeKind=void 0,(function(t){t.Completable="McpCompletable"})($.McpZodTypeKind||($.McpZodTypeKind={}));function h_(t){return t.title!==void 0&&t.title!==""?t.title:"annotations"in t&&t.annotations?.title?t.annotations.title:t.name}var pe;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},t.getValidEnumValues=s=>{const a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(const i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(pe||(pe={}));var Zl;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Zl||(Zl={}));const Y=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nt=t=>{switch(typeof t){case"undefined":return Y.undefined;case"string":return Y.string;case"number":return Number.isNaN(t)?Y.nan:Y.number;case"boolean":return Y.boolean;case"function":return Y.function;case"bigint":return Y.bigint;case"symbol":return Y.symbol;case"object":return Array.isArray(t)?Y.array:t===null?Y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Y.promise:typeof Map<"u"&&t instanceof Map?Y.map:typeof Set<"u"&&t instanceof Set?Y.set:typeof Date<"u"&&t instanceof Date?Y.date:Y.object;default:return Y.unknown}},U=pe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class St extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof St))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];r[a]=r[a]||[],r[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}St.create=t=>new St(t);const Ga=(t,e)=>{let r;switch(t.code){case U.invalid_type:t.received===Y.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case U.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,pe.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:r=`Unrecognized key(s) in object: ${pe.joinValues(t.keys,", ")}`;break;case U.invalid_union:r="Invalid input";break;case U.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${pe.joinValues(t.options)}`;break;case U.invalid_enum_value:r=`Invalid enum value. Expected ${pe.joinValues(t.options)}, received '${t.received}'`;break;case U.invalid_arguments:r="Invalid function arguments";break;case U.invalid_return_type:r="Invalid function return type";break;case U.invalid_date:r="Invalid date";break;case U.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:pe.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case U.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case U.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case U.custom:r="Invalid input";break;case U.invalid_intersection_types:r="Intersection results could not be merged";break;case U.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case U.not_finite:r="Number must be finite";break;default:r=e.defaultError,pe.assertNever(t)}return{message:r}};let p_=Ga;function m_(){return p_}const g_=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function G(t,e){const r=m_(),n=g_({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ga?void 0:Ga].filter(s=>!!s)});t.common.issues.push(n)}class nt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const s of r){if(s.status==="aborted")return se;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const s of r){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return nt.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return se;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const se=Object.freeze({status:"aborted"}),Vr=t=>({status:"dirty",value:t}),at=t=>({status:"valid",value:t}),xl=t=>t.status==="aborted",Ll=t=>t.status==="dirty",ur=t=>t.status==="valid",Is=t=>typeof Promise<"u"&&t instanceof Promise;var X;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(X||(X={}));class At{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Dl=(t,e)=>{if(ur(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new St(t.common.issues);return this._error=r,this._error}}};function ce(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}class he{get description(){return this._def.description}_getType(e){return Nt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Nt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nt,ctx:{common:e.parent.common,data:e.data,parsedType:Nt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Is(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nt(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Dl(n,s)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nt(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:r});return ur(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>ur(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nt(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Is(s)?s:Promise.resolve(s));return Dl(n,a)}refine(e,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:U.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new fr({schema:this,typeName:V.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return $t.create(this,this._def)}nullable(){return hr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _t.create(this)}promise(){return zs.create(this,this._def)}or(e){return Ns.create([this,e],this._def)}and(e){return As.create(this,e,this._def)}transform(e){return new fr({...ce(this._def),schema:this,typeName:V.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Xa({...ce(this._def),innerType:this,defaultValue:r,typeName:V.ZodDefault})}brand(){return new x_({typeName:V.ZodBranded,type:this,...ce(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new ei({...ce(this._def),innerType:this,catchValue:r,typeName:V.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ti.create(this,e)}readonly(){return ri.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const __=/^c[^\s-]{8,}$/i,y_=/^[0-9a-z]+$/,v_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,w_=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,b_=/^[a-z0-9_-]{21}$/i,S_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$_=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,k_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,E_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ya;const R_=/^(?:(?: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])$/,T_=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,P_=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,C_=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,I_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,O_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ul="((\\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])))",N_=new RegExp(`^${Ul}$`);function Vl(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function A_(t){return new RegExp(`^${Vl(t)}$`)}function z_(t){let e=`${Ul}T${Vl(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function j_(t,e){return!!((e==="v4"||!e)&&R_.test(t)||(e==="v6"||!e)&&P_.test(t))}function M_(t,e){if(!S_.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function q_(t,e){return!!((e==="v4"||!e)&&T_.test(t)||(e==="v6"||!e)&&C_.test(t))}class Kt extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Y.string){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_type,expected:Y.string,received:a.parsedType}),se}const n=new nt;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),G(s,{code:U.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),G(s,{code:U.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?G(s,{code:U.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&G(s,{code:U.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")k_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"email",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ya||(Ya=new RegExp(E_,"u")),Ya.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"emoji",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")w_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"uuid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")b_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"nanoid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")__.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"cuid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")y_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"cuid2",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")v_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"ulid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),G(s,{validation:"url",code:U.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"regex",code:U.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?z_(a).test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?N_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?A_(a).test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?$_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"duration",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?j_(e.data,a.version)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"ip",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?M_(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"jwt",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?q_(e.data,a.version)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"cidr",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?I_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"base64",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?O_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"base64url",code:U.invalid_string,message:a.message}),n.dirty()):pe.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:U.invalid_string,...X.errToObj(n)})}_addCheck(e){return new Kt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...X.errToObj(e)})}url(e){return this._addCheck({kind:"url",...X.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...X.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...X.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...X.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...X.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...X.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...X.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...X.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...X.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...X.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...X.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...X.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...X.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...X.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...X.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...X.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...X.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...X.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...X.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...X.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...X.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...X.errToObj(r)})}nonempty(e){return this.min(1,X.errToObj(e))}trim(){return new Kt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Kt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Kt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Kt.create=t=>new Kt({checks:[],typeName:V.ZodString,coerce:t?.coerce??!1,...ce(t)});function Z_(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}class Fr extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Y.number){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_type,expected:Y.number,received:a.parsedType}),se}let n;const s=new nt;for(const a of this._def.checks)a.kind==="int"?pe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:U.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),G(n,{code:U.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),G(n,{code:U.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Z_(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),G(n,{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:U.not_finite,message:a.message}),s.dirty()):pe.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,X.toString(r))}gt(e,r){return this.setLimit("min",e,!1,X.toString(r))}lte(e,r){return this.setLimit("max",e,!0,X.toString(r))}lt(e,r){return this.setLimit("max",e,!1,X.toString(r))}setLimit(e,r,n,s){return new Fr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Fr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:X.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:X.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:X.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:X.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:X.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:X.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&pe.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Fr.create=t=>new Fr({checks:[],typeName:V.ZodNumber,coerce:t?.coerce||!1,...ce(t)});class Hr extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Y.bigint)return this._getInvalidInput(e);let n;const s=new nt;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),G(n,{code:U.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),G(n,{code:U.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),G(n,{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):pe.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return G(r,{code:U.invalid_type,expected:Y.bigint,received:r.parsedType}),se}gte(e,r){return this.setLimit("min",e,!0,X.toString(r))}gt(e,r){return this.setLimit("min",e,!1,X.toString(r))}lte(e,r){return this.setLimit("max",e,!0,X.toString(r))}lt(e,r){return this.setLimit("max",e,!1,X.toString(r))}setLimit(e,r,n,s){return new Hr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Hr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:X.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:X.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:X.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:X.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:X.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Hr.create=t=>new Hr({checks:[],typeName:V.ZodBigInt,coerce:t?.coerce??!1,...ce(t)});class Fl extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.boolean,received:n.parsedType}),se}return at(e.data)}}Fl.create=t=>new Fl({typeName:V.ZodBoolean,coerce:t?.coerce||!1,...ce(t)});class Os extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Y.date){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_type,expected:Y.date,received:a.parsedType}),se}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_date}),se}const n=new nt;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),G(s,{code:U.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),G(s,{code:U.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):pe.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Os({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:X.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:X.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Os.create=t=>new Os({checks:[],coerce:t?.coerce||!1,typeName:V.ZodDate,...ce(t)});class Hl extends he{_parse(e){if(this._getType(e)!==Y.symbol){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.symbol,received:n.parsedType}),se}return at(e.data)}}Hl.create=t=>new Hl({typeName:V.ZodSymbol,...ce(t)});class Wl extends he{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.undefined,received:n.parsedType}),se}return at(e.data)}}Wl.create=t=>new Wl({typeName:V.ZodUndefined,...ce(t)});class Kl extends he{_parse(e){if(this._getType(e)!==Y.null){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.null,received:n.parsedType}),se}return at(e.data)}}Kl.create=t=>new Kl({typeName:V.ZodNull,...ce(t)});class Jl extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return at(e.data)}}Jl.create=t=>new Jl({typeName:V.ZodAny,...ce(t)});class Bl extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return at(e.data)}}Bl.create=t=>new Bl({typeName:V.ZodUnknown,...ce(t)});class zt extends he{_parse(e){const r=this._getOrReturnCtx(e);return G(r,{code:U.invalid_type,expected:Y.never,received:r.parsedType}),se}}zt.create=t=>new zt({typeName:V.ZodNever,...ce(t)});class Gl extends he{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.void,received:n.parsedType}),se}return at(e.data)}}Gl.create=t=>new Gl({typeName:V.ZodVoid,...ce(t)});class _t extends he{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==Y.array)return G(r,{code:U.invalid_type,expected:Y.array,received:r.parsedType}),se;if(s.exactLength!==null){const i=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(i||o)&&(G(r,{code:i?U.too_big:U.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(G(r,{code:U.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(G(r,{code:U.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>s.type._parseAsync(new At(r,i,r.path,o)))).then(i=>nt.mergeArray(n,i));const a=[...r.data].map((i,o)=>s.type._parseSync(new At(r,i,r.path,o)));return nt.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new _t({...this._def,minLength:{value:e,message:X.toString(r)}})}max(e,r){return new _t({...this._def,maxLength:{value:e,message:X.toString(r)}})}length(e,r){return new _t({...this._def,exactLength:{value:e,message:X.toString(r)}})}nonempty(e){return this.min(1,e)}}_t.create=(t,e)=>new _t({type:t,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...ce(e)});function lr(t){if(t instanceof Ae){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=$t.create(lr(n))}return new Ae({...t._def,shape:()=>e})}else return t instanceof _t?new _t({...t._def,type:lr(t.element)}):t instanceof $t?$t.create(lr(t.unwrap())):t instanceof hr?hr.create(lr(t.unwrap())):t instanceof Jt?Jt.create(t.items.map(e=>lr(e))):t}class Ae extends he{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=pe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Y.object){const u=this._getOrReturnCtx(e);return G(u,{code:U.invalid_type,expected:Y.object,received:u.parsedType}),se}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof zt&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const l=a[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new At(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof zt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(G(s,{code:U.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of o){const f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new At(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const f=await l.key,b=await l.value;u.push({key:f,value:b,alwaysSet:l.alwaysSet})}return u}).then(u=>nt.mergeObjectSync(n,u)):nt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return X.errToObj,new Ae({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{const s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:X.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Ae({...this._def,unknownKeys:"strip"})}passthrough(){return new Ae({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ae({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ae({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:V.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Ae({...this._def,catchall:e})}pick(e){const r={};for(const n of pe.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Ae({...this._def,shape:()=>r})}omit(e){const r={};for(const n of pe.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Ae({...this._def,shape:()=>r})}deepPartial(){return lr(this)}partial(e){const r={};for(const n of pe.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new Ae({...this._def,shape:()=>r})}required(e){const r={};for(const n of pe.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof $t;)a=a._def.innerType;r[n]=a}return new Ae({...this._def,shape:()=>r})}keyof(){return ed(pe.objectKeys(this.shape))}}Ae.create=(t,e)=>new Ae({shape:()=>t,unknownKeys:"strip",catchall:zt.create(),typeName:V.ZodObject,...ce(e)}),Ae.strictCreate=(t,e)=>new Ae({shape:()=>t,unknownKeys:"strict",catchall:zt.create(),typeName:V.ZodObject,...ce(e)}),Ae.lazycreate=(t,e)=>new Ae({shape:t,unknownKeys:"strip",catchall:zt.create(),typeName:V.ZodObject,...ce(e)});class Ns extends he{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new St(o.ctx.common.issues));return G(r,{code:U.invalid_union,unionErrors:i}),se}if(r.common.async)return Promise.all(n.map(async a=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new St(c));return G(r,{code:U.invalid_union,unionErrors:o}),se}}get options(){return this._def.options}}Ns.create=(t,e)=>new Ns({options:t,typeName:V.ZodUnion,...ce(e)});function Qa(t,e){const r=Nt(t),n=Nt(e);if(t===e)return{valid:!0,data:t};if(r===Y.object&&n===Y.object){const s=pe.objectKeys(e),a=pe.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(const o of a){const c=Qa(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===Y.array&&n===Y.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],c=Qa(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===Y.date&&n===Y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class As extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(xl(a)||xl(i))return se;const o=Qa(a.value,i.value);return o.valid?((Ll(a)||Ll(i))&&r.dirty(),{status:r.value,value:o.data}):(G(n,{code:U.invalid_intersection_types}),se)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}As.create=(t,e,r)=>new As({left:t,right:e,typeName:V.ZodIntersection,...ce(r)});class Jt extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.array)return G(n,{code:U.invalid_type,expected:Y.array,received:n.parsedType}),se;if(n.data.length<this._def.items.length)return G(n,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),se;!this._def.rest&&n.data.length>this._def.items.length&&(G(n,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new At(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>nt.mergeArray(r,i)):nt.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Jt({...this._def,rest:e})}}Jt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Jt({items:t,typeName:V.ZodTuple,rest:null,...ce(e)})};class Yl extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.map)return G(n,{code:U.invalid_type,expected:Y.map,received:n.parsedType}),se;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new At(n,o,n.path,[u,"key"])),value:a._parse(new At(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return se;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),o.set(u.value,l.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return se;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),o.set(u.value,l.value)}return{status:r.value,value:o}}}}Yl.create=(t,e,r)=>new Yl({valueType:e,keyType:t,typeName:V.ZodMap,...ce(r)});class Wr extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.set)return G(n,{code:U.invalid_type,expected:Y.set,received:n.parsedType}),se;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(G(n,{code:U.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(G(n,{code:U.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const l of c){if(l.status==="aborted")return se;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}const o=[...n.data.values()].map((c,u)=>a._parse(new At(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new Wr({...this._def,minSize:{value:e,message:X.toString(r)}})}max(e,r){return new Wr({...this._def,maxSize:{value:e,message:X.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Wr.create=(t,e)=>new Wr({valueType:t,minSize:null,maxSize:null,typeName:V.ZodSet,...ce(e)});class Ql extends he{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Ql.create=(t,e)=>new Ql({getter:t,typeName:V.ZodLazy,...ce(e)});class Xl extends he{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return G(r,{received:r.data,code:U.invalid_literal,expected:this._def.value}),se}return{status:"valid",value:e.data}}get value(){return this._def.value}}Xl.create=(t,e)=>new Xl({value:t,typeName:V.ZodLiteral,...ce(e)});function ed(t,e){return new dr({values:t,typeName:V.ZodEnum,...ce(e)})}class dr extends he{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return G(r,{expected:pe.joinValues(n),received:r.parsedType,code:U.invalid_type}),se}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return G(r,{received:r.data,code:U.invalid_enum_value,options:n}),se}return at(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return dr.create(e,{...this._def,...r})}exclude(e,r=this._def){return dr.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}dr.create=ed;class td extends he{_parse(e){const r=pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Y.string&&n.parsedType!==Y.number){const s=pe.objectValues(r);return G(n,{expected:pe.joinValues(s),received:n.parsedType,code:U.invalid_type}),se}if(this._cache||(this._cache=new Set(pe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=pe.objectValues(r);return G(n,{received:n.data,code:U.invalid_enum_value,options:s}),se}return at(e.data)}get enum(){return this._def.values}}td.create=(t,e)=>new td({values:t,typeName:V.ZodNativeEnum,...ce(e)});class zs extends he{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Y.promise&&r.common.async===!1)return G(r,{code:U.invalid_type,expected:Y.promise,received:r.parsedType}),se;const n=r.parsedType===Y.promise?r.data:Promise.resolve(r.data);return at(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}zs.create=(t,e)=>new zs({type:t,typeName:V.ZodPromise,...ce(e)});class fr extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{G(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return se;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?se:c.status==="dirty"||r.value==="dirty"?Vr(c.value):c});{if(r.value==="aborted")return se;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?se:o.status==="dirty"||r.value==="dirty"?Vr(o.value):o}}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?se:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?se:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ur(i))return se;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>ur(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):se);pe.assertNever(s)}}fr.create=(t,e,r)=>new fr({schema:t,typeName:V.ZodEffects,effect:e,...ce(r)}),fr.createWithPreprocess=(t,e,r)=>new fr({schema:e,effect:{type:"preprocess",transform:t},typeName:V.ZodEffects,...ce(r)});class $t extends he{_parse(e){return this._getType(e)===Y.undefined?at(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$t.create=(t,e)=>new $t({innerType:t,typeName:V.ZodOptional,...ce(e)});class hr extends he{_parse(e){return this._getType(e)===Y.null?at(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}hr.create=(t,e)=>new hr({innerType:t,typeName:V.ZodNullable,...ce(e)});class Xa extends he{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===Y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Xa.create=(t,e)=>new Xa({innerType:t,typeName:V.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ce(e)});class ei extends he{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Is(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ei.create=(t,e)=>new ei({innerType:t,typeName:V.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ce(e)});class rd extends he{_parse(e){if(this._getType(e)!==Y.nan){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.nan,received:n.parsedType}),se}return{status:"valid",value:e.data}}}rd.create=t=>new rd({typeName:V.ZodNaN,...ce(t)});class x_ extends he{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class ti extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?se:a.status==="dirty"?(r.dirty(),Vr(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?se:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new ti({in:e,out:r,typeName:V.ZodPipeline})}}class ri extends he{_parse(e){const r=this._def.innerType._parse(e),n=s=>(ur(s)&&(s.value=Object.freeze(s.value)),s);return Is(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}ri.create=(t,e)=>new ri({innerType:t,typeName:V.ZodReadonly,...ce(e)});var V;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(V||(V={})),zt.create,_t.create;const L_=Ae.create;Ns.create,As.create,Jt.create,dr.create,zs.create,$t.create,hr.create;const D_=q("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");be.init(t,e),t.def=e,t.parse=(r,n)=>uh(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>ca(t,r,n),t.parseAsync=async(r,n)=>lh(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>ua(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>Pt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))}),U_=q("ZodMiniObject",(t,e)=>{Zc.init(t,e),D_.init(t,e),Se(t,"shape",()=>e.shape)});function nd(t,e){const r={type:"object",get shape(){return Tr(this,"shape",{...t}),this.shape},...Q(e)};return new U_(r)}function lt(t){return!!t._zod}function pr(t){const e=Object.values(t);if(e.length===0)return nd({});const r=e.every(lt),n=e.every(s=>!lt(s));if(r)return nd(t);if(n)return L_(t);throw new Error("Mixed Zod versions detected in object shape.")}function dt(t,e){return lt(t)?ca(t,e):t.safeParse(e)}async function ni(t,e){return lt(t)?await ua(t,e):await t.safeParseAsync(e)}function mr(t){if(!t)return;let e;if(lt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Kr(t){if(t){if(typeof t=="object"){const e=t,r=t;if(!e._def&&!r._zod){const n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return pr(t)}}if(lt(t)){const r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function si(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){const e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function V_(t){return t.description}function F_(t){if(lt(t))return t._zod?.def?.type==="optional";const e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function sd(t){if(lt(t)){const a=t._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}const n=t.value;if(n!==void 0)return n}function Bt(t){return t==="completed"||t==="failed"||t==="cancelled"}const H_=Symbol("Let zodToJsonSchema decide on which parser to use"),ad={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},W_=t=>typeof t=="string"?{...ad,name:t}:{...ad,...t},K_=t=>{const e=W_(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function id(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function we(t,e,r,n,s){t[e]=r,id(t,e,n,s)}const od=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function Be(t){if(t.target!=="openAi")return{};const e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?od(e,t.currentPath):e.join("/")}}function J_(t,e){const r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==V.ZodAny&&(r.items=me(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&we(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&we(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(we(r,"minItems",t.exactLength.value,t.exactLength.message,e),we(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function B_(t,e){const r={type:"integer",format:"int64"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?we(r,"minimum",n.value,n.message,e):we(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),we(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?we(r,"maximum",n.value,n.message,e):we(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),we(r,"maximum",n.value,n.message,e));break;case"multipleOf":we(r,"multipleOf",n.value,n.message,e);break}return r}function G_(){return{type:"boolean"}}function cd(t,e){return me(t.type._def,e)}const Y_=(t,e)=>me(t.innerType._def,e);function ud(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>ud(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Q_(t,e)}}const Q_=(t,e)=>{const r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(const n of t.checks)switch(n.kind){case"min":we(r,"minimum",n.value,n.message,e);break;case"max":we(r,"maximum",n.value,n.message,e);break}return r};function X_(t,e){return{...me(t.innerType._def,e),default:t.defaultValue()}}function ey(t,e){return e.effectStrategy==="input"?me(t.schema._def,e):Be(e)}function ty(t){return{type:"string",enum:Array.from(t.values)}}const ry=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function ny(t,e){const r=[me(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),me(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a);let n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const s=[];return r.forEach(a=>{if(ry(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:o,...c}=a;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function sy(t,e){const r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}let ai;const ft={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ai===void 0&&(ai=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ai),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ld(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":we(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":we(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":ht(r,"email",n.message,e);break;case"format:idn-email":ht(r,"idn-email",n.message,e);break;case"pattern:zod":Ke(r,ft.email,n.message,e);break}break;case"url":ht(r,"uri",n.message,e);break;case"uuid":ht(r,"uuid",n.message,e);break;case"regex":Ke(r,n.regex,n.message,e);break;case"cuid":Ke(r,ft.cuid,n.message,e);break;case"cuid2":Ke(r,ft.cuid2,n.message,e);break;case"startsWith":Ke(r,RegExp(`^${ii(n.value,e)}`),n.message,e);break;case"endsWith":Ke(r,RegExp(`${ii(n.value,e)}$`),n.message,e);break;case"datetime":ht(r,"date-time",n.message,e);break;case"date":ht(r,"date",n.message,e);break;case"time":ht(r,"time",n.message,e);break;case"duration":ht(r,"duration",n.message,e);break;case"length":we(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),we(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Ke(r,RegExp(ii(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&ht(r,"ipv4",n.message,e),n.version!=="v4"&&ht(r,"ipv6",n.message,e);break}case"base64url":Ke(r,ft.base64url,n.message,e);break;case"jwt":Ke(r,ft.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Ke(r,ft.ipv4Cidr,n.message,e),n.version!=="v4"&&Ke(r,ft.ipv6Cidr,n.message,e);break}case"emoji":Ke(r,ft.emoji(),n.message,e);break;case"ulid":{Ke(r,ft.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ht(r,"binary",n.message,e);break}case"contentEncoding:base64":{we(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Ke(r,ft.base64,n.message,e);break}}break}case"nanoid":Ke(r,ft.nanoid,n.message,e)}return r}function ii(t,e){return e.patternStrategy==="escape"?iy(t):t}const ay=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function iy(t){let e="";for(let r=0;r<t.length;r++)ay.has(t[r])||(e+="\\"),e+=t[r];return e}function ht(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):we(t,"format",e,r,n)}function Ke(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:dd(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):we(t,"pattern",dd(e,n),r,n)}function dd(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source;let s="",a=!1,i=!1,o=!1;for(let c=0;c<n.length;c++){if(a){s+=n[c],a=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){o?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),o=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],o=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
|
|
36
|
-
]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
|
|
37
|
-
]))`;continue}}if(r.s&&n[c]==="."){s+=i?`${n[c]}\r
|
|
38
|
-
`:`[${n[c]}\r
|
|
39
|
-
]`;continue}s+=n[c],n[c]==="\\"?a=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}function fd(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===V.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:me(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Be(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};const r={type:"object",additionalProperties:me(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===V.ZodString&&t.keyType._def.checks?.length){const{type:n,...s}=ld(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===V.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===V.ZodBranded&&t.keyType._def.type._def.typeName===V.ZodString&&t.keyType._def.type._def.checks?.length){const{type:n,...s}=cd(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function oy(t,e){if(e.mapStrategy==="record")return fd(t,e);const r=me(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Be(e),n=me(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Be(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function cy(t){const e=t.values,n=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function uy(t){return t.target==="openAi"?void 0:{not:Be({...t,currentPath:[...t.currentPath,"not"]})}}function ly(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const js={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function dy(t,e){if(e.target==="openApi3")return hd(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in js&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,a)=>{const i=js[a._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){const n=r.reduce((s,a)=>{const i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){const s=n.filter((a,i,o)=>o.indexOf(a)===i);return{type:s.length>1?s:s[0],enum:r.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return hd(t,e)}const hd=(t,e)=>{const r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>me(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function fy(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:js[t.innerType._def.typeName],nullable:!0}:{type:[js[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const n=me(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const r=me(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function hy(t,e){const r={type:"number"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"int":r.type="integer",id(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?we(r,"minimum",n.value,n.message,e):we(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),we(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?we(r,"maximum",n.value,n.message,e):we(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),we(r,"maximum",n.value,n.message,e));break;case"multipleOf":we(r,"multipleOf",n.value,n.message,e);break}return r}function py(t,e){const r=e.target==="openAi",n={type:"object",properties:{}},s=[],a=t.shape();for(const o in a){let c=a[o];if(c===void 0||c._def===void 0)continue;let u=gy(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=me(c._def,{...e,currentPath:[...e.currentPath,"properties",o],propertyPath:[...e.currentPath,"properties",o]});l!==void 0&&(n.properties[o]=l,u||s.push(o))}s.length&&(n.required=s);const i=my(t,e);return i!==void 0&&(n.additionalProperties=i),n}function my(t,e){if(t.catchall._def.typeName!=="ZodNever")return me(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function gy(t){try{return t.isOptional()}catch{return!0}}const _y=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return me(t.innerType._def,e);const r=me(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Be(e)},r]}:Be(e)},yy=(t,e)=>{if(e.pipeStrategy==="input")return me(t.in._def,e);if(e.pipeStrategy==="output")return me(t.out._def,e);const r=me(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=me(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function vy(t,e){return me(t.type._def,e)}function wy(t,e){const n={type:"array",uniqueItems:!0,items:me(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&we(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&we(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function by(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>me(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:me(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>me(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function Sy(t){return{not:Be(t)}}function $y(t){return Be(t)}const ky=(t,e)=>me(t.innerType._def,e),Ey=(t,e,r)=>{switch(e){case V.ZodString:return ld(t,r);case V.ZodNumber:return hy(t,r);case V.ZodObject:return py(t,r);case V.ZodBigInt:return B_(t,r);case V.ZodBoolean:return G_();case V.ZodDate:return ud(t,r);case V.ZodUndefined:return Sy(r);case V.ZodNull:return ly(r);case V.ZodArray:return J_(t,r);case V.ZodUnion:case V.ZodDiscriminatedUnion:return dy(t,r);case V.ZodIntersection:return ny(t,r);case V.ZodTuple:return by(t,r);case V.ZodRecord:return fd(t,r);case V.ZodLiteral:return sy(t,r);case V.ZodEnum:return ty(t);case V.ZodNativeEnum:return cy(t);case V.ZodNullable:return fy(t,r);case V.ZodOptional:return _y(t,r);case V.ZodMap:return oy(t,r);case V.ZodSet:return wy(t,r);case V.ZodLazy:return()=>t.getter()._def;case V.ZodPromise:return vy(t,r);case V.ZodNaN:case V.ZodNever:return uy(r);case V.ZodEffects:return ey(t,r);case V.ZodAny:return Be(r);case V.ZodUnknown:return $y(r);case V.ZodDefault:return X_(t,r);case V.ZodBranded:return cd(t,r);case V.ZodReadonly:return ky(t,r);case V.ZodCatch:return Y_(t,r);case V.ZodPipeline:return yy(t,r);case V.ZodFunction:case V.ZodVoid:case V.ZodSymbol:return;default:return(n=>{})()}};function me(t,e,r=!1){const n=e.seen.get(t);if(e.override){const o=e.override?.(t,e,n,r);if(o!==H_)return o}if(n&&!r){const o=Ry(n,e);if(o!==void 0)return o}const s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);const a=Ey(t,t.typeName,e),i=typeof a=="function"?me(a(),e):a;if(i&&Ty(t,e,i),e.postProcess){const o=e.postProcess(i,t,e);return s.jsonSchema=i,o}return s.jsonSchema=i,i}const Ry=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:od(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Be(e)):e.$refStrategy==="seen"?Be(e):void 0}},Ty=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),Py=(t,e)=>{const r=K_(e);let n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:me(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Be(r)}),{}):void 0;const s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=me(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Be(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));const o=s===void 0?n?{...a,[r.definitionPath]:n}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:a}};return r.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o};function Cy(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function pd(t,e){return lt(t)?xm(t,{target:Cy(e?.target),io:e?.pipeStrategy??"input"}):Py(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function md(t){const r=mr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=sd(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function gd(t,e){const r=dt(t,e);if(!r.success)throw r.error;return r.data}const _d=6e4;class oi{constructor(e){this._options=e,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(ss,r=>{this._oncancel(r)}),this.setNotificationHandler(cs,r=>{this._onprogress(r)}),this.setRequestHandler(os,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(us,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new B($.ErrorCode.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ds,async(r,n)=>{const s=async()=>{const a=r.params.taskId;if(this._taskMessageQueue){let o;for(;o=await this._taskMessageQueue.dequeue(a,n.sessionId);){if(o.type==="response"||o.type==="error"){const c=o.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),o.type==="response")l(c);else{const f=c,b=new B(f.error.code,f.error.message,f.error.data);l(b)}else{const f=o.type==="response"?"Response":"Error";this._onerror(new Error(`${f} handler missing for request ${u}`))}continue}await this._transport?.send(o.message,{relatedRequestId:n.requestId})}}const i=await this._taskStore.getTask(a,n.sessionId);if(!i)throw new B($.ErrorCode.InvalidParams,`Task not found: ${a}`);if(!Bt(i.status))return await this._waitForTaskUpdate(a,n.signal),await s();if(Bt(i.status)){const o=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...o,_meta:{...o._meta,[It]:{taskId:a}}}}return await s()};return await s()}),this.setRequestHandler(fs,async(r,n)=>{try{const{tasks:s,nextCursor:a}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:a,_meta:{}}}catch(s){throw new B($.ErrorCode.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(ps,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new B($.ErrorCode.InvalidParams,`Task not found: ${r.params.taskId}`);if(Bt(s.status))throw new B($.ErrorCode.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);const a=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!a)throw new B($.ErrorCode.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(s){throw s instanceof B?s:new B($.ErrorCode.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,s,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:s})}_resetTimeout(e){const r=this._timeoutInfo.get(e);if(!r)return!1;const n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),B.fromError($.ErrorCode.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){const r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;const r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};const n=this.transport?.onerror;this._transport.onerror=a=>{n?.(a),this._onerror(a)};const s=this._transport?.onmessage;this._transport.onmessage=(a,i)=>{s?.(a,i),Vt(a)||ka(a)?this._onresponse(a):rs(a)?this._onrequest(a,i):wu(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const r=B.fromError($.ErrorCode.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){const r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){const n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,s=this._transport,a=e.params?._meta?.[It]?.taskId;if(n===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:$.ErrorCode.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(f=>this._onerror(new Error(`Failed to enqueue error response: ${f}`))):s?.send(l).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);const o=vu(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,u={signal:i.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{const f={relatedRequestId:e.id};a&&(f.relatedTask={taskId:a}),await this.notification(l,f)},sendRequest:async(l,f,b)=>{const v={...b,relatedRequestId:e.id};a&&!v.relatedTask&&(v.relatedTask={taskId:a});const g=v.relatedTask?.taskId??a;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,f,v)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:o?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;const f={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:f,timestamp:Date.now()},s?.sessionId):await s?.send(f)},async l=>{if(i.signal.aborted)return;const f={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:$.ErrorCode.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:f,timestamp:Date.now()},s?.sessionId):await s?.send(f)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:r,...n}=e.params,s=Number(r),a=this._progressHandlers.get(s);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const i=this._responseHandlers.get(s),o=this._timeoutInfo.get(s);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),i(c);return}a(n)}_onresponse(e){const r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Vt(e))n(e);else{const i=new B(e.error.code,e.error.message,e.error.data);n(i)}return}const s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let a=!1;if(Vt(e)&&e.result&&typeof e.result=="object"){const i=e.result;if(i.task&&typeof i.task=="object"){const o=i.task;typeof o.taskId=="string"&&(a=!0,this._taskProgressTokens.set(o.taskId,r))}}if(a||this._progressHandlers.delete(r),Vt(e))s(e);else{const i=B.fromError(e.error.code,e.error.message,e.error.data);s(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){const{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof B?i:new B($.ErrorCode.InternalError,String(i))}}return}let a;try{const i=await this.request(e,Ht,n);if(i.task)a=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new B($.ErrorCode.InternalError,"Task creation did not return a task");for(;;){const o=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:o},Bt(o.status)){o.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:o.status==="failed"?yield{type:"error",error:new B($.ErrorCode.InternalError,`Task ${a} failed`)}:o.status==="cancelled"&&(yield{type:"error",error:new B($.ErrorCode.InternalError,`Task ${a} was cancelled`)});return}if(o.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)};return}const c=o.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof B?i:new B($.ErrorCode.InternalError,String(i))}}}request(e,r,n){const{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i,task:o,relatedTask:c}=n??{};return new Promise((u,l)=>{const f=p=>{l(p)};if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(p){f(p);return}n?.signal?.throwIfAborted();const b=this._requestMessageId++,v={...e,jsonrpc:"2.0",id:b};n?.onprogress&&(this._progressHandlers.set(b,n.onprogress),v.params={...e.params,_meta:{...e.params?._meta||{},progressToken:b}}),o&&(v.params={...v.params,task:o}),c&&(v.params={...v.params,_meta:{...v.params?._meta||{},[It]:c}});const g=p=>{this._responseHandlers.delete(b),this._progressHandlers.delete(b),this._cleanupTimeout(b),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:b,reason:String(p)}},{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(R=>this._onerror(new Error(`Failed to send cancellation: ${R}`)));const y=p instanceof B?p:new B($.ErrorCode.RequestTimeout,String(p));l(y)};this._responseHandlers.set(b,p=>{if(!n?.signal?.aborted){if(p instanceof Error)return l(p);try{const y=dt(r,p.result);y.success?u(y.data):l(y.error)}catch(y){l(y)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});const w=n?.timeout??_d,m=()=>g(B.fromError($.ErrorCode.RequestTimeout,"Request timed out",{timeout:w}));this._setupTimeout(b,w,n?.maxTotalTimeout,m,n?.resetTimeoutOnProgress??!1);const S=c?.taskId;if(S){const p=y=>{const R=this._responseHandlers.get(b);R?R(y):this._onerror(new Error(`Response handler missing for side-channeled request ${b}`))};this._requestResolvers.set(b,p),this._enqueueTaskMessage(S,{type:"request",message:v,timestamp:Date.now()}).catch(y=>{this._cleanupTimeout(b),l(y)})}else this._transport.send(v,{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(p=>{this._cleanupTimeout(b),l(p)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},ls,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},hs,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},zu,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const n=r?.relatedTask?.taskId;if(n){const o={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[It]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:o,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[It]:r.relatedTask}}}),this._transport?.send(o,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[It]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){const n=md(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,a)=>{const i=gd(e,s);return Promise.resolve(r(i,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){const n=md(e);this._notificationHandlers.set(n,s=>{const a=gd(e,s);return Promise.resolve(r(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const s=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,s)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){const n=await this._taskMessageQueue.dequeueAll(e,r);for(const s of n)if(s.type==="request"&&rs(s.message)){const a=s.message.id,i=this._requestResolvers.get(a);i?(i(new B($.ErrorCode.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{const s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,a)=>{if(r.aborted){a(new B($.ErrorCode.InvalidRequest,"Request cancelled"));return}const i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),a(new B($.ErrorCode.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){const n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{const a=await n.getTask(s,r);if(!a)throw new B($.ErrorCode.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(s,a,i)=>{await n.storeTaskResult(s,a,i,r);const o=await n.getTask(s,r);if(o){const c=Zr.parse({method:"notifications/tasks/status",params:o});await this.notification(c),Bt(o.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,a,i)=>{const o=await n.getTask(s,r);if(!o)throw new B($.ErrorCode.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Bt(o.status))throw new B($.ErrorCode.InvalidParams,`Cannot update task "${s}" from terminal status "${o.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,a,i,r);const c=await n.getTask(s,r);if(c){const u=Zr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Bt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function yd(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ci(t,e){const r={...t};for(const n in e){const s=n,a=e[s];if(a===void 0)continue;const i=r[s];yd(i)&&yd(a)?r[s]={...i,...a}:r[s]=a}return r}var Ms={exports:{}},ui={},vd;function Iy(){return vd||(vd=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0;function e(C,M){return{validate:C,compare:M}}t.fullFormats={date:e(a,i),time:e(c(!0),u),"date-time":e(b(!0),v),"iso-time":e(c(),l),"iso-date-time":e(b(),g),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:S,"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:j,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:y,int32:{type:"number",validate:h},int64:{type:"number",validate:_},float:{type:"number",validate:E},double:{type:"number",validate:E},password:!0,binary:!0},t.fastFormats={...t.fullFormats,date:e(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,i),time:e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,u),"date-time":e(/^\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,v),"iso-time":e(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"iso-date-time":e(/^\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,g),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},t.formatNames=Object.keys(t.fullFormats);function r(C){return C%4===0&&(C%100!==0||C%400===0)}const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,s=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(C){const M=n.exec(C);if(!M)return!1;const F=+M[1],D=+M[2],ae=+M[3];return D>=1&&D<=12&&ae>=1&&ae<=(D===2&&r(F)?29:s[D])}function i(C,M){if(C&&M)return C>M?1:C<M?-1:0}const o=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(C){return function(F){const D=o.exec(F);if(!D)return!1;const ae=+D[1],$e=+D[2],xe=+D[3],ge=D[4],mt=D[5]==="-"?-1:1,H=+(D[6]||0),N=+(D[7]||0);if(H>23||N>59||C&&!ge)return!1;if(ae<=23&&$e<=59&&xe<60)return!0;const L=$e-N*mt,z=ae-H*mt-(L<0?1:0);return(z===23||z===-1)&&(L===59||L===-1)&&xe<61}}function u(C,M){if(!(C&&M))return;const F=new Date("2020-01-01T"+C).valueOf(),D=new Date("2020-01-01T"+M).valueOf();if(F&&D)return F-D}function l(C,M){if(!(C&&M))return;const F=o.exec(C),D=o.exec(M);if(F&&D)return C=F[1]+F[2]+F[3],M=D[1]+D[2]+D[3],C>M?1:C<M?-1:0}const f=/t|\s/i;function b(C){const M=c(C);return function(D){const ae=D.split(f);return ae.length===2&&a(ae[0])&&M(ae[1])}}function v(C,M){if(!(C&&M))return;const F=new Date(C).valueOf(),D=new Date(M).valueOf();if(F&&D)return F-D}function g(C,M){if(!(C&&M))return;const[F,D]=C.split(f),[ae,$e]=M.split(f),xe=i(F,ae);if(xe!==void 0)return xe||u(D,$e)}const w=/\/|:/,m=/^(?:[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 S(C){return w.test(C)&&m.test(C)}const p=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(C){return p.lastIndex=0,p.test(C)}const R=-2147483648,d=2**31-1;function h(C){return Number.isInteger(C)&&C<=d&&C>=R}function _(C){return Number.isInteger(C)}function E(){return!0}const I=/[^\\]\\Z/;function j(C){if(I.test(C))return!1;try{return new RegExp(C),!0}catch{return!1}}})(ui)),ui}var li={},wd;function Oy(){return wd||(wd=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;const e=gc(),r=ie(),n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},a={message:({keyword:o,schemaCode:c})=>(0,r.str)`should be ${s[o].okStr} ${c}`,params:({keyword:o,schemaCode:c})=>(0,r._)`{comparison: ${s[o].okStr}, limit: ${c}}`};t.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:a,code(o){const{gen:c,data:u,schemaCode:l,keyword:f,it:b}=o,{opts:v,self:g}=b;if(!v.validateFormats)return;const w=new e.KeywordCxt(b,g.RULES.all.format.definition,"format");w.$data?m():S();function m(){const y=c.scopeValue("formats",{ref:g.formats,code:v.code.formats}),R=c.const("fmt",(0,r._)`${y}[${w.schemaCode}]`);o.fail$data((0,r.or)((0,r._)`typeof ${R} != "object"`,(0,r._)`${R} instanceof RegExp`,(0,r._)`typeof ${R}.compare != "function"`,p(R)))}function S(){const y=w.schema,R=g.formats[y];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${f}": format "${y}" does not define "compare" function`);const d=c.scopeValue("formats",{key:y,ref:R,code:v.code.formats?(0,r._)`${v.code.formats}${(0,r.getProperty)(y)}`:void 0});o.fail$data(p(d))}function p(y){return(0,r._)`${y}.compare(${u}, ${l}) ${s[f].fail} 0`}},dependencies:["format"]};const i=o=>(o.addKeyword(t.formatLimitDefinition),o);t.default=i})(li)),li}var bd;function Ny(){return bd||(bd=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=Iy(),n=Oy(),s=ie(),a=new s.Name("fullFormats"),i=new s.Name("fastFormats"),o=(u,l={keywords:!0})=>{if(Array.isArray(l))return c(u,l,r.fullFormats,a),u;const[f,b]=l.mode==="fast"?[r.fastFormats,i]:[r.fullFormats,a],v=l.formats||r.formatNames;return c(u,v,f,b),l.keywords&&(0,n.default)(u),u};o.get=(u,l="full")=>{const b=(l==="fast"?r.fastFormats:r.fullFormats)[u];if(!b)throw new Error(`Unknown format "${u}"`);return b};function c(u,l,f,b){var v,g;(v=(g=u.opts.code).formats)!==null&&v!==void 0||(g.formats=(0,s._)`require("ajv-formats/dist/formats").${b}`);for(const w of l)u.addFormat(w,f[w])}t.exports=e=o,Object.defineProperty(e,"__esModule",{value:!0}),e.default=o})(Ms,Ms.exports)),Ms.exports}var Ay=Ny();const zy=Xt(Ay);function jy(){const t=new _c({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return zy(t),t}class Sd{constructor(e){this._ajv=e??jy()}getValidator(e){const r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}class My{constructor(e){this._client=e}async*callToolStream(e,r=cr,n){const s=this._client,a={...n,task:n?.task??(s.isToolTask(e.name)?{}:void 0)},i=s.requestStream({method:"tools/call",params:e},r,a),o=s.getToolOutputValidator(e.name);for await(const c of i){if(c.type==="result"&&o){const u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new B($.ErrorCode.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{const l=o(u.structuredContent);if(!l.valid){yield{type:"error",error:new B($.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof B){yield{type:"error",error:l};return}yield{type:"error",error:new B($.ErrorCode.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._client.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,n){return this._client.requestStream(e,r,n)}}function $d(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break}}function kd(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break}}function qs(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){const r=e,n=t.properties;for(const s of Object.keys(n)){const a=n[s];r[s]===void 0&&Object.prototype.hasOwnProperty.call(a,"default")&&(r[s]=a.default),r[s]!==void 0&&qs(a,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)typeof r!="boolean"&&qs(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)typeof r!="boolean"&&qs(r,e)}}function Ed(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};const e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}class qy extends oi{constructor(e,r){super(r),this._clientInfo=e,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 Sd,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Da,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Za,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",ja,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new My(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ci(this._capabilities,e)}setRequestHandler(e,r){const s=mr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(lt(s)){const o=s;a=o._zod?.def?.value??o.value}else{const o=s;a=o._def?.value??o.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const i=a;if(i==="elicitation/create"){const o=async(c,u)=>{const l=dt(Fa,c);if(!l.success){const p=l.error instanceof Error?l.error.message:String(l.error);throw new B($.ErrorCode.InvalidParams,`Invalid elicitation request: ${p}`)}const{params:f}=l.data;f.mode=f.mode??"form";const{supportsFormMode:b,supportsUrlMode:v}=Ed(this._capabilities.elicitation);if(f.mode==="form"&&!b)throw new B($.ErrorCode.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!v)throw new B($.ErrorCode.InvalidParams,"Client does not support URL-mode elicitation requests");const g=await Promise.resolve(r(c,u));if(f.task){const p=dt(Ht,g);if(!p.success){const y=p.error instanceof Error?p.error.message:String(p.error);throw new B($.ErrorCode.InvalidParams,`Invalid task creation result: ${y}`)}return p.data}const w=dt(Ur,g);if(!w.success){const p=w.error instanceof Error?w.error.message:String(w.error);throw new B($.ErrorCode.InvalidParams,`Invalid elicitation result: ${p}`)}const m=w.data,S=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&m.action==="accept"&&m.content&&S&&this._capabilities.elicitation?.form?.applyDefaults)try{qs(S,m.content)}catch{}return m};return super.setRequestHandler(e,o)}if(i==="sampling/createMessage"){const o=async(c,u)=>{const l=dt(Va,c);if(!l.success){const m=l.error instanceof Error?l.error.message:String(l.error);throw new B($.ErrorCode.InvalidParams,`Invalid sampling request: ${m}`)}const{params:f}=l.data,b=await Promise.resolve(r(c,u));if(f.task){const m=dt(Ht,b);if(!m.success){const S=m.error instanceof Error?m.error.message:String(m.error);throw new B($.ErrorCode.InvalidParams,`Invalid task creation result: ${S}`)}return m.data}const g=f.tools||f.toolChoice?Ts:Rs,w=dt(g,b);if(!w.success){const m=w.error instanceof Error?w.error.message:String(w.error);throw new B($.ErrorCode.InvalidParams,`Invalid sampling result: ${m}`)}return w.data};return super.setRequestHandler(e,o)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{const n=await this.request({method:"initialize",params:{protocolVersion:Ut,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ra,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!ya.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.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(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);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 ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);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 ${e})`);break}}assertTaskCapability(e){$d(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&kd(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Ot,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Wa,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Ot,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},qa,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Ma,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Na,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Aa,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},za,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Ot,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Ot,r)}async callTool(e,r=cr,n){if(this.isToolTaskRequired(e.name))throw new B($.ErrorCode.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const s=await this.request({method:"tools/call",params:e},r,n),a=this.getToolOutputValidator(e.name);if(a){if(!s.structuredContent&&!s.isError)throw new B($.ErrorCode.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const i=a(s.structuredContent);if(!i.valid)throw new B($.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof B?i:new B($.ErrorCode.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return s}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const r of e){if(r.outputSchema){const s=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,s)}const n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){const n=await this.request({method:"tools/list",params:e},La,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,r,n,s){const a=Xu.safeParse(n);if(!a.success)throw new Error(`Invalid ${e} listChanged options: ${a.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:i,debounceMs:o}=a.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{const f=await s();c(null,f)}catch(f){const b=f instanceof Error?f:new Error(String(f));c(b,null)}},l=()=>{if(o){const f=this._listChangedDebounceTimers.get(e);f&&clearTimeout(f);const b=setTimeout(u,o);this._listChangedDebounceTimers.set(e,b)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}let di;di=globalThis.crypto;async function Zy(t){return(await di).getRandomValues(new Uint8Array(t))}async function xy(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let n="";for(;n.length<t;){const s=await Zy(t-n.length);for(const a of s)a<r&&(n+=e[a%e.length])}return n}async function Ly(t){return await xy(t)}async function Dy(t){const e=await(await di).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Uy(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await Ly(t),r=await Dy(e);return{code_verifier:e,code_challenge:r}}const Ve=Xm().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:Fg.custom,message:"URL must be parseable",fatal:!0}),Jf}).refine(t=>{const e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Vy=De({resource:T().url(),authorization_servers:K(Ve).optional(),jwks_uri:T().url().optional(),scopes_supported:K(T()).optional(),bearer_methods_supported:K(T()).optional(),resource_signing_alg_values_supported:K(T()).optional(),resource_name:T().optional(),resource_documentation:T().optional(),resource_policy_uri:T().url().optional(),resource_tos_uri:T().url().optional(),tls_client_certificate_bound_access_tokens:ke().optional(),authorization_details_types_supported:K(T()).optional(),dpop_signing_alg_values_supported:K(T()).optional(),dpop_bound_access_tokens_required:ke().optional()}),fi=De({issuer:T(),authorization_endpoint:Ve,token_endpoint:Ve,registration_endpoint:Ve.optional(),scopes_supported:K(T()).optional(),response_types_supported:K(T()),response_modes_supported:K(T()).optional(),grant_types_supported:K(T()).optional(),token_endpoint_auth_methods_supported:K(T()).optional(),token_endpoint_auth_signing_alg_values_supported:K(T()).optional(),service_documentation:Ve.optional(),revocation_endpoint:Ve.optional(),revocation_endpoint_auth_methods_supported:K(T()).optional(),revocation_endpoint_auth_signing_alg_values_supported:K(T()).optional(),introspection_endpoint:T().optional(),introspection_endpoint_auth_methods_supported:K(T()).optional(),introspection_endpoint_auth_signing_alg_values_supported:K(T()).optional(),code_challenge_methods_supported:K(T()).optional(),client_id_metadata_document_supported:ke().optional()}),Fy=De({issuer:T(),authorization_endpoint:Ve,token_endpoint:Ve,userinfo_endpoint:Ve.optional(),jwks_uri:Ve,registration_endpoint:Ve.optional(),scopes_supported:K(T()).optional(),response_types_supported:K(T()),response_modes_supported:K(T()).optional(),grant_types_supported:K(T()).optional(),acr_values_supported:K(T()).optional(),subject_types_supported:K(T()),id_token_signing_alg_values_supported:K(T()),id_token_encryption_alg_values_supported:K(T()).optional(),id_token_encryption_enc_values_supported:K(T()).optional(),userinfo_signing_alg_values_supported:K(T()).optional(),userinfo_encryption_alg_values_supported:K(T()).optional(),userinfo_encryption_enc_values_supported:K(T()).optional(),request_object_signing_alg_values_supported:K(T()).optional(),request_object_encryption_alg_values_supported:K(T()).optional(),request_object_encryption_enc_values_supported:K(T()).optional(),token_endpoint_auth_methods_supported:K(T()).optional(),token_endpoint_auth_signing_alg_values_supported:K(T()).optional(),display_values_supported:K(T()).optional(),claim_types_supported:K(T()).optional(),claims_supported:K(T()).optional(),service_documentation:T().optional(),claims_locales_supported:K(T()).optional(),ui_locales_supported:K(T()).optional(),claims_parameter_supported:ke().optional(),request_parameter_supported:ke().optional(),request_uri_parameter_supported:ke().optional(),require_request_uri_registration:ke().optional(),op_policy_uri:Ve.optional(),op_tos_uri:Ve.optional(),client_id_metadata_document_supported:ke().optional()}),Hy=J({...Fy.shape,...fi.pick({code_challenge_methods_supported:!0}).shape}),Wy=J({access_token:T(),id_token:T().optional(),token_type:T(),expires_in:Hg().optional(),scope:T().optional(),refresh_token:T().optional()}).strip(),Ky=J({error:T(),error_description:T().optional(),error_uri:T().optional()}),Rd=Ve.optional().or(te("").transform(()=>{})),Jy=J({redirect_uris:K(Ve),token_endpoint_auth_method:T().optional(),grant_types:K(T()).optional(),response_types:K(T()).optional(),client_name:T().optional(),client_uri:Ve.optional(),logo_uri:Rd,scope:T().optional(),contacts:K(T()).optional(),tos_uri:Rd,policy_uri:T().optional(),jwks_uri:Ve.optional(),jwks:vg().optional(),software_id:T().optional(),software_version:T().optional(),software_statement:T().optional()}).strip(),By=J({client_id:T(),client_secret:T().optional(),client_id_issued_at:ye().optional(),client_secret_expires_at:ye().optional()}).strip(),Gy=Jy.merge(By);J({error:T(),error_description:T().optional()}).strip(),J({token:T(),token_type_hint:T().optional()}).strip();function Yy(t){const e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function Qy({requestedResource:t,configuredResource:e}){const r=typeof t=="string"?new URL(t):new URL(t.href),n=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;const s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",a=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return s.startsWith(a)}class Ze extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){const e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}}class hi extends Ze{}hi.errorCode="invalid_request";class Zs extends Ze{}Zs.errorCode="invalid_client";class xs extends Ze{}xs.errorCode="invalid_grant";class Ls extends Ze{}Ls.errorCode="unauthorized_client";class pi extends Ze{}pi.errorCode="unsupported_grant_type";class mi extends Ze{}mi.errorCode="invalid_scope";class gi extends Ze{}gi.errorCode="access_denied";class gr extends Ze{}gr.errorCode="server_error";class _i extends Ze{}_i.errorCode="temporarily_unavailable";class yi extends Ze{}yi.errorCode="unsupported_response_type";class vi extends Ze{}vi.errorCode="unsupported_token_type";class wi extends Ze{}wi.errorCode="invalid_token";class bi extends Ze{}bi.errorCode="method_not_allowed";class Si extends Ze{}Si.errorCode="too_many_requests";class Ds extends Ze{}Ds.errorCode="invalid_client_metadata";class $i extends Ze{}$i.errorCode="insufficient_scope";class ki extends Ze{}ki.errorCode="invalid_target";const Xy={[hi.errorCode]:hi,[Zs.errorCode]:Zs,[xs.errorCode]:xs,[Ls.errorCode]:Ls,[pi.errorCode]:pi,[mi.errorCode]:mi,[gi.errorCode]:gi,[gr.errorCode]:gr,[_i.errorCode]:_i,[yi.errorCode]:yi,[vi.errorCode]:vi,[wi.errorCode]:wi,[bi.errorCode]:bi,[Si.errorCode]:Si,[Ds.errorCode]:Ds,[$i.errorCode]:$i,[ki.errorCode]:ki};class it extends Error{constructor(e){super(e??"Unauthorized")}}function ev(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const Ei="code",Ri="S256";function Td(t,e){const r=t.client_secret!==void 0;return e.length===0?r?"client_secret_post":"none":"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&ev(t.token_endpoint_auth_method)&&e.includes(t.token_endpoint_auth_method)?t.token_endpoint_auth_method:r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function tv(t,e,r,n){const{client_id:s,client_secret:a}=e;switch(t){case"client_secret_basic":rv(s,a,r);return;case"client_secret_post":nv(s,a,n);return;case"none":sv(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function rv(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");const n=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${n}`)}function nv(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function sv(t,e){e.set("client_id",t)}async function Ti(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=Ky.parse(JSON.parse(r)),{error:s,error_description:a,error_uri:i}=n,o=Xy[s]||gr;return new o(a||"",i)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new gr(s)}}async function jt(t,e){try{return await Pi(t,e)}catch(r){if(r instanceof Zs||r instanceof Ls)return await t.invalidateCredentials?.("all"),await Pi(t,e);if(r instanceof xs)return await t.invalidateCredentials?.("tokens"),await Pi(t,e);throw r}}async function Pi(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:a}){let i,o;try{i=await Id(e,{resourceMetadataUrl:s},a),i.authorization_servers&&i.authorization_servers.length>0&&(o=i.authorization_servers[0])}catch{}o||(o=new URL("/",e));const c=await Cd(e,t,i),u=await zd(o,{fetchFn:a});let l=await Promise.resolve(t.clientInformation());if(!l){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const m=u?.client_id_metadata_document_supported===!0,S=t.clientMetadataUrl;if(S&&!Pd(S))throw new Ds(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${S}`);if(m&&S)l={client_id:S},await t.saveClientInformation?.(l);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const y=await Zd(o,{metadata:u,clientMetadata:t.clientMetadata,fetchFn:a});await t.saveClientInformation(y),l=y}}const f=!t.redirectUrl;if(r!==void 0||f){const m=await qd(t,o,{metadata:u,resource:c,authorizationCode:r,fetchFn:a});return await t.saveTokens(m),"AUTHORIZED"}const b=await t.tokens();if(b?.refresh_token)try{const m=await Md(o,{metadata:u,clientInformation:l,refreshToken:b.refresh_token,resource:c,addClientAuthentication:t.addClientAuthentication,fetchFn:a});return await t.saveTokens(m),"AUTHORIZED"}catch(m){if(!(!(m instanceof Ze)||m instanceof gr))throw m}const v=t.state?await t.state():void 0,{authorizationUrl:g,codeVerifier:w}=await jd(o,{metadata:u,clientInformation:l,state:v,redirectUrl:t.redirectUrl,scope:n||i?.scopes_supported?.join(" ")||t.clientMetadata.scope,resource:c});return await t.saveCodeVerifier(w),await t.redirectToAuthorization(g),"REDIRECT"}function Pd(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function Cd(t,e,r){const n=Yy(t);if(e.validateResourceURL)return await e.validateResourceURL(n,r?.resource);if(r){if(!Qy({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 Jr(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=Ci(t,"resource_metadata")||void 0;let a;if(s)try{a=new URL(s)}catch{}const i=Ci(t,"scope")||void 0,o=Ci(t,"error")||void 0;return{resourceMetadataUrl:a,scope:i,error:o}}function Ci(t,e){const r=t.headers.get("WWW-Authenticate");if(!r)return null;const n=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),s=r.match(n);return s?s[1]||s[2]:null}function av(t){const e=t.headers.get("WWW-Authenticate");if(!e)return;const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return;const a=/resource_metadata="([^"]*)"/.exec(e);if(a)try{return new URL(a[1])}catch{return}}async function Id(t,e,r=fetch){const n=await Nd(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.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 Vy.parse(await n.json())}async function Ii(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?Ii(t,void 0,r):void 0;throw n}}function iv(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function Od(t,e,r=fetch){return await Ii(t,{"MCP-Protocol-Version":e},r)}function ov(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function Nd(t,e,r,n){const s=new URL(t),a=n?.protocolVersion??Ut;let i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{const c=iv(e,s.pathname);i=new URL(c,n?.metadataServerUrl??s),i.search=s.search}let o=await Od(i,a,r);if(!n?.metadataUrl&&ov(o,s.pathname)){const c=new URL(`/.well-known/${e}`,s);o=await Od(c,a,r)}return o}async function cv(t,{authorizationServerUrl:e,protocolVersion:r}={},n=fetch){typeof t=="string"&&(t=new URL(t)),e||(e=t),typeof e=="string"&&(e=new URL(e)),r??(r=Ut);const s=await Nd(e,"oauth-authorization-server",n,{protocolVersion:r,metadataServerUrl:e});if(!s||s.status===404){await s?.body?.cancel();return}if(!s.ok)throw await s.body?.cancel(),new Error(`HTTP ${s.status} trying to load well-known OAuth metadata`);return fi.parse(await s.json())}function Ad(t){const e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),n;let s=e.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,e.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${s}`,e.origin),type:"oidc"}),n.push({url:new URL(`${s}/.well-known/openid-configuration`,e.origin),type:"oidc"}),n}async function zd(t,{fetchFn:e=fetch,protocolVersion:r=Ut}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=Ad(t);for(const{url:a,type:i}of s){const o=await Ii(a,n,e);if(o){if(!o.ok){if(await o.body?.cancel(),o.status>=400&&o.status<500)continue;throw new Error(`HTTP ${o.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}return i==="oauth"?fi.parse(await o.json()):Hy.parse(await o.json())}}}async function jd(t,{metadata:e,clientInformation:r,redirectUrl:n,scope:s,state:a,resource:i}){let o;if(e){if(o=new URL(e.authorization_endpoint),!e.response_types_supported.includes(Ei))throw new Error(`Incompatible auth server: does not support response type ${Ei}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Ri))throw new Error(`Incompatible auth server: does not support code challenge method ${Ri}`)}else o=new URL("/authorize",t);const c=await Uy(),u=c.code_verifier,l=c.code_challenge;return o.searchParams.set("response_type",Ei),o.searchParams.set("client_id",r.client_id),o.searchParams.set("code_challenge",l),o.searchParams.set("code_challenge_method",Ri),o.searchParams.set("redirect_uri",String(n)),a&&o.searchParams.set("state",a),s&&o.searchParams.set("scope",s),s?.includes("offline_access")&&o.searchParams.append("prompt","consent"),i&&o.searchParams.set("resource",i.href),{authorizationUrl:o,codeVerifier:u}}function Oi(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function Ni(t,{metadata:e,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:a,fetchFn:i}){const o=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(a&&r.set("resource",a.href),s)await s(c,r,o,e);else if(n){const l=e?.token_endpoint_auth_methods_supported??[],f=Td(n,l);tv(f,n,c,r)}const u=await(i??fetch)(o,{method:"POST",headers:c,body:r});if(!u.ok)throw await Ti(u);return Wy.parse(await u.json())}async function uv(t,{metadata:e,clientInformation:r,authorizationCode:n,codeVerifier:s,redirectUri:a,resource:i,addClientAuthentication:o,fetchFn:c}){const u=Oi(n,s,a);return Ni(t,{metadata:e,tokenRequestParams:u,clientInformation:r,addClientAuthentication:o,resource:i,fetchFn:c})}async function Md(t,{metadata:e,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:a,fetchFn:i}){const o=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await Ni(t,{metadata:e,tokenRequestParams:o,clientInformation:r,addClientAuthentication:a,resource:s,fetchFn:i});return{refresh_token:n,...c}}async function qd(t,e,{metadata:r,resource:n,authorizationCode:s,fetchFn:a}={}){const i=t.clientMetadata.scope;let o;if(t.prepareTokenRequest&&(o=await t.prepareTokenRequest(i)),!o){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");const u=await t.codeVerifier();o=Oi(s,u,t.redirectUrl)}const c=await t.clientInformation();return Ni(e,{metadata:r,tokenRequestParams:o,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:n,fetchFn:a})}async function Zd(t,{metadata:e,clientMetadata:r,fetchFn:n}){let s;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(e.registration_endpoint)}else s=new URL("/register",t);const a=await(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!a.ok)throw await Ti(a);return Gy.parse(await a.json())}class Ai extends Error{constructor(e,r){super(e),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}const xd=10,lv=13,Gt=32;function zi(t){}function Ld(t){if(typeof t=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=zi,onError:r=zi,onRetry:n=zi,onComment:s,maxBufferSize:a}=t,i=[];let o=0,c=!0,u,l="",f=0,b,v=!1;function g(d){if(v)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,d.charCodeAt(0)===239&&d.charCodeAt(1)===187&&d.charCodeAt(2)===191&&(d=d.slice(3))),i.length===0){const E=m(d);E!==""&&(i.push(E),o=E.length),w();return}if(d.indexOf(`
|
|
40
|
-
`)===-1&&d.indexOf("\r")===-1){i.push(d),o+=d.length,w();return}i.push(d);const h=i.join("");i.length=0,o=0;const _=m(h);_!==""&&(i.push(_),o=_.length),w()}function w(){a!==void 0&&(o+l.length<=a||(v=!0,i.length=0,o=0,u=void 0,l="",f=0,b=void 0,r(new Ai(`Buffered data exceeded max buffer size of ${a} characters`,{type:"max-buffer-size-exceeded"}))))}function m(d){let h=0;if(d.indexOf("\r")===-1){let _=d.indexOf(`
|
|
41
|
-
`,h);for(;_!==-1;){if(h===_){f>0&&e({id:u,event:b,data:l}),u=void 0,l="",f=0,b=void 0,h=_+1,_=d.indexOf(`
|
|
42
|
-
`,h);continue}const E=d.charCodeAt(h);if(Dd(d,h,E)){const I=d.charCodeAt(h+5)===Gt?h+6:h+5,j=d.slice(I,_);if(f===0&&d.charCodeAt(_+1)===xd){e({id:u,event:b,data:j}),u=void 0,l="",b=void 0,h=_+2,_=d.indexOf(`
|
|
43
|
-
`,h);continue}l=f===0?j:`${l}
|
|
44
|
-
${j}`,f++}else Ud(d,h,E)?b=d.slice(d.charCodeAt(h+6)===Gt?h+7:h+6,_)||void 0:S(d,h,_);h=_+1,_=d.indexOf(`
|
|
45
|
-
`,h)}return d.slice(h)}for(;h<d.length;){const _=d.indexOf("\r",h),E=d.indexOf(`
|
|
46
|
-
`,h);let I=-1;if(_!==-1&&E!==-1?I=_<E?_:E:_!==-1?_===d.length-1?I=-1:I=_:E!==-1&&(I=E),I===-1)break;S(d,h,I),h=I+1,d.charCodeAt(h-1)===lv&&d.charCodeAt(h)===xd&&h++}return d.slice(h)}function S(d,h,_){if(h===_){y();return}const E=d.charCodeAt(h);if(Dd(d,h,E)){const D=d.charCodeAt(h+5)===Gt?h+6:h+5,ae=d.slice(D,_);l=f===0?ae:`${l}
|
|
47
|
-
${ae}`,f++;return}if(Ud(d,h,E)){b=d.slice(d.charCodeAt(h+6)===Gt?h+7:h+6,_)||void 0;return}if(E===105&&d.charCodeAt(h+1)===100&&d.charCodeAt(h+2)===58){const D=d.slice(d.charCodeAt(h+3)===Gt?h+4:h+3,_);u=D.includes("\0")?void 0:D;return}if(E===58){if(s){const D=d.slice(h,_);s(D.slice(d.charCodeAt(h+1)===Gt?2:1))}return}const I=d.slice(h,_),j=I.indexOf(":");if(j===-1){p(I,"",I);return}const C=I.slice(0,j),M=I.charCodeAt(j+1)===Gt?2:1,F=I.slice(j+M);p(C,F,I)}function p(d,h,_){switch(d){case"event":b=h||void 0;break;case"data":l=f===0?h:`${l}
|
|
48
|
-
${h}`,f++;break;case"id":u=h.includes("\0")?void 0:h;break;case"retry":/^\d+$/.test(h)?n(parseInt(h,10)):r(new Ai(`Invalid \`retry\` value: "${h}"`,{type:"invalid-retry",value:h,line:_}));break;default:r(new Ai(`Unknown field "${d.length>20?`${d.slice(0,20)}…`:d}"`,{type:"unknown-field",field:d,value:h,line:_}));break}}function y(){f>0&&e({id:u,event:b,data:l}),u=void 0,l="",f=0,b=void 0}function R(d={}){if(d.consume&&i.length>0){const h=i.join("");S(h,0,h.length)}c=!0,u=void 0,l="",f=0,b=void 0,i.length=0,o=0,v=!1}return{feed:g,reset:R}}function Dd(t,e,r){return r===100&&t.charCodeAt(e+1)===97&&t.charCodeAt(e+2)===116&&t.charCodeAt(e+3)===97&&t.charCodeAt(e+4)===58}function Ud(t,e,r){return r===101&&t.charCodeAt(e+1)===118&&t.charCodeAt(e+2)===101&&t.charCodeAt(e+3)===110&&t.charCodeAt(e+4)===116&&t.charCodeAt(e+5)===58}class Vd extends Event{constructor(e,r){var n,s;super(e),this.code=(n=r?.code)!=null?n:void 0,this.message=(s=r?.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return n(Fd(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(Fd(this),r)}}function dv(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function ji(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(ji).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${ji(t.cause)}`:t.message:`${t}`}function Fd(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Hd=t=>{throw TypeError(t)},Mi=(t,e,r)=>e.has(t)||Hd("Cannot "+r),le=(t,e,r)=>(Mi(t,e,"read from private field"),r?r.call(t):e.get(t)),je=(t,e,r)=>e.has(t)?Hd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Pe=(t,e,r,n)=>(Mi(t,e,"write to private field"),e.set(t,r),r),kt=(t,e,r)=>(Mi(t,e,"access private method"),r),Ge,Yt,_r,Us,Vs,Br,yr,Gr,Mt,vr,wr,br,Yr,pt,qi,Zi,xi,Wd,Li,Di,Qr,Ui,Vi;class Fs extends EventTarget{constructor(e,r){var n,s;super(),je(this,pt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,je(this,Ge),je(this,Yt),je(this,_r),je(this,Us),je(this,Vs),je(this,Br),je(this,yr),je(this,Gr,null),je(this,Mt),je(this,vr),je(this,wr,null),je(this,br,null),je(this,Yr,null),je(this,Zi,async a=>{var i;le(this,vr).reset();const{body:o,redirected:c,status:u,headers:l}=a;if(u===204){kt(this,pt,Qr).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?Pe(this,_r,new URL(a.url)):Pe(this,_r,void 0),u!==200){kt(this,pt,Qr).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){kt(this,pt,Qr).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(le(this,Ge)===this.CLOSED)return;Pe(this,Ge,this.OPEN);const f=new Event("open");if((i=le(this,Yr))==null||i.call(this,f),this.dispatchEvent(f),typeof o!="object"||!o||!("getReader"in o)){kt(this,pt,Qr).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}const b=new TextDecoder,v=o.getReader();let g=!0;do{const{done:w,value:m}=await v.read();m&&le(this,vr).feed(b.decode(m,{stream:!w})),w&&(g=!1,le(this,vr).reset(),kt(this,pt,Ui).call(this))}while(g)}),je(this,xi,a=>{Pe(this,Mt,void 0),!(a.name==="AbortError"||a.type==="aborted")&&kt(this,pt,Ui).call(this,ji(a))}),je(this,Li,a=>{typeof a.id=="string"&&Pe(this,Gr,a.id);const i=new MessageEvent(a.event||"message",{data:a.data,origin:le(this,_r)?le(this,_r).origin:le(this,Yt).origin,lastEventId:a.id||""});le(this,br)&&(!a.event||a.event==="message")&&le(this,br).call(this,i),this.dispatchEvent(i)}),je(this,Di,a=>{Pe(this,Br,a)}),je(this,Vi,()=>{Pe(this,yr,void 0),le(this,Ge)===this.CONNECTING&&kt(this,pt,qi).call(this)});try{if(e instanceof URL)Pe(this,Yt,e);else if(typeof e=="string")Pe(this,Yt,new URL(e,fv()));else throw new Error("Invalid URL")}catch{throw dv("An invalid or illegal string was specified")}Pe(this,vr,Ld({onEvent:le(this,Li),onRetry:le(this,Di)})),Pe(this,Ge,this.CONNECTING),Pe(this,Br,3e3),Pe(this,Vs,(n=r?.fetch)!=null?n:globalThis.fetch),Pe(this,Us,(s=r?.withCredentials)!=null?s:!1),kt(this,pt,qi).call(this)}get readyState(){return le(this,Ge)}get url(){return le(this,Yt).href}get withCredentials(){return le(this,Us)}get onerror(){return le(this,wr)}set onerror(e){Pe(this,wr,e)}get onmessage(){return le(this,br)}set onmessage(e){Pe(this,br,e)}get onopen(){return le(this,Yr)}set onopen(e){Pe(this,Yr,e)}addEventListener(e,r,n){const s=r;super.addEventListener(e,s,n)}removeEventListener(e,r,n){const s=r;super.removeEventListener(e,s,n)}close(){le(this,yr)&&clearTimeout(le(this,yr)),le(this,Ge)!==this.CLOSED&&(le(this,Mt)&&le(this,Mt).abort(),Pe(this,Ge,this.CLOSED),Pe(this,Mt,void 0))}}Ge=new WeakMap,Yt=new WeakMap,_r=new WeakMap,Us=new WeakMap,Vs=new WeakMap,Br=new WeakMap,yr=new WeakMap,Gr=new WeakMap,Mt=new WeakMap,vr=new WeakMap,wr=new WeakMap,br=new WeakMap,Yr=new WeakMap,pt=new WeakSet,qi=function(){Pe(this,Ge,this.CONNECTING),Pe(this,Mt,new AbortController),le(this,Vs)(le(this,Yt),kt(this,pt,Wd).call(this)).then(le(this,Zi)).catch(le(this,xi))},Zi=new WeakMap,xi=new WeakMap,Wd=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...le(this,Gr)?{"Last-Event-ID":le(this,Gr)}:void 0},cache:"no-store",signal:(t=le(this,Mt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Li=new WeakMap,Di=new WeakMap,Qr=function(t,e){var r;le(this,Ge)!==this.CLOSED&&Pe(this,Ge,this.CLOSED);const n=new Vd("error",{code:e,message:t});(r=le(this,wr))==null||r.call(this,n),this.dispatchEvent(n)},Ui=function(t,e){var r;if(le(this,Ge)===this.CLOSED)return;Pe(this,Ge,this.CONNECTING);const n=new Vd("error",{code:e,message:t});(r=le(this,wr))==null||r.call(this,n),this.dispatchEvent(n),Pe(this,yr,setTimeout(le(this,Vi),le(this,Br)))},Vi=new WeakMap,Fs.CONNECTING=0,Fs.OPEN=1,Fs.CLOSED=2;function fv(){const t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}function Xr(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function Fi(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n?.headers?{...Xr(e.headers),...Xr(n.headers)}:e.headers};return t(r,s)}:t}class Kd extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}}class hv{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=Fi(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new it("No auth provider");let e;try{e=await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new it;return await this._startOrAuth()}async _commonHeaders(){const e={};if(this._authProvider){const n=await this._authProvider.tokens();n&&(e.Authorization=`Bearer ${n.access_token}`)}this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const r=Xr(this._requestInit?.headers);return new Headers({...e,...r})}_startOrAuth(){const e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((r,n)=>{this._eventSource=new Fs(this._url.href,{...this._eventSourceInit,fetch:async(s,a)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const o=await e(s,{...a,headers:i});if(o.status===401&&o.headers.has("www-authenticate")){const{resourceMetadataUrl:c,scope:u}=Jr(o);this._resourceMetadataUrl=c,this._scope=u}return o}}),this._abortController=new AbortController,this._eventSource.onerror=s=>{if(s.code===401&&this._authProvider){this._authThenStart().then(r,n);return}const a=new Kd(s.code,s.message,s);n(a),this.onerror?.(a)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",s=>{const a=s;try{if(this._endpoint=new URL(a.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){n(i),this.onerror?.(i),this.close();return}r()}),this._eventSource.onmessage=s=>{const a=s;let i;try{i=qr.parse(JSON.parse(a.data))}catch(o){this.onerror?.(o);return}this.onmessage?.(i)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new it("No auth provider");if(await jt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw new Error("Not connected");try{const r=await this._commonHeaders();r.set("content-type","application/json");const n={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(e),signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._endpoint,n);if(!s.ok){const a=await s.text().catch(()=>null);if(s.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:o}=Jr(s);if(this._resourceMetadataUrl=i,this._scope=o,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${s.status}): ${a}`)}await s.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}}class pv extends TransformStream{constructor({onError:e,onRetry:r,onComment:n,maxBufferSize:s}={}){let a;super({start(i){a=Ld({onEvent:o=>{i.enqueue(o)},onError(o){typeof e=="function"&&e(o),(e==="terminate"||o.type==="max-buffer-size-exceeded")&&i.error(o)},onRetry:r,onComment:n,maxBufferSize:s})},transform(i){a.feed(i)}})}}const mv={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Qt extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}}class gv{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=Fi(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??mv}async _authThenStart(){if(!this._authProvider)throw new it("No auth provider");let e;try{e=await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new it;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const n=await this._authProvider.tokens();n&&(e.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const r=Xr(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){const{resumptionToken:r}=e;try{const n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);const s=await(this._fetch??fetch)(this._url,{method:"GET",headers:n,signal:this._abortController?.signal});if(!s.ok){if(await s.body?.cancel(),s.status===401&&this._authProvider)return await this._authThenStart();if(s.status===405)return;throw new Qt(s.status,`Failed to open SSE stream: ${s.statusText}`)}this._handleSseStream(s.body,e,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,e),s)}_scheduleReconnection(e,r=0){const n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}const s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(a=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(e,r+1)})},s)}_handleSseStream(e,r,n){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=r;let i,o=!1,c=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new pv({onRetry:v=>{this._serverRetryMs=v}})).getReader();for(;;){const{value:v,done:g}=await l.read();if(g)break;if(v.id&&(i=v.id,o=!0,s?.(v.id)),!!v.data&&(!v.event||v.event==="message"))try{const w=qr.parse(JSON.parse(v.data));Vt(w)&&(c=!0,a!==void 0&&(w.id=a)),this.onmessage?.(w)}catch(w){this.onerror?.(w)}}(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},0)}catch(v){this.onerror?.(new Error(`Failed to reconnect: ${v instanceof Error?v.message:String(v)}`))}}})()}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(e){if(!this._authProvider)throw new it("No auth provider");if(await jt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{const{resumptionToken:n,onresumptiontoken:s}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:rs(e)?e.id:void 0}).catch(b=>this.onerror?.(b));return}const a=await this._commonHeaders();a.set("content-type","application/json"),a.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:a,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,i),c=o.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!o.ok){const b=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Qt(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:v,scope:g}=Jr(o);if(this._resourceMetadataUrl=v,this._scope=g,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){const{resourceMetadataUrl:v,scope:g,error:w}=Jr(o);if(w==="insufficient_scope"){const m=o.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===m)throw new Qt(403,"Server returned 403 after trying upscoping");if(g&&(this._scope=g),v&&(this._resourceMetadataUrl=v),this._lastUpscopingHeader=m??void 0,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new it;return this.send(e)}}throw new Qt(o.status,`Error POSTing to endpoint: ${b}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),Pu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(b=>this.onerror?.(b));return}const l=(Array.isArray(e)?e:[e]).filter(b=>"method"in b&&"id"in b&&b.id!==void 0).length>0,f=o.headers.get("content-type");if(l)if(f?.includes("text/event-stream"))this._handleSseStream(o.body,{onresumptiontoken:s},!1);else if(f?.includes("application/json")){const b=await o.json(),v=Array.isArray(b)?b.map(g=>qr.parse(g)):[qr.parse(b)];for(const g of v)this.onmessage?.(g)}else throw await o.body?.cancel(),new Qt(-1,`Unexpected content type: ${f}`);else await o.body?.cancel()}catch(n){throw this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Qt(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}}class _v{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}}class yv extends oi{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Lr.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{const a=this._loggingLevels.get(s);return a?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Sd,this.setRequestHandler(as,n=>this._oninitialize(n)),this.setNotificationHandler(is,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ua,async(n,s)=>{const a=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,o=Lr.safeParse(i);return o.success&&this._loggingLevels.set(a,o.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new _v(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ci(this._capabilities,e)}setRequestHandler(e,r){const s=mr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(lt(s)){const o=s;a=o._zod?.def?.value??o.value}else{const o=s;a=o._def?.value??o.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");if(a==="tools/call"){const o=async(c,u)=>{const l=dt(xr,c);if(!l.success){const g=l.error instanceof Error?l.error.message:String(l.error);throw new B($.ErrorCode.InvalidParams,`Invalid tools/call request: ${g}`)}const{params:f}=l.data,b=await Promise.resolve(r(c,u));if(f.task){const g=dt(Ht,b);if(!g.success){const w=g.error instanceof Error?g.error.message:String(g.error);throw new B($.ErrorCode.InvalidParams,`Invalid task creation result: ${w}`)}return g.data}const v=dt(cr,b);if(!v.success){const g=v.error instanceof Error?v.error.message:String(v.error);throw new B($.ErrorCode.InvalidParams,`Invalid tools/call result: ${g}`)}return v.data};return super.setRequestHandler(e,o)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);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 ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);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 ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);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 ${e})`);break}}assertTaskCapability(e){kd(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&$d(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){const r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:ya.includes(r)?r:Ut,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"},Ot)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],a=s.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,o=i?Array.isArray(i.content)?i.content:[i.content]:[],c=o.some(u=>u.type==="tool_use");if(a){if(s.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){const u=new Set(o.filter(f=>f.type==="tool_use").map(f=>f.id)),l=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(u.size!==l.size||![...u].every(f=>l.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Ts,r):this.request({method:"sampling/createMessage",params:e},Rs,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");const s=e;return this.request({method:"elicitation/create",params:s},Ur,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");const s=e.mode==="form"?e:{...e,mode:"form"},a=await this.request({method:"elicitation/create",params:s},Ur,r);if(a.action==="accept"&&a.content&&s.requestedSchema)try{const o=this._jsonSchemaValidator.getValidator(s.requestedSchema)(a.content);if(!o.valid)throw new B($.ErrorCode.InvalidParams,`Elicitation response content does not match requested schema: ${o.errorMessage}`)}catch(i){throw i instanceof B?i:new B($.ErrorCode.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return a}}}createElicitationCompletionNotifier(e,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:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Ka,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}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"})}}const vv=/^[A-Za-z0-9._-]{1,128}$/;function wv(t){const e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!vv.test(t)){const r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,a)=>a.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function bv(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(const r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Jd(t){const e=wv(t);return bv(t,e.warnings),e.isValid}class Sv{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){const s={taskSupport:"required",...r.execution};if(s.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,s,r._meta,n)}}class $v{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new yv(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Sv(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(Es)),this.server.assertCanSetRequestHandler(qt(xr)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Es,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{const n={name:e,title:r.title,description:r.description,inputSchema:(()=>{const s=Kr(r.inputSchema);return s?pd(s,{strictUnions:!0,pipeStrategy:"input"}):Ev})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){const s=Kr(r.outputSchema);s&&(n.outputSchema=pd(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(xr,async(e,r)=>{try{const n=this._registeredTools[e.params.name];if(!n)throw new B($.ErrorCode.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new B($.ErrorCode.InvalidParams,`Tool ${e.params.name} disabled`);const s=!!e.params.task,a=n.execution?.taskSupport,i="createTask"in n.handler;if((a==="required"||a==="optional")&&!i)throw new B($.ErrorCode.InternalError,`Tool ${e.params.name} has taskSupport '${a}' but was not registered with registerToolTask`);if(a==="required"&&!s)throw new B($.ErrorCode.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(a==="optional"&&!s&&i)return await this.handleAutomaticTaskPolling(n,e,r);const o=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,o,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof B&&n.code===$.ErrorCode.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;const a=Kr(e.inputSchema)??e.inputSchema,i=await ni(a,r);if(!i.success){const o="error"in i?i.error:"Unknown error",c=si(o);throw new B($.ErrorCode.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new B($.ErrorCode.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);const s=Kr(e.outputSchema),a=await ni(s,r.structuredContent);if(!a.success){const i="error"in a?a.error:"Unknown error",o=si(i);throw new B($.ErrorCode.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${o}`)}}async executeToolHandler(e,r,n){const s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");const i={...n,taskStore:n.taskStore};if(e.inputSchema){const o=s;return await Promise.resolve(o.createTask(r,i))}else{const o=s;return await Promise.resolve(o.createTask(i))}}if(e.inputSchema){const i=s;return await Promise.resolve(i(r,n))}else{const i=s;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");const s=await this.validateToolInput(e,r.params.arguments,r.params.name),a=e.handler,i={...n,taskStore:n.taskStore},o=s?await Promise.resolve(a.createTask(s,i)):await Promise.resolve(a.createTask(i)),c=o.task.taskId;let u=o.task;const l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(b=>setTimeout(b,l));const f=await n.taskStore.getTask(c);if(!f)throw new B($.ErrorCode.InternalError,`Task ${c} not found during polling`);u=f}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(qt(Ps)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ps,async e=>{switch(e.params.ref.type){case"ref/prompt":return Cl(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Il(e),this.handleResourceCompletion(e,e.params.ref);default:throw new B($.ErrorCode.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){const n=this._registeredPrompts[r.name];if(!n)throw new B($.ErrorCode.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new B($.ErrorCode.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return en;const a=mr(n.argsSchema)?.[e.params.argument.name];if(!Ba(a))return en;const i=ql(a);if(!i)return en;const o=await i(e.params.argument.value,e.params.context);return Yd(o)}async handleResourceCompletion(e,r){const n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return en;throw new B($.ErrorCode.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return en;const a=await s(e.params.argument.value,e.params.context);return Yd(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(ms)),this.server.assertCanSetRequestHandler(qt(gs)),this.server.assertCanSetRequestHandler(qt(ys)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(ms,async(e,r)=>{const n=Object.entries(this._registeredResources).filter(([a,i])=>i.enabled).map(([a,i])=>({uri:a,name:i.name,...i.metadata})),s=[];for(const a of Object.values(this._registeredResourceTemplates)){if(!a.resourceTemplate.listCallback)continue;const i=await a.resourceTemplate.listCallback(r);for(const o of i.resources)s.push({...a.metadata,...o})}return{resources:[...n,...s]}}),this.server.setRequestHandler(gs,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(ys,async(e,r)=>{const n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new B($.ErrorCode.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(const a of Object.values(this._registeredResourceTemplates)){const i=a.resourceTemplate.uriTemplate.match(n.toString());if(i)return a.readCallback(n,i,r)}throw new B($.ErrorCode.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(vs)),this.server.assertCanSetRequestHandler(qt(ws)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(vs,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?Tv(r.argsSchema):void 0}))})),this.server.setRequestHandler(ws,async(e,r)=>{const n=this._registeredPrompts[e.params.name];if(!n)throw new B($.ErrorCode.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new B($.ErrorCode.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){const s=Kr(n.argsSchema),a=await ni(s,e.params.arguments);if(!a.success){const c="error"in a?a.error:"Unknown error",u=si(c);throw new B($.ErrorCode.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}const i=a.data,o=n.callback;return await Promise.resolve(o(i,r))}else{const s=n.callback;return await Promise.resolve(s(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());const a=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);const i=this._createRegisteredResource(e,void 0,r,s,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const i=this._createRegisteredResourceTemplate(e,void 0,r,s,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);const a=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const a=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}_createRegisteredResource(e,r,n,s,a){const i={name:e,title:r,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:o=>{typeof o.uri<"u"&&o.uri!==n&&(delete this._registeredResources[n],o.uri&&(this._registeredResources[o.uri]=i)),typeof o.name<"u"&&(i.name=o.name),typeof o.title<"u"&&(i.title=o.title),typeof o.metadata<"u"&&(i.metadata=o.metadata),typeof o.callback<"u"&&(i.readCallback=o.callback),typeof o.enabled<"u"&&(i.enabled=o.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,s,a){const i={resourceTemplate:n,title:r,metadata:s,readCallback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=i)),typeof u.title<"u"&&(i.title=u.title),typeof u.template<"u"&&(i.resourceTemplate=u.template),typeof u.metadata<"u"&&(i.metadata=u.metadata),typeof u.callback<"u"&&(i.readCallback=u.callback),typeof u.enabled<"u"&&(i.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;const o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,s,a){const i={title:r,description:n,argsSchema:s===void 0?void 0:pr(s),callback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:o=>{typeof o.name<"u"&&o.name!==e&&(delete this._registeredPrompts[e],o.name&&(this._registeredPrompts[o.name]=i)),typeof o.title<"u"&&(i.title=o.title),typeof o.description<"u"&&(i.description=o.description),typeof o.argsSchema<"u"&&(i.argsSchema=pr(o.argsSchema)),typeof o.callback<"u"&&(i.callback=o.callback),typeof o.enabled<"u"&&(i.enabled=o.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,s&&Object.values(s).some(c=>{const u=c instanceof $t?c._def?.innerType:c;return Ba(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,a,i,o,c,u){Jd(e);const l={title:r,description:n,inputSchema:Gd(s),outputSchema:Gd(a),annotations:i,execution:o,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:f=>{typeof f.name<"u"&&f.name!==e&&(typeof f.name=="string"&&Jd(f.name),delete this._registeredTools[e],f.name&&(this._registeredTools[f.name]=l)),typeof f.title<"u"&&(l.title=f.title),typeof f.description<"u"&&(l.description=f.description),typeof f.paramsSchema<"u"&&(l.inputSchema=pr(f.paramsSchema)),typeof f.outputSchema<"u"&&(l.outputSchema=pr(f.outputSchema)),typeof f.callback<"u"&&(l.handler=f.callback),typeof f.annotations<"u"&&(l.annotations=f.annotations),typeof f._meta<"u"&&(l._meta=f._meta),typeof f.enabled<"u"&&(l.enabled=f.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,a,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){const c=r[0];Hi(c)?(s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Hi(r[0])&&(i=r.shift())):typeof c=="object"&&c!==null&&(i=r.shift())}const o=r[0];return this._createRegisteredTool(e,void 0,n,s,a,i,{taskSupport:"forbidden"},void 0,o)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:s,description:a,inputSchema:i,outputSchema:o,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,s,a,i,o,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());const a=r[0],i=this._createRegisteredPrompt(e,void 0,n,s,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:s,description:a,argsSchema:i}=r,o=this._createRegisteredPrompt(e,s,a,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}}class kv{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new bt(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}}const Ev={type:"object",properties:{}};function Bd(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Rv(t){return"_def"in t||"_zod"in t||Bd(t)}function Hi(t){return typeof t!="object"||t===null||Rv(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(Bd)}function Gd(t){if(t)return Hi(t)?pr(t):t}function Tv(t){const e=mr(t);return e?Object.entries(e).map(([r,n])=>{const s=V_(n),a=F_(n);return{name:r,description:s,required:!a}}):[]}function qt(t){const r=mr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=sd(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Yd(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}const en={completion:{values:[],hasMore:!1}};$.Ajv=_c,$.AnnotationsSchema=Wt,$.AudioContentSchema=$s,$.BaseMetadataSchema=Ft,$.BlobResourceContentsSchema=Ia,$.BooleanSchemaSchema=ll,$.COMPLETABLE_SYMBOL=Cs,$.CallToolRequestParamsSchema=Qu,$.CallToolRequestSchema=xr,$.CallToolResultSchema=cr,$.CancelTaskRequestSchema=ps,$.CancelTaskResultSchema=zu,$.CancelledNotificationParamsSchema=bu,$.CancelledNotificationSchema=ss,$.Client=qy,$.ClientCapabilitiesSchema=Eu,$.ClientNotificationSchema=a_,$.ClientRequestSchema=s_,$.ClientResultSchema=i_,$.ClientTasksCapabilitySchema=$u,$.CompatibilityCallToolResultSchema=r_,$.CompleteRequestParamsSchema=Pl,$.CompleteRequestSchema=Ps,$.CompleteResultSchema=Wa,$.ContentBlockSchema=ks,$.CreateMessageRequestParamsSchema=ul,$.CreateMessageRequestSchema=Va,$.CreateMessageResultSchema=Rs,$.CreateMessageResultWithToolsSchema=Ts,$.CreateTaskResultSchema=Ht,$.CursorSchema=wa,$.DEFAULT_NEGOTIATED_PROTOCOL_VERSION=Wg,$.DEFAULT_REQUEST_TIMEOUT_MSEC=_d,$.ElicitRequestFormParamsSchema=Sl,$.ElicitRequestParamsSchema=kl,$.ElicitRequestSchema=Fa,$.ElicitRequestURLParamsSchema=$l,$.ElicitResultSchema=Ur,$.ElicitationCompleteNotificationParamsSchema=El,$.ElicitationCompleteNotificationSchema=Rl,$.EmbeddedResourceSchema=Ku,$.EmptyResultSchema=Ot,$.EnumSchemaSchema=wl,$.GetPromptRequestParamsSchema=Hu,$.GetPromptRequestSchema=ws,$.GetPromptResultSchema=qa,$.GetTaskPayloadRequestSchema=ds,$.GetTaskPayloadResultSchema=t_,$.GetTaskRequestSchema=us,$.GetTaskResultSchema=ls,$.IconSchema=Su,$.IconsSchema=nr,$.ImageContentSchema=Ss,$.ImplementationSchema=Ea,$.InitializeRequestParamsSchema=Ru,$.InitializeRequestSchema=as,$.InitializeResultSchema=Ra,$.InitializedNotificationSchema=is,$.JSONRPCErrorResponseSchema=Mr,$.JSONRPCErrorSchema=Bg,$.JSONRPCMessageSchema=qr,$.JSONRPCNotificationSchema=$a,$.JSONRPCRequestSchema=Sa,$.JSONRPCResponseSchema=Yg,$.JSONRPCResultResponseSchema=ns,$.JSONRPC_VERSION=zr,$.LATEST_PROTOCOL_VERSION=Ut,$.LegacyTitledEnumSchemaSchema=ml,$.ListChangedOptionsBaseSchema=Xu,$.ListPromptsRequestSchema=vs,$.ListPromptsResultSchema=Ma,$.ListResourceTemplatesRequestSchema=gs,$.ListResourceTemplatesResultSchema=Aa,$.ListResourcesRequestSchema=ms,$.ListResourcesResultSchema=Na,$.ListRootsRequestSchema=Nl,$.ListRootsResultSchema=Ka,$.ListTasksRequestSchema=fs,$.ListTasksResultSchema=hs,$.ListToolsRequestSchema=Es,$.ListToolsResultSchema=La,$.LoggingLevelSchema=Lr,$.LoggingMessageNotificationParamsSchema=tl,$.LoggingMessageNotificationSchema=rl,$.McpError=B,$.McpServer=$v,$.ModelHintSchema=nl,$.ModelPreferencesSchema=sl,$.MultiSelectEnumSchemaSchema=vl,$.NotificationSchema=rt,$.NumberSchemaSchema=fl,$.PaginatedRequestParamsSchema=Ou,$.PaginatedRequestSchema=sr,$.PaginatedResultSchema=ar,$.PingRequestSchema=os,$.PrimitiveSchemaDefinitionSchema=bl,$.ProgressNotificationParamsSchema=Iu,$.ProgressNotificationSchema=cs,$.ProgressSchema=Cu,$.ProgressTokenSchema=va,$.PromptArgumentSchema=Vu,$.PromptListChangedNotificationSchema=Za,$.PromptMessageSchema=Bu,$.PromptReferenceSchema=Tl,$.PromptSchema=Fu,$.Protocol=oi,$.RELATED_TASK_META_KEY=It,$.ReadResourceRequestParamsSchema=Mu,$.ReadResourceRequestSchema=ys,$.ReadResourceResultSchema=za,$.RelatedTaskMetadataSchema=yu,$.RequestIdSchema=jr,$.RequestSchema=Me,$.ResourceContentsSchema=Ta,$.ResourceLinkSchema=Ju,$.ResourceListChangedNotificationSchema=ja,$.ResourceReferenceSchema=n_,$.ResourceRequestParamsSchema=_s,$.ResourceSchema=Oa,$.ResourceTemplate=kv,$.ResourceTemplateReferenceSchema=Ha,$.ResourceTemplateSchema=ju,$.ResourceUpdatedNotificationParamsSchema=Du,$.ResourceUpdatedNotificationSchema=Uu,$.ResultSchema=qe,$.RoleSchema=or,$.RootSchema=Ol,$.RootsListChangedNotificationSchema=Al,$.SSEClientTransport=hv,$.SUPPORTED_PROTOCOL_VERSIONS=ya,$.SamplingContentSchema=ol,$.SamplingMessageContentBlockSchema=Dr,$.SamplingMessageSchema=cl,$.ServerCapabilitiesSchema=Tu,$.ServerNotificationSchema=c_,$.ServerRequestSchema=o_,$.ServerResultSchema=u_,$.ServerTasksCapabilitySchema=ku,$.SetLevelRequestParamsSchema=el,$.SetLevelRequestSchema=Ua,$.SingleSelectEnumSchemaSchema=gl,$.SseError=Kd,$.StreamableHTTPClientTransport=gv,$.StreamableHTTPError=Qt,$.StringSchemaSchema=dl,$.SubscribeRequestParamsSchema=qu,$.SubscribeRequestSchema=Zu,$.TaskAugmentedRequestParamsSchema=rr,$.TaskCreationParamsSchema=Kg,$.TaskMetadataSchema=_u,$.TaskSchema=ir,$.TaskStatusNotificationParamsSchema=Au,$.TaskStatusNotificationSchema=Zr,$.TaskStatusSchema=Nu,$.TextContentSchema=bs,$.TextResourceContentsSchema=Pa,$.TitledMultiSelectEnumSchemaSchema=yl,$.TitledSingleSelectEnumSchemaSchema=pl,$.ToolAnnotationsSchema=Gu,$.ToolChoiceSchema=al,$.ToolExecutionSchema=Yu,$.ToolListChangedNotificationSchema=Da,$.ToolResultContentSchema=il,$.ToolSchema=xa,$.ToolUseContentSchema=Wu,$.UnauthorizedError=it,$.UnsubscribeRequestParamsSchema=xu,$.UnsubscribeRequestSchema=Lu,$.UntitledMultiSelectEnumSchemaSchema=_l,$.UntitledSingleSelectEnumSchemaSchema=hl,$.UriTemplate=bt,$.UrlElicitationRequiredError=zl,$.assertCompleteRequestPrompt=Cl,$.assertCompleteRequestResourceTemplate=Il,$.auth=jt,$.buildDiscoveryUrls=Ad,$.completable=d_,$.createFetchWithInit=Fi,$.discoverAuthorizationServerMetadata=zd,$.discoverOAuthMetadata=cv,$.discoverOAuthProtectedResourceMetadata=Id,$.exchangeAuthorization=uv,$.extractResourceMetadataUrl=av,$.extractWWWAuthenticateParams=Jr,$.fetchToken=qd,$.getCompleter=ql,$.getDisplayName=h_,$.getSupportedElicitationModes=Ed,$.isCompletable=Ba,$.isHttpsUrl=Pd,$.isInitializeRequest=e_,$.isInitializedNotification=Pu,$.isJSONRPCError=Gg,$.isJSONRPCErrorResponse=ka,$.isJSONRPCNotification=wu,$.isJSONRPCRequest=rs,$.isJSONRPCResponse=Jg,$.isJSONRPCResultResponse=Vt,$.isTaskAugmentedRequestParams=vu,$.mergeCapabilities=ci,$.normalizeHeaders=Xr,$.parseErrorResponse=Ti,$.prepareAuthorizationCodeRequest=Oi,$.refreshAuthorization=Md,$.registerClient=Zd,$.selectClientAuthMethod=Td,$.selectResourceURL=Cd,$.startAuthorization=jd,$.unwrapCompletable=f_,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}));
|