@mcpcloud/runtime 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/stdio.js CHANGED
@@ -1,52 +1,77 @@
1
- /*! @mcpcloud/runtime v0.12.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
- var P3=Object.create;var{getPrototypeOf:R3,defineProperty:i1,getOwnPropertyNames:Z3}=Object;var E3=Object.prototype.hasOwnProperty;function I3(W){return this[W]}var C3,_3,S3=(W,X,K)=>{var Y=W!=null&&typeof W==="object";if(Y){var Q=X?C3??=new WeakMap:_3??=new WeakMap,q=Q.get(W);if(q)return q}K=W!=null?P3(R3(W)):{};let J=X||!W||!W.__esModule?i1(K,"default",{value:W,enumerable:!0}):K;for(let G of Z3(W))if(!E3.call(J,G))i1(J,G,{get:I3.bind(W,G),enumerable:!0});if(Y)Q.set(W,J);return J};var A3=(W,X)=>()=>(X||W((X={exports:{}}).exports,X),X.exports);var j3=(W)=>W;function b3(W,X){this[W]=j3.bind(null,X)}var n1=(W,X)=>{for(var K in X)i1(W,K,{get:X[K],enumerable:!0,configurable:!0,set:b3.bind(X,K)})};var t1=(W,X)=>()=>(W&&(X=W(W=0)),X);var j0,i9,y1,b0,G1;var f1=t1(()=>{j0={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},i9={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},y1={Pending:0,Fulfilled:1,Rejected:2},b0={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},G1={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function q1(...W){W6&&console.log("quickjs-emscripten:",...W)}function*q3(W){return yield W}function zQ(W){return q3(K6(W))}function oW(W,X){return(...K)=>{let Y=X.call(W,X6,...K);return K6(Y)}}function BQ(W,X){let K=X.call(W,X6);return K6(K)}function K6(W){function X(K){return K.done?K.value:K.value instanceof Promise?K.value.then((Y)=>X(W.next(Y)),(Y)=>X(W.throw(Y))):X(W.next(K.value))}return X(W.next())}function n9(W,X){let K;try{W.dispose()}catch(Y){K=Y}if(X&&K)throw Object.assign(X,{message:`${X.message}
3
- Then, failed to dispose scope: ${K.message}`,disposeError:K}),X;if(X||K)throw X||K}function $Q(W){let X=W?Array.from(W):[];function K(){return X.forEach((Q)=>Q.alive?Q.dispose():void 0)}function Y(){return X.some((Q)=>Q.alive)}return Object.defineProperty(X,e9,{configurable:!0,enumerable:!1,value:K}),Object.defineProperty(X,"dispose",{configurable:!0,enumerable:!1,value:K}),Object.defineProperty(X,"alive",{configurable:!0,enumerable:!1,get:Y}),X}function m1(W){return!!(W&&(typeof W=="object"||typeof W=="function")&&("alive"in W)&&typeof W.alive=="boolean"&&("dispose"in W)&&typeof W.dispose=="function")}function wQ(W){if(!W)return 0;let X=0;for(let[K,Y]of Object.entries(W)){if(!(K in i9))throw new K3(K);Y&&(X|=i9[K])}return X}function DQ(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{type:X,strict:K,strip:Y,compileOnly:Q,backtraceBarrier:q}=W,J=0;return X==="global"&&(J|=j0.JS_EVAL_TYPE_GLOBAL),X==="module"&&(J|=j0.JS_EVAL_TYPE_MODULE),K&&(J|=j0.JS_EVAL_FLAG_STRICT),Y&&(J|=j0.JS_EVAL_FLAG_STRIP),Q&&(J|=j0.JS_EVAL_FLAG_COMPILE_ONLY),q&&(J|=j0.JS_EVAL_FLAG_BACKTRACE_BARRIER),J}function MQ(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{strings:X,symbols:K,quickjsPrivate:Y,onlyEnumerable:Q,numbers:q,numbersAsStrings:J}=W,G=0;return X&&(G|=b0.JS_GPN_STRING_MASK),K&&(G|=b0.JS_GPN_SYMBOL_MASK),Y&&(G|=b0.JS_GPN_PRIVATE_MASK),Q&&(G|=b0.JS_GPN_ENUM_ONLY),q&&(G|=b0.QTS_GPN_NUMBER_MASK),J&&(G|=b0.QTS_STANDARD_COMPLIANT_NUMBER),G}function OQ(...W){let X=[];for(let K of W)K!==void 0&&(X=X.concat(K));return X}function t9(W){return W>>8}function G6(W,X){X.interruptHandler&&W.setInterruptHandler(X.interruptHandler),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes)}function q6(W,X){X.moduleLoader&&W.setModuleLoader(X.moduleLoader),X.shouldInterrupt&&W.setInterruptHandler(X.shouldInterrupt),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes)}var YQ,QQ=(W,X)=>{for(var K in X)YQ(W,K,{get:X[K],enumerable:!0})},W6=!1,GQ,a9,sW,s9,eW,W3,X3,qQ,JQ,K3,Y3,Q3,G3,C0,X6,V0,e9,rW,X0,T0,iW,D0,Y6,HQ,UQ,f0,LQ,J3=class{constructor(W){this.module=W}toPointerArray(W){let X=new Int32Array(W.map((Q)=>Q.value)),K=X.length*X.BYTES_PER_ELEMENT,Y=this.module._malloc(K);return new Uint8Array(this.module.HEAPU8.buffer,Y,K).set(new Uint8Array(X.buffer)),new X0(Y,void 0,(Q)=>this.module._free(Q))}newTypedArray(W,X){let K=new W(Array(X).fill(0)),Y=K.length*K.BYTES_PER_ELEMENT,Q=this.module._malloc(Y),q=new W(this.module.HEAPU8.buffer,Q,X);return q.set(K),new X0({typedArray:q,ptr:Q},void 0,(J)=>this.module._free(J.ptr))}newMutablePointerArray(W){return this.newTypedArray(Int32Array,W)}newHeapCharPointer(W){let X=this.module.lengthBytesUTF8(W),K=X+1,Y=this.module._malloc(K);return this.module.stringToUTF8(W,Y,K),new X0({ptr:Y,strlen:X},void 0,(Q)=>this.module._free(Q.ptr))}newHeapBufferPointer(W){let X=W.byteLength,K=this.module._malloc(X);return this.module.HEAPU8.set(W,K),new X0({pointer:K,numBytes:X},void 0,(Y)=>this.module._free(Y.pointer))}consumeHeapCharPointer(W){let X=this.module.UTF8ToString(W);return this.module._free(W),X}},DG,MG,FQ,nW=-2147483648,tW=2147483647,c1=0,NQ=class{constructor(){this.nextId=nW,this.freelist=[],this.groups=new Map}put(W){let X=this.allocateId(),K=t9(X),Y=this.groups.get(K);return Y||(Y=new Map,this.groups.set(K,Y)),Y.set(X,W),X}get(W){if(W===c1)throw new C0("no host reference id defined");let X=t9(W),K=this.groups.get(X);if(!K)throw new C0(`host reference id ${W} is not defined`);let Y=K.get(W);if(!Y)throw new C0(`host reference id ${W} is not defined`);return Y}delete(W){if(W===c1)throw new C0("no host reference id defined");let X=t9(W),K=this.groups.get(X);if(!K)throw new C0(`host reference id ${W} is not defined`);K.delete(W),K.size===0&&this.groups.delete(X),this.freelist.push(W)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===c1&&this.nextId++,this.nextId>tW)throw new G3(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${tW-nW}`);return this.nextId++}},aW,VQ,PQ,RQ,ZQ=class{constructor(W){this.freeHostRef=W.freeHostRef,this.callFunction=W.callFunction,this.shouldInterrupt=W.shouldInterrupt,this.loadModuleSource=W.loadModuleSource,this.normalizeModule=W.normalizeModule}},Q6=class{constructor(W){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new ZQ({freeHostRef:(X,K,Y)=>{let Q=this.runtimeCallbacks.get(K);if(!Q)throw Error(`QuickJSRuntime(rt = ${K}) not found when trying to free HostRef(id = ${Y})`);Q.freeHostRef(K,Y)},callFunction:(X,K,Y,Q,q,J)=>this.handleAsyncify(X,()=>{try{let G=this.contextCallbacks.get(K);if(!G)throw Error(`QuickJSContext(ctx = ${K}) not found for C function call "${J}"`);return G.callFunction(K,Y,Q,q,J)}catch(G){return console.error("[C to host error: returning null]",G),0}}),shouldInterrupt:(X,K)=>this.handleAsyncify(X,()=>{try{let Y=this.runtimeCallbacks.get(K);if(!Y)throw Error(`QuickJSRuntime(rt = ${K}) not found for C interrupt`);return Y.shouldInterrupt(K)}catch(Y){return console.error("[C to host interrupt: returning error]",Y),1}}),loadModuleSource:(X,K,Y,Q)=>this.handleAsyncify(X,()=>{try{let q=this.runtimeCallbacks.get(K);if(!q)throw Error(`QuickJSRuntime(rt = ${K}) not found for C module loader`);let J=q.loadModuleSource;if(!J)throw Error(`QuickJSRuntime(rt = ${K}) does not support module loading`);return J(K,Y,Q)}catch(q){return console.error("[C to host module loader error: returning null]",q),0}}),normalizeModule:(X,K,Y,Q,q)=>this.handleAsyncify(X,()=>{try{let J=this.runtimeCallbacks.get(K);if(!J)throw Error(`QuickJSRuntime(rt = ${K}) not found for C module loader`);let G=J.normalizeModule;if(!G)throw Error(`QuickJSRuntime(rt = ${K}) does not support module loading`);return G(K,Y,Q,q)}catch(J){return console.error("[C to host module loader error: returning null]",J),0}})}),this.module=W,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(W,X){this.runtimeCallbacks.set(W,X)}deleteRuntime(W){this.runtimeCallbacks.delete(W)}setContextCallbacks(W,X){this.contextCallbacks.set(W,X)}deleteContext(W){this.contextCallbacks.delete(W)}handleAsyncify(W,X){if(W)return W.handleSleep((Y)=>{try{let Q=X();if(!(Q instanceof Promise)){q1("asyncify.handleSleep: not suspending:",Q),Y(Q);return}if(this.suspended)throw new W3(`Already suspended at: ${this.suspended.stack}
4
- Attempted to suspend at:`);this.suspended=new X3(`(${this.suspendedCount++})`),q1("asyncify.handleSleep: suspending:",this.suspended),Q.then((q)=>{this.suspended=void 0,q1("asyncify.handleSleep: resolved:",q),Y(q)},(q)=>{q1("asyncify.handleSleep: rejected:",q),console.error("QuickJS: cannot handle error in suspended function",q),this.suspended=void 0})}catch(Q){throw q1("asyncify.handleSleep: error:",Q),this.suspended=void 0,Q}});let K=X();if(K instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return K}},z3=class{constructor(W,X){this.module=W,this.ffi=X,this.callbacks=new Q6(W)}newRuntime(W={}){let X=new X0(this.ffi.QTS_NewRuntime(),void 0,(Y)=>{this.ffi.QTS_FreeRuntime(Y),this.callbacks.deleteRuntime(Y)}),K=new RQ({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:X});return G6(K,W),W.moduleLoader&&K.setModuleLoader(W.moduleLoader),K}newContext(W={}){let X=this.newRuntime(),K=X.newContext({...W,ownedLifetimes:OQ(X,W.ownedLifetimes)});return X.context=K,K}evalCode(W,X={}){return D0.withScope((K)=>{let Y=K.manage(this.newContext());q6(Y.runtime,X);let Q=Y.evalCode(W,"eval.js");if(X.memoryLimitBytes!==void 0&&Y.runtime.setMemoryLimit(-1),Q.error)throw Y.dump(K.manage(Q.error));return Y.dump(K.manage(Q.value))})}getWasmMemory(){let W=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!W)throw Error("Variant does not support getting WebAssembly.Memory");return W}getFFI(){return this.ffi}};var B3=t1(()=>{f1();f1();YQ=Object.defineProperty;GQ={};QQ(GQ,{QuickJSAsyncifyError:()=>W3,QuickJSAsyncifySuspended:()=>X3,QuickJSEmptyGetOwnPropertyNames:()=>Q3,QuickJSEmscriptenModuleError:()=>JQ,QuickJSHostRefInvalid:()=>C0,QuickJSHostRefRangeExceeded:()=>G3,QuickJSMemoryLeakDetected:()=>qQ,QuickJSNotImplemented:()=>eW,QuickJSPromisePending:()=>Y3,QuickJSUnknownIntrinsic:()=>K3,QuickJSUnwrapError:()=>a9,QuickJSUseAfterFree:()=>s9,QuickJSWrongOwner:()=>sW});a9=class extends Error{constructor(W,X){let K=typeof W=="object"&&W&&"message"in W?String(W.message):String(W);super(K);this.cause=W,this.context=X,this.name="QuickJSUnwrapError"}},sW=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},s9=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},eW=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},W3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},X3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},qQ=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},JQ=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},K3=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},Y3=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},Q3=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},G3=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},C0=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};X6=q3;X6.of=zQ;V0=class{[Symbol.dispose](){return this.dispose()}},e9=Symbol.dispose??Symbol.for("Symbol.dispose"),rW=V0.prototype;rW[e9]||(rW[e9]=function(){return this.dispose()});X0=class W extends V0{constructor(X,K,Y,Q){super();this._value=X,this.copier=K,this.disposer=Y,this._owner=Q,this._alive=!0,this._constructorStack=W6?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new W(this.copier(this._value),this.copier,this.disposer,this._owner)}consume(X){this.assertAlive();let K=X(this);return this.dispose(),K}map(X){return this.assertAlive(),X(this)}tap(X){return X(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new s9(`Lifetime not alive
1
+ /*! @mcpcloud/runtime v0.12.1 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
2
+ var A3=Object.create;var{getPrototypeOf:j3,defineProperty:t1,getOwnPropertyNames:S3}=Object;var b3=Object.prototype.hasOwnProperty;function T3(W){return this[W]}var k3,v3,x3=(W,X,Y)=>{var Q=W!=null&&typeof W==="object";if(Q){var K=X?k3??=new WeakMap:v3??=new WeakMap,q=K.get(W);if(q)return q}Y=W!=null?A3(j3(W)):{};let J=X||!W||!W.__esModule?t1(Y,"default",{value:W,enumerable:!0}):Y;for(let G of S3(W))if(!b3.call(J,G))t1(J,G,{get:T3.bind(W,G),enumerable:!0});if(Q)K.set(W,J);return J};var g3=(W,X)=>()=>(X||W((X={exports:{}}).exports,X),X.exports);var h3=(W)=>W;function y3(W,X){this[W]=h3.bind(null,X)}var a1=(W,X)=>{for(var Y in X)t1(W,Y,{get:X[Y],enumerable:!0,configurable:!0,set:y3.bind(X,Y)})};var s1=(W,X)=>()=>(W&&(X=W(W=0)),X);var S0,a9,m1,b0,$1;var u1=s1(()=>{S0={JS_EVAL_TYPE_GLOBAL:0,JS_EVAL_TYPE_MODULE:1,JS_EVAL_TYPE_DIRECT:2,JS_EVAL_TYPE_INDIRECT:3,JS_EVAL_TYPE_MASK:3,JS_EVAL_FLAG_STRICT:8,JS_EVAL_FLAG_STRIP:16,JS_EVAL_FLAG_COMPILE_ONLY:32,JS_EVAL_FLAG_BACKTRACE_BARRIER:64},a9={BaseObjects:1,Date:2,Eval:4,StringNormalize:8,RegExp:16,RegExpCompiler:32,JSON:64,Proxy:128,MapSet:256,TypedArrays:512,Promise:1024,BigInt:2048,BigFloat:4096,BigDecimal:8192,OperatorOverloading:16384,BignumExt:32768},m1={Pending:0,Fulfilled:1,Rejected:2},b0={JS_GPN_STRING_MASK:1,JS_GPN_SYMBOL_MASK:2,JS_GPN_PRIVATE_MASK:4,JS_GPN_ENUM_ONLY:16,JS_GPN_SET_ENUM:32,QTS_GPN_NUMBER_MASK:64,QTS_STANDARD_COMPLIANT_NUMBER:128},$1={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function H1(...W){Q4&&console.log("quickjs-emscripten:",...W)}function*L3(W){return yield W}function M7(W){return L3(G4(W))}function eW(W,X){return(...Y)=>{let Q=X.call(W,K4,...Y);return G4(Q)}}function F7(W,X){let Y=X.call(W,K4);return G4(Y)}function G4(W){function X(Y){return Y.done?Y.value:Y.value instanceof Promise?Y.value.then((Q)=>X(W.next(Q)),(Q)=>X(W.throw(Q))):X(W.next(Y.value))}return X(W.next())}function s9(W,X){let Y;try{W.dispose()}catch(Q){Y=Q}if(X&&Y)throw Object.assign(X,{message:`${X.message}
3
+ Then, failed to dispose scope: ${Y.message}`,disposeError:Y}),X;if(X||Y)throw X||Y}function O7(W){let X=W?Array.from(W):[];function Y(){return X.forEach((K)=>K.alive?K.dispose():void 0)}function Q(){return X.some((K)=>K.alive)}return Object.defineProperty(X,Y4,{configurable:!0,enumerable:!1,value:Y}),Object.defineProperty(X,"dispose",{configurable:!0,enumerable:!1,value:Y}),Object.defineProperty(X,"alive",{configurable:!0,enumerable:!1,get:Q}),X}function l1(W){return!!(W&&(typeof W=="object"||typeof W=="function")&&("alive"in W)&&typeof W.alive=="boolean"&&("dispose"in W)&&typeof W.dispose=="function")}function Z7(W){if(!W)return 0;let X=0;for(let[Y,Q]of Object.entries(W)){if(!(Y in a9))throw new B3(Y);Q&&(X|=a9[Y])}return X}function R7(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{type:X,strict:Y,strip:Q,compileOnly:K,backtraceBarrier:q}=W,J=0;return X==="global"&&(J|=S0.JS_EVAL_TYPE_GLOBAL),X==="module"&&(J|=S0.JS_EVAL_TYPE_MODULE),Y&&(J|=S0.JS_EVAL_FLAG_STRICT),Q&&(J|=S0.JS_EVAL_FLAG_STRIP),K&&(J|=S0.JS_EVAL_FLAG_COMPILE_ONLY),q&&(J|=S0.JS_EVAL_FLAG_BACKTRACE_BARRIER),J}function E7(W){if(typeof W=="number")return W;if(W===void 0)return 0;let{strings:X,symbols:Y,quickjsPrivate:Q,onlyEnumerable:K,numbers:q,numbersAsStrings:J}=W,G=0;return X&&(G|=b0.JS_GPN_STRING_MASK),Y&&(G|=b0.JS_GPN_SYMBOL_MASK),Q&&(G|=b0.JS_GPN_PRIVATE_MASK),K&&(G|=b0.JS_GPN_ENUM_ONLY),q&&(G|=b0.QTS_GPN_NUMBER_MASK),J&&(G|=b0.QTS_STANDARD_COMPLIANT_NUMBER),G}function I7(...W){let X=[];for(let Y of W)Y!==void 0&&(X=X.concat(Y));return X}function e9(W){return W>>8}function z4(W,X){X.interruptHandler&&W.setInterruptHandler(X.interruptHandler),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes)}function B4(W,X){X.moduleLoader&&W.setModuleLoader(X.moduleLoader),X.shouldInterrupt&&W.setInterruptHandler(X.shouldInterrupt),X.memoryLimitBytes!==void 0&&W.setMemoryLimit(X.memoryLimitBytes),X.maxStackSizeBytes!==void 0&&W.setMaxStackSize(X.maxStackSizeBytes)}var H7,U7=(W,X)=>{for(var Y in X)H7(W,Y,{get:X[Y],enumerable:!0})},Q4=!1,L7,W4,G3,X4,q3,J3,z3,D7,w7,B3,$3,H3,U3,C0,K4,V0,Y4,W3,X0,T0,X3,D0,q4,V7,N7,m0,P7,D3=class{constructor(W){this.module=W}toPointerArray(W){let X=new Int32Array(W.map((K)=>K.value)),Y=X.length*X.BYTES_PER_ELEMENT,Q=this.module._malloc(Y);return new Uint8Array(this.module.HEAPU8.buffer,Q,Y).set(new Uint8Array(X.buffer)),new X0(Q,void 0,(K)=>this.module._free(K))}newTypedArray(W,X){let Y=new W(Array(X).fill(0)),Q=Y.length*Y.BYTES_PER_ELEMENT,K=this.module._malloc(Q),q=new W(this.module.HEAPU8.buffer,K,X);return q.set(Y),new X0({typedArray:q,ptr:K},void 0,(J)=>this.module._free(J.ptr))}newMutablePointerArray(W){return this.newTypedArray(Int32Array,W)}newHeapCharPointer(W){let X=this.module.lengthBytesUTF8(W),Y=X+1,Q=this.module._malloc(Y);return this.module.stringToUTF8(W,Q,Y),new X0({ptr:Q,strlen:X},void 0,(K)=>this.module._free(K.ptr))}newHeapBufferPointer(W){let X=W.byteLength,Y=this.module._malloc(X);return this.module.HEAPU8.set(W,Y),new X0({pointer:Y,numBytes:X},void 0,(Q)=>this.module._free(Q.pointer))}consumeHeapCharPointer(W){let X=this.module.UTF8ToString(W);return this.module._free(W),X}},ZG,RG,C7,Y3=-2147483648,Q3=2147483647,p1=0,_7=class{constructor(){this.nextId=Y3,this.freelist=[],this.groups=new Map}put(W){let X=this.allocateId(),Y=e9(X),Q=this.groups.get(Y);return Q||(Q=new Map,this.groups.set(Y,Q)),Q.set(X,W),X}get(W){if(W===p1)throw new C0("no host reference id defined");let X=e9(W),Y=this.groups.get(X);if(!Y)throw new C0(`host reference id ${W} is not defined`);let Q=Y.get(W);if(!Q)throw new C0(`host reference id ${W} is not defined`);return Q}delete(W){if(W===p1)throw new C0("no host reference id defined");let X=e9(W),Y=this.groups.get(X);if(!Y)throw new C0(`host reference id ${W} is not defined`);Y.delete(W),Y.size===0&&this.groups.delete(X),this.freelist.push(W)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===p1&&this.nextId++,this.nextId>Q3)throw new U3(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${Q3-Y3}`);return this.nextId++}},K3,A7,j7,S7,b7=class{constructor(W){this.freeHostRef=W.freeHostRef,this.callFunction=W.callFunction,this.shouldInterrupt=W.shouldInterrupt,this.loadModuleSource=W.loadModuleSource,this.normalizeModule=W.normalizeModule}},J4=class{constructor(W){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new b7({freeHostRef:(X,Y,Q)=>{let K=this.runtimeCallbacks.get(Y);if(!K)throw Error(`QuickJSRuntime(rt = ${Y}) not found when trying to free HostRef(id = ${Q})`);K.freeHostRef(Y,Q)},callFunction:(X,Y,Q,K,q,J)=>this.handleAsyncify(X,()=>{try{let G=this.contextCallbacks.get(Y);if(!G)throw Error(`QuickJSContext(ctx = ${Y}) not found for C function call "${J}"`);return G.callFunction(Y,Q,K,q,J)}catch(G){return console.error("[C to host error: returning null]",G),0}}),shouldInterrupt:(X,Y)=>this.handleAsyncify(X,()=>{try{let Q=this.runtimeCallbacks.get(Y);if(!Q)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C interrupt`);return Q.shouldInterrupt(Y)}catch(Q){return console.error("[C to host interrupt: returning error]",Q),1}}),loadModuleSource:(X,Y,Q,K)=>this.handleAsyncify(X,()=>{try{let q=this.runtimeCallbacks.get(Y);if(!q)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C module loader`);let J=q.loadModuleSource;if(!J)throw Error(`QuickJSRuntime(rt = ${Y}) does not support module loading`);return J(Y,Q,K)}catch(q){return console.error("[C to host module loader error: returning null]",q),0}}),normalizeModule:(X,Y,Q,K,q)=>this.handleAsyncify(X,()=>{try{let J=this.runtimeCallbacks.get(Y);if(!J)throw Error(`QuickJSRuntime(rt = ${Y}) not found for C module loader`);let G=J.normalizeModule;if(!G)throw Error(`QuickJSRuntime(rt = ${Y}) does not support module loading`);return G(Y,Q,K,q)}catch(J){return console.error("[C to host module loader error: returning null]",J),0}})}),this.module=W,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(W,X){this.runtimeCallbacks.set(W,X)}deleteRuntime(W){this.runtimeCallbacks.delete(W)}setContextCallbacks(W,X){this.contextCallbacks.set(W,X)}deleteContext(W){this.contextCallbacks.delete(W)}handleAsyncify(W,X){if(W)return W.handleSleep((Q)=>{try{let K=X();if(!(K instanceof Promise)){H1("asyncify.handleSleep: not suspending:",K),Q(K);return}if(this.suspended)throw new J3(`Already suspended at: ${this.suspended.stack}
4
+ Attempted to suspend at:`);this.suspended=new z3(`(${this.suspendedCount++})`),H1("asyncify.handleSleep: suspending:",this.suspended),K.then((q)=>{this.suspended=void 0,H1("asyncify.handleSleep: resolved:",q),Q(q)},(q)=>{H1("asyncify.handleSleep: rejected:",q),console.error("QuickJS: cannot handle error in suspended function",q),this.suspended=void 0})}catch(K){throw H1("asyncify.handleSleep: error:",K),this.suspended=void 0,K}});let Y=X();if(Y instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return Y}},w3=class{constructor(W,X){this.module=W,this.ffi=X,this.callbacks=new J4(W)}newRuntime(W={}){let X=new X0(this.ffi.QTS_NewRuntime(),void 0,(Q)=>{this.ffi.QTS_FreeRuntime(Q),this.callbacks.deleteRuntime(Q)}),Y=new S7({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:X});return z4(Y,W),W.moduleLoader&&Y.setModuleLoader(W.moduleLoader),Y}newContext(W={}){let X=this.newRuntime(),Y=X.newContext({...W,ownedLifetimes:I7(X,W.ownedLifetimes)});return X.context=Y,Y}evalCode(W,X={}){return D0.withScope((Y)=>{let Q=Y.manage(this.newContext());B4(Q.runtime,X);let K=Q.evalCode(W,"eval.js");if(X.memoryLimitBytes!==void 0&&Q.runtime.setMemoryLimit(-1),K.error)throw Q.dump(Y.manage(K.error));return Q.dump(Y.manage(K.value))})}getWasmMemory(){let W=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!W)throw Error("Variant does not support getting WebAssembly.Memory");return W}getFFI(){return this.ffi}};var M3=s1(()=>{u1();u1();H7=Object.defineProperty;L7={};U7(L7,{QuickJSAsyncifyError:()=>J3,QuickJSAsyncifySuspended:()=>z3,QuickJSEmptyGetOwnPropertyNames:()=>H3,QuickJSEmscriptenModuleError:()=>w7,QuickJSHostRefInvalid:()=>C0,QuickJSHostRefRangeExceeded:()=>U3,QuickJSMemoryLeakDetected:()=>D7,QuickJSNotImplemented:()=>q3,QuickJSPromisePending:()=>$3,QuickJSUnknownIntrinsic:()=>B3,QuickJSUnwrapError:()=>W4,QuickJSUseAfterFree:()=>X4,QuickJSWrongOwner:()=>G3});W4=class extends Error{constructor(W,X){let Y=typeof W=="object"&&W&&"message"in W?String(W.message):String(W);super(Y);this.cause=W,this.context=X,this.name="QuickJSUnwrapError"}},G3=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},X4=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},q3=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},J3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},z3=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},D7=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},w7=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},B3=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},$3=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},H3=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},U3=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},C0=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};K4=L3;K4.of=M7;V0=class{[Symbol.dispose](){return this.dispose()}},Y4=Symbol.dispose??Symbol.for("Symbol.dispose"),W3=V0.prototype;W3[Y4]||(W3[Y4]=function(){return this.dispose()});X0=class W extends V0{constructor(X,Y,Q,K){super();this._value=X,this.copier=Y,this.disposer=Q,this._owner=K,this._alive=!0,this._constructorStack=Q4?Error("Lifetime constructed").stack:void 0}get alive(){return this._alive}get value(){return this.assertAlive(),this._value}get owner(){return this._owner}get dupable(){return!!this.copier}dup(){if(this.assertAlive(),!this.copier)throw Error("Non-dupable lifetime");return new W(this.copier(this._value),this.copier,this.disposer,this._owner)}consume(X){this.assertAlive();let Y=X(this);return this.dispose(),Y}map(X){return this.assertAlive(),X(this)}tap(X){return X(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new X4(`Lifetime not alive
5
5
  ${this._constructorStack}
6
- Lifetime used`):new s9("Lifetime not alive")}},T0=class extends X0{constructor(W,X){super(W,void 0,void 0,X)}get dupable(){return!0}dup(){return this}dispose(){}},iW=class extends X0{constructor(W,X,K,Y){super(W,X,K,Y)}dispose(){this._alive=!1}};D0=class W extends V0{constructor(){super(...arguments);this._disposables=new X0(new Set),this.manage=(X)=>(this._disposables.value.add(X),X)}static withScope(X){let K=new W,Y;try{return X(K)}catch(Q){throw Y=Q,Q}finally{n9(K,Y)}}static withScopeMaybeAsync(X,K){return BQ(void 0,function*(Y){let Q=new W,q;try{return yield*Y.of(K.call(X,Y,Q))}catch(J){throw q=J,J}finally{n9(Q,q)}})}static async withScopeAsync(X){let K=new W,Y;try{return await X(K)}catch(Q){throw Y=Q,Q}finally{n9(K,Y)}}get alive(){return this._disposables.alive}dispose(){let X=Array.from(this._disposables.value.values()).reverse();for(let K of X)K.alive&&K.dispose();this._disposables.dispose()}};Y6=class W extends V0{static success(X){return new HQ(X)}static fail(X,K){return new UQ(X,K)}static is(X){return X instanceof W}},HQ=class extends Y6{constructor(W){super();this.value=W}get alive(){return m1(this.value)?this.value.alive:!0}dispose(){m1(this.value)&&this.value.dispose()}unwrap(){return this.value}unwrapOr(W){return this.value}},UQ=class extends Y6{constructor(W,X){super();this.error=W,this.onUnwrap=X}get alive(){return m1(this.error)?this.error.alive:!0}dispose(){m1(this.error)&&this.error.dispose()}unwrap(){throw this.onUnwrap(this),this.error}unwrapOr(W){return W}},f0=Y6,LQ=class extends V0{constructor(W){super();this.resolve=(X)=>{this.resolveHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.resolveHandle,this.context.undefined,X||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.reject=(X)=>{this.rejectHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.rejectHandle,this.context.undefined,X||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.dispose=()=>{this.handle.alive&&this.handle.dispose(),this.disposeResolvers()},this.context=W.context,this.owner=W.context.runtime,this.handle=W.promiseHandle,this.settled=new Promise((X)=>{this.onSettled=X}),this.resolveHandle=W.resolveHandle,this.rejectHandle=W.rejectHandle}get alive(){return this.handle.alive||this.resolveHandle.alive||this.rejectHandle.alive}disposeResolvers(){this.resolveHandle.alive&&this.resolveHandle.dispose(),this.rejectHandle.alive&&this.rejectHandle.dispose()}},DG=Symbol("Unstable"),MG=Object.freeze({BaseObjects:!0,Date:!0,Eval:!0,StringNormalize:!0,RegExp:!0,JSON:!0,Proxy:!0,MapSet:!0,TypedArrays:!0,Promise:!0});FQ=class extends V0{constructor(W,X){super();this.handle=W,this.context=X,this._isDone=!1,this.owner=X.runtime}[Symbol.iterator](){return this}next(W){if(!this.alive||this._isDone)return{done:!0,value:void 0};let X=this._next??(this._next=this.context.getProp(this.handle,"next"));return this.callIteratorMethod(X,W)}return(W){if(!this.alive)return{done:!0,value:void 0};let X=this.context.getProp(this.handle,"return");if(X===this.context.undefined&&W===void 0)return this.dispose(),{done:!0,value:void 0};let K=this.callIteratorMethod(X,W);return X.dispose(),this.dispose(),K}throw(W){if(!this.alive)return{done:!0,value:void 0};let X=W instanceof X0?W:this.context.newError(W),K=this.context.getProp(this.handle,"throw"),Y=this.callIteratorMethod(K,W);return X.alive&&X.dispose(),K.dispose(),this.dispose(),Y}get alive(){return this.handle.alive}dispose(){this._isDone=!0,this.handle.dispose(),this._next?.dispose()}callIteratorMethod(W,X){let K=X?this.context.callFunction(W,this.handle,X):this.context.callFunction(W,this.handle);if(K.error)return this.dispose(),{value:K};let Y=this.context.getProp(K.value,"done").consume((q)=>this.context.dump(q)),Q=this.context.getProp(K.value,"value");return K.value.dispose(),Y&&this.dispose(),{value:f0.success(Q),done:Y}}};aW=class extends V0{constructor(W,X,K){if(K===c1)throw new C0("cannot create HostRef with undefined id");super();this.runtime=W,this.handle=X,this.id=K}get alive(){return this.handle.alive}dispose(){this.handle.dispose()}get value(){return this.runtime.hostRefs.get(this.id)}},VQ=class extends J3{constructor(W){super(W.module);this.scope=new D0,this.copyJSValue=(X)=>this.ffi.QTS_DupValuePointer(this.ctx.value,X),this.freeJSValue=(X)=>{this.ffi.QTS_FreeValuePointer(this.ctx.value,X)},W.ownedLifetimes?.forEach((X)=>this.scope.manage(X)),this.owner=W.owner,this.module=W.module,this.ffi=W.ffi,this.rt=W.rt,this.ctx=this.scope.manage(W.ctx)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}[Symbol.dispose](){return this.dispose()}manage(W){return this.scope.manage(W)}consumeJSCharPointer(W){let X=this.module.UTF8ToString(W);return this.ffi.QTS_FreeCString(this.ctx.value,W),X}heapValueHandle(W,X){let K=X?(Y)=>{X(),this.freeJSValue(Y)}:this.freeJSValue;return new X0(W,this.copyJSValue,K,this.owner)}staticHeapValueHandle(W){return this.manage(this.heapValueHandle(W)),new T0(W,this.owner)}},PQ=class extends V0{constructor(W){super();this._undefined=void 0,this._null=void 0,this._false=void 0,this._true=void 0,this._global=void 0,this._BigInt=void 0,this._Symbol=void 0,this._SymbolIterator=void 0,this._SymbolAsyncIterator=void 0,this.cToHostCallbacks={callFunction:(X,K,Y,Q,q)=>{if(X!==this.ctx.value)throw Error("QuickJSContext instance received C -> JS call with mismatched ctx");let J=this.getFunction(q);return D0.withScopeMaybeAsync(this,function*(G,H){let D=H.manage(new iW(K,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime)),F=Array(Y);for(let N=0;N<Y;N++){let E=this.ffi.QTS_ArgvGetJSValueConstPointer(Q,N);F[N]=H.manage(new iW(E,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime))}try{let N=yield*G(J.apply(D,F));if(N){if("error"in N&&N.error)throw this.runtime.debugLog("throw error",N.error),N.error;let E=H.manage(N instanceof X0?N:N.value);return this.ffi.QTS_DupValuePointer(this.ctx.value,E.value)}return 0}catch(N){return this.errorToHandle(N).consume((E)=>this.ffi.QTS_Throw(this.ctx.value,E.value))}})}},this.runtime=W.runtime,this.module=W.module,this.ffi=W.ffi,this.rt=W.rt,this.ctx=W.ctx,this.memory=new VQ({...W,owner:this.runtime}),W.callbacks.setContextCallbacks(this.ctx.value,this.cToHostCallbacks),this.dump=this.dump.bind(this),this.getString=this.getString.bind(this),this.getNumber=this.getNumber.bind(this),this.resolvePromise=this.resolvePromise.bind(this),this.uint32Out=this.memory.manage(this.memory.newTypedArray(Uint32Array,1))}get alive(){return this.memory.alive}dispose(){this.memory.dispose()}get undefined(){if(this._undefined)return this._undefined;let W=this.ffi.QTS_GetUndefined();return this._undefined=new T0(W)}get null(){if(this._null)return this._null;let W=this.ffi.QTS_GetNull();return this._null=new T0(W)}get true(){if(this._true)return this._true;let W=this.ffi.QTS_GetTrue();return this._true=new T0(W)}get false(){if(this._false)return this._false;let W=this.ffi.QTS_GetFalse();return this._false=new T0(W)}get global(){if(this._global)return this._global;let W=this.ffi.QTS_GetGlobalObject(this.ctx.value);return this._global=this.memory.staticHeapValueHandle(W),this._global}newNumber(W){return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value,W))}newString(W){let X=this.memory.newHeapCharPointer(W).consume((K)=>this.ffi.QTS_NewString(this.ctx.value,K.value.ptr));return this.memory.heapValueHandle(X)}newUniqueSymbol(W){let X=(typeof W=="symbol"?W.description:W)??"",K=this.memory.newHeapCharPointer(X).consume((Y)=>this.ffi.QTS_NewSymbol(this.ctx.value,Y.value.ptr,0));return this.memory.heapValueHandle(K)}newSymbolFor(W){let X=(typeof W=="symbol"?W.description:W)??"",K=this.memory.newHeapCharPointer(X).consume((Y)=>this.ffi.QTS_NewSymbol(this.ctx.value,Y.value.ptr,1));return this.memory.heapValueHandle(K)}getWellKnownSymbol(W){return this._Symbol??(this._Symbol=this.memory.manage(this.getProp(this.global,"Symbol"))),this.getProp(this._Symbol,W)}newBigInt(W){if(!this._BigInt){let Y=this.getProp(this.global,"BigInt");this.memory.manage(Y),this._BigInt=new T0(Y.value,this.runtime)}let X=this._BigInt,K=String(W);return this.newString(K).consume((Y)=>this.unwrapResult(this.callFunction(X,this.undefined,Y)))}newObject(W){W&&this.runtime.assertOwned(W);let X=W?this.ffi.QTS_NewObjectProto(this.ctx.value,W.value):this.ffi.QTS_NewObject(this.ctx.value);return this.memory.heapValueHandle(X)}newArray(){let W=this.ffi.QTS_NewArray(this.ctx.value);return this.memory.heapValueHandle(W)}newArrayBuffer(W){let X=new Uint8Array(W),K=this.memory.newHeapBufferPointer(X),Y=this.ffi.QTS_NewArrayBuffer(this.ctx.value,K.value.pointer,X.length);return this.memory.heapValueHandle(Y)}newPromise(W){let X=D0.withScope((K)=>{let Y=K.manage(this.memory.newMutablePointerArray(2)),Q=this.ffi.QTS_NewPromiseCapability(this.ctx.value,Y.value.ptr),q=this.memory.heapValueHandle(Q),[J,G]=Array.from(Y.value.typedArray).map((H)=>this.memory.heapValueHandle(H));return new LQ({context:this,promiseHandle:q,resolveHandle:J,rejectHandle:G})});return W&&typeof W=="function"&&(W=new Promise(W)),W&&Promise.resolve(W).then(X.resolve,(K)=>K instanceof X0?X.reject(K):this.newError(K).consume(X.reject)),X}newFunction(W,X){let K=typeof W=="function"?W:X;if(!K)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof W=="string"?W:void 0,length:K.length,isConstructor:!1,fn:K})}newConstructorFunction(W,X){let K=typeof W=="function"?W:X;if(!K)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof W=="string"?W:void 0,length:K.length,isConstructor:!0,fn:K})}newFunctionWithOptions(W){let{name:X,length:K,isConstructor:Y,fn:Q}=W,q=this.runtime.hostRefs.put(Q);try{return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value,X??"",K,Y,q))}catch(J){throw this.runtime.hostRefs.delete(q),J}}newError(W){let X=this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value));return W&&typeof W=="object"?(W.name!==void 0&&this.newString(W.name).consume((K)=>this.setProp(X,"name",K)),W.message!==void 0&&this.newString(W.message).consume((K)=>this.setProp(X,"message",K))):typeof W=="string"?this.newString(W).consume((K)=>this.setProp(X,"message",K)):W!==void 0&&this.newString(String(W)).consume((K)=>this.setProp(X,"message",K)),X}newHostRef(W){let X=this.runtime.hostRefs.put(W);try{let K=this.memory.heapValueHandle(this.ffi.QTS_NewHostRef(this.ctx.value,X));return new aW(this.runtime,K,X)}catch(K){throw this.runtime.hostRefs.delete(X),K}}toHostRef(W){let X=this.ffi.QTS_GetHostRefId(W.value);if(X!==0)return this.runtime.hostRefs.get(X),new aW(this.runtime,W.dup(),X)}unwrapHostRef(W){let X=this.ffi.QTS_GetHostRefId(W.value);if(X===0)throw new C0("handle is not a HostRef");return this.runtime.hostRefs.get(X)}typeof(W){return this.runtime.assertOwned(W),this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value,W.value))}getNumber(W){return this.runtime.assertOwned(W),this.ffi.QTS_GetFloat64(this.ctx.value,W.value)}getString(W){return this.runtime.assertOwned(W),this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value,W.value))}getSymbol(W){this.runtime.assertOwned(W);let X=this.memory.consumeJSCharPointer(this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value,W.value));return this.ffi.QTS_IsGlobalSymbol(this.ctx.value,W.value)?Symbol.for(X):Symbol(X)}getBigInt(W){this.runtime.assertOwned(W);let X=this.getString(W);return BigInt(X)}getArrayBuffer(W){this.runtime.assertOwned(W);let X=this.ffi.QTS_GetArrayBufferLength(this.ctx.value,W.value),K=this.ffi.QTS_GetArrayBuffer(this.ctx.value,W.value);if(!K)throw Error("Couldn't allocate memory to get ArrayBuffer");return new X0(this.module.HEAPU8.subarray(K,K+X),void 0,()=>this.module._free(K))}getPromiseState(W){this.runtime.assertOwned(W);let X=this.ffi.QTS_PromiseState(this.ctx.value,W.value);if(X<0)return{type:"fulfilled",value:W,notAPromise:!0};if(X===y1.Pending)return{type:"pending",get error(){return new Y3("Cannot unwrap a pending promise")}};let K=this.ffi.QTS_PromiseResult(this.ctx.value,W.value),Y=this.memory.heapValueHandle(K);if(X===y1.Fulfilled)return{type:"fulfilled",value:Y};if(X===y1.Rejected)return{type:"rejected",error:Y};throw Y.dispose(),Error(`Unknown JSPromiseStateEnum: ${X}`)}resolvePromise(W){this.runtime.assertOwned(W);let X=D0.withScope((K)=>{let Y=K.manage(this.getProp(this.global,"Promise")),Q=K.manage(this.getProp(Y,"resolve"));return this.callFunction(Q,Y,W)});return X.error?Promise.resolve(X):new Promise((K)=>{D0.withScope((Y)=>{let Q=Y.manage(this.newFunction("resolve",(H)=>{K(this.success(H&&H.dup()))})),q=Y.manage(this.newFunction("reject",(H)=>{K(this.fail(H&&H.dup()))})),J=Y.manage(X.value),G=Y.manage(this.getProp(J,"then"));this.callFunction(G,J,Q,q).unwrap().dispose()})})}isEqual(W,X,K=G1.IsStrictlyEqual){if(W===X)return!0;this.runtime.assertOwned(W),this.runtime.assertOwned(X);let Y=this.ffi.QTS_IsEqual(this.ctx.value,W.value,X.value,K);if(Y===-1)throw new eW("WASM variant does not expose equality");return!!Y}eq(W,X){return this.isEqual(W,X,G1.IsStrictlyEqual)}sameValue(W,X){return this.isEqual(W,X,G1.IsSameValue)}sameValueZero(W,X){return this.isEqual(W,X,G1.IsSameValueZero)}getProp(W,X){this.runtime.assertOwned(W);let K;return typeof X=="number"&&X>=0?K=this.ffi.QTS_GetPropNumber(this.ctx.value,W.value,X):K=this.borrowPropertyKey(X).consume((Y)=>this.ffi.QTS_GetProp(this.ctx.value,W.value,Y.value)),this.memory.heapValueHandle(K)}getLength(W){if(this.runtime.assertOwned(W),!(this.ffi.QTS_GetLength(this.ctx.value,this.uint32Out.value.ptr,W.value)<0))return this.uint32Out.value.typedArray[0]}getOwnPropertyNames(W,X={strings:!0,numbersAsStrings:!0}){this.runtime.assertOwned(W),W.value;let K=MQ(X);if(K===0)throw new Q3("No options set, will return an empty array");return D0.withScope((Y)=>{let Q=Y.manage(this.memory.newMutablePointerArray(1)),q=this.ffi.QTS_GetOwnPropertyNames(this.ctx.value,Q.value.ptr,this.uint32Out.value.ptr,W.value,K);if(q)return this.fail(this.memory.heapValueHandle(q));let J=this.uint32Out.value.typedArray[0],G=Q.value.typedArray[0],H=new Uint32Array(this.module.HEAP8.buffer,G,J),D=Array.from(H).map((F)=>this.memory.heapValueHandle(F));return this.ffi.QTS_FreeVoidPointer(this.ctx.value,G),this.success($Q(D))})}getIterator(W){let X=this._SymbolIterator??(this._SymbolIterator=this.memory.manage(this.getWellKnownSymbol("iterator")));return D0.withScope((K)=>{let Y=K.manage(this.getProp(W,X)),Q=this.callFunction(Y,W);return Q.error?Q:this.success(new FQ(Q.value,this))})}setProp(W,X,K){this.runtime.assertOwned(W),this.borrowPropertyKey(X).consume((Y)=>this.ffi.QTS_SetProp(this.ctx.value,W.value,Y.value,K.value))}defineProp(W,X,K){this.runtime.assertOwned(W),D0.withScope((Y)=>{let Q=Y.manage(this.borrowPropertyKey(X)),q=K.value||this.undefined,J=!!K.configurable,G=!!K.enumerable,H=!!K.value,D=K.get?Y.manage(this.newFunction(K.get.name,K.get)):this.undefined,F=K.set?Y.manage(this.newFunction(K.set.name,K.set)):this.undefined;this.ffi.QTS_DefineProp(this.ctx.value,W.value,Q.value,q.value,D.value,F.value,J,G,H)})}callFunction(W,X,...K){this.runtime.assertOwned(W);let Y,Q=K[0];Q===void 0||Array.isArray(Q)?Y=Q??[]:Y=K;let q=this.memory.toPointerArray(Y).consume((G)=>this.ffi.QTS_Call(this.ctx.value,W.value,X.value,Y.length,G.value)),J=this.ffi.QTS_ResolveException(this.ctx.value,q);return J?(this.ffi.QTS_FreeValuePointer(this.ctx.value,q),this.fail(this.memory.heapValueHandle(J))):this.success(this.memory.heapValueHandle(q))}callMethod(W,X,K=[]){return this.getProp(W,X).consume((Y)=>this.callFunction(Y,W,K))}evalCode(W,X="eval.js",K){let Y=K===void 0?1:0,Q=DQ(K),q=this.memory.newHeapCharPointer(W).consume((G)=>this.ffi.QTS_Eval(this.ctx.value,G.value.ptr,G.value.strlen,X,Y,Q)),J=this.ffi.QTS_ResolveException(this.ctx.value,q);return J?(this.ffi.QTS_FreeValuePointer(this.ctx.value,q),this.fail(this.memory.heapValueHandle(J))):this.success(this.memory.heapValueHandle(q))}throw(W){return this.errorToHandle(W).consume((X)=>this.ffi.QTS_Throw(this.ctx.value,X.value))}borrowPropertyKey(W){return typeof W=="number"?this.newNumber(W):typeof W=="string"?this.newString(W):new T0(W.value,this.runtime)}getMemory(W){if(W===this.rt.value)return this.memory;throw Error("Private API. Cannot get memory from a different runtime")}dump(W){this.runtime.assertOwned(W);let X=this.typeof(W);if(X==="string")return this.getString(W);if(X==="number")return this.getNumber(W);if(X==="bigint")return this.getBigInt(W);if(X==="undefined")return;if(X==="symbol")return this.getSymbol(W);let K=this.getPromiseState(W);if(K.type==="fulfilled"&&!K.notAPromise)return W.dispose(),{type:K.type,value:K.value.consume(this.dump)};if(K.type==="pending")return W.dispose(),{type:K.type};if(K.type==="rejected")return W.dispose(),{type:K.type,error:K.error.consume(this.dump)};let Y=this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value,W.value));try{return JSON.parse(Y)}catch{return Y}}unwrapResult(W){if(W.error){let X="context"in W.error?W.error.context:this,K=W.error.consume((Y)=>this.dump(Y));if(K&&typeof K=="object"&&typeof K.message=="string"){let{message:Y,name:Q,stack:q,...J}=K,G=new a9(K,X);typeof Q=="string"&&(G.name=K.name),G.message=Y;let H=G.stack;throw typeof q=="string"&&(G.stack=`${Q}: ${Y}
7
- ${K.stack}Host: ${H}`),Object.assign(G,J),G}throw new a9(K)}return W.value}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { ctx: ${this.ctx.value} rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getFunction(W){let X=this.runtime.hostRefs.get(W);if(typeof X!="function")throw Error(`Host reference ${W} is not a function`);return X}errorToHandle(W){return W instanceof X0?W:this.newError(W)}encodeBinaryJSON(W){let X=this.ffi.QTS_bjson_encode(this.ctx.value,W.value);return this.memory.heapValueHandle(X)}decodeBinaryJSON(W){let X=this.ffi.QTS_bjson_decode(this.ctx.value,W.value);return this.memory.heapValueHandle(X)}success(W){return f0.success(W)}fail(W){return f0.fail(W,(X)=>this.unwrapResult(X))}},RQ=class extends V0{constructor(W){super();this.scope=new D0,this.contextMap=new Map,this.hostRefs=new NQ,this._debugMode=!1,this.cToHostCallbacks={freeHostRef:(X,K)=>{if(X!==this.rt.value)throw Error("Runtime pointer mismatch");this.hostRefs.delete(K)},shouldInterrupt:(X)=>{if(X!==this.rt.value)throw Error("QuickJSContext instance received C -> JS interrupt with mismatched rt");let K=this.interruptHandler;if(!K)throw Error("QuickJSContext had no interrupt handler");return K(this)?1:0},loadModuleSource:oW(this,function*(X,K,Y,Q){let q=this.moduleLoader;if(!q)throw Error("Runtime has no module loader");if(K!==this.rt.value)throw Error("Runtime pointer mismatch");let J=this.contextMap.get(Y)??this.newContext({contextPointer:Y});try{let G=yield*X(q(Q,J));if(typeof G=="object"&&"error"in G&&G.error)throw this.debugLog("cToHostLoadModule: loader returned error",G.error),G.error;let H=typeof G=="string"?G:("value"in G)?G.value:G;return this.memory.newHeapCharPointer(H).value.ptr}catch(G){return this.debugLog("cToHostLoadModule: caught error",G),J.throw(G),0}}),normalizeModule:oW(this,function*(X,K,Y,Q,q){let J=this.moduleNormalizer;if(!J)throw Error("Runtime has no module normalizer");if(K!==this.rt.value)throw Error("Runtime pointer mismatch");let G=this.contextMap.get(Y)??this.newContext({contextPointer:Y});try{let H=yield*X(J(Q,q,G));if(typeof H=="object"&&"error"in H&&H.error)throw this.debugLog("cToHostNormalizeModule: normalizer returned error",H.error),H.error;let D=typeof H=="string"?H:H.value;return G.getMemory(this.rt.value).newHeapCharPointer(D).value.ptr}catch(H){return this.debugLog("normalizeModule: caught error",H),G.throw(H),0}})},W.ownedLifetimes?.forEach((X)=>this.scope.manage(X)),this.module=W.module,this.memory=new J3(this.module),this.ffi=W.ffi,this.rt=W.rt,this.callbacks=W.callbacks,this.scope.manage(this.rt),this.callbacks.setRuntimeCallbacks(this.rt.value,this.cToHostCallbacks),this.executePendingJobs=this.executePendingJobs.bind(this),W6&&this.setDebugMode(!0)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}newContext(W={}){let X=wQ(W.intrinsics),K=new X0(W.contextPointer||this.ffi.QTS_NewContext(this.rt.value,X),void 0,(Q)=>{this.contextMap.delete(Q),this.callbacks.deleteContext(Q),this.ffi.QTS_FreeContext(Q)}),Y=new PQ({module:this.module,ctx:K,ffi:this.ffi,rt:this.rt,ownedLifetimes:W.ownedLifetimes,runtime:this,callbacks:this.callbacks});return this.contextMap.set(K.value,Y),Y}setModuleLoader(W,X){this.moduleLoader=W,this.moduleNormalizer=X,this.ffi.QTS_RuntimeEnableModuleLoader(this.rt.value,this.moduleNormalizer?1:0)}removeModuleLoader(){this.moduleLoader=void 0,this.ffi.QTS_RuntimeDisableModuleLoader(this.rt.value)}hasPendingJob(){return!!this.ffi.QTS_IsJobPending(this.rt.value)}setInterruptHandler(W){let X=this.interruptHandler;this.interruptHandler=W,X||this.ffi.QTS_RuntimeEnableInterruptHandler(this.rt.value)}removeInterruptHandler(){this.interruptHandler&&(this.ffi.QTS_RuntimeDisableInterruptHandler(this.rt.value),this.interruptHandler=void 0)}executePendingJobs(W=-1){let X=this.memory.newMutablePointerArray(1),K=this.ffi.QTS_ExecutePendingJob(this.rt.value,W??-1,X.value.ptr),Y=X.value.typedArray[0];if(X.dispose(),Y===0)return this.ffi.QTS_FreeValuePointerRuntime(this.rt.value,K),f0.success(0);let Q=this.contextMap.get(Y)??this.newContext({contextPointer:Y}),q=Q.getMemory(this.rt.value).heapValueHandle(K);if(Q.typeof(q)==="number"){let J=Q.getNumber(q);return q.dispose(),f0.success(J)}else{let J=Object.assign(q,{context:Q});return f0.fail(J,(G)=>Q.unwrapResult(G))}}setMemoryLimit(W){if(W<0&&W!==-1)throw Error("Cannot set memory limit to negative number. To unset, pass -1");this.ffi.QTS_RuntimeSetMemoryLimit(this.rt.value,W)}computeMemoryUsage(){let W=this.getSystemContext().getMemory(this.rt.value);return W.heapValueHandle(this.ffi.QTS_RuntimeComputeMemoryUsage(this.rt.value,W.ctx.value))}dumpMemoryUsage(){return this.memory.consumeHeapCharPointer(this.ffi.QTS_RuntimeDumpMemoryUsage(this.rt.value))}setMaxStackSize(W){if(W<0)throw Error("Cannot set memory limit to negative number. To unset, pass 0.");this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value,W)}assertOwned(W){if(W.owner&&W.owner.rt!==this.rt)throw new sW(`Handle is not owned by this runtime: ${W.owner.rt.value} != ${this.rt.value}`)}setDebugMode(W){this._debugMode=W,this.ffi.DEBUG&&this.rt.alive&&this.ffi.QTS_SetDebugLogEnabled(this.rt.value,W?1:0)}isDebugMode(){return this._debugMode}debugLog(...W){this._debugMode&&console.log("quickjs-emscripten:",...W)}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getSystemContext(){return this.context||(this.context=this.scope.manage(this.newContext())),this.context}}});var $3={};n1($3,{applyModuleEvalRuntimeOptions:()=>q6,applyBaseRuntimeOptions:()=>G6,QuickJSWASMModule:()=>z3,QuickJSModuleCallbacks:()=>Q6});var H3=t1(()=>{B3()});var O3=A3((u1,M3)=>{(function(W,X){typeof u1==="object"&&typeof M3<"u"?X(u1):typeof define==="function"&&define.amd?define(["exports"],X):(W=typeof globalThis<"u"?globalThis:W||self,X(W.jmespath={}))})(u1,function(W){let X=(z)=>{return z!==null&&Object.prototype.toString.call(z)==="[object Object]"},K=(z,B)=>{if(z===B)return!0;if(typeof z!==typeof B)return!1;if(Array.isArray(z)&&Array.isArray(B)){if(z.length!==B.length)return!1;for(let $=0;$<z.length;$+=1)if(!K(z[$],B[$]))return!1;return!0}if(X(z)&&X(B)){let $=Object.entries(z),U=new Set(Object.keys(B));if($.length!==U.size)return!1;for(let[O,V]of $){if(!K(V,B[O]))return!1;U.delete(O)}return U.size===0}return!1},Y=(z)=>{if(z===""||z===!1||z===null||z===void 0)return!0;if(Array.isArray(z)&&z.length===0)return!0;if(X(z)){for(let B in z)if(z.hasOwnProperty(B))return!1;return!0}return!1},Q=(z)=>{return z>="a"&&z<="z"||z>="A"&&z<="Z"||z==="_"},q=(z)=>{return z>="0"&&z<="9"||z==="-"},J=(z)=>{return z>="a"&&z<="z"||z>="A"&&z<="Z"||z>="0"&&z<="9"||z==="_"};var G;(function(z){z.TOK_EOF="EOF",z.TOK_UNQUOTEDIDENTIFIER="UnquotedIdentifier",z.TOK_QUOTEDIDENTIFIER="QuotedIdentifier",z.TOK_RBRACKET="Rbracket",z.TOK_RPAREN="Rparen",z.TOK_COMMA="Comma",z.TOK_COLON="Colon",z.TOK_RBRACE="Rbrace",z.TOK_NUMBER="Number",z.TOK_CURRENT="Current",z.TOK_ROOT="Root",z.TOK_EXPREF="Expref",z.TOK_PIPE="Pipe",z.TOK_OR="Or",z.TOK_AND="And",z.TOK_EQ="EQ",z.TOK_GT="GT",z.TOK_LT="LT",z.TOK_GTE="GTE",z.TOK_LTE="LTE",z.TOK_NE="NE",z.TOK_FLATTEN="Flatten",z.TOK_STAR="Star",z.TOK_FILTER="Filter",z.TOK_DOT="Dot",z.TOK_NOT="Not",z.TOK_LBRACE="Lbrace",z.TOK_LBRACKET="Lbracket",z.TOK_LPAREN="Lparen",z.TOK_LITERAL="Literal"})(G||(G={}));let H={"(":G.TOK_LPAREN,")":G.TOK_RPAREN,"*":G.TOK_STAR,",":G.TOK_COMMA,".":G.TOK_DOT,":":G.TOK_COLON,"@":G.TOK_CURRENT,["$"]:G.TOK_ROOT,"]":G.TOK_RBRACKET,"{":G.TOK_LBRACE,"}":G.TOK_RBRACE},D={"!":!0,"<":!0,"=":!0,">":!0},F={"\t":!0,"\n":!0,"\r":!0," ":!0};class N{constructor(){this._current=0}tokenize(z){let B=[];this._current=0;let $,U,O;while(this._current<z.length)if(Q(z[this._current]))$=this._current,U=this.consumeUnquotedIdentifier(z),B.push({start:$,type:G.TOK_UNQUOTEDIDENTIFIER,value:U});else if(H[z[this._current]]!==void 0)B.push({start:this._current,type:H[z[this._current]],value:z[this._current]}),this._current+=1;else if(q(z[this._current]))O=this.consumeNumber(z),B.push(O);else if(z[this._current]==="[")O=this.consumeLBracket(z),B.push(O);else if(z[this._current]==='"')$=this._current,U=this.consumeQuotedIdentifier(z),B.push({start:$,type:G.TOK_QUOTEDIDENTIFIER,value:U});else if(z[this._current]==="'")$=this._current,U=this.consumeRawStringLiteral(z),B.push({start:$,type:G.TOK_LITERAL,value:U});else if(z[this._current]==="`"){$=this._current;let V=this.consumeLiteral(z);B.push({start:$,type:G.TOK_LITERAL,value:V})}else if(D[z[this._current]]!==void 0)O=this.consumeOperator(z),O&&B.push(O);else if(F[z[this._current]]!==void 0)this._current+=1;else if(z[this._current]==="&")if($=this._current,this._current+=1,z[this._current]==="&")this._current+=1,B.push({start:$,type:G.TOK_AND,value:"&&"});else B.push({start:$,type:G.TOK_EXPREF,value:"&"});else if(z[this._current]==="|")if($=this._current,this._current+=1,z[this._current]==="|")this._current+=1,B.push({start:$,type:G.TOK_OR,value:"||"});else B.push({start:$,type:G.TOK_PIPE,value:"|"});else{let V=Error(`Unknown character: ${z[this._current]}`);throw V.name="LexerError",V}return B}consumeUnquotedIdentifier(z){let B=this._current;this._current+=1;while(this._current<z.length&&J(z[this._current]))this._current+=1;return z.slice(B,this._current)}consumeQuotedIdentifier(z){let B=this._current;this._current+=1;let $=z.length;while(z[this._current]!=='"'&&this._current<$){let U=this._current;if(z[U]==="\\"&&(z[U+1]==="\\"||z[U+1]==='"'))U+=2;else U+=1;this._current=U}return this._current+=1,JSON.parse(z.slice(B,this._current))}consumeRawStringLiteral(z){let B=this._current;this._current+=1;let $=z.length;while(z[this._current]!=="'"&&this._current<$){let O=this._current;if(z[O]==="\\"&&(z[O+1]==="\\"||z[O+1]==="'"))O+=2;else O+=1;this._current=O}return this._current+=1,z.slice(B+1,this._current-1).replace("\\'","'")}consumeNumber(z){let B=this._current;this._current+=1;let $=z.length;while(q(z[this._current])&&this._current<$)this._current+=1;let U=parseInt(z.slice(B,this._current),10);return{start:B,value:U,type:G.TOK_NUMBER}}consumeLBracket(z){let B=this._current;if(this._current+=1,z[this._current]==="?")return this._current+=1,{start:B,type:G.TOK_FILTER,value:"[?"};if(z[this._current]==="]")return this._current+=1,{start:B,type:G.TOK_FLATTEN,value:"[]"};return{start:B,type:G.TOK_LBRACKET,value:"["}}consumeOperator(z){let B=this._current,$=z[B];if(this._current+=1,$==="!"){if(z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_NE,value:"!="};return{start:B,type:G.TOK_NOT,value:"!"}}if($==="<"){if(z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_LTE,value:"<="};return{start:B,type:G.TOK_LT,value:"<"}}if($===">"){if(z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_GTE,value:">="};return{start:B,type:G.TOK_GT,value:">"}}if($==="="&&z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_EQ,value:"=="}}consumeLiteral(z){this._current+=1;let B=this._current,$=z.length;while(z[this._current]!=="`"&&this._current<$){let V=this._current;if(z[V]==="\\"&&(z[V+1]==="\\"||z[V+1]==="`"))V+=2;else V+=1;this._current=V}let U=z.slice(B,this._current).trimLeft();U=U.replace("\\`","`");let O=this.looksLikeJSON(U)?JSON.parse(U):JSON.parse(`"${U}"`);return this._current+=1,O}looksLikeJSON(z){let $=["true","false","null"],U="-0123456789";if(z==="")return!1;if('[{"'.includes(z[0]))return!0;if($.includes(z))return!0;if("-0123456789".includes(z[0]))try{return JSON.parse(z),!0}catch(O){return!1}return!1}}let E=new N,R={[G.TOK_EOF]:0,[G.TOK_UNQUOTEDIDENTIFIER]:0,[G.TOK_QUOTEDIDENTIFIER]:0,[G.TOK_RBRACKET]:0,[G.TOK_RPAREN]:0,[G.TOK_COMMA]:0,[G.TOK_RBRACE]:0,[G.TOK_NUMBER]:0,[G.TOK_CURRENT]:0,[G.TOK_EXPREF]:0,[G.TOK_ROOT]:0,[G.TOK_PIPE]:1,[G.TOK_OR]:2,[G.TOK_AND]:3,[G.TOK_EQ]:5,[G.TOK_GT]:5,[G.TOK_LT]:5,[G.TOK_GTE]:5,[G.TOK_LTE]:5,[G.TOK_NE]:5,[G.TOK_FLATTEN]:9,[G.TOK_STAR]:20,[G.TOK_FILTER]:21,[G.TOK_DOT]:40,[G.TOK_NOT]:45,[G.TOK_LBRACE]:50,[G.TOK_LBRACKET]:55,[G.TOK_LPAREN]:60};class o{constructor(){this.index=0,this.tokens=[]}parse(z){this.loadTokens(z),this.index=0;let B=this.expression(0);if(this.lookahead(0)!==G.TOK_EOF){let $=this.lookaheadToken(0);this.errorToken($,`Unexpected token type: ${$.type}, value: ${$.value}`)}return B}loadTokens(z){this.tokens=[...E.tokenize(z),{type:G.TOK_EOF,value:"",start:z.length}]}expression(z){let B=this.lookaheadToken(0);this.advance();let $=this.nud(B),U=this.lookahead(0);while(z<R[U])this.advance(),$=this.led(U,$),U=this.lookahead(0);return $}lookahead(z){return this.tokens[this.index+z].type}lookaheadToken(z){return this.tokens[this.index+z]}advance(){this.index+=1}nud(z){let B,$,U;switch(z.type){case G.TOK_LITERAL:return{type:"Literal",value:z.value};case G.TOK_UNQUOTEDIDENTIFIER:return{type:"Field",name:z.value};case G.TOK_QUOTEDIDENTIFIER:let O={type:"Field",name:z.value};if(this.lookahead(0)===G.TOK_LPAREN)throw Error("Quoted identifier not allowed for function names.");else return O;case G.TOK_NOT:return $=this.expression(R.Not),{type:"NotExpression",children:[$]};case G.TOK_STAR:return B={type:"Identity"},$=this.lookahead(0)===G.TOK_RBRACKET&&{type:"Identity"}||this.parseProjectionRHS(R.Star),{type:"ValueProjection",children:[B,$]};case G.TOK_FILTER:return this.led(z.type,{type:"Identity"});case G.TOK_LBRACE:return this.parseMultiselectHash();case G.TOK_FLATTEN:return B={type:G.TOK_FLATTEN,children:[{type:"Identity"}]},$=this.parseProjectionRHS(R.Flatten),{type:"Projection",children:[B,$]};case G.TOK_LBRACKET:if(this.lookahead(0)===G.TOK_NUMBER||this.lookahead(0)===G.TOK_COLON)return $=this.parseIndexExpression(),this.projectIfSlice({type:"Identity"},$);if(this.lookahead(0)===G.TOK_STAR&&this.lookahead(1)===G.TOK_RBRACKET)return this.advance(),this.advance(),$=this.parseProjectionRHS(R.Star),{children:[{type:"Identity"},$],type:"Projection"};return this.parseMultiselectList();case G.TOK_CURRENT:return{type:G.TOK_CURRENT};case G.TOK_ROOT:return{type:G.TOK_ROOT};case G.TOK_EXPREF:return U=this.expression(R.Expref),{type:"ExpressionReference",children:[U]};case G.TOK_LPAREN:let V=[];while(this.lookahead(0)!==G.TOK_RPAREN){if(this.lookahead(0)===G.TOK_CURRENT)U={type:G.TOK_CURRENT},this.advance();else U=this.expression(0);V.push(U)}return this.match(G.TOK_RPAREN),V[0];default:this.errorToken(z)}}led(z,B){let $;switch(z){case G.TOK_DOT:let U=R.Dot;if(this.lookahead(0)!==G.TOK_STAR)return $=this.parseDotRHS(U),{type:"Subexpression",children:[B,$]};return this.advance(),$=this.parseProjectionRHS(U),{type:"ValueProjection",children:[B,$]};case G.TOK_PIPE:return $=this.expression(R.Pipe),{type:G.TOK_PIPE,children:[B,$]};case G.TOK_OR:return $=this.expression(R.Or),{type:"OrExpression",children:[B,$]};case G.TOK_AND:return $=this.expression(R.And),{type:"AndExpression",children:[B,$]};case G.TOK_LPAREN:let O=B.name,V=[],_;while(this.lookahead(0)!==G.TOK_RPAREN){if(this.lookahead(0)===G.TOK_CURRENT)_={type:G.TOK_CURRENT},this.advance();else _=this.expression(0);if(this.lookahead(0)===G.TOK_COMMA)this.match(G.TOK_COMMA);V.push(_)}return this.match(G.TOK_RPAREN),{name:O,type:"Function",children:V};case G.TOK_FILTER:let m=this.expression(0);return this.match(G.TOK_RBRACKET),$=this.lookahead(0)===G.TOK_FLATTEN&&{type:"Identity"}||this.parseProjectionRHS(R.Filter),{type:"FilterProjection",children:[B,$,m]};case G.TOK_FLATTEN:let $0={type:G.TOK_FLATTEN,children:[B]},u=this.parseProjectionRHS(R.Flatten);return{type:"Projection",children:[$0,u]};case G.TOK_EQ:case G.TOK_NE:case G.TOK_GT:case G.TOK_GTE:case G.TOK_LT:case G.TOK_LTE:return this.parseComparator(B,z);case G.TOK_LBRACKET:let C=this.lookaheadToken(0);if(C.type===G.TOK_NUMBER||C.type===G.TOK_COLON)return $=this.parseIndexExpression(),this.projectIfSlice(B,$);return this.match(G.TOK_STAR),this.match(G.TOK_RBRACKET),$=this.parseProjectionRHS(R.Star),{type:"Projection",children:[B,$]};default:return this.errorToken(this.lookaheadToken(0))}}match(z){if(this.lookahead(0)===z){this.advance();return}else{let B=this.lookaheadToken(0);this.errorToken(B,`Expected ${z}, got: ${B.type}`)}}errorToken(z,B=""){let $=Error(B||`Invalid token (${z.type}): "${z.value}"`);throw $.name="ParserError",$}parseIndexExpression(){if(this.lookahead(0)===G.TOK_COLON||this.lookahead(1)===G.TOK_COLON)return this.parseSliceExpression();let z={type:"Index",value:this.lookaheadToken(0).value};return this.advance(),this.match(G.TOK_RBRACKET),z}projectIfSlice(z,B){let $={type:"IndexExpression",children:[z,B]};if(B.type==="Slice")return{children:[$,this.parseProjectionRHS(R.Star)],type:"Projection"};return $}parseSliceExpression(){let z=[null,null,null],B=0,$=this.lookahead(0);while($!==G.TOK_RBRACKET&&B<3){if($===G.TOK_COLON)B+=1,this.advance();else if($===G.TOK_NUMBER)z[B]=this.lookaheadToken(0).value,this.advance();else{let U=this.lookaheadToken(0);this.errorToken(U,`Syntax error, unexpected token: ${U.value}(${U.type})`)}$=this.lookahead(0)}return this.match(G.TOK_RBRACKET),{children:z,type:"Slice"}}parseComparator(z,B){let $=this.expression(R[B]);return{type:"Comparator",name:B,children:[z,$]}}parseDotRHS(z){let B=this.lookahead(0);if([G.TOK_UNQUOTEDIDENTIFIER,G.TOK_QUOTEDIDENTIFIER,G.TOK_STAR].includes(B))return this.expression(z);if(B===G.TOK_LBRACKET)return this.match(G.TOK_LBRACKET),this.parseMultiselectList();if(B===G.TOK_LBRACE)return this.match(G.TOK_LBRACE),this.parseMultiselectHash();let U=this.lookaheadToken(0);this.errorToken(U,`Syntax error, unexpected token: ${U.value}(${U.type})`)}parseProjectionRHS(z){if(R[this.lookahead(0)]<10)return{type:"Identity"};if(this.lookahead(0)===G.TOK_LBRACKET)return this.expression(z);if(this.lookahead(0)===G.TOK_FILTER)return this.expression(z);if(this.lookahead(0)===G.TOK_DOT)return this.match(G.TOK_DOT),this.parseDotRHS(z);let B=this.lookaheadToken(0);this.errorToken(B,`Syntax error, unexpected token: ${B.value}(${B.type})`)}parseMultiselectList(){let z=[];while(this.lookahead(0)!==G.TOK_RBRACKET){let B=this.expression(0);if(z.push(B),this.lookahead(0)===G.TOK_COMMA){if(this.match(G.TOK_COMMA),this.lookahead(0)===G.TOK_RBRACKET)throw Error("Unexpected token Rbracket")}}return this.match(G.TOK_RBRACKET),{type:"MultiSelectList",children:z}}parseMultiselectHash(){let z=[],B=[G.TOK_UNQUOTEDIDENTIFIER,G.TOK_QUOTEDIDENTIFIER],$,U,O;for(;;){if($=this.lookaheadToken(0),!B.includes($.type))throw Error(`Expecting an identifier token, got: ${$.type}`);if(U=$.value,this.advance(),this.match(G.TOK_COLON),O=this.expression(0),z.push({value:O,type:"KeyValuePair",name:U}),this.lookahead(0)===G.TOK_COMMA)this.match(G.TOK_COMMA);else if(this.lookahead(0)===G.TOK_RBRACE){this.match(G.TOK_RBRACE);break}}return{type:"MultiSelectHash",children:z}}}let l=new o;var M;(function(z){z[z.TYPE_NUMBER=0]="TYPE_NUMBER",z[z.TYPE_ANY=1]="TYPE_ANY",z[z.TYPE_STRING=2]="TYPE_STRING",z[z.TYPE_ARRAY=3]="TYPE_ARRAY",z[z.TYPE_OBJECT=4]="TYPE_OBJECT",z[z.TYPE_BOOLEAN=5]="TYPE_BOOLEAN",z[z.TYPE_EXPREF=6]="TYPE_EXPREF",z[z.TYPE_NULL=7]="TYPE_NULL",z[z.TYPE_ARRAY_NUMBER=8]="TYPE_ARRAY_NUMBER",z[z.TYPE_ARRAY_STRING=9]="TYPE_ARRAY_STRING"})(M||(M={}));class J1{constructor(z){this.TYPE_NAME_TABLE={[M.TYPE_NUMBER]:"number",[M.TYPE_ANY]:"any",[M.TYPE_STRING]:"string",[M.TYPE_ARRAY]:"array",[M.TYPE_OBJECT]:"object",[M.TYPE_BOOLEAN]:"boolean",[M.TYPE_EXPREF]:"expression",[M.TYPE_NULL]:"null",[M.TYPE_ARRAY_NUMBER]:"Array<number>",[M.TYPE_ARRAY_STRING]:"Array<string>"},this.functionAbs=([B])=>{return Math.abs(B)},this.functionAvg=([B])=>{let $=0;for(let U=0;U<B.length;U+=1)$+=B[U];return $/B.length},this.functionCeil=([B])=>{return Math.ceil(B)},this.functionContains=(B)=>{let[$,U]=B;return $.includes(U)},this.functionEndsWith=(B)=>{let[$,U]=B;return $.includes(U,$.length-U.length)},this.functionFloor=([B])=>{return Math.floor(B)},this.functionJoin=(B)=>{let[$,U]=B;return U.join($)},this.functionKeys=([B])=>{return Object.keys(B)},this.functionLength=([B])=>{if(!X(B))return B.length;return Object.keys(B).length},this.functionMap=(B)=>{if(!this._interpreter)return[];let $=[],U=this._interpreter,O=B[0],V=B[1];for(let _=0;_<V.length;_+=1)$.push(U.visit(O,V[_]));return $},this.functionMax=([B])=>{if(!B.length)return null;if(this.getTypeName(B[0])===M.TYPE_NUMBER)return Math.max(...B);let U=B,O=U[0];for(let V=1;V<U.length;V+=1)if(O.localeCompare(U[V])<0)O=U[V];return O},this.functionMaxBy=(B)=>{let $=B[1],U=B[0],O=this.createKeyFunction($,[M.TYPE_NUMBER,M.TYPE_STRING]),V=-1/0,_,A;for(let m=0;m<U.length;m+=1)if(A=O&&O(U[m]),A!==void 0&&A>V)V=A,_=U[m];return _},this.functionMerge=(B)=>{let $={};for(let U=0;U<B.length;U+=1){let O=B[U];$=Object.assign($,O)}return $},this.functionMin=([B])=>{if(!B.length)return null;if(this.getTypeName(B[0])===M.TYPE_NUMBER)return Math.min(...B);let U=B,O=U[0];for(let V=1;V<U.length;V+=1)if(U[V].localeCompare(O)<0)O=U[V];return O},this.functionMinBy=(B)=>{let $=B[1],U=B[0],O=this.createKeyFunction($,[M.TYPE_NUMBER,M.TYPE_STRING]),V=1/0,_,A;for(let m=0;m<U.length;m+=1)if(A=O&&O(U[m]),A!==void 0&&A<V)V=A,_=U[m];return _},this.functionNotNull=(B)=>{for(let $=0;$<B.length;$+=1)if(this.getTypeName(B[$])!==M.TYPE_NULL)return B[$];return null},this.functionReverse=([B])=>{if(this.getTypeName(B)===M.TYPE_STRING){let O=B,V="";for(let _=O.length-1;_>=0;_-=1)V+=O[_];return V}let U=B.slice(0);return U.reverse(),U},this.functionSort=([B])=>{return[...B].sort()},this.functionSortBy=(B)=>{if(!this._interpreter)return[];let $=B[0].slice(0);if($.length===0)return $;let U=this._interpreter,O=B[1],V=this.getTypeName(U.visit(O,$[0]));if(V!==void 0&&![M.TYPE_NUMBER,M.TYPE_STRING].includes(V))throw Error(`TypeError: unexpected type (${this.TYPE_NAME_TABLE[V]})`);let _=[];for(let A=0;A<$.length;A+=1)_.push([A,$[A]]);_.sort((A,m)=>{let $0=U.visit(O,A[1]),u=U.visit(O,m[1]);if(this.getTypeName($0)!==V)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[V]}), received ${this.TYPE_NAME_TABLE[this.getTypeName($0)]}`);else if(this.getTypeName(u)!==V)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[V]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(u)]}`);if($0>u)return 1;return $0<u?-1:A[0]-m[0]});for(let A=0;A<_.length;A+=1)$[A]=_[A][1];return $},this.functionStartsWith=([B,$])=>{return B.startsWith($)},this.functionSum=([B])=>{return B.reduce(($,U)=>$+U,0)},this.functionToArray=([B])=>{if(this.getTypeName(B)===M.TYPE_ARRAY)return B;return[B]},this.functionToNumber=([B])=>{let $=this.getTypeName(B),U;if($===M.TYPE_NUMBER)return B;if($===M.TYPE_STRING){if(U=+B,!isNaN(U))return U}return null},this.functionToString=([B])=>{if(this.getTypeName(B)===M.TYPE_STRING)return B;return JSON.stringify(B)},this.functionType=([B])=>{switch(this.getTypeName(B)){case M.TYPE_NUMBER:return"number";case M.TYPE_STRING:return"string";case M.TYPE_ARRAY:return"array";case M.TYPE_OBJECT:return"object";case M.TYPE_BOOLEAN:return"boolean";case M.TYPE_EXPREF:return"expref";case M.TYPE_NULL:return"null";default:return}},this.functionValues=([B])=>{return Object.values(B)},this.functionTable={abs:{_func:this.functionAbs,_signature:[{types:[M.TYPE_NUMBER]}]},avg:{_func:this.functionAvg,_signature:[{types:[M.TYPE_ARRAY_NUMBER]}]},ceil:{_func:this.functionCeil,_signature:[{types:[M.TYPE_NUMBER]}]},contains:{_func:this.functionContains,_signature:[{types:[M.TYPE_STRING,M.TYPE_ARRAY]},{types:[M.TYPE_ANY]}]},ends_with:{_func:this.functionEndsWith,_signature:[{types:[M.TYPE_STRING]},{types:[M.TYPE_STRING]}]},floor:{_func:this.functionFloor,_signature:[{types:[M.TYPE_NUMBER]}]},join:{_func:this.functionJoin,_signature:[{types:[M.TYPE_STRING]},{types:[M.TYPE_ARRAY_STRING]}]},keys:{_func:this.functionKeys,_signature:[{types:[M.TYPE_OBJECT]}]},length:{_func:this.functionLength,_signature:[{types:[M.TYPE_STRING,M.TYPE_ARRAY,M.TYPE_OBJECT]}]},map:{_func:this.functionMap,_signature:[{types:[M.TYPE_EXPREF]},{types:[M.TYPE_ARRAY]}]},max:{_func:this.functionMax,_signature:[{types:[M.TYPE_ARRAY_NUMBER,M.TYPE_ARRAY_STRING]}]},max_by:{_func:this.functionMaxBy,_signature:[{types:[M.TYPE_ARRAY]},{types:[M.TYPE_EXPREF]}]},merge:{_func:this.functionMerge,_signature:[{types:[M.TYPE_OBJECT],variadic:!0}]},min:{_func:this.functionMin,_signature:[{types:[M.TYPE_ARRAY_NUMBER,M.TYPE_ARRAY_STRING]}]},min_by:{_func:this.functionMinBy,_signature:[{types:[M.TYPE_ARRAY]},{types:[M.TYPE_EXPREF]}]},not_null:{_func:this.functionNotNull,_signature:[{types:[M.TYPE_ANY],variadic:!0}]},reverse:{_func:this.functionReverse,_signature:[{types:[M.TYPE_STRING,M.TYPE_ARRAY]}]},sort:{_func:this.functionSort,_signature:[{types:[M.TYPE_ARRAY_STRING,M.TYPE_ARRAY_NUMBER]}]},sort_by:{_func:this.functionSortBy,_signature:[{types:[M.TYPE_ARRAY]},{types:[M.TYPE_EXPREF]}]},starts_with:{_func:this.functionStartsWith,_signature:[{types:[M.TYPE_STRING]},{types:[M.TYPE_STRING]}]},sum:{_func:this.functionSum,_signature:[{types:[M.TYPE_ARRAY_NUMBER]}]},to_array:{_func:this.functionToArray,_signature:[{types:[M.TYPE_ANY]}]},to_number:{_func:this.functionToNumber,_signature:[{types:[M.TYPE_ANY]}]},to_string:{_func:this.functionToString,_signature:[{types:[M.TYPE_ANY]}]},type:{_func:this.functionType,_signature:[{types:[M.TYPE_ANY]}]},values:{_func:this.functionValues,_signature:[{types:[M.TYPE_OBJECT]}]}},this._interpreter=z}registerFunction(z,B,$){if(z in this.functionTable)throw Error(`Function already defined: ${z}()`);this.functionTable[z]={_func:B.bind(this),_signature:$}}callFunction(z,B){let $=this.functionTable[z];if($===void 0)throw Error(`Unknown function: ${z}()`);return this.validateArgs(z,B,$._signature),$._func.call(this,B)}validateInputSignatures(z,B){for(let $=0;$<B.length;$+=1)if("variadic"in B[$]&&$!==B.length-1)throw Error(`ArgumentError: ${z}() 'variadic' argument ${$+1} must occur last`)}validateArgs(z,B,$){var U,O;let V;this.validateInputSignatures(z,$);let _=$.filter((L0)=>{var w0;return(w0=!L0.optional)!==null&&w0!==void 0?w0:!1}).length,A=(O=(U=$[$.length-1])===null||U===void 0?void 0:U.variadic)!==null&&O!==void 0?O:!1,m=B.length<_,$0=B.length>$.length,u=m&&(!A&&_>1||A)?"at least ":"";if(A&&m||!A&&(m||$0))throw V=$.length>1,Error(`ArgumentError: ${z}() takes ${u}${_} argument${V&&"s"||""} but received ${B.length}`);let C,r,P0;for(let L0=0;L0<$.length;L0+=1){P0=!1,C=$[L0].types,r=this.getTypeName(B[L0]);let w0;for(w0=0;w0<C.length;w0+=1)if(r!==void 0&&this.typeMatches(r,C[w0],B[L0])){P0=!0;break}if(!P0&&r!==void 0){let $1=C.map((H1)=>{return this.TYPE_NAME_TABLE[H1]}).join(" | ");throw Error(`TypeError: ${z}() expected argument ${L0+1} to be type (${$1}) but received type ${this.TYPE_NAME_TABLE[r]} instead.`)}}}typeMatches(z,B,$){if(B===M.TYPE_ANY)return!0;if(B===M.TYPE_ARRAY_STRING||B===M.TYPE_ARRAY_NUMBER||B===M.TYPE_ARRAY){if(B===M.TYPE_ARRAY)return z===M.TYPE_ARRAY;if(z===M.TYPE_ARRAY){let U;if(B===M.TYPE_ARRAY_NUMBER)U=M.TYPE_NUMBER;else if(B===M.TYPE_ARRAY_STRING)U=M.TYPE_STRING;for(let O=0;O<$.length;O+=1){let V=this.getTypeName($[O]);if(V!==void 0&&U!==void 0&&!this.typeMatches(V,U,$[O]))return!1}return!0}}else return z===B;return!1}getTypeName(z){switch(Object.prototype.toString.call(z)){case"[object String]":return M.TYPE_STRING;case"[object Number]":return M.TYPE_NUMBER;case"[object Array]":return M.TYPE_ARRAY;case"[object Boolean]":return M.TYPE_BOOLEAN;case"[object Null]":return M.TYPE_NULL;case"[object Object]":if(z.jmespathType===G.TOK_EXPREF)return M.TYPE_EXPREF;return M.TYPE_OBJECT;default:return}}createKeyFunction(z,B){if(!this._interpreter)return;let $=this._interpreter;return(O)=>{let V=$.visit(z,O);if(!B.includes(this.getTypeName(V))){let _=`TypeError: expected one of (${B.map((A)=>this.TYPE_NAME_TABLE[A]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(V)]}`;throw Error(_)}return V}}}class z1{constructor(){this._rootValue=null,this.runtime=new J1(this)}search(z,B){return this._rootValue=B,this.visit(z,B)}visit(z,B){let $,U,O,V,_,A,m,$0,u,C,r;switch(z.type){case"Field":if(B===null)return null;if(X(B)){if(A=B[z.name],A===void 0)return null;return A}return null;case"Subexpression":O=this.visit(z.children[0],B);for(C=1;C<z.children.length;C+=1)if(O=this.visit(z.children[1],O),O===null)return null;return O;case"IndexExpression":return m=this.visit(z.children[0],B),$0=this.visit(z.children[1],m),$0;case"Index":if(!Array.isArray(B))return null;let P0=z.value;if(P0<0)P0=B.length+P0;if(O=B[P0],O===void 0)O=null;return O;case"Slice":if(!Array.isArray(B))return null;let L0=[...z.children],w0=this.computeSliceParams(B.length,L0),[$1,H1,l1]=w0;if(O=[],l1>0)for(C=$1;C<H1;C+=l1)O.push(B[C]);else for(C=$1;C>H1;C+=l1)O.push(B[C]);return O;case"Projection":if(r=this.visit(z.children[0],B),!Array.isArray(r))return null;u=[];for(C=0;C<r.length;C+=1)if(U=this.visit(z.children[1],r[C]),U!==null)u.push(U);return u;case"ValueProjection":if(r=this.visit(z.children[0],B),!X(r))return null;u=[];let V6=Object.values(r);for(C=0;C<V6.length;C+=1)if(U=this.visit(z.children[1],V6[C]),U!==null)u.push(U);return u;case"FilterProjection":if(r=this.visit(z.children[0],B),!Array.isArray(r))return null;let d1=[],P6=[];for(C=0;C<r.length;C+=1)if($=this.visit(z.children[2],r[C]),!Y($))d1.push(r[C]);for(let _0=0;_0<d1.length;_0+=1)if(U=this.visit(z.children[1],d1[_0]),U!==null)P6.push(U);return P6;case"Comparator":switch(V=this.visit(z.children[0],B),_=this.visit(z.children[1],B),z.name){case G.TOK_EQ:O=K(V,_);break;case G.TOK_NE:O=!K(V,_);break;case G.TOK_GT:O=V>_;break;case G.TOK_GTE:O=V>=_;break;case G.TOK_LT:O=V<_;break;case G.TOK_LTE:O=V<=_;break;default:throw Error(`Unknown comparator: ${z.name}`)}return O;case G.TOK_FLATTEN:let o1=this.visit(z.children[0],B);if(!Array.isArray(o1))return null;let U1=[];for(C=0;C<o1.length;C+=1)if(U=o1[C],Array.isArray(U))U1=[...U1,...U];else U1.push(U);return U1;case"Identity":return B;case"MultiSelectList":if(B===null)return null;u=[];for(C=0;C<z.children.length;C+=1)u.push(this.visit(z.children[C],B));return u;case"MultiSelectHash":if(B===null)return null;u={};let r1;for(C=0;C<z.children.length;C+=1)r1=z.children[C],u[r1.name]=this.visit(r1.value,B);return u;case"OrExpression":if($=this.visit(z.children[0],B),Y($))$=this.visit(z.children[1],B);return $;case"AndExpression":if(V=this.visit(z.children[0],B),Y(V))return V;return this.visit(z.children[1],B);case"NotExpression":return V=this.visit(z.children[0],B),Y(V);case"Literal":return z.value;case G.TOK_PIPE:return m=this.visit(z.children[0],B),this.visit(z.children[1],m);case G.TOK_CURRENT:return B;case G.TOK_ROOT:return this._rootValue;case"Function":let R6=[];for(let _0=0;_0<z.children.length;_0+=1)R6.push(this.visit(z.children[_0],B));return this.runtime.callFunction(z.name,R6);case"ExpressionReference":let Z6=z.children[0];return Z6.jmespathType=G.TOK_EXPREF,Z6;default:throw Error(`Unknown node type: ${z.type}`)}}computeSliceParams(z,B){let[$,U,O]=B;if(O===null)O=1;else if(O===0){let _=Error("Invalid slice, step cannot be 0");throw _.name="RuntimeError",_}let V=O<0?!0:!1;return $=$===null?V?z-1:0:this.capSliceRange(z,$,O),U=U===null?V?-1:z:this.capSliceRange(z,U,O),[$,U,O]}capSliceRange(z,B,$){let U=B;if(U<0){if(U+=z,U<0)U=$<0?-1:0}else if(U>=z)U=$<0?z-1:z;return U}}let K0=new z1,n=M.TYPE_ANY,Y0=M.TYPE_ARRAY,p1=M.TYPE_ARRAY_NUMBER,B1=M.TYPE_ARRAY_STRING,z6=M.TYPE_BOOLEAN,B6=M.TYPE_EXPREF,$6=M.TYPE_NULL,H6=M.TYPE_NUMBER,U6=M.TYPE_OBJECT,L6=M.TYPE_STRING;function w6(z){return l.parse(z)}function D6(z){return E.tokenize(z)}let M6=(z,B,$)=>{K0.runtime.registerFunction(z,B,$)};function O6(z,B){let $=l.parse(B);return K0.search($,z)}let F6=K0,N6={compile:w6,registerFunction:M6,search:O6,tokenize:D6,TreeInterpreter:F6,TYPE_ANY:n,TYPE_ARRAY_NUMBER:p1,TYPE_ARRAY_STRING:B1,TYPE_ARRAY:Y0,TYPE_BOOLEAN:z6,TYPE_EXPREF:B6,TYPE_NULL:$6,TYPE_NUMBER:H6,TYPE_OBJECT:U6,TYPE_STRING:L6};W.TYPE_ANY=n,W.TYPE_ARRAY=Y0,W.TYPE_ARRAY_NUMBER=p1,W.TYPE_ARRAY_STRING=B1,W.TYPE_BOOLEAN=z6,W.TYPE_EXPREF=B6,W.TYPE_NULL=$6,W.TYPE_NUMBER=H6,W.TYPE_OBJECT=U6,W.TYPE_STRING=L6,W.TreeInterpreter=F6,W.compile=w6,W.default=N6,W.jmespath=N6,W.registerFunction=M6,W.search=O6,W.tokenize=D6,Object.defineProperty(W,"__esModule",{value:!0})})});import dW from"node:process";var hQ=Object.freeze({status:"aborted"});function w(W,X,K){function Y(G,H){if(!G._zod)Object.defineProperty(G,"_zod",{value:{def:H,constr:J,traits:new Set},enumerable:!1});if(G._zod.traits.has(W))return;G._zod.traits.add(W),X(G,H);let D=J.prototype,F=Object.keys(D);for(let N=0;N<F.length;N++){let E=F[N];if(!(E in G))G[E]=D[E].bind(G)}}let Q=K?.Parent??Object;class q extends Q{}Object.defineProperty(q,"name",{value:W});function J(G){var H;let D=K?.Parent?new q:this;Y(D,G),(H=D._zod).deferred??(H.deferred=[]);for(let F of D._zod.deferred)F();return D}return Object.defineProperty(J,"init",{value:Y}),Object.defineProperty(J,Symbol.hasInstance,{value:(G)=>{if(K?.Parent&&G instanceof K.Parent)return!0;return G?._zod?.traits?.has(W)}}),Object.defineProperty(J,"name",{value:W}),J}var gQ=Symbol("zod_brand");class M0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class c0 extends Error{constructor(W){super(`Encountered unidirectional transform during encode: ${W}`);this.name="ZodEncodeError"}}var L1={};function J0(W){if(W)Object.assign(L1,W);return L1}var j={};n1(j,{unwrapMessage:()=>m0,uint8ArrayToHex:()=>KX,uint8ArrayToBase64url:()=>WX,uint8ArrayToBase64:()=>j6,stringifyPrimitive:()=>O1,slugify:()=>e1,shallowClone:()=>I6,safeExtend:()=>i3,required:()=>a3,randomString:()=>m3,propertyKeyTypes:()=>X9,promiseAllObject:()=>c3,primitiveTypes:()=>C6,prefixIssues:()=>N0,pick:()=>d3,partial:()=>t3,parsedType:()=>Q9,optionalKeys:()=>K9,omit:()=>o3,objectClone:()=>g3,numKeys:()=>u3,nullish:()=>p0,normalizeParams:()=>I,mergeDefs:()=>O0,merge:()=>n3,jsonStringifyReplacer:()=>k0,joinValues:()=>w1,issue:()=>x0,isPlainObject:()=>Z0,isObject:()=>S0,hexToUint8Array:()=>XX,getSizableOrigin:()=>S6,getParsedType:()=>p3,getLengthableOrigin:()=>d0,getEnumValues:()=>u0,getElementAtPath:()=>f3,floatSafeRemainder:()=>s1,finalizeIssue:()=>U0,extend:()=>r3,escapeRegex:()=>F0,esc:()=>D1,defineLazy:()=>b,createTransparentProxy:()=>l3,cloneDef:()=>y3,clone:()=>H0,cleanRegex:()=>l0,cleanEnum:()=>s3,captureStackTrace:()=>M1,cached:()=>v0,base64urlToUint8Array:()=>e3,base64ToUint8Array:()=>A6,assignProp:()=>R0,assertNotEqual:()=>k3,assertNever:()=>x3,assertIs:()=>v3,assertEqual:()=>T3,assert:()=>h3,allowsEval:()=>W9,aborted:()=>E0,NUMBER_FORMAT_RANGES:()=>Y9,Class:()=>b6,BIGINT_FORMAT_RANGES:()=>_6});function T3(W){return W}function k3(W){return W}function v3(W){}function x3(W){throw Error("Unexpected value in exhaustive check")}function h3(W){}function u0(W){let X=Object.values(W).filter((Y)=>typeof Y==="number");return Object.entries(W).filter(([Y,Q])=>X.indexOf(+Y)===-1).map(([Y,Q])=>Q)}function w1(W,X="|"){return W.map((K)=>O1(K)).join(X)}function k0(W,X){if(typeof X==="bigint")return X.toString();return X}function v0(W){return{get value(){{let K=W();return Object.defineProperty(this,"value",{value:K}),K}throw Error("cached value already set")}}}function p0(W){return W===null||W===void 0}function l0(W){let X=W.startsWith("^")?1:0,K=W.endsWith("$")?W.length-1:W.length;return W.slice(X,K)}function s1(W,X){let K=(W.toString().split(".")[1]||"").length,Y=X.toString(),Q=(Y.split(".")[1]||"").length;if(Q===0&&/\d?e-\d?/.test(Y)){let H=Y.match(/\d?e-(\d?)/);if(H?.[1])Q=Number.parseInt(H[1])}let q=K>Q?K:Q,J=Number.parseInt(W.toFixed(q).replace(".","")),G=Number.parseInt(X.toFixed(q).replace(".",""));return J%G/10**q}var E6=Symbol("evaluating");function b(W,X,K){let Y=void 0;Object.defineProperty(W,X,{get(){if(Y===E6)return;if(Y===void 0)Y=E6,Y=K();return Y},set(Q){Object.defineProperty(W,X,{value:Q})},configurable:!0})}function g3(W){return Object.create(Object.getPrototypeOf(W),Object.getOwnPropertyDescriptors(W))}function R0(W,X,K){Object.defineProperty(W,X,{value:K,writable:!0,enumerable:!0,configurable:!0})}function O0(...W){let X={};for(let K of W){let Y=Object.getOwnPropertyDescriptors(K);Object.assign(X,Y)}return Object.defineProperties({},X)}function y3(W){return O0(W._zod.def)}function f3(W,X){if(!X)return W;return X.reduce((K,Y)=>K?.[Y],W)}function c3(W){let X=Object.keys(W),K=X.map((Y)=>W[Y]);return Promise.all(K).then((Y)=>{let Q={};for(let q=0;q<X.length;q++)Q[X[q]]=Y[q];return Q})}function m3(W=10){let K="";for(let Y=0;Y<W;Y++)K+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return K}function D1(W){return JSON.stringify(W)}function e1(W){return W.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var M1="captureStackTrace"in Error?Error.captureStackTrace:(...W)=>{};function S0(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}var W9=v0(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(W){return!1}});function Z0(W){if(S0(W)===!1)return!1;let X=W.constructor;if(X===void 0)return!0;if(typeof X!=="function")return!0;let K=X.prototype;if(S0(K)===!1)return!1;if(Object.prototype.hasOwnProperty.call(K,"isPrototypeOf")===!1)return!1;return!0}function I6(W){if(Z0(W))return{...W};if(Array.isArray(W))return[...W];return W}function u3(W){let X=0;for(let K in W)if(Object.prototype.hasOwnProperty.call(W,K))X++;return X}var p3=(W)=>{let X=typeof W;switch(X){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(W)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(W))return"array";if(W===null)return"null";if(W.then&&typeof W.then==="function"&&W.catch&&typeof W.catch==="function")return"promise";if(typeof Map<"u"&&W instanceof Map)return"map";if(typeof Set<"u"&&W instanceof Set)return"set";if(typeof Date<"u"&&W instanceof Date)return"date";if(typeof File<"u"&&W instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${X}`)}},X9=new Set(["string","number","symbol"]),C6=new Set(["string","number","bigint","boolean","symbol","undefined"]);function F0(W){return W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function H0(W,X,K){let Y=new W._zod.constr(X??W._zod.def);if(!X||K?.parent)Y._zod.parent=W;return Y}function I(W){let X=W;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 l3(W){let X;return new Proxy({},{get(K,Y,Q){return X??(X=W()),Reflect.get(X,Y,Q)},set(K,Y,Q,q){return X??(X=W()),Reflect.set(X,Y,Q,q)},has(K,Y){return X??(X=W()),Reflect.has(X,Y)},deleteProperty(K,Y){return X??(X=W()),Reflect.deleteProperty(X,Y)},ownKeys(K){return X??(X=W()),Reflect.ownKeys(X)},getOwnPropertyDescriptor(K,Y){return X??(X=W()),Reflect.getOwnPropertyDescriptor(X,Y)},defineProperty(K,Y,Q){return X??(X=W()),Reflect.defineProperty(X,Y,Q)}})}function O1(W){if(typeof W==="bigint")return W.toString()+"n";if(typeof W==="string")return`"${W}"`;return`${W}`}function K9(W){return Object.keys(W).filter((X)=>{return W[X]._zod.optin==="optional"&&W[X]._zod.optout==="optional"})}var Y9={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]},_6={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function d3(W,X){let K=W._zod.def,Y=K.checks;if(Y&&Y.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let q=O0(W._zod.def,{get shape(){let J={};for(let G in X){if(!(G in K.shape))throw Error(`Unrecognized key: "${G}"`);if(!X[G])continue;J[G]=K.shape[G]}return R0(this,"shape",J),J},checks:[]});return H0(W,q)}function o3(W,X){let K=W._zod.def,Y=K.checks;if(Y&&Y.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let q=O0(W._zod.def,{get shape(){let J={...W._zod.def.shape};for(let G in X){if(!(G in K.shape))throw Error(`Unrecognized key: "${G}"`);if(!X[G])continue;delete J[G]}return R0(this,"shape",J),J},checks:[]});return H0(W,q)}function r3(W,X){if(!Z0(X))throw Error("Invalid input to extend: expected a plain object");let K=W._zod.def.checks;if(K&&K.length>0){let q=W._zod.def.shape;for(let J in X)if(Object.getOwnPropertyDescriptor(q,J)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let Q=O0(W._zod.def,{get shape(){let q={...W._zod.def.shape,...X};return R0(this,"shape",q),q}});return H0(W,Q)}function i3(W,X){if(!Z0(X))throw Error("Invalid input to safeExtend: expected a plain object");let K=O0(W._zod.def,{get shape(){let Y={...W._zod.def.shape,...X};return R0(this,"shape",Y),Y}});return H0(W,K)}function n3(W,X){let K=O0(W._zod.def,{get shape(){let Y={...W._zod.def.shape,...X._zod.def.shape};return R0(this,"shape",Y),Y},get catchall(){return X._zod.def.catchall},checks:[]});return H0(W,K)}function t3(W,X,K){let Q=X._zod.def.checks;if(Q&&Q.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let J=O0(X._zod.def,{get shape(){let G=X._zod.def.shape,H={...G};if(K)for(let D in K){if(!(D in G))throw Error(`Unrecognized key: "${D}"`);if(!K[D])continue;H[D]=W?new W({type:"optional",innerType:G[D]}):G[D]}else for(let D in G)H[D]=W?new W({type:"optional",innerType:G[D]}):G[D];return R0(this,"shape",H),H},checks:[]});return H0(X,J)}function a3(W,X,K){let Y=O0(X._zod.def,{get shape(){let Q=X._zod.def.shape,q={...Q};if(K)for(let J in K){if(!(J in q))throw Error(`Unrecognized key: "${J}"`);if(!K[J])continue;q[J]=new W({type:"nonoptional",innerType:Q[J]})}else for(let J in Q)q[J]=new W({type:"nonoptional",innerType:Q[J]});return R0(this,"shape",q),q}});return H0(X,Y)}function E0(W,X=0){if(W.aborted===!0)return!0;for(let K=X;K<W.issues.length;K++)if(W.issues[K]?.continue!==!0)return!0;return!1}function N0(W,X){return X.map((K)=>{var Y;return(Y=K).path??(Y.path=[]),K.path.unshift(W),K})}function m0(W){return typeof W==="string"?W:W?.message}function U0(W,X,K){let Y={...W,path:W.path??[]};if(!W.message){let Q=m0(W.inst?._zod.def?.error?.(W))??m0(X?.error?.(W))??m0(K.customError?.(W))??m0(K.localeError?.(W))??"Invalid input";Y.message=Q}if(delete Y.inst,delete Y.continue,!X?.reportInput)delete Y.input;return Y}function S6(W){if(W instanceof Set)return"set";if(W instanceof Map)return"map";if(W instanceof File)return"file";return"unknown"}function d0(W){if(Array.isArray(W))return"array";if(typeof W==="string")return"string";return"unknown"}function Q9(W){let X=typeof W;switch(X){case"number":return Number.isNaN(W)?"nan":"number";case"object":{if(W===null)return"null";if(Array.isArray(W))return"array";let K=W;if(K&&Object.getPrototypeOf(K)!==Object.prototype&&"constructor"in K&&K.constructor)return K.constructor.name}}return X}function x0(...W){let[X,K,Y]=W;if(typeof X==="string")return{message:X,code:"custom",input:K,inst:Y};return{...X}}function s3(W){return Object.entries(W).filter(([X,K])=>{return Number.isNaN(Number.parseInt(X,10))}).map((X)=>X[1])}function A6(W){let X=atob(W),K=new Uint8Array(X.length);for(let Y=0;Y<X.length;Y++)K[Y]=X.charCodeAt(Y);return K}function j6(W){let X="";for(let K=0;K<W.length;K++)X+=String.fromCharCode(W[K]);return btoa(X)}function e3(W){let X=W.replace(/-/g,"+").replace(/_/g,"/"),K="=".repeat((4-X.length%4)%4);return A6(X+K)}function WX(W){return j6(W).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function XX(W){let X=W.replace(/^0x/,"");if(X.length%2!==0)throw Error("Invalid hex string length");let K=new Uint8Array(X.length/2);for(let Y=0;Y<X.length;Y+=2)K[Y/2]=Number.parseInt(X.slice(Y,Y+2),16);return K}function KX(W){return Array.from(W).map((X)=>X.toString(16).padStart(2,"0")).join("")}class b6{constructor(...W){}}var T6=(W,X)=>{W.name="$ZodError",Object.defineProperty(W,"_zod",{value:W._zod,enumerable:!1}),Object.defineProperty(W,"issues",{value:X,enumerable:!1}),W.message=JSON.stringify(X,k0,2),Object.defineProperty(W,"toString",{value:()=>W.message,enumerable:!1})},F1=w("$ZodError",T6),G9=w("$ZodError",T6,{Parent:Error});function k6(W,X=(K)=>K.message){let K={},Y=[];for(let Q of W.issues)if(Q.path.length>0)K[Q.path[0]]=K[Q.path[0]]||[],K[Q.path[0]].push(X(Q));else Y.push(X(Q));return{formErrors:Y,fieldErrors:K}}function v6(W,X=(K)=>K.message){let K={_errors:[]},Y=(Q)=>{for(let q of Q.issues)if(q.code==="invalid_union"&&q.errors.length)q.errors.map((J)=>Y({issues:J}));else if(q.code==="invalid_key")Y({issues:q.issues});else if(q.code==="invalid_element")Y({issues:q.issues});else if(q.path.length===0)K._errors.push(X(q));else{let J=K,G=0;while(G<q.path.length){let H=q.path[G];if(G!==q.path.length-1)J[H]=J[H]||{_errors:[]};else J[H]=J[H]||{_errors:[]},J[H]._errors.push(X(q));J=J[H],G++}}};return Y(W),K}var N1=(W)=>(X,K,Y,Q)=>{let q=Y?Object.assign(Y,{async:!1}):{async:!1},J=X._zod.run({value:K,issues:[]},q);if(J instanceof Promise)throw new M0;if(J.issues.length){let G=new(Q?.Err??W)(J.issues.map((H)=>U0(H,q,J0())));throw M1(G,Q?.callee),G}return J.value};var V1=(W)=>async(X,K,Y,Q)=>{let q=Y?Object.assign(Y,{async:!0}):{async:!0},J=X._zod.run({value:K,issues:[]},q);if(J instanceof Promise)J=await J;if(J.issues.length){let G=new(Q?.Err??W)(J.issues.map((H)=>U0(H,q,J0())));throw M1(G,Q?.callee),G}return J.value};var o0=(W)=>(X,K,Y)=>{let Q=Y?{...Y,async:!1}:{async:!1},q=X._zod.run({value:K,issues:[]},Q);if(q instanceof Promise)throw new M0;return q.issues.length?{success:!1,error:new(W??F1)(q.issues.map((J)=>U0(J,Q,J0())))}:{success:!0,data:q.value}},x6=o0(G9),r0=(W)=>async(X,K,Y)=>{let Q=Y?Object.assign(Y,{async:!0}):{async:!0},q=X._zod.run({value:K,issues:[]},Q);if(q instanceof Promise)q=await q;return q.issues.length?{success:!1,error:new W(q.issues.map((J)=>U0(J,Q,J0())))}:{success:!0,data:q.value}},h6=r0(G9),g6=(W)=>(X,K,Y)=>{let Q=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return N1(W)(X,K,Q)};var y6=(W)=>(X,K,Y)=>{return N1(W)(X,K,Y)};var f6=(W)=>async(X,K,Y)=>{let Q=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return V1(W)(X,K,Q)};var c6=(W)=>async(X,K,Y)=>{return V1(W)(X,K,Y)};var m6=(W)=>(X,K,Y)=>{let Q=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return o0(W)(X,K,Q)};var u6=(W)=>(X,K,Y)=>{return o0(W)(X,K,Y)};var p6=(W)=>async(X,K,Y)=>{let Q=Y?Object.assign(Y,{direction:"backward"}):{direction:"backward"};return r0(W)(X,K,Q)};var l6=(W)=>async(X,K,Y)=>{return r0(W)(X,K,Y)};var d6=/^[cC][^\s-]{8,}$/,o6=/^[0-9a-z]+$/,r6=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,i6=/^[0-9a-vA-V]{20}$/,n6=/^[A-Za-z0-9]{27}$/,t6=/^[a-zA-Z0-9_-]{21}$/,a6=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var s6=/^([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})$/,q9=(W)=>{if(!W)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}-${W}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var e6=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var QX="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function W8(){return new RegExp(QX,"u")}var X8=/^(?:(?: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])$/,K8=/^(([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 Y8=/^((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])$/,Q8=/^(([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])$/,G8=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,J9=/^[A-Za-z0-9_-]*$/;var q8=/^\+[1-9]\d{6,14}$/,J8="(?:(?:\\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])))",z8=new RegExp(`^${J8}$`);function B8(W){return typeof W.precision==="number"?W.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":W.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{${W.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function $8(W){return new RegExp(`^${B8(W)}$`)}function H8(W){let X=B8({precision:W.precision}),K=["Z"];if(W.local)K.push("");if(W.offset)K.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let Y=`${X}(?:${K.join("|")})`;return new RegExp(`^${J8}T(?:${Y})$`)}var U8=(W)=>{let X=W?`[\\s\\S]{${W?.minimum??0},${W?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${X}$`)};var L8=/^-?\d+$/,P1=/^-?\d+(?:\.\d+)?$/,w8=/^(?:true|false)$/i,D8=/^null$/i;var M8=/^[^A-Z]*$/,O8=/^[^a-z]*$/;var t=w("$ZodCheck",(W,X)=>{var K;W._zod??(W._zod={}),W._zod.def=X,(K=W._zod).onattach??(K.onattach=[])}),F8={number:"number",bigint:"bigint",object:"date"},z9=w("$ZodCheckLessThan",(W,X)=>{t.init(W,X);let K=F8[typeof X.value];W._zod.onattach.push((Y)=>{let Q=Y._zod.bag,q=(X.inclusive?Q.maximum:Q.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(X.value<q)if(X.inclusive)Q.maximum=X.value;else Q.exclusiveMaximum=X.value}),W._zod.check=(Y)=>{if(X.inclusive?Y.value<=X.value:Y.value<X.value)return;Y.issues.push({origin:K,code:"too_big",maximum:typeof X.value==="object"?X.value.getTime():X.value,input:Y.value,inclusive:X.inclusive,inst:W,continue:!X.abort})}}),B9=w("$ZodCheckGreaterThan",(W,X)=>{t.init(W,X);let K=F8[typeof X.value];W._zod.onattach.push((Y)=>{let Q=Y._zod.bag,q=(X.inclusive?Q.minimum:Q.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(X.value>q)if(X.inclusive)Q.minimum=X.value;else Q.exclusiveMinimum=X.value}),W._zod.check=(Y)=>{if(X.inclusive?Y.value>=X.value:Y.value>X.value)return;Y.issues.push({origin:K,code:"too_small",minimum:typeof X.value==="object"?X.value.getTime():X.value,input:Y.value,inclusive:X.inclusive,inst:W,continue:!X.abort})}}),N8=w("$ZodCheckMultipleOf",(W,X)=>{t.init(W,X),W._zod.onattach.push((K)=>{var Y;(Y=K._zod.bag).multipleOf??(Y.multipleOf=X.value)}),W._zod.check=(K)=>{if(typeof K.value!==typeof X.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof K.value==="bigint"?K.value%X.value===BigInt(0):s1(K.value,X.value)===0)return;K.issues.push({origin:typeof K.value,code:"not_multiple_of",divisor:X.value,input:K.value,inst:W,continue:!X.abort})}}),V8=w("$ZodCheckNumberFormat",(W,X)=>{t.init(W,X),X.format=X.format||"float64";let K=X.format?.includes("int"),Y=K?"int":"number",[Q,q]=Y9[X.format];W._zod.onattach.push((J)=>{let G=J._zod.bag;if(G.format=X.format,G.minimum=Q,G.maximum=q,K)G.pattern=L8}),W._zod.check=(J)=>{let G=J.value;if(K){if(!Number.isInteger(G)){J.issues.push({expected:Y,format:X.format,code:"invalid_type",continue:!1,input:G,inst:W});return}if(!Number.isSafeInteger(G)){if(G>0)J.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:Y,inclusive:!0,continue:!X.abort});else J.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:Y,inclusive:!0,continue:!X.abort});return}}if(G<Q)J.issues.push({origin:"number",input:G,code:"too_small",minimum:Q,inclusive:!0,inst:W,continue:!X.abort});if(G>q)J.issues.push({origin:"number",input:G,code:"too_big",maximum:q,inclusive:!0,inst:W,continue:!X.abort})}});var P8=w("$ZodCheckMaxLength",(W,X)=>{var K;t.init(W,X),(K=W._zod.def).when??(K.when=(Y)=>{let Q=Y.value;return!p0(Q)&&Q.length!==void 0}),W._zod.onattach.push((Y)=>{let Q=Y._zod.bag.maximum??Number.POSITIVE_INFINITY;if(X.maximum<Q)Y._zod.bag.maximum=X.maximum}),W._zod.check=(Y)=>{let Q=Y.value;if(Q.length<=X.maximum)return;let J=d0(Q);Y.issues.push({origin:J,code:"too_big",maximum:X.maximum,inclusive:!0,input:Q,inst:W,continue:!X.abort})}}),R8=w("$ZodCheckMinLength",(W,X)=>{var K;t.init(W,X),(K=W._zod.def).when??(K.when=(Y)=>{let Q=Y.value;return!p0(Q)&&Q.length!==void 0}),W._zod.onattach.push((Y)=>{let Q=Y._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(X.minimum>Q)Y._zod.bag.minimum=X.minimum}),W._zod.check=(Y)=>{let Q=Y.value;if(Q.length>=X.minimum)return;let J=d0(Q);Y.issues.push({origin:J,code:"too_small",minimum:X.minimum,inclusive:!0,input:Q,inst:W,continue:!X.abort})}}),Z8=w("$ZodCheckLengthEquals",(W,X)=>{var K;t.init(W,X),(K=W._zod.def).when??(K.when=(Y)=>{let Q=Y.value;return!p0(Q)&&Q.length!==void 0}),W._zod.onattach.push((Y)=>{let Q=Y._zod.bag;Q.minimum=X.length,Q.maximum=X.length,Q.length=X.length}),W._zod.check=(Y)=>{let Q=Y.value,q=Q.length;if(q===X.length)return;let J=d0(Q),G=q>X.length;Y.issues.push({origin:J,...G?{code:"too_big",maximum:X.length}:{code:"too_small",minimum:X.length},inclusive:!0,exact:!0,input:Y.value,inst:W,continue:!X.abort})}}),i0=w("$ZodCheckStringFormat",(W,X)=>{var K,Y;if(t.init(W,X),W._zod.onattach.push((Q)=>{let q=Q._zod.bag;if(q.format=X.format,X.pattern)q.patterns??(q.patterns=new Set),q.patterns.add(X.pattern)}),X.pattern)(K=W._zod).check??(K.check=(Q)=>{if(X.pattern.lastIndex=0,X.pattern.test(Q.value))return;Q.issues.push({origin:"string",code:"invalid_format",format:X.format,input:Q.value,...X.pattern?{pattern:X.pattern.toString()}:{},inst:W,continue:!X.abort})});else(Y=W._zod).check??(Y.check=()=>{})}),E8=w("$ZodCheckRegex",(W,X)=>{i0.init(W,X),W._zod.check=(K)=>{if(X.pattern.lastIndex=0,X.pattern.test(K.value))return;K.issues.push({origin:"string",code:"invalid_format",format:"regex",input:K.value,pattern:X.pattern.toString(),inst:W,continue:!X.abort})}}),I8=w("$ZodCheckLowerCase",(W,X)=>{X.pattern??(X.pattern=M8),i0.init(W,X)}),C8=w("$ZodCheckUpperCase",(W,X)=>{X.pattern??(X.pattern=O8),i0.init(W,X)}),_8=w("$ZodCheckIncludes",(W,X)=>{t.init(W,X);let K=F0(X.includes),Y=new RegExp(typeof X.position==="number"?`^.{${X.position}}${K}`:K);X.pattern=Y,W._zod.onattach.push((Q)=>{let q=Q._zod.bag;q.patterns??(q.patterns=new Set),q.patterns.add(Y)}),W._zod.check=(Q)=>{if(Q.value.includes(X.includes,X.position))return;Q.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:X.includes,input:Q.value,inst:W,continue:!X.abort})}}),S8=w("$ZodCheckStartsWith",(W,X)=>{t.init(W,X);let K=new RegExp(`^${F0(X.prefix)}.*`);X.pattern??(X.pattern=K),W._zod.onattach.push((Y)=>{let Q=Y._zod.bag;Q.patterns??(Q.patterns=new Set),Q.patterns.add(K)}),W._zod.check=(Y)=>{if(Y.value.startsWith(X.prefix))return;Y.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:X.prefix,input:Y.value,inst:W,continue:!X.abort})}}),A8=w("$ZodCheckEndsWith",(W,X)=>{t.init(W,X);let K=new RegExp(`.*${F0(X.suffix)}$`);X.pattern??(X.pattern=K),W._zod.onattach.push((Y)=>{let Q=Y._zod.bag;Q.patterns??(Q.patterns=new Set),Q.patterns.add(K)}),W._zod.check=(Y)=>{if(Y.value.endsWith(X.suffix))return;Y.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:X.suffix,input:Y.value,inst:W,continue:!X.abort})}});var j8=w("$ZodCheckOverwrite",(W,X)=>{t.init(W,X),W._zod.check=(K)=>{K.value=X.tx(K.value)}});class $9{constructor(W=[]){if(this.content=[],this.indent=0,this)this.args=W}indented(W){this.indent+=1,W(this),this.indent-=1}write(W){if(typeof W==="function"){W(this,{execution:"sync"}),W(this,{execution:"async"});return}let K=W.split(`
8
- `).filter((q)=>q),Y=Math.min(...K.map((q)=>q.length-q.trimStart().length)),Q=K.map((q)=>q.slice(Y)).map((q)=>" ".repeat(this.indent*2)+q);for(let q of Q)this.content.push(q)}compile(){let W=Function,X=this?.args,Y=[...(this?.content??[""]).map((Q)=>` ${Q}`)];return new W(...X,Y.join(`
9
- `))}}var T8={major:4,minor:3,patch:6};var v=w("$ZodType",(W,X)=>{var K;W??(W={}),W._zod.def=X,W._zod.bag=W._zod.bag||{},W._zod.version=T8;let Y=[...W._zod.def.checks??[]];if(W._zod.traits.has("$ZodCheck"))Y.unshift(W);for(let Q of Y)for(let q of Q._zod.onattach)q(W);if(Y.length===0)(K=W._zod).deferred??(K.deferred=[]),W._zod.deferred?.push(()=>{W._zod.run=W._zod.parse});else{let Q=(J,G,H)=>{let D=E0(J),F;for(let N of G){if(N._zod.def.when){if(!N._zod.def.when(J))continue}else if(D)continue;let E=J.issues.length,R=N._zod.check(J);if(R instanceof Promise&&H?.async===!1)throw new M0;if(F||R instanceof Promise)F=(F??Promise.resolve()).then(async()=>{if(await R,J.issues.length===E)return;if(!D)D=E0(J,E)});else{if(J.issues.length===E)continue;if(!D)D=E0(J,E)}}if(F)return F.then(()=>{return J});return J},q=(J,G,H)=>{if(E0(J))return J.aborted=!0,J;let D=Q(G,Y,H);if(D instanceof Promise){if(H.async===!1)throw new M0;return D.then((F)=>W._zod.parse(F,H))}return W._zod.parse(D,H)};W._zod.run=(J,G)=>{if(G.skipChecks)return W._zod.parse(J,G);if(G.direction==="backward"){let D=W._zod.parse({value:J.value,issues:[]},{...G,skipChecks:!0});if(D instanceof Promise)return D.then((F)=>{return q(F,J,G)});return q(D,J,G)}let H=W._zod.parse(J,G);if(H instanceof Promise){if(G.async===!1)throw new M0;return H.then((D)=>Q(D,Y,G))}return Q(H,Y,G)}}b(W,"~standard",()=>({validate:(Q)=>{try{let q=x6(W,Q);return q.success?{value:q.data}:{issues:q.error?.issues}}catch(q){return h6(W,Q).then((J)=>J.success?{value:J.data}:{issues:J.error?.issues})}},vendor:"zod",version:1}))}),I1=w("$ZodString",(W,X)=>{v.init(W,X),W._zod.pattern=[...W?._zod.bag?.patterns??[]].pop()??U8(W._zod.bag),W._zod.parse=(K,Y)=>{if(X.coerce)try{K.value=String(K.value)}catch(Q){}if(typeof K.value==="string")return K;return K.issues.push({expected:"string",code:"invalid_type",input:K.value,inst:W}),K}}),x=w("$ZodStringFormat",(W,X)=>{i0.init(W,X),I1.init(W,X)}),m8=w("$ZodGUID",(W,X)=>{X.pattern??(X.pattern=s6),x.init(W,X)}),u8=w("$ZodUUID",(W,X)=>{if(X.version){let Y={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[X.version];if(Y===void 0)throw Error(`Invalid UUID version: "${X.version}"`);X.pattern??(X.pattern=q9(Y))}else X.pattern??(X.pattern=q9());x.init(W,X)}),p8=w("$ZodEmail",(W,X)=>{X.pattern??(X.pattern=e6),x.init(W,X)}),l8=w("$ZodURL",(W,X)=>{x.init(W,X),W._zod.check=(K)=>{try{let Y=K.value.trim(),Q=new URL(Y);if(X.hostname){if(X.hostname.lastIndex=0,!X.hostname.test(Q.hostname))K.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:X.hostname.source,input:K.value,inst:W,continue:!X.abort})}if(X.protocol){if(X.protocol.lastIndex=0,!X.protocol.test(Q.protocol.endsWith(":")?Q.protocol.slice(0,-1):Q.protocol))K.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:X.protocol.source,input:K.value,inst:W,continue:!X.abort})}if(X.normalize)K.value=Q.href;else K.value=Y;return}catch(Y){K.issues.push({code:"invalid_format",format:"url",input:K.value,inst:W,continue:!X.abort})}}}),d8=w("$ZodEmoji",(W,X)=>{X.pattern??(X.pattern=W8()),x.init(W,X)}),o8=w("$ZodNanoID",(W,X)=>{X.pattern??(X.pattern=t6),x.init(W,X)}),r8=w("$ZodCUID",(W,X)=>{X.pattern??(X.pattern=d6),x.init(W,X)}),i8=w("$ZodCUID2",(W,X)=>{X.pattern??(X.pattern=o6),x.init(W,X)}),n8=w("$ZodULID",(W,X)=>{X.pattern??(X.pattern=r6),x.init(W,X)}),t8=w("$ZodXID",(W,X)=>{X.pattern??(X.pattern=i6),x.init(W,X)}),a8=w("$ZodKSUID",(W,X)=>{X.pattern??(X.pattern=n6),x.init(W,X)}),s8=w("$ZodISODateTime",(W,X)=>{X.pattern??(X.pattern=H8(X)),x.init(W,X)}),e8=w("$ZodISODate",(W,X)=>{X.pattern??(X.pattern=z8),x.init(W,X)}),W4=w("$ZodISOTime",(W,X)=>{X.pattern??(X.pattern=$8(X)),x.init(W,X)}),X4=w("$ZodISODuration",(W,X)=>{X.pattern??(X.pattern=a6),x.init(W,X)}),K4=w("$ZodIPv4",(W,X)=>{X.pattern??(X.pattern=X8),x.init(W,X),W._zod.bag.format="ipv4"}),Y4=w("$ZodIPv6",(W,X)=>{X.pattern??(X.pattern=K8),x.init(W,X),W._zod.bag.format="ipv6",W._zod.check=(K)=>{try{new URL(`http://[${K.value}]`)}catch{K.issues.push({code:"invalid_format",format:"ipv6",input:K.value,inst:W,continue:!X.abort})}}});var Q4=w("$ZodCIDRv4",(W,X)=>{X.pattern??(X.pattern=Y8),x.init(W,X)}),G4=w("$ZodCIDRv6",(W,X)=>{X.pattern??(X.pattern=Q8),x.init(W,X),W._zod.check=(K)=>{let Y=K.value.split("/");try{if(Y.length!==2)throw Error();let[Q,q]=Y;if(!q)throw Error();let J=Number(q);if(`${J}`!==q)throw Error();if(J<0||J>128)throw Error();new URL(`http://[${Q}]`)}catch{K.issues.push({code:"invalid_format",format:"cidrv6",input:K.value,inst:W,continue:!X.abort})}}});function q4(W){if(W==="")return!0;if(W.length%4!==0)return!1;try{return atob(W),!0}catch{return!1}}var J4=w("$ZodBase64",(W,X)=>{X.pattern??(X.pattern=G8),x.init(W,X),W._zod.bag.contentEncoding="base64",W._zod.check=(K)=>{if(q4(K.value))return;K.issues.push({code:"invalid_format",format:"base64",input:K.value,inst:W,continue:!X.abort})}});function GX(W){if(!J9.test(W))return!1;let X=W.replace(/[-_]/g,(Y)=>Y==="-"?"+":"/"),K=X.padEnd(Math.ceil(X.length/4)*4,"=");return q4(K)}var z4=w("$ZodBase64URL",(W,X)=>{X.pattern??(X.pattern=J9),x.init(W,X),W._zod.bag.contentEncoding="base64url",W._zod.check=(K)=>{if(GX(K.value))return;K.issues.push({code:"invalid_format",format:"base64url",input:K.value,inst:W,continue:!X.abort})}}),B4=w("$ZodE164",(W,X)=>{X.pattern??(X.pattern=q8),x.init(W,X)});function qX(W,X=null){try{let K=W.split(".");if(K.length!==3)return!1;let[Y]=K;if(!Y)return!1;let Q=JSON.parse(atob(Y));if("typ"in Q&&Q?.typ!=="JWT")return!1;if(!Q.alg)return!1;if(X&&(!("alg"in Q)||Q.alg!==X))return!1;return!0}catch{return!1}}var $4=w("$ZodJWT",(W,X)=>{x.init(W,X),W._zod.check=(K)=>{if(qX(K.value,X.alg))return;K.issues.push({code:"invalid_format",format:"jwt",input:K.value,inst:W,continue:!X.abort})}});var U9=w("$ZodNumber",(W,X)=>{v.init(W,X),W._zod.pattern=W._zod.bag.pattern??P1,W._zod.parse=(K,Y)=>{if(X.coerce)try{K.value=Number(K.value)}catch(J){}let Q=K.value;if(typeof Q==="number"&&!Number.isNaN(Q)&&Number.isFinite(Q))return K;let q=typeof Q==="number"?Number.isNaN(Q)?"NaN":!Number.isFinite(Q)?"Infinity":void 0:void 0;return K.issues.push({expected:"number",code:"invalid_type",input:Q,inst:W,...q?{received:q}:{}}),K}}),H4=w("$ZodNumberFormat",(W,X)=>{V8.init(W,X),U9.init(W,X)}),U4=w("$ZodBoolean",(W,X)=>{v.init(W,X),W._zod.pattern=w8,W._zod.parse=(K,Y)=>{if(X.coerce)try{K.value=Boolean(K.value)}catch(q){}let Q=K.value;if(typeof Q==="boolean")return K;return K.issues.push({expected:"boolean",code:"invalid_type",input:Q,inst:W}),K}});var L4=w("$ZodNull",(W,X)=>{v.init(W,X),W._zod.pattern=D8,W._zod.values=new Set([null]),W._zod.parse=(K,Y)=>{let Q=K.value;if(Q===null)return K;return K.issues.push({expected:"null",code:"invalid_type",input:Q,inst:W}),K}});var w4=w("$ZodUnknown",(W,X)=>{v.init(W,X),W._zod.parse=(K)=>K}),D4=w("$ZodNever",(W,X)=>{v.init(W,X),W._zod.parse=(K,Y)=>{return K.issues.push({expected:"never",code:"invalid_type",input:K.value,inst:W}),K}});function k8(W,X,K){if(W.issues.length)X.issues.push(...N0(K,W.issues));X.value[K]=W.value}var M4=w("$ZodArray",(W,X)=>{v.init(W,X),W._zod.parse=(K,Y)=>{let Q=K.value;if(!Array.isArray(Q))return K.issues.push({expected:"array",code:"invalid_type",input:Q,inst:W}),K;K.value=Array(Q.length);let q=[];for(let J=0;J<Q.length;J++){let G=Q[J],H=X.element._zod.run({value:G,issues:[]},Y);if(H instanceof Promise)q.push(H.then((D)=>k8(D,K,J)));else k8(H,K,J)}if(q.length)return Promise.all(q).then(()=>K);return K}});function E1(W,X,K,Y,Q){if(W.issues.length){if(Q&&!(K in Y))return;X.issues.push(...N0(K,W.issues))}if(W.value===void 0){if(K in Y)X.value[K]=void 0}else X.value[K]=W.value}function O4(W){let X=Object.keys(W.shape);for(let Y of X)if(!W.shape?.[Y]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${Y}": expected a Zod schema`);let K=K9(W.shape);return{...W,keys:X,keySet:new Set(X),numKeys:X.length,optionalKeys:new Set(K)}}function F4(W,X,K,Y,Q,q){let J=[],G=Q.keySet,H=Q.catchall._zod,D=H.def.type,F=H.optout==="optional";for(let N in X){if(G.has(N))continue;if(D==="never"){J.push(N);continue}let E=H.run({value:X[N],issues:[]},Y);if(E instanceof Promise)W.push(E.then((R)=>E1(R,K,N,X,F)));else E1(E,K,N,X,F)}if(J.length)K.issues.push({code:"unrecognized_keys",keys:J,input:X,inst:q});if(!W.length)return K;return Promise.all(W).then(()=>{return K})}var JX=w("$ZodObject",(W,X)=>{if(v.init(W,X),!Object.getOwnPropertyDescriptor(X,"shape")?.get){let G=X.shape;Object.defineProperty(X,"shape",{get:()=>{let H={...G};return Object.defineProperty(X,"shape",{value:H}),H}})}let Y=v0(()=>O4(X));b(W._zod,"propValues",()=>{let G=X.shape,H={};for(let D in G){let F=G[D]._zod;if(F.values){H[D]??(H[D]=new Set);for(let N of F.values)H[D].add(N)}}return H});let Q=S0,q=X.catchall,J;W._zod.parse=(G,H)=>{J??(J=Y.value);let D=G.value;if(!Q(D))return G.issues.push({expected:"object",code:"invalid_type",input:D,inst:W}),G;G.value={};let F=[],N=J.shape;for(let E of J.keys){let R=N[E],o=R._zod.optout==="optional",l=R._zod.run({value:D[E],issues:[]},H);if(l instanceof Promise)F.push(l.then((M)=>E1(M,G,E,D,o)));else E1(l,G,E,D,o)}if(!q)return F.length?Promise.all(F).then(()=>G):G;return F4(F,D,G,H,Y.value,W)}}),N4=w("$ZodObjectJIT",(W,X)=>{JX.init(W,X);let K=W._zod.parse,Y=v0(()=>O4(X)),Q=(E)=>{let R=new $9(["shape","payload","ctx"]),o=Y.value,l=(K0)=>{let n=D1(K0);return`shape[${n}]._zod.run({ value: input[${n}], issues: [] }, ctx)`};R.write("const input = payload.value;");let M=Object.create(null),J1=0;for(let K0 of o.keys)M[K0]=`key_${J1++}`;R.write("const newResult = {};");for(let K0 of o.keys){let n=M[K0],Y0=D1(K0),B1=E[K0]?._zod?.optout==="optional";if(R.write(`const ${n} = ${l(K0)};`),B1)R.write(`
10
- if (${n}.issues.length) {
11
- if (${Y0} in input) {
12
- payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
6
+ Lifetime used`):new X4("Lifetime not alive")}},T0=class extends X0{constructor(W,X){super(W,void 0,void 0,X)}get dupable(){return!0}dup(){return this}dispose(){}},X3=class extends X0{constructor(W,X,Y,Q){super(W,X,Y,Q)}dispose(){this._alive=!1}};D0=class W extends V0{constructor(){super(...arguments);this._disposables=new X0(new Set),this.manage=(X)=>(this._disposables.value.add(X),X)}static withScope(X){let Y=new W,Q;try{return X(Y)}catch(K){throw Q=K,K}finally{s9(Y,Q)}}static withScopeMaybeAsync(X,Y){return F7(void 0,function*(Q){let K=new W,q;try{return yield*Q.of(Y.call(X,Q,K))}catch(J){throw q=J,J}finally{s9(K,q)}})}static async withScopeAsync(X){let Y=new W,Q;try{return await X(Y)}catch(K){throw Q=K,K}finally{s9(Y,Q)}}get alive(){return this._disposables.alive}dispose(){let X=Array.from(this._disposables.value.values()).reverse();for(let Y of X)Y.alive&&Y.dispose();this._disposables.dispose()}};q4=class W extends V0{static success(X){return new V7(X)}static fail(X,Y){return new N7(X,Y)}static is(X){return X instanceof W}},V7=class extends q4{constructor(W){super();this.value=W}get alive(){return l1(this.value)?this.value.alive:!0}dispose(){l1(this.value)&&this.value.dispose()}unwrap(){return this.value}unwrapOr(W){return this.value}},N7=class extends q4{constructor(W,X){super();this.error=W,this.onUnwrap=X}get alive(){return l1(this.error)?this.error.alive:!0}dispose(){l1(this.error)&&this.error.dispose()}unwrap(){throw this.onUnwrap(this),this.error}unwrapOr(W){return W}},m0=q4,P7=class extends V0{constructor(W){super();this.resolve=(X)=>{this.resolveHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.resolveHandle,this.context.undefined,X||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.reject=(X)=>{this.rejectHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.rejectHandle,this.context.undefined,X||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.dispose=()=>{this.handle.alive&&this.handle.dispose(),this.disposeResolvers()},this.context=W.context,this.owner=W.context.runtime,this.handle=W.promiseHandle,this.settled=new Promise((X)=>{this.onSettled=X}),this.resolveHandle=W.resolveHandle,this.rejectHandle=W.rejectHandle}get alive(){return this.handle.alive||this.resolveHandle.alive||this.rejectHandle.alive}disposeResolvers(){this.resolveHandle.alive&&this.resolveHandle.dispose(),this.rejectHandle.alive&&this.rejectHandle.dispose()}},ZG=Symbol("Unstable"),RG=Object.freeze({BaseObjects:!0,Date:!0,Eval:!0,StringNormalize:!0,RegExp:!0,JSON:!0,Proxy:!0,MapSet:!0,TypedArrays:!0,Promise:!0});C7=class extends V0{constructor(W,X){super();this.handle=W,this.context=X,this._isDone=!1,this.owner=X.runtime}[Symbol.iterator](){return this}next(W){if(!this.alive||this._isDone)return{done:!0,value:void 0};let X=this._next??(this._next=this.context.getProp(this.handle,"next"));return this.callIteratorMethod(X,W)}return(W){if(!this.alive)return{done:!0,value:void 0};let X=this.context.getProp(this.handle,"return");if(X===this.context.undefined&&W===void 0)return this.dispose(),{done:!0,value:void 0};let Y=this.callIteratorMethod(X,W);return X.dispose(),this.dispose(),Y}throw(W){if(!this.alive)return{done:!0,value:void 0};let X=W instanceof X0?W:this.context.newError(W),Y=this.context.getProp(this.handle,"throw"),Q=this.callIteratorMethod(Y,W);return X.alive&&X.dispose(),Y.dispose(),this.dispose(),Q}get alive(){return this.handle.alive}dispose(){this._isDone=!0,this.handle.dispose(),this._next?.dispose()}callIteratorMethod(W,X){let Y=X?this.context.callFunction(W,this.handle,X):this.context.callFunction(W,this.handle);if(Y.error)return this.dispose(),{value:Y};let Q=this.context.getProp(Y.value,"done").consume((q)=>this.context.dump(q)),K=this.context.getProp(Y.value,"value");return Y.value.dispose(),Q&&this.dispose(),{value:m0.success(K),done:Q}}};K3=class extends V0{constructor(W,X,Y){if(Y===p1)throw new C0("cannot create HostRef with undefined id");super();this.runtime=W,this.handle=X,this.id=Y}get alive(){return this.handle.alive}dispose(){this.handle.dispose()}get value(){return this.runtime.hostRefs.get(this.id)}},A7=class extends D3{constructor(W){super(W.module);this.scope=new D0,this.copyJSValue=(X)=>this.ffi.QTS_DupValuePointer(this.ctx.value,X),this.freeJSValue=(X)=>{this.ffi.QTS_FreeValuePointer(this.ctx.value,X)},W.ownedLifetimes?.forEach((X)=>this.scope.manage(X)),this.owner=W.owner,this.module=W.module,this.ffi=W.ffi,this.rt=W.rt,this.ctx=this.scope.manage(W.ctx)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}[Symbol.dispose](){return this.dispose()}manage(W){return this.scope.manage(W)}consumeJSCharPointer(W){let X=this.module.UTF8ToString(W);return this.ffi.QTS_FreeCString(this.ctx.value,W),X}heapValueHandle(W,X){let Y=X?(Q)=>{X(),this.freeJSValue(Q)}:this.freeJSValue;return new X0(W,this.copyJSValue,Y,this.owner)}staticHeapValueHandle(W){return this.manage(this.heapValueHandle(W)),new T0(W,this.owner)}},j7=class extends V0{constructor(W){super();this._undefined=void 0,this._null=void 0,this._false=void 0,this._true=void 0,this._global=void 0,this._BigInt=void 0,this._Symbol=void 0,this._SymbolIterator=void 0,this._SymbolAsyncIterator=void 0,this.cToHostCallbacks={callFunction:(X,Y,Q,K,q)=>{if(X!==this.ctx.value)throw Error("QuickJSContext instance received C -> JS call with mismatched ctx");let J=this.getFunction(q);return D0.withScopeMaybeAsync(this,function*(G,H){let D=H.manage(new X3(Y,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime)),O=Array(Q);for(let V=0;V<Q;V++){let R=this.ffi.QTS_ArgvGetJSValueConstPointer(K,V);O[V]=H.manage(new X3(R,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime))}try{let V=yield*G(J.apply(D,O));if(V){if("error"in V&&V.error)throw this.runtime.debugLog("throw error",V.error),V.error;let R=H.manage(V instanceof X0?V:V.value);return this.ffi.QTS_DupValuePointer(this.ctx.value,R.value)}return 0}catch(V){return this.errorToHandle(V).consume((R)=>this.ffi.QTS_Throw(this.ctx.value,R.value))}})}},this.runtime=W.runtime,this.module=W.module,this.ffi=W.ffi,this.rt=W.rt,this.ctx=W.ctx,this.memory=new A7({...W,owner:this.runtime}),W.callbacks.setContextCallbacks(this.ctx.value,this.cToHostCallbacks),this.dump=this.dump.bind(this),this.getString=this.getString.bind(this),this.getNumber=this.getNumber.bind(this),this.resolvePromise=this.resolvePromise.bind(this),this.uint32Out=this.memory.manage(this.memory.newTypedArray(Uint32Array,1))}get alive(){return this.memory.alive}dispose(){this.memory.dispose()}get undefined(){if(this._undefined)return this._undefined;let W=this.ffi.QTS_GetUndefined();return this._undefined=new T0(W)}get null(){if(this._null)return this._null;let W=this.ffi.QTS_GetNull();return this._null=new T0(W)}get true(){if(this._true)return this._true;let W=this.ffi.QTS_GetTrue();return this._true=new T0(W)}get false(){if(this._false)return this._false;let W=this.ffi.QTS_GetFalse();return this._false=new T0(W)}get global(){if(this._global)return this._global;let W=this.ffi.QTS_GetGlobalObject(this.ctx.value);return this._global=this.memory.staticHeapValueHandle(W),this._global}newNumber(W){return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value,W))}newString(W){let X=this.memory.newHeapCharPointer(W).consume((Y)=>this.ffi.QTS_NewString(this.ctx.value,Y.value.ptr));return this.memory.heapValueHandle(X)}newUniqueSymbol(W){let X=(typeof W=="symbol"?W.description:W)??"",Y=this.memory.newHeapCharPointer(X).consume((Q)=>this.ffi.QTS_NewSymbol(this.ctx.value,Q.value.ptr,0));return this.memory.heapValueHandle(Y)}newSymbolFor(W){let X=(typeof W=="symbol"?W.description:W)??"",Y=this.memory.newHeapCharPointer(X).consume((Q)=>this.ffi.QTS_NewSymbol(this.ctx.value,Q.value.ptr,1));return this.memory.heapValueHandle(Y)}getWellKnownSymbol(W){return this._Symbol??(this._Symbol=this.memory.manage(this.getProp(this.global,"Symbol"))),this.getProp(this._Symbol,W)}newBigInt(W){if(!this._BigInt){let Q=this.getProp(this.global,"BigInt");this.memory.manage(Q),this._BigInt=new T0(Q.value,this.runtime)}let X=this._BigInt,Y=String(W);return this.newString(Y).consume((Q)=>this.unwrapResult(this.callFunction(X,this.undefined,Q)))}newObject(W){W&&this.runtime.assertOwned(W);let X=W?this.ffi.QTS_NewObjectProto(this.ctx.value,W.value):this.ffi.QTS_NewObject(this.ctx.value);return this.memory.heapValueHandle(X)}newArray(){let W=this.ffi.QTS_NewArray(this.ctx.value);return this.memory.heapValueHandle(W)}newArrayBuffer(W){let X=new Uint8Array(W),Y=this.memory.newHeapBufferPointer(X),Q=this.ffi.QTS_NewArrayBuffer(this.ctx.value,Y.value.pointer,X.length);return this.memory.heapValueHandle(Q)}newPromise(W){let X=D0.withScope((Y)=>{let Q=Y.manage(this.memory.newMutablePointerArray(2)),K=this.ffi.QTS_NewPromiseCapability(this.ctx.value,Q.value.ptr),q=this.memory.heapValueHandle(K),[J,G]=Array.from(Q.value.typedArray).map((H)=>this.memory.heapValueHandle(H));return new P7({context:this,promiseHandle:q,resolveHandle:J,rejectHandle:G})});return W&&typeof W=="function"&&(W=new Promise(W)),W&&Promise.resolve(W).then(X.resolve,(Y)=>Y instanceof X0?X.reject(Y):this.newError(Y).consume(X.reject)),X}newFunction(W,X){let Y=typeof W=="function"?W:X;if(!Y)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof W=="string"?W:void 0,length:Y.length,isConstructor:!1,fn:Y})}newConstructorFunction(W,X){let Y=typeof W=="function"?W:X;if(!Y)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof W=="string"?W:void 0,length:Y.length,isConstructor:!0,fn:Y})}newFunctionWithOptions(W){let{name:X,length:Y,isConstructor:Q,fn:K}=W,q=this.runtime.hostRefs.put(K);try{return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value,X??"",Y,Q,q))}catch(J){throw this.runtime.hostRefs.delete(q),J}}newError(W){let X=this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value));return W&&typeof W=="object"?(W.name!==void 0&&this.newString(W.name).consume((Y)=>this.setProp(X,"name",Y)),W.message!==void 0&&this.newString(W.message).consume((Y)=>this.setProp(X,"message",Y))):typeof W=="string"?this.newString(W).consume((Y)=>this.setProp(X,"message",Y)):W!==void 0&&this.newString(String(W)).consume((Y)=>this.setProp(X,"message",Y)),X}newHostRef(W){let X=this.runtime.hostRefs.put(W);try{let Y=this.memory.heapValueHandle(this.ffi.QTS_NewHostRef(this.ctx.value,X));return new K3(this.runtime,Y,X)}catch(Y){throw this.runtime.hostRefs.delete(X),Y}}toHostRef(W){let X=this.ffi.QTS_GetHostRefId(W.value);if(X!==0)return this.runtime.hostRefs.get(X),new K3(this.runtime,W.dup(),X)}unwrapHostRef(W){let X=this.ffi.QTS_GetHostRefId(W.value);if(X===0)throw new C0("handle is not a HostRef");return this.runtime.hostRefs.get(X)}typeof(W){return this.runtime.assertOwned(W),this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value,W.value))}getNumber(W){return this.runtime.assertOwned(W),this.ffi.QTS_GetFloat64(this.ctx.value,W.value)}getString(W){return this.runtime.assertOwned(W),this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value,W.value))}getSymbol(W){this.runtime.assertOwned(W);let X=this.memory.consumeJSCharPointer(this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value,W.value));return this.ffi.QTS_IsGlobalSymbol(this.ctx.value,W.value)?Symbol.for(X):Symbol(X)}getBigInt(W){this.runtime.assertOwned(W);let X=this.getString(W);return BigInt(X)}getArrayBuffer(W){this.runtime.assertOwned(W);let X=this.ffi.QTS_GetArrayBufferLength(this.ctx.value,W.value),Y=this.ffi.QTS_GetArrayBuffer(this.ctx.value,W.value);if(!Y)throw Error("Couldn't allocate memory to get ArrayBuffer");return new X0(this.module.HEAPU8.subarray(Y,Y+X),void 0,()=>this.module._free(Y))}getPromiseState(W){this.runtime.assertOwned(W);let X=this.ffi.QTS_PromiseState(this.ctx.value,W.value);if(X<0)return{type:"fulfilled",value:W,notAPromise:!0};if(X===m1.Pending)return{type:"pending",get error(){return new $3("Cannot unwrap a pending promise")}};let Y=this.ffi.QTS_PromiseResult(this.ctx.value,W.value),Q=this.memory.heapValueHandle(Y);if(X===m1.Fulfilled)return{type:"fulfilled",value:Q};if(X===m1.Rejected)return{type:"rejected",error:Q};throw Q.dispose(),Error(`Unknown JSPromiseStateEnum: ${X}`)}resolvePromise(W){this.runtime.assertOwned(W);let X=D0.withScope((Y)=>{let Q=Y.manage(this.getProp(this.global,"Promise")),K=Y.manage(this.getProp(Q,"resolve"));return this.callFunction(K,Q,W)});return X.error?Promise.resolve(X):new Promise((Y)=>{D0.withScope((Q)=>{let K=Q.manage(this.newFunction("resolve",(H)=>{Y(this.success(H&&H.dup()))})),q=Q.manage(this.newFunction("reject",(H)=>{Y(this.fail(H&&H.dup()))})),J=Q.manage(X.value),G=Q.manage(this.getProp(J,"then"));this.callFunction(G,J,K,q).unwrap().dispose()})})}isEqual(W,X,Y=$1.IsStrictlyEqual){if(W===X)return!0;this.runtime.assertOwned(W),this.runtime.assertOwned(X);let Q=this.ffi.QTS_IsEqual(this.ctx.value,W.value,X.value,Y);if(Q===-1)throw new q3("WASM variant does not expose equality");return!!Q}eq(W,X){return this.isEqual(W,X,$1.IsStrictlyEqual)}sameValue(W,X){return this.isEqual(W,X,$1.IsSameValue)}sameValueZero(W,X){return this.isEqual(W,X,$1.IsSameValueZero)}getProp(W,X){this.runtime.assertOwned(W);let Y;return typeof X=="number"&&X>=0?Y=this.ffi.QTS_GetPropNumber(this.ctx.value,W.value,X):Y=this.borrowPropertyKey(X).consume((Q)=>this.ffi.QTS_GetProp(this.ctx.value,W.value,Q.value)),this.memory.heapValueHandle(Y)}getLength(W){if(this.runtime.assertOwned(W),!(this.ffi.QTS_GetLength(this.ctx.value,this.uint32Out.value.ptr,W.value)<0))return this.uint32Out.value.typedArray[0]}getOwnPropertyNames(W,X={strings:!0,numbersAsStrings:!0}){this.runtime.assertOwned(W),W.value;let Y=E7(X);if(Y===0)throw new H3("No options set, will return an empty array");return D0.withScope((Q)=>{let K=Q.manage(this.memory.newMutablePointerArray(1)),q=this.ffi.QTS_GetOwnPropertyNames(this.ctx.value,K.value.ptr,this.uint32Out.value.ptr,W.value,Y);if(q)return this.fail(this.memory.heapValueHandle(q));let J=this.uint32Out.value.typedArray[0],G=K.value.typedArray[0],H=new Uint32Array(this.module.HEAP8.buffer,G,J),D=Array.from(H).map((O)=>this.memory.heapValueHandle(O));return this.ffi.QTS_FreeVoidPointer(this.ctx.value,G),this.success(O7(D))})}getIterator(W){let X=this._SymbolIterator??(this._SymbolIterator=this.memory.manage(this.getWellKnownSymbol("iterator")));return D0.withScope((Y)=>{let Q=Y.manage(this.getProp(W,X)),K=this.callFunction(Q,W);return K.error?K:this.success(new C7(K.value,this))})}setProp(W,X,Y){this.runtime.assertOwned(W),this.borrowPropertyKey(X).consume((Q)=>this.ffi.QTS_SetProp(this.ctx.value,W.value,Q.value,Y.value))}defineProp(W,X,Y){this.runtime.assertOwned(W),D0.withScope((Q)=>{let K=Q.manage(this.borrowPropertyKey(X)),q=Y.value||this.undefined,J=!!Y.configurable,G=!!Y.enumerable,H=!!Y.value,D=Y.get?Q.manage(this.newFunction(Y.get.name,Y.get)):this.undefined,O=Y.set?Q.manage(this.newFunction(Y.set.name,Y.set)):this.undefined;this.ffi.QTS_DefineProp(this.ctx.value,W.value,K.value,q.value,D.value,O.value,J,G,H)})}callFunction(W,X,...Y){this.runtime.assertOwned(W);let Q,K=Y[0];K===void 0||Array.isArray(K)?Q=K??[]:Q=Y;let q=this.memory.toPointerArray(Q).consume((G)=>this.ffi.QTS_Call(this.ctx.value,W.value,X.value,Q.length,G.value)),J=this.ffi.QTS_ResolveException(this.ctx.value,q);return J?(this.ffi.QTS_FreeValuePointer(this.ctx.value,q),this.fail(this.memory.heapValueHandle(J))):this.success(this.memory.heapValueHandle(q))}callMethod(W,X,Y=[]){return this.getProp(W,X).consume((Q)=>this.callFunction(Q,W,Y))}evalCode(W,X="eval.js",Y){let Q=Y===void 0?1:0,K=R7(Y),q=this.memory.newHeapCharPointer(W).consume((G)=>this.ffi.QTS_Eval(this.ctx.value,G.value.ptr,G.value.strlen,X,Q,K)),J=this.ffi.QTS_ResolveException(this.ctx.value,q);return J?(this.ffi.QTS_FreeValuePointer(this.ctx.value,q),this.fail(this.memory.heapValueHandle(J))):this.success(this.memory.heapValueHandle(q))}throw(W){return this.errorToHandle(W).consume((X)=>this.ffi.QTS_Throw(this.ctx.value,X.value))}borrowPropertyKey(W){return typeof W=="number"?this.newNumber(W):typeof W=="string"?this.newString(W):new T0(W.value,this.runtime)}getMemory(W){if(W===this.rt.value)return this.memory;throw Error("Private API. Cannot get memory from a different runtime")}dump(W){this.runtime.assertOwned(W);let X=this.typeof(W);if(X==="string")return this.getString(W);if(X==="number")return this.getNumber(W);if(X==="bigint")return this.getBigInt(W);if(X==="undefined")return;if(X==="symbol")return this.getSymbol(W);let Y=this.getPromiseState(W);if(Y.type==="fulfilled"&&!Y.notAPromise)return W.dispose(),{type:Y.type,value:Y.value.consume(this.dump)};if(Y.type==="pending")return W.dispose(),{type:Y.type};if(Y.type==="rejected")return W.dispose(),{type:Y.type,error:Y.error.consume(this.dump)};let Q=this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value,W.value));try{return JSON.parse(Q)}catch{return Q}}unwrapResult(W){if(W.error){let X="context"in W.error?W.error.context:this,Y=W.error.consume((Q)=>this.dump(Q));if(Y&&typeof Y=="object"&&typeof Y.message=="string"){let{message:Q,name:K,stack:q,...J}=Y,G=new W4(Y,X);typeof K=="string"&&(G.name=Y.name),G.message=Q;let H=G.stack;throw typeof q=="string"&&(G.stack=`${K}: ${Q}
7
+ ${Y.stack}Host: ${H}`),Object.assign(G,J),G}throw new W4(Y)}return W.value}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { ctx: ${this.ctx.value} rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getFunction(W){let X=this.runtime.hostRefs.get(W);if(typeof X!="function")throw Error(`Host reference ${W} is not a function`);return X}errorToHandle(W){return W instanceof X0?W:this.newError(W)}encodeBinaryJSON(W){let X=this.ffi.QTS_bjson_encode(this.ctx.value,W.value);return this.memory.heapValueHandle(X)}decodeBinaryJSON(W){let X=this.ffi.QTS_bjson_decode(this.ctx.value,W.value);return this.memory.heapValueHandle(X)}success(W){return m0.success(W)}fail(W){return m0.fail(W,(X)=>this.unwrapResult(X))}},S7=class extends V0{constructor(W){super();this.scope=new D0,this.contextMap=new Map,this.hostRefs=new _7,this._debugMode=!1,this.cToHostCallbacks={freeHostRef:(X,Y)=>{if(X!==this.rt.value)throw Error("Runtime pointer mismatch");this.hostRefs.delete(Y)},shouldInterrupt:(X)=>{if(X!==this.rt.value)throw Error("QuickJSContext instance received C -> JS interrupt with mismatched rt");let Y=this.interruptHandler;if(!Y)throw Error("QuickJSContext had no interrupt handler");return Y(this)?1:0},loadModuleSource:eW(this,function*(X,Y,Q,K){let q=this.moduleLoader;if(!q)throw Error("Runtime has no module loader");if(Y!==this.rt.value)throw Error("Runtime pointer mismatch");let J=this.contextMap.get(Q)??this.newContext({contextPointer:Q});try{let G=yield*X(q(K,J));if(typeof G=="object"&&"error"in G&&G.error)throw this.debugLog("cToHostLoadModule: loader returned error",G.error),G.error;let H=typeof G=="string"?G:("value"in G)?G.value:G;return this.memory.newHeapCharPointer(H).value.ptr}catch(G){return this.debugLog("cToHostLoadModule: caught error",G),J.throw(G),0}}),normalizeModule:eW(this,function*(X,Y,Q,K,q){let J=this.moduleNormalizer;if(!J)throw Error("Runtime has no module normalizer");if(Y!==this.rt.value)throw Error("Runtime pointer mismatch");let G=this.contextMap.get(Q)??this.newContext({contextPointer:Q});try{let H=yield*X(J(K,q,G));if(typeof H=="object"&&"error"in H&&H.error)throw this.debugLog("cToHostNormalizeModule: normalizer returned error",H.error),H.error;let D=typeof H=="string"?H:H.value;return G.getMemory(this.rt.value).newHeapCharPointer(D).value.ptr}catch(H){return this.debugLog("normalizeModule: caught error",H),G.throw(H),0}})},W.ownedLifetimes?.forEach((X)=>this.scope.manage(X)),this.module=W.module,this.memory=new D3(this.module),this.ffi=W.ffi,this.rt=W.rt,this.callbacks=W.callbacks,this.scope.manage(this.rt),this.callbacks.setRuntimeCallbacks(this.rt.value,this.cToHostCallbacks),this.executePendingJobs=this.executePendingJobs.bind(this),Q4&&this.setDebugMode(!0)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}newContext(W={}){let X=Z7(W.intrinsics),Y=new X0(W.contextPointer||this.ffi.QTS_NewContext(this.rt.value,X),void 0,(K)=>{this.contextMap.delete(K),this.callbacks.deleteContext(K),this.ffi.QTS_FreeContext(K)}),Q=new j7({module:this.module,ctx:Y,ffi:this.ffi,rt:this.rt,ownedLifetimes:W.ownedLifetimes,runtime:this,callbacks:this.callbacks});return this.contextMap.set(Y.value,Q),Q}setModuleLoader(W,X){this.moduleLoader=W,this.moduleNormalizer=X,this.ffi.QTS_RuntimeEnableModuleLoader(this.rt.value,this.moduleNormalizer?1:0)}removeModuleLoader(){this.moduleLoader=void 0,this.ffi.QTS_RuntimeDisableModuleLoader(this.rt.value)}hasPendingJob(){return!!this.ffi.QTS_IsJobPending(this.rt.value)}setInterruptHandler(W){let X=this.interruptHandler;this.interruptHandler=W,X||this.ffi.QTS_RuntimeEnableInterruptHandler(this.rt.value)}removeInterruptHandler(){this.interruptHandler&&(this.ffi.QTS_RuntimeDisableInterruptHandler(this.rt.value),this.interruptHandler=void 0)}executePendingJobs(W=-1){let X=this.memory.newMutablePointerArray(1),Y=this.ffi.QTS_ExecutePendingJob(this.rt.value,W??-1,X.value.ptr),Q=X.value.typedArray[0];if(X.dispose(),Q===0)return this.ffi.QTS_FreeValuePointerRuntime(this.rt.value,Y),m0.success(0);let K=this.contextMap.get(Q)??this.newContext({contextPointer:Q}),q=K.getMemory(this.rt.value).heapValueHandle(Y);if(K.typeof(q)==="number"){let J=K.getNumber(q);return q.dispose(),m0.success(J)}else{let J=Object.assign(q,{context:K});return m0.fail(J,(G)=>K.unwrapResult(G))}}setMemoryLimit(W){if(W<0&&W!==-1)throw Error("Cannot set memory limit to negative number. To unset, pass -1");this.ffi.QTS_RuntimeSetMemoryLimit(this.rt.value,W)}computeMemoryUsage(){let W=this.getSystemContext().getMemory(this.rt.value);return W.heapValueHandle(this.ffi.QTS_RuntimeComputeMemoryUsage(this.rt.value,W.ctx.value))}dumpMemoryUsage(){return this.memory.consumeHeapCharPointer(this.ffi.QTS_RuntimeDumpMemoryUsage(this.rt.value))}setMaxStackSize(W){if(W<0)throw Error("Cannot set memory limit to negative number. To unset, pass 0.");this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value,W)}assertOwned(W){if(W.owner&&W.owner.rt!==this.rt)throw new G3(`Handle is not owned by this runtime: ${W.owner.rt.value} != ${this.rt.value}`)}setDebugMode(W){this._debugMode=W,this.ffi.DEBUG&&this.rt.alive&&this.ffi.QTS_SetDebugLogEnabled(this.rt.value,W?1:0)}isDebugMode(){return this._debugMode}debugLog(...W){this._debugMode&&console.log("quickjs-emscripten:",...W)}[Symbol.for("nodejs.util.inspect.custom")](){return this.alive?`${this.constructor.name} { rt: ${this.rt.value} }`:`${this.constructor.name} { disposed }`}getSystemContext(){return this.context||(this.context=this.scope.manage(this.newContext())),this.context}}});var F3={};a1(F3,{applyModuleEvalRuntimeOptions:()=>B4,applyBaseRuntimeOptions:()=>z4,QuickJSWASMModule:()=>w3,QuickJSModuleCallbacks:()=>J4});var O3=s1(()=>{M3()});var E3=g3((d1,R3)=>{(function(W,X){typeof d1==="object"&&typeof R3<"u"?X(d1):typeof define==="function"&&define.amd?define(["exports"],X):(W=typeof globalThis<"u"?globalThis:W||self,X(W.jmespath={}))})(d1,function(W){let X=(z)=>{return z!==null&&Object.prototype.toString.call(z)==="[object Object]"},Y=(z,B)=>{if(z===B)return!0;if(typeof z!==typeof B)return!1;if(Array.isArray(z)&&Array.isArray(B)){if(z.length!==B.length)return!1;for(let $=0;$<z.length;$+=1)if(!Y(z[$],B[$]))return!1;return!0}if(X(z)&&X(B)){let $=Object.entries(z),L=new Set(Object.keys(B));if($.length!==L.size)return!1;for(let[F,N]of $){if(!Y(N,B[F]))return!1;L.delete(F)}return L.size===0}return!1},Q=(z)=>{if(z===""||z===!1||z===null||z===void 0)return!0;if(Array.isArray(z)&&z.length===0)return!0;if(X(z)){for(let B in z)if(z.hasOwnProperty(B))return!1;return!0}return!1},K=(z)=>{return z>="a"&&z<="z"||z>="A"&&z<="Z"||z==="_"},q=(z)=>{return z>="0"&&z<="9"||z==="-"},J=(z)=>{return z>="a"&&z<="z"||z>="A"&&z<="Z"||z>="0"&&z<="9"||z==="_"};var G;(function(z){z.TOK_EOF="EOF",z.TOK_UNQUOTEDIDENTIFIER="UnquotedIdentifier",z.TOK_QUOTEDIDENTIFIER="QuotedIdentifier",z.TOK_RBRACKET="Rbracket",z.TOK_RPAREN="Rparen",z.TOK_COMMA="Comma",z.TOK_COLON="Colon",z.TOK_RBRACE="Rbrace",z.TOK_NUMBER="Number",z.TOK_CURRENT="Current",z.TOK_ROOT="Root",z.TOK_EXPREF="Expref",z.TOK_PIPE="Pipe",z.TOK_OR="Or",z.TOK_AND="And",z.TOK_EQ="EQ",z.TOK_GT="GT",z.TOK_LT="LT",z.TOK_GTE="GTE",z.TOK_LTE="LTE",z.TOK_NE="NE",z.TOK_FLATTEN="Flatten",z.TOK_STAR="Star",z.TOK_FILTER="Filter",z.TOK_DOT="Dot",z.TOK_NOT="Not",z.TOK_LBRACE="Lbrace",z.TOK_LBRACKET="Lbracket",z.TOK_LPAREN="Lparen",z.TOK_LITERAL="Literal"})(G||(G={}));let H={"(":G.TOK_LPAREN,")":G.TOK_RPAREN,"*":G.TOK_STAR,",":G.TOK_COMMA,".":G.TOK_DOT,":":G.TOK_COLON,"@":G.TOK_CURRENT,["$"]:G.TOK_ROOT,"]":G.TOK_RBRACKET,"{":G.TOK_LBRACE,"}":G.TOK_RBRACE},D={"!":!0,"<":!0,"=":!0,">":!0},O={"\t":!0,"\n":!0,"\r":!0," ":!0};class V{constructor(){this._current=0}tokenize(z){let B=[];this._current=0;let $,L,F;while(this._current<z.length)if(K(z[this._current]))$=this._current,L=this.consumeUnquotedIdentifier(z),B.push({start:$,type:G.TOK_UNQUOTEDIDENTIFIER,value:L});else if(H[z[this._current]]!==void 0)B.push({start:this._current,type:H[z[this._current]],value:z[this._current]}),this._current+=1;else if(q(z[this._current]))F=this.consumeNumber(z),B.push(F);else if(z[this._current]==="[")F=this.consumeLBracket(z),B.push(F);else if(z[this._current]==='"')$=this._current,L=this.consumeQuotedIdentifier(z),B.push({start:$,type:G.TOK_QUOTEDIDENTIFIER,value:L});else if(z[this._current]==="'")$=this._current,L=this.consumeRawStringLiteral(z),B.push({start:$,type:G.TOK_LITERAL,value:L});else if(z[this._current]==="`"){$=this._current;let N=this.consumeLiteral(z);B.push({start:$,type:G.TOK_LITERAL,value:N})}else if(D[z[this._current]]!==void 0)F=this.consumeOperator(z),F&&B.push(F);else if(O[z[this._current]]!==void 0)this._current+=1;else if(z[this._current]==="&")if($=this._current,this._current+=1,z[this._current]==="&")this._current+=1,B.push({start:$,type:G.TOK_AND,value:"&&"});else B.push({start:$,type:G.TOK_EXPREF,value:"&"});else if(z[this._current]==="|")if($=this._current,this._current+=1,z[this._current]==="|")this._current+=1,B.push({start:$,type:G.TOK_OR,value:"||"});else B.push({start:$,type:G.TOK_PIPE,value:"|"});else{let N=Error(`Unknown character: ${z[this._current]}`);throw N.name="LexerError",N}return B}consumeUnquotedIdentifier(z){let B=this._current;this._current+=1;while(this._current<z.length&&J(z[this._current]))this._current+=1;return z.slice(B,this._current)}consumeQuotedIdentifier(z){let B=this._current;this._current+=1;let $=z.length;while(z[this._current]!=='"'&&this._current<$){let L=this._current;if(z[L]==="\\"&&(z[L+1]==="\\"||z[L+1]==='"'))L+=2;else L+=1;this._current=L}return this._current+=1,JSON.parse(z.slice(B,this._current))}consumeRawStringLiteral(z){let B=this._current;this._current+=1;let $=z.length;while(z[this._current]!=="'"&&this._current<$){let F=this._current;if(z[F]==="\\"&&(z[F+1]==="\\"||z[F+1]==="'"))F+=2;else F+=1;this._current=F}return this._current+=1,z.slice(B+1,this._current-1).replace("\\'","'")}consumeNumber(z){let B=this._current;this._current+=1;let $=z.length;while(q(z[this._current])&&this._current<$)this._current+=1;let L=parseInt(z.slice(B,this._current),10);return{start:B,value:L,type:G.TOK_NUMBER}}consumeLBracket(z){let B=this._current;if(this._current+=1,z[this._current]==="?")return this._current+=1,{start:B,type:G.TOK_FILTER,value:"[?"};if(z[this._current]==="]")return this._current+=1,{start:B,type:G.TOK_FLATTEN,value:"[]"};return{start:B,type:G.TOK_LBRACKET,value:"["}}consumeOperator(z){let B=this._current,$=z[B];if(this._current+=1,$==="!"){if(z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_NE,value:"!="};return{start:B,type:G.TOK_NOT,value:"!"}}if($==="<"){if(z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_LTE,value:"<="};return{start:B,type:G.TOK_LT,value:"<"}}if($===">"){if(z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_GTE,value:">="};return{start:B,type:G.TOK_GT,value:">"}}if($==="="&&z[this._current]==="=")return this._current+=1,{start:B,type:G.TOK_EQ,value:"=="}}consumeLiteral(z){this._current+=1;let B=this._current,$=z.length;while(z[this._current]!=="`"&&this._current<$){let N=this._current;if(z[N]==="\\"&&(z[N+1]==="\\"||z[N+1]==="`"))N+=2;else N+=1;this._current=N}let L=z.slice(B,this._current).trimLeft();L=L.replace("\\`","`");let F=this.looksLikeJSON(L)?JSON.parse(L):JSON.parse(`"${L}"`);return this._current+=1,F}looksLikeJSON(z){let $=["true","false","null"],L="-0123456789";if(z==="")return!1;if('[{"'.includes(z[0]))return!0;if($.includes(z))return!0;if("-0123456789".includes(z[0]))try{return JSON.parse(z),!0}catch(F){return!1}return!1}}let R=new V,P={[G.TOK_EOF]:0,[G.TOK_UNQUOTEDIDENTIFIER]:0,[G.TOK_QUOTEDIDENTIFIER]:0,[G.TOK_RBRACKET]:0,[G.TOK_RPAREN]:0,[G.TOK_COMMA]:0,[G.TOK_RBRACE]:0,[G.TOK_NUMBER]:0,[G.TOK_CURRENT]:0,[G.TOK_EXPREF]:0,[G.TOK_ROOT]:0,[G.TOK_PIPE]:1,[G.TOK_OR]:2,[G.TOK_AND]:3,[G.TOK_EQ]:5,[G.TOK_GT]:5,[G.TOK_LT]:5,[G.TOK_GTE]:5,[G.TOK_LTE]:5,[G.TOK_NE]:5,[G.TOK_FLATTEN]:9,[G.TOK_STAR]:20,[G.TOK_FILTER]:21,[G.TOK_DOT]:40,[G.TOK_NOT]:45,[G.TOK_LBRACE]:50,[G.TOK_LBRACKET]:55,[G.TOK_LPAREN]:60};class b{constructor(){this.index=0,this.tokens=[]}parse(z){this.loadTokens(z),this.index=0;let B=this.expression(0);if(this.lookahead(0)!==G.TOK_EOF){let $=this.lookaheadToken(0);this.errorToken($,`Unexpected token type: ${$.type}, value: ${$.value}`)}return B}loadTokens(z){this.tokens=[...R.tokenize(z),{type:G.TOK_EOF,value:"",start:z.length}]}expression(z){let B=this.lookaheadToken(0);this.advance();let $=this.nud(B),L=this.lookahead(0);while(z<P[L])this.advance(),$=this.led(L,$),L=this.lookahead(0);return $}lookahead(z){return this.tokens[this.index+z].type}lookaheadToken(z){return this.tokens[this.index+z]}advance(){this.index+=1}nud(z){let B,$,L;switch(z.type){case G.TOK_LITERAL:return{type:"Literal",value:z.value};case G.TOK_UNQUOTEDIDENTIFIER:return{type:"Field",name:z.value};case G.TOK_QUOTEDIDENTIFIER:let F={type:"Field",name:z.value};if(this.lookahead(0)===G.TOK_LPAREN)throw Error("Quoted identifier not allowed for function names.");else return F;case G.TOK_NOT:return $=this.expression(P.Not),{type:"NotExpression",children:[$]};case G.TOK_STAR:return B={type:"Identity"},$=this.lookahead(0)===G.TOK_RBRACKET&&{type:"Identity"}||this.parseProjectionRHS(P.Star),{type:"ValueProjection",children:[B,$]};case G.TOK_FILTER:return this.led(z.type,{type:"Identity"});case G.TOK_LBRACE:return this.parseMultiselectHash();case G.TOK_FLATTEN:return B={type:G.TOK_FLATTEN,children:[{type:"Identity"}]},$=this.parseProjectionRHS(P.Flatten),{type:"Projection",children:[B,$]};case G.TOK_LBRACKET:if(this.lookahead(0)===G.TOK_NUMBER||this.lookahead(0)===G.TOK_COLON)return $=this.parseIndexExpression(),this.projectIfSlice({type:"Identity"},$);if(this.lookahead(0)===G.TOK_STAR&&this.lookahead(1)===G.TOK_RBRACKET)return this.advance(),this.advance(),$=this.parseProjectionRHS(P.Star),{children:[{type:"Identity"},$],type:"Projection"};return this.parseMultiselectList();case G.TOK_CURRENT:return{type:G.TOK_CURRENT};case G.TOK_ROOT:return{type:G.TOK_ROOT};case G.TOK_EXPREF:return L=this.expression(P.Expref),{type:"ExpressionReference",children:[L]};case G.TOK_LPAREN:let N=[];while(this.lookahead(0)!==G.TOK_RPAREN){if(this.lookahead(0)===G.TOK_CURRENT)L={type:G.TOK_CURRENT},this.advance();else L=this.expression(0);N.push(L)}return this.match(G.TOK_RPAREN),N[0];default:this.errorToken(z)}}led(z,B){let $;switch(z){case G.TOK_DOT:let L=P.Dot;if(this.lookahead(0)!==G.TOK_STAR)return $=this.parseDotRHS(L),{type:"Subexpression",children:[B,$]};return this.advance(),$=this.parseProjectionRHS(L),{type:"ValueProjection",children:[B,$]};case G.TOK_PIPE:return $=this.expression(P.Pipe),{type:G.TOK_PIPE,children:[B,$]};case G.TOK_OR:return $=this.expression(P.Or),{type:"OrExpression",children:[B,$]};case G.TOK_AND:return $=this.expression(P.And),{type:"AndExpression",children:[B,$]};case G.TOK_LPAREN:let F=B.name,N=[],_;while(this.lookahead(0)!==G.TOK_RPAREN){if(this.lookahead(0)===G.TOK_CURRENT)_={type:G.TOK_CURRENT},this.advance();else _=this.expression(0);if(this.lookahead(0)===G.TOK_COMMA)this.match(G.TOK_COMMA);N.push(_)}return this.match(G.TOK_RPAREN),{name:F,type:"Function",children:N};case G.TOK_FILTER:let p=this.expression(0);return this.match(G.TOK_RBRACKET),$=this.lookahead(0)===G.TOK_FLATTEN&&{type:"Identity"}||this.parseProjectionRHS(P.Filter),{type:"FilterProjection",children:[B,$,p]};case G.TOK_FLATTEN:let $0={type:G.TOK_FLATTEN,children:[B]},l=this.parseProjectionRHS(P.Flatten);return{type:"Projection",children:[$0,l]};case G.TOK_EQ:case G.TOK_NE:case G.TOK_GT:case G.TOK_GTE:case G.TOK_LT:case G.TOK_LTE:return this.parseComparator(B,z);case G.TOK_LBRACKET:let C=this.lookaheadToken(0);if(C.type===G.TOK_NUMBER||C.type===G.TOK_COLON)return $=this.parseIndexExpression(),this.projectIfSlice(B,$);return this.match(G.TOK_STAR),this.match(G.TOK_RBRACKET),$=this.parseProjectionRHS(P.Star),{type:"Projection",children:[B,$]};default:return this.errorToken(this.lookaheadToken(0))}}match(z){if(this.lookahead(0)===z){this.advance();return}else{let B=this.lookaheadToken(0);this.errorToken(B,`Expected ${z}, got: ${B.type}`)}}errorToken(z,B=""){let $=Error(B||`Invalid token (${z.type}): "${z.value}"`);throw $.name="ParserError",$}parseIndexExpression(){if(this.lookahead(0)===G.TOK_COLON||this.lookahead(1)===G.TOK_COLON)return this.parseSliceExpression();let z={type:"Index",value:this.lookaheadToken(0).value};return this.advance(),this.match(G.TOK_RBRACKET),z}projectIfSlice(z,B){let $={type:"IndexExpression",children:[z,B]};if(B.type==="Slice")return{children:[$,this.parseProjectionRHS(P.Star)],type:"Projection"};return $}parseSliceExpression(){let z=[null,null,null],B=0,$=this.lookahead(0);while($!==G.TOK_RBRACKET&&B<3){if($===G.TOK_COLON)B+=1,this.advance();else if($===G.TOK_NUMBER)z[B]=this.lookaheadToken(0).value,this.advance();else{let L=this.lookaheadToken(0);this.errorToken(L,`Syntax error, unexpected token: ${L.value}(${L.type})`)}$=this.lookahead(0)}return this.match(G.TOK_RBRACKET),{children:z,type:"Slice"}}parseComparator(z,B){let $=this.expression(P[B]);return{type:"Comparator",name:B,children:[z,$]}}parseDotRHS(z){let B=this.lookahead(0);if([G.TOK_UNQUOTEDIDENTIFIER,G.TOK_QUOTEDIDENTIFIER,G.TOK_STAR].includes(B))return this.expression(z);if(B===G.TOK_LBRACKET)return this.match(G.TOK_LBRACKET),this.parseMultiselectList();if(B===G.TOK_LBRACE)return this.match(G.TOK_LBRACE),this.parseMultiselectHash();let L=this.lookaheadToken(0);this.errorToken(L,`Syntax error, unexpected token: ${L.value}(${L.type})`)}parseProjectionRHS(z){if(P[this.lookahead(0)]<10)return{type:"Identity"};if(this.lookahead(0)===G.TOK_LBRACKET)return this.expression(z);if(this.lookahead(0)===G.TOK_FILTER)return this.expression(z);if(this.lookahead(0)===G.TOK_DOT)return this.match(G.TOK_DOT),this.parseDotRHS(z);let B=this.lookaheadToken(0);this.errorToken(B,`Syntax error, unexpected token: ${B.value}(${B.type})`)}parseMultiselectList(){let z=[];while(this.lookahead(0)!==G.TOK_RBRACKET){let B=this.expression(0);if(z.push(B),this.lookahead(0)===G.TOK_COMMA){if(this.match(G.TOK_COMMA),this.lookahead(0)===G.TOK_RBRACKET)throw Error("Unexpected token Rbracket")}}return this.match(G.TOK_RBRACKET),{type:"MultiSelectList",children:z}}parseMultiselectHash(){let z=[],B=[G.TOK_UNQUOTEDIDENTIFIER,G.TOK_QUOTEDIDENTIFIER],$,L,F;for(;;){if($=this.lookaheadToken(0),!B.includes($.type))throw Error(`Expecting an identifier token, got: ${$.type}`);if(L=$.value,this.advance(),this.match(G.TOK_COLON),F=this.expression(0),z.push({value:F,type:"KeyValuePair",name:L}),this.lookahead(0)===G.TOK_COMMA)this.match(G.TOK_COMMA);else if(this.lookahead(0)===G.TOK_RBRACE){this.match(G.TOK_RBRACE);break}}return{type:"MultiSelectHash",children:z}}}let N0=new b;var M;(function(z){z[z.TYPE_NUMBER=0]="TYPE_NUMBER",z[z.TYPE_ANY=1]="TYPE_ANY",z[z.TYPE_STRING=2]="TYPE_STRING",z[z.TYPE_ARRAY=3]="TYPE_ARRAY",z[z.TYPE_OBJECT=4]="TYPE_OBJECT",z[z.TYPE_BOOLEAN=5]="TYPE_BOOLEAN",z[z.TYPE_EXPREF=6]="TYPE_EXPREF",z[z.TYPE_NULL=7]="TYPE_NULL",z[z.TYPE_ARRAY_NUMBER=8]="TYPE_ARRAY_NUMBER",z[z.TYPE_ARRAY_STRING=9]="TYPE_ARRAY_STRING"})(M||(M={}));class k0{constructor(z){this.TYPE_NAME_TABLE={[M.TYPE_NUMBER]:"number",[M.TYPE_ANY]:"any",[M.TYPE_STRING]:"string",[M.TYPE_ARRAY]:"array",[M.TYPE_OBJECT]:"object",[M.TYPE_BOOLEAN]:"boolean",[M.TYPE_EXPREF]:"expression",[M.TYPE_NULL]:"null",[M.TYPE_ARRAY_NUMBER]:"Array<number>",[M.TYPE_ARRAY_STRING]:"Array<string>"},this.functionAbs=([B])=>{return Math.abs(B)},this.functionAvg=([B])=>{let $=0;for(let L=0;L<B.length;L+=1)$+=B[L];return $/B.length},this.functionCeil=([B])=>{return Math.ceil(B)},this.functionContains=(B)=>{let[$,L]=B;return $.includes(L)},this.functionEndsWith=(B)=>{let[$,L]=B;return $.includes(L,$.length-L.length)},this.functionFloor=([B])=>{return Math.floor(B)},this.functionJoin=(B)=>{let[$,L]=B;return L.join($)},this.functionKeys=([B])=>{return Object.keys(B)},this.functionLength=([B])=>{if(!X(B))return B.length;return Object.keys(B).length},this.functionMap=(B)=>{if(!this._interpreter)return[];let $=[],L=this._interpreter,F=B[0],N=B[1];for(let _=0;_<N.length;_+=1)$.push(L.visit(F,N[_]));return $},this.functionMax=([B])=>{if(!B.length)return null;if(this.getTypeName(B[0])===M.TYPE_NUMBER)return Math.max(...B);let L=B,F=L[0];for(let N=1;N<L.length;N+=1)if(F.localeCompare(L[N])<0)F=L[N];return F},this.functionMaxBy=(B)=>{let $=B[1],L=B[0],F=this.createKeyFunction($,[M.TYPE_NUMBER,M.TYPE_STRING]),N=-1/0,_,j;for(let p=0;p<L.length;p+=1)if(j=F&&F(L[p]),j!==void 0&&j>N)N=j,_=L[p];return _},this.functionMerge=(B)=>{let $={};for(let L=0;L<B.length;L+=1){let F=B[L];$=Object.assign($,F)}return $},this.functionMin=([B])=>{if(!B.length)return null;if(this.getTypeName(B[0])===M.TYPE_NUMBER)return Math.min(...B);let L=B,F=L[0];for(let N=1;N<L.length;N+=1)if(L[N].localeCompare(F)<0)F=L[N];return F},this.functionMinBy=(B)=>{let $=B[1],L=B[0],F=this.createKeyFunction($,[M.TYPE_NUMBER,M.TYPE_STRING]),N=1/0,_,j;for(let p=0;p<L.length;p+=1)if(j=F&&F(L[p]),j!==void 0&&j<N)N=j,_=L[p];return _},this.functionNotNull=(B)=>{for(let $=0;$<B.length;$+=1)if(this.getTypeName(B[$])!==M.TYPE_NULL)return B[$];return null},this.functionReverse=([B])=>{if(this.getTypeName(B)===M.TYPE_STRING){let F=B,N="";for(let _=F.length-1;_>=0;_-=1)N+=F[_];return N}let L=B.slice(0);return L.reverse(),L},this.functionSort=([B])=>{return[...B].sort()},this.functionSortBy=(B)=>{if(!this._interpreter)return[];let $=B[0].slice(0);if($.length===0)return $;let L=this._interpreter,F=B[1],N=this.getTypeName(L.visit(F,$[0]));if(N!==void 0&&![M.TYPE_NUMBER,M.TYPE_STRING].includes(N))throw Error(`TypeError: unexpected type (${this.TYPE_NAME_TABLE[N]})`);let _=[];for(let j=0;j<$.length;j+=1)_.push([j,$[j]]);_.sort((j,p)=>{let $0=L.visit(F,j[1]),l=L.visit(F,p[1]);if(this.getTypeName($0)!==N)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[N]}), received ${this.TYPE_NAME_TABLE[this.getTypeName($0)]}`);else if(this.getTypeName(l)!==N)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[N]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(l)]}`);if($0>l)return 1;return $0<l?-1:j[0]-p[0]});for(let j=0;j<_.length;j+=1)$[j]=_[j][1];return $},this.functionStartsWith=([B,$])=>{return B.startsWith($)},this.functionSum=([B])=>{return B.reduce(($,L)=>$+L,0)},this.functionToArray=([B])=>{if(this.getTypeName(B)===M.TYPE_ARRAY)return B;return[B]},this.functionToNumber=([B])=>{let $=this.getTypeName(B),L;if($===M.TYPE_NUMBER)return B;if($===M.TYPE_STRING){if(L=+B,!isNaN(L))return L}return null},this.functionToString=([B])=>{if(this.getTypeName(B)===M.TYPE_STRING)return B;return JSON.stringify(B)},this.functionType=([B])=>{switch(this.getTypeName(B)){case M.TYPE_NUMBER:return"number";case M.TYPE_STRING:return"string";case M.TYPE_ARRAY:return"array";case M.TYPE_OBJECT:return"object";case M.TYPE_BOOLEAN:return"boolean";case M.TYPE_EXPREF:return"expref";case M.TYPE_NULL:return"null";default:return}},this.functionValues=([B])=>{return Object.values(B)},this.functionTable={abs:{_func:this.functionAbs,_signature:[{types:[M.TYPE_NUMBER]}]},avg:{_func:this.functionAvg,_signature:[{types:[M.TYPE_ARRAY_NUMBER]}]},ceil:{_func:this.functionCeil,_signature:[{types:[M.TYPE_NUMBER]}]},contains:{_func:this.functionContains,_signature:[{types:[M.TYPE_STRING,M.TYPE_ARRAY]},{types:[M.TYPE_ANY]}]},ends_with:{_func:this.functionEndsWith,_signature:[{types:[M.TYPE_STRING]},{types:[M.TYPE_STRING]}]},floor:{_func:this.functionFloor,_signature:[{types:[M.TYPE_NUMBER]}]},join:{_func:this.functionJoin,_signature:[{types:[M.TYPE_STRING]},{types:[M.TYPE_ARRAY_STRING]}]},keys:{_func:this.functionKeys,_signature:[{types:[M.TYPE_OBJECT]}]},length:{_func:this.functionLength,_signature:[{types:[M.TYPE_STRING,M.TYPE_ARRAY,M.TYPE_OBJECT]}]},map:{_func:this.functionMap,_signature:[{types:[M.TYPE_EXPREF]},{types:[M.TYPE_ARRAY]}]},max:{_func:this.functionMax,_signature:[{types:[M.TYPE_ARRAY_NUMBER,M.TYPE_ARRAY_STRING]}]},max_by:{_func:this.functionMaxBy,_signature:[{types:[M.TYPE_ARRAY]},{types:[M.TYPE_EXPREF]}]},merge:{_func:this.functionMerge,_signature:[{types:[M.TYPE_OBJECT],variadic:!0}]},min:{_func:this.functionMin,_signature:[{types:[M.TYPE_ARRAY_NUMBER,M.TYPE_ARRAY_STRING]}]},min_by:{_func:this.functionMinBy,_signature:[{types:[M.TYPE_ARRAY]},{types:[M.TYPE_EXPREF]}]},not_null:{_func:this.functionNotNull,_signature:[{types:[M.TYPE_ANY],variadic:!0}]},reverse:{_func:this.functionReverse,_signature:[{types:[M.TYPE_STRING,M.TYPE_ARRAY]}]},sort:{_func:this.functionSort,_signature:[{types:[M.TYPE_ARRAY_STRING,M.TYPE_ARRAY_NUMBER]}]},sort_by:{_func:this.functionSortBy,_signature:[{types:[M.TYPE_ARRAY]},{types:[M.TYPE_EXPREF]}]},starts_with:{_func:this.functionStartsWith,_signature:[{types:[M.TYPE_STRING]},{types:[M.TYPE_STRING]}]},sum:{_func:this.functionSum,_signature:[{types:[M.TYPE_ARRAY_NUMBER]}]},to_array:{_func:this.functionToArray,_signature:[{types:[M.TYPE_ANY]}]},to_number:{_func:this.functionToNumber,_signature:[{types:[M.TYPE_ANY]}]},to_string:{_func:this.functionToString,_signature:[{types:[M.TYPE_ANY]}]},type:{_func:this.functionType,_signature:[{types:[M.TYPE_ANY]}]},values:{_func:this.functionValues,_signature:[{types:[M.TYPE_OBJECT]}]}},this._interpreter=z}registerFunction(z,B,$){if(z in this.functionTable)throw Error(`Function already defined: ${z}()`);this.functionTable[z]={_func:B.bind(this),_signature:$}}callFunction(z,B){let $=this.functionTable[z];if($===void 0)throw Error(`Unknown function: ${z}()`);return this.validateArgs(z,B,$._signature),$._func.call(this,B)}validateInputSignatures(z,B){for(let $=0;$<B.length;$+=1)if("variadic"in B[$]&&$!==B.length-1)throw Error(`ArgumentError: ${z}() 'variadic' argument ${$+1} must occur last`)}validateArgs(z,B,$){var L,F;let N;this.validateInputSignatures(z,$);let _=$.filter((U0)=>{var L0;return(L0=!U0.optional)!==null&&L0!==void 0?L0:!1}).length,j=(F=(L=$[$.length-1])===null||L===void 0?void 0:L.variadic)!==null&&F!==void 0?F:!1,p=B.length<_,$0=B.length>$.length,l=p&&(!j&&_>1||j)?"at least ":"";if(j&&p||!j&&(p||$0))throw N=$.length>1,Error(`ArgumentError: ${z}() takes ${l}${_} argument${N&&"s"||""} but received ${B.length}`);let C,r,P0;for(let U0=0;U0<$.length;U0+=1){P0=!1,C=$[U0].types,r=this.getTypeName(B[U0]);let L0;for(L0=0;L0<C.length;L0+=1)if(r!==void 0&&this.typeMatches(r,C[L0],B[U0])){P0=!0;break}if(!P0&&r!==void 0){let D1=C.map((w1)=>{return this.TYPE_NAME_TABLE[w1]}).join(" | ");throw Error(`TypeError: ${z}() expected argument ${U0+1} to be type (${D1}) but received type ${this.TYPE_NAME_TABLE[r]} instead.`)}}}typeMatches(z,B,$){if(B===M.TYPE_ANY)return!0;if(B===M.TYPE_ARRAY_STRING||B===M.TYPE_ARRAY_NUMBER||B===M.TYPE_ARRAY){if(B===M.TYPE_ARRAY)return z===M.TYPE_ARRAY;if(z===M.TYPE_ARRAY){let L;if(B===M.TYPE_ARRAY_NUMBER)L=M.TYPE_NUMBER;else if(B===M.TYPE_ARRAY_STRING)L=M.TYPE_STRING;for(let F=0;F<$.length;F+=1){let N=this.getTypeName($[F]);if(N!==void 0&&L!==void 0&&!this.typeMatches(N,L,$[F]))return!1}return!0}}else return z===B;return!1}getTypeName(z){switch(Object.prototype.toString.call(z)){case"[object String]":return M.TYPE_STRING;case"[object Number]":return M.TYPE_NUMBER;case"[object Array]":return M.TYPE_ARRAY;case"[object Boolean]":return M.TYPE_BOOLEAN;case"[object Null]":return M.TYPE_NULL;case"[object Object]":if(z.jmespathType===G.TOK_EXPREF)return M.TYPE_EXPREF;return M.TYPE_OBJECT;default:return}}createKeyFunction(z,B){if(!this._interpreter)return;let $=this._interpreter;return(F)=>{let N=$.visit(z,F);if(!B.includes(this.getTypeName(N))){let _=`TypeError: expected one of (${B.map((j)=>this.TYPE_NAME_TABLE[j]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(N)]}`;throw Error(_)}return N}}}class U1{constructor(){this._rootValue=null,this.runtime=new k0(this)}search(z,B){return this._rootValue=B,this.visit(z,B)}visit(z,B){let $,L,F,N,_,j,p,$0,l,C,r;switch(z.type){case"Field":if(B===null)return null;if(X(B)){if(j=B[z.name],j===void 0)return null;return j}return null;case"Subexpression":F=this.visit(z.children[0],B);for(C=1;C<z.children.length;C+=1)if(F=this.visit(z.children[1],F),F===null)return null;return F;case"IndexExpression":return p=this.visit(z.children[0],B),$0=this.visit(z.children[1],p),$0;case"Index":if(!Array.isArray(B))return null;let P0=z.value;if(P0<0)P0=B.length+P0;if(F=B[P0],F===void 0)F=null;return F;case"Slice":if(!Array.isArray(B))return null;let U0=[...z.children],L0=this.computeSliceParams(B.length,U0),[D1,w1,o1]=L0;if(F=[],o1>0)for(C=D1;C<w1;C+=o1)F.push(B[C]);else for(C=D1;C>w1;C+=o1)F.push(B[C]);return F;case"Projection":if(r=this.visit(z.children[0],B),!Array.isArray(r))return null;l=[];for(C=0;C<r.length;C+=1)if(L=this.visit(z.children[1],r[C]),L!==null)l.push(L);return l;case"ValueProjection":if(r=this.visit(z.children[0],B),!X(r))return null;l=[];let Z4=Object.values(r);for(C=0;C<Z4.length;C+=1)if(L=this.visit(z.children[1],Z4[C]),L!==null)l.push(L);return l;case"FilterProjection":if(r=this.visit(z.children[0],B),!Array.isArray(r))return null;let i1=[],R4=[];for(C=0;C<r.length;C+=1)if($=this.visit(z.children[2],r[C]),!Q($))i1.push(r[C]);for(let _0=0;_0<i1.length;_0+=1)if(L=this.visit(z.children[1],i1[_0]),L!==null)R4.push(L);return R4;case"Comparator":switch(N=this.visit(z.children[0],B),_=this.visit(z.children[1],B),z.name){case G.TOK_EQ:F=Y(N,_);break;case G.TOK_NE:F=!Y(N,_);break;case G.TOK_GT:F=N>_;break;case G.TOK_GTE:F=N>=_;break;case G.TOK_LT:F=N<_;break;case G.TOK_LTE:F=N<=_;break;default:throw Error(`Unknown comparator: ${z.name}`)}return F;case G.TOK_FLATTEN:let r1=this.visit(z.children[0],B);if(!Array.isArray(r1))return null;let M1=[];for(C=0;C<r1.length;C+=1)if(L=r1[C],Array.isArray(L))M1=[...M1,...L];else M1.push(L);return M1;case"Identity":return B;case"MultiSelectList":if(B===null)return null;l=[];for(C=0;C<z.children.length;C+=1)l.push(this.visit(z.children[C],B));return l;case"MultiSelectHash":if(B===null)return null;l={};let n1;for(C=0;C<z.children.length;C+=1)n1=z.children[C],l[n1.name]=this.visit(n1.value,B);return l;case"OrExpression":if($=this.visit(z.children[0],B),Q($))$=this.visit(z.children[1],B);return $;case"AndExpression":if(N=this.visit(z.children[0],B),Q(N))return N;return this.visit(z.children[1],B);case"NotExpression":return N=this.visit(z.children[0],B),Q(N);case"Literal":return z.value;case G.TOK_PIPE:return p=this.visit(z.children[0],B),this.visit(z.children[1],p);case G.TOK_CURRENT:return B;case G.TOK_ROOT:return this._rootValue;case"Function":let E4=[];for(let _0=0;_0<z.children.length;_0+=1)E4.push(this.visit(z.children[_0],B));return this.runtime.callFunction(z.name,E4);case"ExpressionReference":let I4=z.children[0];return I4.jmespathType=G.TOK_EXPREF,I4;default:throw Error(`Unknown node type: ${z.type}`)}}computeSliceParams(z,B){let[$,L,F]=B;if(F===null)F=1;else if(F===0){let _=Error("Invalid slice, step cannot be 0");throw _.name="RuntimeError",_}let N=F<0?!0:!1;return $=$===null?N?z-1:0:this.capSliceRange(z,$,F),L=L===null?N?-1:z:this.capSliceRange(z,L,F),[$,L,F]}capSliceRange(z,B,$){let L=B;if(L<0){if(L+=z,L<0)L=$<0?-1:0}else if(L>=z)L=$<0?z-1:z;return L}}let Y0=new U1,x=M.TYPE_ANY,o=M.TYPE_ARRAY,u0=M.TYPE_ARRAY_NUMBER,p0=M.TYPE_ARRAY_STRING,L1=M.TYPE_BOOLEAN,H4=M.TYPE_EXPREF,U4=M.TYPE_NULL,L4=M.TYPE_NUMBER,D4=M.TYPE_OBJECT,w4=M.TYPE_STRING;function M4(z){return N0.parse(z)}function F4(z){return R.tokenize(z)}let O4=(z,B,$)=>{Y0.runtime.registerFunction(z,B,$)};function V4(z,B){let $=N0.parse(B);return Y0.search($,z)}let N4=Y0,P4={compile:M4,registerFunction:O4,search:V4,tokenize:F4,TreeInterpreter:N4,TYPE_ANY:x,TYPE_ARRAY_NUMBER:u0,TYPE_ARRAY_STRING:p0,TYPE_ARRAY:o,TYPE_BOOLEAN:L1,TYPE_EXPREF:H4,TYPE_NULL:U4,TYPE_NUMBER:L4,TYPE_OBJECT:D4,TYPE_STRING:w4};W.TYPE_ANY=x,W.TYPE_ARRAY=o,W.TYPE_ARRAY_NUMBER=u0,W.TYPE_ARRAY_STRING=p0,W.TYPE_BOOLEAN=L1,W.TYPE_EXPREF=H4,W.TYPE_NULL=U4,W.TYPE_NUMBER=L4,W.TYPE_OBJECT=D4,W.TYPE_STRING=w4,W.TreeInterpreter=N4,W.compile=M4,W.default=P4,W.jmespath=P4,W.registerFunction=O4,W.search=V4,W.tokenize=F4,Object.defineProperty(W,"__esModule",{value:!0})})});import sW from"node:process";var C4;function w(W,X,Y){function Q(G,H){if(!G._zod)Object.defineProperty(G,"_zod",{value:{def:H,constr:J,traits:new Set},enumerable:!1});if(G._zod.traits.has(W))return;G._zod.traits.add(W),X(G,H);let D=J.prototype,O=Object.keys(D);for(let V=0;V<O.length;V++){let R=O[V];if(!(R in G))G[R]=D[R].bind(G)}}let K=Y?.Parent??Object;class q extends K{}Object.defineProperty(q,"name",{value:W});function J(G){var H;let D=Y?.Parent?new q:this;Q(D,G),(H=D._zod).deferred??(H.deferred=[]);for(let O of D._zod.deferred)O();return D}return Object.defineProperty(J,"init",{value:Q}),Object.defineProperty(J,Symbol.hasInstance,{value:(G)=>{if(Y?.Parent&&G instanceof Y.Parent)return!0;return G?._zod?.traits?.has(W)}}),Object.defineProperty(J,"name",{value:W}),J}var l7=Symbol("zod_brand");class w0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class l0 extends Error{constructor(W){super(`Encountered unidirectional transform during encode: ${W}`);this.name="ZodEncodeError"}}(C4=globalThis).__zod_globalConfig??(C4.__zod_globalConfig={});var v0=globalThis.__zod_globalConfig;function K0(W){if(W)Object.assign(v0,W);return v0}var S={};a1(S,{unwrapMessage:()=>d0,uint8ArrayToHex:()=>BX,uint8ArrayToBase64url:()=>JX,uint8ArrayToBase64:()=>k4,stringifyPrimitive:()=>N1,slugify:()=>X9,shallowClone:()=>A4,safeExtend:()=>XX,required:()=>KX,randomString:()=>r3,propertyKeyTypes:()=>Q9,promiseAllObject:()=>i3,primitiveTypes:()=>j4,prefixIssues:()=>O0,pick:()=>s3,partial:()=>QX,parsedType:()=>J9,optionalKeys:()=>K9,omit:()=>e3,objectClone:()=>l3,numKeys:()=>n3,nullish:()=>i0,normalizeParams:()=>I,mergeDefs:()=>M0,merge:()=>YX,jsonStringifyReplacer:()=>x0,joinValues:()=>F1,issue:()=>h0,isPlainObject:()=>R0,isObject:()=>A0,hexToUint8Array:()=>zX,getSizableOrigin:()=>b4,getParsedType:()=>t3,getLengthableOrigin:()=>n0,getEnumValues:()=>o0,getElementAtPath:()=>o3,floatSafeRemainder:()=>W9,finalizeIssue:()=>J0,extend:()=>WX,explicitlyAborted:()=>q9,escapeRegex:()=>F0,esc:()=>O1,defineLazy:()=>T,createTransparentProxy:()=>a3,cloneDef:()=>d3,clone:()=>H0,cleanRegex:()=>r0,cleanEnum:()=>GX,captureStackTrace:()=>V1,cached:()=>g0,base64urlToUint8Array:()=>qX,base64ToUint8Array:()=>T4,assignProp:()=>Z0,assertNotEqual:()=>c3,assertNever:()=>u3,assertIs:()=>m3,assertEqual:()=>f3,assert:()=>p3,allowsEval:()=>Y9,aborted:()=>E0,NUMBER_FORMAT_RANGES:()=>G9,Class:()=>v4,BIGINT_FORMAT_RANGES:()=>S4});function f3(W){return W}function c3(W){return W}function m3(W){}function u3(W){throw Error("Unexpected value in exhaustive check")}function p3(W){}function o0(W){let X=Object.values(W).filter((Q)=>typeof Q==="number");return Object.entries(W).filter(([Q,K])=>X.indexOf(+Q)===-1).map(([Q,K])=>K)}function F1(W,X="|"){return W.map((Y)=>N1(Y)).join(X)}function x0(W,X){if(typeof X==="bigint")return X.toString();return X}function g0(W){return{get value(){{let Y=W();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function i0(W){return W===null||W===void 0}function r0(W){let X=W.startsWith("^")?1:0,Y=W.endsWith("$")?W.length-1:W.length;return W.slice(X,Y)}function W9(W,X){let Y=W/X,Q=Math.round(Y),K=Number.EPSILON*Math.max(Math.abs(Y),1);if(Math.abs(Y-Q)<K)return 0;return Y-Q}var _4=Symbol("evaluating");function T(W,X,Y){let Q=void 0;Object.defineProperty(W,X,{get(){if(Q===_4)return;if(Q===void 0)Q=_4,Q=Y();return Q},set(K){Object.defineProperty(W,X,{value:K})},configurable:!0})}function l3(W){return Object.create(Object.getPrototypeOf(W),Object.getOwnPropertyDescriptors(W))}function Z0(W,X,Y){Object.defineProperty(W,X,{value:Y,writable:!0,enumerable:!0,configurable:!0})}function M0(...W){let X={};for(let Y of W){let Q=Object.getOwnPropertyDescriptors(Y);Object.assign(X,Q)}return Object.defineProperties({},X)}function d3(W){return M0(W._zod.def)}function o3(W,X){if(!X)return W;return X.reduce((Y,Q)=>Y?.[Q],W)}function i3(W){let X=Object.keys(W),Y=X.map((Q)=>W[Q]);return Promise.all(Y).then((Q)=>{let K={};for(let q=0;q<X.length;q++)K[X[q]]=Q[q];return K})}function r3(W=10){let Y="";for(let Q=0;Q<W;Q++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function O1(W){return JSON.stringify(W)}function X9(W){return W.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var V1="captureStackTrace"in Error?Error.captureStackTrace:(...W)=>{};function A0(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}var Y9=g0(()=>{if(v0.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(W){return!1}});function R0(W){if(A0(W)===!1)return!1;let X=W.constructor;if(X===void 0)return!0;if(typeof X!=="function")return!0;let Y=X.prototype;if(A0(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function A4(W){if(R0(W))return{...W};if(Array.isArray(W))return[...W];if(W instanceof Map)return new Map(W);if(W instanceof Set)return new Set(W);return W}function n3(W){let X=0;for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))X++;return X}var t3=(W)=>{let X=typeof W;switch(X){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(W)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(W))return"array";if(W===null)return"null";if(W.then&&typeof W.then==="function"&&W.catch&&typeof W.catch==="function")return"promise";if(typeof Map<"u"&&W instanceof Map)return"map";if(typeof Set<"u"&&W instanceof Set)return"set";if(typeof Date<"u"&&W instanceof Date)return"date";if(typeof File<"u"&&W instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${X}`)}},Q9=new Set(["string","number","symbol"]),j4=new Set(["string","number","bigint","boolean","symbol","undefined"]);function F0(W){return W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function H0(W,X,Y){let Q=new W._zod.constr(X??W._zod.def);if(!X||Y?.parent)Q._zod.parent=W;return Q}function I(W){let X=W;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 a3(W){let X;return new Proxy({},{get(Y,Q,K){return X??(X=W()),Reflect.get(X,Q,K)},set(Y,Q,K,q){return X??(X=W()),Reflect.set(X,Q,K,q)},has(Y,Q){return X??(X=W()),Reflect.has(X,Q)},deleteProperty(Y,Q){return X??(X=W()),Reflect.deleteProperty(X,Q)},ownKeys(Y){return X??(X=W()),Reflect.ownKeys(X)},getOwnPropertyDescriptor(Y,Q){return X??(X=W()),Reflect.getOwnPropertyDescriptor(X,Q)},defineProperty(Y,Q,K){return X??(X=W()),Reflect.defineProperty(X,Q,K)}})}function N1(W){if(typeof W==="bigint")return W.toString()+"n";if(typeof W==="string")return`"${W}"`;return`${W}`}function K9(W){return Object.keys(W).filter((X)=>{return W[X]._zod.optin==="optional"&&W[X]._zod.optout==="optional"})}var G9={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]},S4={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function s3(W,X){let Y=W._zod.def,Q=Y.checks;if(Q&&Q.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let q=M0(W._zod.def,{get shape(){let J={};for(let G in X){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!X[G])continue;J[G]=Y.shape[G]}return Z0(this,"shape",J),J},checks:[]});return H0(W,q)}function e3(W,X){let Y=W._zod.def,Q=Y.checks;if(Q&&Q.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let q=M0(W._zod.def,{get shape(){let J={...W._zod.def.shape};for(let G in X){if(!(G in Y.shape))throw Error(`Unrecognized key: "${G}"`);if(!X[G])continue;delete J[G]}return Z0(this,"shape",J),J},checks:[]});return H0(W,q)}function WX(W,X){if(!R0(X))throw Error("Invalid input to extend: expected a plain object");let Y=W._zod.def.checks;if(Y&&Y.length>0){let q=W._zod.def.shape;for(let J in X)if(Object.getOwnPropertyDescriptor(q,J)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let K=M0(W._zod.def,{get shape(){let q={...W._zod.def.shape,...X};return Z0(this,"shape",q),q}});return H0(W,K)}function XX(W,X){if(!R0(X))throw Error("Invalid input to safeExtend: expected a plain object");let Y=M0(W._zod.def,{get shape(){let Q={...W._zod.def.shape,...X};return Z0(this,"shape",Q),Q}});return H0(W,Y)}function YX(W,X){if(W._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let Y=M0(W._zod.def,{get shape(){let Q={...W._zod.def.shape,...X._zod.def.shape};return Z0(this,"shape",Q),Q},get catchall(){return X._zod.def.catchall},checks:X._zod.def.checks??[]});return H0(W,Y)}function QX(W,X,Y){let K=X._zod.def.checks;if(K&&K.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let J=M0(X._zod.def,{get shape(){let G=X._zod.def.shape,H={...G};if(Y)for(let D in Y){if(!(D in G))throw Error(`Unrecognized key: "${D}"`);if(!Y[D])continue;H[D]=W?new W({type:"optional",innerType:G[D]}):G[D]}else for(let D in G)H[D]=W?new W({type:"optional",innerType:G[D]}):G[D];return Z0(this,"shape",H),H},checks:[]});return H0(X,J)}function KX(W,X,Y){let Q=M0(X._zod.def,{get shape(){let K=X._zod.def.shape,q={...K};if(Y)for(let J in Y){if(!(J in q))throw Error(`Unrecognized key: "${J}"`);if(!Y[J])continue;q[J]=new W({type:"nonoptional",innerType:K[J]})}else for(let J in K)q[J]=new W({type:"nonoptional",innerType:K[J]});return Z0(this,"shape",q),q}});return H0(X,Q)}function E0(W,X=0){if(W.aborted===!0)return!0;for(let Y=X;Y<W.issues.length;Y++)if(W.issues[Y]?.continue!==!0)return!0;return!1}function q9(W,X=0){if(W.aborted===!0)return!0;for(let Y=X;Y<W.issues.length;Y++)if(W.issues[Y]?.continue===!1)return!0;return!1}function O0(W,X){return X.map((Y)=>{var Q;return(Q=Y).path??(Q.path=[]),Y.path.unshift(W),Y})}function d0(W){return typeof W==="string"?W:W?.message}function J0(W,X,Y){let Q=W.message?W.message:d0(W.inst?._zod.def?.error?.(W))??d0(X?.error?.(W))??d0(Y.customError?.(W))??d0(Y.localeError?.(W))??"Invalid input",{inst:K,continue:q,input:J,...G}=W;if(G.path??(G.path=[]),G.message=Q,X?.reportInput)G.input=J;return G}function b4(W){if(W instanceof Set)return"set";if(W instanceof Map)return"map";if(W instanceof File)return"file";return"unknown"}function n0(W){if(Array.isArray(W))return"array";if(typeof W==="string")return"string";return"unknown"}function J9(W){let X=typeof W;switch(X){case"number":return Number.isNaN(W)?"nan":"number";case"object":{if(W===null)return"null";if(Array.isArray(W))return"array";let Y=W;if(Y&&Object.getPrototypeOf(Y)!==Object.prototype&&"constructor"in Y&&Y.constructor)return Y.constructor.name}}return X}function h0(...W){let[X,Y,Q]=W;if(typeof X==="string")return{message:X,code:"custom",input:Y,inst:Q};return{...X}}function GX(W){return Object.entries(W).filter(([X,Y])=>{return Number.isNaN(Number.parseInt(X,10))}).map((X)=>X[1])}function T4(W){let X=atob(W),Y=new Uint8Array(X.length);for(let Q=0;Q<X.length;Q++)Y[Q]=X.charCodeAt(Q);return Y}function k4(W){let X="";for(let Y=0;Y<W.length;Y++)X+=String.fromCharCode(W[Y]);return btoa(X)}function qX(W){let X=W.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-X.length%4)%4);return T4(X+Y)}function JX(W){return k4(W).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function zX(W){let X=W.replace(/^0x/,"");if(X.length%2!==0)throw Error("Invalid hex string length");let Y=new Uint8Array(X.length/2);for(let Q=0;Q<X.length;Q+=2)Y[Q/2]=Number.parseInt(X.slice(Q,Q+2),16);return Y}function BX(W){return Array.from(W).map((X)=>X.toString(16).padStart(2,"0")).join("")}class v4{constructor(...W){}}var x4=(W,X)=>{W.name="$ZodError",Object.defineProperty(W,"_zod",{value:W._zod,enumerable:!1}),Object.defineProperty(W,"issues",{value:X,enumerable:!1}),W.message=JSON.stringify(X,x0,2),Object.defineProperty(W,"toString",{value:()=>W.message,enumerable:!1})},P1=w("$ZodError",x4),z9=w("$ZodError",x4,{Parent:Error});function g4(W,X=(Y)=>Y.message){let Y={},Q=[];for(let K of W.issues)if(K.path.length>0)Y[K.path[0]]=Y[K.path[0]]||[],Y[K.path[0]].push(X(K));else Q.push(X(K));return{formErrors:Q,fieldErrors:Y}}function h4(W,X=(Y)=>Y.message){let Y={_errors:[]},Q=(K,q=[])=>{for(let J of K.issues)if(J.code==="invalid_union"&&J.errors.length)J.errors.map((G)=>Q({issues:G},[...q,...J.path]));else if(J.code==="invalid_key")Q({issues:J.issues},[...q,...J.path]);else if(J.code==="invalid_element")Q({issues:J.issues},[...q,...J.path]);else{let G=[...q,...J.path];if(G.length===0)Y._errors.push(X(J));else{let H=Y,D=0;while(D<G.length){let O=G[D];if(D!==G.length-1)H[O]=H[O]||{_errors:[]};else H[O]=H[O]||{_errors:[]},H[O]._errors.push(X(J));H=H[O],D++}}}};return Q(W),Y}var Z1=(W)=>(X,Y,Q,K)=>{let q=Q?{...Q,async:!1}:{async:!1},J=X._zod.run({value:Y,issues:[]},q);if(J instanceof Promise)throw new w0;if(J.issues.length){let G=new(K?.Err??W)(J.issues.map((H)=>J0(H,q,K0())));throw V1(G,K?.callee),G}return J.value};var R1=(W)=>async(X,Y,Q,K)=>{let q=Q?{...Q,async:!0}:{async:!0},J=X._zod.run({value:Y,issues:[]},q);if(J instanceof Promise)J=await J;if(J.issues.length){let G=new(K?.Err??W)(J.issues.map((H)=>J0(H,q,K0())));throw V1(G,K?.callee),G}return J.value};var t0=(W)=>(X,Y,Q)=>{let K=Q?{...Q,async:!1}:{async:!1},q=X._zod.run({value:Y,issues:[]},K);if(q instanceof Promise)throw new w0;return q.issues.length?{success:!1,error:new(W??P1)(q.issues.map((J)=>J0(J,K,K0())))}:{success:!0,data:q.value}},y4=t0(z9),a0=(W)=>async(X,Y,Q)=>{let K=Q?{...Q,async:!0}:{async:!0},q=X._zod.run({value:Y,issues:[]},K);if(q instanceof Promise)q=await q;return q.issues.length?{success:!1,error:new W(q.issues.map((J)=>J0(J,K,K0())))}:{success:!0,data:q.value}},f4=a0(z9),c4=(W)=>(X,Y,Q)=>{let K=Q?{...Q,direction:"backward"}:{direction:"backward"};return Z1(W)(X,Y,K)};var m4=(W)=>(X,Y,Q)=>{return Z1(W)(X,Y,Q)};var u4=(W)=>async(X,Y,Q)=>{let K=Q?{...Q,direction:"backward"}:{direction:"backward"};return R1(W)(X,Y,K)};var p4=(W)=>async(X,Y,Q)=>{return R1(W)(X,Y,Q)};var l4=(W)=>(X,Y,Q)=>{let K=Q?{...Q,direction:"backward"}:{direction:"backward"};return t0(W)(X,Y,K)};var d4=(W)=>(X,Y,Q)=>{return t0(W)(X,Y,Q)};var o4=(W)=>async(X,Y,Q)=>{let K=Q?{...Q,direction:"backward"}:{direction:"backward"};return a0(W)(X,Y,K)};var i4=(W)=>async(X,Y,Q)=>{return a0(W)(X,Y,Q)};var r4=/^[cC][0-9a-z]{6,}$/,n4=/^[0-9a-z]+$/,t4=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,a4=/^[0-9a-vA-V]{20}$/,s4=/^[A-Za-z0-9]{27}$/,e4=/^[a-zA-Z0-9_-]{21}$/,W8=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var X8=/^([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})$/,B9=(W)=>{if(!W)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}-${W}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Y8=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var HX="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Q8(){return new RegExp(HX,"u")}var K8=/^(?:(?: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])$/,G8=/^(([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 q8=/^((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])$/,J8=/^(([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])$/,z8=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$9=/^[A-Za-z0-9_-]*$/;var B8=/^https?$/,$8=/^\+[1-9]\d{6,14}$/,H8="(?:(?:\\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])))",U8=new RegExp(`^${H8}$`);function L8(W){return typeof W.precision==="number"?W.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":W.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{${W.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function D8(W){return new RegExp(`^${L8(W)}$`)}function w8(W){let X=L8({precision:W.precision}),Y=["Z"];if(W.local)Y.push("");if(W.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let Q=`${X}(?:${Y.join("|")})`;return new RegExp(`^${H8}T(?:${Q})$`)}var M8=(W)=>{let X=W?`[\\s\\S]{${W?.minimum??0},${W?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${X}$`)};var F8=/^-?\d+$/,E1=/^-?\d+(?:\.\d+)?$/,O8=/^(?:true|false)$/i,V8=/^null$/i;var N8=/^[^A-Z]*$/,P8=/^[^a-z]*$/;var t=w("$ZodCheck",(W,X)=>{var Y;W._zod??(W._zod={}),W._zod.def=X,(Y=W._zod).onattach??(Y.onattach=[])}),Z8={number:"number",bigint:"bigint",object:"date"},H9=w("$ZodCheckLessThan",(W,X)=>{t.init(W,X);let Y=Z8[typeof X.value];W._zod.onattach.push((Q)=>{let K=Q._zod.bag,q=(X.inclusive?K.maximum:K.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(X.value<q)if(X.inclusive)K.maximum=X.value;else K.exclusiveMaximum=X.value}),W._zod.check=(Q)=>{if(X.inclusive?Q.value<=X.value:Q.value<X.value)return;Q.issues.push({origin:Y,code:"too_big",maximum:typeof X.value==="object"?X.value.getTime():X.value,input:Q.value,inclusive:X.inclusive,inst:W,continue:!X.abort})}}),U9=w("$ZodCheckGreaterThan",(W,X)=>{t.init(W,X);let Y=Z8[typeof X.value];W._zod.onattach.push((Q)=>{let K=Q._zod.bag,q=(X.inclusive?K.minimum:K.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(X.value>q)if(X.inclusive)K.minimum=X.value;else K.exclusiveMinimum=X.value}),W._zod.check=(Q)=>{if(X.inclusive?Q.value>=X.value:Q.value>X.value)return;Q.issues.push({origin:Y,code:"too_small",minimum:typeof X.value==="object"?X.value.getTime():X.value,input:Q.value,inclusive:X.inclusive,inst:W,continue:!X.abort})}}),R8=w("$ZodCheckMultipleOf",(W,X)=>{t.init(W,X),W._zod.onattach.push((Y)=>{var Q;(Q=Y._zod.bag).multipleOf??(Q.multipleOf=X.value)}),W._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):W9(Y.value,X.value)===0)return;Y.issues.push({origin:typeof Y.value,code:"not_multiple_of",divisor:X.value,input:Y.value,inst:W,continue:!X.abort})}}),E8=w("$ZodCheckNumberFormat",(W,X)=>{t.init(W,X),X.format=X.format||"float64";let Y=X.format?.includes("int"),Q=Y?"int":"number",[K,q]=G9[X.format];W._zod.onattach.push((J)=>{let G=J._zod.bag;if(G.format=X.format,G.minimum=K,G.maximum=q,Y)G.pattern=F8}),W._zod.check=(J)=>{let G=J.value;if(Y){if(!Number.isInteger(G)){J.issues.push({expected:Q,format:X.format,code:"invalid_type",continue:!1,input:G,inst:W});return}if(!Number.isSafeInteger(G)){if(G>0)J.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:Q,inclusive:!0,continue:!X.abort});else J.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:Q,inclusive:!0,continue:!X.abort});return}}if(G<K)J.issues.push({origin:"number",input:G,code:"too_small",minimum:K,inclusive:!0,inst:W,continue:!X.abort});if(G>q)J.issues.push({origin:"number",input:G,code:"too_big",maximum:q,inclusive:!0,inst:W,continue:!X.abort})}});var I8=w("$ZodCheckMaxLength",(W,X)=>{var Y;t.init(W,X),(Y=W._zod.def).when??(Y.when=(Q)=>{let K=Q.value;return!i0(K)&&K.length!==void 0}),W._zod.onattach.push((Q)=>{let K=Q._zod.bag.maximum??Number.POSITIVE_INFINITY;if(X.maximum<K)Q._zod.bag.maximum=X.maximum}),W._zod.check=(Q)=>{let K=Q.value;if(K.length<=X.maximum)return;let J=n0(K);Q.issues.push({origin:J,code:"too_big",maximum:X.maximum,inclusive:!0,input:K,inst:W,continue:!X.abort})}}),C8=w("$ZodCheckMinLength",(W,X)=>{var Y;t.init(W,X),(Y=W._zod.def).when??(Y.when=(Q)=>{let K=Q.value;return!i0(K)&&K.length!==void 0}),W._zod.onattach.push((Q)=>{let K=Q._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(X.minimum>K)Q._zod.bag.minimum=X.minimum}),W._zod.check=(Q)=>{let K=Q.value;if(K.length>=X.minimum)return;let J=n0(K);Q.issues.push({origin:J,code:"too_small",minimum:X.minimum,inclusive:!0,input:K,inst:W,continue:!X.abort})}}),_8=w("$ZodCheckLengthEquals",(W,X)=>{var Y;t.init(W,X),(Y=W._zod.def).when??(Y.when=(Q)=>{let K=Q.value;return!i0(K)&&K.length!==void 0}),W._zod.onattach.push((Q)=>{let K=Q._zod.bag;K.minimum=X.length,K.maximum=X.length,K.length=X.length}),W._zod.check=(Q)=>{let K=Q.value,q=K.length;if(q===X.length)return;let J=n0(K),G=q>X.length;Q.issues.push({origin:J,...G?{code:"too_big",maximum:X.length}:{code:"too_small",minimum:X.length},inclusive:!0,exact:!0,input:Q.value,inst:W,continue:!X.abort})}}),s0=w("$ZodCheckStringFormat",(W,X)=>{var Y,Q;if(t.init(W,X),W._zod.onattach.push((K)=>{let q=K._zod.bag;if(q.format=X.format,X.pattern)q.patterns??(q.patterns=new Set),q.patterns.add(X.pattern)}),X.pattern)(Y=W._zod).check??(Y.check=(K)=>{if(X.pattern.lastIndex=0,X.pattern.test(K.value))return;K.issues.push({origin:"string",code:"invalid_format",format:X.format,input:K.value,...X.pattern?{pattern:X.pattern.toString()}:{},inst:W,continue:!X.abort})});else(Q=W._zod).check??(Q.check=()=>{})}),A8=w("$ZodCheckRegex",(W,X)=>{s0.init(W,X),W._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:W,continue:!X.abort})}}),j8=w("$ZodCheckLowerCase",(W,X)=>{X.pattern??(X.pattern=N8),s0.init(W,X)}),S8=w("$ZodCheckUpperCase",(W,X)=>{X.pattern??(X.pattern=P8),s0.init(W,X)}),b8=w("$ZodCheckIncludes",(W,X)=>{t.init(W,X);let Y=F0(X.includes),Q=new RegExp(typeof X.position==="number"?`^.{${X.position}}${Y}`:Y);X.pattern=Q,W._zod.onattach.push((K)=>{let q=K._zod.bag;q.patterns??(q.patterns=new Set),q.patterns.add(Q)}),W._zod.check=(K)=>{if(K.value.includes(X.includes,X.position))return;K.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:X.includes,input:K.value,inst:W,continue:!X.abort})}}),T8=w("$ZodCheckStartsWith",(W,X)=>{t.init(W,X);let Y=new RegExp(`^${F0(X.prefix)}.*`);X.pattern??(X.pattern=Y),W._zod.onattach.push((Q)=>{let K=Q._zod.bag;K.patterns??(K.patterns=new Set),K.patterns.add(Y)}),W._zod.check=(Q)=>{if(Q.value.startsWith(X.prefix))return;Q.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:X.prefix,input:Q.value,inst:W,continue:!X.abort})}}),k8=w("$ZodCheckEndsWith",(W,X)=>{t.init(W,X);let Y=new RegExp(`.*${F0(X.suffix)}$`);X.pattern??(X.pattern=Y),W._zod.onattach.push((Q)=>{let K=Q._zod.bag;K.patterns??(K.patterns=new Set),K.patterns.add(Y)}),W._zod.check=(Q)=>{if(Q.value.endsWith(X.suffix))return;Q.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:X.suffix,input:Q.value,inst:W,continue:!X.abort})}});var v8=w("$ZodCheckOverwrite",(W,X)=>{t.init(W,X),W._zod.check=(Y)=>{Y.value=X.tx(Y.value)}});class L9{constructor(W=[]){if(this.content=[],this.indent=0,this)this.args=W}indented(W){this.indent+=1,W(this),this.indent-=1}write(W){if(typeof W==="function"){W(this,{execution:"sync"}),W(this,{execution:"async"});return}let Y=W.split(`
8
+ `).filter((q)=>q),Q=Math.min(...Y.map((q)=>q.length-q.trimStart().length)),K=Y.map((q)=>q.slice(Q)).map((q)=>" ".repeat(this.indent*2)+q);for(let q of K)this.content.push(q)}compile(){let W=Function,X=this?.args,Q=[...(this?.content??[""]).map((K)=>` ${K}`)];return new W(...X,Q.join(`
9
+ `))}}var g8={major:4,minor:4,patch:3};var g=w("$ZodType",(W,X)=>{var Y;W??(W={}),W._zod.def=X,W._zod.bag=W._zod.bag||{},W._zod.version=g8;let Q=[...W._zod.def.checks??[]];if(W._zod.traits.has("$ZodCheck"))Q.unshift(W);for(let K of Q)for(let q of K._zod.onattach)q(W);if(Q.length===0)(Y=W._zod).deferred??(Y.deferred=[]),W._zod.deferred?.push(()=>{W._zod.run=W._zod.parse});else{let K=(J,G,H)=>{let D=E0(J),O;for(let V of G){if(V._zod.def.when){if(q9(J))continue;if(!V._zod.def.when(J))continue}else if(D)continue;let R=J.issues.length,P=V._zod.check(J);if(P instanceof Promise&&H?.async===!1)throw new w0;if(O||P instanceof Promise)O=(O??Promise.resolve()).then(async()=>{if(await P,J.issues.length===R)return;if(!D)D=E0(J,R)});else{if(J.issues.length===R)continue;if(!D)D=E0(J,R)}}if(O)return O.then(()=>{return J});return J},q=(J,G,H)=>{if(E0(J))return J.aborted=!0,J;let D=K(G,Q,H);if(D instanceof Promise){if(H.async===!1)throw new w0;return D.then((O)=>W._zod.parse(O,H))}return W._zod.parse(D,H)};W._zod.run=(J,G)=>{if(G.skipChecks)return W._zod.parse(J,G);if(G.direction==="backward"){let D=W._zod.parse({value:J.value,issues:[]},{...G,skipChecks:!0});if(D instanceof Promise)return D.then((O)=>{return q(O,J,G)});return q(D,J,G)}let H=W._zod.parse(J,G);if(H instanceof Promise){if(G.async===!1)throw new w0;return H.then((D)=>K(D,Q,G))}return K(H,Q,G)}}T(W,"~standard",()=>({validate:(K)=>{try{let q=y4(W,K);return q.success?{value:q.data}:{issues:q.error?.issues}}catch(q){return f4(W,K).then((J)=>J.success?{value:J.data}:{issues:J.error?.issues})}},vendor:"zod",version:1}))}),A1=w("$ZodString",(W,X)=>{g.init(W,X),W._zod.pattern=[...W?._zod.bag?.patterns??[]].pop()??M8(W._zod.bag),W._zod.parse=(Y,Q)=>{if(X.coerce)try{Y.value=String(Y.value)}catch(K){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:W}),Y}}),h=w("$ZodStringFormat",(W,X)=>{s0.init(W,X),A1.init(W,X)}),d8=w("$ZodGUID",(W,X)=>{X.pattern??(X.pattern=X8),h.init(W,X)}),o8=w("$ZodUUID",(W,X)=>{if(X.version){let Q={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[X.version];if(Q===void 0)throw Error(`Invalid UUID version: "${X.version}"`);X.pattern??(X.pattern=B9(Q))}else X.pattern??(X.pattern=B9());h.init(W,X)}),i8=w("$ZodEmail",(W,X)=>{X.pattern??(X.pattern=Y8),h.init(W,X)}),r8=w("$ZodURL",(W,X)=>{h.init(W,X),W._zod.check=(Y)=>{try{let Q=Y.value.trim();if(!X.normalize&&X.protocol?.source===B8.source){if(!/^https?:\/\//i.test(Q)){Y.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:Y.value,inst:W,continue:!X.abort});return}}let K=new URL(Q);if(X.hostname){if(X.hostname.lastIndex=0,!X.hostname.test(K.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:X.hostname.source,input:Y.value,inst:W,continue:!X.abort})}if(X.protocol){if(X.protocol.lastIndex=0,!X.protocol.test(K.protocol.endsWith(":")?K.protocol.slice(0,-1):K.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:X.protocol.source,input:Y.value,inst:W,continue:!X.abort})}if(X.normalize)Y.value=K.href;else Y.value=Q;return}catch(Q){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:W,continue:!X.abort})}}}),n8=w("$ZodEmoji",(W,X)=>{X.pattern??(X.pattern=Q8()),h.init(W,X)}),t8=w("$ZodNanoID",(W,X)=>{X.pattern??(X.pattern=e4),h.init(W,X)}),a8=w("$ZodCUID",(W,X)=>{X.pattern??(X.pattern=r4),h.init(W,X)}),s8=w("$ZodCUID2",(W,X)=>{X.pattern??(X.pattern=n4),h.init(W,X)}),e8=w("$ZodULID",(W,X)=>{X.pattern??(X.pattern=t4),h.init(W,X)}),W6=w("$ZodXID",(W,X)=>{X.pattern??(X.pattern=a4),h.init(W,X)}),X6=w("$ZodKSUID",(W,X)=>{X.pattern??(X.pattern=s4),h.init(W,X)}),Y6=w("$ZodISODateTime",(W,X)=>{X.pattern??(X.pattern=w8(X)),h.init(W,X)}),Q6=w("$ZodISODate",(W,X)=>{X.pattern??(X.pattern=U8),h.init(W,X)}),K6=w("$ZodISOTime",(W,X)=>{X.pattern??(X.pattern=D8(X)),h.init(W,X)}),G6=w("$ZodISODuration",(W,X)=>{X.pattern??(X.pattern=W8),h.init(W,X)}),q6=w("$ZodIPv4",(W,X)=>{X.pattern??(X.pattern=K8),h.init(W,X),W._zod.bag.format="ipv4"}),J6=w("$ZodIPv6",(W,X)=>{X.pattern??(X.pattern=G8),h.init(W,X),W._zod.bag.format="ipv6",W._zod.check=(Y)=>{try{new URL(`http://[${Y.value}]`)}catch{Y.issues.push({code:"invalid_format",format:"ipv6",input:Y.value,inst:W,continue:!X.abort})}}});var z6=w("$ZodCIDRv4",(W,X)=>{X.pattern??(X.pattern=q8),h.init(W,X)}),B6=w("$ZodCIDRv6",(W,X)=>{X.pattern??(X.pattern=J8),h.init(W,X),W._zod.check=(Y)=>{let Q=Y.value.split("/");try{if(Q.length!==2)throw Error();let[K,q]=Q;if(!q)throw Error();let J=Number(q);if(`${J}`!==q)throw Error();if(J<0||J>128)throw Error();new URL(`http://[${K}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:W,continue:!X.abort})}}});function $6(W){if(W==="")return!0;if(/\s/.test(W))return!1;if(W.length%4!==0)return!1;try{return atob(W),!0}catch{return!1}}var H6=w("$ZodBase64",(W,X)=>{X.pattern??(X.pattern=z8),h.init(W,X),W._zod.bag.contentEncoding="base64",W._zod.check=(Y)=>{if($6(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:W,continue:!X.abort})}});function UX(W){if(!$9.test(W))return!1;let X=W.replace(/[-_]/g,(Q)=>Q==="-"?"+":"/"),Y=X.padEnd(Math.ceil(X.length/4)*4,"=");return $6(Y)}var U6=w("$ZodBase64URL",(W,X)=>{X.pattern??(X.pattern=$9),h.init(W,X),W._zod.bag.contentEncoding="base64url",W._zod.check=(Y)=>{if(UX(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:W,continue:!X.abort})}}),L6=w("$ZodE164",(W,X)=>{X.pattern??(X.pattern=$8),h.init(W,X)});function LX(W,X=null){try{let Y=W.split(".");if(Y.length!==3)return!1;let[Q]=Y;if(!Q)return!1;let K=JSON.parse(atob(Q));if("typ"in K&&K?.typ!=="JWT")return!1;if(!K.alg)return!1;if(X&&(!("alg"in K)||K.alg!==X))return!1;return!0}catch{return!1}}var D6=w("$ZodJWT",(W,X)=>{h.init(W,X),W._zod.check=(Y)=>{if(LX(Y.value,X.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:W,continue:!X.abort})}});var w9=w("$ZodNumber",(W,X)=>{g.init(W,X),W._zod.pattern=W._zod.bag.pattern??E1,W._zod.parse=(Y,Q)=>{if(X.coerce)try{Y.value=Number(Y.value)}catch(J){}let K=Y.value;if(typeof K==="number"&&!Number.isNaN(K)&&Number.isFinite(K))return Y;let q=typeof K==="number"?Number.isNaN(K)?"NaN":!Number.isFinite(K)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:K,inst:W,...q?{received:q}:{}}),Y}}),w6=w("$ZodNumberFormat",(W,X)=>{E8.init(W,X),w9.init(W,X)}),M6=w("$ZodBoolean",(W,X)=>{g.init(W,X),W._zod.pattern=O8,W._zod.parse=(Y,Q)=>{if(X.coerce)try{Y.value=Boolean(Y.value)}catch(q){}let K=Y.value;if(typeof K==="boolean")return Y;return Y.issues.push({expected:"boolean",code:"invalid_type",input:K,inst:W}),Y}});var F6=w("$ZodNull",(W,X)=>{g.init(W,X),W._zod.pattern=V8,W._zod.values=new Set([null]),W._zod.parse=(Y,Q)=>{let K=Y.value;if(K===null)return Y;return Y.issues.push({expected:"null",code:"invalid_type",input:K,inst:W}),Y}});var O6=w("$ZodUnknown",(W,X)=>{g.init(W,X),W._zod.parse=(Y)=>Y}),V6=w("$ZodNever",(W,X)=>{g.init(W,X),W._zod.parse=(Y,Q)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:W}),Y}});function h8(W,X,Y){if(W.issues.length)X.issues.push(...O0(Y,W.issues));X.value[Y]=W.value}var N6=w("$ZodArray",(W,X)=>{g.init(W,X),W._zod.parse=(Y,Q)=>{let K=Y.value;if(!Array.isArray(K))return Y.issues.push({expected:"array",code:"invalid_type",input:K,inst:W}),Y;Y.value=Array(K.length);let q=[];for(let J=0;J<K.length;J++){let G=K[J],H=X.element._zod.run({value:G,issues:[]},Q);if(H instanceof Promise)q.push(H.then((D)=>h8(D,Y,J)));else h8(H,Y,J)}if(q.length)return Promise.all(q).then(()=>Y);return Y}});function _1(W,X,Y,Q,K,q){let J=Y in Q;if(W.issues.length){if(K&&q&&!J)return;X.issues.push(...O0(Y,W.issues))}if(!J&&!K){if(!W.issues.length)X.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[Y]});return}if(W.value===void 0){if(J)X.value[Y]=void 0}else X.value[Y]=W.value}function P6(W){let X=Object.keys(W.shape);for(let Q of X)if(!W.shape?.[Q]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${Q}": expected a Zod schema`);let Y=K9(W.shape);return{...W,keys:X,keySet:new Set(X),numKeys:X.length,optionalKeys:new Set(Y)}}function Z6(W,X,Y,Q,K,q){let J=[],G=K.keySet,H=K.catchall._zod,D=H.def.type,O=H.optin==="optional",V=H.optout==="optional";for(let R in X){if(R==="__proto__")continue;if(G.has(R))continue;if(D==="never"){J.push(R);continue}let P=H.run({value:X[R],issues:[]},Q);if(P instanceof Promise)W.push(P.then((b)=>_1(b,Y,R,X,O,V)));else _1(P,Y,R,X,O,V)}if(J.length)Y.issues.push({code:"unrecognized_keys",keys:J,input:X,inst:q});if(!W.length)return Y;return Promise.all(W).then(()=>{return Y})}var DX=w("$ZodObject",(W,X)=>{if(g.init(W,X),!Object.getOwnPropertyDescriptor(X,"shape")?.get){let G=X.shape;Object.defineProperty(X,"shape",{get:()=>{let H={...G};return Object.defineProperty(X,"shape",{value:H}),H}})}let Q=g0(()=>P6(X));T(W._zod,"propValues",()=>{let G=X.shape,H={};for(let D in G){let O=G[D]._zod;if(O.values){H[D]??(H[D]=new Set);for(let V of O.values)H[D].add(V)}}return H});let K=A0,q=X.catchall,J;W._zod.parse=(G,H)=>{J??(J=Q.value);let D=G.value;if(!K(D))return G.issues.push({expected:"object",code:"invalid_type",input:D,inst:W}),G;G.value={};let O=[],V=J.shape;for(let R of J.keys){let P=V[R],b=P._zod.optin==="optional",N0=P._zod.optout==="optional",M=P._zod.run({value:D[R],issues:[]},H);if(M instanceof Promise)O.push(M.then((k0)=>_1(k0,G,R,D,b,N0)));else _1(M,G,R,D,b,N0)}if(!q)return O.length?Promise.all(O).then(()=>G):G;return Z6(O,D,G,H,Q.value,W)}}),R6=w("$ZodObjectJIT",(W,X)=>{DX.init(W,X);let Y=W._zod.parse,Q=g0(()=>P6(X)),K=(R)=>{let P=new L9(["shape","payload","ctx"]),b=Q.value,N0=(Y0)=>{let x=O1(Y0);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};P.write("const input = payload.value;");let M=Object.create(null),k0=0;for(let Y0 of b.keys)M[Y0]=`key_${k0++}`;P.write("const newResult = {};");for(let Y0 of b.keys){let x=M[Y0],o=O1(Y0),u0=R[Y0],p0=u0?._zod?.optin==="optional",L1=u0?._zod?.optout==="optional";if(P.write(`const ${x} = ${N0(Y0)};`),p0&&L1)P.write(`
10
+ if (${x}.issues.length) {
11
+ if (${o} in input) {
12
+ payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
13
13
  ...iss,
14
- path: iss.path ? [${Y0}, ...iss.path] : [${Y0}]
14
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
15
15
  })));
16
16
  }
17
17
  }
18
18
 
19
- if (${n}.value === undefined) {
20
- if (${Y0} in input) {
21
- newResult[${Y0}] = undefined;
19
+ if (${x}.value === undefined) {
20
+ if (${o} in input) {
21
+ newResult[${o}] = undefined;
22
22
  }
23
23
  } else {
24
- newResult[${Y0}] = ${n}.value;
24
+ newResult[${o}] = ${x}.value;
25
25
  }
26
26
 
27
- `);else R.write(`
28
- if (${n}.issues.length) {
29
- payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
27
+ `);else if(!p0)P.write(`
28
+ const ${x}_present = ${o} in input;
29
+ if (${x}.issues.length) {
30
+ payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
30
31
  ...iss,
31
- path: iss.path ? [${Y0}, ...iss.path] : [${Y0}]
32
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
33
+ })));
34
+ }
35
+ if (!${x}_present && !${x}.issues.length) {
36
+ payload.issues.push({
37
+ code: "invalid_type",
38
+ expected: "nonoptional",
39
+ input: undefined,
40
+ path: [${o}]
41
+ });
42
+ }
43
+
44
+ if (${x}_present) {
45
+ if (${x}.value === undefined) {
46
+ newResult[${o}] = undefined;
47
+ } else {
48
+ newResult[${o}] = ${x}.value;
49
+ }
50
+ }
51
+
52
+ `);else P.write(`
53
+ if (${x}.issues.length) {
54
+ payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
55
+ ...iss,
56
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
32
57
  })));
33
58
  }
34
59
 
35
- if (${n}.value === undefined) {
36
- if (${Y0} in input) {
37
- newResult[${Y0}] = undefined;
60
+ if (${x}.value === undefined) {
61
+ if (${o} in input) {
62
+ newResult[${o}] = undefined;
38
63
  }
39
64
  } else {
40
- newResult[${Y0}] = ${n}.value;
65
+ newResult[${o}] = ${x}.value;
41
66
  }
42
67
 
43
- `)}R.write("payload.value = newResult;"),R.write("return payload;");let z1=R.compile();return(K0,n)=>z1(E,K0,n)},q,J=S0,G=!L1.jitless,D=G&&W9.value,F=X.catchall,N;W._zod.parse=(E,R)=>{N??(N=Y.value);let o=E.value;if(!J(o))return E.issues.push({expected:"object",code:"invalid_type",input:o,inst:W}),E;if(G&&D&&R?.async===!1&&R.jitless!==!0){if(!q)q=Q(X.shape);if(E=q(E,R),!F)return E;return F4([],o,E,R,N,W)}return K(E,R)}});function v8(W,X,K,Y){for(let q of W)if(q.issues.length===0)return X.value=q.value,X;let Q=W.filter((q)=>!E0(q));if(Q.length===1)return X.value=Q[0].value,Q[0];return X.issues.push({code:"invalid_union",input:X.value,inst:K,errors:W.map((q)=>q.issues.map((J)=>U0(J,Y,J0())))}),X}var L9=w("$ZodUnion",(W,X)=>{v.init(W,X),b(W._zod,"optin",()=>X.options.some((Q)=>Q._zod.optin==="optional")?"optional":void 0),b(W._zod,"optout",()=>X.options.some((Q)=>Q._zod.optout==="optional")?"optional":void 0),b(W._zod,"values",()=>{if(X.options.every((Q)=>Q._zod.values))return new Set(X.options.flatMap((Q)=>Array.from(Q._zod.values)));return}),b(W._zod,"pattern",()=>{if(X.options.every((Q)=>Q._zod.pattern)){let Q=X.options.map((q)=>q._zod.pattern);return new RegExp(`^(${Q.map((q)=>l0(q.source)).join("|")})$`)}return});let K=X.options.length===1,Y=X.options[0]._zod.run;W._zod.parse=(Q,q)=>{if(K)return Y(Q,q);let J=!1,G=[];for(let H of X.options){let D=H._zod.run({value:Q.value,issues:[]},q);if(D instanceof Promise)G.push(D),J=!0;else{if(D.issues.length===0)return D;G.push(D)}}if(!J)return v8(G,Q,W,q);return Promise.all(G).then((H)=>{return v8(H,Q,W,q)})}});var V4=w("$ZodDiscriminatedUnion",(W,X)=>{X.inclusive=!1,L9.init(W,X);let K=W._zod.parse;b(W._zod,"propValues",()=>{let Q={};for(let q of X.options){let J=q._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf(q)}"`);for(let[G,H]of Object.entries(J)){if(!Q[G])Q[G]=new Set;for(let D of H)Q[G].add(D)}}return Q});let Y=v0(()=>{let Q=X.options,q=new Map;for(let J of Q){let G=J._zod.propValues?.[X.discriminator];if(!G||G.size===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf(J)}"`);for(let H of G){if(q.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);q.set(H,J)}}return q});W._zod.parse=(Q,q)=>{let J=Q.value;if(!S0(J))return Q.issues.push({code:"invalid_type",expected:"object",input:J,inst:W}),Q;let G=Y.value.get(J?.[X.discriminator]);if(G)return G._zod.run(Q,q);if(X.unionFallback)return K(Q,q);return Q.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:X.discriminator,input:J,path:[X.discriminator],inst:W}),Q}}),P4=w("$ZodIntersection",(W,X)=>{v.init(W,X),W._zod.parse=(K,Y)=>{let Q=K.value,q=X.left._zod.run({value:Q,issues:[]},Y),J=X.right._zod.run({value:Q,issues:[]},Y);if(q instanceof Promise||J instanceof Promise)return Promise.all([q,J]).then(([H,D])=>{return x8(K,H,D)});return x8(K,q,J)}});function H9(W,X){if(W===X)return{valid:!0,data:W};if(W instanceof Date&&X instanceof Date&&+W===+X)return{valid:!0,data:W};if(Z0(W)&&Z0(X)){let K=Object.keys(X),Y=Object.keys(W).filter((q)=>K.indexOf(q)!==-1),Q={...W,...X};for(let q of Y){let J=H9(W[q],X[q]);if(!J.valid)return{valid:!1,mergeErrorPath:[q,...J.mergeErrorPath]};Q[q]=J.data}return{valid:!0,data:Q}}if(Array.isArray(W)&&Array.isArray(X)){if(W.length!==X.length)return{valid:!1,mergeErrorPath:[]};let K=[];for(let Y=0;Y<W.length;Y++){let Q=W[Y],q=X[Y],J=H9(Q,q);if(!J.valid)return{valid:!1,mergeErrorPath:[Y,...J.mergeErrorPath]};K.push(J.data)}return{valid:!0,data:K}}return{valid:!1,mergeErrorPath:[]}}function x8(W,X,K){let Y=new Map,Q;for(let G of X.issues)if(G.code==="unrecognized_keys"){Q??(Q=G);for(let H of G.keys){if(!Y.has(H))Y.set(H,{});Y.get(H).l=!0}}else W.issues.push(G);for(let G of K.issues)if(G.code==="unrecognized_keys")for(let H of G.keys){if(!Y.has(H))Y.set(H,{});Y.get(H).r=!0}else W.issues.push(G);let q=[...Y].filter(([,G])=>G.l&&G.r).map(([G])=>G);if(q.length&&Q)W.issues.push({...Q,keys:q});if(E0(W))return W;let J=H9(X.value,K.value);if(!J.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(J.mergeErrorPath)}`);return W.value=J.data,W}var R4=w("$ZodRecord",(W,X)=>{v.init(W,X),W._zod.parse=(K,Y)=>{let Q=K.value;if(!Z0(Q))return K.issues.push({expected:"record",code:"invalid_type",input:Q,inst:W}),K;let q=[],J=X.keyType._zod.values;if(J){K.value={};let G=new Set;for(let D of J)if(typeof D==="string"||typeof D==="number"||typeof D==="symbol"){G.add(typeof D==="number"?D.toString():D);let F=X.valueType._zod.run({value:Q[D],issues:[]},Y);if(F instanceof Promise)q.push(F.then((N)=>{if(N.issues.length)K.issues.push(...N0(D,N.issues));K.value[D]=N.value}));else{if(F.issues.length)K.issues.push(...N0(D,F.issues));K.value[D]=F.value}}let H;for(let D in Q)if(!G.has(D))H=H??[],H.push(D);if(H&&H.length>0)K.issues.push({code:"unrecognized_keys",input:Q,inst:W,keys:H})}else{K.value={};for(let G of Reflect.ownKeys(Q)){if(G==="__proto__")continue;let H=X.keyType._zod.run({value:G,issues:[]},Y);if(H instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof G==="string"&&P1.test(G)&&H.issues.length){let N=X.keyType._zod.run({value:Number(G),issues:[]},Y);if(N instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(N.issues.length===0)H=N}if(H.issues.length){if(X.mode==="loose")K.value[G]=Q[G];else K.issues.push({code:"invalid_key",origin:"record",issues:H.issues.map((N)=>U0(N,Y,J0())),input:G,path:[G],inst:W});continue}let F=X.valueType._zod.run({value:Q[G],issues:[]},Y);if(F instanceof Promise)q.push(F.then((N)=>{if(N.issues.length)K.issues.push(...N0(G,N.issues));K.value[H.value]=N.value}));else{if(F.issues.length)K.issues.push(...N0(G,F.issues));K.value[H.value]=F.value}}}if(q.length)return Promise.all(q).then(()=>K);return K}});var Z4=w("$ZodEnum",(W,X)=>{v.init(W,X);let K=u0(X.entries),Y=new Set(K);W._zod.values=Y,W._zod.pattern=new RegExp(`^(${K.filter((Q)=>X9.has(typeof Q)).map((Q)=>typeof Q==="string"?F0(Q):Q.toString()).join("|")})$`),W._zod.parse=(Q,q)=>{let J=Q.value;if(Y.has(J))return Q;return Q.issues.push({code:"invalid_value",values:K,input:J,inst:W}),Q}}),E4=w("$ZodLiteral",(W,X)=>{if(v.init(W,X),X.values.length===0)throw Error("Cannot create literal schema with no valid values");let K=new Set(X.values);W._zod.values=K,W._zod.pattern=new RegExp(`^(${X.values.map((Y)=>typeof Y==="string"?F0(Y):Y?F0(Y.toString()):String(Y)).join("|")})$`),W._zod.parse=(Y,Q)=>{let q=Y.value;if(K.has(q))return Y;return Y.issues.push({code:"invalid_value",values:X.values,input:q,inst:W}),Y}});var I4=w("$ZodTransform",(W,X)=>{v.init(W,X),W._zod.parse=(K,Y)=>{if(Y.direction==="backward")throw new c0(W.constructor.name);let Q=X.transform(K.value,K);if(Y.async)return(Q instanceof Promise?Q:Promise.resolve(Q)).then((J)=>{return K.value=J,K});if(Q instanceof Promise)throw new M0;return K.value=Q,K}});function h8(W,X){if(W.issues.length&&X===void 0)return{issues:[],value:void 0};return W}var w9=w("$ZodOptional",(W,X)=>{v.init(W,X),W._zod.optin="optional",W._zod.optout="optional",b(W._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,void 0]):void 0}),b(W._zod,"pattern",()=>{let K=X.innerType._zod.pattern;return K?new RegExp(`^(${l0(K.source)})?$`):void 0}),W._zod.parse=(K,Y)=>{if(X.innerType._zod.optin==="optional"){let Q=X.innerType._zod.run(K,Y);if(Q instanceof Promise)return Q.then((q)=>h8(q,K.value));return h8(Q,K.value)}if(K.value===void 0)return K;return X.innerType._zod.run(K,Y)}}),C4=w("$ZodExactOptional",(W,X)=>{w9.init(W,X),b(W._zod,"values",()=>X.innerType._zod.values),b(W._zod,"pattern",()=>X.innerType._zod.pattern),W._zod.parse=(K,Y)=>{return X.innerType._zod.run(K,Y)}}),_4=w("$ZodNullable",(W,X)=>{v.init(W,X),b(W._zod,"optin",()=>X.innerType._zod.optin),b(W._zod,"optout",()=>X.innerType._zod.optout),b(W._zod,"pattern",()=>{let K=X.innerType._zod.pattern;return K?new RegExp(`^(${l0(K.source)}|null)$`):void 0}),b(W._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,null]):void 0}),W._zod.parse=(K,Y)=>{if(K.value===null)return K;return X.innerType._zod.run(K,Y)}}),S4=w("$ZodDefault",(W,X)=>{v.init(W,X),W._zod.optin="optional",b(W._zod,"values",()=>X.innerType._zod.values),W._zod.parse=(K,Y)=>{if(Y.direction==="backward")return X.innerType._zod.run(K,Y);if(K.value===void 0)return K.value=X.defaultValue,K;let Q=X.innerType._zod.run(K,Y);if(Q instanceof Promise)return Q.then((q)=>g8(q,X));return g8(Q,X)}});function g8(W,X){if(W.value===void 0)W.value=X.defaultValue;return W}var A4=w("$ZodPrefault",(W,X)=>{v.init(W,X),W._zod.optin="optional",b(W._zod,"values",()=>X.innerType._zod.values),W._zod.parse=(K,Y)=>{if(Y.direction==="backward")return X.innerType._zod.run(K,Y);if(K.value===void 0)K.value=X.defaultValue;return X.innerType._zod.run(K,Y)}}),j4=w("$ZodNonOptional",(W,X)=>{v.init(W,X),b(W._zod,"values",()=>{let K=X.innerType._zod.values;return K?new Set([...K].filter((Y)=>Y!==void 0)):void 0}),W._zod.parse=(K,Y)=>{let Q=X.innerType._zod.run(K,Y);if(Q instanceof Promise)return Q.then((q)=>y8(q,W));return y8(Q,W)}});function y8(W,X){if(!W.issues.length&&W.value===void 0)W.issues.push({code:"invalid_type",expected:"nonoptional",input:W.value,inst:X});return W}var b4=w("$ZodCatch",(W,X)=>{v.init(W,X),b(W._zod,"optin",()=>X.innerType._zod.optin),b(W._zod,"optout",()=>X.innerType._zod.optout),b(W._zod,"values",()=>X.innerType._zod.values),W._zod.parse=(K,Y)=>{if(Y.direction==="backward")return X.innerType._zod.run(K,Y);let Q=X.innerType._zod.run(K,Y);if(Q instanceof Promise)return Q.then((q)=>{if(K.value=q.value,q.issues.length)K.value=X.catchValue({...K,error:{issues:q.issues.map((J)=>U0(J,Y,J0()))},input:K.value}),K.issues=[];return K});if(K.value=Q.value,Q.issues.length)K.value=X.catchValue({...K,error:{issues:Q.issues.map((q)=>U0(q,Y,J0()))},input:K.value}),K.issues=[];return K}});var T4=w("$ZodPipe",(W,X)=>{v.init(W,X),b(W._zod,"values",()=>X.in._zod.values),b(W._zod,"optin",()=>X.in._zod.optin),b(W._zod,"optout",()=>X.out._zod.optout),b(W._zod,"propValues",()=>X.in._zod.propValues),W._zod.parse=(K,Y)=>{if(Y.direction==="backward"){let q=X.out._zod.run(K,Y);if(q instanceof Promise)return q.then((J)=>Z1(J,X.in,Y));return Z1(q,X.in,Y)}let Q=X.in._zod.run(K,Y);if(Q instanceof Promise)return Q.then((q)=>Z1(q,X.out,Y));return Z1(Q,X.out,Y)}});function Z1(W,X,K){if(W.issues.length)return W.aborted=!0,W;return X._zod.run({value:W.value,issues:W.issues},K)}var k4=w("$ZodReadonly",(W,X)=>{v.init(W,X),b(W._zod,"propValues",()=>X.innerType._zod.propValues),b(W._zod,"values",()=>X.innerType._zod.values),b(W._zod,"optin",()=>X.innerType?._zod?.optin),b(W._zod,"optout",()=>X.innerType?._zod?.optout),W._zod.parse=(K,Y)=>{if(Y.direction==="backward")return X.innerType._zod.run(K,Y);let Q=X.innerType._zod.run(K,Y);if(Q instanceof Promise)return Q.then(f8);return f8(Q)}});function f8(W){return W.value=Object.freeze(W.value),W}var v4=w("$ZodCustom",(W,X)=>{t.init(W,X),v.init(W,X),W._zod.parse=(K,Y)=>{return K},W._zod.check=(K)=>{let Y=K.value,Q=X.fn(Y);if(Q instanceof Promise)return Q.then((q)=>c8(q,K,Y,W));c8(Q,K,Y,W);return}});function c8(W,X,K,Y){if(!W){let Q={code:"custom",input:K,inst:Y,path:[...Y._zod.def.path??[]],continue:!Y._zod.def.abort};if(Y._zod.def.params)Q.params=Y._zod.def.params;X.issues.push(x0(Q))}}var zX=()=>{let W={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(Q){return W[Q]??null}let K={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"},Y={nan:"NaN"};return(Q)=>{switch(Q.code){case"invalid_type":{let q=Y[Q.expected]??Q.expected,J=Q9(Q.input),G=Y[J]??J;return`Invalid input: expected ${q}, received ${G}`}case"invalid_value":if(Q.values.length===1)return`Invalid input: expected ${O1(Q.values[0])}`;return`Invalid option: expected one of ${w1(Q.values,"|")}`;case"too_big":{let q=Q.inclusive?"<=":"<",J=X(Q.origin);if(J)return`Too big: expected ${Q.origin??"value"} to have ${q}${Q.maximum.toString()} ${J.unit??"elements"}`;return`Too big: expected ${Q.origin??"value"} to be ${q}${Q.maximum.toString()}`}case"too_small":{let q=Q.inclusive?">=":">",J=X(Q.origin);if(J)return`Too small: expected ${Q.origin} to have ${q}${Q.minimum.toString()} ${J.unit}`;return`Too small: expected ${Q.origin} to be ${q}${Q.minimum.toString()}`}case"invalid_format":{let q=Q;if(q.format==="starts_with")return`Invalid string: must start with "${q.prefix}"`;if(q.format==="ends_with")return`Invalid string: must end with "${q.suffix}"`;if(q.format==="includes")return`Invalid string: must include "${q.includes}"`;if(q.format==="regex")return`Invalid string: must match pattern ${q.pattern}`;return`Invalid ${K[q.format]??Q.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${Q.divisor}`;case"unrecognized_keys":return`Unrecognized key${Q.keys.length>1?"s":""}: ${w1(Q.keys,", ")}`;case"invalid_key":return`Invalid key in ${Q.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${Q.origin}`;default:return"Invalid input"}}};function D9(){return{localeError:zX()}}var x4,W7=Symbol("ZodOutput"),X7=Symbol("ZodInput");class h4{constructor(){this._map=new WeakMap,this._idmap=new Map}add(W,...X){let K=X[0];if(this._map.set(W,K),K&&typeof K==="object"&&"id"in K)this._idmap.set(K.id,W);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(W){let X=this._map.get(W);if(X&&typeof X==="object"&&"id"in X)this._idmap.delete(X.id);return this._map.delete(W),this}get(W){let X=W._zod.parent;if(X){let K={...this.get(X)??{}};delete K.id;let Y={...K,...this._map.get(W)};return Object.keys(Y).length?Y:void 0}return this._map.get(W)}has(W){return this._map.has(W)}}function BX(){return new h4}(x4=globalThis).__zod_globalRegistry??(x4.__zod_globalRegistry=BX());var A0=globalThis.__zod_globalRegistry;function g4(W,X){return new W({type:"string",...I(X)})}function y4(W,X){return new W({type:"string",format:"email",check:"string_format",abort:!1,...I(X)})}function M9(W,X){return new W({type:"string",format:"guid",check:"string_format",abort:!1,...I(X)})}function f4(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,...I(X)})}function c4(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(X)})}function m4(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(X)})}function u4(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(X)})}function p4(W,X){return new W({type:"string",format:"url",check:"string_format",abort:!1,...I(X)})}function l4(W,X){return new W({type:"string",format:"emoji",check:"string_format",abort:!1,...I(X)})}function d4(W,X){return new W({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(X)})}function o4(W,X){return new W({type:"string",format:"cuid",check:"string_format",abort:!1,...I(X)})}function r4(W,X){return new W({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(X)})}function i4(W,X){return new W({type:"string",format:"ulid",check:"string_format",abort:!1,...I(X)})}function n4(W,X){return new W({type:"string",format:"xid",check:"string_format",abort:!1,...I(X)})}function t4(W,X){return new W({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(X)})}function a4(W,X){return new W({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(X)})}function s4(W,X){return new W({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(X)})}function e4(W,X){return new W({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(X)})}function W2(W,X){return new W({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(X)})}function X2(W,X){return new W({type:"string",format:"base64",check:"string_format",abort:!1,...I(X)})}function K2(W,X){return new W({type:"string",format:"base64url",check:"string_format",abort:!1,...I(X)})}function Y2(W,X){return new W({type:"string",format:"e164",check:"string_format",abort:!1,...I(X)})}function Q2(W,X){return new W({type:"string",format:"jwt",check:"string_format",abort:!1,...I(X)})}function G2(W,X){return new W({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(X)})}function q2(W,X){return new W({type:"string",format:"date",check:"string_format",...I(X)})}function J2(W,X){return new W({type:"string",format:"time",check:"string_format",precision:null,...I(X)})}function z2(W,X){return new W({type:"string",format:"duration",check:"string_format",...I(X)})}function B2(W,X){return new W({type:"number",checks:[],...I(X)})}function $2(W,X){return new W({type:"number",check:"number_format",abort:!1,format:"safeint",...I(X)})}function H2(W,X){return new W({type:"boolean",...I(X)})}function U2(W,X){return new W({type:"null",...I(X)})}function L2(W){return new W({type:"unknown"})}function w2(W,X){return new W({type:"never",...I(X)})}function C1(W,X){return new z9({check:"less_than",...I(X),value:W,inclusive:!1})}function n0(W,X){return new z9({check:"less_than",...I(X),value:W,inclusive:!0})}function _1(W,X){return new B9({check:"greater_than",...I(X),value:W,inclusive:!1})}function t0(W,X){return new B9({check:"greater_than",...I(X),value:W,inclusive:!0})}function S1(W,X){return new N8({check:"multiple_of",...I(X),value:W})}function A1(W,X){return new P8({check:"max_length",...I(X),maximum:W})}function h0(W,X){return new R8({check:"min_length",...I(X),minimum:W})}function j1(W,X){return new Z8({check:"length_equals",...I(X),length:W})}function O9(W,X){return new E8({check:"string_format",format:"regex",...I(X),pattern:W})}function F9(W){return new I8({check:"string_format",format:"lowercase",...I(W)})}function N9(W){return new C8({check:"string_format",format:"uppercase",...I(W)})}function V9(W,X){return new _8({check:"string_format",format:"includes",...I(X),includes:W})}function P9(W,X){return new S8({check:"string_format",format:"starts_with",...I(X),prefix:W})}function R9(W,X){return new A8({check:"string_format",format:"ends_with",...I(X),suffix:W})}function I0(W){return new j8({check:"overwrite",tx:W})}function Z9(W){return I0((X)=>X.normalize(W))}function E9(){return I0((W)=>W.trim())}function I9(){return I0((W)=>W.toLowerCase())}function C9(){return I0((W)=>W.toUpperCase())}function _9(){return I0((W)=>e1(W))}function D2(W,X,K){return new W({type:"array",element:X,...I(K)})}function M2(W,X,K){let Y=I(K);return Y.abort??(Y.abort=!0),new W({type:"custom",check:"custom",fn:X,...Y})}function O2(W,X,K){return new W({type:"custom",check:"custom",fn:X,...I(K)})}function F2(W){let X=$X((K)=>{return K.addIssue=(Y)=>{if(typeof Y==="string")K.issues.push(x0(Y,K.value,X._zod.def));else{let Q=Y;if(Q.fatal)Q.continue=!1;Q.code??(Q.code="custom"),Q.input??(Q.input=K.value),Q.inst??(Q.inst=X),Q.continue??(Q.continue=!X._zod.def.abort),K.issues.push(x0(Q))}},W(K.value,K)});return X}function $X(W,X){let K=new t({check:"custom",...I(X)});return K._zod.check=W,K}function S9(W){let X=W?.target??"draft-2020-12";if(X==="draft-4")X="draft-04";if(X==="draft-7")X="draft-07";return{processors:W.processors??{},metadataRegistry:W?.metadata??A0,target:X,unrepresentable:W?.unrepresentable??"throw",override:W?.override??(()=>{}),io:W?.io??"output",counter:0,seen:new Map,cycles:W?.cycles??"ref",reused:W?.reused??"inline",external:W?.external??void 0}}function p(W,X,K={path:[],schemaPath:[]}){var Y;let Q=W._zod.def,q=X.seen.get(W);if(q){if(q.count++,K.schemaPath.includes(W))q.cycle=K.path;return q.schema}let J={schema:{},count:1,cycle:void 0,path:K.path};X.seen.set(W,J);let G=W._zod.toJSONSchema?.();if(G)J.schema=G;else{let F={...K,schemaPath:[...K.schemaPath,W],path:K.path};if(W._zod.processJSONSchema)W._zod.processJSONSchema(X,J.schema,F);else{let E=J.schema,R=X.processors[Q.type];if(!R)throw Error(`[toJSONSchema]: Non-representable type encountered: ${Q.type}`);R(W,X,E,F)}let N=W._zod.parent;if(N){if(!J.ref)J.ref=N;p(N,X,F),X.seen.get(N).isParent=!0}}let H=X.metadataRegistry.get(W);if(H)Object.assign(J.schema,H);if(X.io==="input"&&e(W))delete J.schema.examples,delete J.schema.default;if(X.io==="input"&&J.schema._prefault)(Y=J.schema).default??(Y.default=J.schema._prefault);return delete J.schema._prefault,X.seen.get(W).schema}function A9(W,X){let K=W.seen.get(X);if(!K)throw Error("Unprocessed schema. This is a bug in Zod.");let Y=new Map;for(let J of W.seen.entries()){let G=W.metadataRegistry.get(J[0])?.id;if(G){let H=Y.get(G);if(H&&H!==J[0])throw Error(`Duplicate schema id "${G}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);Y.set(G,J[0])}}let Q=(J)=>{let G=W.target==="draft-2020-12"?"$defs":"definitions";if(W.external){let N=W.external.registry.get(J[0])?.id,E=W.external.uri??((o)=>o);if(N)return{ref:E(N)};let R=J[1].defId??J[1].schema.id??`schema${W.counter++}`;return J[1].defId=R,{defId:R,ref:`${E("__shared")}#/${G}/${R}`}}if(J[1]===K)return{ref:"#"};let D=`${"#"}/${G}/`,F=J[1].schema.id??`__schema${W.counter++}`;return{defId:F,ref:D+F}},q=(J)=>{if(J[1].schema.$ref)return;let G=J[1],{ref:H,defId:D}=Q(J);if(G.def={...G.schema},D)G.defId=D;let F=G.schema;for(let N in F)delete F[N];F.$ref=H};if(W.cycles==="throw")for(let J of W.seen.entries()){let G=J[1];if(G.cycle)throw Error(`Cycle detected: #/${G.cycle?.join("/")}/<root>
68
+ `)}P.write("payload.value = newResult;"),P.write("return payload;");let U1=P.compile();return(Y0,x)=>U1(R,Y0,x)},q,J=A0,G=!v0.jitless,D=G&&Y9.value,O=X.catchall,V;W._zod.parse=(R,P)=>{V??(V=Q.value);let b=R.value;if(!J(b))return R.issues.push({expected:"object",code:"invalid_type",input:b,inst:W}),R;if(G&&D&&P?.async===!1&&P.jitless!==!0){if(!q)q=K(X.shape);if(R=q(R,P),!O)return R;return Z6([],b,R,P,V,W)}return Y(R,P)}});function y8(W,X,Y,Q){for(let q of W)if(q.issues.length===0)return X.value=q.value,X;let K=W.filter((q)=>!E0(q));if(K.length===1)return X.value=K[0].value,K[0];return X.issues.push({code:"invalid_union",input:X.value,inst:Y,errors:W.map((q)=>q.issues.map((J)=>J0(J,Q,K0())))}),X}var M9=w("$ZodUnion",(W,X)=>{g.init(W,X),T(W._zod,"optin",()=>X.options.some((Q)=>Q._zod.optin==="optional")?"optional":void 0),T(W._zod,"optout",()=>X.options.some((Q)=>Q._zod.optout==="optional")?"optional":void 0),T(W._zod,"values",()=>{if(X.options.every((Q)=>Q._zod.values))return new Set(X.options.flatMap((Q)=>Array.from(Q._zod.values)));return}),T(W._zod,"pattern",()=>{if(X.options.every((Q)=>Q._zod.pattern)){let Q=X.options.map((K)=>K._zod.pattern);return new RegExp(`^(${Q.map((K)=>r0(K.source)).join("|")})$`)}return});let Y=X.options.length===1?X.options[0]._zod.run:null;W._zod.parse=(Q,K)=>{if(Y)return Y(Q,K);let q=!1,J=[];for(let G of X.options){let H=G._zod.run({value:Q.value,issues:[]},K);if(H instanceof Promise)J.push(H),q=!0;else{if(H.issues.length===0)return H;J.push(H)}}if(!q)return y8(J,Q,W,K);return Promise.all(J).then((G)=>{return y8(G,Q,W,K)})}});var E6=w("$ZodDiscriminatedUnion",(W,X)=>{X.inclusive=!1,M9.init(W,X);let Y=W._zod.parse;T(W._zod,"propValues",()=>{let K={};for(let q of X.options){let J=q._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf(q)}"`);for(let[G,H]of Object.entries(J)){if(!K[G])K[G]=new Set;for(let D of H)K[G].add(D)}}return K});let Q=g0(()=>{let K=X.options,q=new Map;for(let J of K){let G=J._zod.propValues?.[X.discriminator];if(!G||G.size===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf(J)}"`);for(let H of G){if(q.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);q.set(H,J)}}return q});W._zod.parse=(K,q)=>{let J=K.value;if(!A0(J))return K.issues.push({code:"invalid_type",expected:"object",input:J,inst:W}),K;let G=Q.value.get(J?.[X.discriminator]);if(G)return G._zod.run(K,q);if(X.unionFallback||q.direction==="backward")return Y(K,q);return K.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:X.discriminator,options:Array.from(Q.value.keys()),input:J,path:[X.discriminator],inst:W}),K}}),I6=w("$ZodIntersection",(W,X)=>{g.init(W,X),W._zod.parse=(Y,Q)=>{let K=Y.value,q=X.left._zod.run({value:K,issues:[]},Q),J=X.right._zod.run({value:K,issues:[]},Q);if(q instanceof Promise||J instanceof Promise)return Promise.all([q,J]).then(([H,D])=>{return f8(Y,H,D)});return f8(Y,q,J)}});function D9(W,X){if(W===X)return{valid:!0,data:W};if(W instanceof Date&&X instanceof Date&&+W===+X)return{valid:!0,data:W};if(R0(W)&&R0(X)){let Y=Object.keys(X),Q=Object.keys(W).filter((q)=>Y.indexOf(q)!==-1),K={...W,...X};for(let q of Q){let J=D9(W[q],X[q]);if(!J.valid)return{valid:!1,mergeErrorPath:[q,...J.mergeErrorPath]};K[q]=J.data}return{valid:!0,data:K}}if(Array.isArray(W)&&Array.isArray(X)){if(W.length!==X.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let Q=0;Q<W.length;Q++){let K=W[Q],q=X[Q],J=D9(K,q);if(!J.valid)return{valid:!1,mergeErrorPath:[Q,...J.mergeErrorPath]};Y.push(J.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function f8(W,X,Y){let Q=new Map,K;for(let G of X.issues)if(G.code==="unrecognized_keys"){K??(K=G);for(let H of G.keys){if(!Q.has(H))Q.set(H,{});Q.get(H).l=!0}}else W.issues.push(G);for(let G of Y.issues)if(G.code==="unrecognized_keys")for(let H of G.keys){if(!Q.has(H))Q.set(H,{});Q.get(H).r=!0}else W.issues.push(G);let q=[...Q].filter(([,G])=>G.l&&G.r).map(([G])=>G);if(q.length&&K)W.issues.push({...K,keys:q});if(E0(W))return W;let J=D9(X.value,Y.value);if(!J.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(J.mergeErrorPath)}`);return W.value=J.data,W}var C6=w("$ZodRecord",(W,X)=>{g.init(W,X),W._zod.parse=(Y,Q)=>{let K=Y.value;if(!R0(K))return Y.issues.push({expected:"record",code:"invalid_type",input:K,inst:W}),Y;let q=[],J=X.keyType._zod.values;if(J){Y.value={};let G=new Set;for(let D of J)if(typeof D==="string"||typeof D==="number"||typeof D==="symbol"){G.add(typeof D==="number"?D.toString():D);let O=X.keyType._zod.run({value:D,issues:[]},Q);if(O instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(O.issues.length){Y.issues.push({code:"invalid_key",origin:"record",issues:O.issues.map((P)=>J0(P,Q,K0())),input:D,path:[D],inst:W});continue}let V=O.value,R=X.valueType._zod.run({value:K[D],issues:[]},Q);if(R instanceof Promise)q.push(R.then((P)=>{if(P.issues.length)Y.issues.push(...O0(D,P.issues));Y.value[V]=P.value}));else{if(R.issues.length)Y.issues.push(...O0(D,R.issues));Y.value[V]=R.value}}let H;for(let D in K)if(!G.has(D))H=H??[],H.push(D);if(H&&H.length>0)Y.issues.push({code:"unrecognized_keys",input:K,inst:W,keys:H})}else{Y.value={};for(let G of Reflect.ownKeys(K)){if(G==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(K,G))continue;let H=X.keyType._zod.run({value:G,issues:[]},Q);if(H instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof G==="string"&&E1.test(G)&&H.issues.length){let V=X.keyType._zod.run({value:Number(G),issues:[]},Q);if(V instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(V.issues.length===0)H=V}if(H.issues.length){if(X.mode==="loose")Y.value[G]=K[G];else Y.issues.push({code:"invalid_key",origin:"record",issues:H.issues.map((V)=>J0(V,Q,K0())),input:G,path:[G],inst:W});continue}let O=X.valueType._zod.run({value:K[G],issues:[]},Q);if(O instanceof Promise)q.push(O.then((V)=>{if(V.issues.length)Y.issues.push(...O0(G,V.issues));Y.value[H.value]=V.value}));else{if(O.issues.length)Y.issues.push(...O0(G,O.issues));Y.value[H.value]=O.value}}}if(q.length)return Promise.all(q).then(()=>Y);return Y}});var _6=w("$ZodEnum",(W,X)=>{g.init(W,X);let Y=o0(X.entries),Q=new Set(Y);W._zod.values=Q,W._zod.pattern=new RegExp(`^(${Y.filter((K)=>Q9.has(typeof K)).map((K)=>typeof K==="string"?F0(K):K.toString()).join("|")})$`),W._zod.parse=(K,q)=>{let J=K.value;if(Q.has(J))return K;return K.issues.push({code:"invalid_value",values:Y,input:J,inst:W}),K}}),A6=w("$ZodLiteral",(W,X)=>{if(g.init(W,X),X.values.length===0)throw Error("Cannot create literal schema with no valid values");let Y=new Set(X.values);W._zod.values=Y,W._zod.pattern=new RegExp(`^(${X.values.map((Q)=>typeof Q==="string"?F0(Q):Q?F0(Q.toString()):String(Q)).join("|")})$`),W._zod.parse=(Q,K)=>{let q=Q.value;if(Y.has(q))return Q;return Q.issues.push({code:"invalid_value",values:X.values,input:q,inst:W}),Q}});var j6=w("$ZodTransform",(W,X)=>{g.init(W,X),W._zod.optin="optional",W._zod.parse=(Y,Q)=>{if(Q.direction==="backward")throw new l0(W.constructor.name);let K=X.transform(Y.value,Y);if(Q.async)return(K instanceof Promise?K:Promise.resolve(K)).then((J)=>{return Y.value=J,Y.fallback=!0,Y});if(K instanceof Promise)throw new w0;return Y.value=K,Y.fallback=!0,Y}});function c8(W,X){if(X===void 0&&(W.issues.length||W.fallback))return{issues:[],value:void 0};return W}var F9=w("$ZodOptional",(W,X)=>{g.init(W,X),W._zod.optin="optional",W._zod.optout="optional",T(W._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,void 0]):void 0}),T(W._zod,"pattern",()=>{let Y=X.innerType._zod.pattern;return Y?new RegExp(`^(${r0(Y.source)})?$`):void 0}),W._zod.parse=(Y,Q)=>{if(X.innerType._zod.optin==="optional"){let K=Y.value,q=X.innerType._zod.run(Y,Q);if(q instanceof Promise)return q.then((J)=>c8(J,K));return c8(q,K)}if(Y.value===void 0)return Y;return X.innerType._zod.run(Y,Q)}}),S6=w("$ZodExactOptional",(W,X)=>{F9.init(W,X),T(W._zod,"values",()=>X.innerType._zod.values),T(W._zod,"pattern",()=>X.innerType._zod.pattern),W._zod.parse=(Y,Q)=>{return X.innerType._zod.run(Y,Q)}}),b6=w("$ZodNullable",(W,X)=>{g.init(W,X),T(W._zod,"optin",()=>X.innerType._zod.optin),T(W._zod,"optout",()=>X.innerType._zod.optout),T(W._zod,"pattern",()=>{let Y=X.innerType._zod.pattern;return Y?new RegExp(`^(${r0(Y.source)}|null)$`):void 0}),T(W._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,null]):void 0}),W._zod.parse=(Y,Q)=>{if(Y.value===null)return Y;return X.innerType._zod.run(Y,Q)}}),T6=w("$ZodDefault",(W,X)=>{g.init(W,X),W._zod.optin="optional",T(W._zod,"values",()=>X.innerType._zod.values),W._zod.parse=(Y,Q)=>{if(Q.direction==="backward")return X.innerType._zod.run(Y,Q);if(Y.value===void 0)return Y.value=X.defaultValue,Y;let K=X.innerType._zod.run(Y,Q);if(K instanceof Promise)return K.then((q)=>m8(q,X));return m8(K,X)}});function m8(W,X){if(W.value===void 0)W.value=X.defaultValue;return W}var k6=w("$ZodPrefault",(W,X)=>{g.init(W,X),W._zod.optin="optional",T(W._zod,"values",()=>X.innerType._zod.values),W._zod.parse=(Y,Q)=>{if(Q.direction==="backward")return X.innerType._zod.run(Y,Q);if(Y.value===void 0)Y.value=X.defaultValue;return X.innerType._zod.run(Y,Q)}}),v6=w("$ZodNonOptional",(W,X)=>{g.init(W,X),T(W._zod,"values",()=>{let Y=X.innerType._zod.values;return Y?new Set([...Y].filter((Q)=>Q!==void 0)):void 0}),W._zod.parse=(Y,Q)=>{let K=X.innerType._zod.run(Y,Q);if(K instanceof Promise)return K.then((q)=>u8(q,W));return u8(K,W)}});function u8(W,X){if(!W.issues.length&&W.value===void 0)W.issues.push({code:"invalid_type",expected:"nonoptional",input:W.value,inst:X});return W}var x6=w("$ZodCatch",(W,X)=>{g.init(W,X),W._zod.optin="optional",T(W._zod,"optout",()=>X.innerType._zod.optout),T(W._zod,"values",()=>X.innerType._zod.values),W._zod.parse=(Y,Q)=>{if(Q.direction==="backward")return X.innerType._zod.run(Y,Q);let K=X.innerType._zod.run(Y,Q);if(K instanceof Promise)return K.then((q)=>{if(Y.value=q.value,q.issues.length)Y.value=X.catchValue({...Y,error:{issues:q.issues.map((J)=>J0(J,Q,K0()))},input:Y.value}),Y.issues=[],Y.fallback=!0;return Y});if(Y.value=K.value,K.issues.length)Y.value=X.catchValue({...Y,error:{issues:K.issues.map((q)=>J0(q,Q,K0()))},input:Y.value}),Y.issues=[],Y.fallback=!0;return Y}});var O9=w("$ZodPipe",(W,X)=>{g.init(W,X),T(W._zod,"values",()=>X.in._zod.values),T(W._zod,"optin",()=>X.in._zod.optin),T(W._zod,"optout",()=>X.out._zod.optout),T(W._zod,"propValues",()=>X.in._zod.propValues),W._zod.parse=(Y,Q)=>{if(Q.direction==="backward"){let q=X.out._zod.run(Y,Q);if(q instanceof Promise)return q.then((J)=>C1(J,X.in,Q));return C1(q,X.in,Q)}let K=X.in._zod.run(Y,Q);if(K instanceof Promise)return K.then((q)=>C1(q,X.out,Q));return C1(K,X.out,Q)}});function C1(W,X,Y){if(W.issues.length)return W.aborted=!0,W;return X._zod.run({value:W.value,issues:W.issues,fallback:W.fallback},Y)}var g6=w("$ZodPreprocess",(W,X)=>{O9.init(W,X)}),h6=w("$ZodReadonly",(W,X)=>{g.init(W,X),T(W._zod,"propValues",()=>X.innerType._zod.propValues),T(W._zod,"values",()=>X.innerType._zod.values),T(W._zod,"optin",()=>X.innerType?._zod?.optin),T(W._zod,"optout",()=>X.innerType?._zod?.optout),W._zod.parse=(Y,Q)=>{if(Q.direction==="backward")return X.innerType._zod.run(Y,Q);let K=X.innerType._zod.run(Y,Q);if(K instanceof Promise)return K.then(p8);return p8(K)}});function p8(W){return W.value=Object.freeze(W.value),W}var y6=w("$ZodCustom",(W,X)=>{t.init(W,X),g.init(W,X),W._zod.parse=(Y,Q)=>{return Y},W._zod.check=(Y)=>{let Q=Y.value,K=X.fn(Q);if(K instanceof Promise)return K.then((q)=>l8(q,Y,Q,W));l8(K,Y,Q,W);return}});function l8(W,X,Y,Q){if(!W){let K={code:"custom",input:Y,inst:Q,path:[...Q._zod.def.path??[]],continue:!Q._zod.def.abort};if(Q._zod.def.params)K.params=Q._zod.def.params;X.issues.push(h0(K))}}var wX=()=>{let W={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(K){return W[K]??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"},Q={nan:"NaN"};return(K)=>{switch(K.code){case"invalid_type":{let q=Q[K.expected]??K.expected,J=J9(K.input),G=Q[J]??J;return`Invalid input: expected ${q}, received ${G}`}case"invalid_value":if(K.values.length===1)return`Invalid input: expected ${N1(K.values[0])}`;return`Invalid option: expected one of ${F1(K.values,"|")}`;case"too_big":{let q=K.inclusive?"<=":"<",J=X(K.origin);if(J)return`Too big: expected ${K.origin??"value"} to have ${q}${K.maximum.toString()} ${J.unit??"elements"}`;return`Too big: expected ${K.origin??"value"} to be ${q}${K.maximum.toString()}`}case"too_small":{let q=K.inclusive?">=":">",J=X(K.origin);if(J)return`Too small: expected ${K.origin} to have ${q}${K.minimum.toString()} ${J.unit}`;return`Too small: expected ${K.origin} to be ${q}${K.minimum.toString()}`}case"invalid_format":{let q=K;if(q.format==="starts_with")return`Invalid string: must start with "${q.prefix}"`;if(q.format==="ends_with")return`Invalid string: must end with "${q.suffix}"`;if(q.format==="includes")return`Invalid string: must include "${q.includes}"`;if(q.format==="regex")return`Invalid string: must match pattern ${q.pattern}`;return`Invalid ${Y[q.format]??K.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${K.divisor}`;case"unrecognized_keys":return`Unrecognized key${K.keys.length>1?"s":""}: ${F1(K.keys,", ")}`;case"invalid_key":return`Invalid key in ${K.origin}`;case"invalid_union":if(K.options&&Array.isArray(K.options)&&K.options.length>0)return`Invalid discriminator value. Expected ${K.options.map((J)=>`'${J}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${K.origin}`;default:return"Invalid input"}}};function V9(){return{localeError:wX()}}var f6,z5=Symbol("ZodOutput"),B5=Symbol("ZodInput");class c6{constructor(){this._map=new WeakMap,this._idmap=new Map}add(W,...X){let Y=X[0];if(this._map.set(W,Y),Y&&typeof Y==="object"&&"id"in Y)this._idmap.set(Y.id,W);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(W){let X=this._map.get(W);if(X&&typeof X==="object"&&"id"in X)this._idmap.delete(X.id);return this._map.delete(W),this}get(W){let X=W._zod.parent;if(X){let Y={...this.get(X)??{}};delete Y.id;let Q={...Y,...this._map.get(W)};return Object.keys(Q).length?Q:void 0}return this._map.get(W)}has(W){return this._map.has(W)}}function MX(){return new c6}(f6=globalThis).__zod_globalRegistry??(f6.__zod_globalRegistry=MX());var j0=globalThis.__zod_globalRegistry;function m6(W,X){return new W({type:"string",...I(X)})}function u6(W,X){return new W({type:"string",format:"email",check:"string_format",abort:!1,...I(X)})}function N9(W,X){return new W({type:"string",format:"guid",check:"string_format",abort:!1,...I(X)})}function p6(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,...I(X)})}function l6(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(X)})}function d6(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(X)})}function o6(W,X){return new W({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(X)})}function i6(W,X){return new W({type:"string",format:"url",check:"string_format",abort:!1,...I(X)})}function r6(W,X){return new W({type:"string",format:"emoji",check:"string_format",abort:!1,...I(X)})}function n6(W,X){return new W({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(X)})}function t6(W,X){return new W({type:"string",format:"cuid",check:"string_format",abort:!1,...I(X)})}function a6(W,X){return new W({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(X)})}function s6(W,X){return new W({type:"string",format:"ulid",check:"string_format",abort:!1,...I(X)})}function e6(W,X){return new W({type:"string",format:"xid",check:"string_format",abort:!1,...I(X)})}function W2(W,X){return new W({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(X)})}function X2(W,X){return new W({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(X)})}function Y2(W,X){return new W({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(X)})}function Q2(W,X){return new W({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(X)})}function K2(W,X){return new W({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(X)})}function G2(W,X){return new W({type:"string",format:"base64",check:"string_format",abort:!1,...I(X)})}function q2(W,X){return new W({type:"string",format:"base64url",check:"string_format",abort:!1,...I(X)})}function J2(W,X){return new W({type:"string",format:"e164",check:"string_format",abort:!1,...I(X)})}function z2(W,X){return new W({type:"string",format:"jwt",check:"string_format",abort:!1,...I(X)})}function B2(W,X){return new W({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(X)})}function $2(W,X){return new W({type:"string",format:"date",check:"string_format",...I(X)})}function H2(W,X){return new W({type:"string",format:"time",check:"string_format",precision:null,...I(X)})}function U2(W,X){return new W({type:"string",format:"duration",check:"string_format",...I(X)})}function L2(W,X){return new W({type:"number",checks:[],...I(X)})}function D2(W,X){return new W({type:"number",check:"number_format",abort:!1,format:"safeint",...I(X)})}function w2(W,X){return new W({type:"boolean",...I(X)})}function M2(W,X){return new W({type:"null",...I(X)})}function F2(W){return new W({type:"unknown"})}function O2(W,X){return new W({type:"never",...I(X)})}function j1(W,X){return new H9({check:"less_than",...I(X),value:W,inclusive:!1})}function e0(W,X){return new H9({check:"less_than",...I(X),value:W,inclusive:!0})}function S1(W,X){return new U9({check:"greater_than",...I(X),value:W,inclusive:!1})}function W1(W,X){return new U9({check:"greater_than",...I(X),value:W,inclusive:!0})}function b1(W,X){return new R8({check:"multiple_of",...I(X),value:W})}function T1(W,X){return new I8({check:"max_length",...I(X),maximum:W})}function y0(W,X){return new C8({check:"min_length",...I(X),minimum:W})}function k1(W,X){return new _8({check:"length_equals",...I(X),length:W})}function P9(W,X){return new A8({check:"string_format",format:"regex",...I(X),pattern:W})}function Z9(W){return new j8({check:"string_format",format:"lowercase",...I(W)})}function R9(W){return new S8({check:"string_format",format:"uppercase",...I(W)})}function E9(W,X){return new b8({check:"string_format",format:"includes",...I(X),includes:W})}function I9(W,X){return new T8({check:"string_format",format:"starts_with",...I(X),prefix:W})}function C9(W,X){return new k8({check:"string_format",format:"ends_with",...I(X),suffix:W})}function I0(W){return new v8({check:"overwrite",tx:W})}function _9(W){return I0((X)=>X.normalize(W))}function A9(){return I0((W)=>W.trim())}function j9(){return I0((W)=>W.toLowerCase())}function S9(){return I0((W)=>W.toUpperCase())}function b9(){return I0((W)=>X9(W))}function V2(W,X,Y){return new W({type:"array",element:X,...I(Y)})}function N2(W,X,Y){let Q=I(Y);return Q.abort??(Q.abort=!0),new W({type:"custom",check:"custom",fn:X,...Q})}function P2(W,X,Y){return new W({type:"custom",check:"custom",fn:X,...I(Y)})}function Z2(W,X){let Y=FX((Q)=>{return Q.addIssue=(K)=>{if(typeof K==="string")Q.issues.push(h0(K,Q.value,Y._zod.def));else{let q=K;if(q.fatal)q.continue=!1;q.code??(q.code="custom"),q.input??(q.input=Q.value),q.inst??(q.inst=Y),q.continue??(q.continue=!Y._zod.def.abort),Q.issues.push(h0(q))}},W(Q.value,Q)},X);return Y}function FX(W,X){let Y=new t({check:"custom",...I(X)});return Y._zod.check=W,Y}function T9(W){let X=W?.target??"draft-2020-12";if(X==="draft-4")X="draft-04";if(X==="draft-7")X="draft-07";return{processors:W.processors??{},metadataRegistry:W?.metadata??j0,target:X,unrepresentable:W?.unrepresentable??"throw",override:W?.override??(()=>{}),io:W?.io??"output",counter:0,seen:new Map,cycles:W?.cycles??"ref",reused:W?.reused??"inline",external:W?.external??void 0}}function d(W,X,Y={path:[],schemaPath:[]}){var Q;let K=W._zod.def,q=X.seen.get(W);if(q){if(q.count++,Y.schemaPath.includes(W))q.cycle=Y.path;return q.schema}let J={schema:{},count:1,cycle:void 0,path:Y.path};X.seen.set(W,J);let G=W._zod.toJSONSchema?.();if(G)J.schema=G;else{let O={...Y,schemaPath:[...Y.schemaPath,W],path:Y.path};if(W._zod.processJSONSchema)W._zod.processJSONSchema(X,J.schema,O);else{let R=J.schema,P=X.processors[K.type];if(!P)throw Error(`[toJSONSchema]: Non-representable type encountered: ${K.type}`);P(W,X,R,O)}let V=W._zod.parent;if(V){if(!J.ref)J.ref=V;d(V,X,O),X.seen.get(V).isParent=!0}}let H=X.metadataRegistry.get(W);if(H)Object.assign(J.schema,H);if(X.io==="input"&&e(W))delete J.schema.examples,delete J.schema.default;if(X.io==="input"&&"_prefault"in J.schema)(Q=J.schema).default??(Q.default=J.schema._prefault);return delete J.schema._prefault,X.seen.get(W).schema}function k9(W,X){let Y=W.seen.get(X);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let Q=new Map;for(let J of W.seen.entries()){let G=W.metadataRegistry.get(J[0])?.id;if(G){let H=Q.get(G);if(H&&H!==J[0])throw Error(`Duplicate schema id "${G}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);Q.set(G,J[0])}}let K=(J)=>{let G=W.target==="draft-2020-12"?"$defs":"definitions";if(W.external){let V=W.external.registry.get(J[0])?.id,R=W.external.uri??((b)=>b);if(V)return{ref:R(V)};let P=J[1].defId??J[1].schema.id??`schema${W.counter++}`;return J[1].defId=P,{defId:P,ref:`${R("__shared")}#/${G}/${P}`}}if(J[1]===Y)return{ref:"#"};let D=`${"#"}/${G}/`,O=J[1].schema.id??`__schema${W.counter++}`;return{defId:O,ref:D+O}},q=(J)=>{if(J[1].schema.$ref)return;let G=J[1],{ref:H,defId:D}=K(J);if(G.def={...G.schema},D)G.defId=D;let O=G.schema;for(let V in O)delete O[V];O.$ref=H};if(W.cycles==="throw")for(let J of W.seen.entries()){let G=J[1];if(G.cycle)throw Error(`Cycle detected: #/${G.cycle?.join("/")}/<root>
44
69
 
45
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let J of W.seen.entries()){let G=J[1];if(X===J[0]){q(J);continue}if(W.external){let D=W.external.registry.get(J[0])?.id;if(X!==J[0]&&D){q(J);continue}}if(W.metadataRegistry.get(J[0])?.id){q(J);continue}if(G.cycle){q(J);continue}if(G.count>1){if(W.reused==="ref"){q(J);continue}}}}function j9(W,X){let K=W.seen.get(X);if(!K)throw Error("Unprocessed schema. This is a bug in Zod.");let Y=(J)=>{let G=W.seen.get(J);if(G.ref===null)return;let H=G.def??G.schema,D={...H},F=G.ref;if(G.ref=null,F){Y(F);let E=W.seen.get(F),R=E.schema;if(R.$ref&&(W.target==="draft-07"||W.target==="draft-04"||W.target==="openapi-3.0"))H.allOf=H.allOf??[],H.allOf.push(R);else Object.assign(H,R);if(Object.assign(H,D),J._zod.parent===F)for(let l in H){if(l==="$ref"||l==="allOf")continue;if(!(l in D))delete H[l]}if(R.$ref&&E.def)for(let l in H){if(l==="$ref"||l==="allOf")continue;if(l in E.def&&JSON.stringify(H[l])===JSON.stringify(E.def[l]))delete H[l]}}let N=J._zod.parent;if(N&&N!==F){Y(N);let E=W.seen.get(N);if(E?.schema.$ref){if(H.$ref=E.schema.$ref,E.def)for(let R in H){if(R==="$ref"||R==="allOf")continue;if(R in E.def&&JSON.stringify(H[R])===JSON.stringify(E.def[R]))delete H[R]}}}W.override({zodSchema:J,jsonSchema:H,path:G.path??[]})};for(let J of[...W.seen.entries()].reverse())Y(J[0]);let Q={};if(W.target==="draft-2020-12")Q.$schema="https://json-schema.org/draft/2020-12/schema";else if(W.target==="draft-07")Q.$schema="http://json-schema.org/draft-07/schema#";else if(W.target==="draft-04")Q.$schema="http://json-schema.org/draft-04/schema#";else if(W.target==="openapi-3.0");if(W.external?.uri){let J=W.external.registry.get(X)?.id;if(!J)throw Error("Schema is missing an `id` property");Q.$id=W.external.uri(J)}Object.assign(Q,K.def??K.schema);let q=W.external?.defs??{};for(let J of W.seen.entries()){let G=J[1];if(G.def&&G.defId)q[G.defId]=G.def}if(W.external);else if(Object.keys(q).length>0)if(W.target==="draft-2020-12")Q.$defs=q;else Q.definitions=q;try{let J=JSON.parse(JSON.stringify(Q));return Object.defineProperty(J,"~standard",{value:{...X["~standard"],jsonSchema:{input:a0(X,"input",W.processors),output:a0(X,"output",W.processors)}},enumerable:!1,writable:!1}),J}catch(J){throw Error("Error converting schema to JSON.")}}function e(W,X){let K=X??{seen:new Set};if(K.seen.has(W))return!1;K.seen.add(W);let Y=W._zod.def;if(Y.type==="transform")return!0;if(Y.type==="array")return e(Y.element,K);if(Y.type==="set")return e(Y.valueType,K);if(Y.type==="lazy")return e(Y.getter(),K);if(Y.type==="promise"||Y.type==="optional"||Y.type==="nonoptional"||Y.type==="nullable"||Y.type==="readonly"||Y.type==="default"||Y.type==="prefault")return e(Y.innerType,K);if(Y.type==="intersection")return e(Y.left,K)||e(Y.right,K);if(Y.type==="record"||Y.type==="map")return e(Y.keyType,K)||e(Y.valueType,K);if(Y.type==="pipe")return e(Y.in,K)||e(Y.out,K);if(Y.type==="object"){for(let Q in Y.shape)if(e(Y.shape[Q],K))return!0;return!1}if(Y.type==="union"){for(let Q of Y.options)if(e(Q,K))return!0;return!1}if(Y.type==="tuple"){for(let Q of Y.items)if(e(Q,K))return!0;if(Y.rest&&e(Y.rest,K))return!0;return!1}return!1}var N2=(W,X={})=>(K)=>{let Y=S9({...K,processors:X});return p(W,Y),A9(Y,W),j9(Y,W)},a0=(W,X,K={})=>(Y)=>{let{libraryOptions:Q,target:q}=Y??{},J=S9({...Q??{},target:q,io:X,processors:K});return p(W,J),A9(J,W),j9(J,W)};var HX={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},V2=(W,X,K,Y)=>{let Q=K;Q.type="string";let{minimum:q,maximum:J,format:G,patterns:H,contentEncoding:D}=W._zod.bag;if(typeof q==="number")Q.minLength=q;if(typeof J==="number")Q.maxLength=J;if(G){if(Q.format=HX[G]??G,Q.format==="")delete Q.format;if(G==="time")delete Q.format}if(D)Q.contentEncoding=D;if(H&&H.size>0){let F=[...H];if(F.length===1)Q.pattern=F[0].source;else if(F.length>1)Q.allOf=[...F.map((N)=>({...X.target==="draft-07"||X.target==="draft-04"||X.target==="openapi-3.0"?{type:"string"}:{},pattern:N.source}))]}},P2=(W,X,K,Y)=>{let Q=K,{minimum:q,maximum:J,format:G,multipleOf:H,exclusiveMaximum:D,exclusiveMinimum:F}=W._zod.bag;if(typeof G==="string"&&G.includes("int"))Q.type="integer";else Q.type="number";if(typeof F==="number")if(X.target==="draft-04"||X.target==="openapi-3.0")Q.minimum=F,Q.exclusiveMinimum=!0;else Q.exclusiveMinimum=F;if(typeof q==="number"){if(Q.minimum=q,typeof F==="number"&&X.target!=="draft-04")if(F>=q)delete Q.minimum;else delete Q.exclusiveMinimum}if(typeof D==="number")if(X.target==="draft-04"||X.target==="openapi-3.0")Q.maximum=D,Q.exclusiveMaximum=!0;else Q.exclusiveMaximum=D;if(typeof J==="number"){if(Q.maximum=J,typeof D==="number"&&X.target!=="draft-04")if(D<=J)delete Q.maximum;else delete Q.exclusiveMaximum}if(typeof H==="number")Q.multipleOf=H},R2=(W,X,K,Y)=>{K.type="boolean"};var Z2=(W,X,K,Y)=>{if(X.target==="openapi-3.0")K.type="string",K.nullable=!0,K.enum=[null];else K.type="null"};var E2=(W,X,K,Y)=>{K.not={}};var I2=(W,X,K,Y)=>{};var C2=(W,X,K,Y)=>{let Q=W._zod.def,q=u0(Q.entries);if(q.every((J)=>typeof J==="number"))K.type="number";if(q.every((J)=>typeof J==="string"))K.type="string";K.enum=q},_2=(W,X,K,Y)=>{let Q=W._zod.def,q=[];for(let J of Q.values)if(J===void 0){if(X.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof J==="bigint")if(X.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else q.push(Number(J));else q.push(J);if(q.length===0);else if(q.length===1){let J=q[0];if(K.type=J===null?"null":typeof J,X.target==="draft-04"||X.target==="openapi-3.0")K.enum=[J];else K.const=J}else{if(q.every((J)=>typeof J==="number"))K.type="number";if(q.every((J)=>typeof J==="string"))K.type="string";if(q.every((J)=>typeof J==="boolean"))K.type="boolean";if(q.every((J)=>J===null))K.type="null";K.enum=q}};var S2=(W,X,K,Y)=>{if(X.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")};var A2=(W,X,K,Y)=>{if(X.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")};var j2=(W,X,K,Y)=>{let Q=K,q=W._zod.def,{minimum:J,maximum:G}=W._zod.bag;if(typeof J==="number")Q.minItems=J;if(typeof G==="number")Q.maxItems=G;Q.type="array",Q.items=p(q.element,X,{...Y,path:[...Y.path,"items"]})},b2=(W,X,K,Y)=>{let Q=K,q=W._zod.def;Q.type="object",Q.properties={};let J=q.shape;for(let D in J)Q.properties[D]=p(J[D],X,{...Y,path:[...Y.path,"properties",D]});let G=new Set(Object.keys(J)),H=new Set([...G].filter((D)=>{let F=q.shape[D]._zod;if(X.io==="input")return F.optin===void 0;else return F.optout===void 0}));if(H.size>0)Q.required=Array.from(H);if(q.catchall?._zod.def.type==="never")Q.additionalProperties=!1;else if(!q.catchall){if(X.io==="output")Q.additionalProperties=!1}else if(q.catchall)Q.additionalProperties=p(q.catchall,X,{...Y,path:[...Y.path,"additionalProperties"]})},T2=(W,X,K,Y)=>{let Q=W._zod.def,q=Q.inclusive===!1,J=Q.options.map((G,H)=>p(G,X,{...Y,path:[...Y.path,q?"oneOf":"anyOf",H]}));if(q)K.oneOf=J;else K.anyOf=J},k2=(W,X,K,Y)=>{let Q=W._zod.def,q=p(Q.left,X,{...Y,path:[...Y.path,"allOf",0]}),J=p(Q.right,X,{...Y,path:[...Y.path,"allOf",1]}),G=(D)=>("allOf"in D)&&Object.keys(D).length===1,H=[...G(q)?q.allOf:[q],...G(J)?J.allOf:[J]];K.allOf=H};var v2=(W,X,K,Y)=>{let Q=K,q=W._zod.def;Q.type="object";let J=q.keyType,H=J._zod.bag?.patterns;if(q.mode==="loose"&&H&&H.size>0){let F=p(q.valueType,X,{...Y,path:[...Y.path,"patternProperties","*"]});Q.patternProperties={};for(let N of H)Q.patternProperties[N.source]=F}else{if(X.target==="draft-07"||X.target==="draft-2020-12")Q.propertyNames=p(q.keyType,X,{...Y,path:[...Y.path,"propertyNames"]});Q.additionalProperties=p(q.valueType,X,{...Y,path:[...Y.path,"additionalProperties"]})}let D=J._zod.values;if(D){let F=[...D].filter((N)=>typeof N==="string"||typeof N==="number");if(F.length>0)Q.required=F}},x2=(W,X,K,Y)=>{let Q=W._zod.def,q=p(Q.innerType,X,Y),J=X.seen.get(W);if(X.target==="openapi-3.0")J.ref=Q.innerType,K.nullable=!0;else K.anyOf=[q,{type:"null"}]},h2=(W,X,K,Y)=>{let Q=W._zod.def;p(Q.innerType,X,Y);let q=X.seen.get(W);q.ref=Q.innerType},g2=(W,X,K,Y)=>{let Q=W._zod.def;p(Q.innerType,X,Y);let q=X.seen.get(W);q.ref=Q.innerType,K.default=JSON.parse(JSON.stringify(Q.defaultValue))},y2=(W,X,K,Y)=>{let Q=W._zod.def;p(Q.innerType,X,Y);let q=X.seen.get(W);if(q.ref=Q.innerType,X.io==="input")K._prefault=JSON.parse(JSON.stringify(Q.defaultValue))},f2=(W,X,K,Y)=>{let Q=W._zod.def;p(Q.innerType,X,Y);let q=X.seen.get(W);q.ref=Q.innerType;let J;try{J=Q.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}K.default=J},c2=(W,X,K,Y)=>{let Q=W._zod.def,q=X.io==="input"?Q.in._zod.def.type==="transform"?Q.out:Q.in:Q.out;p(q,X,Y);let J=X.seen.get(W);J.ref=q},m2=(W,X,K,Y)=>{let Q=W._zod.def;p(Q.innerType,X,Y);let q=X.seen.get(W);q.ref=Q.innerType,K.readOnly=!0};var b9=(W,X,K,Y)=>{let Q=W._zod.def;p(Q.innerType,X,Y);let q=X.seen.get(W);q.ref=Q.innerType};var e0={};n1(e0,{time:()=>v9,duration:()=>x9,datetime:()=>T9,date:()=>k9,ZodISOTime:()=>l2,ZodISODuration:()=>d2,ZodISODateTime:()=>u2,ZodISODate:()=>p2});var u2=w("ZodISODateTime",(W,X)=>{s8.init(W,X),g.init(W,X)});function T9(W){return G2(u2,W)}var p2=w("ZodISODate",(W,X)=>{e8.init(W,X),g.init(W,X)});function k9(W){return q2(p2,W)}var l2=w("ZodISOTime",(W,X)=>{W4.init(W,X),g.init(W,X)});function v9(W){return J2(l2,W)}var d2=w("ZodISODuration",(W,X)=>{X4.init(W,X),g.init(W,X)});function x9(W){return z2(d2,W)}var o2=(W,X)=>{F1.init(W,X),W.name="ZodError",Object.defineProperties(W,{format:{value:(K)=>v6(W,K)},flatten:{value:(K)=>k6(W,K)},addIssue:{value:(K)=>{W.issues.push(K),W.message=JSON.stringify(W.issues,k0,2)}},addIssues:{value:(K)=>{W.issues.push(...K),W.message=JSON.stringify(W.issues,k0,2)}},isEmpty:{get(){return W.issues.length===0}}})},b7=w("ZodError",o2),G0=w("ZodError",o2,{Parent:Error});var r2=N1(G0),i2=V1(G0),n2=o0(G0),t2=r0(G0),a2=g6(G0),s2=y6(G0),e2=f6(G0),WW=c6(G0),XW=m6(G0),KW=u6(G0),YW=p6(G0),QW=l6(G0);var c=w("ZodType",(W,X)=>{return v.init(W,X),Object.assign(W["~standard"],{jsonSchema:{input:a0(W,"input"),output:a0(W,"output")}}),W.toJSONSchema=N2(W,{}),W.def=X,W.type=X.type,Object.defineProperty(W,"_def",{value:X}),W.check=(...K)=>{return W.clone(j.mergeDefs(X,{checks:[...X.checks??[],...K.map((Y)=>typeof Y==="function"?{_zod:{check:Y,def:{check:"custom"},onattach:[]}}:Y)]}),{parent:!0})},W.with=W.check,W.clone=(K,Y)=>H0(W,K,Y),W.brand=()=>W,W.register=(K,Y)=>{return K.add(W,Y),W},W.parse=(K,Y)=>r2(W,K,Y,{callee:W.parse}),W.safeParse=(K,Y)=>n2(W,K,Y),W.parseAsync=async(K,Y)=>i2(W,K,Y,{callee:W.parseAsync}),W.safeParseAsync=async(K,Y)=>t2(W,K,Y),W.spa=W.safeParseAsync,W.encode=(K,Y)=>a2(W,K,Y),W.decode=(K,Y)=>s2(W,K,Y),W.encodeAsync=async(K,Y)=>e2(W,K,Y),W.decodeAsync=async(K,Y)=>WW(W,K,Y),W.safeEncode=(K,Y)=>XW(W,K,Y),W.safeDecode=(K,Y)=>KW(W,K,Y),W.safeEncodeAsync=async(K,Y)=>YW(W,K,Y),W.safeDecodeAsync=async(K,Y)=>QW(W,K,Y),W.refine=(K,Y)=>W.check($K(K,Y)),W.superRefine=(K)=>W.check(HK(K)),W.overwrite=(K)=>W.check(I0(K)),W.optional=()=>f(W),W.exactOptional=()=>sX(W),W.nullable=()=>JW(W),W.nullish=()=>f(JW(W)),W.nonoptional=(K)=>QK(W,K),W.array=()=>S(W),W.or=(K)=>h([W,K]),W.and=(K)=>T1(W,K),W.transform=(K)=>g9(W,LW(K)),W.default=(K)=>XK(W,K),W.prefault=(K)=>YK(W,K),W.catch=(K)=>qK(W,K),W.pipe=(K)=>g9(W,K),W.readonly=()=>BK(W),W.describe=(K)=>{let Y=W.clone();return A0.add(Y,{description:K}),Y},Object.defineProperty(W,"description",{get(){return A0.get(W)?.description},configurable:!0}),W.meta=(...K)=>{if(K.length===0)return A0.get(W);let Y=W.clone();return A0.add(Y,K[0]),Y},W.isOptional=()=>W.safeParse(void 0).success,W.isNullable=()=>W.safeParse(null).success,W.apply=(K)=>K(W),W}),zW=w("_ZodString",(W,X)=>{I1.init(W,X),c.init(W,X),W._zod.processJSONSchema=(Y,Q,q)=>V2(W,Y,Q,q);let K=W._zod.bag;W.format=K.format??null,W.minLength=K.minimum??null,W.maxLength=K.maximum??null,W.regex=(...Y)=>W.check(O9(...Y)),W.includes=(...Y)=>W.check(V9(...Y)),W.startsWith=(...Y)=>W.check(P9(...Y)),W.endsWith=(...Y)=>W.check(R9(...Y)),W.min=(...Y)=>W.check(h0(...Y)),W.max=(...Y)=>W.check(A1(...Y)),W.length=(...Y)=>W.check(j1(...Y)),W.nonempty=(...Y)=>W.check(h0(1,...Y)),W.lowercase=(Y)=>W.check(F9(Y)),W.uppercase=(Y)=>W.check(N9(Y)),W.trim=()=>W.check(E9()),W.normalize=(...Y)=>W.check(Z9(...Y)),W.toLowerCase=()=>W.check(I9()),W.toUpperCase=()=>W.check(C9()),W.slugify=()=>W.check(_9())}),PX=w("ZodString",(W,X)=>{I1.init(W,X),zW.init(W,X),W.email=(K)=>W.check(y4(RX,K)),W.url=(K)=>W.check(p4(ZX,K)),W.jwt=(K)=>W.check(Q2(yX,K)),W.emoji=(K)=>W.check(l4(EX,K)),W.guid=(K)=>W.check(M9(GW,K)),W.uuid=(K)=>W.check(f4(b1,K)),W.uuidv4=(K)=>W.check(c4(b1,K)),W.uuidv6=(K)=>W.check(m4(b1,K)),W.uuidv7=(K)=>W.check(u4(b1,K)),W.nanoid=(K)=>W.check(d4(IX,K)),W.guid=(K)=>W.check(M9(GW,K)),W.cuid=(K)=>W.check(o4(CX,K)),W.cuid2=(K)=>W.check(r4(_X,K)),W.ulid=(K)=>W.check(i4(SX,K)),W.base64=(K)=>W.check(X2(xX,K)),W.base64url=(K)=>W.check(K2(hX,K)),W.xid=(K)=>W.check(n4(AX,K)),W.ksuid=(K)=>W.check(t4(jX,K)),W.ipv4=(K)=>W.check(a4(bX,K)),W.ipv6=(K)=>W.check(s4(TX,K)),W.cidrv4=(K)=>W.check(e4(kX,K)),W.cidrv6=(K)=>W.check(W2(vX,K)),W.e164=(K)=>W.check(Y2(gX,K)),W.datetime=(K)=>W.check(T9(K)),W.date=(K)=>W.check(k9(K)),W.time=(K)=>W.check(v9(K)),W.duration=(K)=>W.check(x9(K))});function L(W){return g4(PX,W)}var g=w("ZodStringFormat",(W,X)=>{x.init(W,X),zW.init(W,X)}),RX=w("ZodEmail",(W,X)=>{p8.init(W,X),g.init(W,X)});var GW=w("ZodGUID",(W,X)=>{m8.init(W,X),g.init(W,X)});var b1=w("ZodUUID",(W,X)=>{u8.init(W,X),g.init(W,X)});var ZX=w("ZodURL",(W,X)=>{l8.init(W,X),g.init(W,X)});var EX=w("ZodEmoji",(W,X)=>{d8.init(W,X),g.init(W,X)});var IX=w("ZodNanoID",(W,X)=>{o8.init(W,X),g.init(W,X)});var CX=w("ZodCUID",(W,X)=>{r8.init(W,X),g.init(W,X)});var _X=w("ZodCUID2",(W,X)=>{i8.init(W,X),g.init(W,X)});var SX=w("ZodULID",(W,X)=>{n8.init(W,X),g.init(W,X)});var AX=w("ZodXID",(W,X)=>{t8.init(W,X),g.init(W,X)});var jX=w("ZodKSUID",(W,X)=>{a8.init(W,X),g.init(W,X)});var bX=w("ZodIPv4",(W,X)=>{K4.init(W,X),g.init(W,X)});var TX=w("ZodIPv6",(W,X)=>{Y4.init(W,X),g.init(W,X)});var kX=w("ZodCIDRv4",(W,X)=>{Q4.init(W,X),g.init(W,X)});var vX=w("ZodCIDRv6",(W,X)=>{G4.init(W,X),g.init(W,X)});var xX=w("ZodBase64",(W,X)=>{J4.init(W,X),g.init(W,X)});var hX=w("ZodBase64URL",(W,X)=>{z4.init(W,X),g.init(W,X)});var gX=w("ZodE164",(W,X)=>{B4.init(W,X),g.init(W,X)});var yX=w("ZodJWT",(W,X)=>{$4.init(W,X),g.init(W,X)});var BW=w("ZodNumber",(W,X)=>{U9.init(W,X),c.init(W,X),W._zod.processJSONSchema=(Y,Q,q)=>P2(W,Y,Q,q),W.gt=(Y,Q)=>W.check(_1(Y,Q)),W.gte=(Y,Q)=>W.check(t0(Y,Q)),W.min=(Y,Q)=>W.check(t0(Y,Q)),W.lt=(Y,Q)=>W.check(C1(Y,Q)),W.lte=(Y,Q)=>W.check(n0(Y,Q)),W.max=(Y,Q)=>W.check(n0(Y,Q)),W.int=(Y)=>W.check(qW(Y)),W.safe=(Y)=>W.check(qW(Y)),W.positive=(Y)=>W.check(_1(0,Y)),W.nonnegative=(Y)=>W.check(t0(0,Y)),W.negative=(Y)=>W.check(C1(0,Y)),W.nonpositive=(Y)=>W.check(n0(0,Y)),W.multipleOf=(Y,Q)=>W.check(S1(Y,Q)),W.step=(Y,Q)=>W.check(S1(Y,Q)),W.finite=()=>W;let K=W._zod.bag;W.minValue=Math.max(K.minimum??Number.NEGATIVE_INFINITY,K.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,W.maxValue=Math.min(K.maximum??Number.POSITIVE_INFINITY,K.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,W.isInt=(K.format??"").includes("int")||Number.isSafeInteger(K.multipleOf??0.5),W.isFinite=!0,W.format=K.format??null});function T(W){return B2(BW,W)}var fX=w("ZodNumberFormat",(W,X)=>{H4.init(W,X),BW.init(W,X)});function qW(W){return $2(fX,W)}var cX=w("ZodBoolean",(W,X)=>{U4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>R2(W,K,Y,Q)});function i(W){return H2(cX,W)}var mX=w("ZodNull",(W,X)=>{L4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>Z2(W,K,Y,Q)});function $W(W){return U2(mX,W)}var uX=w("ZodUnknown",(W,X)=>{w4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>I2(W,K,Y,Q)});function y(){return L2(uX)}var pX=w("ZodNever",(W,X)=>{D4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>E2(W,K,Y,Q)});function lX(W){return w2(pX,W)}var dX=w("ZodArray",(W,X)=>{M4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>j2(W,K,Y,Q),W.element=X.element,W.min=(K,Y)=>W.check(h0(K,Y)),W.nonempty=(K)=>W.check(h0(1,K)),W.max=(K,Y)=>W.check(A1(K,Y)),W.length=(K,Y)=>W.check(j1(K,Y)),W.unwrap=()=>W.element});function S(W,X){return D2(dX,W,X)}var HW=w("ZodObject",(W,X)=>{N4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>b2(W,K,Y,Q),j.defineLazy(W,"shape",()=>{return X.shape}),W.keyof=()=>Q0(Object.keys(W._zod.def.shape)),W.catchall=(K)=>W.clone({...W._zod.def,catchall:K}),W.passthrough=()=>W.clone({...W._zod.def,catchall:y()}),W.loose=()=>W.clone({...W._zod.def,catchall:y()}),W.strict=()=>W.clone({...W._zod.def,catchall:lX()}),W.strip=()=>W.clone({...W._zod.def,catchall:void 0}),W.extend=(K)=>{return j.extend(W,K)},W.safeExtend=(K)=>{return j.safeExtend(W,K)},W.merge=(K)=>j.merge(W,K),W.pick=(K)=>j.pick(W,K),W.omit=(K)=>j.omit(W,K),W.partial=(...K)=>j.partial(wW,W,K[0]),W.required=(...K)=>j.required(DW,W,K[0])});function P(W,X){let K={type:"object",shape:W??{},...j.normalizeParams(X)};return new HW(K)}function W0(W,X){return new HW({type:"object",shape:W,catchall:y(),...j.normalizeParams(X)})}var UW=w("ZodUnion",(W,X)=>{L9.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>T2(W,K,Y,Q),W.options=X.options});function h(W,X){return new UW({type:"union",options:W,...j.normalizeParams(X)})}var oX=w("ZodDiscriminatedUnion",(W,X)=>{UW.init(W,X),V4.init(W,X)});function y9(W,X,K){return new oX({type:"union",options:X,discriminator:W,...j.normalizeParams(K)})}var rX=w("ZodIntersection",(W,X)=>{P4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>k2(W,K,Y,Q)});function T1(W,X){return new rX({type:"intersection",left:W,right:X})}var iX=w("ZodRecord",(W,X)=>{R4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>v2(W,K,Y,Q),W.keyType=X.keyType,W.valueType=X.valueType});function k(W,X,K){return new iX({type:"record",keyType:W,valueType:X,...j.normalizeParams(K)})}var h9=w("ZodEnum",(W,X)=>{Z4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(Y,Q,q)=>C2(W,Y,Q,q),W.enum=X.entries,W.options=Object.values(X.entries);let K=new Set(Object.keys(X.entries));W.extract=(Y,Q)=>{let q={};for(let J of Y)if(K.has(J))q[J]=X.entries[J];else throw Error(`Key ${J} not found in enum`);return new h9({...X,checks:[],...j.normalizeParams(Q),entries:q})},W.exclude=(Y,Q)=>{let q={...X.entries};for(let J of Y)if(K.has(J))delete q[J];else throw Error(`Key ${J} not found in enum`);return new h9({...X,checks:[],...j.normalizeParams(Q),entries:q})}});function Q0(W,X){let K=Array.isArray(W)?Object.fromEntries(W.map((Y)=>[Y,Y])):W;return new h9({type:"enum",entries:K,...j.normalizeParams(X)})}var nX=w("ZodLiteral",(W,X)=>{E4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>_2(W,K,Y,Q),W.values=new Set(X.values),Object.defineProperty(W,"value",{get(){if(X.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return X.values[0]}})});function Z(W,X){return new nX({type:"literal",values:Array.isArray(W)?W:[W],...j.normalizeParams(X)})}var tX=w("ZodTransform",(W,X)=>{I4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>A2(W,K,Y,Q),W._zod.parse=(K,Y)=>{if(Y.direction==="backward")throw new c0(W.constructor.name);K.addIssue=(q)=>{if(typeof q==="string")K.issues.push(j.issue(q,K.value,X));else{let J=q;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=K.value),J.inst??(J.inst=W),K.issues.push(j.issue(J))}};let Q=X.transform(K.value,K);if(Q instanceof Promise)return Q.then((q)=>{return K.value=q,K});return K.value=Q,K}});function LW(W){return new tX({type:"transform",transform:W})}var wW=w("ZodOptional",(W,X)=>{w9.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>b9(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType});function f(W){return new wW({type:"optional",innerType:W})}var aX=w("ZodExactOptional",(W,X)=>{C4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>b9(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType});function sX(W){return new aX({type:"optional",innerType:W})}var eX=w("ZodNullable",(W,X)=>{_4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>x2(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType});function JW(W){return new eX({type:"nullable",innerType:W})}var WK=w("ZodDefault",(W,X)=>{S4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>g2(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType,W.removeDefault=W.unwrap});function XK(W,X){return new WK({type:"default",innerType:W,get defaultValue(){return typeof X==="function"?X():j.shallowClone(X)}})}var KK=w("ZodPrefault",(W,X)=>{A4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>y2(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType});function YK(W,X){return new KK({type:"prefault",innerType:W,get defaultValue(){return typeof X==="function"?X():j.shallowClone(X)}})}var DW=w("ZodNonOptional",(W,X)=>{j4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>h2(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType});function QK(W,X){return new DW({type:"nonoptional",innerType:W,...j.normalizeParams(X)})}var GK=w("ZodCatch",(W,X)=>{b4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>f2(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType,W.removeCatch=W.unwrap});function qK(W,X){return new GK({type:"catch",innerType:W,catchValue:typeof X==="function"?X:()=>X})}var JK=w("ZodPipe",(W,X)=>{T4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>c2(W,K,Y,Q),W.in=X.in,W.out=X.out});function g9(W,X){return new JK({type:"pipe",in:W,out:X})}var zK=w("ZodReadonly",(W,X)=>{k4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>m2(W,K,Y,Q),W.unwrap=()=>W._zod.def.innerType});function BK(W){return new zK({type:"readonly",innerType:W})}var MW=w("ZodCustom",(W,X)=>{v4.init(W,X),c.init(W,X),W._zod.processJSONSchema=(K,Y,Q)=>S2(W,K,Y,Q)});function OW(W,X){return M2(MW,W??(()=>!0),X)}function $K(W,X={}){return O2(MW,W,X)}function HK(W){return F2(W)}function f9(W,X){return g9(LW(W),X)}J0(D9());var UK="io.modelcontextprotocol/related-task",v1="2.0",d=OW((W)=>W!==null&&(typeof W==="object"||typeof W==="function")),NW=h([L(),T().int()]),VW=L(),i5=W0({ttl:T().optional(),pollInterval:T().optional()}),LK=P({ttl:T().optional()}),wK=P({taskId:L()}),c9=W0({progressToken:NW.optional(),[UK]:wK.optional()}),q0=P({_meta:c9.optional()}),x1=q0.extend({task:LK.optional()});var a=P({method:L(),params:q0.loose().optional()}),z0=P({_meta:c9.optional()}),B0=P({method:L(),params:z0.loose().optional()}),s=W0({_meta:c9.optional()}),h1=h([L(),T().int()]),DK=P({jsonrpc:Z(v1),id:h1,...a.shape}).strict();var MK=P({jsonrpc:Z(v1),...B0.shape}).strict();var PW=P({jsonrpc:Z(v1),id:h1,result:s}).strict();var FW;(function(W){W[W.ConnectionClosed=-32000]="ConnectionClosed",W[W.RequestTimeout=-32001]="RequestTimeout",W[W.ParseError=-32700]="ParseError",W[W.InvalidRequest=-32600]="InvalidRequest",W[W.MethodNotFound=-32601]="MethodNotFound",W[W.InvalidParams=-32602]="InvalidParams",W[W.InternalError=-32603]="InternalError",W[W.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(FW||(FW={}));var RW=P({jsonrpc:Z(v1),id:h1.optional(),error:P({code:T().int(),message:L(),data:y().optional()})}).strict();var ZW=h([DK,MK,PW,RW]),n5=h([PW,RW]),EW=s.strict(),OK=z0.extend({requestId:h1.optional(),reason:L().optional()}),IW=B0.extend({method:Z("notifications/cancelled"),params:OK}),FK=P({src:L(),mimeType:L().optional(),sizes:S(L()).optional(),theme:Q0(["light","dark"]).optional()}),W1=P({icons:S(FK).optional()}),g0=P({name:L(),title:L().optional()}),CW=g0.extend({...g0.shape,...W1.shape,version:L(),websiteUrl:L().optional(),description:L().optional()}),NK=T1(P({applyDefaults:i().optional()}),k(L(),y())),VK=f9((W)=>{if(W&&typeof W==="object"&&!Array.isArray(W)){if(Object.keys(W).length===0)return{form:{}}}return W},T1(P({form:NK.optional(),url:d.optional()}),k(L(),y()).optional())),PK=W0({list:d.optional(),cancel:d.optional(),requests:W0({sampling:W0({createMessage:d.optional()}).optional(),elicitation:W0({create:d.optional()}).optional()}).optional()}),RK=W0({list:d.optional(),cancel:d.optional(),requests:W0({tools:W0({call:d.optional()}).optional()}).optional()}),ZK=P({experimental:k(L(),d).optional(),sampling:P({context:d.optional(),tools:d.optional()}).optional(),elicitation:VK.optional(),roots:P({listChanged:i().optional()}).optional(),tasks:PK.optional(),extensions:k(L(),d).optional()}),EK=q0.extend({protocolVersion:L(),capabilities:ZK,clientInfo:CW}),IK=a.extend({method:Z("initialize"),params:EK});var CK=P({experimental:k(L(),d).optional(),logging:d.optional(),completions:d.optional(),prompts:P({listChanged:i().optional()}).optional(),resources:P({subscribe:i().optional(),listChanged:i().optional()}).optional(),tools:P({listChanged:i().optional()}).optional(),tasks:RK.optional(),extensions:k(L(),d).optional()}),_K=s.extend({protocolVersion:L(),capabilities:CK,serverInfo:CW,instructions:L().optional()}),SK=B0.extend({method:Z("notifications/initialized"),params:z0.optional()});var _W=a.extend({method:Z("ping"),params:q0.optional()}),AK=P({progress:T(),total:f(T()),message:f(L())}),jK=P({...z0.shape,...AK.shape,progressToken:NW}),SW=B0.extend({method:Z("notifications/progress"),params:jK}),bK=q0.extend({cursor:VW.optional()}),X1=a.extend({params:bK.optional()}),K1=s.extend({nextCursor:VW.optional()}),TK=Q0(["working","input_required","completed","failed","cancelled"]),Y1=P({taskId:L(),status:TK,ttl:h([T(),$W()]),createdAt:L(),lastUpdatedAt:L(),pollInterval:f(T()),statusMessage:f(L())}),AW=s.extend({task:Y1}),kK=z0.merge(Y1),jW=B0.extend({method:Z("notifications/tasks/status"),params:kK}),bW=a.extend({method:Z("tasks/get"),params:q0.extend({taskId:L()})}),TW=s.merge(Y1),kW=a.extend({method:Z("tasks/result"),params:q0.extend({taskId:L()})}),t5=s.loose(),vW=X1.extend({method:Z("tasks/list")}),xW=K1.extend({tasks:S(Y1)}),hW=a.extend({method:Z("tasks/cancel"),params:q0.extend({taskId:L()})}),a5=s.merge(Y1),gW=P({uri:L(),mimeType:f(L()),_meta:k(L(),y()).optional()}),yW=gW.extend({text:L()}),m9=L().refine((W)=>{try{return atob(W),!0}catch{return!1}},{message:"Invalid Base64 string"}),fW=gW.extend({blob:m9}),Q1=Q0(["user","assistant"]),y0=P({audience:S(Q1).optional(),priority:T().min(0).max(1).optional(),lastModified:e0.datetime({offset:!0}).optional()}),cW=P({...g0.shape,...W1.shape,uri:L(),description:f(L()),mimeType:f(L()),size:f(T()),annotations:y0.optional(),_meta:f(W0({}))}),vK=P({...g0.shape,...W1.shape,uriTemplate:L(),description:f(L()),mimeType:f(L()),annotations:y0.optional(),_meta:f(W0({}))}),xK=X1.extend({method:Z("resources/list")}),hK=K1.extend({resources:S(cW)}),gK=X1.extend({method:Z("resources/templates/list")}),yK=K1.extend({resourceTemplates:S(vK)}),u9=q0.extend({uri:L()}),fK=u9,cK=a.extend({method:Z("resources/read"),params:fK}),mK=s.extend({contents:S(h([yW,fW]))}),uK=B0.extend({method:Z("notifications/resources/list_changed"),params:z0.optional()}),pK=u9,lK=a.extend({method:Z("resources/subscribe"),params:pK}),dK=u9,oK=a.extend({method:Z("resources/unsubscribe"),params:dK}),rK=z0.extend({uri:L()}),iK=B0.extend({method:Z("notifications/resources/updated"),params:rK}),nK=P({name:L(),description:f(L()),required:f(i())}),tK=P({...g0.shape,...W1.shape,description:f(L()),arguments:f(S(nK)),_meta:f(W0({}))}),aK=X1.extend({method:Z("prompts/list")}),sK=K1.extend({prompts:S(tK)}),eK=q0.extend({name:L(),arguments:k(L(),L()).optional()}),WY=a.extend({method:Z("prompts/get"),params:eK}),p9=P({type:Z("text"),text:L(),annotations:y0.optional(),_meta:k(L(),y()).optional()}),l9=P({type:Z("image"),data:m9,mimeType:L(),annotations:y0.optional(),_meta:k(L(),y()).optional()}),d9=P({type:Z("audio"),data:m9,mimeType:L(),annotations:y0.optional(),_meta:k(L(),y()).optional()}),XY=P({type:Z("tool_use"),name:L(),id:L(),input:k(L(),y()),_meta:k(L(),y()).optional()}),KY=P({type:Z("resource"),resource:h([yW,fW]),annotations:y0.optional(),_meta:k(L(),y()).optional()}),YY=cW.extend({type:Z("resource_link")}),o9=h([p9,l9,d9,YY,KY]),QY=P({role:Q1,content:o9}),GY=s.extend({description:L().optional(),messages:S(QY)}),qY=B0.extend({method:Z("notifications/prompts/list_changed"),params:z0.optional()}),JY=P({title:L().optional(),readOnlyHint:i().optional(),destructiveHint:i().optional(),idempotentHint:i().optional(),openWorldHint:i().optional()}),zY=P({taskSupport:Q0(["required","optional","forbidden"]).optional()}),mW=P({...g0.shape,...W1.shape,description:L().optional(),inputSchema:P({type:Z("object"),properties:k(L(),d).optional(),required:S(L()).optional()}).catchall(y()),outputSchema:P({type:Z("object"),properties:k(L(),d).optional(),required:S(L()).optional()}).catchall(y()).optional(),annotations:JY.optional(),execution:zY.optional(),_meta:k(L(),y()).optional()}),BY=X1.extend({method:Z("tools/list")}),$Y=K1.extend({tools:S(mW)}),uW=s.extend({content:S(o9).default([]),structuredContent:k(L(),y()).optional(),isError:i().optional()}),s5=uW.or(s.extend({toolResult:y()})),HY=x1.extend({name:L(),arguments:k(L(),y()).optional()}),UY=a.extend({method:Z("tools/call"),params:HY}),LY=B0.extend({method:Z("notifications/tools/list_changed"),params:z0.optional()}),e5=P({autoRefresh:i().default(!0),debounceMs:T().int().nonnegative().default(300)}),pW=Q0(["debug","info","notice","warning","error","critical","alert","emergency"]),wY=q0.extend({level:pW}),DY=a.extend({method:Z("logging/setLevel"),params:wY}),MY=z0.extend({level:pW,logger:L().optional(),data:y()}),OY=B0.extend({method:Z("notifications/message"),params:MY}),FY=P({name:L().optional()}),NY=P({hints:S(FY).optional(),costPriority:T().min(0).max(1).optional(),speedPriority:T().min(0).max(1).optional(),intelligencePriority:T().min(0).max(1).optional()}),VY=P({mode:Q0(["auto","required","none"]).optional()}),PY=P({type:Z("tool_result"),toolUseId:L().describe("The unique identifier for the corresponding tool call."),content:S(o9).default([]),structuredContent:P({}).loose().optional(),isError:i().optional(),_meta:k(L(),y()).optional()}),RY=y9("type",[p9,l9,d9]),k1=y9("type",[p9,l9,d9,XY,PY]),ZY=P({role:Q1,content:h([k1,S(k1)]),_meta:k(L(),y()).optional()}),EY=x1.extend({messages:S(ZY),modelPreferences:NY.optional(),systemPrompt:L().optional(),includeContext:Q0(["none","thisServer","allServers"]).optional(),temperature:T().optional(),maxTokens:T().int(),stopSequences:S(L()).optional(),metadata:d.optional(),tools:S(mW).optional(),toolChoice:VY.optional()}),IY=a.extend({method:Z("sampling/createMessage"),params:EY}),CY=s.extend({model:L(),stopReason:f(Q0(["endTurn","stopSequence","maxTokens"]).or(L())),role:Q1,content:RY}),_Y=s.extend({model:L(),stopReason:f(Q0(["endTurn","stopSequence","maxTokens","toolUse"]).or(L())),role:Q1,content:h([k1,S(k1)])}),SY=P({type:Z("boolean"),title:L().optional(),description:L().optional(),default:i().optional()}),AY=P({type:Z("string"),title:L().optional(),description:L().optional(),minLength:T().optional(),maxLength:T().optional(),format:Q0(["email","uri","date","date-time"]).optional(),default:L().optional()}),jY=P({type:Q0(["number","integer"]),title:L().optional(),description:L().optional(),minimum:T().optional(),maximum:T().optional(),default:T().optional()}),bY=P({type:Z("string"),title:L().optional(),description:L().optional(),enum:S(L()),default:L().optional()}),TY=P({type:Z("string"),title:L().optional(),description:L().optional(),oneOf:S(P({const:L(),title:L()})),default:L().optional()}),kY=P({type:Z("string"),title:L().optional(),description:L().optional(),enum:S(L()),enumNames:S(L()).optional(),default:L().optional()}),vY=h([bY,TY]),xY=P({type:Z("array"),title:L().optional(),description:L().optional(),minItems:T().optional(),maxItems:T().optional(),items:P({type:Z("string"),enum:S(L())}),default:S(L()).optional()}),hY=P({type:Z("array"),title:L().optional(),description:L().optional(),minItems:T().optional(),maxItems:T().optional(),items:P({anyOf:S(P({const:L(),title:L()}))}),default:S(L()).optional()}),gY=h([xY,hY]),yY=h([kY,vY,gY]),fY=h([yY,SY,AY,jY]),cY=x1.extend({mode:Z("form").optional(),message:L(),requestedSchema:P({type:Z("object"),properties:k(L(),fY),required:S(L()).optional()})}),mY=x1.extend({mode:Z("url"),message:L(),elicitationId:L(),url:L().url()}),uY=h([cY,mY]),pY=a.extend({method:Z("elicitation/create"),params:uY}),lY=z0.extend({elicitationId:L()}),dY=B0.extend({method:Z("notifications/elicitation/complete"),params:lY}),oY=s.extend({action:Q0(["accept","decline","cancel"]),content:f9((W)=>W===null?void 0:W,k(L(),h([L(),T(),i(),S(L())])).optional())}),rY=P({type:Z("ref/resource"),uri:L()});var iY=P({type:Z("ref/prompt"),name:L()}),nY=q0.extend({ref:h([iY,rY]),argument:P({name:L(),value:L()}),context:P({arguments:k(L(),L()).optional()}).optional()}),tY=a.extend({method:Z("completion/complete"),params:nY});var aY=s.extend({completion:W0({values:S(L()).max(100),total:f(T().int()),hasMore:f(i())})}),sY=P({uri:L().startsWith("file://"),name:L().optional(),_meta:k(L(),y()).optional()}),eY=a.extend({method:Z("roots/list"),params:q0.optional()}),WQ=s.extend({roots:S(sY)}),XQ=B0.extend({method:Z("notifications/roots/list_changed"),params:z0.optional()}),WG=h([_W,IK,tY,DY,WY,aK,xK,gK,cK,lK,oK,UY,BY,bW,kW,vW,hW]),XG=h([IW,SW,SK,XQ,jW]),KG=h([EW,CY,_Y,oY,WQ,TW,xW,AW]),YG=h([_W,IY,pY,eY,bW,kW,vW,hW]),QG=h([IW,SW,OY,iK,uK,LY,qY,jW,dY]),GG=h([EW,_K,aY,GY,sK,hK,yK,mK,uW,$Y,TW,xW,AW]);class r9{append(W){this._buffer=this._buffer?Buffer.concat([this._buffer,W]):W}readMessage(){if(!this._buffer)return null;let W=this._buffer.indexOf(`
46
- `);if(W===-1)return null;let X=this._buffer.toString("utf8",0,W).replace(/\r$/,"");return this._buffer=this._buffer.subarray(W+1),KQ(X)}clear(){this._buffer=void 0}}function KQ(W){return ZW.parse(JSON.parse(W))}function lW(W){return JSON.stringify(W)+`
47
- `}class g1{constructor(W=dW.stdin,X=dW.stdout){this._stdin=W,this._stdout=X,this._readBuffer=new r9,this._started=!1,this._ondata=(K)=>{this._readBuffer.append(K),this.processReadBuffer()},this._onerror=(K)=>{this.onerror?.(K)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let W=this._readBuffer.readMessage();if(W===null)break;this.onmessage?.(W)}catch(W){this.onerror?.(W)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(W){return new Promise((X)=>{let K=lW(W);if(this._stdout.write(K))X();else this._stdout.once("drain",X)})}}import{existsSync as TQ}from"node:fs";f1();async function U3(W){let X=J6(await W),[K,Y,{QuickJSWASMModule:Q}]=await Promise.all([X.importModuleLoader().then(J6),X.importFFI(),Promise.resolve().then(() => (H3(),$3)).then(J6)]),q=await K();q.type="sync";let J=new Y(q);return new Q(q,J)}function J6(W){return W&&"default"in W&&W.default?W.default&&"default"in W.default&&W.default.default?W.default.default:W.default:W}var w3="engine";function EQ(W){let X=(K)=>new URL(K,W).href;return{type:"sync",importFFI:()=>import(X("ffi.mjs")).then((K)=>K.QuickJSFFI),importModuleLoader:()=>import(X("emscripten-module.mjs")).then((K)=>K.default)}}var L3=null;function D3(W){return()=>{return L3??=U3(EQ(W)),L3}}var IQ=S3(O3(),1);var _Q="__mcpcloud_call_tool",Qq=`globalThis.tool = (name, args) =>
48
- globalThis.${_Q}(String(name), JSON.stringify(args ?? {}))
49
- .then((json) => JSON.parse(json));`;var SQ=6,AQ=["log","warn","error","info","debug"],jQ="__mcpcloud_console",Jq=`globalThis.console = {
50
- ${AQ.map((W)=>` ${W}: (...args) => globalThis.${jQ}(${JSON.stringify(W)}, JSON.stringify(args.slice(0, ${SQ}).map((value) => (value instanceof Error ? { __mcpcloudError: value.name + ': ' + value.message } : value)))),`).join(`
70
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let J of W.seen.entries()){let G=J[1];if(X===J[0]){q(J);continue}if(W.external){let D=W.external.registry.get(J[0])?.id;if(X!==J[0]&&D){q(J);continue}}if(W.metadataRegistry.get(J[0])?.id){q(J);continue}if(G.cycle){q(J);continue}if(G.count>1){if(W.reused==="ref"){q(J);continue}}}}function v9(W,X){let Y=W.seen.get(X);if(!Y)throw Error("Unprocessed schema. This is a bug in Zod.");let Q=(G)=>{let H=W.seen.get(G);if(H.ref===null)return;let D=H.def??H.schema,O={...D},V=H.ref;if(H.ref=null,V){Q(V);let P=W.seen.get(V),b=P.schema;if(b.$ref&&(W.target==="draft-07"||W.target==="draft-04"||W.target==="openapi-3.0"))D.allOf=D.allOf??[],D.allOf.push(b);else Object.assign(D,b);if(Object.assign(D,O),G._zod.parent===V)for(let M in D){if(M==="$ref"||M==="allOf")continue;if(!(M in O))delete D[M]}if(b.$ref&&P.def)for(let M in D){if(M==="$ref"||M==="allOf")continue;if(M in P.def&&JSON.stringify(D[M])===JSON.stringify(P.def[M]))delete D[M]}}let R=G._zod.parent;if(R&&R!==V){Q(R);let P=W.seen.get(R);if(P?.schema.$ref){if(D.$ref=P.schema.$ref,P.def)for(let b in D){if(b==="$ref"||b==="allOf")continue;if(b in P.def&&JSON.stringify(D[b])===JSON.stringify(P.def[b]))delete D[b]}}}W.override({zodSchema:G,jsonSchema:D,path:H.path??[]})};for(let G of[...W.seen.entries()].reverse())Q(G[0]);let K={};if(W.target==="draft-2020-12")K.$schema="https://json-schema.org/draft/2020-12/schema";else if(W.target==="draft-07")K.$schema="http://json-schema.org/draft-07/schema#";else if(W.target==="draft-04")K.$schema="http://json-schema.org/draft-04/schema#";else if(W.target==="openapi-3.0");if(W.external?.uri){let G=W.external.registry.get(X)?.id;if(!G)throw Error("Schema is missing an `id` property");K.$id=W.external.uri(G)}Object.assign(K,Y.def??Y.schema);let q=W.metadataRegistry.get(X)?.id;if(q!==void 0&&K.id===q)delete K.id;let J=W.external?.defs??{};for(let G of W.seen.entries()){let H=G[1];if(H.def&&H.defId){if(H.def.id===H.defId)delete H.def.id;J[H.defId]=H.def}}if(W.external);else if(Object.keys(J).length>0)if(W.target==="draft-2020-12")K.$defs=J;else K.definitions=J;try{let G=JSON.parse(JSON.stringify(K));return Object.defineProperty(G,"~standard",{value:{...X["~standard"],jsonSchema:{input:X1(X,"input",W.processors),output:X1(X,"output",W.processors)}},enumerable:!1,writable:!1}),G}catch(G){throw Error("Error converting schema to JSON.")}}function e(W,X){let Y=X??{seen:new Set};if(Y.seen.has(W))return!1;Y.seen.add(W);let Q=W._zod.def;if(Q.type==="transform")return!0;if(Q.type==="array")return e(Q.element,Y);if(Q.type==="set")return e(Q.valueType,Y);if(Q.type==="lazy")return e(Q.getter(),Y);if(Q.type==="promise"||Q.type==="optional"||Q.type==="nonoptional"||Q.type==="nullable"||Q.type==="readonly"||Q.type==="default"||Q.type==="prefault")return e(Q.innerType,Y);if(Q.type==="intersection")return e(Q.left,Y)||e(Q.right,Y);if(Q.type==="record"||Q.type==="map")return e(Q.keyType,Y)||e(Q.valueType,Y);if(Q.type==="pipe"){if(W._zod.traits.has("$ZodCodec"))return!0;return e(Q.in,Y)||e(Q.out,Y)}if(Q.type==="object"){for(let K in Q.shape)if(e(Q.shape[K],Y))return!0;return!1}if(Q.type==="union"){for(let K of Q.options)if(e(K,Y))return!0;return!1}if(Q.type==="tuple"){for(let K of Q.items)if(e(K,Y))return!0;if(Q.rest&&e(Q.rest,Y))return!0;return!1}return!1}var R2=(W,X={})=>(Y)=>{let Q=T9({...Y,processors:X});return d(W,Q),k9(Q,W),v9(Q,W)},X1=(W,X,Y={})=>(Q)=>{let{libraryOptions:K,target:q}=Q??{},J=T9({...K??{},target:q,io:X,processors:Y});return d(W,J),k9(J,W),v9(J,W)};var OX={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},E2=(W,X,Y,Q)=>{let K=Y;K.type="string";let{minimum:q,maximum:J,format:G,patterns:H,contentEncoding:D}=W._zod.bag;if(typeof q==="number")K.minLength=q;if(typeof J==="number")K.maxLength=J;if(G){if(K.format=OX[G]??G,K.format==="")delete K.format;if(G==="time")delete K.format}if(D)K.contentEncoding=D;if(H&&H.size>0){let O=[...H];if(O.length===1)K.pattern=O[0].source;else if(O.length>1)K.allOf=[...O.map((V)=>({...X.target==="draft-07"||X.target==="draft-04"||X.target==="openapi-3.0"?{type:"string"}:{},pattern:V.source}))]}},I2=(W,X,Y,Q)=>{let K=Y,{minimum:q,maximum:J,format:G,multipleOf:H,exclusiveMaximum:D,exclusiveMinimum:O}=W._zod.bag;if(typeof G==="string"&&G.includes("int"))K.type="integer";else K.type="number";let V=typeof O==="number"&&O>=(q??Number.NEGATIVE_INFINITY),R=typeof D==="number"&&D<=(J??Number.POSITIVE_INFINITY),P=X.target==="draft-04"||X.target==="openapi-3.0";if(V)if(P)K.minimum=O,K.exclusiveMinimum=!0;else K.exclusiveMinimum=O;else if(typeof q==="number")K.minimum=q;if(R)if(P)K.maximum=D,K.exclusiveMaximum=!0;else K.exclusiveMaximum=D;else if(typeof J==="number")K.maximum=J;if(typeof H==="number")K.multipleOf=H},C2=(W,X,Y,Q)=>{Y.type="boolean"};var _2=(W,X,Y,Q)=>{if(X.target==="openapi-3.0")Y.type="string",Y.nullable=!0,Y.enum=[null];else Y.type="null"};var A2=(W,X,Y,Q)=>{Y.not={}};var j2=(W,X,Y,Q)=>{};var S2=(W,X,Y,Q)=>{let K=W._zod.def,q=o0(K.entries);if(q.every((J)=>typeof J==="number"))Y.type="number";if(q.every((J)=>typeof J==="string"))Y.type="string";Y.enum=q},b2=(W,X,Y,Q)=>{let K=W._zod.def,q=[];for(let J of K.values)if(J===void 0){if(X.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof J==="bigint")if(X.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else q.push(Number(J));else q.push(J);if(q.length===0);else if(q.length===1){let J=q[0];if(Y.type=J===null?"null":typeof J,X.target==="draft-04"||X.target==="openapi-3.0")Y.enum=[J];else Y.const=J}else{if(q.every((J)=>typeof J==="number"))Y.type="number";if(q.every((J)=>typeof J==="string"))Y.type="string";if(q.every((J)=>typeof J==="boolean"))Y.type="boolean";if(q.every((J)=>J===null))Y.type="null";Y.enum=q}};var T2=(W,X,Y,Q)=>{if(X.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")};var k2=(W,X,Y,Q)=>{if(X.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")};var v2=(W,X,Y,Q)=>{let K=Y,q=W._zod.def,{minimum:J,maximum:G}=W._zod.bag;if(typeof J==="number")K.minItems=J;if(typeof G==="number")K.maxItems=G;K.type="array",K.items=d(q.element,X,{...Q,path:[...Q.path,"items"]})},x2=(W,X,Y,Q)=>{let K=Y,q=W._zod.def;K.type="object",K.properties={};let J=q.shape;for(let D in J)K.properties[D]=d(J[D],X,{...Q,path:[...Q.path,"properties",D]});let G=new Set(Object.keys(J)),H=new Set([...G].filter((D)=>{let O=q.shape[D]._zod;if(X.io==="input")return O.optin===void 0;else return O.optout===void 0}));if(H.size>0)K.required=Array.from(H);if(q.catchall?._zod.def.type==="never")K.additionalProperties=!1;else if(!q.catchall){if(X.io==="output")K.additionalProperties=!1}else if(q.catchall)K.additionalProperties=d(q.catchall,X,{...Q,path:[...Q.path,"additionalProperties"]})},g2=(W,X,Y,Q)=>{let K=W._zod.def,q=K.inclusive===!1,J=K.options.map((G,H)=>d(G,X,{...Q,path:[...Q.path,q?"oneOf":"anyOf",H]}));if(q)Y.oneOf=J;else Y.anyOf=J},h2=(W,X,Y,Q)=>{let K=W._zod.def,q=d(K.left,X,{...Q,path:[...Q.path,"allOf",0]}),J=d(K.right,X,{...Q,path:[...Q.path,"allOf",1]}),G=(D)=>("allOf"in D)&&Object.keys(D).length===1,H=[...G(q)?q.allOf:[q],...G(J)?J.allOf:[J]];Y.allOf=H};var y2=(W,X,Y,Q)=>{let K=Y,q=W._zod.def;K.type="object";let J=q.keyType,H=J._zod.bag?.patterns;if(q.mode==="loose"&&H&&H.size>0){let O=d(q.valueType,X,{...Q,path:[...Q.path,"patternProperties","*"]});K.patternProperties={};for(let V of H)K.patternProperties[V.source]=O}else{if(X.target==="draft-07"||X.target==="draft-2020-12")K.propertyNames=d(q.keyType,X,{...Q,path:[...Q.path,"propertyNames"]});K.additionalProperties=d(q.valueType,X,{...Q,path:[...Q.path,"additionalProperties"]})}let D=J._zod.values;if(D){let O=[...D].filter((V)=>typeof V==="string"||typeof V==="number");if(O.length>0)K.required=O}},f2=(W,X,Y,Q)=>{let K=W._zod.def,q=d(K.innerType,X,Q),J=X.seen.get(W);if(X.target==="openapi-3.0")J.ref=K.innerType,Y.nullable=!0;else Y.anyOf=[q,{type:"null"}]},c2=(W,X,Y,Q)=>{let K=W._zod.def;d(K.innerType,X,Q);let q=X.seen.get(W);q.ref=K.innerType},m2=(W,X,Y,Q)=>{let K=W._zod.def;d(K.innerType,X,Q);let q=X.seen.get(W);q.ref=K.innerType,Y.default=JSON.parse(JSON.stringify(K.defaultValue))},u2=(W,X,Y,Q)=>{let K=W._zod.def;d(K.innerType,X,Q);let q=X.seen.get(W);if(q.ref=K.innerType,X.io==="input")Y._prefault=JSON.parse(JSON.stringify(K.defaultValue))},p2=(W,X,Y,Q)=>{let K=W._zod.def;d(K.innerType,X,Q);let q=X.seen.get(W);q.ref=K.innerType;let J;try{J=K.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Y.default=J},l2=(W,X,Y,Q)=>{let K=W._zod.def,q=K.in._zod.traits.has("$ZodTransform"),J=X.io==="input"?q?K.out:K.in:K.out;d(J,X,Q);let G=X.seen.get(W);G.ref=J},d2=(W,X,Y,Q)=>{let K=W._zod.def;d(K.innerType,X,Q);let q=X.seen.get(W);q.ref=K.innerType,Y.readOnly=!0};var x9=(W,X,Y,Q)=>{let K=W._zod.def;d(K.innerType,X,Q);let q=X.seen.get(W);q.ref=K.innerType};var Q1={};a1(Q1,{time:()=>y9,duration:()=>f9,datetime:()=>g9,date:()=>h9,ZodISOTime:()=>r2,ZodISODuration:()=>n2,ZodISODateTime:()=>o2,ZodISODate:()=>i2});var o2=w("ZodISODateTime",(W,X)=>{Y6.init(W,X),f.init(W,X)});function g9(W){return B2(o2,W)}var i2=w("ZodISODate",(W,X)=>{Q6.init(W,X),f.init(W,X)});function h9(W){return $2(i2,W)}var r2=w("ZodISOTime",(W,X)=>{K6.init(W,X),f.init(W,X)});function y9(W){return H2(r2,W)}var n2=w("ZodISODuration",(W,X)=>{G6.init(W,X),f.init(W,X)});function f9(W){return U2(n2,W)}var _X=(W,X)=>{P1.init(W,X),W.name="ZodError",Object.defineProperties(W,{format:{value:(Y)=>h4(W,Y)},flatten:{value:(Y)=>g4(W,Y)},addIssue:{value:(Y)=>{W.issues.push(Y),W.message=JSON.stringify(W.issues,x0,2)}},addIssues:{value:(Y)=>{W.issues.push(...Y),W.message=JSON.stringify(W.issues,x0,2)}},isEmpty:{get(){return W.issues.length===0}}})};var G0=w("ZodError",_X,{Parent:Error});var t2=Z1(G0),a2=R1(G0),s2=t0(G0),e2=a0(G0),WW=c4(G0),XW=m4(G0),YW=u4(G0),QW=p4(G0),KW=l4(G0),GW=d4(G0),qW=o4(G0),JW=i4(G0);var zW=new WeakMap;function K1(W,X,Y){let Q=Object.getPrototypeOf(W),K=zW.get(Q);if(!K)K=new Set,zW.set(Q,K);if(K.has(X))return;K.add(X);for(let q in Y){let J=Y[q];Object.defineProperty(Q,q,{configurable:!0,enumerable:!1,get(){let G=J.bind(this);return Object.defineProperty(this,q,{configurable:!0,writable:!0,enumerable:!0,value:G}),G},set(G){Object.defineProperty(this,q,{configurable:!0,writable:!0,enumerable:!0,value:G})}})}}var u=w("ZodType",(W,X)=>{return g.init(W,X),Object.assign(W["~standard"],{jsonSchema:{input:X1(W,"input"),output:X1(W,"output")}}),W.toJSONSchema=R2(W,{}),W.def=X,W.type=X.type,Object.defineProperty(W,"_def",{value:X}),W.parse=(Y,Q)=>t2(W,Y,Q,{callee:W.parse}),W.safeParse=(Y,Q)=>s2(W,Y,Q),W.parseAsync=async(Y,Q)=>a2(W,Y,Q,{callee:W.parseAsync}),W.safeParseAsync=async(Y,Q)=>e2(W,Y,Q),W.spa=W.safeParseAsync,W.encode=(Y,Q)=>WW(W,Y,Q),W.decode=(Y,Q)=>XW(W,Y,Q),W.encodeAsync=async(Y,Q)=>YW(W,Y,Q),W.decodeAsync=async(Y,Q)=>QW(W,Y,Q),W.safeEncode=(Y,Q)=>KW(W,Y,Q),W.safeDecode=(Y,Q)=>GW(W,Y,Q),W.safeEncodeAsync=async(Y,Q)=>qW(W,Y,Q),W.safeDecodeAsync=async(Y,Q)=>JW(W,Y,Q),K1(W,"ZodType",{check(...Y){let Q=this.def;return this.clone(S.mergeDefs(Q,{checks:[...Q.checks??[],...Y.map((K)=>typeof K==="function"?{_zod:{check:K,def:{check:"custom"},onattach:[]}}:K)]}),{parent:!0})},with(...Y){return this.check(...Y)},clone(Y,Q){return H0(this,Y,Q)},brand(){return this},register(Y,Q){return Y.add(this,Q),this},refine(Y,Q){return this.check(FY(Y,Q))},superRefine(Y,Q){return this.check(OY(Y,Q))},overwrite(Y){return this.check(I0(Y))},optional(){return m(this)},exactOptional(){return GY(this)},nullable(){return UW(this)},nullish(){return m(UW(this))},nonoptional(Y){return HY(this,Y)},array(){return A(this)},or(Y){return y([this,Y])},and(Y){return x1(this,Y)},transform(Y){return LW(this,VW(Y))},default(Y){return zY(this,Y)},prefault(Y){return $Y(this,Y)},catch(Y){return LY(this,Y)},pipe(Y){return LW(this,Y)},readonly(){return MY(this)},describe(Y){let Q=this.clone();return j0.add(Q,{description:Y}),Q},meta(...Y){if(Y.length===0)return j0.get(this);let Q=this.clone();return j0.add(Q,Y[0]),Q},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(Y){return Y(this)}}),Object.defineProperty(W,"description",{get(){return j0.get(W)?.description},configurable:!0}),W}),DW=w("_ZodString",(W,X)=>{A1.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Q,K,q)=>E2(W,Q,K,q);let Y=W._zod.bag;W.format=Y.format??null,W.minLength=Y.minimum??null,W.maxLength=Y.maximum??null,K1(W,"_ZodString",{regex(...Q){return this.check(P9(...Q))},includes(...Q){return this.check(E9(...Q))},startsWith(...Q){return this.check(I9(...Q))},endsWith(...Q){return this.check(C9(...Q))},min(...Q){return this.check(y0(...Q))},max(...Q){return this.check(T1(...Q))},length(...Q){return this.check(k1(...Q))},nonempty(...Q){return this.check(y0(1,...Q))},lowercase(Q){return this.check(Z9(Q))},uppercase(Q){return this.check(R9(Q))},trim(){return this.check(A9())},normalize(...Q){return this.check(_9(...Q))},toLowerCase(){return this.check(j9())},toUpperCase(){return this.check(S9())},slugify(){return this.check(b9())}})}),jX=w("ZodString",(W,X)=>{A1.init(W,X),DW.init(W,X),W.email=(Y)=>W.check(u6(SX,Y)),W.url=(Y)=>W.check(i6(bX,Y)),W.jwt=(Y)=>W.check(z2(oX,Y)),W.emoji=(Y)=>W.check(r6(TX,Y)),W.guid=(Y)=>W.check(N9(BW,Y)),W.uuid=(Y)=>W.check(p6(v1,Y)),W.uuidv4=(Y)=>W.check(l6(v1,Y)),W.uuidv6=(Y)=>W.check(d6(v1,Y)),W.uuidv7=(Y)=>W.check(o6(v1,Y)),W.nanoid=(Y)=>W.check(n6(kX,Y)),W.guid=(Y)=>W.check(N9(BW,Y)),W.cuid=(Y)=>W.check(t6(vX,Y)),W.cuid2=(Y)=>W.check(a6(xX,Y)),W.ulid=(Y)=>W.check(s6(gX,Y)),W.base64=(Y)=>W.check(G2(pX,Y)),W.base64url=(Y)=>W.check(q2(lX,Y)),W.xid=(Y)=>W.check(e6(hX,Y)),W.ksuid=(Y)=>W.check(W2(yX,Y)),W.ipv4=(Y)=>W.check(X2(fX,Y)),W.ipv6=(Y)=>W.check(Y2(cX,Y)),W.cidrv4=(Y)=>W.check(Q2(mX,Y)),W.cidrv6=(Y)=>W.check(K2(uX,Y)),W.e164=(Y)=>W.check(J2(dX,Y)),W.datetime=(Y)=>W.check(g9(Y)),W.date=(Y)=>W.check(h9(Y)),W.time=(Y)=>W.check(y9(Y)),W.duration=(Y)=>W.check(f9(Y))});function U(W){return m6(jX,W)}var f=w("ZodStringFormat",(W,X)=>{h.init(W,X),DW.init(W,X)}),SX=w("ZodEmail",(W,X)=>{i8.init(W,X),f.init(W,X)});var BW=w("ZodGUID",(W,X)=>{d8.init(W,X),f.init(W,X)});var v1=w("ZodUUID",(W,X)=>{o8.init(W,X),f.init(W,X)});var bX=w("ZodURL",(W,X)=>{r8.init(W,X),f.init(W,X)});var TX=w("ZodEmoji",(W,X)=>{n8.init(W,X),f.init(W,X)});var kX=w("ZodNanoID",(W,X)=>{t8.init(W,X),f.init(W,X)});var vX=w("ZodCUID",(W,X)=>{a8.init(W,X),f.init(W,X)});var xX=w("ZodCUID2",(W,X)=>{s8.init(W,X),f.init(W,X)});var gX=w("ZodULID",(W,X)=>{e8.init(W,X),f.init(W,X)});var hX=w("ZodXID",(W,X)=>{W6.init(W,X),f.init(W,X)});var yX=w("ZodKSUID",(W,X)=>{X6.init(W,X),f.init(W,X)});var fX=w("ZodIPv4",(W,X)=>{q6.init(W,X),f.init(W,X)});var cX=w("ZodIPv6",(W,X)=>{J6.init(W,X),f.init(W,X)});var mX=w("ZodCIDRv4",(W,X)=>{z6.init(W,X),f.init(W,X)});var uX=w("ZodCIDRv6",(W,X)=>{B6.init(W,X),f.init(W,X)});var pX=w("ZodBase64",(W,X)=>{H6.init(W,X),f.init(W,X)});var lX=w("ZodBase64URL",(W,X)=>{U6.init(W,X),f.init(W,X)});var dX=w("ZodE164",(W,X)=>{L6.init(W,X),f.init(W,X)});var oX=w("ZodJWT",(W,X)=>{D6.init(W,X),f.init(W,X)});var wW=w("ZodNumber",(W,X)=>{w9.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Q,K,q)=>I2(W,Q,K,q),K1(W,"ZodNumber",{gt(Q,K){return this.check(S1(Q,K))},gte(Q,K){return this.check(W1(Q,K))},min(Q,K){return this.check(W1(Q,K))},lt(Q,K){return this.check(j1(Q,K))},lte(Q,K){return this.check(e0(Q,K))},max(Q,K){return this.check(e0(Q,K))},int(Q){return this.check($W(Q))},safe(Q){return this.check($W(Q))},positive(Q){return this.check(S1(0,Q))},nonnegative(Q){return this.check(W1(0,Q))},negative(Q){return this.check(j1(0,Q))},nonpositive(Q){return this.check(e0(0,Q))},multipleOf(Q,K){return this.check(b1(Q,K))},step(Q,K){return this.check(b1(Q,K))},finite(){return this}});let Y=W._zod.bag;W.minValue=Math.max(Y.minimum??Number.NEGATIVE_INFINITY,Y.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,W.maxValue=Math.min(Y.maximum??Number.POSITIVE_INFINITY,Y.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,W.isInt=(Y.format??"").includes("int")||Number.isSafeInteger(Y.multipleOf??0.5),W.isFinite=!0,W.format=Y.format??null});function k(W){return L2(wW,W)}var iX=w("ZodNumberFormat",(W,X)=>{w6.init(W,X),wW.init(W,X)});function $W(W){return D2(iX,W)}var rX=w("ZodBoolean",(W,X)=>{M6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>C2(W,Y,Q,K)});function n(W){return w2(rX,W)}var nX=w("ZodNull",(W,X)=>{F6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>_2(W,Y,Q,K)});function MW(W){return M2(nX,W)}var tX=w("ZodUnknown",(W,X)=>{O6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>j2(W,Y,Q,K)});function c(){return F2(tX)}var aX=w("ZodNever",(W,X)=>{V6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>A2(W,Y,Q,K)});function sX(W){return O2(aX,W)}var eX=w("ZodArray",(W,X)=>{N6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>v2(W,Y,Q,K),W.element=X.element,K1(W,"ZodArray",{min(Y,Q){return this.check(y0(Y,Q))},nonempty(Y){return this.check(y0(1,Y))},max(Y,Q){return this.check(T1(Y,Q))},length(Y,Q){return this.check(k1(Y,Q))},unwrap(){return this.element}})});function A(W,X){return V2(eX,W,X)}var FW=w("ZodObject",(W,X)=>{R6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>x2(W,Y,Q,K),S.defineLazy(W,"shape",()=>{return X.shape}),K1(W,"ZodObject",{keyof(){return Q0(Object.keys(this._zod.def.shape))},catchall(Y){return this.clone({...this._zod.def,catchall:Y})},passthrough(){return this.clone({...this._zod.def,catchall:c()})},loose(){return this.clone({...this._zod.def,catchall:c()})},strict(){return this.clone({...this._zod.def,catchall:sX()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(Y){return S.extend(this,Y)},safeExtend(Y){return S.safeExtend(this,Y)},merge(Y){return S.merge(this,Y)},pick(Y){return S.pick(this,Y)},omit(Y){return S.omit(this,Y)},partial(...Y){return S.partial(NW,this,Y[0])},required(...Y){return S.required(PW,this,Y[0])}})});function Z(W,X){let Y={type:"object",shape:W??{},...S.normalizeParams(X)};return new FW(Y)}function W0(W,X){return new FW({type:"object",shape:W,catchall:c(),...S.normalizeParams(X)})}var OW=w("ZodUnion",(W,X)=>{M9.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>g2(W,Y,Q,K),W.options=X.options});function y(W,X){return new OW({type:"union",options:W,...S.normalizeParams(X)})}var WY=w("ZodDiscriminatedUnion",(W,X)=>{OW.init(W,X),E6.init(W,X)});function m9(W,X,Y){return new WY({type:"union",options:X,discriminator:W,...S.normalizeParams(Y)})}var XY=w("ZodIntersection",(W,X)=>{I6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>h2(W,Y,Q,K)});function x1(W,X){return new XY({type:"intersection",left:W,right:X})}var HW=w("ZodRecord",(W,X)=>{C6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>y2(W,Y,Q,K),W.keyType=X.keyType,W.valueType=X.valueType});function v(W,X,Y){if(!X||!X._zod)return new HW({type:"record",keyType:U(),valueType:W,...S.normalizeParams(X)});return new HW({type:"record",keyType:W,valueType:X,...S.normalizeParams(Y)})}var c9=w("ZodEnum",(W,X)=>{_6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Q,K,q)=>S2(W,Q,K,q),W.enum=X.entries,W.options=Object.values(X.entries);let Y=new Set(Object.keys(X.entries));W.extract=(Q,K)=>{let q={};for(let J of Q)if(Y.has(J))q[J]=X.entries[J];else throw Error(`Key ${J} not found in enum`);return new c9({...X,checks:[],...S.normalizeParams(K),entries:q})},W.exclude=(Q,K)=>{let q={...X.entries};for(let J of Q)if(Y.has(J))delete q[J];else throw Error(`Key ${J} not found in enum`);return new c9({...X,checks:[],...S.normalizeParams(K),entries:q})}});function Q0(W,X){let Y=Array.isArray(W)?Object.fromEntries(W.map((Q)=>[Q,Q])):W;return new c9({type:"enum",entries:Y,...S.normalizeParams(X)})}var YY=w("ZodLiteral",(W,X)=>{A6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>b2(W,Y,Q,K),W.values=new Set(X.values),Object.defineProperty(W,"value",{get(){if(X.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return X.values[0]}})});function E(W,X){return new YY({type:"literal",values:Array.isArray(W)?W:[W],...S.normalizeParams(X)})}var QY=w("ZodTransform",(W,X)=>{j6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>k2(W,Y,Q,K),W._zod.parse=(Y,Q)=>{if(Q.direction==="backward")throw new l0(W.constructor.name);Y.addIssue=(q)=>{if(typeof q==="string")Y.issues.push(S.issue(q,Y.value,X));else{let J=q;if(J.fatal)J.continue=!1;J.code??(J.code="custom"),J.input??(J.input=Y.value),J.inst??(J.inst=W),Y.issues.push(S.issue(J))}};let K=X.transform(Y.value,Y);if(K instanceof Promise)return K.then((q)=>{return Y.value=q,Y.fallback=!0,Y});return Y.value=K,Y.fallback=!0,Y}});function VW(W){return new QY({type:"transform",transform:W})}var NW=w("ZodOptional",(W,X)=>{F9.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>x9(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType});function m(W){return new NW({type:"optional",innerType:W})}var KY=w("ZodExactOptional",(W,X)=>{S6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>x9(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType});function GY(W){return new KY({type:"optional",innerType:W})}var qY=w("ZodNullable",(W,X)=>{b6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>f2(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType});function UW(W){return new qY({type:"nullable",innerType:W})}var JY=w("ZodDefault",(W,X)=>{T6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>m2(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType,W.removeDefault=W.unwrap});function zY(W,X){return new JY({type:"default",innerType:W,get defaultValue(){return typeof X==="function"?X():S.shallowClone(X)}})}var BY=w("ZodPrefault",(W,X)=>{k6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>u2(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType});function $Y(W,X){return new BY({type:"prefault",innerType:W,get defaultValue(){return typeof X==="function"?X():S.shallowClone(X)}})}var PW=w("ZodNonOptional",(W,X)=>{v6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>c2(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType});function HY(W,X){return new PW({type:"nonoptional",innerType:W,...S.normalizeParams(X)})}var UY=w("ZodCatch",(W,X)=>{x6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>p2(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType,W.removeCatch=W.unwrap});function LY(W,X){return new UY({type:"catch",innerType:W,catchValue:typeof X==="function"?X:()=>X})}var ZW=w("ZodPipe",(W,X)=>{O9.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>l2(W,Y,Q,K),W.in=X.in,W.out=X.out});function LW(W,X){return new ZW({type:"pipe",in:W,out:X})}var DY=w("ZodPreprocess",(W,X)=>{ZW.init(W,X),g6.init(W,X)}),wY=w("ZodReadonly",(W,X)=>{h6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>d2(W,Y,Q,K),W.unwrap=()=>W._zod.def.innerType});function MY(W){return new wY({type:"readonly",innerType:W})}var RW=w("ZodCustom",(W,X)=>{y6.init(W,X),u.init(W,X),W._zod.processJSONSchema=(Y,Q,K)=>T2(W,Y,Q,K)});function EW(W,X){return N2(RW,W??(()=>!0),X)}function FY(W,X={}){return P2(RW,W,X)}function OY(W,X){return Z2(W,X)}function u9(W,X){return new DY({type:"pipe",in:VW(W),out:X})}K0(V9());var VY="io.modelcontextprotocol/related-task",h1="2.0",i=EW((W)=>W!==null&&(typeof W==="object"||typeof W==="function")),CW=y([U(),k().int()]),_W=U(),XG=W0({ttl:k().optional(),pollInterval:k().optional()}),NY=Z({ttl:k().optional()}),PY=Z({taskId:U()}),p9=W0({progressToken:CW.optional(),[VY]:PY.optional()}),q0=Z({_meta:p9.optional()}),y1=q0.extend({task:NY.optional()});var a=Z({method:U(),params:q0.loose().optional()}),z0=Z({_meta:p9.optional()}),B0=Z({method:U(),params:z0.loose().optional()}),s=W0({_meta:p9.optional()}),f1=y([U(),k().int()]),ZY=Z({jsonrpc:E(h1),id:f1,...a.shape}).strict();var RY=Z({jsonrpc:E(h1),...B0.shape}).strict();var AW=Z({jsonrpc:E(h1),id:f1,result:s}).strict();var IW;(function(W){W[W.ConnectionClosed=-32000]="ConnectionClosed",W[W.RequestTimeout=-32001]="RequestTimeout",W[W.ParseError=-32700]="ParseError",W[W.InvalidRequest=-32600]="InvalidRequest",W[W.MethodNotFound=-32601]="MethodNotFound",W[W.InvalidParams=-32602]="InvalidParams",W[W.InternalError=-32603]="InternalError",W[W.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(IW||(IW={}));var jW=Z({jsonrpc:E(h1),id:f1.optional(),error:Z({code:k().int(),message:U(),data:c().optional()})}).strict();var SW=y([ZY,RY,AW,jW]),YG=y([AW,jW]),bW=s.strict(),EY=z0.extend({requestId:f1.optional(),reason:U().optional()}),TW=B0.extend({method:E("notifications/cancelled"),params:EY}),IY=Z({src:U(),mimeType:U().optional(),sizes:A(U()).optional(),theme:Q0(["light","dark"]).optional()}),G1=Z({icons:A(IY).optional()}),f0=Z({name:U(),title:U().optional()}),kW=f0.extend({...f0.shape,...G1.shape,version:U(),websiteUrl:U().optional(),description:U().optional()}),CY=x1(Z({applyDefaults:n().optional()}),v(U(),c())),_Y=u9((W)=>{if(W&&typeof W==="object"&&!Array.isArray(W)){if(Object.keys(W).length===0)return{form:{}}}return W},x1(Z({form:CY.optional(),url:i.optional()}),v(U(),c()).optional())),AY=W0({list:i.optional(),cancel:i.optional(),requests:W0({sampling:W0({createMessage:i.optional()}).optional(),elicitation:W0({create:i.optional()}).optional()}).optional()}),jY=W0({list:i.optional(),cancel:i.optional(),requests:W0({tools:W0({call:i.optional()}).optional()}).optional()}),SY=Z({experimental:v(U(),i).optional(),sampling:Z({context:i.optional(),tools:i.optional()}).optional(),elicitation:_Y.optional(),roots:Z({listChanged:n().optional()}).optional(),tasks:AY.optional(),extensions:v(U(),i).optional()}),bY=q0.extend({protocolVersion:U(),capabilities:SY,clientInfo:kW}),TY=a.extend({method:E("initialize"),params:bY});var kY=Z({experimental:v(U(),i).optional(),logging:i.optional(),completions:i.optional(),prompts:Z({listChanged:n().optional()}).optional(),resources:Z({subscribe:n().optional(),listChanged:n().optional()}).optional(),tools:Z({listChanged:n().optional()}).optional(),tasks:jY.optional(),extensions:v(U(),i).optional()}),vY=s.extend({protocolVersion:U(),capabilities:kY,serverInfo:kW,instructions:U().optional()}),xY=B0.extend({method:E("notifications/initialized"),params:z0.optional()});var vW=a.extend({method:E("ping"),params:q0.optional()}),gY=Z({progress:k(),total:m(k()),message:m(U())}),hY=Z({...z0.shape,...gY.shape,progressToken:CW}),xW=B0.extend({method:E("notifications/progress"),params:hY}),yY=q0.extend({cursor:_W.optional()}),q1=a.extend({params:yY.optional()}),J1=s.extend({nextCursor:_W.optional()}),fY=Q0(["working","input_required","completed","failed","cancelled"]),z1=Z({taskId:U(),status:fY,ttl:y([k(),MW()]),createdAt:U(),lastUpdatedAt:U(),pollInterval:m(k()),statusMessage:m(U())}),gW=s.extend({task:z1}),cY=z0.merge(z1),hW=B0.extend({method:E("notifications/tasks/status"),params:cY}),yW=a.extend({method:E("tasks/get"),params:q0.extend({taskId:U()})}),fW=s.merge(z1),cW=a.extend({method:E("tasks/result"),params:q0.extend({taskId:U()})}),QG=s.loose(),mW=q1.extend({method:E("tasks/list")}),uW=J1.extend({tasks:A(z1)}),pW=a.extend({method:E("tasks/cancel"),params:q0.extend({taskId:U()})}),KG=s.merge(z1),lW=Z({uri:U(),mimeType:m(U()),_meta:v(U(),c()).optional()}),dW=lW.extend({text:U()}),l9=U().refine((W)=>{try{return atob(W),!0}catch{return!1}},{message:"Invalid Base64 string"}),oW=lW.extend({blob:l9}),B1=Q0(["user","assistant"]),c0=Z({audience:A(B1).optional(),priority:k().min(0).max(1).optional(),lastModified:Q1.datetime({offset:!0}).optional()}),iW=Z({...f0.shape,...G1.shape,uri:U(),description:m(U()),mimeType:m(U()),size:m(k()),annotations:c0.optional(),_meta:m(W0({}))}),mY=Z({...f0.shape,...G1.shape,uriTemplate:U(),description:m(U()),mimeType:m(U()),annotations:c0.optional(),_meta:m(W0({}))}),uY=q1.extend({method:E("resources/list")}),pY=J1.extend({resources:A(iW)}),lY=q1.extend({method:E("resources/templates/list")}),dY=J1.extend({resourceTemplates:A(mY)}),d9=q0.extend({uri:U()}),oY=d9,iY=a.extend({method:E("resources/read"),params:oY}),rY=s.extend({contents:A(y([dW,oW]))}),nY=B0.extend({method:E("notifications/resources/list_changed"),params:z0.optional()}),tY=d9,aY=a.extend({method:E("resources/subscribe"),params:tY}),sY=d9,eY=a.extend({method:E("resources/unsubscribe"),params:sY}),WQ=z0.extend({uri:U()}),XQ=B0.extend({method:E("notifications/resources/updated"),params:WQ}),YQ=Z({name:U(),description:m(U()),required:m(n())}),QQ=Z({...f0.shape,...G1.shape,description:m(U()),arguments:m(A(YQ)),_meta:m(W0({}))}),KQ=q1.extend({method:E("prompts/list")}),GQ=J1.extend({prompts:A(QQ)}),qQ=q0.extend({name:U(),arguments:v(U(),U()).optional()}),JQ=a.extend({method:E("prompts/get"),params:qQ}),o9=Z({type:E("text"),text:U(),annotations:c0.optional(),_meta:v(U(),c()).optional()}),i9=Z({type:E("image"),data:l9,mimeType:U(),annotations:c0.optional(),_meta:v(U(),c()).optional()}),r9=Z({type:E("audio"),data:l9,mimeType:U(),annotations:c0.optional(),_meta:v(U(),c()).optional()}),zQ=Z({type:E("tool_use"),name:U(),id:U(),input:v(U(),c()),_meta:v(U(),c()).optional()}),BQ=Z({type:E("resource"),resource:y([dW,oW]),annotations:c0.optional(),_meta:v(U(),c()).optional()}),$Q=iW.extend({type:E("resource_link")}),n9=y([o9,i9,r9,$Q,BQ]),HQ=Z({role:B1,content:n9}),UQ=s.extend({description:U().optional(),messages:A(HQ)}),LQ=B0.extend({method:E("notifications/prompts/list_changed"),params:z0.optional()}),DQ=Z({title:U().optional(),readOnlyHint:n().optional(),destructiveHint:n().optional(),idempotentHint:n().optional(),openWorldHint:n().optional()}),wQ=Z({taskSupport:Q0(["required","optional","forbidden"]).optional()}),rW=Z({...f0.shape,...G1.shape,description:U().optional(),inputSchema:Z({type:E("object"),properties:v(U(),i).optional(),required:A(U()).optional()}).catchall(c()),outputSchema:Z({type:E("object"),properties:v(U(),i).optional(),required:A(U()).optional()}).catchall(c()).optional(),annotations:DQ.optional(),execution:wQ.optional(),_meta:v(U(),c()).optional()}),MQ=q1.extend({method:E("tools/list")}),FQ=J1.extend({tools:A(rW)}),nW=s.extend({content:A(n9).default([]),structuredContent:v(U(),c()).optional(),isError:n().optional()}),GG=nW.or(s.extend({toolResult:c()})),OQ=y1.extend({name:U(),arguments:v(U(),c()).optional()}),VQ=a.extend({method:E("tools/call"),params:OQ}),NQ=B0.extend({method:E("notifications/tools/list_changed"),params:z0.optional()}),qG=Z({autoRefresh:n().default(!0),debounceMs:k().int().nonnegative().default(300)}),tW=Q0(["debug","info","notice","warning","error","critical","alert","emergency"]),PQ=q0.extend({level:tW}),ZQ=a.extend({method:E("logging/setLevel"),params:PQ}),RQ=z0.extend({level:tW,logger:U().optional(),data:c()}),EQ=B0.extend({method:E("notifications/message"),params:RQ}),IQ=Z({name:U().optional()}),CQ=Z({hints:A(IQ).optional(),costPriority:k().min(0).max(1).optional(),speedPriority:k().min(0).max(1).optional(),intelligencePriority:k().min(0).max(1).optional()}),_Q=Z({mode:Q0(["auto","required","none"]).optional()}),AQ=Z({type:E("tool_result"),toolUseId:U().describe("The unique identifier for the corresponding tool call."),content:A(n9).default([]),structuredContent:Z({}).loose().optional(),isError:n().optional(),_meta:v(U(),c()).optional()}),jQ=m9("type",[o9,i9,r9]),g1=m9("type",[o9,i9,r9,zQ,AQ]),SQ=Z({role:B1,content:y([g1,A(g1)]),_meta:v(U(),c()).optional()}),bQ=y1.extend({messages:A(SQ),modelPreferences:CQ.optional(),systemPrompt:U().optional(),includeContext:Q0(["none","thisServer","allServers"]).optional(),temperature:k().optional(),maxTokens:k().int(),stopSequences:A(U()).optional(),metadata:i.optional(),tools:A(rW).optional(),toolChoice:_Q.optional()}),TQ=a.extend({method:E("sampling/createMessage"),params:bQ}),kQ=s.extend({model:U(),stopReason:m(Q0(["endTurn","stopSequence","maxTokens"]).or(U())),role:B1,content:jQ}),vQ=s.extend({model:U(),stopReason:m(Q0(["endTurn","stopSequence","maxTokens","toolUse"]).or(U())),role:B1,content:y([g1,A(g1)])}),xQ=Z({type:E("boolean"),title:U().optional(),description:U().optional(),default:n().optional()}),gQ=Z({type:E("string"),title:U().optional(),description:U().optional(),minLength:k().optional(),maxLength:k().optional(),format:Q0(["email","uri","date","date-time"]).optional(),default:U().optional()}),hQ=Z({type:Q0(["number","integer"]),title:U().optional(),description:U().optional(),minimum:k().optional(),maximum:k().optional(),default:k().optional()}),yQ=Z({type:E("string"),title:U().optional(),description:U().optional(),enum:A(U()),default:U().optional()}),fQ=Z({type:E("string"),title:U().optional(),description:U().optional(),oneOf:A(Z({const:U(),title:U()})),default:U().optional()}),cQ=Z({type:E("string"),title:U().optional(),description:U().optional(),enum:A(U()),enumNames:A(U()).optional(),default:U().optional()}),mQ=y([yQ,fQ]),uQ=Z({type:E("array"),title:U().optional(),description:U().optional(),minItems:k().optional(),maxItems:k().optional(),items:Z({type:E("string"),enum:A(U())}),default:A(U()).optional()}),pQ=Z({type:E("array"),title:U().optional(),description:U().optional(),minItems:k().optional(),maxItems:k().optional(),items:Z({anyOf:A(Z({const:U(),title:U()}))}),default:A(U()).optional()}),lQ=y([uQ,pQ]),dQ=y([cQ,mQ,lQ]),oQ=y([dQ,xQ,gQ,hQ]),iQ=y1.extend({mode:E("form").optional(),message:U(),requestedSchema:Z({type:E("object"),properties:v(U(),oQ),required:A(U()).optional()})}),rQ=y1.extend({mode:E("url"),message:U(),elicitationId:U(),url:U().url()}),nQ=y([iQ,rQ]),tQ=a.extend({method:E("elicitation/create"),params:nQ}),aQ=z0.extend({elicitationId:U()}),sQ=B0.extend({method:E("notifications/elicitation/complete"),params:aQ}),eQ=s.extend({action:Q0(["accept","decline","cancel"]),content:u9((W)=>W===null?void 0:W,v(U(),y([U(),k(),n(),A(U())])).optional())}),W7=Z({type:E("ref/resource"),uri:U()});var X7=Z({type:E("ref/prompt"),name:U()}),Y7=q0.extend({ref:y([X7,W7]),argument:Z({name:U(),value:U()}),context:Z({arguments:v(U(),U()).optional()}).optional()}),Q7=a.extend({method:E("completion/complete"),params:Y7});var K7=s.extend({completion:W0({values:A(U()).max(100),total:m(k().int()),hasMore:m(n())})}),G7=Z({uri:U().startsWith("file://"),name:U().optional(),_meta:v(U(),c()).optional()}),q7=a.extend({method:E("roots/list"),params:q0.optional()}),J7=s.extend({roots:A(G7)}),z7=B0.extend({method:E("notifications/roots/list_changed"),params:z0.optional()}),JG=y([vW,TY,Q7,ZQ,JQ,KQ,uY,lY,iY,aY,eY,VQ,MQ,yW,cW,mW,pW]),zG=y([TW,xW,xY,z7,hW]),BG=y([bW,kQ,vQ,eQ,J7,fW,uW,gW]),$G=y([vW,TQ,tQ,q7,yW,cW,mW,pW]),HG=y([TW,xW,EQ,XQ,nY,NQ,LQ,hW,sQ]),UG=y([bW,vY,K7,UQ,GQ,pY,dY,rY,nW,FQ,fW,uW,gW]);var B7=10485760;class t9{constructor(W){this._maxBufferSize=W?.maxBufferSize??B7}append(W){if((this._buffer?.length??0)+W.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,W]):W}readMessage(){if(!this._buffer)return null;let W=this._buffer.indexOf(`
71
+ `);if(W===-1)return null;let X=this._buffer.toString("utf8",0,W).replace(/\r$/,"");return this._buffer=this._buffer.subarray(W+1),$7(X)}clear(){this._buffer=void 0}}function $7(W){return SW.parse(JSON.parse(W))}function aW(W){return JSON.stringify(W)+`
72
+ `}class c1{constructor(W=sW.stdin,X=sW.stdout,Y){this._stdin=W,this._stdout=X,this._started=!1,this._ondata=(Q)=>{try{this._readBuffer.append(Q),this.processReadBuffer()}catch(K){this.onerror?.(K),this.close().catch(()=>{})}},this._onerror=(Q)=>{this.onerror?.(Q)},this._readBuffer=new t9({maxBufferSize:Y?.maxBufferSize})}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let W=this._readBuffer.readMessage();if(W===null)break;this.onmessage?.(W)}catch(W){this.onerror?.(W)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(W){return new Promise((X)=>{let Y=aW(W);if(this._stdout.write(Y))X();else this._stdout.once("drain",X)})}}import{existsSync as c7}from"node:fs";u1();async function V3(W){let X=$4(await W),[Y,Q,{QuickJSWASMModule:K}]=await Promise.all([X.importModuleLoader().then($4),X.importFFI(),Promise.resolve().then(() => (O3(),F3)).then($4)]),q=await Y();q.type="sync";let J=new Q(q);return new K(q,J)}function $4(W){return W&&"default"in W&&W.default?W.default&&"default"in W.default&&W.default.default?W.default.default:W.default:W}var P3="engine";function T7(W){let X=(Y)=>new URL(Y,W).href;return{type:"sync",importFFI:()=>import(X("ffi.mjs")).then((Y)=>Y.QuickJSFFI),importModuleLoader:()=>import(X("emscripten-module.mjs")).then((Y)=>Y.default)}}var N3=null;function Z3(W){return()=>{return N3??=V3(T7(W)),N3}}var k7=x3(E3(),1);var x7="__mcpcloud_call_tool",Hq=`globalThis.tool = (name, args) =>
73
+ globalThis.${x7}(String(name), JSON.stringify(args ?? {}))
74
+ .then((json) => JSON.parse(json));`;var g7=6,h7=["log","warn","error","info","debug"],y7="__mcpcloud_console",Dq=`globalThis.console = {
75
+ ${h7.map((W)=>` ${W}: (...args) => globalThis.${y7}(${JSON.stringify(W)}, JSON.stringify(args.slice(0, ${g7}).map((value) => (value instanceof Error ? { __mcpcloudError: value.name + ': ' + value.message } : value)))),`).join(`
51
76
  `)}
52
- };`;var bQ=null;function F3(W){bQ=W}var N3=[`./${w3}/`,"../engine/vendor/","../../engine/vendor/"];function kQ(W=new URL(import.meta.url)){for(let X of N3){let K=new URL(X,W);if(TQ(new URL("emscripten-module.wasm",K)))return K}throw Error(`Code Mode engine not found. Looked for emscripten-module.wasm in: ${N3.join(", ")} (relative to ${W.href}).`)}function V3(){F3(()=>D3(kQ())())}async function vQ(W,X){V3();let K=W.createServer(X),Y=new g1;await K.connect(Y)}export{vQ as startStdioServer,g1 as StdioServerTransport};
77
+ };`;var f7=null;function I3(W){f7=W}var C3=[`./${P3}/`,"../engine/vendor/","../../engine/vendor/"];function m7(W=new URL(import.meta.url)){for(let X of C3){let Y=new URL(X,W);if(c7(new URL("emscripten-module.wasm",Y)))return Y}throw Error(`Code Mode engine not found. Looked for emscripten-module.wasm in: ${C3.join(", ")} (relative to ${W.href}).`)}function _3(){I3(()=>Z3(m7())())}async function u7(W,X){_3();let Y=W.createServer(X),Q=new c1;await Y.connect(Q)}export{u7 as startStdioServer,c1 as StdioServerTransport};