@opentiny/next-sdk 0.1.15 → 0.2.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.
Files changed (42) hide show
  1. package/WebMcpClient.ts +17 -19
  2. package/WebMcpServer.ts +11 -8
  3. package/agent/AgentModelProvider.ts +495 -2
  4. package/agent/type.ts +9 -3
  5. package/agent/utils/generateReActPrompt.ts +55 -0
  6. package/agent/utils/parseReActAction.ts +34 -0
  7. package/dist/WebMcpClient.d.ts +176 -35
  8. package/dist/WebMcpServer.d.ts +43 -154
  9. package/dist/agent/AgentModelProvider.d.ts +35 -1
  10. package/dist/agent/type.d.ts +9 -2
  11. package/dist/agent/utils/generateReActPrompt.d.ts +9 -0
  12. package/dist/agent/utils/parseReActAction.d.ts +14 -0
  13. package/dist/index.es.dev.js +16154 -12116
  14. package/dist/index.es.js +22208 -19236
  15. package/dist/index.js +2411 -320
  16. package/dist/index.umd.dev.js +16147 -12109
  17. package/dist/index.umd.js +109 -67
  18. package/dist/{mcpsdk@1.23.0.dev.js → mcpsdk@1.25.2.dev.js} +8592 -6902
  19. package/dist/{mcpsdk@1.23.0.es.dev.js → mcpsdk@1.25.2.es.dev.js} +8601 -6911
  20. package/dist/mcpsdk@1.25.2.es.js +16796 -0
  21. package/dist/mcpsdk@1.25.2.js +43 -0
  22. package/dist/transport/ExtensionPageServerTransport.d.ts +1 -2
  23. package/dist/webagent.dev.js +15216 -11451
  24. package/dist/webagent.es.dev.js +15260 -11495
  25. package/dist/webagent.es.js +17923 -15160
  26. package/dist/webagent.js +96 -54
  27. package/dist/webmcp-full.dev.js +9872 -8168
  28. package/dist/webmcp-full.es.dev.js +9870 -8166
  29. package/dist/webmcp-full.es.js +10712 -9513
  30. package/dist/webmcp-full.js +31 -31
  31. package/dist/webmcp.dev.js +666 -640
  32. package/dist/webmcp.es.dev.js +664 -638
  33. package/dist/webmcp.es.js +651 -619
  34. package/dist/webmcp.js +1 -1
  35. package/dist/zod@3.25.76.dev.js +30 -32
  36. package/dist/zod@3.25.76.es.dev.js +28 -30
  37. package/dist/zod@3.25.76.es.js +143 -145
  38. package/dist/zod@3.25.76.js +1 -1
  39. package/package.json +10 -9
  40. package/transport/ExtensionPageServerTransport.ts +2 -4
  41. package/dist/mcpsdk@1.23.0.es.js +0 -15584
  42. package/dist/mcpsdk@1.23.0.js +0 -43
@@ -1,43 +1,43 @@
1
- (function(me,_r){typeof exports=="object"&&typeof module<"u"?_r(exports):typeof define=="function"&&define.amd?define(["exports"],_r):(me=typeof globalThis<"u"?globalThis:me||self,_r(me.WebMCP={}))})(this,function(me){"use strict";function _r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var no={exports:{}},Ja={},ot={},gr={},qr={},Q={},Vr={};(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(m){if(super(),!t.IDENTIFIER.test(m))throw new Error("CodeGen: name must be a valid identifier");this.str=m}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(m){super(),this._items=typeof m=="string"?[m]:m}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const m=this._items[0];return m===""||m==='""'}get str(){var m;return(m=this._str)!==null&&m!==void 0?m:this._str=this._items.reduce((w,S)=>`${w}${S}`,"")}get names(){var m;return(m=this._names)!==null&&m!==void 0?m:this._names=this._items.reduce((w,S)=>(S instanceof r&&(w[S.str]=(w[S.str]||0)+1),w),{})}}t._Code=n,t.nil=new n("");function s(d,...m){const w=[d[0]];let S=0;for(;S<m.length;)a(w,m[S]),w.push(d[++S]);return new n(w)}t._=s;const o=new n("+");function i(d,...m){const w=[y(d[0])];let S=0;for(;S<m.length;)w.push(o),a(w,m[S]),w.push(o,y(d[++S]));return c(w),new n(w)}t.str=i;function a(d,m){m instanceof n?d.push(...m._items):m instanceof r?d.push(m):d.push(f(m))}t.addCodeArg=a;function c(d){let m=1;for(;m<d.length-1;){if(d[m]===o){const w=u(d[m-1],d[m+1]);if(w!==void 0){d.splice(m-1,3,w);continue}d[m++]="+"}m++}}function u(d,m){if(m==='""')return d;if(d==='""')return m;if(typeof d=="string")return m instanceof r||d[d.length-1]!=='"'?void 0:typeof m!="string"?`${d.slice(0,-1)}${m}"`:m[0]==='"'?d.slice(0,-1)+m.slice(1):void 0;if(typeof m=="string"&&m[0]==='"'&&!(d instanceof r))return`"${d}${m.slice(1)}`}function l(d,m){return m.emptyStr()?d:d.emptyStr()?m:i`${d}${m}`}t.strConcat=l;function f(d){return typeof d=="number"||typeof d=="boolean"||d===null?d:y(Array.isArray(d)?d.join(","):d)}function _(d){return new n(y(d))}t.stringify=_;function y(d){return JSON.stringify(d).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=y;function g(d){return typeof d=="string"&&t.IDENTIFIER.test(d)?new n(`.${d}`):s`[${d}]`}t.getProperty=g;function v(d){if(typeof d=="string"&&t.IDENTIFIER.test(d))return new n(`${d}`);throw new Error(`CodeGen: invalid export name: ${d}, use explicit $id name mapping`)}t.getEsmExportName=v;function h(d){return new n(d.toString())}t.regexpCode=h})(Vr);var so={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=Vr;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 o 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=o;const i=(0,e._)`\n`;class a 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 o(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 _=this.toName(u),{prefix:y}=_,g=(f=l.key)!==null&&f!==void 0?f:l.ref;let v=this._values[y];if(v){const m=v.get(g);if(m)return m}else v=this._values[y]=new Map;v.set(g,_);const h=this._scope[y]||(this._scope[y]=[]),d=h.length;return h[d]=l.ref,_.setValue(l,{property:y,itemIndex:d}),_}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,_=>{if(_.value===void 0)throw new Error(`CodeGen: name "${_}" has no value`);return _.value.code},l,f)}_reduceValues(u,l,f={},_){let y=e.nil;for(const g in u){const v=u[g];if(!v)continue;const h=f[g]=f[g]||new Map;v.forEach(d=>{if(h.has(d))return;h.set(d,n.Started);let m=l(d);if(m){const w=this.opts.es5?t.varKinds.var:t.varKinds.const;y=(0,e._)`${y}${w} ${d} = ${m};${this.opts._n}`}else if(m=_==null?void 0:_(d))y=(0,e._)`${y}${m}${this.opts._n}`;else throw new r(d);h.set(d,n.Completed)})}return y}}t.ValueScope=a})(so),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=Vr,r=so;var n=Vr;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=so;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 o{optimizeNodes(){return this}optimizeNames(p,b){return this}}class i extends o{constructor(p,b,x){super(),this.varKind=p,this.name=b,this.rhs=x}render({es5:p,_n:b}){const x=p?r.varKinds.var:this.varKind,F=this.rhs===void 0?"":` = ${this.rhs}`;return`${x} ${this.name}${F};`+b}optimizeNames(p,b){if(p[this.name.str])return this.rhs&&(this.rhs=se(this.rhs,p,b)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class a extends o{constructor(p,b,x){super(),this.lhs=p,this.rhs=b,this.sideEffects=x}render({_n:p}){return`${this.lhs} = ${this.rhs};`+p}optimizeNames(p,b){if(!(this.lhs instanceof e.Name&&!p[this.lhs.str]&&!this.sideEffects))return this.rhs=se(this.rhs,p,b),this}get names(){const p=this.lhs instanceof e.Name?{}:{...this.lhs.names};return Se(p,this.rhs)}}class c extends a{constructor(p,b,x,F){super(p,x,F),this.op=b}render({_n:p}){return`${this.lhs} ${this.op}= ${this.rhs};`+p}}class u extends o{constructor(p){super(),this.label=p,this.names={}}render({_n:p}){return`${this.label}:`+p}}class l extends o{constructor(p){super(),this.label=p,this.names={}}render({_n:p}){return`break${this.label?` ${this.label}`:""};`+p}}class f extends o{constructor(p){super(),this.error=p}render({_n:p}){return`throw ${this.error};`+p}get names(){return this.error.names}}class _ extends o{constructor(p){super(),this.code=p}render({_n:p}){return`${this.code};`+p}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(p,b){return this.code=se(this.code,p,b),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class y extends o{constructor(p=[]){super(),this.nodes=p}render(p){return this.nodes.reduce((b,x)=>b+x.render(p),"")}optimizeNodes(){const{nodes:p}=this;let b=p.length;for(;b--;){const x=p[b].optimizeNodes();Array.isArray(x)?p.splice(b,1,...x):x?p[b]=x:p.splice(b,1)}return p.length>0?this:void 0}optimizeNames(p,b){const{nodes:x}=this;let F=x.length;for(;F--;){const H=x[F];H.optimizeNames(p,b)||(De(p,H.names),x.splice(F,1))}return x.length>0?this:void 0}get names(){return this.nodes.reduce((p,b)=>K(p,b.names),{})}}class g extends y{render(p){return"{"+p._n+super.render(p)+"}"+p._n}}class v extends y{}class h extends g{}h.kind="else";class d extends g{constructor(p,b){super(b),this.condition=p}render(p){let b=`if(${this.condition})`+super.render(p);return this.else&&(b+="else "+this.else.render(p)),b}optimizeNodes(){super.optimizeNodes();const p=this.condition;if(p===!0)return this.nodes;let b=this.else;if(b){const x=b.optimizeNodes();b=this.else=Array.isArray(x)?new h(x):x}if(b)return p===!1?b instanceof d?b:b.nodes:this.nodes.length?this:new d(Zt(p),b instanceof d?[b]:b.nodes);if(!(p===!1||!this.nodes.length))return this}optimizeNames(p,b){var x;if(this.else=(x=this.else)===null||x===void 0?void 0:x.optimizeNames(p,b),!!(super.optimizeNames(p,b)||this.else))return this.condition=se(this.condition,p,b),this}get names(){const p=super.names;return Se(p,this.condition),this.else&&K(p,this.else.names),p}}d.kind="if";class m extends g{}m.kind="for";class w extends m{constructor(p){super(),this.iteration=p}render(p){return`for(${this.iteration})`+super.render(p)}optimizeNames(p,b){if(super.optimizeNames(p,b))return this.iteration=se(this.iteration,p,b),this}get names(){return K(super.names,this.iteration.names)}}class S extends m{constructor(p,b,x,F){super(),this.varKind=p,this.name=b,this.from=x,this.to=F}render(p){const b=p.es5?r.varKinds.var:this.varKind,{name:x,from:F,to:H}=this;return`for(${b} ${x}=${F}; ${x}<${H}; ${x}++)`+super.render(p)}get names(){const p=Se(super.names,this.from);return Se(p,this.to)}}class P extends m{constructor(p,b,x,F){super(),this.loop=p,this.varKind=b,this.name=x,this.iterable=F}render(p){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(p)}optimizeNames(p,b){if(super.optimizeNames(p,b))return this.iterable=se(this.iterable,p,b),this}get names(){return K(super.names,this.iterable.names)}}class O extends g{constructor(p,b,x){super(),this.name=p,this.args=b,this.async=x}render(p){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(p)}}O.kind="func";class V extends y{render(p){return"return "+super.render(p)}}V.kind="return";class ce extends g{render(p){let b="try"+super.render(p);return this.catch&&(b+=this.catch.render(p)),this.finally&&(b+=this.finally.render(p)),b}optimizeNodes(){var p,b;return super.optimizeNodes(),(p=this.catch)===null||p===void 0||p.optimizeNodes(),(b=this.finally)===null||b===void 0||b.optimizeNodes(),this}optimizeNames(p,b){var x,F;return super.optimizeNames(p,b),(x=this.catch)===null||x===void 0||x.optimizeNames(p,b),(F=this.finally)===null||F===void 0||F.optimizeNames(p,b),this}get names(){const p=super.names;return this.catch&&K(p,this.catch.names),this.finally&&K(p,this.finally.names),p}}class G extends g{constructor(p){super(),this.error=p}render(p){return`catch(${this.error})`+super.render(p)}}G.kind="catch";class Ae extends g{render(p){return"finally"+super.render(p)}}Ae.kind="finally";class U{constructor(p,b={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...b,_n:b.lines?`
2
- `:""},this._extScope=p,this._scope=new r.Scope({parent:p}),this._nodes=[new v]}toString(){return this._root.render(this.opts)}name(p){return this._scope.name(p)}scopeName(p){return this._extScope.name(p)}scopeValue(p,b){const x=this._extScope.value(p,b);return(this._values[x.prefix]||(this._values[x.prefix]=new Set)).add(x),x}getScopeValue(p,b){return this._extScope.getValue(p,b)}scopeRefs(p){return this._extScope.scopeRefs(p,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(p,b,x,F){const H=this._scope.toName(b);return x!==void 0&&F&&(this._constants[H.str]=x),this._leafNode(new i(p,H,x)),H}const(p,b,x){return this._def(r.varKinds.const,p,b,x)}let(p,b,x){return this._def(r.varKinds.let,p,b,x)}var(p,b,x){return this._def(r.varKinds.var,p,b,x)}assign(p,b,x){return this._leafNode(new a(p,b,x))}add(p,b){return this._leafNode(new c(p,t.operators.ADD,b))}code(p){return typeof p=="function"?p():p!==e.nil&&this._leafNode(new _(p)),this}object(...p){const b=["{"];for(const[x,F]of p)b.length>1&&b.push(","),b.push(x),(x!==F||this.opts.es5)&&(b.push(":"),(0,e.addCodeArg)(b,F));return b.push("}"),new e._Code(b)}if(p,b,x){if(this._blockNode(new d(p)),b&&x)this.code(b).else().code(x).endIf();else if(b)this.code(b).endIf();else if(x)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(p){return this._elseNode(new d(p))}else(){return this._elseNode(new h)}endIf(){return this._endBlockNode(d,h)}_for(p,b){return this._blockNode(p),b&&this.code(b).endFor(),this}for(p,b){return this._for(new w(p),b)}forRange(p,b,x,F,H=this.opts.es5?r.varKinds.var:r.varKinds.let){const fe=this._scope.toName(p);return this._for(new S(H,fe,b,x),()=>F(fe))}forOf(p,b,x,F=r.varKinds.const){const H=this._scope.toName(p);if(this.opts.es5){const fe=b instanceof e.Name?b:this.var("_arr",b);return this.forRange("_i",0,(0,e._)`${fe}.length`,le=>{this.var(H,(0,e._)`${fe}[${le}]`),x(H)})}return this._for(new P("of",F,H,b),()=>x(H))}forIn(p,b,x,F=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(p,(0,e._)`Object.keys(${b})`,x);const H=this._scope.toName(p);return this._for(new P("in",F,H,b),()=>x(H))}endFor(){return this._endBlockNode(m)}label(p){return this._leafNode(new u(p))}break(p){return this._leafNode(new l(p))}return(p){const b=new V;if(this._blockNode(b),this.code(p),b.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(V)}try(p,b,x){if(!b&&!x)throw new Error('CodeGen: "try" without "catch" and "finally"');const F=new ce;if(this._blockNode(F),this.code(p),b){const H=this.name("e");this._currNode=F.catch=new G(H),b(H)}return x&&(this._currNode=F.finally=new Ae,this.code(x)),this._endBlockNode(G,Ae)}throw(p){return this._leafNode(new f(p))}block(p,b){return this._blockStarts.push(this._nodes.length),p&&this.code(p).endBlock(b),this}endBlock(p){const b=this._blockStarts.pop();if(b===void 0)throw new Error("CodeGen: not in self-balancing block");const x=this._nodes.length-b;if(x<0||p!==void 0&&x!==p)throw new Error(`CodeGen: wrong number of nodes: ${x} vs ${p} expected`);return this._nodes.length=b,this}func(p,b=e.nil,x,F){return this._blockNode(new O(p,b,x)),F&&this.code(F).endFunc(),this}endFunc(){return this._endBlockNode(O)}optimize(p=1){for(;p-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(p){return this._currNode.nodes.push(p),this}_blockNode(p){this._currNode.nodes.push(p),this._nodes.push(p)}_endBlockNode(p,b){const x=this._currNode;if(x instanceof p||b&&x instanceof b)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${b?`${p.kind}/${b.kind}`:p.kind}"`)}_elseNode(p){const b=this._currNode;if(!(b instanceof d))throw new Error('CodeGen: "else" without "if"');return this._currNode=b.else=p,this}get _root(){return this._nodes[0]}get _currNode(){const p=this._nodes;return p[p.length-1]}set _currNode(p){const b=this._nodes;b[b.length-1]=p}}t.CodeGen=U;function K(E,p){for(const b in p)E[b]=(E[b]||0)+(p[b]||0);return E}function Se(E,p){return p instanceof e._CodeOrName?K(E,p.names):E}function se(E,p,b){if(E instanceof e.Name)return x(E);if(!F(E))return E;return new e._Code(E._items.reduce((H,fe)=>(fe instanceof e.Name&&(fe=x(fe)),fe instanceof e._Code?H.push(...fe._items):H.push(fe),H),[]));function x(H){const fe=b[H.str];return fe===void 0||p[H.str]!==1?H:(delete p[H.str],fe)}function F(H){return H instanceof e._Code&&H._items.some(fe=>fe instanceof e.Name&&p[fe.str]===1&&b[fe.str]!==void 0)}}function De(E,p){for(const b in p)E[b]=(E[b]||0)-(p[b]||0)}function Zt(E){return typeof E=="boolean"||typeof E=="number"||E===null?!E:(0,e._)`!${R(E)}`}t.not=Zt;const Lt=k(t.operators.AND);function Ln(...E){return E.reduce(Lt)}t.and=Ln;const mr=k(t.operators.OR);function N(...E){return E.reduce(mr)}t.or=N;function k(E){return(p,b)=>p===e.nil?b:b===e.nil?p:(0,e._)`${R(p)} ${E} ${R(b)}`}function R(E){return E instanceof e.Name?E:(0,e._)`(${E})`}}(Q);var M={};Object.defineProperty(M,"__esModule",{value:!0}),M.checkStrictMode=M.getErrorPath=M.Type=M.useFunc=M.setEvaluated=M.evaluatedPropsToName=M.mergeEvaluated=M.eachItem=M.unescapeJsonPointer=M.escapeJsonPointer=M.escapeFragment=M.unescapeFragment=M.schemaRefOrVal=M.schemaHasRulesButRef=M.schemaHasRules=M.checkUnknownRules=M.alwaysValidSchema=M.toHash=void 0;const he=Q,ef=Vr;function tf(t){const e={};for(const r of t)e[r]=!0;return e}M.toHash=tf;function rf(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Ba(t,e),!Ka(e,t.self.RULES.all))}M.alwaysValidSchema=rf;function Ba(t,e=t.schema){const{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;const s=n.RULES.keywords;for(const o in e)s[o]||ec(t,`unknown keyword: "${o}"`)}M.checkUnknownRules=Ba;function Ka(t,e){if(typeof t=="boolean")return!t;for(const r in t)if(e[r])return!0;return!1}M.schemaHasRules=Ka;function nf(t,e){if(typeof t=="boolean")return!t;for(const r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}M.schemaHasRulesButRef=nf;function sf({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,he._)`${r}`}return(0,he._)`${t}${e}${(0,he.getProperty)(n)}`}M.schemaRefOrVal=sf;function of(t){return Ga(decodeURIComponent(t))}M.unescapeFragment=of;function af(t){return encodeURIComponent(oo(t))}M.escapeFragment=af;function oo(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}M.escapeJsonPointer=oo;function Ga(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}M.unescapeJsonPointer=Ga;function cf(t,e){if(Array.isArray(t))for(const r of t)e(r);else e(t)}M.eachItem=cf;function Ya({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{const c=i===void 0?o:i instanceof he.Name?(o instanceof he.Name?t(s,o,i):e(s,o,i),i):o instanceof he.Name?(e(s,i,o),o):r(o,i);return a===he.Name&&!(c instanceof he.Name)?n(s,c):c}}M.mergeEvaluated={props:Ya({mergeNames:(t,e,r)=>t.if((0,he._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,he._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,he._)`${r} || {}`).code((0,he._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,he._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,he._)`${r} || {}`),io(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Xa}),items:Ya({mergeNames:(t,e,r)=>t.if((0,he._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,he._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,he._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,he._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Xa(t,e){if(e===!0)return t.var("props",!0);const r=t.var("props",(0,he._)`{}`);return e!==void 0&&io(t,r,e),r}M.evaluatedPropsToName=Xa;function io(t,e,r){Object.keys(r).forEach(n=>t.assign((0,he._)`${e}${(0,he.getProperty)(n)}`,!0))}M.setEvaluated=io;const Qa={};function uf(t,e){return t.scopeValue("func",{ref:e,code:Qa[e.code]||(Qa[e.code]=new ef._Code(e.code))})}M.useFunc=uf;var ao;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(ao||(M.Type=ao={}));function lf(t,e,r){if(t instanceof he.Name){const n=e===ao.Num;return r?n?(0,he._)`"[" + ${t} + "]"`:(0,he._)`"['" + ${t} + "']"`:n?(0,he._)`"/" + ${t}`:(0,he._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,he.getProperty)(t).toString():"/"+oo(t)}M.getErrorPath=lf;function ec(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}M.checkStrictMode=ec;var bt={};Object.defineProperty(bt,"__esModule",{value:!0});const qe=Q,df={data:new qe.Name("data"),valCxt:new qe.Name("valCxt"),instancePath:new qe.Name("instancePath"),parentData:new qe.Name("parentData"),parentDataProperty:new qe.Name("parentDataProperty"),rootData:new qe.Name("rootData"),dynamicAnchors:new qe.Name("dynamicAnchors"),vErrors:new qe.Name("vErrors"),errors:new qe.Name("errors"),this:new qe.Name("this"),self:new qe.Name("self"),scope:new qe.Name("scope"),json:new qe.Name("json"),jsonPos:new qe.Name("jsonPos"),jsonLen:new qe.Name("jsonLen"),jsonPart:new qe.Name("jsonPart")};bt.default=df,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=Q,r=M,n=bt;t.keywordError={message:({keyword:h})=>(0,e.str)`must pass "${h}" keyword validation`},t.keyword$DataError={message:({keyword:h,schemaType:d})=>d?(0,e.str)`"${h}" keyword must be ${d} ($data)`:(0,e.str)`"${h}" keyword is invalid ($data)`};function s(h,d=t.keywordError,m,w){const{it:S}=h,{gen:P,compositeRule:O,allErrors:V}=S,ce=f(h,d,m);w??(O||V)?c(P,ce):u(S,(0,e._)`[${ce}]`)}t.reportError=s;function o(h,d=t.keywordError,m){const{it:w}=h,{gen:S,compositeRule:P,allErrors:O}=w,V=f(h,d,m);c(S,V),P||O||u(w,n.default.vErrors)}t.reportExtraError=o;function i(h,d){h.assign(n.default.errors,d),h.if((0,e._)`${n.default.vErrors} !== null`,()=>h.if(d,()=>h.assign((0,e._)`${n.default.vErrors}.length`,d),()=>h.assign(n.default.vErrors,null)))}t.resetErrorsCount=i;function a({gen:h,keyword:d,schemaValue:m,data:w,errsCount:S,it:P}){if(S===void 0)throw new Error("ajv implementation error");const O=h.name("err");h.forRange("i",S,n.default.errors,V=>{h.const(O,(0,e._)`${n.default.vErrors}[${V}]`),h.if((0,e._)`${O}.instancePath === undefined`,()=>h.assign((0,e._)`${O}.instancePath`,(0,e.strConcat)(n.default.instancePath,P.errorPath))),h.assign((0,e._)`${O}.schemaPath`,(0,e.str)`${P.errSchemaPath}/${d}`),P.opts.verbose&&(h.assign((0,e._)`${O}.schema`,m),h.assign((0,e._)`${O}.data`,w))})}t.extendErrors=a;function c(h,d){const m=h.const("err",d);h.if((0,e._)`${n.default.vErrors} === null`,()=>h.assign(n.default.vErrors,(0,e._)`[${m}]`),(0,e._)`${n.default.vErrors}.push(${m})`),h.code((0,e._)`${n.default.errors}++`)}function u(h,d){const{gen:m,validateName:w,schemaEnv:S}=h;S.$async?m.throw((0,e._)`new ${h.ValidationError}(${d})`):(m.assign((0,e._)`${w}.errors`,d),m.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(h,d,m){const{createErrors:w}=h.it;return w===!1?(0,e._)`{}`:_(h,d,m)}function _(h,d,m={}){const{gen:w,it:S}=h,P=[y(S,m),g(h,m)];return v(h,d,P),w.object(...P)}function y({errorPath:h},{instancePath:d}){const m=d?(0,e.str)`${h}${(0,r.getErrorPath)(d,r.Type.Str)}`:h;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,m)]}function g({keyword:h,it:{errSchemaPath:d}},{schemaPath:m,parentSchema:w}){let S=w?d:(0,e.str)`${d}/${h}`;return m&&(S=(0,e.str)`${S}${(0,r.getErrorPath)(m,r.Type.Str)}`),[l.schemaPath,S]}function v(h,{params:d,message:m},w){const{keyword:S,data:P,schemaValue:O,it:V}=h,{opts:ce,propertyName:G,topSchemaRef:Ae,schemaPath:U}=V;w.push([l.keyword,S],[l.params,typeof d=="function"?d(h):d||(0,e._)`{}`]),ce.messages&&w.push([l.message,typeof m=="function"?m(h):m]),ce.verbose&&w.push([l.schema,O],[l.parentSchema,(0,e._)`${Ae}${U}`],[n.default.data,P]),G&&w.push([l.propertyName,G])}}(qr),Object.defineProperty(gr,"__esModule",{value:!0}),gr.boolOrEmptySchema=gr.topBoolOrEmptySchema=void 0;const ff=qr,hf=Q,pf=bt,mf={message:"boolean schema is false"};function _f(t){const{gen:e,schema:r,validateName:n}=t;r===!1?tc(t,!1):typeof r=="object"&&r.$async===!0?e.return(pf.default.data):(e.assign((0,hf._)`${n}.errors`,null),e.return(!0))}gr.topBoolOrEmptySchema=_f;function gf(t,e){const{gen:r,schema:n}=t;n===!1?(r.var(e,!1),tc(t)):r.var(e,!0)}gr.boolOrEmptySchema=gf;function tc(t,e){const{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,ff.reportError)(s,mf,void 0,e)}var Oe={},tr={};Object.defineProperty(tr,"__esModule",{value:!0}),tr.getRules=tr.isJSONType=void 0;const vf=["string","number","integer","boolean","null","object","array"],yf=new Set(vf);function bf(t){return typeof t=="string"&&yf.has(t)}tr.isJSONType=bf;function wf(){const t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}tr.getRules=wf;var It={};Object.defineProperty(It,"__esModule",{value:!0}),It.shouldUseRule=It.shouldUseGroup=It.schemaHasRulesForType=void 0;function $f({schema:t,self:e},r){const n=e.RULES.types[r];return n&&n!==!0&&rc(t,n)}It.schemaHasRulesForType=$f;function rc(t,e){return e.rules.some(r=>nc(t,r))}It.shouldUseGroup=rc;function nc(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}It.shouldUseRule=nc,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;const Sf=tr,kf=It,Ef=qr,X=Q,sc=M;var vr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(vr||(Oe.DataType=vr={}));function Pf(t){const e=oc(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Oe.getSchemaTypes=Pf;function oc(t){const e=Array.isArray(t)?t:t?[t]:[];if(e.every(Sf.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Oe.getJSONTypes=oc;function Tf(t,e){const{gen:r,data:n,opts:s}=t,o=xf(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,kf.schemaHasRulesForType)(t,e[0]));if(i){const a=uo(e,n,s.strictNumbers,vr.Wrong);r.if(a,()=>{o.length?Rf(t,e,o):lo(t)})}return i}Oe.coerceAndCheckDataType=Tf;const ic=new Set(["string","number","integer","boolean","null"]);function xf(t,e){return e?t.filter(r=>ic.has(r)||e==="array"&&r==="array"):[]}function Rf(t,e,r){const{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,X._)`typeof ${s}`),a=n.let("coerced",(0,X._)`undefined`);o.coerceTypes==="array"&&n.if((0,X._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,X._)`${s}[0]`).assign(i,(0,X._)`typeof ${s}`).if(uo(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,X._)`${a} !== undefined`);for(const u of r)(ic.has(u)||u==="array"&&o.coerceTypes==="array")&&c(u);n.else(),lo(t),n.endIf(),n.if((0,X._)`${a} !== undefined`,()=>{n.assign(s,a),If(t,a)});function c(u){switch(u){case"string":n.elseIf((0,X._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,X._)`"" + ${s}`).elseIf((0,X._)`${s} === null`).assign(a,(0,X._)`""`);return;case"number":n.elseIf((0,X._)`${i} == "boolean" || ${s} === null
3
- || (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,X._)`+${s}`);return;case"integer":n.elseIf((0,X._)`${i} === "boolean" || ${s} === null
4
- || (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,X._)`+${s}`);return;case"boolean":n.elseIf((0,X._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,X._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,X._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,X._)`${i} === "string" || ${i} === "number"
5
- || ${i} === "boolean" || ${s} === null`).assign(a,(0,X._)`[${s}]`)}}}function If({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,X._)`${e} !== undefined`,()=>t.assign((0,X._)`${e}[${r}]`,n))}function co(t,e,r,n=vr.Correct){const s=n===vr.Correct?X.operators.EQ:X.operators.NEQ;let o;switch(t){case"null":return(0,X._)`${e} ${s} null`;case"array":o=(0,X._)`Array.isArray(${e})`;break;case"object":o=(0,X._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,X._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,X._)`typeof ${e} ${s} ${t}`}return n===vr.Correct?o:(0,X.not)(o);function i(a=X.nil){return(0,X.and)((0,X._)`typeof ${e} == "number"`,a,r?(0,X._)`isFinite(${e})`:X.nil)}}Oe.checkDataType=co;function uo(t,e,r,n){if(t.length===1)return co(t[0],e,r,n);let s;const o=(0,sc.toHash)(t);if(o.array&&o.object){const i=(0,X._)`typeof ${e} != "object"`;s=o.null?i:(0,X._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=X.nil;o.number&&delete o.integer;for(const i in o)s=(0,X.and)(s,co(i,e,r,n));return s}Oe.checkDataTypes=uo;const Cf={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,X._)`{type: ${t}}`:(0,X._)`{type: ${e}}`};function lo(t){const e=Of(t);(0,Ef.reportError)(e,Cf)}Oe.reportTypeError=lo;function Of(t){const{gen:e,data:r,schema:n}=t,s=(0,sc.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}var Dn={};Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.assignDefaults=void 0;const yr=Q,Nf=M;function jf(t,e){const{properties:r,items:n}=t.schema;if(e==="object"&&r)for(const s in r)ac(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>ac(t,o,s.default))}Dn.assignDefaults=jf;function ac(t,e,r){const{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;const a=(0,yr._)`${o}${(0,yr.getProperty)(e)}`;if(s){(0,Nf.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,yr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,yr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,yr._)`${a} = ${(0,yr.stringify)(r)}`)}var wt={},te={};Object.defineProperty(te,"__esModule",{value:!0}),te.validateUnion=te.validateArray=te.usePattern=te.callValidateCode=te.schemaProperties=te.allSchemaProperties=te.noPropertyInData=te.propertyInData=te.isOwnProperty=te.hasPropFunc=te.reportMissingProp=te.checkMissingProp=te.checkReportMissingProp=void 0;const ve=Q,fo=M,Ut=bt,Af=M;function zf(t,e){const{gen:r,data:n,it:s}=t;r.if(po(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,ve._)`${e}`},!0),t.error()})}te.checkReportMissingProp=zf;function Mf({gen:t,data:e,it:{opts:r}},n,s){return(0,ve.or)(...n.map(o=>(0,ve.and)(po(t,e,o,r.ownProperties),(0,ve._)`${s} = ${o}`)))}te.checkMissingProp=Mf;function Zf(t,e){t.setParams({missingProperty:e},!0),t.error()}te.reportMissingProp=Zf;function cc(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ve._)`Object.prototype.hasOwnProperty`})}te.hasPropFunc=cc;function ho(t,e,r){return(0,ve._)`${cc(t)}.call(${e}, ${r})`}te.isOwnProperty=ho;function Lf(t,e,r,n){const s=(0,ve._)`${e}${(0,ve.getProperty)(r)} !== undefined`;return n?(0,ve._)`${s} && ${ho(t,e,r)}`:s}te.propertyInData=Lf;function po(t,e,r,n){const s=(0,ve._)`${e}${(0,ve.getProperty)(r)} === undefined`;return n?(0,ve.or)(s,(0,ve.not)(ho(t,e,r))):s}te.noPropertyInData=po;function uc(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}te.allSchemaProperties=uc;function Uf(t,e){return uc(e).filter(r=>!(0,fo.alwaysValidSchema)(t,e[r]))}te.schemaProperties=Uf;function Df({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,u){const l=u?(0,ve._)`${t}, ${e}, ${n}${s}`:e,f=[[Ut.default.instancePath,(0,ve.strConcat)(Ut.default.instancePath,o)],[Ut.default.parentData,i.parentData],[Ut.default.parentDataProperty,i.parentDataProperty],[Ut.default.rootData,Ut.default.rootData]];i.opts.dynamicRef&&f.push([Ut.default.dynamicAnchors,Ut.default.dynamicAnchors]);const _=(0,ve._)`${l}, ${r.object(...f)}`;return c!==ve.nil?(0,ve._)`${a}.call(${c}, ${_})`:(0,ve._)`${a}(${_})`}te.callValidateCode=Df;const qf=(0,ve._)`new RegExp`;function Vf({gen:t,it:{opts:e}},r){const n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,ve._)`${s.code==="new RegExp"?qf:(0,Af.useFunc)(t,s)}(${r}, ${n})`})}te.usePattern=Vf;function Ff(t){const{gen:e,data:r,keyword:n,it:s}=t,o=e.name("valid");if(s.allErrors){const a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){const c=e.const("len",(0,ve._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:fo.Type.Num},o),e.if((0,ve.not)(o),a)})}}te.validateArray=Ff;function Hf(t){const{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,fo.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;const i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{const l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,ve._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,ve.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}te.validateUnion=Hf,Object.defineProperty(wt,"__esModule",{value:!0}),wt.validateKeywordUsage=wt.validSchemaType=wt.funcKeywordCode=wt.macroKeywordCode=void 0;const Fe=Q,rr=bt,Wf=te,Jf=qr;function Bf(t,e){const{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=dc(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);const u=r.name("valid");t.subschema({schema:a,schemaPath:Fe.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}wt.macroKeywordCode=Bf;function Kf(t,e){var r;const{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;Yf(c,e);const u=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,l=dc(n,s,u),f=n.let("valid");t.block$data(f,_),t.ok((r=e.valid)!==null&&r!==void 0?r:f);function _(){if(e.errors===!1)v(),e.modifying&&lc(t),h(()=>t.error());else{const d=e.async?y():g();e.modifying&&lc(t),h(()=>Gf(t,d))}}function y(){const d=n.let("ruleErrs",null);return n.try(()=>v((0,Fe._)`await `),m=>n.assign(f,!1).if((0,Fe._)`${m} instanceof ${c.ValidationError}`,()=>n.assign(d,(0,Fe._)`${m}.errors`),()=>n.throw(m))),d}function g(){const d=(0,Fe._)`${l}.errors`;return n.assign(d,null),v(Fe.nil),d}function v(d=e.async?(0,Fe._)`await `:Fe.nil){const m=c.opts.passContext?rr.default.this:rr.default.self,w=!("compile"in e&&!a||e.schema===!1);n.assign(f,(0,Fe._)`${d}${(0,Wf.callValidateCode)(t,l,m,w)}`,e.modifying)}function h(d){var m;n.if((0,Fe.not)((m=e.valid)!==null&&m!==void 0?m:f),d)}}wt.funcKeywordCode=Kf;function lc(t){const{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Fe._)`${n.parentData}[${n.parentDataProperty}]`))}function Gf(t,e){const{gen:r}=t;r.if((0,Fe._)`Array.isArray(${e})`,()=>{r.assign(rr.default.vErrors,(0,Fe._)`${rr.default.vErrors} === null ? ${e} : ${rr.default.vErrors}.concat(${e})`).assign(rr.default.errors,(0,Fe._)`${rr.default.vErrors}.length`),(0,Jf.extendErrors)(t)},()=>t.error())}function Yf({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function dc(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Fe.stringify)(r)})}function Xf(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}wt.validSchemaType=Xf;function Qf({schema:t,opts:e,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");const i=s.dependencies;if(i!=null&&i.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){const c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}wt.validateKeywordUsage=Qf;var Dt={};Object.defineProperty(Dt,"__esModule",{value:!0}),Dt.extendSubschemaMode=Dt.extendSubschemaData=Dt.getSubschema=void 0;const $t=Q,fc=M;function eh(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){const a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,$t._)`${t.schemaPath}${(0,$t.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,$t._)`${t.schemaPath}${(0,$t.getProperty)(e)}${(0,$t.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,fc.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}Dt.getSubschema=eh;function th(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:a}=e;if(r!==void 0){const{errorPath:u,dataPathArr:l,opts:f}=e,_=a.let("data",(0,$t._)`${e.data}${(0,$t.getProperty)(r)}`,!0);c(_),t.errorPath=(0,$t.str)`${u}${(0,fc.getErrorPath)(r,n,f.jsPropertySyntax)}`,t.parentDataProperty=(0,$t._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){const u=s instanceof $t.Name?s:a.let("data",s,!0);c(u),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Dt.extendSubschemaData=th;function rh(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}Dt.extendSubschemaMode=rh;var Me={},hc=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,o;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(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r},pc={exports:{}},qt=pc.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};qn(e,n,s,t,"",t)};qt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},qt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},qt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},qt.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 qn(t,e,r,n,s,o,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,o,i,a,c,u);for(var l in n){var f=n[l];if(Array.isArray(f)){if(l in qt.arrayKeywords)for(var _=0;_<f.length;_++)qn(t,e,r,f[_],s+"/"+l+"/"+_,o,s,l,n,_)}else if(l in qt.propsKeywords){if(f&&typeof f=="object")for(var y in f)qn(t,e,r,f[y],s+"/"+l+"/"+nh(y),o,s,l,n,y)}else(l in qt.keywords||t.allKeys&&!(l in qt.skipKeywords))&&qn(t,e,r,f,s+"/"+l,o,s,l,n)}r(n,s,o,i,a,c,u)}}function nh(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}var sh=pc.exports;Object.defineProperty(Me,"__esModule",{value:!0}),Me.getSchemaRefs=Me.resolveUrl=Me.normalizeId=Me._getFullPath=Me.getFullPath=Me.inlineRef=void 0;const oh=M,ih=hc,ah=sh,ch=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function uh(t,e=!0){return typeof t=="boolean"?!0:e===!0?!mo(t):e?mc(t)<=e:!1}Me.inlineRef=uh;const lh=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function mo(t){for(const e in t){if(lh.has(e))return!0;const r=t[e];if(Array.isArray(r)&&r.some(mo)||typeof r=="object"&&mo(r))return!0}return!1}function mc(t){let e=0;for(const r in t){if(r==="$ref")return 1/0;if(e++,!ch.has(r)&&(typeof t[r]=="object"&&(0,oh.eachItem)(t[r],n=>e+=mc(n)),e===1/0))return 1/0}return e}function _c(t,e="",r){r!==!1&&(e=br(e));const n=t.parse(e);return gc(t,n)}Me.getFullPath=_c;function gc(t,e){return t.serialize(e).split("#")[0]+"#"}Me._getFullPath=gc;const dh=/#\/?$/;function br(t){return t?t.replace(dh,""):""}Me.normalizeId=br;function fh(t,e,r){return r=br(r),t.resolve(e,r)}Me.resolveUrl=fh;const hh=/^[a-z_][-a-z0-9._]*$/i;function ph(t,e){if(typeof t=="boolean")return{};const{schemaId:r,uriResolver:n}=this.opts,s=br(t[r]||e),o={"":s},i=_c(n,s,!1),a={},c=new Set;return ah(t,{allKeys:!0},(f,_,y,g)=>{if(g===void 0)return;const v=i+_;let h=o[g];typeof f[r]=="string"&&(h=d.call(this,f[r])),m.call(this,f.$anchor),m.call(this,f.$dynamicAnchor),o[_]=h;function d(w){const S=this.opts.uriResolver.resolve;if(w=br(h?S(h,w):w),c.has(w))throw l(w);c.add(w);let P=this.refs[w];return typeof P=="string"&&(P=this.refs[P]),typeof P=="object"?u(f,P.schema,w):w!==br(v)&&(w[0]==="#"?(u(f,a[w],w),a[w]=f):this.refs[w]=v),w}function m(w){if(typeof w=="string"){if(!hh.test(w))throw new Error(`invalid anchor "${w}"`);d.call(this,`#${w}`)}}}),a;function u(f,_,y){if(_!==void 0&&!ih(f,_))throw l(y)}function l(f){return new Error(`reference "${f}" resolves to more than one schema`)}}Me.getSchemaRefs=ph,Object.defineProperty(ot,"__esModule",{value:!0}),ot.getData=ot.KeywordCxt=ot.validateFunctionCode=void 0;const vc=gr,yc=Oe,_o=It,Vn=Oe,mh=Dn,Fr=wt,go=Dt,q=Q,B=bt,_h=Me,Ct=M,Hr=qr;function gh(t){if(Sc(t)&&(kc(t),$c(t))){bh(t);return}bc(t,()=>(0,vc.topBoolOrEmptySchema)(t))}ot.validateFunctionCode=gh;function bc({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,q._)`${B.default.data}, ${B.default.valCxt}`,n.$async,()=>{t.code((0,q._)`"use strict"; ${wc(r,s)}`),yh(t,s),t.code(o)}):t.func(e,(0,q._)`${B.default.data}, ${vh(s)}`,n.$async,()=>t.code(wc(r,s)).code(o))}function vh(t){return(0,q._)`{${B.default.instancePath}="", ${B.default.parentData}, ${B.default.parentDataProperty}, ${B.default.rootData}=${B.default.data}${t.dynamicRef?(0,q._)`, ${B.default.dynamicAnchors}={}`:q.nil}}={}`}function yh(t,e){t.if(B.default.valCxt,()=>{t.var(B.default.instancePath,(0,q._)`${B.default.valCxt}.${B.default.instancePath}`),t.var(B.default.parentData,(0,q._)`${B.default.valCxt}.${B.default.parentData}`),t.var(B.default.parentDataProperty,(0,q._)`${B.default.valCxt}.${B.default.parentDataProperty}`),t.var(B.default.rootData,(0,q._)`${B.default.valCxt}.${B.default.rootData}`),e.dynamicRef&&t.var(B.default.dynamicAnchors,(0,q._)`${B.default.valCxt}.${B.default.dynamicAnchors}`)},()=>{t.var(B.default.instancePath,(0,q._)`""`),t.var(B.default.parentData,(0,q._)`undefined`),t.var(B.default.parentDataProperty,(0,q._)`undefined`),t.var(B.default.rootData,B.default.data),e.dynamicRef&&t.var(B.default.dynamicAnchors,(0,q._)`{}`)})}function bh(t){const{schema:e,opts:r,gen:n}=t;bc(t,()=>{r.$comment&&e.$comment&&Pc(t),Eh(t),n.let(B.default.vErrors,null),n.let(B.default.errors,0),r.unevaluated&&wh(t),Ec(t),xh(t)})}function wh(t){const{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,q._)`${r}.evaluated`),e.if((0,q._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,q._)`${t.evaluated}.props`,(0,q._)`undefined`)),e.if((0,q._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,q._)`${t.evaluated}.items`,(0,q._)`undefined`))}function wc(t,e){const r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,q._)`/*# sourceURL=${r} */`:q.nil}function $h(t,e){if(Sc(t)&&(kc(t),$c(t))){Sh(t,e);return}(0,vc.boolOrEmptySchema)(t,e)}function $c({schema:t,self:e}){if(typeof t=="boolean")return!t;for(const r in t)if(e.RULES.all[r])return!0;return!1}function Sc(t){return typeof t.schema!="boolean"}function Sh(t,e){const{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&Pc(t),Ph(t),Th(t);const o=n.const("_errs",B.default.errors);Ec(t,o),n.var(e,(0,q._)`${o} === ${B.default.errors}`)}function kc(t){(0,Ct.checkUnknownRules)(t),kh(t)}function Ec(t,e){if(t.opts.jtd)return Tc(t,[],!1,e);const r=(0,yc.getSchemaTypes)(t.schema),n=(0,yc.coerceAndCheckDataType)(t,r);Tc(t,r,!n,e)}function kh(t){const{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ct.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Eh(t){const{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ct.checkStrictMode)(t,"default is ignored in the schema root")}function Ph(t){const e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,_h.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Th(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Pc({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){const o=r.$comment;if(s.$comment===!0)t.code((0,q._)`${B.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){const i=(0,q.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,q._)`${B.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function xh(t){const{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,q._)`${B.default.errors} === 0`,()=>e.return(B.default.data),()=>e.throw((0,q._)`new ${s}(${B.default.vErrors})`)):(e.assign((0,q._)`${n}.errors`,B.default.vErrors),o.unevaluated&&Rh(t),e.return((0,q._)`${B.default.errors} === 0`))}function Rh({gen:t,evaluated:e,props:r,items:n}){r instanceof q.Name&&t.assign((0,q._)`${e}.props`,r),n instanceof q.Name&&t.assign((0,q._)`${e}.items`,n)}function Tc(t,e,r,n){const{gen:s,schema:o,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Ct.schemaHasRulesButRef)(o,l))){s.block(()=>Cc(t,"$ref",l.all.$ref.definition));return}c.jtd||Ih(t,e),s.block(()=>{for(const _ of l.rules)f(_);f(l.post)});function f(_){(0,_o.shouldUseGroup)(o,_)&&(_.type?(s.if((0,Vn.checkDataType)(_.type,i,c.strictNumbers)),xc(t,_),e.length===1&&e[0]===_.type&&r&&(s.else(),(0,Vn.reportTypeError)(t)),s.endIf()):xc(t,_),a||s.if((0,q._)`${B.default.errors} === ${n||0}`))}}function xc(t,e){const{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,mh.assignDefaults)(t,e.type),r.block(()=>{for(const o of e.rules)(0,_o.shouldUseRule)(n,o)&&Cc(t,o.keyword,o.definition,e.type)})}function Ih(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Ch(t,e),t.opts.allowUnionTypes||Oh(t,e),Nh(t,t.dataTypes))}function Ch(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Rc(t.dataTypes,r)||vo(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Ah(t,e)}}function Oh(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&vo(t,"use allowUnionTypes to allow union type keyword")}function Nh(t,e){const r=t.self.RULES.all;for(const n in r){const s=r[n];if(typeof s=="object"&&(0,_o.shouldUseRule)(t.schema,s)){const{type:o}=s.definition;o.length&&!o.some(i=>jh(e,i))&&vo(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function jh(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Rc(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Ah(t,e){const r=[];for(const n of t.dataTypes)Rc(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function vo(t,e){const r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ct.checkStrictMode)(t,e,t.opts.strictTypes)}class Ic{constructor(e,r,n){if((0,Fr.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ct.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Oc(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Fr.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",B.default.errors))}result(e,r,n){this.failResult((0,q.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,q.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:r}=this;this.fail((0,q._)`${r} !== undefined && (${(0,q.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Hr.reportExtraError:Hr.reportError)(this,this.def.error,r)}$dataError(){(0,Hr.reportError)(this,this.def.$dataError||Hr.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Hr.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=q.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=q.nil,r=q.nil){if(!this.$data)return;const{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,q.or)((0,q._)`${s} === undefined`,r)),e!==q.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==q.nil&&n.assign(e,!1)),n.else()}invalid$data(){const{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,q.or)(i(),a());function i(){if(n.length){if(!(r instanceof q.Name))throw new Error("ajv implementation error");const c=Array.isArray(n)?n:[n];return(0,q._)`${(0,Vn.checkDataTypes)(c,r,o.opts.strictNumbers,Vn.DataType.Wrong)}`}return q.nil}function a(){if(s.validateSchema){const c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,q._)`!${c}(${r})`}return q.nil}}subschema(e,r){const n=(0,go.getSubschema)(this.it,e);(0,go.extendSubschemaData)(n,this.it,e),(0,go.extendSubschemaMode)(n,e);const s={...this.it,...n,items:void 0,props:void 0};return $h(s,r),s}mergeEvaluated(e,r){const{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ct.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ct.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){const{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,q.Name)),!0}}ot.KeywordCxt=Ic;function Cc(t,e,r,n){const s=new Ic(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,Fr.funcKeywordCode)(s,r):"macro"in r?(0,Fr.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,Fr.funcKeywordCode)(s,r)}const zh=/^\/(?:[^~]|~0|~1)*$/,Mh=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Oc(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return B.default.rootData;if(t[0]==="/"){if(!zh.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=B.default.rootData}else{const u=Mh.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);const l=+u[1];if(s=u[2],s==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(o=r[e-l],!s)return o}let i=o;const a=s.split("/");for(const u of a)u&&(o=(0,q._)`${o}${(0,q.getProperty)((0,Ct.unescapeJsonPointer)(u))}`,i=(0,q._)`${i} && ${o}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}ot.getData=Oc;var Wr={};Object.defineProperty(Wr,"__esModule",{value:!0});class Zh extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}Wr.default=Zh;var wr={};Object.defineProperty(wr,"__esModule",{value:!0});const yo=Me;class Lh extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,yo.resolveUrl)(e,r,n),this.missingSchema=(0,yo.normalizeId)((0,yo.getFullPath)(e,this.missingRef))}}wr.default=Lh;var Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.resolveSchema=Je.getCompilingSchema=Je.resolveRef=Je.compileSchema=Je.SchemaEnv=void 0;const it=Q,Uh=Wr,nr=bt,at=Me,Nc=M,Dh=ot;class Fn{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,at.normalizeId)(n==null?void 0:n[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n==null?void 0:n.$async,this.refs={}}}Je.SchemaEnv=Fn;function bo(t){const e=jc.call(this,t);if(e)return e;const r=(0,at.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new it.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o});let a;t.$async&&(a=i.scopeValue("Error",{ref:Uh.default,code:(0,it._)`require("ajv/dist/runtime/validation_error").default`}));const c=i.scopeName("validate");t.validateName=c;const u={gen:i,allErrors:this.opts.allErrors,data:nr.default.data,parentData:nr.default.parentData,parentDataProperty:nr.default.parentDataProperty,dataNames:[nr.default.data],dataPathArr:[it.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,it.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:it.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,it._)`""`,opts:this.opts,self:this};let l;try{this._compilations.add(t),(0,Dh.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);const f=i.toString();l=`${i.scopeRefs(nr.default.scope)}return ${f}`,this.opts.code.process&&(l=this.opts.code.process(l,t));const y=new Function(`${nr.default.self}`,`${nr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:y}),y.errors=null,y.schema=t.schema,y.schemaEnv=t,t.$async&&(y.$async=!0),this.opts.code.source===!0&&(y.source={validateName:c,validateCode:f,scopeValues:i._values}),this.opts.unevaluated){const{props:g,items:v}=u;y.evaluated={props:g instanceof it.Name?void 0:g,items:v instanceof it.Name?void 0:v,dynamicProps:g instanceof it.Name,dynamicItems:v instanceof it.Name},y.source&&(y.source.evaluated=(0,it.stringify)(y.evaluated))}return t.validate=y,t}catch(f){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),f}finally{this._compilations.delete(t)}}Je.compileSchema=bo;function qh(t,e,r){var n;r=(0,at.resolveUrl)(this.opts.uriResolver,e,r);const s=t.refs[r];if(s)return s;let o=Hh.call(this,t,r);if(o===void 0){const i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(o=new Fn({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=Vh.call(this,o)}Je.resolveRef=qh;function Vh(t){return(0,at.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:bo.call(this,t)}function jc(t){for(const e of this._compilations)if(Fh(e,t))return e}Je.getCompilingSchema=jc;function Fh(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Hh(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Hn.call(this,t,e)}function Hn(t,e){const r=this.opts.uriResolver.parse(e),n=(0,at._getFullPath)(this.opts.uriResolver,r);let s=(0,at.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return wo.call(this,r,t);const o=(0,at.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){const a=Hn.call(this,t,i);return typeof(a==null?void 0:a.schema)!="object"?void 0:wo.call(this,r,a)}if(typeof(i==null?void 0:i.schema)=="object"){if(i.validate||bo.call(this,i),o===(0,at.normalizeId)(e)){const{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(s=(0,at.resolveUrl)(this.opts.uriResolver,s,u)),new Fn({schema:a,schemaId:c,root:t,baseId:s})}return wo.call(this,r,i)}}Je.resolveSchema=Hn;const Wh=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function wo(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(const a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;const c=r[(0,Nc.unescapeFragment)(a)];if(c===void 0)return;r=c;const u=typeof r=="object"&&r[this.opts.schemaId];!Wh.has(a)&&u&&(e=(0,at.resolveUrl)(this.opts.uriResolver,e,u))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Nc.schemaHasRulesButRef)(r,this.RULES)){const a=(0,at.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=Hn.call(this,n,a)}const{schemaId:i}=this.opts;if(o=o||new Fn({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}const Jh={$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 $o={},Wn={exports:{}};const Bh=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Ac=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);function zc(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}const Kh=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Mc(t){return t.length=0,!0}function Gh(t,e,r){if(t.length){const n=zc(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function Yh(t){let e=0;const r={error:!1,address:"",zone:""},n=[],s=[];let o=!1,i=!1,a=Gh;for(let c=0;c<t.length;c++){const u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(o===!0&&(i=!0),!a(s,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(o=!0),n.push(":");continue}else if(u==="%"){if(!a(s,n,r))break;a=Mc}else{s.push(u);continue}}return s.length&&(a===Mc?r.zone=s.join(""):i?n.push(s.join("")):n.push(zc(s))),r.address=n.join(""),r}function Zc(t){if(Xh(t,":")<2)return{host:t,isIPV6:!1};const e=Yh(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function Xh(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Qh(t){let e=t;const r=[];let n=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(s===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function ep(t,e){const r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function tp(t){const e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!Ac(r)){const n=Zc(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}var Lc={nonSimpleDomain:Kh,recomposeAuthority:tp,normalizeComponentEncoding:ep,removeDotSegments:Qh,isIPv4:Ac,isUUID:Bh,normalizeIPv6:Zc};const{isUUID:rp}=Lc,np=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function Uc(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function Dc(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function qc(t){const e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function sp(t){return t.secure=Uc(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function op(t){if((t.port===(Uc(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){const[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function ip(t,e){if(!t.path)return t.error="URN can not be parsed",t;const r=t.path.match(np);if(r){const n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];const s=`${n}:${e.nid||t.nid}`,o=So(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function ap(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");const r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,o=So(s);o&&(t=o.serialize(t,e));const i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function cp(t,e){const r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!rp(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function up(t){const e=t;return e.nss=(t.uuid||"").toLowerCase(),e}const Vc={scheme:"http",domainHost:!0,parse:Dc,serialize:qc},lp={scheme:"https",domainHost:Vc.domainHost,parse:Dc,serialize:qc},Jn={scheme:"ws",domainHost:!0,parse:sp,serialize:op},dp={scheme:"wss",domainHost:Jn.domainHost,parse:Jn.parse,serialize:Jn.serialize},Bn={http:Vc,https:lp,ws:Jn,wss:dp,urn:{scheme:"urn",parse:ip,serialize:ap,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:cp,serialize:up,skipNormalize:!0}};Object.setPrototypeOf(Bn,null);function So(t){return t&&(Bn[t]||Bn[t.toLowerCase()])||void 0}var fp={SCHEMES:Bn,getSchemeHandler:So};const{normalizeIPv6:hp,removeDotSegments:Jr,recomposeAuthority:pp,normalizeComponentEncoding:Kn,isIPv4:mp,nonSimpleDomain:_p}=Lc,{SCHEMES:gp,getSchemeHandler:Fc}=fp;function vp(t,e){return typeof t=="string"?t=St(Ot(t,e),e):typeof t=="object"&&(t=Ot(St(t,e),e)),t}function yp(t,e,r){const n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=Hc(Ot(t,n),Ot(e,n),n,!0);return n.skipEscape=!0,St(s,n)}function Hc(t,e,r,n){const s={};return n||(t=Ot(St(t,r),r),e=Ot(St(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Jr(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Jr(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=Jr(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=Jr(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function bp(t,e,r){return typeof t=="string"?(t=unescape(t),t=St(Kn(Ot(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=St(Kn(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=St(Kn(Ot(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=St(Kn(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function St(t,e){const r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),s=[],o=Fc(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");const i=pp(r);if(i!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(i),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=Jr(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}const wp=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Ot(t,e){const r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);const o=t.match(wp);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host)if(mp(n.host)===!1){const c=hp(n.host);n.host=c.host.toLowerCase(),s=c.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const i=Fc(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&s===!1&&_p(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}const ko={SCHEMES:gp,normalize:vp,resolve:yp,resolveComponent:Hc,equal:bp,serialize:St,parse:Ot};Wn.exports=ko,Wn.exports.default=ko,Wn.exports.fastUri=ko;var $p=Wn.exports;Object.defineProperty($o,"__esModule",{value:!0});const Wc=$p;Wc.code='require("ajv/dist/runtime/uri").default',$o.default=Wc,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=ot;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var r=Q;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=Wr,s=wr,o=tr,i=Je,a=Q,c=Me,u=Oe,l=M,f=Jh,_=$o,y=(N,k)=>new RegExp(N,k);y.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],v=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),h={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."},d={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},m=200;function w(N){var k,R,E,p,b,x,F,H,fe,le,ze,Dr,Na,ja,Aa,za,Ma,Za,La,Ua,Da,qa,Va,Fa,Ha;const Un=N.strict,Wa=(k=N.code)===null||k===void 0?void 0:k.optimize,Xd=Wa===!0||Wa===void 0?1:Wa||0,Qd=(E=(R=N.code)===null||R===void 0?void 0:R.regExp)!==null&&E!==void 0?E:y,U1=(p=N.uriResolver)!==null&&p!==void 0?p:_.default;return{strictSchema:(x=(b=N.strictSchema)!==null&&b!==void 0?b:Un)!==null&&x!==void 0?x:!0,strictNumbers:(H=(F=N.strictNumbers)!==null&&F!==void 0?F:Un)!==null&&H!==void 0?H:!0,strictTypes:(le=(fe=N.strictTypes)!==null&&fe!==void 0?fe:Un)!==null&&le!==void 0?le:"log",strictTuples:(Dr=(ze=N.strictTuples)!==null&&ze!==void 0?ze:Un)!==null&&Dr!==void 0?Dr:"log",strictRequired:(ja=(Na=N.strictRequired)!==null&&Na!==void 0?Na:Un)!==null&&ja!==void 0?ja:!1,code:N.code?{...N.code,optimize:Xd,regExp:Qd}:{optimize:Xd,regExp:Qd},loopRequired:(Aa=N.loopRequired)!==null&&Aa!==void 0?Aa:m,loopEnum:(za=N.loopEnum)!==null&&za!==void 0?za:m,meta:(Ma=N.meta)!==null&&Ma!==void 0?Ma:!0,messages:(Za=N.messages)!==null&&Za!==void 0?Za:!0,inlineRefs:(La=N.inlineRefs)!==null&&La!==void 0?La:!0,schemaId:(Ua=N.schemaId)!==null&&Ua!==void 0?Ua:"$id",addUsedSchema:(Da=N.addUsedSchema)!==null&&Da!==void 0?Da:!0,validateSchema:(qa=N.validateSchema)!==null&&qa!==void 0?qa:!0,validateFormats:(Va=N.validateFormats)!==null&&Va!==void 0?Va:!0,unicodeRegExp:(Fa=N.unicodeRegExp)!==null&&Fa!==void 0?Fa:!0,int32range:(Ha=N.int32range)!==null&&Ha!==void 0?Ha:!0,uriResolver:U1}}class S{constructor(k={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,k=this.opts={...k,...w(k)};const{es5:R,lines:E}=this.opts.code;this.scope=new a.ValueScope({scope:{},prefixes:v,es5:R,lines:E}),this.logger=K(k.logger);const p=k.validateFormats;k.validateFormats=!1,this.RULES=(0,o.getRules)(),P.call(this,h,k,"NOT SUPPORTED"),P.call(this,d,k,"DEPRECATED","warn"),this._metaOpts=Ae.call(this),k.formats&&ce.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),k.keywords&&G.call(this,k.keywords),typeof k.meta=="object"&&this.addMetaSchema(k.meta),V.call(this),k.validateFormats=p}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:k,meta:R,schemaId:E}=this.opts;let p=f;E==="id"&&(p={...f},p.id=p.$id,delete p.$id),R&&k&&this.addMetaSchema(p,p[E],!1)}defaultMeta(){const{meta:k,schemaId:R}=this.opts;return this.opts.defaultMeta=typeof k=="object"?k[R]||k:void 0}validate(k,R){let E;if(typeof k=="string"){if(E=this.getSchema(k),!E)throw new Error(`no schema with key or ref "${k}"`)}else E=this.compile(k);const p=E(R);return"$async"in E||(this.errors=E.errors),p}compile(k,R){const E=this._addSchema(k,R);return E.validate||this._compileSchemaEnv(E)}compileAsync(k,R){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:E}=this.opts;return p.call(this,k,R);async function p(le,ze){await b.call(this,le.$schema);const Dr=this._addSchema(le,ze);return Dr.validate||x.call(this,Dr)}async function b(le){le&&!this.getSchema(le)&&await p.call(this,{$ref:le},!0)}async function x(le){try{return this._compileSchemaEnv(le)}catch(ze){if(!(ze instanceof s.default))throw ze;return F.call(this,ze),await H.call(this,ze.missingSchema),x.call(this,le)}}function F({missingSchema:le,missingRef:ze}){if(this.refs[le])throw new Error(`AnySchema ${le} is loaded but ${ze} cannot be resolved`)}async function H(le){const ze=await fe.call(this,le);this.refs[le]||await b.call(this,ze.$schema),this.refs[le]||this.addSchema(ze,le,R)}async function fe(le){const ze=this._loading[le];if(ze)return ze;try{return await(this._loading[le]=E(le))}finally{delete this._loading[le]}}}addSchema(k,R,E,p=this.opts.validateSchema){if(Array.isArray(k)){for(const x of k)this.addSchema(x,void 0,E,p);return this}let b;if(typeof k=="object"){const{schemaId:x}=this.opts;if(b=k[x],b!==void 0&&typeof b!="string")throw new Error(`schema ${x} must be string`)}return R=(0,c.normalizeId)(R||b),this._checkUnique(R),this.schemas[R]=this._addSchema(k,E,R,p,!0),this}addMetaSchema(k,R,E=this.opts.validateSchema){return this.addSchema(k,R,!0,E),this}validateSchema(k,R){if(typeof k=="boolean")return!0;let E;if(E=k.$schema,E!==void 0&&typeof E!="string")throw new Error("$schema must be a string");if(E=E||this.opts.defaultMeta||this.defaultMeta(),!E)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const p=this.validate(E,k);if(!p&&R){const b="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(b);else throw new Error(b)}return p}getSchema(k){let R;for(;typeof(R=O.call(this,k))=="string";)k=R;if(R===void 0){const{schemaId:E}=this.opts,p=new i.SchemaEnv({schema:{},schemaId:E});if(R=i.resolveSchema.call(this,p,k),!R)return;this.refs[k]=R}return R.validate||this._compileSchemaEnv(R)}removeSchema(k){if(k instanceof RegExp)return this._removeAllSchemas(this.schemas,k),this._removeAllSchemas(this.refs,k),this;switch(typeof k){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const R=O.call(this,k);return typeof R=="object"&&this._cache.delete(R.schema),delete this.schemas[k],delete this.refs[k],this}case"object":{const R=k;this._cache.delete(R);let E=k[this.opts.schemaId];return E&&(E=(0,c.normalizeId)(E),delete this.schemas[E],delete this.refs[E]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(k){for(const R of k)this.addKeyword(R);return this}addKeyword(k,R){let E;if(typeof k=="string")E=k,typeof R=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),R.keyword=E);else if(typeof k=="object"&&R===void 0){if(R=k,E=R.keyword,Array.isArray(E)&&!E.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(se.call(this,E,R),!R)return(0,l.eachItem)(E,b=>De.call(this,b)),this;Lt.call(this,R);const p={...R,type:(0,u.getJSONTypes)(R.type),schemaType:(0,u.getJSONTypes)(R.schemaType)};return(0,l.eachItem)(E,p.type.length===0?b=>De.call(this,b,p):b=>p.type.forEach(x=>De.call(this,b,p,x))),this}getKeyword(k){const R=this.RULES.all[k];return typeof R=="object"?R.definition:!!R}removeKeyword(k){const{RULES:R}=this;delete R.keywords[k],delete R.all[k];for(const E of R.rules){const p=E.rules.findIndex(b=>b.keyword===k);p>=0&&E.rules.splice(p,1)}return this}addFormat(k,R){return typeof R=="string"&&(R=new RegExp(R)),this.formats[k]=R,this}errorsText(k=this.errors,{separator:R=", ",dataVar:E="data"}={}){return!k||k.length===0?"No errors":k.map(p=>`${E}${p.instancePath} ${p.message}`).reduce((p,b)=>p+R+b)}$dataMetaSchema(k,R){const E=this.RULES.all;k=JSON.parse(JSON.stringify(k));for(const p of R){const b=p.split("/").slice(1);let x=k;for(const F of b)x=x[F];for(const F in E){const H=E[F];if(typeof H!="object")continue;const{$data:fe}=H.definition,le=x[F];fe&&le&&(x[F]=mr(le))}}return k}_removeAllSchemas(k,R){for(const E in k){const p=k[E];(!R||R.test(E))&&(typeof p=="string"?delete k[E]:p&&!p.meta&&(this._cache.delete(p.schema),delete k[E]))}}_addSchema(k,R,E,p=this.opts.validateSchema,b=this.opts.addUsedSchema){let x;const{schemaId:F}=this.opts;if(typeof k=="object")x=k[F];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof k!="boolean")throw new Error("schema must be object or boolean")}let H=this._cache.get(k);if(H!==void 0)return H;E=(0,c.normalizeId)(x||E);const fe=c.getSchemaRefs.call(this,k,E);return H=new i.SchemaEnv({schema:k,schemaId:F,meta:R,baseId:E,localRefs:fe}),this._cache.set(H.schema,H),b&&!E.startsWith("#")&&(E&&this._checkUnique(E),this.refs[E]=H),p&&this.validateSchema(k,!0),H}_checkUnique(k){if(this.schemas[k]||this.refs[k])throw new Error(`schema with key or id "${k}" already exists`)}_compileSchemaEnv(k){if(k.meta?this._compileMetaSchema(k):i.compileSchema.call(this,k),!k.validate)throw new Error("ajv implementation error");return k.validate}_compileMetaSchema(k){const R=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,k)}finally{this.opts=R}}}S.ValidationError=n.default,S.MissingRefError=s.default,t.default=S;function P(N,k,R,E="error"){for(const p in N){const b=p;b in k&&this.logger[E](`${R}: option ${p}. ${N[b]}`)}}function O(N){return N=(0,c.normalizeId)(N),this.schemas[N]||this.refs[N]}function V(){const N=this.opts.schemas;if(N)if(Array.isArray(N))this.addSchema(N);else for(const k in N)this.addSchema(N[k],k)}function ce(){for(const N in this.opts.formats){const k=this.opts.formats[N];k&&this.addFormat(N,k)}}function G(N){if(Array.isArray(N)){this.addVocabulary(N);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const k in N){const R=N[k];R.keyword||(R.keyword=k),this.addKeyword(R)}}function Ae(){const N={...this.opts};for(const k of g)delete N[k];return N}const U={log(){},warn(){},error(){}};function K(N){if(N===!1)return U;if(N===void 0)return console;if(N.log&&N.warn&&N.error)return N;throw new Error("logger must implement log, warn and error methods")}const Se=/^[a-z_$][a-z0-9_$:-]*$/i;function se(N,k){const{RULES:R}=this;if((0,l.eachItem)(N,E=>{if(R.keywords[E])throw new Error(`Keyword ${E} is already defined`);if(!Se.test(E))throw new Error(`Keyword ${E} has invalid name`)}),!!k&&k.$data&&!("code"in k||"validate"in k))throw new Error('$data keyword must have "code" or "validate" function')}function De(N,k,R){var E;const p=k==null?void 0:k.post;if(R&&p)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:b}=this;let x=p?b.post:b.rules.find(({type:H})=>H===R);if(x||(x={type:R,rules:[]},b.rules.push(x)),b.keywords[N]=!0,!k)return;const F={keyword:N,definition:{...k,type:(0,u.getJSONTypes)(k.type),schemaType:(0,u.getJSONTypes)(k.schemaType)}};k.before?Zt.call(this,x,F,k.before):x.rules.push(F),b.all[N]=F,(E=k.implements)===null||E===void 0||E.forEach(H=>this.addKeyword(H))}function Zt(N,k,R){const E=N.rules.findIndex(p=>p.keyword===R);E>=0?N.rules.splice(E,0,k):(N.rules.push(k),this.logger.warn(`rule ${R} is not defined`))}function Lt(N){let{metaSchema:k}=N;k!==void 0&&(N.$data&&this.opts.$data&&(k=mr(k)),N.validateSchema=this.compile(k,!0))}const Ln={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function mr(N){return{anyOf:[N,Ln]}}}(Ja);var Eo={},Po={},To={};Object.defineProperty(To,"__esModule",{value:!0});const Sp={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};To.default=Sp;var sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.callRef=sr.getValidate=void 0;const kp=wr,Jc=te,Be=Q,$r=bt,Bc=Je,Gn=M,Ep={keyword:"$ref",schemaType:"string",code(t){const{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=n,{root:u}=o;if((r==="#"||r==="#/")&&s===u.baseId)return f();const l=Bc.resolveRef.call(c,u,s,r);if(l===void 0)throw new kp.default(n.opts.uriResolver,s,r);if(l instanceof Bc.SchemaEnv)return _(l);return y(l);function f(){if(o===u)return Yn(t,i,o,o.$async);const g=e.scopeValue("root",{ref:u});return Yn(t,(0,Be._)`${g}.validate`,u,u.$async)}function _(g){const v=Kc(t,g);Yn(t,v,g,g.$async)}function y(g){const v=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,Be.stringify)(g)}:{ref:g}),h=e.name("valid"),d=t.subschema({schema:g,dataTypes:[],schemaPath:Be.nil,topSchemaRef:v,errSchemaPath:r},h);t.mergeEvaluated(d),t.ok(h)}}};function Kc(t,e){const{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:e})}.validate`}sr.getValidate=Kc;function Yn(t,e,r,n){const{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,u=c.passContext?$r.default.this:Be.nil;n?l():f();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");const g=s.let("valid");s.try(()=>{s.code((0,Be._)`await ${(0,Jc.callValidateCode)(t,e,u)}`),y(e),i||s.assign(g,!0)},v=>{s.if((0,Be._)`!(${v} instanceof ${o.ValidationError})`,()=>s.throw(v)),_(v),i||s.assign(g,!1)}),t.ok(g)}function f(){t.result((0,Jc.callValidateCode)(t,e,u),()=>y(e),()=>_(e))}function _(g){const v=(0,Be._)`${g}.errors`;s.assign($r.default.vErrors,(0,Be._)`${$r.default.vErrors} === null ? ${v} : ${$r.default.vErrors}.concat(${v})`),s.assign($r.default.errors,(0,Be._)`${$r.default.vErrors}.length`)}function y(g){var v;if(!o.opts.unevaluated)return;const h=(v=r==null?void 0:r.validate)===null||v===void 0?void 0:v.evaluated;if(o.props!==!0)if(h&&!h.dynamicProps)h.props!==void 0&&(o.props=Gn.mergeEvaluated.props(s,h.props,o.props));else{const d=s.var("props",(0,Be._)`${g}.evaluated.props`);o.props=Gn.mergeEvaluated.props(s,d,o.props,Be.Name)}if(o.items!==!0)if(h&&!h.dynamicItems)h.items!==void 0&&(o.items=Gn.mergeEvaluated.items(s,h.items,o.items));else{const d=s.var("items",(0,Be._)`${g}.evaluated.items`);o.items=Gn.mergeEvaluated.items(s,d,o.items,Be.Name)}}}sr.callRef=Yn,sr.default=Ep,Object.defineProperty(Po,"__esModule",{value:!0});const Pp=To,Tp=sr,xp=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Pp.default,Tp.default];Po.default=xp;var xo={},Ro={};Object.defineProperty(Ro,"__esModule",{value:!0});const Xn=Q,Vt=Xn.operators,Qn={maximum:{okStr:"<=",ok:Vt.LTE,fail:Vt.GT},minimum:{okStr:">=",ok:Vt.GTE,fail:Vt.LT},exclusiveMaximum:{okStr:"<",ok:Vt.LT,fail:Vt.GTE},exclusiveMinimum:{okStr:">",ok:Vt.GT,fail:Vt.LTE}},Rp={message:({keyword:t,schemaCode:e})=>(0,Xn.str)`must be ${Qn[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Xn._)`{comparison: ${Qn[t].okStr}, limit: ${e}}`},Ip={keyword:Object.keys(Qn),type:"number",schemaType:"number",$data:!0,error:Rp,code(t){const{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Xn._)`${r} ${Qn[e].fail} ${n} || isNaN(${r})`)}};Ro.default=Ip;var Io={};Object.defineProperty(Io,"__esModule",{value:!0});const Br=Q,Cp={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>(0,Br.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Br._)`{multipleOf: ${t}}`},code(t){const{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,Br._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,Br._)`${i} !== parseInt(${i})`;t.fail$data((0,Br._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Io.default=Cp;var Co={},Oo={};Object.defineProperty(Oo,"__esModule",{value:!0});function Gc(t){const e=t.length;let r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}Oo.default=Gc,Gc.code='require("ajv/dist/runtime/ucs2length").default',Object.defineProperty(Co,"__esModule",{value:!0});const or=Q,Op=M,Np=Oo,jp={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const r=t==="maxLength"?"more":"fewer";return(0,or.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,or._)`{limit: ${t}}`},code(t){const{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?or.operators.GT:or.operators.LT,i=s.opts.unicode===!1?(0,or._)`${r}.length`:(0,or._)`${(0,Op.useFunc)(t.gen,Np.default)}(${r})`;t.fail$data((0,or._)`${i} ${o} ${n}`)}};Co.default=jp;var No={};Object.defineProperty(No,"__esModule",{value:!0});const Ap=te,es=Q,zp={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>(0,es.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,es._)`{pattern: ${t}}`},code(t){const{data:e,$data:r,schema:n,schemaCode:s,it:o}=t,i=o.opts.unicodeRegExp?"u":"",a=r?(0,es._)`(new RegExp(${s}, ${i}))`:(0,Ap.usePattern)(t,n);t.fail$data((0,es._)`!${a}.test(${e})`)}};No.default=zp;var jo={};Object.defineProperty(jo,"__esModule",{value:!0});const Kr=Q,Mp={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const r=t==="maxProperties"?"more":"fewer";return(0,Kr.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Kr._)`{limit: ${t}}`},code(t){const{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?Kr.operators.GT:Kr.operators.LT;t.fail$data((0,Kr._)`Object.keys(${r}).length ${s} ${n}`)}};jo.default=Mp;var Ao={};Object.defineProperty(Ao,"__esModule",{value:!0});const Gr=te,Yr=Q,Zp=M,Lp={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:t}})=>(0,Yr.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Yr._)`{missingProperty: ${t}}`},code(t){const{gen:e,schema:r,schemaCode:n,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;const c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){const y=t.parentSchema.properties,{definedProperties:g}=t.it;for(const v of r)if((y==null?void 0:y[v])===void 0&&!g.has(v)){const h=i.schemaEnv.baseId+i.errSchemaPath,d=`required property "${v}" is not defined at "${h}" (strictRequired)`;(0,Zp.checkStrictMode)(i,d,i.opts.strictRequired)}}function u(){if(c||o)t.block$data(Yr.nil,f);else for(const y of r)(0,Gr.checkReportMissingProp)(t,y)}function l(){const y=e.let("missing");if(c||o){const g=e.let("valid",!0);t.block$data(g,()=>_(y,g)),t.ok(g)}else e.if((0,Gr.checkMissingProp)(t,r,y)),(0,Gr.reportMissingProp)(t,y),e.else()}function f(){e.forOf("prop",n,y=>{t.setParams({missingProperty:y}),e.if((0,Gr.noPropertyInData)(e,s,y,a.ownProperties),()=>t.error())})}function _(y,g){t.setParams({missingProperty:y}),e.forOf(y,n,()=>{e.assign(g,(0,Gr.propertyInData)(e,s,y,a.ownProperties)),e.if((0,Yr.not)(g),()=>{t.error(),e.break()})},Yr.nil)}}};Ao.default=Lp;var zo={};Object.defineProperty(zo,"__esModule",{value:!0});const Xr=Q,Up={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const r=t==="maxItems"?"more":"fewer";return(0,Xr.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Xr._)`{limit: ${t}}`},code(t){const{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?Xr.operators.GT:Xr.operators.LT;t.fail$data((0,Xr._)`${r}.length ${s} ${n}`)}};zo.default=Up;var Mo={},Qr={};Object.defineProperty(Qr,"__esModule",{value:!0});const Yc=hc;Yc.code='require("ajv/dist/runtime/equal").default',Qr.default=Yc,Object.defineProperty(Mo,"__esModule",{value:!0});const Zo=Oe,Ze=Q,Dp=M,qp=Qr,Vp={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:t,j:e}})=>(0,Ze.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Ze._)`{i: ${t}, j: ${e}}`},code(t){const{gen:e,data:r,$data:n,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!n&&!s)return;const c=e.let("valid"),u=o.items?(0,Zo.getSchemaTypes)(o.items):[];t.block$data(c,l,(0,Ze._)`${i} === false`),t.ok(c);function l(){const g=e.let("i",(0,Ze._)`${r}.length`),v=e.let("j");t.setParams({i:g,j:v}),e.assign(c,!0),e.if((0,Ze._)`${g} > 1`,()=>(f()?_:y)(g,v))}function f(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function _(g,v){const h=e.name("item"),d=(0,Zo.checkDataTypes)(u,h,a.opts.strictNumbers,Zo.DataType.Wrong),m=e.const("indices",(0,Ze._)`{}`);e.for((0,Ze._)`;${g}--;`,()=>{e.let(h,(0,Ze._)`${r}[${g}]`),e.if(d,(0,Ze._)`continue`),u.length>1&&e.if((0,Ze._)`typeof ${h} == "string"`,(0,Ze._)`${h} += "_"`),e.if((0,Ze._)`typeof ${m}[${h}] == "number"`,()=>{e.assign(v,(0,Ze._)`${m}[${h}]`),t.error(),e.assign(c,!1).break()}).code((0,Ze._)`${m}[${h}] = ${g}`)})}function y(g,v){const h=(0,Dp.useFunc)(e,qp.default),d=e.name("outer");e.label(d).for((0,Ze._)`;${g}--;`,()=>e.for((0,Ze._)`${v} = ${g}; ${v}--;`,()=>e.if((0,Ze._)`${h}(${r}[${g}], ${r}[${v}])`,()=>{t.error(),e.assign(c,!1).break(d)})))}}};Mo.default=Vp;var Lo={};Object.defineProperty(Lo,"__esModule",{value:!0});const Uo=Q,Fp=M,Hp=Qr,Wp={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>(0,Uo._)`{allowedValue: ${t}}`},code(t){const{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,Uo._)`!${(0,Fp.useFunc)(e,Hp.default)}(${r}, ${s})`):t.fail((0,Uo._)`${o} !== ${r}`)}};Lo.default=Wp;var Do={};Object.defineProperty(Do,"__esModule",{value:!0});const en=Q,Jp=M,Bp=Qr,Kp={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,en._)`{allowedValues: ${t}}`},code(t){const{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");const a=s.length>=i.opts.loopEnum;let c;const u=()=>c??(c=(0,Jp.useFunc)(e,Bp.default));let l;if(a||n)l=e.let("valid"),t.block$data(l,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");const y=e.const("vSchema",o);l=(0,en.or)(...s.map((g,v)=>_(y,v)))}t.pass(l);function f(){e.assign(l,!1),e.forOf("v",o,y=>e.if((0,en._)`${u()}(${r}, ${y})`,()=>e.assign(l,!0).break()))}function _(y,g){const v=s[g];return typeof v=="object"&&v!==null?(0,en._)`${u()}(${r}, ${y}[${g}])`:(0,en._)`${r} === ${v}`}}};Do.default=Kp,Object.defineProperty(xo,"__esModule",{value:!0});const Gp=Ro,Yp=Io,Xp=Co,Qp=No,em=jo,tm=Ao,rm=zo,nm=Mo,sm=Lo,om=Do,im=[Gp.default,Yp.default,Xp.default,Qp.default,em.default,tm.default,rm.default,nm.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},sm.default,om.default];xo.default=im;var qo={},Sr={};Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.validateAdditionalItems=void 0;const ir=Q,Vo=M,am={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>(0,ir.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,ir._)`{limit: ${t}}`},code(t){const{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Vo.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Xc(t,n)}};function Xc(t,e){const{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;const a=r.const("len",(0,ir._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,ir._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Vo.alwaysValidSchema)(i,n)){const u=r.var("valid",(0,ir._)`${a} <= ${e.length}`);r.if((0,ir.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:o,dataProp:l,dataPropType:Vo.Type.Num},u),i.allErrors||r.if((0,ir.not)(u),()=>r.break())})}}Sr.validateAdditionalItems=Xc,Sr.default=am;var Fo={},kr={};Object.defineProperty(kr,"__esModule",{value:!0}),kr.validateTuple=void 0;const Qc=Q,ts=M,cm=te,um={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){const{schema:e,it:r}=t;if(Array.isArray(e))return eu(t,"additionalItems",e);r.items=!0,!(0,ts.alwaysValidSchema)(r,e)&&t.ok((0,cm.validateArray)(t))}};function eu(t,e,r=t.schema){const{gen:n,parentSchema:s,data:o,keyword:i,it:a}=t;l(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=ts.mergeEvaluated.items(n,r.length,a.items));const c=n.name("valid"),u=n.const("len",(0,Qc._)`${o}.length`);r.forEach((f,_)=>{(0,ts.alwaysValidSchema)(a,f)||(n.if((0,Qc._)`${u} > ${_}`,()=>t.subschema({keyword:i,schemaProp:_,dataProp:_},c)),t.ok(c))});function l(f){const{opts:_,errSchemaPath:y}=a,g=r.length,v=g===f.minItems&&(g===f.maxItems||f[e]===!1);if(_.strictTuples&&!v){const h=`"${i}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${y}"`;(0,ts.checkStrictMode)(a,h,_.strictTuples)}}}kr.validateTuple=eu,kr.default=um,Object.defineProperty(Fo,"__esModule",{value:!0});const lm=kr,dm={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,lm.validateTuple)(t,"items")};Fo.default=dm;var Ho={};Object.defineProperty(Ho,"__esModule",{value:!0});const tu=Q,fm=M,hm=te,pm=Sr,mm={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>(0,tu.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,tu._)`{limit: ${t}}`},code(t){const{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,fm.alwaysValidSchema)(n,e)&&(s?(0,pm.validateAdditionalItems)(t,s):t.ok((0,hm.validateArray)(t)))}};Ho.default=mm;var Wo={};Object.defineProperty(Wo,"__esModule",{value:!0});const rt=Q,rs=M,_m={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:e}})=>e===void 0?(0,rt.str)`must contain at least ${t} valid item(s)`:(0,rt.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,rt._)`{minContains: ${t}}`:(0,rt._)`{minContains: ${t}, maxContains: ${e}}`},code(t){const{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;let i,a;const{minContains:c,maxContains:u}=n;o.opts.next?(i=c===void 0?1:c,a=u):i=1;const l=e.const("len",(0,rt._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,rs.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,rs.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,rs.alwaysValidSchema)(o,r)){let v=(0,rt._)`${l} >= ${i}`;a!==void 0&&(v=(0,rt._)`${v} && ${l} <= ${a}`),t.pass(v);return}o.items=!0;const f=e.name("valid");a===void 0&&i===1?y(f,()=>e.if(f,()=>e.break())):i===0?(e.let(f,!0),a!==void 0&&e.if((0,rt._)`${s}.length > 0`,_)):(e.let(f,!1),_()),t.result(f,()=>t.reset());function _(){const v=e.name("_valid"),h=e.let("count",0);y(v,()=>e.if(v,()=>g(h)))}function y(v,h){e.forRange("i",0,l,d=>{t.subschema({keyword:"contains",dataProp:d,dataPropType:rs.Type.Num,compositeRule:!0},v),h()})}function g(v){e.code((0,rt._)`${v}++`),a===void 0?e.if((0,rt._)`${v} >= ${i}`,()=>e.assign(f,!0).break()):(e.if((0,rt._)`${v} > ${a}`,()=>e.assign(f,!1).break()),i===1?e.assign(f,!0):e.if((0,rt._)`${v} >= ${i}`,()=>e.assign(f,!0)))}}};Wo.default=_m;var ru={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=Q,r=M,n=te;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},
1
+ (function($e,hr){typeof exports=="object"&&typeof module<"u"?hr(exports):typeof define=="function"&&define.amd?define(["exports"],hr):($e=typeof globalThis<"u"?globalThis:$e||self,hr($e.WebMCP={}))})(this,(function($e){"use strict";function hr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pn={exports:{}},da={},xt={},er={},fa={},ha={},pa={},pi;function xn(){return pi||(pi=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(f){if(super(),!t.IDENTIFIER.test(f))throw new Error("CodeGen: name must be a valid identifier");this.str=f}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(f){super(),this._items=typeof f=="string"?[f]:f}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const f=this._items[0];return f===""||f==='""'}get str(){var f;return(f=this._str)!==null&&f!==void 0?f:this._str=this._items.reduce((g,b)=>`${g}${b}`,"")}get names(){var f;return(f=this._names)!==null&&f!==void 0?f:this._names=this._items.reduce((g,b)=>(b instanceof r&&(g[b.str]=(g[b.str]||0)+1),g),{})}}t._Code=n,t.nil=new n("");function s(v,...f){const g=[v[0]];let b=0;for(;b<f.length;)i(g,f[b]),g.push(v[++b]);return new n(g)}t._=s;const a=new n("+");function o(v,...f){const g=[_(v[0])];let b=0;for(;b<f.length;)g.push(a),i(g,f[b]),g.push(a,_(v[++b]));return c(g),new n(g)}t.str=o;function i(v,f){f instanceof n?v.push(...f._items):f instanceof r?v.push(f):v.push(d(f))}t.addCodeArg=i;function c(v){let f=1;for(;f<v.length-1;){if(v[f]===a){const g=u(v[f-1],v[f+1]);if(g!==void 0){v.splice(f-1,3,g);continue}v[f++]="+"}f++}}function u(v,f){if(f==='""')return v;if(v==='""')return f;if(typeof v=="string")return f instanceof r||v[v.length-1]!=='"'?void 0:typeof f!="string"?`${v.slice(0,-1)}${f}"`:f[0]==='"'?v.slice(0,-1)+f.slice(1):void 0;if(typeof f=="string"&&f[0]==='"'&&!(v instanceof r))return`"${v}${f.slice(1)}`}function l(v,f){return f.emptyStr()?v:v.emptyStr()?f:o`${v}${f}`}t.strConcat=l;function d(v){return typeof v=="number"||typeof v=="boolean"||v===null?v:_(Array.isArray(v)?v.join(","):v)}function m(v){return new n(_(v))}t.stringify=m;function _(v){return JSON.stringify(v).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=_;function p(v){return typeof v=="string"&&t.IDENTIFIER.test(v)?new n(`.${v}`):s`[${v}]`}t.getProperty=p;function y(v){if(typeof v=="string"&&t.IDENTIFIER.test(v))return new n(`${v}`);throw new Error(`CodeGen: invalid export name: ${v}, use explicit $id name mapping`)}t.getEsmExportName=y;function h(v){return new n(v.toString())}t.regexpCode=h})(pa)),pa}var ma={},mi;function _i(){return mi||(mi=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=xn();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,d;if(!((d=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||d===void 0)&&d.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:d}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(l)}[${d}]`}}t.ValueScopeName=a;const o=(0,e._)`\n`;class i extends s{constructor(u){super(u),this._values={},this._scope=u.scope,this.opts={...u,_n:u.lines?o:e.nil}}get(){return this._scope}name(u){return new a(u,this._newName(u))}value(u,l){var d;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const m=this.toName(u),{prefix:_}=m,p=(d=l.key)!==null&&d!==void 0?d:l.ref;let y=this._values[_];if(y){const f=y.get(p);if(f)return f}else y=this._values[_]=new Map;y.set(p,m);const h=this._scope[_]||(this._scope[_]=[]),v=h.length;return h[v]=l.ref,m.setValue(l,{property:_,itemIndex:v}),m}getValue(u,l){const d=this._values[u];if(d)return d.get(l)}scopeRefs(u,l=this._values){return this._reduceValues(l,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,e._)`${u}${d.scopePath}`})}scopeCode(u=this._values,l,d){return this._reduceValues(u,m=>{if(m.value===void 0)throw new Error(`CodeGen: name "${m}" has no value`);return m.value.code},l,d)}_reduceValues(u,l,d={},m){let _=e.nil;for(const p in u){const y=u[p];if(!y)continue;const h=d[p]=d[p]||new Map;y.forEach(v=>{if(h.has(v))return;h.set(v,n.Started);let f=l(v);if(f){const g=this.opts.es5?t.varKinds.var:t.varKinds.const;_=(0,e._)`${_}${g} ${v} = ${f};${this.opts._n}`}else if(f=m?.(v))_=(0,e._)`${_}${f}${this.opts._n}`;else throw new r(v);h.set(v,n.Completed)})}return _}}t.ValueScope=i})(ma)),ma}var gi;function ie(){return gi||(gi=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=xn(),r=_i();var n=xn();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=_i();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($,E){return this}}class o extends a{constructor($,E,N){super(),this.varKind=$,this.name=E,this.rhs=N}render({es5:$,_n:E}){const N=$?r.varKinds.var:this.varKind,ee=this.rhs===void 0?"":` = ${this.rhs}`;return`${N} ${this.name}${ee};`+E}optimizeNames($,E){if($[this.name.str])return this.rhs&&(this.rhs=Y(this.rhs,$,E)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class i extends a{constructor($,E,N){super(),this.lhs=$,this.rhs=E,this.sideEffects=N}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,E){if(!(this.lhs instanceof e.Name&&!$[this.lhs.str]&&!this.sideEffects))return this.rhs=Y(this.rhs,$,E),this}get names(){const $=this.lhs instanceof e.Name?{}:{...this.lhs.names};return J($,this.rhs)}}class c extends i{constructor($,E,N,ee){super($,N,ee),this.op=E}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class u extends a{constructor($){super(),this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class l extends a{constructor($){super(),this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class d extends a{constructor($){super(),this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class m extends a{constructor($){super(),this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,E){return this.code=Y(this.code,$,E),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class _ extends a{constructor($=[]){super(),this.nodes=$}render($){return this.nodes.reduce((E,N)=>E+N.render($),"")}optimizeNodes(){const{nodes:$}=this;let E=$.length;for(;E--;){const N=$[E].optimizeNodes();Array.isArray(N)?$.splice(E,1,...N):N?$[E]=N:$.splice(E,1)}return $.length>0?this:void 0}optimizeNames($,E){const{nodes:N}=this;let ee=N.length;for(;ee--;){const ne=N[ee];ne.optimizeNames($,E)||(ge($,ne.names),N.splice(ee,1))}return N.length>0?this:void 0}get names(){return this.nodes.reduce(($,E)=>V($,E.names),{})}}class p extends _{render($){return"{"+$._n+super.render($)+"}"+$._n}}class y extends _{}class h extends p{}h.kind="else";class v extends p{constructor($,E){super(E),this.condition=$}render($){let E=`if(${this.condition})`+super.render($);return this.else&&(E+="else "+this.else.render($)),E}optimizeNodes(){super.optimizeNodes();const $=this.condition;if($===!0)return this.nodes;let E=this.else;if(E){const N=E.optimizeNodes();E=this.else=Array.isArray(N)?new h(N):N}if(E)return $===!1?E instanceof v?E:E.nodes:this.nodes.length?this:new v(Ge($),E instanceof v?[E]:E.nodes);if(!($===!1||!this.nodes.length))return this}optimizeNames($,E){var N;if(this.else=(N=this.else)===null||N===void 0?void 0:N.optimizeNames($,E),!!(super.optimizeNames($,E)||this.else))return this.condition=Y(this.condition,$,E),this}get names(){const $=super.names;return J($,this.condition),this.else&&V($,this.else.names),$}}v.kind="if";class f extends p{}f.kind="for";class g extends f{constructor($){super(),this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,E){if(super.optimizeNames($,E))return this.iteration=Y(this.iteration,$,E),this}get names(){return V(super.names,this.iteration.names)}}class b extends f{constructor($,E,N,ee){super(),this.varKind=$,this.name=E,this.from=N,this.to=ee}render($){const E=$.es5?r.varKinds.var:this.varKind,{name:N,from:ee,to:ne}=this;return`for(${E} ${N}=${ee}; ${N}<${ne}; ${N}++)`+super.render($)}get names(){const $=J(super.names,this.from);return J($,this.to)}}class w extends f{constructor($,E,N,ee){super(),this.loop=$,this.varKind=E,this.name=N,this.iterable=ee}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,E){if(super.optimizeNames($,E))return this.iterable=Y(this.iterable,$,E),this}get names(){return V(super.names,this.iterable.names)}}class k extends p{constructor($,E,N){super(),this.name=$,this.args=E,this.async=N}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}k.kind="func";class S extends _{render($){return"return "+super.render($)}}S.kind="return";class C extends p{render($){let E="try"+super.render($);return this.catch&&(E+=this.catch.render($)),this.finally&&(E+=this.finally.render($)),E}optimizeNodes(){var $,E;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(E=this.finally)===null||E===void 0||E.optimizeNodes(),this}optimizeNames($,E){var N,ee;return super.optimizeNames($,E),(N=this.catch)===null||N===void 0||N.optimizeNames($,E),(ee=this.finally)===null||ee===void 0||ee.optimizeNames($,E),this}get names(){const $=super.names;return this.catch&&V($,this.catch.names),this.finally&&V($,this.finally.names),$}}class j extends p{constructor($){super(),this.error=$}render($){return`catch(${this.error})`+super.render($)}}j.kind="catch";class D extends p{render($){return"finally"+super.render($)}}D.kind="finally";class A{constructor($,E={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...E,_n:E.lines?`
2
+ `:""},this._extScope=$,this._scope=new r.Scope({parent:$}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,E){const N=this._extScope.value($,E);return(this._values[N.prefix]||(this._values[N.prefix]=new Set)).add(N),N}getScopeValue($,E){return this._extScope.getValue($,E)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,E,N,ee){const ne=this._scope.toName(E);return N!==void 0&&ee&&(this._constants[ne.str]=N),this._leafNode(new o($,ne,N)),ne}const($,E,N){return this._def(r.varKinds.const,$,E,N)}let($,E,N){return this._def(r.varKinds.let,$,E,N)}var($,E,N){return this._def(r.varKinds.var,$,E,N)}assign($,E,N){return this._leafNode(new i($,E,N))}add($,E){return this._leafNode(new c($,t.operators.ADD,E))}code($){return typeof $=="function"?$():$!==e.nil&&this._leafNode(new m($)),this}object(...$){const E=["{"];for(const[N,ee]of $)E.length>1&&E.push(","),E.push(N),(N!==ee||this.opts.es5)&&(E.push(":"),(0,e.addCodeArg)(E,ee));return E.push("}"),new e._Code(E)}if($,E,N){if(this._blockNode(new v($)),E&&N)this.code(E).else().code(N).endIf();else if(E)this.code(E).endIf();else if(N)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new v($))}else(){return this._elseNode(new h)}endIf(){return this._endBlockNode(v,h)}_for($,E){return this._blockNode($),E&&this.code(E).endFor(),this}for($,E){return this._for(new g($),E)}forRange($,E,N,ee,ne=this.opts.es5?r.varKinds.var:r.varKinds.let){const me=this._scope.toName($);return this._for(new b(ne,me,E,N),()=>ee(me))}forOf($,E,N,ee=r.varKinds.const){const ne=this._scope.toName($);if(this.opts.es5){const me=E instanceof e.Name?E:this.var("_arr",E);return this.forRange("_i",0,(0,e._)`${me}.length`,fe=>{this.var(ne,(0,e._)`${me}[${fe}]`),N(ne)})}return this._for(new w("of",ee,ne,E),()=>N(ne))}forIn($,E,N,ee=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf($,(0,e._)`Object.keys(${E})`,N);const ne=this._scope.toName($);return this._for(new w("in",ee,ne,E),()=>N(ne))}endFor(){return this._endBlockNode(f)}label($){return this._leafNode(new u($))}break($){return this._leafNode(new l($))}return($){const E=new S;if(this._blockNode(E),this.code($),E.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(S)}try($,E,N){if(!E&&!N)throw new Error('CodeGen: "try" without "catch" and "finally"');const ee=new C;if(this._blockNode(ee),this.code($),E){const ne=this.name("e");this._currNode=ee.catch=new j(ne),E(ne)}return N&&(this._currNode=ee.finally=new D,this.code(N)),this._endBlockNode(j,D)}throw($){return this._leafNode(new d($))}block($,E){return this._blockStarts.push(this._nodes.length),$&&this.code($).endBlock(E),this}endBlock($){const E=this._blockStarts.pop();if(E===void 0)throw new Error("CodeGen: not in self-balancing block");const N=this._nodes.length-E;if(N<0||$!==void 0&&N!==$)throw new Error(`CodeGen: wrong number of nodes: ${N} vs ${$} expected`);return this._nodes.length=E,this}func($,E=e.nil,N,ee){return this._blockNode(new k($,E,N)),ee&&this.code(ee).endFunc(),this}endFunc(){return this._endBlockNode(k)}optimize($=1){for(;$-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode($){return this._currNode.nodes.push($),this}_blockNode($){this._currNode.nodes.push($),this._nodes.push($)}_endBlockNode($,E){const N=this._currNode;if(N instanceof $||E&&N instanceof E)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${E?`${$.kind}/${E.kind}`:$.kind}"`)}_elseNode($){const E=this._currNode;if(!(E instanceof v))throw new Error('CodeGen: "else" without "if"');return this._currNode=E.else=$,this}get _root(){return this._nodes[0]}get _currNode(){const $=this._nodes;return $[$.length-1]}set _currNode($){const E=this._nodes;E[E.length-1]=$}}t.CodeGen=A;function V(I,$){for(const E in $)I[E]=(I[E]||0)+($[E]||0);return I}function J(I,$){return $ instanceof e._CodeOrName?V(I,$.names):I}function Y(I,$,E){if(I instanceof e.Name)return N(I);if(!ee(I))return I;return new e._Code(I._items.reduce((ne,me)=>(me instanceof e.Name&&(me=N(me)),me instanceof e._Code?ne.push(...me._items):ne.push(me),ne),[]));function N(ne){const me=E[ne.str];return me===void 0||$[ne.str]!==1?ne:(delete $[ne.str],me)}function ee(ne){return ne instanceof e._Code&&ne._items.some(me=>me instanceof e.Name&&$[me.str]===1&&E[me.str]!==void 0)}}function ge(I,$){for(const E in $)I[E]=(I[E]||0)-($[E]||0)}function Ge(I){return typeof I=="boolean"||typeof I=="number"||I===null?!I:(0,e._)`!${z(I)}`}t.not=Ge;const Ye=P(t.operators.AND);function be(...I){return I.reduce(Ye)}t.and=be;const Tt=P(t.operators.OR);function L(...I){return I.reduce(Tt)}t.or=L;function P(I){return($,E)=>$===e.nil?E:E===e.nil?$:(0,e._)`${z($)} ${I} ${z(E)}`}function z(I){return I instanceof e.Name?I:(0,e._)`(${I})`}})(ha)),ha}var ce={},yi;function he(){if(yi)return ce;yi=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.checkStrictMode=ce.getErrorPath=ce.Type=ce.useFunc=ce.setEvaluated=ce.evaluatedPropsToName=ce.mergeEvaluated=ce.eachItem=ce.unescapeJsonPointer=ce.escapeJsonPointer=ce.escapeFragment=ce.unescapeFragment=ce.schemaRefOrVal=ce.schemaHasRulesButRef=ce.schemaHasRules=ce.checkUnknownRules=ce.alwaysValidSchema=ce.toHash=void 0;const t=ie(),e=xn();function r(w){const k={};for(const S of w)k[S]=!0;return k}ce.toHash=r;function n(w,k){return typeof k=="boolean"?k:Object.keys(k).length===0?!0:(s(w,k),!a(k,w.self.RULES.all))}ce.alwaysValidSchema=n;function s(w,k=w.schema){const{opts:S,self:C}=w;if(!S.strictSchema||typeof k=="boolean")return;const j=C.RULES.keywords;for(const D in k)j[D]||b(w,`unknown keyword: "${D}"`)}ce.checkUnknownRules=s;function a(w,k){if(typeof w=="boolean")return!w;for(const S in w)if(k[S])return!0;return!1}ce.schemaHasRules=a;function o(w,k){if(typeof w=="boolean")return!w;for(const S in w)if(S!=="$ref"&&k.all[S])return!0;return!1}ce.schemaHasRulesButRef=o;function i({topSchemaRef:w,schemaPath:k},S,C,j){if(!j){if(typeof S=="number"||typeof S=="boolean")return S;if(typeof S=="string")return(0,t._)`${S}`}return(0,t._)`${w}${k}${(0,t.getProperty)(C)}`}ce.schemaRefOrVal=i;function c(w){return d(decodeURIComponent(w))}ce.unescapeFragment=c;function u(w){return encodeURIComponent(l(w))}ce.escapeFragment=u;function l(w){return typeof w=="number"?`${w}`:w.replace(/~/g,"~0").replace(/\//g,"~1")}ce.escapeJsonPointer=l;function d(w){return w.replace(/~1/g,"/").replace(/~0/g,"~")}ce.unescapeJsonPointer=d;function m(w,k){if(Array.isArray(w))for(const S of w)k(S);else k(w)}ce.eachItem=m;function _({mergeNames:w,mergeToName:k,mergeValues:S,resultToName:C}){return(j,D,A,V)=>{const J=A===void 0?D:A instanceof t.Name?(D instanceof t.Name?w(j,D,A):k(j,D,A),A):D instanceof t.Name?(k(j,A,D),D):S(D,A);return V===t.Name&&!(J instanceof t.Name)?C(j,J):J}}ce.mergeEvaluated={props:_({mergeNames:(w,k,S)=>w.if((0,t._)`${S} !== true && ${k} !== undefined`,()=>{w.if((0,t._)`${k} === true`,()=>w.assign(S,!0),()=>w.assign(S,(0,t._)`${S} || {}`).code((0,t._)`Object.assign(${S}, ${k})`))}),mergeToName:(w,k,S)=>w.if((0,t._)`${S} !== true`,()=>{k===!0?w.assign(S,!0):(w.assign(S,(0,t._)`${S} || {}`),y(w,S,k))}),mergeValues:(w,k)=>w===!0?!0:{...w,...k},resultToName:p}),items:_({mergeNames:(w,k,S)=>w.if((0,t._)`${S} !== true && ${k} !== undefined`,()=>w.assign(S,(0,t._)`${k} === true ? true : ${S} > ${k} ? ${S} : ${k}`)),mergeToName:(w,k,S)=>w.if((0,t._)`${S} !== true`,()=>w.assign(S,k===!0?!0:(0,t._)`${S} > ${k} ? ${S} : ${k}`)),mergeValues:(w,k)=>w===!0?!0:Math.max(w,k),resultToName:(w,k)=>w.var("items",k)})};function p(w,k){if(k===!0)return w.var("props",!0);const S=w.var("props",(0,t._)`{}`);return k!==void 0&&y(w,S,k),S}ce.evaluatedPropsToName=p;function y(w,k,S){Object.keys(S).forEach(C=>w.assign((0,t._)`${k}${(0,t.getProperty)(C)}`,!0))}ce.setEvaluated=y;const h={};function v(w,k){return w.scopeValue("func",{ref:k,code:h[k.code]||(h[k.code]=new e._Code(k.code))})}ce.useFunc=v;var f;(function(w){w[w.Num=0]="Num",w[w.Str=1]="Str"})(f||(ce.Type=f={}));function g(w,k,S){if(w instanceof t.Name){const C=k===f.Num;return S?C?(0,t._)`"[" + ${w} + "]"`:(0,t._)`"['" + ${w} + "']"`:C?(0,t._)`"/" + ${w}`:(0,t._)`"/" + ${w}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return S?(0,t.getProperty)(w).toString():"/"+l(w)}ce.getErrorPath=g;function b(w,k,S=w.opts.strictSchema){if(S){if(k=`strict mode: ${k}`,S===!0)throw new Error(k);w.self.logger.warn(k)}}return ce.checkStrictMode=b,ce}var In={},vi;function Zt(){if(vi)return In;vi=1,Object.defineProperty(In,"__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 In.default=e,In}var wi;function Cn(){return wi||(wi=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=he(),n=Zt();t.keywordError={message:({keyword:h})=>(0,e.str)`must pass "${h}" keyword validation`},t.keyword$DataError={message:({keyword:h,schemaType:v})=>v?(0,e.str)`"${h}" keyword must be ${v} ($data)`:(0,e.str)`"${h}" keyword is invalid ($data)`};function s(h,v=t.keywordError,f,g){const{it:b}=h,{gen:w,compositeRule:k,allErrors:S}=b,C=d(h,v,f);g??(k||S)?c(w,C):u(b,(0,e._)`[${C}]`)}t.reportError=s;function a(h,v=t.keywordError,f){const{it:g}=h,{gen:b,compositeRule:w,allErrors:k}=g,S=d(h,v,f);c(b,S),w||k||u(g,n.default.vErrors)}t.reportExtraError=a;function o(h,v){h.assign(n.default.errors,v),h.if((0,e._)`${n.default.vErrors} !== null`,()=>h.if(v,()=>h.assign((0,e._)`${n.default.vErrors}.length`,v),()=>h.assign(n.default.vErrors,null)))}t.resetErrorsCount=o;function i({gen:h,keyword:v,schemaValue:f,data:g,errsCount:b,it:w}){if(b===void 0)throw new Error("ajv implementation error");const k=h.name("err");h.forRange("i",b,n.default.errors,S=>{h.const(k,(0,e._)`${n.default.vErrors}[${S}]`),h.if((0,e._)`${k}.instancePath === undefined`,()=>h.assign((0,e._)`${k}.instancePath`,(0,e.strConcat)(n.default.instancePath,w.errorPath))),h.assign((0,e._)`${k}.schemaPath`,(0,e.str)`${w.errSchemaPath}/${v}`),w.opts.verbose&&(h.assign((0,e._)`${k}.schema`,f),h.assign((0,e._)`${k}.data`,g))})}t.extendErrors=i;function c(h,v){const f=h.const("err",v);h.if((0,e._)`${n.default.vErrors} === null`,()=>h.assign(n.default.vErrors,(0,e._)`[${f}]`),(0,e._)`${n.default.vErrors}.push(${f})`),h.code((0,e._)`${n.default.errors}++`)}function u(h,v){const{gen:f,validateName:g,schemaEnv:b}=h;b.$async?f.throw((0,e._)`new ${h.ValidationError}(${v})`):(f.assign((0,e._)`${g}.errors`,v),f.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 d(h,v,f){const{createErrors:g}=h.it;return g===!1?(0,e._)`{}`:m(h,v,f)}function m(h,v,f={}){const{gen:g,it:b}=h,w=[_(b,f),p(h,f)];return y(h,v,w),g.object(...w)}function _({errorPath:h},{instancePath:v}){const f=v?(0,e.str)`${h}${(0,r.getErrorPath)(v,r.Type.Str)}`:h;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,f)]}function p({keyword:h,it:{errSchemaPath:v}},{schemaPath:f,parentSchema:g}){let b=g?v:(0,e.str)`${v}/${h}`;return f&&(b=(0,e.str)`${b}${(0,r.getErrorPath)(f,r.Type.Str)}`),[l.schemaPath,b]}function y(h,{params:v,message:f},g){const{keyword:b,data:w,schemaValue:k,it:S}=h,{opts:C,propertyName:j,topSchemaRef:D,schemaPath:A}=S;g.push([l.keyword,b],[l.params,typeof v=="function"?v(h):v||(0,e._)`{}`]),C.messages&&g.push([l.message,typeof f=="function"?f(h):f]),C.verbose&&g.push([l.schema,k],[l.parentSchema,(0,e._)`${D}${A}`],[n.default.data,w]),j&&g.push([l.propertyName,j])}})(fa)),fa}var bi;function wd(){if(bi)return er;bi=1,Object.defineProperty(er,"__esModule",{value:!0}),er.boolOrEmptySchema=er.topBoolOrEmptySchema=void 0;const t=Cn(),e=ie(),r=Zt(),n={message:"boolean schema is false"};function s(i){const{gen:c,schema:u,validateName:l}=i;u===!1?o(i,!1):typeof u=="object"&&u.$async===!0?c.return(r.default.data):(c.assign((0,e._)`${l}.errors`,null),c.return(!0))}er.topBoolOrEmptySchema=s;function a(i,c){const{gen:u,schema:l}=i;l===!1?(u.var(c,!1),o(i)):u.var(c,!0)}er.boolOrEmptySchema=a;function o(i,c){const{gen:u,data:l}=i,d={gen:u,keyword:"false schema",data:l,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:i};(0,t.reportError)(d,n,void 0,c)}return er}var qe={},tr={},ki;function $i(){if(ki)return tr;ki=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.getRules=tr.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)}tr.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 tr.getRules=n,tr}var It={},Si;function Ti(){if(Si)return It;Si=1,Object.defineProperty(It,"__esModule",{value:!0}),It.shouldUseRule=It.shouldUseGroup=It.schemaHasRulesForType=void 0;function t({schema:n,self:s},a){const o=s.RULES.types[a];return o&&o!==!0&&e(n,o)}It.schemaHasRulesForType=t;function e(n,s){return s.rules.some(a=>r(n,a))}It.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(o=>n[o]!==void 0))}return It.shouldUseRule=r,It}var Ei;function On(){if(Ei)return qe;Ei=1,Object.defineProperty(qe,"__esModule",{value:!0}),qe.reportTypeError=qe.checkDataTypes=qe.checkDataType=qe.coerceAndCheckDataType=qe.getJSONTypes=qe.getSchemaTypes=qe.DataType=void 0;const t=$i(),e=Ti(),r=Cn(),n=ie(),s=he();var a;(function(f){f[f.Correct=0]="Correct",f[f.Wrong=1]="Wrong"})(a||(qe.DataType=a={}));function o(f){const g=i(f.type);if(g.includes("null")){if(f.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!g.length&&f.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');f.nullable===!0&&g.push("null")}return g}qe.getSchemaTypes=o;function i(f){const g=Array.isArray(f)?f:f?[f]:[];if(g.every(t.isJSONType))return g;throw new Error("type must be JSONType or JSONType[]: "+g.join(","))}qe.getJSONTypes=i;function c(f,g){const{gen:b,data:w,opts:k}=f,S=l(g,k.coerceTypes),C=g.length>0&&!(S.length===0&&g.length===1&&(0,e.schemaHasRulesForType)(f,g[0]));if(C){const j=p(g,w,k.strictNumbers,a.Wrong);b.if(j,()=>{S.length?d(f,g,S):h(f)})}return C}qe.coerceAndCheckDataType=c;const u=new Set(["string","number","integer","boolean","null"]);function l(f,g){return g?f.filter(b=>u.has(b)||g==="array"&&b==="array"):[]}function d(f,g,b){const{gen:w,data:k,opts:S}=f,C=w.let("dataType",(0,n._)`typeof ${k}`),j=w.let("coerced",(0,n._)`undefined`);S.coerceTypes==="array"&&w.if((0,n._)`${C} == 'object' && Array.isArray(${k}) && ${k}.length == 1`,()=>w.assign(k,(0,n._)`${k}[0]`).assign(C,(0,n._)`typeof ${k}`).if(p(g,k,S.strictNumbers),()=>w.assign(j,k))),w.if((0,n._)`${j} !== undefined`);for(const A of b)(u.has(A)||A==="array"&&S.coerceTypes==="array")&&D(A);w.else(),h(f),w.endIf(),w.if((0,n._)`${j} !== undefined`,()=>{w.assign(k,j),m(f,j)});function D(A){switch(A){case"string":w.elseIf((0,n._)`${C} == "number" || ${C} == "boolean"`).assign(j,(0,n._)`"" + ${k}`).elseIf((0,n._)`${k} === null`).assign(j,(0,n._)`""`);return;case"number":w.elseIf((0,n._)`${C} == "boolean" || ${k} === null
3
+ || (${C} == "string" && ${k} && ${k} == +${k})`).assign(j,(0,n._)`+${k}`);return;case"integer":w.elseIf((0,n._)`${C} === "boolean" || ${k} === null
4
+ || (${C} === "string" && ${k} && ${k} == +${k} && !(${k} % 1))`).assign(j,(0,n._)`+${k}`);return;case"boolean":w.elseIf((0,n._)`${k} === "false" || ${k} === 0 || ${k} === null`).assign(j,!1).elseIf((0,n._)`${k} === "true" || ${k} === 1`).assign(j,!0);return;case"null":w.elseIf((0,n._)`${k} === "" || ${k} === 0 || ${k} === false`),w.assign(j,null);return;case"array":w.elseIf((0,n._)`${C} === "string" || ${C} === "number"
5
+ || ${C} === "boolean" || ${k} === null`).assign(j,(0,n._)`[${k}]`)}}}function m({gen:f,parentData:g,parentDataProperty:b},w){f.if((0,n._)`${g} !== undefined`,()=>f.assign((0,n._)`${g}[${b}]`,w))}function _(f,g,b,w=a.Correct){const k=w===a.Correct?n.operators.EQ:n.operators.NEQ;let S;switch(f){case"null":return(0,n._)`${g} ${k} null`;case"array":S=(0,n._)`Array.isArray(${g})`;break;case"object":S=(0,n._)`${g} && typeof ${g} == "object" && !Array.isArray(${g})`;break;case"integer":S=C((0,n._)`!(${g} % 1) && !isNaN(${g})`);break;case"number":S=C();break;default:return(0,n._)`typeof ${g} ${k} ${f}`}return w===a.Correct?S:(0,n.not)(S);function C(j=n.nil){return(0,n.and)((0,n._)`typeof ${g} == "number"`,j,b?(0,n._)`isFinite(${g})`:n.nil)}}qe.checkDataType=_;function p(f,g,b,w){if(f.length===1)return _(f[0],g,b,w);let k;const S=(0,s.toHash)(f);if(S.array&&S.object){const C=(0,n._)`typeof ${g} != "object"`;k=S.null?C:(0,n._)`!${g} || ${C}`,delete S.null,delete S.array,delete S.object}else k=n.nil;S.number&&delete S.integer;for(const C in S)k=(0,n.and)(k,_(C,g,b,w));return k}qe.checkDataTypes=p;const y={message:({schema:f})=>`must be ${f}`,params:({schema:f,schemaValue:g})=>typeof f=="string"?(0,n._)`{type: ${f}}`:(0,n._)`{type: ${g}}`};function h(f){const g=v(f);(0,r.reportError)(g,y)}qe.reportTypeError=h;function v(f){const{gen:g,data:b,schema:w}=f,k=(0,s.schemaRefOrVal)(f,w,"type");return{gen:g,keyword:"type",data:b,schema:w.type,schemaCode:k,schemaValue:k,parentSchema:w,params:{},it:f}}return qe}var Mr={},Ri;function bd(){if(Ri)return Mr;Ri=1,Object.defineProperty(Mr,"__esModule",{value:!0}),Mr.assignDefaults=void 0;const t=ie(),e=he();function r(s,a){const{properties:o,items:i}=s.schema;if(a==="object"&&o)for(const c in o)n(s,c,o[c].default);else a==="array"&&Array.isArray(i)&&i.forEach((c,u)=>n(s,u,c.default))}Mr.assignDefaults=r;function n(s,a,o){const{gen:i,compositeRule:c,data:u,opts:l}=s;if(o===void 0)return;const d=(0,t._)`${u}${(0,t.getProperty)(a)}`;if(c){(0,e.checkStrictMode)(s,`default is ignored for: ${d}`);return}let m=(0,t._)`${d} === undefined`;l.useDefaults==="empty"&&(m=(0,t._)`${m} || ${d} === null || ${d} === ""`),i.if(m,(0,t._)`${d} = ${(0,t.stringify)(o)}`)}return Mr}var ft={},ye={},Pi;function ht(){if(Pi)return ye;Pi=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.validateUnion=ye.validateArray=ye.usePattern=ye.callValidateCode=ye.schemaProperties=ye.allSchemaProperties=ye.noPropertyInData=ye.propertyInData=ye.isOwnProperty=ye.hasPropFunc=ye.reportMissingProp=ye.checkMissingProp=ye.checkReportMissingProp=void 0;const t=ie(),e=he(),r=Zt(),n=he();function s(f,g){const{gen:b,data:w,it:k}=f;b.if(l(b,w,g,k.opts.ownProperties),()=>{f.setParams({missingProperty:(0,t._)`${g}`},!0),f.error()})}ye.checkReportMissingProp=s;function a({gen:f,data:g,it:{opts:b}},w,k){return(0,t.or)(...w.map(S=>(0,t.and)(l(f,g,S,b.ownProperties),(0,t._)`${k} = ${S}`)))}ye.checkMissingProp=a;function o(f,g){f.setParams({missingProperty:g},!0),f.error()}ye.reportMissingProp=o;function i(f){return f.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}ye.hasPropFunc=i;function c(f,g,b){return(0,t._)`${i(f)}.call(${g}, ${b})`}ye.isOwnProperty=c;function u(f,g,b,w){const k=(0,t._)`${g}${(0,t.getProperty)(b)} !== undefined`;return w?(0,t._)`${k} && ${c(f,g,b)}`:k}ye.propertyInData=u;function l(f,g,b,w){const k=(0,t._)`${g}${(0,t.getProperty)(b)} === undefined`;return w?(0,t.or)(k,(0,t.not)(c(f,g,b))):k}ye.noPropertyInData=l;function d(f){return f?Object.keys(f).filter(g=>g!=="__proto__"):[]}ye.allSchemaProperties=d;function m(f,g){return d(g).filter(b=>!(0,e.alwaysValidSchema)(f,g[b]))}ye.schemaProperties=m;function _({schemaCode:f,data:g,it:{gen:b,topSchemaRef:w,schemaPath:k,errorPath:S},it:C},j,D,A){const V=A?(0,t._)`${f}, ${g}, ${w}${k}`:g,J=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,S)],[r.default.parentData,C.parentData],[r.default.parentDataProperty,C.parentDataProperty],[r.default.rootData,r.default.rootData]];C.opts.dynamicRef&&J.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const Y=(0,t._)`${V}, ${b.object(...J)}`;return D!==t.nil?(0,t._)`${j}.call(${D}, ${Y})`:(0,t._)`${j}(${Y})`}ye.callValidateCode=_;const p=(0,t._)`new RegExp`;function y({gen:f,it:{opts:g}},b){const w=g.unicodeRegExp?"u":"",{regExp:k}=g.code,S=k(b,w);return f.scopeValue("pattern",{key:S.toString(),ref:S,code:(0,t._)`${k.code==="new RegExp"?p:(0,n.useFunc)(f,k)}(${b}, ${w})`})}ye.usePattern=y;function h(f){const{gen:g,data:b,keyword:w,it:k}=f,S=g.name("valid");if(k.allErrors){const j=g.let("valid",!0);return C(()=>g.assign(j,!1)),j}return g.var(S,!0),C(()=>g.break()),S;function C(j){const D=g.const("len",(0,t._)`${b}.length`);g.forRange("i",0,D,A=>{f.subschema({keyword:w,dataProp:A,dataPropType:e.Type.Num},S),g.if((0,t.not)(S),j)})}}ye.validateArray=h;function v(f){const{gen:g,schema:b,keyword:w,it:k}=f;if(!Array.isArray(b))throw new Error("ajv implementation error");if(b.some(D=>(0,e.alwaysValidSchema)(k,D))&&!k.opts.unevaluated)return;const C=g.let("valid",!1),j=g.name("_valid");g.block(()=>b.forEach((D,A)=>{const V=f.subschema({keyword:w,schemaProp:A,compositeRule:!0},j);g.assign(C,(0,t._)`${C} || ${j}`),f.mergeValidEvaluated(V,j)||g.if((0,t.not)(C))})),f.result(C,()=>f.reset(),()=>f.error(!0))}return ye.validateUnion=v,ye}var xi;function kd(){if(xi)return ft;xi=1,Object.defineProperty(ft,"__esModule",{value:!0}),ft.validateKeywordUsage=ft.validSchemaType=ft.funcKeywordCode=ft.macroKeywordCode=void 0;const t=ie(),e=Zt(),r=ht(),n=Cn();function s(m,_){const{gen:p,keyword:y,schema:h,parentSchema:v,it:f}=m,g=_.macro.call(f.self,h,v,f),b=u(p,y,g);f.opts.validateSchema!==!1&&f.self.validateSchema(g,!0);const w=p.name("valid");m.subschema({schema:g,schemaPath:t.nil,errSchemaPath:`${f.errSchemaPath}/${y}`,topSchemaRef:b,compositeRule:!0},w),m.pass(w,()=>m.error(!0))}ft.macroKeywordCode=s;function a(m,_){var p;const{gen:y,keyword:h,schema:v,parentSchema:f,$data:g,it:b}=m;c(b,_);const w=!g&&_.compile?_.compile.call(b.self,v,f,b):_.validate,k=u(y,h,w),S=y.let("valid");m.block$data(S,C),m.ok((p=_.valid)!==null&&p!==void 0?p:S);function C(){if(_.errors===!1)A(),_.modifying&&o(m),V(()=>m.error());else{const J=_.async?j():D();_.modifying&&o(m),V(()=>i(m,J))}}function j(){const J=y.let("ruleErrs",null);return y.try(()=>A((0,t._)`await `),Y=>y.assign(S,!1).if((0,t._)`${Y} instanceof ${b.ValidationError}`,()=>y.assign(J,(0,t._)`${Y}.errors`),()=>y.throw(Y))),J}function D(){const J=(0,t._)`${k}.errors`;return y.assign(J,null),A(t.nil),J}function A(J=_.async?(0,t._)`await `:t.nil){const Y=b.opts.passContext?e.default.this:e.default.self,ge=!("compile"in _&&!g||_.schema===!1);y.assign(S,(0,t._)`${J}${(0,r.callValidateCode)(m,k,Y,ge)}`,_.modifying)}function V(J){var Y;y.if((0,t.not)((Y=_.valid)!==null&&Y!==void 0?Y:S),J)}}ft.funcKeywordCode=a;function o(m){const{gen:_,data:p,it:y}=m;_.if(y.parentData,()=>_.assign(p,(0,t._)`${y.parentData}[${y.parentDataProperty}]`))}function i(m,_){const{gen:p}=m;p.if((0,t._)`Array.isArray(${_})`,()=>{p.assign(e.default.vErrors,(0,t._)`${e.default.vErrors} === null ? ${_} : ${e.default.vErrors}.concat(${_})`).assign(e.default.errors,(0,t._)`${e.default.vErrors}.length`),(0,n.extendErrors)(m)},()=>m.error())}function c({schemaEnv:m},_){if(_.async&&!m.$async)throw new Error("async keyword in sync schema")}function u(m,_,p){if(p===void 0)throw new Error(`keyword "${_}" failed to compile`);return m.scopeValue("keyword",typeof p=="function"?{ref:p}:{ref:p,code:(0,t.stringify)(p)})}function l(m,_,p=!1){return!_.length||_.some(y=>y==="array"?Array.isArray(m):y==="object"?m&&typeof m=="object"&&!Array.isArray(m):typeof m==y||p&&typeof m>"u")}ft.validSchemaType=l;function d({schema:m,opts:_,self:p,errSchemaPath:y},h,v){if(Array.isArray(h.keyword)?!h.keyword.includes(v):h.keyword!==v)throw new Error("ajv implementation error");const f=h.dependencies;if(f?.some(g=>!Object.prototype.hasOwnProperty.call(m,g)))throw new Error(`parent schema must have dependencies of ${v}: ${f.join(",")}`);if(h.validateSchema&&!h.validateSchema(m[v])){const b=`keyword "${v}" value is invalid at path "${y}": `+p.errorsText(h.validateSchema.errors);if(_.validateSchema==="log")p.logger.error(b);else throw new Error(b)}}return ft.validateKeywordUsage=d,ft}var Ct={},Ii;function $d(){if(Ii)return Ct;Ii=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.extendSubschemaMode=Ct.extendSubschemaData=Ct.getSubschema=void 0;const t=ie(),e=he();function r(a,{keyword:o,schemaProp:i,schema:c,schemaPath:u,errSchemaPath:l,topSchemaRef:d}){if(o!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(o!==void 0){const m=a.schema[o];return i===void 0?{schema:m,schemaPath:(0,t._)`${a.schemaPath}${(0,t.getProperty)(o)}`,errSchemaPath:`${a.errSchemaPath}/${o}`}:{schema:m[i],schemaPath:(0,t._)`${a.schemaPath}${(0,t.getProperty)(o)}${(0,t.getProperty)(i)}`,errSchemaPath:`${a.errSchemaPath}/${o}/${(0,e.escapeFragment)(i)}`}}if(c!==void 0){if(u===void 0||l===void 0||d===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:u,topSchemaRef:d,errSchemaPath:l}}throw new Error('either "keyword" or "schema" must be passed')}Ct.getSubschema=r;function n(a,o,{dataProp:i,dataPropType:c,data:u,dataTypes:l,propertyName:d}){if(u!==void 0&&i!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:m}=o;if(i!==void 0){const{errorPath:p,dataPathArr:y,opts:h}=o,v=m.let("data",(0,t._)`${o.data}${(0,t.getProperty)(i)}`,!0);_(v),a.errorPath=(0,t.str)`${p}${(0,e.getErrorPath)(i,c,h.jsPropertySyntax)}`,a.parentDataProperty=(0,t._)`${i}`,a.dataPathArr=[...y,a.parentDataProperty]}if(u!==void 0){const p=u instanceof t.Name?u:m.let("data",u,!0);_(p),d!==void 0&&(a.propertyName=d)}l&&(a.dataTypes=l);function _(p){a.data=p,a.dataLevel=o.dataLevel+1,a.dataTypes=[],o.definedProperties=new Set,a.parentData=o.data,a.dataNames=[...o.dataNames,p]}}Ct.extendSubschemaData=n;function s(a,{jtdDiscriminator:o,jtdMetadata:i,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=o,a.jtdMetadata=i}return Ct.extendSubschemaMode=s,Ct}var Ke={},_a,Ci;function Oi(){return Ci||(Ci=1,_a=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 o=a[s];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}),_a}var ga={exports:{}},Ni;function Sd(){if(Ni)return ga.exports;Ni=1;var t=ga.exports=function(n,s,a){typeof s=="function"&&(a=s,s={}),a=s.cb||a;var o=typeof a=="function"?a:a.pre||function(){},i=a.post||function(){};e(s,o,i,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,o,i,c,u,l,d,m){if(o&&typeof o=="object"&&!Array.isArray(o)){s(o,i,c,u,l,d,m);for(var _ in o){var p=o[_];if(Array.isArray(p)){if(_ in t.arrayKeywords)for(var y=0;y<p.length;y++)e(n,s,a,p[y],i+"/"+_+"/"+y,c,i,_,o,y)}else if(_ in t.propsKeywords){if(p&&typeof p=="object")for(var h in p)e(n,s,a,p[h],i+"/"+_+"/"+r(h),c,i,_,o,h)}else(_ in t.keywords||n.allKeys&&!(_ in t.skipKeywords))&&e(n,s,a,p,i+"/"+_,c,i,_,o)}a(o,i,c,u,l,d,m)}}function r(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}return ga.exports}var Ai;function Nn(){if(Ai)return Ke;Ai=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.getSchemaRefs=Ke.resolveUrl=Ke.normalizeId=Ke._getFullPath=Ke.getFullPath=Ke.inlineRef=void 0;const t=he(),e=Oi(),r=Sd(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function s(y,h=!0){return typeof y=="boolean"?!0:h===!0?!o(y):h?i(y)<=h:!1}Ke.inlineRef=s;const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function o(y){for(const h in y){if(a.has(h))return!0;const v=y[h];if(Array.isArray(v)&&v.some(o)||typeof v=="object"&&o(v))return!0}return!1}function i(y){let h=0;for(const v in y){if(v==="$ref")return 1/0;if(h++,!n.has(v)&&(typeof y[v]=="object"&&(0,t.eachItem)(y[v],f=>h+=i(f)),h===1/0))return 1/0}return h}function c(y,h="",v){v!==!1&&(h=d(h));const f=y.parse(h);return u(y,f)}Ke.getFullPath=c;function u(y,h){return y.serialize(h).split("#")[0]+"#"}Ke._getFullPath=u;const l=/#\/?$/;function d(y){return y?y.replace(l,""):""}Ke.normalizeId=d;function m(y,h,v){return v=d(v),y.resolve(h,v)}Ke.resolveUrl=m;const _=/^[a-z_][-a-z0-9._]*$/i;function p(y,h){if(typeof y=="boolean")return{};const{schemaId:v,uriResolver:f}=this.opts,g=d(y[v]||h),b={"":g},w=c(f,g,!1),k={},S=new Set;return r(y,{allKeys:!0},(D,A,V,J)=>{if(J===void 0)return;const Y=w+A;let ge=b[J];typeof D[v]=="string"&&(ge=Ge.call(this,D[v])),Ye.call(this,D.$anchor),Ye.call(this,D.$dynamicAnchor),b[A]=ge;function Ge(be){const Tt=this.opts.uriResolver.resolve;if(be=d(ge?Tt(ge,be):be),S.has(be))throw j(be);S.add(be);let L=this.refs[be];return typeof L=="string"&&(L=this.refs[L]),typeof L=="object"?C(D,L.schema,be):be!==d(Y)&&(be[0]==="#"?(C(D,k[be],be),k[be]=D):this.refs[be]=Y),be}function Ye(be){if(typeof be=="string"){if(!_.test(be))throw new Error(`invalid anchor "${be}"`);Ge.call(this,`#${be}`)}}}),k;function C(D,A,V){if(A!==void 0&&!e(D,A))throw j(V)}function j(D){return new Error(`reference "${D}" resolves to more than one schema`)}}return Ke.getSchemaRefs=p,Ke}var ji;function An(){if(ji)return xt;ji=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.getData=xt.KeywordCxt=xt.validateFunctionCode=void 0;const t=wd(),e=On(),r=Ti(),n=On(),s=bd(),a=kd(),o=$d(),i=ie(),c=Zt(),u=Nn(),l=he(),d=Cn();function m(R){if(w(R)&&(S(R),b(R))){h(R);return}_(R,()=>(0,t.topBoolOrEmptySchema)(R))}xt.validateFunctionCode=m;function _({gen:R,validateName:x,schema:M,schemaEnv:U,opts:re},ue){re.code.es5?R.func(x,(0,i._)`${c.default.data}, ${c.default.valCxt}`,U.$async,()=>{R.code((0,i._)`"use strict"; ${f(M,re)}`),y(R,re),R.code(ue)}):R.func(x,(0,i._)`${c.default.data}, ${p(re)}`,U.$async,()=>R.code(f(M,re)).code(ue))}function p(R){return(0,i._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${R.dynamicRef?(0,i._)`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}function y(R,x){R.if(c.default.valCxt,()=>{R.var(c.default.instancePath,(0,i._)`${c.default.valCxt}.${c.default.instancePath}`),R.var(c.default.parentData,(0,i._)`${c.default.valCxt}.${c.default.parentData}`),R.var(c.default.parentDataProperty,(0,i._)`${c.default.valCxt}.${c.default.parentDataProperty}`),R.var(c.default.rootData,(0,i._)`${c.default.valCxt}.${c.default.rootData}`),x.dynamicRef&&R.var(c.default.dynamicAnchors,(0,i._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{R.var(c.default.instancePath,(0,i._)`""`),R.var(c.default.parentData,(0,i._)`undefined`),R.var(c.default.parentDataProperty,(0,i._)`undefined`),R.var(c.default.rootData,c.default.data),x.dynamicRef&&R.var(c.default.dynamicAnchors,(0,i._)`{}`)})}function h(R){const{schema:x,opts:M,gen:U}=R;_(R,()=>{M.$comment&&x.$comment&&J(R),D(R),U.let(c.default.vErrors,null),U.let(c.default.errors,0),M.unevaluated&&v(R),C(R),Y(R)})}function v(R){const{gen:x,validateName:M}=R;R.evaluated=x.const("evaluated",(0,i._)`${M}.evaluated`),x.if((0,i._)`${R.evaluated}.dynamicProps`,()=>x.assign((0,i._)`${R.evaluated}.props`,(0,i._)`undefined`)),x.if((0,i._)`${R.evaluated}.dynamicItems`,()=>x.assign((0,i._)`${R.evaluated}.items`,(0,i._)`undefined`))}function f(R,x){const M=typeof R=="object"&&R[x.schemaId];return M&&(x.code.source||x.code.process)?(0,i._)`/*# sourceURL=${M} */`:i.nil}function g(R,x){if(w(R)&&(S(R),b(R))){k(R,x);return}(0,t.boolOrEmptySchema)(R,x)}function b({schema:R,self:x}){if(typeof R=="boolean")return!R;for(const M in R)if(x.RULES.all[M])return!0;return!1}function w(R){return typeof R.schema!="boolean"}function k(R,x){const{schema:M,gen:U,opts:re}=R;re.$comment&&M.$comment&&J(R),A(R),V(R);const ue=U.const("_errs",c.default.errors);C(R,ue),U.var(x,(0,i._)`${ue} === ${c.default.errors}`)}function S(R){(0,l.checkUnknownRules)(R),j(R)}function C(R,x){if(R.opts.jtd)return Ge(R,[],!1,x);const M=(0,e.getSchemaTypes)(R.schema),U=(0,e.coerceAndCheckDataType)(R,M);Ge(R,M,!U,x)}function j(R){const{schema:x,errSchemaPath:M,opts:U,self:re}=R;x.$ref&&U.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(x,re.RULES)&&re.logger.warn(`$ref: keywords ignored in schema at path "${M}"`)}function D(R){const{schema:x,opts:M}=R;x.default!==void 0&&M.useDefaults&&M.strictSchema&&(0,l.checkStrictMode)(R,"default is ignored in the schema root")}function A(R){const x=R.schema[R.opts.schemaId];x&&(R.baseId=(0,u.resolveUrl)(R.opts.uriResolver,R.baseId,x))}function V(R){if(R.schema.$async&&!R.schemaEnv.$async)throw new Error("async schema in sync schema")}function J({gen:R,schemaEnv:x,schema:M,errSchemaPath:U,opts:re}){const ue=M.$comment;if(re.$comment===!0)R.code((0,i._)`${c.default.self}.logger.log(${ue})`);else if(typeof re.$comment=="function"){const Fe=(0,i.str)`${U}/$comment`,Et=R.scopeValue("root",{ref:x.root});R.code((0,i._)`${c.default.self}.opts.$comment(${ue}, ${Fe}, ${Et}.schema)`)}}function Y(R){const{gen:x,schemaEnv:M,validateName:U,ValidationError:re,opts:ue}=R;M.$async?x.if((0,i._)`${c.default.errors} === 0`,()=>x.return(c.default.data),()=>x.throw((0,i._)`new ${re}(${c.default.vErrors})`)):(x.assign((0,i._)`${U}.errors`,c.default.vErrors),ue.unevaluated&&ge(R),x.return((0,i._)`${c.default.errors} === 0`))}function ge({gen:R,evaluated:x,props:M,items:U}){M instanceof i.Name&&R.assign((0,i._)`${x}.props`,M),U instanceof i.Name&&R.assign((0,i._)`${x}.items`,U)}function Ge(R,x,M,U){const{gen:re,schema:ue,data:Fe,allErrors:Et,opts:tt,self:rt}=R,{RULES:He}=rt;if(ue.$ref&&(tt.ignoreKeywordsWithRef||!(0,l.schemaHasRulesButRef)(ue,He))){re.block(()=>ee(R,"$ref",He.all.$ref.definition));return}tt.jtd||be(R,x),re.block(()=>{for(const dt of He.rules)jr(dt);jr(He.post)});function jr(dt){(0,r.shouldUseGroup)(ue,dt)&&(dt.type?(re.if((0,n.checkDataType)(dt.type,Fe,tt.strictNumbers)),Ye(R,dt),x.length===1&&x[0]===dt.type&&M&&(re.else(),(0,n.reportTypeError)(R)),re.endIf()):Ye(R,dt),Et||re.if((0,i._)`${c.default.errors} === ${U||0}`))}}function Ye(R,x){const{gen:M,schema:U,opts:{useDefaults:re}}=R;re&&(0,s.assignDefaults)(R,x.type),M.block(()=>{for(const ue of x.rules)(0,r.shouldUseRule)(U,ue)&&ee(R,ue.keyword,ue.definition,x.type)})}function be(R,x){R.schemaEnv.meta||!R.opts.strictTypes||(Tt(R,x),R.opts.allowUnionTypes||L(R,x),P(R,R.dataTypes))}function Tt(R,x){if(x.length){if(!R.dataTypes.length){R.dataTypes=x;return}x.forEach(M=>{I(R.dataTypes,M)||E(R,`type "${M}" not allowed by context "${R.dataTypes.join(",")}"`)}),$(R,x)}}function L(R,x){x.length>1&&!(x.length===2&&x.includes("null"))&&E(R,"use allowUnionTypes to allow union type keyword")}function P(R,x){const M=R.self.RULES.all;for(const U in M){const re=M[U];if(typeof re=="object"&&(0,r.shouldUseRule)(R.schema,re)){const{type:ue}=re.definition;ue.length&&!ue.some(Fe=>z(x,Fe))&&E(R,`missing type "${ue.join(",")}" for keyword "${U}"`)}}}function z(R,x){return R.includes(x)||x==="number"&&R.includes("integer")}function I(R,x){return R.includes(x)||x==="integer"&&R.includes("number")}function $(R,x){const M=[];for(const U of R.dataTypes)I(x,U)?M.push(U):x.includes("integer")&&U==="number"&&M.push("integer");R.dataTypes=M}function E(R,x){const M=R.schemaEnv.baseId+R.errSchemaPath;x+=` at "${M}" (strictTypes)`,(0,l.checkStrictMode)(R,x,R.opts.strictTypes)}class N{constructor(x,M,U){if((0,a.validateKeywordUsage)(x,M,U),this.gen=x.gen,this.allErrors=x.allErrors,this.keyword=U,this.data=x.data,this.schema=x.schema[U],this.$data=M.$data&&x.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(x,this.schema,U,this.$data),this.schemaType=M.schemaType,this.parentSchema=x.schema,this.params={},this.it=x,this.def=M,this.$data)this.schemaCode=x.gen.const("vSchema",fe(this.$data,x));else if(this.schemaCode=this.schemaValue,!(0,a.validSchemaType)(this.schema,M.schemaType,M.allowUndefined))throw new Error(`${U} value must be ${JSON.stringify(M.schemaType)}`);("code"in M?M.trackErrors:M.errors!==!1)&&(this.errsCount=x.gen.const("_errs",c.default.errors))}result(x,M,U){this.failResult((0,i.not)(x),M,U)}failResult(x,M,U){this.gen.if(x),U?U():this.error(),M?(this.gen.else(),M(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(x,M){this.failResult((0,i.not)(x),void 0,M)}fail(x){if(x===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(x),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(x){if(!this.$data)return this.fail(x);const{schemaCode:M}=this;this.fail((0,i._)`${M} !== undefined && (${(0,i.or)(this.invalid$data(),x)})`)}error(x,M,U){if(M){this.setParams(M),this._error(x,U),this.setParams({});return}this._error(x,U)}_error(x,M){(x?d.reportExtraError:d.reportError)(this,this.def.error,M)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(x){this.allErrors||this.gen.if(x)}setParams(x,M){M?Object.assign(this.params,x):this.params=x}block$data(x,M,U=i.nil){this.gen.block(()=>{this.check$data(x,U),M()})}check$data(x=i.nil,M=i.nil){if(!this.$data)return;const{gen:U,schemaCode:re,schemaType:ue,def:Fe}=this;U.if((0,i.or)((0,i._)`${re} === undefined`,M)),x!==i.nil&&U.assign(x,!0),(ue.length||Fe.validateSchema)&&(U.elseIf(this.invalid$data()),this.$dataError(),x!==i.nil&&U.assign(x,!1)),U.else()}invalid$data(){const{gen:x,schemaCode:M,schemaType:U,def:re,it:ue}=this;return(0,i.or)(Fe(),Et());function Fe(){if(U.length){if(!(M instanceof i.Name))throw new Error("ajv implementation error");const tt=Array.isArray(U)?U:[U];return(0,i._)`${(0,n.checkDataTypes)(tt,M,ue.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}function Et(){if(re.validateSchema){const tt=x.scopeValue("validate$data",{ref:re.validateSchema});return(0,i._)`!${tt}(${M})`}return i.nil}}subschema(x,M){const U=(0,o.getSubschema)(this.it,x);(0,o.extendSubschemaData)(U,this.it,x),(0,o.extendSubschemaMode)(U,x);const re={...this.it,...U,items:void 0,props:void 0};return g(re,M),re}mergeEvaluated(x,M){const{it:U,gen:re}=this;U.opts.unevaluated&&(U.props!==!0&&x.props!==void 0&&(U.props=l.mergeEvaluated.props(re,x.props,U.props,M)),U.items!==!0&&x.items!==void 0&&(U.items=l.mergeEvaluated.items(re,x.items,U.items,M)))}mergeValidEvaluated(x,M){const{it:U,gen:re}=this;if(U.opts.unevaluated&&(U.props!==!0||U.items!==!0))return re.if(M,()=>this.mergeEvaluated(x,i.Name)),!0}}xt.KeywordCxt=N;function ee(R,x,M,U){const re=new N(R,M,x);"code"in M?M.code(re,U):re.$data&&M.validate?(0,a.funcKeywordCode)(re,M):"macro"in M?(0,a.macroKeywordCode)(re,M):(M.compile||M.validate)&&(0,a.funcKeywordCode)(re,M)}const ne=/^\/(?:[^~]|~0|~1)*$/,me=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function fe(R,{dataLevel:x,dataNames:M,dataPathArr:U}){let re,ue;if(R==="")return c.default.rootData;if(R[0]==="/"){if(!ne.test(R))throw new Error(`Invalid JSON-pointer: ${R}`);re=R,ue=c.default.rootData}else{const rt=me.exec(R);if(!rt)throw new Error(`Invalid JSON-pointer: ${R}`);const He=+rt[1];if(re=rt[2],re==="#"){if(He>=x)throw new Error(tt("property/index",He));return U[x-He]}if(He>x)throw new Error(tt("data",He));if(ue=M[x-He],!re)return ue}let Fe=ue;const Et=re.split("/");for(const rt of Et)rt&&(ue=(0,i._)`${ue}${(0,i.getProperty)((0,l.unescapeJsonPointer)(rt))}`,Fe=(0,i._)`${Fe} && ${ue}`);return Fe;function tt(rt,He){return`Cannot access ${rt} ${He} levels up, current level is ${x}`}}return xt.getData=fe,xt}var jn={},Mi;function ya(){if(Mi)return jn;Mi=1,Object.defineProperty(jn,"__esModule",{value:!0});class t extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return jn.default=t,jn}var Mn={},zi;function zn(){if(zi)return Mn;zi=1,Object.defineProperty(Mn,"__esModule",{value:!0});const t=Nn();class e extends Error{constructor(n,s,a,o){super(o||`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 Mn.default=e,Mn}var nt={},qi;function va(){if(qi)return nt;qi=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.resolveSchema=nt.getCompilingSchema=nt.resolveRef=nt.compileSchema=nt.SchemaEnv=void 0;const t=ie(),e=ya(),r=Zt(),n=Nn(),s=he(),a=An();class o{constructor(v){var f;this.refs={},this.dynamicAnchors={};let g;typeof v.schema=="object"&&(g=v.schema),this.schema=v.schema,this.schemaId=v.schemaId,this.root=v.root||this,this.baseId=(f=v.baseId)!==null&&f!==void 0?f:(0,n.normalizeId)(g?.[v.schemaId||"$id"]),this.schemaPath=v.schemaPath,this.localRefs=v.localRefs,this.meta=v.meta,this.$async=g?.$async,this.refs={}}}nt.SchemaEnv=o;function i(h){const v=l.call(this,h);if(v)return v;const f=(0,n.getFullPath)(this.opts.uriResolver,h.root.baseId),{es5:g,lines:b}=this.opts.code,{ownProperties:w}=this.opts,k=new t.CodeGen(this.scope,{es5:g,lines:b,ownProperties:w});let S;h.$async&&(S=k.scopeValue("Error",{ref:e.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));const C=k.scopeName("validate");h.validateName=C;const j={gen:k,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:k.scopeValue("schema",this.opts.code.source===!0?{ref:h.schema,code:(0,t.stringify)(h.schema)}:{ref:h.schema}),validateName:C,ValidationError:S,schema:h.schema,schemaEnv:h,rootId:f,baseId:h.baseId||f,schemaPath:t.nil,errSchemaPath:h.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this};let D;try{this._compilations.add(h),(0,a.validateFunctionCode)(j),k.optimize(this.opts.code.optimize);const A=k.toString();D=`${k.scopeRefs(r.default.scope)}return ${A}`,this.opts.code.process&&(D=this.opts.code.process(D,h));const J=new Function(`${r.default.self}`,`${r.default.scope}`,D)(this,this.scope.get());if(this.scope.value(C,{ref:J}),J.errors=null,J.schema=h.schema,J.schemaEnv=h,h.$async&&(J.$async=!0),this.opts.code.source===!0&&(J.source={validateName:C,validateCode:A,scopeValues:k._values}),this.opts.unevaluated){const{props:Y,items:ge}=j;J.evaluated={props:Y instanceof t.Name?void 0:Y,items:ge instanceof t.Name?void 0:ge,dynamicProps:Y instanceof t.Name,dynamicItems:ge instanceof t.Name},J.source&&(J.source.evaluated=(0,t.stringify)(J.evaluated))}return h.validate=J,h}catch(A){throw delete h.validate,delete h.validateName,D&&this.logger.error("Error compiling schema, function code:",D),A}finally{this._compilations.delete(h)}}nt.compileSchema=i;function c(h,v,f){var g;f=(0,n.resolveUrl)(this.opts.uriResolver,v,f);const b=h.refs[f];if(b)return b;let w=m.call(this,h,f);if(w===void 0){const k=(g=h.localRefs)===null||g===void 0?void 0:g[f],{schemaId:S}=this.opts;k&&(w=new o({schema:k,schemaId:S,root:h,baseId:v}))}if(w!==void 0)return h.refs[f]=u.call(this,w)}nt.resolveRef=c;function u(h){return(0,n.inlineRef)(h.schema,this.opts.inlineRefs)?h.schema:h.validate?h:i.call(this,h)}function l(h){for(const v of this._compilations)if(d(v,h))return v}nt.getCompilingSchema=l;function d(h,v){return h.schema===v.schema&&h.root===v.root&&h.baseId===v.baseId}function m(h,v){let f;for(;typeof(f=this.refs[v])=="string";)v=f;return f||this.schemas[v]||_.call(this,h,v)}function _(h,v){const f=this.opts.uriResolver.parse(v),g=(0,n._getFullPath)(this.opts.uriResolver,f);let b=(0,n.getFullPath)(this.opts.uriResolver,h.baseId,void 0);if(Object.keys(h.schema).length>0&&g===b)return y.call(this,f,h);const w=(0,n.normalizeId)(g),k=this.refs[w]||this.schemas[w];if(typeof k=="string"){const S=_.call(this,h,k);return typeof S?.schema!="object"?void 0:y.call(this,f,S)}if(typeof k?.schema=="object"){if(k.validate||i.call(this,k),w===(0,n.normalizeId)(v)){const{schema:S}=k,{schemaId:C}=this.opts,j=S[C];return j&&(b=(0,n.resolveUrl)(this.opts.uriResolver,b,j)),new o({schema:S,schemaId:C,root:h,baseId:b})}return y.call(this,f,k)}}nt.resolveSchema=_;const p=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function y(h,{baseId:v,schema:f,root:g}){var b;if(((b=h.fragment)===null||b===void 0?void 0:b[0])!=="/")return;for(const S of h.fragment.slice(1).split("/")){if(typeof f=="boolean")return;const C=f[(0,s.unescapeFragment)(S)];if(C===void 0)return;f=C;const j=typeof f=="object"&&f[this.opts.schemaId];!p.has(S)&&j&&(v=(0,n.resolveUrl)(this.opts.uriResolver,v,j))}let w;if(typeof f!="boolean"&&f.$ref&&!(0,s.schemaHasRulesButRef)(f,this.RULES)){const S=(0,n.resolveUrl)(this.opts.uriResolver,v,f.$ref);w=_.call(this,g,S)}const{schemaId:k}=this.opts;if(w=w||new o({schema:f,schemaId:k,root:g,baseId:v}),w.schema!==w.root.schema)return w}return nt}const Td={$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 qn={},zr={exports:{}},wa,Zi;function Li(){if(Zi)return wa;Zi=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);function r(m){let _="",p=0,y=0;for(y=0;y<m.length;y++)if(p=m[y].charCodeAt(0),p!==48){if(!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102))return"";_+=m[y];break}for(y+=1;y<m.length;y++){if(p=m[y].charCodeAt(0),!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102))return"";_+=m[y]}return _}const n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function s(m){return m.length=0,!0}function a(m,_,p){if(m.length){const y=r(m);if(y!=="")_.push(y);else return p.error=!0,!1;m.length=0}return!0}function o(m){let _=0;const p={error:!1,address:"",zone:""},y=[],h=[];let v=!1,f=!1,g=a;for(let b=0;b<m.length;b++){const w=m[b];if(!(w==="["||w==="]"))if(w===":"){if(v===!0&&(f=!0),!g(h,y,p))break;if(++_>7){p.error=!0;break}b>0&&m[b-1]===":"&&(v=!0),y.push(":");continue}else if(w==="%"){if(!g(h,y,p))break;g=s}else{h.push(w);continue}}return h.length&&(g===s?p.zone=h.join(""):f?y.push(h.join("")):y.push(r(h))),p.address=y.join(""),p}function i(m){if(c(m,":")<2)return{host:m,isIPV6:!1};const _=o(m);if(_.error)return{host:m,isIPV6:!1};{let p=_.address,y=_.address;return _.zone&&(p+="%"+_.zone,y+="%25"+_.zone),{host:p,isIPV6:!0,escapedHost:y}}}function c(m,_){let p=0;for(let y=0;y<m.length;y++)m[y]===_&&p++;return p}function u(m){let _=m;const p=[];let y=-1,h=0;for(;h=_.length;){if(h===1){if(_===".")break;if(_==="/"){p.push("/");break}else{p.push(_);break}}else if(h===2){if(_[0]==="."){if(_[1]===".")break;if(_[1]==="/"){_=_.slice(2);continue}}else if(_[0]==="/"&&(_[1]==="."||_[1]==="/")){p.push("/");break}}else if(h===3&&_==="/.."){p.length!==0&&p.pop(),p.push("/");break}if(_[0]==="."){if(_[1]==="."){if(_[2]==="/"){_=_.slice(3);continue}}else if(_[1]==="/"){_=_.slice(2);continue}}else if(_[0]==="/"&&_[1]==="."){if(_[2]==="/"){_=_.slice(2);continue}else if(_[2]==="."&&_[3]==="/"){_=_.slice(3),p.length!==0&&p.pop();continue}}if((y=_.indexOf("/",1))===-1){p.push(_);break}else p.push(_.slice(0,y)),_=_.slice(y)}return p.join("")}function l(m,_){const p=_!==!0?escape:unescape;return m.scheme!==void 0&&(m.scheme=p(m.scheme)),m.userinfo!==void 0&&(m.userinfo=p(m.userinfo)),m.host!==void 0&&(m.host=p(m.host)),m.path!==void 0&&(m.path=p(m.path)),m.query!==void 0&&(m.query=p(m.query)),m.fragment!==void 0&&(m.fragment=p(m.fragment)),m}function d(m){const _=[];if(m.userinfo!==void 0&&(_.push(m.userinfo),_.push("@")),m.host!==void 0){let p=unescape(m.host);if(!e(p)){const y=i(p);y.isIPV6===!0?p=`[${y.escapedHost}]`:p=m.host}_.push(p)}return(typeof m.port=="number"||typeof m.port=="string")&&(_.push(":"),_.push(String(m.port))),_.length?_.join(""):void 0}return wa={nonSimpleDomain:n,recomposeAuthority:d,normalizeComponentEncoding:l,removeDotSegments:u,isIPv4:e,isUUID:t,normalizeIPv6:i,stringArrayToHexStripped:r},wa}var ba,Ui;function Ed(){if(Ui)return ba;Ui=1;const{isUUID:t}=Li(),e=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(w){return r.indexOf(w)!==-1}function s(w){return w.secure===!0?!0:w.secure===!1?!1:w.scheme?w.scheme.length===3&&(w.scheme[0]==="w"||w.scheme[0]==="W")&&(w.scheme[1]==="s"||w.scheme[1]==="S")&&(w.scheme[2]==="s"||w.scheme[2]==="S"):!1}function a(w){return w.host||(w.error=w.error||"HTTP URIs must have a host."),w}function o(w){const k=String(w.scheme).toLowerCase()==="https";return(w.port===(k?443:80)||w.port==="")&&(w.port=void 0),w.path||(w.path="/"),w}function i(w){return w.secure=s(w),w.resourceName=(w.path||"/")+(w.query?"?"+w.query:""),w.path=void 0,w.query=void 0,w}function c(w){if((w.port===(s(w)?443:80)||w.port==="")&&(w.port=void 0),typeof w.secure=="boolean"&&(w.scheme=w.secure?"wss":"ws",w.secure=void 0),w.resourceName){const[k,S]=w.resourceName.split("?");w.path=k&&k!=="/"?k:void 0,w.query=S,w.resourceName=void 0}return w.fragment=void 0,w}function u(w,k){if(!w.path)return w.error="URN can not be parsed",w;const S=w.path.match(e);if(S){const C=k.scheme||w.scheme||"urn";w.nid=S[1].toLowerCase(),w.nss=S[2];const j=`${C}:${k.nid||w.nid}`,D=b(j);w.path=void 0,D&&(w=D.parse(w,k))}else w.error=w.error||"URN can not be parsed.";return w}function l(w,k){if(w.nid===void 0)throw new Error("URN without nid cannot be serialized");const S=k.scheme||w.scheme||"urn",C=w.nid.toLowerCase(),j=`${S}:${k.nid||C}`,D=b(j);D&&(w=D.serialize(w,k));const A=w,V=w.nss;return A.path=`${C||k.nid}:${V}`,k.skipEscape=!0,A}function d(w,k){const S=w;return S.uuid=S.nss,S.nss=void 0,!k.tolerant&&(!S.uuid||!t(S.uuid))&&(S.error=S.error||"UUID is not valid."),S}function m(w){const k=w;return k.nss=(w.uuid||"").toLowerCase(),k}const _={scheme:"http",domainHost:!0,parse:a,serialize:o},p={scheme:"https",domainHost:_.domainHost,parse:a,serialize:o},y={scheme:"ws",domainHost:!0,parse:i,serialize:c},h={scheme:"wss",domainHost:y.domainHost,parse:y.parse,serialize:y.serialize},g={http:_,https:p,ws:y,wss:h,urn:{scheme:"urn",parse:u,serialize:l,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:d,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(g,null);function b(w){return w&&(g[w]||g[w.toLowerCase()])||void 0}return ba={wsIsSecure:s,SCHEMES:g,isValidSchemeName:n,getSchemeHandler:b},ba}var Di;function Rd(){if(Di)return zr.exports;Di=1;const{normalizeIPv6:t,removeDotSegments:e,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:a}=Li(),{SCHEMES:o,getSchemeHandler:i}=Ed();function c(h,v){return typeof h=="string"?h=m(p(h,v),v):typeof h=="object"&&(h=p(m(h,v),v)),h}function u(h,v,f){const g=f?Object.assign({scheme:"null"},f):{scheme:"null"},b=l(p(h,g),p(v,g),g,!0);return g.skipEscape=!0,m(b,g)}function l(h,v,f,g){const b={};return g||(h=p(m(h,f),f),v=p(m(v,f),f)),f=f||{},!f.tolerant&&v.scheme?(b.scheme=v.scheme,b.userinfo=v.userinfo,b.host=v.host,b.port=v.port,b.path=e(v.path||""),b.query=v.query):(v.userinfo!==void 0||v.host!==void 0||v.port!==void 0?(b.userinfo=v.userinfo,b.host=v.host,b.port=v.port,b.path=e(v.path||""),b.query=v.query):(v.path?(v.path[0]==="/"?b.path=e(v.path):((h.userinfo!==void 0||h.host!==void 0||h.port!==void 0)&&!h.path?b.path="/"+v.path:h.path?b.path=h.path.slice(0,h.path.lastIndexOf("/")+1)+v.path:b.path=v.path,b.path=e(b.path)),b.query=v.query):(b.path=h.path,v.query!==void 0?b.query=v.query:b.query=h.query),b.userinfo=h.userinfo,b.host=h.host,b.port=h.port),b.scheme=h.scheme),b.fragment=v.fragment,b}function d(h,v,f){return typeof h=="string"?(h=unescape(h),h=m(n(p(h,f),!0),{...f,skipEscape:!0})):typeof h=="object"&&(h=m(n(h,!0),{...f,skipEscape:!0})),typeof v=="string"?(v=unescape(v),v=m(n(p(v,f),!0),{...f,skipEscape:!0})):typeof v=="object"&&(v=m(n(v,!0),{...f,skipEscape:!0})),h.toLowerCase()===v.toLowerCase()}function m(h,v){const f={host:h.host,scheme:h.scheme,userinfo:h.userinfo,port:h.port,path:h.path,query:h.query,nid:h.nid,nss:h.nss,uuid:h.uuid,fragment:h.fragment,reference:h.reference,resourceName:h.resourceName,secure:h.secure,error:""},g=Object.assign({},v),b=[],w=i(g.scheme||f.scheme);w&&w.serialize&&w.serialize(f,g),f.path!==void 0&&(g.skipEscape?f.path=unescape(f.path):(f.path=escape(f.path),f.scheme!==void 0&&(f.path=f.path.split("%3A").join(":")))),g.reference!=="suffix"&&f.scheme&&b.push(f.scheme,":");const k=r(f);if(k!==void 0&&(g.reference!=="suffix"&&b.push("//"),b.push(k),f.path&&f.path[0]!=="/"&&b.push("/")),f.path!==void 0){let S=f.path;!g.absolutePath&&(!w||!w.absolutePath)&&(S=e(S)),k===void 0&&S[0]==="/"&&S[1]==="/"&&(S="/%2F"+S.slice(2)),b.push(S)}return f.query!==void 0&&b.push("?",f.query),f.fragment!==void 0&&b.push("#",f.fragment),b.join("")}const _=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(h,v){const f=Object.assign({},v),g={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let b=!1;f.reference==="suffix"&&(f.scheme?h=f.scheme+":"+h:h="//"+h);const w=h.match(_);if(w){if(g.scheme=w[1],g.userinfo=w[3],g.host=w[4],g.port=parseInt(w[5],10),g.path=w[6]||"",g.query=w[7],g.fragment=w[8],isNaN(g.port)&&(g.port=w[5]),g.host)if(s(g.host)===!1){const C=t(g.host);g.host=C.host.toLowerCase(),b=C.isIPV6}else b=!0;g.scheme===void 0&&g.userinfo===void 0&&g.host===void 0&&g.port===void 0&&g.query===void 0&&!g.path?g.reference="same-document":g.scheme===void 0?g.reference="relative":g.fragment===void 0?g.reference="absolute":g.reference="uri",f.reference&&f.reference!=="suffix"&&f.reference!==g.reference&&(g.error=g.error||"URI is not a "+f.reference+" reference.");const k=i(f.scheme||g.scheme);if(!f.unicodeSupport&&(!k||!k.unicodeSupport)&&g.host&&(f.domainHost||k&&k.domainHost)&&b===!1&&a(g.host))try{g.host=URL.domainToASCII(g.host.toLowerCase())}catch(S){g.error=g.error||"Host's domain name can not be converted to ASCII: "+S}(!k||k&&!k.skipNormalize)&&(h.indexOf("%")!==-1&&(g.scheme!==void 0&&(g.scheme=unescape(g.scheme)),g.host!==void 0&&(g.host=unescape(g.host))),g.path&&(g.path=escape(unescape(g.path))),g.fragment&&(g.fragment=encodeURI(decodeURIComponent(g.fragment)))),k&&k.parse&&k.parse(g,f)}else g.error=g.error||"URI can not be parsed.";return g}const y={SCHEMES:o,normalize:c,resolve:u,resolveComponent:l,equal:d,serialize:m,parse:p};return zr.exports=y,zr.exports.default=y,zr.exports.fastUri=y,zr.exports}var Vi;function Pd(){if(Vi)return qn;Vi=1,Object.defineProperty(qn,"__esModule",{value:!0});const t=Rd();return t.code='require("ajv/dist/runtime/uri").default',qn.default=t,qn}var Fi;function xd(){return Fi||(Fi=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=An();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=ya(),s=zn(),a=$i(),o=va(),i=ie(),c=Nn(),u=On(),l=he(),d=Td,m=Pd(),_=(L,P)=>new RegExp(L,P);_.code="new RegExp";const p=["removeAdditional","useDefaults","coerceTypes"],y=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),h={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."},v={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},f=200;function g(L){var P,z,I,$,E,N,ee,ne,me,fe,R,x,M,U,re,ue,Fe,Et,tt,rt,He,jr,dt,di,fi;const Rn=L.strict,hi=(P=L.code)===null||P===void 0?void 0:P.optimize,yd=hi===!0||hi===void 0?1:hi||0,vd=(I=(z=L.code)===null||z===void 0?void 0:z.regExp)!==null&&I!==void 0?I:_,fw=($=L.uriResolver)!==null&&$!==void 0?$:m.default;return{strictSchema:(N=(E=L.strictSchema)!==null&&E!==void 0?E:Rn)!==null&&N!==void 0?N:!0,strictNumbers:(ne=(ee=L.strictNumbers)!==null&&ee!==void 0?ee:Rn)!==null&&ne!==void 0?ne:!0,strictTypes:(fe=(me=L.strictTypes)!==null&&me!==void 0?me:Rn)!==null&&fe!==void 0?fe:"log",strictTuples:(x=(R=L.strictTuples)!==null&&R!==void 0?R:Rn)!==null&&x!==void 0?x:"log",strictRequired:(U=(M=L.strictRequired)!==null&&M!==void 0?M:Rn)!==null&&U!==void 0?U:!1,code:L.code?{...L.code,optimize:yd,regExp:vd}:{optimize:yd,regExp:vd},loopRequired:(re=L.loopRequired)!==null&&re!==void 0?re:f,loopEnum:(ue=L.loopEnum)!==null&&ue!==void 0?ue:f,meta:(Fe=L.meta)!==null&&Fe!==void 0?Fe:!0,messages:(Et=L.messages)!==null&&Et!==void 0?Et:!0,inlineRefs:(tt=L.inlineRefs)!==null&&tt!==void 0?tt:!0,schemaId:(rt=L.schemaId)!==null&&rt!==void 0?rt:"$id",addUsedSchema:(He=L.addUsedSchema)!==null&&He!==void 0?He:!0,validateSchema:(jr=L.validateSchema)!==null&&jr!==void 0?jr:!0,validateFormats:(dt=L.validateFormats)!==null&&dt!==void 0?dt:!0,unicodeRegExp:(di=L.unicodeRegExp)!==null&&di!==void 0?di:!0,int32range:(fi=L.int32range)!==null&&fi!==void 0?fi:!0,uriResolver:fw}}class b{constructor(P={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,P=this.opts={...P,...g(P)};const{es5:z,lines:I}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:y,es5:z,lines:I}),this.logger=V(P.logger);const $=P.validateFormats;P.validateFormats=!1,this.RULES=(0,a.getRules)(),w.call(this,h,P,"NOT SUPPORTED"),w.call(this,v,P,"DEPRECATED","warn"),this._metaOpts=D.call(this),P.formats&&C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),P.keywords&&j.call(this,P.keywords),typeof P.meta=="object"&&this.addMetaSchema(P.meta),S.call(this),P.validateFormats=$}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:P,meta:z,schemaId:I}=this.opts;let $=d;I==="id"&&($={...d},$.id=$.$id,delete $.$id),z&&P&&this.addMetaSchema($,$[I],!1)}defaultMeta(){const{meta:P,schemaId:z}=this.opts;return this.opts.defaultMeta=typeof P=="object"?P[z]||P:void 0}validate(P,z){let I;if(typeof P=="string"){if(I=this.getSchema(P),!I)throw new Error(`no schema with key or ref "${P}"`)}else I=this.compile(P);const $=I(z);return"$async"in I||(this.errors=I.errors),$}compile(P,z){const I=this._addSchema(P,z);return I.validate||this._compileSchemaEnv(I)}compileAsync(P,z){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:I}=this.opts;return $.call(this,P,z);async function $(fe,R){await E.call(this,fe.$schema);const x=this._addSchema(fe,R);return x.validate||N.call(this,x)}async function E(fe){fe&&!this.getSchema(fe)&&await $.call(this,{$ref:fe},!0)}async function N(fe){try{return this._compileSchemaEnv(fe)}catch(R){if(!(R instanceof s.default))throw R;return ee.call(this,R),await ne.call(this,R.missingSchema),N.call(this,fe)}}function ee({missingSchema:fe,missingRef:R}){if(this.refs[fe])throw new Error(`AnySchema ${fe} is loaded but ${R} cannot be resolved`)}async function ne(fe){const R=await me.call(this,fe);this.refs[fe]||await E.call(this,R.$schema),this.refs[fe]||this.addSchema(R,fe,z)}async function me(fe){const R=this._loading[fe];if(R)return R;try{return await(this._loading[fe]=I(fe))}finally{delete this._loading[fe]}}}addSchema(P,z,I,$=this.opts.validateSchema){if(Array.isArray(P)){for(const N of P)this.addSchema(N,void 0,I,$);return this}let E;if(typeof P=="object"){const{schemaId:N}=this.opts;if(E=P[N],E!==void 0&&typeof E!="string")throw new Error(`schema ${N} must be string`)}return z=(0,c.normalizeId)(z||E),this._checkUnique(z),this.schemas[z]=this._addSchema(P,I,z,$,!0),this}addMetaSchema(P,z,I=this.opts.validateSchema){return this.addSchema(P,z,!0,I),this}validateSchema(P,z){if(typeof P=="boolean")return!0;let I;if(I=P.$schema,I!==void 0&&typeof I!="string")throw new Error("$schema must be a string");if(I=I||this.opts.defaultMeta||this.defaultMeta(),!I)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const $=this.validate(I,P);if(!$&&z){const E="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(E);else throw new Error(E)}return $}getSchema(P){let z;for(;typeof(z=k.call(this,P))=="string";)P=z;if(z===void 0){const{schemaId:I}=this.opts,$=new o.SchemaEnv({schema:{},schemaId:I});if(z=o.resolveSchema.call(this,$,P),!z)return;this.refs[P]=z}return z.validate||this._compileSchemaEnv(z)}removeSchema(P){if(P instanceof RegExp)return this._removeAllSchemas(this.schemas,P),this._removeAllSchemas(this.refs,P),this;switch(typeof P){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const z=k.call(this,P);return typeof z=="object"&&this._cache.delete(z.schema),delete this.schemas[P],delete this.refs[P],this}case"object":{const z=P;this._cache.delete(z);let I=P[this.opts.schemaId];return I&&(I=(0,c.normalizeId)(I),delete this.schemas[I],delete this.refs[I]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(P){for(const z of P)this.addKeyword(z);return this}addKeyword(P,z){let I;if(typeof P=="string")I=P,typeof z=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),z.keyword=I);else if(typeof P=="object"&&z===void 0){if(z=P,I=z.keyword,Array.isArray(I)&&!I.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Y.call(this,I,z),!z)return(0,l.eachItem)(I,E=>ge.call(this,E)),this;Ye.call(this,z);const $={...z,type:(0,u.getJSONTypes)(z.type),schemaType:(0,u.getJSONTypes)(z.schemaType)};return(0,l.eachItem)(I,$.type.length===0?E=>ge.call(this,E,$):E=>$.type.forEach(N=>ge.call(this,E,$,N))),this}getKeyword(P){const z=this.RULES.all[P];return typeof z=="object"?z.definition:!!z}removeKeyword(P){const{RULES:z}=this;delete z.keywords[P],delete z.all[P];for(const I of z.rules){const $=I.rules.findIndex(E=>E.keyword===P);$>=0&&I.rules.splice($,1)}return this}addFormat(P,z){return typeof z=="string"&&(z=new RegExp(z)),this.formats[P]=z,this}errorsText(P=this.errors,{separator:z=", ",dataVar:I="data"}={}){return!P||P.length===0?"No errors":P.map($=>`${I}${$.instancePath} ${$.message}`).reduce(($,E)=>$+z+E)}$dataMetaSchema(P,z){const I=this.RULES.all;P=JSON.parse(JSON.stringify(P));for(const $ of z){const E=$.split("/").slice(1);let N=P;for(const ee of E)N=N[ee];for(const ee in I){const ne=I[ee];if(typeof ne!="object")continue;const{$data:me}=ne.definition,fe=N[ee];me&&fe&&(N[ee]=Tt(fe))}}return P}_removeAllSchemas(P,z){for(const I in P){const $=P[I];(!z||z.test(I))&&(typeof $=="string"?delete P[I]:$&&!$.meta&&(this._cache.delete($.schema),delete P[I]))}}_addSchema(P,z,I,$=this.opts.validateSchema,E=this.opts.addUsedSchema){let N;const{schemaId:ee}=this.opts;if(typeof P=="object")N=P[ee];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof P!="boolean")throw new Error("schema must be object or boolean")}let ne=this._cache.get(P);if(ne!==void 0)return ne;I=(0,c.normalizeId)(N||I);const me=c.getSchemaRefs.call(this,P,I);return ne=new o.SchemaEnv({schema:P,schemaId:ee,meta:z,baseId:I,localRefs:me}),this._cache.set(ne.schema,ne),E&&!I.startsWith("#")&&(I&&this._checkUnique(I),this.refs[I]=ne),$&&this.validateSchema(P,!0),ne}_checkUnique(P){if(this.schemas[P]||this.refs[P])throw new Error(`schema with key or id "${P}" already exists`)}_compileSchemaEnv(P){if(P.meta?this._compileMetaSchema(P):o.compileSchema.call(this,P),!P.validate)throw new Error("ajv implementation error");return P.validate}_compileMetaSchema(P){const z=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,P)}finally{this.opts=z}}}b.ValidationError=n.default,b.MissingRefError=s.default,t.default=b;function w(L,P,z,I="error"){for(const $ in L){const E=$;E in P&&this.logger[I](`${z}: option ${$}. ${L[E]}`)}}function k(L){return L=(0,c.normalizeId)(L),this.schemas[L]||this.refs[L]}function S(){const L=this.opts.schemas;if(L)if(Array.isArray(L))this.addSchema(L);else for(const P in L)this.addSchema(L[P],P)}function C(){for(const L in this.opts.formats){const P=this.opts.formats[L];P&&this.addFormat(L,P)}}function j(L){if(Array.isArray(L)){this.addVocabulary(L);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const P in L){const z=L[P];z.keyword||(z.keyword=P),this.addKeyword(z)}}function D(){const L={...this.opts};for(const P of p)delete L[P];return L}const A={log(){},warn(){},error(){}};function V(L){if(L===!1)return A;if(L===void 0)return console;if(L.log&&L.warn&&L.error)return L;throw new Error("logger must implement log, warn and error methods")}const J=/^[a-z_$][a-z0-9_$:-]*$/i;function Y(L,P){const{RULES:z}=this;if((0,l.eachItem)(L,I=>{if(z.keywords[I])throw new Error(`Keyword ${I} is already defined`);if(!J.test(I))throw new Error(`Keyword ${I} has invalid name`)}),!!P&&P.$data&&!("code"in P||"validate"in P))throw new Error('$data keyword must have "code" or "validate" function')}function ge(L,P,z){var I;const $=P?.post;if(z&&$)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:E}=this;let N=$?E.post:E.rules.find(({type:ne})=>ne===z);if(N||(N={type:z,rules:[]},E.rules.push(N)),E.keywords[L]=!0,!P)return;const ee={keyword:L,definition:{...P,type:(0,u.getJSONTypes)(P.type),schemaType:(0,u.getJSONTypes)(P.schemaType)}};P.before?Ge.call(this,N,ee,P.before):N.rules.push(ee),E.all[L]=ee,(I=P.implements)===null||I===void 0||I.forEach(ne=>this.addKeyword(ne))}function Ge(L,P,z){const I=L.rules.findIndex($=>$.keyword===z);I>=0?L.rules.splice(I,0,P):(L.rules.push(P),this.logger.warn(`rule ${z} is not defined`))}function Ye(L){let{metaSchema:P}=L;P!==void 0&&(L.$data&&this.opts.$data&&(P=Tt(P)),L.validateSchema=this.compile(P,!0))}const be={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Tt(L){return{anyOf:[L,be]}}})(da)),da}var Zn={},Ln={},Un={},Hi;function Id(){if(Hi)return Un;Hi=1,Object.defineProperty(Un,"__esModule",{value:!0});const t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return Un.default=t,Un}var Lt={},Wi;function Cd(){if(Wi)return Lt;Wi=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.callRef=Lt.getValidate=void 0;const t=zn(),e=ht(),r=ie(),n=Zt(),s=va(),a=he(),o={keyword:"$ref",schemaType:"string",code(u){const{gen:l,schema:d,it:m}=u,{baseId:_,schemaEnv:p,validateName:y,opts:h,self:v}=m,{root:f}=p;if((d==="#"||d==="#/")&&_===f.baseId)return b();const g=s.resolveRef.call(v,f,_,d);if(g===void 0)throw new t.default(m.opts.uriResolver,_,d);if(g instanceof s.SchemaEnv)return w(g);return k(g);function b(){if(p===f)return c(u,y,p,p.$async);const S=l.scopeValue("root",{ref:f});return c(u,(0,r._)`${S}.validate`,f,f.$async)}function w(S){const C=i(u,S);c(u,C,S,S.$async)}function k(S){const C=l.scopeValue("schema",h.code.source===!0?{ref:S,code:(0,r.stringify)(S)}:{ref:S}),j=l.name("valid"),D=u.subschema({schema:S,dataTypes:[],schemaPath:r.nil,topSchemaRef:C,errSchemaPath:d},j);u.mergeEvaluated(D),u.ok(j)}}};function i(u,l){const{gen:d}=u;return l.validate?d.scopeValue("validate",{ref:l.validate}):(0,r._)`${d.scopeValue("wrapper",{ref:l})}.validate`}Lt.getValidate=i;function c(u,l,d,m){const{gen:_,it:p}=u,{allErrors:y,schemaEnv:h,opts:v}=p,f=v.passContext?n.default.this:r.nil;m?g():b();function g(){if(!h.$async)throw new Error("async schema referenced by sync schema");const S=_.let("valid");_.try(()=>{_.code((0,r._)`await ${(0,e.callValidateCode)(u,l,f)}`),k(l),y||_.assign(S,!0)},C=>{_.if((0,r._)`!(${C} instanceof ${p.ValidationError})`,()=>_.throw(C)),w(C),y||_.assign(S,!1)}),u.ok(S)}function b(){u.result((0,e.callValidateCode)(u,l,f),()=>k(l),()=>w(l))}function w(S){const C=(0,r._)`${S}.errors`;_.assign(n.default.vErrors,(0,r._)`${n.default.vErrors} === null ? ${C} : ${n.default.vErrors}.concat(${C})`),_.assign(n.default.errors,(0,r._)`${n.default.vErrors}.length`)}function k(S){var C;if(!p.opts.unevaluated)return;const j=(C=d?.validate)===null||C===void 0?void 0:C.evaluated;if(p.props!==!0)if(j&&!j.dynamicProps)j.props!==void 0&&(p.props=a.mergeEvaluated.props(_,j.props,p.props));else{const D=_.var("props",(0,r._)`${S}.evaluated.props`);p.props=a.mergeEvaluated.props(_,D,p.props,r.Name)}if(p.items!==!0)if(j&&!j.dynamicItems)j.items!==void 0&&(p.items=a.mergeEvaluated.items(_,j.items,p.items));else{const D=_.var("items",(0,r._)`${S}.evaluated.items`);p.items=a.mergeEvaluated.items(_,D,p.items,r.Name)}}}return Lt.callRef=c,Lt.default=o,Lt}var Ki;function Od(){if(Ki)return Ln;Ki=1,Object.defineProperty(Ln,"__esModule",{value:!0});const t=Id(),e=Cd(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,e.default];return Ln.default=r,Ln}var Dn={},Vn={},Bi;function Nd(){if(Bi)return Vn;Bi=1,Object.defineProperty(Vn,"__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:o})=>(0,t.str)`must be ${r[a].okStr} ${o}`,params:({keyword:a,schemaCode:o})=>(0,t._)`{comparison: ${r[a].okStr}, limit: ${o}}`},s={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:n,code(a){const{keyword:o,data:i,schemaCode:c}=a;a.fail$data((0,t._)`${i} ${r[o].fail} ${c} || isNaN(${i})`)}};return Vn.default=s,Vn}var Fn={},Ji;function Ad(){if(Ji)return Fn;Ji=1,Object.defineProperty(Fn,"__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:o,it:i}=n,c=i.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._)`(${o} === 0 || (${u} = ${a}/${o}, ${l}))`)}};return Fn.default=r,Fn}var Hn={},Wn={},Gi;function jd(){if(Gi)return Wn;Gi=1,Object.defineProperty(Wn,"__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 Wn.default=t,t.code='require("ajv/dist/runtime/ucs2length").default',Wn}var Yi;function Md(){if(Yi)return Hn;Yi=1,Object.defineProperty(Hn,"__esModule",{value:!0});const t=ie(),e=he(),r=jd(),s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:a,schemaCode:o}){const i=a==="maxLength"?"more":"fewer";return(0,t.str)`must NOT have ${i} than ${o} characters`},params:({schemaCode:a})=>(0,t._)`{limit: ${a}}`},code(a){const{keyword:o,data:i,schemaCode:c,it:u}=a,l=o==="maxLength"?t.operators.GT:t.operators.LT,d=u.opts.unicode===!1?(0,t._)`${i}.length`:(0,t._)`${(0,e.useFunc)(a.gen,r.default)}(${i})`;a.fail$data((0,t._)`${d} ${l} ${c}`)}};return Hn.default=s,Hn}var Kn={},Xi;function zd(){if(Xi)return Kn;Xi=1,Object.defineProperty(Kn,"__esModule",{value:!0});const t=ht(),e=ie(),n={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:s})=>(0,e.str)`must match pattern "${s}"`,params:({schemaCode:s})=>(0,e._)`{pattern: ${s}}`},code(s){const{data:a,$data:o,schema:i,schemaCode:c,it:u}=s,l=u.opts.unicodeRegExp?"u":"",d=o?(0,e._)`(new RegExp(${c}, ${l}))`:(0,t.usePattern)(s,i);s.fail$data((0,e._)`!${d}.test(${a})`)}};return Kn.default=n,Kn}var Bn={},Qi;function qd(){if(Qi)return Bn;Qi=1,Object.defineProperty(Bn,"__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:o}=n,i=s==="maxProperties"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`Object.keys(${a}).length ${i} ${o}`)}};return Bn.default=r,Bn}var Jn={},ec;function Zd(){if(ec)return Jn;ec=1,Object.defineProperty(Jn,"__esModule",{value:!0});const t=ht(),e=ie(),r=he(),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:o,schema:i,schemaCode:c,data:u,$data:l,it:d}=a,{opts:m}=d;if(!l&&i.length===0)return;const _=i.length>=m.loopRequired;if(d.allErrors?p():y(),m.strictRequired){const f=a.parentSchema.properties,{definedProperties:g}=a.it;for(const b of i)if(f?.[b]===void 0&&!g.has(b)){const w=d.schemaEnv.baseId+d.errSchemaPath,k=`required property "${b}" is not defined at "${w}" (strictRequired)`;(0,r.checkStrictMode)(d,k,d.opts.strictRequired)}}function p(){if(_||l)a.block$data(e.nil,h);else for(const f of i)(0,t.checkReportMissingProp)(a,f)}function y(){const f=o.let("missing");if(_||l){const g=o.let("valid",!0);a.block$data(g,()=>v(f,g)),a.ok(g)}else o.if((0,t.checkMissingProp)(a,i,f)),(0,t.reportMissingProp)(a,f),o.else()}function h(){o.forOf("prop",c,f=>{a.setParams({missingProperty:f}),o.if((0,t.noPropertyInData)(o,u,f,m.ownProperties),()=>a.error())})}function v(f,g){a.setParams({missingProperty:f}),o.forOf(f,c,()=>{o.assign(g,(0,t.propertyInData)(o,u,f,m.ownProperties)),o.if((0,e.not)(g),()=>{a.error(),o.break()})},e.nil)}}};return Jn.default=s,Jn}var Gn={},tc;function Ld(){if(tc)return Gn;tc=1,Object.defineProperty(Gn,"__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:o}=n,i=s==="maxItems"?t.operators.GT:t.operators.LT;n.fail$data((0,t._)`${a}.length ${i} ${o}`)}};return Gn.default=r,Gn}var Yn={},Xn={},rc;function ka(){if(rc)return Xn;rc=1,Object.defineProperty(Xn,"__esModule",{value:!0});const t=Oi();return t.code='require("ajv/dist/runtime/equal").default',Xn.default=t,Xn}var nc;function Ud(){if(nc)return Yn;nc=1,Object.defineProperty(Yn,"__esModule",{value:!0});const t=On(),e=ie(),r=he(),n=ka(),a={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:o,j:i}})=>(0,e.str)`must NOT have duplicate items (items ## ${i} and ${o} are identical)`,params:({params:{i:o,j:i}})=>(0,e._)`{i: ${o}, j: ${i}}`},code(o){const{gen:i,data:c,$data:u,schema:l,parentSchema:d,schemaCode:m,it:_}=o;if(!u&&!l)return;const p=i.let("valid"),y=d.items?(0,t.getSchemaTypes)(d.items):[];o.block$data(p,h,(0,e._)`${m} === false`),o.ok(p);function h(){const b=i.let("i",(0,e._)`${c}.length`),w=i.let("j");o.setParams({i:b,j:w}),i.assign(p,!0),i.if((0,e._)`${b} > 1`,()=>(v()?f:g)(b,w))}function v(){return y.length>0&&!y.some(b=>b==="object"||b==="array")}function f(b,w){const k=i.name("item"),S=(0,t.checkDataTypes)(y,k,_.opts.strictNumbers,t.DataType.Wrong),C=i.const("indices",(0,e._)`{}`);i.for((0,e._)`;${b}--;`,()=>{i.let(k,(0,e._)`${c}[${b}]`),i.if(S,(0,e._)`continue`),y.length>1&&i.if((0,e._)`typeof ${k} == "string"`,(0,e._)`${k} += "_"`),i.if((0,e._)`typeof ${C}[${k}] == "number"`,()=>{i.assign(w,(0,e._)`${C}[${k}]`),o.error(),i.assign(p,!1).break()}).code((0,e._)`${C}[${k}] = ${b}`)})}function g(b,w){const k=(0,r.useFunc)(i,n.default),S=i.name("outer");i.label(S).for((0,e._)`;${b}--;`,()=>i.for((0,e._)`${w} = ${b}; ${w}--;`,()=>i.if((0,e._)`${k}(${c}[${b}], ${c}[${w}])`,()=>{o.error(),i.assign(p,!1).break(S)})))}}};return Yn.default=a,Yn}var Qn={},sc;function Dd(){if(sc)return Qn;sc=1,Object.defineProperty(Qn,"__esModule",{value:!0});const t=ie(),e=he(),r=ka(),s={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:a})=>(0,t._)`{allowedValue: ${a}}`},code(a){const{gen:o,data:i,$data:c,schemaCode:u,schema:l}=a;c||l&&typeof l=="object"?a.fail$data((0,t._)`!${(0,e.useFunc)(o,r.default)}(${i}, ${u})`):a.fail((0,t._)`${l} !== ${i}`)}};return Qn.default=s,Qn}var es={},ac;function Vd(){if(ac)return es;ac=1,Object.defineProperty(es,"__esModule",{value:!0});const t=ie(),e=he(),r=ka(),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:o,data:i,$data:c,schema:u,schemaCode:l,it:d}=a;if(!c&&u.length===0)throw new Error("enum must have non-empty array");const m=u.length>=d.opts.loopEnum;let _;const p=()=>_??(_=(0,e.useFunc)(o,r.default));let y;if(m||c)y=o.let("valid"),a.block$data(y,h);else{if(!Array.isArray(u))throw new Error("ajv implementation error");const f=o.const("vSchema",l);y=(0,t.or)(...u.map((g,b)=>v(f,b)))}a.pass(y);function h(){o.assign(y,!1),o.forOf("v",l,f=>o.if((0,t._)`${p()}(${i}, ${f})`,()=>o.assign(y,!0).break()))}function v(f,g){const b=u[g];return typeof b=="object"&&b!==null?(0,t._)`${p()}(${i}, ${f}[${g}])`:(0,t._)`${i} === ${b}`}}};return es.default=s,es}var oc;function Fd(){if(oc)return Dn;oc=1,Object.defineProperty(Dn,"__esModule",{value:!0});const t=Nd(),e=Ad(),r=Md(),n=zd(),s=qd(),a=Zd(),o=Ld(),i=Ud(),c=Dd(),u=Vd(),l=[t.default,e.default,r.default,n.default,s.default,a.default,o.default,i.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,u.default];return Dn.default=l,Dn}var ts={},pr={},ic;function cc(){if(ic)return pr;ic=1,Object.defineProperty(pr,"__esModule",{value:!0}),pr.validateAdditionalItems=void 0;const t=ie(),e=he(),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:o,it:i}=a,{items:c}=o;if(!Array.isArray(c)){(0,e.checkStrictMode)(i,'"additionalItems" is ignored when "items" is not an array of schemas');return}s(a,c)}};function s(a,o){const{gen:i,schema:c,data:u,keyword:l,it:d}=a;d.items=!0;const m=i.const("len",(0,t._)`${u}.length`);if(c===!1)a.setParams({len:o.length}),a.pass((0,t._)`${m} <= ${o.length}`);else if(typeof c=="object"&&!(0,e.alwaysValidSchema)(d,c)){const p=i.var("valid",(0,t._)`${m} <= ${o.length}`);i.if((0,t.not)(p),()=>_(p)),a.ok(p)}function _(p){i.forRange("i",o.length,m,y=>{a.subschema({keyword:l,dataProp:y,dataPropType:e.Type.Num},p),d.allErrors||i.if((0,t.not)(p),()=>i.break())})}}return pr.validateAdditionalItems=s,pr.default=n,pr}var rs={},mr={},uc;function lc(){if(uc)return mr;uc=1,Object.defineProperty(mr,"__esModule",{value:!0}),mr.validateTuple=void 0;const t=ie(),e=he(),r=ht(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(a){const{schema:o,it:i}=a;if(Array.isArray(o))return s(a,"additionalItems",o);i.items=!0,!(0,e.alwaysValidSchema)(i,o)&&a.ok((0,r.validateArray)(a))}};function s(a,o,i=a.schema){const{gen:c,parentSchema:u,data:l,keyword:d,it:m}=a;y(u),m.opts.unevaluated&&i.length&&m.items!==!0&&(m.items=e.mergeEvaluated.items(c,i.length,m.items));const _=c.name("valid"),p=c.const("len",(0,t._)`${l}.length`);i.forEach((h,v)=>{(0,e.alwaysValidSchema)(m,h)||(c.if((0,t._)`${p} > ${v}`,()=>a.subschema({keyword:d,schemaProp:v,dataProp:v},_)),a.ok(_))});function y(h){const{opts:v,errSchemaPath:f}=m,g=i.length,b=g===h.minItems&&(g===h.maxItems||h[o]===!1);if(v.strictTuples&&!b){const w=`"${d}" is ${g}-tuple, but minItems or maxItems/${o} are not specified or different at path "${f}"`;(0,e.checkStrictMode)(m,w,v.strictTuples)}}}return mr.validateTuple=s,mr.default=n,mr}var dc;function Hd(){if(dc)return rs;dc=1,Object.defineProperty(rs,"__esModule",{value:!0});const t=lc(),e={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:r=>(0,t.validateTuple)(r,"items")};return rs.default=e,rs}var ns={},fc;function Wd(){if(fc)return ns;fc=1,Object.defineProperty(ns,"__esModule",{value:!0});const t=ie(),e=he(),r=ht(),n=cc(),a={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:o}})=>(0,t.str)`must NOT have more than ${o} items`,params:({params:{len:o}})=>(0,t._)`{limit: ${o}}`},code(o){const{schema:i,parentSchema:c,it:u}=o,{prefixItems:l}=c;u.items=!0,!(0,e.alwaysValidSchema)(u,i)&&(l?(0,n.validateAdditionalItems)(o,l):o.ok((0,r.validateArray)(o)))}};return ns.default=a,ns}var ss={},hc;function Kd(){if(hc)return ss;hc=1,Object.defineProperty(ss,"__esModule",{value:!0});const t=ie(),e=he(),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:o,parentSchema:i,data:c,it:u}=s;let l,d;const{minContains:m,maxContains:_}=i;u.opts.next?(l=m===void 0?1:m,d=_):l=1;const p=a.const("len",(0,t._)`${c}.length`);if(s.setParams({min:l,max:d}),d===void 0&&l===0){(0,e.checkStrictMode)(u,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(d!==void 0&&l>d){(0,e.checkStrictMode)(u,'"minContains" > "maxContains" is always invalid'),s.fail();return}if((0,e.alwaysValidSchema)(u,o)){let g=(0,t._)`${p} >= ${l}`;d!==void 0&&(g=(0,t._)`${g} && ${p} <= ${d}`),s.pass(g);return}u.items=!0;const y=a.name("valid");d===void 0&&l===1?v(y,()=>a.if(y,()=>a.break())):l===0?(a.let(y,!0),d!==void 0&&a.if((0,t._)`${c}.length > 0`,h)):(a.let(y,!1),h()),s.result(y,()=>s.reset());function h(){const g=a.name("_valid"),b=a.let("count",0);v(g,()=>a.if(g,()=>f(b)))}function v(g,b){a.forRange("i",0,p,w=>{s.subschema({keyword:"contains",dataProp:w,dataPropType:e.Type.Num,compositeRule:!0},g),b()})}function f(g){a.code((0,t._)`${g}++`),d===void 0?a.if((0,t._)`${g} >= ${l}`,()=>a.assign(y,!0).break()):(a.if((0,t._)`${g} > ${d}`,()=>a.assign(y,!1).break()),l===1?a.assign(y,!0):a.if((0,t._)`${g} >= ${l}`,()=>a.assign(y,!0)))}}};return ss.default=n,ss}var $a={},pc;function Bd(){return pc||(pc=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=ie(),r=he(),n=ht();t.error={message:({params:{property:c,depsCount:u,deps:l}})=>{const d=u===1?"property":"properties";return(0,e.str)`must have ${d} ${l} when property ${c} is present`},params:({params:{property:c,depsCount:u,deps:l,missingProperty:d}})=>(0,e._)`{property: ${c},
6
+ missingProperty: ${d},
7
7
  depsCount: ${u},
8
- deps: ${l}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[u,l]=o(c);i(c,u),a(c,l)}};function o({schema:c}){const u={},l={};for(const f in c){if(f==="__proto__")continue;const _=Array.isArray(c[f])?u:l;_[f]=c[f]}return[u,l]}function i(c,u=c.schema){const{gen:l,data:f,it:_}=c;if(Object.keys(u).length===0)return;const y=l.let("missing");for(const g in u){const v=u[g];if(v.length===0)continue;const h=(0,n.propertyInData)(l,f,g,_.opts.ownProperties);c.setParams({property:g,depsCount:v.length,deps:v.join(", ")}),_.allErrors?l.if(h,()=>{for(const d of v)(0,n.checkReportMissingProp)(c,d)}):(l.if((0,e._)`${h} && (${(0,n.checkMissingProp)(c,v,y)})`),(0,n.reportMissingProp)(c,y),l.else())}}t.validatePropertyDeps=i;function a(c,u=c.schema){const{gen:l,data:f,keyword:_,it:y}=c,g=l.name("valid");for(const v in u)(0,r.alwaysValidSchema)(y,u[v])||(l.if((0,n.propertyInData)(l,f,v,y.opts.ownProperties),()=>{const h=c.subschema({keyword:_,schemaProp:v},g);c.mergeValidEvaluated(h,g)},()=>l.var(g,!0)),c.ok(g))}t.validateSchemaDeps=a,t.default=s})(ru);var Jo={};Object.defineProperty(Jo,"__esModule",{value:!0});const nu=Q,gm=M,vm={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>(0,nu._)`{propertyName: ${t.propertyName}}`},code(t){const{gen:e,schema:r,data:n,it:s}=t;if((0,gm.alwaysValidSchema)(s,r))return;const o=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,nu.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};Jo.default=vm;var ns={};Object.defineProperty(ns,"__esModule",{value:!0});const ss=te,ct=Q,ym=bt,os=M,bm={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:t})=>(0,ct._)`{additionalProperty: ${t.additionalProperty}}`},code(t){const{gen:e,schema:r,parentSchema:n,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");const{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,os.alwaysValidSchema)(i,r))return;const u=(0,ss.allSchemaProperties)(n.properties),l=(0,ss.allSchemaProperties)(n.patternProperties);f(),t.ok((0,ct._)`${o} === ${ym.default.errors}`);function f(){e.forIn("key",s,h=>{!u.length&&!l.length?g(h):e.if(_(h),()=>g(h))})}function _(h){let d;if(u.length>8){const m=(0,os.schemaRefOrVal)(i,n.properties,"properties");d=(0,ss.isOwnProperty)(e,m,h)}else u.length?d=(0,ct.or)(...u.map(m=>(0,ct._)`${h} === ${m}`)):d=ct.nil;return l.length&&(d=(0,ct.or)(d,...l.map(m=>(0,ct._)`${(0,ss.usePattern)(t,m)}.test(${h})`))),(0,ct.not)(d)}function y(h){e.code((0,ct._)`delete ${s}[${h}]`)}function g(h){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){y(h);return}if(r===!1){t.setParams({additionalProperty:h}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,os.alwaysValidSchema)(i,r)){const d=e.name("valid");c.removeAdditional==="failing"?(v(h,d,!1),e.if((0,ct.not)(d),()=>{t.reset(),y(h)})):(v(h,d),a||e.if((0,ct.not)(d),()=>e.break()))}}function v(h,d,m){const w={keyword:"additionalProperties",dataProp:h,dataPropType:os.Type.Str};m===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(w,d)}}};ns.default=bm;var Bo={};Object.defineProperty(Bo,"__esModule",{value:!0});const wm=ot,su=te,Ko=M,ou=ns,$m={keyword:"properties",type:"object",schemaType:"object",code(t){const{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&ou.default.code(new wm.KeywordCxt(o,ou.default,"additionalProperties"));const i=(0,su.allSchemaProperties)(r);for(const f of i)o.definedProperties.add(f);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=Ko.mergeEvaluated.props(e,(0,Ko.toHash)(i),o.props));const a=i.filter(f=>!(0,Ko.alwaysValidSchema)(o,r[f]));if(a.length===0)return;const c=e.name("valid");for(const f of a)u(f)?l(f):(e.if((0,su.propertyInData)(e,s,f,o.opts.ownProperties)),l(f),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(f),t.ok(c);function u(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function l(f){t.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};Bo.default=$m;var Go={};Object.defineProperty(Go,"__esModule",{value:!0});const iu=te,is=Q,au=M,cu=M,Sm={keyword:"patternProperties",type:"object",schemaType:"object",code(t){const{gen:e,schema:r,data:n,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,iu.allSchemaProperties)(r),c=a.filter(v=>(0,au.alwaysValidSchema)(o,r[v]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;const u=i.strictSchema&&!i.allowMatchingProperties&&s.properties,l=e.name("valid");o.props!==!0&&!(o.props instanceof is.Name)&&(o.props=(0,cu.evaluatedPropsToName)(e,o.props));const{props:f}=o;_();function _(){for(const v of a)u&&y(v),o.allErrors?g(v):(e.var(l,!0),g(v),e.if(l))}function y(v){for(const h in u)new RegExp(v).test(h)&&(0,au.checkStrictMode)(o,`property ${h} matches pattern ${v} (use allowMatchingProperties)`)}function g(v){e.forIn("key",n,h=>{e.if((0,is._)`${(0,iu.usePattern)(t,v)}.test(${h})`,()=>{const d=c.includes(v);d||t.subschema({keyword:"patternProperties",schemaProp:v,dataProp:h,dataPropType:cu.Type.Str},l),o.opts.unevaluated&&f!==!0?e.assign((0,is._)`${f}[${h}]`,!0):!d&&!o.allErrors&&e.if((0,is.not)(l),()=>e.break())})})}}};Go.default=Sm;var Yo={};Object.defineProperty(Yo,"__esModule",{value:!0});const km=M,Em={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:e,schema:r,it:n}=t;if((0,km.alwaysValidSchema)(n,r)){t.fail();return}const s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Yo.default=Em;var Xo={};Object.defineProperty(Xo,"__esModule",{value:!0});const Pm={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:te.validateUnion,error:{message:"must match a schema in anyOf"}};Xo.default=Pm;var Qo={};Object.defineProperty(Qo,"__esModule",{value:!0});const as=Q,Tm=M,xm={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>(0,as._)`{passingSchemas: ${t.passing}}`},code(t){const{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;const o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){o.forEach((l,f)=>{let _;(0,Tm.alwaysValidSchema)(s,l)?e.var(c,!0):_=t.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&e.if((0,as._)`${c} && ${i}`).assign(i,!1).assign(a,(0,as._)`[${a}, ${f}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,f),_&&t.mergeEvaluated(_,as.Name)})})}}};Qo.default=xm;var ei={};Object.defineProperty(ei,"__esModule",{value:!0});const Rm=M,Im={keyword:"allOf",schemaType:"array",code(t){const{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");const s=e.name("valid");r.forEach((o,i)=>{if((0,Rm.alwaysValidSchema)(n,o))return;const a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};ei.default=Im;var ti={};Object.defineProperty(ti,"__esModule",{value:!0});const cs=Q,uu=M,Cm={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>(0,cs.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,cs._)`{failingKeyword: ${t.ifClause}}`},code(t){const{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,uu.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const s=lu(n,"then"),o=lu(n,"else");if(!s&&!o)return;const i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){const l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else s?e.if(a,u("then")):e.if((0,cs.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){const l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,f){return()=>{const _=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(_,i),f?e.assign(f,(0,cs._)`${l}`):t.setParams({ifClause:l})}}}};function lu(t,e){const r=t.schema[e];return r!==void 0&&!(0,uu.alwaysValidSchema)(t,r)}ti.default=Cm;var ri={};Object.defineProperty(ri,"__esModule",{value:!0});const Om=M,Nm={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Om.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};ri.default=Nm,Object.defineProperty(qo,"__esModule",{value:!0});const jm=Sr,Am=Fo,zm=kr,Mm=Ho,Zm=Wo,Lm=ru,Um=Jo,Dm=ns,qm=Bo,Vm=Go,Fm=Yo,Hm=Xo,Wm=Qo,Jm=ei,Bm=ti,Km=ri;function Gm(t=!1){const e=[Fm.default,Hm.default,Wm.default,Jm.default,Bm.default,Km.default,Um.default,Dm.default,Lm.default,qm.default,Vm.default];return t?e.push(Am.default,Mm.default):e.push(jm.default,zm.default),e.push(Zm.default),e}qo.default=Gm;var ni={},si={};Object.defineProperty(si,"__esModule",{value:!0});const xe=Q,Ym={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>(0,xe.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,xe._)`{format: ${t}}`},code(t,e){const{gen:r,data:n,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:f}=a;if(!c.validateFormats)return;s?_():y();function _(){const g=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),v=r.const("fDef",(0,xe._)`${g}[${i}]`),h=r.let("fType"),d=r.let("format");r.if((0,xe._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign(h,(0,xe._)`${v}.type || "string"`).assign(d,(0,xe._)`${v}.validate`),()=>r.assign(h,(0,xe._)`"string"`).assign(d,v)),t.fail$data((0,xe.or)(m(),w()));function m(){return c.strictSchema===!1?xe.nil:(0,xe._)`${i} && !${d}`}function w(){const S=l.$async?(0,xe._)`(${v}.async ? await ${d}(${n}) : ${d}(${n}))`:(0,xe._)`${d}(${n})`,P=(0,xe._)`(typeof ${d} == "function" ? ${S} : ${d}.test(${n}))`;return(0,xe._)`${d} && ${d} !== true && ${h} === ${e} && !${P}`}}function y(){const g=f.formats[o];if(!g){m();return}if(g===!0)return;const[v,h,d]=w(g);v===e&&t.pass(S());function m(){if(c.strictSchema===!1){f.logger.warn(P());return}throw new Error(P());function P(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function w(P){const O=P instanceof RegExp?(0,xe.regexpCode)(P):c.code.formats?(0,xe._)`${c.code.formats}${(0,xe.getProperty)(o)}`:void 0,V=r.scopeValue("formats",{key:o,ref:P,code:O});return typeof P=="object"&&!(P instanceof RegExp)?[P.type||"string",P.validate,(0,xe._)`${V}.validate`]:["string",P,V]}function S(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,xe._)`await ${d}(${n})`}return typeof h=="function"?(0,xe._)`${d}(${n})`:(0,xe._)`${d}.test(${n})`}}}};si.default=Ym,Object.defineProperty(ni,"__esModule",{value:!0});const Xm=[si.default];ni.default=Xm;var Er={};Object.defineProperty(Er,"__esModule",{value:!0}),Er.contentVocabulary=Er.metadataVocabulary=void 0,Er.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Er.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty(Eo,"__esModule",{value:!0});const Qm=Po,e_=xo,t_=qo,r_=ni,du=Er,n_=[Qm.default,e_.default,(0,t_.default)(),r_.default,du.metadataVocabulary,du.contentVocabulary];Eo.default=n_;var oi={},us={};Object.defineProperty(us,"__esModule",{value:!0}),us.DiscrError=void 0;var fu;(function(t){t.Tag="tag",t.Mapping="mapping"})(fu||(us.DiscrError=fu={})),Object.defineProperty(oi,"__esModule",{value:!0});const Pr=Q,ii=us,hu=Je,s_=wr,o_=M,i_={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:t,tagName:e}})=>t===ii.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Pr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},code(t){const{gen:e,data:r,schema:n,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");const c=e.let("valid",!1),u=e.const("tag",(0,Pr._)`${r}${(0,Pr.getProperty)(a)}`);e.if((0,Pr._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:ii.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){const y=_();e.if(!1);for(const g in y)e.elseIf((0,Pr._)`${u} === ${g}`),e.assign(c,f(y[g]));e.else(),t.error(!1,{discrError:ii.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function f(y){const g=e.name("valid"),v=t.subschema({keyword:"oneOf",schemaProp:y},g);return t.mergeEvaluated(v,Pr.Name),g}function _(){var y;const g={},v=d(s);let h=!0;for(let S=0;S<i.length;S++){let P=i[S];if(P!=null&&P.$ref&&!(0,o_.schemaHasRulesButRef)(P,o.self.RULES)){const V=P.$ref;if(P=hu.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,V),P instanceof hu.SchemaEnv&&(P=P.schema),P===void 0)throw new s_.default(o.opts.uriResolver,o.baseId,V)}const O=(y=P==null?void 0:P.properties)===null||y===void 0?void 0:y[a];if(typeof O!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);h=h&&(v||d(P)),m(O,S)}if(!h)throw new Error(`discriminator: "${a}" must be required`);return g;function d({required:S}){return Array.isArray(S)&&S.includes(a)}function m(S,P){if(S.const)w(S.const,P);else if(S.enum)for(const O of S.enum)w(O,P);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w(S,P){if(typeof S!="string"||S in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[S]=P}}}};oi.default=i_;const a_={$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};(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=Ja,n=Eo,s=oi,o=a_,i=["/properties"],a="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(o,i):o;this.addMetaSchema(g,a,!1),this.refs["http://json-schema.org/schema"]=a}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(a)?a:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var u=ot;Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=Q;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=Wr;Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var _=wr;Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return _.default}})})(no,no.exports);var ai=no.exports;const c_=_r(ai),u_=Object.freeze({status:"aborted"});function T(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(const l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}const s=(r==null?void 0:r.Parent)??Object;class o extends s{}Object.defineProperty(o,"name",{value:t});function i(a){var c;const u=r!=null&&r.Parent?new o:this;n(u,a),(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:a=>{var c,u;return r!=null&&r.Parent&&a instanceof r.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(t)}}),Object.defineProperty(i,"name",{value:t}),i}class tn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const pu={};function Ft(t){return pu}function mu(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 l_(t,e){return typeof e=="bigint"?e.toString():e}function ci(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function ui(t){return t==null}function li(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function d_(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}function _e(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 rn(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function nn(t){return JSON.stringify(t)}const _u=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function ls(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const f_=ci(()=>{var t;if(typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)!=null&&t.includes("Cloudflare")))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ds(t){if(ls(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(ls(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const h_=new Set(["string","number","symbol"]);function sn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ht(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r!=null&&r.parent)&&(n._zod.parent=t),n}function D(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if((e==null?void 0:e.message)!==void 0){if((e==null?void 0: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 p_(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const m_={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 __(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 Ht(t,{...t._zod.def,shape:r,checks:[]})}function g_(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 Ht(t,{...t._zod.def,shape:r,checks:[]})}function v_(t,e){if(!ds(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 rn(this,"shape",n),n},checks:[]};return Ht(t,r)}function y_(t,e){return Ht(t,{...t._zod.def,get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return rn(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function b_(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in n))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=t?new t({type:"optional",innerType:n[o]}):n[o])}else for(const o in n)s[o]=t?new t({type:"optional",innerType:n[o]}):n[o];return Ht(e,{...e._zod.def,shape:s,checks:[]})}function w_(t,e,r){const n=e._zod.def.shape,s={...n};if(r)for(const o in r){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);r[o]&&(s[o]=new t({type:"nonoptional",innerType:n[o]}))}else for(const o in n)s[o]=new t({type:"nonoptional",innerType:n[o]});return Ht(e,{...e._zod.def,shape:s,checks:[]})}function on(t,e=0){var r;for(let n=e;n<t.issues.length;n++)if(((r=t.issues[n])==null?void 0:r.continue)!==!0)return!0;return!1}function ar(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function fs(t){return typeof t=="string"?t:t==null?void 0:t.message}function Wt(t,e,r){var s,o,i,a,c,u;const n={...t,path:t.path??[]};if(!t.message){const l=fs((i=(o=(s=t.inst)==null?void 0:s._zod.def)==null?void 0:o.error)==null?void 0:i.call(o,t))??fs((a=e==null?void 0:e.error)==null?void 0:a.call(e,t))??fs((c=r.customError)==null?void 0:c.call(r,t))??fs((u=r.localeError)==null?void 0:u.call(r,t))??"Invalid input";n.message=l}return delete n.inst,delete n.continue,e!=null&&e.reportInput||delete n.input,n}function di(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function an(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const gu=(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,l_,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},vu=T("$ZodError",gu),hs=T("$ZodError",gu,{Parent:Error});function $_(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 S_(t,e){const r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>s({issues:a}));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 a=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(t),n}const yu=t=>(e,r,n,s)=>{const o=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new tn;if(i.issues.length){const a=new((s==null?void 0:s.Err)??t)(i.issues.map(c=>Wt(c,o,Ft())));throw _u(a,s==null?void 0:s.callee),a}return i.value},k_=yu(hs),bu=t=>async(e,r,n,s)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let i=e._zod.run({value:r,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((s==null?void 0:s.Err)??t)(i.issues.map(c=>Wt(c,o,Ft())));throw _u(a,s==null?void 0:s.callee),a}return i.value},E_=bu(hs),wu=t=>(e,r,n)=>{const s=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new tn;return o.issues.length?{success:!1,error:new(t??vu)(o.issues.map(i=>Wt(i,s,Ft())))}:{success:!0,data:o.value}},fi=wu(hs),$u=t=>async(e,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new t(o.issues.map(i=>Wt(i,s,Ft())))}:{success:!0,data:o.value}},hi=$u(hs),P_=/^[cC][^\s-]{8,}$/,T_=/^[0-9a-z]+$/,x_=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,R_=/^[0-9a-vA-V]{20}$/,I_=/^[A-Za-z0-9]{27}$/,C_=/^[a-zA-Z0-9_-]{21}$/,O_=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,N_=/^([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})$/,Su=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)$/,j_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,A_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function z_(){return new RegExp(A_,"u")}const M_=/^(?:(?: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])$/,Z_=/^(([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})$/,L_=/^((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])$/,U_=/^(([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])$/,D_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ku=/^[A-Za-z0-9_-]*$/,q_=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,V_=/^\+(?:[0-9]){6,14}[0-9]$/,Eu="(?:(?:\\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])))",F_=new RegExp(`^${Eu}$`);function Pu(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 H_(t){return new RegExp(`^${Pu(t)}$`)}function W_(t){const e=Pu({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(`^${Eu}T(?:${n})$`)}const J_=t=>{const e=t?`[\\s\\S]{${(t==null?void 0:t.minimum)??0},${(t==null?void 0:t.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},B_=/^\d+$/,K_=/^-?\d+(?:\.\d+)?/i,G_=/true|false/i,Y_=/^[^A-Z]*$/,X_=/^[^a-z]*$/,Ke=T("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Tu={number:"number",bigint:"bigint",object:"date"},xu=T("$ZodCheckLessThan",(t,e)=>{Ke.init(t,e);const r=Tu[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,o=(e.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<o&&(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})}}),Ru=T("$ZodCheckGreaterThan",(t,e)=>{Ke.init(t,e);const r=Tu[typeof e.value];t._zod.onattach.push(n=>{const s=n._zod.bag,o=(e.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>o&&(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})}}),Q_=T("$ZodCheckMultipleOf",(t,e)=>{Ke.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):d_(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})}}),eg=T("$ZodCheckNumberFormat",(t,e)=>{var i;Ke.init(t,e),e.format=e.format||"float64";const r=(i=e.format)==null?void 0:i.includes("int"),n=r?"int":"number",[s,o]=m_[e.format];t._zod.onattach.push(a=>{const c=a._zod.bag;c.format=e.format,c.minimum=s,c.maximum=o,r&&(c.pattern=B_)}),t._zod.check=a=>{const c=a.value;if(r){if(!Number.isInteger(c)){a.issues.push({expected:n,format:e.format,code:"invalid_type",input:c,inst:t});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):a.issues.push({input:c,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}}c<s&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),c>o&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inst:t})}}),tg=T("$ZodCheckMaxLength",(t,e)=>{var r;Ke.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ui(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=di(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),rg=T("$ZodCheckMinLength",(t,e)=>{var r;Ke.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ui(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=di(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),ng=T("$ZodCheckLengthEquals",(t,e)=>{var r;Ke.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!ui(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,o=s.length;if(o===e.length)return;const i=di(s),a=o>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),ps=T("$ZodCheckStringFormat",(t,e)=>{var r,n;Ke.init(t,e),t._zod.onattach.push(s=>{const o=s._zod.bag;o.format=e.format,e.pattern&&(o.patterns??(o.patterns=new Set),o.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=()=>{})}),sg=T("$ZodCheckRegex",(t,e)=>{ps.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})}}),og=T("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Y_),ps.init(t,e)}),ig=T("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=X_),ps.init(t,e)}),ag=T("$ZodCheckIncludes",(t,e)=>{Ke.init(t,e);const r=sn(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.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})}}),cg=T("$ZodCheckStartsWith",(t,e)=>{Ke.init(t,e);const r=new RegExp(`^${sn(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})}}),ug=T("$ZodCheckEndsWith",(t,e)=>{Ke.init(t,e);const r=new RegExp(`.*${sn(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})}}),lg=T("$ZodCheckOverwrite",(t,e)=>{Ke.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class dg{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)),o=n.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of o)this.content.push(i)}compile(){const e=Function,r=this==null?void 0:this.args,s=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new e(...r,s.join(`
10
- `))}}const fg={major:4,minor:0,patch:0},ge=T("$ZodType",(t,e)=>{var s;var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=fg;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const o of n)for(const i of o._zod.onattach)i(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),(s=t._zod.deferred)==null||s.push(()=>{t._zod.run=t._zod.parse});else{const o=(i,a,c)=>{let u=on(i),l;for(const f of a){if(f._zod.def.when){if(!f._zod.def.when(i))continue}else if(u)continue;const _=i.issues.length,y=f._zod.check(i);if(y instanceof Promise&&(c==null?void 0:c.async)===!1)throw new tn;if(l||y instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await y,i.issues.length!==_&&(u||(u=on(i,_)))});else{if(i.issues.length===_)continue;u||(u=on(i,_))}}return l?l.then(()=>i):i};t._zod.run=(i,a)=>{const c=t._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new tn;return c.then(u=>o(u,n,a))}return o(c,n,a)}}t["~standard"]={validate:o=>{var i;try{const a=fi(t,o);return a.success?{value:a.data}:{issues:(i=a.error)==null?void 0:i.issues}}catch{return hi(t,o).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}}),pi=T("$ZodString",(t,e)=>{var r;ge.init(t,e),t._zod.pattern=[...((r=t==null?void 0:t._zod.bag)==null?void 0:r.patterns)??[]].pop()??J_(t._zod.bag),t._zod.parse=(n,s)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),ye=T("$ZodStringFormat",(t,e)=>{ps.init(t,e),pi.init(t,e)}),hg=T("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=N_),ye.init(t,e)}),pg=T("$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=Su(n))}else e.pattern??(e.pattern=Su());ye.init(t,e)}),mg=T("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=j_),ye.init(t,e)}),_g=T("$ZodURL",(t,e)=>{ye.init(t,e),t._zod.check=r=>{try{const n=r.value,s=new URL(n),o=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:q_.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("/")&&o.endsWith("/")?r.value=o.slice(0,-1):r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),gg=T("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=z_()),ye.init(t,e)}),vg=T("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=C_),ye.init(t,e)}),yg=T("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=P_),ye.init(t,e)}),bg=T("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=T_),ye.init(t,e)}),wg=T("$ZodULID",(t,e)=>{e.pattern??(e.pattern=x_),ye.init(t,e)}),$g=T("$ZodXID",(t,e)=>{e.pattern??(e.pattern=R_),ye.init(t,e)}),Sg=T("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=I_),ye.init(t,e)}),kg=T("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=W_(e)),ye.init(t,e)}),Eg=T("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=F_),ye.init(t,e)}),Pg=T("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=H_(e)),ye.init(t,e)}),Tg=T("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=O_),ye.init(t,e)}),xg=T("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=M_),ye.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),Rg=T("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Z_),ye.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})}}}),Ig=T("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=L_),ye.init(t,e)}),Cg=T("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=U_),ye.init(t,e),t._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>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 Iu(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const Og=T("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=D_),ye.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{Iu(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Ng(t){if(!ku.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Iu(r)}const jg=T("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=ku),ye.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{Ng(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Ag=T("$ZodE164",(t,e)=>{e.pattern??(e.pattern=V_),ye.init(t,e)});function zg(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==null?void 0:s.typ)!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}const Mg=T("$ZodJWT",(t,e)=>{ye.init(t,e),t._zod.check=r=>{zg(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),Cu=T("$ZodNumber",(t,e)=>{ge.init(t,e),t._zod.pattern=t._zod.bag.pattern??K_,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 o=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,...o?{received:o}:{}}),r}}),Zg=T("$ZodNumber",(t,e)=>{eg.init(t,e),Cu.init(t,e)}),Lg=T("$ZodBoolean",(t,e)=>{ge.init(t,e),t._zod.pattern=G_,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}}),Ug=T("$ZodAny",(t,e)=>{ge.init(t,e),t._zod.parse=r=>r}),Dg=T("$ZodUnknown",(t,e)=>{ge.init(t,e),t._zod.parse=r=>r}),qg=T("$ZodNever",(t,e)=>{ge.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Ou(t,e,r){t.issues.length&&e.issues.push(...ar(r,t.issues)),e.value[r]=t.value}const Vg=T("$ZodArray",(t,e)=>{ge.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 o=[];for(let i=0;i<s.length;i++){const a=s[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?o.push(c.then(u=>Ou(u,r,i))):Ou(c,r,i)}return o.length?Promise.all(o).then(()=>r):r}});function ms(t,e,r){t.issues.length&&e.issues.push(...ar(r,t.issues)),e.value[r]=t.value}function Nu(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(...ar(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}const ju=T("$ZodObject",(t,e)=>{ge.init(t,e);const r=ci(()=>{const f=Object.keys(e.shape);for(const y of f)if(!(e.shape[y]instanceof ge))throw new Error(`Invalid element at key "${y}": expected a Zod schema`);const _=p_(e.shape);return{shape:e.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(_)}});_e(t._zod,"propValues",()=>{const f=e.shape,_={};for(const y in f){const g=f[y]._zod;if(g.values){_[y]??(_[y]=new Set);for(const v of g.values)_[y].add(v)}}return _});const n=f=>{const _=new dg(["shape","payload","ctx"]),y=r.value,g=m=>{const w=nn(m);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};_.write("const input = payload.value;");const v=Object.create(null);let h=0;for(const m of y.keys)v[m]=`key_${h++}`;_.write("const newResult = {}");for(const m of y.keys)if(y.optionalKeys.has(m)){const w=v[m];_.write(`const ${w} = ${g(m)};`);const S=nn(m);_.write(`
11
- if (${w}.issues.length) {
12
- if (input[${S}] === undefined) {
13
- if (${S} in input) {
14
- newResult[${S}] = undefined;
8
+ deps: ${l}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[u,l]=a(c);o(c,u),i(c,l)}};function a({schema:c}){const u={},l={};for(const d in c){if(d==="__proto__")continue;const m=Array.isArray(c[d])?u:l;m[d]=c[d]}return[u,l]}function o(c,u=c.schema){const{gen:l,data:d,it:m}=c;if(Object.keys(u).length===0)return;const _=l.let("missing");for(const p in u){const y=u[p];if(y.length===0)continue;const h=(0,n.propertyInData)(l,d,p,m.opts.ownProperties);c.setParams({property:p,depsCount:y.length,deps:y.join(", ")}),m.allErrors?l.if(h,()=>{for(const v of y)(0,n.checkReportMissingProp)(c,v)}):(l.if((0,e._)`${h} && (${(0,n.checkMissingProp)(c,y,_)})`),(0,n.reportMissingProp)(c,_),l.else())}}t.validatePropertyDeps=o;function i(c,u=c.schema){const{gen:l,data:d,keyword:m,it:_}=c,p=l.name("valid");for(const y in u)(0,r.alwaysValidSchema)(_,u[y])||(l.if((0,n.propertyInData)(l,d,y,_.opts.ownProperties),()=>{const h=c.subschema({keyword:m,schemaProp:y},p);c.mergeValidEvaluated(h,p)},()=>l.var(p,!0)),c.ok(p))}t.validateSchemaDeps=i,t.default=s})($a)),$a}var as={},mc;function Jd(){if(mc)return as;mc=1,Object.defineProperty(as,"__esModule",{value:!0});const t=ie(),e=he(),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:o,data:i,it:c}=s;if((0,e.alwaysValidSchema)(c,o))return;const u=a.name("valid");a.forIn("key",i,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 as.default=n,as}var os={},_c;function gc(){if(_c)return os;_c=1,Object.defineProperty(os,"__esModule",{value:!0});const t=ht(),e=ie(),r=Zt(),n=he(),a={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:o})=>(0,e._)`{additionalProperty: ${o.additionalProperty}}`},code(o){const{gen:i,schema:c,parentSchema:u,data:l,errsCount:d,it:m}=o;if(!d)throw new Error("ajv implementation error");const{allErrors:_,opts:p}=m;if(m.props=!0,p.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(m,c))return;const y=(0,t.allSchemaProperties)(u.properties),h=(0,t.allSchemaProperties)(u.patternProperties);v(),o.ok((0,e._)`${d} === ${r.default.errors}`);function v(){i.forIn("key",l,k=>{!y.length&&!h.length?b(k):i.if(f(k),()=>b(k))})}function f(k){let S;if(y.length>8){const C=(0,n.schemaRefOrVal)(m,u.properties,"properties");S=(0,t.isOwnProperty)(i,C,k)}else y.length?S=(0,e.or)(...y.map(C=>(0,e._)`${k} === ${C}`)):S=e.nil;return h.length&&(S=(0,e.or)(S,...h.map(C=>(0,e._)`${(0,t.usePattern)(o,C)}.test(${k})`))),(0,e.not)(S)}function g(k){i.code((0,e._)`delete ${l}[${k}]`)}function b(k){if(p.removeAdditional==="all"||p.removeAdditional&&c===!1){g(k);return}if(c===!1){o.setParams({additionalProperty:k}),o.error(),_||i.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(m,c)){const S=i.name("valid");p.removeAdditional==="failing"?(w(k,S,!1),i.if((0,e.not)(S),()=>{o.reset(),g(k)})):(w(k,S),_||i.if((0,e.not)(S),()=>i.break()))}}function w(k,S,C){const j={keyword:"additionalProperties",dataProp:k,dataPropType:n.Type.Str};C===!1&&Object.assign(j,{compositeRule:!0,createErrors:!1,allErrors:!1}),o.subschema(j,S)}}};return os.default=a,os}var is={},yc;function Gd(){if(yc)return is;yc=1,Object.defineProperty(is,"__esModule",{value:!0});const t=An(),e=ht(),r=he(),n=gc(),s={keyword:"properties",type:"object",schemaType:"object",code(a){const{gen:o,schema:i,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 d=(0,e.allSchemaProperties)(i);for(const h of d)l.definedProperties.add(h);l.opts.unevaluated&&d.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(o,(0,r.toHash)(d),l.props));const m=d.filter(h=>!(0,r.alwaysValidSchema)(l,i[h]));if(m.length===0)return;const _=o.name("valid");for(const h of m)p(h)?y(h):(o.if((0,e.propertyInData)(o,u,h,l.opts.ownProperties)),y(h),l.allErrors||o.else().var(_,!0),o.endIf()),a.it.definedProperties.add(h),a.ok(_);function p(h){return l.opts.useDefaults&&!l.compositeRule&&i[h].default!==void 0}function y(h){a.subschema({keyword:"properties",schemaProp:h,dataProp:h},_)}}};return is.default=s,is}var cs={},vc;function Yd(){if(vc)return cs;vc=1,Object.defineProperty(cs,"__esModule",{value:!0});const t=ht(),e=ie(),r=he(),n=he(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(a){const{gen:o,schema:i,data:c,parentSchema:u,it:l}=a,{opts:d}=l,m=(0,t.allSchemaProperties)(i),_=m.filter(b=>(0,r.alwaysValidSchema)(l,i[b]));if(m.length===0||_.length===m.length&&(!l.opts.unevaluated||l.props===!0))return;const p=d.strictSchema&&!d.allowMatchingProperties&&u.properties,y=o.name("valid");l.props!==!0&&!(l.props instanceof e.Name)&&(l.props=(0,n.evaluatedPropsToName)(o,l.props));const{props:h}=l;v();function v(){for(const b of m)p&&f(b),l.allErrors?g(b):(o.var(y,!0),g(b),o.if(y))}function f(b){for(const w in p)new RegExp(b).test(w)&&(0,r.checkStrictMode)(l,`property ${w} matches pattern ${b} (use allowMatchingProperties)`)}function g(b){o.forIn("key",c,w=>{o.if((0,e._)`${(0,t.usePattern)(a,b)}.test(${w})`,()=>{const k=_.includes(b);k||a.subschema({keyword:"patternProperties",schemaProp:b,dataProp:w,dataPropType:n.Type.Str},y),l.opts.unevaluated&&h!==!0?o.assign((0,e._)`${h}[${w}]`,!0):!k&&!l.allErrors&&o.if((0,e.not)(y),()=>o.break())})})}}};return cs.default=s,cs}var us={},wc;function Xd(){if(wc)return us;wc=1,Object.defineProperty(us,"__esModule",{value:!0});const t=he(),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 o=n.name("valid");r.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),r.failResult(o,()=>r.reset(),()=>r.error())},error:{message:"must NOT be valid"}};return us.default=e,us}var ls={},bc;function Qd(){if(bc)return ls;bc=1,Object.defineProperty(ls,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ht().validateUnion,error:{message:"must match a schema in anyOf"}};return ls.default=e,ls}var ds={},kc;function ef(){if(kc)return ds;kc=1,Object.defineProperty(ds,"__esModule",{value:!0});const t=ie(),e=he(),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:o,parentSchema:i,it:c}=s;if(!Array.isArray(o))throw new Error("ajv implementation error");if(c.opts.discriminator&&i.discriminator)return;const u=o,l=a.let("valid",!1),d=a.let("passing",null),m=a.name("_valid");s.setParams({passing:d}),a.block(_),s.result(l,()=>s.reset(),()=>s.error(!0));function _(){u.forEach((p,y)=>{let h;(0,e.alwaysValidSchema)(c,p)?a.var(m,!0):h=s.subschema({keyword:"oneOf",schemaProp:y,compositeRule:!0},m),y>0&&a.if((0,t._)`${m} && ${l}`).assign(l,!1).assign(d,(0,t._)`[${d}, ${y}]`).else(),a.if(m,()=>{a.assign(l,!0),a.assign(d,y),h&&s.mergeEvaluated(h,t.Name)})})}}};return ds.default=n,ds}var fs={},$c;function tf(){if($c)return fs;$c=1,Object.defineProperty(fs,"__esModule",{value:!0});const t=he(),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 o=n.name("valid");s.forEach((i,c)=>{if((0,t.alwaysValidSchema)(a,i))return;const u=r.subschema({keyword:"allOf",schemaProp:c},o);r.ok(o),r.mergeEvaluated(u)})}};return fs.default=e,fs}var hs={},Sc;function rf(){if(Sc)return hs;Sc=1,Object.defineProperty(hs,"__esModule",{value:!0});const t=ie(),e=he(),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:o,parentSchema:i,it:c}=a;i.then===void 0&&i.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 d=o.let("valid",!0),m=o.name("_valid");if(_(),a.reset(),u&&l){const y=o.let("ifClause");a.setParams({ifClause:y}),o.if(m,p("then",y),p("else",y))}else u?o.if(m,p("then")):o.if((0,t.not)(m),p("else"));a.pass(d,()=>a.error(!0));function _(){const y=a.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},m);a.mergeEvaluated(y)}function p(y,h){return()=>{const v=a.subschema({keyword:y},m);o.assign(d,m),a.mergeValidEvaluated(v,d),h?o.assign(h,(0,t._)`${y}`):a.setParams({ifClause:y})}}}};function s(a,o){const i=a.schema[o];return i!==void 0&&!(0,e.alwaysValidSchema)(a,i)}return hs.default=n,hs}var ps={},Tc;function nf(){if(Tc)return ps;Tc=1,Object.defineProperty(ps,"__esModule",{value:!0});const t=he(),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 ps.default=e,ps}var Ec;function sf(){if(Ec)return ts;Ec=1,Object.defineProperty(ts,"__esModule",{value:!0});const t=cc(),e=Hd(),r=lc(),n=Wd(),s=Kd(),a=Bd(),o=Jd(),i=gc(),c=Gd(),u=Yd(),l=Xd(),d=Qd(),m=ef(),_=tf(),p=rf(),y=nf();function h(v=!1){const f=[l.default,d.default,m.default,_.default,p.default,y.default,o.default,i.default,a.default,c.default,u.default];return v?f.push(e.default,n.default):f.push(t.default,r.default),f.push(s.default),f}return ts.default=h,ts}var ms={},_s={},Rc;function af(){if(Rc)return _s;Rc=1,Object.defineProperty(_s,"__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:o,$data:i,schema:c,schemaCode:u,it:l}=n,{opts:d,errSchemaPath:m,schemaEnv:_,self:p}=l;if(!d.validateFormats)return;i?y():h();function y(){const v=a.scopeValue("formats",{ref:p.formats,code:d.code.formats}),f=a.const("fDef",(0,t._)`${v}[${u}]`),g=a.let("fType"),b=a.let("format");a.if((0,t._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>a.assign(g,(0,t._)`${f}.type || "string"`).assign(b,(0,t._)`${f}.validate`),()=>a.assign(g,(0,t._)`"string"`).assign(b,f)),n.fail$data((0,t.or)(w(),k()));function w(){return d.strictSchema===!1?t.nil:(0,t._)`${u} && !${b}`}function k(){const S=_.$async?(0,t._)`(${f}.async ? await ${b}(${o}) : ${b}(${o}))`:(0,t._)`${b}(${o})`,C=(0,t._)`(typeof ${b} == "function" ? ${S} : ${b}.test(${o}))`;return(0,t._)`${b} && ${b} !== true && ${g} === ${s} && !${C}`}}function h(){const v=p.formats[c];if(!v){w();return}if(v===!0)return;const[f,g,b]=k(v);f===s&&n.pass(S());function w(){if(d.strictSchema===!1){p.logger.warn(C());return}throw new Error(C());function C(){return`unknown format "${c}" ignored in schema at path "${m}"`}}function k(C){const j=C instanceof RegExp?(0,t.regexpCode)(C):d.code.formats?(0,t._)`${d.code.formats}${(0,t.getProperty)(c)}`:void 0,D=a.scopeValue("formats",{key:c,ref:C,code:j});return typeof C=="object"&&!(C instanceof RegExp)?[C.type||"string",C.validate,(0,t._)`${D}.validate`]:["string",C,D]}function S(){if(typeof v=="object"&&!(v instanceof RegExp)&&v.async){if(!_.$async)throw new Error("async format in sync schema");return(0,t._)`await ${b}(${o})`}return typeof g=="function"?(0,t._)`${b}(${o})`:(0,t._)`${b}.test(${o})`}}}};return _s.default=r,_s}var Pc;function of(){if(Pc)return ms;Pc=1,Object.defineProperty(ms,"__esModule",{value:!0});const e=[af().default];return ms.default=e,ms}var rr={},xc;function cf(){return xc||(xc=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.contentVocabulary=rr.metadataVocabulary=void 0,rr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],rr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),rr}var Ic;function uf(){if(Ic)return Zn;Ic=1,Object.defineProperty(Zn,"__esModule",{value:!0});const t=Od(),e=Fd(),r=sf(),n=of(),s=cf(),a=[t.default,e.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return Zn.default=a,Zn}var gs={},qr={},Cc;function lf(){if(Cc)return qr;Cc=1,Object.defineProperty(qr,"__esModule",{value:!0}),qr.DiscrError=void 0;var t;return(function(e){e.Tag="tag",e.Mapping="mapping"})(t||(qr.DiscrError=t={})),qr}var Oc;function df(){if(Oc)return gs;Oc=1,Object.defineProperty(gs,"__esModule",{value:!0});const t=ie(),e=lf(),r=va(),n=zn(),s=he(),o={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:i,tagName:c}})=>i===e.DiscrError.Tag?`tag "${c}" must be string`:`value of tag "${c}" must be in oneOf`,params:({params:{discrError:i,tag:c,tagName:u}})=>(0,t._)`{error: ${i}, tag: ${u}, tagValue: ${c}}`},code(i){const{gen:c,data:u,schema:l,parentSchema:d,it:m}=i,{oneOf:_}=d;if(!m.opts.discriminator)throw new Error("discriminator: requires discriminator option");const p=l.propertyName;if(typeof p!="string")throw new Error("discriminator: requires propertyName");if(l.mapping)throw new Error("discriminator: mapping is not supported");if(!_)throw new Error("discriminator: requires oneOf keyword");const y=c.let("valid",!1),h=c.const("tag",(0,t._)`${u}${(0,t.getProperty)(p)}`);c.if((0,t._)`typeof ${h} == "string"`,()=>v(),()=>i.error(!1,{discrError:e.DiscrError.Tag,tag:h,tagName:p})),i.ok(y);function v(){const b=g();c.if(!1);for(const w in b)c.elseIf((0,t._)`${h} === ${w}`),c.assign(y,f(b[w]));c.else(),i.error(!1,{discrError:e.DiscrError.Mapping,tag:h,tagName:p}),c.endIf()}function f(b){const w=c.name("valid"),k=i.subschema({keyword:"oneOf",schemaProp:b},w);return i.mergeEvaluated(k,t.Name),w}function g(){var b;const w={},k=C(d);let S=!0;for(let A=0;A<_.length;A++){let V=_[A];if(V?.$ref&&!(0,s.schemaHasRulesButRef)(V,m.self.RULES)){const Y=V.$ref;if(V=r.resolveRef.call(m.self,m.schemaEnv.root,m.baseId,Y),V instanceof r.SchemaEnv&&(V=V.schema),V===void 0)throw new n.default(m.opts.uriResolver,m.baseId,Y)}const J=(b=V?.properties)===null||b===void 0?void 0:b[p];if(typeof J!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);S=S&&(k||C(V)),j(J,A)}if(!S)throw new Error(`discriminator: "${p}" must be required`);return w;function C({required:A}){return Array.isArray(A)&&A.includes(p)}function j(A,V){if(A.const)D(A.const,V);else if(A.enum)for(const J of A.enum)D(J,V);else throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`)}function D(A,V){if(typeof A!="string"||A in w)throw new Error(`discriminator: "${p}" values must be unique strings`);w[A]=V}}}};return gs.default=o,gs}const ff={$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 Nc;function Ac(){return Nc||(Nc=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=xd(),n=uf(),s=df(),a=ff,o=["/properties"],i="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(p=>this.addVocabulary(p)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const p=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(p,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var u=An();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 d=ya();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var m=zn();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Pn,Pn.exports)),Pn.exports}var hf=Ac();const jc=hr(hf),pf=Object.freeze({status:"aborted"});function O(t,e,r){function n(i,c){var u;Object.defineProperty(i,"_zod",{value:i._zod??{},enumerable:!1}),(u=i._zod).traits??(u.traits=new Set),i._zod.traits.add(t),e(i,c);for(const l in o.prototype)l in i||Object.defineProperty(i,l,{value:o.prototype[l].bind(i)});i._zod.constr=o,i._zod.def=c}const s=r?.Parent??Object;class a extends s{}Object.defineProperty(a,"name",{value:t});function o(i){var c;const u=r?.Parent?new a:this;n(u,i),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:i=>r?.Parent&&i instanceof r.Parent?!0:i?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class Zr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Mc={};function Ut(t){return Mc}function zc(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 mf(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 Ta(t){return t==null}function Ea(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function _f(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(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return a%o/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 Lr(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ur(t){return JSON.stringify(t)}const qc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function ys(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const gf=Sa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function vs(t){if(ys(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(ys(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const yf=new Set(["string","number","symbol"]);function Dr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dt(t,e,r){const n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function X(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 vf(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const wf={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 bf(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 Dt(t,{...t._zod.def,shape:r,checks:[]})}function kf(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 Dt(t,{...t._zod.def,shape:r,checks:[]})}function $f(t,e){if(!vs(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 Lr(this,"shape",n),n},checks:[]};return Dt(t,r)}function Sf(t,e){return Dt(t,{...t._zod.def,get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Lr(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function Tf(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 Dt(e,{...e._zod.def,shape:s,checks:[]})}function Ef(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 Dt(e,{...e._zod.def,shape:s,checks:[]})}function Vr(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function nr(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function ws(t){return typeof t=="string"?t:t?.message}function Vt(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=ws(t.inst?._zod.def?.error?.(t))??ws(e?.error?.(t))??ws(r.customError?.(t))??ws(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Ra(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Fr(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const Zc=(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,mf,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Lc=O("$ZodError",Zc),bs=O("$ZodError",Zc,{Parent:Error});function Rf(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 Pf(t,e){const r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(i=>s({issues:i}));else if(o.code==="invalid_key")s({issues:o.issues});else if(o.code==="invalid_element")s({issues:o.issues});else if(o.path.length===0)n._errors.push(r(o));else{let i=n,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(r(o))):i[u]=i[u]||{_errors:[]},i=i[u],c++}}};return s(t),n}const Uc=t=>(e,r,n,s)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new Zr;if(o.issues.length){const i=new(s?.Err??t)(o.issues.map(c=>Vt(c,a,Ut())));throw qc(i,s?.callee),i}return o.value},xf=Uc(bs),Dc=t=>async(e,r,n,s)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){const i=new(s?.Err??t)(o.issues.map(c=>Vt(c,a,Ut())));throw qc(i,s?.callee),i}return o.value},If=Dc(bs),Vc=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 Zr;return a.issues.length?{success:!1,error:new(t??Lc)(a.issues.map(o=>Vt(o,s,Ut())))}:{success:!0,data:a.value}},Pa=Vc(bs),Fc=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(o=>Vt(o,s,Ut())))}:{success:!0,data:a.value}},xa=Fc(bs),Cf=/^[cC][^\s-]{8,}$/,Of=/^[0-9a-z]+$/,Nf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Af=/^[0-9a-vA-V]{20}$/,jf=/^[A-Za-z0-9]{27}$/,Mf=/^[a-zA-Z0-9_-]{21}$/,zf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qf=/^([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})$/,Hc=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)$/,Zf=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Lf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Uf(){return new RegExp(Lf,"u")}const Df=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Vf=/^(([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})$/,Ff=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Hf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wc=/^[A-Za-z0-9_-]*$/,Kf=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Bf=/^\+(?:[0-9]){6,14}[0-9]$/,Kc="(?:(?:\\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])))",Jf=new RegExp(`^${Kc}$`);function Bc(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 Gf(t){return new RegExp(`^${Bc(t)}$`)}function Yf(t){const e=Bc({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(`^${Kc}T(?:${n})$`)}const Xf=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Qf=/^\d+$/,eh=/^-?\d+(?:\.\d+)?/i,th=/true|false/i,rh=/null/i,nh=/^[^A-Z]*$/,sh=/^[^a-z]*$/,Xe=O("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Jc={number:"number",bigint:"bigint",object:"date"},Gc=O("$ZodCheckLessThan",(t,e)=>{Xe.init(t,e);const r=Jc[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})}}),Yc=O("$ZodCheckGreaterThan",(t,e)=>{Xe.init(t,e);const r=Jc[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})}}),ah=O("$ZodCheckMultipleOf",(t,e)=>{Xe.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):_f(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})}}),oh=O("$ZodCheckNumberFormat",(t,e)=>{Xe.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,a]=wf[e.format];t._zod.onattach.push(o=>{const i=o._zod.bag;i.format=e.format,i.minimum=s,i.maximum=a,r&&(i.pattern=Qf)}),t._zod.check=o=>{const i=o.value;if(r){if(!Number.isInteger(i)){o.issues.push({expected:n,format:e.format,code:"invalid_type",input:i,inst:t});return}if(!Number.isSafeInteger(i)){i>0?o.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):o.issues.push({input:i,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}}i<s&&o.issues.push({origin:"number",input:i,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),i>a&&o.issues.push({origin:"number",input:i,code:"too_big",maximum:a,inst:t})}}),ih=O("$ZodCheckMaxLength",(t,e)=>{var r;Xe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ta(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 o=Ra(s);n.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),ch=O("$ZodCheckMinLength",(t,e)=>{var r;Xe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ta(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 o=Ra(s);n.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),uh=O("$ZodCheckLengthEquals",(t,e)=>{var r;Xe.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!Ta(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 o=Ra(s),i=a>e.length;n.issues.push({origin:o,...i?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),ks=O("$ZodCheckStringFormat",(t,e)=>{var r,n;Xe.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=()=>{})}),lh=O("$ZodCheckRegex",(t,e)=>{ks.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})}}),dh=O("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=nh),ks.init(t,e)}),fh=O("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=sh),ks.init(t,e)}),hh=O("$ZodCheckIncludes",(t,e)=>{Xe.init(t,e);const r=Dr(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})}}),ph=O("$ZodCheckStartsWith",(t,e)=>{Xe.init(t,e);const r=new RegExp(`^${Dr(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})}}),mh=O("$ZodCheckEndsWith",(t,e)=>{Xe.init(t,e);const r=new RegExp(`.*${Dr(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})}}),_h=O("$ZodCheckOverwrite",(t,e)=>{Xe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class gh{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(o=>o),s=Math.min(...n.map(o=>o.length-o.trimStart().length)),a=n.map(o=>o.slice(s)).map(o=>" ".repeat(this.indent*2)+o);for(const o of a)this.content.push(o)}compile(){const e=Function,r=this?.args,s=[...(this?.content??[""]).map(a=>` ${a}`)];return new e(...r,s.join(`
10
+ `))}}const yh={major:4,minor:0,patch:0},ke=O("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=yh;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,o,i)=>{let c=Vr(a),u;for(const l of o){if(l._zod.def.when){if(!l._zod.def.when(a))continue}else if(c)continue;const d=a.issues.length,m=l._zod.check(a);if(m instanceof Promise&&i?.async===!1)throw new Zr;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,a.issues.length!==d&&(c||(c=Vr(a,d)))});else{if(a.issues.length===d)continue;c||(c=Vr(a,d))}}return u?u.then(()=>a):a};t._zod.run=(a,o)=>{const i=t._zod.parse(a,o);if(i instanceof Promise){if(o.async===!1)throw new Zr;return i.then(c=>s(c,n,o))}return s(i,n,o)}}t["~standard"]={validate:s=>{try{const a=Pa(t,s);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return xa(t,s).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}}),Ia=O("$ZodString",(t,e)=>{ke.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Xf(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=O("$ZodStringFormat",(t,e)=>{ks.init(t,e),Ia.init(t,e)}),vh=O("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=qf),Re.init(t,e)}),wh=O("$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=Hc(n))}else e.pattern??(e.pattern=Hc());Re.init(t,e)}),bh=O("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Zf),Re.init(t,e)}),kh=O("$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:Kf.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})}}}),$h=O("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Uf()),Re.init(t,e)}),Sh=O("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Mf),Re.init(t,e)}),Th=O("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Cf),Re.init(t,e)}),Eh=O("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Of),Re.init(t,e)}),Rh=O("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Nf),Re.init(t,e)}),Ph=O("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Af),Re.init(t,e)}),xh=O("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=jf),Re.init(t,e)}),Ih=O("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Yf(e)),Re.init(t,e)}),Ch=O("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Jf),Re.init(t,e)}),Oh=O("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Gf(e)),Re.init(t,e)}),Nh=O("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=zf),Re.init(t,e)}),Ah=O("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Df),Re.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),jh=O("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Vf),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})}}}),Mh=O("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Ff),Re.init(t,e)}),zh=O("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Hf),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 Xc(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const qh=O("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Wf),Re.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{Xc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Zh(t){if(!Wc.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xc(r)}const Lh=O("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Wc),Re.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{Zh(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Uh=O("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Bf),Re.init(t,e)});function Dh(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 Vh=O("$ZodJWT",(t,e)=>{Re.init(t,e),t._zod.check=r=>{Dh(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),Qc=O("$ZodNumber",(t,e)=>{ke.init(t,e),t._zod.pattern=t._zod.bag.pattern??eh,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}}),Fh=O("$ZodNumber",(t,e)=>{oh.init(t,e),Qc.init(t,e)}),Hh=O("$ZodBoolean",(t,e)=>{ke.init(t,e),t._zod.pattern=th,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}}),Wh=O("$ZodNull",(t,e)=>{ke.init(t,e),t._zod.pattern=rh,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}}),Kh=O("$ZodAny",(t,e)=>{ke.init(t,e),t._zod.parse=r=>r}),Bh=O("$ZodUnknown",(t,e)=>{ke.init(t,e),t._zod.parse=r=>r}),Jh=O("$ZodNever",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function eu(t,e,r){t.issues.length&&e.issues.push(...nr(r,t.issues)),e.value[r]=t.value}const Gh=O("$ZodArray",(t,e)=>{ke.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 o=0;o<s.length;o++){const i=s[o],c=e.element._zod.run({value:i,issues:[]},n);c instanceof Promise?a.push(c.then(u=>eu(u,r,o))):eu(c,r,o)}return a.length?Promise.all(a).then(()=>r):r}});function $s(t,e,r){t.issues.length&&e.issues.push(...nr(r,t.issues)),e.value[r]=t.value}function tu(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(...nr(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}const ru=O("$ZodObject",(t,e)=>{ke.init(t,e);const r=Sa(()=>{const d=Object.keys(e.shape);for(const _ of d)if(!(e.shape[_]instanceof ke))throw new Error(`Invalid element at key "${_}": expected a Zod schema`);const m=vf(e.shape);return{shape:e.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(m)}});Se(t._zod,"propValues",()=>{const d=e.shape,m={};for(const _ in d){const p=d[_]._zod;if(p.values){m[_]??(m[_]=new Set);for(const y of p.values)m[_].add(y)}}return m});const n=d=>{const m=new gh(["shape","payload","ctx"]),_=r.value,p=f=>{const g=Ur(f);return`shape[${g}]._zod.run({ value: input[${g}], issues: [] }, ctx)`};m.write("const input = payload.value;");const y=Object.create(null);let h=0;for(const f of _.keys)y[f]=`key_${h++}`;m.write("const newResult = {}");for(const f of _.keys)if(_.optionalKeys.has(f)){const g=y[f];m.write(`const ${g} = ${p(f)};`);const b=Ur(f);m.write(`
11
+ if (${g}.issues.length) {
12
+ if (input[${b}] === undefined) {
13
+ if (${b} in input) {
14
+ newResult[${b}] = undefined;
15
15
  }
16
16
  } else {
17
17
  payload.issues = payload.issues.concat(
18
- ${w}.issues.map((iss) => ({
18
+ ${g}.issues.map((iss) => ({
19
19
  ...iss,
20
- path: iss.path ? [${S}, ...iss.path] : [${S}],
20
+ path: iss.path ? [${b}, ...iss.path] : [${b}],
21
21
  }))
22
22
  );
23
23
  }
24
- } else if (${w}.value === undefined) {
25
- if (${S} in input) newResult[${S}] = undefined;
24
+ } else if (${g}.value === undefined) {
25
+ if (${b} in input) newResult[${b}] = undefined;
26
26
  } else {
27
- newResult[${S}] = ${w}.value;
27
+ newResult[${b}] = ${g}.value;
28
28
  }
29
- `)}else{const w=v[m];_.write(`const ${w} = ${g(m)};`),_.write(`
30
- if (${w}.issues.length) payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
29
+ `)}else{const g=y[f];m.write(`const ${g} = ${p(f)};`),m.write(`
30
+ if (${g}.issues.length) payload.issues = payload.issues.concat(${g}.issues.map(iss => ({
31
31
  ...iss,
32
- path: iss.path ? [${nn(m)}, ...iss.path] : [${nn(m)}]
33
- })));`),_.write(`newResult[${nn(m)}] = ${w}.value`)}_.write("payload.value = newResult;"),_.write("return payload;");const d=_.compile();return(m,w)=>d(f,m,w)};let s;const o=ls,i=!pu.jitless,c=i&&f_.value,u=e.catchall;let l;t._zod.parse=(f,_)=>{l??(l=r.value);const y=f.value;if(!o(y))return f.issues.push({expected:"object",code:"invalid_type",input:y,inst:t}),f;const g=[];if(i&&c&&(_==null?void 0:_.async)===!1&&_.jitless!==!0)s||(s=n(e.shape)),f=s(f,_);else{f.value={};const w=l.shape;for(const S of l.keys){const P=w[S],O=P._zod.run({value:y[S],issues:[]},_),V=P._zod.optin==="optional"&&P._zod.optout==="optional";O instanceof Promise?g.push(O.then(ce=>V?Nu(ce,f,S,y):ms(ce,f,S))):V?Nu(O,f,S,y):ms(O,f,S)}}if(!u)return g.length?Promise.all(g).then(()=>f):f;const v=[],h=l.keySet,d=u._zod,m=d.def.type;for(const w of Object.keys(y)){if(h.has(w))continue;if(m==="never"){v.push(w);continue}const S=d.run({value:y[w],issues:[]},_);S instanceof Promise?g.push(S.then(P=>ms(P,f,w))):ms(S,f,w)}return v.length&&f.issues.push({code:"unrecognized_keys",keys:v,input:y,inst:t}),g.length?Promise.all(g).then(()=>f):f}});function Au(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(o=>Wt(o,n,Ft())))}),e}const zu=T("$ZodUnion",(t,e)=>{ge.init(t,e),_e(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),_e(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),_e(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),_e(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=>li(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1;const o=[];for(const i of e.options){const a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}return s?Promise.all(o).then(i=>Au(i,r,t,n)):Au(o,r,t,n)}}),Fg=T("$ZodDiscriminatedUnion",(t,e)=>{zu.init(t,e);const r=t._zod.parse;_e(t._zod,"propValues",()=>{const s={};for(const o of e.options){const i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(const u of c)s[a].add(u)}}return s});const n=ci(()=>{const s=e.options,o=new Map;for(const i of s){const a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(const c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});t._zod.parse=(s,o)=>{const i=s.value;if(!ls(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),s;const a=n.value.get(i==null?void 0:i[e.discriminator]);return a?a._zod.run(s,o):e.unionFallback?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),s)}}),Hg=T("$ZodIntersection",(t,e)=>{ge.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,o=e.left._zod.run({value:s,issues:[]},n),i=e.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,u])=>Mu(r,c,u)):Mu(r,o,i)}});function mi(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(ds(t)&&ds(e)){const r=Object.keys(e),n=Object.keys(t).filter(o=>r.indexOf(o)!==-1),s={...t,...e};for(const o of n){const i=mi(t[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=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],o=e[n],i=mi(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Mu(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),on(t))return t;const n=mi(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 Wg=T("$ZodRecord",(t,e)=>{ge.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!ds(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;const o=[];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?o.push(u.then(l=>{l.issues.length&&r.issues.push(...ar(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...ar(c,u.issues)),r.value[c]=u.value)}let a;for(const c in s)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:a})}else{r.value={};for(const i of Reflect.ownKeys(s)){if(i==="__proto__")continue;const a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>Wt(u,n,Ft())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}const c=e.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?o.push(c.then(u=>{u.issues.length&&r.issues.push(...ar(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...ar(i,c.issues)),r.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>r):r}}),Jg=T("$ZodEnum",(t,e)=>{ge.init(t,e);const r=mu(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>h_.has(typeof n)).map(n=>typeof n=="string"?sn(n):n.toString()).join("|")})$`),t._zod.parse=(n,s)=>{const o=n.value;return t._zod.values.has(o)||n.issues.push({code:"invalid_value",values:r,input:o,inst:t}),n}}),Bg=T("$ZodLiteral",(t,e)=>{ge.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?sn(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}}),Kg=T("$ZodTransform",(t,e)=>{ge.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 tn;return r.value=s,r}}),Gg=T("$ZodOptional",(t,e)=>{ge.init(t,e),t._zod.optin="optional",t._zod.optout="optional",_e(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),_e(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${li(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)}),Yg=T("$ZodNullable",(t,e)=>{ge.init(t,e),_e(t._zod,"optin",()=>e.innerType._zod.optin),_e(t._zod,"optout",()=>e.innerType._zod.optout),_e(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${li(r.source)}|null)$`):void 0}),_e(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)}),Xg=T("$ZodDefault",(t,e)=>{ge.init(t,e),t._zod.optin="optional",_e(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(o=>Zu(o,e)):Zu(s,e)}});function Zu(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const Qg=T("$ZodPrefault",(t,e)=>{ge.init(t,e),t._zod.optin="optional",_e(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))}),ev=T("$ZodNonOptional",(t,e)=>{ge.init(t,e),_e(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(o=>Lu(o,t)):Lu(s,t)}});function Lu(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 tv=T("$ZodCatch",(t,e)=>{ge.init(t,e),t._zod.optin="optional",_e(t._zod,"optout",()=>e.innerType._zod.optout),_e(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(o=>(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(i=>Wt(i,n,Ft()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(o=>Wt(o,n,Ft()))},input:r.value}),r.issues=[]),r)}}),rv=T("$ZodPipe",(t,e)=>{ge.init(t,e),_e(t._zod,"values",()=>e.in._zod.values),_e(t._zod,"optin",()=>e.in._zod.optin),_e(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(o=>Uu(o,e,n)):Uu(s,e,n)}});function Uu(t,e,r){return on(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}const nv=T("$ZodReadonly",(t,e)=>{ge.init(t,e),_e(t._zod,"propValues",()=>e.innerType._zod.propValues),_e(t._zod,"values",()=>e.innerType._zod.values),_e(t._zod,"optin",()=>e.innerType._zod.optin),_e(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(Du):Du(s)}});function Du(t){return t.value=Object.freeze(t.value),t}const sv=T("$ZodCustom",(t,e)=>{Ke.init(t,e),ge.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(o=>qu(o,r,n,t));qu(s,r,n,t)}});function qu(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(an(s))}}class Vu{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 ov(){return new Vu}const cn=ov();function iv(t,e){return new t({type:"string",...D(e)})}function av(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...D(e)})}function Fu(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...D(e)})}function cv(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...D(e)})}function uv(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(e)})}function lv(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(e)})}function dv(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(e)})}function Hu(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...D(e)})}function fv(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...D(e)})}function hv(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(e)})}function pv(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...D(e)})}function mv(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(e)})}function _v(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...D(e)})}function gv(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...D(e)})}function vv(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(e)})}function yv(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(e)})}function bv(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(e)})}function wv(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(e)})}function $v(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(e)})}function Sv(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...D(e)})}function kv(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...D(e)})}function Ev(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...D(e)})}function Pv(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...D(e)})}function Tv(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(e)})}function xv(t,e){return new t({type:"string",format:"date",check:"string_format",...D(e)})}function Rv(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...D(e)})}function Iv(t,e){return new t({type:"string",format:"duration",check:"string_format",...D(e)})}function Cv(t,e){return new t({type:"number",checks:[],...D(e)})}function Ov(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...D(e)})}function Nv(t,e){return new t({type:"boolean",...D(e)})}function jv(t){return new t({type:"any"})}function Av(t){return new t({type:"unknown"})}function zv(t,e){return new t({type:"never",...D(e)})}function Wu(t,e){return new xu({check:"less_than",...D(e),value:t,inclusive:!1})}function _i(t,e){return new xu({check:"less_than",...D(e),value:t,inclusive:!0})}function Ju(t,e){return new Ru({check:"greater_than",...D(e),value:t,inclusive:!1})}function gi(t,e){return new Ru({check:"greater_than",...D(e),value:t,inclusive:!0})}function Bu(t,e){return new Q_({check:"multiple_of",...D(e),value:t})}function Ku(t,e){return new tg({check:"max_length",...D(e),maximum:t})}function _s(t,e){return new rg({check:"min_length",...D(e),minimum:t})}function Gu(t,e){return new ng({check:"length_equals",...D(e),length:t})}function Mv(t,e){return new sg({check:"string_format",format:"regex",...D(e),pattern:t})}function Zv(t){return new og({check:"string_format",format:"lowercase",...D(t)})}function Lv(t){return new ig({check:"string_format",format:"uppercase",...D(t)})}function Uv(t,e){return new ag({check:"string_format",format:"includes",...D(e),includes:t})}function Dv(t,e){return new cg({check:"string_format",format:"starts_with",...D(e),prefix:t})}function qv(t,e){return new ug({check:"string_format",format:"ends_with",...D(e),suffix:t})}function un(t){return new lg({check:"overwrite",tx:t})}function Vv(t){return un(e=>e.normalize(t))}function Fv(){return un(t=>t.trim())}function Hv(){return un(t=>t.toLowerCase())}function Wv(){return un(t=>t.toUpperCase())}function Jv(t,e,r){return new t({type:"array",element:e,...D(r)})}function Bv(t,e,r){const n=D(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Kv(t,e,r){return new t({type:"custom",check:"custom",fn:e,...D(r)})}class Yu{constructor(e){this.counter=0,this.metadataRegistry=(e==null?void 0:e.metadata)??cn,this.target=(e==null?void 0:e.target)??"draft-2020-12",this.unrepresentable=(e==null?void 0:e.unrepresentable)??"throw",this.override=(e==null?void 0:e.override)??(()=>{}),this.io=(e==null?void 0:e.io)??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var f,_,y;var n;const s=e._zod.def,o={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 a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);const c=(_=(f=e._zod).toJSONSchema)==null?void 0:_.call(f);if(c)a.schema=c;else{const g={...r,schemaPath:[...r.schemaPath,e],path:r.path},v=e._zod.parent;if(v)a.ref=v,this.process(v,g),this.seen.get(v).isParent=!0;else{const h=a.schema;switch(s.type){case"string":{const d=h;d.type="string";const{minimum:m,maximum:w,format:S,patterns:P,contentEncoding:O}=e._zod.bag;if(typeof m=="number"&&(d.minLength=m),typeof w=="number"&&(d.maxLength=w),S&&(d.format=o[S]??S,d.format===""&&delete d.format),O&&(d.contentEncoding=O),P&&P.size>0){const V=[...P];V.length===1?d.pattern=V[0].source:V.length>1&&(a.schema.allOf=[...V.map(ce=>({...this.target==="draft-7"?{type:"string"}:{},pattern:ce.source}))])}break}case"number":{const d=h,{minimum:m,maximum:w,format:S,multipleOf:P,exclusiveMaximum:O,exclusiveMinimum:V}=e._zod.bag;typeof S=="string"&&S.includes("int")?d.type="integer":d.type="number",typeof V=="number"&&(d.exclusiveMinimum=V),typeof m=="number"&&(d.minimum=m,typeof V=="number"&&(V>=m?delete d.minimum:delete d.exclusiveMinimum)),typeof O=="number"&&(d.exclusiveMaximum=O),typeof w=="number"&&(d.maximum=w,typeof O=="number"&&(O<=w?delete d.maximum:delete d.exclusiveMaximum)),typeof P=="number"&&(d.multipleOf=P);break}case"boolean":{const d=h;d.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":{h.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":{h.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const d=h,{minimum:m,maximum:w}=e._zod.bag;typeof m=="number"&&(d.minItems=m),typeof w=="number"&&(d.maxItems=w),d.type="array",d.items=this.process(s.element,{...g,path:[...g.path,"items"]});break}case"object":{const d=h;d.type="object",d.properties={};const m=s.shape;for(const P in m)d.properties[P]=this.process(m[P],{...g,path:[...g.path,"properties",P]});const w=new Set(Object.keys(m)),S=new Set([...w].filter(P=>{const O=s.shape[P]._zod;return this.io==="input"?O.optin===void 0:O.optout===void 0}));S.size>0&&(d.required=Array.from(S)),((y=s.catchall)==null?void 0:y._zod.def.type)==="never"?d.additionalProperties=!1:s.catchall?s.catchall&&(d.additionalProperties=this.process(s.catchall,{...g,path:[...g.path,"additionalProperties"]})):this.io==="output"&&(d.additionalProperties=!1);break}case"union":{const d=h;d.anyOf=s.options.map((m,w)=>this.process(m,{...g,path:[...g.path,"anyOf",w]}));break}case"intersection":{const d=h,m=this.process(s.left,{...g,path:[...g.path,"allOf",0]}),w=this.process(s.right,{...g,path:[...g.path,"allOf",1]}),S=O=>"allOf"in O&&Object.keys(O).length===1,P=[...S(m)?m.allOf:[m],...S(w)?w.allOf:[w]];d.allOf=P;break}case"tuple":{const d=h;d.type="array";const m=s.items.map((P,O)=>this.process(P,{...g,path:[...g.path,"prefixItems",O]}));if(this.target==="draft-2020-12"?d.prefixItems=m:d.items=m,s.rest){const P=this.process(s.rest,{...g,path:[...g.path,"items"]});this.target==="draft-2020-12"?d.items=P:d.additionalItems=P}s.rest&&(d.items=this.process(s.rest,{...g,path:[...g.path,"items"]}));const{minimum:w,maximum:S}=e._zod.bag;typeof w=="number"&&(d.minItems=w),typeof S=="number"&&(d.maxItems=S);break}case"record":{const d=h;d.type="object",d.propertyNames=this.process(s.keyType,{...g,path:[...g.path,"propertyNames"]}),d.additionalProperties=this.process(s.valueType,{...g,path:[...g.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 d=h,m=mu(s.entries);m.every(w=>typeof w=="number")&&(d.type="number"),m.every(w=>typeof w=="string")&&(d.type="string"),d.enum=m;break}case"literal":{const d=h,m=[];for(const w of s.values)if(w===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof w=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");m.push(Number(w))}else m.push(w);if(m.length!==0)if(m.length===1){const w=m[0];d.type=w===null?"null":typeof w,d.const=w}else m.every(w=>typeof w=="number")&&(d.type="number"),m.every(w=>typeof w=="string")&&(d.type="string"),m.every(w=>typeof w=="boolean")&&(d.type="string"),m.every(w=>w===null)&&(d.type="null"),d.enum=m;break}case"file":{const d=h,m={type:"string",format:"binary",contentEncoding:"binary"},{minimum:w,maximum:S,mime:P}=e._zod.bag;w!==void 0&&(m.minLength=w),S!==void 0&&(m.maxLength=S),P?P.length===1?(m.contentMediaType=P[0],Object.assign(d,m)):d.anyOf=P.map(O=>({...m,contentMediaType:O})):Object.assign(d,m);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const d=this.process(s.innerType,g);h.anyOf=[d,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,g),a.ref=s.innerType;break}case"success":{const d=h;d.type="boolean";break}case"default":{this.process(s.innerType,g),a.ref=s.innerType,h.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,g),a.ref=s.innerType,this.io==="input"&&(h._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,g),a.ref=s.innerType;let d;try{d=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}h.default=d;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const d=h,m=e._zod.pattern;if(!m)throw new Error("Pattern not found in template literal");d.type="string",d.pattern=m.source;break}case"pipe":{const d=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(d,g),a.ref=d;break}case"readonly":{this.process(s.innerType,g),a.ref=s.innerType,h.readOnly=!0;break}case"promise":{this.process(s.innerType,g),a.ref=s.innerType;break}case"optional":{this.process(s.innerType,g),a.ref=s.innerType;break}case"lazy":{const d=e._zod.innerType;this.process(d,g),a.ref=d;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(a.schema,u),this.io==="input"&&Ne(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){var l,f,_,y,g,v;const n={cycles:(r==null?void 0:r.cycles)??"ref",reused:(r==null?void 0:r.reused)??"inline",external:(r==null?void 0:r.external)??void 0},s=this.seen.get(e);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=h=>{var P;const d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const O=(P=n.external.registry.get(h[0]))==null?void 0:P.id,V=n.external.uri??(G=>G);if(O)return{ref:V(O)};const ce=h[1].defId??h[1].schema.id??`schema${this.counter++}`;return h[1].defId=ce,{defId:ce,ref:`${V("__shared")}#/${d}/${ce}`}}if(h[1]===s)return{ref:"#"};const w=`#/${d}/`,S=h[1].schema.id??`__schema${this.counter++}`;return{defId:S,ref:w+S}},i=h=>{if(h[1].schema.$ref)return;const d=h[1],{ref:m,defId:w}=o(h);d.def={...d.schema},w&&(d.defId=w);const S=d.schema;for(const P in S)delete S[P];S.$ref=m};if(n.cycles==="throw")for(const h of this.seen.entries()){const d=h[1];if(d.cycle)throw new Error(`Cycle detected: #/${(l=d.cycle)==null?void 0:l.join("/")}/<root>
32
+ path: iss.path ? [${Ur(f)}, ...iss.path] : [${Ur(f)}]
33
+ })));`),m.write(`newResult[${Ur(f)}] = ${g}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");const v=m.compile();return(f,g)=>v(d,f,g)};let s;const a=ys,o=!Mc.jitless,c=o&&gf.value,u=e.catchall;let l;t._zod.parse=(d,m)=>{l??(l=r.value);const _=d.value;if(!a(_))return d.issues.push({expected:"object",code:"invalid_type",input:_,inst:t}),d;const p=[];if(o&&c&&m?.async===!1&&m.jitless!==!0)s||(s=n(e.shape)),d=s(d,m);else{d.value={};const g=l.shape;for(const b of l.keys){const w=g[b],k=w._zod.run({value:_[b],issues:[]},m),S=w._zod.optin==="optional"&&w._zod.optout==="optional";k instanceof Promise?p.push(k.then(C=>S?tu(C,d,b,_):$s(C,d,b))):S?tu(k,d,b,_):$s(k,d,b)}}if(!u)return p.length?Promise.all(p).then(()=>d):d;const y=[],h=l.keySet,v=u._zod,f=v.def.type;for(const g of Object.keys(_)){if(h.has(g))continue;if(f==="never"){y.push(g);continue}const b=v.run({value:_[g],issues:[]},m);b instanceof Promise?p.push(b.then(w=>$s(w,d,g))):$s(b,d,g)}return y.length&&d.issues.push({code:"unrecognized_keys",keys:y,input:_,inst:t}),p.length?Promise.all(p).then(()=>d):d}});function nu(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=>Vt(a,n,Ut())))}),e}const su=O("$ZodUnion",(t,e)=>{ke.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=>Ea(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let s=!1;const a=[];for(const o of e.options){const i=o._zod.run({value:r.value,issues:[]},n);if(i instanceof Promise)a.push(i),s=!0;else{if(i.issues.length===0)return i;a.push(i)}}return s?Promise.all(a).then(o=>nu(o,r,t,n)):nu(a,r,t,n)}}),Yh=O("$ZodDiscriminatedUnion",(t,e)=>{su.init(t,e);const r=t._zod.parse;Se(t._zod,"propValues",()=>{const s={};for(const a of e.options){const o=a._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(a)}"`);for(const[i,c]of Object.entries(o)){s[i]||(s[i]=new Set);for(const u of c)s[i].add(u)}}return s});const n=Sa(()=>{const s=e.options,a=new Map;for(const o of s){const i=o._zod.propValues[e.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const c of i){if(a.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);a.set(c,o)}}return a});t._zod.parse=(s,a)=>{const o=s.value;if(!ys(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),s;const i=n.value.get(o?.[e.discriminator]);return i?i._zod.run(s,a):e.unionFallback?r(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[e.discriminator],inst:t}),s)}}),Xh=O("$ZodIntersection",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{const s=r.value,a=e.left._zod.run({value:s,issues:[]},n),o=e.right._zod.run({value:s,issues:[]},n);return a instanceof Promise||o instanceof Promise?Promise.all([a,o]).then(([c,u])=>au(r,c,u)):au(r,a,o)}});function Ca(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(vs(t)&&vs(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 o=Ca(t[a],e[a]);if(!o.valid)return{valid:!1,mergeErrorPath:[a,...o.mergeErrorPath]};s[a]=o.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],o=Ca(s,a);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function au(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Vr(t))return t;const n=Ca(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 Qh=O("$ZodRecord",(t,e)=>{ke.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!vs(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:t}),r;const a=[];if(e.keyType._zod.values){const o=e.keyType._zod.values;r.value={};for(const c of o)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(...nr(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...nr(c,u.issues)),r.value[c]=u.value)}let i;for(const c in s)o.has(c)||(i=i??[],i.push(c));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:t,keys:i})}else{r.value={};for(const o of Reflect.ownKeys(s)){if(o==="__proto__")continue;const i=e.keyType._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(u=>Vt(u,n,Ut())),input:o,path:[o],inst:t}),r.value[i.value]=i.value;continue}const c=e.valueType._zod.run({value:s[o],issues:[]},n);c instanceof Promise?a.push(c.then(u=>{u.issues.length&&r.issues.push(...nr(o,u.issues)),r.value[i.value]=u.value})):(c.issues.length&&r.issues.push(...nr(o,c.issues)),r.value[i.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),ep=O("$ZodEnum",(t,e)=>{ke.init(t,e);const r=zc(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>yf.has(typeof n)).map(n=>typeof n=="string"?Dr(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}}),tp=O("$ZodLiteral",(t,e)=>{ke.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Dr(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}}),rp=O("$ZodTransform",(t,e)=>{ke.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(o=>(r.value=o,r));if(s instanceof Promise)throw new Zr;return r.value=s,r}}),np=O("$ZodOptional",(t,e)=>{ke.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(`^(${Ea(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)}),sp=O("$ZodNullable",(t,e)=>{ke.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(`^(${Ea(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)}),ap=O("$ZodDefault",(t,e)=>{ke.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=>ou(a,e)):ou(s,e)}});function ou(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const op=O("$ZodPrefault",(t,e)=>{ke.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))}),ip=O("$ZodNonOptional",(t,e)=>{ke.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=>iu(a,t)):iu(s,t)}});function iu(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 cp=O("$ZodCatch",(t,e)=>{ke.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(o=>Vt(o,n,Ut()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(a=>Vt(a,n,Ut()))},input:r.value}),r.issues=[]),r)}}),up=O("$ZodPipe",(t,e)=>{ke.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=>cu(a,e,n)):cu(s,e,n)}});function cu(t,e,r){return Vr(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}const lp=O("$ZodReadonly",(t,e)=>{ke.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(uu):uu(s)}});function uu(t){return t.value=Object.freeze(t.value),t}const dp=O("$ZodCustom",(t,e)=>{Xe.init(t,e),ke.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=>lu(a,r,n,t));lu(s,r,n,t)}});function lu(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(Fr(s))}}class du{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 fp(){return new du}const Hr=fp();function hp(t,e){return new t({type:"string",...X(e)})}function pp(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...X(e)})}function fu(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...X(e)})}function mp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...X(e)})}function _p(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...X(e)})}function gp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...X(e)})}function yp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...X(e)})}function hu(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...X(e)})}function vp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...X(e)})}function wp(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...X(e)})}function bp(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...X(e)})}function kp(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...X(e)})}function $p(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...X(e)})}function Sp(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...X(e)})}function Tp(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...X(e)})}function Ep(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...X(e)})}function Rp(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...X(e)})}function Pp(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...X(e)})}function xp(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...X(e)})}function Ip(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...X(e)})}function Cp(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...X(e)})}function Op(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...X(e)})}function Np(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...X(e)})}function Ap(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...X(e)})}function jp(t,e){return new t({type:"string",format:"date",check:"string_format",...X(e)})}function Mp(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...X(e)})}function zp(t,e){return new t({type:"string",format:"duration",check:"string_format",...X(e)})}function qp(t,e){return new t({type:"number",checks:[],...X(e)})}function Zp(t,e){return new t({type:"number",coerce:!0,checks:[],...X(e)})}function Lp(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...X(e)})}function Up(t,e){return new t({type:"boolean",...X(e)})}function Dp(t,e){return new t({type:"null",...X(e)})}function Vp(t){return new t({type:"any"})}function Fp(t){return new t({type:"unknown"})}function Hp(t,e){return new t({type:"never",...X(e)})}function pu(t,e){return new Gc({check:"less_than",...X(e),value:t,inclusive:!1})}function Oa(t,e){return new Gc({check:"less_than",...X(e),value:t,inclusive:!0})}function mu(t,e){return new Yc({check:"greater_than",...X(e),value:t,inclusive:!1})}function Na(t,e){return new Yc({check:"greater_than",...X(e),value:t,inclusive:!0})}function _u(t,e){return new ah({check:"multiple_of",...X(e),value:t})}function gu(t,e){return new ih({check:"max_length",...X(e),maximum:t})}function Ss(t,e){return new ch({check:"min_length",...X(e),minimum:t})}function yu(t,e){return new uh({check:"length_equals",...X(e),length:t})}function Wp(t,e){return new lh({check:"string_format",format:"regex",...X(e),pattern:t})}function Kp(t){return new dh({check:"string_format",format:"lowercase",...X(t)})}function Bp(t){return new fh({check:"string_format",format:"uppercase",...X(t)})}function Jp(t,e){return new hh({check:"string_format",format:"includes",...X(e),includes:t})}function Gp(t,e){return new ph({check:"string_format",format:"starts_with",...X(e),prefix:t})}function Yp(t,e){return new mh({check:"string_format",format:"ends_with",...X(e),suffix:t})}function Wr(t){return new _h({check:"overwrite",tx:t})}function Xp(t){return Wr(e=>e.normalize(t))}function Qp(){return Wr(t=>t.trim())}function em(){return Wr(t=>t.toLowerCase())}function tm(){return Wr(t=>t.toUpperCase())}function rm(t,e,r){return new t({type:"array",element:e,...X(r)})}function nm(t,e,r){const n=X(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function sm(t,e,r){return new t({type:"custom",check:"custom",fn:e,...X(r)})}class vu{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Hr,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:""},o=this.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;const i={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,i);const c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{const d={...r,schemaPath:[...r.schemaPath,e],path:r.path},m=e._zod.parent;if(m)i.ref=m,this.process(m,d),this.seen.get(m).isParent=!0;else{const _=i.schema;switch(s.type){case"string":{const p=_;p.type="string";const{minimum:y,maximum:h,format:v,patterns:f,contentEncoding:g}=e._zod.bag;if(typeof y=="number"&&(p.minLength=y),typeof h=="number"&&(p.maxLength=h),v&&(p.format=a[v]??v,p.format===""&&delete p.format),g&&(p.contentEncoding=g),f&&f.size>0){const b=[...f];b.length===1?p.pattern=b[0].source:b.length>1&&(i.schema.allOf=[...b.map(w=>({...this.target==="draft-7"?{type:"string"}:{},pattern:w.source}))])}break}case"number":{const p=_,{minimum:y,maximum:h,format:v,multipleOf:f,exclusiveMaximum:g,exclusiveMinimum:b}=e._zod.bag;typeof v=="string"&&v.includes("int")?p.type="integer":p.type="number",typeof b=="number"&&(p.exclusiveMinimum=b),typeof y=="number"&&(p.minimum=y,typeof b=="number"&&(b>=y?delete p.minimum:delete p.exclusiveMinimum)),typeof g=="number"&&(p.exclusiveMaximum=g),typeof h=="number"&&(p.maximum=h,typeof g=="number"&&(g<=h?delete p.maximum:delete p.exclusiveMaximum)),typeof f=="number"&&(p.multipleOf=f);break}case"boolean":{const p=_;p.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":{_.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":{_.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const p=_,{minimum:y,maximum:h}=e._zod.bag;typeof y=="number"&&(p.minItems=y),typeof h=="number"&&(p.maxItems=h),p.type="array",p.items=this.process(s.element,{...d,path:[...d.path,"items"]});break}case"object":{const p=_;p.type="object",p.properties={};const y=s.shape;for(const f in y)p.properties[f]=this.process(y[f],{...d,path:[...d.path,"properties",f]});const h=new Set(Object.keys(y)),v=new Set([...h].filter(f=>{const g=s.shape[f]._zod;return this.io==="input"?g.optin===void 0:g.optout===void 0}));v.size>0&&(p.required=Array.from(v)),s.catchall?._zod.def.type==="never"?p.additionalProperties=!1:s.catchall?s.catchall&&(p.additionalProperties=this.process(s.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{const p=_;p.anyOf=s.options.map((y,h)=>this.process(y,{...d,path:[...d.path,"anyOf",h]}));break}case"intersection":{const p=_,y=this.process(s.left,{...d,path:[...d.path,"allOf",0]}),h=this.process(s.right,{...d,path:[...d.path,"allOf",1]}),v=g=>"allOf"in g&&Object.keys(g).length===1,f=[...v(y)?y.allOf:[y],...v(h)?h.allOf:[h]];p.allOf=f;break}case"tuple":{const p=_;p.type="array";const y=s.items.map((f,g)=>this.process(f,{...d,path:[...d.path,"prefixItems",g]}));if(this.target==="draft-2020-12"?p.prefixItems=y:p.items=y,s.rest){const f=this.process(s.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?p.items=f:p.additionalItems=f}s.rest&&(p.items=this.process(s.rest,{...d,path:[...d.path,"items"]}));const{minimum:h,maximum:v}=e._zod.bag;typeof h=="number"&&(p.minItems=h),typeof v=="number"&&(p.maxItems=v);break}case"record":{const p=_;p.type="object",p.propertyNames=this.process(s.keyType,{...d,path:[...d.path,"propertyNames"]}),p.additionalProperties=this.process(s.valueType,{...d,path:[...d.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 p=_,y=zc(s.entries);y.every(h=>typeof h=="number")&&(p.type="number"),y.every(h=>typeof h=="string")&&(p.type="string"),p.enum=y;break}case"literal":{const p=_,y=[];for(const h of s.values)if(h===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof h=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");y.push(Number(h))}else y.push(h);if(y.length!==0)if(y.length===1){const h=y[0];p.type=h===null?"null":typeof h,p.const=h}else y.every(h=>typeof h=="number")&&(p.type="number"),y.every(h=>typeof h=="string")&&(p.type="string"),y.every(h=>typeof h=="boolean")&&(p.type="string"),y.every(h=>h===null)&&(p.type="null"),p.enum=y;break}case"file":{const p=_,y={type:"string",format:"binary",contentEncoding:"binary"},{minimum:h,maximum:v,mime:f}=e._zod.bag;h!==void 0&&(y.minLength=h),v!==void 0&&(y.maxLength=v),f?f.length===1?(y.contentMediaType=f[0],Object.assign(p,y)):p.anyOf=f.map(g=>({...y,contentMediaType:g})):Object.assign(p,y);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const p=this.process(s.innerType,d);_.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,d),i.ref=s.innerType;break}case"success":{const p=_;p.type="boolean";break}case"default":{this.process(s.innerType,d),i.ref=s.innerType,_.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,d),i.ref=s.innerType,this.io==="input"&&(_._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,d),i.ref=s.innerType;let p;try{p=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}_.default=p;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const p=_,y=e._zod.pattern;if(!y)throw new Error("Pattern not found in template literal");p.type="string",p.pattern=y.source;break}case"pipe":{const p=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(p,d),i.ref=p;break}case"readonly":{this.process(s.innerType,d),i.ref=s.innerType,_.readOnly=!0;break}case"promise":{this.process(s.innerType,d),i.ref=s.innerType;break}case"optional":{this.process(s.innerType,d),i.ref=s.innerType;break}case"lazy":{const p=e._zod.innerType;this.process(p,d),i.ref=p;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(i.schema,u),this.io==="input"&&je(e)&&(delete i.schema.examples,delete i.schema.default),this.io==="input"&&i.schema._prefault&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.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 d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const y=n.external.registry.get(l[0])?.id,h=n.external.uri??(f=>f);if(y)return{ref:h(y)};const v=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=v,{defId:v,ref:`${h("__shared")}#/${d}/${v}`}}if(l[1]===s)return{ref:"#"};const _=`#/${d}/`,p=l[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:_+p}},o=l=>{if(l[1].schema.$ref)return;const d=l[1],{ref:m,defId:_}=a(l);d.def={...d.schema},_&&(d.defId=_);const p=d.schema;for(const y in p)delete p[y];p.$ref=m};if(n.cycles==="throw")for(const l of this.seen.entries()){const d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
34
34
 
35
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of this.seen.entries()){const d=h[1];if(e===h[0]){i(h);continue}if(n.external){const w=(f=n.external.registry.get(h[0]))==null?void 0:f.id;if(e!==h[0]&&w){i(h);continue}}if((_=this.metadataRegistry.get(h[0]))==null?void 0:_.id){i(h);continue}if(d.cycle){i(h);continue}if(d.count>1&&n.reused==="ref"){i(h);continue}}const a=(h,d)=>{const m=this.seen.get(h),w=m.def??m.schema,S={...w};if(m.ref===null)return;const P=m.ref;if(m.ref=null,P){a(P,d);const O=this.seen.get(P).schema;O.$ref&&d.target==="draft-7"?(w.allOf=w.allOf??[],w.allOf.push(O)):(Object.assign(w,O),Object.assign(w,S))}m.isParent||this.override({zodSchema:h,jsonSchema:w,path:m.path??[]})};for(const h of[...this.seen.entries()].reverse())a(h[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}`),(y=n.external)!=null&&y.uri){const h=(g=n.external.registry.get(e))==null?void 0:g.id;if(!h)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(h)}Object.assign(c,s.def);const u=((v=n.external)==null?void 0:v.defs)??{};for(const h of this.seen.entries()){const d=h[1];d.def&&d.defId&&(u[d.defId]=d.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 Gv(t,e){if(t instanceof Vu){const n=new Yu(e),s={};for(const a of t._idmap.entries()){const[c,u]=a;n.process(u)}const o={},i={registry:t,uri:e==null?void 0:e.uri,defs:s};for(const a of t._idmap.entries()){const[c,u]=a;o[c]=n.emit(u,{...e,external:i})}if(Object.keys(s).length>0){const a=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[a]:s}}return{schemas:o}}const r=new Yu(e);return r.process(t),r.emit(t,e)}function Ne(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 Ne(s.element,r);case"object":{for(const o in s.shape)if(Ne(s.shape[o],r))return!0;return!1}case"union":{for(const o of s.options)if(Ne(o,r))return!0;return!1}case"intersection":return Ne(s.left,r)||Ne(s.right,r);case"tuple":{for(const o of s.items)if(Ne(o,r))return!0;return!!(s.rest&&Ne(s.rest,r))}case"record":return Ne(s.keyType,r)||Ne(s.valueType,r);case"map":return Ne(s.keyType,r)||Ne(s.valueType,r);case"set":return Ne(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ne(s.innerType,r);case"lazy":return Ne(s.getter(),r);case"default":return Ne(s.innerType,r);case"prefault":return Ne(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ne(s.in,r)||Ne(s.out,r);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}const Yv=T("ZodISODateTime",(t,e)=>{kg.init(t,e),Ee.init(t,e)});function Xv(t){return Tv(Yv,t)}const Qv=T("ZodISODate",(t,e)=>{Eg.init(t,e),Ee.init(t,e)});function ey(t){return xv(Qv,t)}const ty=T("ZodISOTime",(t,e)=>{Pg.init(t,e),Ee.init(t,e)});function ry(t){return Rv(ty,t)}const ny=T("ZodISODuration",(t,e)=>{Tg.init(t,e),Ee.init(t,e)});function sy(t){return Iv(ny,t)}const gs=T("ZodError",(t,e)=>{vu.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>S_(t,r)},flatten:{value:r=>$_(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}),oy=yu(gs),iy=bu(gs),ay=wu(gs),cy=$u(gs),ke=T("ZodType",(t,e)=>(ge.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)=>Ht(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t),t.parse=(r,n)=>oy(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>ay(t,r,n),t.parseAsync=async(r,n)=>iy(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>cy(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(e0(r,n)),t.superRefine=r=>t.check(t0(r)),t.overwrite=r=>t.check(un(r)),t.optional=()=>re(t),t.nullable=()=>al(t),t.nullish=()=>re(al(t)),t.nonoptional=r=>Wy(t,r),t.array=()=>j(t),t.or=r=>Te([t,r]),t.and=r=>vi(t,r),t.transform=r=>bi(t,ol(r)),t.default=r=>Vy(t,r),t.prefault=r=>Hy(t,r),t.catch=r=>By(t,r),t.pipe=r=>bi(t,r),t.readonly=()=>Yy(t),t.describe=r=>{const n=t.clone();return cn.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){var r;return(r=cn.get(t))==null?void 0:r.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return cn.get(t);const n=t.clone();return cn.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Xu=T("_ZodString",(t,e)=>{pi.init(t,e),ke.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(Mv(...n)),t.includes=(...n)=>t.check(Uv(...n)),t.startsWith=(...n)=>t.check(Dv(...n)),t.endsWith=(...n)=>t.check(qv(...n)),t.min=(...n)=>t.check(_s(...n)),t.max=(...n)=>t.check(Ku(...n)),t.length=(...n)=>t.check(Gu(...n)),t.nonempty=(...n)=>t.check(_s(1,...n)),t.lowercase=n=>t.check(Zv(n)),t.uppercase=n=>t.check(Lv(n)),t.trim=()=>t.check(Fv()),t.normalize=(...n)=>t.check(Vv(...n)),t.toLowerCase=()=>t.check(Hv()),t.toUpperCase=()=>t.check(Wv())}),uy=T("ZodString",(t,e)=>{pi.init(t,e),Xu.init(t,e),t.email=r=>t.check(av(ly,r)),t.url=r=>t.check(Hu(el,r)),t.jwt=r=>t.check(Pv(Py,r)),t.emoji=r=>t.check(fv(fy,r)),t.guid=r=>t.check(Fu(Qu,r)),t.uuid=r=>t.check(cv(vs,r)),t.uuidv4=r=>t.check(uv(vs,r)),t.uuidv6=r=>t.check(lv(vs,r)),t.uuidv7=r=>t.check(dv(vs,r)),t.nanoid=r=>t.check(hv(hy,r)),t.guid=r=>t.check(Fu(Qu,r)),t.cuid=r=>t.check(pv(py,r)),t.cuid2=r=>t.check(mv(my,r)),t.ulid=r=>t.check(_v(_y,r)),t.base64=r=>t.check(Sv(Sy,r)),t.base64url=r=>t.check(kv(ky,r)),t.xid=r=>t.check(gv(gy,r)),t.ksuid=r=>t.check(vv(vy,r)),t.ipv4=r=>t.check(yv(yy,r)),t.ipv6=r=>t.check(bv(by,r)),t.cidrv4=r=>t.check(wv(wy,r)),t.cidrv6=r=>t.check($v($y,r)),t.e164=r=>t.check(Ev(Ey,r)),t.datetime=r=>t.check(Xv(r)),t.date=r=>t.check(ey(r)),t.time=r=>t.check(ry(r)),t.duration=r=>t.check(sy(r))});function $(t){return iv(uy,t)}const Ee=T("ZodStringFormat",(t,e)=>{ye.init(t,e),Xu.init(t,e)}),ly=T("ZodEmail",(t,e)=>{mg.init(t,e),Ee.init(t,e)}),Qu=T("ZodGUID",(t,e)=>{hg.init(t,e),Ee.init(t,e)}),vs=T("ZodUUID",(t,e)=>{pg.init(t,e),Ee.init(t,e)}),el=T("ZodURL",(t,e)=>{_g.init(t,e),Ee.init(t,e)});function dy(t){return Hu(el,t)}const fy=T("ZodEmoji",(t,e)=>{gg.init(t,e),Ee.init(t,e)}),hy=T("ZodNanoID",(t,e)=>{vg.init(t,e),Ee.init(t,e)}),py=T("ZodCUID",(t,e)=>{yg.init(t,e),Ee.init(t,e)}),my=T("ZodCUID2",(t,e)=>{bg.init(t,e),Ee.init(t,e)}),_y=T("ZodULID",(t,e)=>{wg.init(t,e),Ee.init(t,e)}),gy=T("ZodXID",(t,e)=>{$g.init(t,e),Ee.init(t,e)}),vy=T("ZodKSUID",(t,e)=>{Sg.init(t,e),Ee.init(t,e)}),yy=T("ZodIPv4",(t,e)=>{xg.init(t,e),Ee.init(t,e)}),by=T("ZodIPv6",(t,e)=>{Rg.init(t,e),Ee.init(t,e)}),wy=T("ZodCIDRv4",(t,e)=>{Ig.init(t,e),Ee.init(t,e)}),$y=T("ZodCIDRv6",(t,e)=>{Cg.init(t,e),Ee.init(t,e)}),Sy=T("ZodBase64",(t,e)=>{Og.init(t,e),Ee.init(t,e)}),ky=T("ZodBase64URL",(t,e)=>{jg.init(t,e),Ee.init(t,e)}),Ey=T("ZodE164",(t,e)=>{Ag.init(t,e),Ee.init(t,e)}),Py=T("ZodJWT",(t,e)=>{Mg.init(t,e),Ee.init(t,e)}),tl=T("ZodNumber",(t,e)=>{Cu.init(t,e),ke.init(t,e),t.gt=(n,s)=>t.check(Ju(n,s)),t.gte=(n,s)=>t.check(gi(n,s)),t.min=(n,s)=>t.check(gi(n,s)),t.lt=(n,s)=>t.check(Wu(n,s)),t.lte=(n,s)=>t.check(_i(n,s)),t.max=(n,s)=>t.check(_i(n,s)),t.int=n=>t.check(rl(n)),t.safe=n=>t.check(rl(n)),t.positive=n=>t.check(Ju(0,n)),t.nonnegative=n=>t.check(gi(0,n)),t.negative=n=>t.check(Wu(0,n)),t.nonpositive=n=>t.check(_i(0,n)),t.multipleOf=(n,s)=>t.check(Bu(n,s)),t.step=(n,s)=>t.check(Bu(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 be(t){return Cv(tl,t)}const Ty=T("ZodNumberFormat",(t,e)=>{Zg.init(t,e),tl.init(t,e)});function rl(t){return Ov(Ty,t)}const xy=T("ZodBoolean",(t,e)=>{Lg.init(t,e),ke.init(t,e)});function we(t){return Nv(xy,t)}const Ry=T("ZodAny",(t,e)=>{Ug.init(t,e),ke.init(t,e)});function Iy(){return jv(Ry)}const Cy=T("ZodUnknown",(t,e)=>{Dg.init(t,e),ke.init(t,e)});function Re(){return Av(Cy)}const Oy=T("ZodNever",(t,e)=>{qg.init(t,e),ke.init(t,e)});function Ny(t){return zv(Oy,t)}const jy=T("ZodArray",(t,e)=>{Vg.init(t,e),ke.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(_s(r,n)),t.nonempty=r=>t.check(_s(1,r)),t.max=(r,n)=>t.check(Ku(r,n)),t.length=(r,n)=>t.check(Gu(r,n)),t.unwrap=()=>t.element});function j(t,e){return Jv(jy,t,e)}const nl=T("ZodObject",(t,e)=>{ju.init(t,e),ke.init(t,e),_e(t,"shape",()=>e.shape),t.keyof=()=>lt(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Re()}),t.loose=()=>t.clone({...t._zod.def,catchall:Re()}),t.strict=()=>t.clone({...t._zod.def,catchall:Ny()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>v_(t,r),t.merge=r=>y_(t,r),t.pick=r=>__(t,r),t.omit=r=>g_(t,r),t.partial=(...r)=>b_(il,t,r[0]),t.required=(...r)=>w_(cl,t,r[0])});function z(t,e){const r={type:"object",get shape(){return rn(this,"shape",{...t}),this.shape},...D(e)};return new nl(r)}function ut(t,e){return new nl({type:"object",get shape(){return rn(this,"shape",{...t}),this.shape},catchall:Re(),...D(e)})}const sl=T("ZodUnion",(t,e)=>{zu.init(t,e),ke.init(t,e),t.options=e.options});function Te(t,e){return new sl({type:"union",options:t,...D(e)})}const Ay=T("ZodDiscriminatedUnion",(t,e)=>{sl.init(t,e),Fg.init(t,e)});function zy(t,e,r){return new Ay({type:"union",options:e,discriminator:t,...D(r)})}const My=T("ZodIntersection",(t,e)=>{Hg.init(t,e),ke.init(t,e)});function vi(t,e){return new My({type:"intersection",left:t,right:e})}const Zy=T("ZodRecord",(t,e)=>{Wg.init(t,e),ke.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Ie(t,e,r){return new Zy({type:"record",keyType:t,valueType:e,...D(r)})}const yi=T("ZodEnum",(t,e)=>{Jg.init(t,e),ke.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 o={};for(const i of n)if(r.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new yi({...e,checks:[],...D(s),entries:o})},t.exclude=(n,s)=>{const o={...e.entries};for(const i of n)if(r.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new yi({...e,checks:[],...D(s),entries:o})}});function lt(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new yi({type:"enum",entries:r,...D(e)})}const Ly=T("ZodLiteral",(t,e)=>{Bg.init(t,e),ke.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 W(t,e){return new Ly({type:"literal",values:Array.isArray(t)?t:[t],...D(e)})}const Uy=T("ZodTransform",(t,e)=>{Kg.init(t,e),ke.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=o=>{if(typeof o=="string")r.issues.push(an(o,r.value,e));else{const i=o;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(an(i))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});function ol(t){return new Uy({type:"transform",transform:t})}const il=T("ZodOptional",(t,e)=>{Gg.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function re(t){return new il({type:"optional",innerType:t})}const Dy=T("ZodNullable",(t,e)=>{Yg.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function al(t){return new Dy({type:"nullable",innerType:t})}const qy=T("ZodDefault",(t,e)=>{Xg.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Vy(t,e){return new qy({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const Fy=T("ZodPrefault",(t,e)=>{Qg.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Hy(t,e){return new Fy({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const cl=T("ZodNonOptional",(t,e)=>{ev.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Wy(t,e){return new cl({type:"nonoptional",innerType:t,...D(e)})}const Jy=T("ZodCatch",(t,e)=>{tv.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function By(t,e){return new Jy({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const Ky=T("ZodPipe",(t,e)=>{rv.init(t,e),ke.init(t,e),t.in=e.in,t.out=e.out});function bi(t,e){return new Ky({type:"pipe",in:t,out:e})}const Gy=T("ZodReadonly",(t,e)=>{nv.init(t,e),ke.init(t,e)});function Yy(t){return new Gy({type:"readonly",innerType:t})}const ul=T("ZodCustom",(t,e)=>{sv.init(t,e),ke.init(t,e)});function Xy(t){const e=new Ke({check:"custom"});return e._zod.check=t,e}function Qy(t,e){return Bv(ul,t??(()=>!0),e)}function e0(t,e={}){return Kv(ul,t,e)}function t0(t){const e=Xy(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(an(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(an(s))}},t(r.value,r)));return e}function r0(t,e){return bi(ol(t),e)}const n0={custom:"custom"},ln="2025-06-18",ll=[ln,"2025-03-26","2024-11-05","2024-10-07"],ys="2.0",kt=Qy(t=>t!==null&&(typeof t=="object"||typeof t=="function")),dl=Te([$(),be().int()]),fl=$(),s0=ut({progressToken:dl.optional()}),dt=ut({_meta:s0.optional()}),Ge=z({method:$(),params:dt.optional()}),Tr=ut({_meta:Ie($(),Re()).optional()}),ft=z({method:$(),params:Tr.optional()}),nt=ut({_meta:Ie($(),Re()).optional()}),bs=Te([$(),be().int()]),hl=z({jsonrpc:W(ys),id:bs,...Ge.shape}).strict(),pl=t=>hl.safeParse(t).success,ml=z({jsonrpc:W(ys),...ft.shape}).strict(),o0=t=>ml.safeParse(t).success,_l=z({jsonrpc:W(ys),id:bs,result:nt}).strict(),wi=t=>_l.safeParse(t).success;var ie;(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"})(ie||(ie={}));const gl=z({jsonrpc:W(ys),id:bs,error:z({code:be().int(),message:$(),data:re(Re())})}).strict(),i0=t=>gl.safeParse(t).success,cr=Te([hl,ml,_l,gl]),Jt=nt.strict(),a0=Tr.extend({requestId:bs,reason:$().optional()}),$i=ft.extend({method:W("notifications/cancelled"),params:a0}),c0=z({src:$(),mimeType:$().optional(),sizes:j($()).optional()}),dn=z({icons:j(c0).optional()}),xr=z({name:$(),title:$().optional()}),vl=xr.extend({...xr.shape,...dn.shape,version:$(),websiteUrl:$().optional()}),u0=vi(z({applyDefaults:we().optional()}),Ie($(),Re())),l0=r0(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,vi(z({form:u0.optional(),url:kt.optional()}),Ie($(),Re()).optional())),d0=z({experimental:Ie($(),kt).optional(),sampling:z({context:kt.optional(),tools:kt.optional()}).optional(),elicitation:l0.optional(),roots:z({listChanged:we().optional()}).optional()}),f0=dt.extend({protocolVersion:$(),capabilities:d0,clientInfo:vl}),yl=Ge.extend({method:W("initialize"),params:f0}),h0=z({experimental:Ie($(),kt).optional(),logging:kt.optional(),completions:kt.optional(),prompts:re(z({listChanged:re(we())})),resources:z({subscribe:we().optional(),listChanged:we().optional()}).optional(),tools:z({listChanged:we().optional()}).optional()}),bl=nt.extend({protocolVersion:$(),capabilities:h0,serverInfo:vl,instructions:$().optional()}),Si=ft.extend({method:W("notifications/initialized")}),p0=t=>Si.safeParse(t).success,ki=Ge.extend({method:W("ping")}),m0=z({progress:be(),total:re(be()),message:re($())}),_0=z({...Tr.shape,...m0.shape,progressToken:dl}),Ei=ft.extend({method:W("notifications/progress"),params:_0}),g0=dt.extend({cursor:fl.optional()}),ws=Ge.extend({params:g0.optional()}),$s=nt.extend({nextCursor:re(fl)}),wl=z({uri:$(),mimeType:re($()),_meta:Ie($(),Re()).optional()}),$l=wl.extend({text:$()}),Pi=$().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Sl=wl.extend({blob:Pi}),kl=z({...xr.shape,...dn.shape,uri:$(),description:re($()),mimeType:re($()),_meta:re(ut({}))}),v0=z({...xr.shape,...dn.shape,uriTemplate:$(),description:re($()),mimeType:re($()),_meta:re(ut({}))}),Ss=ws.extend({method:W("resources/list")}),El=$s.extend({resources:j(kl)}),Ti=ws.extend({method:W("resources/templates/list")}),Pl=$s.extend({resourceTemplates:j(v0)}),xi=dt.extend({uri:$()}),y0=xi,Ri=Ge.extend({method:W("resources/read"),params:y0}),Tl=nt.extend({contents:j(Te([$l,Sl]))}),xl=ft.extend({method:W("notifications/resources/list_changed")}),b0=xi,Rl=Ge.extend({method:W("resources/subscribe"),params:b0}),w0=xi,Il=Ge.extend({method:W("resources/unsubscribe"),params:w0}),$0=Tr.extend({uri:$()}),Cl=ft.extend({method:W("notifications/resources/updated"),params:$0}),S0=z({name:$(),description:re($()),required:re(we())}),k0=z({...xr.shape,...dn.shape,description:re($()),arguments:re(j(S0)),_meta:re(ut({}))}),Ii=ws.extend({method:W("prompts/list")}),Ol=$s.extend({prompts:j(k0)}),E0=dt.extend({name:$(),arguments:Ie($(),$()).optional()}),Ci=Ge.extend({method:W("prompts/get"),params:E0}),Nl=z({type:W("text"),text:$(),_meta:Ie($(),Re()).optional()}),jl=z({type:W("image"),data:Pi,mimeType:$(),_meta:Ie($(),Re()).optional()}),Al=z({type:W("audio"),data:Pi,mimeType:$(),_meta:Ie($(),Re()).optional()}),P0=z({type:W("tool_use"),name:$(),id:$(),input:z({}).passthrough(),_meta:re(z({}).passthrough())}).passthrough(),T0=z({type:W("resource"),resource:Te([$l,Sl]),_meta:Ie($(),Re()).optional()}),x0=kl.extend({type:W("resource_link")}),Oi=Te([Nl,jl,Al,x0,T0]),R0=z({role:lt(["user","assistant"]),content:Oi}),zl=nt.extend({description:re($()),messages:j(R0)}),Ml=ft.extend({method:W("notifications/prompts/list_changed")}),I0=z({title:$().optional(),readOnlyHint:we().optional(),destructiveHint:we().optional(),idempotentHint:we().optional(),openWorldHint:we().optional()}),Zl=z({...xr.shape,...dn.shape,description:$().optional(),inputSchema:z({type:W("object"),properties:Ie($(),kt).optional(),required:j($()).optional()}).catchall(Re()),outputSchema:z({type:W("object"),properties:Ie($(),kt).optional(),required:j($()).optional()}).catchall(Re()).optional(),annotations:re(I0),_meta:Ie($(),Re()).optional()}),Ni=ws.extend({method:W("tools/list")}),Ll=$s.extend({tools:j(Zl)}),ks=nt.extend({content:j(Oi).default([]),structuredContent:Ie($(),Re()).optional(),isError:re(we())});ks.or(nt.extend({toolResult:Re()}));const C0=dt.extend({name:$(),arguments:re(Ie($(),Re()))}),ji=Ge.extend({method:W("tools/call"),params:C0}),Ul=ft.extend({method:W("notifications/tools/list_changed")}),Es=lt(["debug","info","notice","warning","error","critical","alert","emergency"]),O0=dt.extend({level:Es}),Ps=Ge.extend({method:W("logging/setLevel"),params:O0}),N0=Tr.extend({level:Es,logger:$().optional(),data:Re()}),Dl=ft.extend({method:W("notifications/message"),params:N0}),j0=z({name:$().optional()}),A0=z({hints:re(j(j0)),costPriority:re(be().min(0).max(1)),speedPriority:re(be().min(0).max(1)),intelligencePriority:re(be().min(0).max(1))}),z0=z({mode:re(lt(["auto","required","none"]))}),M0=z({type:W("tool_result"),toolUseId:$().describe("The unique identifier for the corresponding tool call."),content:j(Oi).default([]),structuredContent:z({}).passthrough().optional(),isError:re(we()),_meta:re(z({}).passthrough())}).passthrough(),Ts=zy("type",[Nl,jl,Al,P0,M0]),Z0=z({role:lt(["user","assistant"]),content:Te([Ts,j(Ts)]),_meta:re(z({}).passthrough())}).passthrough(),L0=dt.extend({messages:j(Z0),modelPreferences:A0.optional(),systemPrompt:$().optional(),includeContext:lt(["none","thisServer","allServers"]).optional(),temperature:be().optional(),maxTokens:be().int(),stopSequences:j($()).optional(),metadata:kt.optional(),tools:re(j(Zl)),toolChoice:re(z0)}),ql=Ge.extend({method:W("sampling/createMessage"),params:L0}),Ai=nt.extend({model:$(),stopReason:re(lt(["endTurn","stopSequence","maxTokens","toolUse"]).or($())),role:lt(["user","assistant"]),content:Te([Ts,j(Ts)])}),U0=z({type:W("boolean"),title:$().optional(),description:$().optional(),default:we().optional()}),D0=z({type:W("string"),title:$().optional(),description:$().optional(),minLength:be().optional(),maxLength:be().optional(),format:lt(["email","uri","date","date-time"]).optional(),default:$().optional()}),q0=z({type:lt(["number","integer"]),title:$().optional(),description:$().optional(),minimum:be().optional(),maximum:be().optional(),default:be().optional()}),V0=z({type:W("string"),title:$().optional(),description:$().optional(),enum:j($()),default:$().optional()}),F0=z({type:W("string"),title:$().optional(),description:$().optional(),oneOf:j(z({const:$(),title:$()})),default:$().optional()}),H0=z({type:W("string"),title:$().optional(),description:$().optional(),enum:j($()),enumNames:j($()).optional(),default:$().optional()}),W0=Te([V0,F0]),J0=z({type:W("array"),title:$().optional(),description:$().optional(),minItems:be().optional(),maxItems:be().optional(),items:z({type:W("string"),enum:j($())}),default:j($()).optional()}),B0=z({type:W("array"),title:$().optional(),description:$().optional(),minItems:be().optional(),maxItems:be().optional(),items:z({anyOf:j(z({const:$(),title:$()}))}),default:j($()).optional()}),K0=Te([J0,B0]),G0=Te([H0,W0,K0]),Y0=Te([G0,U0,D0,q0]),X0=dt.extend({mode:W("form").optional(),message:$(),requestedSchema:z({type:W("object"),properties:Ie($(),Y0),required:j($()).optional()})}),Q0=dt.extend({mode:W("url"),message:$(),elicitationId:$(),url:$().url()}),eb=Te([X0,Q0]),zi=Ge.extend({method:W("elicitation/create"),params:eb}),tb=Tr.extend({elicitationId:$()}),rb=ft.extend({method:W("notifications/elicitation/complete"),params:tb}),fn=nt.extend({action:lt(["accept","decline","cancel"]),content:Ie($(),Te([$(),be(),we(),j($())])).optional()}),nb=z({type:W("ref/resource"),uri:$()}),sb=z({type:W("ref/prompt"),name:$()}),ob=dt.extend({ref:Te([sb,nb]),argument:z({name:$(),value:$()}),context:z({arguments:Ie($(),$()).optional()}).optional()}),Mi=Ge.extend({method:W("completion/complete"),params:ob});function ib(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function ab(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}const Vl=nt.extend({completion:ut({values:j($()).max(100),total:re(be().int()),hasMore:re(we())})}),cb=z({uri:$().startsWith("file://"),name:$().optional(),_meta:Ie($(),Re()).optional()}),Fl=Ge.extend({method:W("roots/list")}),Zi=nt.extend({roots:j(cb)}),Hl=ft.extend({method:W("notifications/roots/list_changed")});Te([ki,yl,Mi,Ps,Ci,Ii,Ss,Ti,Ri,Rl,Il,ji,Ni]),Te([$i,Ei,Si,Hl]),Te([Jt,Ai,fn,Zi]),Te([ki,ql,zi,Fl]),Te([$i,Ei,Dl,Cl,xl,Ul,Ml,rb]),Te([Jt,bl,Vl,zl,Ol,El,Pl,Tl,ks,Ll]);class ae 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===ie.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new ub(s.elicitations,r)}return new ae(e,r,n)}}class ub extends ae{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(ie.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){var e,r;return(r=(e=this.data)===null||e===void 0?void 0:e.elicitations)!==null&&r!==void 0?r:[]}}var oe;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const o={};for(const i of s)o[i]=i;return o},t.getValidEnumValues=s=>{const o=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(const a of o)i[a]=s[a];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const o=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(const i of s)if(o(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,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(oe||(oe={}));var Li;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Li||(Li={}));const Z=oe.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 Z.undefined;case"string":return Z.string;case"number":return Number.isNaN(t)?Z.nan:Z.number;case"boolean":return Z.boolean;case"function":return Z.function;case"bigint":return Z.bigint;case"symbol":return Z.symbol;case"object":return Array.isArray(t)?Z.array:t===null?Z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Z.promise:typeof Map<"u"&&t instanceof Map?Z.map:typeof Set<"u"&&t instanceof Set?Z.set:typeof Date<"u"&&t instanceof Date?Z.date:Z.object;default:return Z.unknown}},I=oe.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"]),lb=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class et 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(o){return o.message},n={_errors:[]},s=o=>{for(const i of o.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 a=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof et))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,oe.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 o=s.path[0];r[o]=r[o]||[],r[o].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}et.create=t=>new et(t);const Rr=(t,e)=>{let r;switch(t.code){case I.invalid_type:t.received===Z.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case I.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,oe.jsonStringifyReplacer)}`;break;case I.unrecognized_keys:r=`Unrecognized key(s) in object: ${oe.joinValues(t.keys,", ")}`;break;case I.invalid_union:r="Invalid input";break;case I.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${oe.joinValues(t.options)}`;break;case I.invalid_enum_value:r=`Invalid enum value. Expected ${oe.joinValues(t.options)}, received '${t.received}'`;break;case I.invalid_arguments:r="Invalid function arguments";break;case I.invalid_return_type:r="Invalid function return type";break;case I.invalid_date:r="Invalid date";break;case I.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}"`:oe.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case I.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 I.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 I.custom:r="Invalid input";break;case I.invalid_intersection_types:r="Intersection results could not be merged";break;case I.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case I.not_finite:r="Number must be finite";break;default:r=e.defaultError,oe.assertNever(t)}return{message:r}};let Wl=Rr;function db(t){Wl=t}function xs(){return Wl}const Rs=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,o=[...r,...s.path||[]],i={...s,path:o};if(s.message!==void 0)return{...s,path:o,message:s.message};let a="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)a=u(i,{data:e,defaultError:a}).message;return{...s,path:o,message:a}},fb=[];function A(t,e){const r=xs(),n=Rs({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Rr?void 0:Rr].filter(s=>!!s)});t.common.issues.push(n)}class Ve{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 J;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 o=await s.key,i=await s.value;n.push({key:o,value:i})}return Ve.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return J;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[o.value]=i.value)}return{status:e.value,value:n}}}const J=Object.freeze({status:"aborted"}),Ir=t=>({status:"dirty",value:t}),He=t=>({status:"valid",value:t}),Ui=t=>t.status==="aborted",Di=t=>t.status==="dirty",ur=t=>t.status==="valid",hn=t=>typeof Promise<"u"&&t instanceof Promise;var L;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(L||(L={}));class Et{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 Jl=(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 et(t.common.issues);return this._error=r,this._error}}};function Y(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,a)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}class ee{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 Ve,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(hn(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==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nt(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Jl(n,s)}"~validate"(e){var n,s;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 o=this._parseSync({data:e,path:[],parent:r});return ur(o)?{value:o.value}:{issues:r.common.issues}}catch(o){(s=(n=o==null?void 0:o.message)==null?void 0:n.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(o=>ur(o)?{value:o.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==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nt(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(hn(s)?s:Promise.resolve(s));return Jl(n,o)}refine(e,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,o)=>{const i=e(s),a=()=>o.addIssue({code:I.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!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 mt({schema:this,typeName:C.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 Tt.create(this,this._def)}nullable(){return Yt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pt.create(this)}promise(){return jr.create(this,this._def)}or(e){return gn.create([this,e],this._def)}and(e){return vn.create(this,e,this._def)}transform(e){return new mt({...Y(this._def),schema:this,typeName:C.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Sn({...Y(this._def),innerType:this,defaultValue:r,typeName:C.ZodDefault})}brand(){return new Fi({typeName:C.ZodBranded,type:this,...Y(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new kn({...Y(this._def),innerType:this,catchValue:r,typeName:C.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return En.create(this,e)}readonly(){return Pn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const hb=/^c[^\s-]{8,}$/i,pb=/^[0-9a-z]+$/,mb=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_b=/^[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,gb=/^[a-z0-9_-]{21}$/i,vb=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,yb=/^[-+]?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)?)??$/,bb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qi;const $b=/^(?:(?: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])$/,Sb=/^(?:(?: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])$/,kb=/^(([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]))$/,Eb=/^(([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])$/,Pb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tb=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Bl="((\\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])))",xb=new RegExp(`^${Bl}$`);function Kl(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 Rb(t){return new RegExp(`^${Kl(t)}$`)}function Gl(t){let e=`${Bl}T${Kl(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 Ib(t,e){return!!((e==="v4"||!e)&&$b.test(t)||(e==="v6"||!e)&&kb.test(t))}function Cb(t,e){if(!vb.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==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Ob(t,e){return!!((e==="v4"||!e)&&Sb.test(t)||(e==="v6"||!e)&&Eb.test(t))}class ht extends ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Z.string){const o=this._getOrReturnCtx(e);return A(o,{code:I.invalid_type,expected:Z.string,received:o.parsedType}),J}const n=new Ve;let s;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),A(s,{code:I.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),A(s,{code:I.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const i=e.data.length>o.value,a=e.data.length<o.value;(i||a)&&(s=this._getOrReturnCtx(e,s),i?A(s,{code:I.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&A(s,{code:I.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")bb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"email",code:I.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")qi||(qi=new RegExp(wb,"u")),qi.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"emoji",code:I.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")_b.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"uuid",code:I.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")gb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"nanoid",code:I.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")hb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"cuid",code:I.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")pb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"cuid2",code:I.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")mb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"ulid",code:I.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),A(s,{validation:"url",code:I.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"regex",code:I.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),A(s,{code:I.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),A(s,{code:I.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),A(s,{code:I.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Gl(o).test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{code:I.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?xb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{code:I.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?Rb(o).test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{code:I.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?yb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"duration",code:I.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Ib(e.data,o.version)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"ip",code:I.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?Cb(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"jwt",code:I.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Ob(e.data,o.version)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"cidr",code:I.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Pb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"base64",code:I.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Tb.test(e.data)||(s=this._getOrReturnCtx(e,s),A(s,{validation:"base64url",code:I.invalid_string,message:o.message}),n.dirty()):oe.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:I.invalid_string,...L.errToObj(n)})}_addCheck(e){return new ht({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...L.errToObj(e)})}url(e){return this._addCheck({kind:"url",...L.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...L.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...L.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...L.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...L.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...L.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...L.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...L.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...L.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...L.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...L.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...L.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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...L.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...L.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...L.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...L.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...L.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...L.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...L.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...L.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...L.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...L.errToObj(r)})}nonempty(e){return this.min(1,L.errToObj(e))}trim(){return new ht({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ht({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ht({...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}}ht.create=t=>new ht({checks:[],typeName:C.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Y(t)});function Nb(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}class Bt extends ee{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)!==Z.number){const o=this._getOrReturnCtx(e);return A(o,{code:I.invalid_type,expected:Z.number,received:o.parsedType}),J}let n;const s=new Ve;for(const o of this._def.checks)o.kind==="int"?oe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{code:I.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),A(n,{code:I.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),A(n,{code:I.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?Nb(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),A(n,{code:I.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),A(n,{code:I.not_finite,message:o.message}),s.dirty()):oe.assertNever(o);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,L.toString(r))}gt(e,r){return this.setLimit("min",e,!1,L.toString(r))}lte(e,r){return this.setLimit("max",e,!0,L.toString(r))}lt(e,r){return this.setLimit("max",e,!1,L.toString(r))}setLimit(e,r,n,s){return new Bt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:L.toString(s)}]})}_addCheck(e){return new Bt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:L.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:L.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:L.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L.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"&&oe.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)}}Bt.create=t=>new Bt({checks:[],typeName:C.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Y(t)});class Kt extends ee{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)!==Z.bigint)return this._getInvalidInput(e);let n;const s=new Ve;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),A(n,{code:I.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),A(n,{code:I.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),A(n,{code:I.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):oe.assertNever(o);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return A(r,{code:I.invalid_type,expected:Z.bigint,received:r.parsedType}),J}gte(e,r){return this.setLimit("min",e,!0,L.toString(r))}gt(e,r){return this.setLimit("min",e,!1,L.toString(r))}lte(e,r){return this.setLimit("max",e,!0,L.toString(r))}lt(e,r){return this.setLimit("max",e,!1,L.toString(r))}setLimit(e,r,n,s){return new Kt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:L.toString(s)}]})}_addCheck(e){return new Kt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:L.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}}Kt.create=t=>new Kt({checks:[],typeName:C.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Y(t)});class pn extends ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Z.boolean){const n=this._getOrReturnCtx(e);return A(n,{code:I.invalid_type,expected:Z.boolean,received:n.parsedType}),J}return He(e.data)}}pn.create=t=>new pn({typeName:C.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Y(t)});class lr extends ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Z.date){const o=this._getOrReturnCtx(e);return A(o,{code:I.invalid_type,expected:Z.date,received:o.parsedType}),J}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return A(o,{code:I.invalid_date}),J}const n=new Ve;let s;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),A(s,{code:I.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),A(s,{code:I.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):oe.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new lr({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:L.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:L.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}}lr.create=t=>new lr({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:C.ZodDate,...Y(t)});class Is extends ee{_parse(e){if(this._getType(e)!==Z.symbol){const n=this._getOrReturnCtx(e);return A(n,{code:I.invalid_type,expected:Z.symbol,received:n.parsedType}),J}return He(e.data)}}Is.create=t=>new Is({typeName:C.ZodSymbol,...Y(t)});class mn extends ee{_parse(e){if(this._getType(e)!==Z.undefined){const n=this._getOrReturnCtx(e);return A(n,{code:I.invalid_type,expected:Z.undefined,received:n.parsedType}),J}return He(e.data)}}mn.create=t=>new mn({typeName:C.ZodUndefined,...Y(t)});class _n extends ee{_parse(e){if(this._getType(e)!==Z.null){const n=this._getOrReturnCtx(e);return A(n,{code:I.invalid_type,expected:Z.null,received:n.parsedType}),J}return He(e.data)}}_n.create=t=>new _n({typeName:C.ZodNull,...Y(t)});class Cr extends ee{constructor(){super(...arguments),this._any=!0}_parse(e){return He(e.data)}}Cr.create=t=>new Cr({typeName:C.ZodAny,...Y(t)});class dr extends ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return He(e.data)}}dr.create=t=>new dr({typeName:C.ZodUnknown,...Y(t)});class jt extends ee{_parse(e){const r=this._getOrReturnCtx(e);return A(r,{code:I.invalid_type,expected:Z.never,received:r.parsedType}),J}}jt.create=t=>new jt({typeName:C.ZodNever,...Y(t)});class Cs extends ee{_parse(e){if(this._getType(e)!==Z.undefined){const n=this._getOrReturnCtx(e);return A(n,{code:I.invalid_type,expected:Z.void,received:n.parsedType}),J}return He(e.data)}}Cs.create=t=>new Cs({typeName:C.ZodVoid,...Y(t)});class pt extends ee{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==Z.array)return A(r,{code:I.invalid_type,expected:Z.array,received:r.parsedType}),J;if(s.exactLength!==null){const i=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(i||a)&&(A(r,{code:i?I.too_big:I.too_small,minimum:a?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&&(A(r,{code:I.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&&(A(r,{code:I.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,a)=>s.type._parseAsync(new Et(r,i,r.path,a)))).then(i=>Ve.mergeArray(n,i));const o=[...r.data].map((i,a)=>s.type._parseSync(new Et(r,i,r.path,a)));return Ve.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new pt({...this._def,minLength:{value:e,message:L.toString(r)}})}max(e,r){return new pt({...this._def,maxLength:{value:e,message:L.toString(r)}})}length(e,r){return new pt({...this._def,exactLength:{value:e,message:L.toString(r)}})}nonempty(e){return this.min(1,e)}}pt.create=(t,e)=>new pt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...Y(e)});function Or(t){if(t instanceof Pe){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Tt.create(Or(n))}return new Pe({...t._def,shape:()=>e})}else return t instanceof pt?new pt({...t._def,type:Or(t.element)}):t instanceof Tt?Tt.create(Or(t.unwrap())):t instanceof Yt?Yt.create(Or(t.unwrap())):t instanceof Pt?Pt.create(t.items.map(e=>Or(e))):t}class Pe extends ee{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=oe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Z.object){const u=this._getOrReturnCtx(e);return A(u,{code:I.invalid_type,expected:Z.object,received:u.parsedType}),J}const{status:n,ctx:s}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof jt&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||a.push(u);const c=[];for(const u of i){const l=o[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Et(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof jt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(A(s,{code:I.unrecognized_keys,keys:a}),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 a){const f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Et(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,_=await l.value;u.push({key:f,value:_,alwaysSet:l.alwaysSet})}return u}).then(u=>Ve.mergeObjectSync(n,u)):Ve.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return L.errToObj,new Pe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var o,i;const s=((i=(o=this._def).errorMap)==null?void 0:i.call(o,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:L.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Pe({...this._def,unknownKeys:"strip"})}passthrough(){return new Pe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Pe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Pe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:C.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Pe({...this._def,catchall:e})}pick(e){const r={};for(const n of oe.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Pe({...this._def,shape:()=>r})}omit(e){const r={};for(const n of oe.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Pe({...this._def,shape:()=>r})}deepPartial(){return Or(this)}partial(e){const r={};for(const n of oe.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new Pe({...this._def,shape:()=>r})}required(e){const r={};for(const n of oe.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Tt;)o=o._def.innerType;r[n]=o}return new Pe({...this._def,shape:()=>r})}keyof(){return Yl(oe.objectKeys(this.shape))}}Pe.create=(t,e)=>new Pe({shape:()=>t,unknownKeys:"strip",catchall:jt.create(),typeName:C.ZodObject,...Y(e)}),Pe.strictCreate=(t,e)=>new Pe({shape:()=>t,unknownKeys:"strict",catchall:jt.create(),typeName:C.ZodObject,...Y(e)}),Pe.lazycreate=(t,e)=>new Pe({shape:t,unknownKeys:"strip",catchall:jt.create(),typeName:C.ZodObject,...Y(e)});class gn extends ee{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function s(o){for(const a of o)if(a.result.status==="valid")return a.result;for(const a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(a=>new et(a.ctx.common.issues));return A(r,{code:I.invalid_union,unionErrors:i}),J}if(r.common.async)return Promise.all(n.map(async o=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let o;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"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;const a=i.map(c=>new et(c));return A(r,{code:I.invalid_union,unionErrors:a}),J}}get options(){return this._def.options}}gn.create=(t,e)=>new gn({options:t,typeName:C.ZodUnion,...Y(e)});const At=t=>t instanceof bn?At(t.schema):t instanceof mt?At(t.innerType()):t instanceof wn?[t.value]:t instanceof Gt?t.options:t instanceof $n?oe.objectValues(t.enum):t instanceof Sn?At(t._def.innerType):t instanceof mn?[void 0]:t instanceof _n?[null]:t instanceof Tt?[void 0,...At(t.unwrap())]:t instanceof Yt?[null,...At(t.unwrap())]:t instanceof Fi||t instanceof Pn?At(t.unwrap()):t instanceof kn?At(t._def.innerType):[];class Os extends ee{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Z.object)return A(r,{code:I.invalid_type,expected:Z.object,received:r.parsedType}),J;const n=this.discriminator,s=r.data[n],o=this.optionsMap.get(s);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(A(r,{code:I.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),J)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const s=new Map;for(const o of r){const i=At(o.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of i){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,o)}}return new Os({typeName:C.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...Y(n)})}}function Vi(t,e){const r=Nt(t),n=Nt(e);if(t===e)return{valid:!0,data:t};if(r===Z.object&&n===Z.object){const s=oe.objectKeys(e),o=oe.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(const a of o){const c=Vi(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===Z.array&&n===Z.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let o=0;o<t.length;o++){const i=t[o],a=e[o],c=Vi(i,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===Z.date&&n===Z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class vn extends ee{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(Ui(o)||Ui(i))return J;const a=Vi(o.value,i.value);return a.valid?((Di(o)||Di(i))&&r.dirty(),{status:r.value,value:a.data}):(A(n,{code:I.invalid_intersection_types}),J)};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(([o,i])=>s(o,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}))}}vn.create=(t,e,r)=>new vn({left:t,right:e,typeName:C.ZodIntersection,...Y(r)});class Pt extends ee{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Z.array)return A(n,{code:I.invalid_type,expected:Z.array,received:n.parsedType}),J;if(n.data.length<this._def.items.length)return A(n,{code:I.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J;!this._def.rest&&n.data.length>this._def.items.length&&(A(n,{code:I.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const o=[...n.data].map((i,a)=>{const c=this._def.items[a]||this._def.rest;return c?c._parse(new Et(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>Ve.mergeArray(r,i)):Ve.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new Pt({...this._def,rest:e})}}Pt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pt({items:t,typeName:C.ZodTuple,rest:null,...Y(e)})};class yn extends ee{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!==Z.object)return A(n,{code:I.invalid_type,expected:Z.object,received:n.parsedType}),J;const s=[],o=this._def.keyType,i=this._def.valueType;for(const a in n.data)s.push({key:o._parse(new Et(n,a,n.path,a)),value:i._parse(new Et(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Ve.mergeObjectAsync(r,s):Ve.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ee?new yn({keyType:e,valueType:r,typeName:C.ZodRecord,...Y(n)}):new yn({keyType:ht.create(),valueType:e,typeName:C.ZodRecord,...Y(r)})}}class Ns extends ee{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!==Z.map)return A(n,{code:I.invalid_type,expected:Z.map,received:n.parsedType}),J;const s=this._def.keyType,o=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new Et(n,a,n.path,[u,"key"])),value:o._parse(new Et(n,c,n.path,[u,"value"]))}));if(n.common.async){const a=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 J;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{const a=new Map;for(const c of i){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return J;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}}Ns.create=(t,e,r)=>new Ns({valueType:e,keyType:t,typeName:C.ZodMap,...Y(r)});class fr extends ee{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Z.set)return A(n,{code:I.invalid_type,expected:Z.set,received:n.parsedType}),J;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(A(n,{code:I.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&&(A(n,{code:I.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const o=this._def.valueType;function i(c){const u=new Set;for(const l of c){if(l.status==="aborted")return J;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}const a=[...n.data.values()].map((c,u)=>o._parse(new Et(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new fr({...this._def,minSize:{value:e,message:L.toString(r)}})}max(e,r){return new fr({...this._def,maxSize:{value:e,message:L.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}fr.create=(t,e)=>new fr({valueType:t,minSize:null,maxSize:null,typeName:C.ZodSet,...Y(e)});class Nr extends ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Z.function)return A(r,{code:I.invalid_type,expected:Z.function,received:r.parsedType}),J;function n(a,c){return Rs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xs(),Rr].filter(u=>!!u),issueData:{code:I.invalid_arguments,argumentsError:c}})}function s(a,c){return Rs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xs(),Rr].filter(u=>!!u),issueData:{code:I.invalid_return_type,returnTypeError:c}})}const o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof jr){const a=this;return He(async function(...c){const u=new et([]),l=await a._def.args.parseAsync(c,o).catch(y=>{throw u.addIssue(n(c,y)),u}),f=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(f,o).catch(y=>{throw u.addIssue(s(f,y)),u})})}else{const a=this;return He(function(...c){const u=a._def.args.safeParse(c,o);if(!u.success)throw new et([n(c,u.error)]);const l=Reflect.apply(i,this,u.data),f=a._def.returns.safeParse(l,o);if(!f.success)throw new et([s(l,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Nr({...this._def,args:Pt.create(e).rest(dr.create())})}returns(e){return new Nr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Nr({args:e||Pt.create([]).rest(dr.create()),returns:r||dr.create(),typeName:C.ZodFunction,...Y(n)})}}class bn extends ee{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})}}bn.create=(t,e)=>new bn({getter:t,typeName:C.ZodLazy,...Y(e)});class wn extends ee{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return A(r,{received:r.data,code:I.invalid_literal,expected:this._def.value}),J}return{status:"valid",value:e.data}}get value(){return this._def.value}}wn.create=(t,e)=>new wn({value:t,typeName:C.ZodLiteral,...Y(e)});function Yl(t,e){return new Gt({values:t,typeName:C.ZodEnum,...Y(e)})}class Gt extends ee{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return A(r,{expected:oe.joinValues(n),received:r.parsedType,code:I.invalid_type}),J}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 A(r,{received:r.data,code:I.invalid_enum_value,options:n}),J}return He(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 Gt.create(e,{...this._def,...r})}exclude(e,r=this._def){return Gt.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}Gt.create=Yl;class $n extends ee{_parse(e){const r=oe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Z.string&&n.parsedType!==Z.number){const s=oe.objectValues(r);return A(n,{expected:oe.joinValues(s),received:n.parsedType,code:I.invalid_type}),J}if(this._cache||(this._cache=new Set(oe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=oe.objectValues(r);return A(n,{received:n.data,code:I.invalid_enum_value,options:s}),J}return He(e.data)}get enum(){return this._def.values}}$n.create=(t,e)=>new $n({values:t,typeName:C.ZodNativeEnum,...Y(e)});class jr extends ee{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Z.promise&&r.common.async===!1)return A(r,{code:I.invalid_type,expected:Z.promise,received:r.parsedType}),J;const n=r.parsedType===Z.promise?r.data:Promise.resolve(r.data);return He(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}jr.create=(t,e)=>new jr({type:t,typeName:C.ZodPromise,...Y(e)});class mt extends ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:i=>{A(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){const i=s.transform(n.data,o);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return J;const c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?J:c.status==="dirty"||r.value==="dirty"?Ir(c.value):c});{if(r.value==="aborted")return J;const a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?J:a.status==="dirty"||r.value==="dirty"?Ir(a.value):a}}if(s.type==="refinement"){const i=a=>{const c=s.refinement(a,o);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 a};if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?J:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?J:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.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 J;const a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>ur(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):J);oe.assertNever(s)}}mt.create=(t,e,r)=>new mt({schema:t,typeName:C.ZodEffects,effect:e,...Y(r)}),mt.createWithPreprocess=(t,e,r)=>new mt({schema:e,effect:{type:"preprocess",transform:t},typeName:C.ZodEffects,...Y(r)});class Tt extends ee{_parse(e){return this._getType(e)===Z.undefined?He(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Tt.create=(t,e)=>new Tt({innerType:t,typeName:C.ZodOptional,...Y(e)});class Yt extends ee{_parse(e){return this._getType(e)===Z.null?He(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Yt.create=(t,e)=>new Yt({innerType:t,typeName:C.ZodNullable,...Y(e)});class Sn extends ee{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===Z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Sn.create=(t,e)=>new Sn({innerType:t,typeName:C.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Y(e)});class kn extends ee{_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 hn(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new et(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new et(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}kn.create=(t,e)=>new kn({innerType:t,typeName:C.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Y(e)});class js extends ee{_parse(e){if(this._getType(e)!==Z.nan){const n=this._getOrReturnCtx(e);return A(n,{code:I.invalid_type,expected:Z.nan,received:n.parsedType}),J}return{status:"valid",value:e.data}}}js.create=t=>new js({typeName:C.ZodNaN,...Y(t)});const jb=Symbol("zod_brand");class Fi extends ee{_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 En extends ee{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?J:o.status==="dirty"?(r.dirty(),Ir(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?J: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 En({in:e,out:r,typeName:C.ZodPipeline})}}class Pn extends ee{_parse(e){const r=this._def.innerType._parse(e),n=s=>(ur(s)&&(s.value=Object.freeze(s.value)),s);return hn(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}Pn.create=(t,e)=>new Pn({innerType:t,typeName:C.ZodReadonly,...Y(e)});function Xl(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Ql(t,e={},r){return t?Cr.create().superRefine((n,s)=>{const o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){const a=Xl(e,n),c=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!o){const i=Xl(e,n),a=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:a})}}):Cr.create()}const Ab={object:Pe.lazycreate};var C;(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"})(C||(C={}));const zb=(t,e={message:`Input not instance of ${t.name}`})=>Ql(r=>r instanceof t,e),ed=ht.create,td=Bt.create,Mb=js.create,Zb=Kt.create,rd=pn.create,Lb=lr.create,Ub=Is.create,Db=mn.create,qb=_n.create,Vb=Cr.create,Fb=dr.create,Hb=jt.create,Wb=Cs.create,Jb=pt.create,nd=Pe.create,Bb=Pe.strictCreate,Kb=gn.create,Gb=Os.create,Yb=vn.create,Xb=Pt.create,Qb=yn.create,ew=Ns.create,tw=fr.create,rw=Nr.create,nw=bn.create,sw=wn.create,ow=Gt.create,iw=$n.create,aw=jr.create,sd=mt.create,cw=Tt.create,uw=Yt.create,lw=mt.createWithPreprocess,dw=En.create,fw=Object.freeze(Object.defineProperty({__proto__:null,BRAND:jb,DIRTY:Ir,EMPTY_PATH:fb,INVALID:J,NEVER:J,OK:He,ParseStatus:Ve,Schema:ee,ZodAny:Cr,ZodArray:pt,ZodBigInt:Kt,ZodBoolean:pn,ZodBranded:Fi,ZodCatch:kn,ZodDate:lr,ZodDefault:Sn,ZodDiscriminatedUnion:Os,ZodEffects:mt,ZodEnum:Gt,ZodError:et,get ZodFirstPartyTypeKind(){return C},ZodFunction:Nr,ZodIntersection:vn,ZodIssueCode:I,ZodLazy:bn,ZodLiteral:wn,ZodMap:Ns,ZodNaN:js,ZodNativeEnum:$n,ZodNever:jt,ZodNull:_n,ZodNullable:Yt,ZodNumber:Bt,ZodObject:Pe,ZodOptional:Tt,ZodParsedType:Z,ZodPipeline:En,ZodPromise:jr,ZodReadonly:Pn,ZodRecord:yn,ZodSchema:ee,ZodSet:fr,ZodString:ht,ZodSymbol:Is,ZodTransformer:mt,ZodTuple:Pt,ZodType:ee,ZodUndefined:mn,ZodUnion:gn,ZodUnknown:dr,ZodVoid:Cs,addIssueToContext:A,any:Vb,array:Jb,bigint:Zb,boolean:rd,coerce:{string:t=>ht.create({...t,coerce:!0}),number:t=>Bt.create({...t,coerce:!0}),boolean:t=>pn.create({...t,coerce:!0}),bigint:t=>Kt.create({...t,coerce:!0}),date:t=>lr.create({...t,coerce:!0})},custom:Ql,date:Lb,datetimeRegex:Gl,defaultErrorMap:Rr,discriminatedUnion:Gb,effect:sd,enum:ow,function:rw,getErrorMap:xs,getParsedType:Nt,instanceof:zb,intersection:Yb,isAborted:Ui,isAsync:hn,isDirty:Di,isValid:ur,late:Ab,lazy:nw,literal:sw,makeIssue:Rs,map:ew,nan:Mb,nativeEnum:iw,never:Hb,null:qb,nullable:uw,number:td,object:nd,get objectUtil(){return Li},oboolean:()=>rd().optional(),onumber:()=>td().optional(),optional:cw,ostring:()=>ed().optional(),pipeline:dw,preprocess:lw,promise:aw,quotelessJson:lb,record:Qb,set:tw,setErrorMap:db,strictObject:Bb,string:ed,symbol:Ub,transformer:sd,tuple:Xb,undefined:Db,union:Kb,unknown:Fb,get util(){return oe},void:Wb},Symbol.toStringTag,{value:"Module"})),hw=T("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");ge.init(t,e),t.def=e,t.parse=(r,n)=>k_(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>fi(t,r,n),t.parseAsync=async(r,n)=>E_(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>hi(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)=>Ht(t,r,n),t.brand=()=>t,t.register=(r,n)=>(r.add(t,n),t)}),pw=T("ZodMiniObject",(t,e)=>{ju.init(t,e),hw.init(t,e),_e(t,"shape",()=>e.shape)});function od(t,e){const r={type:"object",get shape(){return rn(this,"shape",{...t}),this.shape},...D(e)};return new pw(r)}function _t(t){return!!t._zod}function Tn(t){const e=Object.values(t);if(e.length===0)return od({});const r=e.every(_t),n=e.every(s=>!_t(s));if(r)return od(t);if(n)return nd(t);throw new Error("Mixed Zod versions detected in object shape.")}function As(t,e){return _t(t)?fi(t,e):t.safeParse(e)}async function Hi(t,e){return _t(t)?await hi(t,e):await t.safeParseAsync(e)}function xn(t){var e,r;if(!t)return;let n;if(_t(t)?n=(r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.shape:n=t.shape,!!n){if(typeof n=="function")try{return n()}catch{return}return n}}function Rn(t){var e;if(t){if(typeof t=="object"){const r=t,n=t;if(!r._def&&!n._zod){const s=Object.values(t);if(s.length>0&&s.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return Tn(t)}}if(_t(t)){const n=(e=t._zod)===null||e===void 0?void 0:e.def;if(n&&(n.typeName==="object"||n.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function Wi(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 mw(t){var e,r,n,s;if(_t(t))return(r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.description;const o=t;return(n=t.description)!==null&&n!==void 0?n:(s=o._def)===null||s===void 0?void 0:s.description}function _w(t){var e,r,n;if(_t(t))return((r=(e=t._zod)===null||e===void 0?void 0:e.def)===null||r===void 0?void 0:r.typeName)==="ZodOptional";const s=t;return typeof t.isOptional=="function"?t.isOptional():((n=s._def)===null||n===void 0?void 0:n.typeName)==="ZodOptional"}function id(t){var e;if(_t(t)){const i=(e=t._zod)===null||e===void 0?void 0:e.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=t._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const s=t.value;if(s!==void 0)return s}const gw=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"},vw=t=>typeof t=="string"?{...ad,name:t}:{...ad,...t},yw=t=>{const e=vw(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 cd(t,e,r,n){n!=null&&n.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function de(t,e,r,n,s){t[e]=r,cd(t,e,n,s)}const ud=(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 Ye(t){if(t.target!=="openAi")return{};const e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?ud(e,t.currentPath):e.join("/")}}function bw(t,e){var n,s,o;const r={type:"array"};return(n=t.type)!=null&&n._def&&((o=(s=t.type)==null?void 0:s._def)==null?void 0:o.typeName)!==C.ZodAny&&(r.items=ue(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&de(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&de(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(de(r,"minItems",t.exactLength.value,t.exactLength.message,e),de(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function ww(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?de(r,"minimum",n.value,n.message,e):de(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),de(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?de(r,"maximum",n.value,n.message,e):de(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),de(r,"maximum",n.value,n.message,e));break;case"multipleOf":de(r,"multipleOf",n.value,n.message,e);break}return r}function $w(){return{type:"boolean"}}function ld(t,e){return ue(t.type._def,e)}const Sw=(t,e)=>ue(t.innerType._def,e);function dd(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,o)=>dd(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 kw(t,e)}}const kw=(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":de(r,"minimum",n.value,n.message,e);break;case"max":de(r,"maximum",n.value,n.message,e);break}return r};function Ew(t,e){return{...ue(t.innerType._def,e),default:t.defaultValue()}}function Pw(t,e){return e.effectStrategy==="input"?ue(t.schema._def,e):Ye(e)}function Tw(t){return{type:"string",enum:Array.from(t.values)}}const xw=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Rw(t,e){const r=[ue(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),ue(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o);let n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const s=[];return r.forEach(o=>{if(xw(o))s.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let i=o;if("additionalProperties"in o&&o.additionalProperties===!1){const{additionalProperties:a,...c}=o;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function Iw(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 Ji;const gt={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:()=>(Ji===void 0&&(Ji=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ji),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 fd(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":de(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":de(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":vt(r,"email",n.message,e);break;case"format:idn-email":vt(r,"idn-email",n.message,e);break;case"pattern:zod":We(r,gt.email,n.message,e);break}break;case"url":vt(r,"uri",n.message,e);break;case"uuid":vt(r,"uuid",n.message,e);break;case"regex":We(r,n.regex,n.message,e);break;case"cuid":We(r,gt.cuid,n.message,e);break;case"cuid2":We(r,gt.cuid2,n.message,e);break;case"startsWith":We(r,RegExp(`^${Bi(n.value,e)}`),n.message,e);break;case"endsWith":We(r,RegExp(`${Bi(n.value,e)}$`),n.message,e);break;case"datetime":vt(r,"date-time",n.message,e);break;case"date":vt(r,"date",n.message,e);break;case"time":vt(r,"time",n.message,e);break;case"duration":vt(r,"duration",n.message,e);break;case"length":de(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),de(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{We(r,RegExp(Bi(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&vt(r,"ipv4",n.message,e),n.version!=="v4"&&vt(r,"ipv6",n.message,e);break}case"base64url":We(r,gt.base64url,n.message,e);break;case"jwt":We(r,gt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&We(r,gt.ipv4Cidr,n.message,e),n.version!=="v4"&&We(r,gt.ipv6Cidr,n.message,e);break}case"emoji":We(r,gt.emoji(),n.message,e);break;case"ulid":{We(r,gt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{vt(r,"binary",n.message,e);break}case"contentEncoding:base64":{de(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{We(r,gt.base64,n.message,e);break}}break}case"nanoid":We(r,gt.nanoid,n.message,e)}return r}function Bi(t,e){return e.patternStrategy==="escape"?Ow(t):t}const Cw=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ow(t){let e="";for(let r=0;r<t.length;r++)Cw.has(t[r])||(e+="\\"),e+=t[r];return e}function vt(t,e,r,n){var s;t.format||(s=t.anyOf)!=null&&s.some(o=>o.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}}})):de(t,"format",e,r,n)}function We(t,e,r,n){var s;t.pattern||(s=t.allOf)!=null&&s.some(o=>o.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:hd(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):de(t,"pattern",hd(e,n),r,n)}function hd(t,e){var c;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="",o=!1,i=!1,a=!1;for(let u=0;u<n.length;u++){if(o){s+=n[u],o=!1;continue}if(r.i){if(i){if(n[u].match(/[a-z]/)){a?(s+=n[u],s+=`${n[u-2]}-${n[u]}`.toUpperCase(),a=!1):n[u+1]==="-"&&((c=n[u+2])!=null&&c.match(/[a-z]/))?(s+=n[u],a=!0):s+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){s+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(r.m){if(n[u]==="^"){s+=`(^|(?<=[\r
36
- ]))`;continue}else if(n[u]==="$"){s+=`($|(?=[\r
37
- ]))`;continue}}if(r.s&&n[u]==="."){s+=i?`${n[u]}\r
38
- `:`[${n[u]}\r
39
- ]`;continue}s+=n[u],n[u]==="\\"?o=!0:i&&n[u]==="]"?i=!1:!i&&n[u]==="["&&(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 pd(t,e){var n,s,o,i,a,c;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"&&((n=t.keyType)==null?void 0:n._def.typeName)===C.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((u,l)=>({...u,[l]:ue(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",l]})??Ye(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};const r={type:"object",additionalProperties:ue(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(((s=t.keyType)==null?void 0:s._def.typeName)===C.ZodString&&((o=t.keyType._def.checks)!=null&&o.length)){const{type:u,...l}=fd(t.keyType._def,e);return{...r,propertyNames:l}}else{if(((i=t.keyType)==null?void 0:i._def.typeName)===C.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(((a=t.keyType)==null?void 0:a._def.typeName)===C.ZodBranded&&t.keyType._def.type._def.typeName===C.ZodString&&((c=t.keyType._def.type._def.checks)!=null&&c.length)){const{type:u,...l}=ld(t.keyType._def,e);return{...r,propertyNames:l}}}return r}function Nw(t,e){if(e.mapStrategy==="record")return pd(t,e);const r=ue(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Ye(e),n=ue(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Ye(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function jw(t){const e=t.values,n=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),s=Array.from(new Set(n.map(o=>typeof o)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function Aw(t){return t.target==="openAi"?void 0:{not:Ye({...t,currentPath:[...t.currentPath,"not"]})}}function zw(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const zs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Mw(t,e){if(e.target==="openApi3")return md(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in zs&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,o)=>{const i=zs[o._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,o)=>{const i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(o._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){const s=n.filter((o,i,a)=>a.indexOf(o)===i);return{type:s.length>1?s:s[0],enum:r.reduce((o,i)=>o.includes(i._def.value)?o:[...o,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(o=>!n.includes(o))],[])};return md(t,e)}const md=(t,e)=>{const r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>ue(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 Zw(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:zs[t.innerType._def.typeName],nullable:!0}:{type:[zs[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const n=ue(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const r=ue(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function Lw(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",cd(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?de(r,"minimum",n.value,n.message,e):de(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),de(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?de(r,"maximum",n.value,n.message,e):de(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),de(r,"maximum",n.value,n.message,e));break;case"multipleOf":de(r,"multipleOf",n.value,n.message,e);break}return r}function Uw(t,e){const r=e.target==="openAi",n={type:"object",properties:{}},s=[],o=t.shape();for(const a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let u=qw(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=ue(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||s.push(a))}s.length&&(n.required=s);const i=Dw(t,e);return i!==void 0&&(n.additionalProperties=i),n}function Dw(t,e){if(t.catchall._def.typeName!=="ZodNever")return ue(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 qw(t){try{return t.isOptional()}catch{return!0}}const Vw=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return ue(t.innerType._def,e);const r=ue(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ye(e)},r]}:Ye(e)},Fw=(t,e)=>{if(e.pipeStrategy==="input")return ue(t.in._def,e);if(e.pipeStrategy==="output")return ue(t.out._def,e);const r=ue(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=ue(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function Hw(t,e){return ue(t.type._def,e)}function Ww(t,e){const n={type:"array",uniqueItems:!0,items:ue(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&de(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&de(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function Jw(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>ue(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:ue(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>ue(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function Bw(t){return{not:Ye(t)}}function Kw(t){return Ye(t)}const Gw=(t,e)=>ue(t.innerType._def,e),Yw=(t,e,r)=>{switch(e){case C.ZodString:return fd(t,r);case C.ZodNumber:return Lw(t,r);case C.ZodObject:return Uw(t,r);case C.ZodBigInt:return ww(t,r);case C.ZodBoolean:return $w();case C.ZodDate:return dd(t,r);case C.ZodUndefined:return Bw(r);case C.ZodNull:return zw(r);case C.ZodArray:return bw(t,r);case C.ZodUnion:case C.ZodDiscriminatedUnion:return Mw(t,r);case C.ZodIntersection:return Rw(t,r);case C.ZodTuple:return Jw(t,r);case C.ZodRecord:return pd(t,r);case C.ZodLiteral:return Iw(t,r);case C.ZodEnum:return Tw(t);case C.ZodNativeEnum:return jw(t);case C.ZodNullable:return Zw(t,r);case C.ZodOptional:return Vw(t,r);case C.ZodMap:return Nw(t,r);case C.ZodSet:return Ww(t,r);case C.ZodLazy:return()=>t.getter()._def;case C.ZodPromise:return Hw(t,r);case C.ZodNaN:case C.ZodNever:return Aw(r);case C.ZodEffects:return Pw(t,r);case C.ZodAny:return Ye(r);case C.ZodUnknown:return Kw(r);case C.ZodDefault:return Ew(t,r);case C.ZodBranded:return ld(t,r);case C.ZodReadonly:return Gw(t,r);case C.ZodCatch:return Sw(t,r);case C.ZodPipeline:return Fw(t,r);case C.ZodFunction:case C.ZodVoid:case C.ZodSymbol:return;default:return(n=>{})()}};function ue(t,e,r=!1){var a;const n=e.seen.get(t);if(e.override){const c=(a=e.override)==null?void 0:a.call(e,t,e,n,r);if(c!==gw)return c}if(n&&!r){const c=Xw(n,e);if(c!==void 0)return c}const s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);const o=Yw(t,t.typeName,e),i=typeof o=="function"?ue(o(),e):o;if(i&&Qw(t,e,i),e.postProcess){const c=e.postProcess(i,t,e);return s.jsonSchema=i,c}return s.jsonSchema=i,i}const Xw=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ud(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`),Ye(e)):e.$refStrategy==="seen"?Ye(e):void 0}},Qw=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),e$=(t,e)=>{const r=yw(e);let n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:ue(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Ye(r)}),{}):void 0;const s=typeof e=="string"?e:(e==null?void 0:e.nameStrategy)==="title"||e==null?void 0:e.name,o=ue(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Ye(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(o.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 a=s===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function t$(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function _d(t,e){var r,n,s;return _t(t)?Gv(t,{target:t$(e==null?void 0:e.target),io:(r=e==null?void 0:e.pipeStrategy)!==null&&r!==void 0?r:"input"}):e$(t,{strictUnions:(n=e==null?void 0:e.strictUnions)!==null&&n!==void 0?n:!0,pipeStrategy:(s=e==null?void 0:e.pipeStrategy)!==null&&s!==void 0?s:"input"})}function gd(t){const e=xn(t),r=e==null?void 0:e.method;if(!r)throw new Error("Schema is missing a method literal");const n=id(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function vd(t,e){const r=As(t,e);if(!r.success)throw r.error;return r.data}const r$=6e4;class yd{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.setNotificationHandler($i,r=>{const n=this._requestHandlerAbortControllers.get(r.params.requestId);n==null||n.abort(r.params.reason)}),this.setNotificationHandler(Ei,r=>{this._onprogress(r)}),this.setRequestHandler(ki,r=>({}))}_setupTimeout(e,r,n,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,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),ae.fromError(ie.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){var r,n,s;this._transport=e;const o=(r=this.transport)===null||r===void 0?void 0:r.onclose;this._transport.onclose=()=>{o==null||o(),this._onclose()};const i=(n=this.transport)===null||n===void 0?void 0:n.onerror;this._transport.onerror=c=>{i==null||i(c),this._onerror(c)};const a=(s=this._transport)===null||s===void 0?void 0:s.onmessage;this._transport.onmessage=(c,u)=>{a==null||a(c,u),wi(c)||i0(c)?this._onresponse(c):pl(c)?this._onrequest(c,u):o0(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var e;const r=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);const n=ae.fromError(ie.ConnectionClosed,"Connection closed");for(const s of r.values())s(n)}_onerror(e){var r;(r=this.onerror)===null||r===void 0||r.call(this,e)}_onnotification(e){var r;const n=(r=this._notificationHandlers.get(e.method))!==null&&r!==void 0?r:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){var n,s;const o=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler,i=this._transport;if(o===void 0){i==null||i.send({jsonrpc:"2.0",id:e.id,error:{code:ie.MethodNotFound,message:"Method not found"}}).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}const a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);const c={signal:a.signal,sessionId:i==null?void 0:i.sessionId,_meta:(s=e.params)===null||s===void 0?void 0:s._meta,sendNotification:u=>this.notification(u,{relatedRequestId:e.id}),sendRequest:(u,l,f)=>this.request(u,l,{...f,relatedRequestId:e.id}),authInfo:r==null?void 0:r.authInfo,requestId:e.id,requestInfo:r==null?void 0:r.requestInfo};Promise.resolve().then(()=>o(e,c)).then(u=>{if(!a.signal.aborted)return i==null?void 0:i.send({result:u,jsonrpc:"2.0",id:e.id})},u=>{var l;if(!a.signal.aborted)return i==null?void 0:i.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:ie.InternalError,message:(l=u.message)!==null&&l!==void 0?l:"Internal error",...u.data!==void 0&&{data:u.data}}})}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:r,...n}=e.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const i=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){i(c);return}o(n)}_onresponse(e){const r=Number(e.id),n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),wi(e))n(e);else{const s=ae.fromError(e.error.code,e.error.message,e.error.data);n(s)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,r,n){const{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}=n??{};return new Promise((a,c)=>{var u,l,f,_,y,g;if(!this._transport){c(new Error("Not connected"));return}((u=this._options)===null||u===void 0?void 0:u.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(l=n==null?void 0:n.signal)===null||l===void 0||l.throwIfAborted();const v=this._requestMessageId++,h={...e,jsonrpc:"2.0",id:v};n!=null&&n.onprogress&&(this._progressHandlers.set(v,n.onprogress),h.params={...e.params,_meta:{...((f=e.params)===null||f===void 0?void 0:f._meta)||{},progressToken:v}});const d=S=>{var P;this._responseHandlers.delete(v),this._progressHandlers.delete(v),this._cleanupTimeout(v),(P=this._transport)===null||P===void 0||P.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:v,reason:String(S)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`))),c(S)};this._responseHandlers.set(v,S=>{var P;if(!(!((P=n==null?void 0:n.signal)===null||P===void 0)&&P.aborted)){if(S instanceof Error)return c(S);try{const O=As(r,S.result);O.success?a(O.data):c(O.error)}catch(O){c(O)}}}),(_=n==null?void 0:n.signal)===null||_===void 0||_.addEventListener("abort",()=>{var S;d((S=n==null?void 0:n.signal)===null||S===void 0?void 0:S.reason)});const m=(y=n==null?void 0:n.timeout)!==null&&y!==void 0?y:r$,w=()=>d(ae.fromError(ie.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(v,m,n==null?void 0:n.maxTotalTimeout,w,(g=n==null?void 0:n.resetTimeoutOnProgress)!==null&&g!==void 0?g:!1),this._transport.send(h,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(S=>{this._cleanupTimeout(v),c(S)})})}async notification(e,r){var n,s;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((s=(n=this._options)===null||n===void 0?void 0:n.debouncedNotificationMethods)!==null&&s!==void 0?s:[]).includes(e.method)&&!e.params&&!(r!=null&&r.relatedRequestId)){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var c;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;const u={...e,jsonrpc:"2.0"};(c=this._transport)===null||c===void 0||c.send(u,r).catch(l=>this._onerror(l))});return}const a={...e,jsonrpc:"2.0"};await this._transport.send(a,r)}setRequestHandler(e,r){const n=gd(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{const i=vd(e,s);return Promise.resolve(r(i,o))})}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=gd(e);this._notificationHandlers.set(n,s=>{const o=vd(e,s);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}}function bd(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function wd(t,e){const r={...t};for(const n in e){const s=n,o=e[s];if(o===void 0)continue;const i=r[s];bd(i)&&bd(o)?r[s]={...i,...o}:r[s]=o}return r}var Ki={exports:{}},$d={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0;function e(U,K){return{validate:U,compare:K}}t.fullFormats={date:e(o,i),time:e(c(!0),u),"date-time":e(_(!0),y),"iso-time":e(c(),l),"iso-date-time":e(_(),g),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:d,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:Ae,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:w,int32:{type:"number",validate:O},int64:{type:"number",validate:V},float:{type:"number",validate:ce},double:{type:"number",validate:ce},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,y),"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(U){return U%4===0&&(U%100!==0||U%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 o(U){const K=n.exec(U);if(!K)return!1;const Se=+K[1],se=+K[2],De=+K[3];return se>=1&&se<=12&&De>=1&&De<=(se===2&&r(Se)?29:s[se])}function i(U,K){if(U&&K)return U>K?1:U<K?-1:0}const a=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(U){return function(Se){const se=a.exec(Se);if(!se)return!1;const De=+se[1],Zt=+se[2],Lt=+se[3],Ln=se[4],mr=se[5]==="-"?-1:1,N=+(se[6]||0),k=+(se[7]||0);if(N>23||k>59||U&&!Ln)return!1;if(De<=23&&Zt<=59&&Lt<60)return!0;const R=Zt-k*mr,E=De-N*mr-(R<0?1:0);return(E===23||E===-1)&&(R===59||R===-1)&&Lt<61}}function u(U,K){if(!(U&&K))return;const Se=new Date("2020-01-01T"+U).valueOf(),se=new Date("2020-01-01T"+K).valueOf();if(Se&&se)return Se-se}function l(U,K){if(!(U&&K))return;const Se=a.exec(U),se=a.exec(K);if(Se&&se)return U=Se[1]+Se[2]+Se[3],K=se[1]+se[2]+se[3],U>K?1:U<K?-1:0}const f=/t|\s/i;function _(U){const K=c(U);return function(se){const De=se.split(f);return De.length===2&&o(De[0])&&K(De[1])}}function y(U,K){if(!(U&&K))return;const Se=new Date(U).valueOf(),se=new Date(K).valueOf();if(Se&&se)return Se-se}function g(U,K){if(!(U&&K))return;const[Se,se]=U.split(f),[De,Zt]=K.split(f),Lt=i(Se,De);if(Lt!==void 0)return Lt||u(se,Zt)}const v=/\/|:/,h=/^(?:[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 d(U){return v.test(U)&&h.test(U)}const m=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function w(U){return m.lastIndex=0,m.test(U)}const S=-2147483648,P=2**31-1;function O(U){return Number.isInteger(U)&&U<=P&&U>=S}function V(U){return Number.isInteger(U)}function ce(){return!0}const G=/[^\\]\\Z/;function Ae(U){if(G.test(U))return!1;try{return new RegExp(U),!0}catch{return!1}}})($d);var Sd={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;const e=ai,r=Q,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}},o={message:({keyword:a,schemaCode:c})=>(0,r.str)`should be ${s[a].okStr} ${c}`,params:({keyword:a,schemaCode:c})=>(0,r._)`{comparison: ${s[a].okStr}, limit: ${c}}`};t.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:o,code(a){const{gen:c,data:u,schemaCode:l,keyword:f,it:_}=a,{opts:y,self:g}=_;if(!y.validateFormats)return;const v=new e.KeywordCxt(_,g.RULES.all.format.definition,"format");v.$data?h():d();function h(){const w=c.scopeValue("formats",{ref:g.formats,code:y.code.formats}),S=c.const("fmt",(0,r._)`${w}[${v.schemaCode}]`);a.fail$data((0,r.or)((0,r._)`typeof ${S} != "object"`,(0,r._)`${S} instanceof RegExp`,(0,r._)`typeof ${S}.compare != "function"`,m(S)))}function d(){const w=v.schema,S=g.formats[w];if(!S||S===!0)return;if(typeof S!="object"||S instanceof RegExp||typeof S.compare!="function")throw new Error(`"${f}": format "${w}" does not define "compare" function`);const P=c.scopeValue("formats",{key:w,ref:S,code:y.code.formats?(0,r._)`${y.code.formats}${(0,r.getProperty)(w)}`:void 0});a.fail$data(m(P))}function m(w){return(0,r._)`${w}.compare(${u}, ${l}) ${s[f].fail} 0`}},dependencies:["format"]};const i=a=>(a.addKeyword(t.formatLimitDefinition),a);t.default=i})(Sd),function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=$d,n=Sd,s=Q,o=new s.Name("fullFormats"),i=new s.Name("fastFormats"),a=(u,l={keywords:!0})=>{if(Array.isArray(l))return c(u,l,r.fullFormats,o),u;const[f,_]=l.mode==="fast"?[r.fastFormats,i]:[r.fullFormats,o],y=l.formats||r.formatNames;return c(u,y,f,_),l.keywords&&(0,n.default)(u),u};a.get=(u,l="full")=>{const _=(l==="fast"?r.fastFormats:r.fullFormats)[u];if(!_)throw new Error(`Unknown format "${u}"`);return _};function c(u,l,f,_){var y,g;(y=(g=u.opts.code).formats)!==null&&y!==void 0||(g.formats=(0,s._)`require("ajv-formats/dist/formats").${_}`);for(const v of l)u.addFormat(v,f[v])}t.exports=e=a,Object.defineProperty(e,"__esModule",{value:!0}),e.default=a}(Ki,Ki.exports);var n$=Ki.exports;const s$=_r(n$);function o$(){const t=new ai.Ajv({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return s$(t),t}class kd{constructor(e){this._ajv=e??o$()}getValidator(e){var r;const n="$id"in e&&typeof e.$id=="string"?(r=this._ajv.getSchema(e.$id))!==null&&r!==void 0?r:this._ajv.compile(e):this._ajv.compile(e);return s=>n(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}}function Ms(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 o=n[s];r[s]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(r[s]=o.default),r[s]!==void 0&&Ms(o,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)Ms(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)Ms(r,e)}}function i$(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 In extends yd{constructor(e,r){var n,s;super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(n=r==null?void 0:r.capabilities)!==null&&n!==void 0?n:{},this._jsonSchemaValidator=(s=r==null?void 0:r.jsonSchemaValidator)!==null&&s!==void 0?s:new kd}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=wd(this._capabilities,e)}setRequestHandler(e,r){var n,s,o;const i=xn(e),a=i==null?void 0:i.method;if(!a)throw new Error("Schema is missing a method literal");let c;if(_t(a)){const l=a,f=(n=l._zod)===null||n===void 0?void 0:n.def;c=(s=f==null?void 0:f.value)!==null&&s!==void 0?s:l.value}else{const l=a,f=l._def;c=(o=f==null?void 0:f.value)!==null&&o!==void 0?o:l.value}if(typeof c!="string")throw new Error("Schema method literal must be a string");if(c==="elicitation/create"){const l=async(f,_)=>{var y,g,v;const h=As(zi,f);if(!h.success){const G=h.error instanceof Error?h.error.message:String(h.error);throw new ae(ie.InvalidParams,`Invalid elicitation request: ${G}`)}const{params:d}=h.data,m=(y=d.mode)!==null&&y!==void 0?y:"form",{supportsFormMode:w,supportsUrlMode:S}=i$(this._capabilities.elicitation);if(m==="form"&&!w)throw new ae(ie.InvalidParams,"Client does not support form-mode elicitation requests");if(m==="url"&&!S)throw new ae(ie.InvalidParams,"Client does not support URL-mode elicitation requests");const P=await Promise.resolve(r(f,_)),O=As(fn,P);if(!O.success){const G=O.error instanceof Error?O.error.message:String(O.error);throw new ae(ie.InvalidParams,`Invalid elicitation result: ${G}`)}const V=O.data,ce=m==="form"?d.requestedSchema:void 0;if(m==="form"&&V.action==="accept"&&V.content&&ce&&!((v=(g=this._capabilities.elicitation)===null||g===void 0?void 0:g.form)===null||v===void 0)&&v.applyDefaults)try{Ms(ce,V.content)}catch{}return V};return super.setRequestHandler(e,l)}return super.setRequestHandler(e,r)}assertCapability(e,r){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[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:ln,capabilities:this._capabilities,clientInfo:this._clientInfo}},bl,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!ll.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"})}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var r,n,s,o,i;switch(e){case"logging/setLevel":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.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(!(!((s=this._serverCapabilities)===null||s===void 0)&&s.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(!(!((o=this._serverCapabilities)===null||o===void 0)&&o.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((i=this._serverCapabilities)===null||i===void 0)&&i.completions))throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){var r;switch(e){case"notifications/roots/list_changed":if(!(!((r=this._capabilities.roots)===null||r===void 0)&&r.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){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}}async ping(e){return this.request({method:"ping"},Jt,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Vl,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Jt,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},zl,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Ol,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},El,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Pl,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},Tl,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Jt,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Jt,r)}async callTool(e,r=ks,n){const s=await this.request({method:"tools/call",params:e},r,n),o=this.getToolOutputValidator(e.name);if(o){if(!s.structuredContent&&!s.isError)throw new ae(ie.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const i=o(s.structuredContent);if(!i.valid)throw new ae(ie.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof ae?i:new ae(ie.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return s}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(const r of e)if(r.outputSchema){const n=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,n)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){const n=await this.request({method:"tools/list",params:e},Ll,r);return this.cacheToolOutputSchemas(n.tools),n}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}class Ed 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}}function Gi(t){}function Pd(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=Gi,onError:r=Gi,onRetry:n=Gi,onComment:s}=t;let o="",i=!0,a,c="",u="";function l(v){const h=i?v.replace(/^\xEF\xBB\xBF/,""):v,[d,m]=a$(`${o}${h}`);for(const w of d)f(w);o=m,i=!1}function f(v){if(v===""){y();return}if(v.startsWith(":")){s&&s(v.slice(v.startsWith(": ")?2:1));return}const h=v.indexOf(":");if(h!==-1){const d=v.slice(0,h),m=v[h+1]===" "?2:1,w=v.slice(h+m);_(d,w,v);return}_(v,"",v)}function _(v,h,d){switch(v){case"event":u=h;break;case"data":c=`${c}${h}
40
- `;break;case"id":a=h.includes("\0")?void 0:h;break;case"retry":/^\d+$/.test(h)?n(parseInt(h,10)):r(new Ed(`Invalid \`retry\` value: "${h}"`,{type:"invalid-retry",value:h,line:d}));break;default:r(new Ed(`Unknown field "${v.length>20?`${v.slice(0,20)}…`:v}"`,{type:"unknown-field",field:v,value:h,line:d}));break}}function y(){c.length>0&&e({id:a,event:u||void 0,data:c.endsWith(`
41
- `)?c.slice(0,-1):c}),a=void 0,c="",u=""}function g(v={}){o&&v.consume&&f(o),i=!0,a=void 0,c="",u="",o=""}return{feed:l,reset:g}}function a$(t){const e=[];let r="",n=0;for(;n<t.length;){const s=t.indexOf("\r",n),o=t.indexOf(`
42
- `,n);let i=-1;if(s!==-1&&o!==-1?i=Math.min(s,o):s!==-1?s===t.length-1?i=-1:i=s:o!==-1&&(i=o),i===-1){r=t.slice(n);break}else{const a=t.slice(n,i);e.push(a),n=i+1,t[n-1]==="\r"&&t[n]===`
43
- `&&n++}}return[e,r]}class Td extends Event{constructor(e,r){var n,s;super(e),this.code=(n=r==null?void 0:r.code)!=null?n:void 0,this.message=(s=r==null?void 0:r.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,n){return n(xd(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(xd(this),r)}}function c$(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Yi(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Yi).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Yi(t.cause)}`:t.message:`${t}`}function xd(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Rd=t=>{throw TypeError(t)},Xi=(t,e,r)=>e.has(t)||Rd("Cannot "+r),ne=(t,e,r)=>(Xi(t,e,"read from private field"),r?r.call(t):e.get(t)),je=(t,e,r)=>e.has(t)?Rd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),$e=(t,e,r,n)=>(Xi(t,e,"write to private field"),e.set(t,r),r),zt=(t,e,r)=>(Xi(t,e,"access private method"),r),Xe,hr,Ar,Zs,Ls,Cn,zr,On,Xt,Mr,Zr,Lr,Nn,yt,Qi,ea,ta,Id,ra,na,jn,sa,oa;class Us extends EventTarget{constructor(e,r){var n,s;super(),je(this,yt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,je(this,Xe),je(this,hr),je(this,Ar),je(this,Zs),je(this,Ls),je(this,Cn),je(this,zr),je(this,On,null),je(this,Xt),je(this,Mr),je(this,Zr,null),je(this,Lr,null),je(this,Nn,null),je(this,ea,async o=>{var i;ne(this,Mr).reset();const{body:a,redirected:c,status:u,headers:l}=o;if(u===204){zt(this,yt,jn).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?$e(this,Ar,new URL(o.url)):$e(this,Ar,void 0),u!==200){zt(this,yt,jn).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){zt(this,yt,jn).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(ne(this,Xe)===this.CLOSED)return;$e(this,Xe,this.OPEN);const f=new Event("open");if((i=ne(this,Nn))==null||i.call(this,f),this.dispatchEvent(f),typeof a!="object"||!a||!("getReader"in a)){zt(this,yt,jn).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}const _=new TextDecoder,y=a.getReader();let g=!0;do{const{done:v,value:h}=await y.read();h&&ne(this,Mr).feed(_.decode(h,{stream:!v})),v&&(g=!1,ne(this,Mr).reset(),zt(this,yt,sa).call(this))}while(g)}),je(this,ta,o=>{$e(this,Xt,void 0),!(o.name==="AbortError"||o.type==="aborted")&&zt(this,yt,sa).call(this,Yi(o))}),je(this,ra,o=>{typeof o.id=="string"&&$e(this,On,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:ne(this,Ar)?ne(this,Ar).origin:ne(this,hr).origin,lastEventId:o.id||""});ne(this,Lr)&&(!o.event||o.event==="message")&&ne(this,Lr).call(this,i),this.dispatchEvent(i)}),je(this,na,o=>{$e(this,Cn,o)}),je(this,oa,()=>{$e(this,zr,void 0),ne(this,Xe)===this.CONNECTING&&zt(this,yt,Qi).call(this)});try{if(e instanceof URL)$e(this,hr,e);else if(typeof e=="string")$e(this,hr,new URL(e,u$()));else throw new Error("Invalid URL")}catch{throw c$("An invalid or illegal string was specified")}$e(this,Mr,Pd({onEvent:ne(this,ra),onRetry:ne(this,na)})),$e(this,Xe,this.CONNECTING),$e(this,Cn,3e3),$e(this,Ls,(n=r==null?void 0:r.fetch)!=null?n:globalThis.fetch),$e(this,Zs,(s=r==null?void 0:r.withCredentials)!=null?s:!1),zt(this,yt,Qi).call(this)}get readyState(){return ne(this,Xe)}get url(){return ne(this,hr).href}get withCredentials(){return ne(this,Zs)}get onerror(){return ne(this,Zr)}set onerror(e){$e(this,Zr,e)}get onmessage(){return ne(this,Lr)}set onmessage(e){$e(this,Lr,e)}get onopen(){return ne(this,Nn)}set onopen(e){$e(this,Nn,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(){ne(this,zr)&&clearTimeout(ne(this,zr)),ne(this,Xe)!==this.CLOSED&&(ne(this,Xt)&&ne(this,Xt).abort(),$e(this,Xe,this.CLOSED),$e(this,Xt,void 0))}}Xe=new WeakMap,hr=new WeakMap,Ar=new WeakMap,Zs=new WeakMap,Ls=new WeakMap,Cn=new WeakMap,zr=new WeakMap,On=new WeakMap,Xt=new WeakMap,Mr=new WeakMap,Zr=new WeakMap,Lr=new WeakMap,Nn=new WeakMap,yt=new WeakSet,Qi=function(){$e(this,Xe,this.CONNECTING),$e(this,Xt,new AbortController),ne(this,Ls)(ne(this,hr),zt(this,yt,Id).call(this)).then(ne(this,ea)).catch(ne(this,ta))},ea=new WeakMap,ta=new WeakMap,Id=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...ne(this,On)?{"Last-Event-ID":ne(this,On)}:void 0},cache:"no-store",signal:(t=ne(this,Xt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},ra=new WeakMap,na=new WeakMap,jn=function(t,e){var r;ne(this,Xe)!==this.CLOSED&&$e(this,Xe,this.CLOSED);const n=new Td("error",{code:e,message:t});(r=ne(this,Zr))==null||r.call(this,n),this.dispatchEvent(n)},sa=function(t,e){var r;if(ne(this,Xe)===this.CLOSED)return;$e(this,Xe,this.CONNECTING);const n=new Td("error",{code:e,message:t});(r=ne(this,Zr))==null||r.call(this,n),this.dispatchEvent(n),$e(this,zr,setTimeout(ne(this,oa),ne(this,Cn)))},oa=new WeakMap,Us.CONNECTING=0,Us.OPEN=1,Us.CLOSED=2;function u$(){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 ia(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function Cd(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n!=null&&n.headers?{...ia(e.headers),...ia(n.headers)}:e.headers};return t(r,s)}:t}let aa;aa=globalThis.crypto;async function l$(t){return(await aa).getRandomValues(new Uint8Array(t))}async function d$(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let n="";for(;n.length<t;){const s=await l$(t-n.length);for(const o of s)o<r&&(n+=e[o%e.length])}return n}async function f$(t){return await d$(t)}async function h$(t){const e=await(await aa).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function p$(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await f$(t),r=await h$(e);return{code_verifier:e,code_challenge:r}}const Le=dy().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:n0.custom,message:"URL must be parseable",fatal:!0}),u_}).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"}),m$=ut({resource:$().url(),authorization_servers:j(Le).optional(),jwks_uri:$().url().optional(),scopes_supported:j($()).optional(),bearer_methods_supported:j($()).optional(),resource_signing_alg_values_supported:j($()).optional(),resource_name:$().optional(),resource_documentation:$().optional(),resource_policy_uri:$().url().optional(),resource_tos_uri:$().url().optional(),tls_client_certificate_bound_access_tokens:we().optional(),authorization_details_types_supported:j($()).optional(),dpop_signing_alg_values_supported:j($()).optional(),dpop_bound_access_tokens_required:we().optional()}),Od=ut({issuer:$(),authorization_endpoint:Le,token_endpoint:Le,registration_endpoint:Le.optional(),scopes_supported:j($()).optional(),response_types_supported:j($()),response_modes_supported:j($()).optional(),grant_types_supported:j($()).optional(),token_endpoint_auth_methods_supported:j($()).optional(),token_endpoint_auth_signing_alg_values_supported:j($()).optional(),service_documentation:Le.optional(),revocation_endpoint:Le.optional(),revocation_endpoint_auth_methods_supported:j($()).optional(),revocation_endpoint_auth_signing_alg_values_supported:j($()).optional(),introspection_endpoint:$().optional(),introspection_endpoint_auth_methods_supported:j($()).optional(),introspection_endpoint_auth_signing_alg_values_supported:j($()).optional(),code_challenge_methods_supported:j($()).optional(),client_id_metadata_document_supported:we().optional()}),_$=ut({issuer:$(),authorization_endpoint:Le,token_endpoint:Le,userinfo_endpoint:Le.optional(),jwks_uri:Le,registration_endpoint:Le.optional(),scopes_supported:j($()).optional(),response_types_supported:j($()),response_modes_supported:j($()).optional(),grant_types_supported:j($()).optional(),acr_values_supported:j($()).optional(),subject_types_supported:j($()),id_token_signing_alg_values_supported:j($()),id_token_encryption_alg_values_supported:j($()).optional(),id_token_encryption_enc_values_supported:j($()).optional(),userinfo_signing_alg_values_supported:j($()).optional(),userinfo_encryption_alg_values_supported:j($()).optional(),userinfo_encryption_enc_values_supported:j($()).optional(),request_object_signing_alg_values_supported:j($()).optional(),request_object_encryption_alg_values_supported:j($()).optional(),request_object_encryption_enc_values_supported:j($()).optional(),token_endpoint_auth_methods_supported:j($()).optional(),token_endpoint_auth_signing_alg_values_supported:j($()).optional(),display_values_supported:j($()).optional(),claim_types_supported:j($()).optional(),claims_supported:j($()).optional(),service_documentation:$().optional(),claims_locales_supported:j($()).optional(),ui_locales_supported:j($()).optional(),claims_parameter_supported:we().optional(),request_parameter_supported:we().optional(),request_uri_parameter_supported:we().optional(),require_request_uri_registration:we().optional(),op_policy_uri:Le.optional(),op_tos_uri:Le.optional(),client_id_metadata_document_supported:we().optional()}),g$=z({..._$.shape,...Od.pick({code_challenge_methods_supported:!0}).shape}),Nd=z({access_token:$(),id_token:$().optional(),token_type:$(),expires_in:be().optional(),scope:$().optional(),refresh_token:$().optional()}).strip(),v$=z({error:$(),error_description:$().optional(),error_uri:$().optional()}),jd=Le.optional().or(W("").transform(()=>{})),y$=z({redirect_uris:j(Le),token_endpoint_auth_method:$().optional(),grant_types:j($()).optional(),response_types:j($()).optional(),client_name:$().optional(),client_uri:Le.optional(),logo_uri:jd,scope:$().optional(),contacts:j($()).optional(),tos_uri:jd,policy_uri:$().optional(),jwks_uri:Le.optional(),jwks:Iy().optional(),software_id:$().optional(),software_version:$().optional(),software_statement:$().optional()}).strip(),b$=z({client_id:$(),client_secret:$().optional(),client_id_issued_at:be().optional(),client_secret_expires_at:be().optional()}).strip(),w$=y$.merge(b$);z({error:$(),error_description:$().optional()}).strip(),z({token:$(),token_type_hint:$().optional()}).strip();function $$(t){const e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function S$({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+"/",o=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return s.startsWith(o)}class Ue 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 ca extends Ue{}ca.errorCode="invalid_request";class Ds extends Ue{}Ds.errorCode="invalid_client";class qs extends Ue{}qs.errorCode="invalid_grant";class Vs extends Ue{}Vs.errorCode="unauthorized_client";class ua extends Ue{}ua.errorCode="unsupported_grant_type";class la extends Ue{}la.errorCode="invalid_scope";class da extends Ue{}da.errorCode="access_denied";class Ur extends Ue{}Ur.errorCode="server_error";class fa extends Ue{}fa.errorCode="temporarily_unavailable";class ha extends Ue{}ha.errorCode="unsupported_response_type";class pa extends Ue{}pa.errorCode="unsupported_token_type";class ma extends Ue{}ma.errorCode="invalid_token";class _a extends Ue{}_a.errorCode="method_not_allowed";class ga extends Ue{}ga.errorCode="too_many_requests";class Fs extends Ue{}Fs.errorCode="invalid_client_metadata";class va extends Ue{}va.errorCode="insufficient_scope";const k$={[ca.errorCode]:ca,[Ds.errorCode]:Ds,[qs.errorCode]:qs,[Vs.errorCode]:Vs,[ua.errorCode]:ua,[la.errorCode]:la,[da.errorCode]:da,[Ur.errorCode]:Ur,[fa.errorCode]:fa,[ha.errorCode]:ha,[pa.errorCode]:pa,[ma.errorCode]:ma,[_a.errorCode]:_a,[ga.errorCode]:ga,[Fs.errorCode]:Fs,[va.errorCode]:va};class st extends Error{constructor(e){super(e??"Unauthorized")}}function E$(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const ya="code",ba="S256";function Ad(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&&E$(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 zd(t,e,r,n){const{client_id:s,client_secret:o}=e;switch(t){case"client_secret_basic":P$(s,o,r);return;case"client_secret_post":T$(s,o,n);return;case"none":x$(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function P$(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 T$(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function x$(t,e){e.set("client_id",t)}async function wa(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=v$.parse(JSON.parse(r)),{error:s,error_description:o,error_uri:i}=n,a=k$[s]||Ur;return new a(o||"",i)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new Ur(s)}}async function pr(t,e){var r,n;try{return await $a(t,e)}catch(s){if(s instanceof Ds||s instanceof Vs)return await((r=t.invalidateCredentials)===null||r===void 0?void 0:r.call(t,"all")),await $a(t,e);if(s instanceof qs)return await((n=t.invalidateCredentials)===null||n===void 0?void 0:n.call(t,"tokens")),await $a(t,e);throw s}}async function $a(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:o}){var i,a;let c,u;try{c=await C$(e,{resourceMetadataUrl:s},o),c.authorization_servers&&c.authorization_servers.length>0&&(u=c.authorization_servers[0])}catch{}u||(u=new URL("/",e));const l=await I$(e,t,c),f=await z$(u,{fetchFn:o});let _=await Promise.resolve(t.clientInformation());if(!_){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const d=(f==null?void 0:f.client_id_metadata_document_supported)===!0,m=t.clientMetadataUrl;if(m&&!R$(m))throw new Fs(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${m}`);if(d&&m)_={client_id:m},await((i=t.saveClientInformation)===null||i===void 0?void 0:i.call(t,_));else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const S=await U$(u,{metadata:f,clientMetadata:t.clientMetadata,fetchFn:o});await t.saveClientInformation(S),_=S}}if(r!==void 0){const d=await t.codeVerifier(),m=await Z$(u,{metadata:f,clientInformation:_,authorizationCode:r,codeVerifier:d,redirectUri:t.redirectUrl,resource:l,addClientAuthentication:t.addClientAuthentication,fetchFn:o});return await t.saveTokens(m),"AUTHORIZED"}const y=await t.tokens();if(y!=null&&y.refresh_token)try{const d=await L$(u,{metadata:f,clientInformation:_,refreshToken:y.refresh_token,resource:l,addClientAuthentication:t.addClientAuthentication,fetchFn:o});return await t.saveTokens(d),"AUTHORIZED"}catch(d){if(!(!(d instanceof Ue)||d instanceof Ur))throw d}const g=t.state?await t.state():void 0,{authorizationUrl:v,codeVerifier:h}=await M$(u,{metadata:f,clientInformation:_,state:g,redirectUrl:t.redirectUrl,scope:n||((a=c==null?void 0:c.scopes_supported)===null||a===void 0?void 0:a.join(" "))||t.clientMetadata.scope,resource:l});return await t.saveCodeVerifier(h),await t.redirectToAuthorization(v),"REDIRECT"}function R$(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function I$(t,e,r){const n=$$(t);if(e.validateResourceURL)return await e.validateResourceURL(n,r==null?void 0:r.resource);if(r){if(!S$({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 Hs(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=Sa(t,"resource_metadata")||void 0;let o;if(s)try{o=new URL(s)}catch{}const i=Sa(t,"scope")||void 0,a=Sa(t,"error")||void 0;return{resourceMetadataUrl:o,scope:i,error:a}}function Sa(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}async function C$(t,e,r=fetch){const n=await j$(t,"oauth-protected-resource",r,{protocolVersion:e==null?void 0:e.protocolVersion,metadataUrl:e==null?void 0:e.resourceMetadataUrl});if(!n||n.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return m$.parse(await n.json())}async function ka(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?ka(t,void 0,r):void 0;throw n}}function O$(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function Md(t,e,r=fetch){return await ka(t,{"MCP-Protocol-Version":e},r)}function N$(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function j$(t,e,r,n){var s,o;const i=new URL(t),a=(s=n==null?void 0:n.protocolVersion)!==null&&s!==void 0?s:ln;let c;if(n!=null&&n.metadataUrl)c=new URL(n.metadataUrl);else{const l=O$(e,i.pathname);c=new URL(l,(o=n==null?void 0:n.metadataServerUrl)!==null&&o!==void 0?o:i),c.search=i.search}let u=await Md(c,a,r);if(!(n!=null&&n.metadataUrl)&&N$(u,i.pathname)){const l=new URL(`/.well-known/${e}`,i);u=await Md(l,a,r)}return u}function A$(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 z$(t,{fetchFn:e=fetch,protocolVersion:r=ln}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=A$(t);for(const{url:o,type:i}of s){const a=await ka(o,n,e);if(a){if(!a.ok){if(a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${o}`)}return i==="oauth"?Od.parse(await a.json()):g$.parse(await a.json())}}}async function M$(t,{metadata:e,clientInformation:r,redirectUrl:n,scope:s,state:o,resource:i}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(ya))throw new Error(`Incompatible auth server: does not support response type ${ya}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(ba))throw new Error(`Incompatible auth server: does not support code challenge method ${ba}`)}else a=new URL("/authorize",t);const c=await p$(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",ya),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",ba),a.searchParams.set("redirect_uri",String(n)),o&&a.searchParams.set("state",o),s&&a.searchParams.set("scope",s),s!=null&&s.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}async function Z$(t,{metadata:e,clientInformation:r,authorizationCode:n,codeVerifier:s,redirectUri:o,resource:i,addClientAuthentication:a,fetchFn:c}){var u;const l="authorization_code",f=e!=null&&e.token_endpoint?new URL(e.token_endpoint):new URL("/token",t);if(e!=null&&e.grant_types_supported&&!e.grant_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support grant type ${l}`);const _=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),y=new URLSearchParams({grant_type:l,code:n,code_verifier:s,redirect_uri:String(o)});if(a)a(_,y,t,e);else{const v=(u=e==null?void 0:e.token_endpoint_auth_methods_supported)!==null&&u!==void 0?u:[],h=Ad(r,v);zd(h,r,_,y)}i&&y.set("resource",i.href);const g=await(c??fetch)(f,{method:"POST",headers:_,body:y});if(!g.ok)throw await wa(g);return Nd.parse(await g.json())}async function L$(t,{metadata:e,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:o,fetchFn:i}){var a;const c="refresh_token";let u;if(e){if(u=new URL(e.token_endpoint),e.grant_types_supported&&!e.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`)}else u=new URL("/token",t);const l=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),f=new URLSearchParams({grant_type:c,refresh_token:n});if(o)o(l,f,t,e);else{const y=(a=e==null?void 0:e.token_endpoint_auth_methods_supported)!==null&&a!==void 0?a:[],g=Ad(r,y);zd(g,r,l,f)}s&&f.set("resource",s.href);const _=await(i??fetch)(u,{method:"POST",headers:l,body:f});if(!_.ok)throw await wa(_);return Nd.parse({refresh_token:n,...await _.json()})}async function U$(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 o=await(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok)throw await wa(o);return w$.parse(await o.json())}class D$ extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}}class An{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r==null?void 0:r.eventSourceInit,this._requestInit=r==null?void 0:r.requestInit,this._authProvider=r==null?void 0:r.authProvider,this._fetch=r==null?void 0:r.fetch,this._fetchWithInit=Cd(r==null?void 0:r.fetch,r==null?void 0:r.requestInit)}async _authThenStart(){var e;if(!this._authProvider)throw new st("No auth provider");let r;try{r=await pr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new st;return await this._startOrAuth()}async _commonHeaders(){var e;const r={};if(this._authProvider){const n=await this._authProvider.tokens();n&&(r.Authorization=`Bearer ${n.access_token}`)}return this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion),new Headers({...r,...(e=this._requestInit)===null||e===void 0?void 0:e.headers})}_startOrAuth(){var e,r,n;const s=(n=(r=(e=this===null||this===void 0?void 0:this._eventSourceInit)===null||e===void 0?void 0:e.fetch)!==null&&r!==void 0?r:this._fetch)!==null&&n!==void 0?n:fetch;return new Promise((o,i)=>{this._eventSource=new Us(this._url.href,{...this._eventSourceInit,fetch:async(a,c)=>{const u=await this._commonHeaders();u.set("Accept","text/event-stream");const l=await s(a,{...c,headers:u});if(l.status===401&&l.headers.has("www-authenticate")){const{resourceMetadataUrl:f,scope:_}=Hs(l);this._resourceMetadataUrl=f,this._scope=_}return l}}),this._abortController=new AbortController,this._eventSource.onerror=a=>{var c;if(a.code===401&&this._authProvider){this._authThenStart().then(o,i);return}const u=new D$(a.code,a.message,a);i(u),(c=this.onerror)===null||c===void 0||c.call(this,u)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",a=>{var c;const u=a;try{if(this._endpoint=new URL(u.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(l){i(l),(c=this.onerror)===null||c===void 0||c.call(this,l),this.close();return}o()}),this._eventSource.onmessage=a=>{var c,u;const l=a;let f;try{f=cr.parse(JSON.parse(l.data))}catch(_){(c=this.onerror)===null||c===void 0||c.call(this,_);return}(u=this.onmessage)===null||u===void 0||u.call(this,f)}})}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 st("No auth provider");if(await pr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new st("Failed to authorize")}async close(){var e,r,n;(e=this._abortController)===null||e===void 0||e.abort(),(r=this._eventSource)===null||r===void 0||r.close(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(e){var r,n,s;if(!this._endpoint)throw new Error("Not connected");try{const o=await this._commonHeaders();o.set("content-type","application/json");const i={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:(r=this._abortController)===null||r===void 0?void 0:r.signal},a=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._endpoint,i);if(!a.ok){if(a.status===401&&this._authProvider){const{resourceMetadataUrl:u,scope:l}=Hs(a);if(this._resourceMetadataUrl=u,this._scope=l,await pr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new st;return this.send(e)}const c=await a.text().catch(()=>null);throw new Error(`Error POSTing to endpoint (HTTP ${a.status}): ${c}`)}}catch(o){throw(s=this.onerror)===null||s===void 0||s.call(this,o),o}}setProtocolVersion(e){this._protocolVersion=e}}class q$ extends TransformStream{constructor({onError:e,onRetry:r,onComment:n}={}){let s;super({start(o){s=Pd({onEvent:i=>{o.enqueue(i)},onError(i){e==="terminate"?o.error(i):typeof e=="function"&&e(i)},onRetry:r,onComment:n})},transform(o){s.feed(o)}})}}const V$={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class zn extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}}class Ws{constructor(e,r){var n;this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r==null?void 0:r.requestInit,this._authProvider=r==null?void 0:r.authProvider,this._fetch=r==null?void 0:r.fetch,this._fetchWithInit=Cd(r==null?void 0:r.fetch,r==null?void 0:r.requestInit),this._sessionId=r==null?void 0:r.sessionId,this._reconnectionOptions=(n=r==null?void 0:r.reconnectionOptions)!==null&&n!==void 0?n:V$}async _authThenStart(){var e;if(!this._authProvider)throw new st("No auth provider");let r;try{r=await pr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw(e=this.onerror)===null||e===void 0||e.call(this,n),n}if(r!=="AUTHORIZED")throw new st;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const r={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(r.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(r["mcp-session-id"]=this._sessionId),this._protocolVersion&&(r["mcp-protocol-version"]=this._protocolVersion);const n=ia((e=this._requestInit)===null||e===void 0?void 0:e.headers);return new Headers({...r,...n})}async _startOrAuthSse(e){var r,n,s;const{resumptionToken:o}=e;try{const i=await this._commonHeaders();i.set("Accept","text/event-stream"),o&&i.set("last-event-id",o);const a=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,{method:"GET",headers:i,signal:(n=this._abortController)===null||n===void 0?void 0:n.signal});if(!a.ok){if(a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new zn(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,e,!0)}catch(i){throw(s=this.onerror)===null||s===void 0||s.call(this,i),i}}_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){var n;const s=this._reconnectionOptions.maxRetries;if(s>0&&r>=s){(n=this.onerror)===null||n===void 0||n.call(this,new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const o=this._getNextReconnectionDelay(r);setTimeout(()=>{this._startOrAuthSse(e).catch(i=>{var a;(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Failed to reconnect SSE stream: ${i instanceof Error?i.message:String(i)}`)),this._scheduleReconnection(e,r+1)})},o)}_handleSseStream(e,r,n){if(!e)return;const{onresumptiontoken:s,replayMessageId:o}=r;let i,a=!1;(async()=>{var u,l,f,_;try{const y=e.pipeThrough(new TextDecoderStream).pipeThrough(new q$({onRetry:v=>{this._serverRetryMs=v}})).getReader();for(;;){const{value:v,done:h}=await y.read();if(h)break;if(v.id&&(i=v.id,a=!0,s==null||s(v.id)),!v.event||v.event==="message")try{const d=cr.parse(JSON.parse(v.data));o!==void 0&&wi(d)&&(d.id=o),(u=this.onmessage)===null||u===void 0||u.call(this,d)}catch(d){(l=this.onerror)===null||l===void 0||l.call(this,d)}}(n||a)&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:o},0)}catch(y){if((f=this.onerror)===null||f===void 0||f.call(this,new Error(`SSE stream disconnected: ${y}`)),(n||a)&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:o},0)}catch(v){(_=this.onerror)===null||_===void 0||_.call(this,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 st("No auth provider");if(await pr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new st("Failed to authorize")}async close(){var e,r;(e=this._abortController)===null||e===void 0||e.abort(),(r=this.onclose)===null||r===void 0||r.call(this)}async send(e,r){var n,s,o,i;try{const{resumptionToken:a,onresumptiontoken:c}=r||{};if(a){this._startOrAuthSse({resumptionToken:a,replayMessageId:pl(e)?e.id:void 0}).catch(h=>{var d;return(d=this.onerror)===null||d===void 0?void 0:d.call(this,h)});return}const u=await this._commonHeaders();u.set("content-type","application/json"),u.set("accept","application/json, text/event-stream");const l={...this._requestInit,method:"POST",headers:u,body:JSON.stringify(e),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},f=await((s=this._fetch)!==null&&s!==void 0?s:fetch)(this._url,l),_=f.headers.get("mcp-session-id");if(_&&(this._sessionId=_),!f.ok){if(f.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new zn(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:d,scope:m}=Hs(f);if(this._resourceMetadataUrl=d,this._scope=m,await pr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new st;return this._hasCompletedAuthFlow=!0,this.send(e)}if(f.status===403&&this._authProvider){const{resourceMetadataUrl:d,scope:m,error:w}=Hs(f);if(w==="insufficient_scope"){const S=f.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===S)throw new zn(403,"Server returned 403 after trying upscoping");if(m&&(this._scope=m),d&&(this._resourceMetadataUrl=d),this._lastUpscopingHeader=S??void 0,await pr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new st;return this.send(e)}}const h=await f.text().catch(()=>null);throw new Error(`Error POSTing to endpoint (HTTP ${f.status}): ${h}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,f.status===202){p0(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(h=>{var d;return(d=this.onerror)===null||d===void 0?void 0:d.call(this,h)});return}const g=(Array.isArray(e)?e:[e]).filter(h=>"method"in h&&"id"in h&&h.id!==void 0).length>0,v=f.headers.get("content-type");if(g)if(v!=null&&v.includes("text/event-stream"))this._handleSseStream(f.body,{onresumptiontoken:c},!1);else if(v!=null&&v.includes("application/json")){const h=await f.json(),d=Array.isArray(h)?h.map(m=>cr.parse(m)):[cr.parse(h)];for(const m of d)(o=this.onmessage)===null||o===void 0||o.call(this,m)}else throw new zn(-1,`Unexpected content type: ${v}`)}catch(a){throw(i=this.onerror)===null||i===void 0||i.call(this,a),a}}get sessionId(){return this._sessionId}async terminateSession(){var e,r,n;if(this._sessionId)try{const s=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:s,signal:(e=this._abortController)===null||e===void 0?void 0:e.signal},i=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,o);if(!i.ok&&i.status!==405)throw new zn(i.status,`Failed to terminate session: ${i.statusText}`);this._sessionId=void 0}catch(s){throw(n=this.onerror)===null||n===void 0||n.call(this,s),s}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r==null?void 0:r.onresumptiontoken})}}const F$="mcp";class Zd{constructor(e){this._url=e}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._socket=new WebSocket(this._url,F$),this._socket.onerror=n=>{var s;const o="error"in n?n.error:new Error(`WebSocket error: ${JSON.stringify(n)}`);r(o),(s=this.onerror)===null||s===void 0||s.call(this,o)},this._socket.onopen=()=>{e()},this._socket.onclose=()=>{var n;(n=this.onclose)===null||n===void 0||n.call(this)},this._socket.onmessage=n=>{var s,o;let i;try{i=cr.parse(JSON.parse(n.data))}catch(a){(s=this.onerror)===null||s===void 0||s.call(this,a);return}(o=this.onmessage)===null||o===void 0||o.call(this,i)}})}async close(){var e;(e=this._socket)===null||e===void 0||e.close()}send(e){return new Promise((r,n)=>{var s;if(!this._socket){n(new Error("Not connected"));return}(s=this._socket)===null||s===void 0||s.send(JSON.stringify(e)),r()})}}function Js(){const t=["224340fQYLJj","function","onmessage","port2","341XVdnBD","313767JEBgqL","950bpstaX","1354759gUhUbE","wRKyh","onclose","2044SvCTUj","endpoint","24msSkHx","164VuWYGY","mOWMr","EkZCC","addEventListener","postMessage","120705iyGzUz","8878392ivIdKn","close","_listen","3619482FaLQHc","start","_endpoint","kgkem","bzNYT","MessageChannel transport error: ","stringify","onmessageerror","HvyCv","undefined","Jwyua","message","_globalObject","parse","authInfo","thraG","220pGvxgp","_port","EGhzU","onerror","data","MhriV"];return Js=function(){return t},Js()}(function(t,e){const r=Ce,n=Ce,s=t();for(;;)try{if(parseInt(r(417))/1*(parseInt(r(421))/2)+parseInt(r(433))/3+parseInt(r(424))/4*(-parseInt(n(429))/5)+parseInt(n(423))/6*(-parseInt(n(418))/7)+-parseInt(n(430))/8+-parseInt(r(416))/9*(-parseInt(r(405))/10)+-parseInt(r(415))/11*(-parseInt(r(411))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Js,650197);const Ld=()=>{const t=Ce,e={EGhzU:function(r,n){return r!==n},kIrDB:"undefined",llYQe:function(r,n){return r!==n},PZfJg:function(r,n){return r(n)},Jwyua:"return this"};return typeof globalThis<"u"?globalThis:e[t(407)](typeof window,e.kIrDB)?window:e.llYQe(typeof global,e.kIrDB)?global:typeof self!==t(398)?self:e.PZfJg(Function,e[t(399)])()},H$=(t,e,r)=>{const n=Ce,s=Ce,o={};o[n(410)]=s(398),o.dBkaX=function(a,c){return a===c},o[s(393)]="function";const i=o;typeof window!==i[s(410)]?t.postMessage(e,"*",r):s(428)in t&&i.dBkaX(typeof t.postMessage,i[n(393)])&&t.postMessage(e,r)},W$=(t,e)=>{const r=Ce,n=Ce,s={};s.MbsGh="addEventListener",s.PPniK=function(i,a){return i===a},s[r(419)]=n(412),s[n(404)]="onmessage",s[r(397)]="undefined";const o=s;o.MbsGh in t&&o.PPniK(typeof t[r(427)],o.wRKyh)?t[r(427)](r(400),e):o.thraG in t&&typeof t[n(413)]!==o[n(397)]&&(t.onmessage=e)};class Bs{constructor(e){const r=Ce;this[r(406)]=e}async start(){const e=Ce,r=Ce;this[e(406)]&&(this[e(406)][e(413)]=n=>{var s,o;const i=e,a=r;try{const c=cr[i(402)](n.data[i(400)]);(s=this[i(413)])==null||s.call(this,c,n[a(409)].extra)}catch(c){const u=new Error("MessageChannel failed to parse message: "+c);(o=this[a(408)])==null||o.call(this,u)}},this._port[e(396)]=n=>{var s;const o=r,i=r,a=new Error(o(394)+JSON[i(395)](n));(s=this.onerror)==null||s.call(this,a)},this[e(406)][e(434)]())}async send(e,r){const n={lEyuq:function(s){return s()},YihNw:function(s,o){return s(o)}};return new Promise((s,o)=>{var i;const a=Ce,c=Ce;try{const u={};u[a(403)]=r==null?void 0:r[a(403)];const l={};l[c(400)]=e,l.extra=u,this[c(406)]&&this[a(406)].postMessage(l),n.lEyuq(s)}catch(u){const l=u instanceof Error?u:new Error(n.YihNw(String,u));(i=this[c(408)])==null||i.call(this,l),o(l)}})}async close(){var e,r;const n=Ce,s=Ce;(e=this._port)==null||e[n(431)](),this._port=void 0,(r=this[s(420)])==null||r.call(this)}}class Ea extends Bs{constructor(e,r=Ld()){const n=Ce,s=Ce,o={EkZCC:function(a,c,u,l){return a(c,u,l)}};super(),this[n(391)]=e,this[s(401)]=r;const i=new MessageChannel;this[s(406)]=i.port1,o[s(426)](H$,this[n(401)],{endpoint:this[s(391)]},[i[s(414)]])}}class Pa extends Bs{constructor(e,r=Ld()){const n=Ce,s={mOWMr:function(o,i){return o===i},kgkem:function(o,i,a){return o(i,a)}};super(),this._endpoint=e,this._globalObject=r,this[n(432)]=new Promise(o=>{const i=n,a=n;s[i(392)](W$,this[a(401)],c=>{const u=a,l=a;c.data&&s[u(425)](c.data[l(422)],this[l(391)])&&(this[l(406)]=c.ports[-1*4852+1*1601+3251],o())})})}async listen(){return this[Ce(432)]}}function Ce(t,e){const r=Js();return Ce=function(n,s){return n=n-(17*-491+-669+9407),r[n]},Ce(t,e)}const J$=()=>{const t=new MessageChannel;return[new Bs(t.port1),new Bs(t.port2)]};(function(t,e){const r=pe,n=pe,s=t();for(;;)try{if(parseInt(r(355))/1+-parseInt(r(356))/2*(-parseInt(r(373))/3)+-parseInt(r(337))/4+parseInt(n(357))/5+-parseInt(n(389))/6*(-parseInt(r(396))/7)+parseInt(n(325))/8*(parseInt(r(382))/9)+-parseInt(r(366))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Ks,-763475+-52067*10+1724410);const B$=async(t,e,r)=>{var n;const s=pe,o=pe,i={};i[s(345)]="tools/list",i.rqstG="tools/call",i.WqUnk="resources/list",i[s(329)]=o(358),i[s(365)]=s(335),i.ookoz="resources/unsubscribe",i[s(385)]=s(340),i.VTIWq="prompts/list",i.SkoRK=s(376),i.QUtUV=s(388),i.XtowM=o(332);const a=i,{id:c,method:u,params:l}=r;let f={};switch(u){case a[o(345)]:f=await e.listTools(l);break;case a.rqstG:f=await e.callTool(l);break;case a[s(334)]:f=await e[s(350)](l);break;case a[o(329)]:f=await e.listResourceTemplates(l);break;case s(372):f=await e[s(383)](l);break;case a.HgYgW:f=await e.subscribeResource(l);break;case a.ookoz:f=await e.unsubscribeResource(l);break;case a[s(385)]:f=await e.getPrompt(l);break;case a.VTIWq:f=await e.listPrompts(l);break;case a[s(344)]:f=await e[s(376)]();break;case a.QUtUV:f=await e.complete(l);break;case s(390):f=await e[s(336)](l==null?void 0:l.level);break}const _={};_[s(361)]=f,_[s(394)]=a[s(364)],_.id=c,await((n=t==null?void 0:t.transport)==null?void 0:n[s(392)](_))},K$=async(t,e,r)=>{var n;const s=pe,o=pe,i={};i.jQBBS="sampling/createMessage",i.EZqgC="elicitation/create",i[s(370)]=o(376),i.aVeaL=o(332);const a=i,{id:c,method:u,params:l}=r;let f={};switch(u){case s(368):const y={};y.method=u,y[o(367)]=l,f=await e.request(y,Zi);break;case a[o(391)]:const g={};g.method=u,g[o(367)]=l,f=await e[o(381)](g,Ai);break;case a.EZqgC:const v={};v.method=u,v.params=l,f=await e.request(v,fn);break;case a[o(370)]:const h={};h.method=u,f=await e[o(381)](h,Jt);break}const _={};return _[o(361)]=f,_.jsonrpc=a[o(387)],_.id=c,await((n=t==null?void 0:t[s(371)])==null?void 0:n.send(_)),f},G$=(t,e)=>{const r=pe,n={gXsjT:function(o,i){return o===i},oegpC:r(351),lZOUC:function(o,i,a,c){return o(i,a,c)},ifIKG:"2.0"},s=t._onrequest;t._onrequest=async(o,i)=>{var a,c,u,l,f;const _=r,y=r,{id:g,method:v}=o;try{n[_(333)](v,n.oegpC)?await s[_(386)](t,o,i):await n.lZOUC(B$,t,e,o)}catch(h){const{code:d,message:m,data:w}=h;try{if(d){const S={};S.code=d,S.message=m,S.data=w;const P={};P.error=S,P[_(394)]=n[y(331)],P.id=g,await((a=t==null?void 0:t.transport)==null?void 0:a.send(P))}else(u=(c=t==null?void 0:t[y(371)])==null?void 0:c.onerror)==null||u.call(c,h)}catch(S){(f=(l=t==null?void 0:t[_(371)])==null?void 0:l.onerror)==null||f.call(l,S)}}}},Y$=(t,e)=>{const r=pe,n=pe,s={};s[r(363)]=function(i,a){return i!==a},s[r(398)]=r(353),s.hzhyg="notifications/cancelled";const o=s;t._onnotification=async i=>{var a,c;const u=r,l=n,{method:f,params:_}=i;if(o[u(363)](f,o[l(398)])&&(o[u(363)](f,o.hzhyg)||_!=null&&_.forward))try{await e.notification(i)}catch(y){(c=(a=t==null?void 0:t.transport)==null?void 0:a.onerror)==null||c.call(a,y)}}},X$=(t,e)=>async r=>{var n,s,o,i,a;const c=pe,u=pe,l={};l.SEmWX=c(332);const f=l;try{return await K$(t,e,r)}catch(_){const{code:y,message:g,data:v}=_;try{if(y){const h={};h[u(377)]=y,h.message=g,h.data=v;const d={};d[u(348)]=h,d.jsonrpc=f[c(338)],d.id=r.id,await((n=t==null?void 0:t.transport)==null?void 0:n[u(392)](d))}else(o=(s=t==null?void 0:t.transport)==null?void 0:s[u(339)])==null||o.call(s,_)}catch(h){(a=(i=t==null?void 0:t[c(371)])==null?void 0:i[u(339)])==null||a.call(i,h)}}},Q$=(t,e)=>async r=>{var n,s,o;const i=pe,a=pe,c={};c.dtUgZ=function(_,y){return _!==y},c.jgCIb=i(353),c.uUjKY="2.0";const u=c,{method:l,params:f}=r;if(u.dtUgZ(l,u.jgCIb)&&(l!==i(400)||f!=null&&f.forward))try{const _={...r};_[i(394)]=u[a(352)],await((n=e==null?void 0:e[i(371)])==null?void 0:n[i(392)](_))}catch(_){(o=(s=t==null?void 0:t[i(371)])==null?void 0:s[a(339)])==null||o.call(s,_)}};function pe(t,e){const r=Ks();return pe=function(n,s){return n=n-(9*-113+-1439*-1+-97),r[n]},pe(t,e)}const e1=(t,e)=>async r=>{var n,s,o,i,a,c;const u=pe,l=pe,f={};f[u(401)]=l(332);const _=f;try{await((n=e==null?void 0:e.transport)==null?void 0:n.send(r))}catch(y){const{code:g,message:v,data:h}=y;try{if(g){const d={};d.code=g,d[u(399)]=v,d.data=h;const m={};m[u(348)]=d,m[u(394)]=_.OhJjz,m.id=r.id,await((s=t==null?void 0:t[u(371)])==null?void 0:s.send(m))}else(i=(o=t==null?void 0:t.transport)==null?void 0:o[l(339)])==null||i.call(o,y)}catch(d){(c=(a=t==null?void 0:t.transport)==null?void 0:a.onerror)==null||c.call(a,d)}}},Ta=()=>{const t=pe,e=pe,r={vnkqu:function(u,l){return u!==l},wxDWr:function(u,l){return u(l)},GdkkV:function(u,l){return u===l}},n=[],s=(u,l)=>{const f=pe,_=pe;if(l){const y=[];for(const g of n)try{y.push(g(u,l))}catch{}for(const g of y)if(r[f(379)](g,null))return g}else for(const y of n)try{r[_(343)](y,u)}catch{}},o=u=>{const l=pe;r[l(384)](typeof u,l(369))&&!n.includes(u)&&n.push(u)},i=u=>{const l=n.indexOf(u);l!==-1&&n.splice(l,1*-6854+8*-33+7119)},a=()=>{const u=pe;n[u(374)]=7102*1+5522+-526*24},c={};return c[t(346)]=s,c[e(330)]=o,c.removeListener=i,c[t(359)]=a,c},t1=t=>{const e=pe,r=pe,n={xwPeb:function(s){return s()},Mfvzm:function(s){return s()}};{const{handleListener:s,addListener:o,removeListener:i,clearListener:a}=n[e(326)](Ta);t._onresponse=s,t[e(395)]=o,t.removeResponseListener=i,t.clearResponseListener=a}{const{handleListener:s,addListener:o,removeListener:i,clearListener:a}=n[r(326)](Ta);t[r(328)]=s,t.addRequestListener=o,t[r(354)]=i,t[r(341)]=a}{const{handleListener:s,addListener:o,removeListener:i,clearListener:a}=n[e(375)](Ta);t[e(342)]=s,t[e(327)]=o,t.removeNotificationListener=i,t.clearNotificationListener=a}};function Ks(){const t=["uUjKY","notifications/initialized","removeRequestListener","96194JysfjF","36346SGEWAV","1357830AJaOeY","resources/templates/list","clearListener","iQqcJ","result","tqDZP","sSeCz","XtowM","HgYgW","3913230mjiatC","params","roots/list","function","bfmJT","transport","resources/read","27FNuDmk","length","Mfvzm","ping","code","_onresponse","vnkqu","cjSoZ","request","9gIMIPC","readResource","GdkkV","ptMjy","call","aVeaL","completion/complete","5035122lFbpzR","logging/setLevel","jQBBS","send","_requestHandlers","jsonrpc","addResponseListener","7SpcenI","ElOQH","MDIkN","message","notifications/cancelled","OhJjz","clear","672216JzFEyR","xwPeb","addNotificationListener","fallbackRequestHandler","sYzPD","addListener","ifIKG","2.0","gXsjT","WqUnk","resources/subscribe","setLoggingLevel","2491772kFUWFh","SEmWX","onerror","prompts/get","clearRequestListener","fallbackNotificationHandler","wxDWr","SkoRK","uTeHc","handleListener","Zybtx","error","originalOnResponse","listResources","initialize"];return Ks=function(){return t},Ks()}const r1=(t,{beforeInit:e,afterInit:r}={})=>{const n=pe,s=pe,o={tqDZP:function(a,c){return a===c},cjSoZ:"function",iQqcJ:n(378),Zybtx:function(a,c){return a(c)},ElOQH:function(a){return a()}},i=new Map(t._notificationHandlers);t[n(393)][n(402)](),t._notificationHandlers[n(402)](),o.tqDZP(typeof e,o[n(380)])&&e(),o[n(362)](t._onresponse.name,o[n(360)])&&(t[s(349)]=t._onresponse),o[n(347)](t1,t),t.addResponseListener(a=>{const c=s;t.originalOnResponse[c(386)](t,a)}),o.tqDZP(typeof r,o[s(380)])&&o[n(397)](r),t[s(327)](a=>{const{method:c}=a,u=i.get(c);o.tqDZP(typeof u,o.cjSoZ)&&u(a)})},n1=xt,s1=xt;(function(t,e){const r=xt,n=xt,s=t();for(;;)try{if(-parseInt(r(393))/1+parseInt(r(397))/2*(-parseInt(r(400))/3)+-parseInt(n(398))/4+parseInt(r(390))/5*(parseInt(n(388))/6)+-parseInt(r(389))/7+-parseInt(r(402))/8*(-parseInt(n(395))/9)+parseInt(n(399))/10*(parseInt(n(385))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Gs,-1*-881393+2*180895+1*-644809);function xt(t,e){const r=Gs();return xt=function(n,s){return n=n-(-1861+-499*4+4241),r[n]},xt(t,e)}function Gs(){const t=["toString","getRandomValues","2101mUsYMI","EQHzo","padStart","30UvDAkd","1609706yzlqYx","974735GrhZVO","randomUUID","REzPF","562771BvAnoG","dHTfU","2047455boiYXf","randomBytes","14664qHAdbF","3772144jLpQch","52310AkWksx","318MkjaVb","from","40WRwnSc"];return Gs=function(){return t},Gs()}const o1=()=>{const t=xt,e=xt,r={};r.REzPF=function(s,o){return s&o},r.suJHI=function(s,o){return s===o},r[t(386)]=function(s,o){return s&o},r[e(394)]="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=r;return n.suJHI(typeof crypto,"object")&&crypto.randomUUID?crypto[e(391)]():n.dHTfU.replace(/[xy]/g,s=>{const o=t,i=t,a=n[o(392)](crypto[o(384)](new Uint8Array(-25*-62+7113+2*-4331))[741*2+-1385*-2+4252*-1],8648+-107*62+-1999);return(n.suJHI(s,"x")?a:n[i(386)](a,-4377+4*1095)|5079+461*-11).toString(9449+4*-461+-7589)})},i1=t=>{const e=xt,r=xt,n=new Uint8Array(t);return crypto.getRandomValues(n),Array[e(401)](n,s=>s[r(403)](-3*1739+-6509+2*5871)[e(387)](2,"0")).join("")},Qt={};Qt[n1(391)]=o1,Qt[s1(396)]=i1;const tt=Rt;(function(t,e){const r=Rt,n=Rt,s=t();for(;;)try{if(parseInt(r(521))/1*(parseInt(n(499))/2)+parseInt(n(543))/3*(parseInt(n(514))/4)+parseInt(r(502))/5*(parseInt(n(539))/6)+parseInt(r(553))/7+parseInt(r(516))/8*(-parseInt(r(518))/9)+-parseInt(r(531))/10+-parseInt(r(545))/11*(parseInt(r(541))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Ys,1472653*1+-2*-897917+-2275789);const a1=(t,e)=>{const r=Rt,n=Rt,s={FyYHt:function(c,u,l){return c(u,l)},Fxtoq:function(c,u,l){return c(u,l)}};G$(t,e),Y$(t,e);const o=X$(e,t),i=s[r(510)](e1,e,t),a=s[n(549)](Q$,e,t);e[n(537)](o),e[r(519)](i),e.addNotificationListener(a),t[n(556)]=()=>{const c=n;e.removeRequestListener(o),e[c(530)](i),e[c(529)](a)}},xa=(t,e,r)=>{const n=Rt,s={pMiva:function(a,c){return a instanceof c},TeTEy:n(546),fyZbd:function(a,c,u){return a(c,u)}},o=()=>{var a;const c=n;s.pMiva(r,An)&&((a=r._eventSource)==null||a.addEventListener(s[c(547)],()=>{var u;const l=c;(u=r[l(509)])==null||u[l(546)]()})),a1(t,e)},i={};i.afterInit=o,s.fyZbd(r1,e,i)},Ud=(t,e=Qt.randomUUID())=>{const r=Rt,n=Rt,s={OfssH:function(l,f,_){return l(f,_)}},o={};o[r(528)]=e;const i=o,a={};a[r(528)]=e;const c={};c[n(558)]=a,c[r(534)]=r(524);const u={requestInit:c,eventSourceInit:{async fetch(l,f){const _=r,y=n,g=new Headers((f==null?void 0:f[_(558)])||{});Object.entries(i)[y(498)](([h,d])=>{g[y(527)](h,d)});const v={...f};return v[y(558)]=g,s.OfssH(fetch,l,v)},withCredentials:!0}};return t&&(u.requestInit[r(558)].Authorization=r(533)+t,i.Authorization="Bearer "+t),u},Dd=(t,e=Qt[tt(517)]())=>{const r=tt,n=tt,s={};s.nwQhY="include";const o=s,i={};i["stream-session-id"]=e;const a={};a.headers=i,a.credentials=o[r(520)];const c={};c[r(544)]=a;const u=c;return t&&(u.requestInit.headers[n(552)]=n(533)+t),u},Ra=async(t,e,r)=>{const n=tt,s=tt,o={CFfFC:function(a){return a()},egwVO:function(a,c,u,l){return a(c,u,l)}},i=o.CFfFC(r);try{return await t[n(538)](i),i}catch(a){if(a instanceof st){const c=await e();return await i[s(505)](c),await o[n(525)](Ra,t,e,r)}else throw a}};function Rt(t,e){const r=Ys();return Rt=function(n,s){return n=n-(74*-67+-8341+-73*-189),r[n]},Rt(t,e)}const qd=(t,e)=>{const r=tt,n=tt,s={};s.RsKXs=function(i,a){return i in a},s.PBhps="waitForOAuthCode",s[r(535)]="function",s[r(507)]="waitForOAuthCode need to be provided when authProvider is provided";const o=s;if(o.RsKXs(o[n(551)],t))return t[n(523)];if(typeof e===o.yTKoP)return e;throw new Error(o.RZhOv)},c1=async t=>{const e=tt,r=tt,n={TFSRn:function(G,Ae,U){return G(Ae,U)},HwvVa:"mcp-sse-proxy-client",ufTHS:function(G){return G()},WIVYl:function(G,Ae,U,K){return G(Ae,U,K)},jniGY:"sessionId"},{client:s,url:o,token:i,sessionId:a,authProvider:c,requestInit:u,eventSourceInit:l,waitForOAuthCode:f}=t,_={};_.authProvider=c,_.requestInit=u,_.eventSourceInit=l;const y=_,g=a||Qt.randomUUID(),v=n[e(506)](Ud,i,g);if(u){const G={...v.requestInit,...u};G.headers={...v[e(544)].headers,...u.headers},y.requestInit=G}else y[r(544)]=v.requestInit;if(l){const G={...v[e(559)],...l};y.eventSourceInit=G}else y.eventSourceInit=v.eventSourceInit;const h={};h.listChanged=!0;const d={};d.roots=h,d.sampling={},d[e(511)]={};const m=d,w={};w[r(536)]=n.HwvVa,w.version=e(526);const S={};S.capabilities=m;const P=new In(w,S),O=()=>new An(new URL(o),y);let V=n[r(504)](O);if(c){const G=n[e(506)](qd,c,f);V=await n[r(513)](Ra,P,G,O)}else await P[e(538)](V);n[r(513)](xa,P,s,V),V[r(557)]=V[r(542)].searchParams[r(532)](n.jniGY);const ce={};return ce.transport=V,ce.sessionId=V[e(557)],ce};function Ys(){const t=["ufTHS","finishAuth","TFSRn","RZhOv","Vajmx","_eventSource","FyYHt","elicitation","transport","WIVYl","13320uyrBtN","sampling","8WTwLJD","randomUUID","6438654bkJHij","addResponseListener","nwQhY","11721GVgRMJ","?sessionId=","waitForOAuthCode","include","egwVO","1.0.0","set","sse-session-id","removeNotificationListener","removeResponseListener","11838520fNkjrV","get","Bearer ","credentials","yTKoP","name","addRequestListener","connect","18VhCgQv","mcp-socket-proxy-client","2819364JNqkQZ","_endpoint","699JyrxCR","requestInit","44ofbsvb","close","TeTEy","QgzDy","Fxtoq","roots","PBhps","Authorization","11309130xGCFwl","&token=","version","onclose","sessionId","headers","eventSourceInit","forEach","62FcOkCa","mcp-stream-proxy-client","zXcpO","1794855cQEXDT","biJOc"];return Ys=function(){return t},Ys()}const u1=async t=>{const e=tt,r=tt,n={Vajmx:e(500),biJOc:function(G){return G()},zXcpO:function(G,Ae,U){return G(Ae,U)},zDnjZ:function(G,Ae,U,K){return G(Ae,U,K)},FQMAh:function(G,Ae,U,K){return G(Ae,U,K)}},{client:s,url:o,token:i,sessionId:a,authProvider:c,requestInit:u,reconnectionOptions:l,waitForOAuthCode:f}=t,_={};_.authProvider=c,_.requestInit=u,_.reconnectionOptions=l;const y=_,g=a||Qt.randomUUID(),v=Dd(i,g);if(u){const G={...v.requestInit,...u};G.headers={...v.requestInit.headers,...u.headers},y[e(544)]=G}else y.requestInit=v.requestInit;const h={};h.listChanged=!0;const d={};d[r(550)]=h,d.sampling={},d.elicitation={};const m=d,w={};w[e(536)]=n[r(508)],w[e(555)]="1.0.0";const S={};S.capabilities=m;const P=new In(w,S),O=()=>new Ws(new URL(o),y);let V=n[e(503)](O);if(c){const G=n[e(501)](qd,c,f);V=await n.zDnjZ(Ra,P,G,O)}else await P.connect(V);n.FQMAh(xa,P,s,V);const ce={};return ce.transport=V,ce[r(557)]=V.sessionId,ce},l1=async t=>{const e=tt,r=tt,n={QgzDy:e(540),jkaVB:function(d,m,w,S){return d(m,w,S)}},{client:s,url:o,token:i,sessionId:a}=t,c={};c.listChanged=!0;const u={};u[e(550)]=c,u[e(515)]={},u[r(511)]={};const l=u,f={};f.name=n[r(548)],f[r(555)]=r(526);const _={};_.capabilities=l;const y=new In(f,_),g=a||Qt[r(517)](),v=new Zd(new URL(o+e(522)+g+r(554)+i));await y.connect(v),n.jkaVB(xa,y,s,v);const h={};return h[e(512)]=v,h[r(557)]=g,h},Mn=Qe,Xs=Qe;function Qe(t,e){const r=Qs();return Qe=function(n,s){return n=n-(-16761+51*337),r[n]},Qe(t,e)}(function(t,e){const r=Qe,n=Qe,s=t();for(;;)try{if(-parseInt(r(440))/1+-parseInt(r(458))/2*(parseInt(r(448))/3)+-parseInt(r(451))/4*(parseInt(n(449))/5)+-parseInt(n(455))/6+-parseInt(r(427))/7+-parseInt(n(438))/8*(parseInt(n(459))/9)+parseInt(r(430))/10*(parseInt(n(436))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(Qs,-220880+1*-333337+-2*-384996);function Qs(){const t=["650XPHLhD","redirectToAuthorization","10856jPvMVb","GET","qcFPW","_redirectUrl","2187414WnlGuZ","resolve","tokens","3976YyOqUl","27ejNHsa","Content-Type","waitForOAuthCode","2903796yvWZFa","_clientMetadata","application/x-www-form-urlencoded","10beEWJk","json","code","_callBackPromise","reject","saveClientInformation","20776349mLNCcF","_codeVerifier","629912aTknXq","_tokens","52074GwcpRo","state","_state","_redirectCallback","_clientInformation","redirect_uris","Failed to redirect: ","clientInformation","381aduWsB"];return Qs=function(){return t},Qs()}const d1=()=>Qt.randomBytes(3485*1+-261+-3184);class f1{constructor(e){const r=Qe,n=Qe;this._callBackPromise={};const{clientMetadata:s,state:o,redirectCallback:i,getAuthCodeByState:a,waitForOAuthCode:c}=e;this[r(428)]=s,this[r(454)]=s[r(445)][0],this._state=o||d1(),this._redirectCallback=i||this.redirectCallbackFunction,this._getAuthCodeByState=a||this.getAuthCodeByStateFunction,this[n(426)]=c||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var r,n,s,o,i,a;const c=Qe,u=Qe,l={qITTp:function(g,v,h){return g(v,h)},qcFPW:c(452)},f=await l.qITTp(fetch,e,{method:l[c(453)]});!f.ok&&((n=(r=this._callBackPromise).reject)==null||n.call(r,u(446)+f.statusText));const _=await this._getAuthCodeByState(this[u(454)],this[c(442)]);if(!_.ok){(o=(s=this[c(433)]).reject)==null||o.call(s,"Failed to fetch auth code: "+_.statusText);return}const y=await _[c(431)]();(a=(i=this[u(433)])[c(456)])==null||a.call(i,y[c(432)])}async getAuthCodeByStateFunction(e,r){const n=Qe,s=Qe,o={};o.tuSmb=n(429);const i=o,a={};a[n(460)]=i.tuSmb;const c={};return c[s(441)]=r,fetch(e,{method:"POST",headers:a,body:new URLSearchParams(c)})}waitForOAuthCodeFunction(){const e=Qe,r=this[e(433)];return()=>new Promise((n,s)=>{const o=e;r.resolve=n,r[o(434)]=s})}get redirectUrl(){return this[Qe(454)]}get clientMetadata(){return this._clientMetadata}state(){return this._state}[Mn(447)](){return this[Mn(444)]}[Xs(435)](e){const r=Mn;this[r(444)]=e}[Xs(457)](){return this[Xs(439)]}saveTokens(e){this._tokens=e}[Xs(450)](e){this[Mn(443)](e)}saveCodeVerifier(e){this._codeVerifier=e}codeVerifier(){if(!this[Mn(437)])throw new Error("No code verifier saved");return this._codeVerifier}}(function(t,e){for(var r=to,n=to,s=t();;)try{var o=parseInt(r(361))/1*(parseInt(n(363))/2)+-parseInt(r(358))/3+parseInt(r(359))/4*(parseInt(r(357))/5)+parseInt(n(354))/6*(parseInt(r(360))/7)+parseInt(n(362))/8+parseInt(n(364))/9+-parseInt(n(356))/10*(parseInt(r(355))/11);if(o===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(eo,-73523*-3+1*-407717+530518);function eo(){var t=["40ecBYYe","1095owKKYD","486870YOVwZy","5752xWiyTO","561484biNVMw","1fWJmxQ","1866064SPnyhb","1109522vMiuMX","1602351pPEGwH","12sVyMLL","2573296LTwOhv"];return eo=function(){return t},eo()}function to(t,e){var r=eo();return to=function(n,s){n=n-(-1*-642+503*-5+2227);var o=r[n];return o},to(t,e)}class h1 extends yd{constructor(e,r){var n,s;super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Es.options.map((o,i)=>[o,i])),this.isMessageIgnored=(o,i)=>{const a=this._loggingLevels.get(i);return a?this.LOG_LEVEL_SEVERITY.get(o)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=(n=r==null?void 0:r.capabilities)!==null&&n!==void 0?n:{},this._instructions=r==null?void 0:r.instructions,this._jsonSchemaValidator=(s=r==null?void 0:r.jsonSchemaValidator)!==null&&s!==void 0?s:new kd,this.setRequestHandler(yl,o=>this._oninitialize(o)),this.setNotificationHandler(Si,()=>{var o;return(o=this.oninitialized)===null||o===void 0?void 0:o.call(this)}),this._capabilities.logging&&this.setRequestHandler(Ps,async(o,i)=>{var a;const c=i.sessionId||((a=i.requestInfo)===null||a===void 0?void 0:a.headers["mcp-session-id"])||void 0,{level:u}=o.params,l=Es.safeParse(u);return l.success&&this._loggingLevels.set(c,l.data),{}})}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=wd(this._capabilities,e)}assertCapabilityForMethod(e){var r,n,s;switch(e){case"sampling/createMessage":if(!(!((r=this._clientCapabilities)===null||r===void 0)&&r.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!(!((n=this._clientCapabilities)===null||n===void 0)&&n.elicitation))throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!(!((s=this._clientCapabilities)===null||s===void 0)&&s.roots))throw new Error(`Client does not support listing roots (required for ${e})`);break}}assertNotificationCapability(e){var r,n;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(!(!((n=(r=this._clientCapabilities)===null||r===void 0?void 0:r.elicitation)===null||n===void 0)&&n.url))throw new Error(`Client does not support URL elicitation (required for ${e})`);break}}assertRequestHandlerCapability(e){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}}async _oninitialize(e){const r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:ll.includes(r)?r:ln,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"},Jt)}async createMessage(e,r){var n,s;if((e.tools||e.toolChoice)&&!(!((s=(n=this._clientCapabilities)===null||n===void 0?void 0:n.sampling)===null||s===void 0)&&s.tools))throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const o=e.messages[e.messages.length-1],i=Array.isArray(o.content)?o.content:[o.content],a=i.some(f=>f.type==="tool_result"),c=e.messages.length>1?e.messages[e.messages.length-2]:void 0,u=c?Array.isArray(c.content)?c.content:[c.content]:[],l=u.some(f=>f.type==="tool_use");if(a){if(i.some(f=>f.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){const f=new Set(u.filter(y=>y.type==="tool_use").map(y=>y.id)),_=new Set(i.filter(y=>y.type==="tool_result").map(y=>y.toolUseId));if(f.size!==_.size||![...f].every(y=>_.has(y)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.request({method:"sampling/createMessage",params:e},Ai,r)}async elicitInput(e,r){var n,s,o,i,a;switch((n=e.mode)!==null&&n!==void 0?n:"form"){case"url":{if(!(!((o=(s=this._clientCapabilities)===null||s===void 0?void 0:s.elicitation)===null||o===void 0)&&o.url))throw new Error("Client does not support url elicitation.");const u=e;return this.request({method:"elicitation/create",params:u},fn,r)}case"form":{if(!(!((a=(i=this._clientCapabilities)===null||i===void 0?void 0:i.elicitation)===null||a===void 0)&&a.form))throw new Error("Client does not support form elicitation.");const u=e.mode==="form"?e:{...e,mode:"form"},l=await this.request({method:"elicitation/create",params:u},fn,r);if(l.action==="accept"&&l.content&&u.requestedSchema)try{const _=this._jsonSchemaValidator.getValidator(u.requestedSchema)(l.content);if(!_.valid)throw new ae(ie.InvalidParams,`Elicitation response content does not match requested schema: ${_.errorMessage}`)}catch(f){throw f instanceof ae?f:new ae(ie.InternalError,`Error validating elicitation response: ${f instanceof Error?f.message:String(f)}`)}return l}}}createElicitationCompletionNotifier(e,r){var n,s;if(!(!((s=(n=this._clientCapabilities)===null||n===void 0?void 0:n.elicitation)===null||s===void 0)&&s.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},Zi,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 Ia=Symbol.for("mcp.completable");function p1(t,e){return Object.defineProperty(t,Ia,{value:{complete:e},enumerable:!1,writable:!1,configurable:!1}),t}function m1(t){return!!t&&typeof t=="object"&&Ia in t}function _1(t){const e=t[Ia];return e==null?void 0:e.complete}var Vd;(function(t){t.Completable="McpCompletable"})(Vd||(Vd={}));const Fd=1e6,Ca=1e6,Hd=1e4,g1=1e6;class Mt{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){Mt.validateLength(e,Fd,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){const r=[];let n="",s=0,o=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(o++,o>Hd)throw new Error(`Template contains too many expressions (max ${Hd})`);const a=e.slice(s+1,i),c=this.getOperator(a),u=a.includes("*"),l=this.getNames(a),f=l[0];for(const _ of l)Mt.validateLength(_,Ca,"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 Mt.validateLength(e,Ca,"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(a=>r[a]).filter(a=>a!==void 0);return i.length===0?"":i.map(a=>Array.isArray(a)?a[0]:a).join(",")}const n=r[e.name];if(n===void 0)return"";const o=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return o.join(",");case"+":return o.join(",");case"#":return"#"+o.join(",");case".":return"."+o.join(".");case"/":return"/"+o.join("/");default:return o.join(",")}}expand(e){let r="",n=!1;for(const s of this.parts){if(typeof s=="string"){r+=s;continue}const o=this.expandPart(s,e);o&&((s.operator==="?"||s.operator==="&")&&n?r+=o.replace("?","&"):r+=o,(s.operator==="?"||s.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){const r=[];for(const o of e.names)Mt.validateLength(o,Ca,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let o=0;o<e.names.length;o++){const i=e.names[o],a=o===0?"\\"+e.operator:"&";r.push({pattern:a+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){Mt.validateLength(e,Fd,"URI");let r="^";const n=[];for(const a of this.parts)if(typeof a=="string")r+=this.escapeRegExp(a);else{const c=this.partToRegExp(a);for(const{pattern:u,name:l}of c)r+=u,n.push({name:l,exploded:a.exploded})}r+="$",Mt.validateLength(r,g1,"Generated regex pattern");const s=new RegExp(r),o=e.match(s);if(!o)return null;const i={};for(let a=0;a<n.length;a++){const{name:c,exploded:u}=n[a],l=o[a+1],f=c.replace("*","");u&&l.includes(",")?i[f]=l.split(","):i[f]=l}return i}}const v1=/^[A-Za-z0-9._-]{1,128}$/;function y1(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"),!v1.test(t)){const r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,o)=>o.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 b1(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 Wd(t){const e=y1(t);return b1(t,e.warnings),e.isValid}class Jd{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 h1(e,r)}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(er(Ni)),this.server.assertCanSetRequestHandler(er(ji)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Ni,()=>({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=Rn(r.inputSchema);return s?_d(s,{strictUnions:!0,pipeStrategy:"input"}):$1})(),annotations:r.annotations,_meta:r._meta};if(r.outputSchema){const s=Rn(r.outputSchema);s&&(n.outputSchema=_d(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(ji,async(e,r)=>{const n=this._registeredTools[e.params.name];let s;try{if(!n)throw new ae(ie.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new ae(ie.InvalidParams,`Tool ${e.params.name} disabled`);if(n.inputSchema){const o=n.callback,i=Rn(n.inputSchema),a=i??n.inputSchema,c=await Hi(a,e.params.arguments);if(!c.success)throw new ae(ie.InvalidParams,`Input validation error: Invalid arguments for tool ${e.params.name}: ${Wi(c.error)}`);const u=c.data;s=await Promise.resolve(o(u,r))}else{const o=n.callback;s=await Promise.resolve(o(r))}if(n.outputSchema&&!s.isError){if(!s.structuredContent)throw new ae(ie.InvalidParams,`Output validation error: Tool ${e.params.name} has an output schema but no structured content was provided`);const o=Rn(n.outputSchema),i=await Hi(o,s.structuredContent);if(!i.success)throw new ae(ie.InvalidParams,`Output validation error: Invalid structured content for tool ${e.params.name}: ${Wi(i.error)}`)}}catch(o){if(o instanceof ae&&o.code===ie.UrlElicitationRequired)throw o;return this.createToolError(o instanceof Error?o.message:String(o))}return s}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(er(Mi)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Mi,async e=>{switch(e.params.ref.type){case"ref/prompt":return ib(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return ab(e),this.handleResourceCompletion(e,e.params.ref);default:throw new ae(ie.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){const n=this._registeredPrompts[r.name];if(!n)throw new ae(ie.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new ae(ie.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Zn;const s=xn(n.argsSchema),o=s==null?void 0:s[e.params.argument.name];if(!m1(o))return Zn;const i=_1(o);if(!i)return Zn;const a=await i(e.params.argument.value,e.params.context);return Kd(a)}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 Zn;throw new ae(ie.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return Zn;const o=await s(e.params.argument.value,e.params.context);return Kd(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(er(Ss)),this.server.assertCanSetRequestHandler(er(Ti)),this.server.assertCanSetRequestHandler(er(Ri)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ss,async(e,r)=>{const n=Object.entries(this._registeredResources).filter(([o,i])=>i.enabled).map(([o,i])=>({uri:o,name:i.name,...i.metadata})),s=[];for(const o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;const i=await o.resourceTemplate.listCallback(r);for(const a of i.resources)s.push({...o.metadata,...a})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Ti,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Ri,async(e,r)=>{const n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new ae(ie.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(const o of Object.values(this._registeredResourceTemplates)){const i=o.resourceTemplate.uriTemplate.match(n.toString());if(i)return o.readCallback(n,i,r)}throw new ae(ie.InvalidParams,`Resource ${n} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(er(Ii)),this.server.assertCanSetRequestHandler(er(Ci)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Ii,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?k1(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ci,async(e,r)=>{const n=this._registeredPrompts[e.params.name];if(!n)throw new ae(ie.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new ae(ie.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){const s=Rn(n.argsSchema),o=await Hi(s,e.params.arguments);if(!o.success)throw new ae(ie.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${Wi(o.error)}`);const i=o.data,a=n.callback;return await Promise.resolve(a(i,r))}else{const s=n.callback;return await Promise.resolve(s(r))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());const o=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,o);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,o);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 o=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const o=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,n,s,o){const i={name:e,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,s,o){const i={resourceTemplate:n,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredResourceTemplates[e],a.name&&(this._registeredResourceTemplates[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.template<"u"&&(i.resourceTemplate=a.template),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResourceTemplates[e]=i,i}_createRegisteredPrompt(e,r,n,s,o){const i={title:r,description:n,argsSchema:s===void 0?void 0:Tn(s),callback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=Tn(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,i}_createRegisteredTool(e,r,n,s,o,i,a,c){Wd(e);const u={title:r,description:n,inputSchema:Bd(s),outputSchema:Bd(o),annotations:i,_meta:a,callback:c,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:l=>{typeof l.name<"u"&&l.name!==e&&(typeof l.name=="string"&&Wd(l.name),delete this._registeredTools[e],l.name&&(this._registeredTools[l.name]=u)),typeof l.title<"u"&&(u.title=l.title),typeof l.description<"u"&&(u.description=l.description),typeof l.paramsSchema<"u"&&(u.inputSchema=Tn(l.paramsSchema)),typeof l.callback<"u"&&(u.callback=l.callback),typeof l.annotations<"u"&&(u.annotations=l.annotations),typeof l._meta<"u"&&(u._meta=l._meta),typeof l.enabled<"u"&&(u.enabled=l.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,o,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){const c=r[0];Oa(c)?(s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Oa(r[0])&&(i=r.shift())):typeof c=="object"&&c!==null&&(i=r.shift())}const a=r[0];return this._createRegisteredTool(e,void 0,n,s,o,i,void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:s,description:o,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,s,o,i,a,c,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 o=r[0],i=this._createRegisteredPrompt(e,void 0,n,s,o);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:o,argsSchema:i}=r,a=this._createRegisteredPrompt(e,s,o,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}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 w1{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Mt(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){var r;return(r=this._callbacks.complete)===null||r===void 0?void 0:r[e]}}const $1={type:"object",properties:{}};function Oa(t){return typeof t!="object"||t===null?!1:Object.keys(t).length===0||Object.values(t).some(S1)}function S1(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Bd(t){if(t)return Oa(t)?Tn(t):t}function k1(t){const e=xn(t);return e?Object.entries(e).map(([r,n])=>{const s=mw(n),o=_w(n);return{name:r,description:s,required:!o}}):[]}function er(t){const e=xn(t),r=e==null?void 0:e.method;if(!r)throw new Error("Schema is missing a method literal");const n=id(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Kd(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}const Zn={completion:{values:[],hasMore:!1}};class E1{constructor(e,r){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new Jd(e||n,r||{capabilities:s}),this.server.server.oninitialized=()=>{var o;(o=this.oninitialized)==null||o.call(this)},this.server.server.onclose=()=>{var o;(o=this.onclose)==null||o.call(this)},this.server.server.onerror=o=>{var i;(i=this.onerror)==null||i.call(this,o)},this.server.server.setRequestHandler(Ps,async()=>({}))}async connect(e){return typeof e.start=="function"?(this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0):(this.transport=new Pa(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,r,n){return this.server.registerTool(e,r,n)}registerPrompt(e,r,n){return this.server.registerPrompt(e,r,n)}registerResource(e,r,n,s){return typeof r=="string"?this.server.registerResource(e,r,n,s):this.server.registerResource(e,r,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,r){return await this.server.server.createMessage(e,r)}async elicitInput(e,r){return await this.server.server.elicitInput(e,r)}async listRoots(e,r){return await this.server.server.listRoots(e,r)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,r,n){return this.server.server.request(e,r,n)}async notification(e,r){return await this.server.server.notification(e,r)}setRequestHandler(e,r){this.server.server.setRequestHandler(e,r)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,r){this.server.server.setNotificationHandler(e,r)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(Rl,e)}onUnsubscribe(e){this.server.server.setRequestHandler(Il,e)}onSetLogLevel(e){this.server.server.setRequestHandler(Ps,e)}onListResources(e){this.server.server.setRequestHandler(Ss,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(Hl,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const P1=(t,e)=>new Pa(t,e),T1=()=>J$(),x1=t=>t instanceof Pa,R1=t=>t instanceof Jd;class I1{constructor(e,r){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new In(e||n,r||{capabilities:s}),this.client.onclose=()=>{var o;(o=this.onclose)==null||o.call(this)},this.client.onerror=o=>{var i;(i=this.onerror)==null||i.call(this,o)}}async connect(e){if(typeof e.start=="function")return this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0,await this.client.connect(this.transport),{transport:this.transport,sessionId:this.transport.sessionId};const{url:r,token:n,sessionId:s,type:o,agent:i,onError:a}=e;if(i===!0){const l={client:this.client,url:r,token:n,sessionId:s};let f;return await(async()=>{const{transport:y,sessionId:g}=o==="sse"?await c1(l):o==="socket"?await l1(l):await u1(l);y.onerror=async v=>{a==null||a(v)},f={transport:y,sessionId:g}})(),f}const c=new URL(r);let u;if(o==="channel"&&(u=new Ea(r),await this.client.connect(u)),o==="sse"){const l=Ud(n,s);u=new An(c,l),await this.client.connect(u)}if(o==="socket"&&(u=new Zd(new URL(`${r}?sessionId=${s}&token=${n}`)),u.sessionId=s,await this.client.connect(u)),typeof u>"u"){const l=Dd(n,s);u=new Ws(c,l),await this.client.connect(u)}return this.transport=u,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,r){return await this.client.complete(e,r)}async setLoggingLevel(e,r){return await this.client.setLoggingLevel(e,r)}async getPrompt(e,r){return await this.client.getPrompt(e,r)}async listPrompts(e,r){return await this.client.listPrompts(e,r)}async listResources(e,r){return await this.client.listResources(e,r)}async listResourceTemplates(e,r){return await this.client.listResourceTemplates(e,r)}async readResource(e,r){return await this.client.readResource(e,r)}async subscribeResource(e,r){return await this.client.subscribeResource(e,r)}async unsubscribeResource(e,r){return await this.client.unsubscribeResource(e,r)}async callTool(e,r){return await this.client.callTool(e,ks,r)}async listTools(e,r){return await this.client.listTools(e,r)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,r,n){return this.client.request(e,r,n)}async notification(e,r){return await this.client.notification(e,r)}setRequestHandler(e,r){this.client.setRequestHandler(e,r)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,r){this.client.setNotificationHandler(e,r)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(zi,e)}onCreateMessage(e){this.client.setRequestHandler(ql,e)}onListRoots(e){this.client.setRequestHandler(Fl,e)}onToolListChanged(e){this.client.setNotificationHandler(Ul,e)}onPromptListChanged(e){this.client.setNotificationHandler(Ml,e)}onResourceListChanged(e){this.client.setNotificationHandler(xl,e)}onResourceUpdated(e){this.client.setNotificationHandler(Cl,e)}onLoggingMessage(e){this.client.setNotificationHandler(Dl,e)}async onPagehide(e){e.persisted||(Gd(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const C1=(t,e)=>new An(t,e),O1=(t,e)=>new Ws(t,e),N1=(t,e)=>new Ea(t,e),j1=t=>t instanceof An,Gd=t=>t instanceof Ws,A1=t=>t instanceof Ea,z1=t=>t instanceof In;function M1(t){var e;return t.title!==void 0&&t.title!==""?t.title:!((e=t.annotations)===null||e===void 0)&&e.title?t.annotations.title:t.name}const Z1=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)}),ro=(t,e,r)=>{window.postMessage({type:t,direction:r,data:e},"*")},Yd=(t,e,r)=>{const n=async function(s){s.source===window&&s.data.type===t&&s.data.direction===r&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class L1{constructor(e=null,r){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||Z1(),this.tabId=r,this._messageListener1=Yd("sidepanel-ready-to-page",()=>{this._lastRegistration&&this._isStarted&&this.notifyRegistration(this._lastRegistration).catch(n=>{console.error("【Page Svr Transport】 notifyRegistration失败:",n)})},"content->page"),this._messageListener2=Yd("mcp-client-to-server-to-page",n=>{var i,a,c;if(n.sessionId!==this.sessionId||n.tabId!==this.tabId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",n.mcpMessage);const s=cr.parse(n.mcpMessage);(i=this.onmessage)==null||i.call(this,s),((a=n.mcpMessage.params)==null?void 0:a.name)&&ro("update-page-app-message",{status:"run",message:(c=n.mcpMessage.params)==null?void 0:c.name},"page->content")},"content->page")}_throwError(e,r){if(e()){const n=new Error(r);throw console.log(r,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,r){var n;this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),ro("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&((n=e.result)!=null&&n.content)&&ro("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{ro("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(r){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(r))}}async close(){if(!this._isClosed)try{this._messageListener1&&this._messageListener1(),this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}me.Ajv=c_,me.AuthClientProvider=f1,me.ExtensionPageServerTransport=L1,me.ResourceTemplate=w1,me.UriTemplate=Mt,me.WebMcpClient=I1,me.WebMcpServer=E1,me.completable=p1,me.createMessageChannelClientTransport=N1,me.createMessageChannelPairTransport=T1,me.createMessageChannelServerTransport=P1,me.createSSEClientTransport=C1,me.createStreamableHTTPClientTransport=O1,me.getDisplayName=M1,me.isMcpClient=z1,me.isMcpServer=R1,me.isMessageChannelClientTransport=A1,me.isMessageChannelServerTransport=x1,me.isSSEClientTransport=j1,me.isStreamableHTTPClientTransport=Gd,me.z=fw,Object.defineProperty(me,Symbol.toStringTag,{value:"Module"})});
35
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of this.seen.entries()){const d=l[1];if(e===l[0]){o(l);continue}if(n.external){const _=n.external.registry.get(l[0])?.id;if(e!==l[0]&&_){o(l);continue}}if(this.metadataRegistry.get(l[0])?.id){o(l);continue}if(d.cycle){o(l);continue}if(d.count>1&&n.reused==="ref"){o(l);continue}}const i=(l,d)=>{const m=this.seen.get(l),_=m.def??m.schema,p={..._};if(m.ref===null)return;const y=m.ref;if(m.ref=null,y){i(y,d);const h=this.seen.get(y).schema;h.$ref&&d.target==="draft-7"?(_.allOf=_.allOf??[],_.allOf.push(h)):(Object.assign(_,h),Object.assign(_,p))}m.isParent||this.override({zodSchema:l,jsonSchema:_,path:m.path??[]})};for(const l of[...this.seen.entries()].reverse())i(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 d=l[1];d.def&&d.defId&&(u[d.defId]=d.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 am(t,e){if(t instanceof du){const n=new vu(e),s={};for(const i of t._idmap.entries()){const[c,u]=i;n.process(u)}const a={},o={registry:t,uri:e?.uri,defs:s};for(const i of t._idmap.entries()){const[c,u]=i;a[c]=n.emit(u,{...e,external:o})}if(Object.keys(s).length>0){const i=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[i]:s}}return{schemas:a}}const r=new vu(e);return r.process(t),r.emit(t,e)}function je(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 je(s.element,r);case"object":{for(const a in s.shape)if(je(s.shape[a],r))return!0;return!1}case"union":{for(const a of s.options)if(je(a,r))return!0;return!1}case"intersection":return je(s.left,r)||je(s.right,r);case"tuple":{for(const a of s.items)if(je(a,r))return!0;return!!(s.rest&&je(s.rest,r))}case"record":return je(s.keyType,r)||je(s.valueType,r);case"map":return je(s.keyType,r)||je(s.valueType,r);case"set":return je(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return je(s.innerType,r);case"lazy":return je(s.getter(),r);case"default":return je(s.innerType,r);case"prefault":return je(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return je(s.in,r)||je(s.out,r);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}const om=O("ZodISODateTime",(t,e)=>{Ih.init(t,e),Ie.init(t,e)});function wu(t){return Ap(om,t)}const im=O("ZodISODate",(t,e)=>{Ch.init(t,e),Ie.init(t,e)});function cm(t){return jp(im,t)}const um=O("ZodISOTime",(t,e)=>{Oh.init(t,e),Ie.init(t,e)});function lm(t){return Mp(um,t)}const dm=O("ZodISODuration",(t,e)=>{Nh.init(t,e),Ie.init(t,e)});function fm(t){return zp(dm,t)}const Ts=O("ZodError",(t,e)=>{Lc.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Pf(t,r)},flatten:{value:r=>Rf(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}),hm=Uc(Ts),pm=Dc(Ts),mm=Vc(Ts),_m=Fc(Ts),Pe=O("ZodType",(t,e)=>(ke.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)=>Dt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>hm(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>mm(t,r,n),t.parseAsync=async(r,n)=>pm(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>_m(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(c_(r,n)),t.superRefine=r=>t.check(u_(r)),t.overwrite=r=>t.check(Wr(r)),t.optional=()=>Ae(t),t.nullable=()=>Cu(t),t.nullish=()=>Ae(Cu(t)),t.nonoptional=r=>e_(t,r),t.array=()=>F(t),t.or=r=>Ee([t,r]),t.and=r=>ja(t,r),t.transform=r=>za(t,xu(r)),t.default=r=>Ym(t,r),t.prefault=r=>Qm(t,r),t.catch=r=>r_(t,r),t.pipe=r=>za(t,r),t.readonly=()=>a_(t),t.describe=r=>{const n=t.clone();return Hr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Hr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Hr.get(t);const n=t.clone();return Hr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),bu=O("_ZodString",(t,e)=>{Ia.init(t,e),Pe.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(Wp(...n)),t.includes=(...n)=>t.check(Jp(...n)),t.startsWith=(...n)=>t.check(Gp(...n)),t.endsWith=(...n)=>t.check(Yp(...n)),t.min=(...n)=>t.check(Ss(...n)),t.max=(...n)=>t.check(gu(...n)),t.length=(...n)=>t.check(yu(...n)),t.nonempty=(...n)=>t.check(Ss(1,...n)),t.lowercase=n=>t.check(Kp(n)),t.uppercase=n=>t.check(Bp(n)),t.trim=()=>t.check(Qp()),t.normalize=(...n)=>t.check(Xp(...n)),t.toLowerCase=()=>t.check(em()),t.toUpperCase=()=>t.check(tm())}),gm=O("ZodString",(t,e)=>{Ia.init(t,e),bu.init(t,e),t.email=r=>t.check(pp(ym,r)),t.url=r=>t.check(hu($u,r)),t.jwt=r=>t.check(Np(Am,r)),t.emoji=r=>t.check(vp(wm,r)),t.guid=r=>t.check(fu(ku,r)),t.uuid=r=>t.check(mp(Es,r)),t.uuidv4=r=>t.check(_p(Es,r)),t.uuidv6=r=>t.check(gp(Es,r)),t.uuidv7=r=>t.check(yp(Es,r)),t.nanoid=r=>t.check(wp(bm,r)),t.guid=r=>t.check(fu(ku,r)),t.cuid=r=>t.check(bp(km,r)),t.cuid2=r=>t.check(kp($m,r)),t.ulid=r=>t.check($p(Sm,r)),t.base64=r=>t.check(Ip(Cm,r)),t.base64url=r=>t.check(Cp(Om,r)),t.xid=r=>t.check(Sp(Tm,r)),t.ksuid=r=>t.check(Tp(Em,r)),t.ipv4=r=>t.check(Ep(Rm,r)),t.ipv6=r=>t.check(Rp(Pm,r)),t.cidrv4=r=>t.check(Pp(xm,r)),t.cidrv6=r=>t.check(xp(Im,r)),t.e164=r=>t.check(Op(Nm,r)),t.datetime=r=>t.check(wu(r)),t.date=r=>t.check(cm(r)),t.time=r=>t.check(lm(r)),t.duration=r=>t.check(fm(r))});function T(t){return hp(gm,t)}const Ie=O("ZodStringFormat",(t,e)=>{Re.init(t,e),bu.init(t,e)}),ym=O("ZodEmail",(t,e)=>{bh.init(t,e),Ie.init(t,e)}),ku=O("ZodGUID",(t,e)=>{vh.init(t,e),Ie.init(t,e)}),Es=O("ZodUUID",(t,e)=>{wh.init(t,e),Ie.init(t,e)}),$u=O("ZodURL",(t,e)=>{kh.init(t,e),Ie.init(t,e)});function vm(t){return hu($u,t)}const wm=O("ZodEmoji",(t,e)=>{$h.init(t,e),Ie.init(t,e)}),bm=O("ZodNanoID",(t,e)=>{Sh.init(t,e),Ie.init(t,e)}),km=O("ZodCUID",(t,e)=>{Th.init(t,e),Ie.init(t,e)}),$m=O("ZodCUID2",(t,e)=>{Eh.init(t,e),Ie.init(t,e)}),Sm=O("ZodULID",(t,e)=>{Rh.init(t,e),Ie.init(t,e)}),Tm=O("ZodXID",(t,e)=>{Ph.init(t,e),Ie.init(t,e)}),Em=O("ZodKSUID",(t,e)=>{xh.init(t,e),Ie.init(t,e)}),Rm=O("ZodIPv4",(t,e)=>{Ah.init(t,e),Ie.init(t,e)}),Pm=O("ZodIPv6",(t,e)=>{jh.init(t,e),Ie.init(t,e)}),xm=O("ZodCIDRv4",(t,e)=>{Mh.init(t,e),Ie.init(t,e)}),Im=O("ZodCIDRv6",(t,e)=>{zh.init(t,e),Ie.init(t,e)}),Cm=O("ZodBase64",(t,e)=>{qh.init(t,e),Ie.init(t,e)}),Om=O("ZodBase64URL",(t,e)=>{Lh.init(t,e),Ie.init(t,e)}),Nm=O("ZodE164",(t,e)=>{Uh.init(t,e),Ie.init(t,e)}),Am=O("ZodJWT",(t,e)=>{Vh.init(t,e),Ie.init(t,e)}),Aa=O("ZodNumber",(t,e)=>{Qc.init(t,e),Pe.init(t,e),t.gt=(n,s)=>t.check(mu(n,s)),t.gte=(n,s)=>t.check(Na(n,s)),t.min=(n,s)=>t.check(Na(n,s)),t.lt=(n,s)=>t.check(pu(n,s)),t.lte=(n,s)=>t.check(Oa(n,s)),t.max=(n,s)=>t.check(Oa(n,s)),t.int=n=>t.check(Su(n)),t.safe=n=>t.check(Su(n)),t.positive=n=>t.check(mu(0,n)),t.nonnegative=n=>t.check(Na(0,n)),t.negative=n=>t.check(pu(0,n)),t.nonpositive=n=>t.check(Oa(0,n)),t.multipleOf=(n,s)=>t.check(_u(n,s)),t.step=(n,s)=>t.check(_u(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 _e(t){return qp(Aa,t)}const jm=O("ZodNumberFormat",(t,e)=>{Fh.init(t,e),Aa.init(t,e)});function Su(t){return Lp(jm,t)}const Mm=O("ZodBoolean",(t,e)=>{Hh.init(t,e),Pe.init(t,e)});function Te(t){return Up(Mm,t)}const zm=O("ZodNull",(t,e)=>{Wh.init(t,e),Pe.init(t,e)});function Tu(t){return Dp(zm,t)}const qm=O("ZodAny",(t,e)=>{Kh.init(t,e),Pe.init(t,e)});function Zm(){return Vp(qm)}const Lm=O("ZodUnknown",(t,e)=>{Bh.init(t,e),Pe.init(t,e)});function Ce(){return Fp(Lm)}const Um=O("ZodNever",(t,e)=>{Jh.init(t,e),Pe.init(t,e)});function Dm(t){return Hp(Um,t)}const Vm=O("ZodArray",(t,e)=>{Gh.init(t,e),Pe.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Ss(r,n)),t.nonempty=r=>t.check(Ss(1,r)),t.max=(r,n)=>t.check(gu(r,n)),t.length=(r,n)=>t.check(yu(r,n)),t.unwrap=()=>t.element});function F(t,e){return rm(Vm,t,e)}const Eu=O("ZodObject",(t,e)=>{ru.init(t,e),Pe.init(t,e),Se(t,"shape",()=>e.shape),t.keyof=()=>st(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ce()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ce()}),t.strict=()=>t.clone({...t._zod.def,catchall:Dm()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>$f(t,r),t.merge=r=>Sf(t,r),t.pick=r=>bf(t,r),t.omit=r=>kf(t,r),t.partial=(...r)=>Tf(Iu,t,r[0]),t.required=(...r)=>Ef(Ou,t,r[0])});function H(t,e){const r={type:"object",get shape(){return Lr(this,"shape",{...t}),this.shape},...X(e)};return new Eu(r)}function Ze(t,e){return new Eu({type:"object",get shape(){return Lr(this,"shape",{...t}),this.shape},catchall:Ce(),...X(e)})}const Ru=O("ZodUnion",(t,e)=>{su.init(t,e),Pe.init(t,e),t.options=e.options});function Ee(t,e){return new Ru({type:"union",options:t,...X(e)})}const Fm=O("ZodDiscriminatedUnion",(t,e)=>{Ru.init(t,e),Yh.init(t,e)});function Pu(t,e,r){return new Fm({type:"union",options:e,discriminator:t,...X(r)})}const Hm=O("ZodIntersection",(t,e)=>{Xh.init(t,e),Pe.init(t,e)});function ja(t,e){return new Hm({type:"intersection",left:t,right:e})}const Wm=O("ZodRecord",(t,e)=>{Qh.init(t,e),Pe.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Oe(t,e,r){return new Wm({type:"record",keyType:t,valueType:e,...X(r)})}const Ma=O("ZodEnum",(t,e)=>{ep.init(t,e),Pe.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 o of n)if(r.has(o))a[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ma({...e,checks:[],...X(s),entries:a})},t.exclude=(n,s)=>{const a={...e.entries};for(const o of n)if(r.has(o))delete a[o];else throw new Error(`Key ${o} not found in enum`);return new Ma({...e,checks:[],...X(s),entries:a})}});function st(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Ma({type:"enum",entries:r,...X(e)})}const Km=O("ZodLiteral",(t,e)=>{tp.init(t,e),Pe.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 Km({type:"literal",values:Array.isArray(t)?t:[t],...X(e)})}const Bm=O("ZodTransform",(t,e)=>{rp.init(t,e),Pe.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=a=>{if(typeof a=="string")r.issues.push(Fr(a,r.value,e));else{const o=a;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!0),r.issues.push(Fr(o))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(a=>(r.value=a,r)):(r.value=s,r)}});function xu(t){return new Bm({type:"transform",transform:t})}const Iu=O("ZodOptional",(t,e)=>{np.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ae(t){return new Iu({type:"optional",innerType:t})}const Jm=O("ZodNullable",(t,e)=>{sp.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Cu(t){return new Jm({type:"nullable",innerType:t})}const Gm=O("ZodDefault",(t,e)=>{ap.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Ym(t,e){return new Gm({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const Xm=O("ZodPrefault",(t,e)=>{op.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Qm(t,e){return new Xm({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const Ou=O("ZodNonOptional",(t,e)=>{ip.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function e_(t,e){return new Ou({type:"nonoptional",innerType:t,...X(e)})}const t_=O("ZodCatch",(t,e)=>{cp.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function r_(t,e){return new t_({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const n_=O("ZodPipe",(t,e)=>{up.init(t,e),Pe.init(t,e),t.in=e.in,t.out=e.out});function za(t,e){return new n_({type:"pipe",in:t,out:e})}const s_=O("ZodReadonly",(t,e)=>{lp.init(t,e),Pe.init(t,e)});function a_(t){return new s_({type:"readonly",innerType:t})}const Nu=O("ZodCustom",(t,e)=>{dp.init(t,e),Pe.init(t,e)});function o_(t){const e=new Xe({check:"custom"});return e._zod.check=t,e}function i_(t,e){return nm(Nu,t??(()=>!0),e)}function c_(t,e={}){return sm(Nu,t,e)}function u_(t){const e=o_(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Fr(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(Fr(s))}},t(r.value,r)));return e}function Au(t,e){return za(xu(t),e)}const l_={custom:"custom"};function d_(t){return Zp(Aa,t)}const Kr="2025-11-25",ju=[Kr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],sr="io.modelcontextprotocol/related-task",Rs="2.0",Le=i_(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Mu=Ee([T(),_e().int()]),zu=T();Ze({ttl:Ee([_e(),Tu()]).optional(),pollInterval:_e().optional()});const f_=H({ttl:_e().optional()}),h_=H({taskId:T()}),qa=Ze({progressToken:Mu.optional(),[sr]:h_.optional()}),at=H({_meta:qa.optional()}),Br=at.extend({task:f_.optional()}),p_=t=>Br.safeParse(t).success,Ue=H({method:T(),params:at.loose().optional()}),ct=H({_meta:qa.optional()}),ut=H({method:T(),params:ct.loose().optional()}),De=Ze({_meta:qa.optional()}),Ps=Ee([T(),_e().int()]),qu=H({jsonrpc:te(Rs),id:Ps,...Ue.shape}).strict(),Za=t=>qu.safeParse(t).success,Zu=H({jsonrpc:te(Rs),...ut.shape}).strict(),m_=t=>Zu.safeParse(t).success,La=H({jsonrpc:te(Rs),id:Ps,result:De}).strict(),Jr=t=>La.safeParse(t).success;var G;(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"})(G||(G={}));const Ua=H({jsonrpc:te(Rs),id:Ps.optional(),error:H({code:_e().int(),message:T(),data:Ce().optional()})}).strict(),__=t=>Ua.safeParse(t).success,ar=Ee([qu,Zu,La,Ua]);Ee([La,Ua]);const Ft=De.strict(),g_=ct.extend({requestId:Ps.optional(),reason:T().optional()}),Da=ut.extend({method:te("notifications/cancelled"),params:g_}),y_=H({src:T(),mimeType:T().optional(),sizes:F(T()).optional(),theme:st(["light","dark"]).optional()}),Gr=H({icons:F(y_).optional()}),_r=H({name:T(),title:T().optional()}),Lu=_r.extend({..._r.shape,...Gr.shape,version:T(),websiteUrl:T().optional(),description:T().optional()}),v_=ja(H({applyDefaults:Te().optional()}),Oe(T(),Ce())),w_=Au(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ja(H({form:v_.optional(),url:Le.optional()}),Oe(T(),Ce()).optional())),b_=Ze({list:Le.optional(),cancel:Le.optional(),requests:Ze({sampling:Ze({createMessage:Le.optional()}).optional(),elicitation:Ze({create:Le.optional()}).optional()}).optional()}),k_=Ze({list:Le.optional(),cancel:Le.optional(),requests:Ze({tools:Ze({call:Le.optional()}).optional()}).optional()}),$_=H({experimental:Oe(T(),Le).optional(),sampling:H({context:Le.optional(),tools:Le.optional()}).optional(),elicitation:w_.optional(),roots:H({listChanged:Te().optional()}).optional(),tasks:b_.optional()}),S_=at.extend({protocolVersion:T(),capabilities:$_,clientInfo:Lu}),Uu=Ue.extend({method:te("initialize"),params:S_}),T_=H({experimental:Oe(T(),Le).optional(),logging:Le.optional(),completions:Le.optional(),prompts:H({listChanged:Te().optional()}).optional(),resources:H({subscribe:Te().optional(),listChanged:Te().optional()}).optional(),tools:H({listChanged:Te().optional()}).optional(),tasks:k_.optional()}),Du=De.extend({protocolVersion:T(),capabilities:T_,serverInfo:Lu,instructions:T().optional()}),Va=ut.extend({method:te("notifications/initialized"),params:ct.optional()}),E_=t=>Va.safeParse(t).success,Fa=Ue.extend({method:te("ping"),params:at.optional()}),R_=H({progress:_e(),total:Ae(_e()),message:Ae(T())}),P_=H({...ct.shape,...R_.shape,progressToken:Mu}),Ha=ut.extend({method:te("notifications/progress"),params:P_}),x_=at.extend({cursor:zu.optional()}),Yr=Ue.extend({params:x_.optional()}),Xr=De.extend({nextCursor:zu.optional()}),I_=st(["working","input_required","completed","failed","cancelled"]),Qr=H({taskId:T(),status:I_,ttl:Ee([_e(),Tu()]),createdAt:T(),lastUpdatedAt:T(),pollInterval:Ae(_e()),statusMessage:Ae(T())}),gr=De.extend({task:Qr}),C_=ct.merge(Qr),xs=ut.extend({method:te("notifications/tasks/status"),params:C_}),Wa=Ue.extend({method:te("tasks/get"),params:at.extend({taskId:T()})}),Ka=De.merge(Qr),Ba=Ue.extend({method:te("tasks/result"),params:at.extend({taskId:T()})});De.loose();const Ja=Yr.extend({method:te("tasks/list")}),Ga=Xr.extend({tasks:F(Qr)}),Ya=Ue.extend({method:te("tasks/cancel"),params:at.extend({taskId:T()})}),O_=De.merge(Qr),Vu=H({uri:T(),mimeType:Ae(T()),_meta:Oe(T(),Ce()).optional()}),Fu=Vu.extend({text:T()}),Xa=T().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Hu=Vu.extend({blob:Xa}),en=st(["user","assistant"]),yr=H({audience:F(en).optional(),priority:_e().min(0).max(1).optional(),lastModified:wu({offset:!0}).optional()}),Wu=H({..._r.shape,...Gr.shape,uri:T(),description:Ae(T()),mimeType:Ae(T()),annotations:yr.optional(),_meta:Ae(Ze({}))}),N_=H({..._r.shape,...Gr.shape,uriTemplate:T(),description:Ae(T()),mimeType:Ae(T()),annotations:yr.optional(),_meta:Ae(Ze({}))}),Is=Yr.extend({method:te("resources/list")}),Ku=Xr.extend({resources:F(Wu)}),Qa=Yr.extend({method:te("resources/templates/list")}),Bu=Xr.extend({resourceTemplates:F(N_)}),eo=at.extend({uri:T()}),A_=eo,to=Ue.extend({method:te("resources/read"),params:A_}),Ju=De.extend({contents:F(Ee([Fu,Hu]))}),ro=ut.extend({method:te("notifications/resources/list_changed"),params:ct.optional()}),j_=eo,Gu=Ue.extend({method:te("resources/subscribe"),params:j_}),M_=eo,Yu=Ue.extend({method:te("resources/unsubscribe"),params:M_}),z_=ct.extend({uri:T()}),Xu=ut.extend({method:te("notifications/resources/updated"),params:z_}),q_=H({name:T(),description:Ae(T()),required:Ae(Te())}),Z_=H({..._r.shape,...Gr.shape,description:Ae(T()),arguments:Ae(F(q_)),_meta:Ae(Ze({}))}),no=Yr.extend({method:te("prompts/list")}),Qu=Xr.extend({prompts:F(Z_)}),L_=at.extend({name:T(),arguments:Oe(T(),T()).optional()}),so=Ue.extend({method:te("prompts/get"),params:L_}),ao=H({type:te("text"),text:T(),annotations:yr.optional(),_meta:Oe(T(),Ce()).optional()}),oo=H({type:te("image"),data:Xa,mimeType:T(),annotations:yr.optional(),_meta:Oe(T(),Ce()).optional()}),io=H({type:te("audio"),data:Xa,mimeType:T(),annotations:yr.optional(),_meta:Oe(T(),Ce()).optional()}),U_=H({type:te("tool_use"),name:T(),id:T(),input:Oe(T(),Ce()),_meta:Oe(T(),Ce()).optional()}),D_=H({type:te("resource"),resource:Ee([Fu,Hu]),annotations:yr.optional(),_meta:Oe(T(),Ce()).optional()}),V_=Wu.extend({type:te("resource_link")}),co=Ee([ao,oo,io,V_,D_]),F_=H({role:en,content:co}),el=De.extend({description:T().optional(),messages:F(F_)}),uo=ut.extend({method:te("notifications/prompts/list_changed"),params:ct.optional()}),H_=H({title:T().optional(),readOnlyHint:Te().optional(),destructiveHint:Te().optional(),idempotentHint:Te().optional(),openWorldHint:Te().optional()}),W_=H({taskSupport:st(["required","optional","forbidden"]).optional()}),tl=H({..._r.shape,...Gr.shape,description:T().optional(),inputSchema:H({type:te("object"),properties:Oe(T(),Le).optional(),required:F(T()).optional()}).catchall(Ce()),outputSchema:H({type:te("object"),properties:Oe(T(),Le).optional(),required:F(T()).optional()}).catchall(Ce()).optional(),annotations:H_.optional(),execution:W_.optional(),_meta:Oe(T(),Ce()).optional()}),lo=Yr.extend({method:te("tools/list")}),rl=Xr.extend({tools:F(tl)}),vr=De.extend({content:F(co).default([]),structuredContent:Oe(T(),Ce()).optional(),isError:Te().optional()});vr.or(De.extend({toolResult:Ce()}));const K_=Br.extend({name:T(),arguments:Oe(T(),Ce()).optional()}),Cs=Ue.extend({method:te("tools/call"),params:K_}),fo=ut.extend({method:te("notifications/tools/list_changed"),params:ct.optional()}),B_=H({autoRefresh:Te().default(!0),debounceMs:_e().int().nonnegative().default(300)}),Os=st(["debug","info","notice","warning","error","critical","alert","emergency"]),J_=at.extend({level:Os}),Ns=Ue.extend({method:te("logging/setLevel"),params:J_}),G_=ct.extend({level:Os,logger:T().optional(),data:Ce()}),nl=ut.extend({method:te("notifications/message"),params:G_}),Y_=H({name:T().optional()}),X_=H({hints:F(Y_).optional(),costPriority:_e().min(0).max(1).optional(),speedPriority:_e().min(0).max(1).optional(),intelligencePriority:_e().min(0).max(1).optional()}),Q_=H({mode:st(["auto","required","none"]).optional()}),eg=H({type:te("tool_result"),toolUseId:T().describe("The unique identifier for the corresponding tool call."),content:F(co).default([]),structuredContent:H({}).loose().optional(),isError:Te().optional(),_meta:Oe(T(),Ce()).optional()}),tg=Pu("type",[ao,oo,io]),As=Pu("type",[ao,oo,io,U_,eg]),rg=H({role:en,content:Ee([As,F(As)]),_meta:Oe(T(),Ce()).optional()}),ng=Br.extend({messages:F(rg),modelPreferences:X_.optional(),systemPrompt:T().optional(),includeContext:st(["none","thisServer","allServers"]).optional(),temperature:_e().optional(),maxTokens:_e().int(),stopSequences:F(T()).optional(),metadata:Le.optional(),tools:F(tl).optional(),toolChoice:Q_.optional()}),ho=Ue.extend({method:te("sampling/createMessage"),params:ng}),js=De.extend({model:T(),stopReason:Ae(st(["endTurn","stopSequence","maxTokens"]).or(T())),role:en,content:tg}),sl=De.extend({model:T(),stopReason:Ae(st(["endTurn","stopSequence","maxTokens","toolUse"]).or(T())),role:en,content:Ee([As,F(As)])}),sg=H({type:te("boolean"),title:T().optional(),description:T().optional(),default:Te().optional()}),ag=H({type:te("string"),title:T().optional(),description:T().optional(),minLength:_e().optional(),maxLength:_e().optional(),format:st(["email","uri","date","date-time"]).optional(),default:T().optional()}),og=H({type:st(["number","integer"]),title:T().optional(),description:T().optional(),minimum:_e().optional(),maximum:_e().optional(),default:_e().optional()}),ig=H({type:te("string"),title:T().optional(),description:T().optional(),enum:F(T()),default:T().optional()}),cg=H({type:te("string"),title:T().optional(),description:T().optional(),oneOf:F(H({const:T(),title:T()})),default:T().optional()}),ug=H({type:te("string"),title:T().optional(),description:T().optional(),enum:F(T()),enumNames:F(T()).optional(),default:T().optional()}),lg=Ee([ig,cg]),dg=H({type:te("array"),title:T().optional(),description:T().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:H({type:te("string"),enum:F(T())}),default:F(T()).optional()}),fg=H({type:te("array"),title:T().optional(),description:T().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:H({anyOf:F(H({const:T(),title:T()}))}),default:F(T()).optional()}),hg=Ee([dg,fg]),pg=Ee([ug,lg,hg]),mg=Ee([pg,sg,ag,og]),_g=Br.extend({mode:te("form").optional(),message:T(),requestedSchema:H({type:te("object"),properties:Oe(T(),mg),required:F(T()).optional()})}),gg=Br.extend({mode:te("url"),message:T(),elicitationId:T(),url:T().url()}),yg=Ee([_g,gg]),po=Ue.extend({method:te("elicitation/create"),params:yg}),vg=ct.extend({elicitationId:T()}),wg=ut.extend({method:te("notifications/elicitation/complete"),params:vg}),tn=De.extend({action:st(["accept","decline","cancel"]),content:Au(t=>t===null?void 0:t,Oe(T(),Ee([T(),_e(),Te(),F(T())])).optional())}),bg=H({type:te("ref/resource"),uri:T()}),kg=H({type:te("ref/prompt"),name:T()}),$g=at.extend({ref:Ee([kg,bg]),argument:H({name:T(),value:T()}),context:H({arguments:Oe(T(),T()).optional()}).optional()}),mo=Ue.extend({method:te("completion/complete"),params:$g});function Sg(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Tg(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}const al=De.extend({completion:Ze({values:F(T()).max(100),total:Ae(_e().int()),hasMore:Ae(Te())})}),Eg=H({uri:T().startsWith("file://"),name:T().optional(),_meta:Oe(T(),Ce()).optional()}),ol=Ue.extend({method:te("roots/list"),params:at.optional()}),_o=De.extend({roots:F(Eg)}),il=ut.extend({method:te("notifications/roots/list_changed"),params:ct.optional()});Ee([Fa,Uu,mo,Ns,so,no,Is,Qa,to,Gu,Yu,Cs,lo,Wa,Ba,Ja,Ya]),Ee([Da,Ha,Va,il,xs]),Ee([Ft,js,sl,tn,_o,Ka,Ga,gr]),Ee([Fa,ho,po,ol,Wa,Ba,Ja,Ya]),Ee([Da,Ha,nl,Xu,ro,fo,uo,xs,wg]),Ee([Ft,Du,al,el,Qu,Ku,Bu,Ju,vr,rl,Ka,Ga,gr]);class K 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===G.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new Rg(s.elicitations,r)}return new K(e,r,n)}}class Rg extends K{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(G.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}var de;(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 o of s)a[o]=o;return a},t.getValidEnumValues=s=>{const a=t.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),o={};for(const i of a)o[i]=s[i];return t.objectValues(o)},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 o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},t.find=(s,a)=>{for(const o of s)if(a(o))return o},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(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(de||(de={}));var go;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(go||(go={}));const B=de.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ot=t=>{switch(typeof t){case"undefined":return B.undefined;case"string":return B.string;case"number":return Number.isNaN(t)?B.nan:B.number;case"boolean":return B.boolean;case"function":return B.function;case"bigint":return B.bigint;case"symbol":return B.symbol;case"object":return Array.isArray(t)?B.array:t===null?B.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?B.promise:typeof Map<"u"&&t instanceof Map?B.map:typeof Set<"u"&&t instanceof Set?B.set:typeof Date<"u"&&t instanceof Date?B.date:B.object;default:return B.unknown}},q=de.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"]),Pg=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class ot 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 o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let i=n,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(r(o))):i[u]=i[u]||{_errors:[]},i=i[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof ot))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,de.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()}}ot.create=t=>new ot(t);const wr=(t,e)=>{let r;switch(t.code){case q.invalid_type:t.received===B.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case q.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,de.jsonStringifyReplacer)}`;break;case q.unrecognized_keys:r=`Unrecognized key(s) in object: ${de.joinValues(t.keys,", ")}`;break;case q.invalid_union:r="Invalid input";break;case q.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${de.joinValues(t.options)}`;break;case q.invalid_enum_value:r=`Invalid enum value. Expected ${de.joinValues(t.options)}, received '${t.received}'`;break;case q.invalid_arguments:r="Invalid function arguments";break;case q.invalid_return_type:r="Invalid function return type";break;case q.invalid_date:r="Invalid date";break;case q.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}"`:de.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case q.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 q.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 q.custom:r="Invalid input";break;case q.invalid_intersection_types:r="Intersection results could not be merged";break;case q.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case q.not_finite:r="Number must be finite";break;default:r=e.defaultError,de.assertNever(t)}return{message:r}};let cl=wr;function xg(t){cl=t}function Ms(){return cl}const zs=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let i="";const c=n.filter(u=>!!u).slice().reverse();for(const u of c)i=u(o,{data:e,defaultError:i}).message;return{...s,path:a,message:i}},Ig=[];function W(t,e){const r=Ms(),n=zs({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===wr?void 0:wr].filter(s=>!!s)});t.common.issues.push(n)}class We{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,o=await s.value;n.push({key:a,value:o})}return We.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return se;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}}const se=Object.freeze({status:"aborted"}),br=t=>({status:"dirty",value:t}),Be=t=>({status:"valid",value:t}),yo=t=>t.status==="aborted",vo=t=>t.status==="dirty",or=t=>t.status==="valid",rn=t=>typeof Promise<"u"&&t instanceof Promise;var Q;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Q||(Q={}));class Rt{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 ul=(t,e)=>{if(or(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 ot(t.common.issues);return this._error=r,this._error}}};function ae(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:(o,i)=>{const{message:c}=t;return o.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??n??i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:c??r??i.defaultError}},description:s}}class oe{get description(){return this._def.description}_getType(e){return Ot(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ot(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new We,ctx:{common:e.parent.common,data:e.data,parsedType:Ot(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(rn(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:Ot(e)},s=this._parseSync({data:e,path:n.path,parent:n});return ul(n,s)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ot(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:r});return or(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=>or(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:Ot(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(rn(s)?s:Promise.resolve(s));return ul(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 o=e(s),i=()=>a.addIssue({code:q.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(i(),!1)):o?!0:(i(),!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 _t({schema:this,typeName:Z.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 gt.create(this,this._def)}nullable(){return Bt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mt.create(this)}promise(){return Tr.create(this,this._def)}or(e){return on.create([this,e],this._def)}and(e){return cn.create(this,e,this._def)}transform(e){return new _t({...ae(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new hn({...ae(this._def),innerType:this,defaultValue:r,typeName:Z.ZodDefault})}brand(){return new ko({typeName:Z.ZodBranded,type:this,...ae(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new pn({...ae(this._def),innerType:this,catchValue:r,typeName:Z.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return mn.create(this,e)}readonly(){return _n.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Cg=/^c[^\s-]{8,}$/i,Og=/^[0-9a-z]+$/,Ng=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ag=/^[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,jg=/^[a-z0-9_-]{21}$/i,Mg=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zg=/^[-+]?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)?)??$/,qg=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wo;const Lg=/^(?:(?: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])$/,Ug=/^(?:(?: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])$/,Dg=/^(([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]))$/,Vg=/^(([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])$/,Fg=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Hg=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ll="((\\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])))",Wg=new RegExp(`^${ll}$`);function dl(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 Kg(t){return new RegExp(`^${dl(t)}$`)}function fl(t){let e=`${ll}T${dl(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 Bg(t,e){return!!((e==="v4"||!e)&&Lg.test(t)||(e==="v6"||!e)&&Dg.test(t))}function Jg(t,e){if(!Mg.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 Gg(t,e){return!!((e==="v4"||!e)&&Ug.test(t)||(e==="v6"||!e)&&Vg.test(t))}class pt extends oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==B.string){const a=this._getOrReturnCtx(e);return W(a,{code:q.invalid_type,expected:B.string,received:a.parsedType}),se}const n=new We;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:q.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),W(s,{code:q.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(s=this._getOrReturnCtx(e,s),o?W(s,{code:q.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&W(s,{code:q.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")qg.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"email",code:q.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")wo||(wo=new RegExp(Zg,"u")),wo.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"emoji",code:q.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ag.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"uuid",code:q.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")jg.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"nanoid",code:q.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Cg.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid",code:q.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Og.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cuid2",code:q.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Ng.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ulid",code:q.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),W(s,{validation:"url",code:q.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),W(s,{validation:"regex",code:q.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),W(s,{code:q.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),W(s,{code:q.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),W(s,{code:q.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?fl(a).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:q.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Wg.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:q.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Kg(a).test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{code:q.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?zg.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"duration",code:q.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Bg(e.data,a.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"ip",code:q.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Jg(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"jwt",code:q.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Gg(e.data,a.version)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"cidr",code:q.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Fg.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64",code:q.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Hg.test(e.data)||(s=this._getOrReturnCtx(e,s),W(s,{validation:"base64url",code:q.invalid_string,message:a.message}),n.dirty()):de.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:q.invalid_string,...Q.errToObj(n)})}_addCheck(e){return new pt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Q.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Q.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Q.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Q.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Q.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Q.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Q.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Q.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Q.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Q.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Q.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Q.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Q.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,...Q.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,...Q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Q.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Q.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...Q.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Q.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Q.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Q.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Q.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Q.errToObj(r)})}nonempty(e){return this.min(1,Q.errToObj(e))}trim(){return new pt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new pt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new pt({...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}}pt.create=t=>new pt({checks:[],typeName:Z.ZodString,coerce:t?.coerce??!1,...ae(t)});function Yg(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(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return a%o/10**s}class Ht extends oe{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)!==B.number){const a=this._getOrReturnCtx(e);return W(a,{code:q.invalid_type,expected:B.number,received:a.parsedType}),se}let n;const s=new We;for(const a of this._def.checks)a.kind==="int"?de.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:q.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),W(n,{code:q.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),W(n,{code:q.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Yg(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),W(n,{code:q.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:q.not_finite,message:a.message}),s.dirty()):de.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,s){return new Ht({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(s)}]})}_addCheck(e){return new Ht({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Q.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Q.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Q.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Q.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"&&de.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)}}Ht.create=t=>new Ht({checks:[],typeName:Z.ZodNumber,coerce:t?.coerce||!1,...ae(t)});class Wt extends oe{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)!==B.bigint)return this._getInvalidInput(e);let n;const s=new We;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),W(n,{code:q.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),W(n,{code:q.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),W(n,{code:q.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):de.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return W(r,{code:q.invalid_type,expected:B.bigint,received:r.parsedType}),se}gte(e,r){return this.setLimit("min",e,!0,Q.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Q.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Q.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Q.toString(r))}setLimit(e,r,n,s){return new Wt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Q.toString(s)}]})}_addCheck(e){return new Wt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Q.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Q.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Q.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}}Wt.create=t=>new Wt({checks:[],typeName:Z.ZodBigInt,coerce:t?.coerce??!1,...ae(t)});class nn extends oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==B.boolean){const n=this._getOrReturnCtx(e);return W(n,{code:q.invalid_type,expected:B.boolean,received:n.parsedType}),se}return Be(e.data)}}nn.create=t=>new nn({typeName:Z.ZodBoolean,coerce:t?.coerce||!1,...ae(t)});class ir extends oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==B.date){const a=this._getOrReturnCtx(e);return W(a,{code:q.invalid_type,expected:B.date,received:a.parsedType}),se}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return W(a,{code:q.invalid_date}),se}const n=new We;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),W(s,{code:q.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),W(s,{code:q.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):de.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ir({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Q.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Q.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}}ir.create=t=>new ir({checks:[],coerce:t?.coerce||!1,typeName:Z.ZodDate,...ae(t)});class qs extends oe{_parse(e){if(this._getType(e)!==B.symbol){const n=this._getOrReturnCtx(e);return W(n,{code:q.invalid_type,expected:B.symbol,received:n.parsedType}),se}return Be(e.data)}}qs.create=t=>new qs({typeName:Z.ZodSymbol,...ae(t)});class sn extends oe{_parse(e){if(this._getType(e)!==B.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:q.invalid_type,expected:B.undefined,received:n.parsedType}),se}return Be(e.data)}}sn.create=t=>new sn({typeName:Z.ZodUndefined,...ae(t)});class an extends oe{_parse(e){if(this._getType(e)!==B.null){const n=this._getOrReturnCtx(e);return W(n,{code:q.invalid_type,expected:B.null,received:n.parsedType}),se}return Be(e.data)}}an.create=t=>new an({typeName:Z.ZodNull,...ae(t)});class kr extends oe{constructor(){super(...arguments),this._any=!0}_parse(e){return Be(e.data)}}kr.create=t=>new kr({typeName:Z.ZodAny,...ae(t)});class cr extends oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Be(e.data)}}cr.create=t=>new cr({typeName:Z.ZodUnknown,...ae(t)});class Nt extends oe{_parse(e){const r=this._getOrReturnCtx(e);return W(r,{code:q.invalid_type,expected:B.never,received:r.parsedType}),se}}Nt.create=t=>new Nt({typeName:Z.ZodNever,...ae(t)});class Zs extends oe{_parse(e){if(this._getType(e)!==B.undefined){const n=this._getOrReturnCtx(e);return W(n,{code:q.invalid_type,expected:B.void,received:n.parsedType}),se}return Be(e.data)}}Zs.create=t=>new Zs({typeName:Z.ZodVoid,...ae(t)});class mt extends oe{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==B.array)return W(r,{code:q.invalid_type,expected:B.array,received:r.parsedType}),se;if(s.exactLength!==null){const o=r.data.length>s.exactLength.value,i=r.data.length<s.exactLength.value;(o||i)&&(W(r,{code:o?q.too_big:q.too_small,minimum:i?s.exactLength.value:void 0,maximum:o?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&&(W(r,{code:q.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&&(W(r,{code:q.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((o,i)=>s.type._parseAsync(new Rt(r,o,r.path,i)))).then(o=>We.mergeArray(n,o));const a=[...r.data].map((o,i)=>s.type._parseSync(new Rt(r,o,r.path,i)));return We.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new mt({...this._def,minLength:{value:e,message:Q.toString(r)}})}max(e,r){return new mt({...this._def,maxLength:{value:e,message:Q.toString(r)}})}length(e,r){return new mt({...this._def,exactLength:{value:e,message:Q.toString(r)}})}nonempty(e){return this.min(1,e)}}mt.create=(t,e)=>new mt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...ae(e)});function $r(t){if(t instanceof Ne){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=gt.create($r(n))}return new Ne({...t._def,shape:()=>e})}else return t instanceof mt?new mt({...t._def,type:$r(t.element)}):t instanceof gt?gt.create($r(t.unwrap())):t instanceof Bt?Bt.create($r(t.unwrap())):t instanceof Pt?Pt.create(t.items.map(e=>$r(e))):t}class Ne extends oe{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=de.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==B.object){const u=this._getOrReturnCtx(e);return W(u,{code:q.invalid_type,expected:B.object,received:u.parsedType}),se}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof Nt&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||i.push(u);const c=[];for(const u of o){const l=a[u],d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Rt(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof Nt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of i)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")i.length>0&&(W(s,{code:q.unrecognized_keys,keys:i}),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 i){const d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Rt(s,d,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const d=await l.key,m=await l.value;u.push({key:d,value:m,alwaysSet:l.alwaysSet})}return u}).then(u=>We.mergeObjectSync(n,u)):We.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return Q.errToObj,new Ne({...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:Q.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Ne({...this._def,unknownKeys:"strip"})}passthrough(){return new Ne({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ne({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ne({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Ne({...this._def,catchall:e})}pick(e){const r={};for(const n of de.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Ne({...this._def,shape:()=>r})}omit(e){const r={};for(const n of de.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Ne({...this._def,shape:()=>r})}deepPartial(){return $r(this)}partial(e){const r={};for(const n of de.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new Ne({...this._def,shape:()=>r})}required(e){const r={};for(const n of de.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof gt;)a=a._def.innerType;r[n]=a}return new Ne({...this._def,shape:()=>r})}keyof(){return hl(de.objectKeys(this.shape))}}Ne.create=(t,e)=>new Ne({shape:()=>t,unknownKeys:"strip",catchall:Nt.create(),typeName:Z.ZodObject,...ae(e)}),Ne.strictCreate=(t,e)=>new Ne({shape:()=>t,unknownKeys:"strict",catchall:Nt.create(),typeName:Z.ZodObject,...ae(e)}),Ne.lazycreate=(t,e)=>new Ne({shape:t,unknownKeys:"strip",catchall:Nt.create(),typeName:Z.ZodObject,...ae(e)});class on extends oe{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(i=>new ot(i.ctx.common.issues));return W(r,{code:q.invalid_union,unionErrors:o}),se}if(r.common.async)return Promise.all(n.map(async a=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];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&&o.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(c=>new ot(c));return W(r,{code:q.invalid_union,unionErrors:i}),se}}get options(){return this._def.options}}on.create=(t,e)=>new on({options:t,typeName:Z.ZodUnion,...ae(e)});const At=t=>t instanceof ln?At(t.schema):t instanceof _t?At(t.innerType()):t instanceof dn?[t.value]:t instanceof Kt?t.options:t instanceof fn?de.objectValues(t.enum):t instanceof hn?At(t._def.innerType):t instanceof sn?[void 0]:t instanceof an?[null]:t instanceof gt?[void 0,...At(t.unwrap())]:t instanceof Bt?[null,...At(t.unwrap())]:t instanceof ko||t instanceof _n?At(t.unwrap()):t instanceof pn?At(t._def.innerType):[];class Ls extends oe{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==B.object)return W(r,{code:q.invalid_type,expected:B.object,received:r.parsedType}),se;const n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(W(r,{code:q.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),se)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const s=new Map;for(const a of r){const o=At(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of o){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,a)}}return new Ls({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...ae(n)})}}function bo(t,e){const r=Ot(t),n=Ot(e);if(t===e)return{valid:!0,data:t};if(r===B.object&&n===B.object){const s=de.objectKeys(e),a=de.objectKeys(t).filter(i=>s.indexOf(i)!==-1),o={...t,...e};for(const i of a){const c=bo(t[i],e[i]);if(!c.valid)return{valid:!1};o[i]=c.data}return{valid:!0,data:o}}else if(r===B.array&&n===B.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<t.length;a++){const o=t[a],i=e[a],c=bo(o,i);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===B.date&&n===B.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class cn extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(a,o)=>{if(yo(a)||yo(o))return se;const i=bo(a.value,o.value);return i.valid?((vo(a)||vo(o))&&r.dirty(),{status:r.value,value:i.data}):(W(n,{code:q.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,o])=>s(a,o)):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}))}}cn.create=(t,e,r)=>new cn({left:t,right:e,typeName:Z.ZodIntersection,...ae(r)});class Pt extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.array)return W(n,{code:q.invalid_type,expected:B.array,received:n.parsedType}),se;if(n.data.length<this._def.items.length)return W(n,{code:q.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),se;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:q.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((o,i)=>{const c=this._def.items[i]||this._def.rest;return c?c._parse(new Rt(n,o,n.path,i)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>We.mergeArray(r,o)):We.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Pt({...this._def,rest:e})}}Pt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pt({items:t,typeName:Z.ZodTuple,rest:null,...ae(e)})};class un extends oe{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!==B.object)return W(n,{code:q.invalid_type,expected:B.object,received:n.parsedType}),se;const s=[],a=this._def.keyType,o=this._def.valueType;for(const i in n.data)s.push({key:a._parse(new Rt(n,i,n.path,i)),value:o._parse(new Rt(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?We.mergeObjectAsync(r,s):We.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof oe?new un({keyType:e,valueType:r,typeName:Z.ZodRecord,...ae(n)}):new un({keyType:pt.create(),valueType:e,typeName:Z.ZodRecord,...ae(r)})}}class Us extends oe{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!==B.map)return W(n,{code:q.invalid_type,expected:B.map,received:n.parsedType}),se;const s=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([i,c],u)=>({key:s._parse(new Rt(n,i,n.path,[u,"key"])),value:a._parse(new Rt(n,c,n.path,[u,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const c of o){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(),i.set(u.value,l.value)}return{status:r.value,value:i}})}else{const i=new Map;for(const c of o){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return se;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),i.set(u.value,l.value)}return{status:r.value,value:i}}}}Us.create=(t,e,r)=>new Us({valueType:e,keyType:t,typeName:Z.ZodMap,...ae(r)});class ur extends oe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==B.set)return W(n,{code:q.invalid_type,expected:B.set,received:n.parsedType}),se;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(W(n,{code:q.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&&(W(n,{code:q.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const a=this._def.valueType;function o(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 i=[...n.data.values()].map((c,u)=>a._parse(new Rt(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>o(c)):o(i)}min(e,r){return new ur({...this._def,minSize:{value:e,message:Q.toString(r)}})}max(e,r){return new ur({...this._def,maxSize:{value:e,message:Q.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}ur.create=(t,e)=>new ur({valueType:t,minSize:null,maxSize:null,typeName:Z.ZodSet,...ae(e)});class Sr extends oe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==B.function)return W(r,{code:q.invalid_type,expected:B.function,received:r.parsedType}),se;function n(i,c){return zs({data:i,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ms(),wr].filter(u=>!!u),issueData:{code:q.invalid_arguments,argumentsError:c}})}function s(i,c){return zs({data:i,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ms(),wr].filter(u=>!!u),issueData:{code:q.invalid_return_type,returnTypeError:c}})}const a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Tr){const i=this;return Be(async function(...c){const u=new ot([]),l=await i._def.args.parseAsync(c,a).catch(_=>{throw u.addIssue(n(c,_)),u}),d=await Reflect.apply(o,this,l);return await i._def.returns._def.type.parseAsync(d,a).catch(_=>{throw u.addIssue(s(d,_)),u})})}else{const i=this;return Be(function(...c){const u=i._def.args.safeParse(c,a);if(!u.success)throw new ot([n(c,u.error)]);const l=Reflect.apply(o,this,u.data),d=i._def.returns.safeParse(l,a);if(!d.success)throw new ot([s(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Sr({...this._def,args:Pt.create(e).rest(cr.create())})}returns(e){return new Sr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Sr({args:e||Pt.create([]).rest(cr.create()),returns:r||cr.create(),typeName:Z.ZodFunction,...ae(n)})}}class ln extends oe{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})}}ln.create=(t,e)=>new ln({getter:t,typeName:Z.ZodLazy,...ae(e)});class dn extends oe{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return W(r,{received:r.data,code:q.invalid_literal,expected:this._def.value}),se}return{status:"valid",value:e.data}}get value(){return this._def.value}}dn.create=(t,e)=>new dn({value:t,typeName:Z.ZodLiteral,...ae(e)});function hl(t,e){return new Kt({values:t,typeName:Z.ZodEnum,...ae(e)})}class Kt extends oe{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return W(r,{expected:de.joinValues(n),received:r.parsedType,code:q.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 W(r,{received:r.data,code:q.invalid_enum_value,options:n}),se}return Be(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 Kt.create(e,{...this._def,...r})}exclude(e,r=this._def){return Kt.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}Kt.create=hl;class fn extends oe{_parse(e){const r=de.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==B.string&&n.parsedType!==B.number){const s=de.objectValues(r);return W(n,{expected:de.joinValues(s),received:n.parsedType,code:q.invalid_type}),se}if(this._cache||(this._cache=new Set(de.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=de.objectValues(r);return W(n,{received:n.data,code:q.invalid_enum_value,options:s}),se}return Be(e.data)}get enum(){return this._def.values}}fn.create=(t,e)=>new fn({values:t,typeName:Z.ZodNativeEnum,...ae(e)});class Tr extends oe{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==B.promise&&r.common.async===!1)return W(r,{code:q.invalid_type,expected:B.promise,received:r.parsedType}),se;const n=r.parsedType===B.promise?r.data:Promise.resolve(r.data);return Be(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Tr.create=(t,e)=>new Tr({type:t,typeName:Z.ZodPromise,...ae(e)});class _t extends oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.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:o=>{W(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async i=>{if(r.value==="aborted")return se;const c=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return c.status==="aborted"?se:c.status==="dirty"||r.value==="dirty"?br(c.value):c});{if(r.value==="aborted")return se;const i=this._def.schema._parseSync({data:o,path:n.path,parent:n});return i.status==="aborted"?se:i.status==="dirty"||r.value==="dirty"?br(i.value):i}}if(s.type==="refinement"){const o=i=>{const c=s.refinement(i,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 i};if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?se:(i.status==="dirty"&&r.dirty(),o(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?se:(i.status==="dirty"&&r.dirty(),o(i.value).then(()=>({status:r.value,value:i.value}))))}if(s.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!or(o))return se;const i=s.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>or(o)?Promise.resolve(s.transform(o.value,a)).then(i=>({status:r.value,value:i})):se);de.assertNever(s)}}_t.create=(t,e,r)=>new _t({schema:t,typeName:Z.ZodEffects,effect:e,...ae(r)}),_t.createWithPreprocess=(t,e,r)=>new _t({schema:e,effect:{type:"preprocess",transform:t},typeName:Z.ZodEffects,...ae(r)});class gt extends oe{_parse(e){return this._getType(e)===B.undefined?Be(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}gt.create=(t,e)=>new gt({innerType:t,typeName:Z.ZodOptional,...ae(e)});class Bt extends oe{_parse(e){return this._getType(e)===B.null?Be(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Bt.create=(t,e)=>new Bt({innerType:t,typeName:Z.ZodNullable,...ae(e)});class hn extends oe{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===B.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}hn.create=(t,e)=>new hn({innerType:t,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ae(e)});class pn extends oe{_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 rn(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}pn.create=(t,e)=>new pn({innerType:t,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ae(e)});class Ds extends oe{_parse(e){if(this._getType(e)!==B.nan){const n=this._getOrReturnCtx(e);return W(n,{code:q.invalid_type,expected:B.nan,received:n.parsedType}),se}return{status:"valid",value:e.data}}}Ds.create=t=>new Ds({typeName:Z.ZodNaN,...ae(t)});const Xg=Symbol("zod_brand");class ko extends oe{_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 mn extends oe{_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(),br(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 mn({in:e,out:r,typeName:Z.ZodPipeline})}}class _n extends oe{_parse(e){const r=this._def.innerType._parse(e),n=s=>(or(s)&&(s.value=Object.freeze(s.value)),s);return rn(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}_n.create=(t,e)=>new _n({innerType:t,typeName:Z.ZodReadonly,...ae(e)});function pl(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function ml(t,e={},r){return t?kr.create().superRefine((n,s)=>{const a=t(n);if(a instanceof Promise)return a.then(o=>{if(!o){const i=pl(e,n),c=i.fatal??r??!0;s.addIssue({code:"custom",...i,fatal:c})}});if(!a){const o=pl(e,n),i=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:i})}}):kr.create()}const Qg={object:Ne.lazycreate};var Z;(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"})(Z||(Z={}));const ey=(t,e={message:`Input not instance of ${t.name}`})=>ml(r=>r instanceof t,e),_l=pt.create,gl=Ht.create,ty=Ds.create,ry=Wt.create,yl=nn.create,ny=ir.create,sy=qs.create,ay=sn.create,oy=an.create,iy=kr.create,cy=cr.create,uy=Nt.create,ly=Zs.create,dy=mt.create,vl=Ne.create,fy=Ne.strictCreate,hy=on.create,py=Ls.create,my=cn.create,_y=Pt.create,gy=un.create,yy=Us.create,vy=ur.create,wy=Sr.create,by=ln.create,ky=dn.create,$y=Kt.create,Sy=fn.create,Ty=Tr.create,wl=_t.create,Ey=gt.create,Ry=Bt.create,Py=_t.createWithPreprocess,xy=mn.create,Iy=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Xg,DIRTY:br,EMPTY_PATH:Ig,INVALID:se,NEVER:se,OK:Be,ParseStatus:We,Schema:oe,ZodAny:kr,ZodArray:mt,ZodBigInt:Wt,ZodBoolean:nn,ZodBranded:ko,ZodCatch:pn,ZodDate:ir,ZodDefault:hn,ZodDiscriminatedUnion:Ls,ZodEffects:_t,ZodEnum:Kt,ZodError:ot,get ZodFirstPartyTypeKind(){return Z},ZodFunction:Sr,ZodIntersection:cn,ZodIssueCode:q,ZodLazy:ln,ZodLiteral:dn,ZodMap:Us,ZodNaN:Ds,ZodNativeEnum:fn,ZodNever:Nt,ZodNull:an,ZodNullable:Bt,ZodNumber:Ht,ZodObject:Ne,ZodOptional:gt,ZodParsedType:B,ZodPipeline:mn,ZodPromise:Tr,ZodReadonly:_n,ZodRecord:un,ZodSchema:oe,ZodSet:ur,ZodString:pt,ZodSymbol:qs,ZodTransformer:_t,ZodTuple:Pt,ZodType:oe,ZodUndefined:sn,ZodUnion:on,ZodUnknown:cr,ZodVoid:Zs,addIssueToContext:W,any:iy,array:dy,bigint:ry,boolean:yl,coerce:{string:(t=>pt.create({...t,coerce:!0})),number:(t=>Ht.create({...t,coerce:!0})),boolean:(t=>nn.create({...t,coerce:!0})),bigint:(t=>Wt.create({...t,coerce:!0})),date:(t=>ir.create({...t,coerce:!0}))},custom:ml,date:ny,datetimeRegex:fl,defaultErrorMap:wr,discriminatedUnion:py,effect:wl,enum:$y,function:wy,getErrorMap:Ms,getParsedType:Ot,instanceof:ey,intersection:my,isAborted:yo,isAsync:rn,isDirty:vo,isValid:or,late:Qg,lazy:by,literal:ky,makeIssue:zs,map:yy,nan:ty,nativeEnum:Sy,never:uy,null:oy,nullable:Ry,number:gl,object:vl,get objectUtil(){return go},oboolean:()=>yl().optional(),onumber:()=>gl().optional(),optional:Ey,ostring:()=>_l().optional(),pipeline:xy,preprocess:Py,promise:Ty,quotelessJson:Pg,record:gy,set:vy,setErrorMap:xg,strictObject:fy,string:_l,symbol:sy,transformer:wl,tuple:_y,undefined:ay,union:hy,unknown:cy,get util(){return de},void:ly},Symbol.toStringTag,{value:"Module"})),Cy=O("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");ke.init(t,e),t.def=e,t.parse=(r,n)=>xf(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Pa(t,r,n),t.parseAsync=async(r,n)=>If(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>xa(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)=>Dt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))}),Oy=O("ZodMiniObject",(t,e)=>{ru.init(t,e),Cy.init(t,e),Se(t,"shape",()=>e.shape)});function bl(t,e){const r={type:"object",get shape(){return Lr(this,"shape",{...t}),this.shape},...X(e)};return new Oy(r)}function yt(t){return!!t._zod}function Er(t){const e=Object.values(t);if(e.length===0)return bl({});const r=e.every(yt),n=e.every(s=>!yt(s));if(r)return bl(t);if(n)return vl(t);throw new Error("Mixed Zod versions detected in object shape.")}function vt(t,e){return yt(t)?Pa(t,e):t.safeParse(e)}async function $o(t,e){return yt(t)?await xa(t,e):await t.safeParseAsync(e)}function Rr(t){if(!t)return;let e;if(yt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function gn(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 Er(t)}}if(yt(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 So(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 Ny(t){return t.description}function Ay(t){if(yt(t))return t._zod?.def?.type==="optional";const e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function kl(t){if(yt(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 lr(t){return t==="completed"||t==="failed"||t==="cancelled"}const jy=Symbol("Let zodToJsonSchema decide on which parser to use"),$l={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"},My=t=>typeof t=="string"?{...$l,name:t}:{...$l,...t},zy=t=>{const e=My(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 Sl(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ve(t,e,r,n,s){t[e]=r,Sl(t,e,n,s)}const Tl=(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 Qe(t){if(t.target!=="openAi")return{};const e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Tl(e,t.currentPath):e.join("/")}}function qy(t,e){const r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==Z.ZodAny&&(r.items=pe(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ve(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ve(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ve(r,"minItems",t.exactLength.value,t.exactLength.message,e),ve(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Zy(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?ve(r,"minimum",n.value,n.message,e):ve(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ve(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ve(r,"maximum",n.value,n.message,e):ve(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ve(r,"maximum",n.value,n.message,e));break;case"multipleOf":ve(r,"multipleOf",n.value,n.message,e);break}return r}function Ly(){return{type:"boolean"}}function El(t,e){return pe(t.type._def,e)}const Uy=(t,e)=>pe(t.innerType._def,e);function Rl(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>Rl(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 Dy(t,e)}}const Dy=(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":ve(r,"minimum",n.value,n.message,e);break;case"max":ve(r,"maximum",n.value,n.message,e);break}return r};function Vy(t,e){return{...pe(t.innerType._def,e),default:t.defaultValue()}}function Fy(t,e){return e.effectStrategy==="input"?pe(t.schema._def,e):Qe(e)}function Hy(t){return{type:"string",enum:Array.from(t.values)}}const Wy=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Ky(t,e){const r=[pe(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),pe(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(Wy(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:i,...c}=a;o=c}else n=void 0;s.push(o)}}),s.length?{allOf:s,...n}:void 0}function By(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 To;const wt={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:()=>(To===void 0&&(To=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),To),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 Pl(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":ve(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ve(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":bt(r,"email",n.message,e);break;case"format:idn-email":bt(r,"idn-email",n.message,e);break;case"pattern:zod":Je(r,wt.email,n.message,e);break}break;case"url":bt(r,"uri",n.message,e);break;case"uuid":bt(r,"uuid",n.message,e);break;case"regex":Je(r,n.regex,n.message,e);break;case"cuid":Je(r,wt.cuid,n.message,e);break;case"cuid2":Je(r,wt.cuid2,n.message,e);break;case"startsWith":Je(r,RegExp(`^${Eo(n.value,e)}`),n.message,e);break;case"endsWith":Je(r,RegExp(`${Eo(n.value,e)}$`),n.message,e);break;case"datetime":bt(r,"date-time",n.message,e);break;case"date":bt(r,"date",n.message,e);break;case"time":bt(r,"time",n.message,e);break;case"duration":bt(r,"duration",n.message,e);break;case"length":ve(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ve(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Je(r,RegExp(Eo(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&bt(r,"ipv4",n.message,e),n.version!=="v4"&&bt(r,"ipv6",n.message,e);break}case"base64url":Je(r,wt.base64url,n.message,e);break;case"jwt":Je(r,wt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Je(r,wt.ipv4Cidr,n.message,e),n.version!=="v4"&&Je(r,wt.ipv6Cidr,n.message,e);break}case"emoji":Je(r,wt.emoji(),n.message,e);break;case"ulid":{Je(r,wt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{bt(r,"binary",n.message,e);break}case"contentEncoding:base64":{ve(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Je(r,wt.base64,n.message,e);break}}break}case"nanoid":Je(r,wt.nanoid,n.message,e)}return r}function Eo(t,e){return e.patternStrategy==="escape"?Gy(t):t}const Jy=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Gy(t){let e="";for(let r=0;r<t.length;r++)Jy.has(t[r])||(e+="\\"),e+=t[r];return e}function bt(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}}})):ve(t,"format",e,r,n)}function Je(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:xl(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ve(t,"pattern",xl(e,n),r,n)}function xl(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,o=!1,i=!1;for(let c=0;c<n.length;c++){if(a){s+=n[c],a=!1;continue}if(r.i){if(o){if(n[c].match(/[a-z]/)){i?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),i=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],i=!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+=o?`${n[c]}\r
38
+ `:`[${n[c]}\r
39
+ ]`;continue}s+=n[c],n[c]==="\\"?a=!0:o&&n[c]==="]"?o=!1:!o&&n[c]==="["&&(o=!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 Il(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===Z.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Qe(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};const r={type:"object",additionalProperties:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===Z.ZodString&&t.keyType._def.checks?.length){const{type:n,...s}=Pl(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===Z.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===Z.ZodBranded&&t.keyType._def.type._def.typeName===Z.ZodString&&t.keyType._def.type._def.checks?.length){const{type:n,...s}=El(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function Yy(t,e){if(e.mapStrategy==="record")return Il(t,e);const r=pe(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Qe(e),n=pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Qe(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function Xy(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 Qy(t){return t.target==="openAi"?void 0:{not:Qe({...t,currentPath:[...t.currentPath,"not"]})}}function ev(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const Vs={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function tv(t,e){if(e.target==="openApi3")return Cl(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Vs&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,a)=>{const o=Vs[a._def.typeName];return o&&!s.includes(o)?[...s,o]: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 o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];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,o,i)=>i.indexOf(a)===o);return{type:s.length>1?s:s[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._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 Cl(t,e)}const Cl=(t,e)=>{const r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>pe(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 rv(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:Vs[t.innerType._def.typeName],nullable:!0}:{type:[Vs[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const n=pe(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const r=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function nv(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",Sl(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ve(r,"minimum",n.value,n.message,e):ve(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ve(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ve(r,"maximum",n.value,n.message,e):ve(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ve(r,"maximum",n.value,n.message,e));break;case"multipleOf":ve(r,"multipleOf",n.value,n.message,e);break}return r}function sv(t,e){const r=e.target==="openAi",n={type:"object",properties:{}},s=[],a=t.shape();for(const i in a){let c=a[i];if(c===void 0||c._def===void 0)continue;let u=ov(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=pe(c._def,{...e,currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]});l!==void 0&&(n.properties[i]=l,u||s.push(i))}s.length&&(n.required=s);const o=av(t,e);return o!==void 0&&(n.additionalProperties=o),n}function av(t,e){if(t.catchall._def.typeName!=="ZodNever")return pe(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 ov(t){try{return t.isOptional()}catch{return!0}}const iv=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return pe(t.innerType._def,e);const r=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Qe(e)},r]}:Qe(e)},cv=(t,e)=>{if(e.pipeStrategy==="input")return pe(t.in._def,e);if(e.pipeStrategy==="output")return pe(t.out._def,e);const r=pe(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=pe(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function uv(t,e){return pe(t.type._def,e)}function lv(t,e){const n={type:"array",uniqueItems:!0,items:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ve(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ve(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function dv(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>pe(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:pe(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>pe(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function fv(t){return{not:Qe(t)}}function hv(t){return Qe(t)}const pv=(t,e)=>pe(t.innerType._def,e),mv=(t,e,r)=>{switch(e){case Z.ZodString:return Pl(t,r);case Z.ZodNumber:return nv(t,r);case Z.ZodObject:return sv(t,r);case Z.ZodBigInt:return Zy(t,r);case Z.ZodBoolean:return Ly();case Z.ZodDate:return Rl(t,r);case Z.ZodUndefined:return fv(r);case Z.ZodNull:return ev(r);case Z.ZodArray:return qy(t,r);case Z.ZodUnion:case Z.ZodDiscriminatedUnion:return tv(t,r);case Z.ZodIntersection:return Ky(t,r);case Z.ZodTuple:return dv(t,r);case Z.ZodRecord:return Il(t,r);case Z.ZodLiteral:return By(t,r);case Z.ZodEnum:return Hy(t);case Z.ZodNativeEnum:return Xy(t);case Z.ZodNullable:return rv(t,r);case Z.ZodOptional:return iv(t,r);case Z.ZodMap:return Yy(t,r);case Z.ZodSet:return lv(t,r);case Z.ZodLazy:return()=>t.getter()._def;case Z.ZodPromise:return uv(t,r);case Z.ZodNaN:case Z.ZodNever:return Qy(r);case Z.ZodEffects:return Fy(t,r);case Z.ZodAny:return Qe(r);case Z.ZodUnknown:return hv(r);case Z.ZodDefault:return Vy(t,r);case Z.ZodBranded:return El(t,r);case Z.ZodReadonly:return pv(t,r);case Z.ZodCatch:return Uy(t,r);case Z.ZodPipeline:return cv(t,r);case Z.ZodFunction:case Z.ZodVoid:case Z.ZodSymbol:return;default:return(n=>{})()}};function pe(t,e,r=!1){const n=e.seen.get(t);if(e.override){const i=e.override?.(t,e,n,r);if(i!==jy)return i}if(n&&!r){const i=_v(n,e);if(i!==void 0)return i}const s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);const a=mv(t,t.typeName,e),o=typeof a=="function"?pe(a(),e):a;if(o&&gv(t,e,o),e.postProcess){const i=e.postProcess(o,t,e);return s.jsonSchema=o,i}return s.jsonSchema=o,o}const _v=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Tl(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`),Qe(e)):e.$refStrategy==="seen"?Qe(e):void 0}},gv=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),yv=(t,e)=>{const r=zy(e);let n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:pe(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Qe(r)}),{}):void 0;const s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=pe(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Qe(r),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(a.title=o),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 i=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"?i.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(i.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in i||"oneOf"in i||"allOf"in i||"type"in i&&Array.isArray(i.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),i};function vv(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Ol(t,e){return yt(t)?am(t,{target:vv(e?.target),io:e?.pipeStrategy??"input"}):yv(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Nl(t){const r=Rr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=kl(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Al(t,e){const r=vt(t,e);if(!r.success)throw r.error;return r.data}const wv=6e4;class jl{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(Da,r=>{this._oncancel(r)}),this.setNotificationHandler(Ha,r=>{this._onprogress(r)}),this.setRequestHandler(Fa,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Wa,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new K(G.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Ba,async(r,n)=>{const s=async()=>{const a=r.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(a,n.sessionId);){if(i.type==="response"||i.type==="error"){const c=i.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),i.type==="response")l(c);else{const d=c,m=new K(d.error.code,d.error.message,d.error.data);l(m)}else{const d=i.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(i.message,{relatedRequestId:n.requestId})}}const o=await this._taskStore.getTask(a,n.sessionId);if(!o)throw new K(G.InvalidParams,`Task not found: ${a}`);if(!lr(o.status))return await this._waitForTaskUpdate(a,n.signal),await s();if(lr(o.status)){const i=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...i,_meta:{...i._meta,[sr]:{taskId:a}}}}return await s()};return await s()}),this.setRequestHandler(Ja,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 K(G.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(Ya,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new K(G.InvalidParams,`Task not found: ${r.params.taskId}`);if(lr(s.status))throw new K(G.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 K(G.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(s){throw s instanceof K?s:new K(G.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),K.fromError(G.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,o)=>{s?.(a,o),Jr(a)||__(a)?this._onresponse(a):Za(a)?this._onrequest(a,o):m_(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=K.fromError(G.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?.[sr]?.taskId;if(n===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:G.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):s?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}const o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);const i=p_(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,u={signal:o.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{const d={relatedRequestId:e.id};a&&(d.relatedTask={taskId:a}),await this.notification(l,d)},sendRequest:async(l,d,m)=>{const _={...m,relatedRequestId:e.id};a&&!_.relatedTask&&(_.relatedTask={taskId:a});const p=_.relatedTask?.taskId??a;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,d,_)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:i?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(o.signal.aborted)return;const d={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)},async l=>{if(o.signal.aborted)return;const d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:G.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)}).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 o=this._responseHandlers.get(s),i=this._timeoutInfo.get(s);if(i&&o&&i.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),o(c);return}a(n)}_onresponse(e){const r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Jr(e))n(e);else{const o=new K(e.error.code,e.error.message,e.error.data);n(o)}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(Jr(e)&&e.result&&typeof e.result=="object"){const o=e.result;if(o.task&&typeof o.task=="object"){const i=o.task;typeof i.taskId=="string"&&(a=!0,this._taskProgressTokens.set(i.taskId,r))}}if(a||this._progressHandlers.delete(r),Jr(e))s(e);else{const o=K.fromError(e.error.code,e.error.message,e.error.data);s(o)}}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(o){yield{type:"error",error:o instanceof K?o:new K(G.InternalError,String(o))}}return}let a;try{const o=await this.request(e,gr,n);if(o.task)a=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new K(G.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:i},lr(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:i.status==="failed"?yield{type:"error",error:new K(G.InternalError,`Task ${a} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new K(G.InternalError,`Task ${a} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)};return}const c=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof K?o:new K(G.InternalError,String(o))}}}request(e,r,n){const{relatedRequestId:s,resumptionToken:a,onresumptiontoken:o,task:i,relatedTask:c}=n??{};return new Promise((u,l)=>{const d=f=>{l(f)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(f){d(f);return}n?.signal?.throwIfAborted();const m=this._requestMessageId++,_={...e,jsonrpc:"2.0",id:m};n?.onprogress&&(this._progressHandlers.set(m,n.onprogress),_.params={...e.params,_meta:{...e.params?._meta||{},progressToken:m}}),i&&(_.params={..._.params,task:i}),c&&(_.params={..._.params,_meta:{..._.params?._meta||{},[sr]:c}});const p=f=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(f)}},{relatedRequestId:s,resumptionToken:a,onresumptiontoken:o}).catch(b=>this._onerror(new Error(`Failed to send cancellation: ${b}`)));const g=f instanceof K?f:new K(G.RequestTimeout,String(f));l(g)};this._responseHandlers.set(m,f=>{if(!n?.signal?.aborted){if(f instanceof Error)return l(f);try{const g=vt(r,f.result);g.success?u(g.data):l(g.error)}catch(g){l(g)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});const y=n?.timeout??wv,h=()=>p(K.fromError(G.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(m,y,n?.maxTotalTimeout,h,n?.resetTimeoutOnProgress??!1);const v=c?.taskId;if(v){const f=g=>{const b=this._responseHandlers.get(m);b?b(g):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,f),this._enqueueTaskMessage(v,{type:"request",message:_,timestamp:Date.now()}).catch(g=>{this._cleanupTimeout(m),l(g)})}else this._transport.send(_,{relatedRequestId:s,resumptionToken:a,onresumptiontoken:o}).catch(f=>{this._cleanupTimeout(m),l(f)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ka,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},Ga,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},O_,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 i={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[sr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:i,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 i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[sr]:r.relatedTask}}}),this._transport?.send(i,r).catch(c=>this._onerror(c))});return}let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[sr]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(e,r){const n=Nl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,a)=>{const o=Al(e,s);return Promise.resolve(r(o,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=Nl(e);this._notificationHandlers.set(n,s=>{const a=Al(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"&&Za(s.message)){const a=s.message.id,o=this._requestResolvers.get(a);o?(o(new K(G.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 K(G.InvalidRequest,"Request cancelled"));return}const o=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(o),a(new K(G.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 K(G.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(s,a,o)=>{await n.storeTaskResult(s,a,o,r);const i=await n.getTask(s,r);if(i){const c=xs.parse({method:"notifications/tasks/status",params:i});await this.notification(c),lr(i.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,a,o)=>{const i=await n.getTask(s,r);if(!i)throw new K(G.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(lr(i.status))throw new K(G.InvalidParams,`Cannot update task "${s}" from terminal status "${i.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,a,o,r);const c=await n.getTask(s,r);if(c){const u=xs.parse({method:"notifications/tasks/status",params:c});await this.notification(u),lr(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function Ml(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function zl(t,e){const r={...t};for(const n in e){const s=n,a=e[s];if(a===void 0)continue;const o=r[s];Ml(o)&&Ml(a)?r[s]={...o,...a}:r[s]=a}return r}var Fs={exports:{}},Ro={},ql;function bv(){return ql||(ql=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0;function e(A,V){return{validate:A,compare:V}}t.fullFormats={date:e(a,o),time:e(c(!0),u),"date-time":e(m(!0),_),"iso-time":e(c(),l),"iso-date-time":e(m(),p),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:v,"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:D,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:g,int32:{type:"number",validate:k},int64:{type:"number",validate:S},float:{type:"number",validate:C},double:{type:"number",validate:C},password:!0,binary:!0},t.fastFormats={...t.fullFormats,date:e(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),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,_),"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,p),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(A){return A%4===0&&(A%100!==0||A%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(A){const V=n.exec(A);if(!V)return!1;const J=+V[1],Y=+V[2],ge=+V[3];return Y>=1&&Y<=12&&ge>=1&&ge<=(Y===2&&r(J)?29:s[Y])}function o(A,V){if(A&&V)return A>V?1:A<V?-1:0}const i=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(A){return function(J){const Y=i.exec(J);if(!Y)return!1;const ge=+Y[1],Ge=+Y[2],Ye=+Y[3],be=Y[4],Tt=Y[5]==="-"?-1:1,L=+(Y[6]||0),P=+(Y[7]||0);if(L>23||P>59||A&&!be)return!1;if(ge<=23&&Ge<=59&&Ye<60)return!0;const z=Ge-P*Tt,I=ge-L*Tt-(z<0?1:0);return(I===23||I===-1)&&(z===59||z===-1)&&Ye<61}}function u(A,V){if(!(A&&V))return;const J=new Date("2020-01-01T"+A).valueOf(),Y=new Date("2020-01-01T"+V).valueOf();if(J&&Y)return J-Y}function l(A,V){if(!(A&&V))return;const J=i.exec(A),Y=i.exec(V);if(J&&Y)return A=J[1]+J[2]+J[3],V=Y[1]+Y[2]+Y[3],A>V?1:A<V?-1:0}const d=/t|\s/i;function m(A){const V=c(A);return function(Y){const ge=Y.split(d);return ge.length===2&&a(ge[0])&&V(ge[1])}}function _(A,V){if(!(A&&V))return;const J=new Date(A).valueOf(),Y=new Date(V).valueOf();if(J&&Y)return J-Y}function p(A,V){if(!(A&&V))return;const[J,Y]=A.split(d),[ge,Ge]=V.split(d),Ye=o(J,ge);if(Ye!==void 0)return Ye||u(Y,Ge)}const y=/\/|:/,h=/^(?:[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 v(A){return y.test(A)&&h.test(A)}const f=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function g(A){return f.lastIndex=0,f.test(A)}const b=-2147483648,w=2**31-1;function k(A){return Number.isInteger(A)&&A<=w&&A>=b}function S(A){return Number.isInteger(A)}function C(){return!0}const j=/[^\\]\\Z/;function D(A){if(j.test(A))return!1;try{return new RegExp(A),!0}catch{return!1}}})(Ro)),Ro}var Po={},Zl;function kv(){return Zl||(Zl=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;const e=Ac(),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:i,schemaCode:c})=>(0,r.str)`should be ${s[i].okStr} ${c}`,params:({keyword:i,schemaCode:c})=>(0,r._)`{comparison: ${s[i].okStr}, limit: ${c}}`};t.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:a,code(i){const{gen:c,data:u,schemaCode:l,keyword:d,it:m}=i,{opts:_,self:p}=m;if(!_.validateFormats)return;const y=new e.KeywordCxt(m,p.RULES.all.format.definition,"format");y.$data?h():v();function h(){const g=c.scopeValue("formats",{ref:p.formats,code:_.code.formats}),b=c.const("fmt",(0,r._)`${g}[${y.schemaCode}]`);i.fail$data((0,r.or)((0,r._)`typeof ${b} != "object"`,(0,r._)`${b} instanceof RegExp`,(0,r._)`typeof ${b}.compare != "function"`,f(b)))}function v(){const g=y.schema,b=p.formats[g];if(!b||b===!0)return;if(typeof b!="object"||b instanceof RegExp||typeof b.compare!="function")throw new Error(`"${d}": format "${g}" does not define "compare" function`);const w=c.scopeValue("formats",{key:g,ref:b,code:_.code.formats?(0,r._)`${_.code.formats}${(0,r.getProperty)(g)}`:void 0});i.fail$data(f(w))}function f(g){return(0,r._)`${g}.compare(${u}, ${l}) ${s[d].fail} 0`}},dependencies:["format"]};const o=i=>(i.addKeyword(t.formatLimitDefinition),i);t.default=o})(Po)),Po}var Ll;function $v(){return Ll||(Ll=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=bv(),n=kv(),s=ie(),a=new s.Name("fullFormats"),o=new s.Name("fastFormats"),i=(u,l={keywords:!0})=>{if(Array.isArray(l))return c(u,l,r.fullFormats,a),u;const[d,m]=l.mode==="fast"?[r.fastFormats,o]:[r.fullFormats,a],_=l.formats||r.formatNames;return c(u,_,d,m),l.keywords&&(0,n.default)(u),u};i.get=(u,l="full")=>{const m=(l==="fast"?r.fastFormats:r.fullFormats)[u];if(!m)throw new Error(`Unknown format "${u}"`);return m};function c(u,l,d,m){var _,p;(_=(p=u.opts.code).formats)!==null&&_!==void 0||(p.formats=(0,s._)`require("ajv-formats/dist/formats").${m}`);for(const y of l)u.addFormat(y,d[y])}t.exports=e=i,Object.defineProperty(e,"__esModule",{value:!0}),e.default=i})(Fs,Fs.exports)),Fs.exports}var Sv=$v();const Tv=hr(Sv);function Ev(){const t=new jc({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Tv(t),t}class Ul{constructor(e){this._ajv=e??Ev()}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 Rv{constructor(e){this._client=e}async*callToolStream(e,r=vr,n){const s=this._client,a={...n,task:n?.task??(s.isToolTask(e.name)?{}:void 0)},o=s.requestStream({method:"tools/call",params:e},r,a),i=s.getToolOutputValidator(e.name);for await(const c of o){if(c.type==="result"&&i){const u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new K(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{const l=i(u.structuredContent);if(!l.valid){yield{type:"error",error:new K(G.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof K){yield{type:"error",error:l};return}yield{type:"error",error:new K(G.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 Dl(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 Vl(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 Hs(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&&Hs(a,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)typeof r!="boolean"&&Hs(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)typeof r!="boolean"&&Hs(r,e)}}function Pv(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 yn extends jl{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 Ul,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",fo,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",uo,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",ro,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Rv(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=zl(this._capabilities,e)}setRequestHandler(e,r){const s=Rr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(yt(s)){const i=s;a=i._zod?.def?.value??i.value}else{const i=s;a=i._def?.value??i.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const o=a;if(o==="elicitation/create"){const i=async(c,u)=>{const l=vt(po,c);if(!l.success){const f=l.error instanceof Error?l.error.message:String(l.error);throw new K(G.InvalidParams,`Invalid elicitation request: ${f}`)}const{params:d}=l.data;d.mode=d.mode??"form";const{supportsFormMode:m,supportsUrlMode:_}=Pv(this._capabilities.elicitation);if(d.mode==="form"&&!m)throw new K(G.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!_)throw new K(G.InvalidParams,"Client does not support URL-mode elicitation requests");const p=await Promise.resolve(r(c,u));if(d.task){const f=vt(gr,p);if(!f.success){const g=f.error instanceof Error?f.error.message:String(f.error);throw new K(G.InvalidParams,`Invalid task creation result: ${g}`)}return f.data}const y=vt(tn,p);if(!y.success){const f=y.error instanceof Error?y.error.message:String(y.error);throw new K(G.InvalidParams,`Invalid elicitation result: ${f}`)}const h=y.data,v=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&h.action==="accept"&&h.content&&v&&this._capabilities.elicitation?.form?.applyDefaults)try{Hs(v,h.content)}catch{}return h};return super.setRequestHandler(e,i)}if(o==="sampling/createMessage"){const i=async(c,u)=>{const l=vt(ho,c);if(!l.success){const p=l.error instanceof Error?l.error.message:String(l.error);throw new K(G.InvalidParams,`Invalid sampling request: ${p}`)}const{params:d}=l.data,m=await Promise.resolve(r(c,u));if(d.task){const p=vt(gr,m);if(!p.success){const y=p.error instanceof Error?p.error.message:String(p.error);throw new K(G.InvalidParams,`Invalid task creation result: ${y}`)}return p.data}const _=vt(js,m);if(!_.success){const p=_.error instanceof Error?_.error.message:String(_.error);throw new K(G.InvalidParams,`Invalid sampling result: ${p}`)}return _.data};return super.setRequestHandler(e,i)}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:Kr,capabilities:this._capabilities,clientInfo:this._clientInfo}},Du,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!ju.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){Dl(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&Vl(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Ft,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},al,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Ft,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},el,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Qu,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Ku,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Bu,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},Ju,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Ft,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Ft,r)}async callTool(e,r=vr,n){if(this.isToolTaskRequired(e.name))throw new K(G.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 K(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent)try{const o=a(s.structuredContent);if(!o.valid)throw new K(G.InvalidParams,`Structured content does not match the tool's output schema: ${o.errorMessage}`)}catch(o){throw o instanceof K?o:new K(G.InvalidParams,`Failed to validate structured content: ${o instanceof Error?o.message:String(o)}`)}}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},rl,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,r,n,s){const a=B_.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:o,debounceMs:i}=a.data,{onChanged:c}=n,u=async()=>{if(!o){c(null,null);return}try{const d=await s();c(null,d)}catch(d){const m=d instanceof Error?d:new Error(String(d));c(m,null)}},l=()=>{if(i){const d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);const m=setTimeout(u,i);this._listChangedDebounceTimers.set(e,m)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}class Fl 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}}function xo(t){}function Hl(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=xo,onError:r=xo,onRetry:n=xo,onComment:s}=t;let a="",o=!0,i,c="",u="";function l(y){const h=o?y.replace(/^\xEF\xBB\xBF/,""):y,[v,f]=xv(`${a}${h}`);for(const g of v)d(g);a=f,o=!1}function d(y){if(y===""){_();return}if(y.startsWith(":")){s&&s(y.slice(y.startsWith(": ")?2:1));return}const h=y.indexOf(":");if(h!==-1){const v=y.slice(0,h),f=y[h+1]===" "?2:1,g=y.slice(h+f);m(v,g,y);return}m(y,"",y)}function m(y,h,v){switch(y){case"event":u=h;break;case"data":c=`${c}${h}
40
+ `;break;case"id":i=h.includes("\0")?void 0:h;break;case"retry":/^\d+$/.test(h)?n(parseInt(h,10)):r(new Fl(`Invalid \`retry\` value: "${h}"`,{type:"invalid-retry",value:h,line:v}));break;default:r(new Fl(`Unknown field "${y.length>20?`${y.slice(0,20)}…`:y}"`,{type:"unknown-field",field:y,value:h,line:v}));break}}function _(){c.length>0&&e({id:i,event:u||void 0,data:c.endsWith(`
41
+ `)?c.slice(0,-1):c}),i=void 0,c="",u=""}function p(y={}){a&&y.consume&&d(a),o=!0,i=void 0,c="",u="",a=""}return{feed:l,reset:p}}function xv(t){const e=[];let r="",n=0;for(;n<t.length;){const s=t.indexOf("\r",n),a=t.indexOf(`
42
+ `,n);let o=-1;if(s!==-1&&a!==-1?o=Math.min(s,a):s!==-1?s===t.length-1?o=-1:o=s:a!==-1&&(o=a),o===-1){r=t.slice(n);break}else{const i=t.slice(n,o);e.push(i),n=o+1,t[n-1]==="\r"&&t[n]===`
43
+ `&&n++}}return[e,r]}class Wl 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(Kl(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(Kl(this),r)}}function Iv(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Io(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Io).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Io(t.cause)}`:t.message:`${t}`}function Kl(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Bl=t=>{throw TypeError(t)},Co=(t,e,r)=>e.has(t)||Bl("Cannot "+r),le=(t,e,r)=>(Co(t,e,"read from private field"),r?r.call(t):e.get(t)),Me=(t,e,r)=>e.has(t)?Bl("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),xe=(t,e,r,n)=>(Co(t,e,"write to private field"),e.set(t,r),r),jt=(t,e,r)=>(Co(t,e,"access private method"),r),et,dr,Pr,Ws,Ks,vn,xr,wn,Jt,Ir,Cr,Or,bn,kt,Oo,No,Ao,Jl,jo,Mo,kn,zo,qo;class Bs extends EventTarget{constructor(e,r){var n,s;super(),Me(this,kt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Me(this,et),Me(this,dr),Me(this,Pr),Me(this,Ws),Me(this,Ks),Me(this,vn),Me(this,xr),Me(this,wn,null),Me(this,Jt),Me(this,Ir),Me(this,Cr,null),Me(this,Or,null),Me(this,bn,null),Me(this,No,async a=>{var o;le(this,Ir).reset();const{body:i,redirected:c,status:u,headers:l}=a;if(u===204){jt(this,kt,kn).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?xe(this,Pr,new URL(a.url)):xe(this,Pr,void 0),u!==200){jt(this,kt,kn).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){jt(this,kt,kn).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(le(this,et)===this.CLOSED)return;xe(this,et,this.OPEN);const d=new Event("open");if((o=le(this,bn))==null||o.call(this,d),this.dispatchEvent(d),typeof i!="object"||!i||!("getReader"in i)){jt(this,kt,kn).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}const m=new TextDecoder,_=i.getReader();let p=!0;do{const{done:y,value:h}=await _.read();h&&le(this,Ir).feed(m.decode(h,{stream:!y})),y&&(p=!1,le(this,Ir).reset(),jt(this,kt,zo).call(this))}while(p)}),Me(this,Ao,a=>{xe(this,Jt,void 0),!(a.name==="AbortError"||a.type==="aborted")&&jt(this,kt,zo).call(this,Io(a))}),Me(this,jo,a=>{typeof a.id=="string"&&xe(this,wn,a.id);const o=new MessageEvent(a.event||"message",{data:a.data,origin:le(this,Pr)?le(this,Pr).origin:le(this,dr).origin,lastEventId:a.id||""});le(this,Or)&&(!a.event||a.event==="message")&&le(this,Or).call(this,o),this.dispatchEvent(o)}),Me(this,Mo,a=>{xe(this,vn,a)}),Me(this,qo,()=>{xe(this,xr,void 0),le(this,et)===this.CONNECTING&&jt(this,kt,Oo).call(this)});try{if(e instanceof URL)xe(this,dr,e);else if(typeof e=="string")xe(this,dr,new URL(e,Cv()));else throw new Error("Invalid URL")}catch{throw Iv("An invalid or illegal string was specified")}xe(this,Ir,Hl({onEvent:le(this,jo),onRetry:le(this,Mo)})),xe(this,et,this.CONNECTING),xe(this,vn,3e3),xe(this,Ks,(n=r?.fetch)!=null?n:globalThis.fetch),xe(this,Ws,(s=r?.withCredentials)!=null?s:!1),jt(this,kt,Oo).call(this)}get readyState(){return le(this,et)}get url(){return le(this,dr).href}get withCredentials(){return le(this,Ws)}get onerror(){return le(this,Cr)}set onerror(e){xe(this,Cr,e)}get onmessage(){return le(this,Or)}set onmessage(e){xe(this,Or,e)}get onopen(){return le(this,bn)}set onopen(e){xe(this,bn,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,xr)&&clearTimeout(le(this,xr)),le(this,et)!==this.CLOSED&&(le(this,Jt)&&le(this,Jt).abort(),xe(this,et,this.CLOSED),xe(this,Jt,void 0))}}et=new WeakMap,dr=new WeakMap,Pr=new WeakMap,Ws=new WeakMap,Ks=new WeakMap,vn=new WeakMap,xr=new WeakMap,wn=new WeakMap,Jt=new WeakMap,Ir=new WeakMap,Cr=new WeakMap,Or=new WeakMap,bn=new WeakMap,kt=new WeakSet,Oo=function(){xe(this,et,this.CONNECTING),xe(this,Jt,new AbortController),le(this,Ks)(le(this,dr),jt(this,kt,Jl).call(this)).then(le(this,No)).catch(le(this,Ao))},No=new WeakMap,Ao=new WeakMap,Jl=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...le(this,wn)?{"Last-Event-ID":le(this,wn)}:void 0},cache:"no-store",signal:(t=le(this,Jt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},jo=new WeakMap,Mo=new WeakMap,kn=function(t,e){var r;le(this,et)!==this.CLOSED&&xe(this,et,this.CLOSED);const n=new Wl("error",{code:e,message:t});(r=le(this,Cr))==null||r.call(this,n),this.dispatchEvent(n)},zo=function(t,e){var r;if(le(this,et)===this.CLOSED)return;xe(this,et,this.CONNECTING);const n=new Wl("error",{code:e,message:t});(r=le(this,Cr))==null||r.call(this,n),this.dispatchEvent(n),xe(this,xr,setTimeout(le(this,qo),le(this,vn)))},qo=new WeakMap,Bs.CONNECTING=0,Bs.OPEN=1,Bs.CLOSED=2;function Cv(){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 Js(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function Gl(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n?.headers?{...Js(e.headers),...Js(n.headers)}:e.headers};return t(r,s)}:t}let Zo;Zo=globalThis.crypto;async function Ov(t){return(await Zo).getRandomValues(new Uint8Array(t))}async function Nv(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let n="";for(;n.length<t;){const s=await Ov(t-n.length);for(const a of s)a<r&&(n+=e[a%e.length])}return n}async function Av(t){return await Nv(t)}async function jv(t){const e=await(await Zo).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Mv(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await Av(t),r=await jv(e);return{code_verifier:e,code_challenge:r}}const Ve=vm().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:l_.custom,message:"URL must be parseable",fatal:!0}),pf}).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"}),zv=Ze({resource:T().url(),authorization_servers:F(Ve).optional(),jwks_uri:T().url().optional(),scopes_supported:F(T()).optional(),bearer_methods_supported:F(T()).optional(),resource_signing_alg_values_supported:F(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:Te().optional(),authorization_details_types_supported:F(T()).optional(),dpop_signing_alg_values_supported:F(T()).optional(),dpop_bound_access_tokens_required:Te().optional()}),Yl=Ze({issuer:T(),authorization_endpoint:Ve,token_endpoint:Ve,registration_endpoint:Ve.optional(),scopes_supported:F(T()).optional(),response_types_supported:F(T()),response_modes_supported:F(T()).optional(),grant_types_supported:F(T()).optional(),token_endpoint_auth_methods_supported:F(T()).optional(),token_endpoint_auth_signing_alg_values_supported:F(T()).optional(),service_documentation:Ve.optional(),revocation_endpoint:Ve.optional(),revocation_endpoint_auth_methods_supported:F(T()).optional(),revocation_endpoint_auth_signing_alg_values_supported:F(T()).optional(),introspection_endpoint:T().optional(),introspection_endpoint_auth_methods_supported:F(T()).optional(),introspection_endpoint_auth_signing_alg_values_supported:F(T()).optional(),code_challenge_methods_supported:F(T()).optional(),client_id_metadata_document_supported:Te().optional()}),qv=Ze({issuer:T(),authorization_endpoint:Ve,token_endpoint:Ve,userinfo_endpoint:Ve.optional(),jwks_uri:Ve,registration_endpoint:Ve.optional(),scopes_supported:F(T()).optional(),response_types_supported:F(T()),response_modes_supported:F(T()).optional(),grant_types_supported:F(T()).optional(),acr_values_supported:F(T()).optional(),subject_types_supported:F(T()),id_token_signing_alg_values_supported:F(T()),id_token_encryption_alg_values_supported:F(T()).optional(),id_token_encryption_enc_values_supported:F(T()).optional(),userinfo_signing_alg_values_supported:F(T()).optional(),userinfo_encryption_alg_values_supported:F(T()).optional(),userinfo_encryption_enc_values_supported:F(T()).optional(),request_object_signing_alg_values_supported:F(T()).optional(),request_object_encryption_alg_values_supported:F(T()).optional(),request_object_encryption_enc_values_supported:F(T()).optional(),token_endpoint_auth_methods_supported:F(T()).optional(),token_endpoint_auth_signing_alg_values_supported:F(T()).optional(),display_values_supported:F(T()).optional(),claim_types_supported:F(T()).optional(),claims_supported:F(T()).optional(),service_documentation:T().optional(),claims_locales_supported:F(T()).optional(),ui_locales_supported:F(T()).optional(),claims_parameter_supported:Te().optional(),request_parameter_supported:Te().optional(),request_uri_parameter_supported:Te().optional(),require_request_uri_registration:Te().optional(),op_policy_uri:Ve.optional(),op_tos_uri:Ve.optional(),client_id_metadata_document_supported:Te().optional()}),Zv=H({...qv.shape,...Yl.pick({code_challenge_methods_supported:!0}).shape}),Lv=H({access_token:T(),id_token:T().optional(),token_type:T(),expires_in:d_().optional(),scope:T().optional(),refresh_token:T().optional()}).strip(),Uv=H({error:T(),error_description:T().optional(),error_uri:T().optional()}),Xl=Ve.optional().or(te("").transform(()=>{})),Dv=H({redirect_uris:F(Ve),token_endpoint_auth_method:T().optional(),grant_types:F(T()).optional(),response_types:F(T()).optional(),client_name:T().optional(),client_uri:Ve.optional(),logo_uri:Xl,scope:T().optional(),contacts:F(T()).optional(),tos_uri:Xl,policy_uri:T().optional(),jwks_uri:Ve.optional(),jwks:Zm().optional(),software_id:T().optional(),software_version:T().optional(),software_statement:T().optional()}).strip(),Vv=H({client_id:T(),client_secret:T().optional(),client_id_issued_at:_e().optional(),client_secret_expires_at:_e().optional()}).strip(),Fv=Dv.merge(Vv);H({error:T(),error_description:T().optional()}).strip(),H({token:T(),token_type_hint:T().optional()}).strip();function Hv(t){const e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function Wv({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 Lo extends ze{}Lo.errorCode="invalid_request";class Gs extends ze{}Gs.errorCode="invalid_client";class Ys extends ze{}Ys.errorCode="invalid_grant";class Xs extends ze{}Xs.errorCode="unauthorized_client";class Uo extends ze{}Uo.errorCode="unsupported_grant_type";class Do extends ze{}Do.errorCode="invalid_scope";class Vo extends ze{}Vo.errorCode="access_denied";class Nr extends ze{}Nr.errorCode="server_error";class Fo extends ze{}Fo.errorCode="temporarily_unavailable";class Ho extends ze{}Ho.errorCode="unsupported_response_type";class Wo extends ze{}Wo.errorCode="unsupported_token_type";class Ko extends ze{}Ko.errorCode="invalid_token";class Bo extends ze{}Bo.errorCode="method_not_allowed";class Jo extends ze{}Jo.errorCode="too_many_requests";class Qs extends ze{}Qs.errorCode="invalid_client_metadata";class Go extends ze{}Go.errorCode="insufficient_scope";class Yo extends ze{}Yo.errorCode="invalid_target";const Kv={[Lo.errorCode]:Lo,[Gs.errorCode]:Gs,[Ys.errorCode]:Ys,[Xs.errorCode]:Xs,[Uo.errorCode]:Uo,[Do.errorCode]:Do,[Vo.errorCode]:Vo,[Nr.errorCode]:Nr,[Fo.errorCode]:Fo,[Ho.errorCode]:Ho,[Wo.errorCode]:Wo,[Ko.errorCode]:Ko,[Bo.errorCode]:Bo,[Jo.errorCode]:Jo,[Qs.errorCode]:Qs,[Go.errorCode]:Go,[Yo.errorCode]:Yo};class lt extends Error{constructor(e){super(e??"Unauthorized")}}function Bv(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const Xo="code",Qo="S256";function Jv(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&&Bv(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 Gv(t,e,r,n){const{client_id:s,client_secret:a}=e;switch(t){case"client_secret_basic":Yv(s,a,r);return;case"client_secret_post":Xv(s,a,n);return;case"none":Qv(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function Yv(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 Xv(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function Qv(t,e){e.set("client_id",t)}async function Ql(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=Uv.parse(JSON.parse(r)),{error:s,error_description:a,error_uri:o}=n,i=Kv[s]||Nr;return new i(a||"",o)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new Nr(s)}}async function fr(t,e){try{return await ei(t,e)}catch(r){if(r instanceof Gs||r instanceof Xs)return await t.invalidateCredentials?.("all"),await ei(t,e);if(r instanceof Ys)return await t.invalidateCredentials?.("tokens"),await ei(t,e);throw r}}async function ei(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:a}){let o,i;try{o=await r0(e,{resourceMetadataUrl:s},a),o.authorization_servers&&o.authorization_servers.length>0&&(i=o.authorization_servers[0])}catch{}i||(i=new URL("/",e));const c=await t0(e,t,o),u=await i0(i,{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 h=u?.client_id_metadata_document_supported===!0,v=t.clientMetadataUrl;if(v&&!e0(v))throw new Qs(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${v}`);if(h&&v)l={client_id:v},await t.saveClientInformation?.(l);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const g=await f0(i,{metadata:u,clientMetadata:t.clientMetadata,fetchFn:a});await t.saveClientInformation(g),l=g}}const d=!t.redirectUrl;if(r!==void 0||d){const h=await d0(t,i,{metadata:u,resource:c,authorizationCode:r,fetchFn:a});return await t.saveTokens(h),"AUTHORIZED"}const m=await t.tokens();if(m?.refresh_token)try{const h=await l0(i,{metadata:u,clientInformation:l,refreshToken:m.refresh_token,resource:c,addClientAuthentication:t.addClientAuthentication,fetchFn:a});return await t.saveTokens(h),"AUTHORIZED"}catch(h){if(!(!(h instanceof ze)||h instanceof Nr))throw h}const _=t.state?await t.state():void 0,{authorizationUrl:p,codeVerifier:y}=await c0(i,{metadata:u,clientInformation:l,state:_,redirectUrl:t.redirectUrl,scope:n||o?.scopes_supported?.join(" ")||t.clientMetadata.scope,resource:c});return await t.saveCodeVerifier(y),await t.redirectToAuthorization(p),"REDIRECT"}function e0(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function t0(t,e,r){const n=Hv(t);if(e.validateResourceURL)return await e.validateResourceURL(n,r?.resource);if(r){if(!Wv({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 ea(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=ti(t,"resource_metadata")||void 0;let a;if(s)try{a=new URL(s)}catch{}const o=ti(t,"scope")||void 0,i=ti(t,"error")||void 0;return{resourceMetadataUrl:a,scope:o,error:i}}function ti(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}async function r0(t,e,r=fetch){const n=await a0(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 zv.parse(await n.json())}async function ri(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?ri(t,void 0,r):void 0;throw n}}function n0(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function ed(t,e,r=fetch){return await ri(t,{"MCP-Protocol-Version":e},r)}function s0(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function a0(t,e,r,n){const s=new URL(t),a=n?.protocolVersion??Kr;let o;if(n?.metadataUrl)o=new URL(n.metadataUrl);else{const c=n0(e,s.pathname);o=new URL(c,n?.metadataServerUrl??s),o.search=s.search}let i=await ed(o,a,r);if(!n?.metadataUrl&&s0(i,s.pathname)){const c=new URL(`/.well-known/${e}`,s);i=await ed(c,a,r)}return i}function o0(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 i0(t,{fetchFn:e=fetch,protocolVersion:r=Kr}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=o0(t);for(const{url:a,type:o}of s){const i=await ri(a,n,e);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw new Error(`HTTP ${i.status} trying to load ${o==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}return o==="oauth"?Yl.parse(await i.json()):Zv.parse(await i.json())}}}async function c0(t,{metadata:e,clientInformation:r,redirectUrl:n,scope:s,state:a,resource:o}){let i;if(e){if(i=new URL(e.authorization_endpoint),!e.response_types_supported.includes(Xo))throw new Error(`Incompatible auth server: does not support response type ${Xo}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Qo))throw new Error(`Incompatible auth server: does not support code challenge method ${Qo}`)}else i=new URL("/authorize",t);const c=await Mv(),u=c.code_verifier,l=c.code_challenge;return i.searchParams.set("response_type",Xo),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",l),i.searchParams.set("code_challenge_method",Qo),i.searchParams.set("redirect_uri",String(n)),a&&i.searchParams.set("state",a),s&&i.searchParams.set("scope",s),s?.includes("offline_access")&&i.searchParams.append("prompt","consent"),o&&i.searchParams.set("resource",o.href),{authorizationUrl:i,codeVerifier:u}}function u0(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function td(t,{metadata:e,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:a,fetchFn:o}){const i=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,i,e);else if(n){const l=e?.token_endpoint_auth_methods_supported??[],d=Jv(n,l);Gv(d,n,c,r)}const u=await(o??fetch)(i,{method:"POST",headers:c,body:r});if(!u.ok)throw await Ql(u);return Lv.parse(await u.json())}async function l0(t,{metadata:e,clientInformation:r,refreshToken:n,resource:s,addClientAuthentication:a,fetchFn:o}){const i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await td(t,{metadata:e,tokenRequestParams:i,clientInformation:r,addClientAuthentication:a,resource:s,fetchFn:o});return{refresh_token:n,...c}}async function d0(t,e,{metadata:r,resource:n,authorizationCode:s,fetchFn:a}={}){const o=t.clientMetadata.scope;let i;if(t.prepareTokenRequest&&(i=await t.prepareTokenRequest(o)),!i){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();i=u0(s,u,t.redirectUrl)}const c=await t.clientInformation();return td(e,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:n,fetchFn:a})}async function f0(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 Ql(a);return Fv.parse(await a.json())}class h0 extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}}class $n{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=Gl(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new lt("No auth provider");let e;try{e=await fr(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 lt;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=Js(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 Bs(this._url.href,{...this._eventSourceInit,fetch:async(s,a)=>{const o=await this._commonHeaders();o.set("Accept","text/event-stream");const i=await e(s,{...a,headers:o});if(i.status===401&&i.headers.has("www-authenticate")){const{resourceMetadataUrl:c,scope:u}=ea(i);this._resourceMetadataUrl=c,this._scope=u}return i}}),this._abortController=new AbortController,this._eventSource.onerror=s=>{if(s.code===401&&this._authProvider){this._authThenStart().then(r,n);return}const a=new h0(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(o){n(o),this.onerror?.(o),this.close();return}r()}),this._eventSource.onmessage=s=>{const a=s;let o;try{o=ar.parse(JSON.parse(a.data))}catch(i){this.onerror?.(i);return}this.onmessage?.(o)}})}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 lt("No auth provider");if(await fr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new lt("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:o,scope:i}=ea(s);if(this._resourceMetadataUrl=o,this._scope=i,await fr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new lt;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 p0 extends TransformStream{constructor({onError:e,onRetry:r,onComment:n}={}){let s;super({start(a){s=Hl({onEvent:o=>{a.enqueue(o)},onError(o){e==="terminate"?a.error(o):typeof e=="function"&&e(o)},onRetry:r,onComment:n})},transform(a){s.feed(a)}})}}const m0={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Ar extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}}class ta{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=Gl(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??m0}async _authThenStart(){if(!this._authProvider)throw new lt("No auth provider");let e;try{e=await fr(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 lt;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=Js(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 Ar(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 o,i=!1,c=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new p0({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:p}=await l.read();if(p)break;if(_.id&&(o=_.id,i=!0,s?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const y=ar.parse(JSON.parse(_.data));Jr(y)&&(c=!0,a!==void 0&&(y.id=a)),this.onmessage?.(y)}catch(y){this.onerror?.(y)}}(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:o,onresumptiontoken:s,replayMessageId:a},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||i)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:o,onresumptiontoken:s,replayMessageId:a},0)}catch(_){this.onerror?.(new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}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 lt("No auth provider");if(await fr(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new lt("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:Za(e)?e.id:void 0}).catch(m=>this.onerror?.(m));return}const a=await this._commonHeaders();a.set("content-type","application/json"),a.set("accept","application/json, text/event-stream");const o={...this._requestInit,method:"POST",headers:a,body:JSON.stringify(e),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._url,o),c=i.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!i.ok){const m=await i.text().catch(()=>null);if(i.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Ar(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:_,scope:p}=ea(i);if(this._resourceMetadataUrl=_,this._scope=p,await fr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new lt;return this._hasCompletedAuthFlow=!0,this.send(e)}if(i.status===403&&this._authProvider){const{resourceMetadataUrl:_,scope:p,error:y}=ea(i);if(y==="insufficient_scope"){const h=i.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===h)throw new Ar(403,"Server returned 403 after trying upscoping");if(p&&(this._scope=p),_&&(this._resourceMetadataUrl=_),this._lastUpscopingHeader=h??void 0,await fr(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new lt;return this.send(e)}}throw new Ar(i.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,i.status===202){await i.body?.cancel(),E_(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}const l=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,d=i.headers.get("content-type");if(l)if(d?.includes("text/event-stream"))this._handleSseStream(i.body,{onresumptiontoken:s},!1);else if(d?.includes("application/json")){const m=await i.json(),_=Array.isArray(m)?m.map(p=>ar.parse(p)):[ar.parse(m)];for(const p of _)this.onmessage?.(p)}else throw await i.body?.cancel(),new Ar(-1,`Unexpected content type: ${d}`);else await i.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 Ar(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})}}const _0="mcp";class rd{constructor(e){this._url=e}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._socket=new WebSocket(this._url,_0),this._socket.onerror=n=>{const s="error"in n?n.error:new Error(`WebSocket error: ${JSON.stringify(n)}`);r(s),this.onerror?.(s)},this._socket.onopen=()=>{e()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=n=>{let s;try{s=ar.parse(JSON.parse(n.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(s)}})}async close(){this._socket?.close()}send(e){return new Promise((r,n)=>{if(!this._socket){n(new Error("Not connected"));return}this._socket?.send(JSON.stringify(e)),r()})}}const Gt=it;(function(t,e){const r=it,n=it,s=t();for(;;)try{if(parseInt(r(403))/1+-parseInt(r(411))/2*(-parseInt(n(406))/3)+-parseInt(n(425))/4*(parseInt(r(387))/5)+-parseInt(n(426))/6+parseInt(n(395))/7*(-parseInt(r(419))/8)+-parseInt(r(413))/9+parseInt(n(400))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(na,-118057+3521*-35+-2099*-233);const nd=()=>{const t=it,e=it,r={};r[t(420)]="3|0|2|1|4",r.vQYJZ=function(o,i){return o!==i},r[e(394)]=e(414),r.ktWqD=function(o,i){return o!==i},r[t(424)]=t(391);const n=r,s=n[e(420)].split("|");let a=859*2+-3*-1039+-4835*1;for(;;){switch(s[a++]){case"0":if(n[e(407)](typeof window,"undefined"))return window;continue;case"1":if(n.vQYJZ(typeof self,n.NZmUq))return self;continue;case"2":if(n[e(405)](typeof global,"undefined"))return global;continue;case"3":if(n[e(405)](typeof globalThis,n[t(394)]))return globalThis;continue;case"4":return Function(n[t(424)])()}break}},g0=(t,e,r)=>{const n=it,s=it,a={};a.eOzBp=function(i,c){return i!==c},a.ooaJk="undefined",a[n(402)]=function(i,c){return i===c},a[n(421)]="function";const o=a;o[s(389)](typeof window,o.ooaJk)?t[s(423)](e,"*",r):n(423)in t&&o.pTvSc(typeof t[s(423)],o[n(421)])&&t.postMessage(e,r)},y0=(t,e)=>{const r=it,n=it,s={};s.nTCfA=function(o,i){return o in i},s[r(390)]="addEventListener",s[r(385)]=function(o,i){return o===i},s[r(409)]="function",s.VaHpd=n(392),s[n(384)]=r(417),s.FPOYW=function(o,i){return o!==i};const a=s;a.nTCfA(a.ogKey,t)&&a[n(385)](typeof t.addEventListener,a[n(409)])?t[n(386)](a.VaHpd,e):a[n(384)]in t&&a[r(398)](typeof t[n(417)],r(414))&&(t.onmessage=e)};class ra{constructor(e){this._port=e}async[Gt(401)](){const e=Gt,r=Gt;this[e(422)]&&(this[r(422)].onmessage=n=>{var s,a;const o=e;try{const i=ar.parse(n.data.message);(s=this.onmessage)==null||s.call(this,i,n[o(412)][o(428)])}catch(i){const c=new Error("MessageChannel failed to parse message: "+i);(a=this[o(383)])==null||a.call(this,c)}},this._port.onmessageerror=n=>{var s;const a=r,o=new Error("MessageChannel transport error: "+JSON[a(415)](n));(s=this.onerror)==null||s.call(this,o)},this[r(422)].start())}async send(e,r){const n={EoBZE:function(s){return s()},leEiG:function(s,a){return s instanceof a},cDUwk:function(s,a){return s(a)}};return new Promise((s,a)=>{var o;const i=it,c=it;try{const u={};u[i(404)]=r?.[i(404)];const l={};l[i(392)]=e,l.extra=u,this._port&&this._port[c(423)](l),n[i(399)](s)}catch(u){const l=n.leEiG(u,Error)?u:new Error(n.cDUwk(String,u));(o=this.onerror)==null||o.call(this,l),a(l)}})}async close(){var e,r;const n=Gt,s=Gt;(e=this._port)==null||e[n(393)](),this[n(422)]=void 0,(r=this[s(408)])==null||r.call(this)}}class ni extends ra{constructor(e,r=nd()){const n=Gt,s={lSpBh:function(o,i,c,u){return o(i,c,u)}};super(),this._endpoint=e,this._globalObject=r;const a=new MessageChannel;this._port=a[n(410)],s[n(418)](g0,this._globalObject,{endpoint:this[n(397)]},[a[n(429)]])}}class si extends ra{constructor(e,r=nd()){const n=Gt,s=Gt,a={HITdC:function(o,i){return o===i},QdDxM:function(o){return o()},jowPp:function(o,i,c){return o(i,c)}};super(),this[n(397)]=e,this[s(388)]=r,this[s(416)]=new Promise(o=>{const i=n,c={XlglK:function(u,l){return a.HITdC(u,l)},pXlad:function(u){return a.QdDxM(u)}};a[i(427)](y0,this._globalObject,u=>{const l=i,d=i;u[l(412)]&&c.XlglK(u.data[d(396)],this._endpoint)&&(this[l(422)]=u[d(430)][-3036+-1518*-2],c.pXlad(o))})})}async listen(){return this._listen}}function na(){const t=["message","close","NZmUq","177464iLQCGm","endpoint","_endpoint","FPOYW","EoBZE","3022630ngzRBs","start","pTvSc","272809yMhhPJ","authInfo","ktWqD","21849KofsKk","vQYJZ","onclose","mkHJS","port1","22dUTKmE","data","608229RXNlUs","undefined","stringify","_listen","onmessage","lSpBh","8FmlYyF","XwdDB","cHbAW","_port","postMessage","kFtNB","72572mbPnfL","689424jqaGZE","jowPp","extra","port2","ports","onerror","Fzdib","mkuHv","addEventListener","55juYkZZ","_globalObject","eOzBp","ogKey","return this"];return na=function(){return t},na()}function it(t,e){const r=na();return it=function(n,s){return n=n-(17227+1*-16844),r[n]},it(t,e)}const v0=()=>{const t=new MessageChannel;return[new ra(t.port1),new ra(t.port2)]};(function(t,e){const r=we,n=we,s=t();for(;;)try{if(parseInt(r(452))/1*(parseInt(n(441))/2)+parseInt(n(434))/3*(-parseInt(n(418))/4)+parseInt(r(459))/5+parseInt(r(482))/6*(-parseInt(r(479))/7)+-parseInt(r(458))/8*(parseInt(r(457))/9)+-parseInt(n(416))/10+-parseInt(r(450))/11*(-parseInt(r(433))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(sa,-411935*1+228107+208149*2);const w0=async(t,e,r)=>{var n;const s=we,a=we,o={};o.VRyiJ="tools/list",o.VkPYu="tools/call",o[s(475)]=s(411),o.SoCaE="resources/templates/list",o[a(484)]="resources/read",o[s(461)]="prompts/get",o.srIIC=a(477),o[a(436)]=a(478),o[a(442)]=s(437),o.dEmVs=s(465);const i=o,{id:c,method:u,params:l}=r;let d={};switch(u){case i.VRyiJ:d=await e.listTools(l);break;case i.VkPYu:d=await e.callTool(l);break;case i.fgMSD:d=await e.listResources(l);break;case i[a(466)]:d=await e.listResourceTemplates(l);break;case i.sthgI:d=await e[s(455)](l);break;case a(486):d=await e.subscribeResource(l);break;case s(410):d=await e.unsubscribeResource(l);break;case i[a(461)]:d=await e[a(414)](l);break;case i[s(412)]:d=await e[s(491)](l);break;case i[s(436)]:d=await e[s(478)]();break;case i.kkNqg:d=await e.complete(l);break;case s(464):d=await e.setLoggingLevel(l?.[a(443)]);break}const m={};m.result=d,m.jsonrpc=i[a(472)],m.id=c,await((n=t?.[a(488)])==null?void 0:n[s(460)](m))},b0=async(t,e,r)=>{var n;const s=we,a=we,o={};o[s(487)]=a(462),o.ypHTC="ping",o.fPExS=s(465);const i=o,{id:c,method:u,params:l}=r;let d={};switch(u){case"roots/list":const _={};_.method=u,_[a(446)]=l,d=await e[s(469)](_,_o);break;case"sampling/createMessage":const p={};p[s(481)]=u,p[s(446)]=l,d=await e.request(p,js);break;case i[s(487)]:const y={};y.method=u,y[a(446)]=l,d=await e.request(y,tn);break;case i.ypHTC:const h={};h.method=u,d=await e.request(h,Ft);break}const m={};return m.result=d,m.jsonrpc=i.fPExS,m.id=c,await((n=t?.transport)==null?void 0:n.send(m)),d};function we(t,e){const r=sa();return we=function(n,s){return n=n-(-8023+4*-2344+-17809*-1),r[n]},we(t,e)}const k0=(t,e)=>{const r=we,n=we,s={vYlhn:function(o,i){return o===i},DhPFX:r(470),NYVNC:function(o,i,c,u){return o(i,c,u)},yfZbw:"2.0"},a=t._onrequest;t[n(463)]=async(o,i)=>{var c,u,l,d,m;const _=n,p=r,{id:y,method:h}=o;try{s[_(451)](h,s.DhPFX)?await a.call(t,o,i):await s[p(474)](w0,t,e,o)}catch(v){const{code:f,message:g,data:b}=v;try{if(f){const w={};w[p(485)]=f,w[_(422)]=g,w.data=b;const k={};k[p(448)]=w,k.jsonrpc=s[_(417)],k.id=y,await((c=t?.transport)==null?void 0:c[p(460)](k))}else(l=(u=t?.transport)==null?void 0:u.onerror)==null||l.call(u,v)}catch(w){(m=(d=t?.transport)==null?void 0:d.onerror)==null||m.call(d,w)}}}},$0=(t,e)=>{const r=we,n=we,s={};s[r(476)]=r(439),s[r(431)]=function(o,i){return o!==i},s.UPdQt="notifications/cancelled";const a=s;t[r(421)]=async o=>{var i,c;const u=r,l=n,{method:d,params:m}=o;if(d!==a[u(476)]&&(a.QWYMz(d,a.UPdQt)||m?.[l(490)]))try{await e[u(445)](o)}catch(_){(c=(i=t?.[u(488)])==null?void 0:i[u(480)])==null||c.call(i,_)}}},S0=(t,e)=>async r=>{var n,s,a,o,i;const c=we,u=we,l={TJhyV:function(d,m,_,p){return d(m,_,p)},MMNTY:c(465)};try{return await l.TJhyV(b0,t,e,r)}catch(d){const{code:m,message:_,data:p}=d;try{if(m){const y={};y.code=m,y[c(422)]=_,y[u(419)]=p;const h={};h[c(448)]=y,h[c(424)]=l.MMNTY,h.id=r.id,await((n=t?.transport)==null?void 0:n[u(460)](h))}else(a=(s=t?.transport)==null?void 0:s[c(480)])==null||a.call(s,d)}catch(y){(i=(o=t?.[c(488)])==null?void 0:o.onerror)==null||i.call(o,y)}}},T0=(t,e)=>async r=>{var n,s,a;const o=we,i=we,c={};c.xmcLM=function(m,_){return m!==_},c.xSWLt="notifications/initialized",c[o(420)]=i(453);const u=c,{method:l,params:d}=r;if(u.xmcLM(l,u.xSWLt)&&(u.xmcLM(l,u[i(420)])||d?.[i(490)]))try{const m={...r};m.jsonrpc=o(465),await((n=e?.[o(488)])==null?void 0:n.send(m))}catch(m){(a=(s=t?.transport)==null?void 0:s.onerror)==null||a.call(s,m)}};function sa(){const t=["JMaxV","cNneM","completion/complete","addResponseListener","notifications/initialized","call","570686biwZQB","kkNqg","level","addNotificationListener","notification","params","addListener","error","_onresponse","164054EGcqjc","vYlhn","1PDRdga","notifications/cancelled","_requestHandlers","readResource","FjTAY","1782ueLDLp","4496TJFZWc","1767765yPcVQJ","send","HefvS","elicitation/create","_onrequest","logging/setLevel","2.0","SoCaE","HucXo","function","request","initialize","push","dEmVs","addRequestListener","NYVNC","fgMSD","CSjwA","prompts/list","ping","35pZrnNj","onerror","method","238086YifXhM","get","sthgI","code","resources/subscribe","sttJM","transport","jsmFN","forward","listPrompts","resources/unsubscribe","resources/list","srIIC","originalOnResponse","getPrompt","indexOf","3653560KcjkMk","yfZbw","4SAWlvk","data","rCDHw","_onnotification","message","UlqiY","jsonrpc","yCyFn","clearNotificationListener","VWsxO","name","UynHf","length","QWYMz","fallbackRequestHandler","492jTClKn","1028589HsbHVQ"];return sa=function(){return t},sa()}const E0=(t,e)=>async r=>{var n,s,a,o,i,c;const u=we,l=we,d={};d.kSvAZ=u(465);const m=d;try{await((n=e?.[l(488)])==null?void 0:n[l(460)](r))}catch(_){const{code:p,message:y,data:h}=_;try{if(p){const v={};v.code=p,v.message=y,v.data=h;const f={};f.error=v,f[l(424)]=m.kSvAZ,f.id=r.id,await((s=t?.transport)==null?void 0:s.send(f))}else(o=(a=t?.transport)==null?void 0:a[u(480)])==null||o.call(a,_)}catch(v){(c=(i=t?.[u(488)])==null?void 0:i[l(480)])==null||c.call(i,v)}}},ai=()=>{const t=we,e={rgPZO:function(c,u){return c!==u},VWsxO:function(c,u){return c(u)},FjTAY:"function"},r=[],n=(c,u)=>{const l=we;if(u){const d=[];for(const m of r)try{d.push(m(c,u))}catch{}for(const m of d)if(e.rgPZO(m,null))return m}else for(const d of r)try{e[l(427)](d,c)}catch{}},s=c=>{const u=we,l=we;typeof c===e[u(456)]&&!r.includes(c)&&r[l(471)](c)},a=c=>{const u=we,l=r[u(415)](c);l!==-1&&r.splice(l,-17591+6*2932)},o=()=>{const c=we;r[c(430)]=-505*7+1322+2213},i={};return i.handleListener=n,i[t(447)]=s,i.removeListener=a,i.clearListener=o,i},R0=t=>{const e=we,r=we,n={UlqiY:function(s){return s()},jsmFN:function(s){return s()}};{const{handleListener:s,addListener:a,removeListener:o,clearListener:i}=n[e(423)](ai);t._onresponse=s,t[r(438)]=a,t.removeResponseListener=o,t.clearResponseListener=i}{const{handleListener:s,addListener:a,removeListener:o,clearListener:i}=n[e(489)](ai);t[e(432)]=s,t[r(473)]=a,t.removeRequestListener=o,t.clearRequestListener=i}{const{handleListener:s,addListener:a,removeListener:o,clearListener:i}=n.jsmFN(ai);t.fallbackNotificationHandler=s,t[e(444)]=a,t.removeNotificationListener=o,t[r(426)]=i}},P0=(t,{beforeInit:e,afterInit:r}={})=>{const n=we,s=we,a={HucXo:function(i,c){return i===c},HicFO:n(468),JMaxV:function(i){return i()},DclXr:function(i,c){return i(c)},UynHf:function(i,c){return i===c},yCyFn:function(i){return i()}},o=new Map(t._notificationHandlers);t[n(454)].clear(),t._notificationHandlers.clear(),a.HucXo(typeof e,a.HicFO)&&a[n(435)](e),a[n(467)](t[n(449)][s(428)],n(449))&&(t[s(413)]=t[s(449)]),a.DclXr(R0,t),t[s(438)](i=>{const c=n;t.originalOnResponse[c(440)](t,i)}),a[n(429)](typeof r,a.HicFO)&&a[s(425)](r),t[s(444)](i=>{const c=s,{method:u}=i,l=o[c(483)](u);a[c(467)](typeof l,"function")&&l(i)})},x0=Mt;(function(t,e){const r=Mt,n=Mt,s=t();for(;;)try{if(parseInt(r(215))/1*(-parseInt(n(217))/2)+parseInt(r(216))/3+parseInt(r(210))/4*(parseInt(n(223))/5)+-parseInt(n(214))/6*(parseInt(n(220))/7)+parseInt(n(212))/8*(parseInt(r(228))/9)+parseInt(r(219))/10+parseInt(r(222))/11*(parseInt(r(224))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(aa,995159+-6*-266138+-1619768);const I0=()=>{const t=Mt,e=Mt,r={};r.svuxn=function(s,a){return s&a},r.ZUPdr=function(s,a){return s===a},r[t(227)]=function(s,a){return s===a},r.SpRzi="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";const n=r;return n[e(227)](typeof crypto,"object")&&crypto[t(211)]?crypto.randomUUID():n.SpRzi.replace(/[xy]/g,s=>{const a=t,o=n.svuxn(crypto.getRandomValues(new Uint8Array(-3798+8571*-1+12370))[0],-8324+8339*1);return(n[a(225)](s,"x")?o:n[a(209)](o,-12998+-1*-13001)|813*10+-3707+883*-5).toString(-1*-1851+6493+-8328)})},C0=t=>{const e=Mt,r=Mt,n=new Uint8Array(t);return crypto[e(221)](n),Array[r(218)](n,s=>s[r(226)](11424+4*-2852).padStart(8950+2237*-4,"0"))[e(213)]("")},Yt={};Yt[x0(211)]=I0,Yt.randomBytes=C0;function Mt(t,e){const r=aa();return Mt=function(n,s){return n=n-(-7373+7187*1+395),r[n]},Mt(t,e)}function aa(){const t=["join","2500590yHdCUG","3CzpgOE","219762yRRBUK","592022JqIdxi","from","6033730pSHJFF","28gKZiuO","getRandomValues","147169GUBreL","5fFOMNB","1140KVOWlq","ZUPdr","toString","DBGzc","45351XtLuDF","svuxn","9892WpQPGF","randomUUID","2504EaskHQ"];return aa=function(){return t},aa()}function zt(t,e){const r=oa();return zt=function(n,s){return n=n-(-1483*3+-5564+20*513),r[n]},zt(t,e)}const $t=zt,Sn=zt;(function(t,e){const r=zt,n=zt,s=t();for(;;)try{if(parseInt(r(302))/1+-parseInt(n(249))/2+-parseInt(r(291))/3+-parseInt(r(292))/4*(parseInt(r(264))/5)+-parseInt(n(273))/6*(parseInt(r(266))/7)+parseInt(r(300))/8*(parseInt(r(269))/9)+parseInt(n(255))/10*(parseInt(r(284))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(oa,-4*308317+753182*2+658196);const O0=(t,e)=>{const r=zt,n=zt,s={olCWX:function(c,u,l){return c(u,l)},sfXDX:function(c,u,l){return c(u,l)},ksWFu:function(c,u,l){return c(u,l)}};s[r(283)](k0,t,e),$0(t,e);const a=s[n(283)](S0,e,t),o=s[n(294)](E0,e,t),i=s[r(277)](T0,e,t);e.addRequestListener(a),e.addResponseListener(o),e[n(287)](i),t.onclose=()=>{const c=r,u=n;e[c(247)](a),e.removeResponseListener(o),e[u(252)](i)}},oi=(t,e,r)=>{const n={QhPqi:function(o,i){return o instanceof i},AIICR:"close",Qalmc:function(o,i,c){return o(i,c)}},s=()=>{var o;n.QhPqi(r,$n)&&((o=r._eventSource)==null||o.addEventListener(n.AIICR,()=>{var i;(i=r[zt(295)])==null||i.close()})),n.Qalmc(O0,t,e)},a={};a.afterInit=s,n.Qalmc(P0,e,a)},sd=(t,e=Yt[$t(299)]())=>{const r=$t,n=$t,s={RVabx:function(l,d,m){return l(d,m)},crCTs:"include"},a={};a["sse-session-id"]=e;const o=a,i={};i["sse-session-id"]=e;const c={};c.headers=i,c.credentials=s[r(304)];const u={requestInit:c,eventSourceInit:{async fetch(l,d){const m=r,_=r,p=new Headers(d?.[m(268)]||{});Object.entries(o).forEach(([h,v])=>{p.set(h,v)});const y={...d};return y.headers=p,s[_(279)](fetch,l,y)},withCredentials:!0}};return t&&(u[r(280)].headers.Authorization="Bearer "+t,o.Authorization=n(256)+t),u},ad=(t,e=Yt[$t(299)]())=>{const r=Sn,n=$t,s={};s[r(271)]="include";const a=s,o={};o["stream-session-id"]=e;const i={};i[n(268)]=o,i.credentials=a[r(271)];const c={};c.requestInit=i;const u=c;return t&&(u[n(280)][r(268)][n(301)]=r(256)+t),u},ii=async(t,e,r)=>{const n=$t,s=$t,a={rRtFD:function(i){return i()},ToRAF:function(i,c){return i instanceof c}},o=a[n(276)](r);try{return await t[s(260)](o),o}catch(i){if(a[n(275)](i,lt)){const c=await e();return await o[n(257)](c),await ii(t,e,r)}else throw i}},od=(t,e)=>{const r=Sn,n=Sn,s={};s[r(267)]=function(o,i){return o in i},s.timcZ="waitForOAuthCode",s[r(253)]=function(o,i){return o===i},s.ufiEQ=r(285),s[n(250)]=r(293);const a=s;if(a.oGmBG(a[r(258)],t))return t[n(278)];if(a[n(253)](typeof e,a.ufiEQ))return e;throw new Error(a.daYBw)};function oa(){const t=["oGmBG","headers","1233BqDPfE","eventSourceInit","jmVYh","wfHUn","1336686qzpbXm","_endpoint","ToRAF","rRtFD","ksWFu","waitForOAuthCode","RVabx","requestInit","mcp-sse-proxy-client","CfBXU","olCWX","341WrxLOu","function","sessionId","addNotificationListener","version","GKDjq","roots","5390433vAXkON","4NpGpPF","waitForOAuthCode need to be provided when authProvider is provided","sfXDX","_eventSource","PdsSn","get","sampling","randomUUID","4064jocfPO","Authorization","452565rqIeHi","elicitation","crCTs","authProvider","removeRequestListener","1.0.0","104070FoHgyi","daYBw","capabilities","removeNotificationListener","lauIp","listChanged","1255910ovFXHu","Bearer ","finishAuth","timcZ","eZwNI","connect","JzpWy","tUMle","kdowC","379385gxVFVP","&token=","49TIzdXg"];return oa=function(){return t},oa()}const N0=async t=>{const e=Sn,r=$t,n={GKDjq:function(j,D,A){return j(D,A)},JzpWy:e(281),mcbiU:"1.0.0",CfBXU:function(j){return j()},kdowC:function(j,D,A,V){return j(D,A,V)},KkViY:"sessionId"},{client:s,url:a,token:o,sessionId:i,authProvider:c,requestInit:u,eventSourceInit:l,waitForOAuthCode:d}=t,m={};m[r(305)]=c,m.requestInit=u,m.eventSourceInit=l;const _=m,p=i||Yt[r(299)](),y=n[e(289)](sd,o,p);if(u){const j={...y.requestInit,...u};j[r(268)]={...y[r(280)][e(268)],...u.headers},_.requestInit=j}else _.requestInit=y[e(280)];if(l){const j={...y[e(270)],...l};_.eventSourceInit=j}else _.eventSourceInit=y[e(270)];const h={};h[e(254)]=!0;const v={};v.roots=h,v[e(298)]={},v[r(303)]={};const f=v,g={};g.name=n[r(261)],g[e(288)]=n.mcbiU;const b={};b[e(251)]=f;const w=new yn(g,b),k=()=>new $n(new URL(a),_);let S=n[e(282)](k);if(c){const j=od(c,d);S=await n[e(263)](ii,w,j,k)}else await w.connect(S);oi(w,s,S),S.sessionId=S[r(274)].searchParams[e(297)](n.KkViY);const C={};return C.transport=S,C.sessionId=S[r(286)],C},A0=async t=>{const e=Sn,r=$t,n={wfHUn:function(j,D,A){return j(D,A)},tUMle:"mcp-stream-proxy-client",omKPe:e(248),rSiEq:function(j){return j()},PdsSn:function(j,D,A,V){return j(D,A,V)}},{client:s,url:a,token:o,sessionId:i,authProvider:c,requestInit:u,reconnectionOptions:l,waitForOAuthCode:d}=t,m={};m.authProvider=c,m.requestInit=u,m.reconnectionOptions=l;const _=m,p=i||Yt.randomUUID(),y=n[r(272)](ad,o,p);if(u){const j={...y[e(280)],...u};j.headers={...y.requestInit[e(268)],...u.headers},_.requestInit=j}else _[r(280)]=y[r(280)];const h={};h[r(254)]=!0;const v={};v.roots=h,v[e(298)]={},v[e(303)]={};const f=v,g={};g.name=n[e(262)],g.version=n.omKPe;const b={};b.capabilities=f;const w=new yn(g,b),k=()=>new ta(new URL(a),_);let S=n.rSiEq(k);if(c){const j=n[e(272)](od,c,d);S=await n[e(296)](ii,w,j,k)}else await w[e(260)](S);n.PdsSn(oi,w,s,S);const C={};return C.transport=S,C[r(286)]=S[r(286)],C},j0=async t=>{const e=$t,r=$t,n={eZwNI:function(v,f,g,b){return v(f,g,b)}},{client:s,url:a,token:o,sessionId:i}=t,c={};c[e(254)]=!0;const u={};u[r(290)]=c,u.sampling={},u.elicitation={};const l=u,d={};d.name="mcp-socket-proxy-client",d.version=r(248);const m={};m[r(251)]=l;const _=new yn(d,m),p=i||Yt[r(299)](),y=new rd(new URL(a+"?sessionId="+p+r(265)+o));await _.connect(y),n[e(259)](oi,_,s,y);const h={};return h.transport=y,h[r(286)]=p,h},Xt=St,Tn=St;(function(t,e){const r=St,n=St,s=t();for(;;)try{if(parseInt(r(216))/1+-parseInt(n(219))/2+-parseInt(r(203))/3*(-parseInt(n(204))/4)+-parseInt(n(199))/5*(parseInt(r(193))/6)+-parseInt(r(211))/7*(-parseInt(r(192))/8)+-parseInt(n(221))/9+parseInt(n(201))/10*(parseInt(r(220))/11)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(ia,1297719+-42747*-22+-1289197);function St(t,e){const r=ia();return St=function(n,s){return n=n-(-4158*1+-2*581+-1*-5510),r[n]},St(t,e)}const M0=()=>Yt.randomBytes(-8746+-382*-23);class z0{constructor(e){const r=St,n=St,s={HbwOh:function(l){return l()}};this._callBackPromise={};const{clientMetadata:a,state:o,redirectCallback:i,getAuthCodeByState:c,waitForOAuthCode:u}=e;this._clientMetadata=a,this[r(206)]=a.redirect_uris[-10*629+1*7646+-1356],this[n(197)]=o||s.HbwOh(M0),this._redirectCallback=i||this[n(202)],this[n(195)]=c||this[r(191)],this.waitForOAuthCode=u||this.waitForOAuthCodeFunction()}async redirectCallbackFunction(e){var r,n,s,a,o,i;const c=St,u=St,l={};l[c(198)]="GET";const d=await fetch(e,l);!d.ok&&((n=(r=this[u(207)])[u(196)])==null||n.call(r,c(208)+d[u(205)]));const m=await this[u(195)](this._redirectUrl,this[c(197)]);if(!m.ok){(a=(s=this[c(207)]).reject)==null||a.call(s,"Failed to fetch auth code: "+m[u(205)]);return}const _=await m.json();(i=(o=this._callBackPromise).resolve)==null||i.call(o,_.code)}async[Xt(191)](e,r){const n=Xt,s={};s.xAOmI="POST";const a=s,o={};o["Content-Type"]=n(217);const i={};return i.state=r,fetch(e,{method:a.xAOmI,headers:o,body:new URLSearchParams(i)})}waitForOAuthCodeFunction(){const e=this._callBackPromise;return()=>new Promise((r,n)=>{const s=St;e.resolve=r,e[s(196)]=n})}get redirectUrl(){return this[Xt(206)]}get[Tn(190)](){return this._clientMetadata}[Xt(213)](){return this[Xt(197)]}[Tn(218)](){return this[Tn(200)]}[Xt(194)](e){this._clientInformation=e}tokens(){return this[Tn(210)]}saveTokens(e){const r=Tn;this[r(210)]=e}redirectToAuthorization(e){this._redirectCallback(e)}saveCodeVerifier(e){this._codeVerifier=e}[Xt(212)](){const e=Xt,r={};r[e(215)]=e(214);const n=r;if(!this[e(209)])throw new Error(n.mMdVl);return this[e(209)]}}function ia(){const t=["370aKMzOb","redirectCallbackFunction","6AWGiLu","697420WEpDtk","statusText","_redirectUrl","_callBackPromise","Failed to redirect: ","_codeVerifier","_tokens","21ofrYNd","codeVerifier","state","No code verifier saved","mMdVl","1546908KURscU","application/x-www-form-urlencoded","clientInformation","2551694UzDoIS","571637jVsNJQ","4355271orhxAD","clientMetadata","getAuthCodeByStateFunction","1400360ybYjeP","30zRTJNb","saveClientInformation","_getAuthCodeByState","reject","_state","method","1634810cQPomO","_clientInformation"];return ia=function(){return t},ia()}(function(t,e){for(var r=ua,n=ua,s=t();;)try{var a=parseInt(r(291))/1+-parseInt(r(295))/2*(parseInt(r(288))/3)+parseInt(r(290))/4*(parseInt(r(296))/5)+-parseInt(n(289))/6+parseInt(r(293))/7*(-parseInt(n(294))/8)+parseInt(n(287))/9+parseInt(n(292))/10;if(a===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(ca,262*-2438+1346066*-1+2*1373311);function ca(){var t=["279100FsqxFu","7326315yxcNFg","50823VTWXXj","6441948uoPUwt","92BSiBRu","1361711dyawqa","5202960gnlAWp","7tNVFlv","11056792usEcvw","90CRWXmt"];return ca=function(){return t},ca()}function ua(t,e){var r=ca();return ua=function(n,s){n=n-287;var a=r[n];return a},ua(t,e)}class q0{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 Z0 extends jl{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Os.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 Ul,this.setRequestHandler(Uu,n=>this._oninitialize(n)),this.setNotificationHandler(Va,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ns,async(n,s)=>{const a=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=n.params,i=Os.safeParse(o);return i.success&&this._loggingLevels.set(a,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new q0(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=zl(this._capabilities,e)}setRequestHandler(e,r){const s=Rr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(yt(s)){const i=s;a=i._zod?.def?.value??i.value}else{const i=s;a=i._def?.value??i.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");if(a==="tools/call"){const i=async(c,u)=>{const l=vt(Cs,c);if(!l.success){const p=l.error instanceof Error?l.error.message:String(l.error);throw new K(G.InvalidParams,`Invalid tools/call request: ${p}`)}const{params:d}=l.data,m=await Promise.resolve(r(c,u));if(d.task){const p=vt(gr,m);if(!p.success){const y=p.error instanceof Error?p.error.message:String(p.error);throw new K(G.InvalidParams,`Invalid task creation result: ${y}`)}return p.data}const _=vt(vr,m);if(!_.success){const p=_.error instanceof Error?_.error.message:String(_.error);throw new K(G.InvalidParams,`Invalid tools/call result: ${p}`)}return _.data};return super.setRequestHandler(e,i)}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){Vl(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Dl(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:ju.includes(r)?r:Kr,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"},Ft)}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"),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,i=o?Array.isArray(o.content)?o.content:[o.content]:[],c=i.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(i.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(s.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},sl,r):this.request({method:"sampling/createMessage",params:e},js,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},tn,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},tn,r);if(a.action==="accept"&&a.content&&s.requestedSchema)try{const i=this._jsonSchemaValidator.getValidator(s.requestedSchema)(a.content);if(!i.valid)throw new K(G.InvalidParams,`Elicitation response content does not match requested schema: ${i.errorMessage}`)}catch(o){throw o instanceof K?o:new K(G.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}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},_o,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 ci=Symbol.for("mcp.completable");function L0(t,e){return Object.defineProperty(t,ci,{value:{complete:e},enumerable:!1,writable:!1,configurable:!1}),t}function id(t){return!!t&&typeof t=="object"&&ci in t}function U0(t){return t[ci]?.complete}var cd;(function(t){t.Completable="McpCompletable"})(cd||(cd={}));const ud=1e6,ui=1e6,ld=1e4,D0=1e6;class qt{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){qt.validateLength(e,ud,"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 o=e.indexOf("}",s);if(o===-1)throw new Error("Unclosed template expression");if(a++,a>ld)throw new Error(`Template contains too many expressions (max ${ld})`);const i=e.slice(s+1,o),c=this.getOperator(i),u=i.includes("*"),l=this.getNames(i),d=l[0];for(const m of l)qt.validateLength(m,ui,"Variable name");r.push({name:d,operator:c,names:l,exploded:u}),s=o+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 qt.validateLength(e,ui,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){const o=e.names.map(c=>{const u=r[c];if(u===void 0)return"";const l=Array.isArray(u)?u.map(d=>this.encodeValue(d,e.operator)).join(","):this.encodeValue(u.toString(),e.operator);return`${c}=${l}`}).filter(c=>c.length>0);return o.length===0?"":(e.operator==="?"?"?":"&")+o.join("&")}if(e.names.length>1){const o=e.names.map(i=>r[i]).filter(i=>i!==void 0);return o.length===0?"":o.map(i=>Array.isArray(i)?i[0]:i).join(",")}const n=r[e.name];if(n===void 0)return"";const a=(Array.isArray(n)?n:[n]).map(o=>this.encodeValue(o,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)qt.validateLength(a,ui,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let a=0;a<e.names.length;a++){const o=e.names[a],i=a===0?"\\"+e.operator:"&";r.push({pattern:i+this.escapeRegExp(o)+"=([^&]+)",name:o})}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){qt.validateLength(e,ud,"URI");let r="^";const n=[];for(const i of this.parts)if(typeof i=="string")r+=this.escapeRegExp(i);else{const c=this.partToRegExp(i);for(const{pattern:u,name:l}of c)r+=u,n.push({name:l,exploded:i.exploded})}r+="$",qt.validateLength(r,D0,"Generated regex pattern");const s=new RegExp(r),a=e.match(s);if(!a)return null;const o={};for(let i=0;i<n.length;i++){const{name:c,exploded:u}=n[i],l=a[i+1],d=c.replace("*","");u&&l.includes(",")?o[d]=l.split(","):o[d]=l}return o}}const V0=/^[A-Za-z0-9._-]{1,128}$/;function F0(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"),!V0.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 H0(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 dd(t){const e=F0(t);return H0(t,e.warnings),e.isValid}class W0{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 fd{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 Z0(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new W0(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(lo)),this.server.assertCanSetRequestHandler(Qt(Cs)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(lo,()=>({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=gn(r.inputSchema);return s?Ol(s,{strictUnions:!0,pipeStrategy:"input"}):B0})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){const s=gn(r.outputSchema);s&&(n.outputSchema=Ol(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Cs,async(e,r)=>{try{const n=this._registeredTools[e.params.name];if(!n)throw new K(G.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new K(G.InvalidParams,`Tool ${e.params.name} disabled`);const s=!!e.params.task,a=n.execution?.taskSupport,o="createTask"in n.handler;if((a==="required"||a==="optional")&&!o)throw new K(G.InternalError,`Tool ${e.params.name} has taskSupport '${a}' but was not registered with registerToolTask`);if(a==="required"&&!s)throw new K(G.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(a==="optional"&&!s&&o)return await this.handleAutomaticTaskPolling(n,e,r);const i=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,i,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof K&&n.code===G.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=gn(e.inputSchema)??e.inputSchema,o=await $o(a,r);if(!o.success){const i="error"in o?o.error:"Unknown error",c=So(i);throw new K(G.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return o.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new K(G.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);const s=gn(e.outputSchema),a=await $o(s,r.structuredContent);if(!a.success){const o="error"in a?a.error:"Unknown error",i=So(o);throw new K(G.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${i}`)}}async executeToolHandler(e,r,n){const s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");const o={...n,taskStore:n.taskStore};if(e.inputSchema){const i=s;return await Promise.resolve(i.createTask(r,o))}else{const i=s;return await Promise.resolve(i.createTask(o))}}if(e.inputSchema){const o=s;return await Promise.resolve(o(r,n))}else{const o=s;return await Promise.resolve(o(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,o={...n,taskStore:n.taskStore},i=s?await Promise.resolve(a.createTask(s,o)):await Promise.resolve(a.createTask(o)),c=i.task.taskId;let u=i.task;const l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(m=>setTimeout(m,l));const d=await n.taskStore.getTask(c);if(!d)throw new K(G.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Qt(mo)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(mo,async e=>{switch(e.params.ref.type){case"ref/prompt":return Sg(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Tg(e),this.handleResourceCompletion(e,e.params.ref);default:throw new K(G.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){const n=this._registeredPrompts[r.name];if(!n)throw new K(G.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new K(G.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return En;const a=Rr(n.argsSchema)?.[e.params.argument.name];if(!id(a))return En;const o=U0(a);if(!o)return En;const i=await o(e.params.argument.value,e.params.context);return md(i)}async handleResourceCompletion(e,r){const n=Object.values(this._registeredResourceTemplates).find(o=>o.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return En;throw new K(G.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 md(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Qt(Is)),this.server.assertCanSetRequestHandler(Qt(Qa)),this.server.assertCanSetRequestHandler(Qt(to)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Is,async(e,r)=>{const n=Object.entries(this._registeredResources).filter(([a,o])=>o.enabled).map(([a,o])=>({uri:a,name:o.name,...o.metadata})),s=[];for(const a of Object.values(this._registeredResourceTemplates)){if(!a.resourceTemplate.listCallback)continue;const o=await a.resourceTemplate.listCallback(r);for(const i of o.resources)s.push({...a.metadata,...i})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Qa,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(to,async(e,r)=>{const n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new K(G.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(const a of Object.values(this._registeredResourceTemplates)){const o=a.resourceTemplate.uriTemplate.match(n.toString());if(o)return a.readCallback(n,o,r)}throw new K(G.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Qt(no)),this.server.assertCanSetRequestHandler(Qt(so)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(no,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?G0(r.argsSchema):void 0}))})),this.server.setRequestHandler(so,async(e,r)=>{const n=this._registeredPrompts[e.params.name];if(!n)throw new K(G.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new K(G.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){const s=gn(n.argsSchema),a=await $o(s,e.params.arguments);if(!a.success){const c="error"in a?a.error:"Unknown error",u=So(c);throw new K(G.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}const o=a.data,i=n.callback;return await Promise.resolve(i(o,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 o=this._createRegisteredResource(e,void 0,r,s,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const o=this._createRegisteredResourceTemplate(e,void 0,r,s,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}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 o={name:e,title:r,metadata:s,readCallback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:i=>{typeof i.uri<"u"&&i.uri!==n&&(delete this._registeredResources[n],i.uri&&(this._registeredResources[i.uri]=o)),typeof i.name<"u"&&(o.name=i.name),typeof i.title<"u"&&(o.title=i.title),typeof i.metadata<"u"&&(o.metadata=i.metadata),typeof i.callback<"u"&&(o.readCallback=i.callback),typeof i.enabled<"u"&&(o.enabled=i.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=o,o}_createRegisteredResourceTemplate(e,r,n,s,a){const o={resourceTemplate:n,title:r,metadata:s,readCallback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=o)),typeof u.title<"u"&&(o.title=u.title),typeof u.template<"u"&&(o.resourceTemplate=u.template),typeof u.metadata<"u"&&(o.metadata=u.metadata),typeof u.callback<"u"&&(o.readCallback=u.callback),typeof u.enabled<"u"&&(o.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=o;const i=n.uriTemplate.variableNames;return Array.isArray(i)&&i.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(e,r,n,s,a){const o={title:r,description:n,argsSchema:s===void 0?void 0:Er(s),callback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:i=>{typeof i.name<"u"&&i.name!==e&&(delete this._registeredPrompts[e],i.name&&(this._registeredPrompts[i.name]=o)),typeof i.title<"u"&&(o.title=i.title),typeof i.description<"u"&&(o.description=i.description),typeof i.argsSchema<"u"&&(o.argsSchema=Er(i.argsSchema)),typeof i.callback<"u"&&(o.callback=i.callback),typeof i.enabled<"u"&&(o.enabled=i.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=o,s&&Object.values(s).some(c=>{const u=c instanceof gt?c._def?.innerType:c;return id(u)})&&this.setCompletionRequestHandler(),o}_createRegisteredTool(e,r,n,s,a,o,i,c,u){dd(e);const l={title:r,description:n,inputSchema:pd(s),outputSchema:pd(a),annotations:o,execution:i,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&dd(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=Er(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Er(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.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,o;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){const c=r[0];li(c)?(s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!li(r[0])&&(o=r.shift())):typeof c=="object"&&c!==null&&(o=r.shift())}const i=r[0];return this._createRegisteredTool(e,void 0,n,s,a,o,{taskSupport:"forbidden"},void 0,i)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:s,description:a,inputSchema:o,outputSchema:i,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,s,a,o,i,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],o=this._createRegisteredPrompt(e,void 0,n,s,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:s,description:a,argsSchema:o}=r,i=this._createRegisteredPrompt(e,s,a,o,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}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 K0{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new qt(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}}const B0={type:"object",properties:{}};function hd(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function J0(t){return"_def"in t||"_zod"in t||hd(t)}function li(t){return typeof t!="object"||t===null||J0(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(hd)}function pd(t){if(t)return li(t)?Er(t):t}function G0(t){const e=Rr(t);return e?Object.entries(e).map(([r,n])=>{const s=Ny(n),a=Ay(n);return{name:r,description:s,required:!a}}):[]}function Qt(t){const r=Rr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=kl(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function md(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}const En={completion:{values:[],hasMore:!1}};class Y0{constructor(e,r){const n={name:"web-mcp-server",version:"1.0.0"},s={prompts:{listChanged:!0},resources:{subscribe:!0,listChanged:!0},tools:{listChanged:!0},completions:{},logging:{}};this.server=new fd(e||n,r||{capabilities:s}),this.server.server.oninitialized=()=>{this.oninitialized?.()},this.server.server.onclose=()=>{this.onclose?.()},this.server.server.onerror=a=>{this.onerror?.(a)},this.server.server.setRequestHandler(Ns,async()=>({}))}async connect(e){return typeof e.start=="function"?(this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0):(this.transport=new si(e),await this.transport.listen()),await this.server.connect(this.transport),this.transport}async close(){await this.server.close()}registerTool(e,r,n){return this.server.registerTool(e,r,n)}registerPrompt(e,r,n){return this.server.registerPrompt(e,r,n)}registerResource(e,r,n,s){return typeof r=="string"?this.server.registerResource(e,r,n,s):this.server.registerResource(e,r,n,s)}isConnected(){return this.server.isConnected()}sendResourceListChanged(){this.server.sendResourceListChanged()}sendToolListChanged(){this.server.sendToolListChanged()}sendPromptListChanged(){this.server.sendPromptListChanged()}getClientCapabilities(){return this.server.server.getClientCapabilities()}getClientVersion(){return this.server.server.getClientVersion()}async ping(){return await this.server.server.ping()}async createMessage(e,r){return await this.server.server.createMessage(e,r)}async elicitInput(e,r){return await this.server.server.elicitInput(e,r)}async listRoots(e,r){return await this.server.server.listRoots(e,r)}async sendLoggingMessage(e){return await this.server.server.sendLoggingMessage(e)}async sendResourceUpdated(e){return await this.server.server.sendResourceUpdated(e)}request(e,r,n){return this.server.server.request(e,r,n)}async notification(e,r){return await this.server.server.notification(e,r)}setRequestHandler(e,r){this.server.server.setRequestHandler(e,r)}removeRequestHandler(e){this.server.server.removeRequestHandler(e)}setNotificationHandler(e,r){this.server.server.setNotificationHandler(e,r)}removeNotificationHandler(e){this.server.server.removeNotificationHandler(e)}onSubscribe(e){this.server.server.setRequestHandler(Gu,e)}onUnsubscribe(e){this.server.server.setRequestHandler(Yu,e)}onSetLogLevel(e){this.server.server.setRequestHandler(Ns,e)}onListResources(e){this.server.server.setRequestHandler(Is,e)}onRootsListChanged(e){this.server.server.setNotificationHandler(il,e)}async onPagehide(e){e.persisted||this.transport&&typeof this.transport.close=="function"&&await this.transport.close()}}const X0=(t,e)=>new si(t,e),Q0=()=>v0(),ew=t=>t instanceof si,tw=t=>t instanceof fd;class rw{constructor(e,r){const n={name:"web-mcp-client",version:"1.0.0"},s={roots:{listChanged:!0},sampling:{},elicitation:{}};this.client=new yn(e||n,r||{capabilities:s}),this.client.onclose=()=>{this.onclose?.()},this.client.onerror=a=>{this.onerror?.(a)}}async connect(e){if(typeof e.start=="function")return this.transport=e,this.transport.onclose=void 0,this.transport.onerror=void 0,this.transport.onmessage=void 0,await this.client.connect(this.transport),{transport:this.transport,sessionId:this.transport.sessionId};const{url:r,token:n,sessionId:s,type:a,agent:o,onError:i}=e;if(o===!0){const l={client:this.client,url:r,token:n,sessionId:s};let d;return await(async()=>{const{transport:_,sessionId:p}=a==="sse"?await N0(l):a==="socket"?await j0(l):await A0(l);_.onerror=async y=>{i?.(y)},d={transport:_,sessionId:p}})(),d}const c=new URL(r);let u;if(a==="channel"&&(u=new ni(r),await this.client.connect(u)),a==="sse"){const l=sd(n,s);u=new $n(c,l),await this.client.connect(u)}if(a==="socket"&&(u=new rd(new URL(`${r}?sessionId=${s}&token=${n}`)),u.sessionId=s,await this.client.connect(u)),typeof u>"u"){const l=ad(n,s);u=new ta(c,l),await this.client.connect(u)}return this.transport=u,{transport:this.transport,sessionId:this.transport.sessionId}}async close(){await this.client.close()}getServerCapabilities(){return this.client.getServerCapabilities()}getServerVersion(){return this.client.getServerVersion()}getInstructions(){return this.client.getInstructions()}async ping(e){return await this.client.ping(e)}async complete(e,r){return await this.client.complete(e,r)}async setLoggingLevel(e,r){return await this.client.setLoggingLevel(e,r)}async getPrompt(e,r){return await this.client.getPrompt(e,r)}async listPrompts(e,r){return await this.client.listPrompts(e,r)}async listResources(e,r){return await this.client.listResources(e,r)}async listResourceTemplates(e,r){return await this.client.listResourceTemplates(e,r)}async readResource(e,r){return await this.client.readResource(e,r)}async subscribeResource(e,r){return await this.client.subscribeResource(e,r)}async unsubscribeResource(e,r){return await this.client.unsubscribeResource(e,r)}async callTool(e,r){return await this.client.callTool(e,vr,r)}async listTools(e,r){return await this.client.listTools(e,r)}async sendRootsListChanged(){return await this.client.sendRootsListChanged()}request(e,r,n){return this.client.request(e,r,n)}async notification(e,r){return await this.client.notification(e,r)}setRequestHandler(e,r){this.client.setRequestHandler(e,r)}removeRequestHandler(e){this.client.removeRequestHandler(e)}setNotificationHandler(e,r){this.client.setNotificationHandler(e,r)}removeNotificationHandler(e){this.client.removeNotificationHandler(e)}onElicit(e){this.client.setRequestHandler(po,e)}onCreateMessage(e){this.client.setRequestHandler(ho,e)}onListRoots(e){this.client.setRequestHandler(ol,e)}onToolListChanged(e){this.client.setNotificationHandler(fo,e)}onPromptListChanged(e){this.client.setNotificationHandler(uo,e)}onResourceListChanged(e){this.client.setNotificationHandler(ro,e)}onResourceUpdated(e){this.client.setNotificationHandler(Xu,e)}onLoggingMessage(e){this.client.setNotificationHandler(nl,e)}async onPagehide(e){e.persisted||(_d(this.transport)?await this.transport.terminateSession():this.transport&&typeof this.transport.close=="function"&&await this.transport.close())}}const nw=(t,e)=>new $n(t,e),sw=(t,e)=>new ta(t,e),aw=(t,e)=>new ni(t,e),ow=t=>t instanceof $n,_d=t=>t instanceof ta,iw=t=>t instanceof ni,cw=t=>t instanceof yn;function uw(t){return t.title!==void 0&&t.title!==""?t.title:"annotations"in t&&t.annotations?.title?t.annotations.title:t.name}const lw=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)}),la=(t,e,r)=>{window.postMessage({type:t,direction:r,data:e},"*")},gd=(t,e,r)=>{const n=async function(s){s.source===window&&s.data.type===t&&s.data.direction===r&&await e(s.data.data)};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)};class dw{constructor(e=null){this._isStarted=!1,this._isClosed=!1,this._lastRegistration=null,this.sessionId=e||lw(),this._messageListener1=gd("sidepanel-ready-to-page",()=>{this._lastRegistration&&this._isStarted&&this.notifyRegistration(this._lastRegistration).catch(r=>{console.error("【Page Svr Transport】 notifyRegistration失败:",r)})},"content->page"),this._messageListener2=gd("mcp-client-to-server-to-page",r=>{if(r.sessionId!==this.sessionId)return;console.log("【Page Svr Transport】 即将处理 mcpMessage",r.mcpMessage);const n=ar.parse(r.mcpMessage);this.onmessage?.(n),r.mcpMessage.params?.name&&la("update-page-app-message",{status:"run",message:r.mcpMessage.params?.name},"page->content")},"content->page")}_throwError(e,r){if(e()){const n=new Error(r);throw console.log(r,n),this.onerror&&this.onerror(n),n}}async start(){if(!this._isStarted){if(this._isClosed)throw new Error("【Page Svr Transport】 已关闭,无法重新启动");this._isStarted=!0}}async send(e,r){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法发送消息"),this._throwError(()=>this._isClosed,"【Page Svr Transport】 已关闭,无法发送消息"),la("mcp-server-to-client-from-page",{sessionId:this.sessionId,mcpMessage:e},"page->content"),"result"in e&&e.result?.content&&la("update-page-app-message",{status:"ready",message:""},"page->content")}async notifyRegistration(e){this._throwError(()=>!this._isStarted,"【Page Svr Transport】 未启动,无法注册消息"),this._lastRegistration=e;try{la("mcp-server-register-from-page",{sessionId:this.sessionId,serverInfo:{...e,url:window.location.origin,title:document.title}},"page->content")}catch(r){this._throwError(()=>!0,"【Page Svr Transport】 注册 server 失败"+String(r))}}async close(){if(!this._isClosed)try{this._messageListener1&&this._messageListener1(),this._messageListener2&&this._messageListener2(),this._isClosed=!0,this._isStarted=!1,this.onclose&&this.onclose()}catch(e){this._throwError(()=>!0,"【Page Svr Transport】 关闭时发生错误"+String(e))}}}$e.Ajv=jc,$e.AuthClientProvider=z0,$e.ExtensionPageServerTransport=dw,$e.ResourceTemplate=K0,$e.UriTemplate=qt,$e.WebMcpClient=rw,$e.WebMcpServer=Y0,$e.completable=L0,$e.createMessageChannelClientTransport=aw,$e.createMessageChannelPairTransport=Q0,$e.createMessageChannelServerTransport=X0,$e.createSSEClientTransport=nw,$e.createStreamableHTTPClientTransport=sw,$e.getDisplayName=uw,$e.isMcpClient=cw,$e.isMcpServer=tw,$e.isMessageChannelClientTransport=iw,$e.isMessageChannelServerTransport=ew,$e.isSSEClientTransport=ow,$e.isStreamableHTTPClientTransport=_d,$e.z=Iy,Object.defineProperty($e,Symbol.toStringTag,{value:"Module"})}));