jotbus 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -26
- package/dist/index.js +65 -50
- package/package.json +34 -7
package/dist/index.js
CHANGED
|
@@ -1,55 +1,58 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
-
var Ob=Object.create;var na=Object.defineProperty;var Rb=Object.getOwnPropertyDescriptor;var Ab=Object.getOwnPropertyNames;var Ib=Object.getPrototypeOf,Cb=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},oa=(e,t)=>{for(var r in t)na(e,r,{get:t[r],enumerable:!0})},Nb=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ab(t))!Cb.call(e,o)&&o!==r&&na(e,o,{get:()=>t[o],enumerable:!(n=Rb(t,o))||n.enumerable});return e};var sa=(e,t,r)=>(r=e!=null?Ob(Ib(e)):{},Nb(t||!e||!e.__esModule?na(r,"default",{value:e,enumerable:!0}):r,e));var Fn=k(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.regexpCode=H.getEsmExportName=H.getProperty=H.safeStringify=H.stringify=H.strConcat=H.addCodeArg=H.str=H._=H.nil=H._Code=H.Name=H.IDENTIFIER=H._CodeOrName=void 0;var Un=class{};H._CodeOrName=Un;H.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var nr=class extends Un{constructor(t){if(super(),!H.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};H.Name=nr;var Be=class extends Un{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof nr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};H._Code=Be;H.nil=new Be("");function Tg(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Bc(r,t[n]),r.push(e[++n]);return new Be(r)}H._=Tg;var Vc=new Be("+");function Og(e,...t){let r=[qn(e[0])],n=0;for(;n<t.length;)r.push(Vc),Bc(r,t[n]),r.push(Vc,qn(e[++n]));return R$(r),new Be(r)}H.str=Og;function Bc(e,t){t instanceof Be?e.push(...t._items):t instanceof nr?e.push(t):e.push(C$(t))}H.addCodeArg=Bc;function R$(e){let t=1;for(;t<e.length-1;){if(e[t]===Vc){let r=A$(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function A$(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof nr||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof nr))return`"${e}${t.slice(1)}`}function I$(e,t){return t.emptyStr()?e:e.emptyStr()?t:Og`${e}${t}`}H.strConcat=I$;function C$(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:qn(Array.isArray(e)?e.join(","):e)}function N$(e){return new Be(qn(e))}H.stringify=N$;function qn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}H.safeStringify=qn;function j$(e){return typeof e=="string"&&H.IDENTIFIER.test(e)?new Be(`.${e}`):Tg`[${e}]`}H.getProperty=j$;function Z$(e){if(typeof e=="string"&&H.IDENTIFIER.test(e))return new Be(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}H.getEsmExportName=Z$;function M$(e){return new Be(e.toString())}H.regexpCode=M$});var Jc=k(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.ValueScope=Ne.ValueScopeName=Ne.Scope=Ne.varKinds=Ne.UsedValueState=void 0;var Ce=Fn(),Hc=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Hs;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Hs||(Ne.UsedValueState=Hs={}));Ne.varKinds={const:new Ce.Name("const"),let:new Ce.Name("let"),var:new Ce.Name("var")};var Ks=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ce.Name?t:this.name(t)}name(t){return new Ce.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Ne.Scope=Ks;var Js=class extends Ce.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ce._)`.${new Ce.Name(r)}[${n}]`}};Ne.ValueScopeName=Js;var D$=(0,Ce._)`\n`,Kc=class extends Ks{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?D$:Ce.nil}}get(){return this._scope}name(t){return new Js(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ce._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ce.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Hs.Started);let l=r(u);if(l){let d=this.opts.es5?Ne.varKinds.var:Ne.varKinds.const;s=(0,Ce._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ce._)`${s}${l}${this.opts._n}`;else throw new Hc(u);c.set(u,Hs.Completed)})}return s}};Ne.ValueScope=Kc});var M=k(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var U=Fn(),Qe=Jc(),Lt=Fn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Lt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Lt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Lt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Lt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Lt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Lt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Lt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Lt.Name}});var Ys=Jc();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Ys.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Ys.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Ys.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Ys.varKinds}});D.operators={GT:new U._Code(">"),GTE:new U._Code(">="),LT:new U._Code("<"),LTE:new U._Code("<="),EQ:new U._Code("==="),NEQ:new U._Code("!=="),NOT:new U._Code("!"),OR:new U._Code("||"),AND:new U._Code("&&"),ADD:new U._Code("+")};var vt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Wc=class extends vt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Qe.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Vr(this.rhs,t,r)),this}get names(){return this.rhs instanceof U._CodeOrName?this.rhs.names:{}}},Ws=class extends vt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof U.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Vr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof U.Name?{}:{...this.lhs.names};return Xs(t,this.rhs)}},Gc=class extends Ws{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Xc=class extends vt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Yc=class extends vt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Qc=class extends vt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},eu=class extends vt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Vr(this.code,t,r),this}get names(){return this.code instanceof U._CodeOrName?this.code.names:{}}},Vn=class extends vt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(L$(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>ir(t,r.names),{})}},$t=class extends Vn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},tu=class extends Vn{},Fr=class extends $t{};Fr.kind="else";var or=class e extends $t{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Fr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Rg(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Vr(this.condition,t,r),this}get names(){let t=super.names;return Xs(t,this.condition),this.else&&ir(t,this.else.names),t}};or.kind="if";var sr=class extends $t{};sr.kind="for";var ru=class extends sr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Vr(this.iteration,t,r),this}get names(){return ir(super.names,this.iteration.names)}},nu=class extends sr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?Qe.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Xs(super.names,this.from);return Xs(t,this.to)}},Gs=class extends sr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Vr(this.iterable,t,r),this}get names(){return ir(super.names,this.iterable.names)}},Bn=class extends $t{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Bn.kind="func";var Hn=class extends Vn{render(t){return"return "+super.render(t)}};Hn.kind="return";var ou=class extends $t{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&ir(t,this.catch.names),this.finally&&ir(t,this.finally.names),t}},Kn=class extends $t{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Kn.kind="catch";var Jn=class extends $t{render(t){return"finally"+super.render(t)}};Jn.kind="finally";var su=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
-
`:""},this._extScope=t,this._scope=new Qe.Scope({parent:t}),this._nodes=[new tu]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Wc(t,s,n)),s}const(t,r,n){return this._def(Qe.varKinds.const,t,r,n)}let(t,r,n){return this._def(Qe.varKinds.let,t,r,n)}var(t,r,n){return this._def(Qe.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Ws(t,r,n))}add(t,r){return this._leafNode(new Gc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==U.nil&&this._leafNode(new eu(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,U.addCodeArg)(r,o));return r.push("}"),new U._Code(r)}if(t,r,n){if(this._blockNode(new or(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new or(t))}else(){return this._elseNode(new Fr)}endIf(){return this._endBlockNode(or,Fr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new ru(t),r)}forRange(t,r,n,o,s=this.opts.es5?Qe.varKinds.var:Qe.varKinds.let){let i=this._scope.toName(t);return this._for(new nu(s,i,r,n),()=>o(i))}forOf(t,r,n,o=Qe.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof U.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,U._)`${i}.length`,a=>{this.var(s,(0,U._)`${i}[${a}]`),n(s)})}return this._for(new Gs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,U._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Gs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(sr)}label(t){return this._leafNode(new Xc(t))}break(t){return this._leafNode(new Yc(t))}return(t){let r=new Hn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Hn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new ou;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Kn(s),r(s)}return n&&(this._currNode=o.finally=new Jn,this.code(n)),this._endBlockNode(Kn,Jn)}throw(t){return this._leafNode(new Qc(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=U.nil,n,o){return this._blockNode(new Bn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Bn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof or))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=su;function ir(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Xs(e,t){return t instanceof U._CodeOrName?ir(e,t.names):e}function Vr(e,t,r){if(e instanceof U.Name)return n(e);if(!o(e))return e;return new U._Code(e._items.reduce((s,i)=>(i instanceof U.Name&&(i=n(i)),i instanceof U._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof U._Code&&s._items.some(i=>i instanceof U.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function L$(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Rg(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,U._)`!${iu(e)}`}D.not=Rg;var U$=Ag(D.operators.AND);function q$(...e){return e.reduce(U$)}D.and=q$;var F$=Ag(D.operators.OR);function V$(...e){return e.reduce(F$)}D.or=V$;function Ag(e){return(t,r)=>t===U.nil?r:r===U.nil?t:(0,U._)`${iu(t)} ${e} ${iu(r)}`}function iu(e){return e instanceof U.Name?e:(0,U._)`(${e})`}});var q=k(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.checkStrictMode=L.getErrorPath=L.Type=L.useFunc=L.setEvaluated=L.evaluatedPropsToName=L.mergeEvaluated=L.eachItem=L.unescapeJsonPointer=L.escapeJsonPointer=L.escapeFragment=L.unescapeFragment=L.schemaRefOrVal=L.schemaHasRulesButRef=L.schemaHasRules=L.checkUnknownRules=L.alwaysValidSchema=L.toHash=void 0;var Y=M(),B$=Fn();function H$(e){let t={};for(let r of e)t[r]=!0;return t}L.toHash=H$;function K$(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Ng(e,t),!jg(t,e.self.RULES.all))}L.alwaysValidSchema=K$;function Ng(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Dg(e,`unknown keyword: "${s}"`)}L.checkUnknownRules=Ng;function jg(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}L.schemaHasRules=jg;function J$(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}L.schemaHasRulesButRef=J$;function W$({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Y._)`${r}`}return(0,Y._)`${e}${t}${(0,Y.getProperty)(n)}`}L.schemaRefOrVal=W$;function G$(e){return Zg(decodeURIComponent(e))}L.unescapeFragment=G$;function X$(e){return encodeURIComponent(cu(e))}L.escapeFragment=X$;function cu(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}L.escapeJsonPointer=cu;function Zg(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}L.unescapeJsonPointer=Zg;function Y$(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}L.eachItem=Y$;function Ig({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof Y.Name?(s instanceof Y.Name?e(o,s,i):t(o,s,i),i):s instanceof Y.Name?(t(o,i,s),s):r(s,i);return a===Y.Name&&!(c instanceof Y.Name)?n(o,c):c}}L.mergeEvaluated={props:Ig({mergeNames:(e,t,r)=>e.if((0,Y._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,Y._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,Y._)`${r} || {}`).code((0,Y._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,Y._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,Y._)`${r} || {}`),uu(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Mg}),items:Ig({mergeNames:(e,t,r)=>e.if((0,Y._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,Y._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,Y._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,Y._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Mg(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,Y._)`{}`);return t!==void 0&&uu(e,r,t),r}L.evaluatedPropsToName=Mg;function uu(e,t,r){Object.keys(r).forEach(n=>e.assign((0,Y._)`${t}${(0,Y.getProperty)(n)}`,!0))}L.setEvaluated=uu;var Cg={};function Q$(e,t){return e.scopeValue("func",{ref:t,code:Cg[t.code]||(Cg[t.code]=new B$._Code(t.code))})}L.useFunc=Q$;var au;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(au||(L.Type=au={}));function eS(e,t,r){if(e instanceof Y.Name){let n=t===au.Num;return r?n?(0,Y._)`"[" + ${e} + "]"`:(0,Y._)`"['" + ${e} + "']"`:n?(0,Y._)`"/" + ${e}`:(0,Y._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Y.getProperty)(e).toString():"/"+cu(e)}L.getErrorPath=eS;function Dg(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}L.checkStrictMode=Dg});var St=k(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var $e=M(),tS={data:new $e.Name("data"),valCxt:new $e.Name("valCxt"),instancePath:new $e.Name("instancePath"),parentData:new $e.Name("parentData"),parentDataProperty:new $e.Name("parentDataProperty"),rootData:new $e.Name("rootData"),dynamicAnchors:new $e.Name("dynamicAnchors"),vErrors:new $e.Name("vErrors"),errors:new $e.Name("errors"),this:new $e.Name("this"),self:new $e.Name("self"),scope:new $e.Name("scope"),json:new $e.Name("json"),jsonPos:new $e.Name("jsonPos"),jsonLen:new $e.Name("jsonLen"),jsonPart:new $e.Name("jsonPart")};lu.default=tS});var Wn=k(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.extendErrors=Se.resetErrorsCount=Se.reportExtraError=Se.reportError=Se.keyword$DataError=Se.keywordError=void 0;var F=M(),Qs=q(),Te=St();Se.keywordError={message:({keyword:e})=>(0,F.str)`must pass "${e}" keyword validation`};Se.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,F.str)`"${e}" keyword must be ${t} ($data)`:(0,F.str)`"${e}" keyword is invalid ($data)`};function rS(e,t=Se.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=qg(e,t,r);n??(i||a)?Lg(s,c):Ug(o,(0,F._)`[${c}]`)}Se.reportError=rS;function nS(e,t=Se.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=qg(e,t,r);Lg(o,a),s||i||Ug(n,Te.default.vErrors)}Se.reportExtraError=nS;function oS(e,t){e.assign(Te.default.errors,t),e.if((0,F._)`${Te.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,F._)`${Te.default.vErrors}.length`,t),()=>e.assign(Te.default.vErrors,null)))}Se.resetErrorsCount=oS;function sS({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Te.default.errors,a=>{e.const(i,(0,F._)`${Te.default.vErrors}[${a}]`),e.if((0,F._)`${i}.instancePath === undefined`,()=>e.assign((0,F._)`${i}.instancePath`,(0,F.strConcat)(Te.default.instancePath,s.errorPath))),e.assign((0,F._)`${i}.schemaPath`,(0,F.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,F._)`${i}.schema`,r),e.assign((0,F._)`${i}.data`,n))})}Se.extendErrors=sS;function Lg(e,t){let r=e.const("err",t);e.if((0,F._)`${Te.default.vErrors} === null`,()=>e.assign(Te.default.vErrors,(0,F._)`[${r}]`),(0,F._)`${Te.default.vErrors}.push(${r})`),e.code((0,F._)`${Te.default.errors}++`)}function Ug(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,F._)`new ${e.ValidationError}(${t})`):(r.assign((0,F._)`${n}.errors`,t),r.return(!1))}var ar={keyword:new F.Name("keyword"),schemaPath:new F.Name("schemaPath"),params:new F.Name("params"),propertyName:new F.Name("propertyName"),message:new F.Name("message"),schema:new F.Name("schema"),parentSchema:new F.Name("parentSchema")};function qg(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,F._)`{}`:iS(e,t,r)}function iS(e,t,r={}){let{gen:n,it:o}=e,s=[aS(o,r),cS(e,r)];return uS(e,t,s),n.object(...s)}function aS({errorPath:e},{instancePath:t}){let r=t?(0,F.str)`${e}${(0,Qs.getErrorPath)(t,Qs.Type.Str)}`:e;return[Te.default.instancePath,(0,F.strConcat)(Te.default.instancePath,r)]}function cS({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,F.str)`${t}/${e}`;return r&&(o=(0,F.str)`${o}${(0,Qs.getErrorPath)(r,Qs.Type.Str)}`),[ar.schemaPath,o]}function uS(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([ar.keyword,o],[ar.params,typeof t=="function"?t(e):t||(0,F._)`{}`]),c.messages&&n.push([ar.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([ar.schema,i],[ar.parentSchema,(0,F._)`${l}${d}`],[Te.default.data,s]),u&&n.push([ar.propertyName,u])}});var Vg=k(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.boolOrEmptySchema=Br.topBoolOrEmptySchema=void 0;var lS=Wn(),dS=M(),fS=St(),pS={message:"boolean schema is false"};function hS(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Fg(e,!1):typeof r=="object"&&r.$async===!0?t.return(fS.default.data):(t.assign((0,dS._)`${n}.errors`,null),t.return(!0))}Br.topBoolOrEmptySchema=hS;function mS(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Fg(e)):r.var(t,!0)}Br.boolOrEmptySchema=mS;function Fg(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,lS.reportError)(o,pS,void 0,t)}});var du=k(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.getRules=Hr.isJSONType=void 0;var gS=["string","number","integer","boolean","null","object","array"],yS=new Set(gS);function _S(e){return typeof e=="string"&&yS.has(e)}Hr.isJSONType=_S;function bS(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Hr.getRules=bS});var fu=k(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Ut.shouldUseRule=Ut.shouldUseGroup=Ut.schemaHasRulesForType=void 0;function wS({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Bg(e,n)}Ut.schemaHasRulesForType=wS;function Bg(e,t){return t.rules.some(r=>Hg(e,r))}Ut.shouldUseGroup=Bg;function Hg(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Ut.shouldUseRule=Hg});var Gn=k(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.reportTypeError=ze.checkDataTypes=ze.checkDataType=ze.coerceAndCheckDataType=ze.getJSONTypes=ze.getSchemaTypes=ze.DataType=void 0;var xS=du(),vS=fu(),$S=Wn(),j=M(),Kg=q(),Kr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Kr||(ze.DataType=Kr={}));function SS(e){let t=Jg(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}ze.getSchemaTypes=SS;function Jg(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(xS.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ze.getJSONTypes=Jg;function zS(e,t){let{gen:r,data:n,opts:o}=e,s=kS(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,vS.schemaHasRulesForType)(e,t[0]));if(i){let a=hu(t,n,o.strictNumbers,Kr.Wrong);r.if(a,()=>{s.length?PS(e,t,s):mu(e)})}return i}ze.coerceAndCheckDataType=zS;var Wg=new Set(["string","number","integer","boolean","null"]);function kS(e,t){return t?e.filter(r=>Wg.has(r)||t==="array"&&r==="array"):[]}function PS(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,j._)`typeof ${o}`),a=n.let("coerced",(0,j._)`undefined`);s.coerceTypes==="array"&&n.if((0,j._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,j._)`${o}[0]`).assign(i,(0,j._)`typeof ${o}`).if(hu(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,j._)`${a} !== undefined`);for(let u of r)(Wg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),mu(e),n.endIf(),n.if((0,j._)`${a} !== undefined`,()=>{n.assign(o,a),ES(e,a)});function c(u){switch(u){case"string":n.elseIf((0,j._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,j._)`"" + ${o}`).elseIf((0,j._)`${o} === null`).assign(a,(0,j._)`""`);return;case"number":n.elseIf((0,j._)`${i} == "boolean" || ${o} === null
|
|
5
|
-
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,
|
|
6
|
-
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,
|
|
7
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,j._)`[${o}]`)}}}function ES({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,j._)`${t} !== undefined`,()=>e.assign((0,j._)`${t}[${r}]`,n))}function pu(e,t,r,n=Kr.Correct){let o=n===Kr.Correct?j.operators.EQ:j.operators.NEQ,s;switch(e){case"null":return(0,j._)`${t} ${o} null`;case"array":s=(0,j._)`Array.isArray(${t})`;break;case"object":s=(0,j._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,j._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,j._)`typeof ${t} ${o} ${e}`}return n===Kr.Correct?s:(0,j.not)(s);function i(a=j.nil){return(0,j.and)((0,j._)`typeof ${t} == "number"`,a,r?(0,j._)`isFinite(${t})`:j.nil)}}ze.checkDataType=pu;function hu(e,t,r,n){if(e.length===1)return pu(e[0],t,r,n);let o,s=(0,Kg.toHash)(e);if(s.array&&s.object){let i=(0,j._)`typeof ${t} != "object"`;o=s.null?i:(0,j._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=j.nil;s.number&&delete s.integer;for(let i in s)o=(0,j.and)(o,pu(i,t,r,n));return o}ze.checkDataTypes=hu;var TS={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,j._)`{type: ${e}}`:(0,j._)`{type: ${t}}`};function mu(e){let t=OS(e);(0,$S.reportError)(t,TS)}ze.reportTypeError=mu;function OS(e){let{gen:t,data:r,schema:n}=e,o=(0,Kg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Xg=k(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.assignDefaults=void 0;var Jr=M(),RS=q();function AS(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Gg(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Gg(e,s,o.default))}ei.assignDefaults=AS;function Gg(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Jr._)`${s}${(0,Jr.getProperty)(t)}`;if(o){(0,RS.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Jr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Jr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Jr._)`${a} = ${(0,Jr.stringify)(r)}`)}});var He=k(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.validateUnion=W.validateArray=W.usePattern=W.callValidateCode=W.schemaProperties=W.allSchemaProperties=W.noPropertyInData=W.propertyInData=W.isOwnProperty=W.hasPropFunc=W.reportMissingProp=W.checkMissingProp=W.checkReportMissingProp=void 0;var re=M(),gu=q(),qt=St(),IS=q();function CS(e,t){let{gen:r,data:n,it:o}=e;r.if(_u(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,re._)`${t}`},!0),e.error()})}W.checkReportMissingProp=CS;function NS({gen:e,data:t,it:{opts:r}},n,o){return(0,re.or)(...n.map(s=>(0,re.and)(_u(e,t,s,r.ownProperties),(0,re._)`${o} = ${s}`)))}W.checkMissingProp=NS;function jS(e,t){e.setParams({missingProperty:t},!0),e.error()}W.reportMissingProp=jS;function Yg(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,re._)`Object.prototype.hasOwnProperty`})}W.hasPropFunc=Yg;function yu(e,t,r){return(0,re._)`${Yg(e)}.call(${t}, ${r})`}W.isOwnProperty=yu;function ZS(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} !== undefined`;return n?(0,re._)`${o} && ${yu(e,t,r)}`:o}W.propertyInData=ZS;function _u(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} === undefined`;return n?(0,re.or)(o,(0,re.not)(yu(e,t,r))):o}W.noPropertyInData=_u;function Qg(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}W.allSchemaProperties=Qg;function MS(e,t){return Qg(t).filter(r=>!(0,gu.alwaysValidSchema)(e,t[r]))}W.schemaProperties=MS;function DS({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,re._)`${e}, ${t}, ${n}${o}`:t,d=[[qt.default.instancePath,(0,re.strConcat)(qt.default.instancePath,s)],[qt.default.parentData,i.parentData],[qt.default.parentDataProperty,i.parentDataProperty],[qt.default.rootData,qt.default.rootData]];i.opts.dynamicRef&&d.push([qt.default.dynamicAnchors,qt.default.dynamicAnchors]);let p=(0,re._)`${l}, ${r.object(...d)}`;return c!==re.nil?(0,re._)`${a}.call(${c}, ${p})`:(0,re._)`${a}(${p})`}W.callValidateCode=DS;var LS=(0,re._)`new RegExp`;function US({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,re._)`${o.code==="new RegExp"?LS:(0,IS.useFunc)(e,o)}(${r}, ${n})`})}W.usePattern=US;function qS(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,re._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:gu.Type.Num},s),t.if((0,re.not)(s),a)})}}W.validateArray=qS;function FS(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,gu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,re._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,re.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}W.validateUnion=FS});var ry=k(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.validateKeywordUsage=st.validSchemaType=st.funcKeywordCode=st.macroKeywordCode=void 0;var Oe=M(),cr=St(),VS=He(),BS=Wn();function HS(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=ty(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Oe.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}st.macroKeywordCode=HS;function KS(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;WS(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=ty(n,o,u),d=n.let("valid");e.block$data(d,p),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function p(){if(t.errors===!1)m(),t.modifying&&ey(e),y(()=>e.error());else{let w=t.async?f():h();t.modifying&&ey(e),y(()=>JS(e,w))}}function f(){let w=n.let("ruleErrs",null);return n.try(()=>m((0,Oe._)`await `),v=>n.assign(d,!1).if((0,Oe._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(w,(0,Oe._)`${v}.errors`),()=>n.throw(v))),w}function h(){let w=(0,Oe._)`${l}.errors`;return n.assign(w,null),m(Oe.nil),w}function m(w=t.async?(0,Oe._)`await `:Oe.nil){let v=c.opts.passContext?cr.default.this:cr.default.self,z=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Oe._)`${w}${(0,VS.callValidateCode)(e,l,v,z)}`,t.modifying)}function y(w){var v;n.if((0,Oe.not)((v=t.valid)!==null&&v!==void 0?v:d),w)}}st.funcKeywordCode=KS;function ey(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Oe._)`${n.parentData}[${n.parentDataProperty}]`))}function JS(e,t){let{gen:r}=e;r.if((0,Oe._)`Array.isArray(${t})`,()=>{r.assign(cr.default.vErrors,(0,Oe._)`${cr.default.vErrors} === null ? ${t} : ${cr.default.vErrors}.concat(${t})`).assign(cr.default.errors,(0,Oe._)`${cr.default.vErrors}.length`),(0,BS.extendErrors)(e)},()=>e.error())}function WS({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function ty(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Oe.stringify)(r)})}function GS(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}st.validSchemaType=GS;function XS({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}st.validateKeywordUsage=XS});var oy=k(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.extendSubschemaMode=Ft.extendSubschemaData=Ft.getSubschema=void 0;var it=M(),ny=q();function YS(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,it._)`${e.schemaPath}${(0,it.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,it._)`${e.schemaPath}${(0,it.getProperty)(t)}${(0,it.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,ny.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Ft.getSubschema=YS;function QS(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,p=a.let("data",(0,it._)`${t.data}${(0,it.getProperty)(r)}`,!0);c(p),e.errorPath=(0,it.str)`${u}${(0,ny.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,it._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof it.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Ft.extendSubschemaData=QS;function ez(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Ft.extendSubschemaMode=ez});var bu=k((YN,sy)=>{"use strict";sy.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var ay=k((QN,iy)=>{"use strict";var Vt=iy.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};ti(t,n,o,e,"",e)};Vt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Vt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Vt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Vt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function ti(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Vt.arrayKeywords)for(var p=0;p<d.length;p++)ti(e,t,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Vt.propsKeywords){if(d&&typeof d=="object")for(var f in d)ti(e,t,r,d[f],o+"/"+l+"/"+tz(f),s,o,l,n,f)}else(l in Vt.keywords||e.allKeys&&!(l in Vt.skipKeywords))&&ti(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function tz(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Xn=k(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.getSchemaRefs=je.resolveUrl=je.normalizeId=je._getFullPath=je.getFullPath=je.inlineRef=void 0;var rz=q(),nz=bu(),oz=ay(),sz=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function iz(e,t=!0){return typeof e=="boolean"?!0:t===!0?!wu(e):t?cy(e)<=t:!1}je.inlineRef=iz;var az=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function wu(e){for(let t in e){if(az.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(wu)||typeof r=="object"&&wu(r))return!0}return!1}function cy(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!sz.has(r)&&(typeof e[r]=="object"&&(0,rz.eachItem)(e[r],n=>t+=cy(n)),t===1/0))return 1/0}return t}function uy(e,t="",r){r!==!1&&(t=Wr(t));let n=e.parse(t);return ly(e,n)}je.getFullPath=uy;function ly(e,t){return e.serialize(t).split("#")[0]+"#"}je._getFullPath=ly;var cz=/#\/?$/;function Wr(e){return e?e.replace(cz,""):""}je.normalizeId=Wr;function uz(e,t,r){return r=Wr(r),e.resolve(t,r)}je.resolveUrl=uz;var lz=/^[a-z_][-a-z0-9._]*$/i;function dz(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Wr(e[r]||t),s={"":o},i=uy(n,o,!1),a={},c=new Set;return oz(e,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let m=i+p,y=s[h];typeof d[r]=="string"&&(y=w.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[p]=y;function w(z){let A=this.opts.uriResolver.resolve;if(z=Wr(y?A(y,z):z),c.has(z))throw l(z);c.add(z);let b=this.refs[z];return typeof b=="string"&&(b=this.refs[b]),typeof b=="object"?u(d,b.schema,z):z!==Wr(m)&&(z[0]==="#"?(u(d,a[z],z),a[z]=d):this.refs[z]=m),z}function v(z){if(typeof z=="string"){if(!lz.test(z))throw new Error(`invalid anchor "${z}"`);w.call(this,`#${z}`)}}}),a;function u(d,p,f){if(p!==void 0&&!nz(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}je.getSchemaRefs=dz});var eo=k(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.getData=Bt.KeywordCxt=Bt.validateFunctionCode=void 0;var my=Vg(),dy=Gn(),vu=fu(),ri=Gn(),fz=Xg(),Qn=ry(),xu=oy(),O=M(),N=St(),pz=Xn(),zt=q(),Yn=Wn();function hz(e){if(_y(e)&&(by(e),yy(e))){yz(e);return}gy(e,()=>(0,my.topBoolOrEmptySchema)(e))}Bt.validateFunctionCode=hz;function gy({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,O._)`${N.default.data}, ${N.default.valCxt}`,n.$async,()=>{e.code((0,O._)`"use strict"; ${fy(r,o)}`),gz(e,o),e.code(s)}):e.func(t,(0,O._)`${N.default.data}, ${mz(o)}`,n.$async,()=>e.code(fy(r,o)).code(s))}function mz(e){return(0,O._)`{${N.default.instancePath}="", ${N.default.parentData}, ${N.default.parentDataProperty}, ${N.default.rootData}=${N.default.data}${e.dynamicRef?(0,O._)`, ${N.default.dynamicAnchors}={}`:O.nil}}={}`}function gz(e,t){e.if(N.default.valCxt,()=>{e.var(N.default.instancePath,(0,O._)`${N.default.valCxt}.${N.default.instancePath}`),e.var(N.default.parentData,(0,O._)`${N.default.valCxt}.${N.default.parentData}`),e.var(N.default.parentDataProperty,(0,O._)`${N.default.valCxt}.${N.default.parentDataProperty}`),e.var(N.default.rootData,(0,O._)`${N.default.valCxt}.${N.default.rootData}`),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,O._)`${N.default.valCxt}.${N.default.dynamicAnchors}`)},()=>{e.var(N.default.instancePath,(0,O._)`""`),e.var(N.default.parentData,(0,O._)`undefined`),e.var(N.default.parentDataProperty,(0,O._)`undefined`),e.var(N.default.rootData,N.default.data),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,O._)`{}`)})}function yz(e){let{schema:t,opts:r,gen:n}=e;gy(e,()=>{r.$comment&&t.$comment&&xy(e),vz(e),n.let(N.default.vErrors,null),n.let(N.default.errors,0),r.unevaluated&&_z(e),wy(e),zz(e)})}function _z(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,O._)`${r}.evaluated`),t.if((0,O._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,O._)`${e.evaluated}.props`,(0,O._)`undefined`)),t.if((0,O._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,O._)`${e.evaluated}.items`,(0,O._)`undefined`))}function fy(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,O._)`/*# sourceURL=${r} */`:O.nil}function bz(e,t){if(_y(e)&&(by(e),yy(e))){wz(e,t);return}(0,my.boolOrEmptySchema)(e,t)}function yy({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function _y(e){return typeof e.schema!="boolean"}function wz(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&xy(e),$z(e),Sz(e);let s=n.const("_errs",N.default.errors);wy(e,s),n.var(t,(0,O._)`${s} === ${N.default.errors}`)}function by(e){(0,zt.checkUnknownRules)(e),xz(e)}function wy(e,t){if(e.opts.jtd)return py(e,[],!1,t);let r=(0,dy.getSchemaTypes)(e.schema),n=(0,dy.coerceAndCheckDataType)(e,r);py(e,r,!n,t)}function xz(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,zt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function vz(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,zt.checkStrictMode)(e,"default is ignored in the schema root")}function $z(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,pz.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Sz(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function xy({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,O._)`${N.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,O.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,O._)`${N.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function zz(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,O._)`${N.default.errors} === 0`,()=>t.return(N.default.data),()=>t.throw((0,O._)`new ${o}(${N.default.vErrors})`)):(t.assign((0,O._)`${n}.errors`,N.default.vErrors),s.unevaluated&&kz(e),t.return((0,O._)`${N.default.errors} === 0`))}function kz({gen:e,evaluated:t,props:r,items:n}){r instanceof O.Name&&e.assign((0,O._)`${t}.props`,r),n instanceof O.Name&&e.assign((0,O._)`${t}.items`,n)}function py(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,zt.schemaHasRulesButRef)(s,l))){o.block(()=>$y(e,"$ref",l.all.$ref.definition));return}c.jtd||Pz(e,t),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,vu.shouldUseGroup)(s,p)&&(p.type?(o.if((0,ri.checkDataType)(p.type,i,c.strictNumbers)),hy(e,p),t.length===1&&t[0]===p.type&&r&&(o.else(),(0,ri.reportTypeError)(e)),o.endIf()):hy(e,p),a||o.if((0,O._)`${N.default.errors} === ${n||0}`))}}function hy(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,fz.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,vu.shouldUseRule)(n,s)&&$y(e,s.keyword,s.definition,t.type)})}function Pz(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Ez(e,t),e.opts.allowUnionTypes||Tz(e,t),Oz(e,e.dataTypes))}function Ez(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{vy(e.dataTypes,r)||$u(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Az(e,t)}}function Tz(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&$u(e,"use allowUnionTypes to allow union type keyword")}function Oz(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,vu.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Rz(t,i))&&$u(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Rz(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function vy(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Az(e,t){let r=[];for(let n of e.dataTypes)vy(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function $u(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,zt.checkStrictMode)(e,t,e.opts.strictTypes)}var ni=class{constructor(t,r,n){if((0,Qn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,zt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Sy(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Qn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",N.default.errors))}result(t,r,n){this.failResult((0,O.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,O.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,O._)`${r} !== undefined && (${(0,O.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Yn.reportExtraError:Yn.reportError)(this,this.def.error,r)}$dataError(){(0,Yn.reportError)(this,this.def.$dataError||Yn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Yn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=O.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=O.nil,r=O.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,O.or)((0,O._)`${o} === undefined`,r)),t!==O.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==O.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,O.or)(i(),a());function i(){if(n.length){if(!(r instanceof O.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,O._)`${(0,ri.checkDataTypes)(c,r,s.opts.strictNumbers,ri.DataType.Wrong)}`}return O.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,O._)`!${c}(${r})`}return O.nil}}subschema(t,r){let n=(0,xu.getSubschema)(this.it,t);(0,xu.extendSubschemaData)(n,this.it,t),(0,xu.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return bz(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=zt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=zt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,O.Name)),!0}};Bt.KeywordCxt=ni;function $y(e,t,r,n){let o=new ni(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Qn.funcKeywordCode)(o,r):"macro"in r?(0,Qn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Qn.funcKeywordCode)(o,r)}var Iz=/^\/(?:[^~]|~0|~1)*$/,Cz=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Sy(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return N.default.rootData;if(e[0]==="/"){if(!Iz.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=N.default.rootData}else{let u=Cz.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,O._)`${s}${(0,O.getProperty)((0,zt.unescapeJsonPointer)(u))}`,i=(0,O._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Bt.getData=Sy});var oi=k(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var Su=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};zu.default=Su});var to=k(Eu=>{"use strict";Object.defineProperty(Eu,"__esModule",{value:!0});var ku=Xn(),Pu=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ku.resolveUrl)(t,r,n),this.missingSchema=(0,ku.normalizeId)((0,ku.getFullPath)(t,this.missingRef))}};Eu.default=Pu});var ii=k(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.resolveSchema=Ke.getCompilingSchema=Ke.resolveRef=Ke.compileSchema=Ke.SchemaEnv=void 0;var et=M(),Nz=oi(),ur=St(),tt=Xn(),zy=q(),jz=eo(),Gr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,tt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Ke.SchemaEnv=Gr;function Ou(e){let t=ky.call(this,e);if(t)return t;let r=(0,tt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new et.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:Nz.default,code:(0,et._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:ur.default.data,parentData:ur.default.parentData,parentDataProperty:ur.default.parentDataProperty,dataNames:[ur.default.data],dataPathArr:[et.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,et.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:et.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,et._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,jz.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(ur.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${ur.default.self}`,`${ur.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:m}=u;f.evaluated={props:h instanceof et.Name?void 0:h,items:m instanceof et.Name?void 0:m,dynamicProps:h instanceof et.Name,dynamicItems:m instanceof et.Name},f.source&&(f.source.evaluated=(0,et.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}Ke.compileSchema=Ou;function Zz(e,t,r){var n;r=(0,tt.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=Lz.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Gr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=Mz.call(this,s)}Ke.resolveRef=Zz;function Mz(e){return(0,tt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ou.call(this,e)}function ky(e){for(let t of this._compilations)if(Dz(t,e))return t}Ke.getCompilingSchema=ky;function Dz(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Lz(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||si.call(this,e,t)}function si(e,t){let r=this.opts.uriResolver.parse(t),n=(0,tt._getFullPath)(this.opts.uriResolver,r),o=(0,tt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Tu.call(this,r,e);let s=(0,tt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=si.call(this,e,i);return typeof a?.schema!="object"?void 0:Tu.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ou.call(this,i),s===(0,tt.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,tt.resolveUrl)(this.opts.uriResolver,o,u)),new Gr({schema:a,schemaId:c,root:e,baseId:o})}return Tu.call(this,r,i)}}Ke.resolveSchema=si;var Uz=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Tu(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,zy.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Uz.has(a)&&u&&(t=(0,tt.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,zy.schemaHasRulesButRef)(r,this.RULES)){let a=(0,tt.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=si.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Gr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var Py=k((s4,qz)=>{qz.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var ju=k((i4,Cy)=>{"use strict";var Fz=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Au=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),Vz=RegExp.prototype.test.bind(/^\d*$/u),lr=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Iu=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ty=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Cu=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),Bz=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ze=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ze[t]="%"+e[t>>4]+e[t&15]}function ke(e){return e<2048?Ze[192|e>>6]+Ze[128|e&63]:e<65536?Ze[224|e>>12]+Ze[128|e>>6&63]+Ze[128|e&63]:Ze[240|e>>18]+Ze[128|e>>12&63]+Ze[128|e>>6&63]+Ze[128|e&63]}function Hz(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var Kz=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),Jz=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),Wz=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),Gz=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Xz(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!Wz(e[t])){if(e[t]==="%"&&t+2<e.length&&lr(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Ey(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function Yz(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!Au(c))return;s+=2;continue}if(!Kz(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Ey(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return Ey(i)}function Ru(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&Jz(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(Qz(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!Xz(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=Yz(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function Qz(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function ek(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var tk={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},rk=/[@/?#:]/g,nk=/[@/?#]/g;function Oy(e,t){let r=t?nk:rk;return r.lastIndex=0,e.replace(r,n=>tk[n])}function Ry(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(lr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Iu(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function ok(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(lr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&Iu(i)?t+=i:t+="%"+s,r+=2;continue}}if(Ty(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Iy(o)?n:Ze[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function sk(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(lr(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Ty(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Ze[i];else if(i<55296||i>57343)r+=ke(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=ke(65536+(i-55296<<10)+(a-56320)),o++):r+=ke(65533)}else r+=ke(65533)}}return r}function Nu(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(lr(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ze[s];else if(s<55296||s>57343)r+=ke(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=ke(65536+(s-55296<<10)+(i-56320)),n++):r+=ke(65533)}else r+=ke(65533)}}return r}function Ay(e){return Nu(e,Bz)}function ik(e){return Nu(e,Cu)}function ak(e){return Nu(e,Cu)}function Iy(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function ck(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(lr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));Iu(i)?t+=i:t+="%"+s,r+=2;continue}}if(Cu(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Iy(o)?n:Ze[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function uk(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(lr(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function lk(e){let t=[];if(e.userinfo!==void 0&&(t.push(Ay(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!Au(r)){let n=Ru(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Ry(r,!0),n=Ru(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Oy(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!Vz(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Cy.exports={nonSimpleDomain:Gz,recomposeAuthority:lk,reescapeHostDelimiters:Oy,normalizePercentEncoding:Ry,normalizePathEncoding:ok,serializePathEncoding:sk,normalizeQueryFragmentEncoding:ck,encodeUserinfo:Ay,encodeQuery:ik,encodeFragment:ak,escapePreservingEscapes:uk,removeDotSegments:ek,isIPv4:Au,isUUID:Fz,normalizeIPv6:Ru,stringArrayToHexStripped:Hz}});var Dy=k((a4,My)=>{"use strict";var{isUUID:dk}=ju(),fk=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,pk=["http","https","ws","wss","urn","urn:uuid"];function hk(e){return pk.indexOf(e)!==-1}function Zu(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Ny(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function jy(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function mk(e){return e.secure=Zu(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function gk(e){if((e.port===(Zu(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function yk(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(fk);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Mu(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function _k(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=Mu(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function bk(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!dk(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function wk(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Zy={scheme:"http",domainHost:!0,parse:Ny,serialize:jy},xk={scheme:"https",domainHost:Zy.domainHost,parse:Ny,serialize:jy},ai={scheme:"ws",domainHost:!0,parse:mk,serialize:gk},vk={scheme:"wss",domainHost:ai.domainHost,parse:ai.parse,serialize:ai.serialize},$k={scheme:"urn",parse:yk,serialize:_k,skipNormalize:!0},Sk={scheme:"urn:uuid",parse:bk,serialize:wk,skipNormalize:!0},ci={http:Zy,https:xk,ws:ai,wss:vk,urn:$k,"urn:uuid":Sk};Object.setPrototypeOf(ci,null);function Mu(e){return e&&(ci[e]||ci[e.toLowerCase()])||void 0}My.exports={wsIsSecure:Zu,SCHEMES:ci,isValidSchemeName:hk,getSchemeHandler:Mu}});var Yy=k((c4,di)=>{"use strict";var{normalizeIPv6:Vy,removeDotSegments:no,recomposeAuthority:zk,normalizePercentEncoding:Du,normalizePathEncoding:kk,serializePathEncoding:Ly,normalizeQueryFragmentEncoding:Uy,encodeQuery:Pk,encodeFragment:Ek,reescapeHostDelimiters:Tk,isIPv4:By,nonSimpleDomain:Ok}=ju(),{SCHEMES:Hy,getSchemeHandler:Lu}=Dy(),Ky=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Jy="URI scheme is malformed.";function qy(e){let t=unescape(String(e));if(!Ky.test(t))throw new TypeError(Jy);return t}function Rk(e,t){return typeof e=="string"?e=Dk(e,t):typeof e=="object"&&(e=li(dr(e,t),t)),e}function Ak(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ui(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:p,malformedSchemeSpecific:f,malformedHost:h,malformedScheme:m}=ui(t,n);if(s||d||i||p||a||f||c||h||u||m)throw new Error(o.error||l.error||"URI is malformed.");let y=Wy(o,l,n,!0),w=Lu(r&&r.scheme||y.scheme),v=y.host,z=v!==void 0&&v!==""&&(By(v)||Vy(v).isIPV6);Gy(y,r||{},w,z);let A=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(y.error&&!A)throw new Error(y.error);return n.skipEscape=!0,dr(y,n)}function Wy(e,t,r,n){let o={};return n||(e=li(dr(e,r),r),t=li(dr(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=no(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=no(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=no(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=no(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function Ik(e,t,r){let n=Fy(e,r),o=Fy(t,r);return n!==void 0&&o!==void 0&&n===o}function dr(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=qy(r.scheme));let s=Lu(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=Du(r.path):r.path=Ly(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=qy(r.scheme),o.push(r.scheme,":"));let c=zk(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=no(u)),a&&(u=Ly(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",Pk(r.query)),r.fragment!==void 0&&o.push("#",Ek(r.fragment)),o.join("")}var Ck=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,Nk=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,jk=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function Zk(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function ro(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function Uu(e){return e[0]==="["&&e[e.length-1]==="]"}function Mk(e){let t=e[4];return ro(e[3])||t!==void 0&&!Uu(t)&&ro(t)||ro(e[6])||ro(e[7])||ro(e[8])}function Gy(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!Uu(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&Ok(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ui(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(Nk);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let p=e.match(jk);if(p!==null){let h=p[1],m=h.replace(/[\t\n\r]/g,"");m.length>=2&&(m.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):h.length!==m.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let f=e.match(Ck);if(f){if(n.scheme=f[1],n.userinfo=f[3],n.host=f[4],n.port=parseInt(f[5],10),n.path=f[6]||"",n.query=f[7],n.fragment=f[8],n.scheme!==void 0){let y=unescape(n.scheme);Ky.test(y)?n.scheme=y.toLowerCase():(n.error=n.error||Jy,u=!0)}s=Mk(f),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=f[5]);let h=Zk(n,f);if(h!==void 0&&(n.error=n.error||h,o=!0),n.host)if(By(n.host)===!1){let w=Uu(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,z=Vy(n.host);l=z.isIPV6||z.isIPVFuture===!0,c=v&&(!w||z.error===!0),n.host=l?z.host:z.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let m=Lu(r.scheme||n.scheme);if(c||(a=Gy(n,r,m,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let y=l?n.host:Du(n.host,!0);l||(y=Du(y.toLowerCase())),n.host=Tk(y,l)}(!m||m&&!m.skipNormalize)&&(n.path&&(n.path=kk(n.path)),n.query&&(n.query=Uy(n.query)),n.fragment&&(n.fragment=Uy(n.fragment))),m&&m.parse&&(m.parse(n,r),m===Hy.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function li(e,t){return ui(e,t).parsed}function Dk(e,t){return Xy(e,t).normalized}function Xy(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ui(e,t);return{normalized:n||o||s||i||a?e:dr(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Fy(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:dr(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=Xy(r,t);return o||s||i||a||c?void 0:n}var qu={SCHEMES:Hy,normalize:Rk,resolve:Ak,resolveComponent:Wy,equal:Ik,serialize:dr,parse:li};di.exports=qu;di.exports.default=qu;di.exports.fastUri=qu});var e_=k(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var Qy=Yy();Qy.code='require("ajv/dist/runtime/uri").default';Fu.default=Qy});var c_=k(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.CodeGen=we.Name=we.nil=we.stringify=we.str=we._=we.KeywordCxt=void 0;var Lk=eo();Object.defineProperty(we,"KeywordCxt",{enumerable:!0,get:function(){return Lk.KeywordCxt}});var Xr=M();Object.defineProperty(we,"_",{enumerable:!0,get:function(){return Xr._}});Object.defineProperty(we,"str",{enumerable:!0,get:function(){return Xr.str}});Object.defineProperty(we,"stringify",{enumerable:!0,get:function(){return Xr.stringify}});Object.defineProperty(we,"nil",{enumerable:!0,get:function(){return Xr.nil}});Object.defineProperty(we,"Name",{enumerable:!0,get:function(){return Xr.Name}});Object.defineProperty(we,"CodeGen",{enumerable:!0,get:function(){return Xr.CodeGen}});var Uk=oi(),s_=to(),qk=du(),oo=ii(),Fk=M(),so=Xn(),fi=Gn(),Bu=q(),t_=Py(),Vk=e_(),i_=(e,t)=>new RegExp(e,t);i_.code="new RegExp";var Bk=["removeAdditional","useDefaults","coerceTypes"],Hk=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Kk={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."},Jk={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},r_=200;function Wk(e){var t,r,n,o,s,i,a,c,u,l,d,p,f,h,m,y,w,v,z,A,b,x,T,K,Z;let oe=e.strict,ft=(t=e.code)===null||t===void 0?void 0:t.optimize,Yt=ft===!0||ft===void 0?1:ft||0,vr=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:i_,Tt=(o=e.uriResolver)!==null&&o!==void 0?o:Vk.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:oe)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:oe)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:oe)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:oe)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=e.strictRequired)!==null&&f!==void 0?f:oe)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:Yt,regExp:vr}:{optimize:Yt,regExp:vr},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:r_,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:r_,meta:(w=e.meta)!==null&&w!==void 0?w:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(z=e.inlineRefs)!==null&&z!==void 0?z:!0,schemaId:(A=e.schemaId)!==null&&A!==void 0?A:"$id",addUsedSchema:(b=e.addUsedSchema)!==null&&b!==void 0?b:!0,validateSchema:(x=e.validateSchema)!==null&&x!==void 0?x:!0,validateFormats:(T=e.validateFormats)!==null&&T!==void 0?T:!0,unicodeRegExp:(K=e.unicodeRegExp)!==null&&K!==void 0?K:!0,int32range:(Z=e.int32range)!==null&&Z!==void 0?Z:!0,uriResolver:Tt}}var io=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Wk(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Fk.ValueScope({scope:{},prefixes:Hk,es5:r,lines:n}),this.logger=t1(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,qk.getRules)(),n_.call(this,Kk,t,"NOT SUPPORTED"),n_.call(this,Jk,t,"DEPRECATED","warn"),this._metaOpts=Qk.call(this),t.formats&&Xk.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Yk.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Gk.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=t_;n==="id"&&(o={...t_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof s_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,so.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=o_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new oo.SchemaEnv({schema:{},schemaId:n});if(r=oo.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=o_.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,so.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(n1.call(this,n,r),!r)return(0,Bu.eachItem)(n,s=>Vu.call(this,s)),this;s1.call(this,r);let o={...r,type:(0,fi.getJSONTypes)(r.type),schemaType:(0,fi.getJSONTypes)(r.schemaType)};return(0,Bu.eachItem)(n,o.type.length===0?s=>Vu.call(this,s,o):s=>o.type.forEach(i=>Vu.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=a_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,so.normalizeId)(i||n);let u=so.getSchemaRefs.call(this,t,n);return c=new oo.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):oo.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{oo.compileSchema.call(this,t)}finally{this.opts=r}}};io.ValidationError=Uk.default;io.MissingRefError=s_.default;we.default=io;function n_(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function o_(e){return e=(0,so.normalizeId)(e),this.schemas[e]||this.refs[e]}function Gk(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function Xk(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Yk(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function Qk(){let e={...this.opts};for(let t of Bk)delete e[t];return e}var e1={log(){},warn(){},error(){}};function t1(e){if(e===!1)return e1;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var r1=/^[a-z_$][a-z0-9_$:-]*$/i;function n1(e,t){let{RULES:r}=this;if((0,Bu.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!r1.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function Vu(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,fi.getJSONTypes)(t.type),schemaType:(0,fi.getJSONTypes)(t.schemaType)}};t.before?o1.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function o1(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function s1(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=a_(t)),e.validateSchema=this.compile(t,!0))}var i1={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function a_(e){return{anyOf:[e,i1]}}});var u_=k(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var a1={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Hu.default=a1});var p_=k(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});fr.callRef=fr.getValidate=void 0;var c1=to(),l_=He(),Me=M(),Yr=St(),d_=ii(),pi=q(),u1={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=d_.resolveRef.call(c,u,o,r);if(l===void 0)throw new c1.default(n.opts.uriResolver,o,r);if(l instanceof d_.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return hi(e,i,s,s.$async);let h=t.scopeValue("root",{ref:u});return hi(e,(0,Me._)`${h}.validate`,u,u.$async)}function p(h){let m=f_(e,h);hi(e,m,h,h.$async)}function f(h){let m=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Me.stringify)(h)}:{ref:h}),y=t.name("valid"),w=e.subschema({schema:h,dataTypes:[],schemaPath:Me.nil,topSchemaRef:m,errSchemaPath:r},y);e.mergeEvaluated(w),e.ok(y)}}};function f_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Me._)`${r.scopeValue("wrapper",{ref:t})}.validate`}fr.getValidate=f_;function hi(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Yr.default.this:Me.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,Me._)`await ${(0,l_.callValidateCode)(e,t,u)}`),f(t),i||o.assign(h,!0)},m=>{o.if((0,Me._)`!(${m} instanceof ${s.ValidationError})`,()=>o.throw(m)),p(m),i||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,l_.callValidateCode)(e,t,u),()=>f(t),()=>p(t))}function p(h){let m=(0,Me._)`${h}.errors`;o.assign(Yr.default.vErrors,(0,Me._)`${Yr.default.vErrors} === null ? ${m} : ${Yr.default.vErrors}.concat(${m})`),o.assign(Yr.default.errors,(0,Me._)`${Yr.default.vErrors}.length`)}function f(h){var m;if(!s.opts.unevaluated)return;let y=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=pi.mergeEvaluated.props(o,y.props,s.props));else{let w=o.var("props",(0,Me._)`${h}.evaluated.props`);s.props=pi.mergeEvaluated.props(o,w,s.props,Me.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=pi.mergeEvaluated.items(o,y.items,s.items));else{let w=o.var("items",(0,Me._)`${h}.evaluated.items`);s.items=pi.mergeEvaluated.items(o,w,s.items,Me.Name)}}}fr.callRef=hi;fr.default=u1});var h_=k(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});var l1=u_(),d1=p_(),f1=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",l1.default,d1.default];Ku.default=f1});var m_=k(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var mi=M(),Ht=mi.operators,gi={maximum:{okStr:"<=",ok:Ht.LTE,fail:Ht.GT},minimum:{okStr:">=",ok:Ht.GTE,fail:Ht.LT},exclusiveMaximum:{okStr:"<",ok:Ht.LT,fail:Ht.GTE},exclusiveMinimum:{okStr:">",ok:Ht.GT,fail:Ht.LTE}},p1={message:({keyword:e,schemaCode:t})=>(0,mi.str)`must be ${gi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,mi._)`{comparison: ${gi[e].okStr}, limit: ${t}}`},h1={keyword:Object.keys(gi),type:"number",schemaType:"number",$data:!0,error:p1,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,mi._)`${r} ${gi[t].fail} ${n} || isNaN(${r})`)}};Ju.default=h1});var g_=k(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var ao=M(),m1={message:({schemaCode:e})=>(0,ao.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,ao._)`{multipleOf: ${e}}`},g1={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:m1,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,ao._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,ao._)`${i} !== parseInt(${i})`;e.fail$data((0,ao._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Wu.default=g1});var __=k(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});function y_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}Gu.default=y_;y_.code='require("ajv/dist/runtime/ucs2length").default'});var b_=k(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});var pr=M(),y1=q(),_1=__(),b1={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,pr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,pr._)`{limit: ${e}}`},w1={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:b1,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?pr.operators.GT:pr.operators.LT,i=o.opts.unicode===!1?(0,pr._)`${r}.length`:(0,pr._)`${(0,y1.useFunc)(e.gen,_1.default)}(${r})`;e.fail$data((0,pr._)`${i} ${s} ${n}`)}};Xu.default=w1});var w_=k(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});var x1=He(),v1=q(),Qr=M(),$1={message:({schemaCode:e})=>(0,Qr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Qr._)`{pattern: ${e}}`},S1={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:$1,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Qr._)`new RegExp`:(0,v1.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Qr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Qr._)`!${l}`)}else{let c=(0,x1.usePattern)(e,o);e.fail$data((0,Qr._)`!${c}.test(${r})`)}}};Yu.default=S1});var x_=k(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var co=M(),z1={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,co.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,co._)`{limit: ${e}}`},k1={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:z1,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?co.operators.GT:co.operators.LT;e.fail$data((0,co._)`Object.keys(${r}).length ${o} ${n}`)}};Qu.default=k1});var v_=k(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});var uo=He(),lo=M(),P1=q(),E1={message:({params:{missingProperty:e}})=>(0,lo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,lo._)`{missingProperty: ${e}}`},T1={keyword:"required",type:"object",schemaType:"array",$data:!0,error:E1,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:h}=e.it;for(let m of r)if(f?.[m]===void 0&&!h.has(m)){let y=i.schemaEnv.baseId+i.errSchemaPath,w=`required property "${m}" is not defined at "${y}" (strictRequired)`;(0,P1.checkStrictMode)(i,w,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(lo.nil,d);else for(let f of r)(0,uo.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(c||s){let h=t.let("valid",!0);e.block$data(h,()=>p(f,h)),e.ok(h)}else t.if((0,uo.checkMissingProp)(e,r,f)),(0,uo.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,uo.noPropertyInData)(t,o,f,a.ownProperties),()=>e.error())})}function p(f,h){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(h,(0,uo.propertyInData)(t,o,f,a.ownProperties)),t.if((0,lo.not)(h),()=>{e.error(),t.break()})},lo.nil)}}};el.default=T1});var $_=k(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});var fo=M(),O1={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,fo.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,fo._)`{limit: ${e}}`},R1={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:O1,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?fo.operators.GT:fo.operators.LT;e.fail$data((0,fo._)`${r}.length ${o} ${n}`)}};tl.default=R1});var yi=k(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});var S_=bu();S_.code='require("ajv/dist/runtime/equal").default';rl.default=S_});var z_=k(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});var nl=Gn(),xe=M(),A1=q(),I1=yi(),C1={message:({params:{i:e,j:t}})=>(0,xe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,xe._)`{i: ${e}, j: ${t}}`},N1={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:C1,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,nl.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,xe._)`${i} === false`),e.ok(c);function l(){let h=t.let("i",(0,xe._)`${r}.length`),m=t.let("j");e.setParams({i:h,j:m}),t.assign(c,!0),t.if((0,xe._)`${h} > 1`,()=>(d()?p:f)(h,m))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function p(h,m){let y=t.name("item"),w=(0,nl.checkDataTypes)(u,y,a.opts.strictNumbers,nl.DataType.Wrong),v=t.const("indices",(0,xe._)`{}`);t.for((0,xe._)`;${h}--;`,()=>{t.let(y,(0,xe._)`${r}[${h}]`),t.if(w,(0,xe._)`continue`),u.length>1&&t.if((0,xe._)`typeof ${y} == "string"`,(0,xe._)`${y} += "_"`),t.if((0,xe._)`typeof ${v}[${y}] == "number"`,()=>{t.assign(m,(0,xe._)`${v}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,xe._)`${v}[${y}] = ${h}`)})}function f(h,m){let y=(0,A1.useFunc)(t,I1.default),w=t.name("outer");t.label(w).for((0,xe._)`;${h}--;`,()=>t.for((0,xe._)`${m} = ${h}; ${m}--;`,()=>t.if((0,xe._)`${y}(${r}[${h}], ${r}[${m}])`,()=>{e.error(),t.assign(c,!1).break(w)})))}}};ol.default=N1});var k_=k(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});var sl=M(),j1=q(),Z1=yi(),M1={message:"must be equal to constant",params:({schemaCode:e})=>(0,sl._)`{allowedValue: ${e}}`},D1={keyword:"const",$data:!0,error:M1,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,sl._)`!${(0,j1.useFunc)(t,Z1.default)}(${r}, ${o})`):e.fail((0,sl._)`${s} !== ${r}`)}};il.default=D1});var P_=k(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});var po=M(),L1=q(),U1=yi(),q1={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,po._)`{allowedValues: ${e}}`},F1={keyword:"enum",schemaType:"array",$data:!0,error:q1,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,L1.useFunc)(t,U1.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=t.const("vSchema",s);l=(0,po.or)(...o.map((h,m)=>p(f,m)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,f=>t.if((0,po._)`${u()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function p(f,h){let m=o[h];return typeof m=="object"&&m!==null?(0,po._)`${u()}(${r}, ${f}[${h}])`:(0,po._)`${r} === ${m}`}}};al.default=F1});var E_=k(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var V1=m_(),B1=g_(),H1=b_(),K1=w_(),J1=x_(),W1=v_(),G1=$_(),X1=z_(),Y1=k_(),Q1=P_(),eP=[V1.default,B1.default,H1.default,K1.default,J1.default,W1.default,G1.default,X1.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Y1.default,Q1.default];cl.default=eP});var ll=k(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.validateAdditionalItems=void 0;var hr=M(),ul=q(),tP={message:({params:{len:e}})=>(0,hr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,hr._)`{limit: ${e}}`},rP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:tP,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,ul.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}T_(e,n)}};function T_(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,hr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,hr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,ul.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,hr._)`${a} <= ${t.length}`);r.if((0,hr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:ul.Type.Num},u),i.allErrors||r.if((0,hr.not)(u),()=>r.break())})}}ho.validateAdditionalItems=T_;ho.default=rP});var dl=k(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.validateTuple=void 0;var O_=M(),_i=q(),nP=He(),oP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return R_(e,"additionalItems",t);r.items=!0,!(0,_i.alwaysValidSchema)(r,t)&&e.ok((0,nP.validateArray)(e))}};function R_(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=_i.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,O_._)`${s}.length`);r.forEach((d,p)=>{(0,_i.alwaysValidSchema)(a,d)||(n.if((0,O_._)`${u} > ${p}`,()=>e.subschema({keyword:i,schemaProp:p,dataProp:p},c)),e.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(p.strictTuples&&!m){let y=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,_i.checkStrictMode)(a,y,p.strictTuples)}}}mo.validateTuple=R_;mo.default=oP});var A_=k(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var sP=dl(),iP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,sP.validateTuple)(e,"items")};fl.default=iP});var C_=k(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});var I_=M(),aP=q(),cP=He(),uP=ll(),lP={message:({params:{len:e}})=>(0,I_.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,I_._)`{limit: ${e}}`},dP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:lP,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,aP.alwaysValidSchema)(n,t)&&(o?(0,uP.validateAdditionalItems)(e,o):e.ok((0,cP.validateArray)(e)))}};pl.default=dP});var N_=k(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});var Je=M(),bi=q(),fP={message:({params:{min:e,max:t}})=>t===void 0?(0,Je.str)`must contain at least ${e} valid item(s)`:(0,Je.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Je._)`{minContains: ${e}}`:(0,Je._)`{minContains: ${e}, maxContains: ${t}}`},pP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:fP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,Je._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,bi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,bi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,bi.alwaysValidSchema)(s,r)){let m=(0,Je._)`${l} >= ${i}`;a!==void 0&&(m=(0,Je._)`${m} && ${l} <= ${a}`),e.pass(m);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?f(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,Je._)`${o}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let m=t.name("_valid"),y=t.let("count",0);f(m,()=>t.if(m,()=>h(y)))}function f(m,y){t.forRange("i",0,l,w=>{e.subschema({keyword:"contains",dataProp:w,dataPropType:bi.Type.Num,compositeRule:!0},m),y()})}function h(m){t.code((0,Je._)`${m}++`),a===void 0?t.if((0,Je._)`${m} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,Je._)`${m} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,Je._)`${m} >= ${i}`,()=>t.assign(d,!0)))}}};hl.default=pP});var M_=k(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.validateSchemaDeps=at.validatePropertyDeps=at.error=void 0;var ml=M(),hP=q(),go=He();at.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,ml.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,ml._)`{property: ${e},
|
|
3
|
+
var Lb=Object.create;var ca=Object.defineProperty;var Ub=Object.getOwnPropertyDescriptor;var qb=Object.getOwnPropertyNames;var Fb=Object.getPrototypeOf,Bb=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ua=(e,t)=>{for(var r in t)ca(e,r,{get:t[r],enumerable:!0})},Vb=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qb(t))!Bb.call(e,o)&&o!==r&&ca(e,o,{get:()=>t[o],enumerable:!(n=Ub(t,o))||n.enumerable});return e};var la=(e,t,r)=>(r=e!=null?Lb(Fb(e)):{},Vb(t||!e||!e.__esModule?ca(r,"default",{value:e,enumerable:!0}):r,e));var ao=P(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.regexpCode=Y.getEsmExportName=Y.getProperty=Y.safeStringify=Y.stringify=Y.strConcat=Y.addCodeArg=Y.str=Y._=Y.nil=Y._Code=Y.Name=Y.IDENTIFIER=Y._CodeOrName=void 0;var so=class{};Y._CodeOrName=so;Y.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var dr=class extends so{constructor(t){if(super(),!Y.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Y.Name=dr;var Ye=class extends so{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof dr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Y._Code=Ye;Y.nil=new Ye("");function uy(e,...t){let r=[e[0]],n=0;for(;n<t.length;)hu(r,t[n]),r.push(e[++n]);return new Ye(r)}Y._=uy;var pu=new Ye("+");function ly(e,...t){let r=[io(e[0])],n=0;for(;n<t.length;)r.push(pu),hu(r,t[n]),r.push(pu,io(e[++n]));return wS(r),new Ye(r)}Y.str=ly;function hu(e,t){t instanceof Ye?e.push(...t._items):t instanceof dr?e.push(t):e.push($S(t))}Y.addCodeArg=hu;function wS(e){let t=1;for(;t<e.length-1;){if(e[t]===pu){let r=xS(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function xS(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof dr||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof dr))return`"${e}${t.slice(1)}`}function vS(e,t){return t.emptyStr()?e:e.emptyStr()?t:ly`${e}${t}`}Y.strConcat=vS;function $S(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:io(Array.isArray(e)?e.join(","):e)}function SS(e){return new Ye(io(e))}Y.stringify=SS;function io(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Y.safeStringify=io;function zS(e){return typeof e=="string"&&Y.IDENTIFIER.test(e)?new Ye(`.${e}`):uy`[${e}]`}Y.getProperty=zS;function kS(e){if(typeof e=="string"&&Y.IDENTIFIER.test(e))return new Ye(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}Y.getEsmExportName=kS;function PS(e){return new Ye(e.toString())}Y.regexpCode=PS});var yu=P(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.ValueScope=Ue.ValueScopeName=Ue.Scope=Ue.varKinds=Ue.UsedValueState=void 0;var Le=ao(),mu=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},pi;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(pi||(Ue.UsedValueState=pi={}));Ue.varKinds={const:new Le.Name("const"),let:new Le.Name("let"),var:new Le.Name("var")};var hi=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Le.Name?t:this.name(t)}name(t){return new Le.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Ue.Scope=hi;var mi=class extends Le.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Le._)`.${new Le.Name(r)}[${n}]`}};Ue.ValueScopeName=mi;var ES=(0,Le._)`\n`,gu=class extends hi{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ES:Le.nil}}get(){return this._scope}name(t){return new mi(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Le._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Le.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,pi.Started);let l=r(u);if(l){let d=this.opts.es5?Ue.varKinds.var:Ue.varKinds.const;s=(0,Le._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Le._)`${s}${l}${this.opts._n}`;else throw new mu(u);c.set(u,pi.Completed)})}return s}};Ue.ValueScope=gu});var U=P(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.or=q.and=q.not=q.CodeGen=q.operators=q.varKinds=q.ValueScopeName=q.ValueScope=q.Scope=q.Name=q.regexpCode=q.stringify=q.getProperty=q.nil=q.strConcat=q.str=q._=void 0;var H=ao(),at=yu(),Kt=ao();Object.defineProperty(q,"_",{enumerable:!0,get:function(){return Kt._}});Object.defineProperty(q,"str",{enumerable:!0,get:function(){return Kt.str}});Object.defineProperty(q,"strConcat",{enumerable:!0,get:function(){return Kt.strConcat}});Object.defineProperty(q,"nil",{enumerable:!0,get:function(){return Kt.nil}});Object.defineProperty(q,"getProperty",{enumerable:!0,get:function(){return Kt.getProperty}});Object.defineProperty(q,"stringify",{enumerable:!0,get:function(){return Kt.stringify}});Object.defineProperty(q,"regexpCode",{enumerable:!0,get:function(){return Kt.regexpCode}});Object.defineProperty(q,"Name",{enumerable:!0,get:function(){return Kt.Name}});var bi=yu();Object.defineProperty(q,"Scope",{enumerable:!0,get:function(){return bi.Scope}});Object.defineProperty(q,"ValueScope",{enumerable:!0,get:function(){return bi.ValueScope}});Object.defineProperty(q,"ValueScopeName",{enumerable:!0,get:function(){return bi.ValueScopeName}});Object.defineProperty(q,"varKinds",{enumerable:!0,get:function(){return bi.varKinds}});q.operators={GT:new H._Code(">"),GTE:new H._Code(">="),LT:new H._Code("<"),LTE:new H._Code("<="),EQ:new H._Code("==="),NEQ:new H._Code("!=="),NOT:new H._Code("!"),OR:new H._Code("||"),AND:new H._Code("&&"),ADD:new H._Code("+")};var Tt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},_u=class extends Tt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?at.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=rn(this.rhs,t,r)),this}get names(){return this.rhs instanceof H._CodeOrName?this.rhs.names:{}}},gi=class extends Tt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof H.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=rn(this.rhs,t,r),this}get names(){let t=this.lhs instanceof H.Name?{}:{...this.lhs.names};return _i(t,this.rhs)}},bu=class extends gi{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},wu=class extends Tt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},xu=class extends Tt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},vu=class extends Tt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},$u=class extends Tt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=rn(this.code,t,r),this}get names(){return this.code instanceof H._CodeOrName?this.code.names:{}}},co=class extends Tt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(TS(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>hr(t,r.names),{})}},Ot=class extends co{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Su=class extends co{},tn=class extends Ot{};tn.kind="else";var fr=class e extends Ot{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new tn(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(dy(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=rn(this.condition,t,r),this}get names(){let t=super.names;return _i(t,this.condition),this.else&&hr(t,this.else.names),t}};fr.kind="if";var pr=class extends Ot{};pr.kind="for";var zu=class extends pr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=rn(this.iteration,t,r),this}get names(){return hr(super.names,this.iteration.names)}},ku=class extends pr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?at.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=_i(super.names,this.from);return _i(t,this.to)}},yi=class extends pr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=rn(this.iterable,t,r),this}get names(){return hr(super.names,this.iterable.names)}},uo=class extends Ot{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};uo.kind="func";var lo=class extends co{render(t){return"return "+super.render(t)}};lo.kind="return";var Pu=class extends Ot{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&hr(t,this.catch.names),this.finally&&hr(t,this.finally.names),t}},fo=class extends Ot{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};fo.kind="catch";var po=class extends Ot{render(t){return"finally"+super.render(t)}};po.kind="finally";var Eu=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
+
`:""},this._extScope=t,this._scope=new at.Scope({parent:t}),this._nodes=[new Su]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new _u(t,s,n)),s}const(t,r,n){return this._def(at.varKinds.const,t,r,n)}let(t,r,n){return this._def(at.varKinds.let,t,r,n)}var(t,r,n){return this._def(at.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new gi(t,r,n))}add(t,r){return this._leafNode(new bu(t,q.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==H.nil&&this._leafNode(new $u(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,H.addCodeArg)(r,o));return r.push("}"),new H._Code(r)}if(t,r,n){if(this._blockNode(new fr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new fr(t))}else(){return this._elseNode(new tn)}endIf(){return this._endBlockNode(fr,tn)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new zu(t),r)}forRange(t,r,n,o,s=this.opts.es5?at.varKinds.var:at.varKinds.let){let i=this._scope.toName(t);return this._for(new ku(s,i,r,n),()=>o(i))}forOf(t,r,n,o=at.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof H.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,H._)`${i}.length`,a=>{this.var(s,(0,H._)`${i}[${a}]`),n(s)})}return this._for(new yi("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?at.varKinds.var:at.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,H._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new yi("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(pr)}label(t){return this._leafNode(new wu(t))}break(t){return this._leafNode(new xu(t))}return(t){let r=new lo;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(lo)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Pu;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new fo(s),r(s)}return n&&(this._currNode=o.finally=new po,this.code(n)),this._endBlockNode(fo,po)}throw(t){return this._leafNode(new vu(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=H.nil,n,o){return this._blockNode(new uo(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(uo)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof fr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};q.CodeGen=Eu;function hr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function _i(e,t){return t instanceof H._CodeOrName?hr(e,t.names):e}function rn(e,t,r){if(e instanceof H.Name)return n(e);if(!o(e))return e;return new H._Code(e._items.reduce((s,i)=>(i instanceof H.Name&&(i=n(i)),i instanceof H._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof H._Code&&s._items.some(i=>i instanceof H.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function TS(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function dy(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,H._)`!${Tu(e)}`}q.not=dy;var OS=fy(q.operators.AND);function RS(...e){return e.reduce(OS)}q.and=RS;var AS=fy(q.operators.OR);function CS(...e){return e.reduce(AS)}q.or=CS;function fy(e){return(t,r)=>t===H.nil?r:r===H.nil?t:(0,H._)`${Tu(t)} ${e} ${Tu(r)}`}function Tu(e){return e instanceof H.Name?e:(0,H._)`(${e})`}});var K=P(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.checkStrictMode=B.getErrorPath=B.Type=B.useFunc=B.setEvaluated=B.evaluatedPropsToName=B.mergeEvaluated=B.eachItem=B.unescapeJsonPointer=B.escapeJsonPointer=B.escapeFragment=B.unescapeFragment=B.schemaRefOrVal=B.schemaHasRulesButRef=B.schemaHasRules=B.checkUnknownRules=B.alwaysValidSchema=B.toHash=void 0;var ne=U(),IS=ao();function NS(e){let t={};for(let r of e)t[r]=!0;return t}B.toHash=NS;function jS(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(my(e,t),!gy(t,e.self.RULES.all))}B.alwaysValidSchema=jS;function my(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||by(e,`unknown keyword: "${s}"`)}B.checkUnknownRules=my;function gy(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}B.schemaHasRules=gy;function ZS(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}B.schemaHasRulesButRef=ZS;function DS({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ne._)`${r}`}return(0,ne._)`${e}${t}${(0,ne.getProperty)(n)}`}B.schemaRefOrVal=DS;function MS(e){return yy(decodeURIComponent(e))}B.unescapeFragment=MS;function LS(e){return encodeURIComponent(Ru(e))}B.escapeFragment=LS;function Ru(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}B.escapeJsonPointer=Ru;function yy(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}B.unescapeJsonPointer=yy;function US(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}B.eachItem=US;function py({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ne.Name?(s instanceof ne.Name?e(o,s,i):t(o,s,i),i):s instanceof ne.Name?(t(o,i,s),s):r(s,i);return a===ne.Name&&!(c instanceof ne.Name)?n(o,c):c}}B.mergeEvaluated={props:py({mergeNames:(e,t,r)=>e.if((0,ne._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ne._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ne._)`${r} || {}`).code((0,ne._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ne._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ne._)`${r} || {}`),Au(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:_y}),items:py({mergeNames:(e,t,r)=>e.if((0,ne._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ne._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ne._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ne._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function _y(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,ne._)`{}`);return t!==void 0&&Au(e,r,t),r}B.evaluatedPropsToName=_y;function Au(e,t,r){Object.keys(r).forEach(n=>e.assign((0,ne._)`${t}${(0,ne.getProperty)(n)}`,!0))}B.setEvaluated=Au;var hy={};function qS(e,t){return e.scopeValue("func",{ref:t,code:hy[t.code]||(hy[t.code]=new IS._Code(t.code))})}B.useFunc=qS;var Ou;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ou||(B.Type=Ou={}));function FS(e,t,r){if(e instanceof ne.Name){let n=t===Ou.Num;return r?n?(0,ne._)`"[" + ${e} + "]"`:(0,ne._)`"['" + ${e} + "']"`:n?(0,ne._)`"/" + ${e}`:(0,ne._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ne.getProperty)(e).toString():"/"+Ru(e)}B.getErrorPath=FS;function by(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}B.checkStrictMode=by});var Rt=P(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var Te=U(),BS={data:new Te.Name("data"),valCxt:new Te.Name("valCxt"),instancePath:new Te.Name("instancePath"),parentData:new Te.Name("parentData"),parentDataProperty:new Te.Name("parentDataProperty"),rootData:new Te.Name("rootData"),dynamicAnchors:new Te.Name("dynamicAnchors"),vErrors:new Te.Name("vErrors"),errors:new Te.Name("errors"),this:new Te.Name("this"),self:new Te.Name("self"),scope:new Te.Name("scope"),json:new Te.Name("json"),jsonPos:new Te.Name("jsonPos"),jsonLen:new Te.Name("jsonLen"),jsonPart:new Te.Name("jsonPart")};Cu.default=BS});var ho=P(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.extendErrors=Oe.resetErrorsCount=Oe.reportExtraError=Oe.reportError=Oe.keyword$DataError=Oe.keywordError=void 0;var J=U(),wi=K(),Ne=Rt();Oe.keywordError={message:({keyword:e})=>(0,J.str)`must pass "${e}" keyword validation`};Oe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,J.str)`"${e}" keyword must be ${t} ($data)`:(0,J.str)`"${e}" keyword is invalid ($data)`};function VS(e,t=Oe.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=vy(e,t,r);n??(i||a)?wy(s,c):xy(o,(0,J._)`[${c}]`)}Oe.reportError=VS;function HS(e,t=Oe.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=vy(e,t,r);wy(o,a),s||i||xy(n,Ne.default.vErrors)}Oe.reportExtraError=HS;function KS(e,t){e.assign(Ne.default.errors,t),e.if((0,J._)`${Ne.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,J._)`${Ne.default.vErrors}.length`,t),()=>e.assign(Ne.default.vErrors,null)))}Oe.resetErrorsCount=KS;function JS({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Ne.default.errors,a=>{e.const(i,(0,J._)`${Ne.default.vErrors}[${a}]`),e.if((0,J._)`${i}.instancePath === undefined`,()=>e.assign((0,J._)`${i}.instancePath`,(0,J.strConcat)(Ne.default.instancePath,s.errorPath))),e.assign((0,J._)`${i}.schemaPath`,(0,J.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,J._)`${i}.schema`,r),e.assign((0,J._)`${i}.data`,n))})}Oe.extendErrors=JS;function wy(e,t){let r=e.const("err",t);e.if((0,J._)`${Ne.default.vErrors} === null`,()=>e.assign(Ne.default.vErrors,(0,J._)`[${r}]`),(0,J._)`${Ne.default.vErrors}.push(${r})`),e.code((0,J._)`${Ne.default.errors}++`)}function xy(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,J._)`new ${e.ValidationError}(${t})`):(r.assign((0,J._)`${n}.errors`,t),r.return(!1))}var mr={keyword:new J.Name("keyword"),schemaPath:new J.Name("schemaPath"),params:new J.Name("params"),propertyName:new J.Name("propertyName"),message:new J.Name("message"),schema:new J.Name("schema"),parentSchema:new J.Name("parentSchema")};function vy(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,J._)`{}`:WS(e,t,r)}function WS(e,t,r={}){let{gen:n,it:o}=e,s=[GS(o,r),XS(e,r)];return YS(e,t,s),n.object(...s)}function GS({errorPath:e},{instancePath:t}){let r=t?(0,J.str)`${e}${(0,wi.getErrorPath)(t,wi.Type.Str)}`:e;return[Ne.default.instancePath,(0,J.strConcat)(Ne.default.instancePath,r)]}function XS({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,J.str)`${t}/${e}`;return r&&(o=(0,J.str)`${o}${(0,wi.getErrorPath)(r,wi.Type.Str)}`),[mr.schemaPath,o]}function YS(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([mr.keyword,o],[mr.params,typeof t=="function"?t(e):t||(0,J._)`{}`]),c.messages&&n.push([mr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([mr.schema,i],[mr.parentSchema,(0,J._)`${l}${d}`],[Ne.default.data,s]),u&&n.push([mr.propertyName,u])}});var Sy=P(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.boolOrEmptySchema=nn.topBoolOrEmptySchema=void 0;var QS=ho(),ez=U(),tz=Rt(),rz={message:"boolean schema is false"};function nz(e){let{gen:t,schema:r,validateName:n}=e;r===!1?$y(e,!1):typeof r=="object"&&r.$async===!0?t.return(tz.default.data):(t.assign((0,ez._)`${n}.errors`,null),t.return(!0))}nn.topBoolOrEmptySchema=nz;function oz(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),$y(e)):r.var(t,!0)}nn.boolOrEmptySchema=oz;function $y(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,QS.reportError)(o,rz,void 0,t)}});var Iu=P(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.getRules=on.isJSONType=void 0;var sz=["string","number","integer","boolean","null","object","array"],iz=new Set(sz);function az(e){return typeof e=="string"&&iz.has(e)}on.isJSONType=az;function cz(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}on.getRules=cz});var Nu=P(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.shouldUseRule=Jt.shouldUseGroup=Jt.schemaHasRulesForType=void 0;function uz({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&zy(e,n)}Jt.schemaHasRulesForType=uz;function zy(e,t){return t.rules.some(r=>ky(e,r))}Jt.shouldUseGroup=zy;function ky(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Jt.shouldUseRule=ky});var mo=P(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.reportTypeError=Re.checkDataTypes=Re.checkDataType=Re.coerceAndCheckDataType=Re.getJSONTypes=Re.getSchemaTypes=Re.DataType=void 0;var lz=Iu(),dz=Nu(),fz=ho(),L=U(),Py=K(),sn;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(sn||(Re.DataType=sn={}));function pz(e){let t=Ey(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Re.getSchemaTypes=pz;function Ey(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(lz.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Re.getJSONTypes=Ey;function hz(e,t){let{gen:r,data:n,opts:o}=e,s=mz(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,dz.schemaHasRulesForType)(e,t[0]));if(i){let a=Zu(t,n,o.strictNumbers,sn.Wrong);r.if(a,()=>{s.length?gz(e,t,s):Du(e)})}return i}Re.coerceAndCheckDataType=hz;var Ty=new Set(["string","number","integer","boolean","null"]);function mz(e,t){return t?e.filter(r=>Ty.has(r)||t==="array"&&r==="array"):[]}function gz(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,L._)`typeof ${o}`),a=n.let("coerced",(0,L._)`undefined`);s.coerceTypes==="array"&&n.if((0,L._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,L._)`${o}[0]`).assign(i,(0,L._)`typeof ${o}`).if(Zu(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,L._)`${a} !== undefined`);for(let u of r)(Ty.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Du(e),n.endIf(),n.if((0,L._)`${a} !== undefined`,()=>{n.assign(o,a),yz(e,a)});function c(u){switch(u){case"string":n.elseIf((0,L._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,L._)`"" + ${o}`).elseIf((0,L._)`${o} === null`).assign(a,(0,L._)`""`);return;case"number":n.elseIf((0,L._)`${i} == "boolean" || ${o} === null
|
|
5
|
+
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,L._)`+${o}`);return;case"integer":n.elseIf((0,L._)`${i} === "boolean" || ${o} === null
|
|
6
|
+
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,L._)`+${o}`);return;case"boolean":n.elseIf((0,L._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,L._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,L._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,L._)`${i} === "string" || ${i} === "number"
|
|
7
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,L._)`[${o}]`)}}}function yz({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,L._)`${t} !== undefined`,()=>e.assign((0,L._)`${t}[${r}]`,n))}function ju(e,t,r,n=sn.Correct){let o=n===sn.Correct?L.operators.EQ:L.operators.NEQ,s;switch(e){case"null":return(0,L._)`${t} ${o} null`;case"array":s=(0,L._)`Array.isArray(${t})`;break;case"object":s=(0,L._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,L._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,L._)`typeof ${t} ${o} ${e}`}return n===sn.Correct?s:(0,L.not)(s);function i(a=L.nil){return(0,L.and)((0,L._)`typeof ${t} == "number"`,a,r?(0,L._)`isFinite(${t})`:L.nil)}}Re.checkDataType=ju;function Zu(e,t,r,n){if(e.length===1)return ju(e[0],t,r,n);let o,s=(0,Py.toHash)(e);if(s.array&&s.object){let i=(0,L._)`typeof ${t} != "object"`;o=s.null?i:(0,L._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=L.nil;s.number&&delete s.integer;for(let i in s)o=(0,L.and)(o,ju(i,t,r,n));return o}Re.checkDataTypes=Zu;var _z={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,L._)`{type: ${e}}`:(0,L._)`{type: ${t}}`};function Du(e){let t=bz(e);(0,fz.reportError)(t,_z)}Re.reportTypeError=Du;function bz(e){let{gen:t,data:r,schema:n}=e,o=(0,Py.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Ry=P(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.assignDefaults=void 0;var an=U(),wz=K();function xz(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Oy(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Oy(e,s,o.default))}xi.assignDefaults=xz;function Oy(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,an._)`${s}${(0,an.getProperty)(t)}`;if(o){(0,wz.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,an._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,an._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,an._)`${a} = ${(0,an.stringify)(r)}`)}});var Qe=P(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.validateUnion=ee.validateArray=ee.usePattern=ee.callValidateCode=ee.schemaProperties=ee.allSchemaProperties=ee.noPropertyInData=ee.propertyInData=ee.isOwnProperty=ee.hasPropFunc=ee.reportMissingProp=ee.checkMissingProp=ee.checkReportMissingProp=void 0;var ae=U(),Mu=K(),Wt=Rt(),vz=K();function $z(e,t){let{gen:r,data:n,it:o}=e;r.if(Uu(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,ae._)`${t}`},!0),e.error()})}ee.checkReportMissingProp=$z;function Sz({gen:e,data:t,it:{opts:r}},n,o){return(0,ae.or)(...n.map(s=>(0,ae.and)(Uu(e,t,s,r.ownProperties),(0,ae._)`${o} = ${s}`)))}ee.checkMissingProp=Sz;function zz(e,t){e.setParams({missingProperty:t},!0),e.error()}ee.reportMissingProp=zz;function Ay(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ae._)`Object.prototype.hasOwnProperty`})}ee.hasPropFunc=Ay;function Lu(e,t,r){return(0,ae._)`${Ay(e)}.call(${t}, ${r})`}ee.isOwnProperty=Lu;function kz(e,t,r,n){let o=(0,ae._)`${t}${(0,ae.getProperty)(r)} !== undefined`;return n?(0,ae._)`${o} && ${Lu(e,t,r)}`:o}ee.propertyInData=kz;function Uu(e,t,r,n){let o=(0,ae._)`${t}${(0,ae.getProperty)(r)} === undefined`;return n?(0,ae.or)(o,(0,ae.not)(Lu(e,t,r))):o}ee.noPropertyInData=Uu;function Cy(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ee.allSchemaProperties=Cy;function Pz(e,t){return Cy(t).filter(r=>!(0,Mu.alwaysValidSchema)(e,t[r]))}ee.schemaProperties=Pz;function Ez({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ae._)`${e}, ${t}, ${n}${o}`:t,d=[[Wt.default.instancePath,(0,ae.strConcat)(Wt.default.instancePath,s)],[Wt.default.parentData,i.parentData],[Wt.default.parentDataProperty,i.parentDataProperty],[Wt.default.rootData,Wt.default.rootData]];i.opts.dynamicRef&&d.push([Wt.default.dynamicAnchors,Wt.default.dynamicAnchors]);let p=(0,ae._)`${l}, ${r.object(...d)}`;return c!==ae.nil?(0,ae._)`${a}.call(${c}, ${p})`:(0,ae._)`${a}(${p})`}ee.callValidateCode=Ez;var Tz=(0,ae._)`new RegExp`;function Oz({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ae._)`${o.code==="new RegExp"?Tz:(0,vz.useFunc)(e,o)}(${r}, ${n})`})}ee.usePattern=Oz;function Rz(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,ae._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Mu.Type.Num},s),t.if((0,ae.not)(s),a)})}}ee.validateArray=Rz;function Az(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Mu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,ae._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,ae.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}ee.validateUnion=Az});var jy=P(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.validateKeywordUsage=ht.validSchemaType=ht.funcKeywordCode=ht.macroKeywordCode=void 0;var je=U(),gr=Rt(),Cz=Qe(),Iz=ho();function Nz(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=Ny(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:je.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}ht.macroKeywordCode=Nz;function jz(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;Dz(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=Ny(n,o,u),d=n.let("valid");e.block$data(d,p),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function p(){if(t.errors===!1)m(),t.modifying&&Iy(e),y(()=>e.error());else{let _=t.async?f():h();t.modifying&&Iy(e),y(()=>Zz(e,_))}}function f(){let _=n.let("ruleErrs",null);return n.try(()=>m((0,je._)`await `),v=>n.assign(d,!1).if((0,je._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(_,(0,je._)`${v}.errors`),()=>n.throw(v))),_}function h(){let _=(0,je._)`${l}.errors`;return n.assign(_,null),m(je.nil),_}function m(_=t.async?(0,je._)`await `:je.nil){let v=c.opts.passContext?gr.default.this:gr.default.self,$=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,je._)`${_}${(0,Cz.callValidateCode)(e,l,v,$)}`,t.modifying)}function y(_){var v;n.if((0,je.not)((v=t.valid)!==null&&v!==void 0?v:d),_)}}ht.funcKeywordCode=jz;function Iy(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,je._)`${n.parentData}[${n.parentDataProperty}]`))}function Zz(e,t){let{gen:r}=e;r.if((0,je._)`Array.isArray(${t})`,()=>{r.assign(gr.default.vErrors,(0,je._)`${gr.default.vErrors} === null ? ${t} : ${gr.default.vErrors}.concat(${t})`).assign(gr.default.errors,(0,je._)`${gr.default.vErrors}.length`),(0,Iz.extendErrors)(e)},()=>e.error())}function Dz({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Ny(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,je.stringify)(r)})}function Mz(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}ht.validSchemaType=Mz;function Lz({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ht.validateKeywordUsage=Lz});var Dy=P(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.extendSubschemaMode=Gt.extendSubschemaData=Gt.getSubschema=void 0;var mt=U(),Zy=K();function Uz(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,mt._)`${e.schemaPath}${(0,mt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,mt._)`${e.schemaPath}${(0,mt.getProperty)(t)}${(0,mt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Zy.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Gt.getSubschema=Uz;function qz(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,p=a.let("data",(0,mt._)`${t.data}${(0,mt.getProperty)(r)}`,!0);c(p),e.errorPath=(0,mt.str)`${u}${(0,Zy.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,mt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof mt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Gt.extendSubschemaData=qz;function Fz(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Gt.extendSubschemaMode=Fz});var qu=P((Xj,My)=>{"use strict";My.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var Uy=P((Yj,Ly)=>{"use strict";var Xt=Ly.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};vi(t,n,o,e,"",e)};Xt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Xt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Xt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Xt.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 vi(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Xt.arrayKeywords)for(var p=0;p<d.length;p++)vi(e,t,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Xt.propsKeywords){if(d&&typeof d=="object")for(var f in d)vi(e,t,r,d[f],o+"/"+l+"/"+Bz(f),s,o,l,n,f)}else(l in Xt.keywords||e.allKeys&&!(l in Xt.skipKeywords))&&vi(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function Bz(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var go=P(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.getSchemaRefs=qe.resolveUrl=qe.normalizeId=qe._getFullPath=qe.getFullPath=qe.inlineRef=void 0;var Vz=K(),Hz=qu(),Kz=Uy(),Jz=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Wz(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Fu(e):t?qy(e)<=t:!1}qe.inlineRef=Wz;var Gz=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Fu(e){for(let t in e){if(Gz.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Fu)||typeof r=="object"&&Fu(r))return!0}return!1}function qy(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Jz.has(r)&&(typeof e[r]=="object"&&(0,Vz.eachItem)(e[r],n=>t+=qy(n)),t===1/0))return 1/0}return t}function Fy(e,t="",r){r!==!1&&(t=cn(t));let n=e.parse(t);return By(e,n)}qe.getFullPath=Fy;function By(e,t){return e.serialize(t).split("#")[0]+"#"}qe._getFullPath=By;var Xz=/#\/?$/;function cn(e){return e?e.replace(Xz,""):""}qe.normalizeId=cn;function Yz(e,t,r){return r=cn(r),e.resolve(t,r)}qe.resolveUrl=Yz;var Qz=/^[a-z_][-a-z0-9._]*$/i;function ek(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=cn(e[r]||t),s={"":o},i=Fy(n,o,!1),a={},c=new Set;return Kz(e,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let m=i+p,y=s[h];typeof d[r]=="string"&&(y=_.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[p]=y;function _($){let C=this.opts.uriResolver.resolve;if($=cn(y?C(y,$):$),c.has($))throw l($);c.add($);let w=this.refs[$];return typeof w=="string"&&(w=this.refs[w]),typeof w=="object"?u(d,w.schema,$):$!==cn(m)&&($[0]==="#"?(u(d,a[$],$),a[$]=d):this.refs[$]=m),$}function v($){if(typeof $=="string"){if(!Qz.test($))throw new Error(`invalid anchor "${$}"`);_.call(this,`#${$}`)}}}),a;function u(d,p,f){if(p!==void 0&&!Hz(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}qe.getSchemaRefs=ek});var bo=P(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.getData=Yt.KeywordCxt=Yt.validateFunctionCode=void 0;var Wy=Sy(),Vy=mo(),Vu=Nu(),$i=mo(),tk=Ry(),_o=jy(),Bu=Dy(),A=U(),Z=Rt(),rk=go(),At=K(),yo=ho();function nk(e){if(Yy(e)&&(Qy(e),Xy(e))){ik(e);return}Gy(e,()=>(0,Wy.topBoolOrEmptySchema)(e))}Yt.validateFunctionCode=nk;function Gy({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,A._)`${Z.default.data}, ${Z.default.valCxt}`,n.$async,()=>{e.code((0,A._)`"use strict"; ${Hy(r,o)}`),sk(e,o),e.code(s)}):e.func(t,(0,A._)`${Z.default.data}, ${ok(o)}`,n.$async,()=>e.code(Hy(r,o)).code(s))}function ok(e){return(0,A._)`{${Z.default.instancePath}="", ${Z.default.parentData}, ${Z.default.parentDataProperty}, ${Z.default.rootData}=${Z.default.data}${e.dynamicRef?(0,A._)`, ${Z.default.dynamicAnchors}={}`:A.nil}}={}`}function sk(e,t){e.if(Z.default.valCxt,()=>{e.var(Z.default.instancePath,(0,A._)`${Z.default.valCxt}.${Z.default.instancePath}`),e.var(Z.default.parentData,(0,A._)`${Z.default.valCxt}.${Z.default.parentData}`),e.var(Z.default.parentDataProperty,(0,A._)`${Z.default.valCxt}.${Z.default.parentDataProperty}`),e.var(Z.default.rootData,(0,A._)`${Z.default.valCxt}.${Z.default.rootData}`),t.dynamicRef&&e.var(Z.default.dynamicAnchors,(0,A._)`${Z.default.valCxt}.${Z.default.dynamicAnchors}`)},()=>{e.var(Z.default.instancePath,(0,A._)`""`),e.var(Z.default.parentData,(0,A._)`undefined`),e.var(Z.default.parentDataProperty,(0,A._)`undefined`),e.var(Z.default.rootData,Z.default.data),t.dynamicRef&&e.var(Z.default.dynamicAnchors,(0,A._)`{}`)})}function ik(e){let{schema:t,opts:r,gen:n}=e;Gy(e,()=>{r.$comment&&t.$comment&&t_(e),dk(e),n.let(Z.default.vErrors,null),n.let(Z.default.errors,0),r.unevaluated&&ak(e),e_(e),hk(e)})}function ak(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,A._)`${r}.evaluated`),t.if((0,A._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,A._)`${e.evaluated}.props`,(0,A._)`undefined`)),t.if((0,A._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,A._)`${e.evaluated}.items`,(0,A._)`undefined`))}function Hy(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,A._)`/*# sourceURL=${r} */`:A.nil}function ck(e,t){if(Yy(e)&&(Qy(e),Xy(e))){uk(e,t);return}(0,Wy.boolOrEmptySchema)(e,t)}function Xy({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function Yy(e){return typeof e.schema!="boolean"}function uk(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&t_(e),fk(e),pk(e);let s=n.const("_errs",Z.default.errors);e_(e,s),n.var(t,(0,A._)`${s} === ${Z.default.errors}`)}function Qy(e){(0,At.checkUnknownRules)(e),lk(e)}function e_(e,t){if(e.opts.jtd)return Ky(e,[],!1,t);let r=(0,Vy.getSchemaTypes)(e.schema),n=(0,Vy.coerceAndCheckDataType)(e,r);Ky(e,r,!n,t)}function lk(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,At.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function dk(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,At.checkStrictMode)(e,"default is ignored in the schema root")}function fk(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,rk.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function pk(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function t_({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,A._)`${Z.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,A.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,A._)`${Z.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function hk(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,A._)`${Z.default.errors} === 0`,()=>t.return(Z.default.data),()=>t.throw((0,A._)`new ${o}(${Z.default.vErrors})`)):(t.assign((0,A._)`${n}.errors`,Z.default.vErrors),s.unevaluated&&mk(e),t.return((0,A._)`${Z.default.errors} === 0`))}function mk({gen:e,evaluated:t,props:r,items:n}){r instanceof A.Name&&e.assign((0,A._)`${t}.props`,r),n instanceof A.Name&&e.assign((0,A._)`${t}.items`,n)}function Ky(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,At.schemaHasRulesButRef)(s,l))){o.block(()=>n_(e,"$ref",l.all.$ref.definition));return}c.jtd||gk(e,t),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Vu.shouldUseGroup)(s,p)&&(p.type?(o.if((0,$i.checkDataType)(p.type,i,c.strictNumbers)),Jy(e,p),t.length===1&&t[0]===p.type&&r&&(o.else(),(0,$i.reportTypeError)(e)),o.endIf()):Jy(e,p),a||o.if((0,A._)`${Z.default.errors} === ${n||0}`))}}function Jy(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,tk.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Vu.shouldUseRule)(n,s)&&n_(e,s.keyword,s.definition,t.type)})}function gk(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(yk(e,t),e.opts.allowUnionTypes||_k(e,t),bk(e,e.dataTypes))}function yk(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{r_(e.dataTypes,r)||Hu(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),xk(e,t)}}function _k(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Hu(e,"use allowUnionTypes to allow union type keyword")}function bk(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Vu.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>wk(t,i))&&Hu(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function wk(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function r_(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function xk(e,t){let r=[];for(let n of e.dataTypes)r_(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Hu(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,At.checkStrictMode)(e,t,e.opts.strictTypes)}var Si=class{constructor(t,r,n){if((0,_o.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,At.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",o_(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,_o.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Z.default.errors))}result(t,r,n){this.failResult((0,A.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,A.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,A._)`${r} !== undefined && (${(0,A.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?yo.reportExtraError:yo.reportError)(this,this.def.error,r)}$dataError(){(0,yo.reportError)(this,this.def.$dataError||yo.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,yo.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=A.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=A.nil,r=A.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,A.or)((0,A._)`${o} === undefined`,r)),t!==A.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==A.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,A.or)(i(),a());function i(){if(n.length){if(!(r instanceof A.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,A._)`${(0,$i.checkDataTypes)(c,r,s.opts.strictNumbers,$i.DataType.Wrong)}`}return A.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,A._)`!${c}(${r})`}return A.nil}}subschema(t,r){let n=(0,Bu.getSubschema)(this.it,t);(0,Bu.extendSubschemaData)(n,this.it,t),(0,Bu.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return ck(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=At.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=At.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,A.Name)),!0}};Yt.KeywordCxt=Si;function n_(e,t,r,n){let o=new Si(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,_o.funcKeywordCode)(o,r):"macro"in r?(0,_o.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,_o.funcKeywordCode)(o,r)}var vk=/^\/(?:[^~]|~0|~1)*$/,$k=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function o_(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return Z.default.rootData;if(e[0]==="/"){if(!vk.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=Z.default.rootData}else{let u=$k.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,A._)`${s}${(0,A.getProperty)((0,At.unescapeJsonPointer)(u))}`,i=(0,A._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Yt.getData=o_});var zi=P(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var Ku=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Ju.default=Ku});var wo=P(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});var Wu=go(),Gu=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Wu.resolveUrl)(t,r,n),this.missingSchema=(0,Wu.normalizeId)((0,Wu.getFullPath)(t,this.missingRef))}};Xu.default=Gu});var Pi=P(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.resolveSchema=et.getCompilingSchema=et.resolveRef=et.compileSchema=et.SchemaEnv=void 0;var ct=U(),Sk=zi(),yr=Rt(),ut=go(),s_=K(),zk=bo(),un=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ut.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};et.SchemaEnv=un;function Qu(e){let t=i_.call(this,e);if(t)return t;let r=(0,ut.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new ct.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:Sk.default,code:(0,ct._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:yr.default.data,parentData:yr.default.parentData,parentDataProperty:yr.default.parentDataProperty,dataNames:[yr.default.data],dataPathArr:[ct.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,ct.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:ct.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ct._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,zk.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(yr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${yr.default.self}`,`${yr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:m}=u;f.evaluated={props:h instanceof ct.Name?void 0:h,items:m instanceof ct.Name?void 0:m,dynamicProps:h instanceof ct.Name,dynamicItems:m instanceof ct.Name},f.source&&(f.source.evaluated=(0,ct.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}et.compileSchema=Qu;function kk(e,t,r){var n;r=(0,ut.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=Tk.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new un({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=Pk.call(this,s)}et.resolveRef=kk;function Pk(e){return(0,ut.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Qu.call(this,e)}function i_(e){for(let t of this._compilations)if(Ek(t,e))return t}et.getCompilingSchema=i_;function Ek(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Tk(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||ki.call(this,e,t)}function ki(e,t){let r=this.opts.uriResolver.parse(t),n=(0,ut._getFullPath)(this.opts.uriResolver,r),o=(0,ut.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Yu.call(this,r,e);let s=(0,ut.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=ki.call(this,e,i);return typeof a?.schema!="object"?void 0:Yu.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Qu.call(this,i),s===(0,ut.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,ut.resolveUrl)(this.opts.uriResolver,o,u)),new un({schema:a,schemaId:c,root:e,baseId:o})}return Yu.call(this,r,i)}}et.resolveSchema=ki;var Ok=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Yu(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,s_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Ok.has(a)&&u&&(t=(0,ut.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,s_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,ut.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=ki.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new un({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var a_=P((o4,Rk)=>{Rk.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var sl=P((s4,h_)=>{"use strict";var Ak=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),tl=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),Ck=RegExp.prototype.test.bind(/^\d*$/u),_r=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),rl=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),u_=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),nl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),Ik=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Fe=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Fe[t]="%"+e[t>>4]+e[t&15]}function Ae(e){return e<2048?Fe[192|e>>6]+Fe[128|e&63]:e<65536?Fe[224|e>>12]+Fe[128|e>>6&63]+Fe[128|e&63]:Fe[240|e>>18]+Fe[128|e>>12&63]+Fe[128|e>>6&63]+Fe[128|e&63]}function Nk(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var jk=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),Zk=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),Dk=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),Mk=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Lk(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!Dk(e[t])){if(e[t]==="%"&&t+2<e.length&&_r(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function c_(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function Uk(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!tl(c))return;s+=2;continue}if(!jk(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:c_(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return c_(i)}function el(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&Zk(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(qk(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!Lk(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=Uk(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function qk(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Fk(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var Bk={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Vk=/[@/?#:]/g,Hk=/[@/?#]/g;function l_(e,t){let r=t?Hk:Vk;return r.lastIndex=0,e.replace(r,n=>Bk[n])}function d_(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(_r(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&rl(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function Kk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(_r(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&rl(i)?t+=i:t+="%"+s,r+=2;continue}}if(u_(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=p_(o)?n:Fe[o];else if(o<55296||o>57343)t+=Ae(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=Ae(65536+(o-55296<<10)+(s-56320)),r++):t+=Ae(65533)}else t+=Ae(65533)}}return t}function Jk(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(_r(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),u_(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Fe[i];else if(i<55296||i>57343)r+=Ae(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=Ae(65536+(i-55296<<10)+(a-56320)),o++):r+=Ae(65533)}else r+=Ae(65533)}}return r}function ol(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(_r(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Fe[s];else if(s<55296||s>57343)r+=Ae(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=Ae(65536+(s-55296<<10)+(i-56320)),n++):r+=Ae(65533)}else r+=Ae(65533)}}return r}function f_(e){return ol(e,Ik)}function Wk(e){return ol(e,nl)}function Gk(e){return ol(e,nl)}function p_(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function Xk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(_r(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));rl(i)?t+=i:t+="%"+s,r+=2;continue}}if(nl(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=p_(o)?n:Fe[o];else if(o<55296||o>57343)t+=Ae(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=Ae(65536+(o-55296<<10)+(s-56320)),r++):t+=Ae(65533)}else t+=Ae(65533)}}return t}function Yk(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(_r(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function Qk(e){let t=[];if(e.userinfo!==void 0&&(t.push(f_(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!tl(r)){let n=el(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=d_(r,!0),n=el(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=l_(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!Ck(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}h_.exports={nonSimpleDomain:Mk,recomposeAuthority:Qk,reescapeHostDelimiters:l_,normalizePercentEncoding:d_,normalizePathEncoding:Kk,serializePathEncoding:Jk,normalizeQueryFragmentEncoding:Xk,encodeUserinfo:f_,encodeQuery:Wk,encodeFragment:Gk,escapePreservingEscapes:Yk,removeDotSegments:Fk,isIPv4:tl,isUUID:Ak,normalizeIPv6:el,stringArrayToHexStripped:Nk}});var b_=P((i4,__)=>{"use strict";var{isUUID:e1}=sl(),t1=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,r1=["http","https","ws","wss","urn","urn:uuid"];function n1(e){return r1.indexOf(e)!==-1}function il(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function m_(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function g_(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function o1(e){return e.secure=il(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function s1(e){if((e.port===(il(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function i1(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(t1);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=al(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function a1(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=al(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function c1(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!e1(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function u1(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var y_={scheme:"http",domainHost:!0,parse:m_,serialize:g_},l1={scheme:"https",domainHost:y_.domainHost,parse:m_,serialize:g_},Ei={scheme:"ws",domainHost:!0,parse:o1,serialize:s1},d1={scheme:"wss",domainHost:Ei.domainHost,parse:Ei.parse,serialize:Ei.serialize},f1={scheme:"urn",parse:i1,serialize:a1,skipNormalize:!0},p1={scheme:"urn:uuid",parse:c1,serialize:u1,skipNormalize:!0},Ti={http:y_,https:l1,ws:Ei,wss:d1,urn:f1,"urn:uuid":p1};Object.setPrototypeOf(Ti,null);function al(e){return e&&(Ti[e]||Ti[e.toLowerCase()])||void 0}__.exports={wsIsSecure:il,SCHEMES:Ti,isValidSchemeName:n1,getSchemeHandler:al}});var A_=P((a4,Ai)=>{"use strict";var{normalizeIPv6:S_,removeDotSegments:vo,recomposeAuthority:h1,normalizePercentEncoding:cl,normalizePathEncoding:m1,serializePathEncoding:w_,normalizeQueryFragmentEncoding:x_,encodeQuery:g1,encodeFragment:y1,reescapeHostDelimiters:_1,isIPv4:z_,nonSimpleDomain:b1}=sl(),{SCHEMES:k_,getSchemeHandler:ul}=b_(),P_=/^[A-Za-z][A-Za-z0-9+.-]*$/u,E_="URI scheme is malformed.";function v_(e){let t=unescape(String(e));if(!P_.test(t))throw new TypeError(E_);return t}function w1(e,t){return typeof e=="string"?e=E1(e,t):typeof e=="object"&&(e=Ri(br(e,t),t)),e}function x1(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=Oi(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:p,malformedSchemeSpecific:f,malformedHost:h,malformedScheme:m}=Oi(t,n);if(s||d||i||p||a||f||c||h||u||m)throw new Error(o.error||l.error||"URI is malformed.");let y=T_(o,l,n,!0),_=ul(r&&r.scheme||y.scheme),v=y.host,$=v!==void 0&&v!==""&&(z_(v)||S_(v).isIPV6);O_(y,r||{},_,$);let C=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(y.error&&!C)throw new Error(y.error);return n.skipEscape=!0,br(y,n)}function T_(e,t,r,n){let o={};return n||(e=Ri(br(e,r),r),t=Ri(br(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=vo(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=vo(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=vo(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=vo(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function v1(e,t,r){let n=$_(e,r),o=$_(t,r);return n!==void 0&&o!==void 0&&n===o}function br(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=v_(r.scheme));let s=ul(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=cl(r.path):r.path=w_(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=v_(r.scheme),o.push(r.scheme,":"));let c=h1(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=vo(u)),a&&(u=w_(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",g1(r.query)),r.fragment!==void 0&&o.push("#",y1(r.fragment)),o.join("")}var $1=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,S1=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,z1=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function k1(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function xo(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function ll(e){return e[0]==="["&&e[e.length-1]==="]"}function P1(e){let t=e[4];return xo(e[3])||t!==void 0&&!ll(t)&&xo(t)||xo(e[6])||xo(e[7])||xo(e[8])}function O_(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!ll(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&b1(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function Oi(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(S1);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let p=e.match(z1);if(p!==null){let h=p[1],m=h.replace(/[\t\n\r]/g,"");m.length>=2&&(m.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):h.length!==m.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let f=e.match($1);if(f){if(n.scheme=f[1],n.userinfo=f[3],n.host=f[4],n.port=parseInt(f[5],10),n.path=f[6]||"",n.query=f[7],n.fragment=f[8],n.scheme!==void 0){let y=unescape(n.scheme);P_.test(y)?n.scheme=y.toLowerCase():(n.error=n.error||E_,u=!0)}s=P1(f),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=f[5]);let h=k1(n,f);if(h!==void 0&&(n.error=n.error||h,o=!0),n.host)if(z_(n.host)===!1){let _=ll(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,$=S_(n.host);l=$.isIPV6||$.isIPVFuture===!0,c=v&&(!_||$.error===!0),n.host=l?$.host:$.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let m=ul(r.scheme||n.scheme);if(c||(a=O_(n,r,m,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let y=l?n.host:cl(n.host,!0);l||(y=cl(y.toLowerCase())),n.host=_1(y,l)}(!m||m&&!m.skipNormalize)&&(n.path&&(n.path=m1(n.path)),n.query&&(n.query=x_(n.query)),n.fragment&&(n.fragment=x_(n.fragment))),m&&m.parse&&(m.parse(n,r),m===k_.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function Ri(e,t){return Oi(e,t).parsed}function E1(e,t){return R_(e,t).normalized}function R_(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=Oi(e,t);return{normalized:n||o||s||i||a?e:br(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function $_(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:br(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=R_(r,t);return o||s||i||a||c?void 0:n}var dl={SCHEMES:k_,normalize:w1,resolve:x1,resolveComponent:T_,equal:v1,serialize:br,parse:Ri};Ai.exports=dl;Ai.exports.default=dl;Ai.exports.fastUri=dl});var I_=P(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var C_=A_();C_.code='require("ajv/dist/runtime/uri").default';fl.default=C_});var q_=P(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.CodeGen=ke.Name=ke.nil=ke.stringify=ke.str=ke._=ke.KeywordCxt=void 0;var T1=bo();Object.defineProperty(ke,"KeywordCxt",{enumerable:!0,get:function(){return T1.KeywordCxt}});var ln=U();Object.defineProperty(ke,"_",{enumerable:!0,get:function(){return ln._}});Object.defineProperty(ke,"str",{enumerable:!0,get:function(){return ln.str}});Object.defineProperty(ke,"stringify",{enumerable:!0,get:function(){return ln.stringify}});Object.defineProperty(ke,"nil",{enumerable:!0,get:function(){return ln.nil}});Object.defineProperty(ke,"Name",{enumerable:!0,get:function(){return ln.Name}});Object.defineProperty(ke,"CodeGen",{enumerable:!0,get:function(){return ln.CodeGen}});var O1=zi(),M_=wo(),R1=Iu(),$o=Pi(),A1=U(),So=go(),Ci=mo(),hl=K(),N_=a_(),C1=I_(),L_=(e,t)=>new RegExp(e,t);L_.code="new RegExp";var I1=["removeAdditional","useDefaults","coerceTypes"],N1=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),j1={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."},Z1={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},j_=200;function D1(e){var t,r,n,o,s,i,a,c,u,l,d,p,f,h,m,y,_,v,$,C,w,x,E,W,D;let S=e.strict,T=(t=e.code)===null||t===void 0?void 0:t.optimize,M=T===!0||T===void 0?1:T||0,F=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:L_,V=(o=e.uriResolver)!==null&&o!==void 0?o:C1.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:S)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:S)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:S)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:S)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=e.strictRequired)!==null&&f!==void 0?f:S)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:M,regExp:F}:{optimize:M,regExp:F},loopRequired:(m=e.loopRequired)!==null&&m!==void 0?m:j_,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:j_,meta:(_=e.meta)!==null&&_!==void 0?_:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:($=e.inlineRefs)!==null&&$!==void 0?$:!0,schemaId:(C=e.schemaId)!==null&&C!==void 0?C:"$id",addUsedSchema:(w=e.addUsedSchema)!==null&&w!==void 0?w:!0,validateSchema:(x=e.validateSchema)!==null&&x!==void 0?x:!0,validateFormats:(E=e.validateFormats)!==null&&E!==void 0?E:!0,unicodeRegExp:(W=e.unicodeRegExp)!==null&&W!==void 0?W:!0,int32range:(D=e.int32range)!==null&&D!==void 0?D:!0,uriResolver:V}}var zo=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...D1(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new A1.ValueScope({scope:{},prefixes:N1,es5:r,lines:n}),this.logger=B1(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,R1.getRules)(),Z_.call(this,j1,t,"NOT SUPPORTED"),Z_.call(this,Z1,t,"DEPRECATED","warn"),this._metaOpts=q1.call(this),t.formats&&L1.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&U1.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),M1.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=N_;n==="id"&&(o={...N_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof M_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,So.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=D_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new $o.SchemaEnv({schema:{},schemaId:n});if(r=$o.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=D_.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,So.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(H1.call(this,n,r),!r)return(0,hl.eachItem)(n,s=>pl.call(this,s)),this;J1.call(this,r);let o={...r,type:(0,Ci.getJSONTypes)(r.type),schemaType:(0,Ci.getJSONTypes)(r.schemaType)};return(0,hl.eachItem)(n,o.type.length===0?s=>pl.call(this,s,o):s=>o.type.forEach(i=>pl.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=U_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,So.normalizeId)(i||n);let u=So.getSchemaRefs.call(this,t,n);return c=new $o.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):$o.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{$o.compileSchema.call(this,t)}finally{this.opts=r}}};zo.ValidationError=O1.default;zo.MissingRefError=M_.default;ke.default=zo;function Z_(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function D_(e){return e=(0,So.normalizeId)(e),this.schemas[e]||this.refs[e]}function M1(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function L1(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function U1(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function q1(){let e={...this.opts};for(let t of I1)delete e[t];return e}var F1={log(){},warn(){},error(){}};function B1(e){if(e===!1)return F1;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var V1=/^[a-z_$][a-z0-9_$:-]*$/i;function H1(e,t){let{RULES:r}=this;if((0,hl.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!V1.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function pl(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Ci.getJSONTypes)(t.type),schemaType:(0,Ci.getJSONTypes)(t.schemaType)}};t.before?K1.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function K1(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function J1(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=U_(t)),e.validateSchema=this.compile(t,!0))}var W1={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function U_(e){return{anyOf:[e,W1]}}});var F_=P(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var G1={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ml.default=G1});var K_=P(wr=>{"use strict";Object.defineProperty(wr,"__esModule",{value:!0});wr.callRef=wr.getValidate=void 0;var X1=wo(),B_=Qe(),Be=U(),dn=Rt(),V_=Pi(),Ii=K(),Y1={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=V_.resolveRef.call(c,u,o,r);if(l===void 0)throw new X1.default(n.opts.uriResolver,o,r);if(l instanceof V_.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return Ni(e,i,s,s.$async);let h=t.scopeValue("root",{ref:u});return Ni(e,(0,Be._)`${h}.validate`,u,u.$async)}function p(h){let m=H_(e,h);Ni(e,m,h,h.$async)}function f(h){let m=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Be.stringify)(h)}:{ref:h}),y=t.name("valid"),_=e.subschema({schema:h,dataTypes:[],schemaPath:Be.nil,topSchemaRef:m,errSchemaPath:r},y);e.mergeEvaluated(_),e.ok(y)}}};function H_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}wr.getValidate=H_;function Ni(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?dn.default.this:Be.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,Be._)`await ${(0,B_.callValidateCode)(e,t,u)}`),f(t),i||o.assign(h,!0)},m=>{o.if((0,Be._)`!(${m} instanceof ${s.ValidationError})`,()=>o.throw(m)),p(m),i||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,B_.callValidateCode)(e,t,u),()=>f(t),()=>p(t))}function p(h){let m=(0,Be._)`${h}.errors`;o.assign(dn.default.vErrors,(0,Be._)`${dn.default.vErrors} === null ? ${m} : ${dn.default.vErrors}.concat(${m})`),o.assign(dn.default.errors,(0,Be._)`${dn.default.vErrors}.length`)}function f(h){var m;if(!s.opts.unevaluated)return;let y=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=Ii.mergeEvaluated.props(o,y.props,s.props));else{let _=o.var("props",(0,Be._)`${h}.evaluated.props`);s.props=Ii.mergeEvaluated.props(o,_,s.props,Be.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=Ii.mergeEvaluated.items(o,y.items,s.items));else{let _=o.var("items",(0,Be._)`${h}.evaluated.items`);s.items=Ii.mergeEvaluated.items(o,_,s.items,Be.Name)}}}wr.callRef=Ni;wr.default=Y1});var J_=P(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});var Q1=F_(),eP=K_(),tP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Q1.default,eP.default];gl.default=tP});var W_=P(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});var ji=U(),Qt=ji.operators,Zi={maximum:{okStr:"<=",ok:Qt.LTE,fail:Qt.GT},minimum:{okStr:">=",ok:Qt.GTE,fail:Qt.LT},exclusiveMaximum:{okStr:"<",ok:Qt.LT,fail:Qt.GTE},exclusiveMinimum:{okStr:">",ok:Qt.GT,fail:Qt.LTE}},rP={message:({keyword:e,schemaCode:t})=>(0,ji.str)`must be ${Zi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ji._)`{comparison: ${Zi[e].okStr}, limit: ${t}}`},nP={keyword:Object.keys(Zi),type:"number",schemaType:"number",$data:!0,error:rP,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ji._)`${r} ${Zi[t].fail} ${n} || isNaN(${r})`)}};yl.default=nP});var G_=P(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});var ko=U(),oP={message:({schemaCode:e})=>(0,ko.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,ko._)`{multipleOf: ${e}}`},sP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:oP,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,ko._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,ko._)`${i} !== parseInt(${i})`;e.fail$data((0,ko._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};_l.default=sP});var Y_=P(bl=>{"use strict";Object.defineProperty(bl,"__esModule",{value:!0});function X_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}bl.default=X_;X_.code='require("ajv/dist/runtime/ucs2length").default'});var Q_=P(wl=>{"use strict";Object.defineProperty(wl,"__esModule",{value:!0});var xr=U(),iP=K(),aP=Y_(),cP={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,xr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,xr._)`{limit: ${e}}`},uP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:cP,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?xr.operators.GT:xr.operators.LT,i=o.opts.unicode===!1?(0,xr._)`${r}.length`:(0,xr._)`${(0,iP.useFunc)(e.gen,aP.default)}(${r})`;e.fail$data((0,xr._)`${i} ${s} ${n}`)}};wl.default=uP});var e0=P(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});var lP=Qe(),dP=K(),fn=U(),fP={message:({schemaCode:e})=>(0,fn.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,fn._)`{pattern: ${e}}`},pP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:fP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,fn._)`new RegExp`:(0,dP.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,fn._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,fn._)`!${l}`)}else{let c=(0,lP.usePattern)(e,o);e.fail$data((0,fn._)`!${c}.test(${r})`)}}};xl.default=pP});var t0=P(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});var Po=U(),hP={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Po.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Po._)`{limit: ${e}}`},mP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:hP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Po.operators.GT:Po.operators.LT;e.fail$data((0,Po._)`Object.keys(${r}).length ${o} ${n}`)}};vl.default=mP});var r0=P($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});var Eo=Qe(),To=U(),gP=K(),yP={message:({params:{missingProperty:e}})=>(0,To.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,To._)`{missingProperty: ${e}}`},_P={keyword:"required",type:"object",schemaType:"array",$data:!0,error:yP,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:h}=e.it;for(let m of r)if(f?.[m]===void 0&&!h.has(m)){let y=i.schemaEnv.baseId+i.errSchemaPath,_=`required property "${m}" is not defined at "${y}" (strictRequired)`;(0,gP.checkStrictMode)(i,_,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(To.nil,d);else for(let f of r)(0,Eo.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(c||s){let h=t.let("valid",!0);e.block$data(h,()=>p(f,h)),e.ok(h)}else t.if((0,Eo.checkMissingProp)(e,r,f)),(0,Eo.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,Eo.noPropertyInData)(t,o,f,a.ownProperties),()=>e.error())})}function p(f,h){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(h,(0,Eo.propertyInData)(t,o,f,a.ownProperties)),t.if((0,To.not)(h),()=>{e.error(),t.break()})},To.nil)}}};$l.default=_P});var n0=P(Sl=>{"use strict";Object.defineProperty(Sl,"__esModule",{value:!0});var Oo=U(),bP={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Oo.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Oo._)`{limit: ${e}}`},wP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:bP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Oo.operators.GT:Oo.operators.LT;e.fail$data((0,Oo._)`${r}.length ${o} ${n}`)}};Sl.default=wP});var Di=P(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});var o0=qu();o0.code='require("ajv/dist/runtime/equal").default';zl.default=o0});var s0=P(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});var kl=mo(),Pe=U(),xP=K(),vP=Di(),$P={message:({params:{i:e,j:t}})=>(0,Pe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Pe._)`{i: ${e}, j: ${t}}`},SP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:$P,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,kl.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,Pe._)`${i} === false`),e.ok(c);function l(){let h=t.let("i",(0,Pe._)`${r}.length`),m=t.let("j");e.setParams({i:h,j:m}),t.assign(c,!0),t.if((0,Pe._)`${h} > 1`,()=>(d()?p:f)(h,m))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function p(h,m){let y=t.name("item"),_=(0,kl.checkDataTypes)(u,y,a.opts.strictNumbers,kl.DataType.Wrong),v=t.const("indices",(0,Pe._)`{}`);t.for((0,Pe._)`;${h}--;`,()=>{t.let(y,(0,Pe._)`${r}[${h}]`),t.if(_,(0,Pe._)`continue`),u.length>1&&t.if((0,Pe._)`typeof ${y} == "string"`,(0,Pe._)`${y} += "_"`),t.if((0,Pe._)`typeof ${v}[${y}] == "number"`,()=>{t.assign(m,(0,Pe._)`${v}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,Pe._)`${v}[${y}] = ${h}`)})}function f(h,m){let y=(0,xP.useFunc)(t,vP.default),_=t.name("outer");t.label(_).for((0,Pe._)`;${h}--;`,()=>t.for((0,Pe._)`${m} = ${h}; ${m}--;`,()=>t.if((0,Pe._)`${y}(${r}[${h}], ${r}[${m}])`,()=>{e.error(),t.assign(c,!1).break(_)})))}}};Pl.default=SP});var i0=P(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});var El=U(),zP=K(),kP=Di(),PP={message:"must be equal to constant",params:({schemaCode:e})=>(0,El._)`{allowedValue: ${e}}`},EP={keyword:"const",$data:!0,error:PP,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,El._)`!${(0,zP.useFunc)(t,kP.default)}(${r}, ${o})`):e.fail((0,El._)`${s} !== ${r}`)}};Tl.default=EP});var a0=P(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});var Ro=U(),TP=K(),OP=Di(),RP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Ro._)`{allowedValues: ${e}}`},AP={keyword:"enum",schemaType:"array",$data:!0,error:RP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,TP.useFunc)(t,OP.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=t.const("vSchema",s);l=(0,Ro.or)(...o.map((h,m)=>p(f,m)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,f=>t.if((0,Ro._)`${u()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function p(f,h){let m=o[h];return typeof m=="object"&&m!==null?(0,Ro._)`${u()}(${r}, ${f}[${h}])`:(0,Ro._)`${r} === ${m}`}}};Ol.default=AP});var c0=P(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});var CP=W_(),IP=G_(),NP=Q_(),jP=e0(),ZP=t0(),DP=r0(),MP=n0(),LP=s0(),UP=i0(),qP=a0(),FP=[CP.default,IP.default,NP.default,jP.default,ZP.default,DP.default,MP.default,LP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},UP.default,qP.default];Rl.default=FP});var Cl=P(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});Ao.validateAdditionalItems=void 0;var vr=U(),Al=K(),BP={message:({params:{len:e}})=>(0,vr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,vr._)`{limit: ${e}}`},VP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:BP,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Al.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}u0(e,n)}};function u0(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,vr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,vr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Al.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,vr._)`${a} <= ${t.length}`);r.if((0,vr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:Al.Type.Num},u),i.allErrors||r.if((0,vr.not)(u),()=>r.break())})}}Ao.validateAdditionalItems=u0;Ao.default=VP});var Il=P(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.validateTuple=void 0;var l0=U(),Mi=K(),HP=Qe(),KP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return d0(e,"additionalItems",t);r.items=!0,!(0,Mi.alwaysValidSchema)(r,t)&&e.ok((0,HP.validateArray)(e))}};function d0(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Mi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,l0._)`${s}.length`);r.forEach((d,p)=>{(0,Mi.alwaysValidSchema)(a,d)||(n.if((0,l0._)`${u} > ${p}`,()=>e.subschema({keyword:i,schemaProp:p,dataProp:p},c)),e.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=a,h=r.length,m=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(p.strictTuples&&!m){let y=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,Mi.checkStrictMode)(a,y,p.strictTuples)}}}Co.validateTuple=d0;Co.default=KP});var f0=P(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});var JP=Il(),WP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,JP.validateTuple)(e,"items")};Nl.default=WP});var h0=P(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:!0});var p0=U(),GP=K(),XP=Qe(),YP=Cl(),QP={message:({params:{len:e}})=>(0,p0.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,p0._)`{limit: ${e}}`},eE={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:QP,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,GP.alwaysValidSchema)(n,t)&&(o?(0,YP.validateAdditionalItems)(e,o):e.ok((0,XP.validateArray)(e)))}};jl.default=eE});var m0=P(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});var tt=U(),Li=K(),tE={message:({params:{min:e,max:t}})=>t===void 0?(0,tt.str)`must contain at least ${e} valid item(s)`:(0,tt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,tt._)`{minContains: ${e}}`:(0,tt._)`{minContains: ${e}, maxContains: ${t}}`},rE={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:tE,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,tt._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,Li.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Li.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Li.alwaysValidSchema)(s,r)){let m=(0,tt._)`${l} >= ${i}`;a!==void 0&&(m=(0,tt._)`${m} && ${l} <= ${a}`),e.pass(m);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?f(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,tt._)`${o}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let m=t.name("_valid"),y=t.let("count",0);f(m,()=>t.if(m,()=>h(y)))}function f(m,y){t.forRange("i",0,l,_=>{e.subschema({keyword:"contains",dataProp:_,dataPropType:Li.Type.Num,compositeRule:!0},m),y()})}function h(m){t.code((0,tt._)`${m}++`),a===void 0?t.if((0,tt._)`${m} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,tt._)`${m} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,tt._)`${m} >= ${i}`,()=>t.assign(d,!0)))}}};Zl.default=rE});var _0=P(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.validateSchemaDeps=gt.validatePropertyDeps=gt.error=void 0;var Dl=U(),nE=K(),Io=Qe();gt.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Dl.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Dl._)`{property: ${e},
|
|
8
8
|
missingProperty: ${n},
|
|
9
9
|
depsCount: ${t},
|
|
10
|
-
deps: ${r}}`};var mP={keyword:"dependencies",type:"object",schemaType:"object",error:at.error,code(e){let[t,r]=gP(e);j_(e,t),Z_(e,r)}};function gP({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function j_(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,go.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,go.checkReportMissingProp)(e,u)}):(r.if((0,ml._)`${c} && (${(0,go.checkMissingProp)(e,a,s)})`),(0,go.reportMissingProp)(e,s),r.else())}}at.validatePropertyDeps=j_;function Z_(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,hP.alwaysValidSchema)(s,t[a])||(r.if((0,go.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}at.validateSchemaDeps=Z_;at.default=mP});var L_=k(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});var D_=M(),yP=q(),_P={message:"property name must be valid",params:({params:e})=>(0,D_._)`{propertyName: ${e.propertyName}}`},bP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:_P,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,yP.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,D_.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};gl.default=bP});var _l=k(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});var wi=He(),rt=M(),wP=St(),xi=q(),xP={message:"must NOT have additional properties",params:({params:e})=>(0,rt._)`{additionalProperty: ${e.additionalProperty}}`},vP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:xP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,xi.alwaysValidSchema)(i,r))return;let u=(0,wi.allSchemaProperties)(n.properties),l=(0,wi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,rt._)`${s} === ${wP.default.errors}`);function d(){t.forIn("key",o,y=>{!u.length&&!l.length?h(y):t.if(p(y),()=>h(y))})}function p(y){let w;if(u.length>8){let v=(0,xi.schemaRefOrVal)(i,n.properties,"properties");w=(0,wi.isOwnProperty)(t,v,y)}else u.length?w=(0,rt.or)(...u.map(v=>(0,rt._)`${y} === ${v}`)):w=rt.nil;return l.length&&(w=(0,rt.or)(w,...l.map(v=>(0,rt._)`${(0,wi.usePattern)(e,v)}.test(${y})`))),(0,rt.not)(w)}function f(y){t.code((0,rt._)`delete ${o}[${y}]`)}function h(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,xi.alwaysValidSchema)(i,r)){let w=t.name("valid");c.removeAdditional==="failing"?(m(y,w,!1),t.if((0,rt.not)(w),()=>{e.reset(),f(y)})):(m(y,w),a||t.if((0,rt.not)(w),()=>t.break()))}}function m(y,w,v){let z={keyword:"additionalProperties",dataProp:y,dataPropType:xi.Type.Str};v===!1&&Object.assign(z,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(z,w)}}};yl.default=vP});var F_=k(wl=>{"use strict";Object.defineProperty(wl,"__esModule",{value:!0});var $P=eo(),U_=He(),bl=q(),q_=_l(),SP={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&q_.default.code(new $P.KeywordCxt(s,q_.default,"additionalProperties"));let i=(0,U_.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=bl.mergeEvaluated.props(t,(0,bl.toHash)(i),s.props));let a=i.filter(d=>!(0,bl.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,U_.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};wl.default=SP});var K_=k(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});var V_=He(),vi=M(),B_=q(),H_=q(),zP={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,V_.allSchemaProperties)(r),c=a.filter(m=>(0,B_.alwaysValidSchema)(s,r[m]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof vi.Name)&&(s.props=(0,H_.evaluatedPropsToName)(t,s.props));let{props:d}=s;p();function p(){for(let m of a)u&&f(m),s.allErrors?h(m):(t.var(l,!0),h(m),t.if(l))}function f(m){for(let y in u)new RegExp(m).test(y)&&(0,B_.checkStrictMode)(s,`property ${y} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){t.forIn("key",n,y=>{t.if((0,vi._)`${(0,V_.usePattern)(e,m)}.test(${y})`,()=>{let w=c.includes(m);w||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:y,dataPropType:H_.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,vi._)`${d}[${y}]`,!0):!w&&!s.allErrors&&t.if((0,vi.not)(l),()=>t.break())})})}}};xl.default=zP});var J_=k(vl=>{"use strict";Object.defineProperty(vl,"__esModule",{value:!0});var kP=q(),PP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,kP.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};vl.default=PP});var W_=k($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});var EP=He(),TP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:EP.validateUnion,error:{message:"must match a schema in anyOf"}};$l.default=TP});var G_=k(Sl=>{"use strict";Object.defineProperty(Sl,"__esModule",{value:!0});var $i=M(),OP=q(),RP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,$i._)`{passingSchemas: ${e.passing}}`},AP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:RP,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let p;(0,OP.alwaysValidSchema)(o,l)?t.var(c,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,$i._)`${c} && ${i}`).assign(i,!1).assign(a,(0,$i._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),p&&e.mergeEvaluated(p,$i.Name)})})}}};Sl.default=AP});var X_=k(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});var IP=q(),CP={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,IP.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};zl.default=CP});var e0=k(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});var Si=M(),Q_=q(),NP={message:({params:e})=>(0,Si.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Si._)`{failingKeyword: ${e.ifClause}}`},jP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:NP,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Q_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Y_(n,"then"),s=Y_(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,Si.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let p=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(p,i),d?t.assign(d,(0,Si._)`${l}`):e.setParams({ifClause:l})}}}};function Y_(e,t){let r=e.schema[t];return r!==void 0&&!(0,Q_.alwaysValidSchema)(e,r)}kl.default=jP});var t0=k(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});var ZP=q(),MP={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,ZP.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Pl.default=MP});var r0=k(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});var DP=ll(),LP=A_(),UP=dl(),qP=C_(),FP=N_(),VP=M_(),BP=L_(),HP=_l(),KP=F_(),JP=K_(),WP=J_(),GP=W_(),XP=G_(),YP=X_(),QP=e0(),eE=t0();function tE(e=!1){let t=[WP.default,GP.default,XP.default,YP.default,QP.default,eE.default,BP.default,HP.default,VP.default,KP.default,JP.default];return e?t.push(LP.default,qP.default):t.push(DP.default,UP.default),t.push(FP.default),t}El.default=tE});var n0=k(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});var le=M(),rE={message:({schemaCode:e})=>(0,le.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,le._)`{format: ${e}}`},nE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:rE,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),m=r.const("fDef",(0,le._)`${h}[${i}]`),y=r.let("fType"),w=r.let("format");r.if((0,le._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(y,(0,le._)`${m}.type || "string"`).assign(w,(0,le._)`${m}.validate`),()=>r.assign(y,(0,le._)`"string"`).assign(w,m)),e.fail$data((0,le.or)(v(),z()));function v(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${w}`}function z(){let A=l.$async?(0,le._)`(${m}.async ? await ${w}(${n}) : ${w}(${n}))`:(0,le._)`${w}(${n})`,b=(0,le._)`(typeof ${w} == "function" ? ${A} : ${w}.test(${n}))`;return(0,le._)`${w} && ${w} !== true && ${y} === ${t} && !${b}`}}function f(){let h=d.formats[s];if(!h){v();return}if(h===!0)return;let[m,y,w]=z(h);m===t&&e.pass(A());function v(){if(c.strictSchema===!1){d.logger.warn(b());return}throw new Error(b());function b(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function z(b){let x=b instanceof RegExp?(0,le.regexpCode)(b):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(s)}`:void 0,T=r.scopeValue("formats",{key:s,ref:b,code:x});return typeof b=="object"&&!(b instanceof RegExp)?[b.type||"string",b.validate,(0,le._)`${T}.validate`]:["string",b,T]}function A(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,le._)`await ${w}(${n})`}return typeof y=="function"?(0,le._)`${w}(${n})`:(0,le._)`${w}.test(${n})`}}}};Tl.default=nE});var o0=k(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});var oE=n0(),sE=[oE.default];Ol.default=sE});var s0=k(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.contentVocabulary=en.metadataVocabulary=void 0;en.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];en.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var a0=k(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});var iE=h_(),aE=E_(),cE=r0(),uE=o0(),i0=s0(),lE=[iE.default,aE.default,(0,cE.default)(),uE.default,i0.metadataVocabulary,i0.contentVocabulary];Rl.default=lE});var u0=k(zi=>{"use strict";Object.defineProperty(zi,"__esModule",{value:!0});zi.DiscrError=void 0;var c0;(function(e){e.Tag="tag",e.Mapping="mapping"})(c0||(zi.DiscrError=c0={}))});var d0=k(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});var tn=M(),Al=u0(),l0=ii(),dE=to(),fE=q(),pE={message:({params:{discrError:e,tagName:t}})=>e===Al.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,tn._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},hE={keyword:"discriminator",type:"object",schemaType:"object",error:pE,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,tn._)`${r}${(0,tn.getProperty)(a)}`);t.if((0,tn._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Al.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let f=p();t.if(!1);for(let h in f)t.elseIf((0,tn._)`${u} === ${h}`),t.assign(c,d(f[h]));t.else(),e.error(!1,{discrError:Al.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(f){let h=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:f},h);return e.mergeEvaluated(m,tn.Name),h}function p(){var f;let h={},m=w(o),y=!0;for(let A=0;A<i.length;A++){let b=i[A];if(b?.$ref&&!(0,fE.schemaHasRulesButRef)(b,s.self.RULES)){let T=b.$ref;if(b=l0.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,T),b instanceof l0.SchemaEnv&&(b=b.schema),b===void 0)throw new dE.default(s.opts.uriResolver,s.baseId,T)}let x=(f=b?.properties)===null||f===void 0?void 0:f[a];if(typeof x!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(m||w(b)),v(x,A)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return h;function w({required:A}){return Array.isArray(A)&&A.includes(a)}function v(A,b){if(A.const)z(A.const,b);else if(A.enum)for(let x of A.enum)z(x,b);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function z(A,b){if(typeof A!="string"||A in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[A]=b}}}};Il.default=hE});var f0=k((G4,mE)=>{mE.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var Nl=k((ne,Cl)=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.MissingRefError=ne.ValidationError=ne.CodeGen=ne.Name=ne.nil=ne.stringify=ne.str=ne._=ne.KeywordCxt=ne.Ajv=void 0;var gE=c_(),yE=a0(),_E=d0(),p0=f0(),bE=["/properties"],ki="http://json-schema.org/draft-07/schema",rn=class extends gE.default{_addVocabularies(){super._addVocabularies(),yE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(_E.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(p0,bE):p0;this.addMetaSchema(t,ki,!1),this.refs["http://json-schema.org/schema"]=ki}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ki)?ki:void 0)}};ne.Ajv=rn;Cl.exports=ne=rn;Cl.exports.Ajv=rn;Object.defineProperty(ne,"__esModule",{value:!0});ne.default=rn;var wE=eo();Object.defineProperty(ne,"KeywordCxt",{enumerable:!0,get:function(){return wE.KeywordCxt}});var nn=M();Object.defineProperty(ne,"_",{enumerable:!0,get:function(){return nn._}});Object.defineProperty(ne,"str",{enumerable:!0,get:function(){return nn.str}});Object.defineProperty(ne,"stringify",{enumerable:!0,get:function(){return nn.stringify}});Object.defineProperty(ne,"nil",{enumerable:!0,get:function(){return nn.nil}});Object.defineProperty(ne,"Name",{enumerable:!0,get:function(){return nn.Name}});Object.defineProperty(ne,"CodeGen",{enumerable:!0,get:function(){return nn.CodeGen}});var xE=oi();Object.defineProperty(ne,"ValidationError",{enumerable:!0,get:function(){return xE.default}});var vE=to();Object.defineProperty(ne,"MissingRefError",{enumerable:!0,get:function(){return vE.default}})});var x0=k(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.formatNames=ut.fastFormats=ut.fullFormats=void 0;function ct(e,t){return{validate:e,compare:t}}ut.fullFormats={date:ct(y0,Dl),time:ct(Zl(!0),Ll),"date-time":ct(h0(!0),b0),"iso-time":ct(Zl(),_0),"iso-date-time":ct(h0(),w0),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:EE,"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:NE,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:TE,int32:{type:"number",validate:AE},int64:{type:"number",validate:IE},float:{type:"number",validate:g0},double:{type:"number",validate:g0},password:!0,binary:!0};ut.fastFormats={...ut.fullFormats,date:ct(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Dl),time:ct(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ll),"date-time":ct(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,b0),"iso-time":ct(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,_0),"iso-date-time":ct(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,w0),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};ut.formatNames=Object.keys(ut.fullFormats);function $E(e){return e%4===0&&(e%100!==0||e%400===0)}var SE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,zE=[0,31,28,31,30,31,30,31,31,30,31,30,31];function y0(e){let t=SE.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&$E(r)?29:zE[n])}function Dl(e,t){if(e&&t)return e>t?1:e<t?-1:0}var jl=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Zl(e){return function(r){let n=jl.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function Ll(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function _0(e,t){if(!(e&&t))return;let r=jl.exec(e),n=jl.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var Ml=/t|\s/i;function h0(e){let t=Zl(e);return function(n){let o=n.split(Ml);return o.length===2&&y0(o[0])&&t(o[1])}}function b0(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function w0(e,t){if(!(e&&t))return;let[r,n]=e.split(Ml),[o,s]=t.split(Ml),i=Dl(r,o);if(i!==void 0)return i||Ll(n,s)}var kE=/\/|:/,PE=/^(?:[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 EE(e){return kE.test(e)&&PE.test(e)}var m0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function TE(e){return m0.lastIndex=0,m0.test(e)}var OE=-(2**31),RE=2**31-1;function AE(e){return Number.isInteger(e)&&e<=RE&&e>=OE}function IE(e){return Number.isInteger(e)}function g0(){return!0}var CE=/[^\\]\\Z/;function NE(e){if(CE.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var v0=k(on=>{"use strict";Object.defineProperty(on,"__esModule",{value:!0});on.formatLimitDefinition=void 0;var jE=Nl(),nt=M(),Kt=nt.operators,Pi={formatMaximum:{okStr:"<=",ok:Kt.LTE,fail:Kt.GT},formatMinimum:{okStr:">=",ok:Kt.GTE,fail:Kt.LT},formatExclusiveMaximum:{okStr:"<",ok:Kt.LT,fail:Kt.GTE},formatExclusiveMinimum:{okStr:">",ok:Kt.GT,fail:Kt.LTE}},ZE={message:({keyword:e,schemaCode:t})=>(0,nt.str)`should be ${Pi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,nt._)`{comparison: ${Pi[e].okStr}, limit: ${t}}`};on.formatLimitDefinition={keyword:Object.keys(Pi),type:"string",schemaType:"string",$data:!0,error:ZE,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new jE.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=t.const("fmt",(0,nt._)`${p}[${c.schemaCode}]`);e.fail$data((0,nt.or)((0,nt._)`typeof ${f} != "object"`,(0,nt._)`${f} instanceof RegExp`,(0,nt._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let h=t.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,nt._)`${i.code.formats}${(0,nt.getProperty)(p)}`:void 0});e.fail$data(d(h))}function d(p){return(0,nt._)`${p}.compare(${r}, ${n}) ${Pi[o].fail} 0`}},dependencies:["format"]};var ME=e=>(e.addKeyword(on.formatLimitDefinition),e);on.default=ME});var k0=k((yo,z0)=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});var sn=x0(),DE=v0(),Ul=M(),$0=new Ul.Name("fullFormats"),LE=new Ul.Name("fastFormats"),ql=(e,t={keywords:!0})=>{if(Array.isArray(t))return S0(e,t,sn.fullFormats,$0),e;let[r,n]=t.mode==="fast"?[sn.fastFormats,LE]:[sn.fullFormats,$0],o=t.formats||sn.formatNames;return S0(e,o,r,n),t.keywords&&(0,DE.default)(e),e};ql.get=(e,t="full")=>{let n=(t==="fast"?sn.fastFormats:sn.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function S0(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Ul._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}z0.exports=yo=ql;Object.defineProperty(yo,"__esModule",{value:!0});yo.default=ql});var A0=k(Fl=>{"use strict";var T0=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,FE=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,O0=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,VE=/\\([\u000b\u0020-\u00ff])/g,BE=/([\\"])/g,R0=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;Fl.format=HE;Fl.parse=KE;function HE(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R0.test(r))throw new TypeError("invalid type");var n=r;if(t&&typeof t=="object")for(var o,s=Object.keys(t).sort(),i=0;i<s.length;i++){if(o=s[i],!O0.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+WE(t[o])}return n}function KE(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?JE(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=r!==-1?t.slice(0,r).trim():t.trim();if(!R0.test(n))throw new TypeError("invalid media type");var o=new GE(n.toLowerCase());if(r!==-1){var s,i,a;for(T0.lastIndex=r;i=T0.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,s=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(VE,"$1"))),o.parameters[s]=a}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}function JE(e){var t;if(typeof e.getHeader=="function"?t=e.getHeader("content-type"):typeof e.headers=="object"&&(t=e.headers&&e.headers["content-type"]),typeof t!="string")throw new TypeError("content-type header is missing from object");return t}function WE(e){var t=String(e);if(O0.test(t))return t;if(t.length>0&&!FE.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(BE,"\\$1")+'"'}function GE(e){this.parameters=Object.create(null),this.type=e}});import{webcrypto as tO}from"node:crypto";import{hostname as rO}from"node:os";import{parseArgs as nO}from"node:util";var C={};oa(C,{BIGINT_FORMAT_RANGES:()=>Jo,CONSTANT_CATCH:()=>jd,Class:()=>ca,NUMBER_FORMAT_RANGES:()=>hn,aborted:()=>We,allowsEval:()=>pa,assert:()=>Lb,assertEqual:()=>jb,assertIs:()=>Mb,assertNever:()=>Db,assertNotEqual:()=>Zb,assignProp:()=>De,attachSchema:()=>Go,base64ToUint8Array:()=>Cd,base64urlToUint8Array:()=>sw,cached:()=>kr,captureStackTrace:()=>Ho,cleanEnum:()=>ow,cleanRegex:()=>pn,clone:()=>qe,cloneDef:()=>Fb,codePointLength:()=>mn,constantCatch:()=>Zd,createTransparentProxy:()=>Wb,defineLazy:()=>Pd,defineLazyInternal:()=>V,derived:()=>uw,esc:()=>da,escapeRegex:()=>mt,explicitlyAborted:()=>ga,extend:()=>Yb,finalizeIssue:()=>Ge,floatSafeRemainder:()=>la,getElementAtPath:()=>Vb,getEnumValues:()=>Sr,getLengthableOrigin:()=>gn,getParsedType:()=>Jb,getSizableOrigin:()=>Id,hexToUint8Array:()=>aw,hide:()=>Xo,installLazyProp:()=>pw,isObject:()=>er,isPlainObject:()=>At,issue:()=>Er,joinValues:()=>Bo,jsonStringifyReplacer:()=>zr,members:()=>_a,merge:()=>ew,mergeDefs:()=>ht,normalizeParams:()=>R,nullish:()=>ua,numKeys:()=>Kb,objectClone:()=>Ub,omit:()=>Xb,optionalKeys:()=>ma,own:()=>Rt,parsedType:()=>ya,partial:()=>tw,pick:()=>Gb,prefixIssues:()=>gt,primitiveTypes:()=>Rd,promiseAllObject:()=>Bb,propertyKeyTypes:()=>ha,randomString:()=>Hb,rawShape:()=>Pr,required:()=>rw,safeExtend:()=>Qb,shallowClone:()=>Od,slugify:()=>fa,stringifyPrimitive:()=>Ko,toZod:()=>kd,uint8ArrayToBase64:()=>Nd,uint8ArrayToBase64url:()=>iw,uint8ArrayToHex:()=>cw,unwrapMessage:()=>$r});function jb(e){return e}function Zb(e){return e}function kd(){return e=>e}function Mb(e){}function Db(e){throw new Error("Unexpected value in exhaustive check")}function Lb(e){}function Sr(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Bo(e,t="|"){return e.map(r=>Ko(r)).join(t)}function zr(e,t){return typeof t=="bigint"?t.toString():t}var aa=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function kr(e){return new aa(e)}function ua(e){return e==null}function pn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function la(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var zd=Symbol("evaluating");function Pd(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==zd)return n===void 0&&(n=zd,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Ub(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function De(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Pr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function pt(e){return Pr(e._zod.def)??e._zod.def.shape}function Ed(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return De(this,t,n),n},enumerable:!0,configurable:!0})}function Td(e,t,r){t in e?De(e,t,r):e[t]=r}function Qt(e,t,r,n){let o=pt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?Ed(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):Td(e,s,n?n(i.value,s):i.value))}}function qb(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?Ed(e,r,()=>t[r]):Td(e,r,n.value))}}function ht(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Fb(e){return ht(e._zod.def)}function Vb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Bb(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function Hb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function da(e){return JSON.stringify(e)}function fa(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ho="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function er(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var pa=kr(()=>{if(Re.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function At(e){if(er(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(er(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Od(e){return At(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Kb(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Jb=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ha=new Set(["string","number","symbol"]),Rd=new Set(["string","number","bigint","boolean","symbol","undefined"]);function mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qe(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function R(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Wb(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function Ko(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ma(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var hn={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]},Jo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Gb(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return Qt(s,e,Wo(e,t)),qe(e,ht(r,{shape:s,checks:[]}))}function Wo(e,t){let r=pt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function Xb(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Wo(e,t)),i={};return Qt(i,e,Reflect.ownKeys(pt(e)).filter(a=>!s.has(a))),qe(e,ht(r,{shape:i,checks:[]}))}function Yb(e,t){if(!At(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=pt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qe(e,ht(e._zod.def,{shape:Ad(e,t)}))}function Ad(e,t){let r={};return Qt(r,e,Reflect.ownKeys(pt(e))),qb(r,t),r}function Qb(e,t){if(!At(t))throw new Error("Invalid input to safeExtend: expected a plain object");return qe(e,ht(e._zod.def,{shape:Ad(e,t)}))}function ew(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Qt(r,e,Reflect.ownKeys(pt(e))),Qt(r,t,Reflect.ownKeys(pt(t)));let n=ht(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return qe(e,n)}function tw(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Wo(t,r)):void 0,c={};return Qt(c,t,Reflect.ownKeys(pt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),qe(t,ht(t._zod.def,{shape:c,checks:[]}))}function rw(e,t,r){let n=r?new Set(Wo(t,r)):void 0,o={};return Qt(o,t,Reflect.ownKeys(pt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),qe(t,ht(t._zod.def,{shape:o}))}function We(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ga(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function gt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function $r(e){return typeof e=="string"?e:e?.message}function Go(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Ge(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:$r(e.inst?._zod.def?.error?.(e))??$r(s?.(e))??$r(t?.error?.(e))??$r(r.customError?.(e))??$r(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Id(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var nw=/[\uD800-\uDBFF]/;function mn(e){let t=e.length;if(!nw.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function gn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ya(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Er(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function ow(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Cd(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Nd(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function sw(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Cd(t+r)}function iw(e){return Nd(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function aw(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function cw(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ca=class{constructor(...t){}};function _a(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):lw(e,r,n.value)}}function Rt(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Xo(e,t,r){return Rt(e,t,r,!1)}function uw(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Rt(this,r,n(this))},set(o){Rt(this,r,o)}})}return t}function lw(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Rt(this,t,r.bind(this))},set(n){Rt(this,t,n)}})}function dw(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var ia,Ot=!1,fw={configurable:!0,get(){Ot=!0}};function V(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&ia!==e._zod){ia=void 0;return}ia=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,fw);let o=Ot;Ot=!1;try{let s=r(this);return Ot?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Ot=Ot||o,s}catch(s){throw delete this[t],Ot=Ot||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function pw(e,t,r,n){let o=dw(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var jd="~constantCatch";function Zd(e){let t=()=>e;return t[jd]=!0,t}var Md,wa=Object.freeze({status:"aborted"}),ba={value:void 0,enumerable:!1},Dd="captureStackTrace"in Error?Error:null;function hw(e){let t=Dd;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Dd=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function _(e,t,r,n){let o={};function s(p){this.def=p,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(p,f){if(p._zod){if(p._zod.traits.has(e))return}else{ba.value=new s(f);try{Object.defineProperty(p,"_zod",ba)}finally{ba.value=void 0}}if(p._zod.traits.add(e),t(p,f),a){let m=Object.getPrototypeOf(p),y=p._zod.constr.prototype,w=m;for(;w&&w!==y;)w=Object.getPrototypeOf(w);let v=w??m;a.has(v)||(a.add(v),_a(v,i))}let h=d.prototype;for(let m in h)Object.prototype.hasOwnProperty.call(h,m)&&(m in p||(p[m]=h[m].bind(p)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(p){let f=n?.Parent?hw(l):this;c(f,p);let h=f._zod.deferred;if(h){for(let y of h)y();f._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(f),f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>n?.Parent&&p instanceof n.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Xe=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Tr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Md=globalThis).__zod_globalConfig??(Md.__zod_globalConfig={});var Re=globalThis.__zod_globalConfig;function Ae(e){return e&&Object.assign(Re,e),Re}function mw(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,zr,2)),e.message}function gw(e){this._zod.message=e}var yw={get:mw,set:gw,enumerable:!0,configurable:!0},va={value:void 0,enumerable:!1},Ld=new WeakSet([Object.prototype,Error.prototype]),Ud=(e,t)=>{e.name="$ZodError",va.value=t,Object.defineProperty(e,"issues",va),va.value=void 0,Object.defineProperty(e,"message",yw);let r=Object.getPrototypeOf(e);Ld.has(r)||(Ld.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},qd=_("$ZodError",Ud),Fd=_("$ZodError",Ud,void 0,{Parent:Error});function _w(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function $a(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?_w(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Sa(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=c[l];d&&p._errors.push(t(i)),c=p,u++}}}};return n(e),r}function Yo(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Qo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Xe;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw Ho(c,s?.callee??t),c}return a.value};return t};var es=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw Ho(c,s?.callee??t),c}return a.value};return t};var yn=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Xe;return s.issues.length?Vd(e,s.issues,o):{success:!0,data:s.value}},za=yn(Fd);function Vd(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>Ge(o,r,Ae()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var ts=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Vd(e,s.issues,o):{success:!0,data:s.value}};var ww=Symbol.for("zod.compile.invalid"),xw=Symbol.for("zod.compile.fallback"),rs=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==ww)return!0;if(n.definite===!0&&r===void 0)return!1}return vw(e,t,r)});function vw(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[xw]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new Xe;return s.issues.length===0}var ns=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Bd=e=>{let t=Qo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Yo(r,i))};return r};var Hd=e=>{let t=Qo(e),r=(n,o,s,i)=>t(n,o,s,Yo(r,i));return r};var Kd=e=>{let t=es(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Yo(r,i))};return r};var Jd=e=>{let t=es(e),r=async(n,o,s,i)=>await t(n,o,s,Yo(r,i));return r};var Wd=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return yn(e)(t,r,o)};var Gd=e=>(t,r,n)=>yn(e)(t,r,n);var Xd=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return ts(e)(t,r,o)};var Yd=e=>async(t,r,n)=>ts(e)(t,r,n);var Qd=/^[cC][0-9a-z]{6,}$/,ef=/^[0-9a-z]+$/,tf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,rf=/^[0-9a-vA-V]{20}$/,nf=/^[A-Za-z0-9]{27}$/,of=/^[a-zA-Z0-9_-]{21}$/;function sf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var af=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var cf=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Pa=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var uf=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var $w="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function lf(){return new RegExp($w,"u")}var df=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ff=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var pf=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,mf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,gf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var yf=/^https?$/,_f=/^\+[1-9]\d{6,14}$/;var bf="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Sw(e){return new RegExp(`^${e}$`)}var wf=Sw(bf);function ka(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function xf(e){return new RegExp(`^${ka(e)}$`)}function vf(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${ka({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${ka({precision:e.precision})}`:r;return new RegExp(`^${bf}T(?:${n})$`)}var $f=/^[\s\S]{0,}$/;var Sf=/^-?\d+n?$/,Ea=/^-?\d+$/,_n=/^-?\d+(?:\.\d+)?$/,zf=/^(?:true|false)$/i,kf=/^null$/i;var Pf=/^[^A-Z]*$/,Ef=/^[^a-z]*$/;var me=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ta=e=>{let t=e.value;return!ua(t)&&t.length!==void 0},os={number:"number",bigint:"bigint",object:"date"},Oa=_("$ZodCheckLessThan",(e,t)=>{me.init(e,t);let r=os[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:os[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ra=_("$ZodCheckGreaterThan",(e,t)=>{me.init(e,t);let r=os[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:os[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Tf=_("$ZodCheckMultipleOf",(e,t)=>{me.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):la(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Of=_("$ZodCheckNumberFormat",(e,t)=>{me.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=hn[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Rf=_("$ZodCheckMaxLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?mn(o):s)<=t.maximum)return;let a=gn(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Af=_("$ZodCheckMinLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?mn(o):s)>=t.minimum)return;let a=gn(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),If=_("$ZodCheckLengthEquals",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?mn(o):s;if(i===t.length)return;let a=gn(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bn=_("$ZodCheckStringFormat",(e,t)=>{var r,n;me.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Cf=_("$ZodCheckRegex",(e,t)=>{bn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Nf=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pf),bn.init(e,t)}),jf=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ef),bn.init(e,t)}),Zf=_("$ZodCheckIncludes",(e,t)=>{me.init(e,t);let r=mt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Mf=_("$ZodCheckStartsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`^${mt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Df=_("$ZodCheckEndsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`.*${mt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Lf=_("$ZodCheckOverwrite",(e,t)=>{me.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ss=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
10
|
+
deps: ${r}}`};var oE={keyword:"dependencies",type:"object",schemaType:"object",error:gt.error,code(e){let[t,r]=sE(e);g0(e,t),y0(e,r)}};function sE({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function g0(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,Io.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Io.checkReportMissingProp)(e,u)}):(r.if((0,Dl._)`${c} && (${(0,Io.checkMissingProp)(e,a,s)})`),(0,Io.reportMissingProp)(e,s),r.else())}}gt.validatePropertyDeps=g0;function y0(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,nE.alwaysValidSchema)(s,t[a])||(r.if((0,Io.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}gt.validateSchemaDeps=y0;gt.default=oE});var w0=P(Ml=>{"use strict";Object.defineProperty(Ml,"__esModule",{value:!0});var b0=U(),iE=K(),aE={message:"property name must be valid",params:({params:e})=>(0,b0._)`{propertyName: ${e.propertyName}}`},cE={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:aE,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,iE.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,b0.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Ml.default=cE});var Ul=P(Ll=>{"use strict";Object.defineProperty(Ll,"__esModule",{value:!0});var Ui=Qe(),lt=U(),uE=Rt(),qi=K(),lE={message:"must NOT have additional properties",params:({params:e})=>(0,lt._)`{additionalProperty: ${e.additionalProperty}}`},dE={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:lE,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,qi.alwaysValidSchema)(i,r))return;let u=(0,Ui.allSchemaProperties)(n.properties),l=(0,Ui.allSchemaProperties)(n.patternProperties);d(),e.ok((0,lt._)`${s} === ${uE.default.errors}`);function d(){t.forIn("key",o,y=>{!u.length&&!l.length?h(y):t.if(p(y),()=>h(y))})}function p(y){let _;if(u.length>8){let v=(0,qi.schemaRefOrVal)(i,n.properties,"properties");_=(0,Ui.isOwnProperty)(t,v,y)}else u.length?_=(0,lt.or)(...u.map(v=>(0,lt._)`${y} === ${v}`)):_=lt.nil;return l.length&&(_=(0,lt.or)(_,...l.map(v=>(0,lt._)`${(0,Ui.usePattern)(e,v)}.test(${y})`))),(0,lt.not)(_)}function f(y){t.code((0,lt._)`delete ${o}[${y}]`)}function h(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,qi.alwaysValidSchema)(i,r)){let _=t.name("valid");c.removeAdditional==="failing"?(m(y,_,!1),t.if((0,lt.not)(_),()=>{e.reset(),f(y)})):(m(y,_),a||t.if((0,lt.not)(_),()=>t.break()))}}function m(y,_,v){let $={keyword:"additionalProperties",dataProp:y,dataPropType:qi.Type.Str};v===!1&&Object.assign($,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema($,_)}}};Ll.default=dE});var $0=P(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});var fE=bo(),x0=Qe(),ql=K(),v0=Ul(),pE={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&v0.default.code(new fE.KeywordCxt(s,v0.default,"additionalProperties"));let i=(0,x0.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=ql.mergeEvaluated.props(t,(0,ql.toHash)(i),s.props));let a=i.filter(d=>!(0,ql.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,x0.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Fl.default=pE});var P0=P(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});var S0=Qe(),Fi=U(),z0=K(),k0=K(),hE={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,S0.allSchemaProperties)(r),c=a.filter(m=>(0,z0.alwaysValidSchema)(s,r[m]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof Fi.Name)&&(s.props=(0,k0.evaluatedPropsToName)(t,s.props));let{props:d}=s;p();function p(){for(let m of a)u&&f(m),s.allErrors?h(m):(t.var(l,!0),h(m),t.if(l))}function f(m){for(let y in u)new RegExp(m).test(y)&&(0,z0.checkStrictMode)(s,`property ${y} matches pattern ${m} (use allowMatchingProperties)`)}function h(m){t.forIn("key",n,y=>{t.if((0,Fi._)`${(0,S0.usePattern)(e,m)}.test(${y})`,()=>{let _=c.includes(m);_||e.subschema({keyword:"patternProperties",schemaProp:m,dataProp:y,dataPropType:k0.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,Fi._)`${d}[${y}]`,!0):!_&&!s.allErrors&&t.if((0,Fi.not)(l),()=>t.break())})})}}};Bl.default=hE});var E0=P(Vl=>{"use strict";Object.defineProperty(Vl,"__esModule",{value:!0});var mE=K(),gE={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,mE.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Vl.default=gE});var T0=P(Hl=>{"use strict";Object.defineProperty(Hl,"__esModule",{value:!0});var yE=Qe(),_E={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:yE.validateUnion,error:{message:"must match a schema in anyOf"}};Hl.default=_E});var O0=P(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});var Bi=U(),bE=K(),wE={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Bi._)`{passingSchemas: ${e.passing}}`},xE={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:wE,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let p;(0,bE.alwaysValidSchema)(o,l)?t.var(c,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,Bi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Bi._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),p&&e.mergeEvaluated(p,Bi.Name)})})}}};Kl.default=xE});var R0=P(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});var vE=K(),$E={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,vE.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Jl.default=$E});var I0=P(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});var Vi=U(),C0=K(),SE={message:({params:e})=>(0,Vi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Vi._)`{failingKeyword: ${e.ifClause}}`},zE={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:SE,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,C0.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=A0(n,"then"),s=A0(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,Vi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let p=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(p,i),d?t.assign(d,(0,Vi._)`${l}`):e.setParams({ifClause:l})}}}};function A0(e,t){let r=e.schema[t];return r!==void 0&&!(0,C0.alwaysValidSchema)(e,r)}Wl.default=zE});var N0=P(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});var kE=K(),PE={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,kE.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Gl.default=PE});var j0=P(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});var EE=Cl(),TE=f0(),OE=Il(),RE=h0(),AE=m0(),CE=_0(),IE=w0(),NE=Ul(),jE=$0(),ZE=P0(),DE=E0(),ME=T0(),LE=O0(),UE=R0(),qE=I0(),FE=N0();function BE(e=!1){let t=[DE.default,ME.default,LE.default,UE.default,qE.default,FE.default,IE.default,NE.default,CE.default,jE.default,ZE.default];return e?t.push(TE.default,RE.default):t.push(EE.default,OE.default),t.push(AE.default),t}Xl.default=BE});var Z0=P(Yl=>{"use strict";Object.defineProperty(Yl,"__esModule",{value:!0});var me=U(),VE={message:({schemaCode:e})=>(0,me.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,me._)`{format: ${e}}`},HE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:VE,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),m=r.const("fDef",(0,me._)`${h}[${i}]`),y=r.let("fType"),_=r.let("format");r.if((0,me._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(y,(0,me._)`${m}.type || "string"`).assign(_,(0,me._)`${m}.validate`),()=>r.assign(y,(0,me._)`"string"`).assign(_,m)),e.fail$data((0,me.or)(v(),$()));function v(){return c.strictSchema===!1?me.nil:(0,me._)`${i} && !${_}`}function $(){let C=l.$async?(0,me._)`(${m}.async ? await ${_}(${n}) : ${_}(${n}))`:(0,me._)`${_}(${n})`,w=(0,me._)`(typeof ${_} == "function" ? ${C} : ${_}.test(${n}))`;return(0,me._)`${_} && ${_} !== true && ${y} === ${t} && !${w}`}}function f(){let h=d.formats[s];if(!h){v();return}if(h===!0)return;let[m,y,_]=$(h);m===t&&e.pass(C());function v(){if(c.strictSchema===!1){d.logger.warn(w());return}throw new Error(w());function w(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function $(w){let x=w instanceof RegExp?(0,me.regexpCode)(w):c.code.formats?(0,me._)`${c.code.formats}${(0,me.getProperty)(s)}`:void 0,E=r.scopeValue("formats",{key:s,ref:w,code:x});return typeof w=="object"&&!(w instanceof RegExp)?[w.type||"string",w.validate,(0,me._)`${E}.validate`]:["string",w,E]}function C(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,me._)`await ${_}(${n})`}return typeof y=="function"?(0,me._)`${_}(${n})`:(0,me._)`${_}.test(${n})`}}}};Yl.default=HE});var D0=P(Ql=>{"use strict";Object.defineProperty(Ql,"__esModule",{value:!0});var KE=Z0(),JE=[KE.default];Ql.default=JE});var M0=P(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.contentVocabulary=pn.metadataVocabulary=void 0;pn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];pn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var U0=P(ed=>{"use strict";Object.defineProperty(ed,"__esModule",{value:!0});var WE=J_(),GE=c0(),XE=j0(),YE=D0(),L0=M0(),QE=[WE.default,GE.default,(0,XE.default)(),YE.default,L0.metadataVocabulary,L0.contentVocabulary];ed.default=QE});var F0=P(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.DiscrError=void 0;var q0;(function(e){e.Tag="tag",e.Mapping="mapping"})(q0||(Hi.DiscrError=q0={}))});var V0=P(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:!0});var hn=U(),td=F0(),B0=Pi(),eT=wo(),tT=K(),rT={message:({params:{discrError:e,tagName:t}})=>e===td.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,hn._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},nT={keyword:"discriminator",type:"object",schemaType:"object",error:rT,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,hn._)`${r}${(0,hn.getProperty)(a)}`);t.if((0,hn._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:td.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let f=p();t.if(!1);for(let h in f)t.elseIf((0,hn._)`${u} === ${h}`),t.assign(c,d(f[h]));t.else(),e.error(!1,{discrError:td.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(f){let h=t.name("valid"),m=e.subschema({keyword:"oneOf",schemaProp:f},h);return e.mergeEvaluated(m,hn.Name),h}function p(){var f;let h={},m=_(o),y=!0;for(let C=0;C<i.length;C++){let w=i[C];if(w?.$ref&&!(0,tT.schemaHasRulesButRef)(w,s.self.RULES)){let E=w.$ref;if(w=B0.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,E),w instanceof B0.SchemaEnv&&(w=w.schema),w===void 0)throw new eT.default(s.opts.uriResolver,s.baseId,E)}let x=(f=w?.properties)===null||f===void 0?void 0:f[a];if(typeof x!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(m||_(w)),v(x,C)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return h;function _({required:C}){return Array.isArray(C)&&C.includes(a)}function v(C,w){if(C.const)$(C.const,w);else if(C.enum)for(let x of C.enum)$(x,w);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function $(C,w){if(typeof C!="string"||C in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[C]=w}}}};rd.default=nT});var H0=P((W4,oT)=>{oT.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var od=P((ce,nd)=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.MissingRefError=ce.ValidationError=ce.CodeGen=ce.Name=ce.nil=ce.stringify=ce.str=ce._=ce.KeywordCxt=ce.Ajv=void 0;var sT=q_(),iT=U0(),aT=V0(),K0=H0(),cT=["/properties"],Ki="http://json-schema.org/draft-07/schema",mn=class extends sT.default{_addVocabularies(){super._addVocabularies(),iT.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(aT.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(K0,cT):K0;this.addMetaSchema(t,Ki,!1),this.refs["http://json-schema.org/schema"]=Ki}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ki)?Ki:void 0)}};ce.Ajv=mn;nd.exports=ce=mn;nd.exports.Ajv=mn;Object.defineProperty(ce,"__esModule",{value:!0});ce.default=mn;var uT=bo();Object.defineProperty(ce,"KeywordCxt",{enumerable:!0,get:function(){return uT.KeywordCxt}});var gn=U();Object.defineProperty(ce,"_",{enumerable:!0,get:function(){return gn._}});Object.defineProperty(ce,"str",{enumerable:!0,get:function(){return gn.str}});Object.defineProperty(ce,"stringify",{enumerable:!0,get:function(){return gn.stringify}});Object.defineProperty(ce,"nil",{enumerable:!0,get:function(){return gn.nil}});Object.defineProperty(ce,"Name",{enumerable:!0,get:function(){return gn.Name}});Object.defineProperty(ce,"CodeGen",{enumerable:!0,get:function(){return gn.CodeGen}});var lT=zi();Object.defineProperty(ce,"ValidationError",{enumerable:!0,get:function(){return lT.default}});var dT=wo();Object.defineProperty(ce,"MissingRefError",{enumerable:!0,get:function(){return dT.default}})});var tb=P(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.formatNames=_t.fastFormats=_t.fullFormats=void 0;function yt(e,t){return{validate:e,compare:t}}_t.fullFormats={date:yt(X0,cd),time:yt(id(!0),ud),"date-time":yt(J0(!0),Q0),"iso-time":yt(id(),Y0),"iso-date-time":yt(J0(),eb),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:yT,"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:ST,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:_T,int32:{type:"number",validate:xT},int64:{type:"number",validate:vT},float:{type:"number",validate:G0},double:{type:"number",validate:G0},password:!0,binary:!0};_t.fastFormats={..._t.fullFormats,date:yt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,cd),time:yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,ud),"date-time":yt(/^\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,Q0),"iso-time":yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Y0),"iso-date-time":yt(/^\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,eb),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 fT(e){return e%4===0&&(e%100!==0||e%400===0)}var pT=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,hT=[0,31,28,31,30,31,30,31,31,30,31,30,31];function X0(e){let t=pT.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&fT(r)?29:hT[n])}function cd(e,t){if(e&&t)return e>t?1:e<t?-1:0}var sd=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function id(e){return function(r){let n=sd.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function ud(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function Y0(e,t){if(!(e&&t))return;let r=sd.exec(e),n=sd.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var ad=/t|\s/i;function J0(e){let t=id(e);return function(n){let o=n.split(ad);return o.length===2&&X0(o[0])&&t(o[1])}}function Q0(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function eb(e,t){if(!(e&&t))return;let[r,n]=e.split(ad),[o,s]=t.split(ad),i=cd(r,o);if(i!==void 0)return i||ud(n,s)}var mT=/\/|:/,gT=/^(?:[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 yT(e){return mT.test(e)&&gT.test(e)}var W0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _T(e){return W0.lastIndex=0,W0.test(e)}var bT=-(2**31),wT=2**31-1;function xT(e){return Number.isInteger(e)&&e<=wT&&e>=bT}function vT(e){return Number.isInteger(e)}function G0(){return!0}var $T=/[^\\]\\Z/;function ST(e){if($T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var rb=P(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.formatLimitDefinition=void 0;var zT=od(),dt=U(),er=dt.operators,Ji={formatMaximum:{okStr:"<=",ok:er.LTE,fail:er.GT},formatMinimum:{okStr:">=",ok:er.GTE,fail:er.LT},formatExclusiveMaximum:{okStr:"<",ok:er.LT,fail:er.GTE},formatExclusiveMinimum:{okStr:">",ok:er.GT,fail:er.LTE}},kT={message:({keyword:e,schemaCode:t})=>(0,dt.str)`should be ${Ji[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,dt._)`{comparison: ${Ji[e].okStr}, limit: ${t}}`};yn.formatLimitDefinition={keyword:Object.keys(Ji),type:"string",schemaType:"string",$data:!0,error:kT,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new zT.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=t.const("fmt",(0,dt._)`${p}[${c.schemaCode}]`);e.fail$data((0,dt.or)((0,dt._)`typeof ${f} != "object"`,(0,dt._)`${f} instanceof RegExp`,(0,dt._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let h=t.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,dt._)`${i.code.formats}${(0,dt.getProperty)(p)}`:void 0});e.fail$data(d(h))}function d(p){return(0,dt._)`${p}.compare(${r}, ${n}) ${Ji[o].fail} 0`}},dependencies:["format"]};var PT=e=>(e.addKeyword(yn.formatLimitDefinition),e);yn.default=PT});var ib=P((No,sb)=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});var _n=tb(),ET=rb(),ld=U(),nb=new ld.Name("fullFormats"),TT=new ld.Name("fastFormats"),dd=(e,t={keywords:!0})=>{if(Array.isArray(t))return ob(e,t,_n.fullFormats,nb),e;let[r,n]=t.mode==="fast"?[_n.fastFormats,TT]:[_n.fullFormats,nb],o=t.formats||_n.formatNames;return ob(e,o,r,n),t.keywords&&(0,ET.default)(e),e};dd.get=(e,t="full")=>{let n=(t==="fast"?_n.fastFormats:_n.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function ob(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,ld._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}sb.exports=No=dd;Object.defineProperty(No,"__esModule",{value:!0});No.default=dd});var fb=P(fd=>{"use strict";var ub=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,AT=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,lb=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,CT=/\\([\u000b\u0020-\u00ff])/g,IT=/([\\"])/g,db=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;fd.format=NT;fd.parse=jT;function NT(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!db.test(r))throw new TypeError("invalid type");var n=r;if(t&&typeof t=="object")for(var o,s=Object.keys(t).sort(),i=0;i<s.length;i++){if(o=s[i],!lb.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+DT(t[o])}return n}function jT(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?ZT(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=r!==-1?t.slice(0,r).trim():t.trim();if(!db.test(n))throw new TypeError("invalid media type");var o=new MT(n.toLowerCase());if(r!==-1){var s,i,a;for(ub.lastIndex=r;i=ub.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,s=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(CT,"$1"))),o.parameters[s]=a}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}function ZT(e){var t;if(typeof e.getHeader=="function"?t=e.getHeader("content-type"):typeof e.headers=="object"&&(t=e.headers&&e.headers["content-type"]),typeof t!="string")throw new TypeError("content-type header is missing from object");return t}function DT(e){var t=String(e);if(lb.test(t))return t;if(t.length>0&&!AT.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(IT,"\\$1")+'"'}function MT(e){this.parameters=Object.create(null),this.type=e}});import{webcrypto as xO}from"node:crypto";import{parseArgs as vO}from"node:util";import{spawnSync as bw}from"node:child_process";import{createInterface as ww}from"node:readline/promises";function da(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var Go=e=>e?`"${e}" `:"";function Hb(e,t=""){if(typeof e!="boolean")throw new TypeError(Go(t)+"expected boolean, got type="+typeof e);return e}function Xo(e,t=""){if(typeof e!="number")throw new TypeError(Go(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(Go(t)+"expected integer >= 0, got "+e);return e}function we(e,t,r=""){if(da(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Xo(t,"length");let n=da(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=Go(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Yo(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Kb(e,t){we(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function fa(e,t){if(Kb(e,t),!Rr(e))throw new Error("invalid output, must be aligned")}function Ed(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function bt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ft(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Tr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Or=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function pa(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}var fe=Or?e=>e:e=>pa(e)>>>0;function Jb(e){for(let t=0;t<e.length;t++)e[t]=pa(e[t]);return e}var vn=Or?e=>e:Jb;function Td(e,t){if(e=we(e),t=we(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function ha(e,t,r){let n=t,o=r||(()=>[]),s=(a,c)=>n(c,...o(a)).update(a).digest(),i=n(new Uint8Array(e),...o(new Uint8Array(0)));return s.outputLen=i.outputLen,s.blockLen=i.blockLen,s.create=(a,...c)=>n(a,...c),s}var Od=(e,t)=>{function r(n,...o){if(we(n,void 0,"key"),e.nonceLength!==void 0){let d=o[0];we(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let s=e.tagLength,i=e.nonceLength!==void 0?1:0;if(!e.withAAD){for(let d=i;d<o.length;d++)if(da(o[d]))throw new Error("AAD not supported")}e.withAAD&&o[i]!==void 0&&we(o[i],void 0,"AAD");let a=t(n,...o),c=(d,p)=>{if(p!==void 0){if(d!==2)throw new Error("cipher output not supported");we(p,void 0,"output")}},u=!1;return{encrypt(d,p){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,we(d,void 0,"data"),c(a.encrypt.length,p),a.encrypt(d,p)},decrypt(d,p){if(we(d,void 0,"data"),s&&d.length<s)throw new Error('"ciphertext" expected length >= tagLength='+s);return c(a.decrypt.length,p),a.decrypt(d,p)}}}return Object.assign(r,e),r};function Rd(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(we(t,e,"output"),r&&!Rr(t))throw new Error("invalid output, must be aligned");return t}function Ad(e,t,r){Xo(e),Xo(t),Hb(r);let n=new Uint8Array(16),o=Tr(n);return o.setBigUint64(0,BigInt(t),r),o.setBigUint64(8,BigInt(e),r),n}function Rr(e){return e.byteOffset%4===0}function rr(e){return Uint8Array.from(we(e))}var nr=16,Cd=new Uint8Array(16),$n=bt(Cd),Wb=225,Gb=(e,t,r,n)=>{let o=n&1;return{s3:r<<31|n>>>1,s2:t<<31|r>>>1,s1:e<<31|t>>>1,s0:e>>>1^Wb<<24&-(o&1)}},Qo=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;var Xb=e=>e>64*1024?8:e>1024?4:2,ma=class{blockLen=nr;outputLen=nr;s0=0;s1=0;s2=0;s3=0;finished=!1;destroyed=!1;t;W;windowSize;constructor(t,r){we(t,16,"key"),t=rr(t);let n=Tr(t),o=n.getUint32(0,!1),s=n.getUint32(4,!1),i=n.getUint32(8,!1),a=n.getUint32(12,!1),c=[];for(let h=0;h<128;h++)c.push({s0:Qo(o),s1:Qo(s),s2:Qo(i),s3:Qo(a)}),{s0:o,s1:s,s2:i,s3:a}=Gb(o,s,i,a);let u=Xb(r||1024);if(![1,2,4,8].includes(u))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=u;let d=128/u,p=this.windowSize=2**u,f=[];for(let h=0;h<d;h++)for(let m=0;m<p;m++){let y=0,_=0,v=0,$=0;for(let C=0;C<u;C++){if(!(m>>>u-C-1&1))continue;let{s0:x,s1:E,s2:W,s3:D}=c[u*h+C];y^=x,_^=E,v^=W,$^=D}f.push({s0:y,s1:_,s2:v,s3:$})}this.t=f}_updateBlock(t,r,n,o){t^=this.s0,r^=this.s1,n^=this.s2,o^=this.s3;let{W:s,t:i,windowSize:a}=this,c=0,u=0,l=0,d=0,p=(1<<s)-1,f=0;for(let h of[t,r,n,o])for(let m=0;m<4;m++){let y=h>>>8*m&255;for(let _=8/s-1;_>=0;_--){let v=y>>>s*_&p,{s0:$,s1:C,s2:w,s3:x}=i[f*a+v];c^=$,u^=C,l^=w,d^=x,f+=1}}this.s0=c,this.s1=u,this.s2=l,this.s3=d}update(t){Yo(this),we(t),t=rr(t);let r=bt(t),n=Math.floor(t.length/nr),o=t.length%nr;for(let s=0;s<n;s++)this._updateBlock(fe(r[s*4+0]),fe(r[s*4+1]),fe(r[s*4+2]),fe(r[s*4+3]));return o&&(Cd.set(t.subarray(n*nr)),this._updateBlock(fe($n[0]),fe($n[1]),fe($n[2]),fe($n[3])),ft($n)),this}destroy(){this.destroyed=!0;let{t}=this;for(let r of t)r.s0=0,r.s1=0,r.s2=0,r.s3=0}digestInto(t){Yo(this),fa(t,this),this.finished=!0;let{s0:r,s1:n,s2:o,s3:s}=this,i=bt(t);i[0]=r,i[1]=n,i[2]=o,i[3]=s,Or||vn(i.subarray(0,nr/4))}digest(){let t=new Uint8Array(nr);return this.digestInto(t),this.destroy(),t}};var ga=ha(16,(e,t)=>new ma(e,t),e=>[e.length]);var _a=16,Yb=4,es=new Uint8Array(_a);var Qb=283;function ew(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}function ba(e){return e<<1^Qb&-(e>>7)}function Id(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(t&1),e=ba(e);return r}var tw=(()=>{let e=new Uint8Array(256);for(let r=0,n=1;r<256;r++,n^=ba(n))e[r]=n;let t=new Uint8Array(256);t[0]=99;for(let r=0;r<255;r++){let n=e[255-r];n|=n<<8,t[e[r]]=(n^n>>4^n>>5^n>>6^n>>7^99)&255}return ft(e),t})();var rw=e=>e<<24|e>>>8,ya=e=>e<<8|e>>>24;function nw(e,t){if(e.length!==256)throw new Error("wrong sbox length");let r=new Uint32Array(256).map((u,l)=>t(e[l])),n=r.map(ya),o=n.map(ya),s=o.map(ya),i=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let u=0;u<256;u++)for(let l=0;l<256;l++){let d=u*256+l;i[d]=r[u]^n[l],a[d]=o[u]^s[l],c[d]=e[u]<<8|e[l]}return{sbox:e,sbox2:c,T0:r,T1:n,T2:o,T3:s,T01:i,T23:a}}var jd=nw(tw,e=>Id(e,3)<<24|e<<16|e<<8|Id(e,2));var ow=(()=>{let e=new Uint8Array(16);for(let t=0,r=1;t<16;t++,r=ba(r))e[t]=r;return e})();function sw(e){we(e);let t=e.length;ew(e);let{sbox2:r}=jd,n=[];(!Or||!Rr(e))&&n.push(e=rr(e));let o=vn(bt(e)),s=o.length,i=c=>Sn(r,c,c,c,c),a=new Uint32Array(t+28);a.set(o);for(let c=s;c<a.length;c++){let u=a[c-1];c%s===0?u=i(rw(u))^ow[c/s-1]:s>6&&c%s===4&&(u=i(u)),a[c]=a[c-s]^u}return ft(...n),a}function ts(e,t,r,n,o,s){return e[r<<8&65280|n>>>8&255]^t[o>>>8&65280|s>>>24&255]}function Sn(e,t,r,n,o){return e[t&255|r&65280]|e[n>>>16&255|o>>>16&65280]<<16}function Nd(e,t,r,n,o){let{sbox2:s,T01:i,T23:a}=jd,c=0;t^=e[c++],r^=e[c++],n^=e[c++],o^=e[c++];let u=e.length/4-2;for(let h=0;h<u;h++){let m=e[c++]^ts(i,a,t,r,n,o),y=e[c++]^ts(i,a,r,n,o,t),_=e[c++]^ts(i,a,n,o,t,r),v=e[c++]^ts(i,a,o,t,r,n);t=m,r=y,n=_,o=v}let l=e[c++]^Sn(s,t,r,n,o),d=e[c++]^Sn(s,r,n,o,t),p=e[c++]^Sn(s,n,o,t,r),f=e[c++]^Sn(s,o,t,r,n);return{s0:l,s1:d,s2:p,s3:f}}function rs(e,t,r,n,o){we(r,_a,"nonce"),we(n),o=Rd(n.length,o);let s=r,i=bt(s),a=Tr(s),c=bt(n),u=bt(o),l=t?0:12,d=n.length,p=a.getUint32(l,t);for(let h=0;h+4<=c.length;h+=4){let{s0:m,s1:y,s2:_,s3:v}=Nd(e,fe(i[0]),fe(i[1]),fe(i[2]),fe(i[3]));u[h+0]=c[h+0]^fe(m),u[h+1]=c[h+1]^fe(y),u[h+2]=c[h+2]^fe(_),u[h+3]=c[h+3]^fe(v),p=p+1>>>0,a.setUint32(l,p,t)}let f=_a*Math.floor(c.length/Yb);if(f<d){let{s0:h,s1:m,s2:y,s3:_}=Nd(e,fe(i[0]),fe(i[1]),fe(i[2]),fe(i[3])),v=new Uint32Array([h,m,y,_]);vn(v);let $=Ed(v);for(let C=f,w=0;C<d;C++,w++)o[C]=n[C]^$[w];ft(v)}return o}function iw(e,t,r,n,o){let s=o?o.length:0,i=e.create(r,n.length+s);o&&i.update(o);let a=Ad(8*n.length,8*s,t);i.update(n),i.update(a);let c=i.digest();return ft(a),c}var wa=Od({blockSize:16,nonceLength:12,tagLength:16,withAAD:!0,varSizeNonce:!0},function(t,r,n){if(r.length<8)throw new Error("aes/gcm: invalid nonce length");let o=16;function s(a,c,u){let l=iw(ga,!1,a,u,n);for(let d=0;d<c.length;d++)l[d]^=c[d];return l}function i(){let a=sw(t),c=es.slice(),u=es.slice();if(rs(a,!1,u,u,c),r.length===12)u.set(r);else{let d=es.slice();Tr(d).setBigUint64(8,BigInt(r.length*8),!1);let f=ga.create(c).update(r).update(d);f.digestInto(u),f.destroy()}let l=rs(a,!1,u,es);return{xk:a,authKey:c,counter:u,tagMask:l}}return{encrypt(a){let{xk:c,authKey:u,counter:l,tagMask:d}=i(),p=new Uint8Array(a.length+o),f=[c,u,l,d];Rr(a)||f.push(a=rr(a)),rs(c,!1,l,a,p.subarray(0,a.length));let h=s(u,d,p.subarray(0,p.length-o));return f.push(h),p.set(h,a.length),ft(...f),p},decrypt(a){let{xk:c,authKey:u,counter:l,tagMask:d}=i(),p=[c,u,d,l];Rr(a)||p.push(a=rr(a));let f=a.subarray(0,-o),h=a.subarray(-o),m=s(u,d,f);if(p.push(m),!Td(m,h))throw ft(...p),new Error("aes-gcm: invalid tag");let y=rs(c,!1,l,f);return ft(...p),y}}});function Zd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var xa=e=>e?`"${e}" `:"";function zn(e,t=""){if(typeof e!="number")throw new TypeError(xa(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(xa(t)+"expected integer >= 0, got "+e);return e}function Nt(e,t,r=""){if(Zd(e)&&(t===void 0||e.length===t))return e;t!==void 0&&zn(t,"length");let n=Zd(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=xa(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function kn(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(zn(e.outputLen),zn(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var aw=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},Dd=(e,t)=>{aw(e,t);let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function Ar(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function ns(e,t){Nt(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function pt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function os(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function rt(e,t){return e<<32-t|e>>>t}function cw(e,t,r="opts"){return Dd(e,"defaults"),t!==void 0&&Dd(t,r),Object.assign(Object.create(null),e,t)}function Md(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=cw({},t,"info");let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}var Ld=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var ss=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(kn(t),Nt(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),pt(o)}update(t){return Ar(this),this.iHash.update(t),this}digestInto(t){Ar(this),ns(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a,canXOF:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.canXOF=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Pn=(()=>{let e=((t,r,n)=>new ss(t,r).update(n).digest());return e.create=(t,r)=>new ss(t,r),e})();var En=Uint8Array.of(0),uw=Uint8Array.of();function lw(e,t,r,n=32,o){kn(e),zn(n,"length"),Nt(t,void 0,"prk");let s=e.outputLen;if(t.length<s)throw new Error('"prk" must be at least HashLen octets');if(n>255*s)throw new Error("Length must be <= 255*HashLen");let i=Math.ceil(n/s);if(r===void 0?r=uw:Nt(r,void 0,"info"),!i)return o&&pt(t),new Uint8Array;let a=o&&i===1?t:new Uint8Array(i*s),{iHash:c,oHash:u}=Pn.create(e,t),l=o?t:new Uint8Array(s),d=i>1?o?.iHash||e.create():void 0;for(let f=0;f<i-1;f++){En[0]=f+1;let h=c._cloneInto(d);f&&h.update(l),h.update(r).update(En).digestInto(l),u._cloneInto(d).update(l).digestInto(l),a.set(l,s*f)}if(En[0]=i,i>1&&c.update(l),c.update(r).update(En).digestInto(l),u.update(l).digestInto(l),a.set(l,s*(i-1)),c.destroy(),u.destroy(),d?.destroy(),l!==a&&pt(l),pt(En),n===a.length)return a;let p=a.slice(0,n);return pt(a),p}var va=(e,t,r,n,o)=>{kn(e),r===void 0&&(r=new Uint8Array(e.outputLen));let s=Pn.create(e,r).update(t);return lw(e,s.digest(),n,o,s)};var dw=e=>e/2**32|0,fw=e=>e>>>0;function Ud(e,t,r,n){let o=dw(r),s=fw(r);e.setUint32(t,n?s:o,n),e.setUint32(t+4,n?o:s,n)}function qd(e,t,r){return e&t^~e&r}function Fd(e,t,r){return e&t^e&r^t&r}var is=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=os(this.buffer)}update(t){Ar(this),Nt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let u=os(t);for(;o<=s-a;a+=o)this.process(u,a);i=!0;continue}n.set(a===0&&c===s?t:t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){Ar(this),ns(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),Ud(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let a=t===r?n:os(t),c=this.outputLen,u=c/4,l=this.get();if(c%4||u>l.length)throw new Error("invalid outputLen");for(let d=0;d<u;d++)a.setUint32(4*d,l[d],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(r),t}clone(){return this._cloneInto()}},Bd=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var pw=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),jt=new Uint32Array(64),$a=class extends is{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,r){super(64,t,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let d=0;d<16;d++,r+=4)jt[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){let p=jt[d-15],f=jt[d-2],h=rt(p,7)^rt(p,18)^p>>>3,m=rt(f,17)^rt(f,19)^f>>>10;jt[d]=m+jt[d-7]+h+jt[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){let p=rt(a,6)^rt(a,11)^rt(a,25),f=l+p+qd(a,c,u)+pw[d]+jt[d]|0,m=(rt(n,2)^rt(n,13)^rt(n,22))+Fd(n,o,s)|0;l=u,u=c,c=a,a=i+f|0,i=s,s=o,o=n,n=f+m|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,a,c,u,l)}roundClean(){pt(jt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),pt(this.buffer)}},Sa=class extends $a{constructor(){super(32,Bd)}};var as=Md(()=>new Sa,Ld(1));var Tn=new TextEncoder,hw=new TextDecoder,mw="ape1",Vd=/^ape1\.([A-Za-z0-9_-]{16})\.([A-Za-z0-9_-]+)$/,gw=/^[A-Za-z0-9_-]{43}$/,yw=/^jb_live_[A-Za-z0-9]{40}$/;function cs(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function za(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4)),r=new Uint8Array(new ArrayBuffer(t.length));for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Hd(){return cs(globalThis.crypto.getRandomValues(new Uint8Array(32)))}var ka=e=>gw.test(e),Kd=e=>typeof e=="string"&&Vd.test(e);function Jd(e){let t=e.trim();if(ka(t))return{token:null,key:t};let[r,n,...o]=t.split(".");if(!yw.test(r)||o.length||n!==void 0&&!ka(n))throw new Error("Not a valid Jotbus token or connection string");return{token:r,key:n??null}}var us=(e,t)=>`${e}.${t}`;async function On(e){if(!ka(e))throw new Error("Invalid workspace key");let t=za(e),r=new Uint8Array(32),n=va(as,t,r,Tn.encode("agentpad/v1/enc"),32),o=va(as,t,r,Tn.encode("agentpad/v1/check"),32),s=cs(Pn(as,o,Tn.encode("agentpad/v1/key-check"))),i=a=>Tn.encode(`agentpad/v1/${a}`);return{check:s,async encrypt(a,c){let u=globalThis.crypto.getRandomValues(new Uint8Array(12)),l=wa(n,u,i(a)).encrypt(Tn.encode(JSON.stringify(c)));return`${mw}.${cs(u)}.${cs(l)}`},async decrypt(a,c){let u=Vd.exec(c);if(!u)throw new Error("Not an encrypted message");let l=wa(n,za(u[1]),i(a)).decrypt(za(u[2])),d=JSON.parse(hw.decode(l));if(typeof d?.c!="string")throw new Error("Malformed message");return d}}}var _w=/jb1_([A-Za-z0-9]{24})\.([A-Za-z0-9_-]{43})(?![A-Za-z0-9_-])/,Wd=(e,t)=>`${e}.${t}`;function Gd(e){let t=_w.exec(e.trim());return t?{invite:`jb1_${t[1]}`,key:t[2]}:null}var or="0.4.0",sr="https://app.jotbus.com",ls=`${sr}/mcp`;var xw=!!(process.stdin.isTTY&&process.stdout.isTTY),Ir=e=>t=>process.stdout.isTTY&&!process.env.NO_COLOR?`\x1B[${e}m${t}\x1B[0m`:t,Cr=Ir("1"),Je=Ir("2"),Pa=Ir("32"),Yd=Ir("36"),vw=Ir("33"),pe=(e="")=>process.stdout.write(`${e}
|
|
11
|
+
`);function ds(e){process.stderr.write(`${Ir("31")("\u2717")} ${e}
|
|
12
|
+
`),process.exit(1)}async function Qd(e,t,r){let n;try{n=await fetch(`${e.origin}/anon/${t}`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"jotbus-cli"},body:JSON.stringify(r)})}catch(s){ds(`Couldn't reach ${e.origin} (${s.message}).`)}let o=await n.json().catch(()=>({}));return n.ok||ds(o.error??`Request failed (${n.status}).`),o}function ef(e){return Math.max(0,Math.round((new Date(e).getTime()-Date.now())/6e4))}var tf=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),ir=(e,t)=>bw(e,t,{stdio:"pipe",encoding:"utf8",timeout:3e4}),$w=e=>ir(e,["--version"]).status===0,Xd=[{name:"Claude Code",bin:"claude",exists:()=>ir("claude",["mcp","get","jotbus"]).status===0,remove:()=>ir("claude",["mcp","remove","jotbus","-s","user"]).status===0,add:(e,t)=>ir("claude",["mcp","add","--scope","user","jotbus","-e",`JOTBUS_TOKEN=${e}`,"--","npx",...t]).status===0,manual:(e,t)=>`claude mcp add --scope user jotbus -e JOTBUS_TOKEN=${e} -- npx ${t.join(" ")}`},{name:"Codex",bin:"codex",exists:()=>/\bjotbus\b/.test(ir("codex",["mcp","list"]).stdout??""),remove:()=>ir("codex",["mcp","remove","jotbus"]).status===0,add:(e,t)=>ir("codex",["mcp","add","jotbus","--env",`JOTBUS_TOKEN=${e}`,"--","npx",...t]).status===0,manual:(e,t)=>`codex mcp add jotbus --env JOTBUS_TOKEN=${e} -- npx ${t.join(" ")}`}];async function Sw(e,t){if(!xw)return t;let r=ww({input:process.stdin,output:process.stdout}),n=(await r.question(`${e} ${Je(t?"[Y/n]":"[y/N]")} `)).trim().toLowerCase();return r.close(),n===""?t:n.startsWith("y")}async function rf(e,t){let r=["-y","jotbus@latest",...e.origin===sr?[]:["--url",`${e.origin}/mcp`]],n=Xd.filter(s=>$w(s.bin)),o=[];if(!e.install||n.length===0){pe(Cr("Add it to your agent:"));for(let s of Xd)pe(` ${Je(s.name+":")} ${s.manual(t,r)}`);return pe(` ${Je("Other MCP clients:")} command "npx ${r.join(" ")}" with env JOTBUS_TOKEN=${t}`),o}for(let s of n){if(s.exists()){if(!(e.yes||await Sw(`${s.name} already has a Jotbus connection. Replace it with this workspace?`,!1))){pe(Je(` Skipped ${s.name}. To switch later, run: npx jotbus@latest join \u2026 --yes (or remove its "jotbus" server and add: ${s.manual(t,r)})`));continue}s.remove()}s.add(t,r)?(o.push(s.name),pe(`${Pa("\u2713")} Added to ${s.name}`)):pe(`${vw("!")} Couldn't add to ${s.name} automatically. Run:
|
|
13
|
+
${s.manual(t,r)}`)}return o}function nf(e){pe(),pe(Cr("Then tell your agent:")),pe(` ${Yd('"Use Jotbus to collaborate."')}`),e.includes("Claude Code")?pe(Je(" (Start a new Claude Code session so it picks up the new connection.)")):e.length&&pe(Je(" (Restart your agent so it picks up the new connection.)"))}async function Ea(e){let t=Hd(),r=await On(t),n=await Qd(e,"workspaces",{key_check:r.check}),o=Wd(n.invite,t);pe(`${Pa("\u2713")} Created temporary workspace ${Cr(n.name)} ${Je(`(end-to-end encrypted, expires in ${ef(n.expires_at)} minutes at ${tf(n.expires_at)})`)}`);let s=await rf(e,us(n.token,t));pe(),pe(Cr("Connect another machine or person:"));let i=e.origin===sr?"":` --origin ${e.origin}`;pe(` ${Yd(`npx jotbus@latest join ${o}${i}`)}`),pe(Je(` or share this link: ${e.origin}/join#${o}`)),pe(Je(" No account needed. Up to 3 connected clients. The invite includes the encryption key, so share it privately.")),pe(),pe(Cr("Keep it beyond 60 minutes:")),pe(Je(` ${e.origin}/claim#${us(n.token,t)}`)),pe(Je(" (only you have this link; it keeps the history and every connected agent)")),nf(s)}async function of(e,t){let r=t?Gd(t):null;r||ds("Usage: npx jotbus join <invite> (the jb1_\u2026 invite or join link you were sent)");let n=await On(r.key),o=await Qd(e,"join",{invite:r.invite});o.key_check!==n.check&&ds("This invite's encryption key doesn't match the workspace. Ask for a fresh invite."),pe(`${Pa("\u2713")} Joined ${Cr(o.name)} ${Je(`(end-to-end encrypted, expires in ${ef(o.expires_at)} minutes at ${tf(o.expires_at)})`)}`);let s=await rf(e,us(o.token,r.key));nf(s)}import{webcrypto as _O}from"node:crypto";import{hostname as bO}from"node:os";var j={};ua(j,{BIGINT_FORMAT_RANGES:()=>ms,CONSTANT_CATCH:()=>yf,Class:()=>Ra,NUMBER_FORMAT_RANGES:()=>An,aborted:()=>nt,allowsEval:()=>ja,assert:()=>Tw,assertEqual:()=>zw,assertIs:()=>Pw,assertNever:()=>Ew,assertNotEqual:()=>kw,assignProp:()=>Ve,attachSchema:()=>ys,base64ToUint8Array:()=>mf,base64urlToUint8Array:()=>Jw,cached:()=>Dr,captureStackTrace:()=>ps,cleanEnum:()=>Kw,cleanRegex:()=>Rn,clone:()=>We,cloneDef:()=>Aw,codePointLength:()=>Cn,constantCatch:()=>_f,createTransparentProxy:()=>Dw,defineLazy:()=>cf,defineLazyInternal:()=>G,derived:()=>Yw,esc:()=>Ia,escapeRegex:()=>vt,explicitlyAborted:()=>Ma,extend:()=>Uw,finalizeIssue:()=>ot,floatSafeRemainder:()=>Ca,getElementAtPath:()=>Cw,getEnumValues:()=>jr,getLengthableOrigin:()=>In,getParsedType:()=>Zw,getSizableOrigin:()=>hf,hexToUint8Array:()=>Gw,hide:()=>_s,installLazyProp:()=>rx,isObject:()=>cr,isPlainObject:()=>Mt,issue:()=>Lr,joinValues:()=>fs,jsonStringifyReplacer:()=>Zr,members:()=>Ua,merge:()=>Fw,mergeDefs:()=>xt,normalizeParams:()=>I,nullish:()=>Aa,numKeys:()=>jw,objectClone:()=>Ow,omit:()=>Lw,optionalKeys:()=>Da,own:()=>Dt,parsedType:()=>La,partial:()=>Bw,pick:()=>Mw,prefixIssues:()=>$t,primitiveTypes:()=>ff,promiseAllObject:()=>Iw,propertyKeyTypes:()=>Za,randomString:()=>Nw,rawShape:()=>Mr,required:()=>Vw,safeExtend:()=>qw,shallowClone:()=>df,slugify:()=>Na,stringifyPrimitive:()=>hs,toZod:()=>af,uint8ArrayToBase64:()=>gf,uint8ArrayToBase64url:()=>Ww,uint8ArrayToHex:()=>Xw,unwrapMessage:()=>Nr});function zw(e){return e}function kw(e){return e}function af(){return e=>e}function Pw(e){}function Ew(e){throw new Error("Unexpected value in exhaustive check")}function Tw(e){}function jr(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function fs(e,t="|"){return e.map(r=>hs(r)).join(t)}function Zr(e,t){return typeof t=="bigint"?t.toString():t}var Oa=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Dr(e){return new Oa(e)}function Aa(e){return e==null}function Rn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ca(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var sf=Symbol("evaluating");function cf(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==sf)return n===void 0&&(n=sf,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Ow(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ve(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Mr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function wt(e){return Mr(e._zod.def)??e._zod.def.shape}function uf(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return Ve(this,t,n),n},enumerable:!0,configurable:!0})}function lf(e,t,r){t in e?Ve(e,t,r):e[t]=r}function ar(e,t,r,n){let o=wt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?uf(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):lf(e,s,n?n(i.value,s):i.value))}}function Rw(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?uf(e,r,()=>t[r]):lf(e,r,n.value))}}function xt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Aw(e){return xt(e._zod.def)}function Cw(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Iw(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function Nw(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ia(e){return JSON.stringify(e)}function Na(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ps="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function cr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ja=Dr(()=>{if(Ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Mt(e){if(cr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(cr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function df(e){return Mt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function jw(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Zw=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Za=new Set(["string","number","symbol"]),ff=new Set(["string","number","bigint","boolean","symbol","undefined"]);function vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function I(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Dw(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function hs(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Da(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var An={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]},ms={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Mw(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return ar(s,e,gs(e,t)),We(e,xt(r,{shape:s,checks:[]}))}function gs(e,t){let r=wt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function Lw(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(gs(e,t)),i={};return ar(i,e,Reflect.ownKeys(wt(e)).filter(a=>!s.has(a))),We(e,xt(r,{shape:i,checks:[]}))}function Uw(e,t){if(!Mt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=wt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return We(e,xt(e._zod.def,{shape:pf(e,t)}))}function pf(e,t){let r={};return ar(r,e,Reflect.ownKeys(wt(e))),Rw(r,t),r}function qw(e,t){if(!Mt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return We(e,xt(e._zod.def,{shape:pf(e,t)}))}function Fw(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ar(r,e,Reflect.ownKeys(wt(e))),ar(r,t,Reflect.ownKeys(wt(t)));let n=xt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return We(e,n)}function Bw(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(gs(t,r)):void 0,c={};return ar(c,t,Reflect.ownKeys(wt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),We(t,xt(t._zod.def,{shape:c,checks:[]}))}function Vw(e,t,r){let n=r?new Set(gs(t,r)):void 0,o={};return ar(o,t,Reflect.ownKeys(wt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),We(t,xt(t._zod.def,{shape:o}))}function nt(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ma(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function $t(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Nr(e){return typeof e=="string"?e:e?.message}function ys(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ot(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Nr(e.inst?._zod.def?.error?.(e))??Nr(s?.(e))??Nr(t?.error?.(e))??Nr(r.customError?.(e))??Nr(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function hf(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var Hw=/[\uD800-\uDBFF]/;function Cn(e){let t=e.length;if(!Hw.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function In(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function La(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Lr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Kw(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function mf(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function gf(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Jw(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return mf(t+r)}function Ww(e){return gf(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Gw(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function Xw(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Ra=class{constructor(...t){}};function Ua(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Qw(e,r,n.value)}}function Dt(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function _s(e,t,r){return Dt(e,t,r,!1)}function Yw(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Dt(this,r,n(this))},set(o){Dt(this,r,o)}})}return t}function Qw(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Dt(this,t,r.bind(this))},set(n){Dt(this,t,n)}})}function ex(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Ta,Zt=!1,tx={configurable:!0,get(){Zt=!0}};function G(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Ta!==e._zod){Ta=void 0;return}Ta=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,tx);let o=Zt;Zt=!1;try{let s=r(this);return Zt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Zt=Zt||o,s}catch(s){throw delete this[t],Zt=Zt||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function rx(e,t,r,n){let o=ex(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var yf="~constantCatch";function _f(e){let t=()=>e;return t[yf]=!0,t}var bf,Fa=Object.freeze({status:"aborted"}),qa={value:void 0,enumerable:!1},wf="captureStackTrace"in Error?Error:null;function nx(e){let t=wf;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return wf=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function b(e,t,r,n){let o={};function s(p){this.def=p,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(p,f){if(p._zod){if(p._zod.traits.has(e))return}else{qa.value=new s(f);try{Object.defineProperty(p,"_zod",qa)}finally{qa.value=void 0}}if(p._zod.traits.add(e),t(p,f),a){let m=Object.getPrototypeOf(p),y=p._zod.constr.prototype,_=m;for(;_&&_!==y;)_=Object.getPrototypeOf(_);let v=_??m;a.has(v)||(a.add(v),Ua(v,i))}let h=d.prototype;for(let m in h)Object.prototype.hasOwnProperty.call(h,m)&&(m in p||(p[m]=h[m].bind(p)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(p){let f=n?.Parent?nx(l):this;c(f,p);let h=f._zod.deferred;if(h){for(let y of h)y();f._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(f),f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>n?.Parent&&p instanceof n.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var st=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ur=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(bf=globalThis).__zod_globalConfig??(bf.__zod_globalConfig={});var Ze=globalThis.__zod_globalConfig;function De(e){return e&&Object.assign(Ze,e),Ze}function ox(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Zr,2)),e.message}function sx(e){this._zod.message=e}var ix={get:ox,set:sx,enumerable:!0,configurable:!0},Va={value:void 0,enumerable:!1},xf=new WeakSet([Object.prototype,Error.prototype]),vf=(e,t)=>{e.name="$ZodError",Va.value=t,Object.defineProperty(e,"issues",Va),Va.value=void 0,Object.defineProperty(e,"message",ix);let r=Object.getPrototypeOf(e);xf.has(r)||(xf.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},$f=b("$ZodError",vf),Sf=b("$ZodError",vf,void 0,{Parent:Error});function ax(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Ha(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?ax(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ka(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=c[l];d&&p._errors.push(t(i)),c=p,u++}}}};return n(e),r}function bs(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ws=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new st;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ot(u,i,De())));throw ps(c,s?.callee??t),c}return a.value};return t};var xs=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ot(u,i,De())));throw ps(c,s?.callee??t),c}return a.value};return t};var Nn=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new st;return s.issues.length?zf(e,s.issues,o):{success:!0,data:s.value}},Ja=Nn(Sf);function zf(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>ot(o,r,De()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var vs=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?zf(e,s.issues,o):{success:!0,data:s.value}};var ux=Symbol.for("zod.compile.invalid"),lx=Symbol.for("zod.compile.fallback"),$s=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==ux)return!0;if(n.definite===!0&&r===void 0)return!1}return dx(e,t,r)});function dx(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[lx]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new st;return s.issues.length===0}var Ss=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},kf=e=>{let t=ws(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,bs(r,i))};return r};var Pf=e=>{let t=ws(e),r=(n,o,s,i)=>t(n,o,s,bs(r,i));return r};var Ef=e=>{let t=xs(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,bs(r,i))};return r};var Tf=e=>{let t=xs(e),r=async(n,o,s,i)=>await t(n,o,s,bs(r,i));return r};var Of=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Nn(e)(t,r,o)};var Rf=e=>(t,r,n)=>Nn(e)(t,r,n);var Af=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return vs(e)(t,r,o)};var Cf=e=>async(t,r,n)=>vs(e)(t,r,n);var If=/^[cC][0-9a-z]{6,}$/,Nf=/^[0-9a-z]+$/,jf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Zf=/^[0-9a-vA-V]{20}$/,Df=/^[A-Za-z0-9]{27}$/,Mf=/^[a-zA-Z0-9_-]{21}$/;function Lf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Uf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var 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})$/,Ga=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var Ff=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var fx="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Bf(){return new RegExp(fx,"u")}var Vf=/^(?:(?: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])$/,Hf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Kf=/^((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])$/,Jf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Gf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Xf=/^https?$/,Yf=/^\+[1-9]\d{6,14}$/;var Qf="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function px(e){return new RegExp(`^${e}$`)}var ep=px(Qf);function Wa(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tp(e){return new RegExp(`^${Wa(e)}$`)}function rp(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Wa({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Wa({precision:e.precision})}`:r;return new RegExp(`^${Qf}T(?:${n})$`)}var np=/^[\s\S]{0,}$/;var op=/^-?\d+n?$/,Xa=/^-?\d+$/,jn=/^-?\d+(?:\.\d+)?$/,sp=/^(?:true|false)$/i,ip=/^null$/i;var ap=/^[^A-Z]*$/,cp=/^[^a-z]*$/;var xe=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ya=e=>{let t=e.value;return!Aa(t)&&t.length!==void 0},zs={number:"number",bigint:"bigint",object:"date"},Qa=b("$ZodCheckLessThan",(e,t)=>{xe.init(e,t);let r=zs[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:zs[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ec=b("$ZodCheckGreaterThan",(e,t)=>{xe.init(e,t);let r=zs[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:zs[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),up=b("$ZodCheckMultipleOf",(e,t)=>{xe.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Ca(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),lp=b("$ZodCheckNumberFormat",(e,t)=>{xe.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=An[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var dp=b("$ZodCheckMaxLength",(e,t)=>{var r;xe.init(e,t),(r=e._zod.def).when??(r.when=Ya),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?Cn(o):s)<=t.maximum)return;let a=In(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fp=b("$ZodCheckMinLength",(e,t)=>{var r;xe.init(e,t),(r=e._zod.def).when??(r.when=Ya),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?Cn(o):s)>=t.minimum)return;let a=In(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),pp=b("$ZodCheckLengthEquals",(e,t)=>{var r;xe.init(e,t),(r=e._zod.def).when??(r.when=Ya),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?Cn(o):s;if(i===t.length)return;let a=In(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Zn=b("$ZodCheckStringFormat",(e,t)=>{var r,n;xe.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),hp=b("$ZodCheckRegex",(e,t)=>{Zn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),mp=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ap),Zn.init(e,t)}),gp=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cp),Zn.init(e,t)}),yp=b("$ZodCheckIncludes",(e,t)=>{xe.init(e,t);let r=vt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),_p=b("$ZodCheckStartsWith",(e,t)=>{xe.init(e,t);let r=new RegExp(`^${vt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),bp=b("$ZodCheckEndsWith",(e,t)=>{xe.init(e,t);let r=new RegExp(`.*${vt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var wp=b("$ZodCheckOverwrite",(e,t)=>{xe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ks=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
11
14
|
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
12
15
|
${r.join(`
|
|
13
16
|
`)}
|
|
14
|
-
};`)(...Object.values(this.closed))}};var qf={major:4,minor:6,patch:5};var J=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qf;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=We(a),d;for(let p of c){if(p._zod.def.when){if(ga(a)||!p._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,h=p._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new Xe;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==f&&(Go(a.issues,f,e),l||(l=We(a,f)))});else{if(a.issues.length===f)continue;Go(a.issues,f,e),l||(l=We(a,f))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(We(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new Xe;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Xe;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return Xo(this,"~standard",Ia(this))},set"~standard"(e){Rt(this,"~standard",e)}}),Qf=(e,t)=>e.issues.length?{issues:e.issues.map(r=>Ge(r,t,Ae()))}:{value:e.value};async function zw(e,t){let r={async:!0};return Qf(await e._zod.run({value:t,issues:[]},r),r)}function Ia(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Qf(n,r)}catch{}return zw(e,t)},vendor:"zod",version:1}}var us=_("$ZodString",(e,t)=>{J.init(e,t),e._zod.pattern=t.pattern??$f,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ee=_("$ZodStringFormat",(e,t)=>{bn.init(e,t),us.init(e,t)}),ep=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=cf),ee.init(e,t)}),tp=_("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Pa(n))}else t.pattern??(t.pattern=Pa());ee.init(e,t)}),rp=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=uf),ee.init(e,t)}),np=1,as=2;function op(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function kw(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?op(e)||as:Pw(e,t)}function Pw(e,t){if(!t.normalize&&t.protocol?.source===yf.source&&!/^https?:\/\//i.test(e))return np;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??as}return new URL(e)}catch{return as}}var Ew=/[\t\n\r]/g;function Ff(e){return e.replace(Ew,"")}function Tw(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ow(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var sp=_("$ZodURL",(e,t)=>{ee.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=kw(n,t);if(o===np){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===as){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ff(n);return}t.hostname&&!Tw(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!Ow(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Ff(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ip=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=lf()),ee.init(e,t)}),ap=_("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?of:sf(t.length)),ee.init(e,t)}),cp=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Qd),ee.init(e,t)}),up=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ef),ee.init(e,t)}),lp=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=tf),ee.init(e,t)}),dp=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=rf),ee.init(e,t)}),fp=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=nf),ee.init(e,t)}),pp=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=vf(t)),ee.init(e,t)}),hp=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=wf),ee.init(e,t)}),mp=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xf(t)),ee.init(e,t)}),gp=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=af),ee.init(e,t)}),yp=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=df),ee.init(e,t)}),Rw=/^[0-9a-fA-F:.]+$/;function _p(e){return Rw.test(e)?op(`http://[${e}]`):!1}var bp=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ff),ee.init(e,t),e._zod.check=r=>{_p(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var wp=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=pf),ee.init(e,t)});function Aw(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:_p(r)}var xp=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=hf),ee.init(e,t),e._zod.check=r=>{Aw(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function vp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ca=/^[0-9a-zA-Z+/]*={0,2}$/,$p=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ca),ee.init(e,t),e._zod.check=r=>{vp(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),ls=/^[A-Za-z0-9_-]*$/;function Iw(e){if(!ls.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return vp(r)}var Sp=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ls),ee.init(e,t),e._zod.check=r=>{Iw(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),zp=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_f),ee.init(e,t)});function Cw(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var kp=_("$ZodJWT",(e,t)=>{ee.init(e,t),e._zod.check=r=>{Cw(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Na=_("$ZodNumber",(e,t)=>{J.init(e,t),e._zod.pattern=_n,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Pp=_("$ZodNumberFormat",(e,t)=>{Of.init(e,t),Na.init(e,t)}),Ep=_("$ZodBoolean",(e,t)=>{J.init(e,t),e._zod.pattern=zf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),Tp=_("$ZodBigInt",(e,t)=>{J.init(e,t),e._zod.pattern=Sf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var Op=_("$ZodNull",(e,t)=>{J.init(e,t),e._zod.pattern=kf,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),Rp=_("$ZodAny",(e,t)=>{J.init(e,t),e._zod.parse=r=>r}),Ap=_("$ZodUnknown",(e,t)=>{J.init(e,t),e._zod.parse=r=>r}),Ip=_("$ZodNever",(e,t)=>{J.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var Cp=_("$ZodDate",(e,t)=>{J.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,s=o instanceof Date;return s&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Vf(e,t,r){e.issues.length&&t.issues.push(...gt(r,e.issues)),t.value[r]=e.value}var Np=_("$ZodArray",(e,t)=>{J.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Vf(d,n,c)));else if(Vf(l,n,c),a&&l.issues.length!==0&&We(l))break}return i.length?Promise.all(i).then(()=>n):n}});function cs(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...gt(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Nw=[];function jp(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Nw,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=ma(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Zp(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,p=u.optout,f=0;for(let h in t){if(i&&r.issues.length!==f){if(We(r,f))break;f=r.issues.length}if(c.has(h))continue;if(h==="__proto__"){l==="never"&&a.push(h);continue}if(l==="never"){a.push(h);continue}let m=u.run({value:t[h],issues:[]},n);m instanceof Promise?e.push(m.then(y=>cs(y,r,h,t,d,p))):cs(m,r,h,t,d,p)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var jw=_("$ZodObject",(e,t)=>{J.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=kr(()=>jp(t));V(e,"propValues",u=>{let l=u.def.shape,d={};for(let p in l){let f=l[p]._zod;if(f.values){Object.prototype.hasOwnProperty.call(d,p)||De(d,p,new Set);for(let h of f.values)d[p].add(h);f.optin!==void 0&&d[p].add(void 0)}}return d});let s=er,i=t.catchall,a,c=Re.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let p=[],f=a.shape,h=l?.abortEarly,m=u.issues.length;for(let y of a.allKeys){if(h&&u.issues.length!==m){if(We(u,m))break;m=u.issues.length}if(y==="__proto__")continue;let w=f[y],v=w._zod.optin,z=w._zod.optout,A=w._zod.run({value:d[y],issues:[]},l);A instanceof Promise?p.push(A.then(b=>cs(b,u,y,d,v,z))):cs(A,u,y,d,v,z)}return i?Zp(p,d,u,l,o.value,e,h===!0):p.length?Promise.all(p).then(()=>u):u}}),Mp=_("$ZodObjectJIT",(e,t)=>{jw.init(e,t);let r=e._zod.parse,n=kr(()=>jp(t)),o=Re.memoizer,s=f=>{let h=n.value,m=h.symbolKeys,y=new ss(["payload","ctx"],{shape:f,inst:e,memo:o,syms:m}),w=b=>`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`,v=(b,x)=>`
|
|
15
|
-
let ${
|
|
16
|
-
for (let i = 0; i < ${
|
|
17
|
-
const iss = ${
|
|
17
|
+
};`)(...Object.values(this.closed))}};var vp={major:4,minor:6,patch:5};var Q=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=vp;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=nt(a),d;for(let p of c){if(p._zod.def.when){if(Ma(a)||!p._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,h=p._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new st;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==f&&(ys(a.issues,f,e),l||(l=nt(a,f)))});else{if(a.issues.length===f)continue;ys(a.issues,f,e),l||(l=nt(a,f))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(nt(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new st;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new st;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return _s(this,"~standard",rc(this))},set"~standard"(e){Dt(this,"~standard",e)}}),Cp=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ot(r,t,De()))}:{value:e.value};async function hx(e,t){let r={async:!0};return Cp(await e._zod.run({value:t,issues:[]},r),r)}function rc(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Cp(n,r)}catch{}return hx(e,t)},vendor:"zod",version:1}}var Os=b("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=t.pattern??np,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),se=b("$ZodStringFormat",(e,t)=>{Zn.init(e,t),Os.init(e,t)}),Ip=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=qf),se.init(e,t)}),Np=b("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ga(n))}else t.pattern??(t.pattern=Ga());se.init(e,t)}),jp=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ff),se.init(e,t)}),Zp=1,Es=2;function Dp(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function mx(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Dp(e)||Es:gx(e,t)}function gx(e,t){if(!t.normalize&&t.protocol?.source===Xf.source&&!/^https?:\/\//i.test(e))return Zp;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Es}return new URL(e)}catch{return Es}}var yx=/[\t\n\r]/g;function $p(e){return e.replace(yx,"")}function _x(e,t){return t.lastIndex=0,t.test(e.hostname)}function bx(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Mp=b("$ZodURL",(e,t)=>{se.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=mx(n,t);if(o===Zp){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Es){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=$p(n);return}t.hostname&&!_x(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!bx(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:$p(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Lp=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Bf()),se.init(e,t)}),Up=b("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Mf:Lf(t.length)),se.init(e,t)}),qp=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=If),se.init(e,t)}),Fp=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Nf),se.init(e,t)}),Bp=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=jf),se.init(e,t)}),Vp=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Zf),se.init(e,t)}),Hp=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Df),se.init(e,t)}),Kp=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=rp(t)),se.init(e,t)}),Jp=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ep),se.init(e,t)}),Wp=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=tp(t)),se.init(e,t)}),Gp=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Uf),se.init(e,t)}),Xp=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Vf),se.init(e,t)}),wx=/^[0-9a-fA-F:.]+$/;function Yp(e){return wx.test(e)?Dp(`http://[${e}]`):!1}var Qp=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Hf),se.init(e,t),e._zod.check=r=>{Yp(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var eh=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Kf),se.init(e,t)});function xx(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:Yp(r)}var th=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Jf),se.init(e,t),e._zod.check=r=>{xx(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function rh(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var nc=/^[0-9a-zA-Z+/]*={0,2}$/,nh=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=nc),se.init(e,t),e._zod.check=r=>{rh(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Rs=/^[A-Za-z0-9_-]*$/;function vx(e){if(!Rs.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return rh(r)}var oh=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Rs),se.init(e,t),e._zod.check=r=>{vx(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),sh=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Yf),se.init(e,t)});function $x(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var ih=b("$ZodJWT",(e,t)=>{se.init(e,t),e._zod.check=r=>{$x(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var oc=b("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=jn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),ah=b("$ZodNumberFormat",(e,t)=>{lp.init(e,t),oc.init(e,t)}),ch=b("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=sp,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),uh=b("$ZodBigInt",(e,t)=>{Q.init(e,t),e._zod.pattern=op,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var lh=b("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=ip,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),dh=b("$ZodAny",(e,t)=>{Q.init(e,t),e._zod.parse=r=>r}),fh=b("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=r=>r}),ph=b("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var hh=b("$ZodDate",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,s=o instanceof Date;return s&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Sp(e,t,r){e.issues.length&&t.issues.push(...$t(r,e.issues)),t.value[r]=e.value}var mh=b("$ZodArray",(e,t)=>{Q.init(e,t);let r=Ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Sp(d,n,c)));else if(Sp(l,n,c),a&&l.issues.length!==0&&nt(l))break}return i.length?Promise.all(i).then(()=>n):n}});function Ts(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...$t(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Sx=[];function gh(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Sx,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=Da(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function yh(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,p=u.optout,f=0;for(let h in t){if(i&&r.issues.length!==f){if(nt(r,f))break;f=r.issues.length}if(c.has(h))continue;if(h==="__proto__"){l==="never"&&a.push(h);continue}if(l==="never"){a.push(h);continue}let m=u.run({value:t[h],issues:[]},n);m instanceof Promise?e.push(m.then(y=>Ts(y,r,h,t,d,p))):Ts(m,r,h,t,d,p)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var zx=b("$ZodObject",(e,t)=>{Q.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Dr(()=>gh(t));G(e,"propValues",u=>{let l=u.def.shape,d={};for(let p in l){let f=l[p]._zod;if(f.values){Object.prototype.hasOwnProperty.call(d,p)||Ve(d,p,new Set);for(let h of f.values)d[p].add(h);f.optin!==void 0&&d[p].add(void 0)}}return d});let s=cr,i=t.catchall,a,c=Ze.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let p=[],f=a.shape,h=l?.abortEarly,m=u.issues.length;for(let y of a.allKeys){if(h&&u.issues.length!==m){if(nt(u,m))break;m=u.issues.length}if(y==="__proto__")continue;let _=f[y],v=_._zod.optin,$=_._zod.optout,C=_._zod.run({value:d[y],issues:[]},l);C instanceof Promise?p.push(C.then(w=>Ts(w,u,y,d,v,$))):Ts(C,u,y,d,v,$)}return i?yh(p,d,u,l,o.value,e,h===!0):p.length?Promise.all(p).then(()=>u):u}}),_h=b("$ZodObjectJIT",(e,t)=>{zx.init(e,t);let r=e._zod.parse,n=Dr(()=>gh(t)),o=Ze.memoizer,s=f=>{let h=n.value,m=h.symbolKeys,y=new ks(["payload","ctx"],{shape:f,inst:e,memo:o,syms:m}),_=w=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,v=(w,x)=>`
|
|
18
|
+
let ${w}_ab = false;
|
|
19
|
+
for (let i = 0; i < ${w}.issues.length; i++) {
|
|
20
|
+
const iss = ${w}.issues[i];
|
|
18
21
|
iss.path = iss.path ? [${x}, ...iss.path] : [${x}];
|
|
19
22
|
payload.issues.push(iss);
|
|
20
|
-
if (iss.continue !== true) ${
|
|
23
|
+
if (iss.continue !== true) ${w}_ab = true;
|
|
21
24
|
}
|
|
22
|
-
if (${
|
|
25
|
+
if (${w}_ab && ctx && ctx.abortEarly) {
|
|
23
26
|
payload.value = newResult;
|
|
24
27
|
return payload;
|
|
25
|
-
}`;y.write("const input = payload.value;");let
|
|
26
|
-
const ${x}_present = ${
|
|
28
|
+
}`;y.write("const input = payload.value;");let $=Object.create(null),C=0;for(let w of h.allKeys)$[w]=`key_${C++}`;y.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of h.allKeys){if(w==="__proto__")continue;let x=$[w],E=typeof w=="symbol"?`syms[${m.indexOf(w)}]`:Ia(w),W=`${E} in input`,D=f[w],S=D?._zod?.optin,T=S!==void 0,M=D?._zod?.optout==="optional";if(y.write(`const ${x} = ${_(E)};`),T&&M){let F=S==="optional"?`${x}_present`:`${x}.value !== undefined || ${x}_present`;y.write(`
|
|
29
|
+
const ${x}_present = ${W};
|
|
27
30
|
if (!${x}.issues.length || ${x}_present) {
|
|
28
|
-
if (${x}.issues.length) {${v(x,
|
|
31
|
+
if (${x}.issues.length) {${v(x,E)}
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
if (${
|
|
32
|
-
newResult[${
|
|
34
|
+
if (${F}) {
|
|
35
|
+
newResult[${E}] = ${x}.value;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
`)}else
|
|
37
|
-
if (${x}.issues.length) {${v(x,
|
|
39
|
+
`)}else T?(y.write(`
|
|
40
|
+
if (${x}.issues.length) {${v(x,E)}
|
|
38
41
|
}
|
|
39
|
-
`),
|
|
40
|
-
if (${x}.value !== undefined || ${
|
|
41
|
-
newResult[${
|
|
42
|
+
`),S==="defaulted"?y.write(`newResult[${E}] = ${x}.value;`):y.write(`
|
|
43
|
+
if (${x}.value !== undefined || ${W}) {
|
|
44
|
+
newResult[${E}] = ${x}.value;
|
|
42
45
|
}
|
|
43
46
|
`)):y.write(`
|
|
44
|
-
const ${x}_present = ${
|
|
45
|
-
if (${x}.issues.length) {${v(x,
|
|
47
|
+
const ${x}_present = ${W};
|
|
48
|
+
if (${x}.issues.length) {${v(x,E)}
|
|
46
49
|
}
|
|
47
50
|
if (!${x}_present && !${x}.issues.length) {
|
|
48
51
|
payload.issues.push({
|
|
49
52
|
code: "invalid_type",
|
|
50
53
|
expected: "nonoptional",
|
|
51
54
|
input: undefined,
|
|
52
|
-
path: [${
|
|
55
|
+
path: [${E}]
|
|
53
56
|
});
|
|
54
57
|
if (ctx && ctx.abortEarly) {
|
|
55
58
|
payload.value = newResult;
|
|
@@ -58,35 +61,47 @@ ${r.join(`
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
if (${x}_present) {
|
|
61
|
-
newResult[${
|
|
64
|
+
newResult[${E}] = ${x}.value;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},i,a=er,c=!Re.jitless,l=c&&pa.value,d=t.catchall,p;e._zod.parse=(f,h)=>{p??(p=n.value);let m=f.value;return a(m)?c&&l&&h?.async===!1&&h.jitless!==!0?(i||(i=s(t.shape)),f=i(f,h),d?Zp([],m,f,h,p,e,h?.abortEarly===!0):f):r(f,h):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function Bf(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!We(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>Ge(i,n,Ae())))}),t)}var ja=_("$ZodUnion",(e,t)=>{J.init(e,t),V(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),V(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),V(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),V(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>pn(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>Bf(a,n,e,o)):Bf(i,n,e,o)}});function Zw(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Dp=_("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ja.init(e,t);let r=e._zod.parse;V(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||De(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Pr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=kr(()=>Zw(t));e._zod.parse=(o,s)=>{let i=o.value;if(!er(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Lp=_("$ZodIntersection",(e,t)=>{J.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Hf(r,c,u)):Hf(r,s,i)}});function Aa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(At(e)&&At(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Aa(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Aa(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Hf(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);s.has(p)||s.set(p,u),d=[p]}else return!1;for(let p of d)n.has(p)||n.set(p,{}),n.get(p)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Aa(t.value,r.value);if(!c.valid){if(We(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Up=_("$ZodRecord",(e,t)=>{J.init(e,t);let r=Re.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!At(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>Ge(h,o,Ae())),input:l,path:[l],inst:e});continue}let p=d.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},o);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...gt(l,h.issues)),n.value[p]=h.value})):(f.issues.length&&n.issues.push(...gt(l,f.issues)),n.value[p]=f.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&_n.test(u)&&l.issues.length){let h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>Ge(h,o,Ae())),input:u,path:[u],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},o);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...gt(u,h.issues)),n.value[p]=h.value})):(f.issues.length&&n.issues.push(...gt(u,f.issues)),n.value[p]=f.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var qp=_("$ZodEnum",(e,t)=>{J.init(e,t);let r=Sr(t.entries),n=new Set(r);e._zod.values=n,V(e,"pattern",o=>{let s=Sr(o.def.entries).filter(i=>ha.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>mt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Fp=_("$ZodLiteral",(e,t)=>{J.init(e,t);let r=new Set(t.values);e._zod.values=r,V(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?mt(s):s?mt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Vp=_("$ZodTransform",(e,t)=>{J.init(e,t),e._zod.optin="optional",Re.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Tr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new Xe;return r.value=o,r}});function Kf(e,t){return e.value=t.issues.length?void 0:t.value,e}var Za=_("$ZodOptional",(e,t)=>{J.init(e,t),V(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",V(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),V(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Kf(r,s)):Kf(r,o)}return t.innerType._zod.run(r,n)}}),Bp=_("$ZodExactOptional",(e,t)=>{Za.init(e,t),V(e,"values",r=>r.def.innerType._zod.values),V(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Hp=_("$ZodNullable",(e,t)=>{J.init(e,t),V(e,"optin",r=>r.def.innerType._zod.optin),V(e,"optout",r=>r.def.innerType._zod.optout),V(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)}|null)$`):void 0}),V(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Kp=_("$ZodDefault",(e,t)=>{J.init(e,t),e._zod.optin="defaulted",V(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Jf(s,t)):Jf(o,t)}});function Jf(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Jp=_("$ZodPrefault",(e,t)=>{J.init(e,t),e._zod.optin="defaulted",V(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Wp=_("$ZodNonOptional",(e,t)=>{J.init(e,t),V(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Wf(s,e)):Wf(o,e)}});function Wf(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Gf(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Ge(o,n,Ae()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Gp=_("$ZodCatch",(e,t)=>{J.init(e,t),V(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),V(e,"optout",r=>r.def.innerType._zod.optout),V(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Gf(r,s,t,n)):Gf(r,o,t,n)}});var Ma=_("$ZodPipe",(e,t)=>{J.init(e,t),V(e,"values",r=>r.def.in._zod.values),V(e,"optin",r=>r.def.in._zod.optin),V(e,"optout",r=>r.def.out._zod.optout),V(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>is(i,t.in,n)):is(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>is(s,t.out,n)):is(o,t.out,n)}});function is(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Xp=_("$ZodPreprocess",(e,t)=>{Ma.init(e,t)}),Yp=_("$ZodReadonly",(e,t)=>{J.init(e,t),V(e,"propValues",r=>r.def.innerType._zod.propValues),V(e,"values",r=>r.def.innerType._zod.values),V(e,"optin",r=>r.def.innerType?._zod?.optin),V(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Xf):Xf(o)}});function Xf(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Qp=_("$ZodCustom",(e,t)=>{me.init(e,t),J.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Yf(s,r,n,e));Yf(o,r,n,e)}});function Yf(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Er(o))}}var La=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},Ua="~memo",eh=[];function th(e){return e!==null&&typeof e=="object"}function Da(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var rh=new WeakMap,wn=0,ps=1,xn=2;function hs(e,t,r){let n=rh.get(e);if(n!==void 0)return n?xn:wn;if(t.has(e))return xn;t.add(e);let o=wn,s=l=>{if(o!==xn&&l?._zod){let d=hs(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let p=wn;for(let f of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,f);if(d&&!h.enumerable)continue;let m=h.get?ps:h.value?._zod?hs(h.value,t,r):wn;m>p&&(p=m)}return p},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Pr(c);a(l?i(l,!0):ps),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?hs(l,t,!1):ps);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let p=d.value;if(!(!p||typeof p!="object")){if(p._zod)s(p);else if(Array.isArray(p))for(let f of p)s(f)}}}return t.delete(e),Mw(e,o)}function Mw(e,t){return t!==ps&&rh.set(e,t===xn),t}function Dw(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var ds,fs=[],Lw={alloc(e,t,r){let n=ds;if(!n)return r;ds=void 0;let o={value:r,issues:null};return n.set(t.value,o),fs.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Uw(s,o.value))throw new La;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let w=hs(e,new Set,!1);if(w===wn)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);w===xn||n?r=!0:n=!0}let l=c.value;if(!th(l))return i(c,u);let d=u[Ua];d||(d={buckets:new WeakMap,backEdges:void 0},u[Ua]=d);let p;o===u?p=s:(p=Dw(d,e),o=u,s=p);let f=p.get(l);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...Da(f.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value)),c;ds=p;let h=fs.length,m=i(c,u);ds=void 0;let y=fs.length>h?fs.pop():void 0;return m instanceof Promise?m.then(w=>(y&&(y.issues=w.issues.length?Da(w.issues):eh),w)):(y&&(y.issues=m.issues.length?Da(m.issues):eh),m)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function qa(){return Lw}function Uw(e,t){let r=e[Ua]?.backEdges;return r!==void 0&&th(t)&&r.has(t)}var qw=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=ya(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${Ko(s.values[0])}`:`Invalid option: expected one of ${Bo(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Bo(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function nh(){return{localeError:qw()}}var oh;var Fa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function sh(){return new Fa}(oh=globalThis).__zod_globalRegistry??(oh.__zod_globalRegistry=sh());var It=globalThis.__zod_globalRegistry;function ms(e){return e.checks&&(e.checks=[...e.checks]),e}function ih(e,t){return new e(ms({type:"string",...R(t)}))}function ah(e,t){return new e(ms({type:"string",coerce:!0,...R(t)}))}function ch(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...R(t)})}function uh(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...R(t)})}function lh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...R(t)})}function dh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...R(t)})}function fh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...R(t)})}function ph(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...R(t)})}function Va(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...R(t)})}function hh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...R(t)})}function mh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...R(t)})}function gh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...R(t)})}function yh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...R(t)})}function _h(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...R(t)})}function bh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...R(t)})}function wh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...R(t)})}function xh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...R(t)})}function vh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...R(t)})}function $h(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...R(t)})}function Sh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...R(t)})}function zh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...R(t)})}function kh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...R(t)})}function Ph(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...R(t)})}function Eh(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...R(t)})}function gs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...R(t)})}function ys(e,t){return new e({type:"string",format:"date",check:"string_format",...R(t)})}function _s(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...R(t)})}function bs(e,t){return new e({type:"string",format:"duration",check:"string_format",...R(t)})}function Th(e,t){return new e(ms({type:"number",checks:[],...R(t)}))}function Oh(e,t){return new e(ms({type:"number",coerce:!0,checks:[],...R(t)}))}function Rh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...R(t)})}function Ah(e,t){return new e({type:"boolean",...R(t)})}function Ih(e,t){return new e({type:"boolean",coerce:!0,...R(t)})}function Ch(e,t){return new e({type:"bigint",coerce:!0,...R(t)})}function Nh(e,t){return new e({type:"null",...R(t)})}function jh(e){return new e({type:"any"})}function Zh(e){return new e({type:"unknown"})}function Mh(e,t){return new e({type:"never",...R(t)})}function Dh(e,t){return new e({type:"date",coerce:!0,...R(t)})}function Rr(e,t){return new Oa({check:"less_than",...R(t),value:e,inclusive:!1})}function yt(e,t){return new Oa({check:"less_than",...R(t),value:e,inclusive:!0})}function Ar(e,t){return new Ra({check:"greater_than",...R(t),value:e,inclusive:!1})}function _t(e,t){return new Ra({check:"greater_than",...R(t),value:e,inclusive:!0})}function vn(e,t){return new Tf({check:"multiple_of",...R(t),value:e})}function ws(e,t){return new Rf({check:"max_length",...R(t),maximum:e})}function Ir(e,t){return new Af({check:"min_length",...R(t),minimum:e})}function xs(e,t){return new If({check:"length_equals",...R(t),length:e})}function Ba(e,t){return new Cf({check:"string_format",format:"regex",...R(t),pattern:e})}function Ha(e){return new Nf({check:"string_format",format:"lowercase",...R(e)})}function Ka(e){return new jf({check:"string_format",format:"uppercase",...R(e)})}function Ja(e,t){return new Zf({check:"string_format",format:"includes",...R(t),includes:e})}function Wa(e,t){return new Mf({check:"string_format",format:"starts_with",...R(t),prefix:e})}function Ga(e,t){return new Df({check:"string_format",format:"ends_with",...R(t),suffix:e})}function Ct(e){return new Lf({check:"overwrite",tx:e})}function Xa(e){return Ct(t=>t.normalize(e))}function Ya(){return Ct(e=>e.trim())}function Qa(){return Ct(e=>e.toLowerCase())}function ec(){return Ct(e=>e.toUpperCase())}function tc(){return Ct(e=>fa(e))}function Lh(e,t,r){return new e({type:"array",element:t,...R(r)})}function Uh(e,t,r){let n=R(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function qh(e,t,r){return new e({type:"custom",check:"custom",fn:t,...R(r)})}function Fh(e,t){let r=Fw(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Er(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Er(s))}},e(n.value,n)),t);return r}function Fw(e,t){let r=new me({check:"custom",...R(t)});return r._zod.check=e,r}function $n(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&De(e,n,r[n]);return e}function nc(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??It,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ye(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ue(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let p=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ue(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&$n(i.schema,c),t.io==="input"&&Pe(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Vh(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function oc(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,p=e.external.uri??(h=>h);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${Vh(f)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Vh(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
67
|
+
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},i,a=cr,c=!Ze.jitless,l=c&&ja.value,d=t.catchall,p;e._zod.parse=(f,h)=>{p??(p=n.value);let m=f.value;return a(m)?c&&l&&h?.async===!1&&h.jitless!==!0?(i||(i=s(t.shape)),f=i(f,h),d?yh([],m,f,h,p,e,h?.abortEarly===!0):f):r(f,h):(f.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),f)}});function zp(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!nt(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>ot(i,n,De())))}),t)}var sc=b("$ZodUnion",(e,t)=>{Q.init(e,t),G(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),G(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),G(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),G(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Rn(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>zp(a,n,e,o)):zp(i,n,e,o)}});function kx(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var bh=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,sc.init(e,t);let r=e._zod.parse;G(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||Ve(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Mr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=Dr(()=>kx(t));e._zod.parse=(o,s)=>{let i=o.value;if(!cr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),wh=b("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>kp(r,c,u)):kp(r,s,i)}});function tc(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Mt(e)&&Mt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=tc(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=tc(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function kp(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let p=String(u.path[0]);s.has(p)||s.set(p,u),d=[p]}else return!1;for(let p of d)n.has(p)||n.set(p,{}),n.get(p)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=tc(t.value,r.value);if(!c.valid){if(nt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var xh=b("$ZodRecord",(e,t)=>{Q.init(e,t);let r=Ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Mt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>ot(h,o,De())),input:l,path:[l],inst:e});continue}let p=d.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},o);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...$t(l,h.issues)),n.value[p]=h.value})):(f.issues.length&&n.issues.push(...$t(l,f.issues)),n.value[p]=f.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&jn.test(u)&&l.issues.length){let h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>ot(h,o,De())),input:u,path:[u],inst:e});continue}let p=l.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},o);f instanceof Promise?i.push(f.then(h=>{h.issues.length&&n.issues.push(...$t(u,h.issues)),n.value[p]=h.value})):(f.issues.length&&n.issues.push(...$t(u,f.issues)),n.value[p]=f.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var vh=b("$ZodEnum",(e,t)=>{Q.init(e,t);let r=jr(t.entries),n=new Set(r);e._zod.values=n,G(e,"pattern",o=>{let s=jr(o.def.entries).filter(i=>Za.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>vt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),$h=b("$ZodLiteral",(e,t)=>{Q.init(e,t);let r=new Set(t.values);e._zod.values=r,G(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?vt(s):s?vt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Sh=b("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.optin="optional",Ze.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ur(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new st;return r.value=o,r}});function Pp(e,t){return e.value=t.issues.length?void 0:t.value,e}var ic=b("$ZodOptional",(e,t)=>{Q.init(e,t),G(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",G(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),G(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Rn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Pp(r,s)):Pp(r,o)}return t.innerType._zod.run(r,n)}}),zh=b("$ZodExactOptional",(e,t)=>{ic.init(e,t),G(e,"values",r=>r.def.innerType._zod.values),G(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),kh=b("$ZodNullable",(e,t)=>{Q.init(e,t),G(e,"optin",r=>r.def.innerType._zod.optin),G(e,"optout",r=>r.def.innerType._zod.optout),G(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Rn(n.source)}|null)$`):void 0}),G(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Ph=b("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="defaulted",G(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ep(s,t)):Ep(o,t)}});function Ep(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Eh=b("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="defaulted",G(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Th=b("$ZodNonOptional",(e,t)=>{Q.init(e,t),G(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Tp(s,e)):Tp(o,e)}});function Tp(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Op(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>ot(o,n,De()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Oh=b("$ZodCatch",(e,t)=>{Q.init(e,t),G(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),G(e,"optout",r=>r.def.innerType._zod.optout),G(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Op(r,s,t,n)):Op(r,o,t,n)}});var ac=b("$ZodPipe",(e,t)=>{Q.init(e,t),G(e,"values",r=>r.def.in._zod.values),G(e,"optin",r=>r.def.in._zod.optin),G(e,"optout",r=>r.def.out._zod.optout),G(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Ps(i,t.in,n)):Ps(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Ps(s,t.out,n)):Ps(o,t.out,n)}});function Ps(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Rh=b("$ZodPreprocess",(e,t)=>{ac.init(e,t)}),Ah=b("$ZodReadonly",(e,t)=>{Q.init(e,t),G(e,"propValues",r=>r.def.innerType._zod.propValues),G(e,"values",r=>r.def.innerType._zod.values),G(e,"optin",r=>r.def.innerType?._zod?.optin),G(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Rp):Rp(o)}});function Rp(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Ch=b("$ZodCustom",(e,t)=>{xe.init(e,t),Q.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Ap(s,r,n,e));Ap(o,r,n,e)}});function Ap(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Lr(o))}}var uc=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},lc="~memo",Ih=[];function Nh(e){return e!==null&&typeof e=="object"}function cc(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var jh=new WeakMap,Dn=0,Is=1,Mn=2;function Ns(e,t,r){let n=jh.get(e);if(n!==void 0)return n?Mn:Dn;if(t.has(e))return Mn;t.add(e);let o=Dn,s=l=>{if(o!==Mn&&l?._zod){let d=Ns(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let p=Dn;for(let f of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,f);if(d&&!h.enumerable)continue;let m=h.get?Is:h.value?._zod?Ns(h.value,t,r):Dn;m>p&&(p=m)}return p},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Mr(c);a(l?i(l,!0):Is),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Ns(l,t,!1):Is);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let p=d.value;if(!(!p||typeof p!="object")){if(p._zod)s(p);else if(Array.isArray(p))for(let f of p)s(f)}}}return t.delete(e),Px(e,o)}function Px(e,t){return t!==Is&&jh.set(e,t===Mn),t}function Ex(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var As,Cs=[],Tx={alloc(e,t,r){let n=As;if(!n)return r;As=void 0;let o={value:r,issues:null};return n.set(t.value,o),Cs.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Ox(s,o.value))throw new uc;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let _=Ns(e,new Set,!1);if(_===Dn)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);_===Mn||n?r=!0:n=!0}let l=c.value;if(!Nh(l))return i(c,u);let d=u[lc];d||(d={buckets:new WeakMap,backEdges:void 0},u[lc]=d);let p;o===u?p=s:(p=Ex(d,e),o=u,s=p);let f=p.get(l);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...cc(f.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value)),c;As=p;let h=Cs.length,m=i(c,u);As=void 0;let y=Cs.length>h?Cs.pop():void 0;return m instanceof Promise?m.then(_=>(y&&(y.issues=_.issues.length?cc(_.issues):Ih),_)):(y&&(y.issues=m.issues.length?cc(m.issues):Ih),m)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function dc(){return Tx}function Ox(e,t){let r=e[lc]?.backEdges;return r!==void 0&&Nh(t)&&r.has(t)}var Rx=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=La(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${hs(s.values[0])}`:`Invalid option: expected one of ${fs(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${fs(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Zh(){return{localeError:Rx()}}var Dh;var fc=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Mh(){return new fc}(Dh=globalThis).__zod_globalRegistry??(Dh.__zod_globalRegistry=Mh());var Lt=globalThis.__zod_globalRegistry;function js(e){return e.checks&&(e.checks=[...e.checks]),e}function Lh(e,t){return new e(js({type:"string",...I(t)}))}function Uh(e,t){return new e(js({type:"string",coerce:!0,...I(t)}))}function qh(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...I(t)})}function Fh(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...I(t)})}function Bh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...I(t)})}function Vh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(t)})}function Hh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(t)})}function Kh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(t)})}function pc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...I(t)})}function Jh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...I(t)})}function Wh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(t)})}function Gh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...I(t)})}function Xh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(t)})}function Yh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...I(t)})}function Qh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...I(t)})}function em(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(t)})}function tm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(t)})}function rm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(t)})}function nm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(t)})}function om(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(t)})}function sm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...I(t)})}function im(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...I(t)})}function am(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...I(t)})}function cm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...I(t)})}function Zs(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(t)})}function Ds(e,t){return new e({type:"string",format:"date",check:"string_format",...I(t)})}function Ms(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...I(t)})}function Ls(e,t){return new e({type:"string",format:"duration",check:"string_format",...I(t)})}function um(e,t){return new e(js({type:"number",checks:[],...I(t)}))}function lm(e,t){return new e(js({type:"number",coerce:!0,checks:[],...I(t)}))}function dm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...I(t)})}function fm(e,t){return new e({type:"boolean",...I(t)})}function pm(e,t){return new e({type:"boolean",coerce:!0,...I(t)})}function hm(e,t){return new e({type:"bigint",coerce:!0,...I(t)})}function mm(e,t){return new e({type:"null",...I(t)})}function gm(e){return new e({type:"any"})}function ym(e){return new e({type:"unknown"})}function _m(e,t){return new e({type:"never",...I(t)})}function bm(e,t){return new e({type:"date",coerce:!0,...I(t)})}function Fr(e,t){return new Qa({check:"less_than",...I(t),value:e,inclusive:!1})}function St(e,t){return new Qa({check:"less_than",...I(t),value:e,inclusive:!0})}function Br(e,t){return new ec({check:"greater_than",...I(t),value:e,inclusive:!1})}function zt(e,t){return new ec({check:"greater_than",...I(t),value:e,inclusive:!0})}function Ln(e,t){return new up({check:"multiple_of",...I(t),value:e})}function Us(e,t){return new dp({check:"max_length",...I(t),maximum:e})}function Vr(e,t){return new fp({check:"min_length",...I(t),minimum:e})}function qs(e,t){return new pp({check:"length_equals",...I(t),length:e})}function hc(e,t){return new hp({check:"string_format",format:"regex",...I(t),pattern:e})}function mc(e){return new mp({check:"string_format",format:"lowercase",...I(e)})}function gc(e){return new gp({check:"string_format",format:"uppercase",...I(e)})}function yc(e,t){return new yp({check:"string_format",format:"includes",...I(t),includes:e})}function _c(e,t){return new _p({check:"string_format",format:"starts_with",...I(t),prefix:e})}function bc(e,t){return new bp({check:"string_format",format:"ends_with",...I(t),suffix:e})}function Ut(e){return new wp({check:"overwrite",tx:e})}function wc(e){return Ut(t=>t.normalize(e))}function xc(){return Ut(e=>e.trim())}function vc(){return Ut(e=>e.toLowerCase())}function $c(){return Ut(e=>e.toUpperCase())}function Sc(){return Ut(e=>Na(e))}function wm(e,t,r){return new e({type:"array",element:t,...I(r)})}function xm(e,t,r){let n=I(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function vm(e,t,r){return new e({type:"custom",check:"custom",fn:t,...I(r)})}function $m(e,t){let r=Ax(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Lr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Lr(s))}},e(n.value,n)),t);return r}function Ax(e,t){let r=new xe({check:"custom",...I(t)});return r._zod.check=e,r}function Un(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&Ve(e,n,r[n]);return e}function kc(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Lt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function it(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function he(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let p=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),he(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Un(i.schema,c),t.io==="input"&&Ce(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Sm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Pc(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,p=e.external.uri??(h=>h);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${Sm(f)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Sm(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
65
68
|
|
|
66
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Kh(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Kh(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Jh=new Set(["type","properties","required","additionalProperties"]),Bh=["oneOf","anyOf"];function Hh(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function rc(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Jh.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Hh(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:rc(a)??{allOf:a};De(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Hh(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function Vw(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Jh)if(o in e)return;let r=t.filter(o=>Bh.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=rc(t);else{let o=r[0],s=Bh.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>rc([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,$n(e,n))}function sc(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let f=e.seen.get(d),h=f.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):$n(u,h),$n(u,l),a._zod.parent===d)for(let y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(h.$ref&&f.def)for(let y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=e.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let h in u)h==="$ref"||h==="allOf"||h in f.def&&JSON.stringify(u[h])===JSON.stringify(f.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Kh(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Vw(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}$n(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,De(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Sn(t,"input",e.processors),output:Sn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Pe(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Pe(n.element,r);if(n.type==="set")return Pe(n.valueType,r);if(n.type==="lazy")return Pe(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Pe(n.innerType,r);if(n.type==="intersection")return Pe(n.left,r)||Pe(n.right,r);if(n.type==="record"||n.type==="map")return Pe(n.keyType,r)||Pe(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Pe(n.in,r)||Pe(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Pe(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Pe(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Pe(o,r))return!0;return!!(n.rest&&Pe(n.rest,r))}return!1}var Wh=(e,t={})=>r=>{let n=nc({...r,processors:t});return ue(e,n),oc(n,e),sc(n,e)},Sn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=nc({...o??{},target:s,io:t,processors:r});return ue(e,i),oc(i,e),sc(i,e)};var Cr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Nr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Gh=(e,t)=>{Cr(e,"minimum",t),Nr(e,"maximum",t)},em=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},tm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},rm=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},nm=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Xh=(e,t)=>Cr(e,"minimum",t.minimum),Yh=(e,t)=>Nr(e,"maximum",t.maximum),Qh=e=>(t,r)=>{nm(t,r.format);let[n,o]=e[r.format];Cr(t,"minimum",n),Nr(t,"maximum",o)},Bw={greater_than:(e,t)=>Cr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Nr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>em(e,t.value),number_format:Qh(hn),bigint_format:Qh(Jo),min_length:Xh,max_length:Yh,length_equals:(e,t)=>Gh(e,t.length),min_size:Xh,max_size:Yh,size_equals:(e,t)=>Gh(e,t.size),string_format:(e,t)=>{nm(e,t.format),t.pattern&&tm(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>rm(e,t.mime)};function ge(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Bw[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&Cr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Cr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Nr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Nr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&em(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&rm(t,o.mime);for(let s of o.patterns??[])tm(t,s);return t}var Hw={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Kw=new Map([[Ca,mf],[ls,gf]]),om=e=>Kw.get(e)??e,sm=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ge(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Hw[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(om);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},im=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ge(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),p=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d?f?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let h=new Set;for(let w of a)Number.isFinite(w)&&w!==0?h.add(Math.abs(w)):Ye(e,t,o,n,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[m,...y]=h;m!==void 0&&(o.multipleOf=m),y.length&&(o.allOf=[...o.allOf??[],...y.map(w=>({multipleOf:w}))])}},am=(e,t,r,n)=>{r.type="boolean"},cm=(e,t,r,n)=>{Ye(e,t,r,n,"BigInt cannot be represented in JSON Schema")};var um=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var lm=(e,t,r,n)=>{r.not={}},dm=(e,t,r,n)=>{},fm=(e,t,r,n)=>{},pm=(e,t,r,n)=>{Ye(e,t,r,n,"Date cannot be represented in JSON Schema")},hm=(e,t,r,n)=>{let o=e._zod.def,s=Sr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},mm=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Ye(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Ye(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var gm=(e,t,r,n)=>{Ye(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var ym=(e,t,r,n)=>{Ye(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var _m=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ge(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ue(s.element,t,{...n,path:[...n.path,"items"]})};function vs(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?vs(t.out):t.type==="catch"?vs(t.innerType):e._zod.optin}var bm=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ye(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)De(o.properties,u,ue(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?vs(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ue(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},wm=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ue(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},xm=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ue(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function ic(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let m=ic(e,h,r);return m===h?t:m}for(let h of["anyOf","oneOf"]){let m=t[h];if(!Array.isArray(m))continue;let y=m.map(w=>ic(e,w,r));y.some((w,v)=>w!==m[v])&&(t={...t,[h]:y})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(h=>h==="number"||h==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(h=>typeof h=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:p,...f}=t;return f.enum?f.enum=f.enum.map(h=>typeof h=="number"?String(h):h):typeof f.const=="number"&&(f.const=String(f.const)),o&&(f.type="string",s||(f.pattern=(n.includes("number")?_n:Ea).source)),f}var ac=new WeakMap;function Jw(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of ac.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=ic(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var vm=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ge(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ue(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)De(o.patternProperties,om(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ue(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=ac.get(t);l||(l=[],ac.set(t,l),t.deferred.push(()=>Jw(t))),l.push(e)}o.additionalProperties=ue(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&vs(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},$m=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},Sm=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},cc=Symbol();function zm(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Ye(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),cc):JSON.parse(i)}var km=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=zm(o.defaultValue,e,t,r,n);i!==cc&&(r.default=i)},Pm=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=zm(o.defaultValue,e,t,r,n);i!==cc&&(r._prefault=i)},Em=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ye(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Tm=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ue(i,t,n);let a=t.seen.get(e);a.ref=i},Om=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var uc=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function $s(e){return!!e._zod}function Ee(e,t){return $s(e)?za(e,t):e.safeParse(t)}function Zr(e){if(!e)return;let t;if($s(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Mr(e){if($s(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var Rm=new WeakSet([Object.prototype,Error.prototype]);function Ss(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var ox=(e,t)=>{qd.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Rm.has(r)||(Rm.add(r),Ss(r,"format",n=>o=>Sa(n,o)),Ss(r,"flatten",n=>o=>$a(n,o)),Ss(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,zr,2)}),Ss(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,zr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Le=_("ZodError",ox,void 0,{Parent:Error});var Am=Qo(Le),Im=es(Le),Cm=yn(Le),Nm=ts(Le),jm=Bd(Le),Zm=Hd(Le),Mm=Kd(Le),Dm=Jd(Le),Lm=Wd(Le),Um=Gd(Le),qm=Xd(Le),Fm=Yd(Le);function ix(){Re.localeError||Ae(nh())}function ks(){Re.memoizer||Ae({memoizer:qa()})}var G=_("ZodType",(e,t)=>(ix(),J.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(C.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return qe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Kx(e,t))},superRefine(e,t){return this.check(Jx(e,t))},overwrite(e){return this.check(Ct(e))},optional(){return ie(this)},exactOptional(){return Nx(this)},nullable(){return Hm(this)},nullish(){return ie(Hm(this))},nonoptional(e){return Ux(this,e)},array(){return $(this)},or(e){return te([this,e])},and(e){return Es(this,e)},transform(e){return Km(this,ng(e))},default(e){return Mx(this,e)},prefault(e){return Lx(this,e)},catch(e){return Fx(this,e)},pipe(e){return Km(this,e)},readonly(){return Hx(this)},describe(e){let t=this.clone();return It.add(t,{description:e}),t},meta(...e){if(e.length===0)return It.get(this);let t=this.clone();return It.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return C.hide(this,"~standard",{...Ia(this),jsonSchema:{input:Sn(this,"input"),output:Sn(this,"output")}})},set"~standard"(e){C.own(this,"~standard",e)},parse:function e(t,r){return Am(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Im(this,t,r,{callee:e})},safeParse(e,t){return Cm(this,e,t)},async safeParseAsync(e,t){return Nm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){C.own(this,"spa",e)},validate(e,t){return rs(this,e,t)},validateAsync(e,t){return ns(this,e,t)},encode:function e(t,r){return jm(this,t,r,{callee:e})},decode:function e(t,r){return Zm(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Mm(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Dm(this,t,r,{callee:e})},safeEncode(e,t){return Lm(this,e,t)},safeDecode(e,t){return Um(this,e,t)},async safeEncodeAsync(e,t){return qm(this,e,t)},async safeDecodeAsync(e,t){return Fm(this,e,t)},toJSONSchema(e){return Wh(this,{})(e)},get description(){return It.get(this)?.description},get _def(){return this._zod.def}}),Jm=_("_ZodString",(e,t)=>{us.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sm(e,r,n,o)},C.derived({format:e=>ge(e).format??null,minLength:e=>ge(e).minimum??null,maxLength:e=>ge(e).maximum??null},{regex(...e){return this.check(Ba(...e))},includes(...e){return this.check(Ja(...e))},startsWith(...e){return this.check(Wa(...e))},endsWith(...e){return this.check(Ga(...e))},min(...e){return this.check(Ir(...e))},max(...e){return this.check(ws(...e))},length(...e){return this.check(xs(...e))},nonempty(...e){return this.check(Ir(1,...e))},lowercase(e){return this.check(Ha(e))},uppercase(e){return this.check(Ka(e))},trim(){return this.check(Ya())},normalize(...e){return this.check(Xa(...e))},toLowerCase(){return this.check(Qa())},toUpperCase(){return this.check(ec())},slugify(){return this.check(tc())}})),dc=_("ZodString",(e,t)=>{us.init(e,t),Jm.init(e,t)},{email(e){return this.check(ch(ax,e))},url(e){return this.check(Va(Wm,e))},jwt(e){return this.check(Eh($x,e))},emoji(e){return this.check(hh(ux,e))},guid(e){return this.check(uh(cx,e))},uuid(e){return this.check(lh(zs,e))},uuidv4(e){return this.check(dh(zs,e))},uuidv6(e){return this.check(fh(zs,e))},uuidv7(e){return this.check(ph(zs,e))},nanoid(e){return this.check(mh(lx,e))},cuid(e){return this.check(gh(dx,e))},cuid2(e){return this.check(yh(fx,e))},ulid(e){return this.check(_h(px,e))},base64(e){return this.check(zh(wx,e))},base64url(e){return this.check(kh(xx,e))},xid(e){return this.check(bh(hx,e))},ksuid(e){return this.check(wh(mx,e))},ipv4(e){return this.check(xh(gx,e))},ipv6(e){return this.check(vh(yx,e))},cidrv4(e){return this.check($h(_x,e))},cidrv6(e){return this.check(Sh(bx,e))},e164(e){return this.check(Ph(vx,e))},datetime(e){return this.check(gs(zn,e))},date(e){return this.check(ys(kn,e))},time(e){return this.check(_s(Pn,e))},duration(e){return this.check(bs(En,e))}});function g(e){return ih(dc,e)}var ae=_("ZodStringFormat",(e,t)=>{ee.init(e,t),Jm.init(e,t)}),zn=_("ZodISODateTime",(e,t)=>{pp.init(e,t),ae.init(e,t)}),kn=_("ZodISODate",(e,t)=>{hp.init(e,t),ae.init(e,t)}),Pn=_("ZodISOTime",(e,t)=>{mp.init(e,t),ae.init(e,t)}),En=_("ZodISODuration",(e,t)=>{gp.init(e,t),ae.init(e,t)}),ax=_("ZodEmail",(e,t)=>{rp.init(e,t),ae.init(e,t)});var cx=_("ZodGUID",(e,t)=>{ep.init(e,t),ae.init(e,t)});var zs=_("ZodUUID",(e,t)=>{tp.init(e,t),ae.init(e,t)});var Wm=_("ZodURL",(e,t)=>{sp.init(e,t),ae.init(e,t)});function Gm(e){return Va(Wm,e)}var ux=_("ZodEmoji",(e,t)=>{ip.init(e,t),ae.init(e,t)});var lx=_("ZodNanoID",(e,t)=>{ap.init(e,t),ae.init(e,t)});var dx=_("ZodCUID",(e,t)=>{cp.init(e,t),ae.init(e,t)});var fx=_("ZodCUID2",(e,t)=>{up.init(e,t),ae.init(e,t)});var px=_("ZodULID",(e,t)=>{lp.init(e,t),ae.init(e,t)});var hx=_("ZodXID",(e,t)=>{dp.init(e,t),ae.init(e,t)});var mx=_("ZodKSUID",(e,t)=>{fp.init(e,t),ae.init(e,t)});var gx=_("ZodIPv4",(e,t)=>{yp.init(e,t),ae.init(e,t)});var yx=_("ZodIPv6",(e,t)=>{bp.init(e,t),ae.init(e,t)});var _x=_("ZodCIDRv4",(e,t)=>{wp.init(e,t),ae.init(e,t)});var bx=_("ZodCIDRv6",(e,t)=>{xp.init(e,t),ae.init(e,t)});var wx=_("ZodBase64",(e,t)=>{$p.init(e,t),ae.init(e,t)});var xx=_("ZodBase64URL",(e,t)=>{Sp.init(e,t),ae.init(e,t)});var vx=_("ZodE164",(e,t)=>{zp.init(e,t),ae.init(e,t)});var $x=_("ZodJWT",(e,t)=>{kp.init(e,t),ae.init(e,t)});var Ps=_("ZodNumber",(e,t)=>{Na.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>im(e,r,n,o),e.isFinite=!0},C.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ge(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ge(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=ge(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ge(e).format??null},{gt(e,t){return this.check(Ar(e,t))},gte(e,t){return this.check(_t(e,t))},min(e,t){return this.check(_t(e,t))},lt(e,t){return this.check(Rr(e,t))},lte(e,t){return this.check(yt(e,t))},max(e,t){return this.check(yt(e,t))},int(e){return this.check(Vm(e))},safe(e){return this.check(Vm(e))},positive(e){return this.check(Ar(0,e))},nonnegative(e){return this.check(_t(0,e))},negative(e){return this.check(Rr(0,e))},nonpositive(e){return this.check(yt(0,e))},multipleOf(e,t){return this.check(vn(e,t))},step(e,t){return this.check(vn(e,t))},finite(){return this}}));function B(e){return Th(Ps,e)}var Sx=_("ZodNumberFormat",(e,t)=>{Pp.init(e,t),Ps.init(e,t)});function Vm(e){return Rh(Sx,e)}var fc=_("ZodBoolean",(e,t)=>{Ep.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>am(e,r,n,o)});function X(e){return Ah(fc,e)}var Xm=_("ZodBigInt",(e,t)=>{Tp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cm(e,r,n,o)},C.derived({minValue:e=>ge(e).minimum??null,maxValue:e=>ge(e).maximum??null,format:e=>ge(e).format??null},{gte(e,t){return this.check(_t(e,t))},min(e,t){return this.check(_t(e,t))},gt(e,t){return this.check(Ar(e,t))},lt(e,t){return this.check(Rr(e,t))},lte(e,t){return this.check(yt(e,t))},max(e,t){return this.check(yt(e,t))},positive(e){return this.check(Ar(BigInt(0),e))},negative(e){return this.check(Rr(BigInt(0),e))},nonpositive(e){return this.check(yt(BigInt(0),e))},nonnegative(e){return this.check(_t(BigInt(0),e))},multipleOf(e,t){return this.check(vn(e,t))}}));var zx=_("ZodNull",(e,t)=>{Op.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>um(e,r,n,o)});function Ym(e){return Nh(zx,e)}var kx=_("ZodAny",(e,t)=>{Rp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dm(e,r,n,o)});function Qm(){return jh(kx)}var Px=_("ZodUnknown",(e,t)=>{Ap.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fm(e,r,n,o)});function se(){return Zh(Px)}var Ex=_("ZodNever",(e,t)=>{Ip.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lm(e,r,n,o)});function Tx(e){return Mh(Ex,e)}var eg=_("ZodDate",(e,t)=>{Cp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pm(e,r,n,o),e.min=(r,n)=>e.check(_t(r,n)),e.max=(r,n)=>e.check(yt(r,n))},C.derived({minDate:e=>{let{minimum:t}=ge(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=ge(e);return t?new Date(t):null}},{}));var Ox=_("ZodArray",(e,t)=>{ks(),Np.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_m(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Ir(e,t))},nonempty(e){return this.check(Ir(1,e))},max(e,t){return this.check(ws(e,t))},length(e,t){return this.check(xs(e,t))},unwrap(){return this.element}});function $(e,t){return Lh(Ox,e,t)}var tg=_("ZodObject",(e,t)=>{ks(),Mp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bm(e,r,n,o),C.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Ie(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(C.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(C.mergeDefs(this._zod.def,{catchall:se()}))},loose(){return this.clone(C.mergeDefs(this._zod.def,{catchall:se()}))},strict(){return this.clone(C.mergeDefs(this._zod.def,{catchall:Tx()}))},strip(){return this.clone(C.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return C.extend(this,e)},safeExtend(e){return C.safeExtend(this,e)},merge(e){return C.merge(this,e)},pick(e){return C.pick(this,e)},omit(e){return C.omit(this,e)},partial(...e){return C.partial(og,this,e[0])},exactPartial(...e){return C.partial(sg,this,e[0],"exactPartial")},required(...e){return C.required(ig,this,e[0])}});function S(e,t){let r={type:"object",shape:e??{},...C.normalizeParams(t)};return new tg(r)}function fe(e,t){return new tg({type:"object",shape:e,catchall:se(),...C.normalizeParams(t)})}var rg=_("ZodUnion",(e,t)=>{ja.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wm(e,r,n,o),e.options=t.options});function te(e,t){return new rg({type:"union",options:e,...C.normalizeParams(t)})}var Rx=_("ZodDiscriminatedUnion",(e,t)=>{rg.init(e,t),Dp.init(e,t)});function pc(e,t,r){return new Rx({type:"union",options:t,discriminator:e,...C.normalizeParams(r)})}var Ax=_("ZodIntersection",(e,t)=>{Lp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xm(e,r,n,o)});function Es(e,t){return new Ax({type:"intersection",left:e,right:t})}var Bm=_("ZodRecord",(e,t)=>{ks(),Up.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vm(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Q(e,t,r){return!t||!t._zod?new Bm({type:"record",keyType:g(),valueType:e,...C.normalizeParams(t)}):new Bm({type:"record",keyType:e,valueType:t,...C.normalizeParams(r)})}var lc=_("ZodEnum",(e,t)=>{qp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(n,o,s)=>hm(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new lc({...t,checks:[],...C.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new lc({...t,checks:[],...C.normalizeParams(o),entries:s})}});function Ie(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new lc({type:"enum",entries:r,...C.normalizeParams(t)})}var Ix=_("ZodLiteral",(e,t)=>{Fp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mm(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function P(e,t){return new Ix({type:"literal",values:Array.isArray(e)?e:[e],...C.normalizeParams(t)})}var Cx=_("ZodTransform",(e,t)=>{ks(),Vp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ym(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Tr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(C.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(C.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function ng(e){return new Cx({type:"transform",transform:e})}var og=_("ZodOptional",(e,t)=>{Za.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ie(e){return new og({type:"optional",innerType:e})}var sg=_("ZodExactOptional",(e,t)=>{Bp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Nx(e){return new sg({type:"optional",innerType:e})}var jx=_("ZodNullable",(e,t)=>{Hp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$m(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Hm(e){return new jx({type:"nullable",innerType:e})}var Zx=_("ZodDefault",(e,t)=>{Kp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>km(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Mx(e,t){return new Zx({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():C.shallowClone(t)}})}var Dx=_("ZodPrefault",(e,t)=>{Jp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Lx(e,t){return new Dx({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():C.shallowClone(t)}})}var ig=_("ZodNonOptional",(e,t)=>{Wp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ux(e,t){return new ig({type:"nonoptional",innerType:e,...C.normalizeParams(t)})}var qx=_("ZodCatch",(e,t)=>{Gp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Em(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fx(e,t){return new qx({type:"catch",innerType:e,catchValue:typeof t=="function"?t:C.constantCatch(t)})}var ag=_("ZodPipe",(e,t)=>{Ma.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tm(e,r,n,o),e.in=t.in,e.out=t.out});function Km(e,t){return new ag({type:"pipe",in:e,out:t})}var Vx=_("ZodPreprocess",(e,t)=>{ag.init(e,t),Xp.init(e,t)}),Bx=_("ZodReadonly",(e,t)=>{Yp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Om(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Hx(e){return new Bx({type:"readonly",innerType:e})}var cg=_("ZodCustom",(e,t)=>{Qp.init(e,t),G.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gm(e,r,n,o)});function ug(e,t){return Uh(cg,e??(()=>!0),t)}function Kx(e,t={}){return qh(cg,e,t)}function Jx(e,t){return Fh(e,t)}function hc(e,t){return new Vx({type:"pipe",in:ng(e),out:t})}var dg={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var lg;lg||(lg={});var Ts={};oa(Ts,{ZodISODate:()=>kn,ZodISODateTime:()=>zn,ZodISODuration:()=>En,ZodISOTime:()=>Pn,date:()=>Xx,datetime:()=>Gx,duration:()=>Qx,time:()=>Yx});function Gx(e){return gs(zn,e)}function Xx(e){return ys(kn,e)}function Yx(e){return _s(Pn,e)}function Qx(e){return bs(En,e)}var Os={};oa(Os,{bigint:()=>nv,boolean:()=>rv,date:()=>ov,number:()=>tv,string:()=>ev});function ev(e){return ah(dc,e)}function tv(e){return Oh(Ps,e)}function rv(e){return Ih(fc,e)}function nv(e){return Ch(Xm,e)}function ov(e){return Dh(eg,e)}var Nt="2025-11-25";var As=[Nt,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],jt="io.modelcontextprotocol/related-task",Is="2.0",pe=ug(e=>e!==null&&(typeof e=="object"||typeof e=="function")),fg=te([g(),B().int()]),pg=g(),XA=fe({ttl:B().optional(),pollInterval:B().optional()}),iv=S({ttl:B().optional()}),av=S({taskId:g()}),gc=fe({progressToken:fg.optional(),[jt]:av.optional()}),Ue=S({_meta:gc.optional()}),Tn=Ue.extend({task:iv.optional()}),hg=e=>Tn.safeParse(e).success,ye=S({method:g(),params:Ue.loose().optional()}),Fe=S({_meta:gc.optional()}),Ve=S({method:g(),params:Fe.loose().optional()}),_e=fe({_meta:gc.optional()}),Cs=te([g(),B().int()]),mg=S({jsonrpc:P(Is),id:Cs,...ye.shape}).strict(),On=e=>mg.safeParse(e).success,gg=S({jsonrpc:P(Is),...Ve.shape}).strict(),yg=e=>gg.safeParse(e).success,yc=S({jsonrpc:P(Is),id:Cs,result:_e}).strict(),tr=e=>yc.safeParse(e).success;var I;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(I||(I={}));var _c=S({jsonrpc:P(Is),id:Cs.optional(),error:S({code:B().int(),message:g(),data:se().optional()})}).strict();var _g=e=>_c.safeParse(e).success;var Lr=te([mg,gg,yc,_c]),YA=te([yc,_c]),bt=_e.strict(),cv=Fe.extend({requestId:Cs.optional(),reason:g().optional()}),Ns=Ve.extend({method:P("notifications/cancelled"),params:cv}),uv=S({src:g(),mimeType:g().optional(),sizes:$(g()).optional(),theme:Ie(["light","dark"]).optional()}),Rn=S({icons:$(uv).optional()}),Dr=S({name:g(),title:g().optional()}),bg=Dr.extend({...Dr.shape,...Rn.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),lv=Es(S({applyDefaults:X().optional()}),Q(g(),se())),dv=hc(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Es(S({form:lv.optional(),url:pe.optional()}),Q(g(),se()).optional())),fv=fe({list:pe.optional(),cancel:pe.optional(),requests:fe({sampling:fe({createMessage:pe.optional()}).optional(),elicitation:fe({create:pe.optional()}).optional()}).optional()}),pv=fe({list:pe.optional(),cancel:pe.optional(),requests:fe({tools:fe({call:pe.optional()}).optional()}).optional()}),hv=S({experimental:Q(g(),pe).optional(),sampling:S({context:pe.optional(),tools:pe.optional()}).optional(),elicitation:dv.optional(),roots:S({listChanged:X().optional()}).optional(),tasks:fv.optional(),extensions:Q(g(),pe).optional()}),mv=Ue.extend({protocolVersion:g(),capabilities:hv,clientInfo:bg}),bc=ye.extend({method:P("initialize"),params:mv});var gv=S({experimental:Q(g(),pe).optional(),logging:pe.optional(),completions:pe.optional(),prompts:S({listChanged:X().optional()}).optional(),resources:S({subscribe:X().optional(),listChanged:X().optional()}).optional(),tools:S({listChanged:X().optional()}).optional(),tasks:pv.optional(),extensions:Q(g(),pe).optional()}),wc=_e.extend({protocolVersion:g(),capabilities:gv,serverInfo:bg,instructions:g().optional()}),js=Ve.extend({method:P("notifications/initialized"),params:Fe.optional()}),wg=e=>js.safeParse(e).success,Zs=ye.extend({method:P("ping"),params:Ue.optional()}),yv=S({progress:B(),total:ie(B()),message:ie(g())}),_v=S({...Fe.shape,...yv.shape,progressToken:fg}),Ms=Ve.extend({method:P("notifications/progress"),params:_v}),bv=Ue.extend({cursor:pg.optional()}),An=ye.extend({params:bv.optional()}),In=_e.extend({nextCursor:pg.optional()}),wv=Ie(["working","input_required","completed","failed","cancelled"]),Cn=S({taskId:g(),status:wv,ttl:te([B(),Ym()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:ie(B()),statusMessage:ie(g())}),wt=_e.extend({task:Cn}),xv=Fe.merge(Cn),Nn=Ve.extend({method:P("notifications/tasks/status"),params:xv}),Ds=ye.extend({method:P("tasks/get"),params:Ue.extend({taskId:g()})}),Ls=_e.merge(Cn),Us=ye.extend({method:P("tasks/result"),params:Ue.extend({taskId:g()})}),QA=_e.loose(),qs=An.extend({method:P("tasks/list")}),Fs=In.extend({tasks:$(Cn)}),Vs=ye.extend({method:P("tasks/cancel"),params:Ue.extend({taskId:g()})}),xg=_e.merge(Cn),vg=S({uri:g(),mimeType:ie(g()),_meta:Q(g(),se()).optional()}),$g=vg.extend({text:g()}),xc=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Sg=vg.extend({blob:xc}),jn=Ie(["user","assistant"]),Ur=S({audience:$(jn).optional(),priority:B().min(0).max(1).optional(),lastModified:Ts.datetime({offset:!0}).optional()}),zg=S({...Dr.shape,...Rn.shape,uri:g(),description:ie(g()),mimeType:ie(g()),size:ie(B()),annotations:Ur.optional(),_meta:ie(fe({}))}),vv=S({...Dr.shape,...Rn.shape,uriTemplate:g(),description:ie(g()),mimeType:ie(g()),annotations:Ur.optional(),_meta:ie(fe({}))}),$v=An.extend({method:P("resources/list")}),vc=In.extend({resources:$(zg)}),Sv=An.extend({method:P("resources/templates/list")}),$c=In.extend({resourceTemplates:$(vv)}),Sc=Ue.extend({uri:g()}),zv=Sc,kv=ye.extend({method:P("resources/read"),params:zv}),zc=_e.extend({contents:$(te([$g,Sg]))}),kc=Ve.extend({method:P("notifications/resources/list_changed"),params:Fe.optional()}),Pv=Sc,Ev=ye.extend({method:P("resources/subscribe"),params:Pv}),Tv=Sc,Ov=ye.extend({method:P("resources/unsubscribe"),params:Tv}),Rv=Fe.extend({uri:g()}),Av=Ve.extend({method:P("notifications/resources/updated"),params:Rv}),Iv=S({name:g(),description:ie(g()),required:ie(X())}),Cv=S({...Dr.shape,...Rn.shape,description:ie(g()),arguments:ie($(Iv)),_meta:ie(fe({}))}),Nv=An.extend({method:P("prompts/list")}),Pc=In.extend({prompts:$(Cv)}),jv=Ue.extend({name:g(),arguments:Q(g(),g()).optional()}),Zv=ye.extend({method:P("prompts/get"),params:jv}),Ec=S({type:P("text"),text:g(),annotations:Ur.optional(),_meta:Q(g(),se()).optional()}),Tc=S({type:P("image"),data:xc,mimeType:g(),annotations:Ur.optional(),_meta:Q(g(),se()).optional()}),Oc=S({type:P("audio"),data:xc,mimeType:g(),annotations:Ur.optional(),_meta:Q(g(),se()).optional()}),Mv=S({type:P("tool_use"),name:g(),id:g(),input:Q(g(),se()),_meta:Q(g(),se()).optional()}),Dv=S({type:P("resource"),resource:te([$g,Sg]),annotations:Ur.optional(),_meta:Q(g(),se()).optional()}),Lv=zg.extend({type:P("resource_link")}),Rc=te([Ec,Tc,Oc,Lv,Dv]),Uv=S({role:jn,content:Rc}),Ac=_e.extend({description:g().optional(),messages:$(Uv)}),Ic=Ve.extend({method:P("notifications/prompts/list_changed"),params:Fe.optional()}),qv=S({title:g().optional(),readOnlyHint:X().optional(),destructiveHint:X().optional(),idempotentHint:X().optional(),openWorldHint:X().optional()}),Fv=S({taskSupport:Ie(["required","optional","forbidden"]).optional()}),kg=S({...Dr.shape,...Rn.shape,description:g().optional(),inputSchema:S({type:P("object"),properties:Q(g(),pe).optional(),required:$(g()).optional()}).catchall(se()),outputSchema:S({type:P("object"),properties:Q(g(),pe).optional(),required:$(g()).optional()}).catchall(se()).optional(),annotations:qv.optional(),execution:Fv.optional(),_meta:Q(g(),se()).optional()}),Cc=An.extend({method:P("tools/list")}),Nc=In.extend({tools:$(kg)}),Zt=_e.extend({content:$(Rc).default([]),structuredContent:Q(g(),se()).optional(),isError:X().optional()}),eI=Zt.or(_e.extend({toolResult:se()})),Vv=Tn.extend({name:g(),arguments:Q(g(),se()).optional()}),Zn=ye.extend({method:P("tools/call"),params:Vv}),jc=Ve.extend({method:P("notifications/tools/list_changed"),params:Fe.optional()}),Pg=S({autoRefresh:X().default(!0),debounceMs:B().int().nonnegative().default(300)}),Mn=Ie(["debug","info","notice","warning","error","critical","alert","emergency"]),Bv=Ue.extend({level:Mn}),Zc=ye.extend({method:P("logging/setLevel"),params:Bv}),Hv=Fe.extend({level:Mn,logger:g().optional(),data:se()}),Kv=Ve.extend({method:P("notifications/message"),params:Hv}),Jv=S({name:g().optional()}),Wv=S({hints:$(Jv).optional(),costPriority:B().min(0).max(1).optional(),speedPriority:B().min(0).max(1).optional(),intelligencePriority:B().min(0).max(1).optional()}),Gv=S({mode:Ie(["auto","required","none"]).optional()}),Xv=S({type:P("tool_result"),toolUseId:g().describe("The unique identifier for the corresponding tool call."),content:$(Rc).default([]),structuredContent:S({}).loose().optional(),isError:X().optional(),_meta:Q(g(),se()).optional()}),Yv=pc("type",[Ec,Tc,Oc]),Rs=pc("type",[Ec,Tc,Oc,Mv,Xv]),Qv=S({role:jn,content:te([Rs,$(Rs)]),_meta:Q(g(),se()).optional()}),e$=Tn.extend({messages:$(Qv),modelPreferences:Wv.optional(),systemPrompt:g().optional(),includeContext:Ie(["none","thisServer","allServers"]).optional(),temperature:B().optional(),maxTokens:B().int(),stopSequences:$(g()).optional(),metadata:pe.optional(),tools:$(kg).optional(),toolChoice:Gv.optional()}),Mc=ye.extend({method:P("sampling/createMessage"),params:e$}),rr=_e.extend({model:g(),stopReason:ie(Ie(["endTurn","stopSequence","maxTokens"]).or(g())),role:jn,content:Yv}),Dn=_e.extend({model:g(),stopReason:ie(Ie(["endTurn","stopSequence","maxTokens","toolUse"]).or(g())),role:jn,content:te([Rs,$(Rs)])}),t$=S({type:P("boolean"),title:g().optional(),description:g().optional(),default:X().optional()}),r$=S({type:P("string"),title:g().optional(),description:g().optional(),minLength:B().optional(),maxLength:B().optional(),format:Ie(["email","uri","date","date-time"]).optional(),default:g().optional()}),n$=S({type:Ie(["number","integer"]),title:g().optional(),description:g().optional(),minimum:B().optional(),maximum:B().optional(),default:B().optional()}),o$=S({type:P("string"),title:g().optional(),description:g().optional(),enum:$(g()),default:g().optional()}),s$=S({type:P("string"),title:g().optional(),description:g().optional(),oneOf:$(S({const:g(),title:g()})),default:g().optional()}),i$=S({type:P("string"),title:g().optional(),description:g().optional(),enum:$(g()),enumNames:$(g()).optional(),default:g().optional()}),a$=te([o$,s$]),c$=S({type:P("array"),title:g().optional(),description:g().optional(),minItems:B().optional(),maxItems:B().optional(),items:S({type:P("string"),enum:$(g())}),default:$(g()).optional()}),u$=S({type:P("array"),title:g().optional(),description:g().optional(),minItems:B().optional(),maxItems:B().optional(),items:S({anyOf:$(S({const:g(),title:g()}))}),default:$(g()).optional()}),l$=te([c$,u$]),d$=te([i$,a$,l$]),f$=te([d$,t$,r$,n$]),p$=Tn.extend({mode:P("form").optional(),message:g(),requestedSchema:S({type:P("object"),properties:Q(g(),f$),required:$(g()).optional()})}),h$=Tn.extend({mode:P("url"),message:g(),elicitationId:g(),url:g().url()}),m$=te([p$,h$]),Dc=ye.extend({method:P("elicitation/create"),params:m$}),g$=Fe.extend({elicitationId:g()}),y$=Ve.extend({method:P("notifications/elicitation/complete"),params:g$}),Mt=_e.extend({action:Ie(["accept","decline","cancel"]),content:hc(e=>e===null?void 0:e,Q(g(),te([g(),B(),X(),$(g())])).optional())}),_$=S({type:P("ref/resource"),uri:g()});var b$=S({type:P("ref/prompt"),name:g()}),w$=Ue.extend({ref:te([b$,_$]),argument:S({name:g(),value:g()}),context:S({arguments:Q(g(),g()).optional()}).optional()}),x$=ye.extend({method:P("completion/complete"),params:w$});var Lc=_e.extend({completion:fe({values:$(g()).max(100),total:ie(B().int()),hasMore:ie(X())})}),v$=S({uri:g().startsWith("file://"),name:g().optional(),_meta:Q(g(),se()).optional()}),$$=ye.extend({method:P("roots/list"),params:Ue.optional()}),Uc=_e.extend({roots:$(v$)}),S$=Ve.extend({method:P("notifications/roots/list_changed"),params:Fe.optional()}),tI=te([Zs,bc,x$,Zc,Zv,Nv,$v,Sv,kv,Ev,Ov,Zn,Cc,Ds,Us,qs,Vs]),rI=te([Ns,Ms,js,S$,Nn]),nI=te([bt,rr,Dn,Mt,Uc,Ls,Fs,wt]),oI=te([Zs,Mc,Dc,$$,Ds,Us,qs,Vs]),sI=te([Ns,Ms,Kv,Av,kc,jc,Ic,Nn,y$]),iI=te([bt,wc,Lc,Ac,Pc,vc,$c,zc,Zt,Nc,Ls,Fs,wt]),E=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===I.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new mc(o.elicitations,r)}return new e(t,r,n)}},mc=class extends E{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(I.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Dt(e){return e==="completed"||e==="failed"||e==="cancelled"}var DI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function qc(e){let r=Zr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Mr(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Fc(e,t){let r=Ee(e,t);if(!r.success)throw r.error;return r.data}var O$=6e4,qr=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ns,r=>{this._oncancel(r)}),this.setNotificationHandler(Ms,r=>{this._onprogress(r)}),this.setRequestHandler(Zs,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ds,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new E(I.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Us,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new E(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new E(I.InvalidParams,`Task not found: ${s}`);if(!Dt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Dt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[jt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(qs,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new E(I.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Vs,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new E(I.InvalidParams,`Task not found: ${r.params.taskId}`);if(Dt(o.status))throw new E(I.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new E(I.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof E?o:new E(I.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),E.fromError(I.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),tr(s)||_g(s)?this._onresponse(s):On(s)?this._onrequest(s,i):yg(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=E.fromError(I.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[jt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:I.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);let a=hg(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new E(I.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:t.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let h=f.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:I.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),tr(t))n(t);else{let i=new E(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(tr(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),tr(t))o(t);else{let i=E.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof E?i:new E(I.InternalError,String(i))}}return}let s;try{let i=await this.request(t,wt,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new E(I.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Dt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new E(I.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new E(I.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof E?i:new E(I.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[jt]:c}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(A=>this._onerror(new Error(`Failed to send cancellation: ${A}`)));let z=v instanceof E?v:new E(I.RequestTimeout,String(v));l(z)};this._responseHandlers.set(p,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let z=Ee(r,v.result);z.success?u(z.data):l(z.error)}catch(z){l(z)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let m=n?.timeout??O$,y=()=>h(E.fromError(I.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(p,m,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let v=z=>{let A=this._responseHandlers.get(p);A?A(z):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(w,{type:"request",message:f,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(p),l(z)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(p),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Ls,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Fs,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},xg,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[jt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[jt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[jt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=qc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Fc(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=qc(t);this._notificationHandlers.set(n,o=>{let s=Fc(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&On(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new E(I.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new E(I.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new E(I.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new E(I.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=Nn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Dt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new E(I.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Dt(a.status))throw new E(I.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=Nn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Dt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Eg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Bs(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];Eg(i)&&Eg(s)?r[o]={...i,...s}:r[o]=s}return r}var P0=sa(Nl(),1),E0=sa(k0(),1);function UE(){let e=new P0.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,E0.default)(e),e}var an=class{constructor(t){this._ajv=t??UE()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ei=class{constructor(t){this._client=t}async*callToolStream(t,r=Zt,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(t.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:t},r,s),a=o.getToolOutputValidator(t.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new E(I.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new E(I.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof E){yield{type:"error",error:l};return}yield{type:"error",error:new E(I.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}};function Ti(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Oi(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function Ri(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,n=e.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&Ri(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&Ri(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&Ri(r,t)}}function qE(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}var Ai=class extends qr{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new an,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",jc,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ic,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",kc,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Ei(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Bs(this._capabilities,t)}setRequestHandler(t,r){let o=Zr(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Mr(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Ee(Dc,c);if(!l.success){let v=l.error instanceof Error?l.error.message:String(l.error);throw new E(I.InvalidParams,`Invalid elicitation request: ${v}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:p,supportsUrlMode:f}=qE(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new E(I.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!f)throw new E(I.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let v=Ee(wt,h);if(!v.success){let z=v.error instanceof Error?v.error.message:String(v.error);throw new E(I.InvalidParams,`Invalid task creation result: ${z}`)}return v.data}let m=Ee(Mt,h);if(!m.success){let v=m.error instanceof Error?m.error.message:String(m.error);throw new E(I.InvalidParams,`Invalid elicitation result: ${v}`)}let y=m.data,w=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&y.action==="accept"&&y.content&&w&&this._capabilities.elicitation?.form?.applyDefaults)try{Ri(w,y.content)}catch{}return y};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ee(Mc,c);if(!l.success){let y=l.error instanceof Error?l.error.message:String(l.error);throw new E(I.InvalidParams,`Invalid sampling request: ${y}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let y=Ee(wt,p);if(!y.success){let w=y.error instanceof Error?y.error.message:String(y.error);throw new E(I.InvalidParams,`Invalid task creation result: ${w}`)}return y.data}let h=d.tools||d.toolChoice?Dn:rr,m=Ee(h,p);if(!m.success){let y=m.error instanceof Error?m.error.message:String(m.error);throw new E(I.InvalidParams,`Invalid sampling result: ${y}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:Nt,capabilities:this._capabilities,clientInfo:this._clientInfo}},wc,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!As.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${t})`);break;case"ping":break}}assertTaskCapability(t){Ti(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&Oi(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},bt,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},Lc,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},bt,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Ac,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Pc,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},vc,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},$c,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},zc,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},bt,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},bt,r)}async callTool(t,r=Zt,n){if(this.isToolTaskRequired(t.name))throw new E(I.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:t},r,n),s=this.getToolOutputValidator(t.name);if(s){if(!o.structuredContent&&!o.isError)throw new E(I.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new E(I.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof E?i:new E(I.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(t){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of t){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let n=await this.request({method:"tools/list",params:t},Nc,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=Pg.safeParse(n);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(t,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var I0=sa(A0(),1);function C0(e){if(e)try{return I0.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function Ii(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function N0(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...Ii(t.headers),...Ii(n.headers)}:t.headers};return e(r,o)}:e}var Vl;Vl=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function XE(e){return(await Vl).getRandomValues(new Uint8Array(e))}async function YE(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await XE(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function QE(e){return await YE(e)}async function eT(e){let t=await(await Vl).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Bl(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await QE(e),r=await eT(t);return{code_verifier:t,code_challenge:r}}var ve=Gm().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:dg.custom,message:"URL must be parseable",fatal:!0}),wa}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Z0=fe({resource:g().url(),authorization_servers:$(ve).optional(),jwks_uri:g().url().optional(),scopes_supported:$(g()).optional(),bearer_methods_supported:$(g()).optional(),resource_signing_alg_values_supported:$(g()).optional(),resource_name:g().optional(),resource_documentation:g().optional(),resource_policy_uri:g().url().optional(),resource_tos_uri:g().url().optional(),tls_client_certificate_bound_access_tokens:X().optional(),authorization_details_types_supported:$(g()).optional(),dpop_signing_alg_values_supported:$(g()).optional(),dpop_bound_access_tokens_required:X().optional()}),Hl=fe({issuer:g(),authorization_endpoint:ve,token_endpoint:ve,registration_endpoint:ve.optional(),scopes_supported:$(g()).optional(),response_types_supported:$(g()),response_modes_supported:$(g()).optional(),grant_types_supported:$(g()).optional(),token_endpoint_auth_methods_supported:$(g()).optional(),token_endpoint_auth_signing_alg_values_supported:$(g()).optional(),service_documentation:ve.optional(),revocation_endpoint:ve.optional(),revocation_endpoint_auth_methods_supported:$(g()).optional(),revocation_endpoint_auth_signing_alg_values_supported:$(g()).optional(),introspection_endpoint:g().optional(),introspection_endpoint_auth_methods_supported:$(g()).optional(),introspection_endpoint_auth_signing_alg_values_supported:$(g()).optional(),code_challenge_methods_supported:$(g()).optional(),client_id_metadata_document_supported:X().optional()}),tT=fe({issuer:g(),authorization_endpoint:ve,token_endpoint:ve,userinfo_endpoint:ve.optional(),jwks_uri:ve,registration_endpoint:ve.optional(),scopes_supported:$(g()).optional(),response_types_supported:$(g()),response_modes_supported:$(g()).optional(),grant_types_supported:$(g()).optional(),acr_values_supported:$(g()).optional(),subject_types_supported:$(g()),id_token_signing_alg_values_supported:$(g()),id_token_encryption_alg_values_supported:$(g()).optional(),id_token_encryption_enc_values_supported:$(g()).optional(),userinfo_signing_alg_values_supported:$(g()).optional(),userinfo_encryption_alg_values_supported:$(g()).optional(),userinfo_encryption_enc_values_supported:$(g()).optional(),request_object_signing_alg_values_supported:$(g()).optional(),request_object_encryption_alg_values_supported:$(g()).optional(),request_object_encryption_enc_values_supported:$(g()).optional(),token_endpoint_auth_methods_supported:$(g()).optional(),token_endpoint_auth_signing_alg_values_supported:$(g()).optional(),display_values_supported:$(g()).optional(),claim_types_supported:$(g()).optional(),claims_supported:$(g()).optional(),service_documentation:g().optional(),claims_locales_supported:$(g()).optional(),ui_locales_supported:$(g()).optional(),claims_parameter_supported:X().optional(),request_parameter_supported:X().optional(),request_uri_parameter_supported:X().optional(),require_request_uri_registration:X().optional(),op_policy_uri:ve.optional(),op_tos_uri:ve.optional(),client_id_metadata_document_supported:X().optional()}),M0=S({...tT.shape,...Hl.pick({code_challenge_methods_supported:!0}).shape}),D0=S({access_token:g(),id_token:g().optional(),token_type:g(),expires_in:Os.number().optional(),scope:g().optional(),refresh_token:g().optional(),issuer:g().optional().catch(void 0)}).strip(),L0=S({error:g(),error_description:g().optional(),error_uri:g().optional()}),j0=ve.optional().or(P("").transform(()=>{})),rT=S({redirect_uris:$(ve),token_endpoint_auth_method:g().optional(),grant_types:$(g()).optional(),response_types:$(g()).optional(),client_name:g().optional(),client_uri:ve.optional(),logo_uri:j0,scope:g().optional(),contacts:$(g()).optional(),tos_uri:j0,policy_uri:g().optional(),jwks_uri:ve.optional(),jwks:Qm().optional(),software_id:g().optional(),software_version:g().optional(),software_statement:g().optional()}).strip(),nT=S({client_id:g(),client_secret:g().optional(),client_id_issued_at:B().optional(),client_secret_expires_at:B().optional(),issuer:g().optional().catch(void 0)}).strip(),U0=rT.merge(nT),hj=S({error:g(),error_description:g().optional()}).strip(),mj=S({token:g(),token_type_hint:g().optional()}).strip();function q0(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function F0({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}var de=class extends Error{constructor(t,r){super(t),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let t={error:this.errorCode,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}get errorCode(){return this.constructor.errorCode}},_o=class extends de{};_o.errorCode="invalid_request";var mr=class extends de{};mr.errorCode="invalid_client";var gr=class extends de{};gr.errorCode="invalid_grant";var yr=class extends de{};yr.errorCode="unauthorized_client";var bo=class extends de{};bo.errorCode="unsupported_grant_type";var wo=class extends de{};wo.errorCode="invalid_scope";var xo=class extends de{};xo.errorCode="access_denied";var kt=class extends de{};kt.errorCode="server_error";var vo=class extends de{};vo.errorCode="temporarily_unavailable";var $o=class extends de{};$o.errorCode="unsupported_response_type";var So=class extends de{};So.errorCode="unsupported_token_type";var zo=class extends de{};zo.errorCode="invalid_token";var ko=class extends de{};ko.errorCode="method_not_allowed";var Po=class extends de{};Po.errorCode="too_many_requests";var _r=class extends de{};_r.errorCode="invalid_client_metadata";var Eo=class extends de{};Eo.errorCode="insufficient_scope";var To=class extends de{};To.errorCode="invalid_target";var V0={[_o.errorCode]:_o,[mr.errorCode]:mr,[gr.errorCode]:gr,[yr.errorCode]:yr,[bo.errorCode]:bo,[wo.errorCode]:wo,[xo.errorCode]:xo,[kt.errorCode]:kt,[vo.errorCode]:vo,[$o.errorCode]:$o,[So.errorCode]:So,[zo.errorCode]:zo,[ko.errorCode]:ko,[Po.errorCode]:Po,[_r.errorCode]:_r,[Eo.errorCode]:Eo,[To.errorCode]:To};var Pt=class extends Error{constructor(t){super(t??"Unauthorized")}};function oT(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var Kl="code",Jl="S256";function sT(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&oT(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function iT(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":aT(o,s,r);return;case"client_secret_post":cT(o,s,n);return;case"none":uT(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function aT(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}function cT(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function uT(e,t){t.set("client_id",e)}async function H0(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let n=L0.parse(JSON.parse(r)),{error:o,error_description:s,error_uri:i}=n,a=V0[o]||kt;return new a(s||"",i)}catch(n){let o=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new kt(o)}}function lT(e,t){let[r,n]=[e,t];try{[r,n]=[new URL(e).href,new URL(t).href]}catch{}return r===n||r.endsWith("/")&&r.slice(0,-1)===n||n.endsWith("/")&&n.slice(0,-1)===r}function Xl(e,t){if(e)return typeof e.issuer!="string"?e.issuer==null?e:{...e,issuer:void 0}:lT(e.issuer,t)?e:void 0}var dT=D0.omit({issuer:!0}),fT=U0.omit({issuer:!0});function K0(e,t){return new Error(`OAuth client information is bound to authorization server ${e.issuer} and is not presented to ${t}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}async function Oo(e,t){try{return await Wl(e,t)}catch(r){if(r instanceof mr||r instanceof yr)return await e.invalidateCredentials?.("all"),await Wl(e,t);if(r instanceof gr)return await e.invalidateCredentials?.("tokens"),await Wl(e,t);throw r}}async function Wl(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let i=await e.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await W0(c,{fetchFn:s}),!a)try{a=await J0(t,{resourceMetadataUrl:l},s)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let Z=await bT(t,{resourceMetadataUrl:l,fetchFn:s});c=Z.authorizationServerUrl,u=Z.authorizationServerMetadata,a=Z.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=String(c),p=await hT(t,e,a),f=p&&a&&!e.validateResourceURL?a.resource:p,h=n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,m=await Promise.resolve(e.clientInformation()),y=Xl(m,d),w=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(m&&!y&&!w)throw K0(m,d);let v=y?.issuer==null?y:void 0,z=async()=>{try{v&&await e.saveClientInformation?.({...v,issuer:d})}catch{}};if(!y){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let Z=u?.client_id_metadata_document_supported===!0,oe=e.clientMetadataUrl;if(oe&&!pT(oe))throw new _r(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${oe}`);if(Z&&oe)y={client_id:oe,issuer:d},await e.saveClientInformation?.(y);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");y={...await ST(c,{metadata:u,clientMetadata:e.clientMetadata,scope:h,fetchFn:s}),issuer:d},await e.saveClientInformation(y)}}let A=!e.redirectUrl;if(r!==void 0||A){let Z=await $T(e,c,{metadata:u,resource:f,authorizationCode:r,fetchFn:s});return await z(),await e.saveTokens({...Z,issuer:d}),"AUTHORIZED"}let b=Xl(await e.tokens(),d);if(b?.refresh_token&&b.issuer==null&&console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged."),b?.refresh_token)try{let Z=await vT(c,{metadata:u,clientInformation:y,refreshToken:b.refresh_token,resource:f,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await z(),await e.saveTokens({...Z,issuer:d}),"AUTHORIZED"}catch(Z){if(!(!(Z instanceof de)||Z instanceof kt))throw Z}let x=e.state?await e.state():void 0,{authorizationUrl:T,codeVerifier:K}=await wT(c,{metadata:u,clientInformation:y,state:x,redirectUrl:e.redirectUrl,scope:h,resource:f});return await e.saveCodeVerifier(K),await e.redirectToAuthorization(T),"REDIRECT"}function pT(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function hT(e,t,r){let n=q0(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!F0({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function Yl(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=Gl(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=Gl(e,"scope")||void 0,a=Gl(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function Gl(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function J0(e,t,r=fetch){let n=await yT(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||n.status===404)throw await n?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return Z0.parse(await n.json())}async function Ql(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?Ql(e,void 0,r):void 0;throw n}}function mT(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function B0(e,t,r=fetch){return await Ql(e,{"MCP-Protocol-Version":t},r)}function gT(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function yT(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??Nt,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=mT(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await B0(i,s,r);if(!n?.metadataUrl&&gT(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await B0(c,s,r)}return a}function _T(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function W0(e,{fetchFn:t=fetch,protocolVersion:r=Nt}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=_T(e);for(let{url:s,type:i}of o){let a=await Ql(s,n,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}return i==="oauth"?Hl.parse(await a.json()):M0.parse(await a.json())}}}async function bT(e,t){let r,n;try{r=await J0(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));let o=await W0(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}function G0(e){return typeof e=="string"?e:e.href}async function wT(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Kl))throw new Error(`Incompatible auth server: does not support response type ${Kl}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(Jl))throw new Error(`Incompatible auth server: does not support code challenge method ${Jl}`)}else a=new URL("/authorize",e);let c=await Bl(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",Kl),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",Jl),a.searchParams.set("redirect_uri",String(n)),s&&a.searchParams.set("state",s),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",G0(i)),{authorizationUrl:a,codeVerifier:u}}function xT(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function X0(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:i}){let a=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",G0(s)),o)await o(c,r,a,t);else if(n){let l=t?.token_endpoint_auth_methods_supported??[],d=sT(n,l);iT(d,n,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await H0(u);return dT.parse(await u.json())}async function vT(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await X0(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:i});return{refresh_token:n,...c}}async function $T(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){let i=async()=>{let l=await e.clientInformation(),d=Xl(l,String(t));if(l&&!d)throw K0(l,String(t));return d},a=await i(),c=e.clientMetadata.scope,u;if(e.prepareTokenRequest&&(u=await e.prepareTokenRequest(c)),!u){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let l=await e.codeVerifier();u=xT(o,l,e.redirectUrl)}return a??(a=await i()),X0(t,{metadata:r,tokenRequestParams:u,clientInformation:a,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}async function ST(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:o}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i=await(o??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!i.ok)throw await H0(i);return fT.parse(await i.json())}var Ro=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},Y0=10,zT=13,br=32;function ed(e){}function tb(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=ed,onError:r=ed,onRetry:n=ed,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,u,l="",d=0,p,f=!1;function h(b){if(f)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,b.charCodeAt(0)===239&&b.charCodeAt(1)===187&&b.charCodeAt(2)===191&&(b=b.slice(3))),i.length===0){let K=y(b);K!==""&&(i.push(K),a=K.length),m();return}if(b.indexOf(`
|
|
67
|
-
`)===-1&&
|
|
68
|
-
`,x);for(;
|
|
69
|
-
`,x);continue}let
|
|
70
|
-
`,x);continue}l=d===0?
|
|
71
|
-
${
|
|
72
|
-
`,x)}return
|
|
73
|
-
`,x),
|
|
74
|
-
${
|
|
75
|
-
${x}`,d++;break;case"id":x.includes("\0")||(u=x);break;case"retry":/^\d+$/.test(x)?n(parseInt(x,10)):r(new Ro(`Invalid \`retry\` value: "${x}"`,{type:"invalid-retry",value:x,line:T}));break;default:r(new Ro(`Unknown field "${b.length>20?`${b.slice(0,20)}\u2026`:b}"`,{type:"unknown-field",field:b,value:x,line:T}));break}}function z(){d>0&&t({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0}function A(b={}){if(b.consume&&i.length>0){let x=i.join("");w(x,0,x.length)}c=!0,u=void 0,l="",d=0,p=void 0,i.length=0,a=0,f=!1}return{feed:h,reset:A}}function Q0(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function eb(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Ci=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=tb({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:n,maxBufferSize:o})},transform(i){s.feed(i)}})}};var kT={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Jt=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Ni=class{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=N0(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??kT}async _authThenStart(){if(!this._authProvider)throw new Pt("No auth provider");let t;try{t=await Oo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new Pt;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(t.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=Ii(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:n,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new Jt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,t,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),o)}_scheduleReconnection(t,r=0){let n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},o)}_handleSseStream(t,r,n){if(!t)return;let{onresumptiontoken:o,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let l=t.pipeThrough(new TextDecoderStream).pipeThrough(new Ci({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){let{value:f,done:h}=await l.read();if(h)break;if(f.id&&(i=f.id,a=!0,o?.(f.id)),!!f.data&&(!f.event||f.event==="message"))try{let m=Lr.parse(JSON.parse(f.data));tr(m)&&(c=!0,s!==void 0&&(m.id=s)),this.onmessage?.(m)}catch(m){this.onerror?.(m)}}(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(f){this.onerror?.(new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new Pt("No auth provider");if(await Oo(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Pt("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,r){try{let{resumptionToken:n,onresumptiontoken:o}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:On(t)?t.id:void 0}).catch(f=>this.onerror?.(f));return}let s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let f=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Jt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:h,scope:m}=Yl(a);if(this._resourceMetadataUrl=h,this._scope=m,await Oo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Pt;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:h,scope:m,error:y}=Yl(a);if(y==="insufficient_scope"){let w=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new Jt(403,"Server returned 403 after trying upscoping");if(m&&(this._scope=m),h&&(this._resourceMetadataUrl=h),this._lastUpscopingHeader=w??void 0,await Oo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Pt;return this.send(t)}}throw new Jt(a.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),wg(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}let l=(Array.isArray(t)?t:[t]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,d=a.headers.get("content-type"),p=C0(d);if(l)if(p==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(p==="application/json"){let f=await a.json(),h=Array.isArray(f)?f.map(m=>Lr.parse(m)):[Lr.parse(f)];for(let m of h)this.onmessage?.(m)}else throw await a.body?.cancel(),new Jt(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Jt(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};var ji=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},rr,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Mt,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};var Zi=class extends qr{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Mn.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new an,this.setRequestHandler(bc,n=>this._oninitialize(n)),this.setNotificationHandler(js,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Zc,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Mn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ji(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Bs(this._capabilities,t)}setRequestHandler(t,r){let o=Zr(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Mr(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Ee(Zn,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new E(I.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let h=Ee(wt,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new E(I.InvalidParams,`Invalid task creation result: ${m}`)}return h.data}let f=Ee(Zt,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new E(I.InvalidParams,`Invalid tools/call result: ${h}`)}return f.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Oi(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Ti(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:As.includes(r)?r:Nt,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},bt)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},Dn,r):this.request({method:"sampling/createMessage",params:t},rr,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Mt,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Mt,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new E(I.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof E?i:new E(I.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},Uc,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import nb from"node:process";var PT=10*1024*1024,Mi=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??PT}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
76
|
-
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),
|
|
77
|
-
`}var Di=class{constructor(t=nb.stdin,r=nb.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new Mi({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=rb(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function td(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var Li=e=>e?`"${e}" `:"";function TT(e,t=""){if(typeof e!="boolean")throw new TypeError(Li(t)+"expected boolean, got type="+typeof e);return e}function Ui(e,t=""){if(typeof e!="number")throw new TypeError(Li(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(Li(t)+"expected integer >= 0, got "+e);return e}function he(e,t,r=""){if(td(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Ui(t,"length");let n=td(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=Li(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function qi(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function OT(e,t){he(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function rd(e,t){if(OT(e,t),!ln(e))throw new Error("invalid output, must be aligned")}function ob(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Et(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function lt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function cn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var un=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function nd(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}var ce=un?e=>e:e=>nd(e)>>>0;function RT(e){for(let t=0;t<e.length;t++)e[t]=nd(e[t]);return e}var Ao=un?e=>e:RT;function sb(e,t){if(e=he(e),t=he(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function od(e,t,r){let n=t,o=r||(()=>[]),s=(a,c)=>n(c,...o(a)).update(a).digest(),i=n(new Uint8Array(e),...o(new Uint8Array(0)));return s.outputLen=i.outputLen,s.blockLen=i.blockLen,s.create=(a,...c)=>n(a,...c),s}var ib=(e,t)=>{function r(n,...o){if(he(n,void 0,"key"),e.nonceLength!==void 0){let d=o[0];he(d,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let s=e.tagLength,i=e.nonceLength!==void 0?1:0;if(!e.withAAD){for(let d=i;d<o.length;d++)if(td(o[d]))throw new Error("AAD not supported")}e.withAAD&&o[i]!==void 0&&he(o[i],void 0,"AAD");let a=t(n,...o),c=(d,p)=>{if(p!==void 0){if(d!==2)throw new Error("cipher output not supported");he(p,void 0,"output")}},u=!1;return{encrypt(d,p){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,he(d,void 0,"data"),c(a.encrypt.length,p),a.encrypt(d,p)},decrypt(d,p){if(he(d,void 0,"data"),s&&d.length<s)throw new Error('"ciphertext" expected length >= tagLength='+s);return c(a.decrypt.length,p),a.decrypt(d,p)}}}return Object.assign(r,e),r};function ab(e,t,r=!0){if(t===void 0)return new Uint8Array(e);if(he(t,e,"output"),r&&!ln(t))throw new Error("invalid output, must be aligned");return t}function cb(e,t,r){Ui(e),Ui(t),TT(r);let n=new Uint8Array(16),o=cn(n);return o.setBigUint64(0,BigInt(t),r),o.setBigUint64(8,BigInt(e),r),n}function ln(e){return e.byteOffset%4===0}function wr(e){return Uint8Array.from(he(e))}var xr=16,ub=new Uint8Array(16),Io=Et(ub),AT=225,IT=(e,t,r,n)=>{let o=n&1;return{s3:r<<31|n>>>1,s2:t<<31|r>>>1,s1:e<<31|t>>>1,s0:e>>>1^AT<<24&-(o&1)}},Fi=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;var CT=e=>e>64*1024?8:e>1024?4:2,sd=class{blockLen=xr;outputLen=xr;s0=0;s1=0;s2=0;s3=0;finished=!1;destroyed=!1;t;W;windowSize;constructor(t,r){he(t,16,"key"),t=wr(t);let n=cn(t),o=n.getUint32(0,!1),s=n.getUint32(4,!1),i=n.getUint32(8,!1),a=n.getUint32(12,!1),c=[];for(let h=0;h<128;h++)c.push({s0:Fi(o),s1:Fi(s),s2:Fi(i),s3:Fi(a)}),{s0:o,s1:s,s2:i,s3:a}=IT(o,s,i,a);let u=CT(r||1024);if(![1,2,4,8].includes(u))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=u;let d=128/u,p=this.windowSize=2**u,f=[];for(let h=0;h<d;h++)for(let m=0;m<p;m++){let y=0,w=0,v=0,z=0;for(let A=0;A<u;A++){if(!(m>>>u-A-1&1))continue;let{s0:x,s1:T,s2:K,s3:Z}=c[u*h+A];y^=x,w^=T,v^=K,z^=Z}f.push({s0:y,s1:w,s2:v,s3:z})}this.t=f}_updateBlock(t,r,n,o){t^=this.s0,r^=this.s1,n^=this.s2,o^=this.s3;let{W:s,t:i,windowSize:a}=this,c=0,u=0,l=0,d=0,p=(1<<s)-1,f=0;for(let h of[t,r,n,o])for(let m=0;m<4;m++){let y=h>>>8*m&255;for(let w=8/s-1;w>=0;w--){let v=y>>>s*w&p,{s0:z,s1:A,s2:b,s3:x}=i[f*a+v];c^=z,u^=A,l^=b,d^=x,f+=1}}this.s0=c,this.s1=u,this.s2=l,this.s3=d}update(t){qi(this),he(t),t=wr(t);let r=Et(t),n=Math.floor(t.length/xr),o=t.length%xr;for(let s=0;s<n;s++)this._updateBlock(ce(r[s*4+0]),ce(r[s*4+1]),ce(r[s*4+2]),ce(r[s*4+3]));return o&&(ub.set(t.subarray(n*xr)),this._updateBlock(ce(Io[0]),ce(Io[1]),ce(Io[2]),ce(Io[3])),lt(Io)),this}destroy(){this.destroyed=!0;let{t}=this;for(let r of t)r.s0=0,r.s1=0,r.s2=0,r.s3=0}digestInto(t){qi(this),rd(t,this),this.finished=!0;let{s0:r,s1:n,s2:o,s3:s}=this,i=Et(t);i[0]=r,i[1]=n,i[2]=o,i[3]=s,un||Ao(i.subarray(0,xr/4))}digest(){let t=new Uint8Array(xr);return this.digestInto(t),this.destroy(),t}};var id=od(16,(e,t)=>new sd(e,t),e=>[e.length]);var cd=16,NT=4,Vi=new Uint8Array(cd);var jT=283;function ZT(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}function ud(e){return e<<1^jT&-(e>>7)}function lb(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(t&1),e=ud(e);return r}var MT=(()=>{let e=new Uint8Array(256);for(let r=0,n=1;r<256;r++,n^=ud(n))e[r]=n;let t=new Uint8Array(256);t[0]=99;for(let r=0;r<255;r++){let n=e[255-r];n|=n<<8,t[e[r]]=(n^n>>4^n>>5^n>>6^n>>7^99)&255}return lt(e),t})();var DT=e=>e<<24|e>>>8,ad=e=>e<<8|e>>>24;function LT(e,t){if(e.length!==256)throw new Error("wrong sbox length");let r=new Uint32Array(256).map((u,l)=>t(e[l])),n=r.map(ad),o=n.map(ad),s=o.map(ad),i=new Uint32Array(256*256),a=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let u=0;u<256;u++)for(let l=0;l<256;l++){let d=u*256+l;i[d]=r[u]^n[l],a[d]=o[u]^s[l],c[d]=e[u]<<8|e[l]}return{sbox:e,sbox2:c,T0:r,T1:n,T2:o,T3:s,T01:i,T23:a}}var fb=LT(MT,e=>lb(e,3)<<24|e<<16|e<<8|lb(e,2));var UT=(()=>{let e=new Uint8Array(16);for(let t=0,r=1;t<16;t++,r=ud(r))e[t]=r;return e})();function qT(e){he(e);let t=e.length;ZT(e);let{sbox2:r}=fb,n=[];(!un||!ln(e))&&n.push(e=wr(e));let o=Ao(Et(e)),s=o.length,i=c=>Co(r,c,c,c,c),a=new Uint32Array(t+28);a.set(o);for(let c=s;c<a.length;c++){let u=a[c-1];c%s===0?u=i(DT(u))^UT[c/s-1]:s>6&&c%s===4&&(u=i(u)),a[c]=a[c-s]^u}return lt(...n),a}function Bi(e,t,r,n,o,s){return e[r<<8&65280|n>>>8&255]^t[o>>>8&65280|s>>>24&255]}function Co(e,t,r,n,o){return e[t&255|r&65280]|e[n>>>16&255|o>>>16&65280]<<16}function db(e,t,r,n,o){let{sbox2:s,T01:i,T23:a}=fb,c=0;t^=e[c++],r^=e[c++],n^=e[c++],o^=e[c++];let u=e.length/4-2;for(let h=0;h<u;h++){let m=e[c++]^Bi(i,a,t,r,n,o),y=e[c++]^Bi(i,a,r,n,o,t),w=e[c++]^Bi(i,a,n,o,t,r),v=e[c++]^Bi(i,a,o,t,r,n);t=m,r=y,n=w,o=v}let l=e[c++]^Co(s,t,r,n,o),d=e[c++]^Co(s,r,n,o,t),p=e[c++]^Co(s,n,o,t,r),f=e[c++]^Co(s,o,t,r,n);return{s0:l,s1:d,s2:p,s3:f}}function Hi(e,t,r,n,o){he(r,cd,"nonce"),he(n),o=ab(n.length,o);let s=r,i=Et(s),a=cn(s),c=Et(n),u=Et(o),l=t?0:12,d=n.length,p=a.getUint32(l,t);for(let h=0;h+4<=c.length;h+=4){let{s0:m,s1:y,s2:w,s3:v}=db(e,ce(i[0]),ce(i[1]),ce(i[2]),ce(i[3]));u[h+0]=c[h+0]^ce(m),u[h+1]=c[h+1]^ce(y),u[h+2]=c[h+2]^ce(w),u[h+3]=c[h+3]^ce(v),p=p+1>>>0,a.setUint32(l,p,t)}let f=cd*Math.floor(c.length/NT);if(f<d){let{s0:h,s1:m,s2:y,s3:w}=db(e,ce(i[0]),ce(i[1]),ce(i[2]),ce(i[3])),v=new Uint32Array([h,m,y,w]);Ao(v);let z=ob(v);for(let A=f,b=0;A<d;A++,b++)o[A]=n[A]^z[b];lt(v)}return o}function FT(e,t,r,n,o){let s=o?o.length:0,i=e.create(r,n.length+s);o&&i.update(o);let a=cb(8*n.length,8*s,t);i.update(n),i.update(a);let c=i.digest();return lt(a),c}var ld=ib({blockSize:16,nonceLength:12,tagLength:16,withAAD:!0,varSizeNonce:!0},function(t,r,n){if(r.length<8)throw new Error("aes/gcm: invalid nonce length");let o=16;function s(a,c,u){let l=FT(id,!1,a,u,n);for(let d=0;d<c.length;d++)l[d]^=c[d];return l}function i(){let a=qT(t),c=Vi.slice(),u=Vi.slice();if(Hi(a,!1,u,u,c),r.length===12)u.set(r);else{let d=Vi.slice();cn(d).setBigUint64(8,BigInt(r.length*8),!1);let f=id.create(c).update(r).update(d);f.digestInto(u),f.destroy()}let l=Hi(a,!1,u,Vi);return{xk:a,authKey:c,counter:u,tagMask:l}}return{encrypt(a){let{xk:c,authKey:u,counter:l,tagMask:d}=i(),p=new Uint8Array(a.length+o),f=[c,u,l,d];ln(a)||f.push(a=wr(a)),Hi(c,!1,l,a,p.subarray(0,a.length));let h=s(u,d,p.subarray(0,p.length-o));return f.push(h),p.set(h,a.length),lt(...f),p},decrypt(a){let{xk:c,authKey:u,counter:l,tagMask:d}=i(),p=[c,u,d,l];ln(a)||p.push(a=wr(a));let f=a.subarray(0,-o),h=a.subarray(-o),m=s(u,d,f);if(p.push(m),!sb(m,h))throw lt(...p),new Error("aes-gcm: invalid tag");let y=Hi(c,!1,l,f);return lt(...p),y}}});function pb(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var dd=e=>e?`"${e}" `:"";function No(e,t=""){if(typeof e!="number")throw new TypeError(dd(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(dd(t)+"expected integer >= 0, got "+e);return e}function Wt(e,t,r=""){if(pb(e)&&(t===void 0||e.length===t))return e;t!==void 0&&No(t,"length");let n=pb(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=dd(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function jo(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(No(e.outputLen),No(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var VT=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},hb=(e,t)=>{VT(e,t);let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function dn(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Ki(e,t){Wt(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function dt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ji(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ot(e,t){return e<<32-t|e>>>t}function BT(e,t,r="opts"){return hb(e,"defaults"),t!==void 0&&hb(t,r),Object.assign(Object.create(null),e,t)}function mb(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=BT({},t,"info");let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}var gb=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});var Wi=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(jo(t),Wt(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),dt(o)}update(t){return dn(this),this.iHash.update(t),this}digestInto(t){dn(this),Ki(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a,canXOF:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.canXOF=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Zo=(()=>{let e=((t,r,n)=>new Wi(t,r).update(n).digest());return e.create=(t,r)=>new Wi(t,r),e})();var Mo=Uint8Array.of(0),HT=Uint8Array.of();function KT(e,t,r,n=32,o){jo(e),No(n,"length"),Wt(t,void 0,"prk");let s=e.outputLen;if(t.length<s)throw new Error('"prk" must be at least HashLen octets');if(n>255*s)throw new Error("Length must be <= 255*HashLen");let i=Math.ceil(n/s);if(r===void 0?r=HT:Wt(r,void 0,"info"),!i)return o&&dt(t),new Uint8Array;let a=o&&i===1?t:new Uint8Array(i*s),{iHash:c,oHash:u}=Zo.create(e,t),l=o?t:new Uint8Array(s),d=i>1?o?.iHash||e.create():void 0;for(let f=0;f<i-1;f++){Mo[0]=f+1;let h=c._cloneInto(d);f&&h.update(l),h.update(r).update(Mo).digestInto(l),u._cloneInto(d).update(l).digestInto(l),a.set(l,s*f)}if(Mo[0]=i,i>1&&c.update(l),c.update(r).update(Mo).digestInto(l),u.update(l).digestInto(l),a.set(l,s*(i-1)),c.destroy(),u.destroy(),d?.destroy(),l!==a&&dt(l),dt(Mo),n===a.length)return a;let p=a.slice(0,n);return dt(a),p}var fd=(e,t,r,n,o)=>{jo(e),r===void 0&&(r=new Uint8Array(e.outputLen));let s=Zo.create(e,r).update(t);return KT(e,s.digest(),n,o,s)};var JT=e=>e/2**32|0,WT=e=>e>>>0;function yb(e,t,r,n){let o=JT(r),s=WT(r);e.setUint32(t,n?s:o,n),e.setUint32(t+4,n?o:s,n)}function _b(e,t,r){return e&t^~e&r}function bb(e,t,r){return e&t^e&r^t&r}var Gi=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Ji(this.buffer)}update(t){dn(this),Wt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let u=Ji(t);for(;o<=s-a;a+=o)this.process(u,a);i=!0;continue}n.set(a===0&&c===s?t:t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){dn(this),Ki(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),yb(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let a=t===r?n:Ji(t),c=this.outputLen,u=c/4,l=this.get();if(c%4||u>l.length)throw new Error("invalid outputLen");for(let d=0;d<u;d++)a.setUint32(4*d,l[d],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(r),t}clone(){return this._cloneInto()}},wb=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var GT=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gt=new Uint32Array(64),pd=class extends Gi{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,r){super(64,t,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let d=0;d<16;d++,r+=4)Gt[d]=t.getUint32(r,!1);for(let d=16;d<64;d++){let p=Gt[d-15],f=Gt[d-2],h=ot(p,7)^ot(p,18)^p>>>3,m=ot(f,17)^ot(f,19)^f>>>10;Gt[d]=m+Gt[d-7]+h+Gt[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){let p=ot(a,6)^ot(a,11)^ot(a,25),f=l+p+_b(a,c,u)+GT[d]+Gt[d]|0,m=(ot(n,2)^ot(n,13)^ot(n,22))+bb(n,o,s)|0;l=u,u=c,c=a,a=i+f|0,i=s,s=o,o=n,n=f+m|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,s,i,a,c,u,l)}roundClean(){dt(Gt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),dt(this.buffer)}},hd=class extends pd{constructor(){super(32,wb)}};var Xi=mb(()=>new hd,gb(1));var Do=new TextEncoder,XT=new TextDecoder,YT="ape1",xb=/^ape1\.([A-Za-z0-9_-]{16})\.([A-Za-z0-9_-]+)$/,QT=/^[A-Za-z0-9_-]{43}$/,eO=/^jb_live_[A-Za-z0-9]{40}$/;function md(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function gd(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4)),r=new Uint8Array(new ArrayBuffer(t.length));for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}var yd=e=>QT.test(e),vb=e=>typeof e=="string"&&xb.test(e);function $b(e){let t=e.trim();if(yd(t))return{token:null,key:t};let[r,n,...o]=t.split(".");if(!eO.test(r)||o.length||n!==void 0&&!yd(n))throw new Error("Not a valid Jotbus token or connection string");return{token:r,key:n??null}}async function Sb(e){if(!yd(e))throw new Error("Invalid workspace key");let t=gd(e),r=new Uint8Array(32),n=fd(Xi,t,r,Do.encode("agentpad/v1/enc"),32),o=fd(Xi,t,r,Do.encode("agentpad/v1/check"),32),s=md(Zo(Xi,o,Do.encode("agentpad/v1/key-check"))),i=a=>Do.encode(`agentpad/v1/${a}`);return{check:s,async encrypt(a,c){let u=globalThis.crypto.getRandomValues(new Uint8Array(12)),l=ld(n,u,i(a)).encrypt(Do.encode(JSON.stringify(c)));return`${YT}.${md(u)}.${md(l)}`},async decrypt(a,c){let u=xb.exec(c);if(!u)throw new Error("Not an encrypted message");let l=ld(n,gd(u[1]),i(a)).decrypt(gd(u[2])),d=JSON.parse(XT.decode(l));if(typeof d?.c!="string")throw new Error("Malformed message");return d}}}var qo="0.2.0",oO=64*1024,kb="https://app.jotbus.com/mcp";globalThis.crypto||(globalThis.crypto=tO);var Qi=e=>process.stderr.write(`[jotbus] ${e}
|
|
78
|
-
`);function
|
|
79
|
-
`),process.exit(0));xd.help&&(process.stdout.write(`jotbus ${qo}: shared scratchpad for coding agents (local MCP client, stdio)
|
|
69
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Pm(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Pm(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Em=new Set(["type","properties","required","additionalProperties"]),zm=["oneOf","anyOf"];function km(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function zc(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Em.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??km(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:zc(a)??{allOf:a};Ve(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=km(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function Cx(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Em)if(o in e)return;let r=t.filter(o=>zm.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=zc(t);else{let o=r[0],s=zm.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>zc([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,Un(e,n))}function Ec(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let f=e.seen.get(d),h=f.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Un(u,h),Un(u,l),a._zod.parent===d)for(let y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(h.$ref&&f.def)for(let y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=e.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let h in u)h==="$ref"||h==="allOf"||h in f.def&&JSON.stringify(u[h])===JSON.stringify(f.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Pm(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Cx(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Un(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Ve(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:qn(t,"input",e.processors),output:qn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ce(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ce(n.element,r);if(n.type==="set")return Ce(n.valueType,r);if(n.type==="lazy")return Ce(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Ce(n.innerType,r);if(n.type==="intersection")return Ce(n.left,r)||Ce(n.right,r);if(n.type==="record"||n.type==="map")return Ce(n.keyType,r)||Ce(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ce(n.in,r)||Ce(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ce(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ce(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ce(o,r))return!0;return!!(n.rest&&Ce(n.rest,r))}return!1}var Tm=(e,t={})=>r=>{let n=kc({...r,processors:t});return he(e,n),Pc(n,e),Ec(n,e)},qn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=kc({...o??{},target:s,io:t,processors:r});return he(e,i),Pc(i,e),Ec(i,e)};var Hr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Kr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Om=(e,t)=>{Hr(e,"minimum",t),Kr(e,"maximum",t)},Im=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Nm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},jm=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Zm=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Rm=(e,t)=>Hr(e,"minimum",t.minimum),Am=(e,t)=>Kr(e,"maximum",t.maximum),Cm=e=>(t,r)=>{Zm(t,r.format);let[n,o]=e[r.format];Hr(t,"minimum",n),Kr(t,"maximum",o)},Ix={greater_than:(e,t)=>Hr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Kr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Im(e,t.value),number_format:Cm(An),bigint_format:Cm(ms),min_length:Rm,max_length:Am,length_equals:(e,t)=>Om(e,t.length),min_size:Rm,max_size:Am,size_equals:(e,t)=>Om(e,t.size),string_format:(e,t)=>{Zm(e,t.format),t.pattern&&Nm(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>jm(e,t.mime)};function ve(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Ix[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&Hr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Hr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Kr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Kr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Im(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&jm(t,o.mime);for(let s of o.patterns??[])Nm(t,s);return t}var Nx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jx=new Map([[nc,Wf],[Rs,Gf]]),Dm=e=>jx.get(e)??e,Mm=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ve(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Nx[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Dm);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Lm=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ve(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),p=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d?f?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let h=new Set;for(let _ of a)Number.isFinite(_)&&_!==0?h.add(Math.abs(_)):it(e,t,o,n,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);let[m,...y]=h;m!==void 0&&(o.multipleOf=m),y.length&&(o.allOf=[...o.allOf??[],...y.map(_=>({multipleOf:_}))])}},Um=(e,t,r,n)=>{r.type="boolean"},qm=(e,t,r,n)=>{it(e,t,r,n,"BigInt cannot be represented in JSON Schema")};var Fm=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Bm=(e,t,r,n)=>{r.not={}},Vm=(e,t,r,n)=>{},Hm=(e,t,r,n)=>{},Km=(e,t,r,n)=>{it(e,t,r,n,"Date cannot be represented in JSON Schema")},Jm=(e,t,r,n)=>{let o=e._zod.def,s=jr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Wm=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(it(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(it(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Gm=(e,t,r,n)=>{it(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Xm=(e,t,r,n)=>{it(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Ym=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ve(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=he(s.element,t,{...n,path:[...n.path,"items"]})};function Fs(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Fs(t.out):t.type==="catch"?Fs(t.innerType):e._zod.optin}var Qm=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&it(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)Ve(o.properties,u,he(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?Fs(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=he(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},eg=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>he(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},tg=(e,t,r,n)=>{let o=e._zod.def,s=he(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=he(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function Tc(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let m=Tc(e,h,r);return m===h?t:m}for(let h of["anyOf","oneOf"]){let m=t[h];if(!Array.isArray(m))continue;let y=m.map(_=>Tc(e,_,r));y.some((_,v)=>_!==m[v])&&(t={...t,[h]:y})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(h=>h==="number"||h==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(h=>typeof h=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:p,...f}=t;return f.enum?f.enum=f.enum.map(h=>typeof h=="number"?String(h):h):typeof f.const=="number"&&(f.const=String(f.const)),o&&(f.type="string",s||(f.pattern=(n.includes("number")?jn:Xa).source)),f}var Oc=new WeakMap;function Zx(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of Oc.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=Tc(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var rg=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ve(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=he(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)Ve(o.patternProperties,Dm(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=he(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Oc.get(t);l||(l=[],Oc.set(t,l),t.deferred.push(()=>Zx(t))),l.push(e)}o.additionalProperties=he(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Fs(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},ng=(e,t,r,n)=>{let o=e._zod.def,s=he(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},og=(e,t,r,n)=>{let o=e._zod.def;he(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Rc=Symbol();function sg(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(it(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Rc):JSON.parse(i)}var ig=(e,t,r,n)=>{let o=e._zod.def;he(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=sg(o.defaultValue,e,t,r,n);i!==Rc&&(r.default=i)},ag=(e,t,r,n)=>{let o=e._zod.def;he(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=sg(o.defaultValue,e,t,r,n);i!==Rc&&(r._prefault=i)},cg=(e,t,r,n)=>{let o=e._zod.def;he(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{it(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},ug=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;he(i,t,n);let a=t.seen.get(e);a.ref=i},lg=(e,t,r,n)=>{let o=e._zod.def;he(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var Ac=(e,t,r,n)=>{let o=e._zod.def;he(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function Bs(e){return!!e._zod}function Ie(e,t){return Bs(e)?Ja(e,t):e.safeParse(t)}function Wr(e){if(!e)return;let t;if(Bs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Gr(e){if(Bs(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var dg=new WeakSet([Object.prototype,Error.prototype]);function Vs(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var Kx=(e,t)=>{$f.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);dg.has(r)||(dg.add(r),Vs(r,"format",n=>o=>Ka(n,o)),Vs(r,"flatten",n=>o=>Ha(n,o)),Vs(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Zr,2)}),Vs(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Zr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var He=b("ZodError",Kx,void 0,{Parent:Error});var fg=ws(He),pg=xs(He),hg=Nn(He),mg=vs(He),gg=kf(He),yg=Pf(He),_g=Ef(He),bg=Tf(He),wg=Of(He),xg=Rf(He),vg=Af(He),$g=Cf(He);function Wx(){Ze.localeError||De(Zh())}function Ks(){Ze.memoizer||De({memoizer:dc()})}var te=b("ZodType",(e,t)=>(Wx(),Q.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(j.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return We(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(jv(e,t))},superRefine(e,t){return this.check(Zv(e,t))},overwrite(e){return this.check(Ut(e))},optional(){return le(this)},exactOptional(){return Sv(this)},nullable(){return kg(this)},nullish(){return le(kg(this))},nonoptional(e){return Ov(this,e)},array(){return z(this)},or(e){return ie([this,e])},and(e){return Ws(this,e)},transform(e){return Pg(this,Zg(e))},default(e){return Pv(this,e)},prefault(e){return Tv(this,e)},catch(e){return Av(this,e)},pipe(e){return Pg(this,e)},readonly(){return Nv(this)},describe(e){let t=this.clone();return Lt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Lt.get(this);let t=this.clone();return Lt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return j.hide(this,"~standard",{...rc(this),jsonSchema:{input:qn(this,"input"),output:qn(this,"output")}})},set"~standard"(e){j.own(this,"~standard",e)},parse:function e(t,r){return fg(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await pg(this,t,r,{callee:e})},safeParse(e,t){return hg(this,e,t)},async safeParseAsync(e,t){return mg(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){j.own(this,"spa",e)},validate(e,t){return $s(this,e,t)},validateAsync(e,t){return Ss(this,e,t)},encode:function e(t,r){return gg(this,t,r,{callee:e})},decode:function e(t,r){return yg(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await _g(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await bg(this,t,r,{callee:e})},safeEncode(e,t){return wg(this,e,t)},safeDecode(e,t){return xg(this,e,t)},async safeEncodeAsync(e,t){return vg(this,e,t)},async safeDecodeAsync(e,t){return $g(this,e,t)},toJSONSchema(e){return Tm(this,{})(e)},get description(){return Lt.get(this)?.description},get _def(){return this._zod.def}}),Eg=b("_ZodString",(e,t)=>{Os.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mm(e,r,n,o)},j.derived({format:e=>ve(e).format??null,minLength:e=>ve(e).minimum??null,maxLength:e=>ve(e).maximum??null},{regex(...e){return this.check(hc(...e))},includes(...e){return this.check(yc(...e))},startsWith(...e){return this.check(_c(...e))},endsWith(...e){return this.check(bc(...e))},min(...e){return this.check(Vr(...e))},max(...e){return this.check(Us(...e))},length(...e){return this.check(qs(...e))},nonempty(...e){return this.check(Vr(1,...e))},lowercase(e){return this.check(mc(e))},uppercase(e){return this.check(gc(e))},trim(){return this.check(xc())},normalize(...e){return this.check(wc(...e))},toLowerCase(){return this.check(vc())},toUpperCase(){return this.check($c())},slugify(){return this.check(Sc())}})),Ic=b("ZodString",(e,t)=>{Os.init(e,t),Eg.init(e,t)},{email(e){return this.check(qh(Gx,e))},url(e){return this.check(pc(Tg,e))},jwt(e){return this.check(cm(fv,e))},emoji(e){return this.check(Jh(Yx,e))},guid(e){return this.check(Fh(Xx,e))},uuid(e){return this.check(Bh(Hs,e))},uuidv4(e){return this.check(Vh(Hs,e))},uuidv6(e){return this.check(Hh(Hs,e))},uuidv7(e){return this.check(Kh(Hs,e))},nanoid(e){return this.check(Wh(Qx,e))},cuid(e){return this.check(Gh(ev,e))},cuid2(e){return this.check(Xh(tv,e))},ulid(e){return this.check(Yh(rv,e))},base64(e){return this.check(sm(uv,e))},base64url(e){return this.check(im(lv,e))},xid(e){return this.check(Qh(nv,e))},ksuid(e){return this.check(em(ov,e))},ipv4(e){return this.check(tm(sv,e))},ipv6(e){return this.check(rm(iv,e))},cidrv4(e){return this.check(nm(av,e))},cidrv6(e){return this.check(om(cv,e))},e164(e){return this.check(am(dv,e))},datetime(e){return this.check(Zs(Fn,e))},date(e){return this.check(Ds(Bn,e))},time(e){return this.check(Ms(Vn,e))},duration(e){return this.check(Ls(Hn,e))}});function g(e){return Lh(Ic,e)}var de=b("ZodStringFormat",(e,t)=>{se.init(e,t),Eg.init(e,t)}),Fn=b("ZodISODateTime",(e,t)=>{Kp.init(e,t),de.init(e,t)}),Bn=b("ZodISODate",(e,t)=>{Jp.init(e,t),de.init(e,t)}),Vn=b("ZodISOTime",(e,t)=>{Wp.init(e,t),de.init(e,t)}),Hn=b("ZodISODuration",(e,t)=>{Gp.init(e,t),de.init(e,t)}),Gx=b("ZodEmail",(e,t)=>{jp.init(e,t),de.init(e,t)});var Xx=b("ZodGUID",(e,t)=>{Ip.init(e,t),de.init(e,t)});var Hs=b("ZodUUID",(e,t)=>{Np.init(e,t),de.init(e,t)});var Tg=b("ZodURL",(e,t)=>{Mp.init(e,t),de.init(e,t)});function Og(e){return pc(Tg,e)}var Yx=b("ZodEmoji",(e,t)=>{Lp.init(e,t),de.init(e,t)});var Qx=b("ZodNanoID",(e,t)=>{Up.init(e,t),de.init(e,t)});var ev=b("ZodCUID",(e,t)=>{qp.init(e,t),de.init(e,t)});var tv=b("ZodCUID2",(e,t)=>{Fp.init(e,t),de.init(e,t)});var rv=b("ZodULID",(e,t)=>{Bp.init(e,t),de.init(e,t)});var nv=b("ZodXID",(e,t)=>{Vp.init(e,t),de.init(e,t)});var ov=b("ZodKSUID",(e,t)=>{Hp.init(e,t),de.init(e,t)});var sv=b("ZodIPv4",(e,t)=>{Xp.init(e,t),de.init(e,t)});var iv=b("ZodIPv6",(e,t)=>{Qp.init(e,t),de.init(e,t)});var av=b("ZodCIDRv4",(e,t)=>{eh.init(e,t),de.init(e,t)});var cv=b("ZodCIDRv6",(e,t)=>{th.init(e,t),de.init(e,t)});var uv=b("ZodBase64",(e,t)=>{nh.init(e,t),de.init(e,t)});var lv=b("ZodBase64URL",(e,t)=>{oh.init(e,t),de.init(e,t)});var dv=b("ZodE164",(e,t)=>{sh.init(e,t),de.init(e,t)});var fv=b("ZodJWT",(e,t)=>{ih.init(e,t),de.init(e,t)});var Js=b("ZodNumber",(e,t)=>{oc.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Lm(e,r,n,o),e.isFinite=!0},j.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ve(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ve(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=ve(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ve(e).format??null},{gt(e,t){return this.check(Br(e,t))},gte(e,t){return this.check(zt(e,t))},min(e,t){return this.check(zt(e,t))},lt(e,t){return this.check(Fr(e,t))},lte(e,t){return this.check(St(e,t))},max(e,t){return this.check(St(e,t))},int(e){return this.check(Sg(e))},safe(e){return this.check(Sg(e))},positive(e){return this.check(Br(0,e))},nonnegative(e){return this.check(zt(0,e))},negative(e){return this.check(Fr(0,e))},nonpositive(e){return this.check(St(0,e))},multipleOf(e,t){return this.check(Ln(e,t))},step(e,t){return this.check(Ln(e,t))},finite(){return this}}));function X(e){return um(Js,e)}var pv=b("ZodNumberFormat",(e,t)=>{ah.init(e,t),Js.init(e,t)});function Sg(e){return dm(pv,e)}var Nc=b("ZodBoolean",(e,t)=>{ch.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Um(e,r,n,o)});function re(e){return fm(Nc,e)}var Rg=b("ZodBigInt",(e,t)=>{uh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qm(e,r,n,o)},j.derived({minValue:e=>ve(e).minimum??null,maxValue:e=>ve(e).maximum??null,format:e=>ve(e).format??null},{gte(e,t){return this.check(zt(e,t))},min(e,t){return this.check(zt(e,t))},gt(e,t){return this.check(Br(e,t))},lt(e,t){return this.check(Fr(e,t))},lte(e,t){return this.check(St(e,t))},max(e,t){return this.check(St(e,t))},positive(e){return this.check(Br(BigInt(0),e))},negative(e){return this.check(Fr(BigInt(0),e))},nonpositive(e){return this.check(St(BigInt(0),e))},nonnegative(e){return this.check(zt(BigInt(0),e))},multipleOf(e,t){return this.check(Ln(e,t))}}));var hv=b("ZodNull",(e,t)=>{lh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fm(e,r,n,o)});function Ag(e){return mm(hv,e)}var mv=b("ZodAny",(e,t)=>{dh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vm(e,r,n,o)});function Cg(){return gm(mv)}var gv=b("ZodUnknown",(e,t)=>{fh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hm(e,r,n,o)});function ue(){return ym(gv)}var yv=b("ZodNever",(e,t)=>{ph.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bm(e,r,n,o)});function _v(e){return _m(yv,e)}var Ig=b("ZodDate",(e,t)=>{hh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Km(e,r,n,o),e.min=(r,n)=>e.check(zt(r,n)),e.max=(r,n)=>e.check(St(r,n))},j.derived({minDate:e=>{let{minimum:t}=ve(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=ve(e);return t?new Date(t):null}},{}));var bv=b("ZodArray",(e,t)=>{Ks(),mh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ym(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Vr(e,t))},nonempty(e){return this.check(Vr(1,e))},max(e,t){return this.check(Us(e,t))},length(e,t){return this.check(qs(e,t))},unwrap(){return this.element}});function z(e,t){return wm(bv,e,t)}var Ng=b("ZodObject",(e,t)=>{Ks(),_h.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qm(e,r,n,o),j.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Me(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(j.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(j.mergeDefs(this._zod.def,{catchall:ue()}))},loose(){return this.clone(j.mergeDefs(this._zod.def,{catchall:ue()}))},strict(){return this.clone(j.mergeDefs(this._zod.def,{catchall:_v()}))},strip(){return this.clone(j.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return j.extend(this,e)},safeExtend(e){return j.safeExtend(this,e)},merge(e){return j.merge(this,e)},pick(e){return j.pick(this,e)},omit(e){return j.omit(this,e)},partial(...e){return j.partial(Dg,this,e[0])},exactPartial(...e){return j.partial(Mg,this,e[0],"exactPartial")},required(...e){return j.required(Lg,this,e[0])}});function k(e,t){let r={type:"object",shape:e??{},...j.normalizeParams(t)};return new Ng(r)}function ye(e,t){return new Ng({type:"object",shape:e,catchall:ue(),...j.normalizeParams(t)})}var jg=b("ZodUnion",(e,t)=>{sc.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eg(e,r,n,o),e.options=t.options});function ie(e,t){return new jg({type:"union",options:e,...j.normalizeParams(t)})}var wv=b("ZodDiscriminatedUnion",(e,t)=>{jg.init(e,t),bh.init(e,t)});function jc(e,t,r){return new wv({type:"union",options:t,discriminator:e,...j.normalizeParams(r)})}var xv=b("ZodIntersection",(e,t)=>{wh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tg(e,r,n,o)});function Ws(e,t){return new xv({type:"intersection",left:e,right:t})}var zg=b("ZodRecord",(e,t)=>{Ks(),xh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rg(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function oe(e,t,r){return!t||!t._zod?new zg({type:"record",keyType:g(),valueType:e,...j.normalizeParams(t)}):new zg({type:"record",keyType:e,valueType:t,...j.normalizeParams(r)})}var Cc=b("ZodEnum",(e,t)=>{vh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Jm(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Cc({...t,checks:[],...j.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Cc({...t,checks:[],...j.normalizeParams(o),entries:s})}});function Me(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Cc({type:"enum",entries:r,...j.normalizeParams(t)})}var vv=b("ZodLiteral",(e,t)=>{$h.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wm(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function O(e,t){return new vv({type:"literal",values:Array.isArray(e)?e:[e],...j.normalizeParams(t)})}var $v=b("ZodTransform",(e,t)=>{Ks(),Sh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xm(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ur(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(j.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(j.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Zg(e){return new $v({type:"transform",transform:e})}var Dg=b("ZodOptional",(e,t)=>{ic.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ac(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function le(e){return new Dg({type:"optional",innerType:e})}var Mg=b("ZodExactOptional",(e,t)=>{zh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ac(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Sv(e){return new Mg({type:"optional",innerType:e})}var zv=b("ZodNullable",(e,t)=>{kh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ng(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function kg(e){return new zv({type:"nullable",innerType:e})}var kv=b("ZodDefault",(e,t)=>{Ph.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ig(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Pv(e,t){return new kv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var Ev=b("ZodPrefault",(e,t)=>{Eh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ag(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Tv(e,t){return new Ev({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():j.shallowClone(t)}})}var Lg=b("ZodNonOptional",(e,t)=>{Th.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>og(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ov(e,t){return new Lg({type:"nonoptional",innerType:e,...j.normalizeParams(t)})}var Rv=b("ZodCatch",(e,t)=>{Oh.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Av(e,t){return new Rv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:j.constantCatch(t)})}var Ug=b("ZodPipe",(e,t)=>{ac.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ug(e,r,n,o),e.in=t.in,e.out=t.out});function Pg(e,t){return new Ug({type:"pipe",in:e,out:t})}var Cv=b("ZodPreprocess",(e,t)=>{Ug.init(e,t),Rh.init(e,t)}),Iv=b("ZodReadonly",(e,t)=>{Ah.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Nv(e){return new Iv({type:"readonly",innerType:e})}var qg=b("ZodCustom",(e,t)=>{Ch.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gm(e,r,n,o)});function Fg(e,t){return xm(qg,e??(()=>!0),t)}function jv(e,t={}){return vm(qg,e,t)}function Zv(e,t){return $m(e,t)}function Zc(e,t){return new Cv({type:"pipe",in:Zg(e),out:t})}var Vg={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var Bg;Bg||(Bg={});var Gs={};ua(Gs,{ZodISODate:()=>Bn,ZodISODateTime:()=>Fn,ZodISODuration:()=>Hn,ZodISOTime:()=>Vn,date:()=>Lv,datetime:()=>Mv,duration:()=>qv,time:()=>Uv});function Mv(e){return Zs(Fn,e)}function Lv(e){return Ds(Bn,e)}function Uv(e){return Ms(Vn,e)}function qv(e){return Ls(Hn,e)}var Xs={};ua(Xs,{bigint:()=>Hv,boolean:()=>Vv,date:()=>Kv,number:()=>Bv,string:()=>Fv});function Fv(e){return Uh(Ic,e)}function Bv(e){return lm(Js,e)}function Vv(e){return pm(Nc,e)}function Hv(e){return hm(Rg,e)}function Kv(e){return bm(Ig,e)}var qt="2025-11-25";var Qs=[qt,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ft="io.modelcontextprotocol/related-task",ei="2.0",_e=Fg(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Hg=ie([g(),X().int()]),Kg=g(),GC=ye({ttl:X().optional(),pollInterval:X().optional()}),Wv=k({ttl:X().optional()}),Gv=k({taskId:g()}),Mc=ye({progressToken:Hg.optional(),[Ft]:Gv.optional()}),Ke=k({_meta:Mc.optional()}),Kn=Ke.extend({task:Wv.optional()}),Jg=e=>Kn.safeParse(e).success,$e=k({method:g(),params:Ke.loose().optional()}),Ge=k({_meta:Mc.optional()}),Xe=k({method:g(),params:Ge.loose().optional()}),Se=ye({_meta:Mc.optional()}),ti=ie([g(),X().int()]),Wg=k({jsonrpc:O(ei),id:ti,...$e.shape}).strict(),Jn=e=>Wg.safeParse(e).success,Gg=k({jsonrpc:O(ei),...Xe.shape}).strict(),Xg=e=>Gg.safeParse(e).success,Lc=k({jsonrpc:O(ei),id:ti,result:Se}).strict(),ur=e=>Lc.safeParse(e).success;var N;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(N||(N={}));var Uc=k({jsonrpc:O(ei),id:ti.optional(),error:k({code:X().int(),message:g(),data:ue().optional()})}).strict();var Yg=e=>Uc.safeParse(e).success;var Yr=ie([Wg,Gg,Lc,Uc]),XC=ie([Lc,Uc]),kt=Se.strict(),Xv=Ge.extend({requestId:ti.optional(),reason:g().optional()}),ri=Xe.extend({method:O("notifications/cancelled"),params:Xv}),Yv=k({src:g(),mimeType:g().optional(),sizes:z(g()).optional(),theme:Me(["light","dark"]).optional()}),Wn=k({icons:z(Yv).optional()}),Xr=k({name:g(),title:g().optional()}),Qg=Xr.extend({...Xr.shape,...Wn.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),Qv=Ws(k({applyDefaults:re().optional()}),oe(g(),ue())),e$=Zc(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ws(k({form:Qv.optional(),url:_e.optional()}),oe(g(),ue()).optional())),t$=ye({list:_e.optional(),cancel:_e.optional(),requests:ye({sampling:ye({createMessage:_e.optional()}).optional(),elicitation:ye({create:_e.optional()}).optional()}).optional()}),r$=ye({list:_e.optional(),cancel:_e.optional(),requests:ye({tools:ye({call:_e.optional()}).optional()}).optional()}),n$=k({experimental:oe(g(),_e).optional(),sampling:k({context:_e.optional(),tools:_e.optional()}).optional(),elicitation:e$.optional(),roots:k({listChanged:re().optional()}).optional(),tasks:t$.optional(),extensions:oe(g(),_e).optional()}),o$=Ke.extend({protocolVersion:g(),capabilities:n$,clientInfo:Qg}),qc=$e.extend({method:O("initialize"),params:o$});var s$=k({experimental:oe(g(),_e).optional(),logging:_e.optional(),completions:_e.optional(),prompts:k({listChanged:re().optional()}).optional(),resources:k({subscribe:re().optional(),listChanged:re().optional()}).optional(),tools:k({listChanged:re().optional()}).optional(),tasks:r$.optional(),extensions:oe(g(),_e).optional()}),Fc=Se.extend({protocolVersion:g(),capabilities:s$,serverInfo:Qg,instructions:g().optional()}),ni=Xe.extend({method:O("notifications/initialized"),params:Ge.optional()}),ey=e=>ni.safeParse(e).success,oi=$e.extend({method:O("ping"),params:Ke.optional()}),i$=k({progress:X(),total:le(X()),message:le(g())}),a$=k({...Ge.shape,...i$.shape,progressToken:Hg}),si=Xe.extend({method:O("notifications/progress"),params:a$}),c$=Ke.extend({cursor:Kg.optional()}),Gn=$e.extend({params:c$.optional()}),Xn=Se.extend({nextCursor:Kg.optional()}),u$=Me(["working","input_required","completed","failed","cancelled"]),Yn=k({taskId:g(),status:u$,ttl:ie([X(),Ag()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:le(X()),statusMessage:le(g())}),Pt=Se.extend({task:Yn}),l$=Ge.merge(Yn),Qn=Xe.extend({method:O("notifications/tasks/status"),params:l$}),ii=$e.extend({method:O("tasks/get"),params:Ke.extend({taskId:g()})}),ai=Se.merge(Yn),ci=$e.extend({method:O("tasks/result"),params:Ke.extend({taskId:g()})}),YC=Se.loose(),ui=Gn.extend({method:O("tasks/list")}),li=Xn.extend({tasks:z(Yn)}),di=$e.extend({method:O("tasks/cancel"),params:Ke.extend({taskId:g()})}),ty=Se.merge(Yn),ry=k({uri:g(),mimeType:le(g()),_meta:oe(g(),ue()).optional()}),ny=ry.extend({text:g()}),Bc=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),oy=ry.extend({blob:Bc}),eo=Me(["user","assistant"]),Qr=k({audience:z(eo).optional(),priority:X().min(0).max(1).optional(),lastModified:Gs.datetime({offset:!0}).optional()}),sy=k({...Xr.shape,...Wn.shape,uri:g(),description:le(g()),mimeType:le(g()),size:le(X()),annotations:Qr.optional(),_meta:le(ye({}))}),d$=k({...Xr.shape,...Wn.shape,uriTemplate:g(),description:le(g()),mimeType:le(g()),annotations:Qr.optional(),_meta:le(ye({}))}),f$=Gn.extend({method:O("resources/list")}),Vc=Xn.extend({resources:z(sy)}),p$=Gn.extend({method:O("resources/templates/list")}),Hc=Xn.extend({resourceTemplates:z(d$)}),Kc=Ke.extend({uri:g()}),h$=Kc,m$=$e.extend({method:O("resources/read"),params:h$}),Jc=Se.extend({contents:z(ie([ny,oy]))}),Wc=Xe.extend({method:O("notifications/resources/list_changed"),params:Ge.optional()}),g$=Kc,y$=$e.extend({method:O("resources/subscribe"),params:g$}),_$=Kc,b$=$e.extend({method:O("resources/unsubscribe"),params:_$}),w$=Ge.extend({uri:g()}),x$=Xe.extend({method:O("notifications/resources/updated"),params:w$}),v$=k({name:g(),description:le(g()),required:le(re())}),$$=k({...Xr.shape,...Wn.shape,description:le(g()),arguments:le(z(v$)),_meta:le(ye({}))}),S$=Gn.extend({method:O("prompts/list")}),Gc=Xn.extend({prompts:z($$)}),z$=Ke.extend({name:g(),arguments:oe(g(),g()).optional()}),k$=$e.extend({method:O("prompts/get"),params:z$}),Xc=k({type:O("text"),text:g(),annotations:Qr.optional(),_meta:oe(g(),ue()).optional()}),Yc=k({type:O("image"),data:Bc,mimeType:g(),annotations:Qr.optional(),_meta:oe(g(),ue()).optional()}),Qc=k({type:O("audio"),data:Bc,mimeType:g(),annotations:Qr.optional(),_meta:oe(g(),ue()).optional()}),P$=k({type:O("tool_use"),name:g(),id:g(),input:oe(g(),ue()),_meta:oe(g(),ue()).optional()}),E$=k({type:O("resource"),resource:ie([ny,oy]),annotations:Qr.optional(),_meta:oe(g(),ue()).optional()}),T$=sy.extend({type:O("resource_link")}),eu=ie([Xc,Yc,Qc,T$,E$]),O$=k({role:eo,content:eu}),tu=Se.extend({description:g().optional(),messages:z(O$)}),ru=Xe.extend({method:O("notifications/prompts/list_changed"),params:Ge.optional()}),R$=k({title:g().optional(),readOnlyHint:re().optional(),destructiveHint:re().optional(),idempotentHint:re().optional(),openWorldHint:re().optional()}),A$=k({taskSupport:Me(["required","optional","forbidden"]).optional()}),iy=k({...Xr.shape,...Wn.shape,description:g().optional(),inputSchema:k({type:O("object"),properties:oe(g(),_e).optional(),required:z(g()).optional()}).catchall(ue()),outputSchema:k({type:O("object"),properties:oe(g(),_e).optional(),required:z(g()).optional()}).catchall(ue()).optional(),annotations:R$.optional(),execution:A$.optional(),_meta:oe(g(),ue()).optional()}),nu=Gn.extend({method:O("tools/list")}),ou=Xn.extend({tools:z(iy)}),Bt=Se.extend({content:z(eu).default([]),structuredContent:oe(g(),ue()).optional(),isError:re().optional()}),QC=Bt.or(Se.extend({toolResult:ue()})),C$=Kn.extend({name:g(),arguments:oe(g(),ue()).optional()}),to=$e.extend({method:O("tools/call"),params:C$}),su=Xe.extend({method:O("notifications/tools/list_changed"),params:Ge.optional()}),ay=k({autoRefresh:re().default(!0),debounceMs:X().int().nonnegative().default(300)}),ro=Me(["debug","info","notice","warning","error","critical","alert","emergency"]),I$=Ke.extend({level:ro}),iu=$e.extend({method:O("logging/setLevel"),params:I$}),N$=Ge.extend({level:ro,logger:g().optional(),data:ue()}),j$=Xe.extend({method:O("notifications/message"),params:N$}),Z$=k({name:g().optional()}),D$=k({hints:z(Z$).optional(),costPriority:X().min(0).max(1).optional(),speedPriority:X().min(0).max(1).optional(),intelligencePriority:X().min(0).max(1).optional()}),M$=k({mode:Me(["auto","required","none"]).optional()}),L$=k({type:O("tool_result"),toolUseId:g().describe("The unique identifier for the corresponding tool call."),content:z(eu).default([]),structuredContent:k({}).loose().optional(),isError:re().optional(),_meta:oe(g(),ue()).optional()}),U$=jc("type",[Xc,Yc,Qc]),Ys=jc("type",[Xc,Yc,Qc,P$,L$]),q$=k({role:eo,content:ie([Ys,z(Ys)]),_meta:oe(g(),ue()).optional()}),F$=Kn.extend({messages:z(q$),modelPreferences:D$.optional(),systemPrompt:g().optional(),includeContext:Me(["none","thisServer","allServers"]).optional(),temperature:X().optional(),maxTokens:X().int(),stopSequences:z(g()).optional(),metadata:_e.optional(),tools:z(iy).optional(),toolChoice:M$.optional()}),au=$e.extend({method:O("sampling/createMessage"),params:F$}),lr=Se.extend({model:g(),stopReason:le(Me(["endTurn","stopSequence","maxTokens"]).or(g())),role:eo,content:U$}),no=Se.extend({model:g(),stopReason:le(Me(["endTurn","stopSequence","maxTokens","toolUse"]).or(g())),role:eo,content:ie([Ys,z(Ys)])}),B$=k({type:O("boolean"),title:g().optional(),description:g().optional(),default:re().optional()}),V$=k({type:O("string"),title:g().optional(),description:g().optional(),minLength:X().optional(),maxLength:X().optional(),format:Me(["email","uri","date","date-time"]).optional(),default:g().optional()}),H$=k({type:Me(["number","integer"]),title:g().optional(),description:g().optional(),minimum:X().optional(),maximum:X().optional(),default:X().optional()}),K$=k({type:O("string"),title:g().optional(),description:g().optional(),enum:z(g()),default:g().optional()}),J$=k({type:O("string"),title:g().optional(),description:g().optional(),oneOf:z(k({const:g(),title:g()})),default:g().optional()}),W$=k({type:O("string"),title:g().optional(),description:g().optional(),enum:z(g()),enumNames:z(g()).optional(),default:g().optional()}),G$=ie([K$,J$]),X$=k({type:O("array"),title:g().optional(),description:g().optional(),minItems:X().optional(),maxItems:X().optional(),items:k({type:O("string"),enum:z(g())}),default:z(g()).optional()}),Y$=k({type:O("array"),title:g().optional(),description:g().optional(),minItems:X().optional(),maxItems:X().optional(),items:k({anyOf:z(k({const:g(),title:g()}))}),default:z(g()).optional()}),Q$=ie([X$,Y$]),eS=ie([W$,G$,Q$]),tS=ie([eS,B$,V$,H$]),rS=Kn.extend({mode:O("form").optional(),message:g(),requestedSchema:k({type:O("object"),properties:oe(g(),tS),required:z(g()).optional()})}),nS=Kn.extend({mode:O("url"),message:g(),elicitationId:g(),url:g().url()}),oS=ie([rS,nS]),cu=$e.extend({method:O("elicitation/create"),params:oS}),sS=Ge.extend({elicitationId:g()}),iS=Xe.extend({method:O("notifications/elicitation/complete"),params:sS}),Vt=Se.extend({action:Me(["accept","decline","cancel"]),content:Zc(e=>e===null?void 0:e,oe(g(),ie([g(),X(),re(),z(g())])).optional())}),aS=k({type:O("ref/resource"),uri:g()});var cS=k({type:O("ref/prompt"),name:g()}),uS=Ke.extend({ref:ie([cS,aS]),argument:k({name:g(),value:g()}),context:k({arguments:oe(g(),g()).optional()}).optional()}),lS=$e.extend({method:O("completion/complete"),params:uS});var uu=Se.extend({completion:ye({values:z(g()).max(100),total:le(X().int()),hasMore:le(re())})}),dS=k({uri:g().startsWith("file://"),name:g().optional(),_meta:oe(g(),ue()).optional()}),fS=$e.extend({method:O("roots/list"),params:Ke.optional()}),lu=Se.extend({roots:z(dS)}),pS=Xe.extend({method:O("notifications/roots/list_changed"),params:Ge.optional()}),eI=ie([oi,qc,lS,iu,k$,S$,f$,p$,m$,y$,b$,to,nu,ii,ci,ui,di]),tI=ie([ri,si,ni,pS,Qn]),rI=ie([kt,lr,no,Vt,lu,ai,li,Pt]),nI=ie([oi,au,cu,fS,ii,ci,ui,di]),oI=ie([ri,si,j$,x$,Wc,su,ru,Qn,iS]),sI=ie([kt,Fc,uu,tu,Gc,Vc,Hc,Jc,Bt,ou,ai,li,Pt]),R=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===N.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Dc(o.elicitations,r)}return new e(t,r,n)}},Dc=class extends R{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Ht(e){return e==="completed"||e==="failed"||e==="cancelled"}var DI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function du(e){let r=Wr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Gr(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function fu(e,t){let r=Ie(e,t);if(!r.success)throw r.error;return r.data}var bS=6e4,en=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(ri,r=>{this._oncancel(r)}),this.setNotificationHandler(si,r=>{this._onprogress(r)}),this.setRequestHandler(oi,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ii,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new R(N.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ci,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new R(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new R(N.InvalidParams,`Task not found: ${s}`);if(!Ht(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Ht(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Ft]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(ui,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new R(N.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(di,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new R(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ht(o.status))throw new R(N.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new R(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof R?o:new R(N.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),R.fromError(N.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),ur(s)||Yg(s)?this._onresponse(s):Jn(s)?this._onrequest(s,i):Xg(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=R.fromError(N.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Ft]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:N.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);let a=Jg(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new R(N.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:t.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let h=f.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:N.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),ur(t))n(t);else{let i=new R(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(ur(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),ur(t))o(t);else{let i=R.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof R?i:new R(N.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Pt,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new R(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Ht(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new R(N.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new R(N.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof R?i:new R(N.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Ft]:c}});let h=v=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(v)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(C=>this._onerror(new Error(`Failed to send cancellation: ${C}`)));let $=v instanceof R?v:new R(N.RequestTimeout,String(v));l($)};this._responseHandlers.set(p,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let $=Ie(r,v.result);$.success?u($.data):l($.error)}catch($){l($)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let m=n?.timeout??bS,y=()=>h(R.fromError(N.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(p,m,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let _=c?.taskId;if(_){let v=$=>{let C=this._responseHandlers.get(p);C?C($):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,v),this._enqueueTaskMessage(_,{type:"request",message:f,timestamp:Date.now()}).catch($=>{this._cleanupTimeout(p),l($)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(p),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},ai,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},li,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},ty,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Ft]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Ft]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Ft]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=du(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=fu(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=du(t);this._notificationHandlers.set(n,o=>{let s=fu(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&Jn(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new R(N.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new R(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new R(N.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new R(N.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=Qn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ht(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new R(N.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Ht(a.status))throw new R(N.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=Qn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ht(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function cy(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fi(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];cy(i)&&cy(s)?r[o]={...i,...s}:r[o]=s}return r}var ab=la(od(),1),cb=la(ib(),1);function OT(){let e=new ab.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,cb.default)(e),e}var bn=class{constructor(t){this._ajv=t??OT()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Wi=class{constructor(t){this._client=t}async*callToolStream(t,r=Bt,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(t.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:t},r,s),a=o.getToolOutputValidator(t.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new R(N.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new R(N.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof R){yield{type:"error",error:l};return}yield{type:"error",error:new R(N.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}};function Gi(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Xi(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function Yi(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,n=e.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&Yi(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&Yi(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&Yi(r,t)}}function RT(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}var Qi=class extends en{constructor(t,r){super(r),this._clientInfo=t,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new bn,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",su,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",ru,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Wc,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Wi(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fi(this._capabilities,t)}setRequestHandler(t,r){let o=Wr(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Gr(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Ie(cu,c);if(!l.success){let v=l.error instanceof Error?l.error.message:String(l.error);throw new R(N.InvalidParams,`Invalid elicitation request: ${v}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:p,supportsUrlMode:f}=RT(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new R(N.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!f)throw new R(N.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let v=Ie(Pt,h);if(!v.success){let $=v.error instanceof Error?v.error.message:String(v.error);throw new R(N.InvalidParams,`Invalid task creation result: ${$}`)}return v.data}let m=Ie(Vt,h);if(!m.success){let v=m.error instanceof Error?m.error.message:String(m.error);throw new R(N.InvalidParams,`Invalid elicitation result: ${v}`)}let y=m.data,_=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&y.action==="accept"&&y.content&&_&&this._capabilities.elicitation?.form?.applyDefaults)try{Yi(_,y.content)}catch{}return y};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ie(au,c);if(!l.success){let y=l.error instanceof Error?l.error.message:String(l.error);throw new R(N.InvalidParams,`Invalid sampling request: ${y}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let y=Ie(Pt,p);if(!y.success){let _=y.error instanceof Error?y.error.message:String(y.error);throw new R(N.InvalidParams,`Invalid task creation result: ${_}`)}return y.data}let h=d.tools||d.toolChoice?no:lr,m=Ie(h,p);if(!m.success){let y=m.error instanceof Error?m.error.message:String(m.error);throw new R(N.InvalidParams,`Invalid sampling result: ${y}`)}return m.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:qt,capabilities:this._capabilities,clientInfo:this._clientInfo}},Fc,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!Qs.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${t})`);break;case"ping":break}}assertTaskCapability(t){Gi(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&Xi(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},kt,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},uu,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},kt,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},tu,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Gc,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Vc,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Hc,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Jc,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},kt,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},kt,r)}async callTool(t,r=Bt,n){if(this.isToolTaskRequired(t.name))throw new R(N.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:t},r,n),s=this.getToolOutputValidator(t.name);if(s){if(!o.structuredContent&&!o.isError)throw new R(N.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new R(N.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof R?i:new R(N.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(t){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of t){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let n=await this.request({method:"tools/list",params:t},ou,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=ay.safeParse(n);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(t,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var pb=la(fb(),1);function hb(e){if(e)try{return pb.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function ea(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function mb(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...ea(t.headers),...ea(n.headers)}:t.headers};return e(r,o)}:e}var pd;pd=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function LT(e){return(await pd).getRandomValues(new Uint8Array(e))}async function UT(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await LT(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function qT(e){return await UT(e)}async function FT(e){let t=await(await pd).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function hd(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await qT(e),r=await FT(t);return{code_verifier:t,code_challenge:r}}var Ee=Og().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Vg.custom,message:"URL must be parseable",fatal:!0}),Fa}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),yb=ye({resource:g().url(),authorization_servers:z(Ee).optional(),jwks_uri:g().url().optional(),scopes_supported:z(g()).optional(),bearer_methods_supported:z(g()).optional(),resource_signing_alg_values_supported:z(g()).optional(),resource_name:g().optional(),resource_documentation:g().optional(),resource_policy_uri:g().url().optional(),resource_tos_uri:g().url().optional(),tls_client_certificate_bound_access_tokens:re().optional(),authorization_details_types_supported:z(g()).optional(),dpop_signing_alg_values_supported:z(g()).optional(),dpop_bound_access_tokens_required:re().optional()}),md=ye({issuer:g(),authorization_endpoint:Ee,token_endpoint:Ee,registration_endpoint:Ee.optional(),scopes_supported:z(g()).optional(),response_types_supported:z(g()),response_modes_supported:z(g()).optional(),grant_types_supported:z(g()).optional(),token_endpoint_auth_methods_supported:z(g()).optional(),token_endpoint_auth_signing_alg_values_supported:z(g()).optional(),service_documentation:Ee.optional(),revocation_endpoint:Ee.optional(),revocation_endpoint_auth_methods_supported:z(g()).optional(),revocation_endpoint_auth_signing_alg_values_supported:z(g()).optional(),introspection_endpoint:g().optional(),introspection_endpoint_auth_methods_supported:z(g()).optional(),introspection_endpoint_auth_signing_alg_values_supported:z(g()).optional(),code_challenge_methods_supported:z(g()).optional(),client_id_metadata_document_supported:re().optional()}),BT=ye({issuer:g(),authorization_endpoint:Ee,token_endpoint:Ee,userinfo_endpoint:Ee.optional(),jwks_uri:Ee,registration_endpoint:Ee.optional(),scopes_supported:z(g()).optional(),response_types_supported:z(g()),response_modes_supported:z(g()).optional(),grant_types_supported:z(g()).optional(),acr_values_supported:z(g()).optional(),subject_types_supported:z(g()),id_token_signing_alg_values_supported:z(g()),id_token_encryption_alg_values_supported:z(g()).optional(),id_token_encryption_enc_values_supported:z(g()).optional(),userinfo_signing_alg_values_supported:z(g()).optional(),userinfo_encryption_alg_values_supported:z(g()).optional(),userinfo_encryption_enc_values_supported:z(g()).optional(),request_object_signing_alg_values_supported:z(g()).optional(),request_object_encryption_alg_values_supported:z(g()).optional(),request_object_encryption_enc_values_supported:z(g()).optional(),token_endpoint_auth_methods_supported:z(g()).optional(),token_endpoint_auth_signing_alg_values_supported:z(g()).optional(),display_values_supported:z(g()).optional(),claim_types_supported:z(g()).optional(),claims_supported:z(g()).optional(),service_documentation:g().optional(),claims_locales_supported:z(g()).optional(),ui_locales_supported:z(g()).optional(),claims_parameter_supported:re().optional(),request_parameter_supported:re().optional(),request_uri_parameter_supported:re().optional(),require_request_uri_registration:re().optional(),op_policy_uri:Ee.optional(),op_tos_uri:Ee.optional(),client_id_metadata_document_supported:re().optional()}),_b=k({...BT.shape,...md.pick({code_challenge_methods_supported:!0}).shape}),bb=k({access_token:g(),id_token:g().optional(),token_type:g(),expires_in:Xs.number().optional(),scope:g().optional(),refresh_token:g().optional(),issuer:g().optional().catch(void 0)}).strip(),wb=k({error:g(),error_description:g().optional(),error_uri:g().optional()}),gb=Ee.optional().or(O("").transform(()=>{})),VT=k({redirect_uris:z(Ee),token_endpoint_auth_method:g().optional(),grant_types:z(g()).optional(),response_types:z(g()).optional(),client_name:g().optional(),client_uri:Ee.optional(),logo_uri:gb,scope:g().optional(),contacts:z(g()).optional(),tos_uri:gb,policy_uri:g().optional(),jwks_uri:Ee.optional(),jwks:Cg().optional(),software_id:g().optional(),software_version:g().optional(),software_statement:g().optional()}).strip(),HT=k({client_id:g(),client_secret:g().optional(),client_id_issued_at:X().optional(),client_secret_expires_at:X().optional(),issuer:g().optional().catch(void 0)}).strip(),xb=VT.merge(HT),pZ=k({error:g(),error_description:g().optional()}).strip(),hZ=k({token:g(),token_type_hint:g().optional()}).strip();function vb(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function $b({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}var ge=class extends Error{constructor(t,r){super(t),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let t={error:this.errorCode,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}get errorCode(){return this.constructor.errorCode}},jo=class extends ge{};jo.errorCode="invalid_request";var $r=class extends ge{};$r.errorCode="invalid_client";var Sr=class extends ge{};Sr.errorCode="invalid_grant";var zr=class extends ge{};zr.errorCode="unauthorized_client";var Zo=class extends ge{};Zo.errorCode="unsupported_grant_type";var Do=class extends ge{};Do.errorCode="invalid_scope";var Mo=class extends ge{};Mo.errorCode="access_denied";var Ct=class extends ge{};Ct.errorCode="server_error";var Lo=class extends ge{};Lo.errorCode="temporarily_unavailable";var Uo=class extends ge{};Uo.errorCode="unsupported_response_type";var qo=class extends ge{};qo.errorCode="unsupported_token_type";var Fo=class extends ge{};Fo.errorCode="invalid_token";var Bo=class extends ge{};Bo.errorCode="method_not_allowed";var Vo=class extends ge{};Vo.errorCode="too_many_requests";var kr=class extends ge{};kr.errorCode="invalid_client_metadata";var Ho=class extends ge{};Ho.errorCode="insufficient_scope";var Ko=class extends ge{};Ko.errorCode="invalid_target";var Sb={[jo.errorCode]:jo,[$r.errorCode]:$r,[Sr.errorCode]:Sr,[zr.errorCode]:zr,[Zo.errorCode]:Zo,[Do.errorCode]:Do,[Mo.errorCode]:Mo,[Ct.errorCode]:Ct,[Lo.errorCode]:Lo,[Uo.errorCode]:Uo,[qo.errorCode]:qo,[Fo.errorCode]:Fo,[Bo.errorCode]:Bo,[Vo.errorCode]:Vo,[kr.errorCode]:kr,[Ho.errorCode]:Ho,[Ko.errorCode]:Ko};var It=class extends Error{constructor(t){super(t??"Unauthorized")}};function KT(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var gd="code",yd="S256";function JT(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&KT(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function WT(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":GT(o,s,r);return;case"client_secret_post":XT(o,s,n);return;case"none":YT(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function GT(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}function XT(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function YT(e,t){t.set("client_id",e)}async function kb(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let n=wb.parse(JSON.parse(r)),{error:o,error_description:s,error_uri:i}=n,a=Sb[o]||Ct;return new a(s||"",i)}catch(n){let o=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new Ct(o)}}function QT(e,t){let[r,n]=[e,t];try{[r,n]=[new URL(e).href,new URL(t).href]}catch{}return r===n||r.endsWith("/")&&r.slice(0,-1)===n||n.endsWith("/")&&n.slice(0,-1)===r}function wd(e,t){if(e)return typeof e.issuer!="string"?e.issuer==null?e:{...e,issuer:void 0}:QT(e.issuer,t)?e:void 0}var eO=bb.omit({issuer:!0}),tO=xb.omit({issuer:!0});function Pb(e,t){return new Error(`OAuth client information is bound to authorization server ${e.issuer} and is not presented to ${t}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}async function Jo(e,t){try{return await _d(e,t)}catch(r){if(r instanceof $r||r instanceof zr)return await e.invalidateCredentials?.("all"),await _d(e,t);if(r instanceof Sr)return await e.invalidateCredentials?.("tokens"),await _d(e,t);throw r}}async function _d(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let i=await e.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await Tb(c,{fetchFn:s}),!a)try{a=await Eb(t,{resourceMetadataUrl:l},s)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let D=await cO(t,{resourceMetadataUrl:l,fetchFn:s});c=D.authorizationServerUrl,u=D.authorizationServerMetadata,a=D.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=String(c),p=await nO(t,e,a),f=p&&a&&!e.validateResourceURL?a.resource:p,h=n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,m=await Promise.resolve(e.clientInformation()),y=wd(m,d),_=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(m&&!y&&!_)throw Pb(m,d);let v=y?.issuer==null?y:void 0,$=async()=>{try{v&&await e.saveClientInformation?.({...v,issuer:d})}catch{}};if(!y){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let D=u?.client_id_metadata_document_supported===!0,S=e.clientMetadataUrl;if(S&&!rO(S))throw new kr(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${S}`);if(D&&S)y={client_id:S,issuer:d},await e.saveClientInformation?.(y);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");y={...await pO(c,{metadata:u,clientMetadata:e.clientMetadata,scope:h,fetchFn:s}),issuer:d},await e.saveClientInformation(y)}}let C=!e.redirectUrl;if(r!==void 0||C){let D=await fO(e,c,{metadata:u,resource:f,authorizationCode:r,fetchFn:s});return await $(),await e.saveTokens({...D,issuer:d}),"AUTHORIZED"}let w=wd(await e.tokens(),d);if(w?.refresh_token&&w.issuer==null&&console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged."),w?.refresh_token)try{let D=await dO(c,{metadata:u,clientInformation:y,refreshToken:w.refresh_token,resource:f,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await $(),await e.saveTokens({...D,issuer:d}),"AUTHORIZED"}catch(D){if(!(!(D instanceof ge)||D instanceof Ct))throw D}let x=e.state?await e.state():void 0,{authorizationUrl:E,codeVerifier:W}=await uO(c,{metadata:u,clientInformation:y,state:x,redirectUrl:e.redirectUrl,scope:h,resource:f});return await e.saveCodeVerifier(W),await e.redirectToAuthorization(E),"REDIRECT"}function rO(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function nO(e,t,r){let n=vb(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!$b({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 xd(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=bd(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=bd(e,"scope")||void 0,a=bd(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function bd(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function Eb(e,t,r=fetch){let n=await iO(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||n.status===404)throw await n?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return yb.parse(await n.json())}async function vd(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?vd(e,void 0,r):void 0;throw n}}function oO(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function zb(e,t,r=fetch){return await vd(e,{"MCP-Protocol-Version":t},r)}function sO(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function iO(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??qt,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=oO(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await zb(i,s,r);if(!n?.metadataUrl&&sO(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await zb(c,s,r)}return a}function aO(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function Tb(e,{fetchFn:t=fetch,protocolVersion:r=qt}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=aO(e);for(let{url:s,type:i}of o){let a=await vd(s,n,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}return i==="oauth"?md.parse(await a.json()):_b.parse(await a.json())}}}async function cO(e,t){let r,n;try{r=await Eb(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));let o=await Tb(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}function Ob(e){return typeof e=="string"?e:e.href}async function uO(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(gd))throw new Error(`Incompatible auth server: does not support response type ${gd}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(yd))throw new Error(`Incompatible auth server: does not support code challenge method ${yd}`)}else a=new URL("/authorize",e);let c=await hd(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",gd),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",yd),a.searchParams.set("redirect_uri",String(n)),s&&a.searchParams.set("state",s),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",Ob(i)),{authorizationUrl:a,codeVerifier:u}}function lO(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Rb(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:i}){let a=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",Ob(s)),o)await o(c,r,a,t);else if(n){let l=t?.token_endpoint_auth_methods_supported??[],d=JT(n,l);WT(d,n,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await kb(u);return eO.parse(await u.json())}async function dO(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await Rb(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:i});return{refresh_token:n,...c}}async function fO(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){let i=async()=>{let l=await e.clientInformation(),d=wd(l,String(t));if(l&&!d)throw Pb(l,String(t));return d},a=await i(),c=e.clientMetadata.scope,u;if(e.prepareTokenRequest&&(u=await e.prepareTokenRequest(c)),!u){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let l=await e.codeVerifier();u=lO(o,l,e.redirectUrl)}return a??(a=await i()),Rb(t,{metadata:r,tokenRequestParams:u,clientInformation:a,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}async function pO(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:o}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i=await(o??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!i.ok)throw await kb(i);return tO.parse(await i.json())}var Wo=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},Ab=10,hO=13,Pr=32;function $d(e){}function Nb(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=$d,onError:r=$d,onRetry:n=$d,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,u,l="",d=0,p,f=!1;function h(w){if(f)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,w.charCodeAt(0)===239&&w.charCodeAt(1)===187&&w.charCodeAt(2)===191&&(w=w.slice(3))),i.length===0){let W=y(w);W!==""&&(i.push(W),a=W.length),m();return}if(w.indexOf(`
|
|
70
|
+
`)===-1&&w.indexOf("\r")===-1){i.push(w),a+=w.length,m();return}i.push(w);let x=i.join("");i.length=0,a=0;let E=y(x);E!==""&&(i.push(E),a=E.length),m()}function m(){s!==void 0&&(a+l.length<=s||(f=!0,i.length=0,a=0,u=void 0,l="",d=0,p=void 0,r(new Wo(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function y(w){let x=0;if(w.indexOf("\r")===-1){let E=w.indexOf(`
|
|
71
|
+
`,x);for(;E!==-1;){if(x===E){d>0&&t({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0,x=E+1,E=w.indexOf(`
|
|
72
|
+
`,x);continue}let W=w.charCodeAt(x);if(Cb(w,x,W)){let D=w.charCodeAt(x+5)===Pr?x+6:x+5,S=w.slice(D,E);if(d===0&&w.charCodeAt(E+1)===Ab){t({id:u,event:p,data:S}),u=void 0,l="",p=void 0,x=E+2,E=w.indexOf(`
|
|
73
|
+
`,x);continue}l=d===0?S:`${l}
|
|
74
|
+
${S}`,d++}else Ib(w,x,W)?p=w.slice(w.charCodeAt(x+6)===Pr?x+7:x+6,E)||void 0:_(w,x,E);x=E+1,E=w.indexOf(`
|
|
75
|
+
`,x)}return w.slice(x)}for(;x<w.length;){let E=w.indexOf("\r",x),W=w.indexOf(`
|
|
76
|
+
`,x),D=-1;if(E!==-1&&W!==-1?D=E<W?E:W:E!==-1?E===w.length-1?D=-1:D=E:W!==-1&&(D=W),D===-1)break;_(w,x,D),x=D+1,w.charCodeAt(x-1)===hO&&w.charCodeAt(x)===Ab&&x++}return w.slice(x)}function _(w,x,E){if(x===E){$();return}let W=w.charCodeAt(x);if(Cb(w,x,W)){let V=w.charCodeAt(x+5)===Pr?x+6:x+5,be=w.slice(V,E);l=d===0?be:`${l}
|
|
77
|
+
${be}`,d++;return}if(Ib(w,x,W)){p=w.slice(w.charCodeAt(x+6)===Pr?x+7:x+6,E)||void 0;return}if(W===105&&w.charCodeAt(x+1)===100&&w.charCodeAt(x+2)===58){let V=w.slice(w.charCodeAt(x+3)===Pr?x+4:x+3,E);V.includes("\0")||(u=V);return}if(W===58){if(o){let V=w.slice(x,E);o(V.slice(w.charCodeAt(x+1)===Pr?2:1))}return}let D=w.slice(x,E),S=D.indexOf(":");if(S===-1){v(D,"",D);return}let T=D.slice(0,S),M=D.charCodeAt(S+1)===Pr?2:1,F=D.slice(S+M);v(T,F,D)}function v(w,x,E){switch(w){case"event":p=x||void 0;break;case"data":l=d===0?x:`${l}
|
|
78
|
+
${x}`,d++;break;case"id":x.includes("\0")||(u=x);break;case"retry":/^\d+$/.test(x)?n(parseInt(x,10)):r(new Wo(`Invalid \`retry\` value: "${x}"`,{type:"invalid-retry",value:x,line:E}));break;default:r(new Wo(`Unknown field "${w.length>20?`${w.slice(0,20)}\u2026`:w}"`,{type:"unknown-field",field:w,value:x,line:E}));break}}function $(){d>0&&t({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0}function C(w={}){if(w.consume&&i.length>0){let x=i.join("");_(x,0,x.length)}c=!0,u=void 0,l="",d=0,p=void 0,i.length=0,a=0,f=!1}return{feed:h,reset:C}}function Cb(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Ib(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var ta=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=Nb({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:n,maxBufferSize:o})},transform(i){s.feed(i)}})}};var mO={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},tr=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},ra=class{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=mb(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??mO}async _authThenStart(){if(!this._authProvider)throw new It("No auth provider");let t;try{t=await Jo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new It;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(t.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=ea(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:n,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new tr(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,t,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),o)}_scheduleReconnection(t,r=0){let n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},o)}_handleSseStream(t,r,n){if(!t)return;let{onresumptiontoken:o,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let l=t.pipeThrough(new TextDecoderStream).pipeThrough(new ta({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){let{value:f,done:h}=await l.read();if(h)break;if(f.id&&(i=f.id,a=!0,o?.(f.id)),!!f.data&&(!f.event||f.event==="message"))try{let m=Yr.parse(JSON.parse(f.data));ur(m)&&(c=!0,s!==void 0&&(m.id=s)),this.onmessage?.(m)}catch(m){this.onerror?.(m)}}(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(f){this.onerror?.(new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new It("No auth provider");if(await Jo(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new It("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,r){try{let{resumptionToken:n,onresumptiontoken:o}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:Jn(t)?t.id:void 0}).catch(f=>this.onerror?.(f));return}let s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let f=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new tr(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:h,scope:m}=xd(a);if(this._resourceMetadataUrl=h,this._scope=m,await Jo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new It;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:h,scope:m,error:y}=xd(a);if(y==="insufficient_scope"){let _=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===_)throw new tr(403,"Server returned 403 after trying upscoping");if(m&&(this._scope=m),h&&(this._resourceMetadataUrl=h),this._lastUpscopingHeader=_??void 0,await Jo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new It;return this.send(t)}}throw new tr(a.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),ey(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}let l=(Array.isArray(t)?t:[t]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,d=a.headers.get("content-type"),p=hb(d);if(l)if(p==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(p==="application/json"){let f=await a.json(),h=Array.isArray(f)?f.map(m=>Yr.parse(m)):[Yr.parse(f)];for(let m of h)this.onmessage?.(m)}else throw await a.body?.cancel(),new tr(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new tr(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};var na=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},lr,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Vt,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};var oa=class extends en{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ro.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new bn,this.setRequestHandler(qc,n=>this._oninitialize(n)),this.setNotificationHandler(ni,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(iu,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=ro.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new na(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fi(this._capabilities,t)}setRequestHandler(t,r){let o=Wr(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Gr(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Ie(to,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new R(N.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let h=Ie(Pt,p);if(!h.success){let m=h.error instanceof Error?h.error.message:String(h.error);throw new R(N.InvalidParams,`Invalid task creation result: ${m}`)}return h.data}let f=Ie(Bt,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new R(N.InvalidParams,`Invalid tools/call result: ${h}`)}return f.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Xi(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Gi(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:Qs.includes(r)?r:qt,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"},kt)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},no,r):this.request({method:"sampling/createMessage",params:t},lr,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Vt,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Vt,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new R(N.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof R?i:new R(N.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},lu,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import Zb from"node:process";var gO=10*1024*1024,sa=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??gO}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
79
|
+
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),yO(r)}clear(){this._buffer=void 0}};function yO(e){return Yr.parse(JSON.parse(e))}function jb(e){return JSON.stringify(e)+`
|
|
80
|
+
`}var ia=class{constructor(t=Zb.stdin,r=Zb.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new sa({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=jb(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var wO=64*1024;globalThis.crypto||(globalThis.crypto=_O);var aa=e=>process.stderr.write(`[jotbus] ${e}
|
|
81
|
+
`);function Sd(e){aa(e),process.exit(1)}async function zd(e){let t=process.env.JOTBUS_TOKEN;t||Sd("Missing JOTBUS_TOKEN. Copy the connection string from the dashboard when you mint a token.");let r;try{r=Jd(t)}catch{Sd("JOTBUS_TOKEN is not a valid Jotbus token or connection string.")}r.token||Sd("JOTBUS_TOKEN contains only a key; use the full connection string from the dashboard.");let n=r.token,o=r.key?await On(r.key):null,s=S=>S.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");function i(S){if(process.env.JOTBUS_AGENT)return process.env.JOTBUS_AGENT.slice(0,64);let T=s(S??""),M=/claude/.test(T)?"claude":/codex/.test(T)?"codex":/cursor/.test(T)?"cursor":T.split("-")[0]||"agent",F=s(bO().split(".")[0].replace(/-?(local|lan|home)$/i,""))||"machine";return`${M}-${F}`.slice(0,64)}let a=null;async function c(){if(a)return a;let S=new Qi({name:"jotbus",version:or});return await S.connect(new ra(new URL(e),{requestInit:{headers:{Authorization:`Bearer ${n}`,"x-jotbus-e2e":"1",...o?{"x-jotbus-key-check":o.check}:{},"User-Agent":`jotbus/${or}`}}})),a=S,S}async function u(S,T){try{return await(await c()).callTool({name:S,arguments:T})}catch(M){throw a=null,M}}let l=S=>S.content?.[0]?.type==="text"?S.content[0].text:"",d=S=>({content:[{type:"text",text:JSON.stringify(S,null,2)}]}),p=S=>({isError:!0,content:[{type:"text",text:S}]}),f=e.replace(/\/mcp\/?$/,""),h=()=>`${f}/claim#${t}`;function m(S,T){if(S.isError||!T)return S;let M;try{M=JSON.parse(l(S))}catch{return S}let F="expires_at"in M?M.expires_at:T.expires_at;if(!F)return S;let V=Math.ceil((new Date(F).getTime()-Date.now())/6e4);if(V>20)return S;let be=h(),xn=V<=0?"This temporary Jotbus workspace has expired.":`This temporary Jotbus workspace expires in ${V} minute${V===1?"":"s"}. `+(T.created_by_you?`Tell the user: to keep it (with its history and connected agents), they can open ${be}`:"Tell the user: whoever created it can keep it with the link `npx jotbus` printed, or start a new one with `npx jotbus`.");return d({...M,notice:xn})}let y=null;async function _(S=!1){if(y&&!S)return y;let T=await u("list_workspaces",{});if(T.isError)throw new Error(l(T));return y=JSON.parse(l(T)),y}async function v(S){let T=await _();if(S==null||S==="")return T.length===1?T[0]:void 0;let M=String(S).trim();return T.find(F=>F.id===M)??T.find(F=>F.name===M.toLowerCase())}function $(S){return S.encrypted?o?o.check!==S.key_check?`The encryption key in JOTBUS_TOKEN doesn't match workspace "${S.name}". Mint a new token from a browser where the workspace is unlocked.`:null:`Workspace "${S.name}" is end-to-end encrypted, but JOTBUS_TOKEN has no key. Use the full connection string (token.key) shown when the token was minted.`:null}async function C(S){if(S.isError)return S;let T=JSON.parse(l(S));if(!T.encrypted)return S;let M=(await _()).find(V=>V.id===T.workspace_id),F=M?$(M):"Unknown workspace";return F?p(F):(T.messages=await Promise.all(T.messages.map(async V=>{if(!Kd(V.content))return{...V,content:"[unreadable: not an encrypted message]"};try{let be=await o.decrypt(T.workspace_id,V.content);return{...V,author:be.a??V.author,content:be.c,metadata:be.m??null}}catch{return{...V,content:"[unreadable: could not decrypt with this key]"}}})),delete T.workspace_id,d(T))}async function w(S,T){switch(S){case"list_workspaces":{let M=await _(!0);return d(M.map(({key_check:F,...V},be)=>({...V,...V.encrypted?{key_ok:!$(M[be])}:{}})))}case"write_workspace":{let M=typeof T.author=="string"&&T.author.trim()||W(),F=await v(T.workspace);if(!F?.encrypted)return u(S,{...T,author:M});let V=$(F);if(V)return p(V);let be=String(T.content??"");if(!be.trim())return p("content must be a non-empty string");if(Buffer.byteLength(be)>wO)return p("Message is too large; the maximum is 64 KB of text.");let xn=T.metadata,kd=await o.encrypt(F.id,{c:be,a:M,...xn?{m:xn}:{}}),{metadata:Pd,author:zO,...Mb}=T;return m(await u(S,{...Mb,workspace:F.id,content:kd}),F)}case"invite_to_workspace":{let M=await v(T.workspace);if(M&&!M.encrypted)return p("Invites are available for end-to-end encrypted workspaces. Share an install command from the dashboard instead.");if(M?.encrypted&&$(M))return p($(M));let F=await u(S,{...T,...M?{workspace:M.id}:{}});if(F.isError)return F;let V=JSON.parse(l(F)),be=`${V.invite_secret}.${r.key}`,{invite_secret:xn,workspace_id:kd,...Pd}=V;return d({...Pd,join_command:`npx jotbus@latest join ${be}`,join_link:`${f}/join#${be}`,tell_the_user:`Send the join command (or link) privately; it contains the workspace's encryption key. The other person runs it in a terminal on their machine (Node 20+, no account needed), then starts a new agent session and says "Use Jotbus to collaborate."`})}case"jotbus_help":{let M=await u(S,T);if(M.isError)return M;let F=(await _())[0],V=[];return F?.temporary&&F.created_by_you?V.push(`This connection created the temporary workspace "${F.name}". Link to keep it (give it to the user only if they want to keep the workspace): ${h()}`):F?.temporary&&V.push(`"${F.name}" is a temporary workspace created by someone else; only its creator can keep it.`),{content:[{type:"text",text:l(M)+(V.length?`
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
## This connection
|
|
84
|
+
${V.join(`
|
|
85
|
+
`)}`:"")}]}}case"read_workspace":case"listen_workspace":return m(await C(await u(S,T)),await v(T.workspace));default:return u(S,T)}}let x="Shared scratchpad for coding agents (Jotbus).";try{x=(await c()).getInstructions()??x;let T=await _();for(let M of T){let F=$(M);F&&aa(F)}aa(`connected: ${T.length} workspace(s)${T.some(M=>M.encrypted)?", end-to-end encrypted":""}`)}catch(S){aa(`could not reach ${e} yet (${S.message}); will retry on first use`)}o&&(x+=`
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
Messages in encrypted workspaces are encrypted and decrypted on this machine; the server only stores ciphertext. Still never post secrets.`),x=x.replace(/\n*Other agents see your messages as written by[^\n]*/,"");let E=new oa({name:"jotbus",version:or},{capabilities:{tools:{}},instructions:x}),W=()=>i(E.getClientVersion()?.name);E.setRequestHandler(nu,async()=>{let{tools:S}=await(await c()).listTools();return{tools:S.map(T=>T.name==="write_workspace"?{...T,description:`${T.description} You appear to other agents as "${W()}"; they can @mention you as @${W()}.`+(o?" In encrypted workspaces the text is encrypted on this machine before upload.":"")}:T)}}),E.setRequestHandler(to,async S=>{try{return await w(S.params.name,S.params.arguments??{})}catch(T){return p(`Jotbus request failed: ${T.message}`)}});let D=()=>process.exit(0);process.stdin.on("end",D),process.stdin.on("close",D),E.onclose=D,await E.connect(new ia)}globalThis.crypto||(globalThis.crypto=xO);var{values:wn,positionals:$O}=vO({allowPositionals:!0,strict:!1,options:{url:{type:"string"},origin:{type:"string"},yes:{type:"boolean",short:"y"},"no-install":{type:"boolean"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}}),Db=`jotbus ${or}: a shared, end-to-end encrypted scratchpad for your coding agents
|
|
88
|
+
|
|
89
|
+
Try it now (no account):
|
|
90
|
+
npx jotbus create a temporary workspace (60 min) and connect your agents
|
|
91
|
+
npx jotbus join <invite> join one from another machine, or share with someone
|
|
92
|
+
|
|
93
|
+
Options:
|
|
94
|
+
-y, --yes don't ask before replacing an existing Jotbus connection
|
|
95
|
+
--no-install just print the commands instead of configuring Claude Code / Codex
|
|
96
|
+
-h, --help, -v, --version
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
Persistent workspaces: sign in at ${sr} and paste the install command it shows.
|
|
99
|
+
|
|
100
|
+
When launched by an agent this runs the MCP server:
|
|
101
|
+
JOTBUS_TOKEN connection string (jb_live_<token>.<key>)
|
|
102
|
+
JOTBUS_AGENT name other agents see (default: <agent>-<hostname>, e.g. claude-macbook)
|
|
103
|
+
--url MCP endpoint (or JOTBUS_URL). Default: ${ls}
|
|
104
|
+
`,[Er,...SO]=$O;if(wn.version)process.stdout.write(`${or}
|
|
105
|
+
`);else if(wn.help||Er==="help")process.stdout.write(Db);else{let e=wn.url??process.env.JOTBUS_URL,r={origin:(wn.origin??process.env.JOTBUS_ORIGIN??e?.replace(/\/mcp\/?$/,"")??sr).replace(/\/$/,""),yes:!!wn.yes,install:!wn["no-install"]};Er==="join"?await of(r,SO[0]):Er==="new"||Er==="create"?await Ea(r):Er==="mcp"?await zd(e??ls):Er?(process.stderr.write(`Unknown command "${Er}".
|
|
91
106
|
|
|
92
|
-
|
|
107
|
+
${Db}`),process.exit(1)):process.stdin.isTTY&&!process.env.JOTBUS_TOKEN?await Ea(r):await zd(e??ls)}
|