@mcpcloud/runtime 0.7.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/codeModeHost.d.ts +25 -0
- package/dist/compat-stdio.js +1 -1
- package/dist/compat-worker.js +1 -1
- package/dist/container-host.js +12 -2
- package/dist/engine/emscripten-module.cloudflare.cjs +21 -0
- package/dist/engine/emscripten-module.cloudflare.d.cts +3 -0
- package/dist/engine/emscripten-module.d.mts +3 -0
- package/dist/engine/emscripten-module.d.ts +11 -0
- package/dist/engine/emscripten-module.mjs +26 -0
- package/dist/engine/emscripten-module.wasm +0 -0
- package/dist/engine/ffi.d.mts +4 -0
- package/dist/engine/ffi.d.ts +85 -0
- package/dist/engine/ffi.mjs +1 -0
- package/dist/engine/manifest.json +51 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +61 -51
- package/dist/node.js +12 -2
- package/dist/projection.d.ts +9 -0
- package/dist/sandbox/bindings.d.ts +116 -0
- package/dist/sandbox/codeModeTool.d.ts +104 -0
- package/dist/sandbox/console.d.ts +51 -0
- package/dist/sandbox/createSandbox.d.ts +16 -1
- package/dist/sandbox/nodeEngine.d.ts +30 -0
- package/dist/sandbox/shape.d.ts +68 -0
- package/dist/sandbox/types.d.ts +80 -2
- package/dist/server.d.ts +13 -0
- package/dist/stdio.js +34 -24
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the engine for hosts that have to serve Code Mode themselves.
|
|
3
|
+
*
|
|
4
|
+
* The Workers edge does not use this: dispatch owns one warm engine for the
|
|
5
|
+
* whole namespace and intercepts `codemode_execute` before it reaches a
|
|
6
|
+
* generated server. Every other host — `bun run start:node` from a self-host
|
|
7
|
+
* export, stdio, and the dedicated-container runtime host, which serves through
|
|
8
|
+
* the same node adapter — has nothing in front of it, so if it does not supply
|
|
9
|
+
* an engine the tool simply never appears on a server whose operator turned it
|
|
10
|
+
* on. Silent absence is the failure worth engineering against here.
|
|
11
|
+
*
|
|
12
|
+
* node-only by construction. It lives under `adapters/` and is imported only by
|
|
13
|
+
* the node and stdio entries, so the Workers bundle never follows a path that
|
|
14
|
+
* reaches `node:fs` or the Node emscripten glue.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveVendorDir(from?: URL): URL;
|
|
17
|
+
/**
|
|
18
|
+
* Offer this process's engine to any server created afterwards.
|
|
19
|
+
*
|
|
20
|
+
* Nothing is loaded here. The engine instantiates on the first execution and
|
|
21
|
+
* not before, so a host whose servers all have Code Mode off never pays for the
|
|
22
|
+
* wasm — which is why this can be called unconditionally at startup rather than
|
|
23
|
+
* gated on a setting the adapter would have to go looking for.
|
|
24
|
+
*/
|
|
25
|
+
export declare function registerNodeCodeModeEngine(): void;
|
package/dist/compat-stdio.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.
|
|
1
|
+
/*! @mcpcloud/runtime v0.12.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var T4=Object.defineProperty;var _4=(W)=>W;function Z4(W,Q){this[W]=_4.bind(null,Q)}var QY=(W,Q)=>{for(var Y in Q)T4(W,Y,{get:Q[Y],enumerable:!0,configurable:!0,set:Z4.bind(Q,Y)})};import P4 from"node:process";var G2=Object.freeze({status:"aborted"});function K(W,Q,Y){function X(w,q){if(!w._zod)Object.defineProperty(w,"_zod",{value:{def:q,constr:H,traits:new Set},enumerable:!1});if(w._zod.traits.has(W))return;w._zod.traits.add(W),Q(w,q);let L=H.prototype,B=Object.keys(L);for(let z=0;z<B.length;z++){let I=B[z];if(!(I in w))w[I]=L[I].bind(w)}}let G=Y?.Parent??Object;class J extends G{}Object.defineProperty(J,"name",{value:W});function H(w){var q;let L=Y?.Parent?new J:this;X(L,w),(q=L._zod).deferred??(q.deferred=[]);for(let B of L._zod.deferred)B();return L}return Object.defineProperty(H,"init",{value:X}),Object.defineProperty(H,Symbol.hasInstance,{value:(w)=>{if(Y?.Parent&&w instanceof Y.Parent)return!0;return w?._zod?.traits?.has(W)}}),Object.defineProperty(H,"name",{value:W}),H}var J2=Symbol("zod_brand");class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class MW extends Error{constructor(W){super(`Encountered unidirectional transform during encode: ${W}`);this.name="ZodEncodeError"}}var vW={};function r(W){if(W)Object.assign(vW,W);return vW}var D={};QY(D,{unwrapMessage:()=>zW,uint8ArrayToHex:()=>Q6,uint8ArrayToBase64url:()=>s4,uint8ArrayToBase64:()=>AY,stringifyPrimitive:()=>cW,slugify:()=>HQ,shallowClone:()=>XY,safeExtend:()=>d4,required:()=>t4,randomString:()=>y4,propertyKeyTypes:()=>AQ,promiseAllObject:()=>u4,primitiveTypes:()=>GY,prefixIssues:()=>QW,pick:()=>l4,partial:()=>i4,parsedType:()=>LQ,optionalKeys:()=>qQ,omit:()=>r4,objectClone:()=>h4,numKeys:()=>m4,nullish:()=>IW,normalizeParams:()=>U,mergeDefs:()=>s,merge:()=>n4,jsonStringifyReplacer:()=>AW,joinValues:()=>gW,issue:()=>KW,isPlainObject:()=>XW,isObject:()=>HW,hexToUint8Array:()=>W6,getSizableOrigin:()=>HY,getParsedType:()=>f4,getLengthableOrigin:()=>OW,getEnumValues:()=>UW,getElementAtPath:()=>c4,floatSafeRemainder:()=>JQ,finalizeIssue:()=>t,extend:()=>p4,escapeRegex:()=>WW,esc:()=>hW,defineLazy:()=>F,createTransparentProxy:()=>o4,cloneDef:()=>x4,clone:()=>i,cleanRegex:()=>VW,cleanEnum:()=>e4,captureStackTrace:()=>xW,cached:()=>qW,base64urlToUint8Array:()=>a4,base64ToUint8Array:()=>wY,assignProp:()=>YW,assertNotEqual:()=>j4,assertNever:()=>v4,assertIs:()=>k4,assertEqual:()=>C4,assert:()=>g4,allowsEval:()=>wQ,aborted:()=>GW,NUMBER_FORMAT_RANGES:()=>KQ,Class:()=>qY,BIGINT_FORMAT_RANGES:()=>JY});function C4(W){return W}function j4(W){return W}function k4(W){}function v4(W){throw Error("Unexpected value in exhaustive check")}function g4(W){}function UW(W){let Q=Object.values(W).filter((X)=>typeof X==="number");return Object.entries(W).filter(([X,G])=>Q.indexOf(+X)===-1).map(([X,G])=>G)}function gW(W,Q="|"){return W.map((Y)=>cW(Y)).join(Q)}function AW(W,Q){if(typeof Q==="bigint")return Q.toString();return Q}function qW(W){return{get value(){{let Y=W();return Object.defineProperty(this,"value",{value:Y}),Y}throw Error("cached value already set")}}}function IW(W){return W===null||W===void 0}function VW(W){let Q=W.startsWith("^")?1:0,Y=W.endsWith("$")?W.length-1:W.length;return W.slice(Q,Y)}function JQ(W,Q){let Y=(W.toString().split(".")[1]||"").length,X=Q.toString(),G=(X.split(".")[1]||"").length;if(G===0&&/\d?e-\d?/.test(X)){let q=X.match(/\d?e-(\d?)/);if(q?.[1])G=Number.parseInt(q[1])}let J=Y>G?Y:G,H=Number.parseInt(W.toFixed(J).replace(".","")),w=Number.parseInt(Q.toFixed(J).replace(".",""));return H%w/10**J}var YY=Symbol("evaluating");function F(W,Q,Y){let X=void 0;Object.defineProperty(W,Q,{get(){if(X===YY)return;if(X===void 0)X=YY,X=Y();return X},set(G){Object.defineProperty(W,Q,{value:G})},configurable:!0})}function h4(W){return Object.create(Object.getPrototypeOf(W),Object.getOwnPropertyDescriptors(W))}function YW(W,Q,Y){Object.defineProperty(W,Q,{value:Y,writable:!0,enumerable:!0,configurable:!0})}function s(...W){let Q={};for(let Y of W){let X=Object.getOwnPropertyDescriptors(Y);Object.assign(Q,X)}return Object.defineProperties({},Q)}function x4(W){return s(W._zod.def)}function c4(W,Q){if(!Q)return W;return Q.reduce((Y,X)=>Y?.[X],W)}function u4(W){let Q=Object.keys(W),Y=Q.map((X)=>W[X]);return Promise.all(Y).then((X)=>{let G={};for(let J=0;J<Q.length;J++)G[Q[J]]=X[J];return G})}function y4(W=10){let Y="";for(let X=0;X<W;X++)Y+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Y}function hW(W){return JSON.stringify(W)}function HQ(W){return W.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xW="captureStackTrace"in Error?Error.captureStackTrace:(...W)=>{};function HW(W){return typeof W==="object"&&W!==null&&!Array.isArray(W)}var wQ=qW(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(W){return!1}});function XW(W){if(HW(W)===!1)return!1;let Q=W.constructor;if(Q===void 0)return!0;if(typeof Q!=="function")return!0;let Y=Q.prototype;if(HW(Y)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Y,"isPrototypeOf")===!1)return!1;return!0}function XY(W){if(XW(W))return{...W};if(Array.isArray(W))return[...W];return W}function m4(W){let Q=0;for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))Q++;return Q}var f4=(W)=>{let Q=typeof W;switch(Q){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: ${Q}`)}},AQ=new Set(["string","number","symbol"]),GY=new Set(["string","number","bigint","boolean","symbol","undefined"]);function WW(W){return W.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function i(W,Q,Y){let X=new W._zod.constr(Q??W._zod.def);if(!Q||Y?.parent)X._zod.parent=W;return X}function U(W){let Q=W;if(!Q)return{};if(typeof Q==="string")return{error:()=>Q};if(Q?.message!==void 0){if(Q?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Q.error=Q.message}if(delete Q.message,typeof Q.error==="string")return{...Q,error:()=>Q.error};return Q}function o4(W){let Q;return new Proxy({},{get(Y,X,G){return Q??(Q=W()),Reflect.get(Q,X,G)},set(Y,X,G,J){return Q??(Q=W()),Reflect.set(Q,X,G,J)},has(Y,X){return Q??(Q=W()),Reflect.has(Q,X)},deleteProperty(Y,X){return Q??(Q=W()),Reflect.deleteProperty(Q,X)},ownKeys(Y){return Q??(Q=W()),Reflect.ownKeys(Q)},getOwnPropertyDescriptor(Y,X){return Q??(Q=W()),Reflect.getOwnPropertyDescriptor(Q,X)},defineProperty(Y,X,G){return Q??(Q=W()),Reflect.defineProperty(Q,X,G)}})}function cW(W){if(typeof W==="bigint")return W.toString()+"n";if(typeof W==="string")return`"${W}"`;return`${W}`}function qQ(W){return Object.keys(W).filter((Q)=>{return W[Q]._zod.optin==="optional"&&W[Q]._zod.optout==="optional"})}var KQ={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]},JY={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function l4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;H[w]=Y.shape[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function r4(W,Q){let Y=W._zod.def,X=Y.checks;if(X&&X.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let J=s(W._zod.def,{get shape(){let H={...W._zod.def.shape};for(let w in Q){if(!(w in Y.shape))throw Error(`Unrecognized key: "${w}"`);if(!Q[w])continue;delete H[w]}return YW(this,"shape",H),H},checks:[]});return i(W,J)}function p4(W,Q){if(!XW(Q))throw Error("Invalid input to extend: expected a plain object");let Y=W._zod.def.checks;if(Y&&Y.length>0){let J=W._zod.def.shape;for(let H in Q)if(Object.getOwnPropertyDescriptor(J,H)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let G=s(W._zod.def,{get shape(){let J={...W._zod.def.shape,...Q};return YW(this,"shape",J),J}});return i(W,G)}function d4(W,Q){if(!XW(Q))throw Error("Invalid input to safeExtend: expected a plain object");let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q};return YW(this,"shape",X),X}});return i(W,Y)}function n4(W,Q){let Y=s(W._zod.def,{get shape(){let X={...W._zod.def.shape,...Q._zod.def.shape};return YW(this,"shape",X),X},get catchall(){return Q._zod.def.catchall},checks:[]});return i(W,Y)}function i4(W,Q,Y){let G=Q._zod.def.checks;if(G&&G.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let H=s(Q._zod.def,{get shape(){let w=Q._zod.def.shape,q={...w};if(Y)for(let L in Y){if(!(L in w))throw Error(`Unrecognized key: "${L}"`);if(!Y[L])continue;q[L]=W?new W({type:"optional",innerType:w[L]}):w[L]}else for(let L in w)q[L]=W?new W({type:"optional",innerType:w[L]}):w[L];return YW(this,"shape",q),q},checks:[]});return i(Q,H)}function t4(W,Q,Y){let X=s(Q._zod.def,{get shape(){let G=Q._zod.def.shape,J={...G};if(Y)for(let H in Y){if(!(H in J))throw Error(`Unrecognized key: "${H}"`);if(!Y[H])continue;J[H]=new W({type:"nonoptional",innerType:G[H]})}else for(let H in G)J[H]=new W({type:"nonoptional",innerType:G[H]});return YW(this,"shape",J),J}});return i(Q,X)}function GW(W,Q=0){if(W.aborted===!0)return!0;for(let Y=Q;Y<W.issues.length;Y++)if(W.issues[Y]?.continue!==!0)return!0;return!1}function QW(W,Q){return Q.map((Y)=>{var X;return(X=Y).path??(X.path=[]),Y.path.unshift(W),Y})}function zW(W){return typeof W==="string"?W:W?.message}function t(W,Q,Y){let X={...W,path:W.path??[]};if(!W.message){let G=zW(W.inst?._zod.def?.error?.(W))??zW(Q?.error?.(W))??zW(Y.customError?.(W))??zW(Y.localeError?.(W))??"Invalid input";X.message=G}if(delete X.inst,delete X.continue,!Q?.reportInput)delete X.input;return X}function HY(W){if(W instanceof Set)return"set";if(W instanceof Map)return"map";if(W instanceof File)return"file";return"unknown"}function OW(W){if(Array.isArray(W))return"array";if(typeof W==="string")return"string";return"unknown"}function LQ(W){let Q=typeof W;switch(Q){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 Q}function KW(...W){let[Q,Y,X]=W;if(typeof Q==="string")return{message:Q,code:"custom",input:Y,inst:X};return{...Q}}function e4(W){return Object.entries(W).filter(([Q,Y])=>{return Number.isNaN(Number.parseInt(Q,10))}).map((Q)=>Q[1])}function wY(W){let Q=atob(W),Y=new Uint8Array(Q.length);for(let X=0;X<Q.length;X++)Y[X]=Q.charCodeAt(X);return Y}function AY(W){let Q="";for(let Y=0;Y<W.length;Y++)Q+=String.fromCharCode(W[Y]);return btoa(Q)}function a4(W){let Q=W.replace(/-/g,"+").replace(/_/g,"/"),Y="=".repeat((4-Q.length%4)%4);return wY(Q+Y)}function s4(W){return AY(W).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function W6(W){let Q=W.replace(/^0x/,"");if(Q.length%2!==0)throw Error("Invalid hex string length");let Y=new Uint8Array(Q.length/2);for(let X=0;X<Q.length;X+=2)Y[X/2]=Number.parseInt(Q.slice(X,X+2),16);return Y}function Q6(W){return Array.from(W).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}class qY{constructor(...W){}}var KY=(W,Q)=>{W.name="$ZodError",Object.defineProperty(W,"_zod",{value:W._zod,enumerable:!1}),Object.defineProperty(W,"issues",{value:Q,enumerable:!1}),W.message=JSON.stringify(Q,AW,2),Object.defineProperty(W,"toString",{value:()=>W.message,enumerable:!1})},uW=K("$ZodError",KY),BQ=K("$ZodError",KY,{Parent:Error});function LY(W,Q=(Y)=>Y.message){let Y={},X=[];for(let G of W.issues)if(G.path.length>0)Y[G.path[0]]=Y[G.path[0]]||[],Y[G.path[0]].push(Q(G));else X.push(Q(G));return{formErrors:X,fieldErrors:Y}}function BY(W,Q=(Y)=>Y.message){let Y={_errors:[]},X=(G)=>{for(let J of G.issues)if(J.code==="invalid_union"&&J.errors.length)J.errors.map((H)=>X({issues:H}));else if(J.code==="invalid_key")X({issues:J.issues});else if(J.code==="invalid_element")X({issues:J.issues});else if(J.path.length===0)Y._errors.push(Q(J));else{let H=Y,w=0;while(w<J.path.length){let q=J.path[w];if(w!==J.path.length-1)H[q]=H[q]||{_errors:[]};else H[q]=H[q]||{_errors:[]},H[q]._errors.push(Q(J));H=H[q],w++}}};return X(W),Y}var yW=(W)=>(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!1}):{async:!1},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)throw new a;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var mW=(W)=>async(Q,Y,X,G)=>{let J=X?Object.assign(X,{async:!0}):{async:!0},H=Q._zod.run({value:Y,issues:[]},J);if(H instanceof Promise)H=await H;if(H.issues.length){let w=new(G?.Err??W)(H.issues.map((q)=>t(q,J,r())));throw xW(w,G?.callee),w}return H.value};var DW=(W)=>(Q,Y,X)=>{let G=X?{...X,async:!1}:{async:!1},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)throw new a;return J.issues.length?{success:!1,error:new(W??uW)(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},NY=DW(BQ),FW=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{async:!0}):{async:!0},J=Q._zod.run({value:Y,issues:[]},G);if(J instanceof Promise)J=await J;return J.issues.length?{success:!1,error:new W(J.issues.map((H)=>t(H,G,r())))}:{success:!0,data:J.value}},MY=FW(BQ),zY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return yW(W)(Q,Y,G)};var UY=(W)=>(Q,Y,X)=>{return yW(W)(Q,Y,X)};var IY=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return mW(W)(Q,Y,G)};var VY=(W)=>async(Q,Y,X)=>{return mW(W)(Q,Y,X)};var OY=(W)=>(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return DW(W)(Q,Y,G)};var DY=(W)=>(Q,Y,X)=>{return DW(W)(Q,Y,X)};var FY=(W)=>async(Q,Y,X)=>{let G=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return FW(W)(Q,Y,G)};var $Y=(W)=>async(Q,Y,X)=>{return FW(W)(Q,Y,X)};var PY=/^[cC][^\s-]{8,}$/,EY=/^[0-9a-z]+$/,RY=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,SY=/^[0-9a-vA-V]{20}$/,bY=/^[A-Za-z0-9]{27}$/,TY=/^[a-zA-Z0-9_-]{21}$/,_Y=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ZY=/^([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})$/,NQ=(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 CY=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var X6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function jY(){return new RegExp(X6,"u")}var kY=/^(?:(?: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])$/,vY=/^(([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 gY=/^((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])$/,hY=/^(([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])$/,xY=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,MQ=/^[A-Za-z0-9_-]*$/;var cY=/^\+[1-9]\d{6,14}$/,uY="(?:(?:\\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])))",yY=new RegExp(`^${uY}$`);function mY(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 fY(W){return new RegExp(`^${mY(W)}$`)}function oY(W){let Q=mY({precision:W.precision}),Y=["Z"];if(W.local)Y.push("");if(W.offset)Y.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let X=`${Q}(?:${Y.join("|")})`;return new RegExp(`^${uY}T(?:${X})$`)}var lY=(W)=>{let Q=W?`[\\s\\S]{${W?.minimum??0},${W?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Q}$`)};var rY=/^-?\d+$/,fW=/^-?\d+(?:\.\d+)?$/,pY=/^(?:true|false)$/i,dY=/^null$/i;var nY=/^[^A-Z]*$/,iY=/^[^a-z]*$/;var g=K("$ZodCheck",(W,Q)=>{var Y;W._zod??(W._zod={}),W._zod.def=Q,(Y=W._zod).onattach??(Y.onattach=[])}),tY={number:"number",bigint:"bigint",object:"date"},zQ=K("$ZodCheckLessThan",(W,Q)=>{g.init(W,Q);let Y=tY[typeof Q.value];W._zod.onattach.push((X)=>{let G=X._zod.bag,J=(Q.inclusive?G.maximum:G.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Q.value<J)if(Q.inclusive)G.maximum=Q.value;else G.exclusiveMaximum=Q.value}),W._zod.check=(X)=>{if(Q.inclusive?X.value<=Q.value:X.value<Q.value)return;X.issues.push({origin:Y,code:"too_big",maximum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:X.value,inclusive:Q.inclusive,inst:W,continue:!Q.abort})}}),UQ=K("$ZodCheckGreaterThan",(W,Q)=>{g.init(W,Q);let Y=tY[typeof Q.value];W._zod.onattach.push((X)=>{let G=X._zod.bag,J=(Q.inclusive?G.minimum:G.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Q.value>J)if(Q.inclusive)G.minimum=Q.value;else G.exclusiveMinimum=Q.value}),W._zod.check=(X)=>{if(Q.inclusive?X.value>=Q.value:X.value>Q.value)return;X.issues.push({origin:Y,code:"too_small",minimum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:X.value,inclusive:Q.inclusive,inst:W,continue:!Q.abort})}}),eY=K("$ZodCheckMultipleOf",(W,Q)=>{g.init(W,Q),W._zod.onattach.push((Y)=>{var X;(X=Y._zod.bag).multipleOf??(X.multipleOf=Q.value)}),W._zod.check=(Y)=>{if(typeof Y.value!==typeof Q.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Y.value==="bigint"?Y.value%Q.value===BigInt(0):JQ(Y.value,Q.value)===0)return;Y.issues.push({origin:typeof Y.value,code:"not_multiple_of",divisor:Q.value,input:Y.value,inst:W,continue:!Q.abort})}}),aY=K("$ZodCheckNumberFormat",(W,Q)=>{g.init(W,Q),Q.format=Q.format||"float64";let Y=Q.format?.includes("int"),X=Y?"int":"number",[G,J]=KQ[Q.format];W._zod.onattach.push((H)=>{let w=H._zod.bag;if(w.format=Q.format,w.minimum=G,w.maximum=J,Y)w.pattern=rY}),W._zod.check=(H)=>{let w=H.value;if(Y){if(!Number.isInteger(w)){H.issues.push({expected:X,format:Q.format,code:"invalid_type",continue:!1,input:w,inst:W});return}if(!Number.isSafeInteger(w)){if(w>0)H.issues.push({input:w,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:X,inclusive:!0,continue:!Q.abort});else H.issues.push({input:w,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:W,origin:X,inclusive:!0,continue:!Q.abort});return}}if(w<G)H.issues.push({origin:"number",input:w,code:"too_small",minimum:G,inclusive:!0,inst:W,continue:!Q.abort});if(w>J)H.issues.push({origin:"number",input:w,code:"too_big",maximum:J,inclusive:!0,inst:W,continue:!Q.abort})}});var sY=K("$ZodCheckMaxLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Q.maximum<G)X._zod.bag.maximum=Q.maximum}),W._zod.check=(X)=>{let G=X.value;if(G.length<=Q.maximum)return;let H=OW(G);X.issues.push({origin:H,code:"too_big",maximum:Q.maximum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),W0=K("$ZodCheckMinLength",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Q.minimum>G)X._zod.bag.minimum=Q.minimum}),W._zod.check=(X)=>{let G=X.value;if(G.length>=Q.minimum)return;let H=OW(G);X.issues.push({origin:H,code:"too_small",minimum:Q.minimum,inclusive:!0,input:G,inst:W,continue:!Q.abort})}}),Q0=K("$ZodCheckLengthEquals",(W,Q)=>{var Y;g.init(W,Q),(Y=W._zod.def).when??(Y.when=(X)=>{let G=X.value;return!IW(G)&&G.length!==void 0}),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.minimum=Q.length,G.maximum=Q.length,G.length=Q.length}),W._zod.check=(X)=>{let G=X.value,J=G.length;if(J===Q.length)return;let H=OW(G),w=J>Q.length;X.issues.push({origin:H,...w?{code:"too_big",maximum:Q.length}:{code:"too_small",minimum:Q.length},inclusive:!0,exact:!0,input:X.value,inst:W,continue:!Q.abort})}}),$W=K("$ZodCheckStringFormat",(W,Q)=>{var Y,X;if(g.init(W,Q),W._zod.onattach.push((G)=>{let J=G._zod.bag;if(J.format=Q.format,Q.pattern)J.patterns??(J.patterns=new Set),J.patterns.add(Q.pattern)}),Q.pattern)(Y=W._zod).check??(Y.check=(G)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(G.value))return;G.issues.push({origin:"string",code:"invalid_format",format:Q.format,input:G.value,...Q.pattern?{pattern:Q.pattern.toString()}:{},inst:W,continue:!Q.abort})});else(X=W._zod).check??(X.check=()=>{})}),Y0=K("$ZodCheckRegex",(W,Q)=>{$W.init(W,Q),W._zod.check=(Y)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Y.value,pattern:Q.pattern.toString(),inst:W,continue:!Q.abort})}}),X0=K("$ZodCheckLowerCase",(W,Q)=>{Q.pattern??(Q.pattern=nY),$W.init(W,Q)}),G0=K("$ZodCheckUpperCase",(W,Q)=>{Q.pattern??(Q.pattern=iY),$W.init(W,Q)}),J0=K("$ZodCheckIncludes",(W,Q)=>{g.init(W,Q);let Y=WW(Q.includes),X=new RegExp(typeof Q.position==="number"?`^.{${Q.position}}${Y}`:Y);Q.pattern=X,W._zod.onattach.push((G)=>{let J=G._zod.bag;J.patterns??(J.patterns=new Set),J.patterns.add(X)}),W._zod.check=(G)=>{if(G.value.includes(Q.includes,Q.position))return;G.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Q.includes,input:G.value,inst:W,continue:!Q.abort})}}),H0=K("$ZodCheckStartsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`^${WW(Q.prefix)}.*`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.startsWith(Q.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Q.prefix,input:X.value,inst:W,continue:!Q.abort})}}),w0=K("$ZodCheckEndsWith",(W,Q)=>{g.init(W,Q);let Y=new RegExp(`.*${WW(Q.suffix)}$`);Q.pattern??(Q.pattern=Y),W._zod.onattach.push((X)=>{let G=X._zod.bag;G.patterns??(G.patterns=new Set),G.patterns.add(Y)}),W._zod.check=(X)=>{if(X.value.endsWith(Q.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Q.suffix,input:X.value,inst:W,continue:!Q.abort})}});var A0=K("$ZodCheckOverwrite",(W,Q)=>{g.init(W,Q),W._zod.check=(Y)=>{Y.value=Q.tx(Y.value)}});class IQ{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(`
|
|
3
3
|
`).filter((J)=>J),X=Math.min(...Y.map((J)=>J.length-J.trimStart().length)),G=Y.map((J)=>J.slice(X)).map((J)=>" ".repeat(this.indent*2)+J);for(let J of G)this.content.push(J)}compile(){let W=Function,Q=this?.args,X=[...(this?.content??[""]).map((G)=>` ${G}`)];return new W(...Q,X.join(`
|
|
4
4
|
`))}}var K0={major:4,minor:3,patch:6};var E=K("$ZodType",(W,Q)=>{var Y;W??(W={}),W._zod.def=Q,W._zod.bag=W._zod.bag||{},W._zod.version=K0;let X=[...W._zod.def.checks??[]];if(W._zod.traits.has("$ZodCheck"))X.unshift(W);for(let G of X)for(let J of G._zod.onattach)J(W);if(X.length===0)(Y=W._zod).deferred??(Y.deferred=[]),W._zod.deferred?.push(()=>{W._zod.run=W._zod.parse});else{let G=(H,w,q)=>{let L=GW(H),B;for(let z of w){if(z._zod.def.when){if(!z._zod.def.when(H))continue}else if(L)continue;let I=H.issues.length,V=z._zod.check(H);if(V instanceof Promise&&q?.async===!1)throw new a;if(B||V instanceof Promise)B=(B??Promise.resolve()).then(async()=>{if(await V,H.issues.length===I)return;if(!L)L=GW(H,I)});else{if(H.issues.length===I)continue;if(!L)L=GW(H,I)}}if(B)return B.then(()=>{return H});return H},J=(H,w,q)=>{if(GW(H))return H.aborted=!0,H;let L=G(w,X,q);if(L instanceof Promise){if(q.async===!1)throw new a;return L.then((B)=>W._zod.parse(B,q))}return W._zod.parse(L,q)};W._zod.run=(H,w)=>{if(w.skipChecks)return W._zod.parse(H,w);if(w.direction==="backward"){let L=W._zod.parse({value:H.value,issues:[]},{...w,skipChecks:!0});if(L instanceof Promise)return L.then((B)=>{return J(B,H,w)});return J(L,H,w)}let q=W._zod.parse(H,w);if(q instanceof Promise){if(w.async===!1)throw new a;return q.then((L)=>G(L,X,w))}return G(q,X,w)}}F(W,"~standard",()=>({validate:(G)=>{try{let J=NY(W,G);return J.success?{value:J.data}:{issues:J.error?.issues}}catch(J){return MY(W,G).then((H)=>H.success?{value:H.data}:{issues:H.error?.issues})}},vendor:"zod",version:1}))}),pW=K("$ZodString",(W,Q)=>{E.init(W,Q),W._zod.pattern=[...W?._zod.bag?.patterns??[]].pop()??lY(W._zod.bag),W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=String(Y.value)}catch(G){}if(typeof Y.value==="string")return Y;return Y.issues.push({expected:"string",code:"invalid_type",input:Y.value,inst:W}),Y}}),R=K("$ZodStringFormat",(W,Q)=>{$W.init(W,Q),pW.init(W,Q)}),O0=K("$ZodGUID",(W,Q)=>{Q.pattern??(Q.pattern=ZY),R.init(W,Q)}),D0=K("$ZodUUID",(W,Q)=>{if(Q.version){let X={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[Q.version];if(X===void 0)throw Error(`Invalid UUID version: "${Q.version}"`);Q.pattern??(Q.pattern=NQ(X))}else Q.pattern??(Q.pattern=NQ());R.init(W,Q)}),F0=K("$ZodEmail",(W,Q)=>{Q.pattern??(Q.pattern=CY),R.init(W,Q)}),$0=K("$ZodURL",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{try{let X=Y.value.trim(),G=new URL(X);if(Q.hostname){if(Q.hostname.lastIndex=0,!Q.hostname.test(G.hostname))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Q.hostname.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.protocol){if(Q.protocol.lastIndex=0,!Q.protocol.test(G.protocol.endsWith(":")?G.protocol.slice(0,-1):G.protocol))Y.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:Q.protocol.source,input:Y.value,inst:W,continue:!Q.abort})}if(Q.normalize)Y.value=G.href;else Y.value=X;return}catch(X){Y.issues.push({code:"invalid_format",format:"url",input:Y.value,inst:W,continue:!Q.abort})}}}),P0=K("$ZodEmoji",(W,Q)=>{Q.pattern??(Q.pattern=jY()),R.init(W,Q)}),E0=K("$ZodNanoID",(W,Q)=>{Q.pattern??(Q.pattern=TY),R.init(W,Q)}),R0=K("$ZodCUID",(W,Q)=>{Q.pattern??(Q.pattern=PY),R.init(W,Q)}),S0=K("$ZodCUID2",(W,Q)=>{Q.pattern??(Q.pattern=EY),R.init(W,Q)}),b0=K("$ZodULID",(W,Q)=>{Q.pattern??(Q.pattern=RY),R.init(W,Q)}),T0=K("$ZodXID",(W,Q)=>{Q.pattern??(Q.pattern=SY),R.init(W,Q)}),_0=K("$ZodKSUID",(W,Q)=>{Q.pattern??(Q.pattern=bY),R.init(W,Q)}),Z0=K("$ZodISODateTime",(W,Q)=>{Q.pattern??(Q.pattern=oY(Q)),R.init(W,Q)}),C0=K("$ZodISODate",(W,Q)=>{Q.pattern??(Q.pattern=yY),R.init(W,Q)}),j0=K("$ZodISOTime",(W,Q)=>{Q.pattern??(Q.pattern=fY(Q)),R.init(W,Q)}),k0=K("$ZodISODuration",(W,Q)=>{Q.pattern??(Q.pattern=_Y),R.init(W,Q)}),v0=K("$ZodIPv4",(W,Q)=>{Q.pattern??(Q.pattern=kY),R.init(W,Q),W._zod.bag.format="ipv4"}),g0=K("$ZodIPv6",(W,Q)=>{Q.pattern??(Q.pattern=vY),R.init(W,Q),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:!Q.abort})}}});var h0=K("$ZodCIDRv4",(W,Q)=>{Q.pattern??(Q.pattern=gY),R.init(W,Q)}),x0=K("$ZodCIDRv6",(W,Q)=>{Q.pattern??(Q.pattern=hY),R.init(W,Q),W._zod.check=(Y)=>{let X=Y.value.split("/");try{if(X.length!==2)throw Error();let[G,J]=X;if(!J)throw Error();let H=Number(J);if(`${H}`!==J)throw Error();if(H<0||H>128)throw Error();new URL(`http://[${G}]`)}catch{Y.issues.push({code:"invalid_format",format:"cidrv6",input:Y.value,inst:W,continue:!Q.abort})}}});function c0(W){if(W==="")return!0;if(W.length%4!==0)return!1;try{return atob(W),!0}catch{return!1}}var u0=K("$ZodBase64",(W,Q)=>{Q.pattern??(Q.pattern=xY),R.init(W,Q),W._zod.bag.contentEncoding="base64",W._zod.check=(Y)=>{if(c0(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64",input:Y.value,inst:W,continue:!Q.abort})}});function G6(W){if(!MQ.test(W))return!1;let Q=W.replace(/[-_]/g,(X)=>X==="-"?"+":"/"),Y=Q.padEnd(Math.ceil(Q.length/4)*4,"=");return c0(Y)}var y0=K("$ZodBase64URL",(W,Q)=>{Q.pattern??(Q.pattern=MQ),R.init(W,Q),W._zod.bag.contentEncoding="base64url",W._zod.check=(Y)=>{if(G6(Y.value))return;Y.issues.push({code:"invalid_format",format:"base64url",input:Y.value,inst:W,continue:!Q.abort})}}),m0=K("$ZodE164",(W,Q)=>{Q.pattern??(Q.pattern=cY),R.init(W,Q)});function J6(W,Q=null){try{let Y=W.split(".");if(Y.length!==3)return!1;let[X]=Y;if(!X)return!1;let G=JSON.parse(atob(X));if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(Q&&(!("alg"in G)||G.alg!==Q))return!1;return!0}catch{return!1}}var f0=K("$ZodJWT",(W,Q)=>{R.init(W,Q),W._zod.check=(Y)=>{if(J6(Y.value,Q.alg))return;Y.issues.push({code:"invalid_format",format:"jwt",input:Y.value,inst:W,continue:!Q.abort})}});var OQ=K("$ZodNumber",(W,Q)=>{E.init(W,Q),W._zod.pattern=W._zod.bag.pattern??fW,W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=Number(Y.value)}catch(H){}let G=Y.value;if(typeof G==="number"&&!Number.isNaN(G)&&Number.isFinite(G))return Y;let J=typeof G==="number"?Number.isNaN(G)?"NaN":!Number.isFinite(G)?"Infinity":void 0:void 0;return Y.issues.push({expected:"number",code:"invalid_type",input:G,inst:W,...J?{received:J}:{}}),Y}}),o0=K("$ZodNumberFormat",(W,Q)=>{aY.init(W,Q),OQ.init(W,Q)}),l0=K("$ZodBoolean",(W,Q)=>{E.init(W,Q),W._zod.pattern=pY,W._zod.parse=(Y,X)=>{if(Q.coerce)try{Y.value=Boolean(Y.value)}catch(J){}let G=Y.value;if(typeof G==="boolean")return Y;return Y.issues.push({expected:"boolean",code:"invalid_type",input:G,inst:W}),Y}});var r0=K("$ZodNull",(W,Q)=>{E.init(W,Q),W._zod.pattern=dY,W._zod.values=new Set([null]),W._zod.parse=(Y,X)=>{let G=Y.value;if(G===null)return Y;return Y.issues.push({expected:"null",code:"invalid_type",input:G,inst:W}),Y}});var p0=K("$ZodUnknown",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y)=>Y}),d0=K("$ZodNever",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{return Y.issues.push({expected:"never",code:"invalid_type",input:Y.value,inst:W}),Y}});function L0(W,Q,Y){if(W.issues.length)Q.issues.push(...QW(Y,W.issues));Q.value[Y]=W.value}var n0=K("$ZodArray",(W,Q)=>{E.init(W,Q),W._zod.parse=(Y,X)=>{let G=Y.value;if(!Array.isArray(G))return Y.issues.push({expected:"array",code:"invalid_type",input:G,inst:W}),Y;Y.value=Array(G.length);let J=[];for(let H=0;H<G.length;H++){let w=G[H],q=Q.element._zod.run({value:w,issues:[]},X);if(q instanceof Promise)J.push(q.then((L)=>L0(L,Y,H)));else L0(q,Y,H)}if(J.length)return Promise.all(J).then(()=>Y);return Y}});function rW(W,Q,Y,X,G){if(W.issues.length){if(G&&!(Y in X))return;Q.issues.push(...QW(Y,W.issues))}if(W.value===void 0){if(Y in X)Q.value[Y]=void 0}else Q.value[Y]=W.value}function i0(W){let Q=Object.keys(W.shape);for(let X of Q)if(!W.shape?.[X]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${X}": expected a Zod schema`);let Y=qQ(W.shape);return{...W,keys:Q,keySet:new Set(Q),numKeys:Q.length,optionalKeys:new Set(Y)}}function t0(W,Q,Y,X,G,J){let H=[],w=G.keySet,q=G.catchall._zod,L=q.def.type,B=q.optout==="optional";for(let z in Q){if(w.has(z))continue;if(L==="never"){H.push(z);continue}let I=q.run({value:Q[z],issues:[]},X);if(I instanceof Promise)W.push(I.then((V)=>rW(V,Y,z,Q,B)));else rW(I,Y,z,Q,B)}if(H.length)Y.issues.push({code:"unrecognized_keys",keys:H,input:Q,inst:J});if(!W.length)return Y;return Promise.all(W).then(()=>{return Y})}var H6=K("$ZodObject",(W,Q)=>{if(E.init(W,Q),!Object.getOwnPropertyDescriptor(Q,"shape")?.get){let w=Q.shape;Object.defineProperty(Q,"shape",{get:()=>{let q={...w};return Object.defineProperty(Q,"shape",{value:q}),q}})}let X=qW(()=>i0(Q));F(W._zod,"propValues",()=>{let w=Q.shape,q={};for(let L in w){let B=w[L]._zod;if(B.values){q[L]??(q[L]=new Set);for(let z of B.values)q[L].add(z)}}return q});let G=HW,J=Q.catchall,H;W._zod.parse=(w,q)=>{H??(H=X.value);let L=w.value;if(!G(L))return w.issues.push({expected:"object",code:"invalid_type",input:L,inst:W}),w;w.value={};let B=[],z=H.shape;for(let I of H.keys){let V=z[I],c=V._zod.optout==="optional",v=V._zod.run({value:L[I],issues:[]},q);if(v instanceof Promise)B.push(v.then((kW)=>rW(kW,w,I,L,c)));else rW(v,w,I,L,c)}if(!J)return B.length?Promise.all(B).then(()=>w):w;return t0(B,L,w,q,X.value,W)}}),e0=K("$ZodObjectJIT",(W,Q)=>{H6.init(W,Q);let Y=W._zod.parse,X=qW(()=>i0(Q)),G=(I)=>{let V=new IQ(["shape","payload","ctx"]),c=X.value,v=(e)=>{let m=hW(e);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};V.write("const input = payload.value;");let kW=Object.create(null),R4=0;for(let e of c.keys)kW[e]=`key_${R4++}`;V.write("const newResult = {};");for(let e of c.keys){let m=kW[e],n=hW(e),b4=I[e]?._zod?.optout==="optional";if(V.write(`const ${m} = ${v(e)};`),b4)V.write(`
|
package/dist/compat-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.
|
|
1
|
+
/*! @mcpcloud/runtime v0.12.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
2
|
var XP=Object.create;var{getPrototypeOf:JP,defineProperty:C9,getOwnPropertyNames:vP}=Object;var zP=Object.prototype.hasOwnProperty;function QP($){return this[$]}var GP,YP,_9=($,U,W)=>{var J=$!=null&&typeof $==="object";if(J){var X=U?GP??=new WeakMap:YP??=new WeakMap,v=X.get($);if(v)return v}W=$!=null?XP(JP($)):{};let z=U||!$||!$.__esModule?C9(W,"default",{value:$,enumerable:!0}):W;for(let Q of vP($))if(!zP.call(z,Q))C9(z,Q,{get:QP.bind($,Q),enumerable:!0});if(J)X.set($,z);return z};var q=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var DP=($)=>$;function HP($,U){this[$]=DP.bind(null,U)}var x4=($,U)=>{for(var W in U)C9($,W,{get:U[W],enumerable:!0,configurable:!0,set:HP.bind(U,W)})};var vW=q((wI)=>{Object.defineProperty(wI,"__esModule",{value:!0});wI.regexpCode=wI.getEsmExportName=wI.getProperty=wI.safeStringify=wI.stringify=wI.strConcat=wI.addCodeArg=wI.str=wI._=wI.nil=wI._Code=wI.Name=wI.IDENTIFIER=wI._CodeOrName=void 0;class hJ{}wI._CodeOrName=hJ;wI.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class H0 extends hJ{constructor($){super();if(!wI.IDENTIFIER.test($))throw Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}wI.Name=H0;class m4 extends hJ{constructor($){super();this._items=typeof $==="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((U,W)=>`${U}${W}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((U,W)=>{if(W instanceof H0)U[W.str]=(U[W.str]||0)+1;return U},{})}}wI._Code=m4;wI.nil=new m4("");function bI($,...U){let W=[$[0]],J=0;while(J<U.length)u8(W,U[J]),W.push($[++J]);return new m4(W)}wI._=bI;var g8=new m4("+");function BI($,...U){let W=[JW($[0])],J=0;while(J<U.length)W.push(g8),u8(W,U[J]),W.push(g8,JW($[++J]));return _T(W),new m4(W)}wI.str=BI;function u8($,U){if(U instanceof m4)$.push(...U._items);else if(U instanceof H0)$.push(U);else $.push(xT(U))}wI.addCodeArg=u8;function _T($){let U=1;while(U<$.length-1){if($[U]===g8){let W=gT($[U-1],$[U+1]);if(W!==void 0){$.splice(U-1,3,W);continue}$[U++]="+"}U++}}function gT($,U){if(U==='""')return $;if($==='""')return U;if(typeof $=="string"){if(U instanceof H0||$[$.length-1]!=='"')return;if(typeof U!="string")return`${$.slice(0,-1)}${U}"`;if(U[0]==='"')return $.slice(0,-1)+U.slice(1);return}if(typeof U=="string"&&U[0]==='"'&&!($ instanceof H0))return`"${$}${U.slice(1)}`;return}function uT($,U){return U.emptyStr()?$:$.emptyStr()?U:BI`${$}${U}`}wI.strConcat=uT;function xT($){return typeof $=="number"||typeof $=="boolean"||$===null?$:JW(Array.isArray($)?$.join(","):$)}function yT($){return new m4(JW($))}wI.stringify=yT;function JW($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}wI.safeStringify=JW;function fT($){return typeof $=="string"&&wI.IDENTIFIER.test($)?new m4(`.${$}`):bI`[${$}]`}wI.getProperty=fT;function hT($){if(typeof $=="string"&&wI.IDENTIFIER.test($))return new m4(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}wI.getEsmExportName=hT;function lT($){return new m4($.toString())}wI.regexpCode=lT});var h8=q((KI)=>{Object.defineProperty(KI,"__esModule",{value:!0});KI.ValueScope=KI.ValueScopeName=KI.Scope=KI.varKinds=KI.UsedValueState=void 0;var D4=vW();class LI extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var mJ;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(mJ||(KI.UsedValueState=mJ={}));KI.varKinds={const:new D4.Name("const"),let:new D4.Name("let"),var:new D4.Name("var")};class y8{constructor({prefixes:$,parent:U}={}){this._names={},this._prefixes=$,this._parent=U}toName($){return $ instanceof D4.Name?$:this.name($)}name($){return new D4.Name(this._newName($))}_newName($){let U=this._names[$]||this._nameGroup($);return`${$}${U.index++}`}_nameGroup($){var U,W;if(((W=(U=this._parent)===null||U===void 0?void 0:U._prefixes)===null||W===void 0?void 0:W.has($))||this._prefixes&&!this._prefixes.has($))throw Error(`CodeGen: prefix "${$}" is not allowed in this scope`);return this._names[$]={prefix:$,index:0}}}KI.Scope=y8;class f8 extends D4.Name{constructor($,U){super(U);this.prefix=$}setValue($,{property:U,itemIndex:W}){this.value=$,this.scopePath=D4._`.${new D4.Name(U)}[${W}]`}}KI.ValueScopeName=f8;var $C=D4._`\n`;class II extends y8{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?$C:D4.nil}}get(){return this._scope}name($){return new f8($,this._newName($))}value($,U){var W;if(U.ref===void 0)throw Error("CodeGen: ref must be passed in value");let J=this.toName($),{prefix:X}=J,v=(W=U.key)!==null&&W!==void 0?W:U.ref,z=this._values[X];if(z){let Y=z.get(v);if(Y)return Y}else z=this._values[X]=new Map;z.set(v,J);let Q=this._scope[X]||(this._scope[X]=[]),G=Q.length;return Q[G]=U.ref,J.setValue(U,{property:X,itemIndex:G}),J}getValue($,U){let W=this._values[$];if(!W)return;return W.get(U)}scopeRefs($,U=this._values){return this._reduceValues(U,(W)=>{if(W.scopePath===void 0)throw Error(`CodeGen: name "${W}" has no value`);return D4._`${$}${W.scopePath}`})}scopeCode($=this._values,U,W){return this._reduceValues($,(J)=>{if(J.value===void 0)throw Error(`CodeGen: name "${J}" has no value`);return J.value.code},U,W)}_reduceValues($,U,W={},J){let X=D4.nil;for(let v in $){let z=$[v];if(!z)continue;let Q=W[v]=W[v]||new Map;z.forEach((G)=>{if(Q.has(G))return;Q.set(G,mJ.Started);let Y=U(G);if(Y){let D=this.opts.es5?KI.varKinds.var:KI.varKinds.const;X=D4._`${X}${D} ${G} = ${Y};${this.opts._n}`}else if(Y=J===null||J===void 0?void 0:J(G))X=D4._`${X}${Y}${this.opts._n}`;else throw new LI(G);Q.set(G,mJ.Completed)})}return X}}KI.ValueScope=II});var s=q((H4)=>{Object.defineProperty(H4,"__esModule",{value:!0});H4.or=H4.and=H4.not=H4.CodeGen=H4.operators=H4.varKinds=H4.ValueScopeName=H4.ValueScope=H4.Scope=H4.Name=H4.regexpCode=H4.stringify=H4.getProperty=H4.nil=H4.strConcat=H4.str=H4._=void 0;var z$=vW(),i4=h8(),c6=vW();Object.defineProperty(H4,"_",{enumerable:!0,get:function(){return c6._}});Object.defineProperty(H4,"str",{enumerable:!0,get:function(){return c6.str}});Object.defineProperty(H4,"strConcat",{enumerable:!0,get:function(){return c6.strConcat}});Object.defineProperty(H4,"nil",{enumerable:!0,get:function(){return c6.nil}});Object.defineProperty(H4,"getProperty",{enumerable:!0,get:function(){return c6.getProperty}});Object.defineProperty(H4,"stringify",{enumerable:!0,get:function(){return c6.stringify}});Object.defineProperty(H4,"regexpCode",{enumerable:!0,get:function(){return c6.regexpCode}});Object.defineProperty(H4,"Name",{enumerable:!0,get:function(){return c6.Name}});var oJ=h8();Object.defineProperty(H4,"Scope",{enumerable:!0,get:function(){return oJ.Scope}});Object.defineProperty(H4,"ValueScope",{enumerable:!0,get:function(){return oJ.ValueScope}});Object.defineProperty(H4,"ValueScopeName",{enumerable:!0,get:function(){return oJ.ValueScopeName}});Object.defineProperty(H4,"varKinds",{enumerable:!0,get:function(){return oJ.varKinds}});H4.operators={GT:new z$._Code(">"),GTE:new z$._Code(">="),LT:new z$._Code("<"),LTE:new z$._Code("<="),EQ:new z$._Code("==="),NEQ:new z$._Code("!=="),NOT:new z$._Code("!"),OR:new z$._Code("||"),AND:new z$._Code("&&"),ADD:new z$._Code("+")};class p6{optimizeNodes(){return this}optimizeNames($,U){return this}}class OI extends p6{constructor($,U,W){super();this.varKind=$,this.name=U,this.rhs=W}render({es5:$,_n:U}){let W=$?i4.varKinds.var:this.varKind,J=this.rhs===void 0?"":` = ${this.rhs}`;return`${W} ${this.name}${J};`+U}optimizeNames($,U){if(!$[this.name.str])return;if(this.rhs)this.rhs=B0(this.rhs,$,U);return this}get names(){return this.rhs instanceof z$._CodeOrName?this.rhs.names:{}}}class i8 extends p6{constructor($,U,W){super();this.lhs=$,this.rhs=U,this.sideEffects=W}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,U){if(this.lhs instanceof z$.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=B0(this.rhs,$,U),this}get names(){let $=this.lhs instanceof z$.Name?{}:{...this.lhs.names};return pJ($,this.rhs)}}class qI extends i8{constructor($,U,W,J){super($,W,J);this.op=U}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class VI extends p6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class FI extends p6{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class jI extends p6{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class MI extends p6{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,U){return this.code=B0(this.code,$,U),this}get names(){return this.code instanceof z$._CodeOrName?this.code.names:{}}}class dJ extends p6{constructor($=[]){super();this.nodes=$}render($){return this.nodes.reduce((U,W)=>U+W.render($),"")}optimizeNodes(){let{nodes:$}=this,U=$.length;while(U--){let W=$[U].optimizeNodes();if(Array.isArray(W))$.splice(U,1,...W);else if(W)$[U]=W;else $.splice(U,1)}return $.length>0?this:void 0}optimizeNames($,U){let{nodes:W}=this,J=W.length;while(J--){let X=W[J];if(X.optimizeNames($,U))continue;JC($,X.names),W.splice(J,1)}return W.length>0?this:void 0}get names(){return this.nodes.reduce(($,U)=>M1($,U.names),{})}}class o6 extends dJ{render($){return"{"+$._n+super.render($)+"}"+$._n}}class EI extends dJ{}class zW extends o6{}zW.kind="else";class F6 extends o6{constructor($,U){super(U);this.condition=$}render($){let U=`if(${this.condition})`+super.render($);if(this.else)U+="else "+this.else.render($);return U}optimizeNodes(){super.optimizeNodes();let $=this.condition;if($===!0)return this.nodes;let U=this.else;if(U){let W=U.optimizeNodes();U=this.else=Array.isArray(W)?new zW(W):W}if(U){if($===!1)return U instanceof F6?U:U.nodes;if(this.nodes.length)return this;return new F6(ZI($),U instanceof F6?[U]:U.nodes)}if($===!1||!this.nodes.length)return;return this}optimizeNames($,U){var W;if(this.else=(W=this.else)===null||W===void 0?void 0:W.optimizeNames($,U),!(super.optimizeNames($,U)||this.else))return;return this.condition=B0(this.condition,$,U),this}get names(){let $=super.names;if(pJ($,this.condition),this.else)M1($,this.else.names);return $}}F6.kind="if";class b0 extends o6{}b0.kind="for";class SI extends b0{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iteration=B0(this.iteration,$,U),this}get names(){return M1(super.names,this.iteration.names)}}class PI extends b0{constructor($,U,W,J){super();this.varKind=$,this.name=U,this.from=W,this.to=J}render($){let U=$.es5?i4.varKinds.var:this.varKind,{name:W,from:J,to:X}=this;return`for(${U} ${W}=${J}; ${W}<${X}; ${W}++)`+super.render($)}get names(){let $=pJ(super.names,this.from);return pJ($,this.to)}}class l8 extends b0{constructor($,U,W,J){super();this.loop=$,this.varKind=U,this.name=W,this.iterable=J}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,U){if(!super.optimizeNames($,U))return;return this.iterable=B0(this.iterable,$,U),this}get names(){return M1(super.names,this.iterable.names)}}class iJ extends o6{constructor($,U,W){super();this.name=$,this.args=U,this.async=W}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}iJ.kind="func";class nJ extends dJ{render($){return"return "+super.render($)}}nJ.kind="return";class RI extends o6{render($){let U="try"+super.render($);if(this.catch)U+=this.catch.render($);if(this.finally)U+=this.finally.render($);return U}optimizeNodes(){var $,U;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(U=this.finally)===null||U===void 0||U.optimizeNodes(),this}optimizeNames($,U){var W,J;return super.optimizeNames($,U),(W=this.catch)===null||W===void 0||W.optimizeNames($,U),(J=this.finally)===null||J===void 0||J.optimizeNames($,U),this}get names(){let $=super.names;if(this.catch)M1($,this.catch.names);if(this.finally)M1($,this.finally.names);return $}}class rJ extends o6{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}rJ.kind="catch";class cJ extends o6{render($){return"finally"+super.render($)}}cJ.kind="finally";class kI{constructor($,U={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...U,_n:U.lines?`
|
|
3
3
|
`:""},this._extScope=$,this._scope=new i4.Scope({parent:$}),this._nodes=[new EI]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,U){let W=this._extScope.value($,U);return(this._values[W.prefix]||(this._values[W.prefix]=new Set)).add(W),W}getScopeValue($,U){return this._extScope.getValue($,U)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,U,W,J){let X=this._scope.toName(U);if(W!==void 0&&J)this._constants[X.str]=W;return this._leafNode(new OI($,X,W)),X}const($,U,W){return this._def(i4.varKinds.const,$,U,W)}let($,U,W){return this._def(i4.varKinds.let,$,U,W)}var($,U,W){return this._def(i4.varKinds.var,$,U,W)}assign($,U,W){return this._leafNode(new i8($,U,W))}add($,U){return this._leafNode(new qI($,H4.operators.ADD,U))}code($){if(typeof $=="function")$();else if($!==z$.nil)this._leafNode(new MI($));return this}object(...$){let U=["{"];for(let[W,J]of $){if(U.length>1)U.push(",");if(U.push(W),W!==J||this.opts.es5)U.push(":"),(0,z$.addCodeArg)(U,J)}return U.push("}"),new z$._Code(U)}if($,U,W){if(this._blockNode(new F6($)),U&&W)this.code(U).else().code(W).endIf();else if(U)this.code(U).endIf();else if(W)throw Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new F6($))}else(){return this._elseNode(new zW)}endIf(){return this._endBlockNode(F6,zW)}_for($,U){if(this._blockNode($),U)this.code(U).endFor();return this}for($,U){return this._for(new SI($),U)}forRange($,U,W,J,X=this.opts.es5?i4.varKinds.var:i4.varKinds.let){let v=this._scope.toName($);return this._for(new PI(X,v,U,W),()=>J(v))}forOf($,U,W,J=i4.varKinds.const){let X=this._scope.toName($);if(this.opts.es5){let v=U instanceof z$.Name?U:this.var("_arr",U);return this.forRange("_i",0,z$._`${v}.length`,(z)=>{this.var(X,z$._`${v}[${z}]`),W(X)})}return this._for(new l8("of",J,X,U),()=>W(X))}forIn($,U,W,J=this.opts.es5?i4.varKinds.var:i4.varKinds.const){if(this.opts.ownProperties)return this.forOf($,z$._`Object.keys(${U})`,W);let X=this._scope.toName($);return this._for(new l8("in",J,X,U),()=>W(X))}endFor(){return this._endBlockNode(b0)}label($){return this._leafNode(new VI($))}break($){return this._leafNode(new FI($))}return($){let U=new nJ;if(this._blockNode(U),this.code($),U.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(nJ)}try($,U,W){if(!U&&!W)throw Error('CodeGen: "try" without "catch" and "finally"');let J=new RI;if(this._blockNode(J),this.code($),U){let X=this.name("e");this._currNode=J.catch=new rJ(X),U(X)}if(W)this._currNode=J.finally=new cJ,this.code(W);return this._endBlockNode(rJ,cJ)}throw($){return this._leafNode(new jI($))}block($,U){if(this._blockStarts.push(this._nodes.length),$)this.code($).endBlock(U);return this}endBlock($){let U=this._blockStarts.pop();if(U===void 0)throw Error("CodeGen: not in self-balancing block");let W=this._nodes.length-U;if(W<0||$!==void 0&&W!==$)throw Error(`CodeGen: wrong number of nodes: ${W} vs ${$} expected`);return this._nodes.length=U,this}func($,U=z$.nil,W,J){if(this._blockNode(new iJ($,U,W)),J)this.code(J).endFunc();return this}endFunc(){return this._endBlockNode(iJ)}optimize($=1){while($-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode($){return this._currNode.nodes.push($),this}_blockNode($){this._currNode.nodes.push($),this._nodes.push($)}_endBlockNode($,U){let W=this._currNode;if(W instanceof $||U&&W instanceof U)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${U?`${$.kind}/${U.kind}`:$.kind}"`)}_elseNode($){let U=this._currNode;if(!(U instanceof F6))throw Error('CodeGen: "else" without "if"');return this._currNode=U.else=$,this}get _root(){return this._nodes[0]}get _currNode(){let $=this._nodes;return $[$.length-1]}set _currNode($){let U=this._nodes;U[U.length-1]=$}}H4.CodeGen=kI;function M1($,U){for(let W in U)$[W]=($[W]||0)+(U[W]||0);return $}function pJ($,U){return U instanceof z$._CodeOrName?M1($,U.names):$}function B0($,U,W){if($ instanceof z$.Name)return J($);if(!X($))return $;return new z$._Code($._items.reduce((v,z)=>{if(z instanceof z$.Name)z=J(z);if(z instanceof z$._Code)v.push(...z._items);else v.push(z);return v},[]));function J(v){let z=W[v.str];if(z===void 0||U[v.str]!==1)return v;return delete U[v.str],z}function X(v){return v instanceof z$._Code&&v._items.some((z)=>z instanceof z$.Name&&U[z.str]===1&&W[z.str]!==void 0)}}function JC($,U){for(let W in U)$[W]=($[W]||0)-(U[W]||0)}function ZI($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:z$._`!${m8($)}`}H4.not=ZI;var vC=TI(H4.operators.AND);function zC(...$){return $.reduce(vC)}H4.and=zC;var QC=TI(H4.operators.OR);function GC(...$){return $.reduce(QC)}H4.or=GC;function TI($){return(U,W)=>U===z$.nil?W:W===z$.nil?U:z$._`${m8(U)} ${$} ${m8(W)}`}function m8($){return $ instanceof z$.Name?$:z$._`(${$})`}});var Y$=q((lI)=>{Object.defineProperty(lI,"__esModule",{value:!0});lI.checkStrictMode=lI.getErrorPath=lI.Type=lI.useFunc=lI.setEvaluated=lI.evaluatedPropsToName=lI.mergeEvaluated=lI.eachItem=lI.unescapeJsonPointer=lI.escapeJsonPointer=lI.escapeFragment=lI.unescapeFragment=lI.schemaRefOrVal=lI.schemaHasRulesButRef=lI.schemaHasRules=lI.checkUnknownRules=lI.alwaysValidSchema=lI.toHash=void 0;var O$=s(),bC=vW();function BC($){let U={};for(let W of $)U[W]=!0;return U}lI.toHash=BC;function wC($,U){if(typeof U=="boolean")return U;if(Object.keys(U).length===0)return!0;return uI($,U),!xI(U,$.self.RULES.all)}lI.alwaysValidSchema=wC;function uI($,U=$.schema){let{opts:W,self:J}=$;if(!W.strictSchema)return;if(typeof U==="boolean")return;let X=J.RULES.keywords;for(let v in U)if(!X[v])hI($,`unknown keyword: "${v}"`)}lI.checkUnknownRules=uI;function xI($,U){if(typeof $=="boolean")return!$;for(let W in $)if(U[W])return!0;return!1}lI.schemaHasRules=xI;function AC($,U){if(typeof $=="boolean")return!$;for(let W in $)if(W!=="$ref"&&U.all[W])return!0;return!1}lI.schemaHasRulesButRef=AC;function LC({topSchemaRef:$,schemaPath:U},W,J,X){if(!X){if(typeof W=="number"||typeof W=="boolean")return W;if(typeof W=="string")return O$._`${W}`}return O$._`${$}${U}${(0,O$.getProperty)(J)}`}lI.schemaRefOrVal=LC;function IC($){return yI(decodeURIComponent($))}lI.unescapeFragment=IC;function KC($){return encodeURIComponent(r8($))}lI.escapeFragment=KC;function r8($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}lI.escapeJsonPointer=r8;function yI($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}lI.unescapeJsonPointer=yI;function NC($,U){if(Array.isArray($))for(let W of $)U(W);else U($)}lI.eachItem=NC;function _I({mergeNames:$,mergeToName:U,mergeValues:W,resultToName:J}){return(X,v,z,Q)=>{let G=z===void 0?v:z instanceof O$.Name?(v instanceof O$.Name?$(X,v,z):U(X,v,z),z):v instanceof O$.Name?(U(X,z,v),v):W(v,z);return Q===O$.Name&&!(G instanceof O$.Name)?J(X,G):G}}lI.mergeEvaluated={props:_I({mergeNames:($,U,W)=>$.if(O$._`${W} !== true && ${U} !== undefined`,()=>{$.if(O$._`${U} === true`,()=>$.assign(W,!0),()=>$.assign(W,O$._`${W} || {}`).code(O$._`Object.assign(${W}, ${U})`))}),mergeToName:($,U,W)=>$.if(O$._`${W} !== true`,()=>{if(U===!0)$.assign(W,!0);else $.assign(W,O$._`${W} || {}`),c8($,W,U)}),mergeValues:($,U)=>$===!0?!0:{...$,...U},resultToName:fI}),items:_I({mergeNames:($,U,W)=>$.if(O$._`${W} !== true && ${U} !== undefined`,()=>$.assign(W,O$._`${U} === true ? true : ${W} > ${U} ? ${W} : ${U}`)),mergeToName:($,U,W)=>$.if(O$._`${W} !== true`,()=>$.assign(W,U===!0?!0:O$._`${W} > ${U} ? ${W} : ${U}`)),mergeValues:($,U)=>$===!0?!0:Math.max($,U),resultToName:($,U)=>$.var("items",U)})};function fI($,U){if(U===!0)return $.var("props",!0);let W=$.var("props",O$._`{}`);if(U!==void 0)c8($,W,U);return W}lI.evaluatedPropsToName=fI;function c8($,U,W){Object.keys(W).forEach((J)=>$.assign(O$._`${U}${(0,O$.getProperty)(J)}`,!0))}lI.setEvaluated=c8;var gI={};function OC($,U){return $.scopeValue("func",{ref:U,code:gI[U.code]||(gI[U.code]=new bC._Code(U.code))})}lI.useFunc=OC;var n8;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(n8||(lI.Type=n8={}));function qC($,U,W){if($ instanceof O$.Name){let J=U===n8.Num;return W?J?O$._`"[" + ${$} + "]"`:O$._`"['" + ${$} + "']"`:J?O$._`"/" + ${$}`:O$._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return W?(0,O$.getProperty)($).toString():"/"+r8($)}lI.getErrorPath=qC;function hI($,U,W=$.opts.strictSchema){if(!W)return;if(U=`strict mode: ${U}`,W===!0)throw Error(U);$.self.logger.warn(U)}lI.checkStrictMode=hI});var j6=q((iI)=>{Object.defineProperty(iI,"__esModule",{value:!0});var o$=s(),fC={data:new o$.Name("data"),valCxt:new o$.Name("valCxt"),instancePath:new o$.Name("instancePath"),parentData:new o$.Name("parentData"),parentDataProperty:new o$.Name("parentDataProperty"),rootData:new o$.Name("rootData"),dynamicAnchors:new o$.Name("dynamicAnchors"),vErrors:new o$.Name("vErrors"),errors:new o$.Name("errors"),this:new o$.Name("this"),self:new o$.Name("self"),scope:new o$.Name("scope"),json:new o$.Name("json"),jsonPos:new o$.Name("jsonPos"),jsonLen:new o$.Name("jsonLen"),jsonPart:new o$.Name("jsonPart")};iI.default=fC});var QW=q((pI)=>{Object.defineProperty(pI,"__esModule",{value:!0});pI.extendErrors=pI.resetErrorsCount=pI.reportExtraError=pI.reportError=pI.keyword$DataError=pI.keywordError=void 0;var D$=s(),aJ=Y$(),U4=j6();pI.keywordError={message:({keyword:$})=>D$.str`must pass "${$}" keyword validation`};pI.keyword$DataError={message:({keyword:$,schemaType:U})=>U?D$.str`"${$}" keyword must be ${U} ($data)`:D$.str`"${$}" keyword is invalid ($data)`};function lC($,U=pI.keywordError,W,J){let{it:X}=$,{gen:v,compositeRule:z,allErrors:Q}=X,G=cI($,U,W);if(J!==null&&J!==void 0?J:z||Q)nI(v,G);else rI(X,D$._`[${G}]`)}pI.reportError=lC;function mC($,U=pI.keywordError,W){let{it:J}=$,{gen:X,compositeRule:v,allErrors:z}=J,Q=cI($,U,W);if(nI(X,Q),!(v||z))rI(J,U4.default.vErrors)}pI.reportExtraError=mC;function iC($,U){$.assign(U4.default.errors,U),$.if(D$._`${U4.default.vErrors} !== null`,()=>$.if(U,()=>$.assign(D$._`${U4.default.vErrors}.length`,U),()=>$.assign(U4.default.vErrors,null)))}pI.resetErrorsCount=iC;function nC({gen:$,keyword:U,schemaValue:W,data:J,errsCount:X,it:v}){if(X===void 0)throw Error("ajv implementation error");let z=$.name("err");$.forRange("i",X,U4.default.errors,(Q)=>{if($.const(z,D$._`${U4.default.vErrors}[${Q}]`),$.if(D$._`${z}.instancePath === undefined`,()=>$.assign(D$._`${z}.instancePath`,(0,D$.strConcat)(U4.default.instancePath,v.errorPath))),$.assign(D$._`${z}.schemaPath`,D$.str`${v.errSchemaPath}/${U}`),v.opts.verbose)$.assign(D$._`${z}.schema`,W),$.assign(D$._`${z}.data`,J)})}pI.extendErrors=nC;function nI($,U){let W=$.const("err",U);$.if(D$._`${U4.default.vErrors} === null`,()=>$.assign(U4.default.vErrors,D$._`[${W}]`),D$._`${U4.default.vErrors}.push(${W})`),$.code(D$._`${U4.default.errors}++`)}function rI($,U){let{gen:W,validateName:J,schemaEnv:X}=$;if(X.$async)W.throw(D$._`new ${$.ValidationError}(${U})`);else W.assign(D$._`${J}.errors`,U),W.return(!1)}var E1={keyword:new D$.Name("keyword"),schemaPath:new D$.Name("schemaPath"),params:new D$.Name("params"),propertyName:new D$.Name("propertyName"),message:new D$.Name("message"),schema:new D$.Name("schema"),parentSchema:new D$.Name("parentSchema")};function cI($,U,W){let{createErrors:J}=$.it;if(J===!1)return D$._`{}`;return rC($,U,W)}function rC($,U,W={}){let{gen:J,it:X}=$,v=[cC(X,W),pC($,W)];return oC($,U,v),J.object(...v)}function cC({errorPath:$},{instancePath:U}){let W=U?D$.str`${$}${(0,aJ.getErrorPath)(U,aJ.Type.Str)}`:$;return[U4.default.instancePath,(0,D$.strConcat)(U4.default.instancePath,W)]}function pC({keyword:$,it:{errSchemaPath:U}},{schemaPath:W,parentSchema:J}){let X=J?U:D$.str`${U}/${$}`;if(W)X=D$.str`${X}${(0,aJ.getErrorPath)(W,aJ.Type.Str)}`;return[E1.schemaPath,X]}function oC($,{params:U,message:W},J){let{keyword:X,data:v,schemaValue:z,it:Q}=$,{opts:G,propertyName:Y,topSchemaRef:D,schemaPath:H}=Q;if(J.push([E1.keyword,X],[E1.params,typeof U=="function"?U($):U||D$._`{}`]),G.messages)J.push([E1.message,typeof W=="function"?W($):W]);if(G.verbose)J.push([E1.schema,z],[E1.parentSchema,D$._`${D}${H}`],[U4.default.data,v]);if(Y)J.push([E1.propertyName,Y])}});var eI=q((tI)=>{Object.defineProperty(tI,"__esModule",{value:!0});tI.boolOrEmptySchema=tI.topBoolOrEmptySchema=void 0;var sC=QW(),$2=s(),U2=j6(),W2={message:"boolean schema is false"};function X2($){let{gen:U,schema:W,validateName:J}=$;if(W===!1)dI($,!1);else if(typeof W=="object"&&W.$async===!0)U.return(U2.default.data);else U.assign($2._`${J}.errors`,null),U.return(!0)}tI.topBoolOrEmptySchema=X2;function J2($,U){let{gen:W,schema:J}=$;if(J===!1)W.var(U,!1),dI($);else W.var(U,!0)}tI.boolOrEmptySchema=J2;function dI($,U){let{gen:W,data:J}=$,X={gen:W,keyword:"false schema",data:J,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,sC.reportError)(X,W2,void 0,U)}});var o8=q((sI)=>{Object.defineProperty(sI,"__esModule",{value:!0});sI.getRules=sI.isJSONType=void 0;var z2=["string","number","integer","boolean","null","object","array"],Q2=new Set(z2);function G2($){return typeof $=="string"&&Q2.has($)}sI.isJSONType=G2;function Y2(){let $={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...$,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},$.number,$.string,$.array,$.object],post:{rules:[]},all:{},keywords:{}}}sI.getRules=Y2});var d8=q((XK)=>{Object.defineProperty(XK,"__esModule",{value:!0});XK.shouldUseRule=XK.shouldUseGroup=XK.schemaHasRulesForType=void 0;function H2({schema:$,self:U},W){let J=U.RULES.types[W];return J&&J!==!0&&UK($,J)}XK.schemaHasRulesForType=H2;function UK($,U){return U.rules.some((W)=>WK($,W))}XK.shouldUseGroup=UK;function WK($,U){var W;return $[U.keyword]!==void 0||((W=U.definition.implements)===null||W===void 0?void 0:W.some((J)=>$[J]!==void 0))}XK.shouldUseRule=WK});var GW=q((GK)=>{Object.defineProperty(GK,"__esModule",{value:!0});GK.reportTypeError=GK.checkDataTypes=GK.checkDataType=GK.coerceAndCheckDataType=GK.getJSONTypes=GK.getSchemaTypes=GK.DataType=void 0;var w2=o8(),A2=d8(),L2=QW(),a=s(),vK=Y$(),w0;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(w0||(GK.DataType=w0={}));function I2($){let U=zK($.type);if(U.includes("null")){if($.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!U.length&&$.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if($.nullable===!0)U.push("null")}return U}GK.getSchemaTypes=I2;function zK($){let U=Array.isArray($)?$:$?[$]:[];if(U.every(w2.isJSONType))return U;throw Error("type must be JSONType or JSONType[]: "+U.join(","))}GK.getJSONTypes=zK;function K2($,U){let{gen:W,data:J,opts:X}=$,v=N2(U,X.coerceTypes),z=U.length>0&&!(v.length===0&&U.length===1&&(0,A2.schemaHasRulesForType)($,U[0]));if(z){let Q=a8(U,J,X.strictNumbers,w0.Wrong);W.if(Q,()=>{if(v.length)O2($,U,v);else e8($)})}return z}GK.coerceAndCheckDataType=K2;var QK=new Set(["string","number","integer","boolean","null"]);function N2($,U){return U?$.filter((W)=>QK.has(W)||U==="array"&&W==="array"):[]}function O2($,U,W){let{gen:J,data:X,opts:v}=$,z=J.let("dataType",a._`typeof ${X}`),Q=J.let("coerced",a._`undefined`);if(v.coerceTypes==="array")J.if(a._`${z} == 'object' && Array.isArray(${X}) && ${X}.length == 1`,()=>J.assign(X,a._`${X}[0]`).assign(z,a._`typeof ${X}`).if(a8(U,X,v.strictNumbers),()=>J.assign(Q,X)));J.if(a._`${Q} !== undefined`);for(let Y of W)if(QK.has(Y)||Y==="array"&&v.coerceTypes==="array")G(Y);J.else(),e8($),J.endIf(),J.if(a._`${Q} !== undefined`,()=>{J.assign(X,Q),q2($,Q)});function G(Y){switch(Y){case"string":J.elseIf(a._`${z} == "number" || ${z} == "boolean"`).assign(Q,a._`"" + ${X}`).elseIf(a._`${X} === null`).assign(Q,a._`""`);return;case"number":J.elseIf(a._`${z} == "boolean" || ${X} === null
|
|
4
4
|
|| (${z} == "string" && ${X} && ${X} == +${X})`).assign(Q,a._`+${X}`);return;case"integer":J.elseIf(a._`${z} === "boolean" || ${X} === null
|
package/dist/container-host.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
/*! @mcpcloud/runtime v0.
|
|
2
|
-
|
|
1
|
+
/*! @mcpcloud/runtime v0.12.0 — (c) MCPCloud.sh. All rights reserved. SEE LICENSE: https://www.npmjs.com/package/@mcpcloud/runtime */
|
|
2
|
+
var w9=Object.create;var{getPrototypeOf:_9,defineProperty:$8,getOwnPropertyNames:N9}=Object;var P9=Object.prototype.hasOwnProperty;function E9(Z){return this[Z]}var S9,I9,x9=(Z,$,K)=>{var Y=Z!=null&&typeof Z==="object";if(Y){var J=$?S9??=new WeakMap:I9??=new WeakMap,q=J.get(Z);if(q)return q}K=Z!=null?w9(_9(Z)):{};let C=$||!Z||!Z.__esModule?$8(K,"default",{value:Z,enumerable:!0}):K;for(let z of N9(Z))if(!P9.call(C,z))$8(C,z,{get:E9.bind(Z,z),enumerable:!0});if(Y)J.set(Z,C);return C};var b9=(Z,$)=>()=>($||Z(($={exports:{}}).exports,$),$.exports);var A9=(Z)=>Z;function T9(Z,$){this[Z]=A9.bind(null,$)}var y9=(Z,$)=>{for(var K in $)$8(Z,K,{get:$[K],enumerable:!0,configurable:!0,set:T9.bind($,K)})};var K8=(Z,$)=>()=>(Z&&($=Z(Z=0)),$);var h,X8,l,k,c;var i=K8(()=>{h={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},X8={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},l={Pending:0,Fulfilled:1,Rejected:2},k={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},c={IsStrictlyEqual:0,IsSameValue:1,IsSameValueZero:2}});function m(...Z){J8&&console.log("quickjs-emscripten:",...Z)}function*W9(Z){return yield Z}function m9(Z){return W9(U8(Z))}function u8(Z,$){return(...K)=>{let Y=$.call(Z,B8,...K);return U8(Y)}}function p9(Z,$){let K=$.call(Z,B8);return U8(K)}function U8(Z){function $(K){return K.done?K.value:K.value instanceof Promise?K.value.then((Y)=>$(Z.next(Y)),(Y)=>$(Z.throw(Y))):$(Z.next(K.value))}return $(Z.next())}function W8(Z,$){let K;try{Z.dispose()}catch(Y){K=Y}if($&&K)throw Object.assign($,{message:`${$.message}
|
|
3
|
+
Then, failed to dispose scope: ${K.message}`,disposeError:K}),$;if($||K)throw $||K}function d9(Z){let $=Z?Array.from(Z):[];function K(){return $.forEach((J)=>J.alive?J.dispose():void 0)}function Y(){return $.some((J)=>J.alive)}return Object.defineProperty($,G8,{configurable:!0,enumerable:!1,value:K}),Object.defineProperty($,"dispose",{configurable:!0,enumerable:!1,value:K}),Object.defineProperty($,"alive",{configurable:!0,enumerable:!1,get:Y}),$}function a(Z){return!!(Z&&(typeof Z=="object"||typeof Z=="function")&&("alive"in Z)&&typeof Z.alive=="boolean"&&("dispose"in Z)&&typeof Z.dispose=="function")}function o9(Z){if(!Z)return 0;let $=0;for(let[K,Y]of Object.entries(Z)){if(!(K in X8))throw new Z9(K);Y&&($|=X8[K])}return $}function a9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{type:$,strict:K,strip:Y,compileOnly:J,backtraceBarrier:q}=Z,C=0;return $==="global"&&(C|=h.JS_EVAL_TYPE_GLOBAL),$==="module"&&(C|=h.JS_EVAL_TYPE_MODULE),K&&(C|=h.JS_EVAL_FLAG_STRICT),Y&&(C|=h.JS_EVAL_FLAG_STRIP),J&&(C|=h.JS_EVAL_FLAG_COMPILE_ONLY),q&&(C|=h.JS_EVAL_FLAG_BACKTRACE_BARRIER),C}function s9(Z){if(typeof Z=="number")return Z;if(Z===void 0)return 0;let{strings:$,symbols:K,quickjsPrivate:Y,onlyEnumerable:J,numbers:q,numbersAsStrings:C}=Z,z=0;return $&&(z|=k.JS_GPN_STRING_MASK),K&&(z|=k.JS_GPN_SYMBOL_MASK),Y&&(z|=k.JS_GPN_PRIVATE_MASK),J&&(z|=k.JS_GPN_ENUM_ONLY),q&&(z|=k.QTS_GPN_NUMBER_MASK),C&&(z|=k.QTS_STANDARD_COMPLIANT_NUMBER),z}function n9(...Z){let $=[];for(let K of Z)K!==void 0&&($=$.concat(K));return $}function z8(Z){return Z>>8}function j8(Z,$){$.interruptHandler&&Z.setInterruptHandler($.interruptHandler),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes)}function H8(Z,$){$.moduleLoader&&Z.setModuleLoader($.moduleLoader),$.shouldInterrupt&&Z.setInterruptHandler($.shouldInterrupt),$.memoryLimitBytes!==void 0&&Z.setMemoryLimit($.memoryLimitBytes),$.maxStackSizeBytes!==void 0&&Z.setMaxStackSize($.maxStackSizeBytes)}var h9,k9=(Z,$)=>{for(var K in $)h9(Z,K,{get:$[K],enumerable:!0})},J8=!1,v9,Y8,n8,Q8,t8,r8,e8,g9,c9,Z9,$9,K9,X9,y,B8,b,G8,l8,_,v,i8,I,q8,u9,l9,g,i9,z9=class{constructor(Z){this.module=Z}toPointerArray(Z){let $=new Int32Array(Z.map((J)=>J.value)),K=$.length*$.BYTES_PER_ELEMENT,Y=this.module._malloc(K);return new Uint8Array(this.module.HEAPU8.buffer,Y,K).set(new Uint8Array($.buffer)),new _(Y,void 0,(J)=>this.module._free(J))}newTypedArray(Z,$){let K=new Z(Array($).fill(0)),Y=K.length*K.BYTES_PER_ELEMENT,J=this.module._malloc(Y),q=new Z(this.module.HEAPU8.buffer,J,$);return q.set(K),new _({typedArray:q,ptr:J},void 0,(C)=>this.module._free(C.ptr))}newMutablePointerArray(Z){return this.newTypedArray(Int32Array,Z)}newHeapCharPointer(Z){let $=this.module.lengthBytesUTF8(Z),K=$+1,Y=this.module._malloc(K);return this.module.stringToUTF8(Z,Y,K),new _({ptr:Y,strlen:$},void 0,(J)=>this.module._free(J.ptr))}newHeapBufferPointer(Z){let $=Z.byteLength,K=this.module._malloc($);return this.module.HEAPU8.set(Z,K),new _({pointer:K,numBytes:$},void 0,(Y)=>this.module._free(Y.pointer))}consumeHeapCharPointer(Z){let $=this.module.UTF8ToString(Z);return this.module._free(Z),$}},yZ,fZ,t9,o8=-2147483648,a8=2147483647,o=0,r9=class{constructor(){this.nextId=o8,this.freelist=[],this.groups=new Map}put(Z){let $=this.allocateId(),K=z8($),Y=this.groups.get(K);return Y||(Y=new Map,this.groups.set(K,Y)),Y.set($,Z),$}get(Z){if(Z===o)throw new y("no host reference id defined");let $=z8(Z),K=this.groups.get($);if(!K)throw new y(`host reference id ${Z} is not defined`);let Y=K.get(Z);if(!Y)throw new y(`host reference id ${Z} is not defined`);return Y}delete(Z){if(Z===o)throw new y("no host reference id defined");let $=z8(Z),K=this.groups.get($);if(!K)throw new y(`host reference id ${Z} is not defined`);K.delete(Z),K.size===0&&this.groups.delete($),this.freelist.push(Z)}allocateId(){if(this.freelist.length>0)return this.freelist.shift();if(this.nextId===o&&this.nextId++,this.nextId>a8)throw new X9(`HostRefMap: too many host refs created without disposing. Max simultaneous host refs: ${a8-o8}`);return this.nextId++}},s8,e9,ZZ,$Z,KZ=class{constructor(Z){this.freeHostRef=Z.freeHostRef,this.callFunction=Z.callFunction,this.shouldInterrupt=Z.shouldInterrupt,this.loadModuleSource=Z.loadModuleSource,this.normalizeModule=Z.normalizeModule}},C8=class{constructor(Z){this.contextCallbacks=new Map,this.runtimeCallbacks=new Map,this.suspendedCount=0,this.cToHostCallbacks=new KZ({freeHostRef:($,K,Y)=>{let J=this.runtimeCallbacks.get(K);if(!J)throw Error(`QuickJSRuntime(rt = ${K}) not found when trying to free HostRef(id = ${Y})`);J.freeHostRef(K,Y)},callFunction:($,K,Y,J,q,C)=>this.handleAsyncify($,()=>{try{let z=this.contextCallbacks.get(K);if(!z)throw Error(`QuickJSContext(ctx = ${K}) not found for C function call "${C}"`);return z.callFunction(K,Y,J,q,C)}catch(z){return console.error("[C to host error: returning null]",z),0}}),shouldInterrupt:($,K)=>this.handleAsyncify($,()=>{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:($,K,Y,J)=>this.handleAsyncify($,()=>{try{let q=this.runtimeCallbacks.get(K);if(!q)throw Error(`QuickJSRuntime(rt = ${K}) not found for C module loader`);let C=q.loadModuleSource;if(!C)throw Error(`QuickJSRuntime(rt = ${K}) does not support module loading`);return C(K,Y,J)}catch(q){return console.error("[C to host module loader error: returning null]",q),0}}),normalizeModule:($,K,Y,J,q)=>this.handleAsyncify($,()=>{try{let C=this.runtimeCallbacks.get(K);if(!C)throw Error(`QuickJSRuntime(rt = ${K}) not found for C module loader`);let z=C.normalizeModule;if(!z)throw Error(`QuickJSRuntime(rt = ${K}) does not support module loading`);return z(K,Y,J,q)}catch(C){return console.error("[C to host module loader error: returning null]",C),0}})}),this.module=Z,this.module.callbacks=this.cToHostCallbacks}setRuntimeCallbacks(Z,$){this.runtimeCallbacks.set(Z,$)}deleteRuntime(Z){this.runtimeCallbacks.delete(Z)}setContextCallbacks(Z,$){this.contextCallbacks.set(Z,$)}deleteContext(Z){this.contextCallbacks.delete(Z)}handleAsyncify(Z,$){if(Z)return Z.handleSleep((Y)=>{try{let J=$();if(!(J instanceof Promise)){m("asyncify.handleSleep: not suspending:",J),Y(J);return}if(this.suspended)throw new r8(`Already suspended at: ${this.suspended.stack}
|
|
4
|
+
Attempted to suspend at:`);this.suspended=new e8(`(${this.suspendedCount++})`),m("asyncify.handleSleep: suspending:",this.suspended),J.then((q)=>{this.suspended=void 0,m("asyncify.handleSleep: resolved:",q),Y(q)},(q)=>{m("asyncify.handleSleep: rejected:",q),console.error("QuickJS: cannot handle error in suspended function",q),this.suspended=void 0})}catch(J){throw m("asyncify.handleSleep: error:",J),this.suspended=void 0,J}});let K=$();if(K instanceof Promise)throw Error("Promise return value not supported in non-asyncify context.");return K}},Y9=class{constructor(Z,$){this.module=Z,this.ffi=$,this.callbacks=new C8(Z)}newRuntime(Z={}){let $=new _(this.ffi.QTS_NewRuntime(),void 0,(Y)=>{this.ffi.QTS_FreeRuntime(Y),this.callbacks.deleteRuntime(Y)}),K=new $Z({module:this.module,callbacks:this.callbacks,ffi:this.ffi,rt:$});return j8(K,Z),Z.moduleLoader&&K.setModuleLoader(Z.moduleLoader),K}newContext(Z={}){let $=this.newRuntime(),K=$.newContext({...Z,ownedLifetimes:n9($,Z.ownedLifetimes)});return $.context=K,K}evalCode(Z,$={}){return I.withScope((K)=>{let Y=K.manage(this.newContext());H8(Y.runtime,$);let J=Y.evalCode(Z,"eval.js");if($.memoryLimitBytes!==void 0&&Y.runtime.setMemoryLimit(-1),J.error)throw Y.dump(K.manage(J.error));return Y.dump(K.manage(J.value))})}getWasmMemory(){let Z=this.module.quickjsEmscriptenInit?.(()=>{})?.getWasmMemory?.();if(!Z)throw Error("Variant does not support getting WebAssembly.Memory");return Z}getFFI(){return this.ffi}};var Q9=K8(()=>{i();i();h9=Object.defineProperty;v9={};k9(v9,{QuickJSAsyncifyError:()=>r8,QuickJSAsyncifySuspended:()=>e8,QuickJSEmptyGetOwnPropertyNames:()=>K9,QuickJSEmscriptenModuleError:()=>c9,QuickJSHostRefInvalid:()=>y,QuickJSHostRefRangeExceeded:()=>X9,QuickJSMemoryLeakDetected:()=>g9,QuickJSNotImplemented:()=>t8,QuickJSPromisePending:()=>$9,QuickJSUnknownIntrinsic:()=>Z9,QuickJSUnwrapError:()=>Y8,QuickJSUseAfterFree:()=>Q8,QuickJSWrongOwner:()=>n8});Y8=class extends Error{constructor(Z,$){let K=typeof Z=="object"&&Z&&"message"in Z?String(Z.message):String(Z);super(K);this.cause=Z,this.context=$,this.name="QuickJSUnwrapError"}},n8=class extends Error{constructor(){super(...arguments);this.name="QuickJSWrongOwner"}},Q8=class extends Error{constructor(){super(...arguments);this.name="QuickJSUseAfterFree"}},t8=class extends Error{constructor(){super(...arguments);this.name="QuickJSNotImplemented"}},r8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifyError"}},e8=class extends Error{constructor(){super(...arguments);this.name="QuickJSAsyncifySuspended"}},g9=class extends Error{constructor(){super(...arguments);this.name="QuickJSMemoryLeakDetected"}},c9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmscriptenModuleError"}},Z9=class extends TypeError{constructor(){super(...arguments);this.name="QuickJSUnknownIntrinsic"}},$9=class extends Error{constructor(){super(...arguments);this.name="QuickJSPromisePending"}},K9=class extends Error{constructor(){super(...arguments);this.name="QuickJSEmptyGetOwnPropertyNames"}},X9=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefRangeExceeded"}},y=class extends Error{constructor(){super(...arguments);this.name="QuickJSHostRefInvalid"}};B8=W9;B8.of=m9;b=class{[Symbol.dispose](){return this.dispose()}},G8=Symbol.dispose??Symbol.for("Symbol.dispose"),l8=b.prototype;l8[G8]||(l8[G8]=function(){return this.dispose()});_=class Z extends b{constructor($,K,Y,J){super();this._value=$,this.copier=K,this.disposer=Y,this._owner=J,this._alive=!0,this._constructorStack=J8?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 Z(this.copier(this._value),this.copier,this.disposer,this._owner)}consume($){this.assertAlive();let K=$(this);return this.dispose(),K}map($){return this.assertAlive(),$(this)}tap($){return $(this),this}dispose(){this.assertAlive(),this.disposer&&this.disposer(this._value),this._alive=!1}assertAlive(){if(!this.alive)throw this._constructorStack?new Q8(`Lifetime not alive
|
|
5
|
+
${this._constructorStack}
|
|
6
|
+
Lifetime used`):new Q8("Lifetime not alive")}},v=class extends _{constructor(Z,$){super(Z,void 0,void 0,$)}get dupable(){return!0}dup(){return this}dispose(){}},i8=class extends _{constructor(Z,$,K,Y){super(Z,$,K,Y)}dispose(){this._alive=!1}};I=class Z extends b{constructor(){super(...arguments);this._disposables=new _(new Set),this.manage=($)=>(this._disposables.value.add($),$)}static withScope($){let K=new Z,Y;try{return $(K)}catch(J){throw Y=J,J}finally{W8(K,Y)}}static withScopeMaybeAsync($,K){return p9(void 0,function*(Y){let J=new Z,q;try{return yield*Y.of(K.call($,Y,J))}catch(C){throw q=C,C}finally{W8(J,q)}})}static async withScopeAsync($){let K=new Z,Y;try{return await $(K)}catch(J){throw Y=J,J}finally{W8(K,Y)}}get alive(){return this._disposables.alive}dispose(){let $=Array.from(this._disposables.value.values()).reverse();for(let K of $)K.alive&&K.dispose();this._disposables.dispose()}};q8=class Z extends b{static success($){return new u9($)}static fail($,K){return new l9($,K)}static is($){return $ instanceof Z}},u9=class extends q8{constructor(Z){super();this.value=Z}get alive(){return a(this.value)?this.value.alive:!0}dispose(){a(this.value)&&this.value.dispose()}unwrap(){return this.value}unwrapOr(Z){return this.value}},l9=class extends q8{constructor(Z,$){super();this.error=Z,this.onUnwrap=$}get alive(){return a(this.error)?this.error.alive:!0}dispose(){a(this.error)&&this.error.dispose()}unwrap(){throw this.onUnwrap(this),this.error}unwrapOr(Z){return Z}},g=q8,i9=class extends b{constructor(Z){super();this.resolve=($)=>{this.resolveHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.resolveHandle,this.context.undefined,$||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.reject=($)=>{this.rejectHandle.alive&&(this.context.unwrapResult(this.context.callFunction(this.rejectHandle,this.context.undefined,$||this.context.undefined)).dispose(),this.disposeResolvers(),this.onSettled())},this.dispose=()=>{this.handle.alive&&this.handle.dispose(),this.disposeResolvers()},this.context=Z.context,this.owner=Z.context.runtime,this.handle=Z.promiseHandle,this.settled=new Promise(($)=>{this.onSettled=$}),this.resolveHandle=Z.resolveHandle,this.rejectHandle=Z.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()}},yZ=Symbol("Unstable"),fZ=Object.freeze({BaseObjects:!0,Date:!0,Eval:!0,StringNormalize:!0,RegExp:!0,JSON:!0,Proxy:!0,MapSet:!0,TypedArrays:!0,Promise:!0});t9=class extends b{constructor(Z,$){super();this.handle=Z,this.context=$,this._isDone=!1,this.owner=$.runtime}[Symbol.iterator](){return this}next(Z){if(!this.alive||this._isDone)return{done:!0,value:void 0};let $=this._next??(this._next=this.context.getProp(this.handle,"next"));return this.callIteratorMethod($,Z)}return(Z){if(!this.alive)return{done:!0,value:void 0};let $=this.context.getProp(this.handle,"return");if($===this.context.undefined&&Z===void 0)return this.dispose(),{done:!0,value:void 0};let K=this.callIteratorMethod($,Z);return $.dispose(),this.dispose(),K}throw(Z){if(!this.alive)return{done:!0,value:void 0};let $=Z instanceof _?Z:this.context.newError(Z),K=this.context.getProp(this.handle,"throw"),Y=this.callIteratorMethod(K,Z);return $.alive&&$.dispose(),K.dispose(),this.dispose(),Y}get alive(){return this.handle.alive}dispose(){this._isDone=!0,this.handle.dispose(),this._next?.dispose()}callIteratorMethod(Z,$){let K=$?this.context.callFunction(Z,this.handle,$):this.context.callFunction(Z,this.handle);if(K.error)return this.dispose(),{value:K};let Y=this.context.getProp(K.value,"done").consume((q)=>this.context.dump(q)),J=this.context.getProp(K.value,"value");return K.value.dispose(),Y&&this.dispose(),{value:g.success(J),done:Y}}};s8=class extends b{constructor(Z,$,K){if(K===o)throw new y("cannot create HostRef with undefined id");super();this.runtime=Z,this.handle=$,this.id=K}get alive(){return this.handle.alive}dispose(){this.handle.dispose()}get value(){return this.runtime.hostRefs.get(this.id)}},e9=class extends z9{constructor(Z){super(Z.module);this.scope=new I,this.copyJSValue=($)=>this.ffi.QTS_DupValuePointer(this.ctx.value,$),this.freeJSValue=($)=>{this.ffi.QTS_FreeValuePointer(this.ctx.value,$)},Z.ownedLifetimes?.forEach(($)=>this.scope.manage($)),this.owner=Z.owner,this.module=Z.module,this.ffi=Z.ffi,this.rt=Z.rt,this.ctx=this.scope.manage(Z.ctx)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}[Symbol.dispose](){return this.dispose()}manage(Z){return this.scope.manage(Z)}consumeJSCharPointer(Z){let $=this.module.UTF8ToString(Z);return this.ffi.QTS_FreeCString(this.ctx.value,Z),$}heapValueHandle(Z,$){let K=$?(Y)=>{$(),this.freeJSValue(Y)}:this.freeJSValue;return new _(Z,this.copyJSValue,K,this.owner)}staticHeapValueHandle(Z){return this.manage(this.heapValueHandle(Z)),new v(Z,this.owner)}},ZZ=class extends b{constructor(Z){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:($,K,Y,J,q)=>{if($!==this.ctx.value)throw Error("QuickJSContext instance received C -> JS call with mismatched ctx");let C=this.getFunction(q);return I.withScopeMaybeAsync(this,function*(z,D){let N=D.manage(new i8(K,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime)),x=Array(Y);for(let M=0;M<Y;M++){let A=this.ffi.QTS_ArgvGetJSValueConstPointer(J,M);x[M]=D.manage(new i8(A,this.memory.copyJSValue,this.memory.freeJSValue,this.runtime))}try{let M=yield*z(C.apply(N,x));if(M){if("error"in M&&M.error)throw this.runtime.debugLog("throw error",M.error),M.error;let A=D.manage(M instanceof _?M:M.value);return this.ffi.QTS_DupValuePointer(this.ctx.value,A.value)}return 0}catch(M){return this.errorToHandle(M).consume((A)=>this.ffi.QTS_Throw(this.ctx.value,A.value))}})}},this.runtime=Z.runtime,this.module=Z.module,this.ffi=Z.ffi,this.rt=Z.rt,this.ctx=Z.ctx,this.memory=new e9({...Z,owner:this.runtime}),Z.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 Z=this.ffi.QTS_GetUndefined();return this._undefined=new v(Z)}get null(){if(this._null)return this._null;let Z=this.ffi.QTS_GetNull();return this._null=new v(Z)}get true(){if(this._true)return this._true;let Z=this.ffi.QTS_GetTrue();return this._true=new v(Z)}get false(){if(this._false)return this._false;let Z=this.ffi.QTS_GetFalse();return this._false=new v(Z)}get global(){if(this._global)return this._global;let Z=this.ffi.QTS_GetGlobalObject(this.ctx.value);return this._global=this.memory.staticHeapValueHandle(Z),this._global}newNumber(Z){return this.memory.heapValueHandle(this.ffi.QTS_NewFloat64(this.ctx.value,Z))}newString(Z){let $=this.memory.newHeapCharPointer(Z).consume((K)=>this.ffi.QTS_NewString(this.ctx.value,K.value.ptr));return this.memory.heapValueHandle($)}newUniqueSymbol(Z){let $=(typeof Z=="symbol"?Z.description:Z)??"",K=this.memory.newHeapCharPointer($).consume((Y)=>this.ffi.QTS_NewSymbol(this.ctx.value,Y.value.ptr,0));return this.memory.heapValueHandle(K)}newSymbolFor(Z){let $=(typeof Z=="symbol"?Z.description:Z)??"",K=this.memory.newHeapCharPointer($).consume((Y)=>this.ffi.QTS_NewSymbol(this.ctx.value,Y.value.ptr,1));return this.memory.heapValueHandle(K)}getWellKnownSymbol(Z){return this._Symbol??(this._Symbol=this.memory.manage(this.getProp(this.global,"Symbol"))),this.getProp(this._Symbol,Z)}newBigInt(Z){if(!this._BigInt){let Y=this.getProp(this.global,"BigInt");this.memory.manage(Y),this._BigInt=new v(Y.value,this.runtime)}let $=this._BigInt,K=String(Z);return this.newString(K).consume((Y)=>this.unwrapResult(this.callFunction($,this.undefined,Y)))}newObject(Z){Z&&this.runtime.assertOwned(Z);let $=Z?this.ffi.QTS_NewObjectProto(this.ctx.value,Z.value):this.ffi.QTS_NewObject(this.ctx.value);return this.memory.heapValueHandle($)}newArray(){let Z=this.ffi.QTS_NewArray(this.ctx.value);return this.memory.heapValueHandle(Z)}newArrayBuffer(Z){let $=new Uint8Array(Z),K=this.memory.newHeapBufferPointer($),Y=this.ffi.QTS_NewArrayBuffer(this.ctx.value,K.value.pointer,$.length);return this.memory.heapValueHandle(Y)}newPromise(Z){let $=I.withScope((K)=>{let Y=K.manage(this.memory.newMutablePointerArray(2)),J=this.ffi.QTS_NewPromiseCapability(this.ctx.value,Y.value.ptr),q=this.memory.heapValueHandle(J),[C,z]=Array.from(Y.value.typedArray).map((D)=>this.memory.heapValueHandle(D));return new i9({context:this,promiseHandle:q,resolveHandle:C,rejectHandle:z})});return Z&&typeof Z=="function"&&(Z=new Promise(Z)),Z&&Promise.resolve(Z).then($.resolve,(K)=>K instanceof _?$.reject(K):this.newError(K).consume($.reject)),$}newFunction(Z,$){let K=typeof Z=="function"?Z:$;if(!K)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof Z=="string"?Z:void 0,length:K.length,isConstructor:!1,fn:K})}newConstructorFunction(Z,$){let K=typeof Z=="function"?Z:$;if(!K)throw TypeError("Expected a function");return this.newFunctionWithOptions({name:typeof Z=="string"?Z:void 0,length:K.length,isConstructor:!0,fn:K})}newFunctionWithOptions(Z){let{name:$,length:K,isConstructor:Y,fn:J}=Z,q=this.runtime.hostRefs.put(J);try{return this.memory.heapValueHandle(this.ffi.QTS_NewFunction(this.ctx.value,$??"",K,Y,q))}catch(C){throw this.runtime.hostRefs.delete(q),C}}newError(Z){let $=this.memory.heapValueHandle(this.ffi.QTS_NewError(this.ctx.value));return Z&&typeof Z=="object"?(Z.name!==void 0&&this.newString(Z.name).consume((K)=>this.setProp($,"name",K)),Z.message!==void 0&&this.newString(Z.message).consume((K)=>this.setProp($,"message",K))):typeof Z=="string"?this.newString(Z).consume((K)=>this.setProp($,"message",K)):Z!==void 0&&this.newString(String(Z)).consume((K)=>this.setProp($,"message",K)),$}newHostRef(Z){let $=this.runtime.hostRefs.put(Z);try{let K=this.memory.heapValueHandle(this.ffi.QTS_NewHostRef(this.ctx.value,$));return new s8(this.runtime,K,$)}catch(K){throw this.runtime.hostRefs.delete($),K}}toHostRef(Z){let $=this.ffi.QTS_GetHostRefId(Z.value);if($!==0)return this.runtime.hostRefs.get($),new s8(this.runtime,Z.dup(),$)}unwrapHostRef(Z){let $=this.ffi.QTS_GetHostRefId(Z.value);if($===0)throw new y("handle is not a HostRef");return this.runtime.hostRefs.get($)}typeof(Z){return this.runtime.assertOwned(Z),this.memory.consumeHeapCharPointer(this.ffi.QTS_Typeof(this.ctx.value,Z.value))}getNumber(Z){return this.runtime.assertOwned(Z),this.ffi.QTS_GetFloat64(this.ctx.value,Z.value)}getString(Z){return this.runtime.assertOwned(Z),this.memory.consumeJSCharPointer(this.ffi.QTS_GetString(this.ctx.value,Z.value))}getSymbol(Z){this.runtime.assertOwned(Z);let $=this.memory.consumeJSCharPointer(this.ffi.QTS_GetSymbolDescriptionOrKey(this.ctx.value,Z.value));return this.ffi.QTS_IsGlobalSymbol(this.ctx.value,Z.value)?Symbol.for($):Symbol($)}getBigInt(Z){this.runtime.assertOwned(Z);let $=this.getString(Z);return BigInt($)}getArrayBuffer(Z){this.runtime.assertOwned(Z);let $=this.ffi.QTS_GetArrayBufferLength(this.ctx.value,Z.value),K=this.ffi.QTS_GetArrayBuffer(this.ctx.value,Z.value);if(!K)throw Error("Couldn't allocate memory to get ArrayBuffer");return new _(this.module.HEAPU8.subarray(K,K+$),void 0,()=>this.module._free(K))}getPromiseState(Z){this.runtime.assertOwned(Z);let $=this.ffi.QTS_PromiseState(this.ctx.value,Z.value);if($<0)return{type:"fulfilled",value:Z,notAPromise:!0};if($===l.Pending)return{type:"pending",get error(){return new $9("Cannot unwrap a pending promise")}};let K=this.ffi.QTS_PromiseResult(this.ctx.value,Z.value),Y=this.memory.heapValueHandle(K);if($===l.Fulfilled)return{type:"fulfilled",value:Y};if($===l.Rejected)return{type:"rejected",error:Y};throw Y.dispose(),Error(`Unknown JSPromiseStateEnum: ${$}`)}resolvePromise(Z){this.runtime.assertOwned(Z);let $=I.withScope((K)=>{let Y=K.manage(this.getProp(this.global,"Promise")),J=K.manage(this.getProp(Y,"resolve"));return this.callFunction(J,Y,Z)});return $.error?Promise.resolve($):new Promise((K)=>{I.withScope((Y)=>{let J=Y.manage(this.newFunction("resolve",(D)=>{K(this.success(D&&D.dup()))})),q=Y.manage(this.newFunction("reject",(D)=>{K(this.fail(D&&D.dup()))})),C=Y.manage($.value),z=Y.manage(this.getProp(C,"then"));this.callFunction(z,C,J,q).unwrap().dispose()})})}isEqual(Z,$,K=c.IsStrictlyEqual){if(Z===$)return!0;this.runtime.assertOwned(Z),this.runtime.assertOwned($);let Y=this.ffi.QTS_IsEqual(this.ctx.value,Z.value,$.value,K);if(Y===-1)throw new t8("WASM variant does not expose equality");return!!Y}eq(Z,$){return this.isEqual(Z,$,c.IsStrictlyEqual)}sameValue(Z,$){return this.isEqual(Z,$,c.IsSameValue)}sameValueZero(Z,$){return this.isEqual(Z,$,c.IsSameValueZero)}getProp(Z,$){this.runtime.assertOwned(Z);let K;return typeof $=="number"&&$>=0?K=this.ffi.QTS_GetPropNumber(this.ctx.value,Z.value,$):K=this.borrowPropertyKey($).consume((Y)=>this.ffi.QTS_GetProp(this.ctx.value,Z.value,Y.value)),this.memory.heapValueHandle(K)}getLength(Z){if(this.runtime.assertOwned(Z),!(this.ffi.QTS_GetLength(this.ctx.value,this.uint32Out.value.ptr,Z.value)<0))return this.uint32Out.value.typedArray[0]}getOwnPropertyNames(Z,$={strings:!0,numbersAsStrings:!0}){this.runtime.assertOwned(Z),Z.value;let K=s9($);if(K===0)throw new K9("No options set, will return an empty array");return I.withScope((Y)=>{let J=Y.manage(this.memory.newMutablePointerArray(1)),q=this.ffi.QTS_GetOwnPropertyNames(this.ctx.value,J.value.ptr,this.uint32Out.value.ptr,Z.value,K);if(q)return this.fail(this.memory.heapValueHandle(q));let C=this.uint32Out.value.typedArray[0],z=J.value.typedArray[0],D=new Uint32Array(this.module.HEAP8.buffer,z,C),N=Array.from(D).map((x)=>this.memory.heapValueHandle(x));return this.ffi.QTS_FreeVoidPointer(this.ctx.value,z),this.success(d9(N))})}getIterator(Z){let $=this._SymbolIterator??(this._SymbolIterator=this.memory.manage(this.getWellKnownSymbol("iterator")));return I.withScope((K)=>{let Y=K.manage(this.getProp(Z,$)),J=this.callFunction(Y,Z);return J.error?J:this.success(new t9(J.value,this))})}setProp(Z,$,K){this.runtime.assertOwned(Z),this.borrowPropertyKey($).consume((Y)=>this.ffi.QTS_SetProp(this.ctx.value,Z.value,Y.value,K.value))}defineProp(Z,$,K){this.runtime.assertOwned(Z),I.withScope((Y)=>{let J=Y.manage(this.borrowPropertyKey($)),q=K.value||this.undefined,C=!!K.configurable,z=!!K.enumerable,D=!!K.value,N=K.get?Y.manage(this.newFunction(K.get.name,K.get)):this.undefined,x=K.set?Y.manage(this.newFunction(K.set.name,K.set)):this.undefined;this.ffi.QTS_DefineProp(this.ctx.value,Z.value,J.value,q.value,N.value,x.value,C,z,D)})}callFunction(Z,$,...K){this.runtime.assertOwned(Z);let Y,J=K[0];J===void 0||Array.isArray(J)?Y=J??[]:Y=K;let q=this.memory.toPointerArray(Y).consume((z)=>this.ffi.QTS_Call(this.ctx.value,Z.value,$.value,Y.length,z.value)),C=this.ffi.QTS_ResolveException(this.ctx.value,q);return C?(this.ffi.QTS_FreeValuePointer(this.ctx.value,q),this.fail(this.memory.heapValueHandle(C))):this.success(this.memory.heapValueHandle(q))}callMethod(Z,$,K=[]){return this.getProp(Z,$).consume((Y)=>this.callFunction(Y,Z,K))}evalCode(Z,$="eval.js",K){let Y=K===void 0?1:0,J=a9(K),q=this.memory.newHeapCharPointer(Z).consume((z)=>this.ffi.QTS_Eval(this.ctx.value,z.value.ptr,z.value.strlen,$,Y,J)),C=this.ffi.QTS_ResolveException(this.ctx.value,q);return C?(this.ffi.QTS_FreeValuePointer(this.ctx.value,q),this.fail(this.memory.heapValueHandle(C))):this.success(this.memory.heapValueHandle(q))}throw(Z){return this.errorToHandle(Z).consume(($)=>this.ffi.QTS_Throw(this.ctx.value,$.value))}borrowPropertyKey(Z){return typeof Z=="number"?this.newNumber(Z):typeof Z=="string"?this.newString(Z):new v(Z.value,this.runtime)}getMemory(Z){if(Z===this.rt.value)return this.memory;throw Error("Private API. Cannot get memory from a different runtime")}dump(Z){this.runtime.assertOwned(Z);let $=this.typeof(Z);if($==="string")return this.getString(Z);if($==="number")return this.getNumber(Z);if($==="bigint")return this.getBigInt(Z);if($==="undefined")return;if($==="symbol")return this.getSymbol(Z);let K=this.getPromiseState(Z);if(K.type==="fulfilled"&&!K.notAPromise)return Z.dispose(),{type:K.type,value:K.value.consume(this.dump)};if(K.type==="pending")return Z.dispose(),{type:K.type};if(K.type==="rejected")return Z.dispose(),{type:K.type,error:K.error.consume(this.dump)};let Y=this.memory.consumeJSCharPointer(this.ffi.QTS_Dump(this.ctx.value,Z.value));try{return JSON.parse(Y)}catch{return Y}}unwrapResult(Z){if(Z.error){let $="context"in Z.error?Z.error.context:this,K=Z.error.consume((Y)=>this.dump(Y));if(K&&typeof K=="object"&&typeof K.message=="string"){let{message:Y,name:J,stack:q,...C}=K,z=new Y8(K,$);typeof J=="string"&&(z.name=K.name),z.message=Y;let D=z.stack;throw typeof q=="string"&&(z.stack=`${J}: ${Y}
|
|
7
|
+
${K.stack}Host: ${D}`),Object.assign(z,C),z}throw new Y8(K)}return Z.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(Z){let $=this.runtime.hostRefs.get(Z);if(typeof $!="function")throw Error(`Host reference ${Z} is not a function`);return $}errorToHandle(Z){return Z instanceof _?Z:this.newError(Z)}encodeBinaryJSON(Z){let $=this.ffi.QTS_bjson_encode(this.ctx.value,Z.value);return this.memory.heapValueHandle($)}decodeBinaryJSON(Z){let $=this.ffi.QTS_bjson_decode(this.ctx.value,Z.value);return this.memory.heapValueHandle($)}success(Z){return g.success(Z)}fail(Z){return g.fail(Z,($)=>this.unwrapResult($))}},$Z=class extends b{constructor(Z){super();this.scope=new I,this.contextMap=new Map,this.hostRefs=new r9,this._debugMode=!1,this.cToHostCallbacks={freeHostRef:($,K)=>{if($!==this.rt.value)throw Error("Runtime pointer mismatch");this.hostRefs.delete(K)},shouldInterrupt:($)=>{if($!==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:u8(this,function*($,K,Y,J){let q=this.moduleLoader;if(!q)throw Error("Runtime has no module loader");if(K!==this.rt.value)throw Error("Runtime pointer mismatch");let C=this.contextMap.get(Y)??this.newContext({contextPointer:Y});try{let z=yield*$(q(J,C));if(typeof z=="object"&&"error"in z&&z.error)throw this.debugLog("cToHostLoadModule: loader returned error",z.error),z.error;let D=typeof z=="string"?z:("value"in z)?z.value:z;return this.memory.newHeapCharPointer(D).value.ptr}catch(z){return this.debugLog("cToHostLoadModule: caught error",z),C.throw(z),0}}),normalizeModule:u8(this,function*($,K,Y,J,q){let C=this.moduleNormalizer;if(!C)throw Error("Runtime has no module normalizer");if(K!==this.rt.value)throw Error("Runtime pointer mismatch");let z=this.contextMap.get(Y)??this.newContext({contextPointer:Y});try{let D=yield*$(C(J,q,z));if(typeof D=="object"&&"error"in D&&D.error)throw this.debugLog("cToHostNormalizeModule: normalizer returned error",D.error),D.error;let N=typeof D=="string"?D:D.value;return z.getMemory(this.rt.value).newHeapCharPointer(N).value.ptr}catch(D){return this.debugLog("normalizeModule: caught error",D),z.throw(D),0}})},Z.ownedLifetimes?.forEach(($)=>this.scope.manage($)),this.module=Z.module,this.memory=new z9(this.module),this.ffi=Z.ffi,this.rt=Z.rt,this.callbacks=Z.callbacks,this.scope.manage(this.rt),this.callbacks.setRuntimeCallbacks(this.rt.value,this.cToHostCallbacks),this.executePendingJobs=this.executePendingJobs.bind(this),J8&&this.setDebugMode(!0)}get alive(){return this.scope.alive}dispose(){return this.scope.dispose()}newContext(Z={}){let $=o9(Z.intrinsics),K=new _(Z.contextPointer||this.ffi.QTS_NewContext(this.rt.value,$),void 0,(J)=>{this.contextMap.delete(J),this.callbacks.deleteContext(J),this.ffi.QTS_FreeContext(J)}),Y=new ZZ({module:this.module,ctx:K,ffi:this.ffi,rt:this.rt,ownedLifetimes:Z.ownedLifetimes,runtime:this,callbacks:this.callbacks});return this.contextMap.set(K.value,Y),Y}setModuleLoader(Z,$){this.moduleLoader=Z,this.moduleNormalizer=$,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(Z){let $=this.interruptHandler;this.interruptHandler=Z,$||this.ffi.QTS_RuntimeEnableInterruptHandler(this.rt.value)}removeInterruptHandler(){this.interruptHandler&&(this.ffi.QTS_RuntimeDisableInterruptHandler(this.rt.value),this.interruptHandler=void 0)}executePendingJobs(Z=-1){let $=this.memory.newMutablePointerArray(1),K=this.ffi.QTS_ExecutePendingJob(this.rt.value,Z??-1,$.value.ptr),Y=$.value.typedArray[0];if($.dispose(),Y===0)return this.ffi.QTS_FreeValuePointerRuntime(this.rt.value,K),g.success(0);let J=this.contextMap.get(Y)??this.newContext({contextPointer:Y}),q=J.getMemory(this.rt.value).heapValueHandle(K);if(J.typeof(q)==="number"){let C=J.getNumber(q);return q.dispose(),g.success(C)}else{let C=Object.assign(q,{context:J});return g.fail(C,(z)=>J.unwrapResult(z))}}setMemoryLimit(Z){if(Z<0&&Z!==-1)throw Error("Cannot set memory limit to negative number. To unset, pass -1");this.ffi.QTS_RuntimeSetMemoryLimit(this.rt.value,Z)}computeMemoryUsage(){let Z=this.getSystemContext().getMemory(this.rt.value);return Z.heapValueHandle(this.ffi.QTS_RuntimeComputeMemoryUsage(this.rt.value,Z.ctx.value))}dumpMemoryUsage(){return this.memory.consumeHeapCharPointer(this.ffi.QTS_RuntimeDumpMemoryUsage(this.rt.value))}setMaxStackSize(Z){if(Z<0)throw Error("Cannot set memory limit to negative number. To unset, pass 0.");this.ffi.QTS_RuntimeSetMaxStackSize(this.rt.value,Z)}assertOwned(Z){if(Z.owner&&Z.owner.rt!==this.rt)throw new n8(`Handle is not owned by this runtime: ${Z.owner.rt.value} != ${this.rt.value}`)}setDebugMode(Z){this._debugMode=Z,this.ffi.DEBUG&&this.rt.alive&&this.ffi.QTS_SetDebugLogEnabled(this.rt.value,Z?1:0)}isDebugMode(){return this._debugMode}debugLog(...Z){this._debugMode&&console.log("quickjs-emscripten:",...Z)}[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 G9={};y9(G9,{applyModuleEvalRuntimeOptions:()=>H8,applyBaseRuntimeOptions:()=>j8,QuickJSWASMModule:()=>Y9,QuickJSModuleCallbacks:()=>C8});var J9=K8(()=>{Q9()});var H9=b9((s,j9)=>{(function(Z,$){typeof s==="object"&&typeof j9<"u"?$(s):typeof define==="function"&&define.amd?define(["exports"],$):(Z=typeof globalThis<"u"?globalThis:Z||self,$(Z.jmespath={}))})(s,function(Z){let $=(X)=>{return X!==null&&Object.prototype.toString.call(X)==="[object Object]"},K=(X,W)=>{if(X===W)return!0;if(typeof X!==typeof W)return!1;if(Array.isArray(X)&&Array.isArray(W)){if(X.length!==W.length)return!1;for(let Q=0;Q<X.length;Q+=1)if(!K(X[Q],W[Q]))return!1;return!0}if($(X)&&$(W)){let Q=Object.entries(X),G=new Set(Object.keys(W));if(Q.length!==G.size)return!1;for(let[U,j]of Q){if(!K(j,W[U]))return!1;G.delete(U)}return G.size===0}return!1},Y=(X)=>{if(X===""||X===!1||X===null||X===void 0)return!0;if(Array.isArray(X)&&X.length===0)return!0;if($(X)){for(let W in X)if(X.hasOwnProperty(W))return!1;return!0}return!1},J=(X)=>{return X>="a"&&X<="z"||X>="A"&&X<="Z"||X==="_"},q=(X)=>{return X>="0"&&X<="9"||X==="-"},C=(X)=>{return X>="a"&&X<="z"||X>="A"&&X<="Z"||X>="0"&&X<="9"||X==="_"};var z;(function(X){X.TOK_EOF="EOF",X.TOK_UNQUOTEDIDENTIFIER="UnquotedIdentifier",X.TOK_QUOTEDIDENTIFIER="QuotedIdentifier",X.TOK_RBRACKET="Rbracket",X.TOK_RPAREN="Rparen",X.TOK_COMMA="Comma",X.TOK_COLON="Colon",X.TOK_RBRACE="Rbrace",X.TOK_NUMBER="Number",X.TOK_CURRENT="Current",X.TOK_ROOT="Root",X.TOK_EXPREF="Expref",X.TOK_PIPE="Pipe",X.TOK_OR="Or",X.TOK_AND="And",X.TOK_EQ="EQ",X.TOK_GT="GT",X.TOK_LT="LT",X.TOK_GTE="GTE",X.TOK_LTE="LTE",X.TOK_NE="NE",X.TOK_FLATTEN="Flatten",X.TOK_STAR="Star",X.TOK_FILTER="Filter",X.TOK_DOT="Dot",X.TOK_NOT="Not",X.TOK_LBRACE="Lbrace",X.TOK_LBRACKET="Lbracket",X.TOK_LPAREN="Lparen",X.TOK_LITERAL="Literal"})(z||(z={}));let D={"(":z.TOK_LPAREN,")":z.TOK_RPAREN,"*":z.TOK_STAR,",":z.TOK_COMMA,".":z.TOK_DOT,":":z.TOK_COLON,"@":z.TOK_CURRENT,["$"]:z.TOK_ROOT,"]":z.TOK_RBRACKET,"{":z.TOK_LBRACE,"}":z.TOK_RBRACE},N={"!":!0,"<":!0,"=":!0,">":!0},x={"\t":!0,"\n":!0,"\r":!0," ":!0};class M{constructor(){this._current=0}tokenize(X){let W=[];this._current=0;let Q,G,U;while(this._current<X.length)if(J(X[this._current]))Q=this._current,G=this.consumeUnquotedIdentifier(X),W.push({start:Q,type:z.TOK_UNQUOTEDIDENTIFIER,value:G});else if(D[X[this._current]]!==void 0)W.push({start:this._current,type:D[X[this._current]],value:X[this._current]}),this._current+=1;else if(q(X[this._current]))U=this.consumeNumber(X),W.push(U);else if(X[this._current]==="[")U=this.consumeLBracket(X),W.push(U);else if(X[this._current]==='"')Q=this._current,G=this.consumeQuotedIdentifier(X),W.push({start:Q,type:z.TOK_QUOTEDIDENTIFIER,value:G});else if(X[this._current]==="'")Q=this._current,G=this.consumeRawStringLiteral(X),W.push({start:Q,type:z.TOK_LITERAL,value:G});else if(X[this._current]==="`"){Q=this._current;let j=this.consumeLiteral(X);W.push({start:Q,type:z.TOK_LITERAL,value:j})}else if(N[X[this._current]]!==void 0)U=this.consumeOperator(X),U&&W.push(U);else if(x[X[this._current]]!==void 0)this._current+=1;else if(X[this._current]==="&")if(Q=this._current,this._current+=1,X[this._current]==="&")this._current+=1,W.push({start:Q,type:z.TOK_AND,value:"&&"});else W.push({start:Q,type:z.TOK_EXPREF,value:"&"});else if(X[this._current]==="|")if(Q=this._current,this._current+=1,X[this._current]==="|")this._current+=1,W.push({start:Q,type:z.TOK_OR,value:"||"});else W.push({start:Q,type:z.TOK_PIPE,value:"|"});else{let j=Error(`Unknown character: ${X[this._current]}`);throw j.name="LexerError",j}return W}consumeUnquotedIdentifier(X){let W=this._current;this._current+=1;while(this._current<X.length&&C(X[this._current]))this._current+=1;return X.slice(W,this._current)}consumeQuotedIdentifier(X){let W=this._current;this._current+=1;let Q=X.length;while(X[this._current]!=='"'&&this._current<Q){let G=this._current;if(X[G]==="\\"&&(X[G+1]==="\\"||X[G+1]==='"'))G+=2;else G+=1;this._current=G}return this._current+=1,JSON.parse(X.slice(W,this._current))}consumeRawStringLiteral(X){let W=this._current;this._current+=1;let Q=X.length;while(X[this._current]!=="'"&&this._current<Q){let U=this._current;if(X[U]==="\\"&&(X[U+1]==="\\"||X[U+1]==="'"))U+=2;else U+=1;this._current=U}return this._current+=1,X.slice(W+1,this._current-1).replace("\\'","'")}consumeNumber(X){let W=this._current;this._current+=1;let Q=X.length;while(q(X[this._current])&&this._current<Q)this._current+=1;let G=parseInt(X.slice(W,this._current),10);return{start:W,value:G,type:z.TOK_NUMBER}}consumeLBracket(X){let W=this._current;if(this._current+=1,X[this._current]==="?")return this._current+=1,{start:W,type:z.TOK_FILTER,value:"[?"};if(X[this._current]==="]")return this._current+=1,{start:W,type:z.TOK_FLATTEN,value:"[]"};return{start:W,type:z.TOK_LBRACKET,value:"["}}consumeOperator(X){let W=this._current,Q=X[W];if(this._current+=1,Q==="!"){if(X[this._current]==="=")return this._current+=1,{start:W,type:z.TOK_NE,value:"!="};return{start:W,type:z.TOK_NOT,value:"!"}}if(Q==="<"){if(X[this._current]==="=")return this._current+=1,{start:W,type:z.TOK_LTE,value:"<="};return{start:W,type:z.TOK_LT,value:"<"}}if(Q===">"){if(X[this._current]==="=")return this._current+=1,{start:W,type:z.TOK_GTE,value:">="};return{start:W,type:z.TOK_GT,value:">"}}if(Q==="="&&X[this._current]==="=")return this._current+=1,{start:W,type:z.TOK_EQ,value:"=="}}consumeLiteral(X){this._current+=1;let W=this._current,Q=X.length;while(X[this._current]!=="`"&&this._current<Q){let j=this._current;if(X[j]==="\\"&&(X[j+1]==="\\"||X[j+1]==="`"))j+=2;else j+=1;this._current=j}let G=X.slice(W,this._current).trimLeft();G=G.replace("\\`","`");let U=this.looksLikeJSON(G)?JSON.parse(G):JSON.parse(`"${G}"`);return this._current+=1,U}looksLikeJSON(X){let Q=["true","false","null"],G="-0123456789";if(X==="")return!1;if('[{"'.includes(X[0]))return!0;if(Q.includes(X))return!0;if("-0123456789".includes(X[0]))try{return JSON.parse(X),!0}catch(U){return!1}return!1}}let A=new M,w={[z.TOK_EOF]:0,[z.TOK_UNQUOTEDIDENTIFIER]:0,[z.TOK_QUOTEDIDENTIFIER]:0,[z.TOK_RBRACKET]:0,[z.TOK_RPAREN]:0,[z.TOK_COMMA]:0,[z.TOK_RBRACE]:0,[z.TOK_NUMBER]:0,[z.TOK_CURRENT]:0,[z.TOK_EXPREF]:0,[z.TOK_ROOT]:0,[z.TOK_PIPE]:1,[z.TOK_OR]:2,[z.TOK_AND]:3,[z.TOK_EQ]:5,[z.TOK_GT]:5,[z.TOK_LT]:5,[z.TOK_GTE]:5,[z.TOK_LTE]:5,[z.TOK_NE]:5,[z.TOK_FLATTEN]:9,[z.TOK_STAR]:20,[z.TOK_FILTER]:21,[z.TOK_DOT]:40,[z.TOK_NOT]:45,[z.TOK_LBRACE]:50,[z.TOK_LBRACKET]:55,[z.TOK_LPAREN]:60};class F8{constructor(){this.index=0,this.tokens=[]}parse(X){this.loadTokens(X),this.index=0;let W=this.expression(0);if(this.lookahead(0)!==z.TOK_EOF){let Q=this.lookaheadToken(0);this.errorToken(Q,`Unexpected token type: ${Q.type}, value: ${Q.value}`)}return W}loadTokens(X){this.tokens=[...A.tokenize(X),{type:z.TOK_EOF,value:"",start:X.length}]}expression(X){let W=this.lookaheadToken(0);this.advance();let Q=this.nud(W),G=this.lookahead(0);while(X<w[G])this.advance(),Q=this.led(G,Q),G=this.lookahead(0);return Q}lookahead(X){return this.tokens[this.index+X].type}lookaheadToken(X){return this.tokens[this.index+X]}advance(){this.index+=1}nud(X){let W,Q,G;switch(X.type){case z.TOK_LITERAL:return{type:"Literal",value:X.value};case z.TOK_UNQUOTEDIDENTIFIER:return{type:"Field",name:X.value};case z.TOK_QUOTEDIDENTIFIER:let U={type:"Field",name:X.value};if(this.lookahead(0)===z.TOK_LPAREN)throw Error("Quoted identifier not allowed for function names.");else return U;case z.TOK_NOT:return Q=this.expression(w.Not),{type:"NotExpression",children:[Q]};case z.TOK_STAR:return W={type:"Identity"},Q=this.lookahead(0)===z.TOK_RBRACKET&&{type:"Identity"}||this.parseProjectionRHS(w.Star),{type:"ValueProjection",children:[W,Q]};case z.TOK_FILTER:return this.led(X.type,{type:"Identity"});case z.TOK_LBRACE:return this.parseMultiselectHash();case z.TOK_FLATTEN:return W={type:z.TOK_FLATTEN,children:[{type:"Identity"}]},Q=this.parseProjectionRHS(w.Flatten),{type:"Projection",children:[W,Q]};case z.TOK_LBRACKET:if(this.lookahead(0)===z.TOK_NUMBER||this.lookahead(0)===z.TOK_COLON)return Q=this.parseIndexExpression(),this.projectIfSlice({type:"Identity"},Q);if(this.lookahead(0)===z.TOK_STAR&&this.lookahead(1)===z.TOK_RBRACKET)return this.advance(),this.advance(),Q=this.parseProjectionRHS(w.Star),{children:[{type:"Identity"},Q],type:"Projection"};return this.parseMultiselectList();case z.TOK_CURRENT:return{type:z.TOK_CURRENT};case z.TOK_ROOT:return{type:z.TOK_ROOT};case z.TOK_EXPREF:return G=this.expression(w.Expref),{type:"ExpressionReference",children:[G]};case z.TOK_LPAREN:let j=[];while(this.lookahead(0)!==z.TOK_RPAREN){if(this.lookahead(0)===z.TOK_CURRENT)G={type:z.TOK_CURRENT},this.advance();else G=this.expression(0);j.push(G)}return this.match(z.TOK_RPAREN),j[0];default:this.errorToken(X)}}led(X,W){let Q;switch(X){case z.TOK_DOT:let G=w.Dot;if(this.lookahead(0)!==z.TOK_STAR)return Q=this.parseDotRHS(G),{type:"Subexpression",children:[W,Q]};return this.advance(),Q=this.parseProjectionRHS(G),{type:"ValueProjection",children:[W,Q]};case z.TOK_PIPE:return Q=this.expression(w.Pipe),{type:z.TOK_PIPE,children:[W,Q]};case z.TOK_OR:return Q=this.expression(w.Or),{type:"OrExpression",children:[W,Q]};case z.TOK_AND:return Q=this.expression(w.And),{type:"AndExpression",children:[W,Q]};case z.TOK_LPAREN:let U=W.name,j=[],L;while(this.lookahead(0)!==z.TOK_RPAREN){if(this.lookahead(0)===z.TOK_CURRENT)L={type:z.TOK_CURRENT},this.advance();else L=this.expression(0);if(this.lookahead(0)===z.TOK_COMMA)this.match(z.TOK_COMMA);j.push(L)}return this.match(z.TOK_RPAREN),{name:U,type:"Function",children:j};case z.TOK_FILTER:let F=this.expression(0);return this.match(z.TOK_RBRACKET),Q=this.lookahead(0)===z.TOK_FLATTEN&&{type:"Identity"}||this.parseProjectionRHS(w.Filter),{type:"FilterProjection",children:[W,Q,F]};case z.TOK_FLATTEN:let P={type:z.TOK_FLATTEN,children:[W]},R=this.parseProjectionRHS(w.Flatten);return{type:"Projection",children:[P,R]};case z.TOK_EQ:case z.TOK_NE:case z.TOK_GT:case z.TOK_GTE:case z.TOK_LT:case z.TOK_LTE:return this.parseComparator(W,X);case z.TOK_LBRACKET:let H=this.lookaheadToken(0);if(H.type===z.TOK_NUMBER||H.type===z.TOK_COLON)return Q=this.parseIndexExpression(),this.projectIfSlice(W,Q);return this.match(z.TOK_STAR),this.match(z.TOK_RBRACKET),Q=this.parseProjectionRHS(w.Star),{type:"Projection",children:[W,Q]};default:return this.errorToken(this.lookaheadToken(0))}}match(X){if(this.lookahead(0)===X){this.advance();return}else{let W=this.lookaheadToken(0);this.errorToken(W,`Expected ${X}, got: ${W.type}`)}}errorToken(X,W=""){let Q=Error(W||`Invalid token (${X.type}): "${X.value}"`);throw Q.name="ParserError",Q}parseIndexExpression(){if(this.lookahead(0)===z.TOK_COLON||this.lookahead(1)===z.TOK_COLON)return this.parseSliceExpression();let X={type:"Index",value:this.lookaheadToken(0).value};return this.advance(),this.match(z.TOK_RBRACKET),X}projectIfSlice(X,W){let Q={type:"IndexExpression",children:[X,W]};if(W.type==="Slice")return{children:[Q,this.parseProjectionRHS(w.Star)],type:"Projection"};return Q}parseSliceExpression(){let X=[null,null,null],W=0,Q=this.lookahead(0);while(Q!==z.TOK_RBRACKET&&W<3){if(Q===z.TOK_COLON)W+=1,this.advance();else if(Q===z.TOK_NUMBER)X[W]=this.lookaheadToken(0).value,this.advance();else{let G=this.lookaheadToken(0);this.errorToken(G,`Syntax error, unexpected token: ${G.value}(${G.type})`)}Q=this.lookahead(0)}return this.match(z.TOK_RBRACKET),{children:X,type:"Slice"}}parseComparator(X,W){let Q=this.expression(w[W]);return{type:"Comparator",name:W,children:[X,Q]}}parseDotRHS(X){let W=this.lookahead(0);if([z.TOK_UNQUOTEDIDENTIFIER,z.TOK_QUOTEDIDENTIFIER,z.TOK_STAR].includes(W))return this.expression(X);if(W===z.TOK_LBRACKET)return this.match(z.TOK_LBRACKET),this.parseMultiselectList();if(W===z.TOK_LBRACE)return this.match(z.TOK_LBRACE),this.parseMultiselectHash();let G=this.lookaheadToken(0);this.errorToken(G,`Syntax error, unexpected token: ${G.value}(${G.type})`)}parseProjectionRHS(X){if(w[this.lookahead(0)]<10)return{type:"Identity"};if(this.lookahead(0)===z.TOK_LBRACKET)return this.expression(X);if(this.lookahead(0)===z.TOK_FILTER)return this.expression(X);if(this.lookahead(0)===z.TOK_DOT)return this.match(z.TOK_DOT),this.parseDotRHS(X);let W=this.lookaheadToken(0);this.errorToken(W,`Syntax error, unexpected token: ${W.value}(${W.type})`)}parseMultiselectList(){let X=[];while(this.lookahead(0)!==z.TOK_RBRACKET){let W=this.expression(0);if(X.push(W),this.lookahead(0)===z.TOK_COMMA){if(this.match(z.TOK_COMMA),this.lookahead(0)===z.TOK_RBRACKET)throw Error("Unexpected token Rbracket")}}return this.match(z.TOK_RBRACKET),{type:"MultiSelectList",children:X}}parseMultiselectHash(){let X=[],W=[z.TOK_UNQUOTEDIDENTIFIER,z.TOK_QUOTEDIDENTIFIER],Q,G,U;for(;;){if(Q=this.lookaheadToken(0),!W.includes(Q.type))throw Error(`Expecting an identifier token, got: ${Q.type}`);if(G=Q.value,this.advance(),this.match(z.TOK_COLON),U=this.expression(0),X.push({value:U,type:"KeyValuePair",name:G}),this.lookahead(0)===z.TOK_COMMA)this.match(z.TOK_COMMA);else if(this.lookahead(0)===z.TOK_RBRACE){this.match(z.TOK_RBRACE);break}}return{type:"MultiSelectHash",children:X}}}let R8=new F8;var B;(function(X){X[X.TYPE_NUMBER=0]="TYPE_NUMBER",X[X.TYPE_ANY=1]="TYPE_ANY",X[X.TYPE_STRING=2]="TYPE_STRING",X[X.TYPE_ARRAY=3]="TYPE_ARRAY",X[X.TYPE_OBJECT=4]="TYPE_OBJECT",X[X.TYPE_BOOLEAN=5]="TYPE_BOOLEAN",X[X.TYPE_EXPREF=6]="TYPE_EXPREF",X[X.TYPE_NULL=7]="TYPE_NULL",X[X.TYPE_ARRAY_NUMBER=8]="TYPE_ARRAY_NUMBER",X[X.TYPE_ARRAY_STRING=9]="TYPE_ARRAY_STRING"})(B||(B={}));class M8{constructor(X){this.TYPE_NAME_TABLE={[B.TYPE_NUMBER]:"number",[B.TYPE_ANY]:"any",[B.TYPE_STRING]:"string",[B.TYPE_ARRAY]:"array",[B.TYPE_OBJECT]:"object",[B.TYPE_BOOLEAN]:"boolean",[B.TYPE_EXPREF]:"expression",[B.TYPE_NULL]:"null",[B.TYPE_ARRAY_NUMBER]:"Array<number>",[B.TYPE_ARRAY_STRING]:"Array<string>"},this.functionAbs=([W])=>{return Math.abs(W)},this.functionAvg=([W])=>{let Q=0;for(let G=0;G<W.length;G+=1)Q+=W[G];return Q/W.length},this.functionCeil=([W])=>{return Math.ceil(W)},this.functionContains=(W)=>{let[Q,G]=W;return Q.includes(G)},this.functionEndsWith=(W)=>{let[Q,G]=W;return Q.includes(G,Q.length-G.length)},this.functionFloor=([W])=>{return Math.floor(W)},this.functionJoin=(W)=>{let[Q,G]=W;return G.join(Q)},this.functionKeys=([W])=>{return Object.keys(W)},this.functionLength=([W])=>{if(!$(W))return W.length;return Object.keys(W).length},this.functionMap=(W)=>{if(!this._interpreter)return[];let Q=[],G=this._interpreter,U=W[0],j=W[1];for(let L=0;L<j.length;L+=1)Q.push(G.visit(U,j[L]));return Q},this.functionMax=([W])=>{if(!W.length)return null;if(this.getTypeName(W[0])===B.TYPE_NUMBER)return Math.max(...W);let G=W,U=G[0];for(let j=1;j<G.length;j+=1)if(U.localeCompare(G[j])<0)U=G[j];return U},this.functionMaxBy=(W)=>{let Q=W[1],G=W[0],U=this.createKeyFunction(Q,[B.TYPE_NUMBER,B.TYPE_STRING]),j=-1/0,L,O;for(let F=0;F<G.length;F+=1)if(O=U&&U(G[F]),O!==void 0&&O>j)j=O,L=G[F];return L},this.functionMerge=(W)=>{let Q={};for(let G=0;G<W.length;G+=1){let U=W[G];Q=Object.assign(Q,U)}return Q},this.functionMin=([W])=>{if(!W.length)return null;if(this.getTypeName(W[0])===B.TYPE_NUMBER)return Math.min(...W);let G=W,U=G[0];for(let j=1;j<G.length;j+=1)if(G[j].localeCompare(U)<0)U=G[j];return U},this.functionMinBy=(W)=>{let Q=W[1],G=W[0],U=this.createKeyFunction(Q,[B.TYPE_NUMBER,B.TYPE_STRING]),j=1/0,L,O;for(let F=0;F<G.length;F+=1)if(O=U&&U(G[F]),O!==void 0&&O<j)j=O,L=G[F];return L},this.functionNotNull=(W)=>{for(let Q=0;Q<W.length;Q+=1)if(this.getTypeName(W[Q])!==B.TYPE_NULL)return W[Q];return null},this.functionReverse=([W])=>{if(this.getTypeName(W)===B.TYPE_STRING){let U=W,j="";for(let L=U.length-1;L>=0;L-=1)j+=U[L];return j}let G=W.slice(0);return G.reverse(),G},this.functionSort=([W])=>{return[...W].sort()},this.functionSortBy=(W)=>{if(!this._interpreter)return[];let Q=W[0].slice(0);if(Q.length===0)return Q;let G=this._interpreter,U=W[1],j=this.getTypeName(G.visit(U,Q[0]));if(j!==void 0&&![B.TYPE_NUMBER,B.TYPE_STRING].includes(j))throw Error(`TypeError: unexpected type (${this.TYPE_NAME_TABLE[j]})`);let L=[];for(let O=0;O<Q.length;O+=1)L.push([O,Q[O]]);L.sort((O,F)=>{let P=G.visit(U,O[1]),R=G.visit(U,F[1]);if(this.getTypeName(P)!==j)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[j]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(P)]}`);else if(this.getTypeName(R)!==j)throw Error(`TypeError: expected (${this.TYPE_NAME_TABLE[j]}), received ${this.TYPE_NAME_TABLE[this.getTypeName(R)]}`);if(P>R)return 1;return P<R?-1:O[0]-F[0]});for(let O=0;O<L.length;O+=1)Q[O]=L[O][1];return Q},this.functionStartsWith=([W,Q])=>{return W.startsWith(Q)},this.functionSum=([W])=>{return W.reduce((Q,G)=>Q+G,0)},this.functionToArray=([W])=>{if(this.getTypeName(W)===B.TYPE_ARRAY)return W;return[W]},this.functionToNumber=([W])=>{let Q=this.getTypeName(W),G;if(Q===B.TYPE_NUMBER)return W;if(Q===B.TYPE_STRING){if(G=+W,!isNaN(G))return G}return null},this.functionToString=([W])=>{if(this.getTypeName(W)===B.TYPE_STRING)return W;return JSON.stringify(W)},this.functionType=([W])=>{switch(this.getTypeName(W)){case B.TYPE_NUMBER:return"number";case B.TYPE_STRING:return"string";case B.TYPE_ARRAY:return"array";case B.TYPE_OBJECT:return"object";case B.TYPE_BOOLEAN:return"boolean";case B.TYPE_EXPREF:return"expref";case B.TYPE_NULL:return"null";default:return}},this.functionValues=([W])=>{return Object.values(W)},this.functionTable={abs:{_func:this.functionAbs,_signature:[{types:[B.TYPE_NUMBER]}]},avg:{_func:this.functionAvg,_signature:[{types:[B.TYPE_ARRAY_NUMBER]}]},ceil:{_func:this.functionCeil,_signature:[{types:[B.TYPE_NUMBER]}]},contains:{_func:this.functionContains,_signature:[{types:[B.TYPE_STRING,B.TYPE_ARRAY]},{types:[B.TYPE_ANY]}]},ends_with:{_func:this.functionEndsWith,_signature:[{types:[B.TYPE_STRING]},{types:[B.TYPE_STRING]}]},floor:{_func:this.functionFloor,_signature:[{types:[B.TYPE_NUMBER]}]},join:{_func:this.functionJoin,_signature:[{types:[B.TYPE_STRING]},{types:[B.TYPE_ARRAY_STRING]}]},keys:{_func:this.functionKeys,_signature:[{types:[B.TYPE_OBJECT]}]},length:{_func:this.functionLength,_signature:[{types:[B.TYPE_STRING,B.TYPE_ARRAY,B.TYPE_OBJECT]}]},map:{_func:this.functionMap,_signature:[{types:[B.TYPE_EXPREF]},{types:[B.TYPE_ARRAY]}]},max:{_func:this.functionMax,_signature:[{types:[B.TYPE_ARRAY_NUMBER,B.TYPE_ARRAY_STRING]}]},max_by:{_func:this.functionMaxBy,_signature:[{types:[B.TYPE_ARRAY]},{types:[B.TYPE_EXPREF]}]},merge:{_func:this.functionMerge,_signature:[{types:[B.TYPE_OBJECT],variadic:!0}]},min:{_func:this.functionMin,_signature:[{types:[B.TYPE_ARRAY_NUMBER,B.TYPE_ARRAY_STRING]}]},min_by:{_func:this.functionMinBy,_signature:[{types:[B.TYPE_ARRAY]},{types:[B.TYPE_EXPREF]}]},not_null:{_func:this.functionNotNull,_signature:[{types:[B.TYPE_ANY],variadic:!0}]},reverse:{_func:this.functionReverse,_signature:[{types:[B.TYPE_STRING,B.TYPE_ARRAY]}]},sort:{_func:this.functionSort,_signature:[{types:[B.TYPE_ARRAY_STRING,B.TYPE_ARRAY_NUMBER]}]},sort_by:{_func:this.functionSortBy,_signature:[{types:[B.TYPE_ARRAY]},{types:[B.TYPE_EXPREF]}]},starts_with:{_func:this.functionStartsWith,_signature:[{types:[B.TYPE_STRING]},{types:[B.TYPE_STRING]}]},sum:{_func:this.functionSum,_signature:[{types:[B.TYPE_ARRAY_NUMBER]}]},to_array:{_func:this.functionToArray,_signature:[{types:[B.TYPE_ANY]}]},to_number:{_func:this.functionToNumber,_signature:[{types:[B.TYPE_ANY]}]},to_string:{_func:this.functionToString,_signature:[{types:[B.TYPE_ANY]}]},type:{_func:this.functionType,_signature:[{types:[B.TYPE_ANY]}]},values:{_func:this.functionValues,_signature:[{types:[B.TYPE_OBJECT]}]}},this._interpreter=X}registerFunction(X,W,Q){if(X in this.functionTable)throw Error(`Function already defined: ${X}()`);this.functionTable[X]={_func:W.bind(this),_signature:Q}}callFunction(X,W){let Q=this.functionTable[X];if(Q===void 0)throw Error(`Unknown function: ${X}()`);return this.validateArgs(X,W,Q._signature),Q._func.call(this,W)}validateInputSignatures(X,W){for(let Q=0;Q<W.length;Q+=1)if("variadic"in W[Q]&&Q!==W.length-1)throw Error(`ArgumentError: ${X}() 'variadic' argument ${Q+1} must occur last`)}validateArgs(X,W,Q){var G,U;let j;this.validateInputSignatures(X,Q);let L=Q.filter((E)=>{var S;return(S=!E.optional)!==null&&S!==void 0?S:!1}).length,O=(U=(G=Q[Q.length-1])===null||G===void 0?void 0:G.variadic)!==null&&U!==void 0?U:!1,F=W.length<L,P=W.length>Q.length,R=F&&(!O&&L>1||O)?"at least ":"";if(O&&F||!O&&(F||P))throw j=Q.length>1,Error(`ArgumentError: ${X}() takes ${R}${L} argument${j&&"s"||""} but received ${W.length}`);let H,V,T;for(let E=0;E<Q.length;E+=1){T=!1,H=Q[E].types,V=this.getTypeName(W[E]);let S;for(S=0;S<H.length;S+=1)if(V!==void 0&&this.typeMatches(V,H[S],W[E])){T=!0;break}if(!T&&V!==void 0){let p=H.map((d)=>{return this.TYPE_NAME_TABLE[d]}).join(" | ");throw Error(`TypeError: ${X}() expected argument ${E+1} to be type (${p}) but received type ${this.TYPE_NAME_TABLE[V]} instead.`)}}}typeMatches(X,W,Q){if(W===B.TYPE_ANY)return!0;if(W===B.TYPE_ARRAY_STRING||W===B.TYPE_ARRAY_NUMBER||W===B.TYPE_ARRAY){if(W===B.TYPE_ARRAY)return X===B.TYPE_ARRAY;if(X===B.TYPE_ARRAY){let G;if(W===B.TYPE_ARRAY_NUMBER)G=B.TYPE_NUMBER;else if(W===B.TYPE_ARRAY_STRING)G=B.TYPE_STRING;for(let U=0;U<Q.length;U+=1){let j=this.getTypeName(Q[U]);if(j!==void 0&&G!==void 0&&!this.typeMatches(j,G,Q[U]))return!1}return!0}}else return X===W;return!1}getTypeName(X){switch(Object.prototype.toString.call(X)){case"[object String]":return B.TYPE_STRING;case"[object Number]":return B.TYPE_NUMBER;case"[object Array]":return B.TYPE_ARRAY;case"[object Boolean]":return B.TYPE_BOOLEAN;case"[object Null]":return B.TYPE_NULL;case"[object Object]":if(X.jmespathType===z.TOK_EXPREF)return B.TYPE_EXPREF;return B.TYPE_OBJECT;default:return}}createKeyFunction(X,W){if(!this._interpreter)return;let Q=this._interpreter;return(U)=>{let j=Q.visit(X,U);if(!W.includes(this.getTypeName(j))){let L=`TypeError: expected one of (${W.map((O)=>this.TYPE_NAME_TABLE[O]).join(" | ")}), received ${this.TYPE_NAME_TABLE[this.getTypeName(j)]}`;throw Error(L)}return j}}}class V8{constructor(){this._rootValue=null,this.runtime=new M8(this)}search(X,W){return this._rootValue=W,this.visit(X,W)}visit(X,W){let Q,G,U,j,L,O,F,P,R,H,V;switch(X.type){case"Field":if(W===null)return null;if($(W)){if(O=W[X.name],O===void 0)return null;return O}return null;case"Subexpression":U=this.visit(X.children[0],W);for(H=1;H<X.children.length;H+=1)if(U=this.visit(X.children[1],U),U===null)return null;return U;case"IndexExpression":return F=this.visit(X.children[0],W),P=this.visit(X.children[1],F),P;case"Index":if(!Array.isArray(W))return null;let T=X.value;if(T<0)T=W.length+T;if(U=W[T],U===void 0)U=null;return U;case"Slice":if(!Array.isArray(W))return null;let E=[...X.children],S=this.computeSliceParams(W.length,E),[p,d,t]=S;if(U=[],t>0)for(H=p;H<d;H+=t)U.push(W[H]);else for(H=p;H>d;H+=t)U.push(W[H]);return U;case"Projection":if(V=this.visit(X.children[0],W),!Array.isArray(V))return null;R=[];for(H=0;H<V.length;H+=1)if(G=this.visit(X.children[1],V[H]),G!==null)R.push(G);return R;case"ValueProjection":if(V=this.visit(X.children[0],W),!$(V))return null;R=[];let g8=Object.values(V);for(H=0;H<g8.length;H+=1)if(G=this.visit(X.children[1],g8[H]),G!==null)R.push(G);return R;case"FilterProjection":if(V=this.visit(X.children[0],W),!Array.isArray(V))return null;let r=[],c8=[];for(H=0;H<V.length;H+=1)if(Q=this.visit(X.children[2],V[H]),!Y(Q))r.push(V[H]);for(let f=0;f<r.length;f+=1)if(G=this.visit(X.children[1],r[f]),G!==null)c8.push(G);return c8;case"Comparator":switch(j=this.visit(X.children[0],W),L=this.visit(X.children[1],W),X.name){case z.TOK_EQ:U=K(j,L);break;case z.TOK_NE:U=!K(j,L);break;case z.TOK_GT:U=j>L;break;case z.TOK_GTE:U=j>=L;break;case z.TOK_LT:U=j<L;break;case z.TOK_LTE:U=j<=L;break;default:throw Error(`Unknown comparator: ${X.name}`)}return U;case z.TOK_FLATTEN:let e=this.visit(X.children[0],W);if(!Array.isArray(e))return null;let u=[];for(H=0;H<e.length;H+=1)if(G=e[H],Array.isArray(G))u=[...u,...G];else u.push(G);return u;case"Identity":return W;case"MultiSelectList":if(W===null)return null;R=[];for(H=0;H<X.children.length;H+=1)R.push(this.visit(X.children[H],W));return R;case"MultiSelectHash":if(W===null)return null;R={};let Z8;for(H=0;H<X.children.length;H+=1)Z8=X.children[H],R[Z8.name]=this.visit(Z8.value,W);return R;case"OrExpression":if(Q=this.visit(X.children[0],W),Y(Q))Q=this.visit(X.children[1],W);return Q;case"AndExpression":if(j=this.visit(X.children[0],W),Y(j))return j;return this.visit(X.children[1],W);case"NotExpression":return j=this.visit(X.children[0],W),Y(j);case"Literal":return X.value;case z.TOK_PIPE:return F=this.visit(X.children[0],W),this.visit(X.children[1],F);case z.TOK_CURRENT:return W;case z.TOK_ROOT:return this._rootValue;case"Function":let m8=[];for(let f=0;f<X.children.length;f+=1)m8.push(this.visit(X.children[f],W));return this.runtime.callFunction(X.name,m8);case"ExpressionReference":let p8=X.children[0];return p8.jmespathType=z.TOK_EXPREF,p8;default:throw Error(`Unknown node type: ${X.type}`)}}computeSliceParams(X,W){let[Q,G,U]=W;if(U===null)U=1;else if(U===0){let L=Error("Invalid slice, step cannot be 0");throw L.name="RuntimeError",L}let j=U<0?!0:!1;return Q=Q===null?j?X-1:0:this.capSliceRange(X,Q,U),G=G===null?j?-1:X:this.capSliceRange(X,G,U),[Q,G,U]}capSliceRange(X,W,Q){let G=W;if(G<0){if(G+=X,G<0)G=Q<0?-1:0}else if(G>=X)G=Q<0?X-1:X;return G}}let n=new V8,w8=B.TYPE_ANY,_8=B.TYPE_ARRAY,N8=B.TYPE_ARRAY_NUMBER,P8=B.TYPE_ARRAY_STRING,E8=B.TYPE_BOOLEAN,S8=B.TYPE_EXPREF,I8=B.TYPE_NULL,x8=B.TYPE_NUMBER,b8=B.TYPE_OBJECT,A8=B.TYPE_STRING;function T8(X){return R8.parse(X)}function y8(X){return A.tokenize(X)}let f8=(X,W,Q)=>{n.runtime.registerFunction(X,W,Q)};function h8(X,W){let Q=R8.parse(W);return n.search(Q,X)}let k8=n,v8={compile:T8,registerFunction:f8,search:h8,tokenize:y8,TreeInterpreter:k8,TYPE_ANY:w8,TYPE_ARRAY_NUMBER:N8,TYPE_ARRAY_STRING:P8,TYPE_ARRAY:_8,TYPE_BOOLEAN:E8,TYPE_EXPREF:S8,TYPE_NULL:I8,TYPE_NUMBER:x8,TYPE_OBJECT:b8,TYPE_STRING:A8};Z.TYPE_ANY=w8,Z.TYPE_ARRAY=_8,Z.TYPE_ARRAY_NUMBER=N8,Z.TYPE_ARRAY_STRING=P8,Z.TYPE_BOOLEAN=E8,Z.TYPE_EXPREF=S8,Z.TYPE_NULL=I8,Z.TYPE_NUMBER=x8,Z.TYPE_OBJECT=b8,Z.TYPE_STRING=A8,Z.TreeInterpreter=k8,Z.compile=T8,Z.default=v8,Z.jmespath=v8,Z.registerFunction=f8,Z.search=h8,Z.tokenize=y8,Object.defineProperty(Z,"__esModule",{value:!0})})});import{mkdirSync as RZ,mkdtempSync as MZ,writeFileSync as VZ}from"node:fs";import{tmpdir as wZ}from"node:os";import{dirname as _Z,join as L8}from"node:path";import{pathToFileURL as NZ}from"node:url";import{timingSafeEqual as CZ}from"node:crypto";import{createServer as jZ}from"node:http";import{Readable as HZ}from"node:stream";function f9(){return typeof process>"u"?{}:process.env}function d8(Z=f9()){return Z.MCP_BEARER_TOKEN?.trim()||null}import{existsSync as UZ}from"node:fs";i();async function B9(Z){let $=D8(await Z),[K,Y,{QuickJSWASMModule:J}]=await Promise.all([$.importModuleLoader().then(D8),$.importFFI(),Promise.resolve().then(() => (J9(),G9)).then(D8)]),q=await K();q.type="sync";let C=new Y(q);return new J(q,C)}function D8(Z){return Z&&"default"in Z&&Z.default?Z.default&&"default"in Z.default&&Z.default.default?Z.default.default:Z.default:Z}var q9="engine";function XZ(Z){let $=(K)=>new URL(K,Z).href;return{type:"sync",importFFI:()=>import($("ffi.mjs")).then((K)=>K.QuickJSFFI),importModuleLoader:()=>import($("emscripten-module.mjs")).then((K)=>K.default)}}var U9=null;function C9(Z){return()=>{return U9??=B9(XZ(Z)),U9}}var WZ=x9(H9(),1);var YZ="__mcpcloud_call_tool",w1=`globalThis.tool = (name, args) =>
|
|
8
|
+
globalThis.${YZ}(String(name), JSON.stringify(args ?? {}))
|
|
9
|
+
.then((json) => JSON.parse(json));`;var QZ=6,GZ=["log","warn","error","info","debug"],JZ="__mcpcloud_console",P1=`globalThis.console = {
|
|
10
|
+
${GZ.map((Z)=>` ${Z}: (...args) => globalThis.${JZ}(${JSON.stringify(Z)}, JSON.stringify(args.slice(0, ${QZ}).map((value) => (value instanceof Error ? { __mcpcloudError: value.name + ': ' + value.message } : value)))),`).join(`
|
|
11
|
+
`)}
|
|
12
|
+
};`;var BZ=null;function D9(Z){BZ=Z}var L9=[`./${q9}/`,"../engine/vendor/","../../engine/vendor/"];function qZ(Z=new URL(import.meta.url)){for(let $ of L9){let K=new URL($,Z);if(UZ(new URL("emscripten-module.wasm",K)))return K}throw Error(`Code Mode engine not found. Looked for emscripten-module.wasm in: ${L9.join(", ")} (relative to ${Z.href}).`)}function O9(){D9(()=>C9(qZ())())}function DZ(Z,$){let K=Buffer.from(Z),Y=Buffer.from($);return K.length===Y.length&&CZ(K,Y)}function LZ(Z,$){let K=d8($);if(!K)return null;if(new URL(Z.url).pathname==="/health")return null;let Y=Z.headers.get("authorization")??"",J=/^Bearer\s+(.+)$/i.exec(Y.trim());if(J&&DZ(J[1].trim(),K))return null;return Response.json({error:"unauthorized",message:"This MCP endpoint requires a bearer token (set in Authorization: Bearer <token>)."},{status:401,headers:{"www-authenticate":"Bearer"}})}function OZ(Z,$){let K=new URL(Z.url??"/",$),Y=new Headers;for(let[C,z]of Object.entries(Z.headers))if(Array.isArray(z))for(let D of z)Y.append(C,D);else if(typeof z==="string")Y.set(C,z);let J=Z.method??"GET",q=J==="GET"||J==="HEAD"?void 0:HZ.toWeb(Z);return new Request(K,{method:J,headers:Y,body:q,...q?{duplex:"half"}:{}})}async function FZ(Z,$){if($.statusCode=Z.status,Z.headers.forEach((Y,J)=>{$.setHeader(J,Y)}),!Z.body){$.end();return}let K=Z.body.getReader();for(;;){let{done:Y,value:J}=await K.read();if(Y)break;$.write(J)}$.end()}function F9(Z,$={}){O9();let K=$.port??Number(process.env.PORT??8080),Y=$.hostname??"0.0.0.0",J=jZ((q,C)=>{let z=`http://${q.headers.host??`${Y}:${K}`}`,D=OZ(q,z),N=LZ(D,$.env);(N?Promise.resolve(N):Z.handleRequest(D,$.env)).then((M)=>FZ(M,C)).catch(()=>{C.statusCode=500,C.end(JSON.stringify({error:"internal_error"}))})});return J.listen(K,Y),J}var O8=1;function R9(Z=process.env){let $=Z.BUNDLE_URL?.trim(),K=Z.BUNDLE_SHA256?.trim();if(!$)throw Error("BUNDLE_URL is not set; the runtime host has no code to run.");if(!K)throw Error("BUNDLE_SHA256 is not set; refusing to boot unverified code.");let Y=Number(Z.PORT??8080);if(!Number.isInteger(Y)||Y<=0)throw Error(`Invalid PORT: ${String(Z.PORT)}`);return{bundleUrl:$,bundleSha256:K,port:Y}}async function PZ(Z){let $=Z.buffer.slice(Z.byteOffset,Z.byteOffset+Z.byteLength),K=await crypto.subtle.digest("SHA-256",$);return Array.from(new Uint8Array(K)).map((Y)=>Y.toString(16).padStart(2,"0")).join("")}function EZ(Z){let $=JSON.parse(new TextDecoder().decode(Z));if(!$||typeof $!=="object")throw Error("Boot artifact must be a JSON object.");let K=$;if(K.schemaVersion!==O8)throw Error(`Unsupported boot artifact schemaVersion: ${String(K.schemaVersion)}.`);if(typeof K.runtimeVersion!=="string"||typeof K.mainEntry!=="string"||!Array.isArray(K.files))throw Error("Boot artifact is malformed.");let Y=K.files.map((J)=>{if(!J||typeof J!=="object"||typeof J.path!=="string"||typeof J.content!=="string")throw Error("Boot artifact files must be { path, content }.");let q=J;return{path:q.path,content:q.content}});return{schemaVersion:O8,runtimeVersion:K.runtimeVersion,mainEntry:K.mainEntry,files:Y}}async function M9(Z,$=fetch){let K=await $(Z.bundleUrl);if(!K.ok)throw Error(`Bundle fetch failed (HTTP ${K.status}).`);let Y=new Uint8Array(await K.arrayBuffer()),J=await PZ(Y);if(J!==Z.bundleSha256.toLowerCase())throw Error(`Bundle sha256 mismatch (expected ${Z.bundleSha256}, got ${J}).`);return EZ(Y)}function V9(Z,$){for(let K of Z.files){let Y=L8($,K.path);RZ(_Z(Y),{recursive:!0}),VZ(Y,K.content)}return{entryPath:L8($,Z.mainEntry)}}async function SZ(Z={}){let $=Z.bootConfig??R9(),K=await M9($,Z.fetchImpl),Y=Z.workDir??MZ(L8(wZ(),"mcpcloud-server-")),{entryPath:J}=V9(K,Y),q=await import(NZ(J).href),C=q.server??q.default;if(!C)throw Error(`Boot module ${K.mainEntry} does not export a \`server\`.`);let z={port:$.port,...Z.hostname?{hostname:Z.hostname}:{},...Z.env?{env:Z.env}:{}};return F9(C,z)}export{SZ as serveFromBundle,R9 as resolveBootConfig,V9 as materializeBundle,M9 as fetchAndVerifyBundle,O8 as BOOT_ARTIFACT_SCHEMA_VERSION};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var QuickJSRaw=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var c=moduleArg;function n(a){a={log:a||function(){}};for(const d of n.Qa)d(a);return c.quickJSEmscriptenExtensions=a}n.Qa=[];c.quickjsEmscriptenInit=n;n.Qa.push(a=>{a.getWasmMemory=function(){return q}});var r="./this.program",t="",u;try{t=(new URL(".",_scriptName)).href}catch{}u=async a=>{a=await fetch(a,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+" : "+a.url);};var v=console.log.bind(console),w=console.error.bind(console),y,z=!1,A,B,C,D,E,F,G,H,I=!1;
|
|
2
|
+
function J(){var a=q.buffer;c.HEAP8=D=new Int8Array(a);new Int16Array(a);c.HEAPU8=E=new Uint8Array(a);new Uint16Array(a);F=new Int32Array(a);G=new Uint32Array(a);new Float32Array(a);new Float64Array(a);H=new BigInt64Array(a);new BigUint64Array(a)}function K(a){c.onAbort?.(a);a="Aborted("+a+")";w(a);z=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");C?.(a);throw a;}var L;
|
|
3
|
+
async function aa(a){if(!y)try{var d=await u(a);return new Uint8Array(d)}catch{}if(a==L&&y)a=new Uint8Array(y);else throw"both async and sync fetching of the wasm failed";return a}async function ba(a,d){try{var b=await aa(a);return await WebAssembly.instantiate(b,d)}catch(e){w(`failed to asynchronously prepare wasm: ${e}`),K(e)}}
|
|
4
|
+
async function ca(a){var d=L;if(!y)try{var b=fetch(d,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(b,a)}catch(e){w(`wasm streaming compile failed: ${e}`),w("falling back to ArrayBuffer instantiation")}return ba(d,a)}class M{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
|
|
5
|
+
var N=a=>{for(;0<a.length;)a.shift()(c)},O=[],P=[],da=()=>{var a=c.preRun.shift();P.push(a)},Q=!0,q,ea=new TextDecoder,fa=(a,d,b,e)=>{b=d+b;if(e)return b;for(;a[d]&&!(d>=b);)++d;return d},R=(a,d,b)=>a?ea.decode(E.subarray(a,fa(E,a,d,b))):"",S=0,ha=[0,31,60,91,121,152,182,213,244,274,305,335],ia=[0,31,59,90,120,151,181,212,243,273,304,334],T={},ja=a=>{if(!(a instanceof M||"unwind"==a))throw a;},ka=a=>{A=a;Q||0<S||(c.onExit?.(a),z=!0);throw new M(a);},la=a=>{if(!z)try{a()}catch(d){ja(d)}finally{if(!(Q||
|
|
6
|
+
0<S))try{A=a=A,ka(a)}catch(d){ja(d)}}},U=(a,d,b)=>{var e=E;if(!(0<b))return 0;var f=d;b=d+b-1;for(var g=0;g<a.length;++g){var h=a.codePointAt(g);if(127>=h){if(d>=b)break;e[d++]=h}else if(2047>=h){if(d+1>=b)break;e[d++]=192|h>>6;e[d++]=128|h&63}else if(65535>=h){if(d+2>=b)break;e[d++]=224|h>>12;e[d++]=128|h>>6&63;e[d++]=128|h&63}else{if(d+3>=b)break;e[d++]=240|h>>18;e[d++]=128|h>>12&63;e[d++]=128|h>>6&63;e[d++]=128|h&63;g++}}e[d]=0;return d-f},V={},ma=()=>{if(!W){var a={USER:"web_user",LOGNAME:"web_user",
|
|
7
|
+
PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:r||"./this.program"},d;for(d in V)void 0===V[d]?delete a[d]:a[d]=V[d];var b=[];for(d in a)b.push(`${d}=${a[d]}`);W=b}return W},W,X=a=>{for(var d=0,b=0;b<a.length;++b){var e=a.charCodeAt(b);127>=e?d++:2047>=e?d+=2:55296<=e&&57343>=e?(d+=4,++b):d+=3}return d},na=[null,[],[]],qa=(a,d,b,e)=>{var f={string:k=>{var l=0;if(null!==k&&void 0!==k&&0!==k){l=X(k)+1;var p=Y(l);U(k,p,l);l=p}return l},array:k=>
|
|
8
|
+
{var l=Y(k.length);D.set(k,l);return l}};a=c["_"+a];var g=[],h=0;if(e)for(var m=0;m<e.length;m++){var x=f[b[m]];x?(0===h&&(h=oa()),g[m]=x(e[m])):g[m]=e[m]}b=a(...g);return b=function(k){0!==h&&pa(h);return"string"===d?R(k):"boolean"===d?!!k:k}(b)};c.wasmMemory?q=c.wasmMemory:q=new WebAssembly.Memory({initial:(c.INITIAL_MEMORY||16777216)/65536,maximum:32768});J();c.noExitRuntime&&(Q=c.noExitRuntime);c.print&&(v=c.print);c.printErr&&(w=c.printErr);c.wasmBinary&&(y=c.wasmBinary);c.thisProgram&&(r=c.thisProgram);
|
|
9
|
+
if(c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.shift()();c.cwrap=(a,d,b,e)=>{var f=!b||b.every(g=>"number"===g||"boolean"===g);return"string"!==d&&f&&!e?c["_"+a]:(...g)=>qa(a,d,b,g)};c.UTF8ToString=R;c.stringToUTF8=(a,d,b)=>U(a,d,b);c.lengthBytesUTF8=X;
|
|
10
|
+
var ra,pa,Y,oa,sa={b:(a,d,b,e)=>K(`Assertion failed: ${R(a)}, at: `+[d?R(d):"unknown filename",b,e?R(e):"unknown function"]),r:()=>K(""),l:()=>{Q=!1;S=0},m:function(a,d){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);a=new Date(1E3*a);F[d>>2]=a.getSeconds();F[d+4>>2]=a.getMinutes();F[d+8>>2]=a.getHours();F[d+12>>2]=a.getDate();F[d+16>>2]=a.getMonth();F[d+20>>2]=a.getFullYear()-1900;F[d+24>>2]=a.getDay();var b=a.getFullYear();F[d+28>>2]=(0!==b%4||0===b%100&&0!==b%400?ia:ha)[a.getMonth()]+
|
|
11
|
+
a.getDate()-1|0;F[d+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();var e=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();F[d+32>>2]=(b!=e&&a.getTimezoneOffset()==Math.min(e,b))|0},j:(a,d)=>{T[a]&&(clearTimeout(T[a].id),delete T[a]);if(!d)return 0;var b=setTimeout(()=>{delete T[a];la(()=>ra(a,performance.now()))},d);T[a]={id:b,Ra:d};return 0},n:(a,d,b,e)=>{var f=(new Date).getFullYear(),g=(new Date(f,0,1)).getTimezoneOffset();f=(new Date(f,6,1)).getTimezoneOffset();
|
|
12
|
+
G[a>>2]=60*Math.max(g,f);F[d>>2]=Number(g!=f);d=h=>{var m=Math.abs(h);return`UTC${0<=h?"-":"+"}${String(Math.floor(m/60)).padStart(2,"0")}${String(m%60).padStart(2,"0")}`};a=d(g);d=d(f);f<g?(U(a,b,17),U(d,e,17)):(U(a,e,17),U(d,b,17))},q:function(a,d,b){if(!(0<=a&&3>=a))return 28;H[b>>3]=BigInt(Math.round(1E6*(0===a?Date.now():performance.now())));return 0},p:()=>Date.now(),k:a=>{var d=E.length;a>>>=0;if(2147483648<a)return!1;for(var b=1;4>=b;b*=2){var e=d*(1+.2/b);e=Math.min(e,a+100663296);a:{e=(Math.min(2147483648,
|
|
13
|
+
65536*Math.ceil(Math.max(a,e)/65536))-q.buffer.byteLength+65535)/65536|0;try{q.grow(e);J();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},e:(a,d)=>{var b=0,e=0,f;for(f of ma()){var g=d+b;G[a+e>>2]=g;b+=U(f,g,Infinity)+1;e+=4}return 0},f:(a,d)=>{var b=ma();G[a>>2]=b.length;a=0;for(var e of b)a+=X(e)+1;G[d>>2]=a;return 0},d:()=>52,o:function(){return 70},c:(a,d,b,e)=>{for(var f=0,g=0;g<b;g++){var h=G[d>>2],m=G[d+4>>2];d+=8;for(var x=0;x<m;x++){var k=a,l=E[h+x],p=na[k];0===l||10===l?(k=1===
|
|
14
|
+
k?v:w,l=fa(p,0),l=ea.decode(p.buffer?p.subarray(0,l):new Uint8Array(p.slice(0,l))),k(l),p.length=0):p.push(l)}f+=m}G[e>>2]=f;return 0},a:q,s:ka,t:function(a,d,b,e,f){return c.callbacks.callFunction(void 0,a,d,b,e,f)},i:function(a){return c.callbacks.shouldInterrupt(void 0,a)},h:function(a,d,b){b=R(b);return c.callbacks.loadModuleSource(void 0,a,d,b)},g:function(a,d,b,e){b=R(b);e=R(e);return c.callbacks.normalizeModule(void 0,a,d,b,e)},u:function(a,d){c.callbacks.freeHostRef(void 0,a,d)}},Z;
|
|
15
|
+
Z=await (async function(){function a(b){b=Z=b.exports;c._malloc=b.w;c._QTS_Throw=b.x;c._QTS_NewError=b.y;c._QTS_RuntimeSetMemoryLimit=b.z;c._QTS_RuntimeComputeMemoryUsage=b.A;c._QTS_RuntimeDumpMemoryUsage=b.B;c._QTS_RecoverableLeakCheck=b.C;c._QTS_BuildIsSanitizeLeak=b.D;c._QTS_RuntimeSetMaxStackSize=b.E;c._QTS_GetUndefined=b.F;c._QTS_GetNull=b.G;c._QTS_GetFalse=b.H;c._QTS_GetTrue=b.I;c._QTS_NewHostRef=b.J;c._QTS_GetHostRefId=b.K;c._QTS_NewRuntime=b.L;c._QTS_FreeRuntime=b.M;c._free=b.N;
|
|
16
|
+
c._QTS_NewContext=b.O;c._QTS_FreeContext=b.P;c._QTS_FreeValuePointer=b.Q;c._QTS_FreeValuePointerRuntime=b.R;c._QTS_FreeVoidPointer=b.S;c._QTS_FreeCString=b.T;c._QTS_DupValuePointer=b.U;c._QTS_NewObject=b.V;c._QTS_NewObjectProto=b.W;c._QTS_NewArray=b.X;c._QTS_NewArrayBuffer=b.Y;c._QTS_NewFloat64=b.Z;c._QTS_GetFloat64=b._;c._QTS_NewString=b.$;c._QTS_GetString=b.aa;c._QTS_GetArrayBuffer=b.ba;c._QTS_GetArrayBufferLength=b.ca;c._QTS_NewSymbol=b.da;c._QTS_GetSymbolDescriptionOrKey=b.ea;c._QTS_IsGlobalSymbol=
|
|
17
|
+
b.fa;c._QTS_IsJobPending=b.ga;c._QTS_ExecutePendingJob=b.ha;c._QTS_GetProp=b.ia;c._QTS_GetPropNumber=b.ja;c._QTS_SetProp=b.ka;c._QTS_DefineProp=b.la;c._QTS_GetOwnPropertyNames=b.ma;c._QTS_Call=b.na;c._QTS_ResolveException=b.oa;c._QTS_Dump=b.pa;c._QTS_Eval=b.qa;c._QTS_GetModuleNamespace=b.ra;c._QTS_Typeof=b.sa;c._QTS_GetLength=b.ta;c._QTS_IsEqual=b.ua;c._QTS_GetGlobalObject=b.va;c._QTS_NewPromiseCapability=b.wa;c._QTS_PromiseState=b.xa;c._QTS_PromiseResult=b.ya;c._QTS_TestStringArg=b.za;c._QTS_GetDebugLogEnabled=
|
|
18
|
+
b.Aa;c._QTS_SetDebugLogEnabled=b.Ba;c._QTS_BuildIsDebug=b.Ca;c._QTS_BuildIsAsyncify=b.Da;c._QTS_NewFunction=b.Ea;c._QTS_ArgvGetJSValueConstPointer=b.Fa;c._QTS_RuntimeEnableInterruptHandler=b.Ga;c._QTS_RuntimeDisableInterruptHandler=b.Ha;c._QTS_RuntimeEnableModuleLoader=b.Ia;c._QTS_RuntimeDisableModuleLoader=b.Ja;c._QTS_bjson_encode=b.Ka;c._QTS_bjson_decode=b.La;ra=b.Ma;pa=b.Na;Y=b.Oa;oa=b.Pa;return Z}var d={a:sa};if(c.instantiateWasm)return new Promise(b=>{c.instantiateWasm(d,(e,f)=>{b(a(e,f))})});
|
|
19
|
+
L??=c.locateFile?c.locateFile("emscripten-module.wasm",t):t+"emscripten-module.wasm";return a((await ca(d)).instance)}());
|
|
20
|
+
(function(){function a(){c.calledRun=!0;if(!z){I=!0;Z.v();B?.(c);c.onRuntimeInitialized?.();if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;){var d=c.postRun.shift();O.push(d)}N(O)}}if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)da();N(P);c.setStatus?(c.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>c.setStatus(""),1);a()},1)):a()})();I?moduleRtn=c:moduleRtn=new Promise((a,d)=>{B=a;C=d});
|
|
21
|
+
;return moduleRtn}})();if(typeof exports==="object"&&typeof module==="object"){module.exports=QuickJSRaw;module.exports.default=QuickJSRaw}else if(typeof define==="function"&&define["amd"])define([],()=>QuickJSRaw);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Generated from upstream/templates/emscripten-module.SYNC.d.ts
|
|
2
|
+
import type { EmscriptenModuleLoader, QuickJSEmscriptenModule } from "@jitl/quickjs-ffi-types"
|
|
3
|
+
/**
|
|
4
|
+
* Emscripten module built from the unmodified [`quickjs/quickjs.h`](../quickjs/quickjs.h)
|
|
5
|
+
* and our FFI support functions [c/interface.c](../c/interface.c).
|
|
6
|
+
*
|
|
7
|
+
* Note that emscripten modules returned by a `MODULARIZE=1` emscripten build
|
|
8
|
+
* (like this one) load asynchronously.
|
|
9
|
+
*/
|
|
10
|
+
declare const ModuleLoader: EmscriptenModuleLoader<QuickJSEmscriptenModule>
|
|
11
|
+
export default ModuleLoader
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
async function QuickJSRaw(moduleArg={}){var moduleRtn;var d=moduleArg,aa=!!globalThis.window,n=!!globalThis.WorkerGlobalScope,q=globalThis.process?.versions?.node&&"renderer"!=globalThis.process?.type;if(q){const {createRequire:a}=await import("node:module");var require=a(import.meta.url)}function r(a){a={log:a||function(){}};for(const c of r.Qa)c(a);return d.quickJSEmscriptenExtensions=a}r.Qa=[];d.quickjsEmscriptenInit=r;r.Qa.push(a=>{a.getWasmMemory=function(){return t}});
|
|
2
|
+
var u="./this.program",v=(a,c)=>{throw c;},w=import.meta.url,y="",z,A;
|
|
3
|
+
if(q){var fs=require("node:fs");w.startsWith("file:")&&(y=require("node:path").dirname(require("node:url").fileURLToPath(w))+"/");A=a=>{a=B(a)?new URL(a):a;return fs.readFileSync(a)};z=async a=>{a=B(a)?new URL(a):a;return fs.readFileSync(a,void 0)};1<process.argv.length&&(u=process.argv[1].replace(/\\/g,"/"));process.argv.slice(2);v=(a,c)=>{process.exitCode=a;throw c;}}else if(aa||n){try{y=(new URL(".",w)).href}catch{}n&&(A=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.responseType="arraybuffer";
|
|
4
|
+
c.send(null);return new Uint8Array(c.response)});z=async a=>{if(B(a))return new Promise((b,e)=>{var f=new XMLHttpRequest;f.open("GET",a,!0);f.responseType="arraybuffer";f.onload=()=>{200==f.status||0==f.status&&f.response?b(f.response):e(f.status)};f.onerror=e;f.send(null)});var c=await fetch(a,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw Error(c.status+" : "+c.url);}}
|
|
5
|
+
var C=console.log.bind(console),D=console.error.bind(console),E,F=!1,G,B=a=>a.startsWith("file://"),H,I,J,K,L,M,ba,ca=!1;function da(){var a=t.buffer;d.HEAP8=J=new Int8Array(a);new Int16Array(a);d.HEAPU8=K=new Uint8Array(a);new Uint16Array(a);L=new Int32Array(a);M=new Uint32Array(a);new Float32Array(a);new Float64Array(a);ba=new BigInt64Array(a);new BigUint64Array(a)}
|
|
6
|
+
function N(a){d.onAbort?.(a);a="Aborted("+a+")";D(a);F=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");I?.(a);throw a;}var O;async function ea(a){if(!E)try{var c=await z(a);return new Uint8Array(c)}catch{}if(a==O&&E)a=new Uint8Array(E);else if(A)a=A(a);else throw"both async and sync fetching of the wasm failed";return a}
|
|
7
|
+
async function fa(a,c){try{var b=await ea(a);return await WebAssembly.instantiate(b,c)}catch(e){D(`failed to asynchronously prepare wasm: ${e}`),N(e)}}async function ha(a){var c=O;if(!E&&!B(c)&&!q)try{var b=fetch(c,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(b,a)}catch(e){D(`wasm streaming compile failed: ${e}`),D("falling back to ArrayBuffer instantiation")}return fa(c,a)}
|
|
8
|
+
class P{name="ExitStatus";constructor(a){this.message=`Program terminated with exit(${a})`;this.status=a}}
|
|
9
|
+
var ia=a=>{for(;0<a.length;)a.shift()(d)},ja=[],ka=[],la=()=>{var a=d.preRun.shift();ka.push(a)},Q=!0,t,ma=new TextDecoder,na=(a,c,b,e)=>{b=c+b;if(e)return b;for(;a[c]&&!(c>=b);)++c;return c},R=(a,c,b)=>a?ma.decode(K.subarray(a,na(K,a,c,b))):"",S=0,oa=[0,31,60,91,121,152,182,213,244,274,305,335],pa=[0,31,59,90,120,151,181,212,243,273,304,334],T={},qa=a=>{G=a;Q||0<S||(d.onExit?.(a),F=!0);v(a,new P(a))},ra=a=>{if(!F)try{a()}catch(c){c instanceof P||"unwind"==c||v(1,c)}finally{if(!(Q||0<S))try{G=a=G,
|
|
10
|
+
qa(a)}catch(c){c instanceof P||"unwind"==c||v(1,c)}}},U=(a,c,b)=>{var e=K;if(!(0<b))return 0;var f=c;b=c+b-1;for(var g=0;g<a.length;++g){var h=a.codePointAt(g);if(127>=h){if(c>=b)break;e[c++]=h}else if(2047>=h){if(c+1>=b)break;e[c++]=192|h>>6;e[c++]=128|h&63}else if(65535>=h){if(c+2>=b)break;e[c++]=224|h>>12;e[c++]=128|h>>6&63;e[c++]=128|h&63}else{if(c+3>=b)break;e[c++]=240|h>>18;e[c++]=128|h>>12&63;e[c++]=128|h>>6&63;e[c++]=128|h&63;g++}}e[c]=0;return c-f},V={},sa=()=>{if(!W){var a={USER:"web_user",
|
|
11
|
+
LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:u||"./this.program"},c;for(c in V)void 0===V[c]?delete a[c]:a[c]=V[c];var b=[];for(c in a)b.push(`${c}=${a[c]}`);W=b}return W},W,X=a=>{for(var c=0,b=0;b<a.length;++b){var e=a.charCodeAt(b);127>=e?c++:2047>=e?c+=2:55296<=e&&57343>=e?(c+=4,++b):c+=3}return c},ta=[null,[],[]],wa=(a,c,b,e)=>{var f={string:k=>{var l=0;if(null!==k&&void 0!==k&&0!==k){l=X(k)+1;var p=Y(l);U(k,p,
|
|
12
|
+
l);l=p}return l},array:k=>{var l=Y(k.length);J.set(k,l);return l}};a=d["_"+a];var g=[],h=0;if(e)for(var m=0;m<e.length;m++){var x=f[b[m]];x?(0===h&&(h=ua()),g[m]=x(e[m])):g[m]=e[m]}b=a(...g);return b=function(k){0!==h&&va(h);return"string"===c?R(k):"boolean"===c?!!k:k}(b)};d.wasmMemory?t=d.wasmMemory:t=new WebAssembly.Memory({initial:(d.INITIAL_MEMORY||16777216)/65536,maximum:32768});da();d.noExitRuntime&&(Q=d.noExitRuntime);d.print&&(C=d.print);d.printErr&&(D=d.printErr);d.wasmBinary&&(E=d.wasmBinary);
|
|
13
|
+
d.thisProgram&&(u=d.thisProgram);if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.shift()();d.cwrap=(a,c,b,e)=>{var f=!b||b.every(g=>"number"===g||"boolean"===g);return"string"!==c&&f&&!e?d["_"+a]:(...g)=>wa(a,c,b,g)};d.UTF8ToString=R;d.stringToUTF8=(a,c,b)=>U(a,c,b);d.lengthBytesUTF8=X;
|
|
14
|
+
var xa,va,Y,ua,ya={b:(a,c,b,e)=>N(`Assertion failed: ${R(a)}, at: `+[c?R(c):"unknown filename",b,e?R(e):"unknown function"]),r:()=>N(""),l:()=>{Q=!1;S=0},m:function(a,c){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);a=new Date(1E3*a);L[c>>2]=a.getSeconds();L[c+4>>2]=a.getMinutes();L[c+8>>2]=a.getHours();L[c+12>>2]=a.getDate();L[c+16>>2]=a.getMonth();L[c+20>>2]=a.getFullYear()-1900;L[c+24>>2]=a.getDay();var b=a.getFullYear();L[c+28>>2]=(0!==b%4||0===b%100&&0!==b%400?pa:oa)[a.getMonth()]+
|
|
15
|
+
a.getDate()-1|0;L[c+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),6,1)).getTimezoneOffset();var e=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();L[c+32>>2]=(b!=e&&a.getTimezoneOffset()==Math.min(e,b))|0},j:(a,c)=>{T[a]&&(clearTimeout(T[a].id),delete T[a]);if(!c)return 0;var b=setTimeout(()=>{delete T[a];ra(()=>xa(a,performance.now()))},c);T[a]={id:b,Ra:c};return 0},n:(a,c,b,e)=>{var f=(new Date).getFullYear(),g=(new Date(f,0,1)).getTimezoneOffset();f=(new Date(f,6,1)).getTimezoneOffset();
|
|
16
|
+
M[a>>2]=60*Math.max(g,f);L[c>>2]=Number(g!=f);c=h=>{var m=Math.abs(h);return`UTC${0<=h?"-":"+"}${String(Math.floor(m/60)).padStart(2,"0")}${String(m%60).padStart(2,"0")}`};a=c(g);c=c(f);f<g?(U(a,b,17),U(c,e,17)):(U(a,e,17),U(c,b,17))},q:function(a,c,b){if(!(0<=a&&3>=a))return 28;ba[b>>3]=BigInt(Math.round(1E6*(0===a?Date.now():performance.now())));return 0},p:()=>Date.now(),k:a=>{var c=K.length;a>>>=0;if(2147483648<a)return!1;for(var b=1;4>=b;b*=2){var e=c*(1+.2/b);e=Math.min(e,a+100663296);a:{e=
|
|
17
|
+
(Math.min(2147483648,65536*Math.ceil(Math.max(a,e)/65536))-t.buffer.byteLength+65535)/65536|0;try{t.grow(e);da();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},e:(a,c)=>{var b=0,e=0,f;for(f of sa()){var g=c+b;M[a+e>>2]=g;b+=U(f,g,Infinity)+1;e+=4}return 0},f:(a,c)=>{var b=sa();M[a>>2]=b.length;a=0;for(var e of b)a+=X(e)+1;M[c>>2]=a;return 0},d:()=>52,o:function(){return 70},c:(a,c,b,e)=>{for(var f=0,g=0;g<b;g++){var h=M[c>>2],m=M[c+4>>2];c+=8;for(var x=0;x<m;x++){var k=a,l=K[h+x],p=ta[k];
|
|
18
|
+
0===l||10===l?(k=1===k?C:D,l=na(p,0),l=ma.decode(p.buffer?p.subarray(0,l):new Uint8Array(p.slice(0,l))),k(l),p.length=0):p.push(l)}f+=m}M[e>>2]=f;return 0},a:t,s:qa,t:function(a,c,b,e,f){return d.callbacks.callFunction(void 0,a,c,b,e,f)},i:function(a){return d.callbacks.shouldInterrupt(void 0,a)},h:function(a,c,b){b=R(b);return d.callbacks.loadModuleSource(void 0,a,c,b)},g:function(a,c,b,e){b=R(b);e=R(e);return d.callbacks.normalizeModule(void 0,a,c,b,e)},u:function(a,c){d.callbacks.freeHostRef(void 0,
|
|
19
|
+
a,c)}},Z;
|
|
20
|
+
Z=await (async function(){function a(b){b=Z=b.exports;d._malloc=b.w;d._QTS_Throw=b.x;d._QTS_NewError=b.y;d._QTS_RuntimeSetMemoryLimit=b.z;d._QTS_RuntimeComputeMemoryUsage=b.A;d._QTS_RuntimeDumpMemoryUsage=b.B;d._QTS_RecoverableLeakCheck=b.C;d._QTS_BuildIsSanitizeLeak=b.D;d._QTS_RuntimeSetMaxStackSize=b.E;d._QTS_GetUndefined=b.F;d._QTS_GetNull=b.G;d._QTS_GetFalse=b.H;d._QTS_GetTrue=b.I;d._QTS_NewHostRef=b.J;d._QTS_GetHostRefId=b.K;d._QTS_NewRuntime=b.L;d._QTS_FreeRuntime=b.M;d._free=b.N;
|
|
21
|
+
d._QTS_NewContext=b.O;d._QTS_FreeContext=b.P;d._QTS_FreeValuePointer=b.Q;d._QTS_FreeValuePointerRuntime=b.R;d._QTS_FreeVoidPointer=b.S;d._QTS_FreeCString=b.T;d._QTS_DupValuePointer=b.U;d._QTS_NewObject=b.V;d._QTS_NewObjectProto=b.W;d._QTS_NewArray=b.X;d._QTS_NewArrayBuffer=b.Y;d._QTS_NewFloat64=b.Z;d._QTS_GetFloat64=b._;d._QTS_NewString=b.$;d._QTS_GetString=b.aa;d._QTS_GetArrayBuffer=b.ba;d._QTS_GetArrayBufferLength=b.ca;d._QTS_NewSymbol=b.da;d._QTS_GetSymbolDescriptionOrKey=b.ea;d._QTS_IsGlobalSymbol=
|
|
22
|
+
b.fa;d._QTS_IsJobPending=b.ga;d._QTS_ExecutePendingJob=b.ha;d._QTS_GetProp=b.ia;d._QTS_GetPropNumber=b.ja;d._QTS_SetProp=b.ka;d._QTS_DefineProp=b.la;d._QTS_GetOwnPropertyNames=b.ma;d._QTS_Call=b.na;d._QTS_ResolveException=b.oa;d._QTS_Dump=b.pa;d._QTS_Eval=b.qa;d._QTS_GetModuleNamespace=b.ra;d._QTS_Typeof=b.sa;d._QTS_GetLength=b.ta;d._QTS_IsEqual=b.ua;d._QTS_GetGlobalObject=b.va;d._QTS_NewPromiseCapability=b.wa;d._QTS_PromiseState=b.xa;d._QTS_PromiseResult=b.ya;d._QTS_TestStringArg=b.za;d._QTS_GetDebugLogEnabled=
|
|
23
|
+
b.Aa;d._QTS_SetDebugLogEnabled=b.Ba;d._QTS_BuildIsDebug=b.Ca;d._QTS_BuildIsAsyncify=b.Da;d._QTS_NewFunction=b.Ea;d._QTS_ArgvGetJSValueConstPointer=b.Fa;d._QTS_RuntimeEnableInterruptHandler=b.Ga;d._QTS_RuntimeDisableInterruptHandler=b.Ha;d._QTS_RuntimeEnableModuleLoader=b.Ia;d._QTS_RuntimeDisableModuleLoader=b.Ja;d._QTS_bjson_encode=b.Ka;d._QTS_bjson_decode=b.La;xa=b.Ma;va=b.Na;Y=b.Oa;ua=b.Pa;return Z}var c={a:ya};if(d.instantiateWasm)return new Promise(b=>{d.instantiateWasm(c,(e,f)=>{b(a(e,f))})});
|
|
24
|
+
O??=d.locateFile?d.locateFile?d.locateFile("emscripten-module.wasm",y):y+"emscripten-module.wasm":(new URL("emscripten-module.wasm",import.meta.url)).href;return a((await ha(c)).instance)}());
|
|
25
|
+
(function(){function a(){d.calledRun=!0;if(!F){ca=!0;Z.v();H?.(d);d.onRuntimeInitialized?.();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var c=d.postRun.shift();ja.push(c)}ia(ja)}}if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)la();ia(ka);d.setStatus?(d.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>d.setStatus(""),1);a()},1)):a()})();ca?moduleRtn=d:moduleRtn=new Promise((a,c)=>{H=a;I=c});
|
|
26
|
+
;return moduleRtn}export default QuickJSRaw;
|
|
Binary file
|