@augmentcode/onison 0.0.1 → 0.0.21
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/CHANGELOG.md +0 -0
- package/README.md +0 -0
- package/auggie-v2.mjs +7713 -0
- package/auggie-v2.mjs.d/extensions/ask-user/index.js +24 -0
- package/auggie-v2.mjs.d/extensions/manifest.json +12 -0
- package/auggie-v2.mjs.d/extensions/mcp/index.js +90 -0
- package/auggie-v2.mjs.d/photon_rs_bg.wasm +0 -0
- package/indexing-worker.mjs +208 -0
- package/package.json +30 -9
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import{createRequire as bL}from"node:module";var AL=Object.create;var{getPrototypeOf:OL,defineProperty:P6,getOwnPropertyNames:NL}=Object;var UL=Object.prototype.hasOwnProperty;function ML(Q){return this[Q]}var wL,PL,j6=(Q,X,Y)=>{var J=Q!=null&&typeof Q==="object";if(J){var W=X?wL??=new WeakMap:PL??=new WeakMap,$=W.get(Q);if($)return $}Y=Q!=null?AL(OL(Q)):{};let B=X||!Q||!Q.__esModule?P6(Y,"default",{value:Q,enumerable:!0}):Y;for(let G of NL(Q))if(!UL.call(B,G))P6(B,G,{get:ML.bind(Q,G),enumerable:!0});if(J)W.set(Q,B);return B};var w=(Q,X)=>()=>(X||Q((X={exports:{}}).exports,X),X.exports);var jL=(Q)=>Q;function IL(Q,X){this[Q]=jL.bind(null,X)}var I6=(Q,X)=>{for(var Y in X)P6(Q,Y,{get:X[Y],enumerable:!0,configurable:!0,set:IL.bind(X,Y)})};var o0=bL(import.meta.url);var X8=w((B3)=>{Object.defineProperty(B3,"__esModule",{value:!0});B3.regexpCode=B3.getEsmExportName=B3.getProperty=B3.safeStringify=B3.stringify=B3.strConcat=B3.addCodeArg=B3.str=B3._=B3.nil=B3._Code=B3.Name=B3.IDENTIFIER=B3._CodeOrName=void 0;class zQ{}B3._CodeOrName=zQ;B3.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class X9 extends zQ{constructor(Q){super();if(!B3.IDENTIFIER.test(Q))throw Error("CodeGen: name must be a valid identifier");this.str=Q}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}B3.Name=X9;class h0 extends zQ{constructor(Q){super();this._items=typeof Q==="string"?[Q]:Q}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let Q=this._items[0];return Q===""||Q==='""'}get str(){var Q;return(Q=this._str)!==null&&Q!==void 0?Q:this._str=this._items.reduce((X,Y)=>`${X}${Y}`,"")}get names(){var Q;return(Q=this._names)!==null&&Q!==void 0?Q:this._names=this._items.reduce((X,Y)=>{if(Y instanceof X9)X[Y.str]=(X[Y.str]||0)+1;return X},{})}}B3._Code=h0;B3.nil=new h0("");function W3(Q,...X){let Y=[Q[0]],J=0;while(J<X.length)$X(Y,X[J]),Y.push(Q[++J]);return new h0(Y)}B3._=W3;var WX=new h0("+");function $3(Q,...X){let Y=[Q8(Q[0])],J=0;while(J<X.length)Y.push(WX),$X(Y,X[J]),Y.push(WX,Q8(Q[++J]));return jz(Y),new h0(Y)}B3.str=$3;function $X(Q,X){if(X instanceof h0)Q.push(...X._items);else if(X instanceof X9)Q.push(X);else Q.push(Tz(X))}B3.addCodeArg=$X;function jz(Q){let X=1;while(X<Q.length-1){if(Q[X]===WX){let Y=Iz(Q[X-1],Q[X+1]);if(Y!==void 0){Q.splice(X-1,3,Y);continue}Q[X++]="+"}X++}}function Iz(Q,X){if(X==='""')return Q;if(Q==='""')return X;if(typeof Q=="string"){if(X instanceof X9||Q[Q.length-1]!=='"')return;if(typeof X!="string")return`${Q.slice(0,-1)}${X}"`;if(X[0]==='"')return Q.slice(0,-1)+X.slice(1);return}if(typeof X=="string"&&X[0]==='"'&&!(Q instanceof X9))return`"${Q}${X.slice(1)}`;return}function bz(Q,X){return X.emptyStr()?Q:Q.emptyStr()?X:$3`${Q}${X}`}B3.strConcat=bz;function Tz(Q){return typeof Q=="number"||typeof Q=="boolean"||Q===null?Q:Q8(Array.isArray(Q)?Q.join(","):Q)}function Rz(Q){return new h0(Q8(Q))}B3.stringify=Rz;function Q8(Q){return JSON.stringify(Q).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}B3.safeStringify=Q8;function Ez(Q){return typeof Q=="string"&&B3.IDENTIFIER.test(Q)?new h0(`.${Q}`):W3`[${Q}]`}B3.getProperty=Ez;function Sz(Q){if(typeof Q=="string"&&B3.IDENTIFIER.test(Q))return new h0(`${Q}`);throw Error(`CodeGen: invalid export name: ${Q}, use explicit $id name mapping`)}B3.getEsmExportName=Sz;function Cz(Q){return new h0(Q.toString())}B3.regexpCode=Cz});var KX=w((Z3)=>{Object.defineProperty(Z3,"__esModule",{value:!0});Z3.ValueScope=Z3.ValueScopeName=Z3.Scope=Z3.varKinds=Z3.UsedValueState=void 0;var M0=X8();class H3 extends Error{constructor(Q){super(`CodeGen: "code" for ${Q} not defined`);this.value=Q.value}}var AQ;(function(Q){Q[Q.Started=0]="Started",Q[Q.Completed=1]="Completed"})(AQ||(Z3.UsedValueState=AQ={}));Z3.varKinds={const:new M0.Name("const"),let:new M0.Name("let"),var:new M0.Name("var")};class GX{constructor({prefixes:Q,parent:X}={}){this._names={},this._prefixes=Q,this._parent=X}toName(Q){return Q instanceof M0.Name?Q:this.name(Q)}name(Q){return new M0.Name(this._newName(Q))}_newName(Q){let X=this._names[Q]||this._nameGroup(Q);return`${Q}${X.index++}`}_nameGroup(Q){var X,Y;if(((Y=(X=this._parent)===null||X===void 0?void 0:X._prefixes)===null||Y===void 0?void 0:Y.has(Q))||this._prefixes&&!this._prefixes.has(Q))throw Error(`CodeGen: prefix "${Q}" is not allowed in this scope`);return this._names[Q]={prefix:Q,index:0}}}Z3.Scope=GX;class HX extends M0.Name{constructor(Q,X){super(X);this.prefix=Q}setValue(Q,{property:X,itemIndex:Y}){this.value=Q,this.scopePath=M0._`.${new M0.Name(X)}[${Y}]`}}Z3.ValueScopeName=HX;var pz=M0._`\n`;class K3 extends GX{constructor(Q){super(Q);this._values={},this._scope=Q.scope,this.opts={...Q,_n:Q.lines?pz:M0.nil}}get(){return this._scope}name(Q){return new HX(Q,this._newName(Q))}value(Q,X){var Y;if(X.ref===void 0)throw Error("CodeGen: ref must be passed in value");let J=this.toName(Q),{prefix:W}=J,$=(Y=X.key)!==null&&Y!==void 0?Y:X.ref,B=this._values[W];if(B){let H=B.get($);if(H)return H}else B=this._values[W]=new Map;B.set($,J);let G=this._scope[W]||(this._scope[W]=[]),K=G.length;return G[K]=X.ref,J.setValue(X,{property:W,itemIndex:K}),J}getValue(Q,X){let Y=this._values[Q];if(!Y)return;return Y.get(X)}scopeRefs(Q,X=this._values){return this._reduceValues(X,(Y)=>{if(Y.scopePath===void 0)throw Error(`CodeGen: name "${Y}" has no value`);return M0._`${Q}${Y.scopePath}`})}scopeCode(Q=this._values,X,Y){return this._reduceValues(Q,(J)=>{if(J.value===void 0)throw Error(`CodeGen: name "${J}" has no value`);return J.value.code},X,Y)}_reduceValues(Q,X,Y={},J){let W=M0.nil;for(let $ in Q){let B=Q[$];if(!B)continue;let G=Y[$]=Y[$]||new Map;B.forEach((K)=>{if(G.has(K))return;G.set(K,AQ.Started);let H=X(K);if(H){let Z=this.opts.es5?Z3.varKinds.var:Z3.varKinds.const;W=M0._`${W}${Z} ${K} = ${H};${this.opts._n}`}else if(H=J===null||J===void 0?void 0:J(K))W=M0._`${W}${H}${this.opts._n}`;else throw new H3(K);G.set(K,AQ.Completed)})}return W}}Z3.ValueScope=K3});var x=w((w0)=>{Object.defineProperty(w0,"__esModule",{value:!0});w0.or=w0.and=w0.not=w0.CodeGen=w0.operators=w0.varKinds=w0.ValueScopeName=w0.ValueScope=w0.Scope=w0.Name=w0.regexpCode=w0.stringify=w0.getProperty=w0.nil=w0.strConcat=w0.str=w0._=void 0;var g=X8(),u0=KX(),O1=X8();Object.defineProperty(w0,"_",{enumerable:!0,get:function(){return O1._}});Object.defineProperty(w0,"str",{enumerable:!0,get:function(){return O1.str}});Object.defineProperty(w0,"strConcat",{enumerable:!0,get:function(){return O1.strConcat}});Object.defineProperty(w0,"nil",{enumerable:!0,get:function(){return O1.nil}});Object.defineProperty(w0,"getProperty",{enumerable:!0,get:function(){return O1.getProperty}});Object.defineProperty(w0,"stringify",{enumerable:!0,get:function(){return O1.stringify}});Object.defineProperty(w0,"regexpCode",{enumerable:!0,get:function(){return O1.regexpCode}});Object.defineProperty(w0,"Name",{enumerable:!0,get:function(){return O1.Name}});var PQ=KX();Object.defineProperty(w0,"Scope",{enumerable:!0,get:function(){return PQ.Scope}});Object.defineProperty(w0,"ValueScope",{enumerable:!0,get:function(){return PQ.ValueScope}});Object.defineProperty(w0,"ValueScopeName",{enumerable:!0,get:function(){return PQ.ValueScopeName}});Object.defineProperty(w0,"varKinds",{enumerable:!0,get:function(){return PQ.varKinds}});w0.operators={GT:new g._Code(">"),GTE:new g._Code(">="),LT:new g._Code("<"),LTE:new g._Code("<="),EQ:new g._Code("==="),NEQ:new g._Code("!=="),NOT:new g._Code("!"),OR:new g._Code("||"),AND:new g._Code("&&"),ADD:new g._Code("+")};class N1{optimizeNodes(){return this}optimizeNames(Q,X){return this}}class V3 extends N1{constructor(Q,X,Y){super();this.varKind=Q,this.name=X,this.rhs=Y}render({es5:Q,_n:X}){let Y=Q?u0.varKinds.var:this.varKind,J=this.rhs===void 0?"":` = ${this.rhs}`;return`${Y} ${this.name}${J};`+X}optimizeNames(Q,X){if(!Q[this.name.str])return;if(this.rhs)this.rhs=J9(this.rhs,Q,X);return this}get names(){return this.rhs instanceof g._CodeOrName?this.rhs.names:{}}}class VX extends N1{constructor(Q,X,Y){super();this.lhs=Q,this.rhs=X,this.sideEffects=Y}render({_n:Q}){return`${this.lhs} = ${this.rhs};`+Q}optimizeNames(Q,X){if(this.lhs instanceof g.Name&&!Q[this.lhs.str]&&!this.sideEffects)return;return this.rhs=J9(this.rhs,Q,X),this}get names(){let Q=this.lhs instanceof g.Name?{}:{...this.lhs.names};return wQ(Q,this.rhs)}}class D3 extends VX{constructor(Q,X,Y,J){super(Q,Y,J);this.op=X}render({_n:Q}){return`${this.lhs} ${this.op}= ${this.rhs};`+Q}}class q3 extends N1{constructor(Q){super();this.label=Q,this.names={}}render({_n:Q}){return`${this.label}:`+Q}}class z3 extends N1{constructor(Q){super();this.label=Q,this.names={}}render({_n:Q}){return`break${this.label?` ${this.label}`:""};`+Q}}class F3 extends N1{constructor(Q){super();this.error=Q}render({_n:Q}){return`throw ${this.error};`+Q}get names(){return this.error.names}}class A3 extends N1{constructor(Q){super();this.code=Q}render({_n:Q}){return`${this.code};`+Q}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(Q,X){return this.code=J9(this.code,Q,X),this}get names(){return this.code instanceof g._CodeOrName?this.code.names:{}}}class jQ extends N1{constructor(Q=[]){super();this.nodes=Q}render(Q){return this.nodes.reduce((X,Y)=>X+Y.render(Q),"")}optimizeNodes(){let{nodes:Q}=this,X=Q.length;while(X--){let Y=Q[X].optimizeNodes();if(Array.isArray(Y))Q.splice(X,1,...Y);else if(Y)Q[X]=Y;else Q.splice(X,1)}return Q.length>0?this:void 0}optimizeNames(Q,X){let{nodes:Y}=this,J=Y.length;while(J--){let W=Y[J];if(W.optimizeNames(Q,X))continue;oz(Q,W.names),Y.splice(J,1)}return Y.length>0?this:void 0}get names(){return this.nodes.reduce((Q,X)=>k1(Q,X.names),{})}}class U1 extends jQ{render(Q){return"{"+Q._n+super.render(Q)+"}"+Q._n}}class O3 extends jQ{}class Y8 extends U1{}Y8.kind="else";class Y1 extends U1{constructor(Q,X){super(X);this.condition=Q}render(Q){let X=`if(${this.condition})`+super.render(Q);if(this.else)X+="else "+this.else.render(Q);return X}optimizeNodes(){super.optimizeNodes();let Q=this.condition;if(Q===!0)return this.nodes;let X=this.else;if(X){let Y=X.optimizeNodes();X=this.else=Array.isArray(Y)?new Y8(Y):Y}if(X){if(Q===!1)return X instanceof Y1?X:X.nodes;if(this.nodes.length)return this;return new Y1(P3(Q),X instanceof Y1?[X]:X.nodes)}if(Q===!1||!this.nodes.length)return;return this}optimizeNames(Q,X){var Y;if(this.else=(Y=this.else)===null||Y===void 0?void 0:Y.optimizeNames(Q,X),!(super.optimizeNames(Q,X)||this.else))return;return this.condition=J9(this.condition,Q,X),this}get names(){let Q=super.names;if(wQ(Q,this.condition),this.else)k1(Q,this.else.names);return Q}}Y1.kind="if";class Y9 extends U1{}Y9.kind="for";class N3 extends Y9{constructor(Q){super();this.iteration=Q}render(Q){return`for(${this.iteration})`+super.render(Q)}optimizeNames(Q,X){if(!super.optimizeNames(Q,X))return;return this.iteration=J9(this.iteration,Q,X),this}get names(){return k1(super.names,this.iteration.names)}}class U3 extends Y9{constructor(Q,X,Y,J){super();this.varKind=Q,this.name=X,this.from=Y,this.to=J}render(Q){let X=Q.es5?u0.varKinds.var:this.varKind,{name:Y,from:J,to:W}=this;return`for(${X} ${Y}=${J}; ${Y}<${W}; ${Y}++)`+super.render(Q)}get names(){let Q=wQ(super.names,this.from);return wQ(Q,this.to)}}class ZX extends Y9{constructor(Q,X,Y,J){super();this.loop=Q,this.varKind=X,this.name=Y,this.iterable=J}render(Q){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(Q)}optimizeNames(Q,X){if(!super.optimizeNames(Q,X))return;return this.iterable=J9(this.iterable,Q,X),this}get names(){return k1(super.names,this.iterable.names)}}class OQ extends U1{constructor(Q,X,Y){super();this.name=Q,this.args=X,this.async=Y}render(Q){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(Q)}}OQ.kind="func";class NQ extends jQ{render(Q){return"return "+super.render(Q)}}NQ.kind="return";class M3 extends U1{render(Q){let X="try"+super.render(Q);if(this.catch)X+=this.catch.render(Q);if(this.finally)X+=this.finally.render(Q);return X}optimizeNodes(){var Q,X;return super.optimizeNodes(),(Q=this.catch)===null||Q===void 0||Q.optimizeNodes(),(X=this.finally)===null||X===void 0||X.optimizeNodes(),this}optimizeNames(Q,X){var Y,J;return super.optimizeNames(Q,X),(Y=this.catch)===null||Y===void 0||Y.optimizeNames(Q,X),(J=this.finally)===null||J===void 0||J.optimizeNames(Q,X),this}get names(){let Q=super.names;if(this.catch)k1(Q,this.catch.names);if(this.finally)k1(Q,this.finally.names);return Q}}class UQ extends U1{constructor(Q){super();this.error=Q}render(Q){return`catch(${this.error})`+super.render(Q)}}UQ.kind="catch";class MQ extends U1{render(Q){return"finally"+super.render(Q)}}MQ.kind="finally";class w3{constructor(Q,X={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...X,_n:X.lines?`
|
|
2
|
+
`:""},this._extScope=Q,this._scope=new u0.Scope({parent:Q}),this._nodes=[new O3]}toString(){return this._root.render(this.opts)}name(Q){return this._scope.name(Q)}scopeName(Q){return this._extScope.name(Q)}scopeValue(Q,X){let Y=this._extScope.value(Q,X);return(this._values[Y.prefix]||(this._values[Y.prefix]=new Set)).add(Y),Y}getScopeValue(Q,X){return this._extScope.getValue(Q,X)}scopeRefs(Q){return this._extScope.scopeRefs(Q,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(Q,X,Y,J){let W=this._scope.toName(X);if(Y!==void 0&&J)this._constants[W.str]=Y;return this._leafNode(new V3(Q,W,Y)),W}const(Q,X,Y){return this._def(u0.varKinds.const,Q,X,Y)}let(Q,X,Y){return this._def(u0.varKinds.let,Q,X,Y)}var(Q,X,Y){return this._def(u0.varKinds.var,Q,X,Y)}assign(Q,X,Y){return this._leafNode(new VX(Q,X,Y))}add(Q,X){return this._leafNode(new D3(Q,w0.operators.ADD,X))}code(Q){if(typeof Q=="function")Q();else if(Q!==g.nil)this._leafNode(new A3(Q));return this}object(...Q){let X=["{"];for(let[Y,J]of Q){if(X.length>1)X.push(",");if(X.push(Y),Y!==J||this.opts.es5)X.push(":"),(0,g.addCodeArg)(X,J)}return X.push("}"),new g._Code(X)}if(Q,X,Y){if(this._blockNode(new Y1(Q)),X&&Y)this.code(X).else().code(Y).endIf();else if(X)this.code(X).endIf();else if(Y)throw Error('CodeGen: "else" body without "then" body');return this}elseIf(Q){return this._elseNode(new Y1(Q))}else(){return this._elseNode(new Y8)}endIf(){return this._endBlockNode(Y1,Y8)}_for(Q,X){if(this._blockNode(Q),X)this.code(X).endFor();return this}for(Q,X){return this._for(new N3(Q),X)}forRange(Q,X,Y,J,W=this.opts.es5?u0.varKinds.var:u0.varKinds.let){let $=this._scope.toName(Q);return this._for(new U3(W,$,X,Y),()=>J($))}forOf(Q,X,Y,J=u0.varKinds.const){let W=this._scope.toName(Q);if(this.opts.es5){let $=X instanceof g.Name?X:this.var("_arr",X);return this.forRange("_i",0,g._`${$}.length`,(B)=>{this.var(W,g._`${$}[${B}]`),Y(W)})}return this._for(new ZX("of",J,W,X),()=>Y(W))}forIn(Q,X,Y,J=this.opts.es5?u0.varKinds.var:u0.varKinds.const){if(this.opts.ownProperties)return this.forOf(Q,g._`Object.keys(${X})`,Y);let W=this._scope.toName(Q);return this._for(new ZX("in",J,W,X),()=>Y(W))}endFor(){return this._endBlockNode(Y9)}label(Q){return this._leafNode(new q3(Q))}break(Q){return this._leafNode(new z3(Q))}return(Q){let X=new NQ;if(this._blockNode(X),this.code(Q),X.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(NQ)}try(Q,X,Y){if(!X&&!Y)throw Error('CodeGen: "try" without "catch" and "finally"');let J=new M3;if(this._blockNode(J),this.code(Q),X){let W=this.name("e");this._currNode=J.catch=new UQ(W),X(W)}if(Y)this._currNode=J.finally=new MQ,this.code(Y);return this._endBlockNode(UQ,MQ)}throw(Q){return this._leafNode(new F3(Q))}block(Q,X){if(this._blockStarts.push(this._nodes.length),Q)this.code(Q).endBlock(X);return this}endBlock(Q){let X=this._blockStarts.pop();if(X===void 0)throw Error("CodeGen: not in self-balancing block");let Y=this._nodes.length-X;if(Y<0||Q!==void 0&&Y!==Q)throw Error(`CodeGen: wrong number of nodes: ${Y} vs ${Q} expected`);return this._nodes.length=X,this}func(Q,X=g.nil,Y,J){if(this._blockNode(new OQ(Q,X,Y)),J)this.code(J).endFunc();return this}endFunc(){return this._endBlockNode(OQ)}optimize(Q=1){while(Q-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(Q){return this._currNode.nodes.push(Q),this}_blockNode(Q){this._currNode.nodes.push(Q),this._nodes.push(Q)}_endBlockNode(Q,X){let Y=this._currNode;if(Y instanceof Q||X&&Y instanceof X)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${X?`${Q.kind}/${X.kind}`:Q.kind}"`)}_elseNode(Q){let X=this._currNode;if(!(X instanceof Y1))throw Error('CodeGen: "else" without "if"');return this._currNode=X.else=Q,this}get _root(){return this._nodes[0]}get _currNode(){let Q=this._nodes;return Q[Q.length-1]}set _currNode(Q){let X=this._nodes;X[X.length-1]=Q}}w0.CodeGen=w3;function k1(Q,X){for(let Y in X)Q[Y]=(Q[Y]||0)+(X[Y]||0);return Q}function wQ(Q,X){return X instanceof g._CodeOrName?k1(Q,X.names):Q}function J9(Q,X,Y){if(Q instanceof g.Name)return J(Q);if(!W(Q))return Q;return new g._Code(Q._items.reduce(($,B)=>{if(B instanceof g.Name)B=J(B);if(B instanceof g._Code)$.push(...B._items);else $.push(B);return $},[]));function J($){let B=Y[$.str];if(B===void 0||X[$.str]!==1)return $;return delete X[$.str],B}function W($){return $ instanceof g._Code&&$._items.some((B)=>B instanceof g.Name&&X[B.str]===1&&Y[B.str]!==void 0)}}function oz(Q,X){for(let Y in X)Q[Y]=(Q[Y]||0)-(X[Y]||0)}function P3(Q){return typeof Q=="boolean"||typeof Q=="number"||Q===null?!Q:g._`!${LX(Q)}`}w0.not=P3;var rz=j3(w0.operators.AND);function tz(...Q){return Q.reduce(rz)}w0.and=tz;var az=j3(w0.operators.OR);function sz(...Q){return Q.reduce(az)}w0.or=sz;function j3(Q){return(X,Y)=>X===g.nil?Y:Y===g.nil?X:g._`${LX(X)} ${Q} ${LX(Y)}`}function LX(Q){return Q instanceof g.Name?Q:g._`(${Q})`}});var f=w((_3)=>{Object.defineProperty(_3,"__esModule",{value:!0});_3.checkStrictMode=_3.getErrorPath=_3.Type=_3.useFunc=_3.setEvaluated=_3.evaluatedPropsToName=_3.mergeEvaluated=_3.eachItem=_3.unescapeJsonPointer=_3.escapeJsonPointer=_3.escapeFragment=_3.unescapeFragment=_3.schemaRefOrVal=_3.schemaHasRulesButRef=_3.schemaHasRules=_3.checkUnknownRules=_3.alwaysValidSchema=_3.toHash=void 0;var d=x(),YF=X8();function JF(Q){let X={};for(let Y of Q)X[Y]=!0;return X}_3.toHash=JF;function WF(Q,X){if(typeof X=="boolean")return X;if(Object.keys(X).length===0)return!0;return R3(Q,X),!E3(X,Q.self.RULES.all)}_3.alwaysValidSchema=WF;function R3(Q,X=Q.schema){let{opts:Y,self:J}=Q;if(!Y.strictSchema)return;if(typeof X==="boolean")return;let W=J.RULES.keywords;for(let $ in X)if(!W[$])k3(Q,`unknown keyword: "${$}"`)}_3.checkUnknownRules=R3;function E3(Q,X){if(typeof Q=="boolean")return!Q;for(let Y in Q)if(X[Y])return!0;return!1}_3.schemaHasRules=E3;function $F(Q,X){if(typeof Q=="boolean")return!Q;for(let Y in Q)if(Y!=="$ref"&&X.all[Y])return!0;return!1}_3.schemaHasRulesButRef=$F;function BF({topSchemaRef:Q,schemaPath:X},Y,J,W){if(!W){if(typeof Y=="number"||typeof Y=="boolean")return Y;if(typeof Y=="string")return d._`${Y}`}return d._`${Q}${X}${(0,d.getProperty)(J)}`}_3.schemaRefOrVal=BF;function GF(Q){return S3(decodeURIComponent(Q))}_3.unescapeFragment=GF;function HF(Q){return encodeURIComponent(qX(Q))}_3.escapeFragment=HF;function qX(Q){if(typeof Q=="number")return`${Q}`;return Q.replace(/~/g,"~0").replace(/\//g,"~1")}_3.escapeJsonPointer=qX;function S3(Q){return Q.replace(/~1/g,"/").replace(/~0/g,"~")}_3.unescapeJsonPointer=S3;function KF(Q,X){if(Array.isArray(Q))for(let Y of Q)X(Y);else X(Q)}_3.eachItem=KF;function b3({mergeNames:Q,mergeToName:X,mergeValues:Y,resultToName:J}){return(W,$,B,G)=>{let K=B===void 0?$:B instanceof d.Name?($ instanceof d.Name?Q(W,$,B):X(W,$,B),B):$ instanceof d.Name?(X(W,B,$),$):Y($,B);return G===d.Name&&!(K instanceof d.Name)?J(W,K):K}}_3.mergeEvaluated={props:b3({mergeNames:(Q,X,Y)=>Q.if(d._`${Y} !== true && ${X} !== undefined`,()=>{Q.if(d._`${X} === true`,()=>Q.assign(Y,!0),()=>Q.assign(Y,d._`${Y} || {}`).code(d._`Object.assign(${Y}, ${X})`))}),mergeToName:(Q,X,Y)=>Q.if(d._`${Y} !== true`,()=>{if(X===!0)Q.assign(Y,!0);else Q.assign(Y,d._`${Y} || {}`),zX(Q,Y,X)}),mergeValues:(Q,X)=>Q===!0?!0:{...Q,...X},resultToName:C3}),items:b3({mergeNames:(Q,X,Y)=>Q.if(d._`${Y} !== true && ${X} !== undefined`,()=>Q.assign(Y,d._`${X} === true ? true : ${Y} > ${X} ? ${Y} : ${X}`)),mergeToName:(Q,X,Y)=>Q.if(d._`${Y} !== true`,()=>Q.assign(Y,X===!0?!0:d._`${Y} > ${X} ? ${Y} : ${X}`)),mergeValues:(Q,X)=>Q===!0?!0:Math.max(Q,X),resultToName:(Q,X)=>Q.var("items",X)})};function C3(Q,X){if(X===!0)return Q.var("props",!0);let Y=Q.var("props",d._`{}`);if(X!==void 0)zX(Q,Y,X);return Y}_3.evaluatedPropsToName=C3;function zX(Q,X,Y){Object.keys(Y).forEach((J)=>Q.assign(d._`${X}${(0,d.getProperty)(J)}`,!0))}_3.setEvaluated=zX;var T3={};function ZF(Q,X){return Q.scopeValue("func",{ref:X,code:T3[X.code]||(T3[X.code]=new YF._Code(X.code))})}_3.useFunc=ZF;var DX;(function(Q){Q[Q.Num=0]="Num",Q[Q.Str=1]="Str"})(DX||(_3.Type=DX={}));function LF(Q,X,Y){if(Q instanceof d.Name){let J=X===DX.Num;return Y?J?d._`"[" + ${Q} + "]"`:d._`"['" + ${Q} + "']"`:J?d._`"/" + ${Q}`:d._`"/" + ${Q}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return Y?(0,d.getProperty)(Q).toString():"/"+qX(Q)}_3.getErrorPath=LF;function k3(Q,X,Y=Q.opts.strictSchema){if(!Y)return;if(X=`strict mode: ${X}`,Y===!0)throw Error(X);Q.self.logger.warn(X)}_3.checkStrictMode=k3});var J1=w((v3)=>{Object.defineProperty(v3,"__esModule",{value:!0});var q0=x(),EF={data:new q0.Name("data"),valCxt:new q0.Name("valCxt"),instancePath:new q0.Name("instancePath"),parentData:new q0.Name("parentData"),parentDataProperty:new q0.Name("parentDataProperty"),rootData:new q0.Name("rootData"),dynamicAnchors:new q0.Name("dynamicAnchors"),vErrors:new q0.Name("vErrors"),errors:new q0.Name("errors"),this:new q0.Name("this"),self:new q0.Name("self"),scope:new q0.Name("scope"),json:new q0.Name("json"),jsonPos:new q0.Name("jsonPos"),jsonLen:new q0.Name("jsonLen"),jsonPart:new q0.Name("jsonPart")};v3.default=EF});var J8=w((h3)=>{Object.defineProperty(h3,"__esModule",{value:!0});h3.extendErrors=h3.resetErrorsCount=h3.reportExtraError=h3.reportError=h3.keyword$DataError=h3.keywordError=void 0;var h=x(),bQ=f(),F0=J1();h3.keywordError={message:({keyword:Q})=>h.str`must pass "${Q}" keyword validation`};h3.keyword$DataError={message:({keyword:Q,schemaType:X})=>X?h.str`"${Q}" keyword must be ${X} ($data)`:h.str`"${Q}" keyword is invalid ($data)`};function CF(Q,X=h3.keywordError,Y,J){let{it:W}=Q,{gen:$,compositeRule:B,allErrors:G}=W,K=f3(Q,X,Y);if(J!==null&&J!==void 0?J:B||G)y3($,K);else g3(W,h._`[${K}]`)}h3.reportError=CF;function kF(Q,X=h3.keywordError,Y){let{it:J}=Q,{gen:W,compositeRule:$,allErrors:B}=J,G=f3(Q,X,Y);if(y3(W,G),!($||B))g3(J,F0.default.vErrors)}h3.reportExtraError=kF;function _F(Q,X){Q.assign(F0.default.errors,X),Q.if(h._`${F0.default.vErrors} !== null`,()=>Q.if(X,()=>Q.assign(h._`${F0.default.vErrors}.length`,X),()=>Q.assign(F0.default.vErrors,null)))}h3.resetErrorsCount=_F;function xF({gen:Q,keyword:X,schemaValue:Y,data:J,errsCount:W,it:$}){if(W===void 0)throw Error("ajv implementation error");let B=Q.name("err");Q.forRange("i",W,F0.default.errors,(G)=>{if(Q.const(B,h._`${F0.default.vErrors}[${G}]`),Q.if(h._`${B}.instancePath === undefined`,()=>Q.assign(h._`${B}.instancePath`,(0,h.strConcat)(F0.default.instancePath,$.errorPath))),Q.assign(h._`${B}.schemaPath`,h.str`${$.errSchemaPath}/${X}`),$.opts.verbose)Q.assign(h._`${B}.schema`,Y),Q.assign(h._`${B}.data`,J)})}h3.extendErrors=xF;function y3(Q,X){let Y=Q.const("err",X);Q.if(h._`${F0.default.vErrors} === null`,()=>Q.assign(F0.default.vErrors,h._`[${Y}]`),h._`${F0.default.vErrors}.push(${Y})`),Q.code(h._`${F0.default.errors}++`)}function g3(Q,X){let{gen:Y,validateName:J,schemaEnv:W}=Q;if(W.$async)Y.throw(h._`new ${Q.ValidationError}(${X})`);else Y.assign(h._`${J}.errors`,X),Y.return(!1)}var _1={keyword:new h.Name("keyword"),schemaPath:new h.Name("schemaPath"),params:new h.Name("params"),propertyName:new h.Name("propertyName"),message:new h.Name("message"),schema:new h.Name("schema"),parentSchema:new h.Name("parentSchema")};function f3(Q,X,Y){let{createErrors:J}=Q.it;if(J===!1)return h._`{}`;return vF(Q,X,Y)}function vF(Q,X,Y={}){let{gen:J,it:W}=Q,$=[yF(W,Y),gF(Q,Y)];return fF(Q,X,$),J.object(...$)}function yF({errorPath:Q},{instancePath:X}){let Y=X?h.str`${Q}${(0,bQ.getErrorPath)(X,bQ.Type.Str)}`:Q;return[F0.default.instancePath,(0,h.strConcat)(F0.default.instancePath,Y)]}function gF({keyword:Q,it:{errSchemaPath:X}},{schemaPath:Y,parentSchema:J}){let W=J?X:h.str`${X}/${Q}`;if(Y)W=h.str`${W}${(0,bQ.getErrorPath)(Y,bQ.Type.Str)}`;return[_1.schemaPath,W]}function fF(Q,{params:X,message:Y},J){let{keyword:W,data:$,schemaValue:B,it:G}=Q,{opts:K,propertyName:H,topSchemaRef:Z,schemaPath:L}=G;if(J.push([_1.keyword,W],[_1.params,typeof X=="function"?X(Q):X||h._`{}`]),K.messages)J.push([_1.message,typeof Y=="function"?Y(Q):Y]);if(K.verbose)J.push([_1.schema,B],[_1.parentSchema,h._`${Z}${L}`],[F0.default.data,$]);if(H)J.push([_1.propertyName,H])}});var p3=w((l3)=>{Object.defineProperty(l3,"__esModule",{value:!0});l3.boolOrEmptySchema=l3.topBoolOrEmptySchema=void 0;var cF=J8(),pF=x(),dF=J1(),iF={message:"boolean schema is false"};function nF(Q){let{gen:X,schema:Y,validateName:J}=Q;if(Y===!1)m3(Q,!1);else if(typeof Y=="object"&&Y.$async===!0)X.return(dF.default.data);else X.assign(pF._`${J}.errors`,null),X.return(!0)}l3.topBoolOrEmptySchema=nF;function oF(Q,X){let{gen:Y,schema:J}=Q;if(J===!1)Y.var(X,!1),m3(Q);else Y.var(X,!0)}l3.boolOrEmptySchema=oF;function m3(Q,X){let{gen:Y,data:J}=Q,W={gen:Y,keyword:"false schema",data:J,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:Q};(0,cF.reportError)(W,iF,void 0,X)}});var AX=w((d3)=>{Object.defineProperty(d3,"__esModule",{value:!0});d3.getRules=d3.isJSONType=void 0;var tF=["string","number","integer","boolean","null","object","array"],aF=new Set(tF);function sF(Q){return typeof Q=="string"&&aF.has(Q)}d3.isJSONType=sF;function eF(){let Q={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...Q,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},Q.number,Q.string,Q.array,Q.object],post:{rules:[]},all:{},keywords:{}}}d3.getRules=eF});var OX=w((r3)=>{Object.defineProperty(r3,"__esModule",{value:!0});r3.shouldUseRule=r3.shouldUseGroup=r3.schemaHasRulesForType=void 0;function XA({schema:Q,self:X},Y){let J=X.RULES.types[Y];return J&&J!==!0&&n3(Q,J)}r3.schemaHasRulesForType=XA;function n3(Q,X){return X.rules.some((Y)=>o3(Q,Y))}r3.shouldUseGroup=n3;function o3(Q,X){var Y;return Q[X.keyword]!==void 0||((Y=X.definition.implements)===null||Y===void 0?void 0:Y.some((J)=>Q[J]!==void 0))}r3.shouldUseRule=o3});var W8=w((QB)=>{Object.defineProperty(QB,"__esModule",{value:!0});QB.reportTypeError=QB.checkDataTypes=QB.checkDataType=QB.coerceAndCheckDataType=QB.getJSONTypes=QB.getSchemaTypes=QB.DataType=void 0;var WA=AX(),$A=OX(),BA=J8(),_=x(),a3=f(),W9;(function(Q){Q[Q.Correct=0]="Correct",Q[Q.Wrong=1]="Wrong"})(W9||(QB.DataType=W9={}));function GA(Q){let X=s3(Q.type);if(X.includes("null")){if(Q.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!X.length&&Q.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if(Q.nullable===!0)X.push("null")}return X}QB.getSchemaTypes=GA;function s3(Q){let X=Array.isArray(Q)?Q:Q?[Q]:[];if(X.every(WA.isJSONType))return X;throw Error("type must be JSONType or JSONType[]: "+X.join(","))}QB.getJSONTypes=s3;function HA(Q,X){let{gen:Y,data:J,opts:W}=Q,$=KA(X,W.coerceTypes),B=X.length>0&&!($.length===0&&X.length===1&&(0,$A.schemaHasRulesForType)(Q,X[0]));if(B){let G=UX(X,J,W.strictNumbers,W9.Wrong);Y.if(G,()=>{if($.length)ZA(Q,X,$);else MX(Q)})}return B}QB.coerceAndCheckDataType=HA;var e3=new Set(["string","number","integer","boolean","null"]);function KA(Q,X){return X?Q.filter((Y)=>e3.has(Y)||X==="array"&&Y==="array"):[]}function ZA(Q,X,Y){let{gen:J,data:W,opts:$}=Q,B=J.let("dataType",_._`typeof ${W}`),G=J.let("coerced",_._`undefined`);if($.coerceTypes==="array")J.if(_._`${B} == 'object' && Array.isArray(${W}) && ${W}.length == 1`,()=>J.assign(W,_._`${W}[0]`).assign(B,_._`typeof ${W}`).if(UX(X,W,$.strictNumbers),()=>J.assign(G,W)));J.if(_._`${G} !== undefined`);for(let H of Y)if(e3.has(H)||H==="array"&&$.coerceTypes==="array")K(H);J.else(),MX(Q),J.endIf(),J.if(_._`${G} !== undefined`,()=>{J.assign(W,G),LA(Q,G)});function K(H){switch(H){case"string":J.elseIf(_._`${B} == "number" || ${B} == "boolean"`).assign(G,_._`"" + ${W}`).elseIf(_._`${W} === null`).assign(G,_._`""`);return;case"number":J.elseIf(_._`${B} == "boolean" || ${W} === null
|
|
3
|
+
|| (${B} == "string" && ${W} && ${W} == +${W})`).assign(G,_._`+${W}`);return;case"integer":J.elseIf(_._`${B} === "boolean" || ${W} === null
|
|
4
|
+
|| (${B} === "string" && ${W} && ${W} == +${W} && !(${W} % 1))`).assign(G,_._`+${W}`);return;case"boolean":J.elseIf(_._`${W} === "false" || ${W} === 0 || ${W} === null`).assign(G,!1).elseIf(_._`${W} === "true" || ${W} === 1`).assign(G,!0);return;case"null":J.elseIf(_._`${W} === "" || ${W} === 0 || ${W} === false`),J.assign(G,null);return;case"array":J.elseIf(_._`${B} === "string" || ${B} === "number"
|
|
5
|
+
|| ${B} === "boolean" || ${W} === null`).assign(G,_._`[${W}]`)}}}function LA({gen:Q,parentData:X,parentDataProperty:Y},J){Q.if(_._`${X} !== undefined`,()=>Q.assign(_._`${X}[${Y}]`,J))}function NX(Q,X,Y,J=W9.Correct){let W=J===W9.Correct?_.operators.EQ:_.operators.NEQ,$;switch(Q){case"null":return _._`${X} ${W} null`;case"array":$=_._`Array.isArray(${X})`;break;case"object":$=_._`${X} && typeof ${X} == "object" && !Array.isArray(${X})`;break;case"integer":$=B(_._`!(${X} % 1) && !isNaN(${X})`);break;case"number":$=B();break;default:return _._`typeof ${X} ${W} ${Q}`}return J===W9.Correct?$:(0,_.not)($);function B(G=_.nil){return(0,_.and)(_._`typeof ${X} == "number"`,G,Y?_._`isFinite(${X})`:_.nil)}}QB.checkDataType=NX;function UX(Q,X,Y,J){if(Q.length===1)return NX(Q[0],X,Y,J);let W,$=(0,a3.toHash)(Q);if($.array&&$.object){let B=_._`typeof ${X} != "object"`;W=$.null?B:_._`!${X} || ${B}`,delete $.null,delete $.array,delete $.object}else W=_.nil;if($.number)delete $.integer;for(let B in $)W=(0,_.and)(W,NX(B,X,Y,J));return W}QB.checkDataTypes=UX;var VA={message:({schema:Q})=>`must be ${Q}`,params:({schema:Q,schemaValue:X})=>typeof Q=="string"?_._`{type: ${Q}}`:_._`{type: ${X}}`};function MX(Q){let X=DA(Q);(0,BA.reportError)(X,VA)}QB.reportTypeError=MX;function DA(Q){let{gen:X,data:Y,schema:J}=Q,W=(0,a3.schemaRefOrVal)(Q,J,"type");return{gen:X,keyword:"type",data:Y,schema:J.type,schemaCode:W,schemaValue:W,parentSchema:J,params:{},it:Q}}});var $B=w((JB)=>{Object.defineProperty(JB,"__esModule",{value:!0});JB.assignDefaults=void 0;var $9=x(),UA=f();function MA(Q,X){let{properties:Y,items:J}=Q.schema;if(X==="object"&&Y)for(let W in Y)YB(Q,W,Y[W].default);else if(X==="array"&&Array.isArray(J))J.forEach((W,$)=>YB(Q,$,W.default))}JB.assignDefaults=MA;function YB(Q,X,Y){let{gen:J,compositeRule:W,data:$,opts:B}=Q;if(Y===void 0)return;let G=$9._`${$}${(0,$9.getProperty)(X)}`;if(W){(0,UA.checkStrictMode)(Q,`default is ignored for: ${G}`);return}let K=$9._`${G} === undefined`;if(B.useDefaults==="empty")K=$9._`${K} || ${G} === null || ${G} === ""`;J.if(K,$9._`${G} = ${(0,$9.stringify)(Y)}`)}});var x0=w((HB)=>{Object.defineProperty(HB,"__esModule",{value:!0});HB.validateUnion=HB.validateArray=HB.usePattern=HB.callValidateCode=HB.schemaProperties=HB.allSchemaProperties=HB.noPropertyInData=HB.propertyInData=HB.isOwnProperty=HB.hasPropFunc=HB.reportMissingProp=HB.checkMissingProp=HB.checkReportMissingProp=void 0;var t=x(),wX=f(),M1=J1(),wA=f();function PA(Q,X){let{gen:Y,data:J,it:W}=Q;Y.if(jX(Y,J,X,W.opts.ownProperties),()=>{Q.setParams({missingProperty:t._`${X}`},!0),Q.error()})}HB.checkReportMissingProp=PA;function jA({gen:Q,data:X,it:{opts:Y}},J,W){return(0,t.or)(...J.map(($)=>(0,t.and)(jX(Q,X,$,Y.ownProperties),t._`${W} = ${$}`)))}HB.checkMissingProp=jA;function IA(Q,X){Q.setParams({missingProperty:X},!0),Q.error()}HB.reportMissingProp=IA;function BB(Q){return Q.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:t._`Object.prototype.hasOwnProperty`})}HB.hasPropFunc=BB;function PX(Q,X,Y){return t._`${BB(Q)}.call(${X}, ${Y})`}HB.isOwnProperty=PX;function bA(Q,X,Y,J){let W=t._`${X}${(0,t.getProperty)(Y)} !== undefined`;return J?t._`${W} && ${PX(Q,X,Y)}`:W}HB.propertyInData=bA;function jX(Q,X,Y,J){let W=t._`${X}${(0,t.getProperty)(Y)} === undefined`;return J?(0,t.or)(W,(0,t.not)(PX(Q,X,Y))):W}HB.noPropertyInData=jX;function GB(Q){return Q?Object.keys(Q).filter((X)=>X!=="__proto__"):[]}HB.allSchemaProperties=GB;function TA(Q,X){return GB(X).filter((Y)=>!(0,wX.alwaysValidSchema)(Q,X[Y]))}HB.schemaProperties=TA;function RA({schemaCode:Q,data:X,it:{gen:Y,topSchemaRef:J,schemaPath:W,errorPath:$},it:B},G,K,H){let Z=H?t._`${Q}, ${X}, ${J}${W}`:X,L=[[M1.default.instancePath,(0,t.strConcat)(M1.default.instancePath,$)],[M1.default.parentData,B.parentData],[M1.default.parentDataProperty,B.parentDataProperty],[M1.default.rootData,M1.default.rootData]];if(B.opts.dynamicRef)L.push([M1.default.dynamicAnchors,M1.default.dynamicAnchors]);let V=t._`${Z}, ${Y.object(...L)}`;return K!==t.nil?t._`${G}.call(${K}, ${V})`:t._`${G}(${V})`}HB.callValidateCode=RA;var EA=t._`new RegExp`;function SA({gen:Q,it:{opts:X}},Y){let J=X.unicodeRegExp?"u":"",{regExp:W}=X.code,$=W(Y,J);return Q.scopeValue("pattern",{key:$.toString(),ref:$,code:t._`${W.code==="new RegExp"?EA:(0,wA.useFunc)(Q,W)}(${Y}, ${J})`})}HB.usePattern=SA;function CA(Q){let{gen:X,data:Y,keyword:J,it:W}=Q,$=X.name("valid");if(W.allErrors){let G=X.let("valid",!0);return B(()=>X.assign(G,!1)),G}return X.var($,!0),B(()=>X.break()),$;function B(G){let K=X.const("len",t._`${Y}.length`);X.forRange("i",0,K,(H)=>{Q.subschema({keyword:J,dataProp:H,dataPropType:wX.Type.Num},$),X.if((0,t.not)($),G)})}}HB.validateArray=CA;function kA(Q){let{gen:X,schema:Y,keyword:J,it:W}=Q;if(!Array.isArray(Y))throw Error("ajv implementation error");if(Y.some((K)=>(0,wX.alwaysValidSchema)(W,K))&&!W.opts.unevaluated)return;let B=X.let("valid",!1),G=X.name("_valid");X.block(()=>Y.forEach((K,H)=>{let Z=Q.subschema({keyword:J,schemaProp:H,compositeRule:!0},G);if(X.assign(B,t._`${B} || ${G}`),!Q.mergeValidEvaluated(Z,G))X.if((0,t.not)(B))})),Q.result(B,()=>Q.reset(),()=>Q.error(!0))}HB.validateUnion=kA});var qB=w((VB)=>{Object.defineProperty(VB,"__esModule",{value:!0});VB.validateKeywordUsage=VB.validSchemaType=VB.funcKeywordCode=VB.macroKeywordCode=void 0;var A0=x(),x1=J1(),dA=x0(),iA=J8();function nA(Q,X){let{gen:Y,keyword:J,schema:W,parentSchema:$,it:B}=Q,G=X.macro.call(B.self,W,$,B),K=LB(Y,J,G);if(B.opts.validateSchema!==!1)B.self.validateSchema(G,!0);let H=Y.name("valid");Q.subschema({schema:G,schemaPath:A0.nil,errSchemaPath:`${B.errSchemaPath}/${J}`,topSchemaRef:K,compositeRule:!0},H),Q.pass(H,()=>Q.error(!0))}VB.macroKeywordCode=nA;function oA(Q,X){var Y;let{gen:J,keyword:W,schema:$,parentSchema:B,$data:G,it:K}=Q;tA(K,X);let H=!G&&X.compile?X.compile.call(K.self,$,B,K):X.validate,Z=LB(J,W,H),L=J.let("valid");Q.block$data(L,V),Q.ok((Y=X.valid)!==null&&Y!==void 0?Y:L);function V(){if(X.errors===!1){if(A(),X.modifying)ZB(Q);N(()=>Q.error())}else{let F=X.async?D():z();if(X.modifying)ZB(Q);N(()=>rA(Q,F))}}function D(){let F=J.let("ruleErrs",null);return J.try(()=>A(A0._`await `),(U)=>J.assign(L,!1).if(A0._`${U} instanceof ${K.ValidationError}`,()=>J.assign(F,A0._`${U}.errors`),()=>J.throw(U))),F}function z(){let F=A0._`${Z}.errors`;return J.assign(F,null),A(A0.nil),F}function A(F=X.async?A0._`await `:A0.nil){let U=K.opts.passContext?x1.default.this:x1.default.self,M=!(("compile"in X)&&!G||X.schema===!1);J.assign(L,A0._`${F}${(0,dA.callValidateCode)(Q,Z,U,M)}`,X.modifying)}function N(F){var U;J.if((0,A0.not)((U=X.valid)!==null&&U!==void 0?U:L),F)}}VB.funcKeywordCode=oA;function ZB(Q){let{gen:X,data:Y,it:J}=Q;X.if(J.parentData,()=>X.assign(Y,A0._`${J.parentData}[${J.parentDataProperty}]`))}function rA(Q,X){let{gen:Y}=Q;Y.if(A0._`Array.isArray(${X})`,()=>{Y.assign(x1.default.vErrors,A0._`${x1.default.vErrors} === null ? ${X} : ${x1.default.vErrors}.concat(${X})`).assign(x1.default.errors,A0._`${x1.default.vErrors}.length`),(0,iA.extendErrors)(Q)},()=>Q.error())}function tA({schemaEnv:Q},X){if(X.async&&!Q.$async)throw Error("async keyword in sync schema")}function LB(Q,X,Y){if(Y===void 0)throw Error(`keyword "${X}" failed to compile`);return Q.scopeValue("keyword",typeof Y=="function"?{ref:Y}:{ref:Y,code:(0,A0.stringify)(Y)})}function aA(Q,X,Y=!1){return!X.length||X.some((J)=>J==="array"?Array.isArray(Q):J==="object"?Q&&typeof Q=="object"&&!Array.isArray(Q):typeof Q==J||Y&&typeof Q>"u")}VB.validSchemaType=aA;function sA({schema:Q,opts:X,self:Y,errSchemaPath:J},W,$){if(Array.isArray(W.keyword)?!W.keyword.includes($):W.keyword!==$)throw Error("ajv implementation error");let B=W.dependencies;if(B===null||B===void 0?void 0:B.some((G)=>!Object.prototype.hasOwnProperty.call(Q,G)))throw Error(`parent schema must have dependencies of ${$}: ${B.join(",")}`);if(W.validateSchema){if(!W.validateSchema(Q[$])){let K=`keyword "${$}" value is invalid at path "${J}": `+Y.errorsText(W.validateSchema.errors);if(X.validateSchema==="log")Y.logger.error(K);else throw Error(K)}}}VB.validateKeywordUsage=sA});var OB=w((FB)=>{Object.defineProperty(FB,"__esModule",{value:!0});FB.extendSubschemaMode=FB.extendSubschemaData=FB.getSubschema=void 0;var i0=x(),zB=f();function YO(Q,{keyword:X,schemaProp:Y,schema:J,schemaPath:W,errSchemaPath:$,topSchemaRef:B}){if(X!==void 0&&J!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(X!==void 0){let G=Q.schema[X];return Y===void 0?{schema:G,schemaPath:i0._`${Q.schemaPath}${(0,i0.getProperty)(X)}`,errSchemaPath:`${Q.errSchemaPath}/${X}`}:{schema:G[Y],schemaPath:i0._`${Q.schemaPath}${(0,i0.getProperty)(X)}${(0,i0.getProperty)(Y)}`,errSchemaPath:`${Q.errSchemaPath}/${X}/${(0,zB.escapeFragment)(Y)}`}}if(J!==void 0){if(W===void 0||$===void 0||B===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:J,schemaPath:W,topSchemaRef:B,errSchemaPath:$}}throw Error('either "keyword" or "schema" must be passed')}FB.getSubschema=YO;function JO(Q,X,{dataProp:Y,dataPropType:J,data:W,dataTypes:$,propertyName:B}){if(W!==void 0&&Y!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:G}=X;if(Y!==void 0){let{errorPath:H,dataPathArr:Z,opts:L}=X,V=G.let("data",i0._`${X.data}${(0,i0.getProperty)(Y)}`,!0);K(V),Q.errorPath=i0.str`${H}${(0,zB.getErrorPath)(Y,J,L.jsPropertySyntax)}`,Q.parentDataProperty=i0._`${Y}`,Q.dataPathArr=[...Z,Q.parentDataProperty]}if(W!==void 0){let H=W instanceof i0.Name?W:G.let("data",W,!0);if(K(H),B!==void 0)Q.propertyName=B}if($)Q.dataTypes=$;function K(H){Q.data=H,Q.dataLevel=X.dataLevel+1,Q.dataTypes=[],X.definedProperties=new Set,Q.parentData=X.data,Q.dataNames=[...X.dataNames,H]}}FB.extendSubschemaData=JO;function WO(Q,{jtdDiscriminator:X,jtdMetadata:Y,compositeRule:J,createErrors:W,allErrors:$}){if(J!==void 0)Q.compositeRule=J;if(W!==void 0)Q.createErrors=W;if($!==void 0)Q.allErrors=$;Q.jtdDiscriminator=X,Q.jtdMetadata=Y}FB.extendSubschemaMode=WO});var IX=w((_C,NB)=>{NB.exports=function Q(X,Y){if(X===Y)return!0;if(X&&Y&&typeof X=="object"&&typeof Y=="object"){if(X.constructor!==Y.constructor)return!1;var J,W,$;if(Array.isArray(X)){if(J=X.length,J!=Y.length)return!1;for(W=J;W--!==0;)if(!Q(X[W],Y[W]))return!1;return!0}if(X.constructor===RegExp)return X.source===Y.source&&X.flags===Y.flags;if(X.valueOf!==Object.prototype.valueOf)return X.valueOf()===Y.valueOf();if(X.toString!==Object.prototype.toString)return X.toString()===Y.toString();if($=Object.keys(X),J=$.length,J!==Object.keys(Y).length)return!1;for(W=J;W--!==0;)if(!Object.prototype.hasOwnProperty.call(Y,$[W]))return!1;for(W=J;W--!==0;){var B=$[W];if(!Q(X[B],Y[B]))return!1}return!0}return X!==X&&Y!==Y}});var MB=w((xC,UB)=>{var w1=UB.exports=function(Q,X,Y){if(typeof X=="function")Y=X,X={};Y=X.cb||Y;var J=typeof Y=="function"?Y:Y.pre||function(){},W=Y.post||function(){};TQ(X,J,W,Q,"",Q)};w1.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};w1.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};w1.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};w1.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 TQ(Q,X,Y,J,W,$,B,G,K,H){if(J&&typeof J=="object"&&!Array.isArray(J)){X(J,W,$,B,G,K,H);for(var Z in J){var L=J[Z];if(Array.isArray(L)){if(Z in w1.arrayKeywords)for(var V=0;V<L.length;V++)TQ(Q,X,Y,L[V],W+"/"+Z+"/"+V,$,W,Z,J,V)}else if(Z in w1.propsKeywords){if(L&&typeof L=="object")for(var D in L)TQ(Q,X,Y,L[D],W+"/"+Z+"/"+GO(D),$,W,Z,J,D)}else if(Z in w1.keywords||Q.allKeys&&!(Z in w1.skipKeywords))TQ(Q,X,Y,L,W+"/"+Z,$,W,Z,J)}Y(J,W,$,B,G,K,H)}}function GO(Q){return Q.replace(/~/g,"~0").replace(/\//g,"~1")}});var $8=w((IB)=>{Object.defineProperty(IB,"__esModule",{value:!0});IB.getSchemaRefs=IB.resolveUrl=IB.normalizeId=IB._getFullPath=IB.getFullPath=IB.inlineRef=void 0;var HO=f(),KO=IX(),ZO=MB(),LO=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function VO(Q,X=!0){if(typeof Q=="boolean")return!0;if(X===!0)return!bX(Q);if(!X)return!1;return wB(Q)<=X}IB.inlineRef=VO;var DO=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function bX(Q){for(let X in Q){if(DO.has(X))return!0;let Y=Q[X];if(Array.isArray(Y)&&Y.some(bX))return!0;if(typeof Y=="object"&&bX(Y))return!0}return!1}function wB(Q){let X=0;for(let Y in Q){if(Y==="$ref")return 1/0;if(X++,LO.has(Y))continue;if(typeof Q[Y]=="object")(0,HO.eachItem)(Q[Y],(J)=>X+=wB(J));if(X===1/0)return 1/0}return X}function PB(Q,X="",Y){if(Y!==!1)X=B9(X);let J=Q.parse(X);return jB(Q,J)}IB.getFullPath=PB;function jB(Q,X){return Q.serialize(X).split("#")[0]+"#"}IB._getFullPath=jB;var qO=/#\/?$/;function B9(Q){return Q?Q.replace(qO,""):""}IB.normalizeId=B9;function zO(Q,X,Y){return Y=B9(Y),Q.resolve(X,Y)}IB.resolveUrl=zO;var FO=/^[a-z_][-a-z0-9._]*$/i;function AO(Q,X){if(typeof Q=="boolean")return{};let{schemaId:Y,uriResolver:J}=this.opts,W=B9(Q[Y]||X),$={"":W},B=PB(J,W,!1),G={},K=new Set;return ZO(Q,{allKeys:!0},(L,V,D,z)=>{if(z===void 0)return;let A=B+V,N=$[z];if(typeof L[Y]=="string")N=F.call(this,L[Y]);U.call(this,L.$anchor),U.call(this,L.$dynamicAnchor),$[V]=N;function F(M){let b=this.opts.uriResolver.resolve;if(M=B9(N?b(N,M):M),K.has(M))throw Z(M);K.add(M);let P=this.refs[M];if(typeof P=="string")P=this.refs[P];if(typeof P=="object")H(L,P.schema,M);else if(M!==B9(A))if(M[0]==="#")H(L,G[M],M),G[M]=L;else this.refs[M]=A;return M}function U(M){if(typeof M=="string"){if(!FO.test(M))throw Error(`invalid anchor "${M}"`);F.call(this,`#${M}`)}}}),G;function H(L,V,D){if(V!==void 0&&!KO(L,V))throw Z(D)}function Z(L){return Error(`reference "${L}" resolves to more than one schema`)}}IB.getSchemaRefs=AO});var H8=w((mB)=>{Object.defineProperty(mB,"__esModule",{value:!0});mB.getData=mB.KeywordCxt=mB.validateFunctionCode=void 0;var CB=p3(),TB=W8(),RX=OX(),RQ=W8(),PO=$B(),G8=qB(),TX=OB(),R=x(),k=J1(),jO=$8(),W1=f(),B8=J8();function IO(Q){if(xB(Q)){if(vB(Q),_B(Q)){RO(Q);return}}kB(Q,()=>(0,CB.topBoolOrEmptySchema)(Q))}mB.validateFunctionCode=IO;function kB({gen:Q,validateName:X,schema:Y,schemaEnv:J,opts:W},$){if(W.code.es5)Q.func(X,R._`${k.default.data}, ${k.default.valCxt}`,J.$async,()=>{Q.code(R._`"use strict"; ${RB(Y,W)}`),TO(Q,W),Q.code($)});else Q.func(X,R._`${k.default.data}, ${bO(W)}`,J.$async,()=>Q.code(RB(Y,W)).code($))}function bO(Q){return R._`{${k.default.instancePath}="", ${k.default.parentData}, ${k.default.parentDataProperty}, ${k.default.rootData}=${k.default.data}${Q.dynamicRef?R._`, ${k.default.dynamicAnchors}={}`:R.nil}}={}`}function TO(Q,X){Q.if(k.default.valCxt,()=>{if(Q.var(k.default.instancePath,R._`${k.default.valCxt}.${k.default.instancePath}`),Q.var(k.default.parentData,R._`${k.default.valCxt}.${k.default.parentData}`),Q.var(k.default.parentDataProperty,R._`${k.default.valCxt}.${k.default.parentDataProperty}`),Q.var(k.default.rootData,R._`${k.default.valCxt}.${k.default.rootData}`),X.dynamicRef)Q.var(k.default.dynamicAnchors,R._`${k.default.valCxt}.${k.default.dynamicAnchors}`)},()=>{if(Q.var(k.default.instancePath,R._`""`),Q.var(k.default.parentData,R._`undefined`),Q.var(k.default.parentDataProperty,R._`undefined`),Q.var(k.default.rootData,k.default.data),X.dynamicRef)Q.var(k.default.dynamicAnchors,R._`{}`)})}function RO(Q){let{schema:X,opts:Y,gen:J}=Q;kB(Q,()=>{if(Y.$comment&&X.$comment)gB(Q);if(_O(Q),J.let(k.default.vErrors,null),J.let(k.default.errors,0),Y.unevaluated)EO(Q);yB(Q),yO(Q)});return}function EO(Q){let{gen:X,validateName:Y}=Q;Q.evaluated=X.const("evaluated",R._`${Y}.evaluated`),X.if(R._`${Q.evaluated}.dynamicProps`,()=>X.assign(R._`${Q.evaluated}.props`,R._`undefined`)),X.if(R._`${Q.evaluated}.dynamicItems`,()=>X.assign(R._`${Q.evaluated}.items`,R._`undefined`))}function RB(Q,X){let Y=typeof Q=="object"&&Q[X.schemaId];return Y&&(X.code.source||X.code.process)?R._`/*# sourceURL=${Y} */`:R.nil}function SO(Q,X){if(xB(Q)){if(vB(Q),_B(Q)){CO(Q,X);return}}(0,CB.boolOrEmptySchema)(Q,X)}function _B({schema:Q,self:X}){if(typeof Q=="boolean")return!Q;for(let Y in Q)if(X.RULES.all[Y])return!0;return!1}function xB(Q){return typeof Q.schema!="boolean"}function CO(Q,X){let{schema:Y,gen:J,opts:W}=Q;if(W.$comment&&Y.$comment)gB(Q);xO(Q),vO(Q);let $=J.const("_errs",k.default.errors);yB(Q,$),J.var(X,R._`${$} === ${k.default.errors}`)}function vB(Q){(0,W1.checkUnknownRules)(Q),kO(Q)}function yB(Q,X){if(Q.opts.jtd)return EB(Q,[],!1,X);let Y=(0,TB.getSchemaTypes)(Q.schema),J=(0,TB.coerceAndCheckDataType)(Q,Y);EB(Q,Y,!J,X)}function kO(Q){let{schema:X,errSchemaPath:Y,opts:J,self:W}=Q;if(X.$ref&&J.ignoreKeywordsWithRef&&(0,W1.schemaHasRulesButRef)(X,W.RULES))W.logger.warn(`$ref: keywords ignored in schema at path "${Y}"`)}function _O(Q){let{schema:X,opts:Y}=Q;if(X.default!==void 0&&Y.useDefaults&&Y.strictSchema)(0,W1.checkStrictMode)(Q,"default is ignored in the schema root")}function xO(Q){let X=Q.schema[Q.opts.schemaId];if(X)Q.baseId=(0,jO.resolveUrl)(Q.opts.uriResolver,Q.baseId,X)}function vO(Q){if(Q.schema.$async&&!Q.schemaEnv.$async)throw Error("async schema in sync schema")}function gB({gen:Q,schemaEnv:X,schema:Y,errSchemaPath:J,opts:W}){let $=Y.$comment;if(W.$comment===!0)Q.code(R._`${k.default.self}.logger.log(${$})`);else if(typeof W.$comment=="function"){let B=R.str`${J}/$comment`,G=Q.scopeValue("root",{ref:X.root});Q.code(R._`${k.default.self}.opts.$comment(${$}, ${B}, ${G}.schema)`)}}function yO(Q){let{gen:X,schemaEnv:Y,validateName:J,ValidationError:W,opts:$}=Q;if(Y.$async)X.if(R._`${k.default.errors} === 0`,()=>X.return(k.default.data),()=>X.throw(R._`new ${W}(${k.default.vErrors})`));else{if(X.assign(R._`${J}.errors`,k.default.vErrors),$.unevaluated)gO(Q);X.return(R._`${k.default.errors} === 0`)}}function gO({gen:Q,evaluated:X,props:Y,items:J}){if(Y instanceof R.Name)Q.assign(R._`${X}.props`,Y);if(J instanceof R.Name)Q.assign(R._`${X}.items`,J)}function EB(Q,X,Y,J){let{gen:W,schema:$,data:B,allErrors:G,opts:K,self:H}=Q,{RULES:Z}=H;if($.$ref&&(K.ignoreKeywordsWithRef||!(0,W1.schemaHasRulesButRef)($,Z))){W.block(()=>hB(Q,"$ref",Z.all.$ref.definition));return}if(!K.jtd)fO(Q,X);W.block(()=>{for(let V of Z.rules)L(V);L(Z.post)});function L(V){if(!(0,RX.shouldUseGroup)($,V))return;if(V.type){if(W.if((0,RQ.checkDataType)(V.type,B,K.strictNumbers)),SB(Q,V),X.length===1&&X[0]===V.type&&Y)W.else(),(0,RQ.reportTypeError)(Q);W.endIf()}else SB(Q,V);if(!G)W.if(R._`${k.default.errors} === ${J||0}`)}}function SB(Q,X){let{gen:Y,schema:J,opts:{useDefaults:W}}=Q;if(W)(0,PO.assignDefaults)(Q,X.type);Y.block(()=>{for(let $ of X.rules)if((0,RX.shouldUseRule)(J,$))hB(Q,$.keyword,$.definition,X.type)})}function fO(Q,X){if(Q.schemaEnv.meta||!Q.opts.strictTypes)return;if(hO(Q,X),!Q.opts.allowUnionTypes)uO(Q,X);mO(Q,Q.dataTypes)}function hO(Q,X){if(!X.length)return;if(!Q.dataTypes.length){Q.dataTypes=X;return}X.forEach((Y)=>{if(!fB(Q.dataTypes,Y))EX(Q,`type "${Y}" not allowed by context "${Q.dataTypes.join(",")}"`)}),cO(Q,X)}function uO(Q,X){if(X.length>1&&!(X.length===2&&X.includes("null")))EX(Q,"use allowUnionTypes to allow union type keyword")}function mO(Q,X){let Y=Q.self.RULES.all;for(let J in Y){let W=Y[J];if(typeof W=="object"&&(0,RX.shouldUseRule)(Q.schema,W)){let{type:$}=W.definition;if($.length&&!$.some((B)=>lO(X,B)))EX(Q,`missing type "${$.join(",")}" for keyword "${J}"`)}}}function lO(Q,X){return Q.includes(X)||X==="number"&&Q.includes("integer")}function fB(Q,X){return Q.includes(X)||X==="integer"&&Q.includes("number")}function cO(Q,X){let Y=[];for(let J of Q.dataTypes)if(fB(X,J))Y.push(J);else if(X.includes("integer")&&J==="number")Y.push("integer");Q.dataTypes=Y}function EX(Q,X){let Y=Q.schemaEnv.baseId+Q.errSchemaPath;X+=` at "${Y}" (strictTypes)`,(0,W1.checkStrictMode)(Q,X,Q.opts.strictTypes)}class SX{constructor(Q,X,Y){if((0,G8.validateKeywordUsage)(Q,X,Y),this.gen=Q.gen,this.allErrors=Q.allErrors,this.keyword=Y,this.data=Q.data,this.schema=Q.schema[Y],this.$data=X.$data&&Q.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,W1.schemaRefOrVal)(Q,this.schema,Y,this.$data),this.schemaType=X.schemaType,this.parentSchema=Q.schema,this.params={},this.it=Q,this.def=X,this.$data)this.schemaCode=Q.gen.const("vSchema",uB(this.$data,Q));else if(this.schemaCode=this.schemaValue,!(0,G8.validSchemaType)(this.schema,X.schemaType,X.allowUndefined))throw Error(`${Y} value must be ${JSON.stringify(X.schemaType)}`);if("code"in X?X.trackErrors:X.errors!==!1)this.errsCount=Q.gen.const("_errs",k.default.errors)}result(Q,X,Y){this.failResult((0,R.not)(Q),X,Y)}failResult(Q,X,Y){if(this.gen.if(Q),Y)Y();else this.error();if(X){if(this.gen.else(),X(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(Q,X){this.failResult((0,R.not)(Q),void 0,X)}fail(Q){if(Q===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(Q),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(Q){if(!this.$data)return this.fail(Q);let{schemaCode:X}=this;this.fail(R._`${X} !== undefined && (${(0,R.or)(this.invalid$data(),Q)})`)}error(Q,X,Y){if(X){this.setParams(X),this._error(Q,Y),this.setParams({});return}this._error(Q,Y)}_error(Q,X){(Q?B8.reportExtraError:B8.reportError)(this,this.def.error,X)}$dataError(){(0,B8.reportError)(this,this.def.$dataError||B8.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,B8.resetErrorsCount)(this.gen,this.errsCount)}ok(Q){if(!this.allErrors)this.gen.if(Q)}setParams(Q,X){if(X)Object.assign(this.params,Q);else this.params=Q}block$data(Q,X,Y=R.nil){this.gen.block(()=>{this.check$data(Q,Y),X()})}check$data(Q=R.nil,X=R.nil){if(!this.$data)return;let{gen:Y,schemaCode:J,schemaType:W,def:$}=this;if(Y.if((0,R.or)(R._`${J} === undefined`,X)),Q!==R.nil)Y.assign(Q,!0);if(W.length||$.validateSchema){if(Y.elseIf(this.invalid$data()),this.$dataError(),Q!==R.nil)Y.assign(Q,!1)}Y.else()}invalid$data(){let{gen:Q,schemaCode:X,schemaType:Y,def:J,it:W}=this;return(0,R.or)($(),B());function $(){if(Y.length){if(!(X instanceof R.Name))throw Error("ajv implementation error");let G=Array.isArray(Y)?Y:[Y];return R._`${(0,RQ.checkDataTypes)(G,X,W.opts.strictNumbers,RQ.DataType.Wrong)}`}return R.nil}function B(){if(J.validateSchema){let G=Q.scopeValue("validate$data",{ref:J.validateSchema});return R._`!${G}(${X})`}return R.nil}}subschema(Q,X){let Y=(0,TX.getSubschema)(this.it,Q);(0,TX.extendSubschemaData)(Y,this.it,Q),(0,TX.extendSubschemaMode)(Y,Q);let J={...this.it,...Y,items:void 0,props:void 0};return SO(J,X),J}mergeEvaluated(Q,X){let{it:Y,gen:J}=this;if(!Y.opts.unevaluated)return;if(Y.props!==!0&&Q.props!==void 0)Y.props=W1.mergeEvaluated.props(J,Q.props,Y.props,X);if(Y.items!==!0&&Q.items!==void 0)Y.items=W1.mergeEvaluated.items(J,Q.items,Y.items,X)}mergeValidEvaluated(Q,X){let{it:Y,gen:J}=this;if(Y.opts.unevaluated&&(Y.props!==!0||Y.items!==!0))return J.if(X,()=>this.mergeEvaluated(Q,R.Name)),!0}}mB.KeywordCxt=SX;function hB(Q,X,Y,J){let W=new SX(Q,Y,X);if("code"in Y)Y.code(W,J);else if(W.$data&&Y.validate)(0,G8.funcKeywordCode)(W,Y);else if("macro"in Y)(0,G8.macroKeywordCode)(W,Y);else if(Y.compile||Y.validate)(0,G8.funcKeywordCode)(W,Y)}var pO=/^\/(?:[^~]|~0|~1)*$/,dO=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function uB(Q,{dataLevel:X,dataNames:Y,dataPathArr:J}){let W,$;if(Q==="")return k.default.rootData;if(Q[0]==="/"){if(!pO.test(Q))throw Error(`Invalid JSON-pointer: ${Q}`);W=Q,$=k.default.rootData}else{let H=dO.exec(Q);if(!H)throw Error(`Invalid JSON-pointer: ${Q}`);let Z=+H[1];if(W=H[2],W==="#"){if(Z>=X)throw Error(K("property/index",Z));return J[X-Z]}if(Z>X)throw Error(K("data",Z));if($=Y[X-Z],!W)return $}let B=$,G=W.split("/");for(let H of G)if(H)$=R._`${$}${(0,R.getProperty)((0,W1.unescapeJsonPointer)(H))}`,B=R._`${B} && ${$}`;return B;function K(H,Z){return`Cannot access ${H} ${Z} levels up, current level is ${X}`}}mB.getData=uB});var EQ=w((pB)=>{Object.defineProperty(pB,"__esModule",{value:!0});class cB extends Error{constructor(Q){super("validation failed");this.errors=Q,this.ajv=this.validation=!0}}pB.default=cB});var K8=w((iB)=>{Object.defineProperty(iB,"__esModule",{value:!0});var CX=$8();class dB extends Error{constructor(Q,X,Y,J){super(J||`can't resolve reference ${Y} from id ${X}`);this.missingRef=(0,CX.resolveUrl)(Q,X,Y),this.missingSchema=(0,CX.normalizeId)((0,CX.getFullPath)(Q,this.missingRef))}}iB.default=dB});var CQ=w((rB)=>{Object.defineProperty(rB,"__esModule",{value:!0});rB.resolveSchema=rB.getCompilingSchema=rB.resolveRef=rB.compileSchema=rB.SchemaEnv=void 0;var m0=x(),tO=EQ(),v1=J1(),l0=$8(),nB=f(),aO=H8();class Z8{constructor(Q){var X;this.refs={},this.dynamicAnchors={};let Y;if(typeof Q.schema=="object")Y=Q.schema;this.schema=Q.schema,this.schemaId=Q.schemaId,this.root=Q.root||this,this.baseId=(X=Q.baseId)!==null&&X!==void 0?X:(0,l0.normalizeId)(Y===null||Y===void 0?void 0:Y[Q.schemaId||"$id"]),this.schemaPath=Q.schemaPath,this.localRefs=Q.localRefs,this.meta=Q.meta,this.$async=Y===null||Y===void 0?void 0:Y.$async,this.refs={}}}rB.SchemaEnv=Z8;function _X(Q){let X=oB.call(this,Q);if(X)return X;let Y=(0,l0.getFullPath)(this.opts.uriResolver,Q.root.baseId),{es5:J,lines:W}=this.opts.code,{ownProperties:$}=this.opts,B=new m0.CodeGen(this.scope,{es5:J,lines:W,ownProperties:$}),G;if(Q.$async)G=B.scopeValue("Error",{ref:tO.default,code:m0._`require("ajv/dist/runtime/validation_error").default`});let K=B.scopeName("validate");Q.validateName=K;let H={gen:B,allErrors:this.opts.allErrors,data:v1.default.data,parentData:v1.default.parentData,parentDataProperty:v1.default.parentDataProperty,dataNames:[v1.default.data],dataPathArr:[m0.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:B.scopeValue("schema",this.opts.code.source===!0?{ref:Q.schema,code:(0,m0.stringify)(Q.schema)}:{ref:Q.schema}),validateName:K,ValidationError:G,schema:Q.schema,schemaEnv:Q,rootId:Y,baseId:Q.baseId||Y,schemaPath:m0.nil,errSchemaPath:Q.schemaPath||(this.opts.jtd?"":"#"),errorPath:m0._`""`,opts:this.opts,self:this},Z;try{this._compilations.add(Q),(0,aO.validateFunctionCode)(H),B.optimize(this.opts.code.optimize);let L=B.toString();if(Z=`${B.scopeRefs(v1.default.scope)}return ${L}`,this.opts.code.process)Z=this.opts.code.process(Z,Q);let D=Function(`${v1.default.self}`,`${v1.default.scope}`,Z)(this,this.scope.get());if(this.scope.value(K,{ref:D}),D.errors=null,D.schema=Q.schema,D.schemaEnv=Q,Q.$async)D.$async=!0;if(this.opts.code.source===!0)D.source={validateName:K,validateCode:L,scopeValues:B._values};if(this.opts.unevaluated){let{props:z,items:A}=H;if(D.evaluated={props:z instanceof m0.Name?void 0:z,items:A instanceof m0.Name?void 0:A,dynamicProps:z instanceof m0.Name,dynamicItems:A instanceof m0.Name},D.source)D.source.evaluated=(0,m0.stringify)(D.evaluated)}return Q.validate=D,Q}catch(L){if(delete Q.validate,delete Q.validateName,Z)this.logger.error("Error compiling schema, function code:",Z);throw L}finally{this._compilations.delete(Q)}}rB.compileSchema=_X;function sO(Q,X,Y){var J;Y=(0,l0.resolveUrl)(this.opts.uriResolver,X,Y);let W=Q.refs[Y];if(W)return W;let $=XN.call(this,Q,Y);if($===void 0){let B=(J=Q.localRefs)===null||J===void 0?void 0:J[Y],{schemaId:G}=this.opts;if(B)$=new Z8({schema:B,schemaId:G,root:Q,baseId:X})}if($===void 0)return;return Q.refs[Y]=eO.call(this,$)}rB.resolveRef=sO;function eO(Q){if((0,l0.inlineRef)(Q.schema,this.opts.inlineRefs))return Q.schema;return Q.validate?Q:_X.call(this,Q)}function oB(Q){for(let X of this._compilations)if(QN(X,Q))return X}rB.getCompilingSchema=oB;function QN(Q,X){return Q.schema===X.schema&&Q.root===X.root&&Q.baseId===X.baseId}function XN(Q,X){let Y;while(typeof(Y=this.refs[X])=="string")X=Y;return Y||this.schemas[X]||SQ.call(this,Q,X)}function SQ(Q,X){let Y=this.opts.uriResolver.parse(X),J=(0,l0._getFullPath)(this.opts.uriResolver,Y),W=(0,l0.getFullPath)(this.opts.uriResolver,Q.baseId,void 0);if(Object.keys(Q.schema).length>0&&J===W)return kX.call(this,Y,Q);let $=(0,l0.normalizeId)(J),B=this.refs[$]||this.schemas[$];if(typeof B=="string"){let G=SQ.call(this,Q,B);if(typeof(G===null||G===void 0?void 0:G.schema)!=="object")return;return kX.call(this,Y,G)}if(typeof(B===null||B===void 0?void 0:B.schema)!=="object")return;if(!B.validate)_X.call(this,B);if($===(0,l0.normalizeId)(X)){let{schema:G}=B,{schemaId:K}=this.opts,H=G[K];if(H)W=(0,l0.resolveUrl)(this.opts.uriResolver,W,H);return new Z8({schema:G,schemaId:K,root:Q,baseId:W})}return kX.call(this,Y,B)}rB.resolveSchema=SQ;var YN=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function kX(Q,{baseId:X,schema:Y,root:J}){var W;if(((W=Q.fragment)===null||W===void 0?void 0:W[0])!=="/")return;for(let G of Q.fragment.slice(1).split("/")){if(typeof Y==="boolean")return;let K=Y[(0,nB.unescapeFragment)(G)];if(K===void 0)return;Y=K;let H=typeof Y==="object"&&Y[this.opts.schemaId];if(!YN.has(G)&&H)X=(0,l0.resolveUrl)(this.opts.uriResolver,X,H)}let $;if(typeof Y!="boolean"&&Y.$ref&&!(0,nB.schemaHasRulesButRef)(Y,this.RULES)){let G=(0,l0.resolveUrl)(this.opts.uriResolver,X,Y.$ref);$=SQ.call(this,J,G)}let{schemaId:B}=this.opts;if($=$||new Z8({schema:Y,schemaId:B,root:J,baseId:X}),$.schema!==$.root.schema)return $;return}});var aB=w((uC,GN)=>{GN.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 yX=w((mC,JG)=>{var HN=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),eB=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),xX=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),QG=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),KN=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function vX(Q){let X="",Y=0,J=0;for(J=0;J<Q.length;J++){if(Y=Q[J].charCodeAt(0),Y===48)continue;if(!(Y>=48&&Y<=57||Y>=65&&Y<=70||Y>=97&&Y<=102))return"";X+=Q[J];break}for(J+=1;J<Q.length;J++){if(Y=Q[J].charCodeAt(0),!(Y>=48&&Y<=57||Y>=65&&Y<=70||Y>=97&&Y<=102))return"";X+=Q[J]}return X}var ZN=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function sB(Q){return Q.length=0,!0}function LN(Q,X,Y){if(Q.length){let J=vX(Q);if(J!=="")X.push(J);else return Y.error=!0,!1;Q.length=0}return!0}function VN(Q){let X=0,Y={error:!1,address:"",zone:""},J=[],W=[],$=!1,B=!1,G=LN;for(let K=0;K<Q.length;K++){let H=Q[K];if(H==="["||H==="]")continue;if(H===":"){if($===!0)B=!0;if(!G(W,J,Y))break;if(++X>7){Y.error=!0;break}if(K>0&&Q[K-1]===":")$=!0;J.push(":");continue}else if(H==="%"){if(!G(W,J,Y))break;G=sB}else{W.push(H);continue}}if(W.length)if(G===sB)Y.zone=W.join("");else if(B)J.push(W.join(""));else J.push(vX(W));return Y.address=J.join(""),Y}function XG(Q){if(DN(Q,":")<2)return{host:Q,isIPV6:!1};let X=VN(Q);if(!X.error){let{address:Y,address:J}=X;if(X.zone)Y+="%"+X.zone,J+="%25"+X.zone;return{host:Y,isIPV6:!0,escapedHost:J}}else return{host:Q,isIPV6:!1}}function DN(Q,X){let Y=0;for(let J=0;J<Q.length;J++)if(Q[J]===X)Y++;return Y}function qN(Q){let X=Q,Y=[],J=-1,W=0;while(W=X.length){if(W===1)if(X===".")break;else if(X==="/"){Y.push("/");break}else{Y.push(X);break}else if(W===2){if(X[0]==="."){if(X[1]===".")break;else if(X[1]==="/"){X=X.slice(2);continue}}else if(X[0]==="/"){if(X[1]==="."||X[1]==="/"){Y.push("/");break}}}else if(W===3){if(X==="/.."){if(Y.length!==0)Y.pop();Y.push("/");break}}if(X[0]==="."){if(X[1]==="."){if(X[2]==="/"){X=X.slice(3);continue}}else if(X[1]==="/"){X=X.slice(2);continue}}else if(X[0]==="/"){if(X[1]==="."){if(X[2]==="/"){X=X.slice(2);continue}else if(X[2]==="."){if(X[3]==="/"){if(X=X.slice(3),Y.length!==0)Y.pop();continue}}}}if((J=X.indexOf("/",1))===-1){Y.push(X);break}else Y.push(X.slice(0,J)),X=X.slice(J)}return Y.join("")}var zN={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},FN=/[@/?#:]/g,AN=/[@/?#]/g;function YG(Q,X){let Y=X?AN:FN;return Y.lastIndex=0,Q.replace(Y,(J)=>zN[J])}function ON(Q,X=!1){if(Q.indexOf("%")===-1)return Q;let Y="";for(let J=0;J<Q.length;J++){if(Q[J]==="%"&&J+2<Q.length){let W=Q.slice(J+1,J+3);if(xX(W)){let $=W.toUpperCase(),B=String.fromCharCode(parseInt($,16));if(X&&QG(B))Y+=B;else Y+="%"+$;J+=2;continue}}Y+=Q[J]}return Y}function NN(Q){let X="";for(let Y=0;Y<Q.length;Y++){if(Q[Y]==="%"&&Y+2<Q.length){let J=Q.slice(Y+1,Y+3);if(xX(J)){let W=J.toUpperCase(),$=String.fromCharCode(parseInt(W,16));if($!=="."&&QG($))X+=$;else X+="%"+W;Y+=2;continue}}if(KN(Q[Y]))X+=Q[Y];else X+=escape(Q[Y])}return X}function UN(Q){let X="";for(let Y=0;Y<Q.length;Y++){if(Q[Y]==="%"&&Y+2<Q.length){let J=Q.slice(Y+1,Y+3);if(xX(J)){X+="%"+J.toUpperCase(),Y+=2;continue}}X+=escape(Q[Y])}return X}function MN(Q){let X=[];if(Q.userinfo!==void 0)X.push(Q.userinfo),X.push("@");if(Q.host!==void 0){let Y=unescape(Q.host);if(!eB(Y)){let J=XG(Y);if(J.isIPV6===!0)Y=`[${J.escapedHost}]`;else Y=YG(Y,!1)}X.push(Y)}if(typeof Q.port==="number"||typeof Q.port==="string")X.push(":"),X.push(String(Q.port));return X.length?X.join(""):void 0}JG.exports={nonSimpleDomain:ZN,recomposeAuthority:MN,reescapeHostDelimiters:YG,normalizePercentEncoding:ON,normalizePathEncoding:NN,escapePreservingEscapes:UN,removeDotSegments:qN,isIPv4:eB,isUUID:HN,normalizeIPv6:XG,stringArrayToHexStripped:vX}});var HG=w((lC,GG)=>{var{isUUID:wN}=yX(),PN=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,jN=["http","https","ws","wss","urn","urn:uuid"];function IN(Q){return jN.indexOf(Q)!==-1}function gX(Q){if(Q.secure===!0)return!0;else if(Q.secure===!1)return!1;else if(Q.scheme)return Q.scheme.length===3&&(Q.scheme[0]==="w"||Q.scheme[0]==="W")&&(Q.scheme[1]==="s"||Q.scheme[1]==="S")&&(Q.scheme[2]==="s"||Q.scheme[2]==="S");else return!1}function WG(Q){if(!Q.host)Q.error=Q.error||"HTTP URIs must have a host.";return Q}function $G(Q){let X=String(Q.scheme).toLowerCase()==="https";if(Q.port===(X?443:80)||Q.port==="")Q.port=void 0;if(!Q.path)Q.path="/";return Q}function bN(Q){return Q.secure=gX(Q),Q.resourceName=(Q.path||"/")+(Q.query?"?"+Q.query:""),Q.path=void 0,Q.query=void 0,Q}function TN(Q){if(Q.port===(gX(Q)?443:80)||Q.port==="")Q.port=void 0;if(typeof Q.secure==="boolean")Q.scheme=Q.secure?"wss":"ws",Q.secure=void 0;if(Q.resourceName){let[X,Y]=Q.resourceName.split("?");Q.path=X&&X!=="/"?X:void 0,Q.query=Y,Q.resourceName=void 0}return Q.fragment=void 0,Q}function RN(Q,X){if(!Q.path)return Q.error="URN can not be parsed",Q;let Y=Q.path.match(PN);if(Y){let J=X.scheme||Q.scheme||"urn";Q.nid=Y[1].toLowerCase(),Q.nss=Y[2];let W=`${J}:${X.nid||Q.nid}`,$=fX(W);if(Q.path=void 0,$)Q=$.parse(Q,X)}else Q.error=Q.error||"URN can not be parsed.";return Q}function EN(Q,X){if(Q.nid===void 0)throw Error("URN without nid cannot be serialized");let Y=X.scheme||Q.scheme||"urn",J=Q.nid.toLowerCase(),W=`${Y}:${X.nid||J}`,$=fX(W);if($)Q=$.serialize(Q,X);let B=Q,G=Q.nss;return B.path=`${J||X.nid}:${G}`,X.skipEscape=!0,B}function SN(Q,X){let Y=Q;if(Y.uuid=Y.nss,Y.nss=void 0,!X.tolerant&&(!Y.uuid||!wN(Y.uuid)))Y.error=Y.error||"UUID is not valid.";return Y}function CN(Q){let X=Q;return X.nss=(Q.uuid||"").toLowerCase(),X}var BG={scheme:"http",domainHost:!0,parse:WG,serialize:$G},kN={scheme:"https",domainHost:BG.domainHost,parse:WG,serialize:$G},kQ={scheme:"ws",domainHost:!0,parse:bN,serialize:TN},_N={scheme:"wss",domainHost:kQ.domainHost,parse:kQ.parse,serialize:kQ.serialize},xN={scheme:"urn",parse:RN,serialize:EN,skipNormalize:!0},vN={scheme:"urn:uuid",parse:SN,serialize:CN,skipNormalize:!0},_Q={http:BG,https:kN,ws:kQ,wss:_N,urn:xN,"urn:uuid":vN};Object.setPrototypeOf(_Q,null);function fX(Q){return Q&&(_Q[Q]||_Q[Q.toLowerCase()])||void 0}GG.exports={wsIsSecure:gX,SCHEMES:_Q,isValidSchemeName:IN,getSchemeHandler:fX}});var qG=w((cC,xQ)=>{var{normalizeIPv6:yN,removeDotSegments:L8,recomposeAuthority:gN,normalizePercentEncoding:fN,normalizePathEncoding:hN,escapePreservingEscapes:uN,reescapeHostDelimiters:mN,isIPv4:lN,nonSimpleDomain:cN}=yX(),{SCHEMES:pN,getSchemeHandler:ZG}=HG();function dN(Q,X){if(typeof Q==="string")Q=tN(Q,X);else if(typeof Q==="object")Q=G9(y1(Q,X),X);return Q}function iN(Q,X,Y){let J=Y?Object.assign({scheme:"null"},Y):{scheme:"null"},W=LG(G9(Q,J),G9(X,J),J,!0);return J.skipEscape=!0,y1(W,J)}function LG(Q,X,Y,J){let W={};if(!J)Q=G9(y1(Q,Y),Y),X=G9(y1(X,Y),Y);if(Y=Y||{},!Y.tolerant&&X.scheme)W.scheme=X.scheme,W.userinfo=X.userinfo,W.host=X.host,W.port=X.port,W.path=L8(X.path||""),W.query=X.query;else{if(X.userinfo!==void 0||X.host!==void 0||X.port!==void 0)W.userinfo=X.userinfo,W.host=X.host,W.port=X.port,W.path=L8(X.path||""),W.query=X.query;else{if(!X.path)if(W.path=Q.path,X.query!==void 0)W.query=X.query;else W.query=Q.query;else{if(X.path[0]==="/")W.path=L8(X.path);else{if((Q.userinfo!==void 0||Q.host!==void 0||Q.port!==void 0)&&!Q.path)W.path="/"+X.path;else if(!Q.path)W.path=X.path;else W.path=Q.path.slice(0,Q.path.lastIndexOf("/")+1)+X.path;W.path=L8(W.path)}W.query=X.query}W.userinfo=Q.userinfo,W.host=Q.host,W.port=Q.port}W.scheme=Q.scheme}return W.fragment=X.fragment,W}function nN(Q,X,Y){let J=KG(Q,Y),W=KG(X,Y);return J!==void 0&&W!==void 0&&J.toLowerCase()===W.toLowerCase()}function y1(Q,X){let Y={host:Q.host,scheme:Q.scheme,userinfo:Q.userinfo,port:Q.port,path:Q.path,query:Q.query,nid:Q.nid,nss:Q.nss,uuid:Q.uuid,fragment:Q.fragment,reference:Q.reference,resourceName:Q.resourceName,secure:Q.secure,error:""},J=Object.assign({},X),W=[],$=ZG(J.scheme||Y.scheme);if($&&$.serialize)$.serialize(Y,J);if(Y.path!==void 0)if(!J.skipEscape){if(Y.path=uN(Y.path),Y.scheme!==void 0)Y.path=Y.path.split("%3A").join(":")}else Y.path=fN(Y.path);if(J.reference!=="suffix"&&Y.scheme)W.push(Y.scheme,":");let B=gN(Y);if(B!==void 0){if(J.reference!=="suffix")W.push("//");if(W.push(B),Y.path&&Y.path[0]!=="/")W.push("/")}if(Y.path!==void 0){let G=Y.path;if(!J.absolutePath&&(!$||!$.absolutePath))G=L8(G);if(B===void 0&&G[0]==="/"&&G[1]==="/")G="/%2F"+G.slice(2);W.push(G)}if(Y.query!==void 0)W.push("?",Y.query);if(Y.fragment!==void 0)W.push("#",Y.fragment);return W.join("")}var oN=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function rN(Q,X){if(X[2]!==void 0&&Q.path&&Q.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof Q.port==="number"&&(Q.port<0||Q.port>65535))return"URI port is malformed.";return}function VG(Q,X){let Y=Object.assign({},X),J={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},W=!1,$=!1;if(Y.reference==="suffix")if(Y.scheme)Q=Y.scheme+":"+Q;else Q="//"+Q;let B=Q.match(oN);if(B){if(J.scheme=B[1],J.userinfo=B[3],J.host=B[4],J.port=parseInt(B[5],10),J.path=B[6]||"",J.query=B[7],J.fragment=B[8],isNaN(J.port))J.port=B[5];let G=rN(J,B);if(G!==void 0)J.error=J.error||G,W=!0;if(J.host)if(lN(J.host)===!1){let Z=yN(J.host);J.host=Z.host.toLowerCase(),$=Z.isIPV6}else $=!0;if(J.scheme===void 0&&J.userinfo===void 0&&J.host===void 0&&J.port===void 0&&J.query===void 0&&!J.path)J.reference="same-document";else if(J.scheme===void 0)J.reference="relative";else if(J.fragment===void 0)J.reference="absolute";else J.reference="uri";if(Y.reference&&Y.reference!=="suffix"&&Y.reference!==J.reference)J.error=J.error||"URI is not a "+Y.reference+" reference.";let K=ZG(Y.scheme||J.scheme);if(!Y.unicodeSupport&&(!K||!K.unicodeSupport)){if(J.host&&(Y.domainHost||K&&K.domainHost)&&$===!1&&cN(J.host))try{J.host=URL.domainToASCII(J.host.toLowerCase())}catch(H){J.error=J.error||"Host's domain name can not be converted to ASCII: "+H}}if(!K||K&&!K.skipNormalize){if(Q.indexOf("%")!==-1){if(J.scheme!==void 0)J.scheme=unescape(J.scheme);if(J.host!==void 0)J.host=mN(unescape(J.host),$)}if(J.path)J.path=hN(J.path);if(J.fragment)try{J.fragment=encodeURI(decodeURIComponent(J.fragment))}catch{J.error=J.error||"URI malformed"}}if(K&&K.parse)K.parse(J,Y)}else J.error=J.error||"URI can not be parsed.";return{parsed:J,malformedAuthorityOrPort:W}}function G9(Q,X){return VG(Q,X).parsed}function tN(Q,X){return DG(Q,X).normalized}function DG(Q,X){let{parsed:Y,malformedAuthorityOrPort:J}=VG(Q,X);return{normalized:J?Q:y1(Y,X),malformedAuthorityOrPort:J}}function KG(Q,X){if(typeof Q==="string"){let{normalized:Y,malformedAuthorityOrPort:J}=DG(Q,X);return J?void 0:Y}if(typeof Q==="object")return y1(Q,X)}var hX={SCHEMES:pN,normalize:dN,resolve:iN,resolveComponent:LG,equal:nN,serialize:y1,parse:G9};xQ.exports=hX;xQ.exports.default=hX;xQ.exports.fastUri=hX});var AG=w((FG)=>{Object.defineProperty(FG,"__esModule",{value:!0});var zG=qG();zG.code='require("ajv/dist/runtime/uri").default';FG.default=zG});var IG=w(($1)=>{Object.defineProperty($1,"__esModule",{value:!0});$1.CodeGen=$1.Name=$1.nil=$1.stringify=$1.str=$1._=$1.KeywordCxt=void 0;var sN=H8();Object.defineProperty($1,"KeywordCxt",{enumerable:!0,get:function(){return sN.KeywordCxt}});var H9=x();Object.defineProperty($1,"_",{enumerable:!0,get:function(){return H9._}});Object.defineProperty($1,"str",{enumerable:!0,get:function(){return H9.str}});Object.defineProperty($1,"stringify",{enumerable:!0,get:function(){return H9.stringify}});Object.defineProperty($1,"nil",{enumerable:!0,get:function(){return H9.nil}});Object.defineProperty($1,"Name",{enumerable:!0,get:function(){return H9.Name}});Object.defineProperty($1,"CodeGen",{enumerable:!0,get:function(){return H9.CodeGen}});var eN=EQ(),wG=K8(),QU=AX(),V8=CQ(),XU=x(),D8=$8(),vQ=W8(),mX=f(),OG=aB(),YU=AG(),PG=(Q,X)=>new RegExp(Q,X);PG.code="new RegExp";var JU=["removeAdditional","useDefaults","coerceTypes"],WU=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),$U={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."},BU={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},NG=200;function GU(Q){var X,Y,J,W,$,B,G,K,H,Z,L,V,D,z,A,N,F,U,M,b,P,n,O0,T1,E9;let E0=Q.strict,l1=(X=Q.code)===null||X===void 0?void 0:X.optimize,eY=l1===!0||l1===void 0?1:l1||0,QJ=(J=(Y=Q.code)===null||Y===void 0?void 0:Y.regExp)!==null&&J!==void 0?J:PG,FL=(W=Q.uriResolver)!==null&&W!==void 0?W:YU.default;return{strictSchema:(B=($=Q.strictSchema)!==null&&$!==void 0?$:E0)!==null&&B!==void 0?B:!0,strictNumbers:(K=(G=Q.strictNumbers)!==null&&G!==void 0?G:E0)!==null&&K!==void 0?K:!0,strictTypes:(Z=(H=Q.strictTypes)!==null&&H!==void 0?H:E0)!==null&&Z!==void 0?Z:"log",strictTuples:(V=(L=Q.strictTuples)!==null&&L!==void 0?L:E0)!==null&&V!==void 0?V:"log",strictRequired:(z=(D=Q.strictRequired)!==null&&D!==void 0?D:E0)!==null&&z!==void 0?z:!1,code:Q.code?{...Q.code,optimize:eY,regExp:QJ}:{optimize:eY,regExp:QJ},loopRequired:(A=Q.loopRequired)!==null&&A!==void 0?A:NG,loopEnum:(N=Q.loopEnum)!==null&&N!==void 0?N:NG,meta:(F=Q.meta)!==null&&F!==void 0?F:!0,messages:(U=Q.messages)!==null&&U!==void 0?U:!0,inlineRefs:(M=Q.inlineRefs)!==null&&M!==void 0?M:!0,schemaId:(b=Q.schemaId)!==null&&b!==void 0?b:"$id",addUsedSchema:(P=Q.addUsedSchema)!==null&&P!==void 0?P:!0,validateSchema:(n=Q.validateSchema)!==null&&n!==void 0?n:!0,validateFormats:(O0=Q.validateFormats)!==null&&O0!==void 0?O0:!0,unicodeRegExp:(T1=Q.unicodeRegExp)!==null&&T1!==void 0?T1:!0,int32range:(E9=Q.int32range)!==null&&E9!==void 0?E9:!0,uriResolver:FL}}class yQ{constructor(Q={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,Q=this.opts={...Q,...GU(Q)};let{es5:X,lines:Y}=this.opts.code;this.scope=new XU.ValueScope({scope:{},prefixes:WU,es5:X,lines:Y}),this.logger=DU(Q.logger);let J=Q.validateFormats;if(Q.validateFormats=!1,this.RULES=(0,QU.getRules)(),UG.call(this,$U,Q,"NOT SUPPORTED"),UG.call(this,BU,Q,"DEPRECATED","warn"),this._metaOpts=LU.call(this),Q.formats)KU.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),Q.keywords)ZU.call(this,Q.keywords);if(typeof Q.meta=="object")this.addMetaSchema(Q.meta);HU.call(this),Q.validateFormats=J}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:Q,meta:X,schemaId:Y}=this.opts,J=OG;if(Y==="id")J={...OG},J.id=J.$id,delete J.$id;if(X&&Q)this.addMetaSchema(J,J[Y],!1)}defaultMeta(){let{meta:Q,schemaId:X}=this.opts;return this.opts.defaultMeta=typeof Q=="object"?Q[X]||Q:void 0}validate(Q,X){let Y;if(typeof Q=="string"){if(Y=this.getSchema(Q),!Y)throw Error(`no schema with key or ref "${Q}"`)}else Y=this.compile(Q);let J=Y(X);if(!("$async"in Y))this.errors=Y.errors;return J}compile(Q,X){let Y=this._addSchema(Q,X);return Y.validate||this._compileSchemaEnv(Y)}compileAsync(Q,X){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:Y}=this.opts;return J.call(this,Q,X);async function J(H,Z){await W.call(this,H.$schema);let L=this._addSchema(H,Z);return L.validate||$.call(this,L)}async function W(H){if(H&&!this.getSchema(H))await J.call(this,{$ref:H},!0)}async function $(H){try{return this._compileSchemaEnv(H)}catch(Z){if(!(Z instanceof wG.default))throw Z;return B.call(this,Z),await G.call(this,Z.missingSchema),$.call(this,H)}}function B({missingSchema:H,missingRef:Z}){if(this.refs[H])throw Error(`AnySchema ${H} is loaded but ${Z} cannot be resolved`)}async function G(H){let Z=await K.call(this,H);if(!this.refs[H])await W.call(this,Z.$schema);if(!this.refs[H])this.addSchema(Z,H,X)}async function K(H){let Z=this._loading[H];if(Z)return Z;try{return await(this._loading[H]=Y(H))}finally{delete this._loading[H]}}}addSchema(Q,X,Y,J=this.opts.validateSchema){if(Array.isArray(Q)){for(let $ of Q)this.addSchema($,void 0,Y,J);return this}let W;if(typeof Q==="object"){let{schemaId:$}=this.opts;if(W=Q[$],W!==void 0&&typeof W!="string")throw Error(`schema ${$} must be string`)}return X=(0,D8.normalizeId)(X||W),this._checkUnique(X),this.schemas[X]=this._addSchema(Q,Y,X,J,!0),this}addMetaSchema(Q,X,Y=this.opts.validateSchema){return this.addSchema(Q,X,!0,Y),this}validateSchema(Q,X){if(typeof Q=="boolean")return!0;let Y;if(Y=Q.$schema,Y!==void 0&&typeof Y!="string")throw Error("$schema must be a string");if(Y=Y||this.opts.defaultMeta||this.defaultMeta(),!Y)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let J=this.validate(Y,Q);if(!J&&X){let W="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(W);else throw Error(W)}return J}getSchema(Q){let X;while(typeof(X=MG.call(this,Q))=="string")Q=X;if(X===void 0){let{schemaId:Y}=this.opts,J=new V8.SchemaEnv({schema:{},schemaId:Y});if(X=V8.resolveSchema.call(this,J,Q),!X)return;this.refs[Q]=X}return X.validate||this._compileSchemaEnv(X)}removeSchema(Q){if(Q instanceof RegExp)return this._removeAllSchemas(this.schemas,Q),this._removeAllSchemas(this.refs,Q),this;switch(typeof Q){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let X=MG.call(this,Q);if(typeof X=="object")this._cache.delete(X.schema);return delete this.schemas[Q],delete this.refs[Q],this}case"object":{let X=Q;this._cache.delete(X);let Y=Q[this.opts.schemaId];if(Y)Y=(0,D8.normalizeId)(Y),delete this.schemas[Y],delete this.refs[Y];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary(Q){for(let X of Q)this.addKeyword(X);return this}addKeyword(Q,X){let Y;if(typeof Q=="string"){if(Y=Q,typeof X=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),X.keyword=Y}else if(typeof Q=="object"&&X===void 0){if(X=Q,Y=X.keyword,Array.isArray(Y)&&!Y.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(zU.call(this,Y,X),!X)return(0,mX.eachItem)(Y,(W)=>uX.call(this,W)),this;AU.call(this,X);let J={...X,type:(0,vQ.getJSONTypes)(X.type),schemaType:(0,vQ.getJSONTypes)(X.schemaType)};return(0,mX.eachItem)(Y,J.type.length===0?(W)=>uX.call(this,W,J):(W)=>J.type.forEach(($)=>uX.call(this,W,J,$))),this}getKeyword(Q){let X=this.RULES.all[Q];return typeof X=="object"?X.definition:!!X}removeKeyword(Q){let{RULES:X}=this;delete X.keywords[Q],delete X.all[Q];for(let Y of X.rules){let J=Y.rules.findIndex((W)=>W.keyword===Q);if(J>=0)Y.rules.splice(J,1)}return this}addFormat(Q,X){if(typeof X=="string")X=new RegExp(X);return this.formats[Q]=X,this}errorsText(Q=this.errors,{separator:X=", ",dataVar:Y="data"}={}){if(!Q||Q.length===0)return"No errors";return Q.map((J)=>`${Y}${J.instancePath} ${J.message}`).reduce((J,W)=>J+X+W)}$dataMetaSchema(Q,X){let Y=this.RULES.all;Q=JSON.parse(JSON.stringify(Q));for(let J of X){let W=J.split("/").slice(1),$=Q;for(let B of W)$=$[B];for(let B in Y){let G=Y[B];if(typeof G!="object")continue;let{$data:K}=G.definition,H=$[B];if(K&&H)$[B]=jG(H)}}return Q}_removeAllSchemas(Q,X){for(let Y in Q){let J=Q[Y];if(!X||X.test(Y)){if(typeof J=="string")delete Q[Y];else if(J&&!J.meta)this._cache.delete(J.schema),delete Q[Y]}}}_addSchema(Q,X,Y,J=this.opts.validateSchema,W=this.opts.addUsedSchema){let $,{schemaId:B}=this.opts;if(typeof Q=="object")$=Q[B];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof Q!="boolean")throw Error("schema must be object or boolean");let G=this._cache.get(Q);if(G!==void 0)return G;Y=(0,D8.normalizeId)($||Y);let K=D8.getSchemaRefs.call(this,Q,Y);if(G=new V8.SchemaEnv({schema:Q,schemaId:B,meta:X,baseId:Y,localRefs:K}),this._cache.set(G.schema,G),W&&!Y.startsWith("#")){if(Y)this._checkUnique(Y);this.refs[Y]=G}if(J)this.validateSchema(Q,!0);return G}_checkUnique(Q){if(this.schemas[Q]||this.refs[Q])throw Error(`schema with key or id "${Q}" already exists`)}_compileSchemaEnv(Q){if(Q.meta)this._compileMetaSchema(Q);else V8.compileSchema.call(this,Q);if(!Q.validate)throw Error("ajv implementation error");return Q.validate}_compileMetaSchema(Q){let X=this.opts;this.opts=this._metaOpts;try{V8.compileSchema.call(this,Q)}finally{this.opts=X}}}yQ.ValidationError=eN.default;yQ.MissingRefError=wG.default;$1.default=yQ;function UG(Q,X,Y,J="error"){for(let W in Q){let $=W;if($ in X)this.logger[J](`${Y}: option ${W}. ${Q[$]}`)}}function MG(Q){return Q=(0,D8.normalizeId)(Q),this.schemas[Q]||this.refs[Q]}function HU(){let Q=this.opts.schemas;if(!Q)return;if(Array.isArray(Q))this.addSchema(Q);else for(let X in Q)this.addSchema(Q[X],X)}function KU(){for(let Q in this.opts.formats){let X=this.opts.formats[Q];if(X)this.addFormat(Q,X)}}function ZU(Q){if(Array.isArray(Q)){this.addVocabulary(Q);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let X in Q){let Y=Q[X];if(!Y.keyword)Y.keyword=X;this.addKeyword(Y)}}function LU(){let Q={...this.opts};for(let X of JU)delete Q[X];return Q}var VU={log(){},warn(){},error(){}};function DU(Q){if(Q===!1)return VU;if(Q===void 0)return console;if(Q.log&&Q.warn&&Q.error)return Q;throw Error("logger must implement log, warn and error methods")}var qU=/^[a-z_$][a-z0-9_$:-]*$/i;function zU(Q,X){let{RULES:Y}=this;if((0,mX.eachItem)(Q,(J)=>{if(Y.keywords[J])throw Error(`Keyword ${J} is already defined`);if(!qU.test(J))throw Error(`Keyword ${J} has invalid name`)}),!X)return;if(X.$data&&!(("code"in X)||("validate"in X)))throw Error('$data keyword must have "code" or "validate" function')}function uX(Q,X,Y){var J;let W=X===null||X===void 0?void 0:X.post;if(Y&&W)throw Error('keyword with "post" flag cannot have "type"');let{RULES:$}=this,B=W?$.post:$.rules.find(({type:K})=>K===Y);if(!B)B={type:Y,rules:[]},$.rules.push(B);if($.keywords[Q]=!0,!X)return;let G={keyword:Q,definition:{...X,type:(0,vQ.getJSONTypes)(X.type),schemaType:(0,vQ.getJSONTypes)(X.schemaType)}};if(X.before)FU.call(this,B,G,X.before);else B.rules.push(G);$.all[Q]=G,(J=X.implements)===null||J===void 0||J.forEach((K)=>this.addKeyword(K))}function FU(Q,X,Y){let J=Q.rules.findIndex((W)=>W.keyword===Y);if(J>=0)Q.rules.splice(J,0,X);else Q.rules.push(X),this.logger.warn(`rule ${Y} is not defined`)}function AU(Q){let{metaSchema:X}=Q;if(X===void 0)return;if(Q.$data&&this.opts.$data)X=jG(X);Q.validateSchema=this.compile(X,!0)}var OU={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function jG(Q){return{anyOf:[Q,OU]}}});var TG=w((bG)=>{Object.defineProperty(bG,"__esModule",{value:!0});var MU={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};bG.default=MU});var _G=w((CG)=>{Object.defineProperty(CG,"__esModule",{value:!0});CG.callRef=CG.getValidate=void 0;var PU=K8(),RG=x0(),P0=x(),K9=J1(),EG=CQ(),gQ=f(),jU={keyword:"$ref",schemaType:"string",code(Q){let{gen:X,schema:Y,it:J}=Q,{baseId:W,schemaEnv:$,validateName:B,opts:G,self:K}=J,{root:H}=$;if((Y==="#"||Y==="#/")&&W===H.baseId)return L();let Z=EG.resolveRef.call(K,H,W,Y);if(Z===void 0)throw new PU.default(J.opts.uriResolver,W,Y);if(Z instanceof EG.SchemaEnv)return V(Z);return D(Z);function L(){if($===H)return fQ(Q,B,$,$.$async);let z=X.scopeValue("root",{ref:H});return fQ(Q,P0._`${z}.validate`,H,H.$async)}function V(z){let A=SG(Q,z);fQ(Q,A,z,z.$async)}function D(z){let A=X.scopeValue("schema",G.code.source===!0?{ref:z,code:(0,P0.stringify)(z)}:{ref:z}),N=X.name("valid"),F=Q.subschema({schema:z,dataTypes:[],schemaPath:P0.nil,topSchemaRef:A,errSchemaPath:Y},N);Q.mergeEvaluated(F),Q.ok(N)}}};function SG(Q,X){let{gen:Y}=Q;return X.validate?Y.scopeValue("validate",{ref:X.validate}):P0._`${Y.scopeValue("wrapper",{ref:X})}.validate`}CG.getValidate=SG;function fQ(Q,X,Y,J){let{gen:W,it:$}=Q,{allErrors:B,schemaEnv:G,opts:K}=$,H=K.passContext?K9.default.this:P0.nil;if(J)Z();else L();function Z(){if(!G.$async)throw Error("async schema referenced by sync schema");let z=W.let("valid");W.try(()=>{if(W.code(P0._`await ${(0,RG.callValidateCode)(Q,X,H)}`),D(X),!B)W.assign(z,!0)},(A)=>{if(W.if(P0._`!(${A} instanceof ${$.ValidationError})`,()=>W.throw(A)),V(A),!B)W.assign(z,!1)}),Q.ok(z)}function L(){Q.result((0,RG.callValidateCode)(Q,X,H),()=>D(X),()=>V(X))}function V(z){let A=P0._`${z}.errors`;W.assign(K9.default.vErrors,P0._`${K9.default.vErrors} === null ? ${A} : ${K9.default.vErrors}.concat(${A})`),W.assign(K9.default.errors,P0._`${K9.default.vErrors}.length`)}function D(z){var A;if(!$.opts.unevaluated)return;let N=(A=Y===null||Y===void 0?void 0:Y.validate)===null||A===void 0?void 0:A.evaluated;if($.props!==!0)if(N&&!N.dynamicProps){if(N.props!==void 0)$.props=gQ.mergeEvaluated.props(W,N.props,$.props)}else{let F=W.var("props",P0._`${z}.evaluated.props`);$.props=gQ.mergeEvaluated.props(W,F,$.props,P0.Name)}if($.items!==!0)if(N&&!N.dynamicItems){if(N.items!==void 0)$.items=gQ.mergeEvaluated.items(W,N.items,$.items)}else{let F=W.var("items",P0._`${z}.evaluated.items`);$.items=gQ.mergeEvaluated.items(W,F,$.items,P0.Name)}}}CG.callRef=fQ;CG.default=jU});var vG=w((xG)=>{Object.defineProperty(xG,"__esModule",{value:!0});var TU=TG(),RU=_G(),EU=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",TU.default,RU.default];xG.default=EU});var gG=w((yG)=>{Object.defineProperty(yG,"__esModule",{value:!0});var hQ=x(),P1=hQ.operators,uQ={maximum:{okStr:"<=",ok:P1.LTE,fail:P1.GT},minimum:{okStr:">=",ok:P1.GTE,fail:P1.LT},exclusiveMaximum:{okStr:"<",ok:P1.LT,fail:P1.GTE},exclusiveMinimum:{okStr:">",ok:P1.GT,fail:P1.LTE}},CU={message:({keyword:Q,schemaCode:X})=>hQ.str`must be ${uQ[Q].okStr} ${X}`,params:({keyword:Q,schemaCode:X})=>hQ._`{comparison: ${uQ[Q].okStr}, limit: ${X}}`},kU={keyword:Object.keys(uQ),type:"number",schemaType:"number",$data:!0,error:CU,code(Q){let{keyword:X,data:Y,schemaCode:J}=Q;Q.fail$data(hQ._`${Y} ${uQ[X].fail} ${J} || isNaN(${Y})`)}};yG.default=kU});var hG=w((fG)=>{Object.defineProperty(fG,"__esModule",{value:!0});var q8=x(),xU={message:({schemaCode:Q})=>q8.str`must be multiple of ${Q}`,params:({schemaCode:Q})=>q8._`{multipleOf: ${Q}}`},vU={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:xU,code(Q){let{gen:X,data:Y,schemaCode:J,it:W}=Q,$=W.opts.multipleOfPrecision,B=X.let("res"),G=$?q8._`Math.abs(Math.round(${B}) - ${B}) > 1e-${$}`:q8._`${B} !== parseInt(${B})`;Q.fail$data(q8._`(${J} === 0 || (${B} = ${Y}/${J}, ${G}))`)}};fG.default=vU});var lG=w((mG)=>{Object.defineProperty(mG,"__esModule",{value:!0});function uG(Q){let X=Q.length,Y=0,J=0,W;while(J<X)if(Y++,W=Q.charCodeAt(J++),W>=55296&&W<=56319&&J<X){if(W=Q.charCodeAt(J),(W&64512)===56320)J++}return Y}mG.default=uG;uG.code='require("ajv/dist/runtime/ucs2length").default'});var pG=w((cG)=>{Object.defineProperty(cG,"__esModule",{value:!0});var g1=x(),fU=f(),hU=lG(),uU={message({keyword:Q,schemaCode:X}){let Y=Q==="maxLength"?"more":"fewer";return g1.str`must NOT have ${Y} than ${X} characters`},params:({schemaCode:Q})=>g1._`{limit: ${Q}}`},mU={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:uU,code(Q){let{keyword:X,data:Y,schemaCode:J,it:W}=Q,$=X==="maxLength"?g1.operators.GT:g1.operators.LT,B=W.opts.unicode===!1?g1._`${Y}.length`:g1._`${(0,fU.useFunc)(Q.gen,hU.default)}(${Y})`;Q.fail$data(g1._`${B} ${$} ${J}`)}};cG.default=mU});var iG=w((dG)=>{Object.defineProperty(dG,"__esModule",{value:!0});var cU=x0(),pU=f(),Z9=x(),dU={message:({schemaCode:Q})=>Z9.str`must match pattern "${Q}"`,params:({schemaCode:Q})=>Z9._`{pattern: ${Q}}`},iU={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:dU,code(Q){let{gen:X,data:Y,$data:J,schema:W,schemaCode:$,it:B}=Q,G=B.opts.unicodeRegExp?"u":"";if(J){let{regExp:K}=B.opts.code,H=K.code==="new RegExp"?Z9._`new RegExp`:(0,pU.useFunc)(X,K),Z=X.let("valid");X.try(()=>X.assign(Z,Z9._`${H}(${$}, ${G}).test(${Y})`),()=>X.assign(Z,!1)),Q.fail$data(Z9._`!${Z}`)}else{let K=(0,cU.usePattern)(Q,W);Q.fail$data(Z9._`!${K}.test(${Y})`)}}};dG.default=iU});var oG=w((nG)=>{Object.defineProperty(nG,"__esModule",{value:!0});var z8=x(),oU={message({keyword:Q,schemaCode:X}){let Y=Q==="maxProperties"?"more":"fewer";return z8.str`must NOT have ${Y} than ${X} properties`},params:({schemaCode:Q})=>z8._`{limit: ${Q}}`},rU={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:oU,code(Q){let{keyword:X,data:Y,schemaCode:J}=Q,W=X==="maxProperties"?z8.operators.GT:z8.operators.LT;Q.fail$data(z8._`Object.keys(${Y}).length ${W} ${J}`)}};nG.default=rU});var tG=w((rG)=>{Object.defineProperty(rG,"__esModule",{value:!0});var F8=x0(),A8=x(),aU=f(),sU={message:({params:{missingProperty:Q}})=>A8.str`must have required property '${Q}'`,params:({params:{missingProperty:Q}})=>A8._`{missingProperty: ${Q}}`},eU={keyword:"required",type:"object",schemaType:"array",$data:!0,error:sU,code(Q){let{gen:X,schema:Y,schemaCode:J,data:W,$data:$,it:B}=Q,{opts:G}=B;if(!$&&Y.length===0)return;let K=Y.length>=G.loopRequired;if(B.allErrors)H();else Z();if(G.strictRequired){let D=Q.parentSchema.properties,{definedProperties:z}=Q.it;for(let A of Y)if((D===null||D===void 0?void 0:D[A])===void 0&&!z.has(A)){let N=B.schemaEnv.baseId+B.errSchemaPath,F=`required property "${A}" is not defined at "${N}" (strictRequired)`;(0,aU.checkStrictMode)(B,F,B.opts.strictRequired)}}function H(){if(K||$)Q.block$data(A8.nil,L);else for(let D of Y)(0,F8.checkReportMissingProp)(Q,D)}function Z(){let D=X.let("missing");if(K||$){let z=X.let("valid",!0);Q.block$data(z,()=>V(D,z)),Q.ok(z)}else X.if((0,F8.checkMissingProp)(Q,Y,D)),(0,F8.reportMissingProp)(Q,D),X.else()}function L(){X.forOf("prop",J,(D)=>{Q.setParams({missingProperty:D}),X.if((0,F8.noPropertyInData)(X,W,D,G.ownProperties),()=>Q.error())})}function V(D,z){Q.setParams({missingProperty:D}),X.forOf(D,J,()=>{X.assign(z,(0,F8.propertyInData)(X,W,D,G.ownProperties)),X.if((0,A8.not)(z),()=>{Q.error(),X.break()})},A8.nil)}}};rG.default=eU});var sG=w((aG)=>{Object.defineProperty(aG,"__esModule",{value:!0});var O8=x(),XM={message({keyword:Q,schemaCode:X}){let Y=Q==="maxItems"?"more":"fewer";return O8.str`must NOT have ${Y} than ${X} items`},params:({schemaCode:Q})=>O8._`{limit: ${Q}}`},YM={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:XM,code(Q){let{keyword:X,data:Y,schemaCode:J}=Q,W=X==="maxItems"?O8.operators.GT:O8.operators.LT;Q.fail$data(O8._`${Y}.length ${W} ${J}`)}};aG.default=YM});var mQ=w((QH)=>{Object.defineProperty(QH,"__esModule",{value:!0});var eG=IX();eG.code='require("ajv/dist/runtime/equal").default';QH.default=eG});var YH=w((XH)=>{Object.defineProperty(XH,"__esModule",{value:!0});var lX=W8(),V0=x(),$M=f(),BM=mQ(),GM={message:({params:{i:Q,j:X}})=>V0.str`must NOT have duplicate items (items ## ${X} and ${Q} are identical)`,params:({params:{i:Q,j:X}})=>V0._`{i: ${Q}, j: ${X}}`},HM={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:GM,code(Q){let{gen:X,data:Y,$data:J,schema:W,parentSchema:$,schemaCode:B,it:G}=Q;if(!J&&!W)return;let K=X.let("valid"),H=$.items?(0,lX.getSchemaTypes)($.items):[];Q.block$data(K,Z,V0._`${B} === false`),Q.ok(K);function Z(){let z=X.let("i",V0._`${Y}.length`),A=X.let("j");Q.setParams({i:z,j:A}),X.assign(K,!0),X.if(V0._`${z} > 1`,()=>(L()?V:D)(z,A))}function L(){return H.length>0&&!H.some((z)=>z==="object"||z==="array")}function V(z,A){let N=X.name("item"),F=(0,lX.checkDataTypes)(H,N,G.opts.strictNumbers,lX.DataType.Wrong),U=X.const("indices",V0._`{}`);X.for(V0._`;${z}--;`,()=>{if(X.let(N,V0._`${Y}[${z}]`),X.if(F,V0._`continue`),H.length>1)X.if(V0._`typeof ${N} == "string"`,V0._`${N} += "_"`);X.if(V0._`typeof ${U}[${N}] == "number"`,()=>{X.assign(A,V0._`${U}[${N}]`),Q.error(),X.assign(K,!1).break()}).code(V0._`${U}[${N}] = ${z}`)})}function D(z,A){let N=(0,$M.useFunc)(X,BM.default),F=X.name("outer");X.label(F).for(V0._`;${z}--;`,()=>X.for(V0._`${A} = ${z}; ${A}--;`,()=>X.if(V0._`${N}(${Y}[${z}], ${Y}[${A}])`,()=>{Q.error(),X.assign(K,!1).break(F)})))}}};XH.default=HM});var WH=w((JH)=>{Object.defineProperty(JH,"__esModule",{value:!0});var cX=x(),ZM=f(),LM=mQ(),VM={message:"must be equal to constant",params:({schemaCode:Q})=>cX._`{allowedValue: ${Q}}`},DM={keyword:"const",$data:!0,error:VM,code(Q){let{gen:X,data:Y,$data:J,schemaCode:W,schema:$}=Q;if(J||$&&typeof $=="object")Q.fail$data(cX._`!${(0,ZM.useFunc)(X,LM.default)}(${Y}, ${W})`);else Q.fail(cX._`${$} !== ${Y}`)}};JH.default=DM});var BH=w(($H)=>{Object.defineProperty($H,"__esModule",{value:!0});var N8=x(),zM=f(),FM=mQ(),AM={message:"must be equal to one of the allowed values",params:({schemaCode:Q})=>N8._`{allowedValues: ${Q}}`},OM={keyword:"enum",schemaType:"array",$data:!0,error:AM,code(Q){let{gen:X,data:Y,$data:J,schema:W,schemaCode:$,it:B}=Q;if(!J&&W.length===0)throw Error("enum must have non-empty array");let G=W.length>=B.opts.loopEnum,K,H=()=>K!==null&&K!==void 0?K:K=(0,zM.useFunc)(X,FM.default),Z;if(G||J)Z=X.let("valid"),Q.block$data(Z,L);else{if(!Array.isArray(W))throw Error("ajv implementation error");let D=X.const("vSchema",$);Z=(0,N8.or)(...W.map((z,A)=>V(D,A)))}Q.pass(Z);function L(){X.assign(Z,!1),X.forOf("v",$,(D)=>X.if(N8._`${H()}(${Y}, ${D})`,()=>X.assign(Z,!0).break()))}function V(D,z){let A=W[z];return typeof A==="object"&&A!==null?N8._`${H()}(${Y}, ${D}[${z}])`:N8._`${Y} === ${A}`}}};$H.default=OM});var HH=w((GH)=>{Object.defineProperty(GH,"__esModule",{value:!0});var UM=gG(),MM=hG(),wM=pG(),PM=iG(),jM=oG(),IM=tG(),bM=sG(),TM=YH(),RM=WH(),EM=BH(),SM=[UM.default,MM.default,wM.default,PM.default,jM.default,IM.default,bM.default,TM.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},RM.default,EM.default];GH.default=SM});var dX=w((ZH)=>{Object.defineProperty(ZH,"__esModule",{value:!0});ZH.validateAdditionalItems=void 0;var f1=x(),pX=f(),kM={message:({params:{len:Q}})=>f1.str`must NOT have more than ${Q} items`,params:({params:{len:Q}})=>f1._`{limit: ${Q}}`},_M={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:kM,code(Q){let{parentSchema:X,it:Y}=Q,{items:J}=X;if(!Array.isArray(J)){(0,pX.checkStrictMode)(Y,'"additionalItems" is ignored when "items" is not an array of schemas');return}KH(Q,J)}};function KH(Q,X){let{gen:Y,schema:J,data:W,keyword:$,it:B}=Q;B.items=!0;let G=Y.const("len",f1._`${W}.length`);if(J===!1)Q.setParams({len:X.length}),Q.pass(f1._`${G} <= ${X.length}`);else if(typeof J=="object"&&!(0,pX.alwaysValidSchema)(B,J)){let H=Y.var("valid",f1._`${G} <= ${X.length}`);Y.if((0,f1.not)(H),()=>K(H)),Q.ok(H)}function K(H){Y.forRange("i",X.length,G,(Z)=>{if(Q.subschema({keyword:$,dataProp:Z,dataPropType:pX.Type.Num},H),!B.allErrors)Y.if((0,f1.not)(H),()=>Y.break())})}}ZH.validateAdditionalItems=KH;ZH.default=_M});var iX=w((qH)=>{Object.defineProperty(qH,"__esModule",{value:!0});qH.validateTuple=void 0;var VH=x(),lQ=f(),vM=x0(),yM={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(Q){let{schema:X,it:Y}=Q;if(Array.isArray(X))return DH(Q,"additionalItems",X);if(Y.items=!0,(0,lQ.alwaysValidSchema)(Y,X))return;Q.ok((0,vM.validateArray)(Q))}};function DH(Q,X,Y=Q.schema){let{gen:J,parentSchema:W,data:$,keyword:B,it:G}=Q;if(Z(W),G.opts.unevaluated&&Y.length&&G.items!==!0)G.items=lQ.mergeEvaluated.items(J,Y.length,G.items);let K=J.name("valid"),H=J.const("len",VH._`${$}.length`);Y.forEach((L,V)=>{if((0,lQ.alwaysValidSchema)(G,L))return;J.if(VH._`${H} > ${V}`,()=>Q.subschema({keyword:B,schemaProp:V,dataProp:V},K)),Q.ok(K)});function Z(L){let{opts:V,errSchemaPath:D}=G,z=Y.length,A=z===L.minItems&&(z===L.maxItems||L[X]===!1);if(V.strictTuples&&!A){let N=`"${B}" is ${z}-tuple, but minItems or maxItems/${X} are not specified or different at path "${D}"`;(0,lQ.checkStrictMode)(G,N,V.strictTuples)}}}qH.validateTuple=DH;qH.default=yM});var AH=w((FH)=>{Object.defineProperty(FH,"__esModule",{value:!0});var fM=iX(),hM={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:(Q)=>(0,fM.validateTuple)(Q,"items")};FH.default=hM});var UH=w((NH)=>{Object.defineProperty(NH,"__esModule",{value:!0});var OH=x(),mM=f(),lM=x0(),cM=dX(),pM={message:({params:{len:Q}})=>OH.str`must NOT have more than ${Q} items`,params:({params:{len:Q}})=>OH._`{limit: ${Q}}`},dM={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:pM,code(Q){let{schema:X,parentSchema:Y,it:J}=Q,{prefixItems:W}=Y;if(J.items=!0,(0,mM.alwaysValidSchema)(J,X))return;if(W)(0,cM.validateAdditionalItems)(Q,W);else Q.ok((0,lM.validateArray)(Q))}};NH.default=dM});var wH=w((MH)=>{Object.defineProperty(MH,"__esModule",{value:!0});var v0=x(),cQ=f(),nM={message:({params:{min:Q,max:X}})=>X===void 0?v0.str`must contain at least ${Q} valid item(s)`:v0.str`must contain at least ${Q} and no more than ${X} valid item(s)`,params:({params:{min:Q,max:X}})=>X===void 0?v0._`{minContains: ${Q}}`:v0._`{minContains: ${Q}, maxContains: ${X}}`},oM={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:nM,code(Q){let{gen:X,schema:Y,parentSchema:J,data:W,it:$}=Q,B,G,{minContains:K,maxContains:H}=J;if($.opts.next)B=K===void 0?1:K,G=H;else B=1;let Z=X.const("len",v0._`${W}.length`);if(Q.setParams({min:B,max:G}),G===void 0&&B===0){(0,cQ.checkStrictMode)($,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(G!==void 0&&B>G){(0,cQ.checkStrictMode)($,'"minContains" > "maxContains" is always invalid'),Q.fail();return}if((0,cQ.alwaysValidSchema)($,Y)){let A=v0._`${Z} >= ${B}`;if(G!==void 0)A=v0._`${A} && ${Z} <= ${G}`;Q.pass(A);return}$.items=!0;let L=X.name("valid");if(G===void 0&&B===1)D(L,()=>X.if(L,()=>X.break()));else if(B===0){if(X.let(L,!0),G!==void 0)X.if(v0._`${W}.length > 0`,V)}else X.let(L,!1),V();Q.result(L,()=>Q.reset());function V(){let A=X.name("_valid"),N=X.let("count",0);D(A,()=>X.if(A,()=>z(N)))}function D(A,N){X.forRange("i",0,Z,(F)=>{Q.subschema({keyword:"contains",dataProp:F,dataPropType:cQ.Type.Num,compositeRule:!0},A),N()})}function z(A){if(X.code(v0._`${A}++`),G===void 0)X.if(v0._`${A} >= ${B}`,()=>X.assign(L,!0).break());else if(X.if(v0._`${A} > ${G}`,()=>X.assign(L,!1).break()),B===1)X.assign(L,!0);else X.if(v0._`${A} >= ${B}`,()=>X.assign(L,!0))}}};MH.default=oM});var RH=w((IH)=>{Object.defineProperty(IH,"__esModule",{value:!0});IH.validateSchemaDeps=IH.validatePropertyDeps=IH.error=void 0;var nX=x(),tM=f(),U8=x0();IH.error={message:({params:{property:Q,depsCount:X,deps:Y}})=>{let J=X===1?"property":"properties";return nX.str`must have ${J} ${Y} when property ${Q} is present`},params:({params:{property:Q,depsCount:X,deps:Y,missingProperty:J}})=>nX._`{property: ${Q},
|
|
6
|
+
missingProperty: ${J},
|
|
7
|
+
depsCount: ${X},
|
|
8
|
+
deps: ${Y}}`};var aM={keyword:"dependencies",type:"object",schemaType:"object",error:IH.error,code(Q){let[X,Y]=sM(Q);PH(Q,X),jH(Q,Y)}};function sM({schema:Q}){let X={},Y={};for(let J in Q){if(J==="__proto__")continue;let W=Array.isArray(Q[J])?X:Y;W[J]=Q[J]}return[X,Y]}function PH(Q,X=Q.schema){let{gen:Y,data:J,it:W}=Q;if(Object.keys(X).length===0)return;let $=Y.let("missing");for(let B in X){let G=X[B];if(G.length===0)continue;let K=(0,U8.propertyInData)(Y,J,B,W.opts.ownProperties);if(Q.setParams({property:B,depsCount:G.length,deps:G.join(", ")}),W.allErrors)Y.if(K,()=>{for(let H of G)(0,U8.checkReportMissingProp)(Q,H)});else Y.if(nX._`${K} && (${(0,U8.checkMissingProp)(Q,G,$)})`),(0,U8.reportMissingProp)(Q,$),Y.else()}}IH.validatePropertyDeps=PH;function jH(Q,X=Q.schema){let{gen:Y,data:J,keyword:W,it:$}=Q,B=Y.name("valid");for(let G in X){if((0,tM.alwaysValidSchema)($,X[G]))continue;Y.if((0,U8.propertyInData)(Y,J,G,$.opts.ownProperties),()=>{let K=Q.subschema({keyword:W,schemaProp:G},B);Q.mergeValidEvaluated(K,B)},()=>Y.var(B,!0)),Q.ok(B)}}IH.validateSchemaDeps=jH;IH.default=aM});var CH=w((SH)=>{Object.defineProperty(SH,"__esModule",{value:!0});var EH=x(),Xw=f(),Yw={message:"property name must be valid",params:({params:Q})=>EH._`{propertyName: ${Q.propertyName}}`},Jw={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Yw,code(Q){let{gen:X,schema:Y,data:J,it:W}=Q;if((0,Xw.alwaysValidSchema)(W,Y))return;let $=X.name("valid");X.forIn("key",J,(B)=>{Q.setParams({propertyName:B}),Q.subschema({keyword:"propertyNames",data:B,dataTypes:["string"],propertyName:B,compositeRule:!0},$),X.if((0,EH.not)($),()=>{if(Q.error(!0),!W.allErrors)X.break()})}),Q.ok($)}};SH.default=Jw});var oX=w((kH)=>{Object.defineProperty(kH,"__esModule",{value:!0});var pQ=x0(),c0=x(),$w=J1(),dQ=f(),Bw={message:"must NOT have additional properties",params:({params:Q})=>c0._`{additionalProperty: ${Q.additionalProperty}}`},Gw={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Bw,code(Q){let{gen:X,schema:Y,parentSchema:J,data:W,errsCount:$,it:B}=Q;if(!$)throw Error("ajv implementation error");let{allErrors:G,opts:K}=B;if(B.props=!0,K.removeAdditional!=="all"&&(0,dQ.alwaysValidSchema)(B,Y))return;let H=(0,pQ.allSchemaProperties)(J.properties),Z=(0,pQ.allSchemaProperties)(J.patternProperties);L(),Q.ok(c0._`${$} === ${$w.default.errors}`);function L(){X.forIn("key",W,(N)=>{if(!H.length&&!Z.length)z(N);else X.if(V(N),()=>z(N))})}function V(N){let F;if(H.length>8){let U=(0,dQ.schemaRefOrVal)(B,J.properties,"properties");F=(0,pQ.isOwnProperty)(X,U,N)}else if(H.length)F=(0,c0.or)(...H.map((U)=>c0._`${N} === ${U}`));else F=c0.nil;if(Z.length)F=(0,c0.or)(F,...Z.map((U)=>c0._`${(0,pQ.usePattern)(Q,U)}.test(${N})`));return(0,c0.not)(F)}function D(N){X.code(c0._`delete ${W}[${N}]`)}function z(N){if(K.removeAdditional==="all"||K.removeAdditional&&Y===!1){D(N);return}if(Y===!1){if(Q.setParams({additionalProperty:N}),Q.error(),!G)X.break();return}if(typeof Y=="object"&&!(0,dQ.alwaysValidSchema)(B,Y)){let F=X.name("valid");if(K.removeAdditional==="failing")A(N,F,!1),X.if((0,c0.not)(F),()=>{Q.reset(),D(N)});else if(A(N,F),!G)X.if((0,c0.not)(F),()=>X.break())}}function A(N,F,U){let M={keyword:"additionalProperties",dataProp:N,dataPropType:dQ.Type.Str};if(U===!1)Object.assign(M,{compositeRule:!0,createErrors:!1,allErrors:!1});Q.subschema(M,F)}}};kH.default=Gw});var yH=w((vH)=>{Object.defineProperty(vH,"__esModule",{value:!0});var Kw=H8(),_H=x0(),rX=f(),xH=oX(),Zw={keyword:"properties",type:"object",schemaType:"object",code(Q){let{gen:X,schema:Y,parentSchema:J,data:W,it:$}=Q;if($.opts.removeAdditional==="all"&&J.additionalProperties===void 0)xH.default.code(new Kw.KeywordCxt($,xH.default,"additionalProperties"));let B=(0,_H.allSchemaProperties)(Y);for(let L of B)$.definedProperties.add(L);if($.opts.unevaluated&&B.length&&$.props!==!0)$.props=rX.mergeEvaluated.props(X,(0,rX.toHash)(B),$.props);let G=B.filter((L)=>!(0,rX.alwaysValidSchema)($,Y[L]));if(G.length===0)return;let K=X.name("valid");for(let L of G){if(H(L))Z(L);else{if(X.if((0,_H.propertyInData)(X,W,L,$.opts.ownProperties)),Z(L),!$.allErrors)X.else().var(K,!0);X.endIf()}Q.it.definedProperties.add(L),Q.ok(K)}function H(L){return $.opts.useDefaults&&!$.compositeRule&&Y[L].default!==void 0}function Z(L){Q.subschema({keyword:"properties",schemaProp:L,dataProp:L},K)}}};vH.default=Zw});var mH=w((uH)=>{Object.defineProperty(uH,"__esModule",{value:!0});var gH=x0(),iQ=x(),fH=f(),hH=f(),Vw={keyword:"patternProperties",type:"object",schemaType:"object",code(Q){let{gen:X,schema:Y,data:J,parentSchema:W,it:$}=Q,{opts:B}=$,G=(0,gH.allSchemaProperties)(Y),K=G.filter((A)=>(0,fH.alwaysValidSchema)($,Y[A]));if(G.length===0||K.length===G.length&&(!$.opts.unevaluated||$.props===!0))return;let H=B.strictSchema&&!B.allowMatchingProperties&&W.properties,Z=X.name("valid");if($.props!==!0&&!($.props instanceof iQ.Name))$.props=(0,hH.evaluatedPropsToName)(X,$.props);let{props:L}=$;V();function V(){for(let A of G){if(H)D(A);if($.allErrors)z(A);else X.var(Z,!0),z(A),X.if(Z)}}function D(A){for(let N in H)if(new RegExp(A).test(N))(0,fH.checkStrictMode)($,`property ${N} matches pattern ${A} (use allowMatchingProperties)`)}function z(A){X.forIn("key",J,(N)=>{X.if(iQ._`${(0,gH.usePattern)(Q,A)}.test(${N})`,()=>{let F=K.includes(A);if(!F)Q.subschema({keyword:"patternProperties",schemaProp:A,dataProp:N,dataPropType:hH.Type.Str},Z);if($.opts.unevaluated&&L!==!0)X.assign(iQ._`${L}[${N}]`,!0);else if(!F&&!$.allErrors)X.if((0,iQ.not)(Z),()=>X.break())})})}}};uH.default=Vw});var cH=w((lH)=>{Object.defineProperty(lH,"__esModule",{value:!0});var qw=f(),zw={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(Q){let{gen:X,schema:Y,it:J}=Q;if((0,qw.alwaysValidSchema)(J,Y)){Q.fail();return}let W=X.name("valid");Q.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},W),Q.failResult(W,()=>Q.reset(),()=>Q.error())},error:{message:"must NOT be valid"}};lH.default=zw});var dH=w((pH)=>{Object.defineProperty(pH,"__esModule",{value:!0});var Aw=x0(),Ow={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Aw.validateUnion,error:{message:"must match a schema in anyOf"}};pH.default=Ow});var nH=w((iH)=>{Object.defineProperty(iH,"__esModule",{value:!0});var nQ=x(),Uw=f(),Mw={message:"must match exactly one schema in oneOf",params:({params:Q})=>nQ._`{passingSchemas: ${Q.passing}}`},ww={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Mw,code(Q){let{gen:X,schema:Y,parentSchema:J,it:W}=Q;if(!Array.isArray(Y))throw Error("ajv implementation error");if(W.opts.discriminator&&J.discriminator)return;let $=Y,B=X.let("valid",!1),G=X.let("passing",null),K=X.name("_valid");Q.setParams({passing:G}),X.block(H),Q.result(B,()=>Q.reset(),()=>Q.error(!0));function H(){$.forEach((Z,L)=>{let V;if((0,Uw.alwaysValidSchema)(W,Z))X.var(K,!0);else V=Q.subschema({keyword:"oneOf",schemaProp:L,compositeRule:!0},K);if(L>0)X.if(nQ._`${K} && ${B}`).assign(B,!1).assign(G,nQ._`[${G}, ${L}]`).else();X.if(K,()=>{if(X.assign(B,!0),X.assign(G,L),V)Q.mergeEvaluated(V,nQ.Name)})})}}};iH.default=ww});var rH=w((oH)=>{Object.defineProperty(oH,"__esModule",{value:!0});var jw=f(),Iw={keyword:"allOf",schemaType:"array",code(Q){let{gen:X,schema:Y,it:J}=Q;if(!Array.isArray(Y))throw Error("ajv implementation error");let W=X.name("valid");Y.forEach(($,B)=>{if((0,jw.alwaysValidSchema)(J,$))return;let G=Q.subschema({keyword:"allOf",schemaProp:B},W);Q.ok(W),Q.mergeEvaluated(G)})}};oH.default=Iw});var eH=w((sH)=>{Object.defineProperty(sH,"__esModule",{value:!0});var oQ=x(),aH=f(),Tw={message:({params:Q})=>oQ.str`must match "${Q.ifClause}" schema`,params:({params:Q})=>oQ._`{failingKeyword: ${Q.ifClause}}`},Rw={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Tw,code(Q){let{gen:X,parentSchema:Y,it:J}=Q;if(Y.then===void 0&&Y.else===void 0)(0,aH.checkStrictMode)(J,'"if" without "then" and "else" is ignored');let W=tH(J,"then"),$=tH(J,"else");if(!W&&!$)return;let B=X.let("valid",!0),G=X.name("_valid");if(K(),Q.reset(),W&&$){let Z=X.let("ifClause");Q.setParams({ifClause:Z}),X.if(G,H("then",Z),H("else",Z))}else if(W)X.if(G,H("then"));else X.if((0,oQ.not)(G),H("else"));Q.pass(B,()=>Q.error(!0));function K(){let Z=Q.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},G);Q.mergeEvaluated(Z)}function H(Z,L){return()=>{let V=Q.subschema({keyword:Z},G);if(X.assign(B,G),Q.mergeValidEvaluated(V,B),L)X.assign(L,oQ._`${Z}`);else Q.setParams({ifClause:Z})}}}};function tH(Q,X){let Y=Q.schema[X];return Y!==void 0&&!(0,aH.alwaysValidSchema)(Q,Y)}sH.default=Rw});var XK=w((QK)=>{Object.defineProperty(QK,"__esModule",{value:!0});var Sw=f(),Cw={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:Q,parentSchema:X,it:Y}){if(X.if===void 0)(0,Sw.checkStrictMode)(Y,`"${Q}" without "if" is ignored`)}};QK.default=Cw});var JK=w((YK)=>{Object.defineProperty(YK,"__esModule",{value:!0});var _w=dX(),xw=AH(),vw=iX(),yw=UH(),gw=wH(),fw=RH(),hw=CH(),uw=oX(),mw=yH(),lw=mH(),cw=cH(),pw=dH(),dw=nH(),iw=rH(),nw=eH(),ow=XK();function rw(Q=!1){let X=[cw.default,pw.default,dw.default,iw.default,nw.default,ow.default,hw.default,uw.default,fw.default,mw.default,lw.default];if(Q)X.push(xw.default,yw.default);else X.push(_w.default,vw.default);return X.push(gw.default),X}YK.default=rw});var $K=w((WK)=>{Object.defineProperty(WK,"__esModule",{value:!0});var Y0=x(),aw={message:({schemaCode:Q})=>Y0.str`must match format "${Q}"`,params:({schemaCode:Q})=>Y0._`{format: ${Q}}`},sw={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:aw,code(Q,X){let{gen:Y,data:J,$data:W,schema:$,schemaCode:B,it:G}=Q,{opts:K,errSchemaPath:H,schemaEnv:Z,self:L}=G;if(!K.validateFormats)return;if(W)V();else D();function V(){let z=Y.scopeValue("formats",{ref:L.formats,code:K.code.formats}),A=Y.const("fDef",Y0._`${z}[${B}]`),N=Y.let("fType"),F=Y.let("format");Y.if(Y0._`typeof ${A} == "object" && !(${A} instanceof RegExp)`,()=>Y.assign(N,Y0._`${A}.type || "string"`).assign(F,Y0._`${A}.validate`),()=>Y.assign(N,Y0._`"string"`).assign(F,A)),Q.fail$data((0,Y0.or)(U(),M()));function U(){if(K.strictSchema===!1)return Y0.nil;return Y0._`${B} && !${F}`}function M(){let b=Z.$async?Y0._`(${A}.async ? await ${F}(${J}) : ${F}(${J}))`:Y0._`${F}(${J})`,P=Y0._`(typeof ${F} == "function" ? ${b} : ${F}.test(${J}))`;return Y0._`${F} && ${F} !== true && ${N} === ${X} && !${P}`}}function D(){let z=L.formats[$];if(!z){U();return}if(z===!0)return;let[A,N,F]=M(z);if(A===X)Q.pass(b());function U(){if(K.strictSchema===!1){L.logger.warn(P());return}throw Error(P());function P(){return`unknown format "${$}" ignored in schema at path "${H}"`}}function M(P){let n=P instanceof RegExp?(0,Y0.regexpCode)(P):K.code.formats?Y0._`${K.code.formats}${(0,Y0.getProperty)($)}`:void 0,O0=Y.scopeValue("formats",{key:$,ref:P,code:n});if(typeof P=="object"&&!(P instanceof RegExp))return[P.type||"string",P.validate,Y0._`${O0}.validate`];return["string",P,O0]}function b(){if(typeof z=="object"&&!(z instanceof RegExp)&&z.async){if(!Z.$async)throw Error("async format in sync schema");return Y0._`await ${F}(${J})`}return typeof N=="function"?Y0._`${F}(${J})`:Y0._`${F}.test(${J})`}}}};WK.default=sw});var GK=w((BK)=>{Object.defineProperty(BK,"__esModule",{value:!0});var QP=$K(),XP=[QP.default];BK.default=XP});var ZK=w((HK)=>{Object.defineProperty(HK,"__esModule",{value:!0});HK.contentVocabulary=HK.metadataVocabulary=void 0;HK.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];HK.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var DK=w((VK)=>{Object.defineProperty(VK,"__esModule",{value:!0});var WP=vG(),$P=HH(),BP=JK(),GP=GK(),LK=ZK(),HP=[WP.default,$P.default,(0,BP.default)(),GP.default,LK.metadataVocabulary,LK.contentVocabulary];VK.default=HP});var AK=w((zK)=>{Object.defineProperty(zK,"__esModule",{value:!0});zK.DiscrError=void 0;var qK;(function(Q){Q.Tag="tag",Q.Mapping="mapping"})(qK||(zK.DiscrError=qK={}))});var UK=w((NK)=>{Object.defineProperty(NK,"__esModule",{value:!0});var L9=x(),tX=AK(),OK=CQ(),ZP=K8(),LP=f(),VP={message:({params:{discrError:Q,tagName:X}})=>Q===tX.DiscrError.Tag?`tag "${X}" must be string`:`value of tag "${X}" must be in oneOf`,params:({params:{discrError:Q,tag:X,tagName:Y}})=>L9._`{error: ${Q}, tag: ${Y}, tagValue: ${X}}`},DP={keyword:"discriminator",type:"object",schemaType:"object",error:VP,code(Q){let{gen:X,data:Y,schema:J,parentSchema:W,it:$}=Q,{oneOf:B}=W;if(!$.opts.discriminator)throw Error("discriminator: requires discriminator option");let G=J.propertyName;if(typeof G!="string")throw Error("discriminator: requires propertyName");if(J.mapping)throw Error("discriminator: mapping is not supported");if(!B)throw Error("discriminator: requires oneOf keyword");let K=X.let("valid",!1),H=X.const("tag",L9._`${Y}${(0,L9.getProperty)(G)}`);X.if(L9._`typeof ${H} == "string"`,()=>Z(),()=>Q.error(!1,{discrError:tX.DiscrError.Tag,tag:H,tagName:G})),Q.ok(K);function Z(){let D=V();X.if(!1);for(let z in D)X.elseIf(L9._`${H} === ${z}`),X.assign(K,L(D[z]));X.else(),Q.error(!1,{discrError:tX.DiscrError.Mapping,tag:H,tagName:G}),X.endIf()}function L(D){let z=X.name("valid"),A=Q.subschema({keyword:"oneOf",schemaProp:D},z);return Q.mergeEvaluated(A,L9.Name),z}function V(){var D;let z={},A=F(W),N=!0;for(let b=0;b<B.length;b++){let P=B[b];if((P===null||P===void 0?void 0:P.$ref)&&!(0,LP.schemaHasRulesButRef)(P,$.self.RULES)){let O0=P.$ref;if(P=OK.resolveRef.call($.self,$.schemaEnv.root,$.baseId,O0),P instanceof OK.SchemaEnv)P=P.schema;if(P===void 0)throw new ZP.default($.opts.uriResolver,$.baseId,O0)}let n=(D=P===null||P===void 0?void 0:P.properties)===null||D===void 0?void 0:D[G];if(typeof n!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${G}"`);N=N&&(A||F(P)),U(n,b)}if(!N)throw Error(`discriminator: "${G}" must be required`);return z;function F({required:b}){return Array.isArray(b)&&b.includes(G)}function U(b,P){if(b.const)M(b.const,P);else if(b.enum)for(let n of b.enum)M(n,P);else throw Error(`discriminator: "properties/${G}" must have "const" or "enum"`)}function M(b,P){if(typeof b!="string"||b in z)throw Error(`discriminator: "${G}" values must be unique strings`);z[b]=P}}}};NK.default=DP});var MK=w((gk,zP)=>{zP.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 sX=w((j0,aX)=>{Object.defineProperty(j0,"__esModule",{value:!0});j0.MissingRefError=j0.ValidationError=j0.CodeGen=j0.Name=j0.nil=j0.stringify=j0.str=j0._=j0.KeywordCxt=j0.Ajv=void 0;var FP=IG(),AP=DK(),OP=UK(),wK=MK(),NP=["/properties"],rQ="http://json-schema.org/draft-07/schema";class M8 extends FP.default{_addVocabularies(){if(super._addVocabularies(),AP.default.forEach((Q)=>this.addVocabulary(Q)),this.opts.discriminator)this.addKeyword(OP.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let Q=this.opts.$data?this.$dataMetaSchema(wK,NP):wK;this.addMetaSchema(Q,rQ,!1),this.refs["http://json-schema.org/schema"]=rQ}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(rQ)?rQ:void 0)}}j0.Ajv=M8;aX.exports=j0=M8;aX.exports.Ajv=M8;Object.defineProperty(j0,"__esModule",{value:!0});j0.default=M8;var UP=H8();Object.defineProperty(j0,"KeywordCxt",{enumerable:!0,get:function(){return UP.KeywordCxt}});var V9=x();Object.defineProperty(j0,"_",{enumerable:!0,get:function(){return V9._}});Object.defineProperty(j0,"str",{enumerable:!0,get:function(){return V9.str}});Object.defineProperty(j0,"stringify",{enumerable:!0,get:function(){return V9.stringify}});Object.defineProperty(j0,"nil",{enumerable:!0,get:function(){return V9.nil}});Object.defineProperty(j0,"Name",{enumerable:!0,get:function(){return V9.Name}});Object.defineProperty(j0,"CodeGen",{enumerable:!0,get:function(){return V9.CodeGen}});var MP=EQ();Object.defineProperty(j0,"ValidationError",{enumerable:!0,get:function(){return MP.default}});var wP=K8();Object.defineProperty(j0,"MissingRefError",{enumerable:!0,get:function(){return wP.default}})});var kK=w((SK)=>{Object.defineProperty(SK,"__esModule",{value:!0});SK.formatNames=SK.fastFormats=SK.fullFormats=void 0;function n0(Q,X){return{validate:Q,compare:X}}SK.fullFormats={date:n0(bK,YY),time:n0(QY(!0),JY),"date-time":n0(PK(!0),RK),"iso-time":n0(QY(),TK),"iso-date-time":n0(PK(),EK),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:SP,"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:gP,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:CP,int32:{type:"number",validate:xP},int64:{type:"number",validate:vP},float:{type:"number",validate:IK},double:{type:"number",validate:IK},password:!0,binary:!0};SK.fastFormats={...SK.fullFormats,date:n0(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,YY),time:n0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,JY),"date-time":n0(/^\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,RK),"iso-time":n0(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,TK),"iso-date-time":n0(/^\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,EK),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};SK.formatNames=Object.keys(SK.fullFormats);function IP(Q){return Q%4===0&&(Q%100!==0||Q%400===0)}var bP=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,TP=[0,31,28,31,30,31,30,31,31,30,31,30,31];function bK(Q){let X=bP.exec(Q);if(!X)return!1;let Y=+X[1],J=+X[2],W=+X[3];return J>=1&&J<=12&&W>=1&&W<=(J===2&&IP(Y)?29:TP[J])}function YY(Q,X){if(!(Q&&X))return;if(Q>X)return 1;if(Q<X)return-1;return 0}var eX=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function QY(Q){return function(Y){let J=eX.exec(Y);if(!J)return!1;let W=+J[1],$=+J[2],B=+J[3],G=J[4],K=J[5]==="-"?-1:1,H=+(J[6]||0),Z=+(J[7]||0);if(H>23||Z>59||Q&&!G)return!1;if(W<=23&&$<=59&&B<60)return!0;let L=$-Z*K,V=W-H*K-(L<0?1:0);return(V===23||V===-1)&&(L===59||L===-1)&&B<61}}function JY(Q,X){if(!(Q&&X))return;let Y=new Date("2020-01-01T"+Q).valueOf(),J=new Date("2020-01-01T"+X).valueOf();if(!(Y&&J))return;return Y-J}function TK(Q,X){if(!(Q&&X))return;let Y=eX.exec(Q),J=eX.exec(X);if(!(Y&&J))return;if(Q=Y[1]+Y[2]+Y[3],X=J[1]+J[2]+J[3],Q>X)return 1;if(Q<X)return-1;return 0}var XY=/t|\s/i;function PK(Q){let X=QY(Q);return function(J){let W=J.split(XY);return W.length===2&&bK(W[0])&&X(W[1])}}function RK(Q,X){if(!(Q&&X))return;let Y=new Date(Q).valueOf(),J=new Date(X).valueOf();if(!(Y&&J))return;return Y-J}function EK(Q,X){if(!(Q&&X))return;let[Y,J]=Q.split(XY),[W,$]=X.split(XY),B=YY(Y,W);if(B===void 0)return;return B||JY(J,$)}var RP=/\/|:/,EP=/^(?:[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 SP(Q){return RP.test(Q)&&EP.test(Q)}var jK=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function CP(Q){return jK.lastIndex=0,jK.test(Q)}var kP=-2147483648,_P=2147483647;function xP(Q){return Number.isInteger(Q)&&Q<=_P&&Q>=kP}function vP(Q){return Number.isInteger(Q)}function IK(){return!0}var yP=/[^\\]\\Z/;function gP(Q){if(yP.test(Q))return!1;try{return new RegExp(Q),!0}catch(X){return!1}}});var xK=w((_K)=>{Object.defineProperty(_K,"__esModule",{value:!0});_K.formatLimitDefinition=void 0;var hP=sX(),p0=x(),j1=p0.operators,tQ={formatMaximum:{okStr:"<=",ok:j1.LTE,fail:j1.GT},formatMinimum:{okStr:">=",ok:j1.GTE,fail:j1.LT},formatExclusiveMaximum:{okStr:"<",ok:j1.LT,fail:j1.GTE},formatExclusiveMinimum:{okStr:">",ok:j1.GT,fail:j1.LTE}},uP={message:({keyword:Q,schemaCode:X})=>p0.str`should be ${tQ[Q].okStr} ${X}`,params:({keyword:Q,schemaCode:X})=>p0._`{comparison: ${tQ[Q].okStr}, limit: ${X}}`};_K.formatLimitDefinition={keyword:Object.keys(tQ),type:"string",schemaType:"string",$data:!0,error:uP,code(Q){let{gen:X,data:Y,schemaCode:J,keyword:W,it:$}=Q,{opts:B,self:G}=$;if(!B.validateFormats)return;let K=new hP.KeywordCxt($,G.RULES.all.format.definition,"format");if(K.$data)H();else Z();function H(){let V=X.scopeValue("formats",{ref:G.formats,code:B.code.formats}),D=X.const("fmt",p0._`${V}[${K.schemaCode}]`);Q.fail$data((0,p0.or)(p0._`typeof ${D} != "object"`,p0._`${D} instanceof RegExp`,p0._`typeof ${D}.compare != "function"`,L(D)))}function Z(){let V=K.schema,D=G.formats[V];if(!D||D===!0)return;if(typeof D!="object"||D instanceof RegExp||typeof D.compare!="function")throw Error(`"${W}": format "${V}" does not define "compare" function`);let z=X.scopeValue("formats",{key:V,ref:D,code:B.code.formats?p0._`${B.code.formats}${(0,p0.getProperty)(V)}`:void 0});Q.fail$data(L(z))}function L(V){return p0._`${V}.compare(${Y}, ${J}) ${tQ[W].fail} 0`}},dependencies:["format"]};var mP=(Q)=>{return Q.addKeyword(_K.formatLimitDefinition),Q};_K.default=mP});var fK=w((w8,gK)=>{Object.defineProperty(w8,"__esModule",{value:!0});var D9=kK(),cP=xK(),BY=x(),vK=new BY.Name("fullFormats"),pP=new BY.Name("fastFormats"),GY=(Q,X={keywords:!0})=>{if(Array.isArray(X))return yK(Q,X,D9.fullFormats,vK),Q;let[Y,J]=X.mode==="fast"?[D9.fastFormats,pP]:[D9.fullFormats,vK],W=X.formats||D9.formatNames;if(yK(Q,W,Y,J),X.keywords)(0,cP.default)(Q);return Q};GY.get=(Q,X="full")=>{let J=(X==="fast"?D9.fastFormats:D9.fullFormats)[Q];if(!J)throw Error(`Unknown format "${Q}"`);return J};function yK(Q,X,Y,J){var W,$;(W=($=Q.opts.code).formats)!==null&&W!==void 0||($.formats=BY._`require("ajv-formats/dist/formats").${J}`);for(let B of X)Q.addFormat(B,Y[B])}gK.exports=w8=GY;Object.defineProperty(w8,"__esModule",{value:!0});w8.default=GY});var DZ=w((T_,VZ)=>{VZ.exports=LZ;LZ.sync=wj;var KZ=o0("fs");function Mj(Q,X){var Y=X.pathExt!==void 0?X.pathExt:process.env.PATHEXT;if(!Y)return!0;if(Y=Y.split(";"),Y.indexOf("")!==-1)return!0;for(var J=0;J<Y.length;J++){var W=Y[J].toLowerCase();if(W&&Q.substr(-W.length).toLowerCase()===W)return!0}return!1}function ZZ(Q,X,Y){if(!Q.isSymbolicLink()&&!Q.isFile())return!1;return Mj(X,Y)}function LZ(Q,X,Y){KZ.stat(Q,function(J,W){Y(J,J?!1:ZZ(W,Q,X))})}function wj(Q,X){return ZZ(KZ.statSync(Q),Q,X)}});var OZ=w((R_,AZ)=>{AZ.exports=zZ;zZ.sync=Pj;var qZ=o0("fs");function zZ(Q,X,Y){qZ.stat(Q,function(J,W){Y(J,J?!1:FZ(W,X))})}function Pj(Q,X){return FZ(qZ.statSync(Q),X)}function FZ(Q,X){return Q.isFile()&&jj(Q,X)}function jj(Q,X){var{mode:Y,uid:J,gid:W}=Q,$=X.uid!==void 0?X.uid:process.getuid&&process.getuid(),B=X.gid!==void 0?X.gid:process.getgid&&process.getgid(),G=parseInt("100",8),K=parseInt("010",8),H=parseInt("001",8),Z=G|K,L=Y&H||Y&K&&W===B||Y&G&&J===$||Y&Z&&$===0;return L}});var UZ=w((S_,NZ)=>{var E_=o0("fs"),z6;if(process.platform==="win32"||global.TESTING_WINDOWS)z6=DZ();else z6=OZ();NZ.exports=kY;kY.sync=Ij;function kY(Q,X,Y){if(typeof X==="function")Y=X,X={};if(!Y){if(typeof Promise!=="function")throw TypeError("callback not provided");return new Promise(function(J,W){kY(Q,X||{},function($,B){if($)W($);else J(B)})})}z6(Q,X||{},function(J,W){if(J){if(J.code==="EACCES"||X&&X.ignoreErrors)J=null,W=!1}Y(J,W)})}function Ij(Q,X){try{return z6.sync(Q,X||{})}catch(Y){if(X&&X.ignoreErrors||Y.code==="EACCES")return!1;else throw Y}}});var TZ=w((C_,bZ)=>{var b9=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",MZ=o0("path"),bj=b9?";":":",wZ=UZ(),PZ=(Q)=>Object.assign(Error(`not found: ${Q}`),{code:"ENOENT"}),jZ=(Q,X)=>{let Y=X.colon||bj,J=Q.match(/\//)||b9&&Q.match(/\\/)?[""]:[...b9?[process.cwd()]:[],...(X.path||process.env.PATH||"").split(Y)],W=b9?X.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",$=b9?W.split(Y):[""];if(b9){if(Q.indexOf(".")!==-1&&$[0]!=="")$.unshift("")}return{pathEnv:J,pathExt:$,pathExtExe:W}},IZ=(Q,X,Y)=>{if(typeof X==="function")Y=X,X={};if(!X)X={};let{pathEnv:J,pathExt:W,pathExtExe:$}=jZ(Q,X),B=[],G=(H)=>new Promise((Z,L)=>{if(H===J.length)return X.all&&B.length?Z(B):L(PZ(Q));let V=J[H],D=/^".*"$/.test(V)?V.slice(1,-1):V,z=MZ.join(D,Q),A=!D&&/^\.[\\\/]/.test(Q)?Q.slice(0,2)+z:z;Z(K(A,H,0))}),K=(H,Z,L)=>new Promise((V,D)=>{if(L===W.length)return V(G(Z+1));let z=W[L];wZ(H+z,{pathExt:$},(A,N)=>{if(!A&&N)if(X.all)B.push(H+z);else return V(H+z);return V(K(H,Z,L+1))})});return Y?G(0).then((H)=>Y(null,H),Y):G(0)},Tj=(Q,X)=>{X=X||{};let{pathEnv:Y,pathExt:J,pathExtExe:W}=jZ(Q,X),$=[];for(let B=0;B<Y.length;B++){let G=Y[B],K=/^".*"$/.test(G)?G.slice(1,-1):G,H=MZ.join(K,Q),Z=!K&&/^\.[\\\/]/.test(Q)?Q.slice(0,2)+H:H;for(let L=0;L<J.length;L++){let V=Z+J[L];try{if(wZ.sync(V,{pathExt:W}))if(X.all)$.push(V);else return V}catch(D){}}}if(X.all&&$.length)return $;if(X.nothrow)return null;throw PZ(Q)};bZ.exports=IZ;IZ.sync=Tj});var EZ=w((k_,_Y)=>{var RZ=(Q={})=>{let X=Q.env||process.env;if((Q.platform||process.platform)!=="win32")return"PATH";return Object.keys(X).reverse().find((J)=>J.toUpperCase()==="PATH")||"Path"};_Y.exports=RZ;_Y.exports.default=RZ});var _Z=w((__,kZ)=>{var SZ=o0("path"),Rj=TZ(),Ej=EZ();function CZ(Q,X){let Y=Q.options.env||process.env,J=process.cwd(),W=Q.options.cwd!=null,$=W&&process.chdir!==void 0&&!process.chdir.disabled;if($)try{process.chdir(Q.options.cwd)}catch(G){}let B;try{B=Rj.sync(Q.command,{path:Y[Ej({env:Y})],pathExt:X?SZ.delimiter:void 0})}catch(G){}finally{if($)process.chdir(J)}if(B)B=SZ.resolve(W?Q.options.cwd:"",B);return B}function Sj(Q){return CZ(Q)||CZ(Q,!0)}kZ.exports=Sj});var xZ=w((_j,vY)=>{var xY=/([()\][%!^"`<>&|;, *?])/g;function Cj(Q){return Q=Q.replace(xY,"^$1"),Q}function kj(Q,X){if(Q=`${Q}`,Q=Q.replace(/(?=(\\+?)?)\1"/g,"$1$1\\\""),Q=Q.replace(/(?=(\\+?)?)\1$/,"$1$1"),Q=`"${Q}"`,Q=Q.replace(xY,"^$1"),X)Q=Q.replace(xY,"^$1");return Q}_j.command=Cj;_j.argument=kj});var yZ=w((x_,vZ)=>{vZ.exports=/^#!(.*)/});var fZ=w((v_,gZ)=>{var yj=yZ();gZ.exports=(Q="")=>{let X=Q.match(yj);if(!X)return null;let[Y,J]=X[0].replace(/#! ?/,"").split(" "),W=Y.split("/").pop();if(W==="env")return J;return J?`${W} ${J}`:W}});var uZ=w((y_,hZ)=>{var yY=o0("fs"),gj=fZ();function fj(Q){let Y=Buffer.alloc(150),J;try{J=yY.openSync(Q,"r"),yY.readSync(J,Y,0,150,0),yY.closeSync(J)}catch(W){}return gj(Y.toString())}hZ.exports=fj});var pZ=w((g_,cZ)=>{var hj=o0("path"),mZ=_Z(),lZ=xZ(),uj=uZ(),mj=process.platform==="win32",lj=/\.(?:com|exe)$/i,cj=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function pj(Q){Q.file=mZ(Q);let X=Q.file&&uj(Q.file);if(X)return Q.args.unshift(Q.file),Q.command=X,mZ(Q);return Q.file}function dj(Q){if(!mj)return Q;let X=pj(Q),Y=!lj.test(X);if(Q.options.forceShell||Y){let J=cj.test(X);Q.command=hj.normalize(Q.command),Q.command=lZ.command(Q.command),Q.args=Q.args.map(($)=>lZ.argument($,J));let W=[Q.command].concat(Q.args).join(" ");Q.args=["/d","/s","/c",`"${W}"`],Q.command=process.env.comspec||"cmd.exe",Q.options.windowsVerbatimArguments=!0}return Q}function ij(Q,X,Y){if(X&&!Array.isArray(X))Y=X,X=null;X=X?X.slice(0):[],Y=Object.assign({},Y);let J={command:Q,args:X,options:Y,file:void 0,original:{command:Q,args:X}};return Y.shell?J:dj(J)}cZ.exports=ij});var nZ=w((f_,iZ)=>{var gY=process.platform==="win32";function fY(Q,X){return Object.assign(Error(`${X} ${Q.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${X} ${Q.command}`,path:Q.command,spawnargs:Q.args})}function nj(Q,X){if(!gY)return;let Y=Q.emit;Q.emit=function(J,W){if(J==="exit"){let $=dZ(W,X);if($)return Y.call(Q,"error",$)}return Y.apply(Q,arguments)}}function dZ(Q,X){if(gY&&Q===1&&!X.file)return fY(X.original,"spawn");return null}function oj(Q,X){if(gY&&Q===1&&!X.file)return fY(X.original,"spawnSync");return null}iZ.exports={hookChildProcess:nj,verifyENOENT:dZ,verifyENOENTSync:oj,notFoundError:fY}});var tZ=w((h_,T9)=>{var oZ=o0("child_process"),hY=pZ(),uY=nZ();function rZ(Q,X,Y){let J=hY(Q,X,Y),W=oZ.spawn(J.command,J.args,J.options);return uY.hookChildProcess(W,J),W}function rj(Q,X,Y){let J=hY(Q,X,Y),W=oZ.spawnSync(J.command,J.args,J.options);return W.error=W.error||uY.verifyENOENTSync(W.status,J),W}T9.exports=rZ;T9.exports.spawn=rZ;T9.exports.sync=rj;T9.exports._parse=hY;T9.exports._enoent=uY});import{logger as wI}from"@hermes/logger";function TL(Q){let X=Q.access_token_expires_at?Q.access_token_expires_at.seconds*1000+Math.floor(Q.access_token_expires_at.nanos/1e6):void 0;return{accessToken:Q.access_token,refreshToken:Q.refresh_token,expiresAt:X,tokenType:Q.token_type,scope:Q.scope,serverMetadata:{issuer:Q.issuer??Q.authorization_endpoint,authorization_endpoint:Q.authorization_endpoint,token_endpoint:Q.token_endpoint},client:{client_id:Q.client_id,client_secret:Q.client_secret}}}function XJ(Q,X){let Y=[];for(let[J,W]of Object.entries(X))Q.set(J,TL(W)),Y.push(J);return Y}var b6=["list"];function RL(Q){return Q.config.registrySource??"local"}function EL(Q){let X=Q.status,Y=RL(Q);if(X==="auth_required")return`${Q.name} [${Y}] — auth_required (needs authentication)`;let J=Q.tools.length,W=`${Q.name} [${Y}] — ${X} (${J} tool${J===1?"":"s"})`;if(X==="failed"&&Q.lastError)return`${W}
|
|
9
|
+
error: ${Q.lastError}`;return W}function SL(Q){return` ! ${Q.server?`${Q.server}: `:""}${Q.message}`}function CL(Q){let X=[];if(Q.servers.size===0)X.push("No MCP servers configured."),X.push("Add servers under the 'mcpServers' key in ~/.pi/settings.json or <cwd>/.pi/settings.json.");else{X.push(`MCP servers (${Q.servers.size}):`);for(let Y of Q.servers.values())X.push(` • ${EL(Y)}`)}if(Q.diagnostics.length>0){X.push(""),X.push("Diagnostics:");for(let Y of Q.diagnostics)X.push(SL(Y))}return X.join(`
|
|
10
|
+
`)}function kL(Q){let X=Q.trim().split(/\s+/)[0];if(!X)return"list";if(b6.includes(X))return X;return}function YJ(Q,X){Q.registerCommand("mcp",{description:"List configured MCP servers and their status",getArgumentCompletions:(Y)=>{let J=Y.trim().toLowerCase();return b6.filter((W)=>W.startsWith(J)).map((W)=>({value:W}))},handler:async(Y,J)=>{let W=kL(Y);if(!W){J.ui.notify(`Unknown /mcp subcommand. Available: ${b6.join(", ")}.`,"warning");return}switch(W){case"list":{J.ui.notify(CL(X),"info");return}default:return W}}})}import{readFileSync as cL}from"node:fs";import{join as KJ}from"node:path";import{CONFIG_DIR_NAME as pL}from"@augmentcode/auggie-v2";import{homedir as JJ}from"node:os";import{sep as _L}from"node:path";class $J extends Error{variableName;constructor(Q){super(`Missing environment variable "${Q}"`);this.name="EnvVariableExpansionError",this.variableName=Q}}var xL=/(?<!\\)\$\{([a-zA-Z_][a-zA-Z0-9_]*)(?::-([\s\S]*?))?\}/g,vL=/\\\$\{/g,yL=new Set(["workspaceFolder","augmentToken"]),WJ="${workspaceFolder}";function BJ(Q,X){if(!Q.includes(WJ))return Q;return Q.split(WJ).join(X)}function GJ(Q,X){if(!Q.includes("${"))return Q;return Q.replace(xL,(J,W,$)=>{if(yL.has(W))return J;let B=X[W];if(B!==void 0)return B;if($!==void 0)return $;throw new $J(W)}).replace(vL,"${")}function gL(Q){if(!Q.startsWith("~"))return Q;if(Q==="~")return JJ();if(Q.startsWith("~/")||Q.startsWith(`~${_L}`))return JJ()+Q.slice(1);return Q}function T6(Q,X,Y){return gL(GJ(BJ(Q,X),Y))}function C8(Q,X,Y){return GJ(BJ(Q,X),Y)}function HJ(Q,X,Y){let J={};for(let[W,$]of Object.entries(Q))J[W]=C8($,X,Y);return J}var fL="$augment-";function hL(Q,X,Y){if(!Q)return;let J={};for(let[W,$]of Object.entries(Q))J[W]=$.startsWith(fL)?$:C8($,X,Y);return J}function k8(Q,X){let Y=process.env;return{...Q,url:C8(Q.url,X,Y),headers:hL(Q.headers,X,Y)}}function _8(Q,X){let Y=process.env;return{...Q,command:T6(Q.command,X,Y),args:Q.args,env:Q.env?HJ(Q.env,X,Y):void 0,cwd:Q.cwd?T6(Q.cwd,X,Y):X}}import{logger as uL}from"@hermes/logger";var mL=uL.child({prefix:"pi-mcp"});class K1 extends Error{constructor(Q){super(Q);this.name="McpConfigError"}}function R6(Q){if(Q.type==="stdio"||Q.type==="http"||Q.type==="sse")return Q.type;if(Q.url)return"http";if(Q.command)return"stdio";return}function lL(Q){if(!Q)return;let X={};for(let[Y,J]of Object.entries(Q)){if(J===null||J===void 0)continue;X[Y]=String(J)}return Object.keys(X).length>0?X:void 0}function x8(Q,X){let Y=R6(X);if(!Y)throw new K1(`MCP server "${Q}" must declare a 'command' (stdio) or 'url' (http/sse) property`);if(Y==="http"||Y==="sse"){if(!X.url)throw new K1(`MCP server "${Q}" has type "${Y}" but no 'url' property`);return{type:Y,name:X.name??Q,disabled:X.disabled,url:X.url,headers:X.headers,auth:X.auth==="oauth"?"oauth":void 0,timeoutMs:X.timeoutMs}}let J=X.command;if(!J)throw new K1(`MCP server "${Q}" has type "stdio" but no 'command' property`);let W=(X.args??[]).map((G)=>String(G)),$=W.length>0?`${J} ${W.join(" ")}`:J,B=X.name??Q;if(X.useShellInterpolation===!1)mL.warn(`MCP server "${B}": useShellInterpolation:false is ignored; settings.json stdio servers always shell-wrap in Wave 1 (V1 json.ts parity)`);return{type:"stdio",name:B,disabled:X.disabled,command:$,args:[],env:lL(X.env),cwd:X.cwd,timeoutMs:X.timeoutMs,useShellInterpolation:!0}}function ZJ(Q,X,Y){let J;try{J=cL(Q,"utf-8")}catch(W){if(W?.code==="ENOENT")return{};return Y.push({message:`Failed to read ${X} settings.json (${Q}): ${W instanceof Error?W.message:String(W)}`}),{}}try{let W=JSON.parse(J);if(W&&typeof W==="object")return W;return Y.push({message:`${X} settings.json (${Q}) does not parse to an object`}),{}}catch(W){return Y.push({message:`Failed to parse ${X} settings.json (${Q}): ${W instanceof Error?W.message:String(W)}`}),{}}}function dL(Q,X){let Y={};if(Q){for(let[J,W]of Object.entries(Q))if(W)Y[J]=W}if(X)for(let[J,W]of Object.entries(X)){if(W===null){delete Y[J];continue}if(W)Y[J]=W}return Y}function LJ(Q,X){let Y=[],J=KJ(X,"settings.json"),W=KJ(Q,pL,"settings.json"),$=ZJ(J,"global",Y),B=ZJ(W,"project",Y),G=dL($.mcpServers,B.mcpServers),K=[];for(let[H,Z]of Object.entries(G))try{let L=x8(H,Z);K.push(L.type==="stdio"?_8(L,Q):k8(L,Q))}catch(L){let V=L instanceof K1?L.message:`Failed to normalize MCP server "${H}": ${L instanceof Error?L.message:String(L)}`;Y.push({server:H,message:V})}return{servers:K,diagnostics:Y}}import{logger as sL}from"@hermes/logger";import{Type as eL}from"@sinclair/typebox";class E6{_tokens=new Map;_authRequired=new Set;get(Q){return this._tokens.get(Q)}set(Q,X){this._tokens.set(Q,X),this._authRequired.delete(Q)}delete(Q){this._tokens.delete(Q)}markAuthRequired(Q){this._authRequired.add(Q)}isAuthRequired(Q){return this._authRequired.has(Q)}clearAuthRequired(Q){this._authRequired.delete(Q)}}var S6=Symbol.for("__pi_mcp_state__");function G0(){let Q=globalThis;if(Q[S6])return Q[S6];let X={servers:new Map,tokens:new E6,refreshes:new Map,credsListenerBound:!1,configIdsListenerBound:!1,registryGeneration:0,credentials:void 0,secretsClient:void 0,workspaceRoot:void 0,connectStarted:!1,diagnostics:[],currentLoad:void 0};return Q[S6]=X,X}function iL(Q){if(Q&&typeof Q==="object"&&!Array.isArray(Q))return Q;return}function nL(Q){let X=[];for(let Y of Q)if(Y.type==="text")X.push({type:"text",text:Y.text});else X.push({type:"image",mimeType:Y.mimeType,data:Y.data});return X}function oL(Q){let X=[];for(let Y of Q)if(Y.type==="text")X.push(Y.text);return X.join(`
|
|
11
|
+
`).trim()}function rL(Q,X,Y){if(Q.isError){let $=oL(Q.content);throw Error($||`MCP tool "${X}/${Y}" reported an error`)}let J=nL(Q.content);return{content:J.length>0?J:[{type:"text",text:""}],details:void 0}}async function VJ(Q){let X=Q.getHost();if(!X||X.status!=="success")throw Error(`MCP server "${Q.serverName}" is not available (status: ${X?.status??"unknown"})`);let Y=Q.map.resolve(Q.namespaced),J=iL(Q.params),W=await X.callTool(Y,J,Q.signal);return rL(W,Q.serverName,Y)}var tL=/[^a-zA-Z0-9_-]/g;function C6(Q){return Q.replace(tL,"_")}function aL(Q,X){let Y=C6(X),J=C6(Q),W=`${Y}_${J}`;if(W.length<=64)return W;return W.slice(0,64)}class k6{_serverName;_map=new Map;constructor(Q){this._serverName=Q}put(Q){let X=aL(this._serverName,Q),Y=this._map.get(X),J=Y!==void 0&&Y!==Q;if(Y===void 0)this._map.set(X,Q);return{namespaced:X,collision:J}}resolve(Q){let X=this._map.get(Q);if(X)return X;let Y=`_${C6(this._serverName)}`;if(Q.endsWith(Y))return Q.slice(0,Q.length-Y.length);return Q}}var _6=sL.child({prefix:"pi-mcp"}),DJ=new Map;function QV(Q){let X=DJ.get(Q);if(!X)X=new k6(Q),DJ.set(Q,X);return X}function v8(Q,X){let Y=QV(X.name),J=X.name,W=()=>G0().servers.get(J),$=0;for(let B of X.listTools()){let{namespaced:G,collision:K}=Y.put(B.name);if(K){let L=Y.resolve(G),V=`Tool name collision detected in MCP server "${J}": "${B.name}" and "${L}" both map to "${G}". Only the first tool will be available.`,D=G0();if(!D.diagnostics.some((A)=>A.server===J&&A.message.includes(`both map to "${G}"`)))_6.warn(V),D.diagnostics.push({server:J,message:V});continue}let H;try{H=eL.Unsafe(B.inputSchema??{})}catch(L){_6.warn(`Skipping MCP tool "${J}/${B.name}": invalid input schema (${L instanceof Error?L.message:String(L)})`);continue}let Z={name:G,label:B.name,description:B.description??"",parameters:H,execute:(L,V,D,z,A)=>VJ({serverName:J,namespaced:G,map:Y,getHost:W,params:V,signal:D})};Q.registerTool(Z),$+=1}if($>0)_6.info(`Registered ${$} MCP tool(s) from server "${J}"`)}function qJ(Q,X){for(let Y of X.servers.values())if(Y.status==="success"&&Y.config.registrySource===void 0)v8(Q,Y)}import{logger as QI}from"@hermes/logger";function zJ(Q,X=Date.now()){return Q.expiresAt!==void 0&&X+20000>=Q.expiresAt}function FJ(Q,X=Date.now()){return Q.expiresAt!==void 0&&Q.expiresAt<=X}async function AJ(Q){if(!Q.refreshToken)throw Error("No refresh token available");let X=new URLSearchParams({grant_type:"refresh_token",refresh_token:Q.refreshToken,client_id:Q.client.client_id});if(Q.client.client_secret)X.set("client_secret",Q.client.client_secret);let Y=await fetch(Q.serverMetadata.token_endpoint,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:X.toString(),signal:AbortSignal.timeout(1e4)});if(!Y.ok){let W=(await Y.text().catch(()=>"")).slice(0,500);throw Error(`Token refresh failed: ${Y.status} ${Y.statusText}${W?` — ${W}`:""}`)}let J=await Y.json();return{accessToken:J.access_token,refreshToken:J.refresh_token||Q.refreshToken,expiresAt:J.expires_in?Date.now()+J.expires_in*1000:void 0,tokenType:J.token_type??Q.tokenType,scope:J.scope??Q.scope,serverMetadata:Q.serverMetadata,client:Q.client}}import{logger as XV}from"@hermes/logger";var y8=XV.child({prefix:"pi-mcp"}),YV="$augment-",OJ=/\$augment-[a-zA-Z0-9_.-]+/g,JV=new RegExp(OJ.source);function g8(Q){return JV.test(Q)}function WV(Q){return Q.slice(YV.length)}async function $V(Q,X,Y){let J=[...Q.matchAll(OJ)];if(J.length===0)return Q;let W=Q;for(let $=J.length-1;$>=0;$--){let B=J[$],G=B[0],K=B.index,H=WV(G);try{let Z=await Y(H);if(Z===void 0){y8.warn(`Secret "${H}" not found for "${X}"; leaving reference as-is`);continue}W=W.slice(0,K)+Z+W.slice(K+G.length),y8.debug(`Resolved secret reference for "${X}"`)}catch(Z){let L=Z instanceof Error?Z.message:String(Z);y8.error(`Failed to resolve secret "${H}" for "${X}": ${L}; leaving reference as-is`)}}return W}async function NJ({configEnv:Q,localEnv:X,getSecret:Y}){let J={};for(let[W,$]of Object.entries(Q)){if(!g8($)){J[W]=$;continue}if(W in X){y8.debug(`"${W}" references a secret but is already set in the local environment; using local value`),J[W]=X[W];continue}J[W]=await $V($,W,Y)}return J}var UJ,x6=Object.freeze({status:"aborted"});function O(Q,X,Y){function J(G,K){if(!G._zod)Object.defineProperty(G,"_zod",{value:{def:K,constr:B,traits:new Set},enumerable:!1});if(G._zod.traits.has(Q))return;G._zod.traits.add(Q),X(G,K);let H=B.prototype,Z=Object.keys(H);for(let L=0;L<Z.length;L++){let V=Z[L];if(!(V in G))G[V]=H[V].bind(G)}}let W=Y?.Parent??Object;class $ extends W{}Object.defineProperty($,"name",{value:Q});function B(G){var K;let H=Y?.Parent?new $:this;J(H,G),(K=H._zod).deferred??(K.deferred=[]);for(let Z of H._zod.deferred)Z();return H}return Object.defineProperty(B,"init",{value:J}),Object.defineProperty(B,Symbol.hasInstance,{value:(G)=>{if(Y?.Parent&&G instanceof Y.Parent)return!0;return G?._zod?.traits?.has(Q)}}),Object.defineProperty(B,"name",{value:Q}),B}var BV=Symbol("zod_brand");class r0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class S9 extends Error{constructor(Q){super(`Encountered unidirectional transform during encode: ${Q}`);this.name="ZodEncodeError"}}(UJ=globalThis).__zod_globalConfig??(UJ.__zod_globalConfig={});var c1=globalThis.__zod_globalConfig;function N0(Q){if(Q)Object.assign(c1,Q);return c1}var y={};I6(y,{unwrapMessage:()=>C9,uint8ArrayToHex:()=>CV,uint8ArrayToBase64url:()=>EV,uint8ArrayToBase64:()=>TJ,stringifyPrimitive:()=>m8,slugify:()=>g6,shallowClone:()=>wJ,safeExtend:()=>PV,required:()=>bV,randomString:()=>FV,propertyKeyTypes:()=>h6,promiseAllObject:()=>zV,primitiveTypes:()=>PJ,prefixIssues:()=>s0,pick:()=>UV,partial:()=>IV,parsedType:()=>c6,optionalKeys:()=>u6,omit:()=>MV,objectClone:()=>VV,numKeys:()=>AV,nullish:()=>_9,normalizeParams:()=>E,mergeDefs:()=>t0,merge:()=>jV,jsonStringifyReplacer:()=>p1,joinValues:()=>f8,issue:()=>i1,isPlainObject:()=>L1,isObject:()=>R1,hexToUint8Array:()=>SV,getSizableOrigin:()=>IJ,getParsedType:()=>OV,getLengthableOrigin:()=>v9,getEnumValues:()=>k9,getElementAtPath:()=>qV,floatSafeRemainder:()=>y6,finalizeIssue:()=>C0,extend:()=>wV,explicitlyAborted:()=>l6,escapeRegex:()=>a0,esc:()=>h8,defineLazy:()=>m,createTransparentProxy:()=>NV,cloneDef:()=>DV,clone:()=>S0,cleanRegex:()=>x9,cleanEnum:()=>TV,captureStackTrace:()=>u8,cached:()=>d1,base64urlToUint8Array:()=>RV,base64ToUint8Array:()=>bJ,assignProp:()=>Z1,assertNotEqual:()=>HV,assertNever:()=>ZV,assertIs:()=>KV,assertEqual:()=>GV,assert:()=>LV,allowsEval:()=>f6,aborted:()=>V1,NUMBER_FORMAT_RANGES:()=>m6,Class:()=>RJ,BIGINT_FORMAT_RANGES:()=>jJ});function GV(Q){return Q}function HV(Q){return Q}function KV(Q){}function ZV(Q){throw Error("Unexpected value in exhaustive check")}function LV(Q){}function k9(Q){let X=Object.values(Q).filter((J)=>typeof J==="number");return Object.entries(Q).filter(([J,W])=>X.indexOf(+J)===-1).map(([J,W])=>W)}function f8(Q,X="|"){return Q.map((Y)=>m8(Y)).join(X)}function p1(Q,X){if(typeof X==="bigint")return X.toString();return X}function d1(Q){return{get value(){{let Y=Q();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function _9(Q){return Q===null||Q===void 0}function x9(Q){let X=Q.startsWith("^")?1:0,Y=Q.endsWith("$")?Q.length-1:Q.length;return Q.slice(X,Y)}function y6(Q,X){let Y=Q/X,J=Math.round(Y),W=Number.EPSILON*Math.max(Math.abs(Y),1);if(Math.abs(Y-J)<W)return 0;return Y-J}var MJ=Symbol("evaluating");function m(Q,X,Y){let J=void 0;Object.defineProperty(Q,X,{get(){if(J===MJ)return;if(J===void 0)J=MJ,J=Y();return J},set(W){Object.defineProperty(Q,X,{value:W})},configurable:!0})}function VV(Q){return Object.create(Object.getPrototypeOf(Q),Object.getOwnPropertyDescriptors(Q))}function Z1(Q,X,Y){Object.defineProperty(Q,X,{value:Y,writable:!0,enumerable:!0,configurable:!0})}function t0(...Q){let X={};for(let Y of Q){let J=Object.getOwnPropertyDescriptors(Y);Object.assign(X,J)}return Object.defineProperties({},X)}function DV(Q){return t0(Q._zod.def)}function qV(Q,X){if(!X)return Q;return X.reduce((Y,J)=>Y?.[J],Q)}function zV(Q){let X=Object.keys(Q),Y=X.map((J)=>Q[J]);return Promise.all(Y).then((J)=>{let W={};for(let $=0;$<X.length;$++)W[X[$]]=J[$];return W})}function FV(Q=10){let Y="";for(let J=0;J<Q;J++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function h8(Q){return JSON.stringify(Q)}function g6(Q){return Q.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var u8="captureStackTrace"in Error?Error.captureStackTrace:(...Q)=>{};function R1(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}var f6=d1(()=>{if(c1.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(Q){return!1}});function L1(Q){if(R1(Q)===!1)return!1;let X=Q.constructor;if(X===void 0)return!0;if(typeof X!=="function")return!0;let Y=X.prototype;if(R1(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function wJ(Q){if(L1(Q))return{...Q};if(Array.isArray(Q))return[...Q];if(Q instanceof Map)return new Map(Q);if(Q instanceof Set)return new Set(Q);return Q}function AV(Q){let X=0;for(let Y in Q)if(Object.prototype.hasOwnProperty.call(Q,Y))X++;return X}var OV=(Q)=>{let X=typeof Q;switch(X){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(Q)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Q.then&&typeof Q.then==="function"&&Q.catch&&typeof Q.catch==="function")return"promise";if(typeof Map<"u"&&Q instanceof Map)return"map";if(typeof Set<"u"&&Q instanceof Set)return"set";if(typeof Date<"u"&&Q instanceof Date)return"date";if(typeof File<"u"&&Q instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${X}`)}},h6=new Set(["string","number","symbol"]),PJ=new Set(["string","number","bigint","boolean","symbol","undefined"]);function a0(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S0(Q,X,Y){let J=new Q._zod.constr(X??Q._zod.def);if(!X||Y?.parent)J._zod.parent=Q;return J}function E(Q){let X=Q;if(!X)return{};if(typeof X==="string")return{error:()=>X};if(X?.message!==void 0){if(X?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");X.error=X.message}if(delete X.message,typeof X.error==="string")return{...X,error:()=>X.error};return X}function NV(Q){let X;return new Proxy({},{get(Y,J,W){return X??(X=Q()),Reflect.get(X,J,W)},set(Y,J,W,$){return X??(X=Q()),Reflect.set(X,J,W,$)},has(Y,J){return X??(X=Q()),Reflect.has(X,J)},deleteProperty(Y,J){return X??(X=Q()),Reflect.deleteProperty(X,J)},ownKeys(Y){return X??(X=Q()),Reflect.ownKeys(X)},getOwnPropertyDescriptor(Y,J){return X??(X=Q()),Reflect.getOwnPropertyDescriptor(X,J)},defineProperty(Y,J,W){return X??(X=Q()),Reflect.defineProperty(X,J,W)}})}function m8(Q){if(typeof Q==="bigint")return Q.toString()+"n";if(typeof Q==="string")return`"${Q}"`;return`${Q}`}function u6(Q){return Object.keys(Q).filter((X)=>{return Q[X]._zod.optin==="optional"&&Q[X]._zod.optout==="optional"})}var m6={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},jJ={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function UV(Q,X){let Y=Q._zod.def,J=Y.checks;if(J&&J.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let $=t0(Q._zod.def,{get shape(){let B={};for(let G in X){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!X[G])continue;B[G]=Y.shape[G]}return Z1(this,"shape",B),B},checks:[]});return S0(Q,$)}function MV(Q,X){let Y=Q._zod.def,J=Y.checks;if(J&&J.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let $=t0(Q._zod.def,{get shape(){let B={...Q._zod.def.shape};for(let G in X){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!X[G])continue;delete B[G]}return Z1(this,"shape",B),B},checks:[]});return S0(Q,$)}function wV(Q,X){if(!L1(X))throw Error("Invalid input to extend: expected a plain object");let Y=Q._zod.def.checks;if(Y&&Y.length>0){let $=Q._zod.def.shape;for(let B in X)if(Object.getOwnPropertyDescriptor($,B)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let W=t0(Q._zod.def,{get shape(){let $={...Q._zod.def.shape,...X};return Z1(this,"shape",$),$}});return S0(Q,W)}function PV(Q,X){if(!L1(X))throw Error("Invalid input to safeExtend: expected a plain object");let Y=t0(Q._zod.def,{get shape(){let J={...Q._zod.def.shape,...X};return Z1(this,"shape",J),J}});return S0(Q,Y)}function jV(Q,X){if(Q._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let Y=t0(Q._zod.def,{get shape(){let J={...Q._zod.def.shape,...X._zod.def.shape};return Z1(this,"shape",J),J},get catchall(){return X._zod.def.catchall},checks:X._zod.def.checks??[]});return S0(Q,Y)}function IV(Q,X,Y){let W=X._zod.def.checks;if(W&&W.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let B=t0(X._zod.def,{get shape(){let G=X._zod.def.shape,K={...G};if(Y)for(let H in Y){if(!(H in G))throw Error(`Unrecognized key: "${H}"`);if(!Y[H])continue;K[H]=Q?new Q({type:"optional",innerType:G[H]}):G[H]}else for(let H in G)K[H]=Q?new Q({type:"optional",innerType:G[H]}):G[H];return Z1(this,"shape",K),K},checks:[]});return S0(X,B)}function bV(Q,X,Y){let J=t0(X._zod.def,{get shape(){let W=X._zod.def.shape,$={...W};if(Y)for(let B in Y){if(!(B in $))throw Error(`Unrecognized key: "${B}"`);if(!Y[B])continue;$[B]=new Q({type:"nonoptional",innerType:W[B]})}else for(let B in W)$[B]=new Q({type:"nonoptional",innerType:W[B]});return Z1(this,"shape",$),$}});return S0(X,J)}function V1(Q,X=0){if(Q.aborted===!0)return!0;for(let Y=X;Y<Q.issues.length;Y++)if(Q.issues[Y]?.continue!==!0)return!0;return!1}function l6(Q,X=0){if(Q.aborted===!0)return!0;for(let Y=X;Y<Q.issues.length;Y++)if(Q.issues[Y]?.continue===!1)return!0;return!1}function s0(Q,X){return X.map((Y)=>{var J;return(J=Y).path??(J.path=[]),Y.path.unshift(Q),Y})}function C9(Q){return typeof Q==="string"?Q:Q?.message}function C0(Q,X,Y){let J=Q.message?Q.message:C9(Q.inst?._zod.def?.error?.(Q))??C9(X?.error?.(Q))??C9(Y.customError?.(Q))??C9(Y.localeError?.(Q))??"Invalid input",{inst:W,continue:$,input:B,...G}=Q;if(G.path??(G.path=[]),G.message=J,X?.reportInput)G.input=B;return G}function IJ(Q){if(Q instanceof Set)return"set";if(Q instanceof Map)return"map";if(Q instanceof File)return"file";return"unknown"}function v9(Q){if(Array.isArray(Q))return"array";if(typeof Q==="string")return"string";return"unknown"}function c6(Q){let X=typeof Q;switch(X){case"number":return Number.isNaN(Q)?"nan":"number";case"object":{if(Q===null)return"null";if(Array.isArray(Q))return"array";let Y=Q;if(Y&&Object.getPrototypeOf(Y)!==Object.prototype&&"constructor"in Y&&Y.constructor)return Y.constructor.name}}return X}function i1(...Q){let[X,Y,J]=Q;if(typeof X==="string")return{message:X,code:"custom",input:Y,inst:J};return{...X}}function TV(Q){return Object.entries(Q).filter(([X,Y])=>{return Number.isNaN(Number.parseInt(X,10))}).map((X)=>X[1])}function bJ(Q){let X=atob(Q),Y=new Uint8Array(X.length);for(let J=0;J<X.length;J++)Y[J]=X.charCodeAt(J);return Y}function TJ(Q){let X="";for(let Y=0;Y<Q.length;Y++)X+=String.fromCharCode(Q[Y]);return btoa(X)}function RV(Q){let X=Q.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-X.length%4)%4);return bJ(X+Y)}function EV(Q){return TJ(Q).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function SV(Q){let X=Q.replace(/^0x/,"");if(X.length%2!==0)throw Error("Invalid hex string length");let Y=new Uint8Array(X.length/2);for(let J=0;J<X.length;J+=2)Y[J/2]=Number.parseInt(X.slice(J,J+2),16);return Y}function CV(Q){return Array.from(Q).map((X)=>X.toString(16).padStart(2,"0")).join("")}class RJ{constructor(...Q){}}var EJ=(Q,X)=>{Q.name="$ZodError",Object.defineProperty(Q,"_zod",{value:Q._zod,enumerable:!1}),Object.defineProperty(Q,"issues",{value:X,enumerable:!1}),Q.message=JSON.stringify(X,p1,2),Object.defineProperty(Q,"toString",{value:()=>Q.message,enumerable:!1})},l8=O("$ZodError",EJ),p6=O("$ZodError",EJ,{Parent:Error});function d6(Q,X=(Y)=>Y.message){let Y={},J=[];for(let W of Q.issues)if(W.path.length>0)Y[W.path[0]]=Y[W.path[0]]||[],Y[W.path[0]].push(X(W));else J.push(X(W));return{formErrors:J,fieldErrors:Y}}function i6(Q,X=(Y)=>Y.message){let Y={_errors:[]},J=(W,$=[])=>{for(let B of W.issues)if(B.code==="invalid_union"&&B.errors.length)B.errors.map((G)=>J({issues:G},[...$,...B.path]));else if(B.code==="invalid_key")J({issues:B.issues},[...$,...B.path]);else if(B.code==="invalid_element")J({issues:B.issues},[...$,...B.path]);else{let G=[...$,...B.path];if(G.length===0)Y._errors.push(X(B));else{let K=Y,H=0;while(H<G.length){let Z=G[H];if(H!==G.length-1)K[Z]=K[Z]||{_errors:[]};else K[Z]=K[Z]||{_errors:[]},K[Z]._errors.push(X(B));K=K[Z],H++}}}};return J(Q),Y}var c8=(Q)=>(X,Y,J,W)=>{let $=J?{...J,async:!1}:{async:!1},B=X._zod.run({value:Y,issues:[]},$);if(B instanceof Promise)throw new r0;if(B.issues.length){let G=new(W?.Err??Q)(B.issues.map((K)=>C0(K,$,N0())));throw u8(G,W?.callee),G}return B.value};var p8=(Q)=>async(X,Y,J,W)=>{let $=J?{...J,async:!0}:{async:!0},B=X._zod.run({value:Y,issues:[]},$);if(B instanceof Promise)B=await B;if(B.issues.length){let G=new(W?.Err??Q)(B.issues.map((K)=>C0(K,$,N0())));throw u8(G,W?.callee),G}return B.value};var y9=(Q)=>(X,Y,J)=>{let W=J?{...J,async:!1}:{async:!1},$=X._zod.run({value:Y,issues:[]},W);if($ instanceof Promise)throw new r0;return $.issues.length?{success:!1,error:new(Q??l8)($.issues.map((B)=>C0(B,W,N0())))}:{success:!0,data:$.value}},g9=y9(p6),f9=(Q)=>async(X,Y,J)=>{let W=J?{...J,async:!0}:{async:!0},$=X._zod.run({value:Y,issues:[]},W);if($ instanceof Promise)$=await $;return $.issues.length?{success:!1,error:new Q($.issues.map((B)=>C0(B,W,N0())))}:{success:!0,data:$.value}},d8=f9(p6),SJ=(Q)=>(X,Y,J)=>{let W=J?{...J,direction:"backward"}:{direction:"backward"};return c8(Q)(X,Y,W)};var CJ=(Q)=>(X,Y,J)=>{return c8(Q)(X,Y,J)};var kJ=(Q)=>async(X,Y,J)=>{let W=J?{...J,direction:"backward"}:{direction:"backward"};return p8(Q)(X,Y,W)};var _J=(Q)=>async(X,Y,J)=>{return p8(Q)(X,Y,J)};var xJ=(Q)=>(X,Y,J)=>{let W=J?{...J,direction:"backward"}:{direction:"backward"};return y9(Q)(X,Y,W)};var vJ=(Q)=>(X,Y,J)=>{return y9(Q)(X,Y,J)};var yJ=(Q)=>async(X,Y,J)=>{let W=J?{...J,direction:"backward"}:{direction:"backward"};return f9(Q)(X,Y,W)};var gJ=(Q)=>async(X,Y,J)=>{return f9(Q)(X,Y,J)};var fJ=/^[cC][0-9a-z]{6,}$/,hJ=/^[0-9a-z]+$/,uJ=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,mJ=/^[0-9a-vA-V]{20}$/,lJ=/^[A-Za-z0-9]{27}$/,cJ=/^[a-zA-Z0-9_-]{21}$/,pJ=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var dJ=/^([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})$/,n6=(Q)=>{if(!Q)return/^([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)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${Q}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var iJ=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var _V="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function nJ(){return new RegExp(_V,"u")}var oJ=/^(?:(?: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])$/,rJ=/^(([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 tJ=/^((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])$/,aJ=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,sJ=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,o6=/^[A-Za-z0-9_-]*$/;var eJ=/^https?$/,Q7=/^\+[1-9]\d{6,14}$/,X7="(?:(?:\\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])))",Y7=new RegExp(`^${X7}$`);function J7(Q){return typeof Q.precision==="number"?Q.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":Q.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${Q.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function W7(Q){return new RegExp(`^${J7(Q)}$`)}function $7(Q){let X=J7({precision:Q.precision}),Y=["Z"];if(Q.local)Y.push("");if(Q.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let J=`${X}(?:${Y.join("|")})`;return new RegExp(`^${X7}T(?:${J})$`)}var B7=(Q)=>{let X=Q?`[\\s\\S]{${Q?.minimum??0},${Q?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${X}$`)},G7=/^-?\d+n?$/,H7=/^-?\d+$/,i8=/^-?\d+(?:\.\d+)?$/,K7=/^(?:true|false)$/i,Z7=/^null$/i;var L7=/^[^A-Z]*$/,V7=/^[^a-z]*$/;var H0=O("$ZodCheck",(Q,X)=>{var Y;Q._zod??(Q._zod={}),Q._zod.def=X,(Y=Q._zod).onattach??(Y.onattach=[])}),D7={number:"number",bigint:"bigint",object:"date"},r6=O("$ZodCheckLessThan",(Q,X)=>{H0.init(Q,X);let Y=D7[typeof X.value];Q._zod.onattach.push((J)=>{let W=J._zod.bag,$=(X.inclusive?W.maximum:W.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(X.value<$)if(X.inclusive)W.maximum=X.value;else W.exclusiveMaximum=X.value}),Q._zod.check=(J)=>{if(X.inclusive?J.value<=X.value:J.value<X.value)return;J.issues.push({origin:Y,code:"too_big",maximum:typeof X.value==="object"?X.value.getTime():X.value,input:J.value,inclusive:X.inclusive,inst:Q,continue:!X.abort})}}),t6=O("$ZodCheckGreaterThan",(Q,X)=>{H0.init(Q,X);let Y=D7[typeof X.value];Q._zod.onattach.push((J)=>{let W=J._zod.bag,$=(X.inclusive?W.minimum:W.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(X.value>$)if(X.inclusive)W.minimum=X.value;else W.exclusiveMinimum=X.value}),Q._zod.check=(J)=>{if(X.inclusive?J.value>=X.value:J.value>X.value)return;J.issues.push({origin:Y,code:"too_small",minimum:typeof X.value==="object"?X.value.getTime():X.value,input:J.value,inclusive:X.inclusive,inst:Q,continue:!X.abort})}}),q7=O("$ZodCheckMultipleOf",(Q,X)=>{H0.init(Q,X),Q._zod.onattach.push((Y)=>{var J;(J=Y._zod.bag).multipleOf??(J.multipleOf=X.value)}),Q._zod.check=(Y)=>{if(typeof Y.value!==typeof X.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Y.value==="bigint"?Y.value%X.value===BigInt(0):y6(Y.value,X.value)===0)return;Y.issues.push({origin:typeof Y.value,code:"not_multiple_of",divisor:X.value,input:Y.value,inst:Q,continue:!X.abort})}}),z7=O("$ZodCheckNumberFormat",(Q,X)=>{H0.init(Q,X),X.format=X.format||"float64";let Y=X.format?.includes("int"),J=Y?"int":"number",[W,$]=m6[X.format];Q._zod.onattach.push((B)=>{let G=B._zod.bag;if(G.format=X.format,G.minimum=W,G.maximum=$,Y)G.pattern=H7}),Q._zod.check=(B)=>{let G=B.value;if(Y){if(!Number.isInteger(G)){B.issues.push({expected:J,format:X.format,code:"invalid_type",continue:!1,input:G,inst:Q});return}if(!Number.isSafeInteger(G)){if(G>0)B.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:J,inclusive:!0,continue:!X.abort});else B.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:Q,origin:J,inclusive:!0,continue:!X.abort});return}}if(G<W)B.issues.push({origin:"number",input:G,code:"too_small",minimum:W,inclusive:!0,inst:Q,continue:!X.abort});if(G>$)B.issues.push({origin:"number",input:G,code:"too_big",maximum:$,inclusive:!0,inst:Q,continue:!X.abort})}});var F7=O("$ZodCheckMaxLength",(Q,X)=>{var Y;H0.init(Q,X),(Y=Q._zod.def).when??(Y.when=(J)=>{let W=J.value;return!_9(W)&&W.length!==void 0}),Q._zod.onattach.push((J)=>{let W=J._zod.bag.maximum??Number.POSITIVE_INFINITY;if(X.maximum<W)J._zod.bag.maximum=X.maximum}),Q._zod.check=(J)=>{let W=J.value;if(W.length<=X.maximum)return;let B=v9(W);J.issues.push({origin:B,code:"too_big",maximum:X.maximum,inclusive:!0,input:W,inst:Q,continue:!X.abort})}}),A7=O("$ZodCheckMinLength",(Q,X)=>{var Y;H0.init(Q,X),(Y=Q._zod.def).when??(Y.when=(J)=>{let W=J.value;return!_9(W)&&W.length!==void 0}),Q._zod.onattach.push((J)=>{let W=J._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(X.minimum>W)J._zod.bag.minimum=X.minimum}),Q._zod.check=(J)=>{let W=J.value;if(W.length>=X.minimum)return;let B=v9(W);J.issues.push({origin:B,code:"too_small",minimum:X.minimum,inclusive:!0,input:W,inst:Q,continue:!X.abort})}}),O7=O("$ZodCheckLengthEquals",(Q,X)=>{var Y;H0.init(Q,X),(Y=Q._zod.def).when??(Y.when=(J)=>{let W=J.value;return!_9(W)&&W.length!==void 0}),Q._zod.onattach.push((J)=>{let W=J._zod.bag;W.minimum=X.length,W.maximum=X.length,W.length=X.length}),Q._zod.check=(J)=>{let W=J.value,$=W.length;if($===X.length)return;let B=v9(W),G=$>X.length;J.issues.push({origin:B,...G?{code:"too_big",maximum:X.length}:{code:"too_small",minimum:X.length},inclusive:!0,exact:!0,input:J.value,inst:Q,continue:!X.abort})}}),u9=O("$ZodCheckStringFormat",(Q,X)=>{var Y,J;if(H0.init(Q,X),Q._zod.onattach.push((W)=>{let $=W._zod.bag;if($.format=X.format,X.pattern)$.patterns??($.patterns=new Set),$.patterns.add(X.pattern)}),X.pattern)(Y=Q._zod).check??(Y.check=(W)=>{if(X.pattern.lastIndex=0,X.pattern.test(W.value))return;W.issues.push({origin:"string",code:"invalid_format",format:X.format,input:W.value,...X.pattern?{pattern:X.pattern.toString()}:{},inst:Q,continue:!X.abort})});else(J=Q._zod).check??(J.check=()=>{})}),N7=O("$ZodCheckRegex",(Q,X)=>{u9.init(Q,X),Q._zod.check=(Y)=>{if(X.pattern.lastIndex=0,X.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Y.value,pattern:X.pattern.toString(),inst:Q,continue:!X.abort})}}),U7=O("$ZodCheckLowerCase",(Q,X)=>{X.pattern??(X.pattern=L7),u9.init(Q,X)}),M7=O("$ZodCheckUpperCase",(Q,X)=>{X.pattern??(X.pattern=V7),u9.init(Q,X)}),w7=O("$ZodCheckIncludes",(Q,X)=>{H0.init(Q,X);let Y=a0(X.includes),J=new RegExp(typeof X.position==="number"?`^.{${X.position}}${Y}`:Y);X.pattern=J,Q._zod.onattach.push((W)=>{let $=W._zod.bag;$.patterns??($.patterns=new Set),$.patterns.add(J)}),Q._zod.check=(W)=>{if(W.value.includes(X.includes,X.position))return;W.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:X.includes,input:W.value,inst:Q,continue:!X.abort})}}),P7=O("$ZodCheckStartsWith",(Q,X)=>{H0.init(Q,X);let Y=new RegExp(`^${a0(X.prefix)}.*`);X.pattern??(X.pattern=Y),Q._zod.onattach.push((J)=>{let W=J._zod.bag;W.patterns??(W.patterns=new Set),W.patterns.add(Y)}),Q._zod.check=(J)=>{if(J.value.startsWith(X.prefix))return;J.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:X.prefix,input:J.value,inst:Q,continue:!X.abort})}}),j7=O("$ZodCheckEndsWith",(Q,X)=>{H0.init(Q,X);let Y=new RegExp(`.*${a0(X.suffix)}$`);X.pattern??(X.pattern=Y),Q._zod.onattach.push((J)=>{let W=J._zod.bag;W.patterns??(W.patterns=new Set),W.patterns.add(Y)}),Q._zod.check=(J)=>{if(J.value.endsWith(X.suffix))return;J.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:X.suffix,input:J.value,inst:Q,continue:!X.abort})}});var I7=O("$ZodCheckOverwrite",(Q,X)=>{H0.init(Q,X),Q._zod.check=(Y)=>{Y.value=X.tx(Y.value)}});class a6{constructor(Q=[]){if(this.content=[],this.indent=0,this)this.args=Q}indented(Q){this.indent+=1,Q(this),this.indent-=1}write(Q){if(typeof Q==="function"){Q(this,{execution:"sync"}),Q(this,{execution:"async"});return}let Y=Q.split(`
|
|
12
|
+
`).filter(($)=>$),J=Math.min(...Y.map(($)=>$.length-$.trimStart().length)),W=Y.map(($)=>$.slice(J)).map(($)=>" ".repeat(this.indent*2)+$);for(let $ of W)this.content.push($)}compile(){let Q=Function,X=this?.args,J=[...(this?.content??[""]).map((W)=>` ${W}`)];return new Q(...X,J.join(`
|
|
13
|
+
`))}}var T7={major:4,minor:4,patch:3};var l=O("$ZodType",(Q,X)=>{var Y;Q??(Q={}),Q._zod.def=X,Q._zod.bag=Q._zod.bag||{},Q._zod.version=T7;let J=[...Q._zod.def.checks??[]];if(Q._zod.traits.has("$ZodCheck"))J.unshift(Q);for(let W of J)for(let $ of W._zod.onattach)$(Q);if(J.length===0)(Y=Q._zod).deferred??(Y.deferred=[]),Q._zod.deferred?.push(()=>{Q._zod.run=Q._zod.parse});else{let W=(B,G,K)=>{let H=V1(B),Z;for(let L of G){if(L._zod.def.when){if(l6(B))continue;if(!L._zod.def.when(B))continue}else if(H)continue;let V=B.issues.length,D=L._zod.check(B);if(D instanceof Promise&&K?.async===!1)throw new r0;if(Z||D instanceof Promise)Z=(Z??Promise.resolve()).then(async()=>{if(await D,B.issues.length===V)return;if(!H)H=V1(B,V)});else{if(B.issues.length===V)continue;if(!H)H=V1(B,V)}}if(Z)return Z.then(()=>{return B});return B},$=(B,G,K)=>{if(V1(B))return B.aborted=!0,B;let H=W(G,J,K);if(H instanceof Promise){if(K.async===!1)throw new r0;return H.then((Z)=>Q._zod.parse(Z,K))}return Q._zod.parse(H,K)};Q._zod.run=(B,G)=>{if(G.skipChecks)return Q._zod.parse(B,G);if(G.direction==="backward"){let H=Q._zod.parse({value:B.value,issues:[]},{...G,skipChecks:!0});if(H instanceof Promise)return H.then((Z)=>{return $(Z,B,G)});return $(H,B,G)}let K=Q._zod.parse(B,G);if(K instanceof Promise){if(G.async===!1)throw new r0;return K.then((H)=>W(H,J,G))}return W(K,J,G)}}m(Q,"~standard",()=>({validate:(W)=>{try{let $=g9(Q,W);return $.success?{value:$.data}:{issues:$.error?.issues}}catch($){return d8(Q,W).then((B)=>B.success?{value:B.data}:{issues:B.error?.issues})}},vendor:"zod",version:1}))}),r8=O("$ZodString",(Q,X)=>{l.init(Q,X),Q._zod.pattern=[...Q?._zod.bag?.patterns??[]].pop()??B7(Q._zod.bag),Q._zod.parse=(Y,J)=>{if(X.coerce)try{Y.value=String(Y.value)}catch(W){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:Q}),Y}}),o=O("$ZodStringFormat",(Q,X)=>{u9.init(Q,X),r8.init(Q,X)}),y7=O("$ZodGUID",(Q,X)=>{X.pattern??(X.pattern=dJ),o.init(Q,X)}),g7=O("$ZodUUID",(Q,X)=>{if(X.version){let J={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[X.version];if(J===void 0)throw Error(`Invalid UUID version: "${X.version}"`);X.pattern??(X.pattern=n6(J))}else X.pattern??(X.pattern=n6());o.init(Q,X)}),f7=O("$ZodEmail",(Q,X)=>{X.pattern??(X.pattern=iJ),o.init(Q,X)}),h7=O("$ZodURL",(Q,X)=>{o.init(Q,X),Q._zod.check=(Y)=>{try{let J=Y.value.trim();if(!X.normalize&&X.protocol?.source===eJ.source){if(!/^https?:\/\//i.test(J)){Y.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:Y.value,inst:Q,continue:!X.abort});return}}let W=new URL(J);if(X.hostname){if(X.hostname.lastIndex=0,!X.hostname.test(W.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:X.hostname.source,input:Y.value,inst:Q,continue:!X.abort})}if(X.protocol){if(X.protocol.lastIndex=0,!X.protocol.test(W.protocol.endsWith(":")?W.protocol.slice(0,-1):W.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:X.protocol.source,input:Y.value,inst:Q,continue:!X.abort})}if(X.normalize)Y.value=W.href;else Y.value=J;return}catch(J){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:Q,continue:!X.abort})}}}),u7=O("$ZodEmoji",(Q,X)=>{X.pattern??(X.pattern=nJ()),o.init(Q,X)}),m7=O("$ZodNanoID",(Q,X)=>{X.pattern??(X.pattern=cJ),o.init(Q,X)}),l7=O("$ZodCUID",(Q,X)=>{X.pattern??(X.pattern=fJ),o.init(Q,X)}),c7=O("$ZodCUID2",(Q,X)=>{X.pattern??(X.pattern=hJ),o.init(Q,X)}),p7=O("$ZodULID",(Q,X)=>{X.pattern??(X.pattern=uJ),o.init(Q,X)}),d7=O("$ZodXID",(Q,X)=>{X.pattern??(X.pattern=mJ),o.init(Q,X)}),i7=O("$ZodKSUID",(Q,X)=>{X.pattern??(X.pattern=lJ),o.init(Q,X)}),n7=O("$ZodISODateTime",(Q,X)=>{X.pattern??(X.pattern=$7(X)),o.init(Q,X)}),o7=O("$ZodISODate",(Q,X)=>{X.pattern??(X.pattern=Y7),o.init(Q,X)}),r7=O("$ZodISOTime",(Q,X)=>{X.pattern??(X.pattern=W7(X)),o.init(Q,X)}),t7=O("$ZodISODuration",(Q,X)=>{X.pattern??(X.pattern=pJ),o.init(Q,X)}),a7=O("$ZodIPv4",(Q,X)=>{X.pattern??(X.pattern=oJ),o.init(Q,X),Q._zod.bag.format="ipv4"}),s7=O("$ZodIPv6",(Q,X)=>{X.pattern??(X.pattern=rJ),o.init(Q,X),Q._zod.bag.format="ipv6",Q._zod.check=(Y)=>{try{new URL(`http://[${Y.value}]`)}catch{Y.issues.push({code:"invalid_format",format:"ipv6",input:Y.value,inst:Q,continue:!X.abort})}}});var e7=O("$ZodCIDRv4",(Q,X)=>{X.pattern??(X.pattern=tJ),o.init(Q,X)}),QW=O("$ZodCIDRv6",(Q,X)=>{X.pattern??(X.pattern=aJ),o.init(Q,X),Q._zod.check=(Y)=>{let J=Y.value.split("/");try{if(J.length!==2)throw Error();let[W,$]=J;if(!$)throw Error();let B=Number($);if(`${B}`!==$)throw Error();if(B<0||B>128)throw Error();new URL(`http://[${W}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:Q,continue:!X.abort})}}});function XW(Q){if(Q==="")return!0;if(/\s/.test(Q))return!1;if(Q.length%4!==0)return!1;try{return atob(Q),!0}catch{return!1}}var YW=O("$ZodBase64",(Q,X)=>{X.pattern??(X.pattern=sJ),o.init(Q,X),Q._zod.bag.contentEncoding="base64",Q._zod.check=(Y)=>{if(XW(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:Q,continue:!X.abort})}});function yV(Q){if(!o6.test(Q))return!1;let X=Q.replace(/[-_]/g,(J)=>J==="-"?"+":"/"),Y=X.padEnd(Math.ceil(X.length/4)*4,"=");return XW(Y)}var JW=O("$ZodBase64URL",(Q,X)=>{X.pattern??(X.pattern=o6),o.init(Q,X),Q._zod.bag.contentEncoding="base64url",Q._zod.check=(Y)=>{if(yV(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:Q,continue:!X.abort})}}),WW=O("$ZodE164",(Q,X)=>{X.pattern??(X.pattern=Q7),o.init(Q,X)});function gV(Q,X=null){try{let Y=Q.split(".");if(Y.length!==3)return!1;let[J]=Y;if(!J)return!1;let W=JSON.parse(atob(J));if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(X&&(!("alg"in W)||W.alg!==X))return!1;return!0}catch{return!1}}var $W=O("$ZodJWT",(Q,X)=>{o.init(Q,X),Q._zod.check=(Y)=>{if(gV(Y.value,X.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:Q,continue:!X.abort})}});var e6=O("$ZodNumber",(Q,X)=>{l.init(Q,X),Q._zod.pattern=Q._zod.bag.pattern??i8,Q._zod.parse=(Y,J)=>{if(X.coerce)try{Y.value=Number(Y.value)}catch(B){}let W=Y.value;if(typeof W==="number"&&!Number.isNaN(W)&&Number.isFinite(W))return Y;let $=typeof W==="number"?Number.isNaN(W)?"NaN":!Number.isFinite(W)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:W,inst:Q,...$?{received:$}:{}}),Y}}),BW=O("$ZodNumberFormat",(Q,X)=>{z7.init(Q,X),e6.init(Q,X)}),GW=O("$ZodBoolean",(Q,X)=>{l.init(Q,X),Q._zod.pattern=K7,Q._zod.parse=(Y,J)=>{if(X.coerce)try{Y.value=Boolean(Y.value)}catch($){}let W=Y.value;if(typeof W==="boolean")return Y;return Y.issues.push({expected:"boolean",code:"invalid_type",input:W,inst:Q}),Y}}),HW=O("$ZodBigInt",(Q,X)=>{l.init(Q,X),Q._zod.pattern=G7,Q._zod.parse=(Y,J)=>{if(X.coerce)try{Y.value=BigInt(Y.value)}catch(W){}if(typeof Y.value==="bigint")return Y;return Y.issues.push({expected:"bigint",code:"invalid_type",input:Y.value,inst:Q}),Y}});var KW=O("$ZodNull",(Q,X)=>{l.init(Q,X),Q._zod.pattern=Z7,Q._zod.values=new Set([null]),Q._zod.parse=(Y,J)=>{let W=Y.value;if(W===null)return Y;return Y.issues.push({expected:"null",code:"invalid_type",input:W,inst:Q}),Y}}),ZW=O("$ZodAny",(Q,X)=>{l.init(Q,X),Q._zod.parse=(Y)=>Y}),LW=O("$ZodUnknown",(Q,X)=>{l.init(Q,X),Q._zod.parse=(Y)=>Y}),VW=O("$ZodNever",(Q,X)=>{l.init(Q,X),Q._zod.parse=(Y,J)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:Q}),Y}});var DW=O("$ZodDate",(Q,X)=>{l.init(Q,X),Q._zod.parse=(Y,J)=>{if(X.coerce)try{Y.value=new Date(Y.value)}catch(G){}let W=Y.value,$=W instanceof Date;if($&&!Number.isNaN(W.getTime()))return Y;return Y.issues.push({expected:"date",code:"invalid_type",input:W,...$?{received:"Invalid Date"}:{},inst:Q}),Y}});function R7(Q,X,Y){if(Q.issues.length)X.issues.push(...s0(Y,Q.issues));X.value[Y]=Q.value}var qW=O("$ZodArray",(Q,X)=>{l.init(Q,X),Q._zod.parse=(Y,J)=>{let W=Y.value;if(!Array.isArray(W))return Y.issues.push({expected:"array",code:"invalid_type",input:W,inst:Q}),Y;Y.value=Array(W.length);let $=[];for(let B=0;B<W.length;B++){let G=W[B],K=X.element._zod.run({value:G,issues:[]},J);if(K instanceof Promise)$.push(K.then((H)=>R7(H,Y,B)));else R7(K,Y,B)}if($.length)return Promise.all($).then(()=>Y);return Y}});function o8(Q,X,Y,J,W,$){let B=Y in J;if(Q.issues.length){if(W&&$&&!B)return;X.issues.push(...s0(Y,Q.issues))}if(!B&&!W){if(!Q.issues.length)X.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Y]});return}if(Q.value===void 0){if(B)X.value[Y]=void 0}else X.value[Y]=Q.value}function zW(Q){let X=Object.keys(Q.shape);for(let J of X)if(!Q.shape?.[J]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${J}": expected a Zod schema`);let Y=u6(Q.shape);return{...Q,keys:X,keySet:new Set(X),numKeys:X.length,optionalKeys:new Set(Y)}}function FW(Q,X,Y,J,W,$){let B=[],G=W.keySet,K=W.catchall._zod,H=K.def.type,Z=K.optin==="optional",L=K.optout==="optional";for(let V in X){if(V==="__proto__")continue;if(G.has(V))continue;if(H==="never"){B.push(V);continue}let D=K.run({value:X[V],issues:[]},J);if(D instanceof Promise)Q.push(D.then((z)=>o8(z,Y,V,X,Z,L)));else o8(D,Y,V,X,Z,L)}if(B.length)Y.issues.push({code:"unrecognized_keys",keys:B,input:X,inst:$});if(!Q.length)return Y;return Promise.all(Q).then(()=>{return Y})}var fV=O("$ZodObject",(Q,X)=>{if(l.init(Q,X),!Object.getOwnPropertyDescriptor(X,"shape")?.get){let G=X.shape;Object.defineProperty(X,"shape",{get:()=>{let K={...G};return Object.defineProperty(X,"shape",{value:K}),K}})}let J=d1(()=>zW(X));m(Q._zod,"propValues",()=>{let G=X.shape,K={};for(let H in G){let Z=G[H]._zod;if(Z.values){K[H]??(K[H]=new Set);for(let L of Z.values)K[H].add(L)}}return K});let W=R1,$=X.catchall,B;Q._zod.parse=(G,K)=>{B??(B=J.value);let H=G.value;if(!W(H))return G.issues.push({expected:"object",code:"invalid_type",input:H,inst:Q}),G;G.value={};let Z=[],L=B.shape;for(let V of B.keys){let D=L[V],z=D._zod.optin==="optional",A=D._zod.optout==="optional",N=D._zod.run({value:H[V],issues:[]},K);if(N instanceof Promise)Z.push(N.then((F)=>o8(F,G,V,H,z,A)));else o8(N,G,V,H,z,A)}if(!$)return Z.length?Promise.all(Z).then(()=>G):G;return FW(Z,H,G,K,J.value,Q)}}),AW=O("$ZodObjectJIT",(Q,X)=>{fV.init(Q,X);let Y=Q._zod.parse,J=d1(()=>zW(X)),W=(V)=>{let D=new a6(["shape","payload","ctx"]),z=J.value,A=(M)=>{let b=h8(M);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};D.write("const input = payload.value;");let N=Object.create(null),F=0;for(let M of z.keys)N[M]=`key_${F++}`;D.write("const newResult = {};");for(let M of z.keys){let b=N[M],P=h8(M),n=V[M],O0=n?._zod?.optin==="optional",T1=n?._zod?.optout==="optional";if(D.write(`const ${b} = ${A(M)};`),O0&&T1)D.write(`
|
|
14
|
+
if (${b}.issues.length) {
|
|
15
|
+
if (${P} in input) {
|
|
16
|
+
payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
17
|
+
...iss,
|
|
18
|
+
path: iss.path ? [${P}, ...iss.path] : [${P}]
|
|
19
|
+
})));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (${b}.value === undefined) {
|
|
24
|
+
if (${P} in input) {
|
|
25
|
+
newResult[${P}] = undefined;
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
newResult[${P}] = ${b}.value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
`);else if(!O0)D.write(`
|
|
32
|
+
const ${b}_present = ${P} in input;
|
|
33
|
+
if (${b}.issues.length) {
|
|
34
|
+
payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
35
|
+
...iss,
|
|
36
|
+
path: iss.path ? [${P}, ...iss.path] : [${P}]
|
|
37
|
+
})));
|
|
38
|
+
}
|
|
39
|
+
if (!${b}_present && !${b}.issues.length) {
|
|
40
|
+
payload.issues.push({
|
|
41
|
+
code: "invalid_type",
|
|
42
|
+
expected: "nonoptional",
|
|
43
|
+
input: undefined,
|
|
44
|
+
path: [${P}]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (${b}_present) {
|
|
49
|
+
if (${b}.value === undefined) {
|
|
50
|
+
newResult[${P}] = undefined;
|
|
51
|
+
} else {
|
|
52
|
+
newResult[${P}] = ${b}.value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
`);else D.write(`
|
|
57
|
+
if (${b}.issues.length) {
|
|
58
|
+
payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
59
|
+
...iss,
|
|
60
|
+
path: iss.path ? [${P}, ...iss.path] : [${P}]
|
|
61
|
+
})));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (${b}.value === undefined) {
|
|
65
|
+
if (${P} in input) {
|
|
66
|
+
newResult[${P}] = undefined;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
newResult[${P}] = ${b}.value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
`)}D.write("payload.value = newResult;"),D.write("return payload;");let U=D.compile();return(M,b)=>U(V,M,b)},$,B=R1,G=!c1.jitless,H=G&&f6.value,Z=X.catchall,L;Q._zod.parse=(V,D)=>{L??(L=J.value);let z=V.value;if(!B(z))return V.issues.push({expected:"object",code:"invalid_type",input:z,inst:Q}),V;if(G&&H&&D?.async===!1&&D.jitless!==!0){if(!$)$=W(X.shape);if(V=$(V,D),!Z)return V;return FW([],z,V,D,L,Q)}return Y(V,D)}});function E7(Q,X,Y,J){for(let $ of Q)if($.issues.length===0)return X.value=$.value,X;let W=Q.filter(($)=>!V1($));if(W.length===1)return X.value=W[0].value,W[0];return X.issues.push({code:"invalid_union",input:X.value,inst:Y,errors:Q.map(($)=>$.issues.map((B)=>C0(B,J,N0())))}),X}var Q4=O("$ZodUnion",(Q,X)=>{l.init(Q,X),m(Q._zod,"optin",()=>X.options.some((J)=>J._zod.optin==="optional")?"optional":void 0),m(Q._zod,"optout",()=>X.options.some((J)=>J._zod.optout==="optional")?"optional":void 0),m(Q._zod,"values",()=>{if(X.options.every((J)=>J._zod.values))return new Set(X.options.flatMap((J)=>Array.from(J._zod.values)));return}),m(Q._zod,"pattern",()=>{if(X.options.every((J)=>J._zod.pattern)){let J=X.options.map((W)=>W._zod.pattern);return new RegExp(`^(${J.map((W)=>x9(W.source)).join("|")})$`)}return});let Y=X.options.length===1?X.options[0]._zod.run:null;Q._zod.parse=(J,W)=>{if(Y)return Y(J,W);let $=!1,B=[];for(let G of X.options){let K=G._zod.run({value:J.value,issues:[]},W);if(K instanceof Promise)B.push(K),$=!0;else{if(K.issues.length===0)return K;B.push(K)}}if(!$)return E7(B,J,Q,W);return Promise.all(B).then((G)=>{return E7(G,J,Q,W)})}});var OW=O("$ZodDiscriminatedUnion",(Q,X)=>{X.inclusive=!1,Q4.init(Q,X);let Y=Q._zod.parse;m(Q._zod,"propValues",()=>{let W={};for(let $ of X.options){let B=$._zod.propValues;if(!B||Object.keys(B).length===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf($)}"`);for(let[G,K]of Object.entries(B)){if(!W[G])W[G]=new Set;for(let H of K)W[G].add(H)}}return W});let J=d1(()=>{let W=X.options,$=new Map;for(let B of W){let G=B._zod.propValues?.[X.discriminator];if(!G||G.size===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf(B)}"`);for(let K of G){if($.has(K))throw Error(`Duplicate discriminator value "${String(K)}"`);$.set(K,B)}}return $});Q._zod.parse=(W,$)=>{let B=W.value;if(!R1(B))return W.issues.push({code:"invalid_type",expected:"object",input:B,inst:Q}),W;let G=J.value.get(B?.[X.discriminator]);if(G)return G._zod.run(W,$);if(X.unionFallback||$.direction==="backward")return Y(W,$);return W.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:X.discriminator,options:Array.from(J.value.keys()),input:B,path:[X.discriminator],inst:Q}),W}}),NW=O("$ZodIntersection",(Q,X)=>{l.init(Q,X),Q._zod.parse=(Y,J)=>{let W=Y.value,$=X.left._zod.run({value:W,issues:[]},J),B=X.right._zod.run({value:W,issues:[]},J);if($ instanceof Promise||B instanceof Promise)return Promise.all([$,B]).then(([K,H])=>{return S7(Y,K,H)});return S7(Y,$,B)}});function s6(Q,X){if(Q===X)return{valid:!0,data:Q};if(Q instanceof Date&&X instanceof Date&&+Q===+X)return{valid:!0,data:Q};if(L1(Q)&&L1(X)){let Y=Object.keys(X),J=Object.keys(Q).filter(($)=>Y.indexOf($)!==-1),W={...Q,...X};for(let $ of J){let B=s6(Q[$],X[$]);if(!B.valid)return{valid:!1,mergeErrorPath:[$,...B.mergeErrorPath]};W[$]=B.data}return{valid:!0,data:W}}if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let J=0;J<Q.length;J++){let W=Q[J],$=X[J],B=s6(W,$);if(!B.valid)return{valid:!1,mergeErrorPath:[J,...B.mergeErrorPath]};Y.push(B.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function S7(Q,X,Y){let J=new Map,W;for(let G of X.issues)if(G.code==="unrecognized_keys"){W??(W=G);for(let K of G.keys){if(!J.has(K))J.set(K,{});J.get(K).l=!0}}else Q.issues.push(G);for(let G of Y.issues)if(G.code==="unrecognized_keys")for(let K of G.keys){if(!J.has(K))J.set(K,{});J.get(K).r=!0}else Q.issues.push(G);let $=[...J].filter(([,G])=>G.l&&G.r).map(([G])=>G);if($.length&&W)Q.issues.push({...W,keys:$});if(V1(Q))return Q;let B=s6(X.value,Y.value);if(!B.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(B.mergeErrorPath)}`);return Q.value=B.data,Q}var UW=O("$ZodRecord",(Q,X)=>{l.init(Q,X),Q._zod.parse=(Y,J)=>{let W=Y.value;if(!L1(W))return Y.issues.push({expected:"record",code:"invalid_type",input:W,inst:Q}),Y;let $=[],B=X.keyType._zod.values;if(B){Y.value={};let G=new Set;for(let H of B)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){G.add(typeof H==="number"?H.toString():H);let Z=X.keyType._zod.run({value:H,issues:[]},J);if(Z instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(Z.issues.length){Y.issues.push({code:"invalid_key",origin:"record",issues:Z.issues.map((D)=>C0(D,J,N0())),input:H,path:[H],inst:Q});continue}let L=Z.value,V=X.valueType._zod.run({value:W[H],issues:[]},J);if(V instanceof Promise)$.push(V.then((D)=>{if(D.issues.length)Y.issues.push(...s0(H,D.issues));Y.value[L]=D.value}));else{if(V.issues.length)Y.issues.push(...s0(H,V.issues));Y.value[L]=V.value}}let K;for(let H in W)if(!G.has(H))K=K??[],K.push(H);if(K&&K.length>0)Y.issues.push({code:"unrecognized_keys",input:W,inst:Q,keys:K})}else{Y.value={};for(let G of Reflect.ownKeys(W)){if(G==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(W,G))continue;let K=X.keyType._zod.run({value:G,issues:[]},J);if(K instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof G==="string"&&i8.test(G)&&K.issues.length){let L=X.keyType._zod.run({value:Number(G),issues:[]},J);if(L instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(L.issues.length===0)K=L}if(K.issues.length){if(X.mode==="loose")Y.value[G]=W[G];else Y.issues.push({code:"invalid_key",origin:"record",issues:K.issues.map((L)=>C0(L,J,N0())),input:G,path:[G],inst:Q});continue}let Z=X.valueType._zod.run({value:W[G],issues:[]},J);if(Z instanceof Promise)$.push(Z.then((L)=>{if(L.issues.length)Y.issues.push(...s0(G,L.issues));Y.value[K.value]=L.value}));else{if(Z.issues.length)Y.issues.push(...s0(G,Z.issues));Y.value[K.value]=Z.value}}}if($.length)return Promise.all($).then(()=>Y);return Y}});var MW=O("$ZodEnum",(Q,X)=>{l.init(Q,X);let Y=k9(X.entries),J=new Set(Y);Q._zod.values=J,Q._zod.pattern=new RegExp(`^(${Y.filter((W)=>h6.has(typeof W)).map((W)=>typeof W==="string"?a0(W):W.toString()).join("|")})$`),Q._zod.parse=(W,$)=>{let B=W.value;if(J.has(B))return W;return W.issues.push({code:"invalid_value",values:Y,input:B,inst:Q}),W}}),wW=O("$ZodLiteral",(Q,X)=>{if(l.init(Q,X),X.values.length===0)throw Error("Cannot create literal schema with no valid values");let Y=new Set(X.values);Q._zod.values=Y,Q._zod.pattern=new RegExp(`^(${X.values.map((J)=>typeof J==="string"?a0(J):J?a0(J.toString()):String(J)).join("|")})$`),Q._zod.parse=(J,W)=>{let $=J.value;if(Y.has($))return J;return J.issues.push({code:"invalid_value",values:X.values,input:$,inst:Q}),J}});var PW=O("$ZodTransform",(Q,X)=>{l.init(Q,X),Q._zod.optin="optional",Q._zod.parse=(Y,J)=>{if(J.direction==="backward")throw new S9(Q.constructor.name);let W=X.transform(Y.value,Y);if(J.async)return(W instanceof Promise?W:Promise.resolve(W)).then((B)=>{return Y.value=B,Y.fallback=!0,Y});if(W instanceof Promise)throw new r0;return Y.value=W,Y.fallback=!0,Y}});function C7(Q,X){if(X===void 0&&(Q.issues.length||Q.fallback))return{issues:[],value:void 0};return Q}var X4=O("$ZodOptional",(Q,X)=>{l.init(Q,X),Q._zod.optin="optional",Q._zod.optout="optional",m(Q._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,void 0]):void 0}),m(Q._zod,"pattern",()=>{let Y=X.innerType._zod.pattern;return Y?new RegExp(`^(${x9(Y.source)})?$`):void 0}),Q._zod.parse=(Y,J)=>{if(X.innerType._zod.optin==="optional"){let W=Y.value,$=X.innerType._zod.run(Y,J);if($ instanceof Promise)return $.then((B)=>C7(B,W));return C7($,W)}if(Y.value===void 0)return Y;return X.innerType._zod.run(Y,J)}}),jW=O("$ZodExactOptional",(Q,X)=>{X4.init(Q,X),m(Q._zod,"values",()=>X.innerType._zod.values),m(Q._zod,"pattern",()=>X.innerType._zod.pattern),Q._zod.parse=(Y,J)=>{return X.innerType._zod.run(Y,J)}}),IW=O("$ZodNullable",(Q,X)=>{l.init(Q,X),m(Q._zod,"optin",()=>X.innerType._zod.optin),m(Q._zod,"optout",()=>X.innerType._zod.optout),m(Q._zod,"pattern",()=>{let Y=X.innerType._zod.pattern;return Y?new RegExp(`^(${x9(Y.source)}|null)$`):void 0}),m(Q._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,null]):void 0}),Q._zod.parse=(Y,J)=>{if(Y.value===null)return Y;return X.innerType._zod.run(Y,J)}}),bW=O("$ZodDefault",(Q,X)=>{l.init(Q,X),Q._zod.optin="optional",m(Q._zod,"values",()=>X.innerType._zod.values),Q._zod.parse=(Y,J)=>{if(J.direction==="backward")return X.innerType._zod.run(Y,J);if(Y.value===void 0)return Y.value=X.defaultValue,Y;let W=X.innerType._zod.run(Y,J);if(W instanceof Promise)return W.then(($)=>k7($,X));return k7(W,X)}});function k7(Q,X){if(Q.value===void 0)Q.value=X.defaultValue;return Q}var TW=O("$ZodPrefault",(Q,X)=>{l.init(Q,X),Q._zod.optin="optional",m(Q._zod,"values",()=>X.innerType._zod.values),Q._zod.parse=(Y,J)=>{if(J.direction==="backward")return X.innerType._zod.run(Y,J);if(Y.value===void 0)Y.value=X.defaultValue;return X.innerType._zod.run(Y,J)}}),RW=O("$ZodNonOptional",(Q,X)=>{l.init(Q,X),m(Q._zod,"values",()=>{let Y=X.innerType._zod.values;return Y?new Set([...Y].filter((J)=>J!==void 0)):void 0}),Q._zod.parse=(Y,J)=>{let W=X.innerType._zod.run(Y,J);if(W instanceof Promise)return W.then(($)=>_7($,Q));return _7(W,Q)}});function _7(Q,X){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:X});return Q}var EW=O("$ZodCatch",(Q,X)=>{l.init(Q,X),Q._zod.optin="optional",m(Q._zod,"optout",()=>X.innerType._zod.optout),m(Q._zod,"values",()=>X.innerType._zod.values),Q._zod.parse=(Y,J)=>{if(J.direction==="backward")return X.innerType._zod.run(Y,J);let W=X.innerType._zod.run(Y,J);if(W instanceof Promise)return W.then(($)=>{if(Y.value=$.value,$.issues.length)Y.value=X.catchValue({...Y,error:{issues:$.issues.map((B)=>C0(B,J,N0()))},input:Y.value}),Y.issues=[],Y.fallback=!0;return Y});if(Y.value=W.value,W.issues.length)Y.value=X.catchValue({...Y,error:{issues:W.issues.map(($)=>C0($,J,N0()))},input:Y.value}),Y.issues=[],Y.fallback=!0;return Y}});var Y4=O("$ZodPipe",(Q,X)=>{l.init(Q,X),m(Q._zod,"values",()=>X.in._zod.values),m(Q._zod,"optin",()=>X.in._zod.optin),m(Q._zod,"optout",()=>X.out._zod.optout),m(Q._zod,"propValues",()=>X.in._zod.propValues),Q._zod.parse=(Y,J)=>{if(J.direction==="backward"){let $=X.out._zod.run(Y,J);if($ instanceof Promise)return $.then((B)=>n8(B,X.in,J));return n8($,X.in,J)}let W=X.in._zod.run(Y,J);if(W instanceof Promise)return W.then(($)=>n8($,X.out,J));return n8(W,X.out,J)}});function n8(Q,X,Y){if(Q.issues.length)return Q.aborted=!0,Q;return X._zod.run({value:Q.value,issues:Q.issues,fallback:Q.fallback},Y)}var SW=O("$ZodPreprocess",(Q,X)=>{Y4.init(Q,X)}),CW=O("$ZodReadonly",(Q,X)=>{l.init(Q,X),m(Q._zod,"propValues",()=>X.innerType._zod.propValues),m(Q._zod,"values",()=>X.innerType._zod.values),m(Q._zod,"optin",()=>X.innerType?._zod?.optin),m(Q._zod,"optout",()=>X.innerType?._zod?.optout),Q._zod.parse=(Y,J)=>{if(J.direction==="backward")return X.innerType._zod.run(Y,J);let W=X.innerType._zod.run(Y,J);if(W instanceof Promise)return W.then(x7);return x7(W)}});function x7(Q){return Q.value=Object.freeze(Q.value),Q}var kW=O("$ZodCustom",(Q,X)=>{H0.init(Q,X),l.init(Q,X),Q._zod.parse=(Y,J)=>{return Y},Q._zod.check=(Y)=>{let J=Y.value,W=X.fn(J);if(W instanceof Promise)return W.then(($)=>v7($,Y,J,Q));v7(W,Y,J,Q);return}});function v7(Q,X,Y,J){if(!Q){let W={code:"custom",input:Y,inst:J,path:[...J._zod.def.path??[]],continue:!J._zod.def.abort};if(J._zod.def.params)W.params=J._zod.def.params;X.issues.push(i1(W))}}var hV=()=>{let Q={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 X(W){return Q[W]??null}let Y={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",jwt:"JWT",template_literal:"input"},J={nan:"NaN"};return(W)=>{switch(W.code){case"invalid_type":{let $=J[W.expected]??W.expected,B=c6(W.input),G=J[B]??B;return`Invalid input: expected ${$}, received ${G}`}case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${m8(W.values[0])}`;return`Invalid option: expected one of ${f8(W.values,"|")}`;case"too_big":{let $=W.inclusive?"<=":"<",B=X(W.origin);if(B)return`Too big: expected ${W.origin??"value"} to have ${$}${W.maximum.toString()} ${B.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${$}${W.maximum.toString()}`}case"too_small":{let $=W.inclusive?">=":">",B=X(W.origin);if(B)return`Too small: expected ${W.origin} to have ${$}${W.minimum.toString()} ${B.unit}`;return`Too small: expected ${W.origin} to be ${$}${W.minimum.toString()}`}case"invalid_format":{let $=W;if($.format==="starts_with")return`Invalid string: must start with "${$.prefix}"`;if($.format==="ends_with")return`Invalid string: must end with "${$.suffix}"`;if($.format==="includes")return`Invalid string: must include "${$.includes}"`;if($.format==="regex")return`Invalid string: must match pattern ${$.pattern}`;return`Invalid ${Y[$.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${f8(W.keys,", ")}`;case"invalid_key":return`Invalid key in ${W.origin}`;case"invalid_union":if(W.options&&Array.isArray(W.options)&&W.options.length>0)return`Invalid discriminator value. Expected ${W.options.map((B)=>`'${B}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${W.origin}`;default:return"Invalid input"}}};function J4(){return{localeError:hV()}}var _W,uV=Symbol("ZodOutput"),mV=Symbol("ZodInput");class xW{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...X){let Y=X[0];if(this._map.set(Q,Y),Y&&typeof Y==="object"&&"id"in Y)this._idmap.set(Y.id,Q);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let X=this._map.get(Q);if(X&&typeof X==="object"&&"id"in X)this._idmap.delete(X.id);return this._map.delete(Q),this}get(Q){let X=Q._zod.parent;if(X){let Y={...this.get(X)??{}};delete Y.id;let J={...Y,...this._map.get(Q)};return Object.keys(J).length?J:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function vW(){return new xW}(_W=globalThis).__zod_globalRegistry??(_W.__zod_globalRegistry=vW());var D1=globalThis.__zod_globalRegistry;function yW(Q,X){return new Q({type:"string",...E(X)})}function gW(Q,X){return new Q({type:"string",coerce:!0,...E(X)})}function fW(Q,X){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...E(X)})}function W4(Q,X){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...E(X)})}function hW(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...E(X)})}function uW(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(X)})}function mW(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(X)})}function lW(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(X)})}function $4(Q,X){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...E(X)})}function cW(Q,X){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...E(X)})}function pW(Q,X){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(X)})}function dW(Q,X){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...E(X)})}function iW(Q,X){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(X)})}function nW(Q,X){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...E(X)})}function oW(Q,X){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...E(X)})}function rW(Q,X){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(X)})}function tW(Q,X){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(X)})}function aW(Q,X){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(X)})}function sW(Q,X){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(X)})}function eW(Q,X){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(X)})}function Q5(Q,X){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...E(X)})}function X5(Q,X){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...E(X)})}function Y5(Q,X){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...E(X)})}function J5(Q,X){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...E(X)})}function W5(Q,X){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(X)})}function $5(Q,X){return new Q({type:"string",format:"date",check:"string_format",...E(X)})}function B5(Q,X){return new Q({type:"string",format:"time",check:"string_format",precision:null,...E(X)})}function G5(Q,X){return new Q({type:"string",format:"duration",check:"string_format",...E(X)})}function H5(Q,X){return new Q({type:"number",checks:[],...E(X)})}function K5(Q,X){return new Q({type:"number",coerce:!0,checks:[],...E(X)})}function Z5(Q,X){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...E(X)})}function L5(Q,X){return new Q({type:"boolean",...E(X)})}function V5(Q,X){return new Q({type:"boolean",coerce:!0,...E(X)})}function D5(Q,X){return new Q({type:"bigint",coerce:!0,...E(X)})}function q5(Q,X){return new Q({type:"null",...E(X)})}function z5(Q){return new Q({type:"any"})}function F5(Q){return new Q({type:"unknown"})}function A5(Q,X){return new Q({type:"never",...E(X)})}function O5(Q,X){return new Q({type:"date",coerce:!0,...E(X)})}function n1(Q,X){return new r6({check:"less_than",...E(X),value:Q,inclusive:!1})}function e0(Q,X){return new r6({check:"less_than",...E(X),value:Q,inclusive:!0})}function o1(Q,X){return new t6({check:"greater_than",...E(X),value:Q,inclusive:!1})}function g0(Q,X){return new t6({check:"greater_than",...E(X),value:Q,inclusive:!0})}function m9(Q,X){return new q7({check:"multiple_of",...E(X),value:Q})}function t8(Q,X){return new F7({check:"max_length",...E(X),maximum:Q})}function r1(Q,X){return new A7({check:"min_length",...E(X),minimum:Q})}function a8(Q,X){return new O7({check:"length_equals",...E(X),length:Q})}function B4(Q,X){return new N7({check:"string_format",format:"regex",...E(X),pattern:Q})}function G4(Q){return new U7({check:"string_format",format:"lowercase",...E(Q)})}function H4(Q){return new M7({check:"string_format",format:"uppercase",...E(Q)})}function K4(Q,X){return new w7({check:"string_format",format:"includes",...E(X),includes:Q})}function Z4(Q,X){return new P7({check:"string_format",format:"starts_with",...E(X),prefix:Q})}function L4(Q,X){return new j7({check:"string_format",format:"ends_with",...E(X),suffix:Q})}function q1(Q){return new I7({check:"overwrite",tx:Q})}function V4(Q){return q1((X)=>X.normalize(Q))}function D4(){return q1((Q)=>Q.trim())}function q4(){return q1((Q)=>Q.toLowerCase())}function z4(){return q1((Q)=>Q.toUpperCase())}function F4(){return q1((Q)=>g6(Q))}function N5(Q,X,Y){return new Q({type:"array",element:X,...E(Y)})}function U5(Q,X,Y){let J=E(Y);return J.abort??(J.abort=!0),new Q({type:"custom",check:"custom",fn:X,...J})}function M5(Q,X,Y){return new Q({type:"custom",check:"custom",fn:X,...E(Y)})}function w5(Q,X){let Y=lV((J)=>{return J.addIssue=(W)=>{if(typeof W==="string")J.issues.push(i1(W,J.value,Y._zod.def));else{let $=W;if($.fatal)$.continue=!1;$.code??($.code="custom"),$.input??($.input=J.value),$.inst??($.inst=Y),$.continue??($.continue=!Y._zod.def.abort),J.issues.push(i1($))}},Q(J.value,J)},X);return Y}function lV(Q,X){let Y=new H0({check:"custom",...E(X)});return Y._zod.check=Q,Y}function A4(Q){let X=Q?.target??"draft-2020-12";if(X==="draft-4")X="draft-04";if(X==="draft-7")X="draft-07";return{processors:Q.processors??{},metadataRegistry:Q?.metadata??D1,target:X,unrepresentable:Q?.unrepresentable??"throw",override:Q?.override??(()=>{}),io:Q?.io??"output",counter:0,seen:new Map,cycles:Q?.cycles??"ref",reused:Q?.reused??"inline",external:Q?.external??void 0}}function X0(Q,X,Y={path:[],schemaPath:[]}){var J;let W=Q._zod.def,$=X.seen.get(Q);if($){if($.count++,Y.schemaPath.includes(Q))$.cycle=Y.path;return $.schema}let B={schema:{},count:1,cycle:void 0,path:Y.path};X.seen.set(Q,B);let G=Q._zod.toJSONSchema?.();if(G)B.schema=G;else{let Z={...Y,schemaPath:[...Y.schemaPath,Q],path:Y.path};if(Q._zod.processJSONSchema)Q._zod.processJSONSchema(X,B.schema,Z);else{let V=B.schema,D=X.processors[W.type];if(!D)throw Error(`[toJSONSchema]: Non-representable type encountered: ${W.type}`);D(Q,X,V,Z)}let L=Q._zod.parent;if(L){if(!B.ref)B.ref=L;X0(L,X,Z),X.seen.get(L).isParent=!0}}let K=X.metadataRegistry.get(Q);if(K)Object.assign(B.schema,K);if(X.io==="input"&&z0(Q))delete B.schema.examples,delete B.schema.default;if(X.io==="input"&&"_prefault"in B.schema)(J=B.schema).default??(J.default=B.schema._prefault);return delete B.schema._prefault,X.seen.get(Q).schema}function O4(Q,X){let Y=Q.seen.get(X);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let J=new Map;for(let B of Q.seen.entries()){let G=Q.metadataRegistry.get(B[0])?.id;if(G){let K=J.get(G);if(K&&K!==B[0])throw Error(`Duplicate schema id "${G}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);J.set(G,B[0])}}let W=(B)=>{let G=Q.target==="draft-2020-12"?"$defs":"definitions";if(Q.external){let L=Q.external.registry.get(B[0])?.id,V=Q.external.uri??((z)=>z);if(L)return{ref:V(L)};let D=B[1].defId??B[1].schema.id??`schema${Q.counter++}`;return B[1].defId=D,{defId:D,ref:`${V("__shared")}#/${G}/${D}`}}if(B[1]===Y)return{ref:"#"};let H=`${"#"}/${G}/`,Z=B[1].schema.id??`__schema${Q.counter++}`;return{defId:Z,ref:H+Z}},$=(B)=>{if(B[1].schema.$ref)return;let G=B[1],{ref:K,defId:H}=W(B);if(G.def={...G.schema},H)G.defId=H;let Z=G.schema;for(let L in Z)delete Z[L];Z.$ref=K};if(Q.cycles==="throw")for(let B of Q.seen.entries()){let G=B[1];if(G.cycle)throw Error(`Cycle detected: #/${G.cycle?.join("/")}/<root>
|
|
73
|
+
|
|
74
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let B of Q.seen.entries()){let G=B[1];if(X===B[0]){$(B);continue}if(Q.external){let H=Q.external.registry.get(B[0])?.id;if(X!==B[0]&&H){$(B);continue}}if(Q.metadataRegistry.get(B[0])?.id){$(B);continue}if(G.cycle){$(B);continue}if(G.count>1){if(Q.reused==="ref"){$(B);continue}}}}function N4(Q,X){let Y=Q.seen.get(X);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let J=(G)=>{let K=Q.seen.get(G);if(K.ref===null)return;let H=K.def??K.schema,Z={...H},L=K.ref;if(K.ref=null,L){J(L);let D=Q.seen.get(L),z=D.schema;if(z.$ref&&(Q.target==="draft-07"||Q.target==="draft-04"||Q.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(z);else Object.assign(H,z);if(Object.assign(H,Z),G._zod.parent===L)for(let N in H){if(N==="$ref"||N==="allOf")continue;if(!(N in Z))delete H[N]}if(z.$ref&&D.def)for(let N in H){if(N==="$ref"||N==="allOf")continue;if(N in D.def&&JSON.stringify(H[N])===JSON.stringify(D.def[N]))delete H[N]}}let V=G._zod.parent;if(V&&V!==L){J(V);let D=Q.seen.get(V);if(D?.schema.$ref){if(H.$ref=D.schema.$ref,D.def)for(let z in H){if(z==="$ref"||z==="allOf")continue;if(z in D.def&&JSON.stringify(H[z])===JSON.stringify(D.def[z]))delete H[z]}}}Q.override({zodSchema:G,jsonSchema:H,path:K.path??[]})};for(let G of[...Q.seen.entries()].reverse())J(G[0]);let W={};if(Q.target==="draft-2020-12")W.$schema="https://json-schema.org/draft/2020-12/schema";else if(Q.target==="draft-07")W.$schema="http://json-schema.org/draft-07/schema#";else if(Q.target==="draft-04")W.$schema="http://json-schema.org/draft-04/schema#";else if(Q.target==="openapi-3.0");if(Q.external?.uri){let G=Q.external.registry.get(X)?.id;if(!G)throw Error("Schema is missing an `id` property");W.$id=Q.external.uri(G)}Object.assign(W,Y.def??Y.schema);let $=Q.metadataRegistry.get(X)?.id;if($!==void 0&&W.id===$)delete W.id;let B=Q.external?.defs??{};for(let G of Q.seen.entries()){let K=G[1];if(K.def&&K.defId){if(K.def.id===K.defId)delete K.def.id;B[K.defId]=K.def}}if(Q.external);else if(Object.keys(B).length>0)if(Q.target==="draft-2020-12")W.$defs=B;else W.definitions=B;try{let G=JSON.parse(JSON.stringify(W));return Object.defineProperty(G,"~standard",{value:{...X["~standard"],jsonSchema:{input:l9(X,"input",Q.processors),output:l9(X,"output",Q.processors)}},enumerable:!1,writable:!1}),G}catch(G){throw Error("Error converting schema to JSON.")}}function z0(Q,X){let Y=X??{seen:new Set};if(Y.seen.has(Q))return!1;Y.seen.add(Q);let J=Q._zod.def;if(J.type==="transform")return!0;if(J.type==="array")return z0(J.element,Y);if(J.type==="set")return z0(J.valueType,Y);if(J.type==="lazy")return z0(J.getter(),Y);if(J.type==="promise"||J.type==="optional"||J.type==="nonoptional"||J.type==="nullable"||J.type==="readonly"||J.type==="default"||J.type==="prefault")return z0(J.innerType,Y);if(J.type==="intersection")return z0(J.left,Y)||z0(J.right,Y);if(J.type==="record"||J.type==="map")return z0(J.keyType,Y)||z0(J.valueType,Y);if(J.type==="pipe"){if(Q._zod.traits.has("$ZodCodec"))return!0;return z0(J.in,Y)||z0(J.out,Y)}if(J.type==="object"){for(let W in J.shape)if(z0(J.shape[W],Y))return!0;return!1}if(J.type==="union"){for(let W of J.options)if(z0(W,Y))return!0;return!1}if(J.type==="tuple"){for(let W of J.items)if(z0(W,Y))return!0;if(J.rest&&z0(J.rest,Y))return!0;return!1}return!1}var P5=(Q,X={})=>(Y)=>{let J=A4({...Y,processors:X});return X0(Q,J),O4(J,Q),N4(J,Q)},l9=(Q,X,Y={})=>(J)=>{let{libraryOptions:W,target:$}=J??{},B=A4({...W??{},target:$,io:X,processors:Y});return X0(Q,B),O4(B,Q),N4(B,Q)};var cV={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},j5=(Q,X,Y,J)=>{let W=Y;W.type="string";let{minimum:$,maximum:B,format:G,patterns:K,contentEncoding:H}=Q._zod.bag;if(typeof $==="number")W.minLength=$;if(typeof B==="number")W.maxLength=B;if(G){if(W.format=cV[G]??G,W.format==="")delete W.format;if(G==="time")delete W.format}if(H)W.contentEncoding=H;if(K&&K.size>0){let Z=[...K];if(Z.length===1)W.pattern=Z[0].source;else if(Z.length>1)W.allOf=[...Z.map((L)=>({...X.target==="draft-07"||X.target==="draft-04"||X.target==="openapi-3.0"?{type:"string"}:{},pattern:L.source}))]}},I5=(Q,X,Y,J)=>{let W=Y,{minimum:$,maximum:B,format:G,multipleOf:K,exclusiveMaximum:H,exclusiveMinimum:Z}=Q._zod.bag;if(typeof G==="string"&&G.includes("int"))W.type="integer";else W.type="number";let L=typeof Z==="number"&&Z>=($??Number.NEGATIVE_INFINITY),V=typeof H==="number"&&H<=(B??Number.POSITIVE_INFINITY),D=X.target==="draft-04"||X.target==="openapi-3.0";if(L)if(D)W.minimum=Z,W.exclusiveMinimum=!0;else W.exclusiveMinimum=Z;else if(typeof $==="number")W.minimum=$;if(V)if(D)W.maximum=H,W.exclusiveMaximum=!0;else W.exclusiveMaximum=H;else if(typeof B==="number")W.maximum=B;if(typeof K==="number")W.multipleOf=K},b5=(Q,X,Y,J)=>{Y.type="boolean"},T5=(Q,X,Y,J)=>{if(X.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")};var R5=(Q,X,Y,J)=>{if(X.target==="openapi-3.0")Y.type="string",Y.nullable=!0,Y.enum=[null];else Y.type="null"};var E5=(Q,X,Y,J)=>{Y.not={}},S5=(Q,X,Y,J)=>{},C5=(Q,X,Y,J)=>{},k5=(Q,X,Y,J)=>{if(X.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},_5=(Q,X,Y,J)=>{let W=Q._zod.def,$=k9(W.entries);if($.every((B)=>typeof B==="number"))Y.type="number";if($.every((B)=>typeof B==="string"))Y.type="string";Y.enum=$},x5=(Q,X,Y,J)=>{let W=Q._zod.def,$=[];for(let B of W.values)if(B===void 0){if(X.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof B==="bigint")if(X.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else $.push(Number(B));else $.push(B);if($.length===0);else if($.length===1){let B=$[0];if(Y.type=B===null?"null":typeof B,X.target==="draft-04"||X.target==="openapi-3.0")Y.enum=[B];else Y.const=B}else{if($.every((B)=>typeof B==="number"))Y.type="number";if($.every((B)=>typeof B==="string"))Y.type="string";if($.every((B)=>typeof B==="boolean"))Y.type="boolean";if($.every((B)=>B===null))Y.type="null";Y.enum=$}};var v5=(Q,X,Y,J)=>{if(X.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")};var y5=(Q,X,Y,J)=>{if(X.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")};var g5=(Q,X,Y,J)=>{let W=Y,$=Q._zod.def,{minimum:B,maximum:G}=Q._zod.bag;if(typeof B==="number")W.minItems=B;if(typeof G==="number")W.maxItems=G;W.type="array",W.items=X0($.element,X,{...J,path:[...J.path,"items"]})},f5=(Q,X,Y,J)=>{let W=Y,$=Q._zod.def;W.type="object",W.properties={};let B=$.shape;for(let H in B)W.properties[H]=X0(B[H],X,{...J,path:[...J.path,"properties",H]});let G=new Set(Object.keys(B)),K=new Set([...G].filter((H)=>{let Z=$.shape[H]._zod;if(X.io==="input")return Z.optin===void 0;else return Z.optout===void 0}));if(K.size>0)W.required=Array.from(K);if($.catchall?._zod.def.type==="never")W.additionalProperties=!1;else if(!$.catchall){if(X.io==="output")W.additionalProperties=!1}else if($.catchall)W.additionalProperties=X0($.catchall,X,{...J,path:[...J.path,"additionalProperties"]})},h5=(Q,X,Y,J)=>{let W=Q._zod.def,$=W.inclusive===!1,B=W.options.map((G,K)=>X0(G,X,{...J,path:[...J.path,$?"oneOf":"anyOf",K]}));if($)Y.oneOf=B;else Y.anyOf=B},u5=(Q,X,Y,J)=>{let W=Q._zod.def,$=X0(W.left,X,{...J,path:[...J.path,"allOf",0]}),B=X0(W.right,X,{...J,path:[...J.path,"allOf",1]}),G=(H)=>("allOf"in H)&&Object.keys(H).length===1,K=[...G($)?$.allOf:[$],...G(B)?B.allOf:[B]];Y.allOf=K};var m5=(Q,X,Y,J)=>{let W=Y,$=Q._zod.def;W.type="object";let B=$.keyType,K=B._zod.bag?.patterns;if($.mode==="loose"&&K&&K.size>0){let Z=X0($.valueType,X,{...J,path:[...J.path,"patternProperties","*"]});W.patternProperties={};for(let L of K)W.patternProperties[L.source]=Z}else{if(X.target==="draft-07"||X.target==="draft-2020-12")W.propertyNames=X0($.keyType,X,{...J,path:[...J.path,"propertyNames"]});W.additionalProperties=X0($.valueType,X,{...J,path:[...J.path,"additionalProperties"]})}let H=B._zod.values;if(H){let Z=[...H].filter((L)=>typeof L==="string"||typeof L==="number");if(Z.length>0)W.required=Z}},l5=(Q,X,Y,J)=>{let W=Q._zod.def,$=X0(W.innerType,X,J),B=X.seen.get(Q);if(X.target==="openapi-3.0")B.ref=W.innerType,Y.nullable=!0;else Y.anyOf=[$,{type:"null"}]},c5=(Q,X,Y,J)=>{let W=Q._zod.def;X0(W.innerType,X,J);let $=X.seen.get(Q);$.ref=W.innerType},p5=(Q,X,Y,J)=>{let W=Q._zod.def;X0(W.innerType,X,J);let $=X.seen.get(Q);$.ref=W.innerType,Y.default=JSON.parse(JSON.stringify(W.defaultValue))},d5=(Q,X,Y,J)=>{let W=Q._zod.def;X0(W.innerType,X,J);let $=X.seen.get(Q);if($.ref=W.innerType,X.io==="input")Y._prefault=JSON.parse(JSON.stringify(W.defaultValue))},i5=(Q,X,Y,J)=>{let W=Q._zod.def;X0(W.innerType,X,J);let $=X.seen.get(Q);$.ref=W.innerType;let B;try{B=W.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Y.default=B},n5=(Q,X,Y,J)=>{let W=Q._zod.def,$=W.in._zod.traits.has("$ZodTransform"),B=X.io==="input"?$?W.out:W.in:W.out;X0(B,X,J);let G=X.seen.get(Q);G.ref=B},o5=(Q,X,Y,J)=>{let W=Q._zod.def;X0(W.innerType,X,J);let $=X.seen.get(Q);$.ref=W.innerType,Y.readOnly=!0};var U4=(Q,X,Y,J)=>{let W=Q._zod.def;X0(W.innerType,X,J);let $=X.seen.get(Q);$.ref=W.innerType};function a1(Q){return!!Q._zod}function f0(Q,X){if(a1(Q))return g9(Q,X);return Q.safeParse(X)}function s8(Q){if(!Q)return;let X;if(a1(Q))X=Q._zod?.def?.shape;else X=Q.shape;if(!X)return;if(typeof X==="function")try{return X()}catch{return}return X}function r5(Q){if(a1(Q)){let $=Q._zod?.def;if($){if($.value!==void 0)return $.value;if(Array.isArray($.values)&&$.values.length>0)return $.values[0]}}let Y=Q._def;if(Y){if(Y.value!==void 0)return Y.value;if(Array.isArray(Y.values)&&Y.values.length>0)return Y.values[0]}let J=Q.value;if(J!==void 0)return J;return}var c9={};I6(c9,{time:()=>P4,duration:()=>j4,datetime:()=>M4,date:()=>w4,ZodISOTime:()=>s5,ZodISODuration:()=>e5,ZodISODateTime:()=>t5,ZodISODate:()=>a5});var t5=O("ZodISODateTime",(Q,X)=>{n7.init(Q,X),a.init(Q,X)});function M4(Q){return W5(t5,Q)}var a5=O("ZodISODate",(Q,X)=>{o7.init(Q,X),a.init(Q,X)});function w4(Q){return $5(a5,Q)}var s5=O("ZodISOTime",(Q,X)=>{r7.init(Q,X),a.init(Q,X)});function P4(Q){return B5(s5,Q)}var e5=O("ZodISODuration",(Q,X)=>{t7.init(Q,X),a.init(Q,X)});function j4(Q){return G5(e5,Q)}var aV=(Q,X)=>{l8.init(Q,X),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(Y)=>i6(Q,Y)},flatten:{value:(Y)=>d6(Q,Y)},addIssue:{value:(Y)=>{Q.issues.push(Y),Q.message=JSON.stringify(Q.issues,p1,2)}},addIssues:{value:(Y)=>{Q.issues.push(...Y),Q.message=JSON.stringify(Q.issues,p1,2)}},isEmpty:{get(){return Q.issues.length===0}}})};var T0=O("ZodError",aV,{Parent:Error});var X$=c8(T0),Y$=p8(T0),J$=y9(T0),W$=f9(T0),$$=SJ(T0),B$=CJ(T0),G$=kJ(T0),H$=_J(T0),K$=xJ(T0),Z$=vJ(T0),L$=yJ(T0),V$=gJ(T0);var D$=new WeakMap;function p9(Q,X,Y){let J=Object.getPrototypeOf(Q),W=D$.get(J);if(!W)W=new Set,D$.set(J,W);if(W.has(X))return;W.add(X);for(let $ in Y){let B=Y[$];Object.defineProperty(J,$,{configurable:!0,enumerable:!1,get(){let G=B.bind(this);return Object.defineProperty(this,$,{configurable:!0,writable:!0,enumerable:!0,value:G}),G},set(G){Object.defineProperty(this,$,{configurable:!0,writable:!0,enumerable:!0,value:G})}})}}var c=O("ZodType",(Q,X)=>{return l.init(Q,X),Object.assign(Q["~standard"],{jsonSchema:{input:l9(Q,"input"),output:l9(Q,"output")}}),Q.toJSONSchema=P5(Q,{}),Q.def=X,Q.type=X.type,Object.defineProperty(Q,"_def",{value:X}),Q.parse=(Y,J)=>X$(Q,Y,J,{callee:Q.parse}),Q.safeParse=(Y,J)=>J$(Q,Y,J),Q.parseAsync=async(Y,J)=>Y$(Q,Y,J,{callee:Q.parseAsync}),Q.safeParseAsync=async(Y,J)=>W$(Q,Y,J),Q.spa=Q.safeParseAsync,Q.encode=(Y,J)=>$$(Q,Y,J),Q.decode=(Y,J)=>B$(Q,Y,J),Q.encodeAsync=async(Y,J)=>G$(Q,Y,J),Q.decodeAsync=async(Y,J)=>H$(Q,Y,J),Q.safeEncode=(Y,J)=>K$(Q,Y,J),Q.safeDecode=(Y,J)=>Z$(Q,Y,J),Q.safeEncodeAsync=async(Y,J)=>L$(Q,Y,J),Q.safeDecodeAsync=async(Y,J)=>V$(Q,Y,J),p9(Q,"ZodType",{check(...Y){let J=this.def;return this.clone(y.mergeDefs(J,{checks:[...J.checks??[],...Y.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}),{parent:!0})},with(...Y){return this.check(...Y)},clone(Y,J){return S0(this,Y,J)},brand(){return this},register(Y,J){return Y.add(this,J),this},refine(Y,J){return this.check(hD(Y,J))},superRefine(Y,J){return this.check(uD(Y,J))},overwrite(Y){return this.check(q1(Y))},optional(){return e(this)},exactOptional(){return TD(this)},nullable(){return A$(this)},nullish(){return e(A$(this))},nonoptional(Y){return _D(this,Y)},array(){return j(this)},or(Y){return r([this,Y])},and(Y){return XQ(this,Y)},transform(Y){return O$(this,R$(Y))},default(Y){return SD(this,Y)},prefault(Y){return kD(this,Y)},catch(Y){return vD(this,Y)},pipe(Y){return O$(this,Y)},readonly(){return fD(this)},describe(Y){let J=this.clone();return D1.add(J,{description:Y}),J},meta(...Y){if(Y.length===0)return D1.get(this);let J=this.clone();return D1.add(J,Y[0]),J},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(Y){return Y(this)}}),Object.defineProperty(Q,"description",{get(){return D1.get(Q)?.description},configurable:!0}),Q}),N$=O("_ZodString",(Q,X)=>{r8.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(J,W,$)=>j5(Q,J,W,$);let Y=Q._zod.bag;Q.format=Y.format??null,Q.minLength=Y.minimum??null,Q.maxLength=Y.maximum??null,p9(Q,"_ZodString",{regex(...J){return this.check(B4(...J))},includes(...J){return this.check(K4(...J))},startsWith(...J){return this.check(Z4(...J))},endsWith(...J){return this.check(L4(...J))},min(...J){return this.check(r1(...J))},max(...J){return this.check(t8(...J))},length(...J){return this.check(a8(...J))},nonempty(...J){return this.check(r1(1,...J))},lowercase(J){return this.check(G4(J))},uppercase(J){return this.check(H4(J))},trim(){return this.check(D4())},normalize(...J){return this.check(V4(...J))},toLowerCase(){return this.check(q4())},toUpperCase(){return this.check(z4())},slugify(){return this.check(F4())}})}),b4=O("ZodString",(Q,X)=>{r8.init(Q,X),N$.init(Q,X),Q.email=(Y)=>Q.check(fW(eV,Y)),Q.url=(Y)=>Q.check($4(U$,Y)),Q.jwt=(Y)=>Q.check(J5(qD,Y)),Q.emoji=(Y)=>Q.check(cW(QD,Y)),Q.guid=(Y)=>Q.check(W4(q$,Y)),Q.uuid=(Y)=>Q.check(hW(e8,Y)),Q.uuidv4=(Y)=>Q.check(uW(e8,Y)),Q.uuidv6=(Y)=>Q.check(mW(e8,Y)),Q.uuidv7=(Y)=>Q.check(lW(e8,Y)),Q.nanoid=(Y)=>Q.check(pW(XD,Y)),Q.guid=(Y)=>Q.check(W4(q$,Y)),Q.cuid=(Y)=>Q.check(dW(YD,Y)),Q.cuid2=(Y)=>Q.check(iW(JD,Y)),Q.ulid=(Y)=>Q.check(nW(WD,Y)),Q.base64=(Y)=>Q.check(Q5(LD,Y)),Q.base64url=(Y)=>Q.check(X5(VD,Y)),Q.xid=(Y)=>Q.check(oW($D,Y)),Q.ksuid=(Y)=>Q.check(rW(BD,Y)),Q.ipv4=(Y)=>Q.check(tW(GD,Y)),Q.ipv6=(Y)=>Q.check(aW(HD,Y)),Q.cidrv4=(Y)=>Q.check(sW(KD,Y)),Q.cidrv6=(Y)=>Q.check(eW(ZD,Y)),Q.e164=(Y)=>Q.check(Y5(DD,Y)),Q.datetime=(Y)=>Q.check(M4(Y)),Q.date=(Y)=>Q.check(w4(Y)),Q.time=(Y)=>Q.check(P4(Y)),Q.duration=(Y)=>Q.check(j4(Y))});function q(Q){return yW(b4,Q)}var a=O("ZodStringFormat",(Q,X)=>{o.init(Q,X),N$.init(Q,X)}),eV=O("ZodEmail",(Q,X)=>{f7.init(Q,X),a.init(Q,X)});var q$=O("ZodGUID",(Q,X)=>{y7.init(Q,X),a.init(Q,X)});var e8=O("ZodUUID",(Q,X)=>{g7.init(Q,X),a.init(Q,X)});var U$=O("ZodURL",(Q,X)=>{h7.init(Q,X),a.init(Q,X)});function M$(Q){return $4(U$,Q)}var QD=O("ZodEmoji",(Q,X)=>{u7.init(Q,X),a.init(Q,X)});var XD=O("ZodNanoID",(Q,X)=>{m7.init(Q,X),a.init(Q,X)});var YD=O("ZodCUID",(Q,X)=>{l7.init(Q,X),a.init(Q,X)});var JD=O("ZodCUID2",(Q,X)=>{c7.init(Q,X),a.init(Q,X)});var WD=O("ZodULID",(Q,X)=>{p7.init(Q,X),a.init(Q,X)});var $D=O("ZodXID",(Q,X)=>{d7.init(Q,X),a.init(Q,X)});var BD=O("ZodKSUID",(Q,X)=>{i7.init(Q,X),a.init(Q,X)});var GD=O("ZodIPv4",(Q,X)=>{a7.init(Q,X),a.init(Q,X)});var HD=O("ZodIPv6",(Q,X)=>{s7.init(Q,X),a.init(Q,X)});var KD=O("ZodCIDRv4",(Q,X)=>{e7.init(Q,X),a.init(Q,X)});var ZD=O("ZodCIDRv6",(Q,X)=>{QW.init(Q,X),a.init(Q,X)});var LD=O("ZodBase64",(Q,X)=>{YW.init(Q,X),a.init(Q,X)});var VD=O("ZodBase64URL",(Q,X)=>{JW.init(Q,X),a.init(Q,X)});var DD=O("ZodE164",(Q,X)=>{WW.init(Q,X),a.init(Q,X)});var qD=O("ZodJWT",(Q,X)=>{$W.init(Q,X),a.init(Q,X)});var QQ=O("ZodNumber",(Q,X)=>{e6.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(J,W,$)=>I5(Q,J,W,$),p9(Q,"ZodNumber",{gt(J,W){return this.check(o1(J,W))},gte(J,W){return this.check(g0(J,W))},min(J,W){return this.check(g0(J,W))},lt(J,W){return this.check(n1(J,W))},lte(J,W){return this.check(e0(J,W))},max(J,W){return this.check(e0(J,W))},int(J){return this.check(z$(J))},safe(J){return this.check(z$(J))},positive(J){return this.check(o1(0,J))},nonnegative(J){return this.check(g0(0,J))},negative(J){return this.check(n1(0,J))},nonpositive(J){return this.check(e0(0,J))},multipleOf(J,W){return this.check(m9(J,W))},step(J,W){return this.check(m9(J,W))},finite(){return this}});let Y=Q._zod.bag;Q.minValue=Math.max(Y.minimum??Number.NEGATIVE_INFINITY,Y.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(Y.maximum??Number.POSITIVE_INFINITY,Y.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(Y.format??"").includes("int")||Number.isSafeInteger(Y.multipleOf??0.5),Q.isFinite=!0,Q.format=Y.format??null});function u(Q){return H5(QQ,Q)}var zD=O("ZodNumberFormat",(Q,X)=>{BW.init(Q,X),QQ.init(Q,X)});function z$(Q){return Z5(zD,Q)}var T4=O("ZodBoolean",(Q,X)=>{GW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>b5(Q,Y,J,W)});function p(Q){return L5(T4,Q)}var w$=O("ZodBigInt",(Q,X)=>{HW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(J,W,$)=>T5(Q,J,W,$),Q.gte=(J,W)=>Q.check(g0(J,W)),Q.min=(J,W)=>Q.check(g0(J,W)),Q.gt=(J,W)=>Q.check(o1(J,W)),Q.gte=(J,W)=>Q.check(g0(J,W)),Q.min=(J,W)=>Q.check(g0(J,W)),Q.lt=(J,W)=>Q.check(n1(J,W)),Q.lte=(J,W)=>Q.check(e0(J,W)),Q.max=(J,W)=>Q.check(e0(J,W)),Q.positive=(J)=>Q.check(o1(BigInt(0),J)),Q.negative=(J)=>Q.check(n1(BigInt(0),J)),Q.nonpositive=(J)=>Q.check(e0(BigInt(0),J)),Q.nonnegative=(J)=>Q.check(g0(BigInt(0),J)),Q.multipleOf=(J,W)=>Q.check(m9(J,W));let Y=Q._zod.bag;Q.minValue=Y.minimum??null,Q.maxValue=Y.maximum??null,Q.format=Y.format??null});var FD=O("ZodNull",(Q,X)=>{KW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>R5(Q,Y,J,W)});function P$(Q){return q5(FD,Q)}var AD=O("ZodAny",(Q,X)=>{ZW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>S5(Q,Y,J,W)});function j$(){return z5(AD)}var OD=O("ZodUnknown",(Q,X)=>{LW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>C5(Q,Y,J,W)});function s(){return F5(OD)}var ND=O("ZodNever",(Q,X)=>{VW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>E5(Q,Y,J,W)});function UD(Q){return A5(ND,Q)}var I$=O("ZodDate",(Q,X)=>{DW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(J,W,$)=>k5(Q,J,W,$),Q.min=(J,W)=>Q.check(g0(J,W)),Q.max=(J,W)=>Q.check(e0(J,W));let Y=Q._zod.bag;Q.minDate=Y.minimum?new Date(Y.minimum):null,Q.maxDate=Y.maximum?new Date(Y.maximum):null});var MD=O("ZodArray",(Q,X)=>{qW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>g5(Q,Y,J,W),Q.element=X.element,p9(Q,"ZodArray",{min(Y,J){return this.check(r1(Y,J))},nonempty(Y){return this.check(r1(1,Y))},max(Y,J){return this.check(t8(Y,J))},length(Y,J){return this.check(a8(Y,J))},unwrap(){return this.element}})});function j(Q,X){return N5(MD,Q,X)}var b$=O("ZodObject",(Q,X)=>{AW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>f5(Q,Y,J,W),y.defineLazy(Q,"shape",()=>{return X.shape}),p9(Q,"ZodObject",{keyof(){return U0(Object.keys(this._zod.def.shape))},catchall(Y){return this.clone({...this._zod.def,catchall:Y})},passthrough(){return this.clone({...this._zod.def,catchall:s()})},loose(){return this.clone({...this._zod.def,catchall:s()})},strict(){return this.clone({...this._zod.def,catchall:UD()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(Y){return y.extend(this,Y)},safeExtend(Y){return y.safeExtend(this,Y)},merge(Y){return y.merge(this,Y)},pick(Y){return y.pick(this,Y)},omit(Y){return y.omit(this,Y)},partial(...Y){return y.partial(E$,this,Y[0])},required(...Y){return y.required(S$,this,Y[0])}})});function I(Q,X){let Y={type:"object",shape:Q??{},...y.normalizeParams(X)};return new b$(Y)}function W0(Q,X){return new b$({type:"object",shape:Q,catchall:s(),...y.normalizeParams(X)})}var T$=O("ZodUnion",(Q,X)=>{Q4.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>h5(Q,Y,J,W),Q.options=X.options});function r(Q,X){return new T$({type:"union",options:Q,...y.normalizeParams(X)})}var wD=O("ZodDiscriminatedUnion",(Q,X)=>{T$.init(Q,X),OW.init(Q,X)});function R4(Q,X,Y){return new wD({type:"union",options:X,discriminator:Q,...y.normalizeParams(Y)})}var PD=O("ZodIntersection",(Q,X)=>{NW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>u5(Q,Y,J,W)});function XQ(Q,X){return new PD({type:"intersection",left:Q,right:X})}var F$=O("ZodRecord",(Q,X)=>{UW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>m5(Q,Y,J,W),Q.keyType=X.keyType,Q.valueType=X.valueType});function i(Q,X,Y){if(!X||!X._zod)return new F$({type:"record",keyType:q(),valueType:Q,...y.normalizeParams(X)});return new F$({type:"record",keyType:Q,valueType:X,...y.normalizeParams(Y)})}var I4=O("ZodEnum",(Q,X)=>{MW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(J,W,$)=>_5(Q,J,W,$),Q.enum=X.entries,Q.options=Object.values(X.entries);let Y=new Set(Object.keys(X.entries));Q.extract=(J,W)=>{let $={};for(let B of J)if(Y.has(B))$[B]=X.entries[B];else throw Error(`Key ${B} not found in enum`);return new I4({...X,checks:[],...y.normalizeParams(W),entries:$})},Q.exclude=(J,W)=>{let $={...X.entries};for(let B of J)if(Y.has(B))delete $[B];else throw Error(`Key ${B} not found in enum`);return new I4({...X,checks:[],...y.normalizeParams(W),entries:$})}});function U0(Q,X){let Y=Array.isArray(Q)?Object.fromEntries(Q.map((J)=>[J,J])):Q;return new I4({type:"enum",entries:Y,...y.normalizeParams(X)})}var jD=O("ZodLiteral",(Q,X)=>{wW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>x5(Q,Y,J,W),Q.values=new Set(X.values),Object.defineProperty(Q,"value",{get(){if(X.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return X.values[0]}})});function T(Q,X){return new jD({type:"literal",values:Array.isArray(Q)?Q:[Q],...y.normalizeParams(X)})}var ID=O("ZodTransform",(Q,X)=>{PW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>y5(Q,Y,J,W),Q._zod.parse=(Y,J)=>{if(J.direction==="backward")throw new S9(Q.constructor.name);Y.addIssue=($)=>{if(typeof $==="string")Y.issues.push(y.issue($,Y.value,X));else{let B=$;if(B.fatal)B.continue=!1;B.code??(B.code="custom"),B.input??(B.input=Y.value),B.inst??(B.inst=Q),Y.issues.push(y.issue(B))}};let W=X.transform(Y.value,Y);if(W instanceof Promise)return W.then(($)=>{return Y.value=$,Y.fallback=!0,Y});return Y.value=W,Y.fallback=!0,Y}});function R$(Q){return new ID({type:"transform",transform:Q})}var E$=O("ZodOptional",(Q,X)=>{X4.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>U4(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType});function e(Q){return new E$({type:"optional",innerType:Q})}var bD=O("ZodExactOptional",(Q,X)=>{jW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>U4(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType});function TD(Q){return new bD({type:"optional",innerType:Q})}var RD=O("ZodNullable",(Q,X)=>{IW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>l5(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType});function A$(Q){return new RD({type:"nullable",innerType:Q})}var ED=O("ZodDefault",(Q,X)=>{bW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>p5(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function SD(Q,X){return new ED({type:"default",innerType:Q,get defaultValue(){return typeof X==="function"?X():y.shallowClone(X)}})}var CD=O("ZodPrefault",(Q,X)=>{TW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>d5(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType});function kD(Q,X){return new CD({type:"prefault",innerType:Q,get defaultValue(){return typeof X==="function"?X():y.shallowClone(X)}})}var S$=O("ZodNonOptional",(Q,X)=>{RW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>c5(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType});function _D(Q,X){return new S$({type:"nonoptional",innerType:Q,...y.normalizeParams(X)})}var xD=O("ZodCatch",(Q,X)=>{EW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>i5(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function vD(Q,X){return new xD({type:"catch",innerType:Q,catchValue:typeof X==="function"?X:()=>X})}var C$=O("ZodPipe",(Q,X)=>{Y4.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>n5(Q,Y,J,W),Q.in=X.in,Q.out=X.out});function O$(Q,X){return new C$({type:"pipe",in:Q,out:X})}var yD=O("ZodPreprocess",(Q,X)=>{C$.init(Q,X),SW.init(Q,X)}),gD=O("ZodReadonly",(Q,X)=>{CW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>o5(Q,Y,J,W),Q.unwrap=()=>Q._zod.def.innerType});function fD(Q){return new gD({type:"readonly",innerType:Q})}var k$=O("ZodCustom",(Q,X)=>{kW.init(Q,X),c.init(Q,X),Q._zod.processJSONSchema=(Y,J,W)=>v5(Q,Y,J,W)});function _$(Q,X){return U5(k$,Q??(()=>!0),X)}function hD(Q,X={}){return M5(k$,Q,X)}function uD(Q,X){return w5(Q,X)}function E4(Q,X){return new yD({type:"pipe",in:R$(Q),out:X})}var v$={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 x$;(function(Q){})(x$||(x$={}));var YQ={};I6(YQ,{string:()=>mD,number:()=>lD,date:()=>dD,boolean:()=>cD,bigint:()=>pD});function mD(Q){return gW(b4,Q)}function lD(Q){return K5(QQ,Q)}function cD(Q){return V5(T4,Q)}function pD(Q){return D5(w$,Q)}function dD(Q){return O5(I$,Q)}N0(J4());var e1="2025-11-25";var y$=[e1,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],z1="io.modelcontextprotocol/related-task",WQ="2.0",$0=_$((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),g$=r([q(),u().int()]),f$=q(),MR=W0({ttl:u().optional(),pollInterval:u().optional()}),nD=I({ttl:u().optional()}),oD=I({taskId:q()}),S4=W0({progressToken:g$.optional(),[z1]:oD.optional()}),R0=I({_meta:S4.optional()}),d9=R0.extend({task:nD.optional()}),h$=(Q)=>d9.safeParse(Q).success,K0=I({method:q(),params:R0.loose().optional()}),k0=I({_meta:S4.optional()}),_0=I({method:q(),params:k0.loose().optional()}),Z0=W0({_meta:S4.optional()}),$Q=r([q(),u().int()]),u$=I({jsonrpc:T(WQ),id:$Q,...K0.shape}).strict(),i9=(Q)=>u$.safeParse(Q).success,m$=I({jsonrpc:T(WQ),..._0.shape}).strict(),l$=(Q)=>m$.safeParse(Q).success,C4=I({jsonrpc:T(WQ),id:$Q,result:Z0}).strict(),E1=(Q)=>C4.safeParse(Q).success;var C;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(C||(C={}));var k4=I({jsonrpc:T(WQ),id:$Q.optional(),error:I({code:u().int(),message:q(),data:s().optional()})}).strict();var c$=(Q)=>k4.safeParse(Q).success;var F1=r([u$,m$,C4,k4]),wR=r([C4,k4]),S1=Z0.strict(),rD=k0.extend({requestId:$Q.optional(),reason:q().optional()}),BQ=_0.extend({method:T("notifications/cancelled"),params:rD}),tD=I({src:q(),mimeType:q().optional(),sizes:j(q()).optional(),theme:U0(["light","dark"]).optional()}),n9=I({icons:j(tD).optional()}),s1=I({name:q(),title:q().optional()}),p$=s1.extend({...s1.shape,...n9.shape,version:q(),websiteUrl:q().optional(),description:q().optional()}),aD=XQ(I({applyDefaults:p().optional()}),i(q(),s())),sD=E4((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},XQ(I({form:aD.optional(),url:$0.optional()}),i(q(),s()).optional())),eD=W0({list:$0.optional(),cancel:$0.optional(),requests:W0({sampling:W0({createMessage:$0.optional()}).optional(),elicitation:W0({create:$0.optional()}).optional()}).optional()}),Qq=W0({list:$0.optional(),cancel:$0.optional(),requests:W0({tools:W0({call:$0.optional()}).optional()}).optional()}),Xq=I({experimental:i(q(),$0).optional(),sampling:I({context:$0.optional(),tools:$0.optional()}).optional(),elicitation:sD.optional(),roots:I({listChanged:p().optional()}).optional(),tasks:eD.optional(),extensions:i(q(),$0).optional()}),Yq=R0.extend({protocolVersion:q(),capabilities:Xq,clientInfo:p$}),Jq=K0.extend({method:T("initialize"),params:Yq});var Wq=I({experimental:i(q(),$0).optional(),logging:$0.optional(),completions:$0.optional(),prompts:I({listChanged:p().optional()}).optional(),resources:I({subscribe:p().optional(),listChanged:p().optional()}).optional(),tools:I({listChanged:p().optional()}).optional(),tasks:Qq.optional(),extensions:i(q(),$0).optional()}),_4=Z0.extend({protocolVersion:q(),capabilities:Wq,serverInfo:p$,instructions:q().optional()}),d$=_0.extend({method:T("notifications/initialized"),params:k0.optional()}),i$=(Q)=>d$.safeParse(Q).success,GQ=K0.extend({method:T("ping"),params:R0.optional()}),$q=I({progress:u(),total:e(u()),message:e(q())}),Bq=I({...k0.shape,...$q.shape,progressToken:g$}),HQ=_0.extend({method:T("notifications/progress"),params:Bq}),Gq=R0.extend({cursor:f$.optional()}),o9=K0.extend({params:Gq.optional()}),r9=Z0.extend({nextCursor:f$.optional()}),Hq=U0(["working","input_required","completed","failed","cancelled"]),t9=I({taskId:q(),status:Hq,ttl:r([u(),P$()]),createdAt:q(),lastUpdatedAt:q(),pollInterval:e(u()),statusMessage:e(q())}),C1=Z0.extend({task:t9}),Kq=k0.merge(t9),a9=_0.extend({method:T("notifications/tasks/status"),params:Kq}),KQ=K0.extend({method:T("tasks/get"),params:R0.extend({taskId:q()})}),ZQ=Z0.merge(t9),LQ=K0.extend({method:T("tasks/result"),params:R0.extend({taskId:q()})}),PR=Z0.loose(),VQ=o9.extend({method:T("tasks/list")}),DQ=r9.extend({tasks:j(t9)}),qQ=K0.extend({method:T("tasks/cancel"),params:R0.extend({taskId:q()})}),n$=Z0.merge(t9),o$=I({uri:q(),mimeType:e(q()),_meta:i(q(),s()).optional()}),r$=o$.extend({text:q()}),x4=q().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),t$=o$.extend({blob:x4}),s9=U0(["user","assistant"]),Q9=I({audience:j(s9).optional(),priority:u().min(0).max(1).optional(),lastModified:c9.datetime({offset:!0}).optional()}),a$=I({...s1.shape,...n9.shape,uri:q(),description:e(q()),mimeType:e(q()),size:e(u()),annotations:Q9.optional(),_meta:e(W0({}))}),Zq=I({...s1.shape,...n9.shape,uriTemplate:q(),description:e(q()),mimeType:e(q()),annotations:Q9.optional(),_meta:e(W0({}))}),Lq=o9.extend({method:T("resources/list")}),v4=r9.extend({resources:j(a$)}),Vq=o9.extend({method:T("resources/templates/list")}),y4=r9.extend({resourceTemplates:j(Zq)}),g4=R0.extend({uri:q()}),Dq=g4,qq=K0.extend({method:T("resources/read"),params:Dq}),f4=Z0.extend({contents:j(r([r$,t$]))}),h4=_0.extend({method:T("notifications/resources/list_changed"),params:k0.optional()}),zq=g4,Fq=K0.extend({method:T("resources/subscribe"),params:zq}),Aq=g4,Oq=K0.extend({method:T("resources/unsubscribe"),params:Aq}),Nq=k0.extend({uri:q()}),Uq=_0.extend({method:T("notifications/resources/updated"),params:Nq}),Mq=I({name:q(),description:e(q()),required:e(p())}),wq=I({...s1.shape,...n9.shape,description:e(q()),arguments:e(j(Mq)),_meta:e(W0({}))}),Pq=o9.extend({method:T("prompts/list")}),u4=r9.extend({prompts:j(wq)}),jq=R0.extend({name:q(),arguments:i(q(),q()).optional()}),Iq=K0.extend({method:T("prompts/get"),params:jq}),m4=I({type:T("text"),text:q(),annotations:Q9.optional(),_meta:i(q(),s()).optional()}),l4=I({type:T("image"),data:x4,mimeType:q(),annotations:Q9.optional(),_meta:i(q(),s()).optional()}),c4=I({type:T("audio"),data:x4,mimeType:q(),annotations:Q9.optional(),_meta:i(q(),s()).optional()}),bq=I({type:T("tool_use"),name:q(),id:q(),input:i(q(),s()),_meta:i(q(),s()).optional()}),Tq=I({type:T("resource"),resource:r([r$,t$]),annotations:Q9.optional(),_meta:i(q(),s()).optional()}),Rq=a$.extend({type:T("resource_link")}),p4=r([m4,l4,c4,Rq,Tq]),Eq=I({role:s9,content:p4}),d4=Z0.extend({description:q().optional(),messages:j(Eq)}),i4=_0.extend({method:T("notifications/prompts/list_changed"),params:k0.optional()}),Sq=I({title:q().optional(),readOnlyHint:p().optional(),destructiveHint:p().optional(),idempotentHint:p().optional(),openWorldHint:p().optional()}),Cq=I({taskSupport:U0(["required","optional","forbidden"]).optional()}),s$=I({...s1.shape,...n9.shape,description:q().optional(),inputSchema:I({type:T("object"),properties:i(q(),$0).optional(),required:j(q()).optional()}).catchall(s()),outputSchema:I({type:T("object"),properties:i(q(),$0).optional(),required:j(q()).optional()}).catchall(s()).optional(),annotations:Sq.optional(),execution:Cq.optional(),_meta:i(q(),s()).optional()}),kq=o9.extend({method:T("tools/list")}),n4=r9.extend({tools:j(s$)}),Q1=Z0.extend({content:j(p4).default([]),structuredContent:i(q(),s()).optional(),isError:p().optional()}),jR=Q1.or(Z0.extend({toolResult:s()})),_q=d9.extend({name:q(),arguments:i(q(),s()).optional()}),xq=K0.extend({method:T("tools/call"),params:_q}),o4=_0.extend({method:T("notifications/tools/list_changed"),params:k0.optional()}),e$=I({autoRefresh:p().default(!0),debounceMs:u().int().nonnegative().default(300)}),Q3=U0(["debug","info","notice","warning","error","critical","alert","emergency"]),vq=R0.extend({level:Q3}),yq=K0.extend({method:T("logging/setLevel"),params:vq}),gq=k0.extend({level:Q3,logger:q().optional(),data:s()}),fq=_0.extend({method:T("notifications/message"),params:gq}),hq=I({name:q().optional()}),uq=I({hints:j(hq).optional(),costPriority:u().min(0).max(1).optional(),speedPriority:u().min(0).max(1).optional(),intelligencePriority:u().min(0).max(1).optional()}),mq=I({mode:U0(["auto","required","none"]).optional()}),lq=I({type:T("tool_result"),toolUseId:q().describe("The unique identifier for the corresponding tool call."),content:j(p4).default([]),structuredContent:I({}).loose().optional(),isError:p().optional(),_meta:i(q(),s()).optional()}),cq=R4("type",[m4,l4,c4]),JQ=R4("type",[m4,l4,c4,bq,lq]),pq=I({role:s9,content:r([JQ,j(JQ)]),_meta:i(q(),s()).optional()}),dq=d9.extend({messages:j(pq),modelPreferences:uq.optional(),systemPrompt:q().optional(),includeContext:U0(["none","thisServer","allServers"]).optional(),temperature:u().optional(),maxTokens:u().int(),stopSequences:j(q()).optional(),metadata:$0.optional(),tools:j(s$).optional(),toolChoice:mq.optional()}),r4=K0.extend({method:T("sampling/createMessage"),params:dq}),t4=Z0.extend({model:q(),stopReason:e(U0(["endTurn","stopSequence","maxTokens"]).or(q())),role:s9,content:cq}),a4=Z0.extend({model:q(),stopReason:e(U0(["endTurn","stopSequence","maxTokens","toolUse"]).or(q())),role:s9,content:r([JQ,j(JQ)])}),iq=I({type:T("boolean"),title:q().optional(),description:q().optional(),default:p().optional()}),nq=I({type:T("string"),title:q().optional(),description:q().optional(),minLength:u().optional(),maxLength:u().optional(),format:U0(["email","uri","date","date-time"]).optional(),default:q().optional()}),oq=I({type:U0(["number","integer"]),title:q().optional(),description:q().optional(),minimum:u().optional(),maximum:u().optional(),default:u().optional()}),rq=I({type:T("string"),title:q().optional(),description:q().optional(),enum:j(q()),default:q().optional()}),tq=I({type:T("string"),title:q().optional(),description:q().optional(),oneOf:j(I({const:q(),title:q()})),default:q().optional()}),aq=I({type:T("string"),title:q().optional(),description:q().optional(),enum:j(q()),enumNames:j(q()).optional(),default:q().optional()}),sq=r([rq,tq]),eq=I({type:T("array"),title:q().optional(),description:q().optional(),minItems:u().optional(),maxItems:u().optional(),items:I({type:T("string"),enum:j(q())}),default:j(q()).optional()}),Qz=I({type:T("array"),title:q().optional(),description:q().optional(),minItems:u().optional(),maxItems:u().optional(),items:I({anyOf:j(I({const:q(),title:q()}))}),default:j(q()).optional()}),Xz=r([eq,Qz]),Yz=r([aq,sq,Xz]),Jz=r([Yz,iq,nq,oq]),Wz=d9.extend({mode:T("form").optional(),message:q(),requestedSchema:I({type:T("object"),properties:i(q(),Jz),required:j(q()).optional()})}),$z=d9.extend({mode:T("url"),message:q(),elicitationId:q(),url:q().url()}),Bz=r([Wz,$z]),s4=K0.extend({method:T("elicitation/create"),params:Bz}),Gz=k0.extend({elicitationId:q()}),Hz=_0.extend({method:T("notifications/elicitation/complete"),params:Gz}),e4=Z0.extend({action:U0(["accept","decline","cancel"]),content:E4((Q)=>Q===null?void 0:Q,i(q(),r([q(),u(),p(),j(q())])).optional())}),Kz=I({type:T("ref/resource"),uri:q()});var Zz=I({type:T("ref/prompt"),name:q()}),Lz=R0.extend({ref:r([Zz,Kz]),argument:I({name:q(),value:q()}),context:I({arguments:i(q(),q()).optional()}).optional()}),Vz=K0.extend({method:T("completion/complete"),params:Lz});var QX=Z0.extend({completion:W0({values:j(q()).max(100),total:e(u().int()),hasMore:e(p())})}),Dz=I({uri:q().startsWith("file://"),name:q().optional(),_meta:i(q(),s()).optional()}),qz=K0.extend({method:T("roots/list"),params:R0.optional()}),zz=Z0.extend({roots:j(Dz)}),Fz=_0.extend({method:T("notifications/roots/list_changed"),params:k0.optional()}),IR=r([GQ,Jq,Vz,yq,Iq,Pq,Lq,Vq,qq,Fq,Oq,xq,kq,KQ,LQ,VQ,qQ]),bR=r([BQ,HQ,d$,Fz,a9]),TR=r([S1,t4,a4,e4,zz,ZQ,DQ,C1]),RR=r([GQ,r4,s4,qz,KQ,LQ,VQ,qQ]),ER=r([BQ,HQ,fq,Uq,h4,o4,i4,a9,Hz]),SR=r([S1,_4,QX,d4,u4,v4,y4,f4,Q1,n4,ZQ,DQ,C1]);class S extends Error{constructor(Q,X,Y){super(`MCP error ${Q}: ${X}`);this.code=Q,this.data=Y,this.name="McpError"}static fromError(Q,X,Y){if(Q===C.UrlElicitationRequired&&Y){let J=Y;if(J.elicitations)return new X3(J.elicitations,X)}return new S(Q,X,Y)}}class X3 extends S{constructor(Q,X=`URL elicitation${Q.length>1?"s":""} required`){super(C.UrlElicitationRequired,X,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function A1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var Az=Symbol("Let zodToJsonSchema decide on which parser to use");var K2=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function XX(Q){let Y=s8(Q)?.method;if(!Y)throw Error("Schema is missing a method literal");let J=r5(Y);if(typeof J!=="string")throw Error("Schema method literal must be a string");return J}function YX(Q,X){let Y=f0(Q,X);if(!Y.success)throw Y.error;return Y.data}var Pz=60000;class JX{constructor(Q){if(this._options=Q,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(BQ,(X)=>{this._oncancel(X)}),this.setNotificationHandler(HQ,(X)=>{this._onprogress(X)}),this.setRequestHandler(GQ,(X)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(KQ,async(X,Y)=>{let J=await this._taskStore.getTask(X.params.taskId,Y.sessionId);if(!J)throw new S(C.InvalidParams,"Failed to retrieve task: Task not found");return{...J}}),this.setRequestHandler(LQ,async(X,Y)=>{let J=async()=>{let W=X.params.taskId;if(this._taskMessageQueue){let B;while(B=await this._taskMessageQueue.dequeue(W,Y.sessionId)){if(B.type==="response"||B.type==="error"){let G=B.message,K=G.id,H=this._requestResolvers.get(K);if(H)if(this._requestResolvers.delete(K),B.type==="response")H(G);else{let Z=G,L=new S(Z.error.code,Z.error.message,Z.error.data);H(L)}else{let Z=B.type==="response"?"Response":"Error";this._onerror(Error(`${Z} handler missing for request ${K}`))}continue}await this._transport?.send(B.message,{relatedRequestId:Y.requestId})}}let $=await this._taskStore.getTask(W,Y.sessionId);if(!$)throw new S(C.InvalidParams,`Task not found: ${W}`);if(!A1($.status))return await this._waitForTaskUpdate(W,Y.signal),await J();if(A1($.status)){let B=await this._taskStore.getTaskResult(W,Y.sessionId);return this._clearTaskQueue(W),{...B,_meta:{...B._meta,[z1]:{taskId:W}}}}return await J()};return await J()}),this.setRequestHandler(VQ,async(X,Y)=>{try{let{tasks:J,nextCursor:W}=await this._taskStore.listTasks(X.params?.cursor,Y.sessionId);return{tasks:J,nextCursor:W,_meta:{}}}catch(J){throw new S(C.InvalidParams,`Failed to list tasks: ${J instanceof Error?J.message:String(J)}`)}}),this.setRequestHandler(qQ,async(X,Y)=>{try{let J=await this._taskStore.getTask(X.params.taskId,Y.sessionId);if(!J)throw new S(C.InvalidParams,`Task not found: ${X.params.taskId}`);if(A1(J.status))throw new S(C.InvalidParams,`Cannot cancel task in terminal status: ${J.status}`);await this._taskStore.updateTaskStatus(X.params.taskId,"cancelled","Client cancelled task execution.",Y.sessionId),this._clearTaskQueue(X.params.taskId);let W=await this._taskStore.getTask(X.params.taskId,Y.sessionId);if(!W)throw new S(C.InvalidParams,`Task not found after cancellation: ${X.params.taskId}`);return{_meta:{},...W}}catch(J){if(J instanceof S)throw J;throw new S(C.InvalidRequest,`Failed to cancel task: ${J instanceof Error?J.message:String(J)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,X,Y,J,W=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(J,X),startTime:Date.now(),timeout:X,maxTotalTimeout:Y,resetTimeoutOnProgress:W,onTimeout:J})}_resetTimeout(Q){let X=this._timeoutInfo.get(Q);if(!X)return!1;let Y=Date.now()-X.startTime;if(X.maxTotalTimeout&&Y>=X.maxTotalTimeout)throw this._timeoutInfo.delete(Q),S.fromError(C.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:X.maxTotalTimeout,totalElapsed:Y});return clearTimeout(X.timeoutId),X.timeoutId=setTimeout(X.onTimeout,X.timeout),!0}_cleanupTimeout(Q){let X=this._timeoutInfo.get(Q);if(X)clearTimeout(X.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){if(this._transport)throw Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=Q;let X=this.transport?.onclose;this._transport.onclose=()=>{X?.(),this._onclose()};let Y=this.transport?.onerror;this._transport.onerror=(W)=>{Y?.(W),this._onerror(W)};let J=this._transport?.onmessage;this._transport.onmessage=(W,$)=>{if(J?.(W,$),E1(W)||c$(W))this._onresponse(W);else if(i9(W))this._onrequest(W,$);else if(l$(W))this._onnotification(W);else this._onerror(Error(`Unknown message type: ${JSON.stringify(W)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let Y of this._timeoutInfo.values())clearTimeout(Y.timeoutId);this._timeoutInfo.clear();for(let Y of this._requestHandlerAbortControllers.values())Y.abort();this._requestHandlerAbortControllers.clear();let X=S.fromError(C.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let Y of Q.values())Y(X)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let X=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X(Q)).catch((Y)=>this._onerror(Error(`Uncaught error in notification handler: ${Y}`)))}_onrequest(Q,X){let Y=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,J=this._transport,W=Q.params?._meta?.[z1]?.taskId;if(Y===void 0){let H={jsonrpc:"2.0",id:Q.id,error:{code:C.MethodNotFound,message:"Method not found"}};if(W&&this._taskMessageQueue)this._enqueueTaskMessage(W,{type:"error",message:H,timestamp:Date.now()},J?.sessionId).catch((Z)=>this._onerror(Error(`Failed to enqueue error response: ${Z}`)));else J?.send(H).catch((Z)=>this._onerror(Error(`Failed to send an error response: ${Z}`)));return}let $=new AbortController;this._requestHandlerAbortControllers.set(Q.id,$);let B=h$(Q.params)?Q.params.task:void 0,G=this._taskStore?this.requestTaskStore(Q,J?.sessionId):void 0,K={signal:$.signal,sessionId:J?.sessionId,_meta:Q.params?._meta,sendNotification:async(H)=>{if($.signal.aborted)return;let Z={relatedRequestId:Q.id};if(W)Z.relatedTask={taskId:W};await this.notification(H,Z)},sendRequest:async(H,Z,L)=>{if($.signal.aborted)throw new S(C.ConnectionClosed,"Request was cancelled");let V={...L,relatedRequestId:Q.id};if(W&&!V.relatedTask)V.relatedTask={taskId:W};let D=V.relatedTask?.taskId??W;if(D&&G)await G.updateTaskStatus(D,"input_required");return await this.request(H,Z,V)},authInfo:X?.authInfo,requestId:Q.id,requestInfo:X?.requestInfo,taskId:W,taskStore:G,taskRequestedTtl:B?.ttl,closeSSEStream:X?.closeSSEStream,closeStandaloneSSEStream:X?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(B)this.assertTaskHandlerCapability(Q.method)}).then(()=>Y(Q,K)).then(async(H)=>{if($.signal.aborted)return;let Z={result:H,jsonrpc:"2.0",id:Q.id};if(W&&this._taskMessageQueue)await this._enqueueTaskMessage(W,{type:"response",message:Z,timestamp:Date.now()},J?.sessionId);else await J?.send(Z)},async(H)=>{if($.signal.aborted)return;let Z={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(H.code)?H.code:C.InternalError,message:H.message??"Internal error",...H.data!==void 0&&{data:H.data}}};if(W&&this._taskMessageQueue)await this._enqueueTaskMessage(W,{type:"error",message:Z,timestamp:Date.now()},J?.sessionId);else await J?.send(Z)}).catch((H)=>this._onerror(Error(`Failed to send response: ${H}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(Q.id)===$)this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:X,...Y}=Q.params,J=Number(X),W=this._progressHandlers.get(J);if(!W){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let $=this._responseHandlers.get(J),B=this._timeoutInfo.get(J);if(B&&$&&B.resetTimeoutOnProgress)try{this._resetTimeout(J)}catch(G){this._responseHandlers.delete(J),this._progressHandlers.delete(J),this._cleanupTimeout(J),$(G);return}W(Y)}_onresponse(Q){let X=Number(Q.id),Y=this._requestResolvers.get(X);if(Y){if(this._requestResolvers.delete(X),E1(Q))Y(Q);else{let $=new S(Q.error.code,Q.error.message,Q.error.data);Y($)}return}let J=this._responseHandlers.get(X);if(J===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(X),this._cleanupTimeout(X);let W=!1;if(E1(Q)&&Q.result&&typeof Q.result==="object"){let $=Q.result;if($.task&&typeof $.task==="object"){let B=$.task;if(typeof B.taskId==="string")W=!0,this._taskProgressTokens.set(B.taskId,X)}}if(!W)this._progressHandlers.delete(X);if(E1(Q))J(Q);else{let $=S.fromError(Q.error.code,Q.error.message,Q.error.data);J($)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,X,Y){let{task:J}=Y??{};if(!J){try{yield{type:"result",result:await this.request(Q,X,Y)}}catch($){yield{type:"error",error:$ instanceof S?$:new S(C.InternalError,String($))}}return}let W;try{let $=await this.request(Q,C1,Y);if($.task)W=$.task.taskId,yield{type:"taskCreated",task:$.task};else throw new S(C.InternalError,"Task creation did not return a task");while(!0){let B=await this.getTask({taskId:W},Y);if(yield{type:"taskStatus",task:B},A1(B.status)){if(B.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:W},X,Y)};else if(B.status==="failed")yield{type:"error",error:new S(C.InternalError,`Task ${W} failed`)};else if(B.status==="cancelled")yield{type:"error",error:new S(C.InternalError,`Task ${W} was cancelled`)};return}if(B.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:W},X,Y)};return}let G=B.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((K)=>setTimeout(K,G)),Y?.signal?.throwIfAborted()}}catch($){yield{type:"error",error:$ instanceof S?$:new S(C.InternalError,String($))}}}request(Q,X,Y){let{relatedRequestId:J,resumptionToken:W,onresumptiontoken:$,task:B,relatedTask:G}=Y??{};return new Promise((K,H)=>{let Z=(F)=>{H(F)};if(!this._transport){Z(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),B)this.assertTaskCapability(Q.method)}catch(F){Z(F);return}Y?.signal?.throwIfAborted();let L=this._requestMessageId++,V={...Q,jsonrpc:"2.0",id:L};if(Y?.onprogress)this._progressHandlers.set(L,Y.onprogress),V.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:L}};if(B)V.params={...V.params,task:B};if(G)V.params={...V.params,_meta:{...V.params?._meta||{},[z1]:G}};let D=(F)=>{this._responseHandlers.delete(L),this._progressHandlers.delete(L),this._cleanupTimeout(L),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:L,reason:String(F)}},{relatedRequestId:J,resumptionToken:W,onresumptiontoken:$}).catch((M)=>this._onerror(Error(`Failed to send cancellation: ${M}`)));let U=F instanceof S?F:new S(C.RequestTimeout,String(F));H(U)};this._responseHandlers.set(L,(F)=>{if(Y?.signal?.aborted)return;if(F instanceof Error)return H(F);try{let U=f0(X,F.result);if(!U.success)H(U.error);else K(U.data)}catch(U){H(U)}}),Y?.signal?.addEventListener("abort",()=>{D(Y?.signal?.reason)});let z=Y?.timeout??Pz,A=()=>D(S.fromError(C.RequestTimeout,"Request timed out",{timeout:z}));this._setupTimeout(L,z,Y?.maxTotalTimeout,A,Y?.resetTimeoutOnProgress??!1);let N=G?.taskId;if(N){let F=(U)=>{let M=this._responseHandlers.get(L);if(M)M(U);else this._onerror(Error(`Response handler missing for side-channeled request ${L}`))};this._requestResolvers.set(L,F),this._enqueueTaskMessage(N,{type:"request",message:V,timestamp:Date.now()}).catch((U)=>{this._cleanupTimeout(L),H(U)})}else this._transport.send(V,{relatedRequestId:J,resumptionToken:W,onresumptiontoken:$}).catch((F)=>{this._cleanupTimeout(L),H(F)})})}async getTask(Q,X){return this.request({method:"tasks/get",params:Q},ZQ,X)}async getTaskResult(Q,X,Y){return this.request({method:"tasks/result",params:Q},X,Y)}async listTasks(Q,X){return this.request({method:"tasks/list",params:Q},DQ,X)}async cancelTask(Q,X){return this.request({method:"tasks/cancel",params:Q},n$,X)}async notification(Q,X){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let Y=X?.relatedTask?.taskId;if(Y){let B={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[z1]:X.relatedTask}}};await this._enqueueTaskMessage(Y,{type:"notification",message:B,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!X?.relatedRequestId&&!X?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let B={...Q,jsonrpc:"2.0"};if(X?.relatedTask)B={...B,params:{...B.params,_meta:{...B.params?._meta||{},[z1]:X.relatedTask}}};this._transport?.send(B,X).catch((G)=>this._onerror(G))});return}let $={...Q,jsonrpc:"2.0"};if(X?.relatedTask)$={...$,params:{...$.params,_meta:{...$.params?._meta||{},[z1]:X.relatedTask}}};await this._transport.send($,X)}setRequestHandler(Q,X){let Y=XX(Q);this.assertRequestHandlerCapability(Y),this._requestHandlers.set(Y,(J,W)=>{let $=YX(Q,J);return Promise.resolve(X($,W))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,X){let Y=XX(Q);this._notificationHandlers.set(Y,(J)=>{let W=YX(Q,J);return Promise.resolve(X(W))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let X=this._taskProgressTokens.get(Q);if(X!==void 0)this._progressHandlers.delete(X),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,X,Y){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let J=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,X,Y,J)}async _clearTaskQueue(Q,X){if(this._taskMessageQueue){let Y=await this._taskMessageQueue.dequeueAll(Q,X);for(let J of Y)if(J.type==="request"&&i9(J.message)){let W=J.message.id,$=this._requestResolvers.get(W);if($)$(new S(C.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(W);else this._onerror(Error(`Resolver missing for request ${W} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,X){let Y=this._options?.defaultTaskPollInterval??1000;try{let J=await this._taskStore?.getTask(Q);if(J?.pollInterval)Y=J.pollInterval}catch{}return new Promise((J,W)=>{if(X.aborted){W(new S(C.InvalidRequest,"Request cancelled"));return}let $=setTimeout(J,Y);X.addEventListener("abort",()=>{clearTimeout($),W(new S(C.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,X){let Y=this._taskStore;if(!Y)throw Error("No task store configured");return{createTask:async(J)=>{if(!Q)throw Error("No request provided");return await Y.createTask(J,Q.id,{method:Q.method,params:Q.params},X)},getTask:async(J)=>{let W=await Y.getTask(J,X);if(!W)throw new S(C.InvalidParams,"Failed to retrieve task: Task not found");return W},storeTaskResult:async(J,W,$)=>{await Y.storeTaskResult(J,W,$,X);let B=await Y.getTask(J,X);if(B){let G=a9.parse({method:"notifications/tasks/status",params:B});if(await this.notification(G),A1(B.status))this._cleanupTaskProgressHandler(J)}},getTaskResult:(J)=>{return Y.getTaskResult(J,X)},updateTaskStatus:async(J,W,$)=>{let B=await Y.getTask(J,X);if(!B)throw new S(C.InvalidParams,`Task "${J}" not found - it may have been cleaned up`);if(A1(B.status))throw new S(C.InvalidParams,`Cannot update task "${J}" from terminal status "${B.status}" to "${W}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await Y.updateTaskStatus(J,W,$,X);let G=await Y.getTask(J,X);if(G){let K=a9.parse({method:"notifications/tasks/status",params:G});if(await this.notification(K),A1(G.status))this._cleanupTaskProgressHandler(J)}},listTasks:(J)=>{return Y.listTasks(J,X)}}}}function Y3(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function J3(Q,X){let Y={...Q};for(let J in X){let W=J,$=X[W];if($===void 0)continue;let B=Y[W];if(Y3(B)&&Y3($))Y[W]={...B,...$};else Y[W]=$}return Y}var hK=j6(sX(),1),uK=j6(fK(),1);function dP(){let Q=new hK.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return uK.default(Q),Q}class HY{constructor(Q){this._ajv=Q??dP()}getValidator(Q){let X="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(Y)=>{if(X(Y))return{valid:!0,data:Y,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(X.errors)}}}}class KY{constructor(Q){this._client=Q}async*callToolStream(Q,X=Q1,Y){let J=this._client,W={...Y,task:Y?.task??(J.isToolTask(Q.name)?{}:void 0)},$=J.requestStream({method:"tools/call",params:Q},X,W),B=J.getToolOutputValidator(Q.name);for await(let G of $){if(G.type==="result"&&B){let K=G.result;if(!K.structuredContent&&!K.isError){yield{type:"error",error:new S(C.InvalidRequest,`Tool ${Q.name} has an output schema but did not return structured content`)};return}if(K.structuredContent)try{let H=B(K.structuredContent);if(!H.valid){yield{type:"error",error:new S(C.InvalidParams,`Structured content does not match the tool's output schema: ${H.errorMessage}`)};return}}catch(H){if(H instanceof S){yield{type:"error",error:H};return}yield{type:"error",error:new S(C.InvalidParams,`Failed to validate structured content: ${H instanceof Error?H.message:String(H)}`)};return}}yield G}}async getTask(Q,X){return this._client.getTask({taskId:Q},X)}async getTaskResult(Q,X,Y){return this._client.getTaskResult({taskId:Q},X,Y)}async listTasks(Q,X){return this._client.listTasks(Q?{cursor:Q}:void 0,X)}async cancelTask(Q,X){return this._client.cancelTask({taskId:Q},X)}requestStream(Q,X,Y){return this._client.requestStream(Q,X,Y)}}function mK(Q,X,Y){if(!Q)throw Error(`${Y} does not support task creation (required for ${X})`);switch(X){case"tools/call":if(!Q.tools?.call)throw Error(`${Y} does not support task creation for tools/call (required for ${X})`);break;default:break}}function lK(Q,X,Y){if(!Q)throw Error(`${Y} does not support task creation (required for ${X})`);switch(X){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${Y} does not support task creation for sampling/createMessage (required for ${X})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${Y} does not support task creation for elicitation/create (required for ${X})`);break;default:break}}function aQ(Q,X){if(!Q||X===null||typeof X!=="object")return;if(Q.type==="object"&&Q.properties&&typeof Q.properties==="object"){let Y=X,J=Q.properties;for(let W of Object.keys(J)){let $=J[W];if(Y[W]===void 0&&Object.prototype.hasOwnProperty.call($,"default"))Y[W]=$.default;if(Y[W]!==void 0)aQ($,Y[W])}}if(Array.isArray(Q.anyOf)){for(let Y of Q.anyOf)if(typeof Y!=="boolean")aQ(Y,X)}if(Array.isArray(Q.oneOf)){for(let Y of Q.oneOf)if(typeof Y!=="boolean")aQ(Y,X)}}function iP(Q){if(!Q)return{supportsFormMode:!1,supportsUrlMode:!1};let X=Q.form!==void 0,Y=Q.url!==void 0;return{supportsFormMode:X||!X&&!Y,supportsUrlMode:Y}}class ZY extends JX{constructor(Q,X){super(X);if(this._clientInfo=Q,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=X?.capabilities??{},this._jsonSchemaValidator=X?.jsonSchemaValidator??new HY,X?.listChanged)this._pendingListChangedConfig=X.listChanged}_setupListChangedHandlers(Q){if(Q.tools&&this._serverCapabilities?.tools?.listChanged)this._setupListChangedHandler("tools",o4,Q.tools,async()=>{return(await this.listTools()).tools});if(Q.prompts&&this._serverCapabilities?.prompts?.listChanged)this._setupListChangedHandler("prompts",i4,Q.prompts,async()=>{return(await this.listPrompts()).prompts});if(Q.resources&&this._serverCapabilities?.resources?.listChanged)this._setupListChangedHandler("resources",h4,Q.resources,async()=>{return(await this.listResources()).resources})}get experimental(){if(!this._experimental)this._experimental={tasks:new KY(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=J3(this._capabilities,Q)}setRequestHandler(Q,X){let J=s8(Q)?.method;if(!J)throw Error("Schema is missing a method literal");let W;if(a1(J)){let B=J;W=B._zod?.def?.value??B.value}else{let B=J;W=B._def?.value??B.value}if(typeof W!=="string")throw Error("Schema method literal must be a string");let $=W;if($==="elicitation/create"){let B=async(G,K)=>{let H=f0(s4,G);if(!H.success){let F=H.error instanceof Error?H.error.message:String(H.error);throw new S(C.InvalidParams,`Invalid elicitation request: ${F}`)}let{params:Z}=H.data;Z.mode=Z.mode??"form";let{supportsFormMode:L,supportsUrlMode:V}=iP(this._capabilities.elicitation);if(Z.mode==="form"&&!L)throw new S(C.InvalidParams,"Client does not support form-mode elicitation requests");if(Z.mode==="url"&&!V)throw new S(C.InvalidParams,"Client does not support URL-mode elicitation requests");let D=await Promise.resolve(X(G,K));if(Z.task){let F=f0(C1,D);if(!F.success){let U=F.error instanceof Error?F.error.message:String(F.error);throw new S(C.InvalidParams,`Invalid task creation result: ${U}`)}return F.data}let z=f0(e4,D);if(!z.success){let F=z.error instanceof Error?z.error.message:String(z.error);throw new S(C.InvalidParams,`Invalid elicitation result: ${F}`)}let A=z.data,N=Z.mode==="form"?Z.requestedSchema:void 0;if(Z.mode==="form"&&A.action==="accept"&&A.content&&N){if(this._capabilities.elicitation?.form?.applyDefaults)try{aQ(N,A.content)}catch{}}return A};return super.setRequestHandler(Q,B)}if($==="sampling/createMessage"){let B=async(G,K)=>{let H=f0(r4,G);if(!H.success){let A=H.error instanceof Error?H.error.message:String(H.error);throw new S(C.InvalidParams,`Invalid sampling request: ${A}`)}let{params:Z}=H.data,L=await Promise.resolve(X(G,K));if(Z.task){let A=f0(C1,L);if(!A.success){let N=A.error instanceof Error?A.error.message:String(A.error);throw new S(C.InvalidParams,`Invalid task creation result: ${N}`)}return A.data}let D=Z.tools||Z.toolChoice?a4:t4,z=f0(D,L);if(!z.success){let A=z.error instanceof Error?z.error.message:String(z.error);throw new S(C.InvalidParams,`Invalid sampling result: ${A}`)}return z.data};return super.setRequestHandler(Q,B)}return super.setRequestHandler(Q,X)}assertCapability(Q,X){if(!this._serverCapabilities?.[Q])throw Error(`Server does not support ${Q} (required for ${X})`)}async connect(Q,X){if(await super.connect(Q),Q.sessionId!==void 0)return;try{let Y=await this.request({method:"initialize",params:{protocolVersion:e1,capabilities:this._capabilities,clientInfo:this._clientInfo}},_4,X);if(Y===void 0)throw Error(`Server sent invalid initialize result: ${Y}`);if(!y$.includes(Y.protocolVersion))throw Error(`Server's protocol version is not supported: ${Y.protocolVersion}`);if(this._serverCapabilities=Y.capabilities,this._serverVersion=Y.serverInfo,Q.setProtocolVersion)Q.setProtocolVersion(Y.protocolVersion);if(this._instructions=Y.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig)this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0}catch(Y){throw this.close(),Y}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(Q){switch(Q){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${Q})`);if(Q==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${Q})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"sampling/createMessage":if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${Q})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${Q})`);break;case"roots/list":if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${Q})`);break;case"ping":break}}assertTaskCapability(Q){mK(this._serverCapabilities?.tasks?.requests,Q,"Server")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;lK(this._capabilities.tasks?.requests,Q,"Client")}async ping(Q){return this.request({method:"ping"},S1,Q)}async complete(Q,X){return this.request({method:"completion/complete",params:Q},QX,X)}async setLoggingLevel(Q,X){return this.request({method:"logging/setLevel",params:{level:Q}},S1,X)}async getPrompt(Q,X){return this.request({method:"prompts/get",params:Q},d4,X)}async listPrompts(Q,X){return this.request({method:"prompts/list",params:Q},u4,X)}async listResources(Q,X){return this.request({method:"resources/list",params:Q},v4,X)}async listResourceTemplates(Q,X){return this.request({method:"resources/templates/list",params:Q},y4,X)}async readResource(Q,X){return this.request({method:"resources/read",params:Q},f4,X)}async subscribeResource(Q,X){return this.request({method:"resources/subscribe",params:Q},S1,X)}async unsubscribeResource(Q,X){return this.request({method:"resources/unsubscribe",params:Q},S1,X)}async callTool(Q,X=Q1,Y){if(this.isToolTaskRequired(Q.name))throw new S(C.InvalidRequest,`Tool "${Q.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let J=await this.request({method:"tools/call",params:Q},X,Y),W=this.getToolOutputValidator(Q.name);if(W){if(!J.structuredContent&&!J.isError)throw new S(C.InvalidRequest,`Tool ${Q.name} has an output schema but did not return structured content`);if(J.structuredContent)try{let $=W(J.structuredContent);if(!$.valid)throw new S(C.InvalidParams,`Structured content does not match the tool's output schema: ${$.errorMessage}`)}catch($){if($ instanceof S)throw $;throw new S(C.InvalidParams,`Failed to validate structured content: ${$ instanceof Error?$.message:String($)}`)}}return J}isToolTask(Q){if(!this._serverCapabilities?.tasks?.requests?.tools?.call)return!1;return this._cachedKnownTaskTools.has(Q)}isToolTaskRequired(Q){return this._cachedRequiredTaskTools.has(Q)}cacheToolMetadata(Q){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let X of Q){if(X.outputSchema){let J=this._jsonSchemaValidator.getValidator(X.outputSchema);this._cachedToolOutputValidators.set(X.name,J)}let Y=X.execution?.taskSupport;if(Y==="required"||Y==="optional")this._cachedKnownTaskTools.add(X.name);if(Y==="required")this._cachedRequiredTaskTools.add(X.name)}}getToolOutputValidator(Q){return this._cachedToolOutputValidators.get(Q)}async listTools(Q,X){let Y=await this.request({method:"tools/list",params:Q},n4,X);return this.cacheToolMetadata(Y.tools),Y}_setupListChangedHandler(Q,X,Y,J){let W=e$.safeParse(Y);if(!W.success)throw Error(`Invalid ${Q} listChanged options: ${W.error.message}`);if(typeof Y.onChanged!=="function")throw Error(`Invalid ${Q} listChanged options: onChanged must be a function`);let{autoRefresh:$,debounceMs:B}=W.data,{onChanged:G}=Y,K=async()=>{if(!$){G(null,null);return}try{let Z=await J();G(null,Z)}catch(Z){let L=Z instanceof Error?Z:Error(String(Z));G(L,null)}},H=()=>{if(B){let Z=this._listChangedDebounceTimers.get(Q);if(Z)clearTimeout(Z);let L=setTimeout(K,B);this._listChangedDebounceTimers.set(Q,L)}else K()};this.setNotificationHandler(X,H)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}class VY extends Error{constructor(Q,X){super(Q),this.name="ParseError",this.type=X.type,this.field=X.field,this.value=X.value,this.line=X.line}}var cK=10,nP=13,h1=32;function LY(Q){}function sQ(Q){if(typeof Q=="function")throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:X=LY,onError:Y=LY,onRetry:J=LY,onComment:W}=Q,$=[],B=!0,G,K="",H=0,Z;function L(F){if(B&&(B=!1,F.charCodeAt(0)===239&&F.charCodeAt(1)===187&&F.charCodeAt(2)===191&&(F=F.slice(3))),$.length===0){let b=V(F);b!==""&&$.push(b);return}if(F.indexOf(`
|
|
75
|
+
`)===-1&&F.indexOf("\r")===-1){$.push(F);return}$.push(F);let U=$.join("");$.length=0;let M=V(U);M!==""&&$.push(M)}function V(F){let U=0;if(F.indexOf("\r")===-1){let M=F.indexOf(`
|
|
76
|
+
`,U);for(;M!==-1;){if(U===M){H>0&&X({id:G,event:Z,data:K}),G=void 0,K="",H=0,Z=void 0,U=M+1,M=F.indexOf(`
|
|
77
|
+
`,U);continue}let b=F.charCodeAt(U);if(pK(F,U,b)){let P=F.charCodeAt(U+5)===h1?U+6:U+5,n=F.slice(P,M);if(H===0&&F.charCodeAt(M+1)===cK){X({id:G,event:Z,data:n}),G=void 0,K="",Z=void 0,U=M+2,M=F.indexOf(`
|
|
78
|
+
`,U);continue}K=H===0?n:`${K}
|
|
79
|
+
${n}`,H++}else dK(F,U,b)?Z=F.slice(F.charCodeAt(U+6)===h1?U+7:U+6,M)||void 0:D(F,U,M);U=M+1,M=F.indexOf(`
|
|
80
|
+
`,U)}return F.slice(U)}for(;U<F.length;){let M=F.indexOf("\r",U),b=F.indexOf(`
|
|
81
|
+
`,U),P=-1;if(M!==-1&&b!==-1?P=M<b?M:b:M!==-1?M===F.length-1?P=-1:P=M:b!==-1&&(P=b),P===-1)break;D(F,U,P),U=P+1,F.charCodeAt(U-1)===nP&&F.charCodeAt(U)===cK&&U++}return F.slice(U)}function D(F,U,M){if(U===M){A();return}let b=F.charCodeAt(U);if(pK(F,U,b)){let E0=F.charCodeAt(U+5)===h1?U+6:U+5,l1=F.slice(E0,M);K=H===0?l1:`${K}
|
|
82
|
+
${l1}`,H++;return}if(dK(F,U,b)){Z=F.slice(F.charCodeAt(U+6)===h1?U+7:U+6,M)||void 0;return}if(b===105&&F.charCodeAt(U+1)===100&&F.charCodeAt(U+2)===58){let E0=F.slice(F.charCodeAt(U+3)===h1?U+4:U+3,M);G=E0.includes("\x00")?void 0:E0;return}if(b===58){if(W){let E0=F.slice(U,M);W(E0.slice(F.charCodeAt(U+1)===h1?2:1))}return}let P=F.slice(U,M),n=P.indexOf(":");if(n===-1){z(P,"",P);return}let O0=P.slice(0,n),T1=P.charCodeAt(n+1)===h1?2:1,E9=P.slice(n+T1);z(O0,E9,P)}function z(F,U,M){switch(F){case"event":Z=U||void 0;break;case"data":K=H===0?U:`${K}
|
|
83
|
+
${U}`,H++;break;case"id":G=U.includes("\x00")?void 0:U;break;case"retry":/^\d+$/.test(U)?J(parseInt(U,10)):Y(new VY(`Invalid \`retry\` value: "${U}"`,{type:"invalid-retry",value:U,line:M}));break;default:Y(new VY(`Unknown field "${F.length>20?`${F.slice(0,20)}…`:F}"`,{type:"unknown-field",field:F,value:U,line:M}));break}}function A(){H>0&&X({id:G,event:Z,data:K}),G=void 0,K="",H=0,Z=void 0}function N(F={}){if(F.consume&&$.length>0){let U=$.join("");D(U,0,U.length)}B=!0,G=void 0,K="",H=0,Z=void 0,$.length=0}return{feed:L,reset:N}}function pK(Q,X,Y){return Y===100&&Q.charCodeAt(X+1)===97&&Q.charCodeAt(X+2)===116&&Q.charCodeAt(X+3)===97&&Q.charCodeAt(X+4)===58}function dK(Q,X,Y){return Y===101&&Q.charCodeAt(X+1)===118&&Q.charCodeAt(X+2)===101&&Q.charCodeAt(X+3)===110&&Q.charCodeAt(X+4)===116&&Q.charCodeAt(X+5)===58}class DY extends Event{constructor(Q,X){var Y,J;super(Q),this.code=(Y=X==null?void 0:X.code)!=null?Y:void 0,this.message=(J=X==null?void 0:X.message)!=null?J:void 0}[Symbol.for("nodejs.util.inspect.custom")](Q,X,Y){return Y(iK(this),X)}[Symbol.for("Deno.customInspect")](Q,X){return Q(iK(this),X)}}function oP(Q){let X=globalThis.DOMException;return typeof X=="function"?new X(Q,"SyntaxError"):SyntaxError(Q)}function qY(Q){return Q instanceof Error?"errors"in Q&&Array.isArray(Q.errors)?Q.errors.map(qY).join(", "):("cause"in Q)&&Q.cause instanceof Error?`${Q}: ${qY(Q.cause)}`:Q.message:`${Q}`}function iK(Q){return{type:Q.type,message:Q.message,code:Q.code,defaultPrevented:Q.defaultPrevented,cancelable:Q.cancelable,timeStamp:Q.timeStamp}}var oK=(Q)=>{throw TypeError(Q)},wY=(Q,X,Y)=>X.has(Q)||oK("Cannot "+Y),v=(Q,X,Y)=>(wY(Q,X,"read from private field"),Y?Y.call(Q):X.get(Q)),B0=(Q,X,Y)=>X.has(Q)?oK("Cannot add the same private member more than once"):X instanceof WeakSet?X.add(Q):X.set(Q,Y),Q0=(Q,X,Y,J)=>(wY(Q,X,"write to private field"),X.set(Q,Y),Y),B1=(Q,X,Y)=>(wY(Q,X,"access private method"),Y),I0,u1,q9,eQ,Q6,I8,A9,b8,I1,z9,O9,F9,P8,d0,zY,FY,AY,nK,OY,NY,j8,UY,MY;class N9 extends EventTarget{constructor(Q,X){var Y,J;super(),B0(this,d0),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,B0(this,I0),B0(this,u1),B0(this,q9),B0(this,eQ),B0(this,Q6),B0(this,I8),B0(this,A9),B0(this,b8,null),B0(this,I1),B0(this,z9),B0(this,O9,null),B0(this,F9,null),B0(this,P8,null),B0(this,FY,async(W)=>{var $;v(this,z9).reset();let{body:B,redirected:G,status:K,headers:H}=W;if(K===204){B1(this,d0,j8).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(G?Q0(this,q9,new URL(W.url)):Q0(this,q9,void 0),K!==200){B1(this,d0,j8).call(this,`Non-200 status code (${K})`,K);return}if(!(H.get("content-type")||"").startsWith("text/event-stream")){B1(this,d0,j8).call(this,'Invalid content type, expected "text/event-stream"',K);return}if(v(this,I0)===this.CLOSED)return;Q0(this,I0,this.OPEN);let Z=new Event("open");if(($=v(this,P8))==null||$.call(this,Z),this.dispatchEvent(Z),typeof B!="object"||!B||!("getReader"in B)){B1(this,d0,j8).call(this,"Invalid response body, expected a web ReadableStream",K),this.close();return}let L=new TextDecoder,V=B.getReader(),D=!0;do{let{done:z,value:A}=await V.read();A&&v(this,z9).feed(L.decode(A,{stream:!z})),z&&(D=!1,v(this,z9).reset(),B1(this,d0,UY).call(this))}while(D)}),B0(this,AY,(W)=>{Q0(this,I1,void 0),!(W.name==="AbortError"||W.type==="aborted")&&B1(this,d0,UY).call(this,qY(W))}),B0(this,OY,(W)=>{typeof W.id=="string"&&Q0(this,b8,W.id);let $=new MessageEvent(W.event||"message",{data:W.data,origin:v(this,q9)?v(this,q9).origin:v(this,u1).origin,lastEventId:W.id||""});v(this,F9)&&(!W.event||W.event==="message")&&v(this,F9).call(this,$),this.dispatchEvent($)}),B0(this,NY,(W)=>{Q0(this,I8,W)}),B0(this,MY,()=>{Q0(this,A9,void 0),v(this,I0)===this.CONNECTING&&B1(this,d0,zY).call(this)});try{if(Q instanceof URL)Q0(this,u1,Q);else if(typeof Q=="string")Q0(this,u1,new URL(Q,rP()));else throw Error("Invalid URL")}catch{throw oP("An invalid or illegal string was specified")}Q0(this,z9,sQ({onEvent:v(this,OY),onRetry:v(this,NY)})),Q0(this,I0,this.CONNECTING),Q0(this,I8,3000),Q0(this,Q6,(Y=X==null?void 0:X.fetch)!=null?Y:globalThis.fetch),Q0(this,eQ,(J=X==null?void 0:X.withCredentials)!=null?J:!1),B1(this,d0,zY).call(this)}get readyState(){return v(this,I0)}get url(){return v(this,u1).href}get withCredentials(){return v(this,eQ)}get onerror(){return v(this,O9)}set onerror(Q){Q0(this,O9,Q)}get onmessage(){return v(this,F9)}set onmessage(Q){Q0(this,F9,Q)}get onopen(){return v(this,P8)}set onopen(Q){Q0(this,P8,Q)}addEventListener(Q,X,Y){let J=X;super.addEventListener(Q,J,Y)}removeEventListener(Q,X,Y){let J=X;super.removeEventListener(Q,J,Y)}close(){v(this,A9)&&clearTimeout(v(this,A9)),v(this,I0)!==this.CLOSED&&(v(this,I1)&&v(this,I1).abort(),Q0(this,I0,this.CLOSED),Q0(this,I1,void 0))}}I0=new WeakMap,u1=new WeakMap,q9=new WeakMap,eQ=new WeakMap,Q6=new WeakMap,I8=new WeakMap,A9=new WeakMap,b8=new WeakMap,I1=new WeakMap,z9=new WeakMap,O9=new WeakMap,F9=new WeakMap,P8=new WeakMap,d0=new WeakSet,zY=function(){Q0(this,I0,this.CONNECTING),Q0(this,I1,new AbortController),v(this,Q6)(v(this,u1),B1(this,d0,nK).call(this)).then(v(this,FY)).catch(v(this,AY))},FY=new WeakMap,AY=new WeakMap,nK=function(){var Q;let X={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...v(this,b8)?{"Last-Event-ID":v(this,b8)}:void 0},cache:"no-store",signal:(Q=v(this,I1))==null?void 0:Q.signal};return"window"in globalThis&&(X.credentials=this.withCredentials?"include":"same-origin"),X},OY=new WeakMap,NY=new WeakMap,j8=function(Q,X){var Y;v(this,I0)!==this.CLOSED&&Q0(this,I0,this.CLOSED);let J=new DY("error",{code:X,message:Q});(Y=v(this,O9))==null||Y.call(this,J),this.dispatchEvent(J)},UY=function(Q,X){var Y;if(v(this,I0)===this.CLOSED)return;Q0(this,I0,this.CONNECTING);let J=new DY("error",{code:X,message:Q});(Y=v(this,O9))==null||Y.call(this,J),this.dispatchEvent(J),Q0(this,A9,setTimeout(v(this,MY),v(this,I8)))},MY=new WeakMap,N9.CONNECTING=0,N9.OPEN=1,N9.CLOSED=2;function rP(){let Q="document"in globalThis?globalThis.document:void 0;return Q&&typeof Q=="object"&&"baseURI"in Q&&typeof Q.baseURI=="string"?Q.baseURI:void 0}function U9(Q){if(!Q)return{};if(Q instanceof Headers)return Object.fromEntries(Q.entries());if(Array.isArray(Q))return Object.fromEntries(Q);return{...Q}}function X6(Q=fetch,X){if(!X)return Q;return async(Y,J)=>{let W={...X,...J,headers:J?.headers?{...U9(X.headers),...U9(J.headers)}:X.headers};return Q(Y,W)}}var PY;PY=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then((Q)=>Q.webcrypto);async function tP(Q){return(await PY).getRandomValues(new Uint8Array(Q))}async function aP(Q){let Y=Math.pow(2,8)-Math.pow(2,8)%66,J="";while(J.length<Q){let W=await tP(Q-J.length);for(let $ of W)if($<Y)J+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"[$%66]}return J}async function sP(Q){return await aP(Q)}async function eP(Q){let X=await(await PY).subtle.digest("SHA-256",new TextEncoder().encode(Q));return btoa(String.fromCharCode(...new Uint8Array(X))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function jY(Q){if(!Q)Q=43;if(Q<43||Q>128)throw`Expected a length between 43 and 128. Received ${Q}.`;let X=await sP(Q),Y=await eP(X);return{code_verifier:X,code_challenge:Y}}var D0=M$().superRefine((Q,X)=>{if(!URL.canParse(Q))return X.addIssue({code:v$.custom,message:"URL must be parseable",fatal:!0}),x6}).refine((Q)=>{let X=new URL(Q);return X.protocol!=="javascript:"&&X.protocol!=="data:"&&X.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),tK=W0({resource:q().url(),authorization_servers:j(D0).optional(),jwks_uri:q().url().optional(),scopes_supported:j(q()).optional(),bearer_methods_supported:j(q()).optional(),resource_signing_alg_values_supported:j(q()).optional(),resource_name:q().optional(),resource_documentation:q().optional(),resource_policy_uri:q().url().optional(),resource_tos_uri:q().url().optional(),tls_client_certificate_bound_access_tokens:p().optional(),authorization_details_types_supported:j(q()).optional(),dpop_signing_alg_values_supported:j(q()).optional(),dpop_bound_access_tokens_required:p().optional()}),IY=W0({issuer:q(),authorization_endpoint:D0,token_endpoint:D0,registration_endpoint:D0.optional(),scopes_supported:j(q()).optional(),response_types_supported:j(q()),response_modes_supported:j(q()).optional(),grant_types_supported:j(q()).optional(),token_endpoint_auth_methods_supported:j(q()).optional(),token_endpoint_auth_signing_alg_values_supported:j(q()).optional(),service_documentation:D0.optional(),revocation_endpoint:D0.optional(),revocation_endpoint_auth_methods_supported:j(q()).optional(),revocation_endpoint_auth_signing_alg_values_supported:j(q()).optional(),introspection_endpoint:q().optional(),introspection_endpoint_auth_methods_supported:j(q()).optional(),introspection_endpoint_auth_signing_alg_values_supported:j(q()).optional(),code_challenge_methods_supported:j(q()).optional(),client_id_metadata_document_supported:p().optional()}),Qj=W0({issuer:q(),authorization_endpoint:D0,token_endpoint:D0,userinfo_endpoint:D0.optional(),jwks_uri:D0,registration_endpoint:D0.optional(),scopes_supported:j(q()).optional(),response_types_supported:j(q()),response_modes_supported:j(q()).optional(),grant_types_supported:j(q()).optional(),acr_values_supported:j(q()).optional(),subject_types_supported:j(q()),id_token_signing_alg_values_supported:j(q()),id_token_encryption_alg_values_supported:j(q()).optional(),id_token_encryption_enc_values_supported:j(q()).optional(),userinfo_signing_alg_values_supported:j(q()).optional(),userinfo_encryption_alg_values_supported:j(q()).optional(),userinfo_encryption_enc_values_supported:j(q()).optional(),request_object_signing_alg_values_supported:j(q()).optional(),request_object_encryption_alg_values_supported:j(q()).optional(),request_object_encryption_enc_values_supported:j(q()).optional(),token_endpoint_auth_methods_supported:j(q()).optional(),token_endpoint_auth_signing_alg_values_supported:j(q()).optional(),display_values_supported:j(q()).optional(),claim_types_supported:j(q()).optional(),claims_supported:j(q()).optional(),service_documentation:q().optional(),claims_locales_supported:j(q()).optional(),ui_locales_supported:j(q()).optional(),claims_parameter_supported:p().optional(),request_parameter_supported:p().optional(),request_uri_parameter_supported:p().optional(),require_request_uri_registration:p().optional(),op_policy_uri:D0.optional(),op_tos_uri:D0.optional(),client_id_metadata_document_supported:p().optional()}),aK=I({...Qj.shape,...IY.pick({code_challenge_methods_supported:!0}).shape}),sK=I({access_token:q(),id_token:q().optional(),token_type:q(),expires_in:YQ.number().optional(),scope:q().optional(),refresh_token:q().optional()}).strip(),eK=I({error:q(),error_description:q().optional(),error_uri:q().optional()}),rK=D0.optional().or(T("").transform(()=>{return})),Xj=I({redirect_uris:j(D0),token_endpoint_auth_method:q().optional(),grant_types:j(q()).optional(),response_types:j(q()).optional(),client_name:q().optional(),client_uri:D0.optional(),logo_uri:rK,scope:q().optional(),contacts:j(q()).optional(),tos_uri:rK,policy_uri:q().optional(),jwks_uri:D0.optional(),jwks:j$().optional(),software_id:q().optional(),software_version:q().optional(),software_statement:q().optional()}).strip(),Yj=I({client_id:q(),client_secret:q().optional(),client_id_issued_at:u().optional(),client_secret_expires_at:u().optional()}).strip(),QZ=Xj.merge(Yj),Z_=I({error:q(),error_description:q().optional()}).strip(),L_=I({token:q(),token_type_hint:q().optional()}).strip();function XZ(Q){let X=typeof Q==="string"?new URL(Q):new URL(Q.href);return X.hash="",X}function YZ({requestedResource:Q,configuredResource:X}){let Y=typeof Q==="string"?new URL(Q):new URL(Q.href),J=typeof X==="string"?new URL(X):new URL(X.href);if(Y.origin!==J.origin)return!1;if(Y.pathname.length<J.pathname.length)return!1;let W=Y.pathname.endsWith("/")?Y.pathname:Y.pathname+"/",$=J.pathname.endsWith("/")?J.pathname:J.pathname+"/";return W.startsWith($)}class J0 extends Error{constructor(Q,X){super(Q);this.errorUri=X,this.name=this.constructor.name}toResponseObject(){let Q={error:this.errorCode,error_description:this.message};if(this.errorUri)Q.error_uri=this.errorUri;return Q}get errorCode(){return this.constructor.errorCode}}class Y6 extends J0{}Y6.errorCode="invalid_request";class M9 extends J0{}M9.errorCode="invalid_client";class w9 extends J0{}w9.errorCode="invalid_grant";class P9 extends J0{}P9.errorCode="unauthorized_client";class J6 extends J0{}J6.errorCode="unsupported_grant_type";class W6 extends J0{}W6.errorCode="invalid_scope";class $6 extends J0{}$6.errorCode="access_denied";class b1 extends J0{}b1.errorCode="server_error";class B6 extends J0{}B6.errorCode="temporarily_unavailable";class G6 extends J0{}G6.errorCode="unsupported_response_type";class H6 extends J0{}H6.errorCode="unsupported_token_type";class K6 extends J0{}K6.errorCode="invalid_token";class Z6 extends J0{}Z6.errorCode="method_not_allowed";class L6 extends J0{}L6.errorCode="too_many_requests";class j9 extends J0{}j9.errorCode="invalid_client_metadata";class V6 extends J0{}V6.errorCode="insufficient_scope";class D6 extends J0{}D6.errorCode="invalid_target";var JZ={[Y6.errorCode]:Y6,[M9.errorCode]:M9,[w9.errorCode]:w9,[P9.errorCode]:P9,[J6.errorCode]:J6,[W6.errorCode]:W6,[$6.errorCode]:$6,[b1.errorCode]:b1,[B6.errorCode]:B6,[G6.errorCode]:G6,[H6.errorCode]:H6,[K6.errorCode]:K6,[Z6.errorCode]:Z6,[L6.errorCode]:L6,[j9.errorCode]:j9,[V6.errorCode]:V6,[D6.errorCode]:D6};class b0 extends Error{constructor(Q){super(Q??"Unauthorized")}}function Jj(Q){return["client_secret_basic","client_secret_post","none"].includes(Q)}var bY="code",TY="S256";function Wj(Q,X){let Y=Q.client_secret!==void 0;if("token_endpoint_auth_method"in Q&&Q.token_endpoint_auth_method&&Jj(Q.token_endpoint_auth_method)&&(X.length===0||X.includes(Q.token_endpoint_auth_method)))return Q.token_endpoint_auth_method;if(X.length===0)return Y?"client_secret_basic":"none";if(Y&&X.includes("client_secret_basic"))return"client_secret_basic";if(Y&&X.includes("client_secret_post"))return"client_secret_post";if(X.includes("none"))return"none";return Y?"client_secret_post":"none"}function $j(Q,X,Y,J){let{client_id:W,client_secret:$}=X;switch(Q){case"client_secret_basic":Bj(W,$,Y);return;case"client_secret_post":Gj(W,$,J);return;case"none":Hj(W,J);return;default:throw Error(`Unsupported client authentication method: ${Q}`)}}function Bj(Q,X,Y){if(!X)throw Error("client_secret_basic authentication requires a client_secret");let J=btoa(`${Q}:${X}`);Y.set("Authorization",`Basic ${J}`)}function Gj(Q,X,Y){if(Y.set("client_id",Q),X)Y.set("client_secret",X)}function Hj(Q,X){X.set("client_id",Q)}async function $Z(Q){let X=Q instanceof Response?Q.status:void 0,Y=Q instanceof Response?await Q.text():Q;try{let J=eK.parse(JSON.parse(Y)),{error:W,error_description:$,error_uri:B}=J;return new(JZ[W]||b1)($||"",B)}catch(J){let W=`${X?`HTTP ${X}: `:""}Invalid OAuth error response: ${J}. Raw body: ${Y}`;return new b1(W)}}async function G1(Q,X){try{return await RY(Q,X)}catch(Y){if(Y instanceof M9||Y instanceof P9)return await Q.invalidateCredentials?.("all"),await RY(Q,X);else if(Y instanceof w9)return await Q.invalidateCredentials?.("tokens"),await RY(Q,X);throw Y}}async function RY(Q,{serverUrl:X,authorizationCode:Y,scope:J,resourceMetadataUrl:W,fetchFn:$}){let B=await Q.discoveryState?.(),G,K,H,Z=W;if(!Z&&B?.resourceMetadataUrl)Z=new URL(B.resourceMetadataUrl);if(B?.authorizationServerUrl){if(K=B.authorizationServerUrl,G=B.resourceMetadata,H=B.authorizationServerMetadata??await GZ(K,{fetchFn:$}),!G)try{G=await BZ(X,{resourceMetadataUrl:Z},$)}catch{}if(H!==B.authorizationServerMetadata||G!==B.resourceMetadata)await Q.saveDiscoveryState?.({authorizationServerUrl:String(K),resourceMetadataUrl:Z?.toString(),resourceMetadata:G,authorizationServerMetadata:H})}else{let M=await zj(X,{resourceMetadataUrl:Z,fetchFn:$});K=M.authorizationServerUrl,H=M.authorizationServerMetadata,G=M.resourceMetadata,await Q.saveDiscoveryState?.({authorizationServerUrl:String(K),resourceMetadataUrl:Z?.toString(),resourceMetadata:G,authorizationServerMetadata:H})}let L=await Zj(X,Q,G),V=J||G?.scopes_supported?.join(" ")||Q.clientMetadata.scope,D=await Promise.resolve(Q.clientInformation());if(!D){if(Y!==void 0)throw Error("Existing OAuth client information is required when exchanging an authorization code");let M=H?.client_id_metadata_document_supported===!0,b=Q.clientMetadataUrl;if(b&&!Kj(b))throw new j9(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${b}`);if(M&&b)D={client_id:b},await Q.saveClientInformation?.(D);else{if(!Q.saveClientInformation)throw Error("OAuth client information must be saveable for dynamic registration");let n=await Uj(K,{metadata:H,clientMetadata:Q.clientMetadata,scope:V,fetchFn:$});await Q.saveClientInformation(n),D=n}}let z=!Q.redirectUrl;if(Y!==void 0||z){let M=await Nj(Q,K,{metadata:H,resource:L,authorizationCode:Y,fetchFn:$});return await Q.saveTokens(M),"AUTHORIZED"}let A=await Q.tokens();if(A?.refresh_token)try{let M=await Oj(K,{metadata:H,clientInformation:D,refreshToken:A.refresh_token,resource:L,addClientAuthentication:Q.addClientAuthentication,fetchFn:$});return await Q.saveTokens(M),"AUTHORIZED"}catch(M){if(!(M instanceof J0)||M instanceof b1);else throw M}let N=Q.state?await Q.state():void 0,{authorizationUrl:F,codeVerifier:U}=await Fj(K,{metadata:H,clientInformation:D,state:N,redirectUrl:Q.redirectUrl,scope:V,resource:L});return await Q.saveCodeVerifier(U),await Q.redirectToAuthorization(F),"REDIRECT"}function Kj(Q){if(!Q)return!1;try{let X=new URL(Q);return X.protocol==="https:"&&X.pathname!=="/"}catch{return!1}}async function Zj(Q,X,Y){let J=XZ(Q);if(X.validateResourceURL)return await X.validateResourceURL(J,Y?.resource);if(!Y)return;if(!YZ({requestedResource:J,configuredResource:Y.resource}))throw Error(`Protected resource ${Y.resource} does not match expected ${J} (or origin)`);return new URL(Y.resource)}function I9(Q){let X=Q.headers.get("WWW-Authenticate");if(!X)return{};let[Y,J]=X.split(" ");if(Y.toLowerCase()!=="bearer"||!J)return{};let W=EY(Q,"resource_metadata")||void 0,$;if(W)try{$=new URL(W)}catch{}let B=EY(Q,"scope")||void 0,G=EY(Q,"error")||void 0;return{resourceMetadataUrl:$,scope:B,error:G}}function EY(Q,X){let Y=Q.headers.get("WWW-Authenticate");if(!Y)return null;let J=new RegExp(`${X}=(?:"([^"]+)"|([^\\s,]+))`),W=Y.match(J);if(W)return W[1]||W[2];return null}async function BZ(Q,X,Y=fetch){let J=await Dj(Q,"oauth-protected-resource",Y,{protocolVersion:X?.protocolVersion,metadataUrl:X?.resourceMetadataUrl});if(!J||J.status===404)throw await J?.body?.cancel(),Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!J.ok)throw await J.body?.cancel(),Error(`HTTP ${J.status} trying to load well-known OAuth protected resource metadata.`);return tK.parse(await J.json())}async function SY(Q,X,Y=fetch){try{return await Y(Q,{headers:X})}catch(J){if(J instanceof TypeError)if(X)return SY(Q,void 0,Y);else return;throw J}}function Lj(Q,X="",Y={}){if(X.endsWith("/"))X=X.slice(0,-1);return Y.prependPathname?`${X}/.well-known/${Q}`:`/.well-known/${Q}${X}`}async function WZ(Q,X,Y=fetch){return await SY(Q,{"MCP-Protocol-Version":X},Y)}function Vj(Q,X){return!Q||Q.status>=400&&Q.status<500&&X!=="/"}async function Dj(Q,X,Y,J){let W=new URL(Q),$=J?.protocolVersion??e1,B;if(J?.metadataUrl)B=new URL(J.metadataUrl);else{let K=Lj(X,W.pathname);B=new URL(K,J?.metadataServerUrl??W),B.search=W.search}let G=await WZ(B,$,Y);if(!J?.metadataUrl&&Vj(G,W.pathname)){let K=new URL(`/.well-known/${X}`,W);G=await WZ(K,$,Y)}return G}function qj(Q){let X=typeof Q==="string"?new URL(Q):Q,Y=X.pathname!=="/",J=[];if(!Y)return J.push({url:new URL("/.well-known/oauth-authorization-server",X.origin),type:"oauth"}),J.push({url:new URL("/.well-known/openid-configuration",X.origin),type:"oidc"}),J;let W=X.pathname;if(W.endsWith("/"))W=W.slice(0,-1);return J.push({url:new URL(`/.well-known/oauth-authorization-server${W}`,X.origin),type:"oauth"}),J.push({url:new URL(`/.well-known/openid-configuration${W}`,X.origin),type:"oidc"}),J.push({url:new URL(`${W}/.well-known/openid-configuration`,X.origin),type:"oidc"}),J}async function GZ(Q,{fetchFn:X=fetch,protocolVersion:Y=e1}={}){let J={"MCP-Protocol-Version":Y,Accept:"application/json"},W=qj(Q);for(let{url:$,type:B}of W){let G=await SY($,J,X);if(!G)continue;if(!G.ok){if(await G.body?.cancel(),G.status>=400&&G.status<500)continue;throw Error(`HTTP ${G.status} trying to load ${B==="oauth"?"OAuth":"OpenID provider"} metadata from ${$}`)}if(B==="oauth")return IY.parse(await G.json());else return aK.parse(await G.json())}return}async function zj(Q,X){let Y,J;try{if(Y=await BZ(Q,{resourceMetadataUrl:X?.resourceMetadataUrl},X?.fetchFn),Y.authorization_servers&&Y.authorization_servers.length>0)J=Y.authorization_servers[0]}catch{}if(!J)J=String(new URL("/",Q));let W=await GZ(J,{fetchFn:X?.fetchFn});return{authorizationServerUrl:J,authorizationServerMetadata:W,resourceMetadata:Y}}async function Fj(Q,{metadata:X,clientInformation:Y,redirectUrl:J,scope:W,state:$,resource:B}){let G;if(X){if(G=new URL(X.authorization_endpoint),!X.response_types_supported.includes(bY))throw Error(`Incompatible auth server: does not support response type ${bY}`);if(X.code_challenge_methods_supported&&!X.code_challenge_methods_supported.includes(TY))throw Error(`Incompatible auth server: does not support code challenge method ${TY}`)}else G=new URL("/authorize",Q);let K=await jY(),H=K.code_verifier,Z=K.code_challenge;if(G.searchParams.set("response_type",bY),G.searchParams.set("client_id",Y.client_id),G.searchParams.set("code_challenge",Z),G.searchParams.set("code_challenge_method",TY),G.searchParams.set("redirect_uri",String(J)),$)G.searchParams.set("state",$);if(W)G.searchParams.set("scope",W);if(W?.includes("offline_access"))G.searchParams.append("prompt","consent");if(B)G.searchParams.set("resource",B.href);return{authorizationUrl:G,codeVerifier:H}}function Aj(Q,X,Y){return new URLSearchParams({grant_type:"authorization_code",code:Q,code_verifier:X,redirect_uri:String(Y)})}async function HZ(Q,{metadata:X,tokenRequestParams:Y,clientInformation:J,addClientAuthentication:W,resource:$,fetchFn:B}){let G=X?.token_endpoint?new URL(X.token_endpoint):new URL("/token",Q),K=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if($)Y.set("resource",$.href);if(W)await W(K,Y,G,X);else if(J){let Z=X?.token_endpoint_auth_methods_supported??[],L=Wj(J,Z);$j(L,J,K,Y)}let H=await(B??fetch)(G,{method:"POST",headers:K,body:Y});if(!H.ok)throw await $Z(H);return sK.parse(await H.json())}async function Oj(Q,{metadata:X,clientInformation:Y,refreshToken:J,resource:W,addClientAuthentication:$,fetchFn:B}){let G=new URLSearchParams({grant_type:"refresh_token",refresh_token:J}),K=await HZ(Q,{metadata:X,tokenRequestParams:G,clientInformation:Y,addClientAuthentication:$,resource:W,fetchFn:B});return{refresh_token:J,...K}}async function Nj(Q,X,{metadata:Y,resource:J,authorizationCode:W,fetchFn:$}={}){let B=Q.clientMetadata.scope,G;if(Q.prepareTokenRequest)G=await Q.prepareTokenRequest(B);if(!G){if(!W)throw Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!Q.redirectUrl)throw Error("redirectUrl is required for authorization_code flow");let H=await Q.codeVerifier();G=Aj(W,H,Q.redirectUrl)}let K=await Q.clientInformation();return HZ(X,{metadata:Y,tokenRequestParams:G,clientInformation:K??void 0,addClientAuthentication:Q.addClientAuthentication,resource:J,fetchFn:$})}async function Uj(Q,{metadata:X,clientMetadata:Y,scope:J,fetchFn:W}){let $;if(X){if(!X.registration_endpoint)throw Error("Incompatible auth server: does not support dynamic client registration");$=new URL(X.registration_endpoint)}else $=new URL("/register",Q);let B=await(W??fetch)($,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...Y,...J!==void 0?{scope:J}:{}})});if(!B.ok)throw await $Z(B);return QZ.parse(await B.json())}class q6 extends Error{constructor(Q,X,Y){super(`SSE error: ${X}`);this.code=Q,this.event=Y}}class CY{constructor(Q,X){this._url=Q,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=X?.eventSourceInit,this._requestInit=X?.requestInit,this._authProvider=X?.authProvider,this._fetch=X?.fetch,this._fetchWithInit=X6(X?.fetch,X?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new b0("No auth provider");let Q;try{Q=await G1(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(X){throw this.onerror?.(X),X}if(Q!=="AUTHORIZED")throw new b0;return await this._startOrAuth()}async _commonHeaders(){let Q={};if(this._authProvider){let Y=await this._authProvider.tokens();if(Y)Q.Authorization=`Bearer ${Y.access_token}`}if(this._protocolVersion)Q["mcp-protocol-version"]=this._protocolVersion;let X=U9(this._requestInit?.headers);return new Headers({...Q,...X})}_startOrAuth(){let Q=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((X,Y)=>{this._eventSource=new N9(this._url.href,{...this._eventSourceInit,fetch:async(J,W)=>{let $=await this._commonHeaders();$.set("Accept","text/event-stream");let B=await Q(J,{...W,headers:$});if(B.status===401&&B.headers.has("www-authenticate")){let{resourceMetadataUrl:G,scope:K}=I9(B);this._resourceMetadataUrl=G,this._scope=K}return B}}),this._abortController=new AbortController,this._eventSource.onerror=(J)=>{if(J.code===401&&this._authProvider){this._authThenStart().then(X,Y);return}let W=new q6(J.code,J.message,J);Y(W),this.onerror?.(W)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",(J)=>{let W=J;try{if(this._endpoint=new URL(W.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch($){Y($),this.onerror?.($),this.close();return}X()}),this._eventSource.onmessage=(J)=>{let W=J,$;try{$=F1.parse(JSON.parse(W.data))}catch(B){this.onerror?.(B);return}this.onmessage?.($)}})}async start(){if(this._eventSource)throw Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(Q){if(!this._authProvider)throw new b0("No auth provider");if(await G1(this._authProvider,{serverUrl:this._url,authorizationCode:Q,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new b0("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(Q){if(!this._endpoint)throw Error("Not connected");try{let X=await this._commonHeaders();X.set("content-type","application/json");let Y={...this._requestInit,method:"POST",headers:X,body:JSON.stringify(Q),signal:this._abortController?.signal},J=await(this._fetch??fetch)(this._endpoint,Y);if(!J.ok){let W=await J.text().catch(()=>null);if(J.status===401&&this._authProvider){let{resourceMetadataUrl:$,scope:B}=I9(J);if(this._resourceMetadataUrl=$,this._scope=B,await G1(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new b0;return this.send(Q)}throw Error(`Error POSTing to endpoint (HTTP ${J.status}): ${W}`)}await J.body?.cancel()}catch(X){throw this.onerror?.(X),X}}setProtocolVersion(Q){this._protocolVersion=Q}}var sZ=j6(tZ(),1);import lY from"node:process";import{PassThrough as aj}from"node:stream";class mY{append(Q){this._buffer=this._buffer?Buffer.concat([this._buffer,Q]):Q}readMessage(){if(!this._buffer)return null;let Q=this._buffer.indexOf(`
|
|
84
|
+
`);if(Q===-1)return null;let X=this._buffer.toString("utf8",0,Q).replace(/\r$/,"");return this._buffer=this._buffer.subarray(Q+1),tj(X)}clear(){this._buffer=void 0}}function tj(Q){return F1.parse(JSON.parse(Q))}function aZ(Q){return JSON.stringify(Q)+`
|
|
85
|
+
`}var sj=lY.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function F6(){let Q={};for(let X of sj){let Y=lY.env[X];if(Y===void 0)continue;if(Y.startsWith("()"))continue;Q[X]=Y}return Q}class cY{constructor(Q){if(this._readBuffer=new mY,this._stderrStream=null,this._serverParams=Q,Q.stderr==="pipe"||Q.stderr==="overlapped")this._stderrStream=new aj}async start(){if(this._process)throw Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((Q,X)=>{if(this._process=sZ.default(this._serverParams.command,this._serverParams.args??[],{env:{...F6(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:lY.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",(Y)=>{X(Y),this.onerror?.(Y)}),this._process.on("spawn",()=>{Q()}),this._process.on("close",(Y)=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",(Y)=>{this.onerror?.(Y)}),this._process.stdout?.on("data",(Y)=>{this._readBuffer.append(Y),this.processReadBuffer()}),this._process.stdout?.on("error",(Y)=>{this.onerror?.(Y)}),this._stderrStream&&this._process.stderr)this._process.stderr.pipe(this._stderrStream)})}get stderr(){if(this._stderrStream)return this._stderrStream;return this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;this.onmessage?.(Q)}catch(Q){this.onerror?.(Q)}}async close(){if(this._process){let Q=this._process;this._process=void 0;let X=new Promise((Y)=>{Q.once("close",()=>{Y()})});try{Q.stdin?.end()}catch{}if(await Promise.race([X,new Promise((Y)=>setTimeout(Y,2000).unref())]),Q.exitCode===null){try{Q.kill("SIGTERM")}catch{}await Promise.race([X,new Promise((Y)=>setTimeout(Y,2000).unref())])}if(Q.exitCode===null)try{Q.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(Q){return new Promise((X)=>{if(!this._process?.stdin)throw Error("Not connected");let Y=aZ(Q);if(this._process.stdin.write(Y))X();else this._process.stdin.once("drain",X)})}}class pY extends TransformStream{constructor({onError:Q,onRetry:X,onComment:Y}={}){let J;super({start(W){J=sQ({onEvent:($)=>{W.enqueue($)},onError($){Q==="terminate"?W.error($):typeof Q=="function"&&Q($)},onRetry:X,onComment:Y})},transform(W){J.feed(W)}})}}var ej={initialReconnectionDelay:1000,maxReconnectionDelay:30000,reconnectionDelayGrowFactor:1.5,maxRetries:2};class H1 extends Error{constructor(Q,X){super(`Streamable HTTP error: ${X}`);this.code=Q}}class dY{constructor(Q,X){this._hasCompletedAuthFlow=!1,this._url=Q,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=X?.requestInit,this._authProvider=X?.authProvider,this._fetch=X?.fetch,this._fetchWithInit=X6(X?.fetch,X?.requestInit),this._sessionId=X?.sessionId,this._reconnectionOptions=X?.reconnectionOptions??ej}async _authThenStart(){if(!this._authProvider)throw new b0("No auth provider");let Q;try{Q=await G1(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(X){throw this.onerror?.(X),X}if(Q!=="AUTHORIZED")throw new b0;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let Q={};if(this._authProvider){let Y=await this._authProvider.tokens();if(Y)Q.Authorization=`Bearer ${Y.access_token}`}if(this._sessionId)Q["mcp-session-id"]=this._sessionId;if(this._protocolVersion)Q["mcp-protocol-version"]=this._protocolVersion;let X=U9(this._requestInit?.headers);return new Headers({...Q,...X})}async _startOrAuthSse(Q){let{resumptionToken:X}=Q;try{let Y=await this._commonHeaders();if(Y.set("Accept","text/event-stream"),X)Y.set("last-event-id",X);let J=await(this._fetch??fetch)(this._url,{method:"GET",headers:Y,signal:this._abortController?.signal});if(!J.ok){if(await J.body?.cancel(),J.status===401&&this._authProvider)return await this._authThenStart();if(J.status===405)return;throw new H1(J.status,`Failed to open SSE stream: ${J.statusText}`)}this._handleSseStream(J.body,Q,!0)}catch(Y){throw this.onerror?.(Y),Y}}_getNextReconnectionDelay(Q){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let X=this._reconnectionOptions.initialReconnectionDelay,Y=this._reconnectionOptions.reconnectionDelayGrowFactor,J=this._reconnectionOptions.maxReconnectionDelay;return Math.min(X*Math.pow(Y,Q),J)}_scheduleReconnection(Q,X=0){let Y=this._reconnectionOptions.maxRetries;if(X>=Y){this.onerror?.(Error(`Maximum reconnection attempts (${Y}) exceeded.`));return}let J=this._getNextReconnectionDelay(X);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(Q).catch((W)=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${W instanceof Error?W.message:String(W)}`)),this._scheduleReconnection(Q,X+1)})},J)}_handleSseStream(Q,X,Y){if(!Q)return;let{onresumptiontoken:J,replayMessageId:W}=X,$,B=!1,G=!1;(async()=>{try{let H=Q.pipeThrough(new TextDecoderStream).pipeThrough(new pY({onRetry:(V)=>{this._serverRetryMs=V}})).getReader();while(!0){let{value:V,done:D}=await H.read();if(D)break;if(V.id)$=V.id,B=!0,J?.(V.id);if(!V.data)continue;if(!V.event||V.event==="message")try{let z=F1.parse(JSON.parse(V.data));if(E1(z)){if(G=!0,W!==void 0)z.id=W}this.onmessage?.(z)}catch(z){this.onerror?.(z)}}if((Y||B)&&!G&&this._abortController&&!this._abortController.signal.aborted)this._scheduleReconnection({resumptionToken:$,onresumptiontoken:J,replayMessageId:W},0)}catch(H){if(this.onerror?.(Error(`SSE stream disconnected: ${H}`)),(Y||B)&&!G&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:$,onresumptiontoken:J,replayMessageId:W},0)}catch(V){this.onerror?.(Error(`Failed to reconnect: ${V instanceof Error?V.message:String(V)}`))}}})()}async start(){if(this._abortController)throw Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(Q){if(!this._authProvider)throw new b0("No auth provider");if(await G1(this._authProvider,{serverUrl:this._url,authorizationCode:Q,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new b0("Failed to authorize")}async close(){if(this._reconnectionTimeout)clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0;this._abortController?.abort(),this.onclose?.()}async send(Q,X){try{let{resumptionToken:Y,onresumptiontoken:J}=X||{};if(Y){this._startOrAuthSse({resumptionToken:Y,replayMessageId:i9(Q)?Q.id:void 0}).catch((L)=>this.onerror?.(L));return}let W=await this._commonHeaders();W.set("content-type","application/json"),W.set("accept","application/json, text/event-stream");let $={...this._requestInit,method:"POST",headers:W,body:JSON.stringify(Q),signal:this._abortController?.signal},B=await(this._fetch??fetch)(this._url,$),G=B.headers.get("mcp-session-id");if(G)this._sessionId=G;if(!B.ok){let L=await B.text().catch(()=>null);if(B.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new H1(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:V,scope:D}=I9(B);if(this._resourceMetadataUrl=V,this._scope=D,await G1(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new b0;return this._hasCompletedAuthFlow=!0,this.send(Q)}if(B.status===403&&this._authProvider){let{resourceMetadataUrl:V,scope:D,error:z}=I9(B);if(z==="insufficient_scope"){let A=B.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new H1(403,"Server returned 403 after trying upscoping");if(D)this._scope=D;if(V)this._resourceMetadataUrl=V;if(this._lastUpscopingHeader=A??void 0,await G1(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new b0;return this.send(Q)}}throw new H1(B.status,`Error POSTing to endpoint: ${L}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,B.status===202){if(await B.body?.cancel(),i$(Q))this._startOrAuthSse({resumptionToken:void 0}).catch((L)=>this.onerror?.(L));return}let H=(Array.isArray(Q)?Q:[Q]).filter((L)=>("method"in L)&&("id"in L)&&L.id!==void 0).length>0,Z=B.headers.get("content-type");if(H)if(Z?.includes("text/event-stream"))this._handleSseStream(B.body,{onresumptiontoken:J},!1);else if(Z?.includes("application/json")){let L=await B.json(),V=Array.isArray(L)?L.map((D)=>F1.parse(D)):[F1.parse(L)];for(let D of V)this.onmessage?.(D)}else throw await B.body?.cancel(),new H1(-1,`Unexpected content type: ${Z}`);else await B.body?.cancel()}catch(Y){throw this.onerror?.(Y),Y}}get sessionId(){return this._sessionId}async terminateSession(){if(!this._sessionId)return;try{let Q=await this._commonHeaders(),X={...this._requestInit,method:"DELETE",headers:Q,signal:this._abortController?.signal},Y=await(this._fetch??fetch)(this._url,X);if(await Y.body?.cancel(),!Y.ok&&Y.status!==405)throw new H1(Y.status,`Failed to terminate session: ${Y.statusText}`);this._sessionId=void 0}catch(Q){throw this.onerror?.(Q),Q}}setProtocolVersion(Q){this._protocolVersion=Q}get protocolVersion(){return this._protocolVersion}async resumeStream(Q,X){await this._startOrAuthSse({resumptionToken:Q,onresumptiontoken:X?.onresumptiontoken})}}function eZ(Q){if(!Q.useShellInterpolation)return{command:Q.command,args:Q.args};if(process.platform==="win32")return{command:"cmd.exe",args:["/c",Q.command]};return{command:"/bin/sh",args:["-c",Q.command]}}function QL(Q){return{...F6(),...Q??{}}}function XL(){return F6()}class T8 extends cY{static MAX_CAPTURED_LINES=100;static MAX_LINE_BUFFER_CHARS=16384;_captured=[];_lineBuffer="";async start(){await super.start();let Q=this.stderr;if(!Q)return;Q.on("data",(X)=>this.ingestStderr(X))}ingestStderr(Q){this._lineBuffer+=Q.toString();let X=this._lineBuffer.split(`
|
|
86
|
+
`);if(this._lineBuffer=X.at(-1)??"",this._lineBuffer.length>T8.MAX_LINE_BUFFER_CHARS)this._lineBuffer=this._lineBuffer.slice(-T8.MAX_LINE_BUFFER_CHARS);for(let Y of X.slice(0,-1))this.pushCapturedLine(`${Y}
|
|
87
|
+
`)}pushCapturedLine(Q){if(this._captured.push(Q),this._captured.length>T8.MAX_CAPTURED_LINES)this._captured.shift()}consumeStderr(){if(this._lineBuffer.length>0)this.pushCapturedLine(this._lineBuffer),this._lineBuffer="";let Q=this._captured.join("");return this._captured=[],Q}}function YL(Q){let X={command:Q.command,args:Q.args,env:Q.env,stderr:"pipe",...Q.cwd?{cwd:Q.cwd}:{}};return new T8(X)}function JL(Q){if(!Q)return;return(X,Y)=>{let J=new Headers(Y?.headers);for(let[W,$]of Object.entries(Q()))J.set(W,$);return fetch(X,{...Y,headers:J})}}function WL(Q,X){let Y=JL(X.getHeaders);return new dY(new URL(Q),{requestInit:{headers:{...X.headers}},...Y?{fetch:Y}:{}})}function $L(Q,X){let Y=JL(X.getHeaders);return new CY(new URL(Q),{requestInit:{headers:{...X.headers}},...Y?{fetch:Y}:{}})}function BL(){return new ZY({name:"hermes-mcp-client",version:"0.1.0"},{capabilities:{}})}function A6(Q){return(Q instanceof H1||Q instanceof q6)&&Q.code===401}var y0=QI.child({prefix:"pi-mcp"}),XI=new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*[a-zA-Z]`,"g");function YI(Q,X){if(!X)return Q;try{let Y=X.consumeStderr();if(!Y.trim())return Q;let J=Y.replace(XI,"").split(`
|
|
88
|
+
`).map(($)=>$.trim()).filter(($)=>$.length>0).pop();if(!J)return Q;let W=J.length>200?`${J.slice(0,200)}…`:J;return`${Q}: ${W}`}catch{return Q}}var JI=2000000;function WI(Q){for(let X of Object.values(Q))if(g8(X))return!0;return!1}var O6="${augmentToken}";function $I(Q){try{let X=new URL(Q);if(X.protocol!=="https:")return!1;let{hostname:Y}=X;return Y==="augmentcode.com"||Y.endsWith(".augmentcode.com")}catch{return!1}}function BI(Q){try{let X=new URL(Q);return`${X.protocol}//${X.hostname}`}catch{return"<invalid URL>"}}class N6{name;_config;_client;_status;_lastError;_tools=[];_connectPromise;_disposed=!1;_resolvedEnv;_resolvedHeaders;constructor(Q){this._config=Q,this.name=Q.name,this._status=Q.disabled?"disabled":"initializing"}get status(){return this._status}get config(){return this._config}get lastError(){return this._lastError}get tools(){return this._tools}connect(){if(this._status==="disabled")return Promise.resolve();if(this._connectPromise)return this._connectPromise;return this._connectPromise=this._doConnect().catch((Q)=>{y0.warn(`MCP server "${this.name}" connect failed: ${Q instanceof Error?Q.message:String(Q)}`)}),this._connectPromise}async _doConnect(){let Q,X;try{let Y=this._config;if(Y.type==="http"||Y.type==="sse")await this._maybeProactiveRefresh();this._expandAugmentToken(),await this._resolveSecretRefs();let J=this._createTransport();if(Y.type==="stdio")X=J;Q=BL(),this._client=Q,await Q.connect(J);let W=await this._withAuthRetry(()=>{if(!this._client)throw Error(`MCP server "${this.name}" client is gone`);return this._client.listTools()});if(this._disposed){await Q.close(),this._client=void 0;return}this._tools=W.tools??[],this._status="success",this._lastError=void 0,G0().tokens.clearAuthRequired(this.name),y0.info(`MCP server "${this.name}" connected (${this._tools.length} tool(s))`)}catch(Y){if(A6(Y))this._status="auth_required",G0().tokens.markAuthRequired(this.name);else this._status="failed";let J=Y instanceof Error?Y.message:String(Y);this._lastError=YI(J,X);let W=this._client??Q;if(W){try{await W.close()}catch($){y0.debug(`MCP server "${this.name}" close after failed connect: ${$ instanceof Error?$.message:String($)}`)}this._client=void 0}}}_createTransport(){let Q=this._config;switch(Q.type){case"stdio":{let X=eZ(Q),Y=QL(this._resolvedEnv??Q.env);return YL({command:X.command,args:X.args,env:Y,cwd:Q.cwd})}case"http":return WL(Q.url,{headers:this._resolvedHeaders??Q.headers??{},getHeaders:()=>this._buildAuthHeaders()});case"sse":return $L(Q.url,{headers:this._resolvedHeaders??Q.headers??{},getHeaders:()=>this._buildAuthHeaders()});default:return Q}}async _resolveSecretRefs(){let Q=this._config,X=Q.type==="stdio"?Q.env:this._resolvedHeaders??Q.headers;if(!X||!WI(X))return;let Y=G0().secretsClient;if(!Y){this._recordLiteralRefs(X,"no credentials available");return}let J;try{J=await NJ({configEnv:X,localEnv:Q.type==="stdio"?XL():{},getSecret:(W)=>Y.getSecret(W)})}catch(W){y0.error(`MCP server "${this.name}" secret resolution failed: ${W instanceof Error?W.message:String(W)}`),this._recordLiteralRefs(X,"secret resolution error");return}if(Q.type==="stdio")this._resolvedEnv=J;else this._resolvedHeaders=J;this._recordLiteralRefs(J??X,"secret not found")}_recordLiteralRefs(Q,X){let Y=G0();for(let[J,W]of Object.entries(Q)){if(!g8(W))continue;let $=`secret reference in "${J}" left unresolved (${X})`;if(Y.diagnostics.some((G)=>G.server===this.name&&G.message===$))continue;Y.diagnostics.push({server:this.name,message:$}),y0.warn(`MCP server "${this.name}": ${$}`)}}_expandAugmentToken(){let Q=this._config;if(Q.type!=="http"&&Q.type!=="sse")return;let X=Q.headers;if(!X)return;if(!Object.values(X).some(($)=>$.includes(O6)))return;let J;if($I(Q.url)){let $=G0().credentials?.apiKey;if($)J=$;else this._recordTokenDiagnostic(`${O6} in a header but no Augment credentials are available; sending the literal placeholder`,"warn")}else this._recordTokenDiagnostic(`${O6} in a header is only expanded for https augmentcode.com / *.augmentcode.com URLs; "${BI(Q.url)}" does not qualify, sending the literal placeholder`,"error");if(J===void 0)return;let W={};for(let[$,B]of Object.entries(X))W[$]=B.replaceAll(O6,J);this._resolvedHeaders=W}_recordTokenDiagnostic(Q,X){let Y=G0();if(Y.diagnostics.some(($)=>$.server===this.name&&$.message===Q))return;Y.diagnostics.push({server:this.name,message:Q});let W=`MCP server "${this.name}": ${Q}`;if(X==="error")y0.error(W);else y0.warn(W)}_buildAuthHeaders(){let Q=G0().tokens.get(this.name);return Q?{Authorization:`Bearer ${Q.accessToken}`}:{}}async _maybeProactiveRefresh(){let Q=G0().tokens.get(this.name);if(!Q)return;if(zJ(Q)){if(Q.refreshToken)await this._refreshTokenDeduped();else if(FJ(Q))G0().tokens.markAuthRequired(this.name)}}_refreshTokenDeduped(){let Q=G0(),X=Q.refreshes.get(this.name);if(X)return X;let Y=(async()=>{let J=Q.tokens.get(this.name);if(!J?.refreshToken){Q.tokens.markAuthRequired(this.name);return}try{let W=await AJ(J);Q.tokens.set(this.name,W),y0.debug(`MCP server "${this.name}" token refreshed`)}catch(W){Q.tokens.markAuthRequired(this.name),y0.warn(`MCP server "${this.name}" token refresh failed: ${W instanceof Error?W.message:String(W)}`)}})().finally(()=>{Q.refreshes.delete(this.name)});return Q.refreshes.set(this.name,Y),Y}async _withAuthRetry(Q){let X=this._config;if(X.type!=="http"&&X.type!=="sse")return Q();try{return await Q()}catch(Y){if(!A6(Y))throw Y;y0.debug(`MCP server "${this.name}" got 401, attempting token refresh + retry`),await this._refreshTokenDeduped();try{return await Q()}catch(J){if(A6(J))this._status="auth_required",G0().tokens.markAuthRequired(this.name),y0.warn(`MCP server "${this.name}" still 401 after refresh — auth_required`);throw J}}}listTools(){return this._tools}async callTool(Q,X,Y){if(this._status!=="success"||!this._client)throw Error(`MCP server "${this.name}" is not connected (status: ${this._status})`);let J=this._config.timeoutMs??JI,W=await this._withAuthRetry(()=>{if(!this._client)throw Error(`MCP server "${this.name}" client is gone`);return this._client.callTool({name:Q,arguments:X??{}},Q1,{timeout:J,signal:Y})}),$=[];if(Array.isArray(W.content)){for(let B of W.content)if(B.type==="text"&&typeof B.text==="string")$.push({type:"text",text:B.text});else if(B.type==="image"&&typeof B.data==="string"&&typeof B.mimeType==="string"){let G=B;$.push({type:"image",mimeType:G.mimeType,data:G.data})}}return{isError:W.isError===!0,content:$}}async dispose(){this._disposed=!0;let Q=this._client;if(this._client=void 0,!Q)return;try{await Q.close()}catch(X){y0.debug(`MCP server "${this.name}" close error: ${X instanceof Error?X.message:String(X)}`)}}}async function U6(Q,X,Y){let J=[];for(let W of Q){let $=X.servers.get(W.name);if($)$.dispose();let B=new N6(W);X.servers.set(W.name,B),J.push(B.connect().then(()=>{if(B.status==="success")v8(X.currentLoad?.latestPi??Y,B)}))}await Promise.all(J)}async function GL(Q,X,Y){let J=X.servers.get(Q);if(!J)return;let W=J.config;J.dispose();let $=new N6(W);if(X.servers.set(Q,$),await $.connect(),$.status==="success")v8(Y,$)}import{logger as FI}from"@hermes/logger";import{logger as GI}from"@hermes/logger";var HL=GI.child({prefix:"pi-mcp"}),R8={maxTries:3,initialMs:500,mult:2,maxMs:2000},iY=30000,E8=200;class R9 extends Error{statusCode;statusText;responseBody;constructor(Q,X,Y){super(`${Q} ${X}: ${Y}`);this.name="McpRegistryHttpError",this.statusCode=Q,this.statusText=X,this.responseBody=Y}}function HI(Q){if(Q instanceof R9)return Q.statusCode>=500;return!0}function KI(Q){return new Promise((X)=>setTimeout(X,Q))}async function M6(Q){let X;for(let Y=0;Y<R8.maxTries;Y++)try{return await Q()}catch(J){if(X=J,!HI(J))throw J;if(Y<R8.maxTries-1){let W=Math.min(R8.initialMs*R8.mult**Y,R8.maxMs);await KI(W)}}throw X}class nY{apiKey;apiUrl;fetchImpl;timeoutMs;constructor(Q,X,Y){this.apiKey=Q.apiKey,this.apiUrl=Q.apiUrl.replace(/\/+$/,""),this.fetchImpl=X,this.timeoutMs=Y??iY}async callApi(Q,X){let J=await(this.fetchImpl??fetch)(`${this.apiUrl}${Q}`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:X===void 0?"{}":JSON.stringify({product_type:X}),signal:AbortSignal.timeout(this.timeoutMs)});if(!J.ok){let W=await J.text().catch(()=>""),$=W.length>E8?`${W.slice(0,E8)}…[truncated]`:W;throw new R9(J.status,J.statusText,$)}return await J.json()}getMcpTenantConfigs(Q){return M6(()=>this.callApi("/settings/get-mcp-tenant-configs",Q))}getMcpUserConfigs(Q){return M6(()=>this.callApi("/settings/get-mcp-user-configs",Q))}}async function KL(Q,X){let Y=[],[J,W]=await Promise.allSettled([Q.getMcpTenantConfigs(X),Q.getMcpUserConfigs(X)]),$={},B={};if(J.status==="fulfilled")$=J.value;else{let G=`Failed to fetch tenant MCP configs: ${String(J.reason)}`;HL.warn(G),Y.push({message:G})}if(W.status==="fulfilled")B=W.value;else{let G=`Failed to fetch user MCP configs: ${String(W.reason)}`;HL.warn(G),Y.push({message:G})}return{tenant:$,user:B,diagnostics:Y}}var oY={UNSPECIFIED:0,NONE:1,OAUTH:2,API_KEY:3},S8={UNSPECIFIED:0,CLI:1,CLOUD_AGENT:2};function ZI(Q){if(Q===void 0||Q===null)return;if(typeof Q==="number"||!Number.isNaN(Number(Q)))switch(Number(Q)){case oY.OAUTH:return"oauth";case oY.API_KEY:return"header";default:return}let X=String(Q).toLowerCase();if(X==="oauth"||X==="mcp_auth_type_oauth")return"oauth";if(X==="header"||X==="api_key"||X==="mcp_auth_type_api_key")return"header";return}function LI(Q){if(typeof Q==="number"||!Number.isNaN(Number(Q)))switch(Number(Q)){case S8.CLI:return"cli";case S8.CLOUD_AGENT:return"cloud_agent";default:return}switch(Q){case"MCP_PRODUCT_TYPE_CLI":return"cli";case"MCP_PRODUCT_TYPE_CLOUD_AGENT":return"cloud_agent";default:return}}function ZL(Q){if(!Q||Q.length===0)return;let X=Q.map(LI).filter((Y)=>Y!==void 0);return X.length===0?void 0:X}function LL(Q,X){let Y=Q.config;if(!Y)return{ok:!1,reason:"no config payload"};let J=ZI(Y.auth_type),W={name:Y.name,type:Y.type==="http"||Y.type==="sse"||Y.type==="stdio"?Y.type:void 0,disabled:Y.disabled,command:Y.command,args:Y.args,env:Y.env,url:Y.url,auth:J==="oauth"?"oauth":void 0,timeoutMs:Y.timeout_ms,useShellInterpolation:Y.use_shell_interpolation},$=R6(W);if(($==="http"||$==="sse")&&Y.env)W.headers=Y.env;try{return{ok:!0,server:{...x8(Y.name??Q.id,W),id:Q.id,registrySource:X}}}catch(B){return{ok:!1,reason:B instanceof K1?B.message:String(B)}}}function rY(Q,X,Y){let J=new Map;for(let W of Q)if(Y(W.id))J.set(W.id,W);for(let W of X)J.set(W.id,W);return[...J.values()]}function VI(Q){let{tenantConfigs:X,userConfigs:Y,enabledSharedServerIds:J,configIds:W}=Q;if(W!=null&&W.length===0){let Z=rY(X,Y,()=>!0);return{selected:[],filteredOutIds:Z.map((L)=>L.id),missingIds:[]}}if(W!=null){let Z=new Set(W),L=rY(X,Y,()=>!0),V=new Set(L.map((N)=>N.id)),D=L.filter((N)=>Z.has(N.id)),z=L.filter((N)=>!Z.has(N.id)).map((N)=>N.id),A=W.filter((N)=>!V.has(N));return{selected:D,filteredOutIds:z,missingIds:A}}let $=new Set(J),B=[];for(let Z of X)if(!$.has(Z.id))B.push(Z.id);let G=rY(X,Y,(Z)=>$.has(Z)),K=new Set(Y.map((Z)=>Z.id)),H=[];for(let Z of G){let V=!K.has(Z.id)&&$.has(Z.id)?Q.serverProductPreferences[Z.id]?.enabled_products:void 0,D=ZL(V??Z.enabled_products);if(D===void 0||D.includes("cloud_agent"))H.push(Z);else B.push(Z.id)}return{selected:H,filteredOutIds:B,missingIds:[]}}function DI(Q){return Q==null?S8.CLOUD_AGENT:void 0}function qI(Q){return Q.map((X)=>({message:`Selected MCP config id "${X}" was not returned by the registry (not opted in to the shared server, deleted, or an unknown id)`}))}function zI(Q,X,Y,J){try{return{ok:!0,server:Q.type==="stdio"?_8(Q,J):k8(Q,J)}}catch(W){let $=W instanceof Error?W.message:String(W);return{ok:!1,diagnostic:{server:Q.name,message:`Skipped registry MCP server "${Q.name}" (id=${X}, ${Y}): ${$}`}}}}async function VL(Q){let X=Q.client??new nY(Q.creds),{tenant:Y,user:J,diagnostics:W}=await KL(X,DI(Q.configIds)),$=J.mcp_configs??[],B=new Set($.map((D)=>D.id)),{selected:G,filteredOutIds:K,missingIds:H}=VI({tenantConfigs:Y.mcp_configs??[],userConfigs:$,enabledSharedServerIds:J.enabled_shared_server_ids??[],serverProductPreferences:J.server_product_preferences??{},configIds:Q.configIds});W.push(...qI(H));let Z=[],L=new Set(Q.localServerNames),V=[...G.filter((D)=>B.has(D.id)),...G.filter((D)=>!B.has(D.id))];for(let D of V){if(D.config?.disabled)continue;let z=B.has(D.id)?"user":"tenant",A=LL(D,z);if(!A.ok){let U=D.config?.name;W.push({server:U,message:`Skipped registry MCP server "${U??D.id}" (id=${D.id}, ${z}): ${A.reason}`});continue}let N=A.server;if(L.has(N.name)){let U=Q.localServerNames.has(N.name)?`Skipped registry MCP server "${N.name}" (id=${D.id}, ${z}): a local server with the same name takes precedence`:`Skipped registry MCP server "${N.name}" (id=${D.id}, ${z}): name collides with a higher-precedence registry server`;W.push({server:N.name,message:U});continue}let F=zI(N,D.id,z,Q.workspaceRoot);if(!F.ok){W.push(F.diagnostic);continue}L.add(N.name),Z.push(F.server)}return{servers:Z,diagnostics:W,filteredOutIds:K}}var m1=FI.child({prefix:"pi-mcp"});function AI(Q){for(let[X,Y]of Q.servers)if(Y.config.registrySource!==void 0)Y.dispose(),Q.servers.delete(X)}function DL(Q){let{pi:X,state:Y,data:J,deps:W}=Q,$=W?.discover??VL,B=W?.connect??U6,G=J;if(!G||typeof G!=="object"||Array.isArray(G))return m1.warn("augment:mcp-config-ids payload is not an object"),Promise.resolve();let K=Y.credentials;if(!K)return m1.warn("augment:mcp-config-ids received before credentials; skipping registry discovery"),Promise.resolve();AI(Y),Y.diagnostics=Y.diagnostics.filter((V)=>V.origin!=="registry");let H=++Y.registryGeneration,Z=Y.currentLoad?.latestPi??X,L=new Set;for(let V of Y.servers.values())if(V.config.registrySource===void 0)L.add(V.name);return $({configIds:G.configIds,creds:K,workspaceRoot:Y.workspaceRoot??process.cwd(),localServerNames:L}).then((V)=>{if(Y.registryGeneration!==H){m1.info(`Registry discovery superseded by a newer selection; skipping ${V.servers.length} server(s)`);return}for(let D of V.diagnostics)Y.diagnostics.push({...D,origin:"registry"}),m1.warn(D.message);if(V.filteredOutIds.length>0)m1.info(`Registry discovery filtered out ${V.filteredOutIds.length} server(s) by selection/opt-in/product`);if(V.servers.length===0)return;return m1.info(`Registry discovery: connecting ${V.servers.length} server(s)`),B(V.servers,Y,Z)}).catch((V)=>{let D=`Registry discovery failed: ${V instanceof Error?V.message:String(V)}`;if(m1.warn(D),Y.registryGeneration===H)Y.diagnostics.push({message:D,origin:"registry"})})}import{logger as OI}from"@hermes/logger";var tY=OI.child({prefix:"pi-mcp"}),NI=1;function UI(Q){return Q.replace(/[^a-zA-Z0-9_-]/g,"-")}function MI(Q,X){if(X?.["augment:encoding"]!=="base64")return Q;if(/^[A-Za-z0-9+/]*={0,2}$/.test(Q)&&Q.length%4===0)return Buffer.from(Q,"base64").toString("utf-8");return Q}class aY{apiKey;apiUrl;fetchImpl;timeoutMs;cache=new Map;inflight=new Map;constructor(Q,X,Y){this.apiKey=Q.apiKey,this.apiUrl=Q.apiUrl.replace(/\/+$/,""),this.fetchImpl=X,this.timeoutMs=Y??iY}getSecret(Q){let X=UI(Q),Y=this.inflight.get(X);if(Y)return Y;let J=this._resolve(X).finally(()=>{this.inflight.delete(X)});return this.inflight.set(X,J),J}async _resolve(Q){let X=await this._tryGet("/user-secrets/get",{name:Q,scope:NI},Q);if(X.value!==void 0)return this.cache.set(Q,X.value),X.value;let Y=await this._tryGet("/tenant-secrets/get",{name:Q},Q);if(Y.value!==void 0)return this.cache.set(Q,Y.value),Y.value;if(X.errored||Y.errored){let J=this.cache.get(Q);if(J!==void 0)tY.debug(`Secret "${Q}" lookup failed; using cached fallback value`);return J}this.cache.delete(Q);return}async _tryGet(Q,X,Y){try{let J=await M6(()=>this._callApi(Q,X)),W=J.secret?.value;if(W===void 0)return{errored:!1};return{value:MI(W,J.secret?.tags),errored:!1}}catch(J){if(J instanceof R9&&J.statusCode===404)return tY.debug(`Secret "${Y}" not found via ${Q} (404)`),{errored:!1};let W=J instanceof Error?J.message:String(J);return tY.debug(`Secret "${Y}" lookup via ${Q} failed: ${W}`),{errored:!0}}}async _callApi(Q,X){let J=await(this.fetchImpl??fetch)(`${this.apiUrl}${Q}`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify(X),signal:AbortSignal.timeout(this.timeoutMs)});if(!J.ok){let W=await J.text().catch(()=>""),$=W.length>E8?`${W.slice(0,E8)}…[truncated]`:W;throw new R9(J.status,J.statusText,$)}return await J.json()}}function sY(Q){return{latestPi:Q}}var w6=wI.child({prefix:"pi-mcp"}),qL="augment:mcp-oauth-credentials",zL="augment:credentials",PI="augment:mcp-config-ids";function jI(Q,X){if(X.credsListenerBound)return;X.credsListenerBound=!0,Q.events.on(qL,(Y)=>{if(!Y||typeof Y!=="object"){w6.warn(`${qL} payload is not an object`);return}let J=Y,W=XJ(X.tokens,J);if(W.length===0)return;w6.info(`Seeded MCP OAuth token(s) for ${W.length} server(s)`);let $=X.currentLoad?.latestPi??Q;for(let B of W){let G=X.servers.get(B);if(G&&G.config.type!=="stdio"&&G.config.auth==="oauth")GL(B,X,$)}})}function II(Q,X){if(X.configIdsListenerBound)return;X.configIdsListenerBound=!0,Q.events.on(zL,(Y)=>{let J=Y;if(!J||typeof J.apiKey!=="string"||typeof J.apiUrl!=="string"){w6.warn(`${zL} payload missing apiKey or apiUrl`);return}X.credentials={apiKey:J.apiKey,apiUrl:J.apiUrl},X.secretsClient=new aY(X.credentials)}),Q.events.on(PI,(Y)=>{DL({pi:Q,state:X,data:Y})})}function bI(Q){let X=G0();X.currentLoad=sY(Q),YJ(Q,X),jI(Q,X),II(Q,X),Q.on("session_start",(Y,J)=>{if(X.currentLoad=sY(Q),X.workspaceRoot=J.cwd,X.connectStarted)qJ(Q,X);else{X.connectStarted=!0;let{servers:W,diagnostics:$}=LJ(J.cwd,J.agentDir);for(let B of $)X.diagnostics.push(B),w6.warn(B.message);U6(W,X,Q)}})}export{bI as default};
|
|
89
|
+
|
|
90
|
+
//# debugId=2318A7F9CA5D90EE64756E2164756E21
|