@uptimizr/playcanvas 0.2.5 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,4 +55,4 @@ ${s}`:s:"",l=Function,d=`return (input) => {
55
55
  ${s}
56
56
  }`,f;try{f=new l(...a,d)(...c)}catch(m){throw new R(`this schema (generated code failed to evaluate: ${m.message})`)}return n?.debug&&(f.code=u),f}function N(e,n){for(let[o,t]of e.constants)if(t===n)return o;let i=`c${e.constantCounter++}`;return e.constants.set(i,n),i}function T(e){return`v${e.varCounter++}`}function J$(e,n){let i=e._zod.run({value:n,issues:[]},{});if(i&&typeof i.then=="function")return xe;let o=i;return o.issues.length===0?o.value:xe}function le(e,n,i,o,t=!0){let r=e.content.length,a=n.constants.size,c=n.constantCounter,s=n.varCounter;try{return Q(e,n,i,o,t)}catch(u){if(!(u instanceof R)||!u.islandable)throw u;if(e.content.length=r,n.constants.size>a){let l=Array.from(n.constants.keys()).slice(a);for(let d of l)n.constants.delete(d)}return n.constantCounter=c,n.varCounter=s,G$(e,n,i,o)}}function G$(e,n,i,o){let t=N(n,i),r=N(n,J$),a=T(n);return e.write(`const ${a} = ${r}(${t}, ${o});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var B$=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function W$(e,n,i,o){let t=i._zod.def.checks;if(!t||t.length===0)return o;let r=o;for(let a of t){let c=a._zod.def;if(c.when&&!B$.has(c.check))throw new R('check with a custom "when" condition');switch(c.check){case"greater_than":K$(e,n,c,r);break;case"less_than":X$(e,n,c,r);break;case"multiple_of":q$(e,n,c,r);break;case"number_format":Mm(e,c,r);break;case"min_length":{let s=vt(c.minimum,"min_length"),u=As(e,n,r,`${r}.length >= ${s} && ${r}.length < ${c.minimum*2}`);e.write(`if (${u} < ${s}) return INVALID;`);break}case"max_length":{let s=vt(c.maximum,"max_length"),u=As(e,n,r,`${r}.length > ${s}`);e.write(`if (${u} > ${s}) return INVALID;`);break}case"length_equals":{let s=vt(c.length,"length_equals"),u=As(e,n,r,`${r}.length >= ${s} && ${r}.length <= ${c.length*2}`);e.write(`if (${u} !== ${s}) return INVALID;`);break}case"min_size":e.write(`if (${r}.size < ${vt(c.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${r}.size > ${vt(c.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${r}.size !== ${vt(c.size,"size_equals")}) return INVALID;`);break;case"string_format":r=Rm(e,n,c,r);break;case"custom":r=ty(e,n,a,r);break;case"bigint_format":H$(e,c,r);break;case"mime_type":Y$(e,n,c,r);break;case"property":Q$(e,n,c,r);break;case"overwrite":{let s=T(n);ey(e,n,a,r,s),r=s;break}default:throw new R(`check type ${c.check}`)}}return r}function As(e,n,i,o){let t=N(n,ft),r=T(n);return e.write(`const ${r} = typeof ${i} === "string" && ${o} ? ${t}(${i}) : ${i}.length;`),r}function vt(e,n){if(typeof e!="number"||!Number.isFinite(e))throw new R(`${n} bound of type ${typeof e}`);return`${e}`}function Lm(e,n){if(typeof n=="bigint")return`${n}n`;if(typeof n=="number"){if(Number.isNaN(n))throw new R("comparison check with NaN bound");return`${n}`}if(n instanceof Date){if(Number.isNaN(n.getTime()))throw new R("comparison check with Invalid Date bound");return N(e,n)}throw new R(`comparison check bound of type ${typeof n}`)}function K$(e,n,i,o){let t=i.inclusive?"<":"<=";e.write(`if (${o} ${t} ${Lm(n,i.value)}) return INVALID;`)}function X$(e,n,i,o){let t=i.inclusive?">":">=";e.write(`if (${o} ${t} ${Lm(n,i.value)}) return INVALID;`)}function q$(e,n,i,o){if(typeof i.value=="bigint"){if(i.value===BigInt(0))throw new R("multiple_of check with a zero divisor");e.write(`if (${o} % ${i.value}n !== 0n) return INVALID;`)}else{let t=N(n,zn);e.write(`if (${t}(${o}, ${vt(i.value,"multiple_of")}) !== 0) return INVALID;`)}}function Mm(e,n,i){let o=n.format;switch(o){case"safeint":e.write(`if (!Number.isSafeInteger(${i})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${i}) || ${i} < -2147483648 || ${i} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${i}) || ${i} < 0 || ${i} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${i}) || ${i} < -3.4028234663852886e38 || ${i} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${i})) return INVALID;`);break;default:throw new R(`number format ${o}`)}}function H$(e,n,i){let o=n.format;if(o)switch(o){case"int64":e.write(`if (${i} < -9223372036854775808n || ${i} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${i} < 0n || ${i} > 18446744073709551615n) return INVALID;`);break;default:throw new R(`bigint format ${o}`)}}function Y$(e,n,i,o){let t=i.mime;if(t&&t.length>0){let r=N(n,new Set(t));e.write(`if (!${r}.has(${o}.type)) return INVALID;`)}}function Q$(e,n,i,o){let t=`${o}[${JSON.stringify(i.property)}]`;Q(e,n,i.schema,t)}function ey(e,n,i,o,t){let r=i._zod.def.tx;if(!r)throw new R("overwrite check without a transform function");if(yt(r))throw new Ae("z.compile: async overwrite transforms are not supported");let a=N(n,r);e.write(`const ${t} = ${a}(${o});`)}function Es(){throw new ge}function Vs(e){this.issues.push(e)}function ty(e,n,i,o){let t=i._zod.def;if(t.fn){if(yt(t.fn))throw new Ae("z.compile: async .refine() predicates are not supported");let r=N(n,t.fn),a=N(n,Es),c=T(n);return e.write(`const ${c} = ${r}(${o});`),e.write(`if (${c} instanceof Promise) ${a}();`),e.write(`if (!${c}) return INVALID;`),o}if(i._zod.check){if(yt(i._zod.check))throw new Ae("z.compile: async .superRefine() / check functions are not supported");let r=i._zod.check,c=N(n,u=>{let l={value:u,issues:[],addIssue:Vs};return r(l)instanceof Promise&&Es(),l.issues.length===0?l.value:xe}),s=T(n);return e.write(`const ${s} = ${c}(${o});`),e.write(`if (${s} === INVALID) return INVALID;`),s}throw new R("custom check without a predicate or check function")}var ny=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Rm(e,n,i,o){let t=i.format;if(t==="base64"){let s=N(n,Vn);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(t==="base64url"){let s=N(n,ii);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(t==="jwt"){let s=N(n,ai),u=N(n,i.alg??null);return e.write(`if (!${s}(${o}, ${u})) return INVALID;`),o}if(t==="ipv6"){let s=N(n,Zn);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(t==="cidrv6"){let s=N(n,ri);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(t==="credit_card"){let s=N(n,oi);return e.write(`if (!${s}(${o})) return INVALID;`),o}let r=i;if(t==="url"||t==="httpurl"||r.normalize||r.hostname!==void 0||r.protocol!==void 0){let s=N(n,Qr),u=N(n,i),l=T(n),d=T(n);if(e.write(`const ${l} = ${o}.trim();`),e.write(`const ${d} = ${s}(${l}, ${u});`),e.write(`if (typeof ${d} === "number") return INVALID;`),r.hostname!==void 0){let v=N(n,ti);e.write(`if (!${v}(${d}, ${u}.hostname)) return INVALID;`)}if(r.protocol!==void 0){let v=N(n,ni);e.write(`if (!${v}(${d}, ${u}.protocol)) return INVALID;`)}let f=T(n),m=r.normalize?`${d}.href`:`${N(n,ei)}(${l})`;return e.write(`const ${f} = ${m};`),f}let a=i.fn;if(a){if(yt(a))throw new R(`async string format ${t}`);let s=N(n,a);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(ny.has(t)&&i.pattern){let s=N(n,i.pattern);return e.write(`${s}.lastIndex = 0;`),e.write(`if (!${s}.test(${o})) return INVALID;`),o}let c=i.format;switch(c){case"regex":throw new R("regex format without a pattern");case"lowercase":e.write(`if (${o} !== ${o}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${o} !== ${o}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${o}.includes(${fe(i.includes)})) return INVALID;`);break;case"starts_with":{let s=i.prefix;e.write(`if (${o}.slice(0, ${s.length}) !== ${fe(s)}) return INVALID;`);break}case"ends_with":{let s=i.suffix;e.write(`if (${o}.slice(-${s.length}) !== ${fe(s)}) return INVALID;`);break}default:throw new R(`string format ${c}`)}return o}function Q(e,n,i,o,t=!0){let r=i._zod.def,a=r.type;if(r.coerce)throw new R(`coercion (z.coerce.${a}())`);let c=t||!!r.checks?.length,s;switch(a){case"string":s=ry(e,n,i,o);break;case"number":s=iy(e,i,o);break;case"boolean":s=oy(e,o);break;case"bigint":s=ay(e,i,o);break;case"symbol":s=cy(e,o);break;case"undefined":s=sy(e,o);break;case"null":s=uy(e,o);break;case"any":case"unknown":s=o;break;case"never":e.write("return INVALID;"),s=o;break;case"void":s=ly(e,o);break;case"nan":s=dy(e,o);break;case"date":s=fy(e,o);break;case"object":s=my(e,n,i,o,c);break;case"optional":s=py(e,n,i,o,c);break;case"nullable":s=hy(e,n,i,o,c);break;case"array":s=$y(e,n,i,o,c);break;case"literal":s=yy(e,n,i,o);break;case"enum":s=by(e,n,i,o);break;case"readonly":{let u=Zm(e,n,i,o),l=T(n);e.write(`const ${l} = Object.freeze(${u});`),s=l;break}case"success":Zm(e,n,i,o),s="true";break;case"default":case"prefault":s=_y(e,n,i,o);break;case"nonoptional":s=xy(e,n,i,o);break;case"tuple":s=ky(e,n,i,o);break;case"union":s=wy(e,n,i,o);break;case"intersection":s=zy(e,n,i,o);break;case"record":s=Py(e,n,i,o);break;case"map":s=Oy(e,n,i,o);break;case"set":s=jy(e,n,i,o);break;case"file":s=Ny(e,o);break;case"template_literal":s=Uy(e,n,i,o);break;case"lazy":s=Ty(e,n,i,o);break;case"pipe":s=Ay(e,n,i,o);break;case"custom":s=Ey(e,n,i,o);break;case"transform":s=Vy(e,n,i,o);break;case"catch":s=Zy(e,n,i,o);break;default:throw new R(`schema type ${a}`)}return s===null?null:W$(e,n,i,s)}function ry(e,n,i,o){e.write(`if (typeof ${o} !== "string") return INVALID;`);let t=i._zod.def;return t.format===void 0?o:Rm(e,n,t,o)}function iy(e,n,i){e.write(`if (typeof ${i} !== "number" || !Number.isFinite(${i})) return INVALID;`);let o=n._zod.def;return o.check==="number_format"&&o.format&&Mm(e,{format:o.format},i),i}function oy(e,n){return e.write(`if (typeof ${n} !== "boolean") return INVALID;`),n}function ay(e,n,i){e.write(`if (typeof ${i} !== "bigint") return INVALID;`);let o=n._zod.def;if(o.format)switch(o.format){case"int64":e.write(`if (${i} < -9223372036854775808n || ${i} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${i} < 0n || ${i} > 18446744073709551615n) return INVALID;`);break}return i}function cy(e,n){return e.write(`if (typeof ${n} !== "symbol") return INVALID;`),n}function sy(e,n){return e.write(`if (${n} !== undefined) return INVALID;`),n}function uy(e,n){return e.write(`if (${n} !== null) return INVALID;`),n}function ly(e,n){return e.write(`if (${n} !== undefined) return INVALID;`),n}function dy(e,n){return e.write(`if (typeof ${n} !== "number" || !Number.isNaN(${n})) return INVALID;`),n}function fy(e,n){return e.write(`if (!(${n} instanceof Date) || Number.isNaN(${n}.getTime())) return INVALID;`),n}function my(e,n,i,o,t=!0){let r=i._zod.def;e.write(`if (typeof ${o} !== "object" || ${o} === null || Array.isArray(${o})) return INVALID;`);let a=r.shape,c=Object.keys(a),s=Object.getOwnPropertySymbols(a),u=s.length?[...c,...s]:c,l=h=>typeof h=="symbol"?N(n,h):fe(h),d=h=>typeof h=="symbol"?`[${l(h)}]`:fe(h),f=a;if(c.includes("__proto__"))throw new R('object shape key "__proto__"');let m=new Map;for(let h of u){let P=f[h],A=l(h),U=T(n);if(e.write(`const ${U} = ${o}[${A}];`),P._zod.optin!==void 0){let j=T(n);e.write(`let ${j} = (() => {`),e.indented(O=>{let Y=le(O,n,P,U);O.write(`return ${Y};`)}),e.write("})();"),P._zod.optout==="optional"?(e.write(`if (${j} === INVALID) {`),e.indented(O=>{O.write(`if (${A} in ${o}) return INVALID;`),O.write(`${j} = undefined;`)}),e.write("}")):e.write(`if (${j} === INVALID) return INVALID;`),m.set(h,j)}else{vy(P)&&e.write(`if (!(${A} in ${o})) return INVALID;`);let j=le(e,n,P,U,t);j!==null&&m.set(h,j)}}let v=r.catchall,y="none";if(v){let h=v._zod.def.type;if(h==="never"){let P=c.map(A=>`k !== ${fe(A)}`).join(" && ")||"true";e.write(`for (const k in ${o}) {`),e.indented(A=>{A.write(`if (${P}) return INVALID;`)}),e.write("}")}else(h==="unknown"||h==="any")&&!v._zod.def.checks?.length?y="passthrough":y="schema"}let x=T(n),I=u.some(h=>$t(f[h])||Cs(f[h]));if(!t){if(y==="schema"){let h=c.length>0?N(n,new Set(c)):null;e.write(`for (const k in ${o}) {`),e.indented(P=>{P.write('if (k === "__proto__") continue;'),h&&P.write(`if (${h}.has(k)) continue;`);let A=T(n);P.write(`const ${A} = ${o}[k];`),le(P,n,v,A,!1)}),e.write("}")}return null}if(I){e.write(`const ${x} = {};`);for(let h of u){let P=l(h),A=m.get(h);Cs(f[h])?e.write(`if (${P} in ${o}) ${x}[${P}] = ${A};`):$t(f[h])?e.write(`if (${A} !== undefined || ${P} in ${o}) ${x}[${P}] = ${A};`):e.write(`${x}[${P}] = ${A};`)}}else{let h=u.map(P=>`${d(P)}: ${m.get(P)}`).join(", ");e.write(`const ${x} = { ${h} };`)}if(y!=="none"){let h=c.length>0?N(n,new Set(c)):null;e.write(`for (const k in ${o}) {`),e.indented(P=>{if(P.write('if (k === "__proto__") continue;'),h&&P.write(`if (${h}.has(k)) continue;`),y==="passthrough")P.write(`${x}[k] = ${o}[k];`);else{let A=T(n);P.write(`const ${A} = ${o}[k];`);let U=le(P,n,v,A);P.write(`${x}[k] = ${U};`)}}),e.write("}")}return x}function py(e,n,i,o,t=!0){let r=i._zod.def;if(gy(i))return Q(e,n,r.innerType,o,t);if(r.innerType._zod.optin==="defaulted"){let c=T(n),s=T(n);return e.write(`let ${c};`),e.write(`if (${o} === undefined) {`),e.indented(u=>{u.write(`const ${s} = (() => {`),u.indented(l=>{let d=Q(l,n,r.innerType,o);l.write(`return ${d};`)}),u.write("})();"),u.write(`if (${s} !== INVALID) ${c} = ${s};`)}),e.write("} else {"),e.indented(u=>{let l=Q(u,n,r.innerType,o);u.write(`${c} = ${l};`)}),e.write("}"),c}let a=t?T(n):null;return a&&e.write(`let ${a};`),e.write(`if (${o} !== undefined) {`),e.indented(c=>{let s=Q(c,n,r.innerType,o,t);a&&s!==null&&c.write(`${a} = ${s};`)}),e.write("}"),a}function gy(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function vy(e){return e._zod.optin===void 0&&ht(e)}function ht(e){if(e._zod.def.coerce)return!0;let n=e._zod.def;switch(n.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return n.innerType?ht(n.innerType):!1;case"literal":return!!n.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return n.innerType?ht(n.innerType):!0;case"catch":return!0;case"union":return n.options?n.options.some(ht):!0;case"intersection":return!n.left||!n.right?!0:ht(n.left)&&ht(n.right);case"pipe":return n.in?ht(n.in):!0;default:return!0}}function Cs(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function $t(e){let n=e._zod.def;switch(n.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!n.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return n.innerType?$t(n.innerType):!0;case"union":return n.options?n.options.some($t):!0;case"intersection":return!n.left||!n.right||$t(n.left)||$t(n.right);case"pipe":return n.out?$t(n.out):!0;default:return!0}}function hy(e,n,i,o,t=!0){let r=i._zod.def,a=t?T(n):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${o} !== null) {`),e.indented(c=>{let s=Q(c,n,r.innerType,o,t);a&&s!==null&&c.write(`${a} = ${s};`)}),e.write("}"),a}function $y(e,n,i,o,t=!0){let r=i._zod.def;e.write(`if (!Array.isArray(${o})) return INVALID;`);let a=t?T(n):null,c=T(n),s=T(n);return a&&e.write(`const ${a} = new Array(${o}.length);`),e.write(`for (let ${c} = 0; ${c} < ${o}.length; ${c}++) {`),e.indented(u=>{u.write(`const ${s} = ${o}[${c}];`);let l=le(u,n,r.element,s,t);a&&l!==null&&u.write(`${a}[${c}] = ${l};`)}),e.write("}"),a}function yy(e,n,i,o){let r=i._zod.def.values;if(r.length!==1){let c=N(n,new Set(r));return e.write(`if (!${c}.has(${o})) return INVALID;`),o}let a=r[0];if(typeof a=="number"&&Number.isNaN(a)){let c=N(n,new Set(r));return e.write(`if (!${c}.has(${o})) return INVALID;`),o}if(typeof a=="string")e.write(`if (${o} !== ${fe(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${o} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${o} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${o} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${o} !== ${a}n) return INVALID;`);else throw new R(`literal type ${typeof a}`);return o}function by(e,n,i,o){let t=i._zod.values;if(!t)throw new R("enum schema without enumerated values");let r=N(n,t);return e.write(`if (!${r}.has(${o})) return INVALID;`),o}function Zm(e,n,i,o){let t=i._zod.def;return Q(e,n,t.innerType,o)}function _y(e,n,i,o){let t=i._zod.def,a=Object.getOwnPropertyDescriptor(i._zod.def,"defaultValue")?()=>i._zod.def.defaultValue:void 0;if(i._zod.def.type==="prefault"){if(!a)return Q(e,n,t.innerType,o);let s=N(n,a),u=T(n);return e.write(`let ${u} = ${o};`),e.write(`if (${o} === undefined) ${u} = ${s}();`),Q(e,n,t.innerType,u)}let c=T(n);if(a){let s=N(n,a),u=N(n,Pn);e.write(`let ${c};`),e.write(`if (${o} === undefined) {`),e.indented(l=>{l.write(`${c} = ${u}(${s}());`)}),e.write("} else {"),e.indented(l=>{let d=Q(l,n,t.innerType,o);l.write(`${c} = ${d} === undefined ? ${u}(${s}()) : ${d};`)}),e.write("}")}else e.write(`let ${c};`),e.write(`if (${o} !== undefined) {`),e.indented(s=>{let u=Q(s,n,t.innerType,o);s.write(`${c} = ${u};`)}),e.write("}");return c}function xy(e,n,i,o){let t=i._zod.def,r=Q(e,n,t.innerType,o),a=T(n);return e.write(`const ${a} = ${r};`),e.write(`if (${a} === undefined) return INVALID;`),a}function ky(e,n,i,o){let t=i._zod.def,r=t.items,a=t.rest;e.write(`if (!Array.isArray(${o})) return INVALID;`);let c=Vm(r,"optin"),s=Vm(r,"optout");a?e.write(`if (${o}.length < ${c}) return INVALID;`):e.write(`if (${o}.length < ${c} || ${o}.length > ${r.length}) return INVALID;`);let u=T(n);e.write(`const ${u} = [];`);for(let l=0;l<r.length;l++){let d=r[l];if(l>=s)e.write(`if (${u}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${o}.length) {`),f.indented(m=>{let v=T(n);m.write(`const ${v} = ${o}[${l}];`);let y=le(m,n,d,v);m.write(`${u}[${l}] = ${y};`)}),f.write("} else {"),f.indented(m=>{if(Cs(d)){m.write(`${u}.length = ${l};`);return}let v=T(n),y=T(n);m.write(`const ${v} = undefined;`),m.write(`const ${y} = (() => {`),m.indented(x=>{let I=le(x,n,d,v);x.write(`return ${I};`)}),m.write("})();"),m.write(`if (${y} === INVALID || ${y} === undefined) ${u}.length = ${l};`),m.write(`else ${u}[${l}] = ${y};`)}),f.write("}")}),e.write("}");else{let f=T(n);e.write(`const ${f} = ${o}[${l}];`);let m=le(e,n,d,f);e.write(`${u}[${l}] = ${m};`)}}if(a){let l=T(n),d=T(n);e.write(`for (let ${l} = ${r.length}; ${l} < ${o}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${o}[${l}];`);let m=le(f,n,a,d);f.write(`${u}[${l}] = ${m};`)}),e.write("}")}return u}function Vm(e,n){for(let i=e.length-1;i>=0;i--)if(!(n==="optin"?e[i]._zod.optin!==void 0:e[i]._zod.optout==="optional"))return i+1;return 0}function wy(e,n,i,o){let t=i._zod.def,r=t.options;if(t.discriminator)return Iy(e,n,t,o);if(t.inclusive===!1)throw new R("exclusive unions (z.xor)");if(r.length===0)return e.write("return INVALID;"),o;if(r.length===1)return Q(e,n,r[0],o);if(r.every(s=>s._zod.def.type==="literal"&&!s._zod.def.checks?.length)){let s=new Set(r.flatMap(l=>l._zod.def.values)),u=N(n,s);return e.write(`if (!${u}.has(${o})) return INVALID;`),o}let c=T(n);e.write(`let ${c};`);for(let s=0;s<r.length;s++){let u=r[s];s===0?e.write(`${c} = (() => {`):e.write(`if (${c} === INVALID) ${c} = (() => {`),e.indented(l=>{let d=Q(l,n,u,o);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${c} === INVALID) return INVALID;`),c}function Iy(e,n,i,o){if(i.unionFallback)throw new R("discriminated union with unionFallback");if(i.options.length===0)return e.write("return INVALID;"),o;let t=T(n),r=T(n);e.write(`const ${t} = ${o}?.[${fe(i.discriminator)}];`),e.write(`let ${r};`);let a=!0,c=new Set;for(let s of i.options){let u=s._zod.propValues?.[i.discriminator];if(!u||u.size===0)throw new R("discriminated union option without static discriminator values");for(let f of u){if(c.has(f))throw new R(`duplicate discriminator value ${String(f)}`);c.add(f)}let l=Array.from(u,f=>Sy(n,t,f)),d=a?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{let m=Q(f,n,s,o);f.write(`${r} = ${m};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),r}function Sy(e,n,i){if(typeof i=="string")return`${n} === ${fe(i)}`;if(typeof i=="number")return Number.isNaN(i)?`Number.isNaN(${n})`:`${n} === ${i}`;if(typeof i=="boolean")return`${n} === ${i}`;if(i===null)return`${n} === null`;if(i===void 0)return`${n} === undefined`;if(typeof i=="bigint")return`${n} === ${i}n`;if(typeof i=="symbol"){let o=N(e,i);return`${n} === ${o}`}throw new R(`literal discriminator value ${String(i)}`)}function zy(e,n,i,o){let t=i._zod.def,r=le(e,n,t.left,o),a=le(e,n,t.right,o),c=N(n,Lt),s=T(n);return e.write(`const ${s} = ${c}(${r}, ${a});`),e.write(`if (!${s}.valid) return INVALID;`),`${s}.data`}function Py(e,n,i,o){let t=i._zod.def,r=N(n,ze);e.write(`if (!${r}(${o})) return INVALID;`);let a=T(n),c=T(n),s=T(n);e.write(`const ${a} = {};`);let u=t,l=u.partial?void 0:t.keyType._zod.values;if(l){let v=[];for(let x of l){if(!(typeof x=="string"||typeof x=="number"||typeof x=="symbol"))throw new R(`record key value ${String(x)}`);let I=typeof x=="number"?x.toString():x;if(I==="__proto__")throw new R('record key "__proto__"');v.push(I);let h=N(n,x),P=Q(e,n,t.keyType,h),A=T(n);e.write(`const ${A} = ${o}[${Dy(n,I)}];`);let U=le(e,n,t.valueType,A);e.write(`${a}[${P}] = ${U};`)}let y=N(n,new Set(v));return e.write(`for (const ${c} in ${o}) {`),e.indented(x=>{x.write(`if (${y}.has(${c})) continue;`),u.mode==="loose"?x.write(`if (${c} !== "__proto__") ${a}[${c}] = ${o}[${c}];`):x.write("return INVALID;")}),e.write("}"),a}let d=t.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let v=t.mode==="loose",y=N(n,_i(t.keyType)),x=N(n,He),I=N(n,Object.prototype.propertyIsEnumerable),h=T(n);return e.write(`for (const ${c} of Reflect.ownKeys(${o})) {`),e.indented(P=>{P.write(`if (${c} === "__proto__") continue;`),P.write(`if (!${I}.call(${o}, ${c})) continue;`),P.write(`let ${h} = ${y}(${c});`),P.write(`if (${h} === INVALID && typeof ${c} === "string" && ${x}.test(${c})) ${h} = ${y}(Number(${c}));`),v?P.write(`if (${h} === INVALID) { ${a}[${c}] = ${o}[${c}]; continue; }`):P.write(`if (${h} === INVALID) return INVALID;`),P.write(`if (${h} === "__proto__") continue;`);let A=T(n);P.write(`const ${A} = ${o}[${c}];`);let U=le(P,n,t.valueType,A);P.write(`${a}[${h}] = ${U};`)}),e.write("}"),a}let m=N(n,Object.prototype.propertyIsEnumerable);return e.write(`for (const ${c} of Reflect.ownKeys(${o})) {`),e.indented(v=>{v.write(`if (${c} === "__proto__") continue;`),v.write(`if (!${m}.call(${o}, ${c})) continue;`),v.write(`if (typeof ${c} !== "string") return INVALID;`),v.write(`const ${s} = ${o}[${c}];`);let y=le(v,n,t.valueType,s);v.write(`${a}[${c}] = ${y};`)}),e.write("}"),a}function Dy(e,n){return typeof n=="string"?fe(n):N(e,n)}function Oy(e,n,i,o){let t=i._zod.def;e.write(`if (!(${o} instanceof Map)) return INVALID;`);let r=T(n),a=T(n),c=T(n);return e.write(`const ${r} = new Map();`),e.write(`for (const [${a}, ${c}] of ${o}) {`),e.indented(s=>{let u=Q(s,n,t.keyType,a),l=Q(s,n,t.valueType,c);s.write(`${r}.set(${u}, ${l});`)}),e.write("}"),r}function jy(e,n,i,o){let t=i._zod.def;e.write(`if (!(${o} instanceof Set)) return INVALID;`);let r=T(n),a=T(n);return e.write(`const ${r} = new Set();`),e.write(`for (const ${a} of ${o}) {`),e.indented(c=>{let s=Q(c,n,t.valueType,a);c.write(`${r}.add(${s});`)}),e.write("}"),r}function Ny(e,n){return e.write(`if (!(${n} instanceof File)) return INVALID;`),n}function Uy(e,n,i,o){e.write(`if (typeof ${o} !== "string") return INVALID;`);let t=i._zod.pattern;if(t){let r=N(n,t);e.write(`${r}.lastIndex = 0;`),e.write(`if (!${r}.test(${o})) return INVALID;`)}return o}function Ty(e,n,i,o){let t=i._zod.def,r=N(n,t.getter),a=N(n,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(s=>{s.write(`const inner = ${r}();`),s.write(`${a}.parser = function(input) {`),s.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),s.write("};")}),e.write("}");let c=T(n);return e.write(`const ${c} = ${a}.parser(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),c}function Ay(e,n,i,o){let t=i._zod.def,r=Q(e,n,t.in,o);if(t.transform){if(yt(t.transform))throw new Ae("z.compile: async transforms in pipes are not supported");let a=t.transform,s=N(n,l=>{let d={value:l,issues:[],addIssue:Vs},f=a(l,d);return f instanceof Promise?xe:d.issues.length===0?f:xe}),u=T(n);return e.write(`const ${u} = ${s}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),Q(e,n,t.out,u)}else return Q(e,n,t.out,r)}function yt(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function Ey(e,n,i,o){let t=i._zod.def;if(t.fn){if(yt(t.fn))throw new Ae("z.compile: async custom predicates are not supported");let r=N(n,t.fn),a=N(n,Es),c=T(n);e.write(`const ${c} = ${r}(${o});`),e.write(`if (${c} instanceof Promise) ${a}();`),e.write(`if (!${c}) return INVALID;`)}else throw new R("custom schema without a predicate function");return o}function Cy(e,n,i){let o=e._zod.run({value:i,issues:[]},{});if(o&&typeof o.then=="function")return xe;let t=o;return t.issues.length===0?t.value:n()}function Zy(e,n,i,o){let t=i._zod.def;if(!t.catchValue[Or])throw new R("catch with a callback (only a constant catch value compiles)",!1);let r=T(n);e.write(`let ${r} = (() => {`),e.indented(u=>{let l=le(u,n,t.innerType,o);u.write(`return ${l};`)}),e.write("})();");let a=N(n,t.innerType),c=N(n,t.catchValue),s=N(n,Cy);return e.write(`if (${r} === INVALID) {`),e.indented(u=>{u.write(`${r} = ${s}(${a}, ${c}, ${o});`),u.write(`if (${r} === INVALID) return INVALID;`)}),e.write("}"),r}function Vy(e,n,i,o){let t=i._zod.def;if(t.transform){if(yt(t.transform))throw new Ae("z.compile: async transforms are not supported");let r=t.transform,c=N(n,u=>{let l={value:u,issues:[],addIssue:Vs},d=r(u,l);return d instanceof Promise?xe:l.issues.length===0?d:xe}),s=T(n);return e.write(`const ${s} = ${c}(${o});`),e.write(`if (${s} === INVALID) return INVALID;`),s}return o}function Ls(e,n){return new e({type:"string",...k(n)})}function Ms(e,n){return new e({type:"string",coerce:!0,...k(n)})}function xi(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,...k(n)})}function ki(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...k(n)})}function wi(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...k(n)})}function Ii(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(n)})}function Si(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(n)})}function zi(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(n)})}function Wn(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,...k(n)})}function Pi(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...k(n)})}function Di(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(n)})}function Oi(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...k(n)})}function ji(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(n)})}function Ni(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...k(n)})}function Ui(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...k(n)})}function Ti(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(n)})}function Ai(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(n)})}function Ei(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(n)})}function Rs(e,n){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...k(n)})}function Ci(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(n)})}function Zi(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(n)})}function Vi(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...k(n)})}function Li(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...k(n)})}function Mi(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...k(n)})}function Fs(e,n){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...k(n)})}function Ri(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...k(n)})}var Js={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Kn(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(n)})}function Xn(e,n){return new e({type:"string",format:"date",check:"string_format",...k(n)})}function qn(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,...k(n)})}function Hn(e,n){return new e({type:"string",format:"duration",check:"string_format",...k(n)})}function Gs(e,n){return new e({type:"number",checks:[],...k(n)})}function Bs(e,n){return new e({type:"number",coerce:!0,checks:[],...k(n)})}function Ws(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(n)})}function Ks(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...k(n)})}function Xs(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...k(n)})}function qs(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...k(n)})}function Hs(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...k(n)})}function Ys(e,n){return new e({type:"boolean",...k(n)})}function Qs(e,n){return new e({type:"boolean",coerce:!0,...k(n)})}function eu(e,n){return new e({type:"bigint",...k(n)})}function tu(e,n){return new e({type:"bigint",coerce:!0,...k(n)})}function nu(e,n){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...k(n)})}function ru(e,n){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...k(n)})}function iu(e,n){return new e({type:"symbol",...k(n)})}function ou(e,n){return new e({type:"undefined",...k(n)})}function au(e,n){return new e({type:"null",...k(n)})}function cu(e){return new e({type:"any"})}function su(e){return new e({type:"unknown"})}function uu(e,n){return new e({type:"never",...k(n)})}function lu(e,n){return new e({type:"void",...k(n)})}function du(e,n){return new e({type:"date",...k(n)})}function fu(e,n){return new e({type:"date",coerce:!0,...k(n)})}function mu(e,n){return new e({type:"nan",...k(n)})}function Ze(e,n){return new Gr({check:"less_than",...k(n),value:e,inclusive:!1})}function ke(e,n){return new Gr({check:"less_than",...k(n),value:e,inclusive:!0})}function Ve(e,n){return new Br({check:"greater_than",...k(n),value:e,inclusive:!1})}function we(e,n){return new Br({check:"greater_than",...k(n),value:e,inclusive:!0})}function Fi(e){return Ve(0,e)}function Ji(e){return Ze(0,e)}function Gi(e){return ke(0,e)}function Bi(e){return we(0,e)}function Ye(e,n){return new Qa({check:"multiple_of",...k(n),value:e})}function Qe(e,n){return new nc({check:"max_size",...k(n),maximum:e})}function Le(e,n){return new rc({check:"min_size",...k(n),minimum:e})}function bt(e,n){return new ic({check:"size_equals",...k(n),size:e})}function _t(e,n){return new oc({check:"max_length",...k(n),maximum:e})}function Je(e,n){return new ac({check:"min_length",...k(n),minimum:e})}function xt(e,n){return new cc({check:"length_equals",...k(n),length:e})}function Rt(e,n){return new sc({check:"string_format",format:"regex",...k(n),pattern:e})}function Ft(e){return new uc({check:"string_format",format:"lowercase",...k(e)})}function Jt(e){return new lc({check:"string_format",format:"uppercase",...k(e)})}function Gt(e,n){return new dc({check:"string_format",format:"includes",...k(n),includes:e})}function Bt(e,n){return new fc({check:"string_format",format:"starts_with",...k(n),prefix:e})}function Wt(e,n){return new mc({check:"string_format",format:"ends_with",...k(n),suffix:e})}function Wi(e,n,i){return new Wr({check:"property",property:e,schema:n,...k(i)})}function Ki(e){return Object.entries(e).map(([n,i])=>new Wr({check:"property",property:n,schema:i}))}function Kt(e,n){return new pc({check:"mime_type",mime:e,...k(n)})}function Ee(e){return new gc({check:"overwrite",tx:e})}function Xt(e){return Ee(n=>n.normalize(e))}function qt(){return Ee(e=>e.trim())}function Ht(){return Ee(e=>e.toLowerCase())}function Yt(){return Ee(e=>e.toUpperCase())}function Qt(){return Ee(e=>Qo(e))}function pu(e,n,i){return new e({type:"array",element:n,...k(i)})}function Ly(e,n,i){return new e({type:"union",options:n,...k(i)})}function My(e,n,i){return new e({type:"union",options:n,inclusive:!1,...k(i)})}function Ry(e,n,i,o){return new e({type:"union",options:i,discriminator:n,...k(o)})}function Fy(e,n,i){return new e({type:"intersection",left:n,right:i})}function Jy(e,n,i,o){let t=i instanceof E,r=t?o:i,a=t?i:null;return new e({type:"tuple",items:n,rest:a,...k(r)})}function Gy(e,n,i,o){return new e({type:"record",keyType:n,valueType:i,...k(o)})}function By(e,n,i,o){return new e({type:"map",keyType:n,valueType:i,...k(o)})}function Wy(e,n,i){return new e({type:"set",valueType:n,...k(i)})}function Ky(e,n,i){let o=Array.isArray(n)?Object.fromEntries(n.map(t=>[t,t])):n;return new e({type:"enum",entries:o,...k(i)})}function Xy(e,n,i){return new e({type:"enum",entries:n,...k(i)})}function qy(e,n,i){return new e({type:"literal",values:Array.isArray(n)?n:[n],...k(i)})}function gu(e,n){return new e({type:"file",...k(n)})}function Hy(e,n){return new e({type:"transform",transform:n})}function Yy(e,n){return new e({type:"optional",innerType:n})}function Qy(e,n){return new e({type:"nullable",innerType:n})}function eb(e,n,i){return new e({type:"default",innerType:n,get defaultValue(){return typeof i=="function"?i():Pn(i)}})}function tb(e,n,i){return new e({type:"nonoptional",innerType:n,...k(i)})}function nb(e,n){return new e({type:"success",innerType:n})}function rb(e,n,i){return new e({type:"catch",innerType:n,catchValue:typeof i=="function"?i:sa(i)})}function ib(e,n,i){return new e({type:"pipe",in:n,out:i})}function ob(e,n){return new e({type:"readonly",innerType:n})}function ab(e,n,i){return new e({type:"template_literal",parts:n,...k(i)})}function cb(e,n){return new e({type:"lazy",getter:n})}function sb(e,n){return new e({type:"promise",innerType:n})}function vu(e,n,i){let o=k(i);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:n,...o})}function hu(e,n,i){return new e({type:"custom",check:"custom",fn:n,...k(i)})}function $u(e,n){let i=Fm(o=>(o.addIssue=t=>{if(typeof t=="string")o.issues.push(Tt(t,o.value,i._zod.def));else{let r=t;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),"input"in r||(r.input=o.value),r.inst??(r.inst=i),r.continue??(r.continue=!i._zod.def.abort),o.issues.push(Tt(r))}},e(o.value,o)),n);return i}function Fm(e,n){let i=new H({check:"custom",...k(n)});return i._zod.check=e,i}function yu(e){let n=new H({check:"describe"});return n._zod.onattach=[i=>{let o=oe.get(i)??{};oe.add(i,{...o,description:e})}],n._zod.check=()=>{},n}function bu(e){let n=new H({check:"meta"});return n._zod.onattach=[i=>{let o=oe.get(i)??{};oe.add(i,{...o,...e})}],n._zod.check=()=>{},n}function _u(e,n){let i=k(n),o=i.truthy??["true","1","yes","on","y","enabled"],t=i.falsy??["false","0","no","off","n","disabled"];i.case!=="sensitive"&&(o=o.map(m=>typeof m=="string"?m.toLowerCase():m),t=t.map(m=>typeof m=="string"?m.toLowerCase():m));let r=new Set(o),a=new Set(t),c=e.Codec??Rn,s=e.Boolean??Ln,u=e.String??gt,l=new u({type:"string",error:i.error}),d=new s({type:"boolean",error:i.error}),f=new c({type:"pipe",in:l,out:d,transform:((m,v)=>{let y=m;return i.case!=="sensitive"&&(y=y.toLowerCase()),r.has(y)?!0:a.has(y)?!1:(v.issues.push({code:"invalid_value",expected:"stringbool",values:[...r,...a],input:v.value,inst:f,continue:!1}),{})}),reverseTransform:((m,v)=>m===!0?o[0]||"true":t[0]||"false"),error:i.error});return f._zod.bag.truthy=o,f._zod.bag.falsy=t,f._zod.bag.case=i.case??"insensitive",f}function en(e,n,i,o={}){let t=k(o),r={check:"string_format",type:"string",format:n,fn:typeof i=="function"?i:c=>i.test(c),...t};return i instanceof RegExp&&(r.pattern=i),new e(r)}function Yn(e,...n){for(let i of n)for(let o of Reflect.ownKeys(i))Object.prototype.propertyIsEnumerable.call(i,o)&&ee(e,o,i[o]);return e}function et(e){let n=e?.target??"draft-2020-12";return n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??oe,target:n,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function re(e,n,i,o,t){let r=typeof n.unrepresentable=="function"?n.unrepresentable({zodSchema:e,path:o.path,message:t}):n.unrepresentable;if(r==="any")return!1;if(r===void 0||r==="throw")throw new Error(t);return Object.assign(i,r),!0}function W(e,n,i={path:[],schemaPath:[]}){var o;let t=e._zod.def,r=n.seen.get(e);if(r)return r.count++,i.schemaPath.includes(e)&&(r.cycle=i.path),r.schema;let a={schema:{},count:1,cycle:void 0,path:i.path};n.seen.set(e,a),n.sharedDefsExtractedFor=void 0,n.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let l={...i,schemaPath:[...i.schemaPath,e],path:i.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,a.schema,l);else{let f=a.schema,m=n.processors[t.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${t.type}`);m(e,n,f,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),W(d,n,l),n.seen.get(d).isParent=!0)}let s=n.metadataRegistry.get(e);return s&&Yn(a.schema,s),n.io==="input"&&de(e)&&(delete a.schema.examples,delete a.schema.default),n.io==="input"&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,n.seen.get(e).schema}function Jm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function tt(e,n){let i=e.seen.get(n);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let a of e.seen.entries()){let c=e.metadataRegistry.get(a[0])?.id;if(c){let s=o.get(c);if(s&&s!==a[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,a[0])}}let t=a=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??(v=>v);if(d)return{ref:f(d)};let m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${f("__shared")}#/${c}/${Jm(m)}`}}let s="#",u=`${s}/${c}/`;if(a[1]===i&&!a[1].schema.id)return{ref:s};let l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Jm(l)}},r=a=>{if(a[1].schema.$ref)return;let c=a[1],{ref:s,defId:u}=t(a);c.def={...c.schema},u&&(c.defId=u);let l=c.schema;for(let d in l)delete l[d];l.$ref=s};if(e.cycles==="throw")for(let a of e.seen.entries()){let c=a[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
57
57
 
58
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let c=a[1];if(n===a[0]){r(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(n!==a[0]&&u){r(a);continue}}if(e.metadataRegistry.get(a[0])?.id){r(a);continue}if(c.cycle){r(a);continue}if(c.count>1&&e.reused==="ref"){r(a);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Wm(e){let n=e.anyOf;if(!Array.isArray(n)||n.length===0||e.type!==void 0)return;let i=[];for(let o of n){if(!o||typeof o!="object")return;Wm(o);let t=Object.keys(o);if(t.length!==1||t[0]!=="type")return;let r=o.type;for(let a of Array.isArray(r)?r:[r]){if(typeof a!="string")return;i.includes(a)||i.push(a)}}delete e.anyOf,e.type=i.length===1?i[0]:i}var Km=new Set(["type","properties","required","additionalProperties"]),Gm=["oneOf","anyOf"];function Bm(e){let n=e.additionalProperties;return n===void 0||n===!1||typeof n!="object"||n===null?null:Object.keys(n).length?n:null}function xu(e){let n=[];for(let r of e){if(typeof r!="object"||r.type!=="object")return null;for(let a in r)if(!Km.has(a))return null;n.push(r)}let i={},o=new Set;for(let r of n){for(let a in r.properties){if(Object.prototype.hasOwnProperty.call(i,a))continue;let c=[];for(let u of n){let l=u.properties?.[a]??Bm(u);l!=null&&(c.some(d=>JSON.stringify(d)===JSON.stringify(l))||c.push(l))}let s=c.length===1?c[0]:xu(c)??{allOf:c};ee(i,a,s)}for(let a of r.required??[])o.add(a)}let t={type:"object",properties:i};if(o.size&&(t.required=[...o]),n.every(r=>r.additionalProperties===!1))t.additionalProperties=!1;else{let r=[];for(let a of n){let c=Bm(a);c&&!r.some(s=>JSON.stringify(s)===JSON.stringify(c))&&r.push(c)}r.length===1?t.additionalProperties=r[0]:r.length>1&&(t.additionalProperties={allOf:r})}return t}function ub(e){let n=e.allOf;if(!Array.isArray(n)||n.length<2)return;for(let t of Km)if(t in e)return;let i=n.filter(t=>Gm.some(r=>Array.isArray(t[r]))),o=null;if(!i.length)o=xu(n);else{let t=i[0],r=Gm.find(s=>Array.isArray(t[s]));if(Object.keys(t).length!==1)return;let a=n.filter(s=>s!==t),c=t[r].map(s=>xu([...a,s]));if(c.some(s=>!s))return;o={[r]:c}}o&&(delete e.allOf,Yn(e,o))}function nt(e,n){let i=e.seen.get(n);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=c=>{let s=e.seen.get(c);if(s.ref===null)return;let u=s.def??s.schema,l={...u},d=s.ref;if(s.ref=null,d){o(d);let m=e.seen.get(d),v=m.schema;if(v.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(v)):Yn(u,v),Yn(u,l),c._zod.parent===d)for(let x in u)x==="$ref"||x==="allOf"||x in l||delete u[x];if(v.$ref&&m.def)for(let x in u)x==="$ref"||x==="allOf"||x in m.def&&JSON.stringify(u[x])===JSON.stringify(m.def[x])&&delete u[x]}let f=c._zod.parent;if(f&&f!==d){o(f);let m=e.seen.get(f);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let v in u)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(u[v])===JSON.stringify(m.def[v])&&delete u[v]}e.override({zodSchema:c,jsonSchema:u,path:s.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())Wm(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let s of e.seen.values())for(let u of[s.schema,s.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=c.get(l);d?d.push(u):c.set(l,[u])}for(let s of e.intersections)for(let u of c.get(s)??[])ub(u)}}let t={};if(e.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let c=e.external.registry.get(n)?.id;if(!c)throw new Error("Schema is missing an `id` property");t.$id=e.external.uri(c)}Yn(t,i.defId?i.schema:i.def??i.schema);let r=e.metadataRegistry.get(n)?.id;r!==void 0&&t.id===r&&delete t.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let s=c[1];s.def&&s.defId&&(s.def.id===s.defId&&delete s.def.id,ee(a,s.defId,s.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?t.$defs=a:t.definitions=a);try{let c=JSON.parse(JSON.stringify(t));return Object.defineProperty(c,"~standard",{value:{...n["~standard"],jsonSchema:{input:tn(n,"input",e.processors),output:tn(n,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function de(e,n){let i=n??{seen:new Set};if(i.seen.has(e))return!1;i.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return de(o.element,i);if(o.type==="set")return de(o.valueType,i);if(o.type==="lazy")return de(o.getter(),i);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return de(o.innerType,i);if(o.type==="intersection")return de(o.left,i)||de(o.right,i);if(o.type==="record"||o.type==="map")return de(o.keyType,i)||de(o.valueType,i);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:de(o.in,i)||de(o.out,i);if(o.type==="object"){for(let t in o.shape)if(de(o.shape[t],i))return!0;return!1}if(o.type==="union"){for(let t of o.options)if(de(t,i))return!0;return!1}if(o.type==="tuple"){for(let t of o.items)if(de(t,i))return!0;return!!(o.rest&&de(o.rest,i))}return!1}var ku=(e,n={})=>i=>{let o=et({...i,processors:n});return W(e,o),tt(o,e),nt(o,e)},tn=(e,n,i={})=>o=>{let{libraryOptions:t,target:r}=o??{},a=et({...t??{},target:r,io:n,processors:i});return W(e,a),tt(a,e),nt(a,e)};var lb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Su=(e,n,i,o)=>{let t=i;t.type="string";let{minimum:r,maximum:a,format:c,patterns:s,contentEncoding:u,laxFormat:l}=e._zod.bag;if(typeof r=="number"&&(t.minLength=r),typeof a=="number"&&(t.maxLength=a),c&&(t.format=lb[c]??c,t.format===""&&delete t.format,(c==="time"||l)&&delete t.format),u&&(t.contentEncoding=u),s&&s.size>0){let d=[...s];d.length===1?t.pattern=d[0].source:d.length>1&&(t.allOf=[...d.map(f=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},zu=(e,n,i,o)=>{let t=i,{minimum:r,maximum:a,format:c,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof c=="string"&&c.includes("int")?t.type="integer":t.type="number";let d=typeof l=="number"&&l>=(r??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),m=n.target==="draft-04"||n.target==="openapi-3.0";d?m?(t.minimum=l,t.exclusiveMinimum=!0):t.exclusiveMinimum=l:typeof r=="number"&&(t.minimum=r),f?m?(t.maximum=u,t.exclusiveMaximum=!0):t.exclusiveMaximum=u:typeof a=="number"&&(t.maximum=a),typeof s=="number"&&(Number.isFinite(s)&&s!==0?t.multipleOf=Math.abs(s):re(e,n,t,o,`A multipleOf divisor of ${s} cannot be represented in JSON Schema`))},Pu=(e,n,i,o)=>{i.type="boolean"},Du=(e,n,i,o)=>{re(e,n,i,o,"BigInt cannot be represented in JSON Schema")},Ou=(e,n,i,o)=>{re(e,n,i,o,"Symbols cannot be represented in JSON Schema")},ju=(e,n,i,o)=>{n.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},Nu=(e,n,i,o)=>{re(e,n,i,o,"Undefined cannot be represented in JSON Schema")},Uu=(e,n,i,o)=>{re(e,n,i,o,"Void cannot be represented in JSON Schema")},Tu=(e,n,i,o)=>{i.not={}},Au=(e,n,i,o)=>{},Eu=(e,n,i,o)=>{},Cu=(e,n,i,o)=>{re(e,n,i,o,"Date cannot be represented in JSON Schema")},Zu=(e,n,i,o)=>{let t=e._zod.def,r=In(t.entries);if(r.length===0){i.not={};return}r.every(a=>typeof a=="number")&&(i.type="number"),r.every(a=>typeof a=="string")&&(i.type="string"),i.enum=r},Vu=(e,n,i,o)=>{let t=e._zod.def;if(t.values.length===0){i.not={};return}let r=[];for(let a of t.values)if(a===void 0){if(re(e,n,i,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(re(e,n,i,o,"BigInt literals cannot be represented in JSON Schema"))return;r.push(Number(a))}else r.push(a);if(r.length!==0)if(r.length===1){let a=r[0];i.type=a===null?"null":typeof a,n.target==="draft-04"||n.target==="openapi-3.0"?i.enum=[a]:i.const=a}else r.every(a=>typeof a=="number")&&(i.type="number"),r.every(a=>typeof a=="string")&&(i.type="string"),r.every(a=>typeof a=="boolean")&&(i.type="boolean"),r.every(a=>a===null)&&(i.type="null"),i.enum=r},Lu=(e,n,i,o)=>{re(e,n,i,o,"NaN cannot be represented in JSON Schema")},Mu=(e,n,i,o)=>{let t=i,r=e._zod.pattern;if(!r)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=r.source},Ru=(e,n,i,o)=>{let t=i,r={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:c,mime:s}=e._zod.bag;a!==void 0&&(r.minLength=a),c!==void 0&&(r.maxLength=c),s?s.length===1?(r.contentMediaType=s[0],Object.assign(t,r)):(Object.assign(t,r),t.anyOf=s.map(u=>({contentMediaType:u}))):Object.assign(t,r)},Fu=(e,n,i,o)=>{i.type="boolean"},Ju=(e,n,i,o)=>{re(e,n,i,o,"Custom types cannot be represented in JSON Schema")},Gu=(e,n,i,o)=>{re(e,n,i,o,"Function types cannot be represented in JSON Schema")},Bu=(e,n,i,o)=>{re(e,n,i,o,"Transforms cannot be represented in JSON Schema")},Wu=(e,n,i,o)=>{re(e,n,i,o,"Map cannot be represented in JSON Schema")},Ku=(e,n,i,o)=>{re(e,n,i,o,"Set cannot be represented in JSON Schema")},Xu=(e,n,i,o)=>{let t=i,r=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;typeof a=="number"&&(t.minItems=a),typeof c=="number"&&(t.maxItems=c),t.type="array",t.items=W(r.element,n,{...o,path:[...o.path,"items"]})};function Qn(e){let n=e._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?Qn(n.out):n.type==="catch"?Qn(n.innerType):e._zod.optin}var qu=(e,n,i,o)=>{let t=i,r=e._zod.def,a=r.shape;if(Object.getOwnPropertySymbols(a).length&&re(e,n,t,o,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let l in a)ee(t.properties,l,W(a[l],n,{...o,path:[...o.path,"properties",l]}));let s=new Set(Object.keys(a)),u=new Set([...s].filter(l=>{let d=r.shape[l];return n.io==="input"?Qn(d)===void 0:d._zod.optout===void 0}));u.size>0&&(t.required=Array.from(u)),r.catchall?._zod.def.type==="never"?t.additionalProperties=!1:r.catchall?r.catchall&&(t.additionalProperties=W(r.catchall,n,{...o,path:[...o.path,"additionalProperties"]})):n.io==="output"&&(t.additionalProperties=!1)},qi=(e,n,i,o)=>{let t=e._zod.def,r=t.inclusive===!1,a=t.options.map((c,s)=>W(c,n,{...o,path:[...o.path,r?"oneOf":"anyOf",s]}));r?i.oneOf=a:i.anyOf=a},Hu=(e,n,i,o)=>{let t=e._zod.def,r=W(t.left,n,{...o,path:[...o.path,"allOf",0]}),a=W(t.right,n,{...o,path:[...o.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,s=[...c(r)?r.allOf:[r],...c(a)?a.allOf:[a]];i.allOf=s,n.intersections.push(s)},Yu=(e,n,i,o)=>{let t=i,r=e._zod.def;t.type="array";let a=n.target==="draft-2020-12"?"prefixItems":"items",c=n.target==="draft-2020-12"||n.target==="openapi-3.0"?"items":"additionalItems",s=r.items.map((y,x)=>W(y,n,{...o,path:[...o.path,a,x]})),u=r.rest?W(r.rest,n,{...o,path:[...o.path,c,...n.target==="openapi-3.0"?[r.items.length]:[]]}):null,l=r.items.length;for(;l>0;){let y=r.items[l-1];if(!(n.io==="input"?Qn(y)!==void 0:y._zod.optout==="optional"))break;l--}let d=r.items.length,f=!r.rest;n.target==="draft-2020-12"?(t.prefixItems=s,f?t.items=!1:u&&(t.items=u),l>0&&(t.minItems=l),f&&(t.maxItems=d)):n.target==="openapi-3.0"?(t.items={anyOf:s},u&&t.items.anyOf.push(u),l>0&&(t.minItems=l),f&&(t.maxItems=d)):(t.items=s,f?t.additionalItems=!1:u&&(t.additionalItems=u),l>0&&(t.minItems=l),f&&(t.maxItems=d));let{minimum:m,maximum:v}=e._zod.bag;typeof m=="number"&&(t.minItems=m),typeof v=="number"&&(t.maxItems=v)};function wu(e,n,i){if(n.$ref){if(i.has(n))return n;i.add(n);let v=e.get(n)?.def;if(!v)return n;let y=wu(e,v,i);return y===v?n:y}for(let v of["anyOf","oneOf"]){let y=n[v];if(!Array.isArray(y))continue;let x=y.map(I=>wu(e,I,i));x.some((I,h)=>I!==y[h])&&(n={...n,[v]:x})}let o=Array.isArray(n.type)?n.type:[n.type],t=!o.includes("string")&&o.some(v=>v==="number"||v==="integer"),r=n.enum??(n.const!==void 0?[n.const]:void 0);if(!t&&!r?.some(v=>typeof v=="number"))return n;let{minimum:a,maximum:c,exclusiveMinimum:s,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...m}=n;return m.enum?m.enum=m.enum.map(v=>typeof v=="number"?String(v):v):typeof m.const=="number"&&(m.const=String(m.const)),t&&(m.type="string",r||(m.pattern=(o.includes("number")?He:An).source)),m}var Iu=new WeakMap;function db(e){let n=new Map;for(let o of e.seen.values())o.def&&!n.has(o.schema)&&n.set(o.schema,o);let i=new Map;for(let o of Iu.get(e)??[]){let t=e.seen.get(o),r=(t?.def??t?.schema)?.propertyNames;if(!r||r===!0||i.has(r))continue;let a=wu(n,r,new Set);a!==r&&i.set(r,a)}if(i.size)for(let o of e.seen.values())for(let t of[o.schema,o.def]){let r=t&&i.get(t.propertyNames);r&&(t.propertyNames=r)}}var Qu=(e,n,i,o)=>{let t=i,r=e._zod.def;t.type="object";let a=r.keyType,s=a._zod.bag?.patterns;if(r.mode==="loose"&&s&&s.size>0){let d=W(r.valueType,n,{...o,path:[...o.path,"patternProperties","*"]});t.patternProperties={};for(let f of s)ee(t.patternProperties,f.source,d)}else{if(n.target==="draft-07"||n.target==="draft-2020-12"){t.propertyNames=W(r.keyType,n,{...o,path:[...o.path,"propertyNames"]});let d=Iu.get(n);d||(d=[],Iu.set(n,d),n.deferred.push(()=>db(n))),d.push(e)}t.additionalProperties=W(r.valueType,n,{...o,path:[...o.path,"additionalProperties"]})}let u=a._zod.values,l=n.io==="input"&&Qn(r.valueType)!==void 0;if(u&&!r.partial&&!l){let d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(t.required=d.map(String))}},el=(e,n,i,o)=>{let t=e._zod.def,r=W(t.innerType,n,o),a=n.seen.get(e);n.target==="openapi-3.0"?(a.ref=t.innerType,i.nullable=!0):i.anyOf=[r,{type:"null"}]},tl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType},nl=Symbol();function Xm(e,n,i,o,t){let r=!1,a=JSON.stringify(e,(c,s)=>typeof s!="bigint"?s:(r=!0,null));return r?(re(n,i,o,t,"BigInt defaults cannot be represented in JSON Schema"),nl):JSON.parse(a)}var rl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType;let a=Xm(t.defaultValue,e,n,i,o);a!==nl&&(i.default=a)},il=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);if(r.ref=t.innerType,n.io!=="input")return;let a=Xm(t.defaultValue,e,n,i,o);a!==nl&&(i._prefault=a)},ol=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{re(e,n,i,o,"Dynamic catch values are not supported in JSON Schema");return}i.default=a},al=(e,n,i,o)=>{let t=e._zod.def,r=t.in._zod.traits.has("$ZodTransform"),a=n.io==="input"?r?t.out:t.in:t.out;W(a,n,o);let c=n.seen.get(e);c.ref=a},cl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType,i.readOnly=!0},sl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType},Hi=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType},ul=(e,n,i,o)=>{let t=e._zod.innerType;W(t,n,o);let r=n.seen.get(e);r.ref=t},Xi={string:Su,number:zu,boolean:Pu,bigint:Du,symbol:Ou,null:ju,undefined:Nu,void:Uu,never:Tu,any:Au,unknown:Eu,date:Cu,enum:Zu,literal:Vu,nan:Lu,template_literal:Mu,file:Ru,success:Fu,custom:Ju,function:Gu,transform:Bu,map:Wu,set:Ku,array:Xu,object:qu,union:qi,intersection:Hu,tuple:Yu,record:Qu,nullable:el,nonoptional:tl,default:rl,prefault:il,catch:ol,pipe:al,readonly:cl,promise:sl,optional:Hi,lazy:ul};function Yi(e,n){if("_idmap"in e){let o=e,t=et({...n,processors:Xi}),r={};for(let s of o._idmap.entries()){let[u,l]=s;W(l,t)}let a={},c={registry:o,uri:n?.uri,defs:r};t.external=c;for(let s of o._idmap.entries()){let[u,l]=s;tt(t,l),ee(a,u,nt(t,l))}if(Object.keys(r).length>0){let s=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[s]:r}}return{schemas:a}}let i=et({...n,processors:Xi});return W(e,i),tt(i,e),nt(i,e)}var Qi=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(n){this.ctx.counter=n}get seen(){return this.ctx.seen}constructor(n){let i=n?.target??"draft-2020-12";i==="draft-4"&&(i="draft-04"),i==="draft-7"&&(i="draft-07"),this.ctx=et({processors:Xi,target:i,...n?.metadata&&{metadata:n.metadata},...n?.unrepresentable&&{unrepresentable:n.unrepresentable},...n?.override&&{override:n.override},...n?.io&&{io:n.io}})}process(n,i={path:[],schemaPath:[]}){return W(n,this.ctx,i)}emit(n,i){i&&(i.cycles&&(this.ctx.cycles=i.cycles),i.reused&&(this.ctx.reused=i.reused),i.external&&(this.ctx.external=i.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,tt(this.ctx,n);let o=nt(this.ctx,n),{"~standard":t,...r}=o;return r}};var qm={};var dn={};Fe(dn,{ZodAny:()=>Ol,ZodArray:()=>Tl,ZodBase64:()=>yo,ZodBase64URL:()=>bo,ZodBigInt:()=>un,ZodBigIntFormat:()=>ko,ZodBoolean:()=>sn,ZodCIDRv4:()=>ho,ZodCIDRv6:()=>$o,ZodCUID:()=>uo,ZodCUID2:()=>lo,ZodCatch:()=>td,ZodCodec:()=>ur,ZodCreditCard:()=>kl,ZodCustom:()=>lr,ZodCustomStringFormat:()=>an,ZodDate:()=>rr,ZodDefault:()=>Xl,ZodDiscriminatedUnion:()=>El,ZodE164:()=>_o,ZodEmail:()=>oo,ZodEmoji:()=>co,ZodEnum:()=>rn,ZodExactOptional:()=>zo,ZodFile:()=>Gl,ZodFunction:()=>dd,ZodGUID:()=>ao,ZodIPv4:()=>go,ZodIPv6:()=>vo,ZodISODate:()=>it,ZodISODateTime:()=>rt,ZodISODuration:()=>at,ZodISOTime:()=>ot,ZodIntersection:()=>Cl,ZodJWT:()=>xo,ZodKSUID:()=>po,ZodLazy:()=>sd,ZodLiteral:()=>Jl,ZodMAC:()=>xl,ZodMap:()=>Rl,ZodNaN:()=>rd,ZodNanoID:()=>so,ZodNever:()=>Nl,ZodNonOptional:()=>Po,ZodNull:()=>Pl,ZodNullable:()=>Kl,ZodNumber:()=>cn,ZodNumberFormat:()=>St,ZodObject:()=>or,ZodOptional:()=>cr,ZodPipe:()=>sr,ZodPrefault:()=>Hl,ZodPreprocess:()=>id,ZodPromise:()=>ld,ZodReadonly:()=>od,ZodRecord:()=>nn,ZodSet:()=>Fl,ZodString:()=>on,ZodStringFormat:()=>q,ZodSuccess:()=>ed,ZodSymbol:()=>Sl,ZodTemplateLiteral:()=>cd,ZodTransform:()=>Bl,ZodTuple:()=>Vl,ZodType:()=>Z,ZodULID:()=>fo,ZodURL:()=>nr,ZodUUID:()=>Me,ZodUndefined:()=>zl,ZodUnion:()=>ar,ZodUnknown:()=>jl,ZodVoid:()=>Ul,ZodXID:()=>mo,ZodXor:()=>Al,_ZodString:()=>io,_default:()=>ql,_function:()=>ag,any:()=>Cp,array:()=>ir,base64:()=>yp,base64url:()=>bp,bigint:()=>Np,boolean:()=>Il,catch:()=>nd,check:()=>cg,cidrv4:()=>hp,cidrv6:()=>$p,codec:()=>ng,creditCard:()=>xp,cuid:()=>up,cuid2:()=>lp,custom:()=>sg,date:()=>Vp,describe:()=>ug,discriminatedUnion:()=>Gp,e164:()=>_p,email:()=>Qm,emoji:()=>cp,enum:()=>Io,exactOptional:()=>Wl,file:()=>Yp,float32:()=>Pp,float64:()=>Dp,function:()=>ag,guid:()=>ep,hash:()=>zp,hex:()=>Sp,hostname:()=>Ip,httpUrl:()=>ap,instanceof:()=>dg,int:()=>no,int32:()=>Op,int64:()=>Up,intersection:()=>Zl,invertCodec:()=>rg,ipv4:()=>pp,ipv6:()=>vp,json:()=>mg,jwt:()=>kp,keyof:()=>Lp,ksuid:()=>mp,lazy:()=>ud,literal:()=>Hp,looseObject:()=>Fp,looseRecord:()=>Wp,mac:()=>gp,map:()=>Kp,meta:()=>lg,nan:()=>tg,nanoid:()=>sp,nativeEnum:()=>qp,never:()=>wo,nonoptional:()=>Ql,null:()=>Dl,nullable:()=>tr,nullish:()=>Qp,number:()=>wl,object:()=>Mp,optional:()=>wt,partialRecord:()=>Bp,pipe:()=>ro,prefault:()=>Yl,preprocess:()=>pg,promise:()=>og,readonly:()=>ad,record:()=>Ml,refine:()=>fd,set:()=>Xp,strictObject:()=>Rp,string:()=>er,stringFormat:()=>wp,stringbool:()=>fg,success:()=>eg,superRefine:()=>md,symbol:()=>Ap,templateLiteral:()=>ig,transform:()=>So,tuple:()=>Ll,uint32:()=>jp,uint64:()=>Tp,ulid:()=>dp,undefined:()=>Ep,union:()=>ln,unknown:()=>kt,url:()=>op,uuid:()=>tp,uuidv4:()=>np,uuidv6:()=>rp,uuidv7:()=>ip,void:()=>Zp,xid:()=>fp,xor:()=>Jp});var eo={};Fe(eo,{endsWith:()=>Wt,gt:()=>Ve,gte:()=>we,includes:()=>Gt,length:()=>xt,lowercase:()=>Ft,lt:()=>Ze,lte:()=>ke,maxLength:()=>_t,maxSize:()=>Qe,mime:()=>Kt,minLength:()=>Je,minSize:()=>Le,multipleOf:()=>Ye,negative:()=>Ji,nonnegative:()=>Bi,nonpositive:()=>Gi,normalize:()=>Xt,overwrite:()=>Ee,positive:()=>Fi,properties:()=>Ki,property:()=>Wi,regex:()=>Rt,size:()=>bt,slugify:()=>Qt,startsWith:()=>Bt,toLowerCase:()=>Ht,toUpperCase:()=>Yt,trim:()=>qt,uppercase:()=>Jt});var Hm=new WeakSet([Object.prototype,Error.prototype]);function to(e,n,i){Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){let o=i(this);return Object.defineProperty(this,n,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,n,{value:o,configurable:!0,writable:!0})}})}var Ym=(e,n)=>{Nn.init(e,n),e.name="ZodError";let i=Object.getPrototypeOf(e);Hm.has(i)||(Hm.add(i),to(i,"format",o=>t=>Tn(o,t)),to(i,"flatten",o=>t=>Un(o,t)),to(i,"addIssue",o=>t=>{o.issues.push(t),o.message=JSON.stringify(o.issues,Nt,2)}),to(i,"addIssues",o=>t=>{o.issues.push(...t),o.message=JSON.stringify(o.issues,Nt,2)}),Object.defineProperty(i,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},mb=p("ZodError",Ym),he=p("ZodError",Ym,void 0,{Parent:Error});var ll=At(he),dl=Et(he),fl=Ct(he),ml=Zt(he),pl=Tr(he),gl=Ar(he),vl=Er(he),hl=Cr(he),$l=Zr(he),yl=Vr(he),bl=Lr(he),_l=Mr(he);function gb(){ie.localeError||ne(vi())}function It(){ie.memoizer||ne({memoizer:Jn()})}var Z=p("ZodType",(e,n)=>(gb(),E.init(e,n),e.def=n,e.type=n.type,e),{check(...e){let n=this.def;return this.clone(_.mergeDefs(n,{checks:[...n.checks??[],...e.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,n){return B(this,e,n)},brand(){return this},register(e,n){return e.add(this,n),this},refine(e,n){return this.check(fd(e,n))},superRefine(e,n){return this.check(md(e,n))},overwrite(e){return this.check(Ee(e))},optional(){return wt(this)},exactOptional(){return Wl(this)},nullable(){return tr(this)},nullish(){return wt(tr(this))},nonoptional(e){return Ql(this,e)},array(){return ir(this)},or(e){return ln([this,e])},and(e){return Zl(this,e)},transform(e){return ro(this,So(e))},default(e){return ql(this,e)},prefault(e){return Yl(this,e)},catch(e){return nd(this,e)},pipe(e){return ro(this,e)},readonly(){return ad(this)},describe(e){let n=this.clone();return oe.add(n,{description:e}),n},meta(...e){if(e.length===0)return oe.get(this);let n=this.clone();return oe.add(n,e[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...n){return n.length===0?e(this):e(this,...n)},get"~standard"(){return _.hide(this,"~standard",{...Yr(this),jsonSchema:{input:tn(this,"input"),output:tn(this,"output")}})},set"~standard"(e){_.own(this,"~standard",e)},parse:function e(n,i){return ll(this,n,i,{callee:e})},parseAsync:async function e(n,i){return await dl(this,n,i,{callee:e})},safeParse(e,n){return fl(this,e,n)},async safeParseAsync(e,n){return ml(this,e,n)},get spa(){return this?.safeParseAsync},set spa(e){_.own(this,"spa",e)},encode:function e(n,i){return pl(this,n,i,{callee:e})},decode:function e(n,i){return gl(this,n,i,{callee:e})},encodeAsync:async function e(n,i){return await vl(this,n,i,{callee:e})},decodeAsync:async function e(n,i){return await hl(this,n,i,{callee:e})},safeEncode(e,n){return $l(this,e,n)},safeDecode(e,n){return yl(this,e,n)},async safeEncodeAsync(e,n){return bl(this,e,n)},async safeDecodeAsync(e,n){return _l(this,e,n)},toJSONSchema(e){return ku(this,{})(e)},get description(){return oe.get(this)?.description},get _def(){return this._zod.def}}),io=p("_ZodString",(e,n)=>{gt.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Su(e,o,t,r);let i=e._zod.bag;e.format=i.format??null,e.minLength=i.minimum??null,e.maxLength=i.maximum??null},{regex(...e){return this.check(Rt(...e))},includes(...e){return this.check(Gt(...e))},startsWith(...e){return this.check(Bt(...e))},endsWith(...e){return this.check(Wt(...e))},min(...e){return this.check(Je(...e))},max(...e){return this.check(_t(...e))},length(...e){return this.check(xt(...e))},nonempty(...e){return this.check(Je(1,...e))},lowercase(e){return this.check(Ft(e))},uppercase(e){return this.check(Jt(e))},trim(){return this.check(qt())},normalize(...e){return this.check(Xt(...e))},toLowerCase(){return this.check(Ht())},toUpperCase(){return this.check(Yt())},slugify(){return this.check(Qt())}}),on=p("ZodString",(e,n)=>{gt.init(e,n),io.init(e,n)},{email(e){return this.check(xi(oo,e))},url(e){return this.check(Wn(nr,e))},jwt(e){return this.check(Ri(xo,e))},emoji(e){return this.check(Pi(co,e))},guid(e){return this.check(ki(ao,e))},uuid(e){return this.check(wi(Me,e))},uuidv4(e){return this.check(Ii(Me,e))},uuidv6(e){return this.check(Si(Me,e))},uuidv7(e){return this.check(zi(Me,e))},nanoid(e){return this.check(Di(so,e))},cuid(e){return this.check(Oi(uo,e))},cuid2(e){return this.check(ji(lo,e))},ulid(e){return this.check(Ni(fo,e))},base64(e){return this.check(Vi(yo,e))},base64url(e){return this.check(Li(bo,e))},xid(e){return this.check(Ui(mo,e))},ksuid(e){return this.check(Ti(po,e))},ipv4(e){return this.check(Ai(go,e))},ipv6(e){return this.check(Ei(vo,e))},cidrv4(e){return this.check(Ci(ho,e))},cidrv6(e){return this.check(Zi($o,e))},e164(e){return this.check(Mi(_o,e))},datetime(e){return this.check(Kn(rt,e))},date(e){return this.check(Xn(it,e))},time(e){return this.check(qn(ot,e))},duration(e){return this.check(Hn(at,e))}});function er(e){return Ls(on,e)}var q=p("ZodStringFormat",(e,n)=>{X.init(e,n),io.init(e,n)}),rt=p("ZodISODateTime",(e,n)=>{jc.init(e,n),q.init(e,n)}),it=p("ZodISODate",(e,n)=>{Nc.init(e,n),q.init(e,n)}),ot=p("ZodISOTime",(e,n)=>{Uc.init(e,n),q.init(e,n)}),at=p("ZodISODuration",(e,n)=>{Tc.init(e,n),q.init(e,n)}),oo=p("ZodEmail",(e,n)=>{bc.init(e,n),q.init(e,n)});function Qm(e){return xi(oo,e)}var ao=p("ZodGUID",(e,n)=>{$c.init(e,n),q.init(e,n)});function ep(e){return ki(ao,e)}var Me=p("ZodUUID",(e,n)=>{yc.init(e,n),q.init(e,n)});function tp(e){return wi(Me,e)}function np(e){return Ii(Me,e)}function rp(e){return Si(Me,e)}function ip(e){return zi(Me,e)}var nr=p("ZodURL",(e,n)=>{kc.init(e,n),q.init(e,n)});function op(e){return Wn(nr,e)}function ap(e){return Wn(nr,{protocol:ue.httpProtocol,hostname:ue.domain,..._.normalizeParams(e)})}var co=p("ZodEmoji",(e,n)=>{wc.init(e,n),q.init(e,n)});function cp(e){return Pi(co,e)}var so=p("ZodNanoID",(e,n)=>{Ic.init(e,n),q.init(e,n)});function sp(e){return Di(so,e)}var uo=p("ZodCUID",(e,n)=>{Sc.init(e,n),q.init(e,n)});function up(e){return Oi(uo,e)}var lo=p("ZodCUID2",(e,n)=>{zc.init(e,n),q.init(e,n)});function lp(e){return ji(lo,e)}var fo=p("ZodULID",(e,n)=>{Pc.init(e,n),q.init(e,n)});function dp(e){return Ni(fo,e)}var mo=p("ZodXID",(e,n)=>{Dc.init(e,n),q.init(e,n)});function fp(e){return Ui(mo,e)}var po=p("ZodKSUID",(e,n)=>{Oc.init(e,n),q.init(e,n)});function mp(e){return Ti(po,e)}var go=p("ZodIPv4",(e,n)=>{Ac.init(e,n),q.init(e,n)});function pp(e){return Ai(go,e)}var xl=p("ZodMAC",(e,n)=>{Cc.init(e,n),q.init(e,n)});function gp(e){return Rs(xl,e)}var vo=p("ZodIPv6",(e,n)=>{Ec.init(e,n),q.init(e,n)});function vp(e){return Ei(vo,e)}var ho=p("ZodCIDRv4",(e,n)=>{Zc.init(e,n),q.init(e,n)});function hp(e){return Ci(ho,e)}var $o=p("ZodCIDRv6",(e,n)=>{Vc.init(e,n),q.init(e,n)});function $p(e){return Zi($o,e)}var yo=p("ZodBase64",(e,n)=>{Lc.init(e,n),q.init(e,n)});function yp(e){return Vi(yo,e)}var bo=p("ZodBase64URL",(e,n)=>{Mc.init(e,n),q.init(e,n)});function bp(e){return Li(bo,e)}var _o=p("ZodE164",(e,n)=>{Rc.init(e,n),q.init(e,n)});function _p(e){return Mi(_o,e)}var kl=p("ZodCreditCard",(e,n)=>{Fc.init(e,n),q.init(e,n)});function xp(e){return Fs(kl,e)}var xo=p("ZodJWT",(e,n)=>{Jc.init(e,n),q.init(e,n)});function kp(e){return Ri(xo,e)}var an=p("ZodCustomStringFormat",(e,n)=>{Gc.init(e,n),q.init(e,n)});function wp(e,n,i={}){return en(an,e,n,i)}function Ip(e){return en(an,"hostname",ue.hostname,e)}function Sp(e){return en(an,"hex",ue.hex,e)}function zp(e,n){let i=n?.enc??"hex",o=`${e}_${i}`,t=ue[o];if(!t)throw new Error(`Unrecognized hash format: ${o}`);return en(an,o,t,n)}var cn=p("ZodNumber",(e,n)=>{ci.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>zu(e,o,t,r);let i=e._zod.bag;e.minValue=Math.max(i.minimum??Number.NEGATIVE_INFINITY,i.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(i.maximum??Number.POSITIVE_INFINITY,i.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(i.format??"").includes("int")||Number.isSafeInteger(i.multipleOf??.5),e.isFinite=!0,e.format=i.format??null},{gt(e,n){return this.check(Ve(e,n))},gte(e,n){return this.check(we(e,n))},min(e,n){return this.check(we(e,n))},lt(e,n){return this.check(Ze(e,n))},lte(e,n){return this.check(ke(e,n))},max(e,n){return this.check(ke(e,n))},int(e){return this.check(no(e))},safe(e){return this.check(no(e))},positive(e){return this.check(Ve(0,e))},nonnegative(e){return this.check(we(0,e))},negative(e){return this.check(Ze(0,e))},nonpositive(e){return this.check(ke(0,e))},multipleOf(e,n){return this.check(Ye(e,n))},step(e,n){return this.check(Ye(e,n))},finite(){return this}});function wl(e){return Gs(cn,e)}var St=p("ZodNumberFormat",(e,n)=>{Bc.init(e,n),cn.init(e,n)});function no(e){return Ws(St,e)}function Pp(e){return Ks(St,e)}function Dp(e){return Xs(St,e)}function Op(e){return qs(St,e)}function jp(e){return Hs(St,e)}var sn=p("ZodBoolean",(e,n)=>{Ln.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Pu(e,i,o,t)});function Il(e){return Ys(sn,e)}var un=p("ZodBigInt",(e,n)=>{si.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Du(e,o,t,r);let i=e._zod.bag;e.minValue=i.minimum??null,e.maxValue=i.maximum??null,e.format=i.format??null},{gte(e,n){return this.check(we(e,n))},min(e,n){return this.check(we(e,n))},gt(e,n){return this.check(Ve(e,n))},lt(e,n){return this.check(Ze(e,n))},lte(e,n){return this.check(ke(e,n))},max(e,n){return this.check(ke(e,n))},positive(e){return this.check(Ve(BigInt(0),e))},negative(e){return this.check(Ze(BigInt(0),e))},nonpositive(e){return this.check(ke(BigInt(0),e))},nonnegative(e){return this.check(we(BigInt(0),e))},multipleOf(e,n){return this.check(Ye(e,n))}});function Np(e){return eu(un,e)}var ko=p("ZodBigIntFormat",(e,n)=>{Wc.init(e,n),un.init(e,n)});function Up(e){return nu(ko,e)}function Tp(e){return ru(ko,e)}var Sl=p("ZodSymbol",(e,n)=>{Kc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ou(e,i,o,t)});function Ap(e){return iu(Sl,e)}var zl=p("ZodUndefined",(e,n)=>{Xc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Nu(e,i,o,t)});function Ep(e){return ou(zl,e)}var Pl=p("ZodNull",(e,n)=>{qc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>ju(e,i,o,t)});function Dl(e){return au(Pl,e)}var Ol=p("ZodAny",(e,n)=>{Hc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Au(e,i,o,t)});function Cp(){return cu(Ol)}var jl=p("ZodUnknown",(e,n)=>{Yc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Eu(e,i,o,t)});function kt(){return su(jl)}var Nl=p("ZodNever",(e,n)=>{Qc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Tu(e,i,o,t)});function wo(e){return uu(Nl,e)}var Ul=p("ZodVoid",(e,n)=>{es.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Uu(e,i,o,t)});function Zp(e){return lu(Ul,e)}var rr=p("ZodDate",(e,n)=>{ts.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Cu(e,o,t,r),e.min=(o,t)=>e.check(we(o,t)),e.max=(o,t)=>e.check(ke(o,t));let i=e._zod.bag;e.minDate=i.minimum?new Date(i.minimum):null,e.maxDate=i.maximum?new Date(i.maximum):null});function Vp(e){return du(rr,e)}var Tl=p("ZodArray",(e,n)=>{It(),ns.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Xu(e,i,o,t),e.element=n.element},{min(e,n){return this.check(Je(e,n))},nonempty(e){return this.check(Je(1,e))},max(e,n){return this.check(_t(e,n))},length(e,n){return this.check(xt(e,n))},unwrap(){return this.element}});function ir(e,n){return pu(Tl,e,n)}function Lp(e){let n=e._zod.def.shape;return Io(Object.keys(n))}var or=p("ZodObject",(e,n)=>{It(),rs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>qu(e,i,o,t),_.installLazyProp(e,"shape",i=>i._zod.def.shape,!1)},{keyof(){return Io(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:kt()})},loose(){return this.clone({...this._zod.def,catchall:kt()})},strict(){return this.clone({...this._zod.def,catchall:wo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return _.extend(this,e)},safeExtend(e){return _.safeExtend(this,e)},merge(e){return _.merge(this,e)},pick(e){return _.pick(this,e)},omit(e){return _.omit(this,e)},partial(...e){return _.partial(cr,this,e[0])},exactPartial(...e){return _.partial(zo,this,e[0],"exactPartial")},required(...e){return _.required(Po,this,e[0])}});function Mp(e,n){let i={type:"object",shape:e??{},..._.normalizeParams(n)};return new or(i)}function Rp(e,n){return new or({type:"object",shape:e,catchall:wo(),..._.normalizeParams(n)})}function Fp(e,n){return new or({type:"object",shape:e,catchall:kt(),..._.normalizeParams(n)})}var ar=p("ZodUnion",(e,n)=>{Mn.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>qi(e,i,o,t),e.options=n.options});function ln(e,n){return new ar({type:"union",options:e,..._.normalizeParams(n)})}var Al=p("ZodXor",(e,n)=>{ar.init(e,n),is.init(e,n),e._zod.processJSONSchema=(i,o,t)=>qi(e,i,o,t),e.options=n.options});function Jp(e,n){return new Al({type:"union",options:e,inclusive:!1,..._.normalizeParams(n)})}var El=p("ZodDiscriminatedUnion",(e,n)=>{ar.init(e,n),as.init(e,n)});function Gp(e,n,i){return new El({type:"union",options:n,discriminator:e,..._.normalizeParams(i)})}var Cl=p("ZodIntersection",(e,n)=>{cs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Hu(e,i,o,t)});function Zl(e,n){return new Cl({type:"intersection",left:e,right:n})}var Vl=p("ZodTuple",(e,n)=>{It(),ui.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Yu(e,i,o,t)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(n=>new cr({type:"optional",innerType:n}))})}});function Ll(e,n,i){let o=n instanceof E,t=o?i:n,r=o?n:null;return new Vl({type:"tuple",items:e,rest:r,..._.normalizeParams(t)})}var nn=p("ZodRecord",(e,n)=>{It(),ss.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Qu(e,i,o,t),e.keyType=n.keyType,e.valueType=n.valueType});function Ml(e,n,i){return!n||!n._zod?new nn({type:"record",keyType:er(),valueType:e,..._.normalizeParams(n)}):new nn({type:"record",keyType:e,valueType:n,..._.normalizeParams(i)})}function Bp(e,n,i){return new nn({type:"record",keyType:e,valueType:n,..._.normalizeParams(i),partial:!0})}function Wp(e,n,i){return new nn({type:"record",keyType:e,valueType:n,mode:"loose",..._.normalizeParams(i)})}var Rl=p("ZodMap",(e,n)=>{It(),us.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Wu(e,i,o,t),e.keyType=n.keyType,e.valueType=n.valueType,e.min=(...i)=>e.check(Le(...i)),e.nonempty=i=>e.check(Le(1,i)),e.max=(...i)=>e.check(Qe(...i)),e.size=(...i)=>e.check(bt(...i))});function Kp(e,n,i){return new Rl({type:"map",keyType:e,valueType:n,..._.normalizeParams(i)})}var Fl=p("ZodSet",(e,n)=>{It(),ls.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ku(e,i,o,t),e.min=(...i)=>e.check(Le(...i)),e.nonempty=i=>e.check(Le(1,i)),e.max=(...i)=>e.check(Qe(...i)),e.size=(...i)=>e.check(bt(...i))});function Xp(e,n){return new Fl({type:"set",valueType:e,..._.normalizeParams(n)})}var rn=p("ZodEnum",(e,n)=>{ds.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Zu(e,o,t,r),e.enum=n.entries,e.options=Object.values(n.entries);let i=new Set(Object.keys(n.entries));e.extract=(o,t)=>{let r={};for(let a of o)if(i.has(a))r[a]=n.entries[a];else throw new Error(`Key ${a} not found in enum`);return new rn({...n,checks:[],..._.normalizeParams(t),entries:r})},e.exclude=(o,t)=>{let r={...n.entries};for(let a of o)if(i.has(a))delete r[a];else throw new Error(`Key ${a} not found in enum`);return new rn({...n,checks:[],..._.normalizeParams(t),entries:r})}});function Io(e,n){let i=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new rn({type:"enum",entries:i,..._.normalizeParams(n)})}function qp(e,n){return new rn({type:"enum",entries:e,..._.normalizeParams(n)})}var Jl=p("ZodLiteral",(e,n)=>{fs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Vu(e,i,o,t),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function Hp(e,n){return new Jl({type:"literal",values:Array.isArray(e)?e:[e],..._.normalizeParams(n)})}var Gl=p("ZodFile",(e,n)=>{ms.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ru(e,i,o,t),e.min=(i,o)=>e.check(Le(i,o)),e.max=(i,o)=>e.check(Qe(i,o)),e.mime=(i,o)=>e.check(Kt(Array.isArray(i)?i:[i],o))});function Yp(e){return gu(Gl,e)}var Bl=p("ZodTransform",(e,n)=>{It(),ps.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Bu(e,i,o,t),e._zod.parse=(i,o)=>{if(o.direction==="backward")throw new qe(e.constructor.name);i.addIssue=r=>{if(typeof r=="string")i.issues.push(_.issue(r,i.value,n));else{let a=r;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=i.value),a.inst??(a.inst=e),i.issues.push(_.issue(a))}};let t=n.transform(i.value,i);return t instanceof Promise?t.then(r=>(i.value=r,i)):(i.value=t,i)}});function So(e){return new Bl({type:"transform",transform:e})}var cr=p("ZodOptional",(e,n)=>{li.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Hi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function wt(e){return new cr({type:"optional",innerType:e})}var zo=p("ZodExactOptional",(e,n)=>{gs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Hi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Wl(e){return new zo({type:"optional",innerType:e})}var Kl=p("ZodNullable",(e,n)=>{vs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>el(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function tr(e){return new Kl({type:"nullable",innerType:e})}function Qp(e){return wt(tr(e))}var Xl=p("ZodDefault",(e,n)=>{hs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>rl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ql(e,n){return new Xl({type:"default",innerType:e,get defaultValue(){return typeof n=="function"?n():_.shallowClone(n)}})}var Hl=p("ZodPrefault",(e,n)=>{$s.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>il(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Yl(e,n){return new Hl({type:"prefault",innerType:e,get defaultValue(){return typeof n=="function"?n():_.shallowClone(n)}})}var Po=p("ZodNonOptional",(e,n)=>{ys.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>tl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Ql(e,n){return new Po({type:"nonoptional",innerType:e,..._.normalizeParams(n)})}var ed=p("ZodSuccess",(e,n)=>{bs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Fu(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function eg(e){return new ed({type:"success",innerType:e})}var td=p("ZodCatch",(e,n)=>{_s.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>ol(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nd(e,n){return new td({type:"catch",innerType:e,catchValue:typeof n=="function"?n:_.constantCatch(n)})}var rd=p("ZodNaN",(e,n)=>{xs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Lu(e,i,o,t)});function tg(e){return mu(rd,e)}var sr=p("ZodPipe",(e,n)=>{di.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>al(e,i,o,t),e.in=n.in,e.out=n.out});function ro(e,n){return new sr({type:"pipe",in:e,out:n})}var ur=p("ZodCodec",(e,n)=>{sr.init(e,n),Rn.init(e,n)});function ng(e,n,i){return new ur({type:"pipe",in:e,out:n,transform:i.decode,reverseTransform:i.encode})}function rg(e){let n=e._zod.def;return new ur({type:"pipe",in:n.out,out:n.in,transform:n.reverseTransform,reverseTransform:n.transform})}var id=p("ZodPreprocess",(e,n)=>{sr.init(e,n),ks.init(e,n)}),od=p("ZodReadonly",(e,n)=>{ws.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>cl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function ad(e){return new od({type:"readonly",innerType:e})}var cd=p("ZodTemplateLiteral",(e,n)=>{Is.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Mu(e,i,o,t)});function ig(e,n){return new cd({type:"template_literal",parts:e,..._.normalizeParams(n)})}var sd=p("ZodLazy",(e,n)=>{Fn.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>ul(e,i,o,t),e.unwrap=()=>e._zod.def.getter()});function ud(e){return new sd({type:"lazy",getter:e})}var ld=p("ZodPromise",(e,n)=>{zs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>sl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function og(e){return new ld({type:"promise",innerType:e})}var dd=p("ZodFunction",(e,n)=>{Ss.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Gu(e,i,o,t)});function ag(e){return new dd({type:"function",input:Array.isArray(e?.input)?Ll(e?.input):e?.input??ir(kt()),output:e?.output??kt()})}var lr=p("ZodCustom",(e,n)=>{Ps.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ju(e,i,o,t)});function cg(e){let n=new H({check:"custom"});return n._zod.check=e,n}function sg(e,n){return vu(lr,e??(()=>!0),n)}function fd(e,n={}){return hu(lr,e,n)}function md(e,n){return $u(e,n)}var ug=yu,lg=bu;function dg(e,n={}){let i=new lr({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,..._.normalizeParams(n)});return i._zod.bag.Class=e,i._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:i,path:[...i._zod.def.path??[]]})},i}var fg=(...e)=>_u({Codec:ur,Boolean:sn,String:on},...e);function mg(e){let n=ud(()=>ln([er(e),wl(),Il(),Dl(),ir(n),Ml(er(),n)]));return n}function pg(e,n){return new id({type:"pipe",in:So(e),out:n})}var vb={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function hb(e){ne({customError:e})}function $b(){return ne().customError}var pd;pd||(pd={});var dr={};Fe(dr,{ZodISODate:()=>it,ZodISODateTime:()=>rt,ZodISODuration:()=>at,ZodISOTime:()=>ot,date:()=>bb,datetime:()=>yb,duration:()=>xb,time:()=>_b});function yb(e){return Kn(rt,e)}function bb(e){return Xn(it,e)}function _b(e){return qn(ot,e)}function xb(e){return Hn(at,e)}var S={...dn,...eo,iso:dr},kb=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function wb(e,n){let i=e.$schema;return i==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":i==="http://json-schema.org/draft-07/schema#"?"draft-7":i==="http://json-schema.org/draft-04/schema#"?"draft-4":n??"draft-2020-12"}function gg(e,n){return e.map((i,o)=>o<n?i:i.optional())}function Ib(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Sb(e,n){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let i=e.slice(1).split("/").filter(Boolean);if(i.length===0)return n.rootSchema;let o=n.version==="draft-2020-12"?"$defs":"definitions";if(i[0]===o){let t=i[1]===void 0?void 0:Ib(i[1]);if(!t||!n.defs[t])throw new Error(`Reference not found: ${e}`);return n.defs[t]}throw new Error(`Reference not found: ${e}`)}function zb(e,n){return S.transform(o=>o).check(o=>{let t=o.value;if(!(typeof t!="object"||t===null||Array.isArray(t)))for(let r of Object.getOwnPropertyNames(t)){let a=n.safeParse(r);a.success||o.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:r,path:[r],continue:!0})}}).pipe(e)}function vg(e,n){if(e!==!1)return e===void 0||e===!0?S.any():$e(e,n)}var Pb=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function hg(e,n){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return S.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let t=e.$ref;if(n.refs.has(t))return n.refs.get(t);if(n.processing.has(t))return S.lazy(()=>{if(!n.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return n.refs.get(t)});n.processing.add(t);let r=Sb(t,n),a=$e(r,n);return n.refs.set(t,a),n.processing.delete(t),a}if(e.enum!==void 0){let t=e.enum;if(n.version==="openapi-3.0"&&e.nullable===!0&&t.length===1&&t[0]===null)return S.null();if(t.length===0)return S.never();if(t.length===1)return S.literal(t[0]);if(t.every(a=>typeof a=="string"))return S.enum(t);let r=t.map(a=>S.literal(a));return r.length<2?r[0]:S.union([r[0],r[1],...r.slice(2)])}if(e.const!==void 0)return S.literal(e.const);let i=e.type;if(Array.isArray(i)){let t=i.map(r=>{let a={...e,type:r};return hg(a,n)});return t.length===0?S.never():t.length===1?t[0]:S.union(t)}if(!i)return S.any();let o;switch(i){case"string":{let t=S.string();if(e.format){let r=e.format;r==="email"?t=t.check(S.email()):r==="uri"||r==="uri-reference"?t=t.check(S.url()):r==="uuid"||r==="guid"?t=t.check(S.uuid()):r==="date-time"?t=t.check(S.iso.datetime({offset:!0})):r==="date"?t=t.check(S.iso.date()):r==="time"?t=t.check(S.regex(Pb)):r==="duration"?t=t.check(S.iso.duration()):r==="hostname"?t=t.check(S.hostname()):r==="ipv4"?t=t.check(S.ipv4()):r==="ipv6"?t=t.check(S.ipv6()):r==="mac"?t=t.check(S.mac()):r==="cidr"?t=t.check(S.cidrv4()):r==="cidr-v6"?t=t.check(S.cidrv6()):r==="base64"?t=t.check(S.base64()):r==="base64url"?t=t.check(S.base64url()):r==="e164"?t=t.check(S.e164()):r==="credit_card"?t=t.check(S.creditCard()):r==="jwt"?t=t.check(S.jwt()):r==="emoji"?t=t.check(S.emoji()):r==="nanoid"?t=t.check(S.nanoid()):r==="cuid"?t=t.check(S.cuid()):r==="cuid2"?t=t.check(S.cuid2()):r==="ulid"?t=t.check(S.ulid()):r==="xid"?t=t.check(S.xid()):r==="ksuid"&&(t=t.check(S.ksuid()))}typeof e.minLength=="number"&&(t=t.min(e.minLength)),typeof e.maxLength=="number"&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),o=t;break}case"number":case"integer":{let t=i==="integer"?S.number().int():S.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum=="number"?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(t=t.lt(e.maximum)),typeof e.multipleOf=="number"&&(t=t.multipleOf(e.multipleOf)),o=t;break}case"boolean":{o=S.boolean();break}case"null":{o=S.null();break}case"object":{let t={},r=e.properties||{},a=new Set(e.required||[]),c=typeof e.additionalProperties=="object"?$e(e.additionalProperties,n):void 0;for(let[s,u]of Object.entries(r)){let l=$e(u,n);ee(t,s,a.has(s)?l:l.optional())}if(e.patternProperties){let s=e.patternProperties,u=Object.keys(s),l=[];for(let f of u){let m=$e(s[f],n),v=S.string().regex(new RegExp(f));l.push(S.looseRecord(v,m))}let d=[];if(Object.keys(t).length>0&&d.push(S.object(t).passthrough()),d.push(...l),d.length===0)o=S.object({}).passthrough();else if(d.length===1)o=d[0];else{let f=S.intersection(d[0],d[1]);for(let m=2;m<d.length;m++)f=S.intersection(f,d[m]);o=f}if(e.additionalProperties===!1){let f=Object.keys(t),m=u.map(y=>new RegExp(y)),v=o;o=o.check(y=>{if(!ze(y.value))return;let x=[];for(let I of Object.keys(y.value))f.includes(I)||m.some(h=>h.test(I))||x.push(I);x.length&&y.issues.push({code:"unrecognized_keys",keys:x,input:y.value,inst:v})})}}else{let s=S.object(t);e.additionalProperties===!1?o=s.strict():c?o=s.catchall(c):o=s.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let s=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;o=zb(o,$e(s,n))}break}case"array":{let t=e.prefixItems,r=e.items;if(t&&Array.isArray(t)){let a=typeof e.minItems=="number"?e.minItems:0,c=t.map(d=>$e(d,n)),s=gg(c,a),u=Array.isArray(r)?void 0:vg(r,n),l=S.tuple(s);o=u?l.rest(u):l,typeof e.minItems=="number"&&(o=o.check(S.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(S.maxLength(e.maxItems)))}else if(Array.isArray(r)){let a=typeof e.minItems=="number"?e.minItems:0,c=r.map(d=>$e(d,n)),s=gg(c,a),u=vg(e.additionalItems,n),l=S.tuple(s);o=u?l.rest(u):l,typeof e.minItems=="number"&&(o=o.check(S.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(S.maxLength(e.maxItems)))}else if(r!==void 0){let a=$e(r,n),c=S.array(a);typeof e.minItems=="number"&&(c=c.min(e.minItems)),typeof e.maxItems=="number"&&(c=c.max(e.maxItems)),o=c}else o=S.array(S.any());break}default:throw new Error(`Unsupported type: ${i}`)}return o}function $e(e,n){if(typeof e=="boolean")return e?S.any():S.never();let i=hg(e,n),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let c=e.anyOf.map(u=>$e(u,n)),s=S.union(c);i=o?S.intersection(i,s):s}if(e.oneOf&&Array.isArray(e.oneOf)){let c=e.oneOf.map(u=>$e(u,n)),s=S.xor(c);i=o?S.intersection(i,s):s}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)i=o?i:S.any();else{let c=o?i:$e(e.allOf[0],n),s=o?0:1;for(let u=s;u<e.allOf.length;u++)c=S.intersection(c,$e(e.allOf[u],n));i=c}e.nullable===!0&&n.version==="openapi-3.0"&&(i=S.nullable(i)),e.readOnly===!0&&(i=S.readonly(i)),e.default!==void 0&&(i=i.default(e.default));let t={},r=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let c of r)c in e&&(t[c]=e[c]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let c of a)c in e&&(t[c]=e[c]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(t.propertyNames=e.propertyNames);for(let c of Object.keys(e))kb.has(c)||ee(t,c,e[c]);return Object.keys(t).length>0&&n.registry.add(i,t),e.description&&(i=i.describe(e.description)),i}function $g(e,n){if(typeof e=="boolean")return e?S.any():S.never();let i;try{i=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=wb(i,n?.defaultTarget),t=i.$defs||i.definitions||{},r={version:o,defs:t,refs:new Map,processing:new Set,rootSchema:i,registry:n?.registry??oe};return $e(i,r)}var yg=Symbol("z.visit/resolving");function fr(e,n){let i=typeof n=="function"?n:(a,c)=>{let s=n[a._zod.def.type];return s?s(a,c):a},o=new Map;function t(a){let c=o.get(a);if(c===yg)return new Fn({type:"lazy",getter:()=>o.get(a)});if(c!==void 0)return c;o.set(a,yg);let s=r(a),u=i(s,s!==a);return o.set(a,u),u}function r(a){let c=a._zod.def,s=c.type;switch(s){case"object":{let u=c.shape,l=Object.keys(u),d=!1,f={};for(let v of l){let y=t(u[v]);y!==u[v]&&(d=!0),f[v]=y}let m=c.catchall;return c.catchall&&(m=t(c.catchall),m!==c.catchall&&(d=!0)),d?B(a,{...c,shape:f,catchall:m}):a}case"array":{let u=t(c.element);return u===c.element?a:B(a,{...c,element:u})}case"tuple":{let u=c.items,l=!1,d=[];for(let m of u){let v=t(m);v!==m&&(l=!0),d.push(v)}let f=c.rest;return c.rest&&(f=t(c.rest),f!==c.rest&&(l=!0)),l?B(a,{...c,items:d,rest:f}):a}case"record":case"map":{let u=t(c.keyType),l=t(c.valueType);return u===c.keyType&&l===c.valueType?a:B(a,{...c,keyType:u,valueType:l})}case"set":{let u=t(c.valueType);return u===c.valueType?a:B(a,{...c,valueType:u})}case"union":{let u=c.options,l=!1,d=[];for(let f of u){let m=t(f);m!==f&&(l=!0),d.push(m)}return l?B(a,{...c,options:d}):a}case"intersection":{let u=t(c.left),l=t(c.right);return u===c.left&&l===c.right?a:B(a,{...c,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=t(c.innerType);return u===c.innerType?a:B(a,{...c,innerType:u})}case"pipe":{let u=t(c.in),l=t(c.out);return u===c.in&&l===c.out?a:B(a,{...c,in:u,out:l})}case"function":{let u=t(c.input),l=t(c.output);return u===c.input&&l===c.output?a:B(a,{...c,input:u,output:l})}case"lazy":{let u=c.getter,{_cachedInner:l,...d}=c;return B(a,{...d,getter:()=>t(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return t(e)}function bg(e){return fr(e,{object:n=>n.partial(),union:n=>{let i=n._zod.def;return i.discriminator===void 0?n:ln(i.options)}})}function Db(e,n){if(!n?.length)return e;let i=e._zod.def;return B(e,Te(i,{checks:[...i.checks??[],...n]}),{parent:!0})}function _g(e){return Db(e.out,e.checks)}function Ob(e){return e.in._zod.traits.has("$ZodTransform")?_g(e):e.in}function xg(e){return fr(e,{pipe:n=>Ob(n._zod.def),default:(n,i)=>i?wt(n._zod.def.innerType):n,catch:(n,i)=>i?n._zod.def.innerType:n})}function kg(e){return fr(e,{pipe:n=>_g(n._zod.def),prefault:(n,i)=>i?n._zod.def.innerType:n})}var gd={};Fe(gd,{bigint:()=>Tb,boolean:()=>Ub,date:()=>Ab,number:()=>Nb,string:()=>jb});function jb(e){return Ms(on,e)}function Nb(e){return Bs(cn,e)}function Ub(e){return Qs(sn,e)}function Tb(e){return tu(un,e)}function Ab(e){return fu(rr,e)}var zt={maxBatchEvents:1e3,maxProjectIdLength:128,maxSessionIdLength:128,maxSdkVersionLength:64,maxUrlLength:2048,maxTitleLength:512,maxReferrerLength:2048,maxLanguageLength:35,maxMeshNameLength:256,maxAssetNameLength:1024,maxCustomNameLength:128,maxCustomPropValueLength:1024,maxCustomPropEntries:64,maxUserIdLength:128,maxUserTraitValueLength:1024,maxUserTraitEntries:64,maxSceneDescriptionLength:256,maxCameraNameLength:128,maxSceneProxyMeshNameLength:256,maxSceneProxyMeshPathLength:512,maxSceneProxyMeshes:1e4,maxNodeIdLength:128,maxBoneIdLength:128,maxChildPathLength:512,maxGraphicsDiagnosticMessageLength:1024,maxGraphicsDiagnosticCodeLength:64};var Do=C.tuple([C.number(),C.number(),C.number()]),vd=C.tuple([C.number(),C.number(),C.number(),C.number()]),Eb=C.tuple([C.number(),C.number()]),Cb=C.tuple([C.number().min(0).max(1),C.number().min(0).max(1)]),hd=C.number().int().nonnegative(),fn=C.string().regex(/^[A-Za-z0-9._:-]{1,64}$/,"sceneId must be 1-64 chars of [A-Za-z0-9._:-]");var $d=C.enum(["left","right"]),Oo=C.enum(["y","z"]),iI=C.object({handedness:$d,upAxis:Oo.default("y"),unitScale:C.number().positive().default(1)}).passthrough();var yd=C.tuple([C.number(),C.number(),C.number(),C.number(),C.number(),C.number()]),wg=C.literal("aabb"),Ig=C.object({position:Do,rotation:vd,scale:Do}),Sg=C.object({name:C.string().max(zt.maxSceneProxyMeshNameLength),aabb:yd,triangles:C.number().int().nonnegative().optional(),path:C.string().min(1).max(zt.maxSceneProxyMeshPathLength).optional(),world:Ig.optional()}),mr=1,bd=C.object({version:C.literal(mr),sceneId:fn,kind:wg,bounds:yd,upAxis:Oo,handedness:$d.optional(),unitScale:C.number().positive(),meshes:C.array(Sg).max(zt.maxSceneProxyMeshes),meshCount:C.number().int().nonnegative(),contentHash:C.string().min(1),capturedAt:hd,sdkVersion:C.string().min(1)});var jo=class{maxSize;items=[];constructor(n){this.maxSize=n}get size(){return this.items.length}enqueue(n){this.items.push(n),this.items.length>this.maxSize&&this.items.splice(0,this.items.length-this.maxSize)}drain(){let n=this.items;return this.items=[],n}prepend(n){this.items=[...n,...this.items],this.items.length>this.maxSize&&this.items.splice(0,this.items.length-this.maxSize)}};function Pg(){let e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Dg(e){let n=e.replace(/\/$/,"")+"/api/v1/collect";return{async send(i){let o=JSON.stringify(i),t=globalThis.navigator;if(t&&typeof t.sendBeacon=="function"){let a=new Blob([o],{type:"application/json"});return t.sendBeacon(n,a)}let r=globalThis.fetch;if(typeof r!="function")return!1;try{return(await r(n,{method:"POST",headers:{"content-type":"application/json"},body:o,keepalive:o.length<64e3})).ok}catch{return!1}}}}function Og(e){return{process:n=>e.send(n),processUnload:n=>e.send(n),dispose:()=>{}}}var Zb="/api/v1/collect";function Vb(e){return e.replace(/\/$/,"")+Zb}function Lb(e){let n=new Set,i=[];for(let o of e.events)for(let t of Object.values(o)){let r;t instanceof ArrayBuffer?r=t:ArrayBuffer.isView(t)&&(r=t.buffer),r&&!n.has(r)&&(n.add(r),i.push(r))}return i}function _d(){return new Worker(new URL("./offloadWorker.js",import.meta.url),{type:"module"})}function jg(e){let n=e.workerFactory??_d,i;try{i=n()}catch{return null}let o=1,t=!1,r=new Map,a=c=>{for(let s of r.values())s(c);r.clear()};i.addEventListener("message",c=>{let s=c.data;if(!s||s.type!=="result")return;let u=r.get(s.id);u&&(r.delete(s.id),u(s.ok))}),i.addEventListener("error",()=>{a(!1)});try{i.postMessage({type:"init",url:Vb(e.endpoint)})}catch{return i.terminate?.(),null}return{process(c){if(t)return Promise.resolve(!1);let s=o++;return new Promise(u=>{r.set(s,u);try{i.postMessage({type:"batch",id:s,batch:c},Lb(c))}catch{r.delete(s),u(!1)}})},processUnload:c=>e.unloadTransport.send(c),dispose:()=>{t||(t=!0,a(!1),i.terminate?.())}}}var No={orbitDeg:1,rollDeg:1,zoom:.02,pan:.005},Mb=180/Math.PI;function mn(e,n){return[e[0]-n[0],e[1]-n[1],e[2]-n[2]]}function Ie(e,n){return e[0]*n[0]+e[1]*n[1]+e[2]*n[2]}function gn(e){return Math.hypot(e[0],e[1],e[2])}function pn(e){let n=gn(e);return n>1e-9?[e[0]/n,e[1]/n,e[2]/n]:[0,0,0]}function Ug(e,n){let i=gn(e),o=gn(n);if(i<1e-9||o<1e-9)return 0;let t=Math.min(1,Math.max(-1,Ie(e,n)/(i*o)));return Math.acos(t)*Mb}function Ng(e,n){let i=e.position,o=pn(e.forward),t=n.position,r=pn(n.forward),a=mn(i,t),c=Ie(o,o),s=Ie(o,r),u=Ie(r,r),l=Ie(o,a),d=Ie(r,a),f=c*u-s*s;if(f<1e-4)return null;let m=(s*d-u*l)/f,v=(c*d-s*l)/f;if(m<=0||v<=0)return null;let y=[i[0]+m*o[0],i[1]+m*o[1],i[2]+m*o[2]],x=[t[0]+v*r[0],t[1]+v*r[1],t[2]+v*r[2]];return{pivot:[(y[0]+x[0])/2,(y[1]+x[1])/2,(y[2]+x[2])/2],distance:(m+v)/2}}function Rb(e,n){if(!e.up||!n.up)return 0;let i=pn([e.forward[0]+n.forward[0],e.forward[1]+n.forward[1],e.forward[2]+n.forward[2]]);if(gn(i)<1e-6)return 0;let o=pn(mn(e.up,[i[0]*Ie(e.up,i),i[1]*Ie(e.up,i),i[2]*Ie(e.up,i)])),t=pn(mn(n.up,[i[0]*Ie(n.up,i),i[1]*Ie(n.up,i),i[2]*Ie(n.up,i)]));return Ug(o,t)}function Tg(e,n,i={}){let o=i.sensitivity&&i.sensitivity>0?i.sensitivity:1,t={orbitDeg:(i.thresholds?.orbitDeg??No.orbitDeg)*o,rollDeg:(i.thresholds?.rollDeg??No.rollDeg)*o,zoom:(i.thresholds?.zoom??No.zoom)*o,pan:(i.thresholds?.pan??No.pan)*o},r=e.pivot&&e.distance!==void 0?{pivot:e.pivot,distance:e.distance,explicit:!0}:null,a=r?null:Ng(e,n),c=r??(a?{...a,explicit:!1}:null),s=Ug(e.forward,n.forward),u=Rb(e,n),l,d=!1;e.fov!==void 0&&n.fov!==void 0&&n.fov>1e-6?l=e.fov/n.fov:r&&e.distance!==void 0&&n.distance!==void 0&&n.distance>1e-6&&(l=e.distance/n.distance,d=!0);let f=mn(n.position,e.position),m,v=!1;if(c){let U=r?n.pivot??c.pivot:Ng(n,e)?.pivot??c.pivot,j=mn(U,c.pivot),O=pn(e.forward),Y=Ie(j,O),ce=mn(j,[O[0]*Y,O[1]*Y,O[2]*Y]);m=gn(ce)}else m=gn(f),v=m>0;let y=c&&c.distance>1e-6?c.distance:i.sceneRadius&&i.sceneRadius>1e-6?i.sceneRadius:void 0,x=y?m/y:m,I=l!==void 0?Math.abs(l-1):0,h=[];if(s>t.orbitDeg&&h.push({kind:"orbit",ratio:s/t.orbitDeg}),u>t.rollDeg&&h.push({kind:"roll",ratio:u/t.rollDeg}),I>t.zoom&&h.push({kind:d?"dolly":"zoom",ratio:I/t.zoom}),x>t.pan&&h.push({kind:v?"fly":"pan",ratio:x/t.pan}),h.length===0)return null;h.sort((U,j)=>j.ratio-U.ratio);let A={kind:h[0].kind};return s>t.orbitDeg&&(A.orbitDeg=s),u>t.rollDeg&&(A.rollDeg=u),I>t.zoom&&l!==void 0&&(A.zoomRatio=l),x>t.pan&&(A.panDist=x),A}function Ag(e){let n=[e[12]??0,e[13]??0,e[14]??0],i=Math.hypot(e[0],e[1],e[2]),o=Math.hypot(e[4],e[5],e[6]),t=Math.hypot(e[8],e[9],e[10]);e[0]*(e[5]*e[10]-e[6]*e[9])-e[4]*(e[1]*e[10]-e[2]*e[9])+e[8]*(e[1]*e[6]-e[2]*e[5])<0&&(i=-i);let a=i!==0?1/i:0,c=o!==0?1/o:0,s=t!==0?1/t:0,u=e[0]*a,l=e[1]*a,d=e[2]*a,f=e[4]*c,m=e[5]*c,v=e[6]*c,y=e[8]*s,x=e[9]*s,I=e[10]*s,h=u+m+I,P,A,U,j;if(h>0){let O=.5/Math.sqrt(h+1);j=.25/O,P=(v-x)*O,A=(y-d)*O,U=(l-f)*O}else if(u>m&&u>I){let O=2*Math.sqrt(1+u-m-I);j=(v-x)/O,P=.25*O,A=(f+l)/O,U=(y+d)/O}else if(m>I){let O=2*Math.sqrt(1+m-u-I);j=(y-d)/O,P=(f+l)/O,A=.25*O,U=(x+v)/O}else{let O=2*Math.sqrt(1+I-u-m);j=(l-f)/O,P=(y+d)/O,A=(x+v)/O,U=.25*O}return{position:n,rotation:[P,A,U,j],scale:[i,o,t]}}function pr(e,n){if(e.length===0)return 0;let i=Math.ceil(n/100*e.length),o=Math.min(e.length,Math.max(1,i))-1;return e[o]??0}function Eg(e,n){return[e[0]-n[0],e[1]-n[1],e[2]-n[2]]}function Cg(e,n){return e[0]*n[0]+e[1]*n[1]+e[2]*n[2]}function Uo(e){return Math.hypot(e[0],e[1],e[2])}function xd(e){return e<0?0:e>1?1:e}function To(e,n,i,o,t,r,a){let c=Eg(t,e),s=Uo(c)||1e-6,l=Cg(c,n)/(s*i)>=a,d=Math.atan2(r,s),f=xd(d/(o||1e-6));return{centered:l,frac:f}}function Ao(e,n,i){for(let o=0;o<6;o++)if(Math.abs((e[o]??0)-(n[o]??0))>i)return!1;return!0}function Eo(e){return[Math.round(e[0]*1e3)/1e3,Math.round(e[1]*1e3)/1e3,Math.round(e[2]*1e3)/1e3,Math.round(e[3]*1e3)/1e3,Math.round(e[4]*1e3)/1e3,Math.round(e[5]*1e3)/1e3]}function Pt(e,n,i){return Math.abs(e[0]-n[0])<=i&&Math.abs(e[1]-n[1])<=i&&Math.abs(e[2]-n[2])<=i}function Co(e,n,i){return!(!Pt(e.position,n.position,i)||!Pt(e.direction,n.direction,i)||e.target===void 0!=(n.target===void 0)||e.target&&n.target&&!Pt(e.target,n.target,i)||e.fov===void 0!=(n.fov===void 0)||e.fov!==void 0&&n.fov!==void 0&&Math.abs(e.fov-n.fov)>i||e.aspect===void 0!=(n.aspect===void 0)||e.aspect!==void 0&&n.aspect!==void 0&&Math.abs(e.aspect-n.aspect)>i||e.near===void 0!=(n.near===void 0)||e.near!==void 0&&n.near!==void 0&&Math.abs(e.near-n.near)>i)}function Zo(e,n,i){return!(!Pt(e.position,n.position,i)||Math.abs(e.rotation[0]-n.rotation[0])>i||Math.abs(e.rotation[1]-n.rotation[1])>i||Math.abs(e.rotation[2]-n.rotation[2])>i||Math.abs(e.rotation[3]-n.rotation[3])>i||e.scale===void 0!=(n.scale===void 0)||e.scale&&n.scale&&!Pt(e.scale,n.scale,i))}function kd(e){let n=e.emit,i,o=new Map,t=new Map,r=new Map;function a(l){let d=l.frameTimes,f;if(d.length>0){let y=0;for(let I=0;I<d.length;I++)d[I]>l.jankFrameMs&&y++;let x=Array.from(d).sort((I,h)=>I-h);f={frameTimeP95Ms:pr(x,95),frameTimeP99Ms:pr(x,99),longFrames:y}}let m=e.perf?.suppressIdle??!1,v=e.perf?.fpsThreshold??0;m&&i!==void 0&&Math.abs(l.fps-i)<=v||(i=l.fps,n({type:"frame_perf",fps:l.fps,...f??{},...typeof l.dpr=="number"&&l.dpr>0?{dpr:l.dpr}:{},...l.renderScale!==void 0?{renderScale:l.renderScale}:{},...l.position?{position:l.position}:{}}))}function c(l){let d=l.decomposed??Fb(l.matrix,l.scaleEps),f=l.boneId?`${l.nodeId}\0bone\0${l.boneId}`:l.childPath!==void 0?`${l.nodeId}\0${l.childPath}`:l.nodeId,m=e.node?.suppressIdle??!1,v=o.get(f);m&&v&&Zo(v,d,l.scaleEps)||(o.set(f,d),n({type:"node_transform",nodeId:l.nodeId,...l.childPath!==void 0?{childPath:l.childPath}:{},...l.boneId!==void 0?{boneId:l.boneId}:{},position:d.position,rotation:d.rotation,...d.scale?{scale:d.scale}:{}}))}function s(l){if(l.stepMs<=0)return;let d=e.visibility?.centeredCos??1,f=e.visibility?.boundingBox??!1,m=Uo(l.forward)||1,v=(l.fov||.8)/2;for(let y of l.meshes){let{centered:x,frac:I}=To(l.camPos,l.forward,m,v,y.center,y.radius,d),h=t.get(y.mesh);h||(h={visibleMs:0,centeredMs:0,maxScreenFraction:0},t.set(y.mesh,h)),h.visibleMs+=l.stepMs,x&&(h.centeredMs+=l.stepMs),I>h.maxScreenFraction&&(h.maxScreenFraction=I),f&&y.aabb&&(h.bounds=y.aabb)}}function u(){if(t.size===0)return;let l=e.visibility?.boundsEps??.001,d=t;t=new Map;for(let[f,m]of d){if(m.visibleMs<=0)continue;let v;if(m.bounds){let y=r.get(f);(!y||!Ao(y,m.bounds,l))&&(v=Eo(m.bounds),r.set(f,m.bounds))}n({type:"mesh_visibility",mesh:f,visibleMs:Math.round(m.visibleMs),...m.centeredMs>0?{centeredMs:Math.round(m.centeredMs)}:{},...m.maxScreenFraction>0?{maxScreenFraction:Math.round(m.maxScreenFraction*1e4)/1e4}:{},...v?{bounds:v}:{}})}}return{ingest(l){switch(l.channel){case"camera":n({type:"camera_sample",position:l.position,direction:l.direction,...l.target?{target:l.target}:{},...l.fov!==void 0?{fov:l.fov}:{},...l.aspect!==void 0?{aspect:l.aspect}:{},...l.near!==void 0?{near:l.near}:{},...l.hitPoint?{hitPoint:l.hitPoint}:{},...l.hitMesh?{hitMesh:l.hitMesh}:{}});return;case"perf":a(l);return;case"node":c(l);return;case"visibilityTick":s(l);return;case"visibilityFlush":u();return;case"gesture":{let d=Tg(l.start,l.end,l.options??{});if(!d)return;n({type:"camera_gesture",kind:d.kind,durationMs:l.durationMs,...d.orbitDeg!==void 0?{orbitDeg:d.orbitDeg}:{},...d.rollDeg!==void 0?{rollDeg:d.rollDeg}:{},...d.zoomRatio!==void 0?{zoomRatio:d.zoomRatio}:{},...d.panDist!==void 0?{panDist:d.panDist}:{},...l.source?{source:l.source}:{}});return}case"hover":n({type:"hover_dwell",mesh:l.mesh,dwellMs:l.dwellMs,...l.source?{source:l.source}:{},...l.uv?{uv:l.uv}:{}});return}},reset(){i=void 0,o.clear(),t=new Map,r.clear()}}}function Fb(e,n){if(!e||e.length<16)return{position:[0,0,0],rotation:[0,0,0,1]};let i=Ag(e),o={position:i.position,rotation:i.rotation},[t,r,a]=i.scale;return(Math.abs(t-1)>n||Math.abs(r-1)>n||Math.abs(a-1)>n)&&(o.scale=i.scale),o}function wd(e){return e.channel==="perf"?[e.frameTimes.buffer]:e.channel==="node"&&e.matrix?[e.matrix.buffer]:[]}function Zg(e){return{ingest:n=>e.ingest(n),drain:()=>Promise.resolve(),dispose:()=>{}}}function Vg(e){let n=e.workerFactory??_d,i;try{i=n()}catch{return null}let o=!1,t=1,r=new Map;i.addEventListener("message",a=>{let c=a.data;if(c){if(c.type==="events")e.onEvents(c.events,c.capturedAt);else if(c.type==="unloadDone"){let s=r.get(c.id);s&&(r.delete(c.id),s())}}}),i.addEventListener("error",()=>{for(let a of r.values())a();r.clear()});try{i.postMessage({type:"aggInit",config:e.config})}catch{return i.terminate?.(),null}return{ingest(a,c){if(!o)try{i.postMessage({type:"snapshot",capturedAt:c,snapshot:a},wd(a))}catch{}},drain(){if(o)return Promise.resolve();let a=t++;return new Promise(c=>{r.set(a,c);try{i.postMessage({type:"flushUnload",id:a})}catch{r.delete(a),c()}})},dispose(){if(!o){o=!0;for(let a of r.values())a();r.clear(),i.terminate?.()}}}}var gr="0.1.0";var Vo={batchSize:20,flushIntervalMs:5e3,maxQueueSize:1e3,resizeDebounceMs:250};function Jb(e){return{projectId:e.projectId,endpoint:e.endpoint,sdkVersion:e.sdkVersion??gr,batchSize:e.batchSize??Vo.batchSize,flushIntervalMs:e.flushIntervalMs??Vo.flushIntervalMs,maxQueueSize:e.maxQueueSize??Vo.maxQueueSize,offload:e.offload??"main",disabled:e.disabled??!1,captureLifecycle:e.captureLifecycle??!0,resizeDebounceMs:e.resizeDebounceMs??Vo.resizeDebounceMs,captureErrors:e.captureErrors??!1,captureGraphicsDiagnostics:e.captureGraphicsDiagnostics??!1,captureShaderSource:e.captureShaderSource??!1,debug:e.debug??!1}}var vr=class e{config;sessionId;queue;transport;processor;beforeSend;collectors=[];handles=[];aggSinks=[];customTransport;createWorkerFn;started=!1;startedAt=0;url;currentScene=Sr;pageMeta;flushTimer;resizeTimer;errorCount=0;lastErrorKey;positionProvider;boundVisibility=()=>this.onVisibilityChange();boundPageHide=()=>{this.stop("hidden")};boundFocus=()=>this.onFocusChange(!0);boundBlur=()=>this.onFocusChange(!1);boundResize=()=>this.onResize();boundError=n=>this.onErrorEvent(n);boundRejection=n=>this.onUnhandledRejection(n);constructor(n){this.config=Jb(n),this.sessionId=Pg(),this.queue=new jo(this.config.maxQueueSize),this.transport=n.transport??Dg(this.config.endpoint),this.customTransport=n.transport,this.createWorkerFn=n.createWorker,this.processor=this.createProcessor(n),this.beforeSend=n.beforeSend}use(n){return this.collectors.push(n),this.started&&this.startCollector(n),this}start(n={}){if(!(this.started||this.config.disabled)){if(this.started=!0,this.startedAt=this.now(),this.url=n.url??this.defaultUrl(),this.pageMeta=n.pageMeta,n.sceneId!=null){let i=fn.safeParse(n.sceneId);i.success?this.currentScene=i.data:this.log(`ignoring invalid initial sceneId: ${String(n.sceneId)}`)}this.emit({type:"session_start",...n.device?{device:n.device}:{},...n.graphics?{graphics:n.graphics}:{},...n.scene?{scene:n.scene}:{},...n.connector?{connector:n.connector}:{},...n.user?{user:n.user}:{}}),this.config.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.config.flushIntervalMs)),this.bindLifecycle();for(let i of this.collectors)this.startCollector(i)}}setScene(n){if(this.config.disabled)return;let i=fn.safeParse(n);if(!i.success){this.log(`ignoring invalid sceneId: ${String(n)}`);return}i.data!==this.currentScene&&(this.currentScene=i.data,this.started&&this.emit({type:"scene_change"}))}setPositionProvider(n){this.positionProvider=n}emit(n){!this.started||this.config.disabled||this.emitInternal(n,this.now())}emitInternal(n,i){if(this.config.disabled)return;let o={...n,projectId:this.config.projectId,sessionId:this.sessionId,ts:i,sdkVersion:this.config.sdkVersion,...this.url?{url:this.url}:{},...this.currentScene!==Sr?{sceneId:this.currentScene}:{},...this.pageMeta?{pageMeta:this.pageMeta}:{}};this.enrichPosition(o);let t=this.beforeSend?this.beforeSend(o):o;t&&(this.queue.enqueue(t),this.queue.size>=this.config.batchSize&&this.flush())}enrichPosition(n){if(!(n.type!=="runtime_error"&&n.type!=="graphics_diagnostic")&&!(this.positionProvider===void 0||n.position))try{let i=this.positionProvider();i&&(n.position=i)}catch(i){this.log("positionProvider threw; emitting without position",i)}}track(n,i){this.emit({type:"custom",name:n,...i?{props:i}:{}})}trackInput(n,i={}){n&&this.emit({type:"input_action",action:n,source:i.source??"keyboard",...i.code?{code:i.code}:{},...typeof i.button=="number"?{button:i.button}:{},...typeof i.pressed=="boolean"?{pressed:i.pressed}:{},...i.handedness?{handedness:i.handedness}:{},...i.sourceId?{sourceId:i.sourceId}:{}})}reportCapabilityChange(n){n.kind&&this.emit({type:"capability_change",kind:n.kind,...n.from?{from:n.from}:{},...n.to?{to:n.to}:{},...n.reason?{reason:n.reason}:{},...typeof n.durationMs=="number"?{durationMs:n.durationMs}:{},...n.source?{source:n.source}:{},...n.handedness?{handedness:n.handedness}:{}})}async flush(n){let i=this.queue.drain();if(i.length===0)return;let o={schemaVersion:"1.0",events:i};await(n?.unload?this.processor.processUnload(o):this.processor.process(o))||(this.queue.prepend(i),this.log("flush failed; re-queued",i.length))}async stop(n="manual"){if(this.started){this.emit({type:"session_end",durationMs:this.now()-this.startedAt,reason:n}),this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0),this.unbindLifecycle();for(let i of this.handles.splice(0))i.stop();this.aggSinks.length>0&&await Promise.all(this.aggSinks.map(i=>i.drain())),this.started=!1,await this.flush({unload:!0});for(let i of this.aggSinks.splice(0))i.dispose();this.processor.dispose()}}now(){return Date.now()}createProcessor(n){if(this.config.offload==="worker")if(n.transport)this.log("custom transport set; worker offload disabled (transport runs on main thread)");else{let i=jg({endpoint:this.config.endpoint,unloadTransport:this.transport,...n.createWorker?{workerFactory:n.createWorker}:{}});if(i)return i;this.log("worker offload unavailable; falling back to main-thread processor")}return Og(this.transport)}createAggregation(n){if(this.config.offload==="worker"&&!this.customTransport){let t=Vg({config:n,onEvents:(r,a)=>{for(let c of r)this.emitInternal(c,a)},...this.createWorkerFn?{workerFactory:this.createWorkerFn}:{}});if(t)return this.aggSinks.push(t),r=>t.ingest(r,this.now());this.log("worker aggregation unavailable; falling back to main-thread aggregator")}let i=kd({...n,emit:t=>this.emit(t)}),o=Zg(i);return this.aggSinks.push(o),t=>o.ingest(t,this.now())}startCollector(n){let i={config:this.config,sessionId:this.sessionId,emit:o=>this.emit(o),track:(o,t)=>this.track(o,t),trackInput:(o,t)=>this.trackInput(o,t),reportCapabilityChange:o=>this.reportCapabilityChange(o),setScene:o=>this.setScene(o),setPositionProvider:o=>this.setPositionProvider(o),createAggregation:o=>this.createAggregation(o),now:()=>this.now()};try{let o=n.start(i);o&&this.handles.push(o)}catch(o){this.log(`collector "${n.name}" failed to start`,o)}}onVisibilityChange(){let n=globalThis.document,i=n?.visibilityState==="hidden";this.config.captureLifecycle&&n&&this.emit({type:"visibility_change",state:i?"hidden":"visible"}),i&&this.flush({unload:!0})}onFocusChange(n){this.config.captureLifecycle&&this.emit({type:"focus_change",focused:n})}onResize(){this.config.captureLifecycle&&(this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(()=>{this.resizeTimer=void 0,this.emitViewportResize()},this.config.resizeDebounceMs))}emitViewportResize(){let n=globalThis;typeof n.innerWidth!="number"||typeof n.innerHeight!="number"||n.innerWidth<=0||n.innerHeight<=0||this.emit({type:"viewport_resize",width:n.innerWidth,height:n.innerHeight,...typeof n.devicePixelRatio=="number"?{dpr:n.devicePixelRatio}:{}})}static MAX_ERRORS_PER_SESSION=50;onErrorEvent(n){this.emitError({kind:"error",message:n.message||"Unknown error",...n.filename?{source:n.filename}:{},...typeof n.lineno=="number"?{lineno:n.lineno}:{},...typeof n.colno=="number"?{colno:n.colno}:{},...n.error instanceof Error&&n.error.stack?{stack:n.error.stack}:{}})}onUnhandledRejection(n){let i=n.reason,o=i instanceof Error?i.message:typeof i=="string"?i:"Unhandled promise rejection";this.emitError({kind:"unhandledrejection",message:o||"Unhandled promise rejection",...i instanceof Error&&i.stack?{stack:i.stack}:{}})}emitError(n){if(this.errorCount>=e.MAX_ERRORS_PER_SESSION)return;let i=`${n.message}\0${n.stack??""}`;i!==this.lastErrorKey&&(this.lastErrorKey=i,this.errorCount+=1,this.emit({type:"runtime_error",kind:n.kind,message:n.message.slice(0,1024),...n.source?{source:n.source.slice(0,1024)}:{},...typeof n.lineno=="number"?{lineno:n.lineno}:{},...typeof n.colno=="number"?{colno:n.colno}:{},...n.stack?{stack:n.stack.slice(0,4096)}:{}}))}bindLifecycle(){let n=globalThis.document,i=globalThis.addEventListener?globalThis:void 0;n?.addEventListener("visibilitychange",this.boundVisibility),i?.addEventListener("pagehide",this.boundPageHide),this.config.captureLifecycle&&i&&(i.addEventListener("focus",this.boundFocus),i.addEventListener("blur",this.boundBlur),i.addEventListener("resize",this.boundResize),this.emitViewportResize()),this.config.captureErrors&&i&&(i.addEventListener("error",this.boundError),i.addEventListener("unhandledrejection",this.boundRejection))}unbindLifecycle(){let n=globalThis.document,i=globalThis.removeEventListener?globalThis:void 0;n?.removeEventListener("visibilitychange",this.boundVisibility),i?.removeEventListener("pagehide",this.boundPageHide),i?.removeEventListener("focus",this.boundFocus),i?.removeEventListener("blur",this.boundBlur),i?.removeEventListener("resize",this.boundResize),i?.removeEventListener("error",this.boundError),i?.removeEventListener("unhandledrejection",this.boundRejection),this.resizeTimer&&(clearTimeout(this.resizeTimer),this.resizeTimer=void 0)}defaultUrl(){return globalThis.location?.href}log(...n){this.config.debug&&console.debug("[uptimizr]",...n)}};function Dt(e,n){return e===void 0?{mode:"interval",ms:n}:e==="frame"?{mode:"frame"}:e<=0?{mode:"off"}:{mode:"interval",ms:1e3/e}}function ae(e){return e===0?0:e}function Re(e,n){return n==="left"?[e[0],e[1],e[2]]:[ae(e[0]),ae(e[1]),ae(-e[2])]}function hr(e,n){return n==="left"?[e[0],e[1],e[2]]:[ae(e[0]),ae(e[1]),ae(-e[2])]}function Id(e,n){return n==="left"?[e[0],e[1],e[2],e[3],e[4],e[5]]:[ae(e[0]),ae(e[1]),ae(-e[5]),ae(e[3]),ae(e[4]),ae(-e[2])]}function vn(e,n){return n==="left"?[e[0],e[1],e[2],e[3]]:[ae(-e[0]),ae(-e[1]),ae(e[2]),ae(e[3])]}function Lo(e){return[e.x,e.y,e.z]}function Mo(e){return e<0?0:e>1?1:e}import{Ray as Lg,Vec3 as ct}from"playcanvas";var Mg="uptimizr-";function Sd(e,n){let i=new Lg,o=new ct,t=new ct,r=new ct,a=new ct;return(c,s)=>{let u=n.camera,l=u?.camera;if(!u||!l)return;let d=e.graphicsDevice,f=d?.canvas,m=f?.clientWidth||f?.width||d?.width||1,v=f?.clientHeight||f?.height||d?.height||1,y=(c+1)/2*m,x=(1-s)/2*v,I=u.nearClip??.1,h=u.farClip??1e3;l.screenToWorld(y,x,I,m,v,o),l.screenToWorld(y,x,h,m,v,t),i.origin.copy(o),i.direction.copy(t).sub(o).normalize();let P=1/0,A;if(e.root?.forEach?.(j=>{let O=j;if(O.enabled===!1)return;let Y=O.render?.meshInstances??O.model?.meshInstances;if(Y)for(let ce of Y){if(ce.visible===!1)continue;let se=ce.node?.name??"";if(se.startsWith(Mg))continue;let Oe=ce.aabb;if(!Oe||typeof Oe.intersectsRay!="function"||!Oe.intersectsRay(i,r))continue;let Se=r.x-i.origin.x,je=r.y-i.origin.y,Ne=r.z-i.origin.z,st=Se*Se+je*je+Ne*Ne;st<P&&(P=st,A=se,a.copy(r))}}),A!==void 0)return{point:[a.x,a.y,a.z],name:A}}}function zd(e,n,i={}){let o=new Lg,t=new ct,r=new ct,a=new ct,c=new ct,s=i.maxDistance??1e3,u=s*s,l=i.meshes&&i.meshes.length>0?new Set(i.meshes):null,d=i.predicate;return()=>{let f=n.camera,m=f?.camera;if(!f||!m)return;let v=e.graphicsDevice,y=v?.canvas,x=y?.clientWidth||y?.width||v?.width||1,I=y?.clientHeight||y?.height||v?.height||1,h=x/2,P=I/2,A=f.nearClip??.1,U=f.farClip??1e3;m.screenToWorld(h,P,A,x,I,t),m.screenToWorld(h,P,U,x,I,r),o.origin.copy(t),o.direction.copy(r).sub(t).normalize();let j=1/0,O;if(e.root?.forEach?.(ce=>{let se=ce;if(se.enabled===!1)return;let Oe=se.render?.meshInstances??se.model?.meshInstances;if(Oe)for(let Se of Oe){if(Se.visible===!1)continue;let je=Se.node?.name??"";if(je.startsWith(Mg)||l&&!l.has(je)||d&&Se.node&&!d(Se.node))continue;let Ne=Se.aabb;if(!Ne||typeof Ne.intersectsRay!="function"||!Ne.intersectsRay(o,a))continue;let st=a.x-o.origin.x,hn=a.y-o.origin.y,Go=a.z-o.origin.z,$r=st*st+hn*hn+Go*Go;$r<j&&(j=$r,O=je,c.copy(a))}}),!(O===void 0||j>u))return{point:[c.x,c.y,c.z],name:O}}}function Rg(e){let n=e.pointerType;return n==="mouse"||n==="pen"||n==="touch"?n:typeof n=="string"&&n.length>0?"other":void 0}function Gb(e){if(typeof document>"u")return!1;let n=document.pointerLockElement;return n!=null&&n===e()}var Bb=zt.maxAssetNameLength;function Wb(e,n){return[e[0]-n[0],e[1]-n[1],e[2]-n[2]]}function Kb(e,n){return e[0]*n[0]+e[1]*n[1]+e[2]*n[2]}function Xb(e){return e!==null&&typeof e=="object"?e.hz:e}function qb(e){if(e===null||typeof e!="object")return null;let n=e.include;return n==="*"||Array.isArray(n)&&n.length>0?{include:n,maxDepth:e.maxDepth??8,maxNodes:e.maxNodes??64,exclude:new Set(e.exclude??[])}:null}function Hb(e,n){let i=[],o=n.include==="*",t=o?null:new Set(n.include),r=[];for(let a of e.children??[])r.push({node:a,path:a.name??"",depth:1});for(;r.length>0&&i.length<n.maxNodes;){let{node:a,path:c,depth:s}=r.shift(),u=a.name;if(!(typeof u!="string"||u.length===0)&&!n.exclude.has(u)&&!Gg(a)&&((o||t.has(u))&&i.push({childPath:c,node:a}),s<n.maxDepth))for(let l of a.children??[]){let d=l.name??"";r.push({node:l,path:c?`${c}/${d}`:d,depth:s+1})}}return i}function Gg(e){return e.camera!=null}function Fg(e,n){let i=e.getPosition?.()??{x:0,y:0,z:0},o=e.getRotation?.()??{x:0,y:0,z:0,w:1},t={position:Re([i.x,i.y,i.z],"right"),rotation:vn([o.x,o.y,o.z,o.w],"right")},r=e.getWorldTransform?.()?.getScale?.();return r&&(Math.abs(r.x-1)>n||Math.abs(r.y-1)>n||Math.abs(r.z-1)>n)&&(t.scale=Lo(r)),t}function Jg(e,n){return typeof n=="function"?n()??null:typeof n=="string"?e.findByName?.(n)??null:n??null}function Yb(e){let n=new Set,i=[],o=[...e.render?.meshInstances??[],...e.model?.meshInstances??[]];for(let t of o){let r=t.skinInstance?.bones;if(r)for(let a of r){let c=a?.name;typeof c!="string"||n.has(c)||(n.add(c),i.push(a))}}return i}function Qb(e,n){let i=Yb(e);if(i.length===0)return[];if(n==="*")return i;let o=new Map;for(let r of i)typeof r.name=="string"&&o.set(r.name,r);let t=[];for(let r of n){let a=o.get(r);a&&t.push(a)}return t}function e_(e,n){if(!e.getLocalPosition||!e.getLocalRotation)return null;let i=e.getLocalPosition(),o=e.getLocalRotation(),t={position:Re([i.x,i.y,i.z],"right"),rotation:vn([o.x,o.y,o.z,o.w],"right")},r=e.getLocalScale?.();return r&&(Math.abs(r.x-1)>n||Math.abs(r.y-1)>n||Math.abs(r.z-1)>n)&&(t.scale=Lo(r)),t}function Bg(e){return e.render?.meshInstances??e.model?.meshInstances??[]}function t_(e){let n=1/0,i=1/0,o=1/0,t=-1/0,r=-1/0,a=-1/0,c=!1;for(let s of Bg(e)){let u=s.aabb;if(!u||typeof u.getMin!="function"||typeof u.getMax!="function")continue;let l=u.getMin(),d=u.getMax();c=!0,l.x<n&&(n=l.x),l.y<i&&(i=l.y),l.z<o&&(o=l.z),d.x>t&&(t=d.x),d.y>r&&(r=d.y),d.z>a&&(a=d.z)}return c?{center:[(n+t)/2,(i+r)/2,(o+a)/2],radius:.5*Math.hypot(t-n,r-i,a-o),aabb:[n,i,o,t,r,a]}:null}function n_(e,n,i,o){return Kb(Wb(e,i),o)+n>0}function Pd(e){let{app:n,camera:i,sampleCameraMs:o=1e3,samplePerfMs:t=2e3,pointerMoveThrottleMs:r=250,suppressIdleSamples:a=!0,suppressIdlePerfSamples:c=!1,cameraEpsilon:s=.001,perfFpsThreshold:u=1,cameraGestureSensitivity:l=1,capture:d={},sampling:f={}}=e,m=Dt(f.camera,o),v=Dt(f.perf,t),y=Dt(f.pointerMove,r),x=e.keyBindings??{},I=Object.keys(x).length>0,h={camera:(d.camera??!0)&&m.mode!=="off",pointerMove:(d.pointerMove??!0)&&y.mode!=="off",clicks:d.clicks??!0,buttons:d.buttons??!0,cameraGesture:d.cameraGesture??!0,meshPicks:d.meshPicks??!0,perf:(d.perf??!0)&&v.mode!=="off",contextLoss:d.contextLoss??!0,assetLoad:d.assetLoad??!0,meshVisibility:d.meshVisibility??!1,hoverDwell:d.hoverDwell??!1,resourceSample:d.resourceSample??!1,gaze:(d.gaze??!1)&&(d.camera??!0)&&m.mode!=="off",nodes:d.nodes??!0,bones:d.bones??!0,keyboard:(d.keyboard??!0)&&I},P=e.actors??{},A=h.nodes?Object.keys(f.nodes??{}).filter(K=>{let ye=Object.prototype.hasOwnProperty.call(P,K);return ye||console.warn(`[uptimizr] sampling.nodes["${K}"] has no matching entry in \`actors\`; ignoring. Declare the node in \`actors\` to capture its transform.`),ye}):[],U=A.length>0,j=h.bones?Object.keys(f.bones??{}).filter(K=>{if(!Object.prototype.hasOwnProperty.call(P,K))return console.warn(`[uptimizr] sampling.bones["${K}"] has no matching entry in \`actors\`; ignoring. Declare the node in \`actors\` to capture its bones.`),!1;let be=f.bones[K].include;return be!=="*"&&(!Array.isArray(be)||be.length===0)?(console.warn(`[uptimizr] sampling.bones["${K}"].include is empty; ignoring. Provide bone names or "*" to capture bones.`),!1):!0}):[],O=j.length>0,Y=e.meshVisibility??{},ce=Y.windowMs??5e3,se=Y.meshes&&Y.meshes.length>0?new Set(Y.meshes):void 0,Oe=Math.cos((Y.centeredAngleDeg??12)*Math.PI/180),Se=Y.maxMeshes??50,je=Y.boundingBox??!1,Ne=e.hoverDwell??{},st=Ne.minDwellMs??500,hn=Ne.meshes&&Ne.meshes.length>0?new Set(Ne.meshes):void 0,$r=(e.resourceSample??{}).intervalMs??15e3,Ad=y.mode==="interval"?y.ms:0;return{name:"playcanvas",start(K){let ye=n,Ed={perf:{suppressIdle:c,fpsThreshold:u},node:{suppressIdle:a},visibility:{centeredCos:Oe,boundingBox:je,boundsEps:.001}},be=K.createAggregation(Ed),$n=[],yn=[],yr=[],bn=[],br=!1,Cd=!1,_r=0,Bo,Wo=null,qg=()=>ye.stats?.frame?.fps??0,Ko=w=>{if(!w||typeof w.fov!="number")return;let D=w.fov*Math.PI/180;if(w.horizontalFov){let z=typeof w.aspectRatio=="number"&&w.aspectRatio>0?w.aspectRatio:1;return 2*Math.atan(Math.tan(D/2)/z)}return D},Hg=h.gaze?e.gaze?.probe??zd(n,i,e.gaze??{}):void 0,Zd=()=>{let w=i,D=w.getPosition(),z=w.forward,V=Re([D.x,D.y,D.z],"right"),G=hr([z.x,z.y,z.z],"right"),L=Ko(w.camera),F={position:V,direction:G,...L!==void 0?{fov:L}:{}};if(a&&Bo&&Co(Bo,F,s))return;Bo=F;let J=Hg?.(),te=J?Re(J.point,"right"):void 0,_e=J&&J.name?J.name:void 0;be({channel:"camera",position:F.position,direction:F.direction,...F.fov!==void 0?{fov:F.fov}:{},...te?{hitPoint:te}:{},..._e?{hitMesh:_e}:{}})},Vd=()=>{let w=i,D=w.getPosition(),z=w.forward,V=w.up,G={position:Re([D.x,D.y,D.z],"right"),forward:hr([z.x,z.y,z.z],"right"),up:hr([V.x,V.y,V.z],"right")},L=Ko(w.camera);return L!==void 0&&(G.fov=L),G},Yg=()=>{let w=qg();w<=0||be({channel:"perf",frameTimes:new Float32Array(0),fps:w,jankFrameMs:0})},Ld=()=>{if(!Cd)for(let w of yr)w()},Md=()=>{br||(ye.on("frameend",Ld),br=!0)},xr=(w,D)=>{w.mode==="interval"?$n.push(setInterval(D,w.ms)):w.mode==="frame"&&(yr.push(D),Md())};if(h.camera&&(Zd(),xr(m,Zd)),h.perf&&xr(v,Yg),U){let w=ye.root,D=new Set;for(let z of A){let V=P[z],G=f.nodes?.[z],L=Dt(Xb(G),o);if(L.mode==="off")continue;let F=qb(G),J=()=>{let te=Jg(w,V);if(te){if(Gg(te)){D.has(z)||(D.add(z),console.warn(`[uptimizr] actor "${z}" resolves to a camera; refusing node_transform capture. The visitor camera is already captured as camera_sample.`));return}if(be({channel:"node",nodeId:z,decomposed:Fg(te,s),scaleEps:s}),F)for(let{childPath:_e,node:Ce}of Hb(te,F))be({channel:"node",nodeId:z,childPath:_e,decomposed:Fg(Ce,s),scaleEps:s})}};J(),xr(L,J)}}if(O){let w=ye.root,D=new Set;for(let z of j){let V=P[z],G=f.bones[z],L=Dt(G.hz,o);if(L.mode==="off")continue;let F=()=>{let J=Jg(w,V);if(!J)return;let te=Qb(J,G.include);if(te.length===0){D.has(z)||(D.add(z),console.warn(`[uptimizr] actor "${z}" resolves to no matching skeleton bones; skipping Tier 2 capture. Declare the skinned entity and check the bone names.`));return}for(let _e of te){let Ce=_e.name;if(typeof Ce!="string")continue;let kn=e_(_e,s);kn&&be({channel:"node",nodeId:z,boneId:Ce,decomposed:kn,scaleEps:s})}};F(),xr(L,F)}}if(h.meshVisibility){let w=K.now(),D=()=>{let V=K.now(),G=V-w;if(w=V,G<=0)return;let L=i,F=L.getPosition(),J=L.forward,te=[F.x,F.y,F.z],_e=[J.x,J.y,J.z],Ce=Ko(L.camera)??0,kn=0,Xo=[];ye.root?.forEach?.(ov=>{let wr=ov;if(Bg(wr).length===0)return;let Ir=wr.name;if(!Ir||Ir.startsWith("uptimizr-"))return;if(se){if(!se.has(Ir))return}else if(wr.enabled===!1||kn>=Se)return;let Ue=t_(wr);Ue&&(kn++,n_(Ue.center,Ue.radius,te,_e)&&Xo.push({mesh:Ir,center:Ue.center,radius:Ue.radius,...je?{aabb:[Ue.aabb[0],Ue.aabb[1],-Ue.aabb[5],Ue.aabb[3],Ue.aabb[4],-Ue.aabb[2]]}:{}}))}),Xo.length!==0&&be({channel:"visibilityTick",stepMs:G,camPos:te,forward:_e,fov:Ce,meshes:Xo})},z=()=>be({channel:"visibilityFlush"});yr.push(D),Md(),$n.push(setInterval(z,ce)),bn.push(z)}let Qg=h.pointerMove||h.clicks||h.buttons||h.meshPicks||h.hoverDwell,Be=ye.graphicsDevice?.canvas,Rd=Qg&&Be?e.raycast??Sd(n,i):void 0,We=(w,D)=>{Be&&(Be.addEventListener(w,D),yn.push({target:Be,type:w,handler:D}))},ev=w=>{if(Gb(()=>Be))return[.5,.5];let D=Be&&typeof Be.getBoundingClientRect=="function"?Be.getBoundingClientRect():{left:0,top:0,width:0,height:0},z=D.width||1,V=D.height||1;return[Mo((w.clientX-D.left)/z),Mo((w.clientY-D.top)/V)]},tv=w=>{if(!Rd)return;let D=w[0]*2-1,z=1-w[1]*2;return Rd(D,z)},_n=w=>{let D=ev(w),z=tv(D),V=z?Re(z.point,"right"):void 0,G=z?.name?z.name:void 0,L=Rg(w);return{screen:D,...V?{hitPoint:V}:{},...G?{hitMesh:G}:{},...L?{source:L}:{},...z?{hit:z}:{}}},ut,Fd=0,xn=!1,kr,Jd=w=>{if(ut!==void 0&&!xn){let D=w-Fd;D>=st&&be({channel:"hover",mesh:ut,dwellMs:D,...kr?{source:kr}:{}})}ut=void 0,xn=!1,kr=void 0},nv=(w,D,z)=>{let V=D!==void 0&&(!hn||hn.has(D))?D:void 0;V!==ut&&(Jd(w),V!==void 0&&(ut=V,Fd=w,xn=!1,kr=z))},rv=w=>{let D=w;if(h.hoverDwell){let J=_n(D);if(nv(K.now(),J.hitMesh,J.source),h.pointerMove){let te=K.now();te-_r>=Ad&&(_r=te,K.emit({type:"pointer_move",screen:J.screen,...J.hitPoint?{hitPoint:J.hitPoint}:{},...J.hitMesh?{hitMesh:J.hitMesh}:{},...J.source?{source:J.source}:{}}))}return}if(!h.pointerMove)return;let z=K.now();if(z-_r<Ad)return;_r=z;let{screen:V,hitPoint:G,hitMesh:L,source:F}=_n(D);K.emit({type:"pointer_move",screen:V,...G?{hitPoint:G}:{},...L?{hitMesh:L}:{},...F?{source:F}:{}})},Gd=(w,D)=>{let z=D;if(w==="pointer_down"&&h.hoverDwell){let{hitMesh:J}=_n(z);J!==void 0&&J===ut&&(xn=!0)}if(!h.buttons)return;let{screen:V,hitPoint:G,hitMesh:L,source:F}=_n(z);K.emit({type:w,screen:V,...G?{hitPoint:G}:{},...L?{hitMesh:L}:{},...typeof z.button=="number"?{button:z.button}:{},...F?{source:F}:{}})},iv=w=>{let D=w,{screen:z,hitPoint:V,hitMesh:G,source:L,hit:F}=_n(D);h.hoverDwell&&G!==void 0&&G===ut&&(xn=!0),h.clicks&&K.emit({type:"pointer_click",screen:z,...V?{hitPoint:V}:{},...G?{hitMesh:G}:{},...typeof D.button=="number"?{button:D.button}:{},...L?{source:L}:{}}),h.meshPicks&&F&&K.emit({type:"mesh_interaction",mesh:F.name,kind:"pick",...V?{point:V}:{},...L?{source:L}:{}})};if((h.pointerMove||h.hoverDwell)&&We("pointermove",rv),(h.buttons||h.hoverDwell)&&We("pointerdown",w=>Gd("pointer_down",w)),h.buttons&&We("pointerup",w=>Gd("pointer_up",w)),(h.clicks||h.meshPicks||h.hoverDwell)&&We("click",iv),h.cameraGesture){let w=z=>{Wo={sample:Vd(),ts:K.now(),source:Rg(z)}},D=()=>{let z=Wo;Wo=null,z&&be({channel:"gesture",start:z.sample,end:Vd(),durationMs:Math.max(0,Math.round(K.now()-z.ts)),options:{sensitivity:l},...z.source?{source:z.source}:{}})};We("pointerdown",w),We("pointerup",D)}h.hoverDwell&&bn.push(()=>Jd(K.now())),h.contextLoss&&(We("webglcontextlost",()=>K.emit({type:"context_lost"})),We("webglcontextrestored",()=>K.emit({type:"context_restored"})));let lt=ye.assets;if(h.assetLoad&&lt){let w=new Map,D=L=>L.id??L,z=L=>{w.set(D(L),K.now())},V=L=>{let F=L,J=D(F),te=w.get(J);if(te===void 0)return;w.delete(J);let _e={type:"asset_load",name:(F.name??"asset").slice(0,Bb),loadMs:Math.max(0,Math.round(K.now()-te))},Ce=F.file?.size;typeof Ce=="number"&&Ce>0&&(_e.bytes=Ce),K.emit(_e)},G=(...L)=>{let F=L[1];F&&w.delete(D(F))};lt.on("load:start",z),lt.on("load",V),lt.on("error",G),bn.push(()=>{lt.off("load:start",z),lt.off("load",V),lt.off("error",G),w.clear()})}if(h.resourceSample){let w=()=>{let D={},z=ye.stats?.frame?.triangles;typeof z=="number"&&z>0&&(D.triangles=Math.round(z));let V=globalThis.performance?.memory;V&&typeof V.usedJSHeapSize=="number"&&V.usedJSHeapSize>0&&(D.jsHeapBytes=V.usedJSHeapSize),Object.keys(D).length!==0&&K.emit({type:"resource_sample",...D})};$n.push(setInterval(w,$r))}if(h.keyboard&&typeof window<"u"){let w=window,D=G=>L=>{let F=L,J=F.code;if(!J||G&&F.repeat)return;let te=x[J];te&&K.trackInput(te,{source:"keyboard",code:J,pressed:G})},z=D(!0),V=D(!1);w.addEventListener("keydown",z),w.addEventListener("keyup",V),yn.push({target:w,type:"keydown",handler:z}),yn.push({target:w,type:"keyup",handler:V})}return{stop(){for(let w of bn)w();bn.length=0,Cd=!0;for(let w of $n)clearInterval(w);$n.length=0,br&&(ye.off("frameend",Ld),br=!1),yr.length=0;for(let w of yn)w.target.removeEventListener(w.type,w.handler);yn.length=0}}}}}function Ro(e){return e.isWebGPU===!0}function Wg(e){let n=e.maxTextureSize;return typeof n=="number"?n:void 0}function Fo(e){let n=e;return n.isWebGPU?!1:n.isWebGL2!==!1}function Jo(e){let i=e.gl;if(!i)return{};let o=i,t={};try{let r=typeof o.getExtension=="function"?o.getExtension("WEBGL_debug_renderer_info"):null,a=r?r.UNMASKED_VENDOR_WEBGL:o.VENDOR,c=r?r.UNMASKED_RENDERER_WEBGL:o.RENDERER,s=o.getParameter(a),u=o.getParameter(c),l=o.getParameter(o.VERSION);typeof s=="string"&&s&&(t.vendor=s),typeof u=="string"&&u&&(t.renderer=u),typeof l=="string"&&l&&(t.version=l)}catch{}return t}function Dd(e){let n=e.graphicsDevice,i=Jo(n),o=typeof navigator<"u"?navigator:void 0,r={engine:Ro(n)?"webgpu":Fo(n)?"webgl2":"webgl"};i.vendor&&(r.vendor=i.vendor),i.renderer&&(r.renderer=i.renderer);let a=Wg(n);return typeof a=="number"&&(r.maxTextureSize=a),typeof o?.hardwareConcurrency=="number"&&(r.hardwareConcurrency=o.hardwareConcurrency),typeof o?.deviceMemory=="number"&&(r.deviceMemoryGb=o.deviceMemory),o?.userAgent&&(r.isMobile=/Mobi|Android|iPhone|iPad/i.test(o.userAgent)),r}function r_(e){if(e){if(/Direct3D11|D3D11/i.test(e))return"d3d11";if(/Direct3D12|D3D12/i.test(e))return"d3d12";if(/Metal/i.test(e))return"metal";if(/Vulkan/i.test(e))return"vulkan";if(/OpenGL ES/i.test(e))return"opengles";if(/OpenGL/i.test(e))return"opengl"}}function Od(e){let n=e.graphicsDevice,i=Ro(n),o=Jo(n),a={api:i?"webgpu":Fo(n)?"webgl2":"webgl",shadingLanguage:i?"wgsl":"glsl-es"},c=i?void 0:r_(o.renderer);return c&&(a.backend=c),o.version&&(a.apiVersion=o.version),a}import{version as jd}from"playcanvas";function Nd(){let e={name:"playcanvas",coordinateSystem:{handedness:"right",upAxis:"y",unitScale:1}};return typeof jd=="string"&&jd&&(e.version=jd),e}import{PROJECTION_ORTHOGRAPHIC as i_,PROJECTION_PERSPECTIVE as o_}from"playcanvas";function Kg(e){let i=e?.camera?.projection;return i===o_?"free":i===i_?"static":"other"}function Ud(e,n){let i={},o=n;o&&(i.cameraType=Kg(n),typeof o.name=="string"&&o.name&&(i.cameraName=o.name));let t=e.root;if(t&&typeof t.forEach=="function"){let r=0;t.forEach(a=>{let c=a,s=c.render?.meshInstances?.length??0,u=c.model?.meshInstances?.length??0;r+=s+u}),i.meshCount=r}return i}function a_(e,n,i){let o=new vr({projectId:i.projectId,endpoint:i.endpoint,flushIntervalMs:i.flushIntervalMs,transport:i.transport,disabled:i.disabled,debug:i.debug});o.use(Pd({app:e,camera:n,sampleCameraMs:i.sampleCameraMs,samplePerfMs:i.samplePerfMs,pointerMoveThrottleMs:i.pointerMoveThrottleMs,suppressIdleSamples:i.suppressIdleSamples,suppressIdlePerfSamples:i.suppressIdlePerfSamples,cameraEpsilon:i.cameraEpsilon,perfFpsThreshold:i.perfFpsThreshold,capture:i.capture,...i.gaze?{gaze:i.gaze}:{},...i.sampling?{sampling:i.sampling}:{},...i.actors?{actors:i.actors}:{},...i.keyBindings?{keyBindings:i.keyBindings}:{}}));let t={...Ud(e,n),...i.sceneDescription?{description:i.sceneDescription}:{},...i.cameraType?{cameraType:i.cameraType}:{}};return o.start({device:Dd(e),graphics:Od(e),connector:Nd(),scene:t,...i.user?{user:i.user}:{},...i.meta}),o}function c_(e,n){let i=[],o=e;for(;o&&o!==n;){let t=typeof o.name=="string"?o.name:"";if(!t)return;i.unshift(t),o=o.parent}return i.length>0?i.join("/"):void 0}function s_(e){let n=e.getPosition?.(),i=e.getRotation?.(),o=e.getWorldTransform?.()?.getScale?.();if(!(!n||!i||!o))return{position:Re([n.x,n.y,n.z],"right"),rotation:vn([i.x,i.y,i.z,i.w??1],"right"),scale:[o.x,o.y,o.z]}}var u_="uptimizr-";function De(e){return Math.round(e*1e4)/1e4}function l_(e){let n=2166136261;for(let i=0;i<e.length;i++)n^=e.charCodeAt(i),n=Math.imul(n,16777619);return(n>>>0).toString(16).padStart(8,"0")}function Xg(e){return Math.abs((e[3]-e[0])*(e[4]-e[1])*(e[5]-e[2]))}function Td(e){return e.render?.meshInstances??e.model?.meshInstances??[]}function d_(e){let i=Td(e);if(i.length===0)return;let o=1/0,t=1/0,r=1/0,a=-1/0,c=-1/0,s=-1/0,u=!1;for(let l of i){let d=l.aabb;if(!d||typeof d.getMin!="function"||typeof d.getMax!="function")continue;let f=d.getMin(),m=d.getMax();u=!0,f.x<o&&(o=f.x),f.y<t&&(t=f.y),f.z<r&&(r=f.z),m.x>a&&(a=m.x),m.y>c&&(c=m.y),m.z>s&&(s=m.z)}if(u)return[o,t,r,a,c,s]}function f_(e){let n=e,i=0;for(let o of Td(n)){let t=o.mesh?.primitive;if(t)for(let r of t)typeof r.count=="number"&&r.count>0&&(i+=Math.floor(r.count/3))}return i}function m_(e,n){let i=n.boundsOf??d_,o=n.trianglesOf??f_,t=[],r=1/0,a=1/0,c=1/0,s=-1/0,u=-1/0,l=-1/0,d=0,f=e.root;f&&typeof f.forEach=="function"&&f.forEach(I=>{let h=I;if(h.enabled===!1||Td(h).length===0)return;let P=typeof h.name=="string"?h.name:"";if(P.startsWith(u_)||n.includeMesh&&!n.includeMesh(P))return;let A=i(h);if(!A)return;let U=Id(A,"right");d++;let j=[De(U[0]),De(U[1]),De(U[2]),De(U[3]),De(U[4]),De(U[5])],O={name:P,aabb:j},Y=o(h);Y>0&&(O.triangles=Y);let ce=c_(h,f),se=s_(h);ce&&se&&(O.path=ce,O.world=se),t.push(O),r=Math.min(r,U[0]),a=Math.min(a,U[1]),c=Math.min(c,U[2]),s=Math.max(s,U[3]),u=Math.max(u,U[4]),l=Math.max(l,U[5])});let m=t;typeof n.maxMeshes=="number"&&n.maxMeshes>=0&&t.length>n.maxMeshes&&(m=[...t].sort((I,h)=>Xg(h.aabb)-Xg(I.aabb)).slice(0,n.maxMeshes));let v=d===0?[0,0,0,0,0,0]:[De(r),De(a),De(c),De(s),De(u),De(l)],y=JSON.stringify({v:mr,kind:"aabb",bounds:v,meshes:[...m].sort((I,h)=>I.name<h.name?-1:I.name>h.name?1:0).map(I=>I.path&&I.world?[I.name,I.aabb,I.path,I.world.position,I.world.rotation,I.world.scale]:[I.name,I.aabb])}),x={version:mr,sceneId:n.sceneId,kind:"aabb",bounds:v,upAxis:n.upAxis??"y",handedness:"right",unitScale:n.unitScale??1,meshes:m,meshCount:d,contentHash:l_(y),capturedAt:(n.now??Date.now)(),sdkVersion:n.sdkVersion??gr};return bd.parse(x)}export{Mo as clamp01,Kg as classifyCamera,zd as createGazeRaycaster,Sd as createSceneRaycaster,Pd as playcanvasCollector,Nd as readConnector,Dd as readDeviceCaps,Od as readGraphics,Ud as readSceneMeta,m_ as scanSceneProxy,Lo as toVec3,a_ as trackScene};
58
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let c=a[1];if(n===a[0]){r(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(n!==a[0]&&u){r(a);continue}}if(e.metadataRegistry.get(a[0])?.id){r(a);continue}if(c.cycle){r(a);continue}if(c.count>1&&e.reused==="ref"){r(a);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Wm(e){let n=e.anyOf;if(!Array.isArray(n)||n.length===0||e.type!==void 0)return;let i=[];for(let o of n){if(!o||typeof o!="object")return;Wm(o);let t=Object.keys(o);if(t.length!==1||t[0]!=="type")return;let r=o.type;for(let a of Array.isArray(r)?r:[r]){if(typeof a!="string")return;i.includes(a)||i.push(a)}}delete e.anyOf,e.type=i.length===1?i[0]:i}var Km=new Set(["type","properties","required","additionalProperties"]),Gm=["oneOf","anyOf"];function Bm(e){let n=e.additionalProperties;return n===void 0||n===!1||typeof n!="object"||n===null?null:Object.keys(n).length?n:null}function xu(e){let n=[];for(let r of e){if(typeof r!="object"||r.type!=="object")return null;for(let a in r)if(!Km.has(a))return null;n.push(r)}let i={},o=new Set;for(let r of n){for(let a in r.properties){if(Object.prototype.hasOwnProperty.call(i,a))continue;let c=[];for(let u of n){let l=u.properties?.[a]??Bm(u);l!=null&&(c.some(d=>JSON.stringify(d)===JSON.stringify(l))||c.push(l))}let s=c.length===1?c[0]:xu(c)??{allOf:c};ee(i,a,s)}for(let a of r.required??[])o.add(a)}let t={type:"object",properties:i};if(o.size&&(t.required=[...o]),n.every(r=>r.additionalProperties===!1))t.additionalProperties=!1;else{let r=[];for(let a of n){let c=Bm(a);c&&!r.some(s=>JSON.stringify(s)===JSON.stringify(c))&&r.push(c)}r.length===1?t.additionalProperties=r[0]:r.length>1&&(t.additionalProperties={allOf:r})}return t}function ub(e){let n=e.allOf;if(!Array.isArray(n)||n.length<2)return;for(let t of Km)if(t in e)return;let i=n.filter(t=>Gm.some(r=>Array.isArray(t[r]))),o=null;if(!i.length)o=xu(n);else{let t=i[0],r=Gm.find(s=>Array.isArray(t[s]));if(Object.keys(t).length!==1)return;let a=n.filter(s=>s!==t),c=t[r].map(s=>xu([...a,s]));if(c.some(s=>!s))return;o={[r]:c}}o&&(delete e.allOf,Yn(e,o))}function nt(e,n){let i=e.seen.get(n);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=c=>{let s=e.seen.get(c);if(s.ref===null)return;let u=s.def??s.schema,l={...u},d=s.ref;if(s.ref=null,d){o(d);let m=e.seen.get(d),v=m.schema;if(v.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(v)):Yn(u,v),Yn(u,l),c._zod.parent===d)for(let x in u)x==="$ref"||x==="allOf"||x in l||delete u[x];if(v.$ref&&m.def)for(let x in u)x==="$ref"||x==="allOf"||x in m.def&&JSON.stringify(u[x])===JSON.stringify(m.def[x])&&delete u[x]}let f=c._zod.parent;if(f&&f!==d){o(f);let m=e.seen.get(f);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let v in u)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(u[v])===JSON.stringify(m.def[v])&&delete u[v]}e.override({zodSchema:c,jsonSchema:u,path:s.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())Wm(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let s of e.seen.values())for(let u of[s.schema,s.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=c.get(l);d?d.push(u):c.set(l,[u])}for(let s of e.intersections)for(let u of c.get(s)??[])ub(u)}}let t={};if(e.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let c=e.external.registry.get(n)?.id;if(!c)throw new Error("Schema is missing an `id` property");t.$id=e.external.uri(c)}Yn(t,i.defId?i.schema:i.def??i.schema);let r=e.metadataRegistry.get(n)?.id;r!==void 0&&t.id===r&&delete t.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let s=c[1];s.def&&s.defId&&(s.def.id===s.defId&&delete s.def.id,ee(a,s.defId,s.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?t.$defs=a:t.definitions=a);try{let c=JSON.parse(JSON.stringify(t));return Object.defineProperty(c,"~standard",{value:{...n["~standard"],jsonSchema:{input:tn(n,"input",e.processors),output:tn(n,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function de(e,n){let i=n??{seen:new Set};if(i.seen.has(e))return!1;i.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return de(o.element,i);if(o.type==="set")return de(o.valueType,i);if(o.type==="lazy")return de(o.getter(),i);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return de(o.innerType,i);if(o.type==="intersection")return de(o.left,i)||de(o.right,i);if(o.type==="record"||o.type==="map")return de(o.keyType,i)||de(o.valueType,i);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:de(o.in,i)||de(o.out,i);if(o.type==="object"){for(let t in o.shape)if(de(o.shape[t],i))return!0;return!1}if(o.type==="union"){for(let t of o.options)if(de(t,i))return!0;return!1}if(o.type==="tuple"){for(let t of o.items)if(de(t,i))return!0;return!!(o.rest&&de(o.rest,i))}return!1}var ku=(e,n={})=>i=>{let o=et({...i,processors:n});return W(e,o),tt(o,e),nt(o,e)},tn=(e,n,i={})=>o=>{let{libraryOptions:t,target:r}=o??{},a=et({...t??{},target:r,io:n,processors:i});return W(e,a),tt(a,e),nt(a,e)};var lb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Su=(e,n,i,o)=>{let t=i;t.type="string";let{minimum:r,maximum:a,format:c,patterns:s,contentEncoding:u,laxFormat:l}=e._zod.bag;if(typeof r=="number"&&(t.minLength=r),typeof a=="number"&&(t.maxLength=a),c&&(t.format=lb[c]??c,t.format===""&&delete t.format,(c==="time"||l)&&delete t.format),u&&(t.contentEncoding=u),s&&s.size>0){let d=[...s];d.length===1?t.pattern=d[0].source:d.length>1&&(t.allOf=[...d.map(f=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},zu=(e,n,i,o)=>{let t=i,{minimum:r,maximum:a,format:c,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof c=="string"&&c.includes("int")?t.type="integer":t.type="number";let d=typeof l=="number"&&l>=(r??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),m=n.target==="draft-04"||n.target==="openapi-3.0";d?m?(t.minimum=l,t.exclusiveMinimum=!0):t.exclusiveMinimum=l:typeof r=="number"&&(t.minimum=r),f?m?(t.maximum=u,t.exclusiveMaximum=!0):t.exclusiveMaximum=u:typeof a=="number"&&(t.maximum=a),typeof s=="number"&&(Number.isFinite(s)&&s!==0?t.multipleOf=Math.abs(s):re(e,n,t,o,`A multipleOf divisor of ${s} cannot be represented in JSON Schema`))},Pu=(e,n,i,o)=>{i.type="boolean"},Du=(e,n,i,o)=>{re(e,n,i,o,"BigInt cannot be represented in JSON Schema")},Ou=(e,n,i,o)=>{re(e,n,i,o,"Symbols cannot be represented in JSON Schema")},ju=(e,n,i,o)=>{n.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},Nu=(e,n,i,o)=>{re(e,n,i,o,"Undefined cannot be represented in JSON Schema")},Uu=(e,n,i,o)=>{re(e,n,i,o,"Void cannot be represented in JSON Schema")},Tu=(e,n,i,o)=>{i.not={}},Au=(e,n,i,o)=>{},Eu=(e,n,i,o)=>{},Cu=(e,n,i,o)=>{re(e,n,i,o,"Date cannot be represented in JSON Schema")},Zu=(e,n,i,o)=>{let t=e._zod.def,r=In(t.entries);if(r.length===0){i.not={};return}r.every(a=>typeof a=="number")&&(i.type="number"),r.every(a=>typeof a=="string")&&(i.type="string"),i.enum=r},Vu=(e,n,i,o)=>{let t=e._zod.def;if(t.values.length===0){i.not={};return}let r=[];for(let a of t.values)if(a===void 0){if(re(e,n,i,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(re(e,n,i,o,"BigInt literals cannot be represented in JSON Schema"))return;r.push(Number(a))}else r.push(a);if(r.length!==0)if(r.length===1){let a=r[0];i.type=a===null?"null":typeof a,n.target==="draft-04"||n.target==="openapi-3.0"?i.enum=[a]:i.const=a}else r.every(a=>typeof a=="number")&&(i.type="number"),r.every(a=>typeof a=="string")&&(i.type="string"),r.every(a=>typeof a=="boolean")&&(i.type="boolean"),r.every(a=>a===null)&&(i.type="null"),i.enum=r},Lu=(e,n,i,o)=>{re(e,n,i,o,"NaN cannot be represented in JSON Schema")},Mu=(e,n,i,o)=>{let t=i,r=e._zod.pattern;if(!r)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=r.source},Ru=(e,n,i,o)=>{let t=i,r={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:c,mime:s}=e._zod.bag;a!==void 0&&(r.minLength=a),c!==void 0&&(r.maxLength=c),s?s.length===1?(r.contentMediaType=s[0],Object.assign(t,r)):(Object.assign(t,r),t.anyOf=s.map(u=>({contentMediaType:u}))):Object.assign(t,r)},Fu=(e,n,i,o)=>{i.type="boolean"},Ju=(e,n,i,o)=>{re(e,n,i,o,"Custom types cannot be represented in JSON Schema")},Gu=(e,n,i,o)=>{re(e,n,i,o,"Function types cannot be represented in JSON Schema")},Bu=(e,n,i,o)=>{re(e,n,i,o,"Transforms cannot be represented in JSON Schema")},Wu=(e,n,i,o)=>{re(e,n,i,o,"Map cannot be represented in JSON Schema")},Ku=(e,n,i,o)=>{re(e,n,i,o,"Set cannot be represented in JSON Schema")},Xu=(e,n,i,o)=>{let t=i,r=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;typeof a=="number"&&(t.minItems=a),typeof c=="number"&&(t.maxItems=c),t.type="array",t.items=W(r.element,n,{...o,path:[...o.path,"items"]})};function Qn(e){let n=e._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?Qn(n.out):n.type==="catch"?Qn(n.innerType):e._zod.optin}var qu=(e,n,i,o)=>{let t=i,r=e._zod.def,a=r.shape;if(Object.getOwnPropertySymbols(a).length&&re(e,n,t,o,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let l in a)ee(t.properties,l,W(a[l],n,{...o,path:[...o.path,"properties",l]}));let s=new Set(Object.keys(a)),u=new Set([...s].filter(l=>{let d=r.shape[l];return n.io==="input"?Qn(d)===void 0:d._zod.optout===void 0}));u.size>0&&(t.required=Array.from(u)),r.catchall?._zod.def.type==="never"?t.additionalProperties=!1:r.catchall?r.catchall&&(t.additionalProperties=W(r.catchall,n,{...o,path:[...o.path,"additionalProperties"]})):n.io==="output"&&(t.additionalProperties=!1)},qi=(e,n,i,o)=>{let t=e._zod.def,r=t.inclusive===!1,a=t.options.map((c,s)=>W(c,n,{...o,path:[...o.path,r?"oneOf":"anyOf",s]}));r?i.oneOf=a:i.anyOf=a},Hu=(e,n,i,o)=>{let t=e._zod.def,r=W(t.left,n,{...o,path:[...o.path,"allOf",0]}),a=W(t.right,n,{...o,path:[...o.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,s=[...c(r)?r.allOf:[r],...c(a)?a.allOf:[a]];i.allOf=s,n.intersections.push(s)},Yu=(e,n,i,o)=>{let t=i,r=e._zod.def;t.type="array";let a=n.target==="draft-2020-12"?"prefixItems":"items",c=n.target==="draft-2020-12"||n.target==="openapi-3.0"?"items":"additionalItems",s=r.items.map((y,x)=>W(y,n,{...o,path:[...o.path,a,x]})),u=r.rest?W(r.rest,n,{...o,path:[...o.path,c,...n.target==="openapi-3.0"?[r.items.length]:[]]}):null,l=r.items.length;for(;l>0;){let y=r.items[l-1];if(!(n.io==="input"?Qn(y)!==void 0:y._zod.optout==="optional"))break;l--}let d=r.items.length,f=!r.rest;n.target==="draft-2020-12"?(t.prefixItems=s,f?t.items=!1:u&&(t.items=u),l>0&&(t.minItems=l),f&&(t.maxItems=d)):n.target==="openapi-3.0"?(t.items={anyOf:s},u&&t.items.anyOf.push(u),l>0&&(t.minItems=l),f&&(t.maxItems=d)):(t.items=s,f?t.additionalItems=!1:u&&(t.additionalItems=u),l>0&&(t.minItems=l),f&&(t.maxItems=d));let{minimum:m,maximum:v}=e._zod.bag;typeof m=="number"&&(t.minItems=m),typeof v=="number"&&(t.maxItems=v)};function wu(e,n,i){if(n.$ref){if(i.has(n))return n;i.add(n);let v=e.get(n)?.def;if(!v)return n;let y=wu(e,v,i);return y===v?n:y}for(let v of["anyOf","oneOf"]){let y=n[v];if(!Array.isArray(y))continue;let x=y.map(I=>wu(e,I,i));x.some((I,h)=>I!==y[h])&&(n={...n,[v]:x})}let o=Array.isArray(n.type)?n.type:[n.type],t=!o.includes("string")&&o.some(v=>v==="number"||v==="integer"),r=n.enum??(n.const!==void 0?[n.const]:void 0);if(!t&&!r?.some(v=>typeof v=="number"))return n;let{minimum:a,maximum:c,exclusiveMinimum:s,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...m}=n;return m.enum?m.enum=m.enum.map(v=>typeof v=="number"?String(v):v):typeof m.const=="number"&&(m.const=String(m.const)),t&&(m.type="string",r||(m.pattern=(o.includes("number")?He:An).source)),m}var Iu=new WeakMap;function db(e){let n=new Map;for(let o of e.seen.values())o.def&&!n.has(o.schema)&&n.set(o.schema,o);let i=new Map;for(let o of Iu.get(e)??[]){let t=e.seen.get(o),r=(t?.def??t?.schema)?.propertyNames;if(!r||r===!0||i.has(r))continue;let a=wu(n,r,new Set);a!==r&&i.set(r,a)}if(i.size)for(let o of e.seen.values())for(let t of[o.schema,o.def]){let r=t&&i.get(t.propertyNames);r&&(t.propertyNames=r)}}var Qu=(e,n,i,o)=>{let t=i,r=e._zod.def;t.type="object";let a=r.keyType,s=a._zod.bag?.patterns;if(r.mode==="loose"&&s&&s.size>0){let d=W(r.valueType,n,{...o,path:[...o.path,"patternProperties","*"]});t.patternProperties={};for(let f of s)ee(t.patternProperties,f.source,d)}else{if(n.target==="draft-07"||n.target==="draft-2020-12"){t.propertyNames=W(r.keyType,n,{...o,path:[...o.path,"propertyNames"]});let d=Iu.get(n);d||(d=[],Iu.set(n,d),n.deferred.push(()=>db(n))),d.push(e)}t.additionalProperties=W(r.valueType,n,{...o,path:[...o.path,"additionalProperties"]})}let u=a._zod.values,l=n.io==="input"&&Qn(r.valueType)!==void 0;if(u&&!r.partial&&!l){let d=[...u].filter(f=>typeof f=="string"||typeof f=="number");d.length>0&&(t.required=d.map(String))}},el=(e,n,i,o)=>{let t=e._zod.def,r=W(t.innerType,n,o),a=n.seen.get(e);n.target==="openapi-3.0"?(a.ref=t.innerType,i.nullable=!0):i.anyOf=[r,{type:"null"}]},tl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType},nl=Symbol();function Xm(e,n,i,o,t){let r=!1,a=JSON.stringify(e,(c,s)=>typeof s!="bigint"?s:(r=!0,null));return r?(re(n,i,o,t,"BigInt defaults cannot be represented in JSON Schema"),nl):JSON.parse(a)}var rl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType;let a=Xm(t.defaultValue,e,n,i,o);a!==nl&&(i.default=a)},il=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);if(r.ref=t.innerType,n.io!=="input")return;let a=Xm(t.defaultValue,e,n,i,o);a!==nl&&(i._prefault=a)},ol=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{re(e,n,i,o,"Dynamic catch values are not supported in JSON Schema");return}i.default=a},al=(e,n,i,o)=>{let t=e._zod.def,r=t.in._zod.traits.has("$ZodTransform"),a=n.io==="input"?r?t.out:t.in:t.out;W(a,n,o);let c=n.seen.get(e);c.ref=a},cl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType,i.readOnly=!0},sl=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType},Hi=(e,n,i,o)=>{let t=e._zod.def;W(t.innerType,n,o);let r=n.seen.get(e);r.ref=t.innerType},ul=(e,n,i,o)=>{let t=e._zod.innerType;W(t,n,o);let r=n.seen.get(e);r.ref=t},Xi={string:Su,number:zu,boolean:Pu,bigint:Du,symbol:Ou,null:ju,undefined:Nu,void:Uu,never:Tu,any:Au,unknown:Eu,date:Cu,enum:Zu,literal:Vu,nan:Lu,template_literal:Mu,file:Ru,success:Fu,custom:Ju,function:Gu,transform:Bu,map:Wu,set:Ku,array:Xu,object:qu,union:qi,intersection:Hu,tuple:Yu,record:Qu,nullable:el,nonoptional:tl,default:rl,prefault:il,catch:ol,pipe:al,readonly:cl,promise:sl,optional:Hi,lazy:ul};function Yi(e,n){if("_idmap"in e){let o=e,t=et({...n,processors:Xi}),r={};for(let s of o._idmap.entries()){let[u,l]=s;W(l,t)}let a={},c={registry:o,uri:n?.uri,defs:r};t.external=c;for(let s of o._idmap.entries()){let[u,l]=s;tt(t,l),ee(a,u,nt(t,l))}if(Object.keys(r).length>0){let s=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[s]:r}}return{schemas:a}}let i=et({...n,processors:Xi});return W(e,i),tt(i,e),nt(i,e)}var Qi=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(n){this.ctx.counter=n}get seen(){return this.ctx.seen}constructor(n){let i=n?.target??"draft-2020-12";i==="draft-4"&&(i="draft-04"),i==="draft-7"&&(i="draft-07"),this.ctx=et({processors:Xi,target:i,...n?.metadata&&{metadata:n.metadata},...n?.unrepresentable&&{unrepresentable:n.unrepresentable},...n?.override&&{override:n.override},...n?.io&&{io:n.io}})}process(n,i={path:[],schemaPath:[]}){return W(n,this.ctx,i)}emit(n,i){i&&(i.cycles&&(this.ctx.cycles=i.cycles),i.reused&&(this.ctx.reused=i.reused),i.external&&(this.ctx.external=i.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,tt(this.ctx,n);let o=nt(this.ctx,n),{"~standard":t,...r}=o;return r}};var qm={};var dn={};Fe(dn,{ZodAny:()=>Ol,ZodArray:()=>Tl,ZodBase64:()=>yo,ZodBase64URL:()=>bo,ZodBigInt:()=>un,ZodBigIntFormat:()=>ko,ZodBoolean:()=>sn,ZodCIDRv4:()=>ho,ZodCIDRv6:()=>$o,ZodCUID:()=>uo,ZodCUID2:()=>lo,ZodCatch:()=>td,ZodCodec:()=>ur,ZodCreditCard:()=>kl,ZodCustom:()=>lr,ZodCustomStringFormat:()=>an,ZodDate:()=>rr,ZodDefault:()=>Xl,ZodDiscriminatedUnion:()=>El,ZodE164:()=>_o,ZodEmail:()=>oo,ZodEmoji:()=>co,ZodEnum:()=>rn,ZodExactOptional:()=>zo,ZodFile:()=>Gl,ZodFunction:()=>dd,ZodGUID:()=>ao,ZodIPv4:()=>go,ZodIPv6:()=>vo,ZodISODate:()=>it,ZodISODateTime:()=>rt,ZodISODuration:()=>at,ZodISOTime:()=>ot,ZodIntersection:()=>Cl,ZodJWT:()=>xo,ZodKSUID:()=>po,ZodLazy:()=>sd,ZodLiteral:()=>Jl,ZodMAC:()=>xl,ZodMap:()=>Rl,ZodNaN:()=>rd,ZodNanoID:()=>so,ZodNever:()=>Nl,ZodNonOptional:()=>Po,ZodNull:()=>Pl,ZodNullable:()=>Kl,ZodNumber:()=>cn,ZodNumberFormat:()=>St,ZodObject:()=>or,ZodOptional:()=>cr,ZodPipe:()=>sr,ZodPrefault:()=>Hl,ZodPreprocess:()=>id,ZodPromise:()=>ld,ZodReadonly:()=>od,ZodRecord:()=>nn,ZodSet:()=>Fl,ZodString:()=>on,ZodStringFormat:()=>q,ZodSuccess:()=>ed,ZodSymbol:()=>Sl,ZodTemplateLiteral:()=>cd,ZodTransform:()=>Bl,ZodTuple:()=>Vl,ZodType:()=>Z,ZodULID:()=>fo,ZodURL:()=>nr,ZodUUID:()=>Me,ZodUndefined:()=>zl,ZodUnion:()=>ar,ZodUnknown:()=>jl,ZodVoid:()=>Ul,ZodXID:()=>mo,ZodXor:()=>Al,_ZodString:()=>io,_default:()=>ql,_function:()=>ag,any:()=>Cp,array:()=>ir,base64:()=>yp,base64url:()=>bp,bigint:()=>Np,boolean:()=>Il,catch:()=>nd,check:()=>cg,cidrv4:()=>hp,cidrv6:()=>$p,codec:()=>ng,creditCard:()=>xp,cuid:()=>up,cuid2:()=>lp,custom:()=>sg,date:()=>Vp,describe:()=>ug,discriminatedUnion:()=>Gp,e164:()=>_p,email:()=>Qm,emoji:()=>cp,enum:()=>Io,exactOptional:()=>Wl,file:()=>Yp,float32:()=>Pp,float64:()=>Dp,function:()=>ag,guid:()=>ep,hash:()=>zp,hex:()=>Sp,hostname:()=>Ip,httpUrl:()=>ap,instanceof:()=>dg,int:()=>no,int32:()=>Op,int64:()=>Up,intersection:()=>Zl,invertCodec:()=>rg,ipv4:()=>pp,ipv6:()=>vp,json:()=>mg,jwt:()=>kp,keyof:()=>Lp,ksuid:()=>mp,lazy:()=>ud,literal:()=>Hp,looseObject:()=>Fp,looseRecord:()=>Wp,mac:()=>gp,map:()=>Kp,meta:()=>lg,nan:()=>tg,nanoid:()=>sp,nativeEnum:()=>qp,never:()=>wo,nonoptional:()=>Ql,null:()=>Dl,nullable:()=>tr,nullish:()=>Qp,number:()=>wl,object:()=>Mp,optional:()=>wt,partialRecord:()=>Bp,pipe:()=>ro,prefault:()=>Yl,preprocess:()=>pg,promise:()=>og,readonly:()=>ad,record:()=>Ml,refine:()=>fd,set:()=>Xp,strictObject:()=>Rp,string:()=>er,stringFormat:()=>wp,stringbool:()=>fg,success:()=>eg,superRefine:()=>md,symbol:()=>Ap,templateLiteral:()=>ig,transform:()=>So,tuple:()=>Ll,uint32:()=>jp,uint64:()=>Tp,ulid:()=>dp,undefined:()=>Ep,union:()=>ln,unknown:()=>kt,url:()=>op,uuid:()=>tp,uuidv4:()=>np,uuidv6:()=>rp,uuidv7:()=>ip,void:()=>Zp,xid:()=>fp,xor:()=>Jp});var eo={};Fe(eo,{endsWith:()=>Wt,gt:()=>Ve,gte:()=>we,includes:()=>Gt,length:()=>xt,lowercase:()=>Ft,lt:()=>Ze,lte:()=>ke,maxLength:()=>_t,maxSize:()=>Qe,mime:()=>Kt,minLength:()=>Je,minSize:()=>Le,multipleOf:()=>Ye,negative:()=>Ji,nonnegative:()=>Bi,nonpositive:()=>Gi,normalize:()=>Xt,overwrite:()=>Ee,positive:()=>Fi,properties:()=>Ki,property:()=>Wi,regex:()=>Rt,size:()=>bt,slugify:()=>Qt,startsWith:()=>Bt,toLowerCase:()=>Ht,toUpperCase:()=>Yt,trim:()=>qt,uppercase:()=>Jt});var Hm=new WeakSet([Object.prototype,Error.prototype]);function to(e,n,i){Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){let o=i(this);return Object.defineProperty(this,n,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,n,{value:o,configurable:!0,writable:!0})}})}var Ym=(e,n)=>{Nn.init(e,n),e.name="ZodError";let i=Object.getPrototypeOf(e);Hm.has(i)||(Hm.add(i),to(i,"format",o=>t=>Tn(o,t)),to(i,"flatten",o=>t=>Un(o,t)),to(i,"addIssue",o=>t=>{o.issues.push(t),o.message=JSON.stringify(o.issues,Nt,2)}),to(i,"addIssues",o=>t=>{o.issues.push(...t),o.message=JSON.stringify(o.issues,Nt,2)}),Object.defineProperty(i,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},mb=p("ZodError",Ym),he=p("ZodError",Ym,void 0,{Parent:Error});var ll=At(he),dl=Et(he),fl=Ct(he),ml=Zt(he),pl=Tr(he),gl=Ar(he),vl=Er(he),hl=Cr(he),$l=Zr(he),yl=Vr(he),bl=Lr(he),_l=Mr(he);function gb(){ie.localeError||ne(vi())}function It(){ie.memoizer||ne({memoizer:Jn()})}var Z=p("ZodType",(e,n)=>(gb(),E.init(e,n),e.def=n,e.type=n.type,e),{check(...e){let n=this.def;return this.clone(_.mergeDefs(n,{checks:[...n.checks??[],...e.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,n){return B(this,e,n)},brand(){return this},register(e,n){return e.add(this,n),this},refine(e,n){return this.check(fd(e,n))},superRefine(e,n){return this.check(md(e,n))},overwrite(e){return this.check(Ee(e))},optional(){return wt(this)},exactOptional(){return Wl(this)},nullable(){return tr(this)},nullish(){return wt(tr(this))},nonoptional(e){return Ql(this,e)},array(){return ir(this)},or(e){return ln([this,e])},and(e){return Zl(this,e)},transform(e){return ro(this,So(e))},default(e){return ql(this,e)},prefault(e){return Yl(this,e)},catch(e){return nd(this,e)},pipe(e){return ro(this,e)},readonly(){return ad(this)},describe(e){let n=this.clone();return oe.add(n,{description:e}),n},meta(...e){if(e.length===0)return oe.get(this);let n=this.clone();return oe.add(n,e[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...n){return n.length===0?e(this):e(this,...n)},get"~standard"(){return _.hide(this,"~standard",{...Yr(this),jsonSchema:{input:tn(this,"input"),output:tn(this,"output")}})},set"~standard"(e){_.own(this,"~standard",e)},parse:function e(n,i){return ll(this,n,i,{callee:e})},parseAsync:async function e(n,i){return await dl(this,n,i,{callee:e})},safeParse(e,n){return fl(this,e,n)},async safeParseAsync(e,n){return ml(this,e,n)},get spa(){return this?.safeParseAsync},set spa(e){_.own(this,"spa",e)},encode:function e(n,i){return pl(this,n,i,{callee:e})},decode:function e(n,i){return gl(this,n,i,{callee:e})},encodeAsync:async function e(n,i){return await vl(this,n,i,{callee:e})},decodeAsync:async function e(n,i){return await hl(this,n,i,{callee:e})},safeEncode(e,n){return $l(this,e,n)},safeDecode(e,n){return yl(this,e,n)},async safeEncodeAsync(e,n){return bl(this,e,n)},async safeDecodeAsync(e,n){return _l(this,e,n)},toJSONSchema(e){return ku(this,{})(e)},get description(){return oe.get(this)?.description},get _def(){return this._zod.def}}),io=p("_ZodString",(e,n)=>{gt.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Su(e,o,t,r);let i=e._zod.bag;e.format=i.format??null,e.minLength=i.minimum??null,e.maxLength=i.maximum??null},{regex(...e){return this.check(Rt(...e))},includes(...e){return this.check(Gt(...e))},startsWith(...e){return this.check(Bt(...e))},endsWith(...e){return this.check(Wt(...e))},min(...e){return this.check(Je(...e))},max(...e){return this.check(_t(...e))},length(...e){return this.check(xt(...e))},nonempty(...e){return this.check(Je(1,...e))},lowercase(e){return this.check(Ft(e))},uppercase(e){return this.check(Jt(e))},trim(){return this.check(qt())},normalize(...e){return this.check(Xt(...e))},toLowerCase(){return this.check(Ht())},toUpperCase(){return this.check(Yt())},slugify(){return this.check(Qt())}}),on=p("ZodString",(e,n)=>{gt.init(e,n),io.init(e,n)},{email(e){return this.check(xi(oo,e))},url(e){return this.check(Wn(nr,e))},jwt(e){return this.check(Ri(xo,e))},emoji(e){return this.check(Pi(co,e))},guid(e){return this.check(ki(ao,e))},uuid(e){return this.check(wi(Me,e))},uuidv4(e){return this.check(Ii(Me,e))},uuidv6(e){return this.check(Si(Me,e))},uuidv7(e){return this.check(zi(Me,e))},nanoid(e){return this.check(Di(so,e))},cuid(e){return this.check(Oi(uo,e))},cuid2(e){return this.check(ji(lo,e))},ulid(e){return this.check(Ni(fo,e))},base64(e){return this.check(Vi(yo,e))},base64url(e){return this.check(Li(bo,e))},xid(e){return this.check(Ui(mo,e))},ksuid(e){return this.check(Ti(po,e))},ipv4(e){return this.check(Ai(go,e))},ipv6(e){return this.check(Ei(vo,e))},cidrv4(e){return this.check(Ci(ho,e))},cidrv6(e){return this.check(Zi($o,e))},e164(e){return this.check(Mi(_o,e))},datetime(e){return this.check(Kn(rt,e))},date(e){return this.check(Xn(it,e))},time(e){return this.check(qn(ot,e))},duration(e){return this.check(Hn(at,e))}});function er(e){return Ls(on,e)}var q=p("ZodStringFormat",(e,n)=>{X.init(e,n),io.init(e,n)}),rt=p("ZodISODateTime",(e,n)=>{jc.init(e,n),q.init(e,n)}),it=p("ZodISODate",(e,n)=>{Nc.init(e,n),q.init(e,n)}),ot=p("ZodISOTime",(e,n)=>{Uc.init(e,n),q.init(e,n)}),at=p("ZodISODuration",(e,n)=>{Tc.init(e,n),q.init(e,n)}),oo=p("ZodEmail",(e,n)=>{bc.init(e,n),q.init(e,n)});function Qm(e){return xi(oo,e)}var ao=p("ZodGUID",(e,n)=>{$c.init(e,n),q.init(e,n)});function ep(e){return ki(ao,e)}var Me=p("ZodUUID",(e,n)=>{yc.init(e,n),q.init(e,n)});function tp(e){return wi(Me,e)}function np(e){return Ii(Me,e)}function rp(e){return Si(Me,e)}function ip(e){return zi(Me,e)}var nr=p("ZodURL",(e,n)=>{kc.init(e,n),q.init(e,n)});function op(e){return Wn(nr,e)}function ap(e){return Wn(nr,{protocol:ue.httpProtocol,hostname:ue.domain,..._.normalizeParams(e)})}var co=p("ZodEmoji",(e,n)=>{wc.init(e,n),q.init(e,n)});function cp(e){return Pi(co,e)}var so=p("ZodNanoID",(e,n)=>{Ic.init(e,n),q.init(e,n)});function sp(e){return Di(so,e)}var uo=p("ZodCUID",(e,n)=>{Sc.init(e,n),q.init(e,n)});function up(e){return Oi(uo,e)}var lo=p("ZodCUID2",(e,n)=>{zc.init(e,n),q.init(e,n)});function lp(e){return ji(lo,e)}var fo=p("ZodULID",(e,n)=>{Pc.init(e,n),q.init(e,n)});function dp(e){return Ni(fo,e)}var mo=p("ZodXID",(e,n)=>{Dc.init(e,n),q.init(e,n)});function fp(e){return Ui(mo,e)}var po=p("ZodKSUID",(e,n)=>{Oc.init(e,n),q.init(e,n)});function mp(e){return Ti(po,e)}var go=p("ZodIPv4",(e,n)=>{Ac.init(e,n),q.init(e,n)});function pp(e){return Ai(go,e)}var xl=p("ZodMAC",(e,n)=>{Cc.init(e,n),q.init(e,n)});function gp(e){return Rs(xl,e)}var vo=p("ZodIPv6",(e,n)=>{Ec.init(e,n),q.init(e,n)});function vp(e){return Ei(vo,e)}var ho=p("ZodCIDRv4",(e,n)=>{Zc.init(e,n),q.init(e,n)});function hp(e){return Ci(ho,e)}var $o=p("ZodCIDRv6",(e,n)=>{Vc.init(e,n),q.init(e,n)});function $p(e){return Zi($o,e)}var yo=p("ZodBase64",(e,n)=>{Lc.init(e,n),q.init(e,n)});function yp(e){return Vi(yo,e)}var bo=p("ZodBase64URL",(e,n)=>{Mc.init(e,n),q.init(e,n)});function bp(e){return Li(bo,e)}var _o=p("ZodE164",(e,n)=>{Rc.init(e,n),q.init(e,n)});function _p(e){return Mi(_o,e)}var kl=p("ZodCreditCard",(e,n)=>{Fc.init(e,n),q.init(e,n)});function xp(e){return Fs(kl,e)}var xo=p("ZodJWT",(e,n)=>{Jc.init(e,n),q.init(e,n)});function kp(e){return Ri(xo,e)}var an=p("ZodCustomStringFormat",(e,n)=>{Gc.init(e,n),q.init(e,n)});function wp(e,n,i={}){return en(an,e,n,i)}function Ip(e){return en(an,"hostname",ue.hostname,e)}function Sp(e){return en(an,"hex",ue.hex,e)}function zp(e,n){let i=n?.enc??"hex",o=`${e}_${i}`,t=ue[o];if(!t)throw new Error(`Unrecognized hash format: ${o}`);return en(an,o,t,n)}var cn=p("ZodNumber",(e,n)=>{ci.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>zu(e,o,t,r);let i=e._zod.bag;e.minValue=Math.max(i.minimum??Number.NEGATIVE_INFINITY,i.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(i.maximum??Number.POSITIVE_INFINITY,i.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(i.format??"").includes("int")||Number.isSafeInteger(i.multipleOf??.5),e.isFinite=!0,e.format=i.format??null},{gt(e,n){return this.check(Ve(e,n))},gte(e,n){return this.check(we(e,n))},min(e,n){return this.check(we(e,n))},lt(e,n){return this.check(Ze(e,n))},lte(e,n){return this.check(ke(e,n))},max(e,n){return this.check(ke(e,n))},int(e){return this.check(no(e))},safe(e){return this.check(no(e))},positive(e){return this.check(Ve(0,e))},nonnegative(e){return this.check(we(0,e))},negative(e){return this.check(Ze(0,e))},nonpositive(e){return this.check(ke(0,e))},multipleOf(e,n){return this.check(Ye(e,n))},step(e,n){return this.check(Ye(e,n))},finite(){return this}});function wl(e){return Gs(cn,e)}var St=p("ZodNumberFormat",(e,n)=>{Bc.init(e,n),cn.init(e,n)});function no(e){return Ws(St,e)}function Pp(e){return Ks(St,e)}function Dp(e){return Xs(St,e)}function Op(e){return qs(St,e)}function jp(e){return Hs(St,e)}var sn=p("ZodBoolean",(e,n)=>{Ln.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Pu(e,i,o,t)});function Il(e){return Ys(sn,e)}var un=p("ZodBigInt",(e,n)=>{si.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Du(e,o,t,r);let i=e._zod.bag;e.minValue=i.minimum??null,e.maxValue=i.maximum??null,e.format=i.format??null},{gte(e,n){return this.check(we(e,n))},min(e,n){return this.check(we(e,n))},gt(e,n){return this.check(Ve(e,n))},lt(e,n){return this.check(Ze(e,n))},lte(e,n){return this.check(ke(e,n))},max(e,n){return this.check(ke(e,n))},positive(e){return this.check(Ve(BigInt(0),e))},negative(e){return this.check(Ze(BigInt(0),e))},nonpositive(e){return this.check(ke(BigInt(0),e))},nonnegative(e){return this.check(we(BigInt(0),e))},multipleOf(e,n){return this.check(Ye(e,n))}});function Np(e){return eu(un,e)}var ko=p("ZodBigIntFormat",(e,n)=>{Wc.init(e,n),un.init(e,n)});function Up(e){return nu(ko,e)}function Tp(e){return ru(ko,e)}var Sl=p("ZodSymbol",(e,n)=>{Kc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ou(e,i,o,t)});function Ap(e){return iu(Sl,e)}var zl=p("ZodUndefined",(e,n)=>{Xc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Nu(e,i,o,t)});function Ep(e){return ou(zl,e)}var Pl=p("ZodNull",(e,n)=>{qc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>ju(e,i,o,t)});function Dl(e){return au(Pl,e)}var Ol=p("ZodAny",(e,n)=>{Hc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Au(e,i,o,t)});function Cp(){return cu(Ol)}var jl=p("ZodUnknown",(e,n)=>{Yc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Eu(e,i,o,t)});function kt(){return su(jl)}var Nl=p("ZodNever",(e,n)=>{Qc.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Tu(e,i,o,t)});function wo(e){return uu(Nl,e)}var Ul=p("ZodVoid",(e,n)=>{es.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Uu(e,i,o,t)});function Zp(e){return lu(Ul,e)}var rr=p("ZodDate",(e,n)=>{ts.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Cu(e,o,t,r),e.min=(o,t)=>e.check(we(o,t)),e.max=(o,t)=>e.check(ke(o,t));let i=e._zod.bag;e.minDate=i.minimum?new Date(i.minimum):null,e.maxDate=i.maximum?new Date(i.maximum):null});function Vp(e){return du(rr,e)}var Tl=p("ZodArray",(e,n)=>{It(),ns.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Xu(e,i,o,t),e.element=n.element},{min(e,n){return this.check(Je(e,n))},nonempty(e){return this.check(Je(1,e))},max(e,n){return this.check(_t(e,n))},length(e,n){return this.check(xt(e,n))},unwrap(){return this.element}});function ir(e,n){return pu(Tl,e,n)}function Lp(e){let n=e._zod.def.shape;return Io(Object.keys(n))}var or=p("ZodObject",(e,n)=>{It(),rs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>qu(e,i,o,t),_.installLazyProp(e,"shape",i=>i._zod.def.shape,!1)},{keyof(){return Io(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:kt()})},loose(){return this.clone({...this._zod.def,catchall:kt()})},strict(){return this.clone({...this._zod.def,catchall:wo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return _.extend(this,e)},safeExtend(e){return _.safeExtend(this,e)},merge(e){return _.merge(this,e)},pick(e){return _.pick(this,e)},omit(e){return _.omit(this,e)},partial(...e){return _.partial(cr,this,e[0])},exactPartial(...e){return _.partial(zo,this,e[0],"exactPartial")},required(...e){return _.required(Po,this,e[0])}});function Mp(e,n){let i={type:"object",shape:e??{},..._.normalizeParams(n)};return new or(i)}function Rp(e,n){return new or({type:"object",shape:e,catchall:wo(),..._.normalizeParams(n)})}function Fp(e,n){return new or({type:"object",shape:e,catchall:kt(),..._.normalizeParams(n)})}var ar=p("ZodUnion",(e,n)=>{Mn.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>qi(e,i,o,t),e.options=n.options});function ln(e,n){return new ar({type:"union",options:e,..._.normalizeParams(n)})}var Al=p("ZodXor",(e,n)=>{ar.init(e,n),is.init(e,n),e._zod.processJSONSchema=(i,o,t)=>qi(e,i,o,t),e.options=n.options});function Jp(e,n){return new Al({type:"union",options:e,inclusive:!1,..._.normalizeParams(n)})}var El=p("ZodDiscriminatedUnion",(e,n)=>{ar.init(e,n),as.init(e,n)});function Gp(e,n,i){return new El({type:"union",options:n,discriminator:e,..._.normalizeParams(i)})}var Cl=p("ZodIntersection",(e,n)=>{cs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Hu(e,i,o,t)});function Zl(e,n){return new Cl({type:"intersection",left:e,right:n})}var Vl=p("ZodTuple",(e,n)=>{It(),ui.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Yu(e,i,o,t)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(n=>new cr({type:"optional",innerType:n}))})}});function Ll(e,n,i){let o=n instanceof E,t=o?i:n,r=o?n:null;return new Vl({type:"tuple",items:e,rest:r,..._.normalizeParams(t)})}var nn=p("ZodRecord",(e,n)=>{It(),ss.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Qu(e,i,o,t),e.keyType=n.keyType,e.valueType=n.valueType});function Ml(e,n,i){return!n||!n._zod?new nn({type:"record",keyType:er(),valueType:e,..._.normalizeParams(n)}):new nn({type:"record",keyType:e,valueType:n,..._.normalizeParams(i)})}function Bp(e,n,i){return new nn({type:"record",keyType:e,valueType:n,..._.normalizeParams(i),partial:!0})}function Wp(e,n,i){return new nn({type:"record",keyType:e,valueType:n,mode:"loose",..._.normalizeParams(i)})}var Rl=p("ZodMap",(e,n)=>{It(),us.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Wu(e,i,o,t),e.keyType=n.keyType,e.valueType=n.valueType,e.min=(...i)=>e.check(Le(...i)),e.nonempty=i=>e.check(Le(1,i)),e.max=(...i)=>e.check(Qe(...i)),e.size=(...i)=>e.check(bt(...i))});function Kp(e,n,i){return new Rl({type:"map",keyType:e,valueType:n,..._.normalizeParams(i)})}var Fl=p("ZodSet",(e,n)=>{It(),ls.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ku(e,i,o,t),e.min=(...i)=>e.check(Le(...i)),e.nonempty=i=>e.check(Le(1,i)),e.max=(...i)=>e.check(Qe(...i)),e.size=(...i)=>e.check(bt(...i))});function Xp(e,n){return new Fl({type:"set",valueType:e,..._.normalizeParams(n)})}var rn=p("ZodEnum",(e,n)=>{ds.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(o,t,r)=>Zu(e,o,t,r),e.enum=n.entries,e.options=Object.values(n.entries);let i=new Set(Object.keys(n.entries));e.extract=(o,t)=>{let r={};for(let a of o)if(i.has(a))r[a]=n.entries[a];else throw new Error(`Key ${a} not found in enum`);return new rn({...n,checks:[],..._.normalizeParams(t),entries:r})},e.exclude=(o,t)=>{let r={...n.entries};for(let a of o)if(i.has(a))delete r[a];else throw new Error(`Key ${a} not found in enum`);return new rn({...n,checks:[],..._.normalizeParams(t),entries:r})}});function Io(e,n){let i=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new rn({type:"enum",entries:i,..._.normalizeParams(n)})}function qp(e,n){return new rn({type:"enum",entries:e,..._.normalizeParams(n)})}var Jl=p("ZodLiteral",(e,n)=>{fs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Vu(e,i,o,t),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function Hp(e,n){return new Jl({type:"literal",values:Array.isArray(e)?e:[e],..._.normalizeParams(n)})}var Gl=p("ZodFile",(e,n)=>{ms.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ru(e,i,o,t),e.min=(i,o)=>e.check(Le(i,o)),e.max=(i,o)=>e.check(Qe(i,o)),e.mime=(i,o)=>e.check(Kt(Array.isArray(i)?i:[i],o))});function Yp(e){return gu(Gl,e)}var Bl=p("ZodTransform",(e,n)=>{It(),ps.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Bu(e,i,o,t),e._zod.parse=(i,o)=>{if(o.direction==="backward")throw new qe(e.constructor.name);i.addIssue=r=>{if(typeof r=="string")i.issues.push(_.issue(r,i.value,n));else{let a=r;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=i.value),a.inst??(a.inst=e),i.issues.push(_.issue(a))}};let t=n.transform(i.value,i);return t instanceof Promise?t.then(r=>(i.value=r,i)):(i.value=t,i)}});function So(e){return new Bl({type:"transform",transform:e})}var cr=p("ZodOptional",(e,n)=>{li.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Hi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function wt(e){return new cr({type:"optional",innerType:e})}var zo=p("ZodExactOptional",(e,n)=>{gs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Hi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Wl(e){return new zo({type:"optional",innerType:e})}var Kl=p("ZodNullable",(e,n)=>{vs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>el(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function tr(e){return new Kl({type:"nullable",innerType:e})}function Qp(e){return wt(tr(e))}var Xl=p("ZodDefault",(e,n)=>{hs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>rl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ql(e,n){return new Xl({type:"default",innerType:e,get defaultValue(){return typeof n=="function"?n():_.shallowClone(n)}})}var Hl=p("ZodPrefault",(e,n)=>{$s.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>il(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Yl(e,n){return new Hl({type:"prefault",innerType:e,get defaultValue(){return typeof n=="function"?n():_.shallowClone(n)}})}var Po=p("ZodNonOptional",(e,n)=>{ys.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>tl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Ql(e,n){return new Po({type:"nonoptional",innerType:e,..._.normalizeParams(n)})}var ed=p("ZodSuccess",(e,n)=>{bs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Fu(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function eg(e){return new ed({type:"success",innerType:e})}var td=p("ZodCatch",(e,n)=>{_s.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>ol(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nd(e,n){return new td({type:"catch",innerType:e,catchValue:typeof n=="function"?n:_.constantCatch(n)})}var rd=p("ZodNaN",(e,n)=>{xs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Lu(e,i,o,t)});function tg(e){return mu(rd,e)}var sr=p("ZodPipe",(e,n)=>{di.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>al(e,i,o,t),e.in=n.in,e.out=n.out});function ro(e,n){return new sr({type:"pipe",in:e,out:n})}var ur=p("ZodCodec",(e,n)=>{sr.init(e,n),Rn.init(e,n)});function ng(e,n,i){return new ur({type:"pipe",in:e,out:n,transform:i.decode,reverseTransform:i.encode})}function rg(e){let n=e._zod.def;return new ur({type:"pipe",in:n.out,out:n.in,transform:n.reverseTransform,reverseTransform:n.transform})}var id=p("ZodPreprocess",(e,n)=>{sr.init(e,n),ks.init(e,n)}),od=p("ZodReadonly",(e,n)=>{ws.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>cl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function ad(e){return new od({type:"readonly",innerType:e})}var cd=p("ZodTemplateLiteral",(e,n)=>{Is.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Mu(e,i,o,t)});function ig(e,n){return new cd({type:"template_literal",parts:e,..._.normalizeParams(n)})}var sd=p("ZodLazy",(e,n)=>{Fn.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>ul(e,i,o,t),e.unwrap=()=>e._zod.def.getter()});function ud(e){return new sd({type:"lazy",getter:e})}var ld=p("ZodPromise",(e,n)=>{zs.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>sl(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function og(e){return new ld({type:"promise",innerType:e})}var dd=p("ZodFunction",(e,n)=>{Ss.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Gu(e,i,o,t)});function ag(e){return new dd({type:"function",input:Array.isArray(e?.input)?Ll(e?.input):e?.input??ir(kt()),output:e?.output??kt()})}var lr=p("ZodCustom",(e,n)=>{Ps.init(e,n),Z.init(e,n),e._zod.processJSONSchema=(i,o,t)=>Ju(e,i,o,t)});function cg(e){let n=new H({check:"custom"});return n._zod.check=e,n}function sg(e,n){return vu(lr,e??(()=>!0),n)}function fd(e,n={}){return hu(lr,e,n)}function md(e,n){return $u(e,n)}var ug=yu,lg=bu;function dg(e,n={}){let i=new lr({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,..._.normalizeParams(n)});return i._zod.bag.Class=e,i._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:i,path:[...i._zod.def.path??[]]})},i}var fg=(...e)=>_u({Codec:ur,Boolean:sn,String:on},...e);function mg(e){let n=ud(()=>ln([er(e),wl(),Il(),Dl(),ir(n),Ml(er(),n)]));return n}function pg(e,n){return new id({type:"pipe",in:So(e),out:n})}var vb={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function hb(e){ne({customError:e})}function $b(){return ne().customError}var pd;pd||(pd={});var dr={};Fe(dr,{ZodISODate:()=>it,ZodISODateTime:()=>rt,ZodISODuration:()=>at,ZodISOTime:()=>ot,date:()=>bb,datetime:()=>yb,duration:()=>xb,time:()=>_b});function yb(e){return Kn(rt,e)}function bb(e){return Xn(it,e)}function _b(e){return qn(ot,e)}function xb(e){return Hn(at,e)}var S={...dn,...eo,iso:dr},kb=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function wb(e,n){let i=e.$schema;return i==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":i==="http://json-schema.org/draft-07/schema#"?"draft-7":i==="http://json-schema.org/draft-04/schema#"?"draft-4":n??"draft-2020-12"}function gg(e,n){return e.map((i,o)=>o<n?i:i.optional())}function Ib(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Sb(e,n){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let i=e.slice(1).split("/").filter(Boolean);if(i.length===0)return n.rootSchema;let o=n.version==="draft-2020-12"?"$defs":"definitions";if(i[0]===o){let t=i[1]===void 0?void 0:Ib(i[1]);if(!t||!n.defs[t])throw new Error(`Reference not found: ${e}`);return n.defs[t]}throw new Error(`Reference not found: ${e}`)}function zb(e,n){return S.transform(o=>o).check(o=>{let t=o.value;if(!(typeof t!="object"||t===null||Array.isArray(t)))for(let r of Object.getOwnPropertyNames(t)){let a=n.safeParse(r);a.success||o.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:r,path:[r],continue:!0})}}).pipe(e)}function vg(e,n){if(e!==!1)return e===void 0||e===!0?S.any():$e(e,n)}var Pb=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function hg(e,n){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return S.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let t=e.$ref;if(n.refs.has(t))return n.refs.get(t);if(n.processing.has(t))return S.lazy(()=>{if(!n.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return n.refs.get(t)});n.processing.add(t);let r=Sb(t,n),a=$e(r,n);return n.refs.set(t,a),n.processing.delete(t),a}if(e.enum!==void 0){let t=e.enum;if(n.version==="openapi-3.0"&&e.nullable===!0&&t.length===1&&t[0]===null)return S.null();if(t.length===0)return S.never();if(t.length===1)return S.literal(t[0]);if(t.every(a=>typeof a=="string"))return S.enum(t);let r=t.map(a=>S.literal(a));return r.length<2?r[0]:S.union([r[0],r[1],...r.slice(2)])}if(e.const!==void 0)return S.literal(e.const);let i=e.type;if(Array.isArray(i)){let t=i.map(r=>{let a={...e,type:r};return hg(a,n)});return t.length===0?S.never():t.length===1?t[0]:S.union(t)}if(!i)return S.any();let o;switch(i){case"string":{let t=S.string();if(e.format){let r=e.format;r==="email"?t=t.check(S.email()):r==="uri"||r==="uri-reference"?t=t.check(S.url()):r==="uuid"||r==="guid"?t=t.check(S.uuid()):r==="date-time"?t=t.check(S.iso.datetime({offset:!0})):r==="date"?t=t.check(S.iso.date()):r==="time"?t=t.check(S.regex(Pb)):r==="duration"?t=t.check(S.iso.duration()):r==="hostname"?t=t.check(S.hostname()):r==="ipv4"?t=t.check(S.ipv4()):r==="ipv6"?t=t.check(S.ipv6()):r==="mac"?t=t.check(S.mac()):r==="cidr"?t=t.check(S.cidrv4()):r==="cidr-v6"?t=t.check(S.cidrv6()):r==="base64"?t=t.check(S.base64()):r==="base64url"?t=t.check(S.base64url()):r==="e164"?t=t.check(S.e164()):r==="credit_card"?t=t.check(S.creditCard()):r==="jwt"?t=t.check(S.jwt()):r==="emoji"?t=t.check(S.emoji()):r==="nanoid"?t=t.check(S.nanoid()):r==="cuid"?t=t.check(S.cuid()):r==="cuid2"?t=t.check(S.cuid2()):r==="ulid"?t=t.check(S.ulid()):r==="xid"?t=t.check(S.xid()):r==="ksuid"&&(t=t.check(S.ksuid()))}typeof e.minLength=="number"&&(t=t.min(e.minLength)),typeof e.maxLength=="number"&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),o=t;break}case"number":case"integer":{let t=i==="integer"?S.number().int():S.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum=="number"?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(t=t.lt(e.maximum)),typeof e.multipleOf=="number"&&(t=t.multipleOf(e.multipleOf)),o=t;break}case"boolean":{o=S.boolean();break}case"null":{o=S.null();break}case"object":{let t={},r=e.properties||{},a=new Set(e.required||[]),c=typeof e.additionalProperties=="object"?$e(e.additionalProperties,n):void 0;for(let[s,u]of Object.entries(r)){let l=$e(u,n);ee(t,s,a.has(s)?l:l.optional())}if(e.patternProperties){let s=e.patternProperties,u=Object.keys(s),l=[];for(let f of u){let m=$e(s[f],n),v=S.string().regex(new RegExp(f));l.push(S.looseRecord(v,m))}let d=[];if(Object.keys(t).length>0&&d.push(S.object(t).passthrough()),d.push(...l),d.length===0)o=S.object({}).passthrough();else if(d.length===1)o=d[0];else{let f=S.intersection(d[0],d[1]);for(let m=2;m<d.length;m++)f=S.intersection(f,d[m]);o=f}if(e.additionalProperties===!1){let f=Object.keys(t),m=u.map(y=>new RegExp(y)),v=o;o=o.check(y=>{if(!ze(y.value))return;let x=[];for(let I of Object.keys(y.value))f.includes(I)||m.some(h=>h.test(I))||x.push(I);x.length&&y.issues.push({code:"unrecognized_keys",keys:x,input:y.value,inst:v})})}}else{let s=S.object(t);e.additionalProperties===!1?o=s.strict():c?o=s.catchall(c):o=s.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let s=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;o=zb(o,$e(s,n))}break}case"array":{let t=e.prefixItems,r=e.items;if(t&&Array.isArray(t)){let a=typeof e.minItems=="number"?e.minItems:0,c=t.map(d=>$e(d,n)),s=gg(c,a),u=Array.isArray(r)?void 0:vg(r,n),l=S.tuple(s);o=u?l.rest(u):l,typeof e.minItems=="number"&&(o=o.check(S.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(S.maxLength(e.maxItems)))}else if(Array.isArray(r)){let a=typeof e.minItems=="number"?e.minItems:0,c=r.map(d=>$e(d,n)),s=gg(c,a),u=vg(e.additionalItems,n),l=S.tuple(s);o=u?l.rest(u):l,typeof e.minItems=="number"&&(o=o.check(S.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(S.maxLength(e.maxItems)))}else if(r!==void 0){let a=$e(r,n),c=S.array(a);typeof e.minItems=="number"&&(c=c.min(e.minItems)),typeof e.maxItems=="number"&&(c=c.max(e.maxItems)),o=c}else o=S.array(S.any());break}default:throw new Error(`Unsupported type: ${i}`)}return o}function $e(e,n){if(typeof e=="boolean")return e?S.any():S.never();let i=hg(e,n),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let c=e.anyOf.map(u=>$e(u,n)),s=S.union(c);i=o?S.intersection(i,s):s}if(e.oneOf&&Array.isArray(e.oneOf)){let c=e.oneOf.map(u=>$e(u,n)),s=S.xor(c);i=o?S.intersection(i,s):s}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)i=o?i:S.any();else{let c=o?i:$e(e.allOf[0],n),s=o?0:1;for(let u=s;u<e.allOf.length;u++)c=S.intersection(c,$e(e.allOf[u],n));i=c}e.nullable===!0&&n.version==="openapi-3.0"&&(i=S.nullable(i)),e.readOnly===!0&&(i=S.readonly(i)),e.default!==void 0&&(i=i.default(e.default));let t={},r=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let c of r)c in e&&(t[c]=e[c]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let c of a)c in e&&(t[c]=e[c]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(t.propertyNames=e.propertyNames);for(let c of Object.keys(e))kb.has(c)||ee(t,c,e[c]);return Object.keys(t).length>0&&n.registry.add(i,t),e.description&&(i=i.describe(e.description)),i}function $g(e,n){if(typeof e=="boolean")return e?S.any():S.never();let i;try{i=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=wb(i,n?.defaultTarget),t=i.$defs||i.definitions||{},r={version:o,defs:t,refs:new Map,processing:new Set,rootSchema:i,registry:n?.registry??oe};return $e(i,r)}var yg=Symbol("z.visit/resolving");function fr(e,n){let i=typeof n=="function"?n:(a,c)=>{let s=n[a._zod.def.type];return s?s(a,c):a},o=new Map;function t(a){let c=o.get(a);if(c===yg)return new Fn({type:"lazy",getter:()=>o.get(a)});if(c!==void 0)return c;o.set(a,yg);let s=r(a),u=i(s,s!==a);return o.set(a,u),u}function r(a){let c=a._zod.def,s=c.type;switch(s){case"object":{let u=c.shape,l=Object.keys(u),d=!1,f={};for(let v of l){let y=t(u[v]);y!==u[v]&&(d=!0),f[v]=y}let m=c.catchall;return c.catchall&&(m=t(c.catchall),m!==c.catchall&&(d=!0)),d?B(a,{...c,shape:f,catchall:m}):a}case"array":{let u=t(c.element);return u===c.element?a:B(a,{...c,element:u})}case"tuple":{let u=c.items,l=!1,d=[];for(let m of u){let v=t(m);v!==m&&(l=!0),d.push(v)}let f=c.rest;return c.rest&&(f=t(c.rest),f!==c.rest&&(l=!0)),l?B(a,{...c,items:d,rest:f}):a}case"record":case"map":{let u=t(c.keyType),l=t(c.valueType);return u===c.keyType&&l===c.valueType?a:B(a,{...c,keyType:u,valueType:l})}case"set":{let u=t(c.valueType);return u===c.valueType?a:B(a,{...c,valueType:u})}case"union":{let u=c.options,l=!1,d=[];for(let f of u){let m=t(f);m!==f&&(l=!0),d.push(m)}return l?B(a,{...c,options:d}):a}case"intersection":{let u=t(c.left),l=t(c.right);return u===c.left&&l===c.right?a:B(a,{...c,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=t(c.innerType);return u===c.innerType?a:B(a,{...c,innerType:u})}case"pipe":{let u=t(c.in),l=t(c.out);return u===c.in&&l===c.out?a:B(a,{...c,in:u,out:l})}case"function":{let u=t(c.input),l=t(c.output);return u===c.input&&l===c.output?a:B(a,{...c,input:u,output:l})}case"lazy":{let u=c.getter,{_cachedInner:l,...d}=c;return B(a,{...d,getter:()=>t(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return t(e)}function bg(e){return fr(e,{object:n=>n.partial(),union:n=>{let i=n._zod.def;return i.discriminator===void 0?n:ln(i.options)}})}function Db(e,n){if(!n?.length)return e;let i=e._zod.def;return B(e,Te(i,{checks:[...i.checks??[],...n]}),{parent:!0})}function _g(e){return Db(e.out,e.checks)}function Ob(e){return e.in._zod.traits.has("$ZodTransform")?_g(e):e.in}function xg(e){return fr(e,{pipe:n=>Ob(n._zod.def),default:(n,i)=>i?wt(n._zod.def.innerType):n,catch:(n,i)=>i?n._zod.def.innerType:n})}function kg(e){return fr(e,{pipe:n=>_g(n._zod.def),prefault:(n,i)=>i?n._zod.def.innerType:n})}var gd={};Fe(gd,{bigint:()=>Tb,boolean:()=>Ub,date:()=>Ab,number:()=>Nb,string:()=>jb});function jb(e){return Ms(on,e)}function Nb(e){return Bs(cn,e)}function Ub(e){return Qs(sn,e)}function Tb(e){return tu(un,e)}function Ab(e){return fu(rr,e)}var zt={maxBatchEvents:1e3,maxProjectIdLength:128,maxSessionIdLength:128,maxSdkVersionLength:64,maxUrlLength:2048,maxTitleLength:512,maxReferrerLength:2048,maxLanguageLength:35,maxMeshNameLength:256,maxAssetNameLength:1024,maxCustomNameLength:128,maxCustomPropValueLength:1024,maxCustomPropEntries:64,maxUserIdLength:128,maxUserTraitValueLength:1024,maxUserTraitEntries:64,maxSceneDescriptionLength:256,maxCameraNameLength:128,maxSceneProxyMeshNameLength:256,maxSceneProxyMeshPathLength:512,maxSceneProxyMeshes:1e4,maxNodeIdLength:128,maxBoneIdLength:128,maxChildPathLength:512,maxGraphicsDiagnosticMessageLength:1024,maxGraphicsDiagnosticCodeLength:64};var Do=C.tuple([C.number(),C.number(),C.number()]),vd=C.tuple([C.number(),C.number(),C.number(),C.number()]),Eb=C.tuple([C.number(),C.number()]),Cb=C.tuple([C.number().min(0).max(1),C.number().min(0).max(1)]),hd=C.number().int().nonnegative(),fn=C.string().regex(/^[A-Za-z0-9._:-]{1,64}$/,"sceneId must be 1-64 chars of [A-Za-z0-9._:-]");var $d=C.enum(["left","right"]),Oo=C.enum(["y","z"]),oI=C.object({handedness:$d,upAxis:Oo.default("y"),unitScale:C.number().positive().default(1)}).passthrough();var yd=C.tuple([C.number(),C.number(),C.number(),C.number(),C.number(),C.number()]),wg=C.literal("aabb"),Ig=C.object({position:Do,rotation:vd,scale:Do}),Sg=C.object({name:C.string().max(zt.maxSceneProxyMeshNameLength),aabb:yd,triangles:C.number().int().nonnegative().optional(),path:C.string().min(1).max(zt.maxSceneProxyMeshPathLength).optional(),world:Ig.optional()}),mr=1,bd=C.object({version:C.literal(mr),sceneId:fn,kind:wg,bounds:yd,upAxis:Oo,handedness:$d.optional(),unitScale:C.number().positive(),meshes:C.array(Sg).max(zt.maxSceneProxyMeshes),meshCount:C.number().int().nonnegative(),contentHash:C.string().min(1),capturedAt:hd,sdkVersion:C.string().min(1)});var jo=class{maxSize;items=[];constructor(n){this.maxSize=n}get size(){return this.items.length}enqueue(n){this.items.push(n),this.items.length>this.maxSize&&this.items.splice(0,this.items.length-this.maxSize)}drain(){let n=this.items;return this.items=[],n}prepend(n){this.items=[...n,...this.items],this.items.length>this.maxSize&&this.items.splice(0,this.items.length-this.maxSize)}};function Pg(){let e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Dg(e){let n=e.replace(/\/$/,"")+"/api/v1/collect";return{async send(i){let o=JSON.stringify(i),t=globalThis.navigator;if(t&&typeof t.sendBeacon=="function"){let a=new Blob([o],{type:"application/json"});return t.sendBeacon(n,a)}let r=globalThis.fetch;if(typeof r!="function")return!1;try{let a=await r(n,{method:"POST",headers:{"content-type":"application/json"},body:o,keepalive:o.length<64e3});return a.ok?!0:a.status>=400&&a.status<500&&a.status!==408&&a.status!==429}catch{return!1}}}}function Og(e){return{process:n=>e.send(n),processUnload:n=>e.send(n),dispose:()=>{}}}var Zb="/api/v1/collect";function Vb(e){return e.replace(/\/$/,"")+Zb}function Lb(e){let n=new Set,i=[];for(let o of e.events)for(let t of Object.values(o)){let r;t instanceof ArrayBuffer?r=t:ArrayBuffer.isView(t)&&(r=t.buffer),r&&!n.has(r)&&(n.add(r),i.push(r))}return i}function _d(){return new Worker(new URL("./offloadWorker.js",import.meta.url),{type:"module"})}function jg(e){let n=e.workerFactory??_d,i;try{i=n()}catch{return null}let o=1,t=!1,r=new Map,a=c=>{for(let s of r.values())s(c);r.clear()};i.addEventListener("message",c=>{let s=c.data;if(!s||s.type!=="result")return;let u=r.get(s.id);u&&(r.delete(s.id),u(s.ok))}),i.addEventListener("error",()=>{a(!1)});try{i.postMessage({type:"init",url:Vb(e.endpoint)})}catch{return i.terminate?.(),null}return{process(c){if(t)return Promise.resolve(!1);let s=o++;return new Promise(u=>{r.set(s,u);try{i.postMessage({type:"batch",id:s,batch:c},Lb(c))}catch{r.delete(s),u(!1)}})},processUnload:c=>e.unloadTransport.send(c),dispose:()=>{t||(t=!0,a(!1),i.terminate?.())}}}var No={orbitDeg:1,rollDeg:1,zoom:.02,pan:.005},Mb=180/Math.PI;function mn(e,n){return[e[0]-n[0],e[1]-n[1],e[2]-n[2]]}function Ie(e,n){return e[0]*n[0]+e[1]*n[1]+e[2]*n[2]}function gn(e){return Math.hypot(e[0],e[1],e[2])}function pn(e){let n=gn(e);return n>1e-9?[e[0]/n,e[1]/n,e[2]/n]:[0,0,0]}function Ug(e,n){let i=gn(e),o=gn(n);if(i<1e-9||o<1e-9)return 0;let t=Math.min(1,Math.max(-1,Ie(e,n)/(i*o)));return Math.acos(t)*Mb}function Ng(e,n){let i=e.position,o=pn(e.forward),t=n.position,r=pn(n.forward),a=mn(i,t),c=Ie(o,o),s=Ie(o,r),u=Ie(r,r),l=Ie(o,a),d=Ie(r,a),f=c*u-s*s;if(f<1e-4)return null;let m=(s*d-u*l)/f,v=(c*d-s*l)/f;if(m<=0||v<=0)return null;let y=[i[0]+m*o[0],i[1]+m*o[1],i[2]+m*o[2]],x=[t[0]+v*r[0],t[1]+v*r[1],t[2]+v*r[2]];return{pivot:[(y[0]+x[0])/2,(y[1]+x[1])/2,(y[2]+x[2])/2],distance:(m+v)/2}}function Rb(e,n){if(!e.up||!n.up)return 0;let i=pn([e.forward[0]+n.forward[0],e.forward[1]+n.forward[1],e.forward[2]+n.forward[2]]);if(gn(i)<1e-6)return 0;let o=pn(mn(e.up,[i[0]*Ie(e.up,i),i[1]*Ie(e.up,i),i[2]*Ie(e.up,i)])),t=pn(mn(n.up,[i[0]*Ie(n.up,i),i[1]*Ie(n.up,i),i[2]*Ie(n.up,i)]));return Ug(o,t)}function Tg(e,n,i={}){let o=i.sensitivity&&i.sensitivity>0?i.sensitivity:1,t={orbitDeg:(i.thresholds?.orbitDeg??No.orbitDeg)*o,rollDeg:(i.thresholds?.rollDeg??No.rollDeg)*o,zoom:(i.thresholds?.zoom??No.zoom)*o,pan:(i.thresholds?.pan??No.pan)*o},r=e.pivot&&e.distance!==void 0?{pivot:e.pivot,distance:e.distance,explicit:!0}:null,a=r?null:Ng(e,n),c=r??(a?{...a,explicit:!1}:null),s=Ug(e.forward,n.forward),u=Rb(e,n),l,d=!1;e.fov!==void 0&&n.fov!==void 0&&n.fov>1e-6?l=e.fov/n.fov:r&&e.distance!==void 0&&n.distance!==void 0&&n.distance>1e-6&&(l=e.distance/n.distance,d=!0);let f=mn(n.position,e.position),m,v=!1;if(c){let U=r?n.pivot??c.pivot:Ng(n,e)?.pivot??c.pivot,j=mn(U,c.pivot),O=pn(e.forward),Y=Ie(j,O),ce=mn(j,[O[0]*Y,O[1]*Y,O[2]*Y]);m=gn(ce)}else m=gn(f),v=m>0;let y=c&&c.distance>1e-6?c.distance:i.sceneRadius&&i.sceneRadius>1e-6?i.sceneRadius:void 0,x=y?m/y:m,I=l!==void 0?Math.abs(l-1):0,h=[];if(s>t.orbitDeg&&h.push({kind:"orbit",ratio:s/t.orbitDeg}),u>t.rollDeg&&h.push({kind:"roll",ratio:u/t.rollDeg}),I>t.zoom&&h.push({kind:d?"dolly":"zoom",ratio:I/t.zoom}),x>t.pan&&h.push({kind:v?"fly":"pan",ratio:x/t.pan}),h.length===0)return null;h.sort((U,j)=>j.ratio-U.ratio);let A={kind:h[0].kind};return s>t.orbitDeg&&(A.orbitDeg=s),u>t.rollDeg&&(A.rollDeg=u),I>t.zoom&&l!==void 0&&(A.zoomRatio=l),x>t.pan&&(A.panDist=x),A}function Ag(e){let n=[e[12]??0,e[13]??0,e[14]??0],i=Math.hypot(e[0],e[1],e[2]),o=Math.hypot(e[4],e[5],e[6]),t=Math.hypot(e[8],e[9],e[10]);e[0]*(e[5]*e[10]-e[6]*e[9])-e[4]*(e[1]*e[10]-e[2]*e[9])+e[8]*(e[1]*e[6]-e[2]*e[5])<0&&(i=-i);let a=i!==0?1/i:0,c=o!==0?1/o:0,s=t!==0?1/t:0,u=e[0]*a,l=e[1]*a,d=e[2]*a,f=e[4]*c,m=e[5]*c,v=e[6]*c,y=e[8]*s,x=e[9]*s,I=e[10]*s,h=u+m+I,P,A,U,j;if(h>0){let O=.5/Math.sqrt(h+1);j=.25/O,P=(v-x)*O,A=(y-d)*O,U=(l-f)*O}else if(u>m&&u>I){let O=2*Math.sqrt(1+u-m-I);j=(v-x)/O,P=.25*O,A=(f+l)/O,U=(y+d)/O}else if(m>I){let O=2*Math.sqrt(1+m-u-I);j=(y-d)/O,P=(f+l)/O,A=.25*O,U=(x+v)/O}else{let O=2*Math.sqrt(1+I-u-m);j=(l-f)/O,P=(y+d)/O,A=(x+v)/O,U=.25*O}return{position:n,rotation:[P,A,U,j],scale:[i,o,t]}}function pr(e,n){if(e.length===0)return 0;let i=Math.ceil(n/100*e.length),o=Math.min(e.length,Math.max(1,i))-1;return e[o]??0}function Eg(e,n){return[e[0]-n[0],e[1]-n[1],e[2]-n[2]]}function Cg(e,n){return e[0]*n[0]+e[1]*n[1]+e[2]*n[2]}function Uo(e){return Math.hypot(e[0],e[1],e[2])}function xd(e){return e<0?0:e>1?1:e}function To(e,n,i,o,t,r,a){let c=Eg(t,e),s=Uo(c)||1e-6,l=Cg(c,n)/(s*i)>=a,d=Math.atan2(r,s),f=xd(d/(o||1e-6));return{centered:l,frac:f}}function Ao(e,n,i){for(let o=0;o<6;o++)if(Math.abs((e[o]??0)-(n[o]??0))>i)return!1;return!0}function Eo(e){return[Math.round(e[0]*1e3)/1e3,Math.round(e[1]*1e3)/1e3,Math.round(e[2]*1e3)/1e3,Math.round(e[3]*1e3)/1e3,Math.round(e[4]*1e3)/1e3,Math.round(e[5]*1e3)/1e3]}function Pt(e,n,i){return Math.abs(e[0]-n[0])<=i&&Math.abs(e[1]-n[1])<=i&&Math.abs(e[2]-n[2])<=i}function Co(e,n,i){return!(!Pt(e.position,n.position,i)||!Pt(e.direction,n.direction,i)||e.target===void 0!=(n.target===void 0)||e.target&&n.target&&!Pt(e.target,n.target,i)||e.fov===void 0!=(n.fov===void 0)||e.fov!==void 0&&n.fov!==void 0&&Math.abs(e.fov-n.fov)>i||e.aspect===void 0!=(n.aspect===void 0)||e.aspect!==void 0&&n.aspect!==void 0&&Math.abs(e.aspect-n.aspect)>i||e.near===void 0!=(n.near===void 0)||e.near!==void 0&&n.near!==void 0&&Math.abs(e.near-n.near)>i)}function Zo(e,n,i){return!(!Pt(e.position,n.position,i)||Math.abs(e.rotation[0]-n.rotation[0])>i||Math.abs(e.rotation[1]-n.rotation[1])>i||Math.abs(e.rotation[2]-n.rotation[2])>i||Math.abs(e.rotation[3]-n.rotation[3])>i||e.scale===void 0!=(n.scale===void 0)||e.scale&&n.scale&&!Pt(e.scale,n.scale,i))}function Fb(e){for(let n=0;n<e.length;n++)if(!Number.isFinite(e[n]))return!1;return!0}function kd(e){let n=e.emit,i,o=new Map,t=new Map,r=new Map;function a(l){if(!Number.isFinite(l.fps)||l.fps<0)return;let d=l.frameTimes,f;if(d.length>0){let y=0;for(let I=0;I<d.length;I++)d[I]>l.jankFrameMs&&y++;let x=Array.from(d).sort((I,h)=>I-h);f={frameTimeP95Ms:pr(x,95),frameTimeP99Ms:pr(x,99),longFrames:y}}let m=e.perf?.suppressIdle??!1,v=e.perf?.fpsThreshold??0;m&&i!==void 0&&Math.abs(l.fps-i)<=v||(i=l.fps,n({type:"frame_perf",fps:l.fps,...f??{},...typeof l.dpr=="number"&&l.dpr>0?{dpr:l.dpr}:{},...l.renderScale!==void 0?{renderScale:l.renderScale}:{},...l.position?{position:l.position}:{}}))}function c(l){let d=l.decomposed??Jb(l.matrix,l.scaleEps),f=l.boneId?`${l.nodeId}\0bone\0${l.boneId}`:l.childPath!==void 0?`${l.nodeId}\0${l.childPath}`:l.nodeId,m=e.node?.suppressIdle??!1,v=o.get(f);m&&v&&Zo(v,d,l.scaleEps)||(o.set(f,d),n({type:"node_transform",nodeId:l.nodeId,...l.childPath!==void 0?{childPath:l.childPath}:{},...l.boneId!==void 0?{boneId:l.boneId}:{},position:d.position,rotation:d.rotation,...d.scale?{scale:d.scale}:{}}))}function s(l){if(l.stepMs<=0)return;let d=e.visibility?.centeredCos??1,f=e.visibility?.boundingBox??!1,m=Uo(l.forward)||1,v=(l.fov||.8)/2;for(let y of l.meshes){let{centered:x,frac:I}=To(l.camPos,l.forward,m,v,y.center,y.radius,d),h=t.get(y.mesh);h||(h={visibleMs:0,centeredMs:0,maxScreenFraction:0},t.set(y.mesh,h)),h.visibleMs+=l.stepMs,x&&(h.centeredMs+=l.stepMs),I>h.maxScreenFraction&&(h.maxScreenFraction=I),f&&y.aabb&&(h.bounds=y.aabb)}}function u(){if(t.size===0)return;let l=e.visibility?.boundsEps??.001,d=t;t=new Map;for(let[f,m]of d){if(m.visibleMs<=0)continue;let v;if(m.bounds&&Fb(m.bounds)){let y=r.get(f);(!y||!Ao(y,m.bounds,l))&&(v=Eo(m.bounds),r.set(f,m.bounds))}n({type:"mesh_visibility",mesh:f,visibleMs:Math.round(m.visibleMs),...m.centeredMs>0?{centeredMs:Math.round(m.centeredMs)}:{},...m.maxScreenFraction>0?{maxScreenFraction:Math.round(m.maxScreenFraction*1e4)/1e4}:{},...v?{bounds:v}:{}})}}return{ingest(l){switch(l.channel){case"camera":n({type:"camera_sample",position:l.position,direction:l.direction,...l.target?{target:l.target}:{},...l.fov!==void 0?{fov:l.fov}:{},...l.aspect!==void 0?{aspect:l.aspect}:{},...l.near!==void 0?{near:l.near}:{},...l.hitPoint?{hitPoint:l.hitPoint}:{},...l.hitMesh?{hitMesh:l.hitMesh}:{}});return;case"perf":a(l);return;case"node":c(l);return;case"visibilityTick":s(l);return;case"visibilityFlush":u();return;case"gesture":{let d=Tg(l.start,l.end,l.options??{});if(!d)return;n({type:"camera_gesture",kind:d.kind,durationMs:l.durationMs,...d.orbitDeg!==void 0?{orbitDeg:d.orbitDeg}:{},...d.rollDeg!==void 0?{rollDeg:d.rollDeg}:{},...d.zoomRatio!==void 0?{zoomRatio:d.zoomRatio}:{},...d.panDist!==void 0?{panDist:d.panDist}:{},...l.source?{source:l.source}:{}});return}case"hover":n({type:"hover_dwell",mesh:l.mesh,dwellMs:l.dwellMs,...l.source?{source:l.source}:{},...l.uv?{uv:l.uv}:{}});return}},reset(){i=void 0,o.clear(),t=new Map,r.clear()}}}function Jb(e,n){if(!e||e.length<16)return{position:[0,0,0],rotation:[0,0,0,1]};let i=Ag(e),o={position:i.position,rotation:i.rotation},[t,r,a]=i.scale;return(Math.abs(t-1)>n||Math.abs(r-1)>n||Math.abs(a-1)>n)&&(o.scale=i.scale),o}function wd(e){return e.channel==="perf"?[e.frameTimes.buffer]:e.channel==="node"&&e.matrix?[e.matrix.buffer]:[]}function Zg(e){return{ingest:n=>e.ingest(n),drain:()=>Promise.resolve(),dispose:()=>{}}}function Vg(e){let n=e.workerFactory??_d,i;try{i=n()}catch{return null}let o=!1,t=1,r=new Map;i.addEventListener("message",a=>{let c=a.data;if(c){if(c.type==="events")e.onEvents(c.events,c.capturedAt);else if(c.type==="unloadDone"){let s=r.get(c.id);s&&(r.delete(c.id),s())}}}),i.addEventListener("error",()=>{for(let a of r.values())a();r.clear()});try{i.postMessage({type:"aggInit",config:e.config})}catch{return i.terminate?.(),null}return{ingest(a,c){if(!o)try{i.postMessage({type:"snapshot",capturedAt:c,snapshot:a},wd(a))}catch{}},drain(){if(o)return Promise.resolve();let a=t++;return new Promise(c=>{r.set(a,c);try{i.postMessage({type:"flushUnload",id:a})}catch{r.delete(a),c()}})},dispose(){if(!o){o=!0;for(let a of r.values())a();r.clear(),i.terminate?.()}}}}var gr="0.1.0";var Vo={batchSize:20,flushIntervalMs:5e3,maxQueueSize:1e3,resizeDebounceMs:250};function Gb(e){return{projectId:e.projectId,endpoint:e.endpoint,sdkVersion:e.sdkVersion??gr,batchSize:e.batchSize??Vo.batchSize,flushIntervalMs:e.flushIntervalMs??Vo.flushIntervalMs,maxQueueSize:e.maxQueueSize??Vo.maxQueueSize,offload:e.offload??"main",disabled:e.disabled??!1,captureLifecycle:e.captureLifecycle??!0,resizeDebounceMs:e.resizeDebounceMs??Vo.resizeDebounceMs,captureErrors:e.captureErrors??!1,captureGraphicsDiagnostics:e.captureGraphicsDiagnostics??!1,captureShaderSource:e.captureShaderSource??!1,debug:e.debug??!1}}var vr=class e{config;sessionId;queue;transport;processor;beforeSend;collectors=[];handles=[];aggSinks=[];customTransport;createWorkerFn;started=!1;startedAt=0;url;currentScene=Sr;pageMeta;flushTimer;resizeTimer;errorCount=0;lastErrorKey;positionProvider;boundVisibility=()=>this.onVisibilityChange();boundPageHide=()=>{this.stop("hidden")};boundFocus=()=>this.onFocusChange(!0);boundBlur=()=>this.onFocusChange(!1);boundResize=()=>this.onResize();boundError=n=>this.onErrorEvent(n);boundRejection=n=>this.onUnhandledRejection(n);constructor(n){this.config=Gb(n),this.sessionId=Pg(),this.queue=new jo(this.config.maxQueueSize),this.transport=n.transport??Dg(this.config.endpoint),this.customTransport=n.transport,this.createWorkerFn=n.createWorker,this.processor=this.createProcessor(n),this.beforeSend=n.beforeSend}use(n){return this.collectors.push(n),this.started&&this.startCollector(n),this}start(n={}){if(!(this.started||this.config.disabled)){if(this.started=!0,this.startedAt=this.now(),this.url=n.url??this.defaultUrl(),this.pageMeta=n.pageMeta,n.sceneId!=null){let i=fn.safeParse(n.sceneId);i.success?this.currentScene=i.data:this.log(`ignoring invalid initial sceneId: ${String(n.sceneId)}`)}this.emit({type:"session_start",...n.device?{device:n.device}:{},...n.graphics?{graphics:n.graphics}:{},...n.scene?{scene:n.scene}:{},...n.connector?{connector:n.connector}:{},...n.user?{user:n.user}:{}}),this.config.flushIntervalMs>0&&(this.flushTimer=setInterval(()=>{this.flush()},this.config.flushIntervalMs)),this.bindLifecycle();for(let i of this.collectors)this.startCollector(i)}}setScene(n){if(this.config.disabled)return;let i=fn.safeParse(n);if(!i.success){this.log(`ignoring invalid sceneId: ${String(n)}`);return}i.data!==this.currentScene&&(this.currentScene=i.data,this.started&&this.emit({type:"scene_change"}))}setPositionProvider(n){this.positionProvider=n}emit(n){!this.started||this.config.disabled||this.emitInternal(n,this.now())}emitInternal(n,i){if(this.config.disabled)return;let o={...n,projectId:this.config.projectId,sessionId:this.sessionId,ts:i,sdkVersion:this.config.sdkVersion,...this.url?{url:this.url}:{},...this.currentScene!==Sr?{sceneId:this.currentScene}:{},...this.pageMeta?{pageMeta:this.pageMeta}:{}};this.enrichPosition(o);let t=this.beforeSend?this.beforeSend(o):o;t&&(this.queue.enqueue(t),this.queue.size>=this.config.batchSize&&this.flush())}enrichPosition(n){if(!(n.type!=="runtime_error"&&n.type!=="graphics_diagnostic")&&!(this.positionProvider===void 0||n.position))try{let i=this.positionProvider();i&&(n.position=i)}catch(i){this.log("positionProvider threw; emitting without position",i)}}track(n,i){this.emit({type:"custom",name:n,...i?{props:i}:{}})}trackInput(n,i={}){n&&this.emit({type:"input_action",action:n,source:i.source??"keyboard",...i.code?{code:i.code}:{},...typeof i.button=="number"?{button:i.button}:{},...typeof i.pressed=="boolean"?{pressed:i.pressed}:{},...i.handedness?{handedness:i.handedness}:{},...i.sourceId?{sourceId:i.sourceId}:{}})}reportCapabilityChange(n){n.kind&&this.emit({type:"capability_change",kind:n.kind,...n.from?{from:n.from}:{},...n.to?{to:n.to}:{},...n.reason?{reason:n.reason}:{},...typeof n.durationMs=="number"?{durationMs:n.durationMs}:{},...n.source?{source:n.source}:{},...n.handedness?{handedness:n.handedness}:{}})}async flush(n){let i=this.queue.drain();if(i.length===0)return;let o={schemaVersion:"1.0",events:i};await(n?.unload?this.processor.processUnload(o):this.processor.process(o))||(this.queue.prepend(i),this.log("flush failed; re-queued",i.length))}async stop(n="manual"){if(this.started){this.emit({type:"session_end",durationMs:this.now()-this.startedAt,reason:n}),this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0),this.unbindLifecycle();for(let i of this.handles.splice(0))i.stop();this.aggSinks.length>0&&await Promise.all(this.aggSinks.map(i=>i.drain())),this.started=!1,await this.flush({unload:!0});for(let i of this.aggSinks.splice(0))i.dispose();this.processor.dispose()}}now(){return Date.now()}createProcessor(n){if(this.config.offload==="worker")if(n.transport)this.log("custom transport set; worker offload disabled (transport runs on main thread)");else{let i=jg({endpoint:this.config.endpoint,unloadTransport:this.transport,...n.createWorker?{workerFactory:n.createWorker}:{}});if(i)return i;this.log("worker offload unavailable; falling back to main-thread processor")}return Og(this.transport)}createAggregation(n){if(this.config.offload==="worker"&&!this.customTransport){let t=Vg({config:n,onEvents:(r,a)=>{for(let c of r)this.emitInternal(c,a)},...this.createWorkerFn?{workerFactory:this.createWorkerFn}:{}});if(t)return this.aggSinks.push(t),r=>t.ingest(r,this.now());this.log("worker aggregation unavailable; falling back to main-thread aggregator")}let i=kd({...n,emit:t=>this.emit(t)}),o=Zg(i);return this.aggSinks.push(o),t=>o.ingest(t,this.now())}startCollector(n){let i={config:this.config,sessionId:this.sessionId,emit:o=>this.emit(o),track:(o,t)=>this.track(o,t),trackInput:(o,t)=>this.trackInput(o,t),reportCapabilityChange:o=>this.reportCapabilityChange(o),setScene:o=>this.setScene(o),setPositionProvider:o=>this.setPositionProvider(o),createAggregation:o=>this.createAggregation(o),now:()=>this.now()};try{let o=n.start(i);o&&this.handles.push(o)}catch(o){this.log(`collector "${n.name}" failed to start`,o)}}onVisibilityChange(){let n=globalThis.document,i=n?.visibilityState==="hidden";this.config.captureLifecycle&&n&&this.emit({type:"visibility_change",state:i?"hidden":"visible"}),i&&this.flush({unload:!0})}onFocusChange(n){this.config.captureLifecycle&&this.emit({type:"focus_change",focused:n})}onResize(){this.config.captureLifecycle&&(this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(()=>{this.resizeTimer=void 0,this.emitViewportResize()},this.config.resizeDebounceMs))}emitViewportResize(){let n=globalThis;typeof n.innerWidth!="number"||typeof n.innerHeight!="number"||n.innerWidth<=0||n.innerHeight<=0||this.emit({type:"viewport_resize",width:n.innerWidth,height:n.innerHeight,...typeof n.devicePixelRatio=="number"?{dpr:n.devicePixelRatio}:{}})}static MAX_ERRORS_PER_SESSION=50;onErrorEvent(n){this.emitError({kind:"error",message:n.message||"Unknown error",...n.filename?{source:n.filename}:{},...typeof n.lineno=="number"?{lineno:n.lineno}:{},...typeof n.colno=="number"?{colno:n.colno}:{},...n.error instanceof Error&&n.error.stack?{stack:n.error.stack}:{}})}onUnhandledRejection(n){let i=n.reason,o=i instanceof Error?i.message:typeof i=="string"?i:"Unhandled promise rejection";this.emitError({kind:"unhandledrejection",message:o||"Unhandled promise rejection",...i instanceof Error&&i.stack?{stack:i.stack}:{}})}emitError(n){if(this.errorCount>=e.MAX_ERRORS_PER_SESSION)return;let i=`${n.message}\0${n.stack??""}`;i!==this.lastErrorKey&&(this.lastErrorKey=i,this.errorCount+=1,this.emit({type:"runtime_error",kind:n.kind,message:n.message.slice(0,1024),...n.source?{source:n.source.slice(0,1024)}:{},...typeof n.lineno=="number"?{lineno:n.lineno}:{},...typeof n.colno=="number"?{colno:n.colno}:{},...n.stack?{stack:n.stack.slice(0,4096)}:{}}))}bindLifecycle(){let n=globalThis.document,i=globalThis.addEventListener?globalThis:void 0;n?.addEventListener("visibilitychange",this.boundVisibility),i?.addEventListener("pagehide",this.boundPageHide),this.config.captureLifecycle&&i&&(i.addEventListener("focus",this.boundFocus),i.addEventListener("blur",this.boundBlur),i.addEventListener("resize",this.boundResize),this.emitViewportResize()),this.config.captureErrors&&i&&(i.addEventListener("error",this.boundError),i.addEventListener("unhandledrejection",this.boundRejection))}unbindLifecycle(){let n=globalThis.document,i=globalThis.removeEventListener?globalThis:void 0;n?.removeEventListener("visibilitychange",this.boundVisibility),i?.removeEventListener("pagehide",this.boundPageHide),i?.removeEventListener("focus",this.boundFocus),i?.removeEventListener("blur",this.boundBlur),i?.removeEventListener("resize",this.boundResize),i?.removeEventListener("error",this.boundError),i?.removeEventListener("unhandledrejection",this.boundRejection),this.resizeTimer&&(clearTimeout(this.resizeTimer),this.resizeTimer=void 0)}defaultUrl(){return globalThis.location?.href}log(...n){this.config.debug&&console.debug("[uptimizr]",...n)}};function Dt(e,n){return e===void 0?{mode:"interval",ms:n}:e==="frame"?{mode:"frame"}:e<=0?{mode:"off"}:{mode:"interval",ms:1e3/e}}function ae(e){return e===0?0:e}function Re(e,n){return n==="left"?[e[0],e[1],e[2]]:[ae(e[0]),ae(e[1]),ae(-e[2])]}function hr(e,n){return n==="left"?[e[0],e[1],e[2]]:[ae(e[0]),ae(e[1]),ae(-e[2])]}function Id(e,n){return n==="left"?[e[0],e[1],e[2],e[3],e[4],e[5]]:[ae(e[0]),ae(e[1]),ae(-e[5]),ae(e[3]),ae(e[4]),ae(-e[2])]}function vn(e,n){return n==="left"?[e[0],e[1],e[2],e[3]]:[ae(-e[0]),ae(-e[1]),ae(e[2]),ae(e[3])]}function Lo(e){return[e.x,e.y,e.z]}function Mo(e){return e<0?0:e>1?1:e}import{Ray as Lg,Vec3 as ct}from"playcanvas";var Mg="uptimizr-";function Sd(e,n){let i=new Lg,o=new ct,t=new ct,r=new ct,a=new ct;return(c,s)=>{let u=n.camera,l=u?.camera;if(!u||!l)return;let d=e.graphicsDevice,f=d?.canvas,m=f?.clientWidth||f?.width||d?.width||1,v=f?.clientHeight||f?.height||d?.height||1,y=(c+1)/2*m,x=(1-s)/2*v,I=u.nearClip??.1,h=u.farClip??1e3;l.screenToWorld(y,x,I,m,v,o),l.screenToWorld(y,x,h,m,v,t),i.origin.copy(o),i.direction.copy(t).sub(o).normalize();let P=1/0,A;if(e.root?.forEach?.(j=>{let O=j;if(O.enabled===!1)return;let Y=O.render?.meshInstances??O.model?.meshInstances;if(Y)for(let ce of Y){if(ce.visible===!1)continue;let se=ce.node?.name??"";if(se.startsWith(Mg))continue;let Oe=ce.aabb;if(!Oe||typeof Oe.intersectsRay!="function"||!Oe.intersectsRay(i,r))continue;let Se=r.x-i.origin.x,je=r.y-i.origin.y,Ne=r.z-i.origin.z,st=Se*Se+je*je+Ne*Ne;st<P&&(P=st,A=se,a.copy(r))}}),A!==void 0)return{point:[a.x,a.y,a.z],name:A}}}function zd(e,n,i={}){let o=new Lg,t=new ct,r=new ct,a=new ct,c=new ct,s=i.maxDistance??1e3,u=s*s,l=i.meshes&&i.meshes.length>0?new Set(i.meshes):null,d=i.predicate;return()=>{let f=n.camera,m=f?.camera;if(!f||!m)return;let v=e.graphicsDevice,y=v?.canvas,x=y?.clientWidth||y?.width||v?.width||1,I=y?.clientHeight||y?.height||v?.height||1,h=x/2,P=I/2,A=f.nearClip??.1,U=f.farClip??1e3;m.screenToWorld(h,P,A,x,I,t),m.screenToWorld(h,P,U,x,I,r),o.origin.copy(t),o.direction.copy(r).sub(t).normalize();let j=1/0,O;if(e.root?.forEach?.(ce=>{let se=ce;if(se.enabled===!1)return;let Oe=se.render?.meshInstances??se.model?.meshInstances;if(Oe)for(let Se of Oe){if(Se.visible===!1)continue;let je=Se.node?.name??"";if(je.startsWith(Mg)||l&&!l.has(je)||d&&Se.node&&!d(Se.node))continue;let Ne=Se.aabb;if(!Ne||typeof Ne.intersectsRay!="function"||!Ne.intersectsRay(o,a))continue;let st=a.x-o.origin.x,hn=a.y-o.origin.y,Go=a.z-o.origin.z,$r=st*st+hn*hn+Go*Go;$r<j&&(j=$r,O=je,c.copy(a))}}),!(O===void 0||j>u))return{point:[c.x,c.y,c.z],name:O}}}function Rg(e){let n=e.pointerType;return n==="mouse"||n==="pen"||n==="touch"?n:typeof n=="string"&&n.length>0?"other":void 0}function Bb(e){if(typeof document>"u")return!1;let n=document.pointerLockElement;return n!=null&&n===e()}var Wb=zt.maxAssetNameLength;function Kb(e,n){return[e[0]-n[0],e[1]-n[1],e[2]-n[2]]}function Xb(e,n){return e[0]*n[0]+e[1]*n[1]+e[2]*n[2]}function qb(e){return e!==null&&typeof e=="object"?e.hz:e}function Hb(e){if(e===null||typeof e!="object")return null;let n=e.include;return n==="*"||Array.isArray(n)&&n.length>0?{include:n,maxDepth:e.maxDepth??8,maxNodes:e.maxNodes??64,exclude:new Set(e.exclude??[])}:null}function Yb(e,n){let i=[],o=n.include==="*",t=o?null:new Set(n.include),r=[];for(let a of e.children??[])r.push({node:a,path:a.name??"",depth:1});for(;r.length>0&&i.length<n.maxNodes;){let{node:a,path:c,depth:s}=r.shift(),u=a.name;if(!(typeof u!="string"||u.length===0)&&!n.exclude.has(u)&&!Gg(a)&&((o||t.has(u))&&i.push({childPath:c,node:a}),s<n.maxDepth))for(let l of a.children??[]){let d=l.name??"";r.push({node:l,path:c?`${c}/${d}`:d,depth:s+1})}}return i}function Gg(e){return e.camera!=null}function Fg(e,n){let i=e.getPosition?.()??{x:0,y:0,z:0},o=e.getRotation?.()??{x:0,y:0,z:0,w:1},t={position:Re([i.x,i.y,i.z],"right"),rotation:vn([o.x,o.y,o.z,o.w],"right")},r=e.getWorldTransform?.()?.getScale?.();return r&&(Math.abs(r.x-1)>n||Math.abs(r.y-1)>n||Math.abs(r.z-1)>n)&&(t.scale=Lo(r)),t}function Jg(e,n){return typeof n=="function"?n()??null:typeof n=="string"?e.findByName?.(n)??null:n??null}function Qb(e){let n=new Set,i=[],o=[...e.render?.meshInstances??[],...e.model?.meshInstances??[]];for(let t of o){let r=t.skinInstance?.bones;if(r)for(let a of r){let c=a?.name;typeof c!="string"||n.has(c)||(n.add(c),i.push(a))}}return i}function e_(e,n){let i=Qb(e);if(i.length===0)return[];if(n==="*")return i;let o=new Map;for(let r of i)typeof r.name=="string"&&o.set(r.name,r);let t=[];for(let r of n){let a=o.get(r);a&&t.push(a)}return t}function t_(e,n){if(!e.getLocalPosition||!e.getLocalRotation)return null;let i=e.getLocalPosition(),o=e.getLocalRotation(),t={position:Re([i.x,i.y,i.z],"right"),rotation:vn([o.x,o.y,o.z,o.w],"right")},r=e.getLocalScale?.();return r&&(Math.abs(r.x-1)>n||Math.abs(r.y-1)>n||Math.abs(r.z-1)>n)&&(t.scale=Lo(r)),t}function Bg(e){return e.render?.meshInstances??e.model?.meshInstances??[]}function n_(e){let n=1/0,i=1/0,o=1/0,t=-1/0,r=-1/0,a=-1/0,c=!1;for(let s of Bg(e)){let u=s.aabb;if(!u||typeof u.getMin!="function"||typeof u.getMax!="function")continue;let l=u.getMin(),d=u.getMax();c=!0,l.x<n&&(n=l.x),l.y<i&&(i=l.y),l.z<o&&(o=l.z),d.x>t&&(t=d.x),d.y>r&&(r=d.y),d.z>a&&(a=d.z)}return c?{center:[(n+t)/2,(i+r)/2,(o+a)/2],radius:.5*Math.hypot(t-n,r-i,a-o),aabb:[n,i,o,t,r,a]}:null}function r_(e,n,i,o){return Xb(Kb(e,i),o)+n>0}function Pd(e){let{app:n,camera:i,sampleCameraMs:o=1e3,samplePerfMs:t=2e3,pointerMoveThrottleMs:r=250,suppressIdleSamples:a=!0,suppressIdlePerfSamples:c=!1,cameraEpsilon:s=.001,perfFpsThreshold:u=1,cameraGestureSensitivity:l=1,capture:d={},sampling:f={}}=e,m=Dt(f.camera,o),v=Dt(f.perf,t),y=Dt(f.pointerMove,r),x=e.keyBindings??{},I=Object.keys(x).length>0,h={camera:(d.camera??!0)&&m.mode!=="off",pointerMove:(d.pointerMove??!0)&&y.mode!=="off",clicks:d.clicks??!0,buttons:d.buttons??!0,cameraGesture:d.cameraGesture??!0,meshPicks:d.meshPicks??!0,perf:(d.perf??!0)&&v.mode!=="off",contextLoss:d.contextLoss??!0,assetLoad:d.assetLoad??!0,meshVisibility:d.meshVisibility??!1,hoverDwell:d.hoverDwell??!1,resourceSample:d.resourceSample??!1,gaze:(d.gaze??!1)&&(d.camera??!0)&&m.mode!=="off",nodes:d.nodes??!0,bones:d.bones??!0,keyboard:(d.keyboard??!0)&&I},P=e.actors??{},A=h.nodes?Object.keys(f.nodes??{}).filter(K=>{let ye=Object.prototype.hasOwnProperty.call(P,K);return ye||console.warn(`[uptimizr] sampling.nodes["${K}"] has no matching entry in \`actors\`; ignoring. Declare the node in \`actors\` to capture its transform.`),ye}):[],U=A.length>0,j=h.bones?Object.keys(f.bones??{}).filter(K=>{if(!Object.prototype.hasOwnProperty.call(P,K))return console.warn(`[uptimizr] sampling.bones["${K}"] has no matching entry in \`actors\`; ignoring. Declare the node in \`actors\` to capture its bones.`),!1;let be=f.bones[K].include;return be!=="*"&&(!Array.isArray(be)||be.length===0)?(console.warn(`[uptimizr] sampling.bones["${K}"].include is empty; ignoring. Provide bone names or "*" to capture bones.`),!1):!0}):[],O=j.length>0,Y=e.meshVisibility??{},ce=Y.windowMs??5e3,se=Y.meshes&&Y.meshes.length>0?new Set(Y.meshes):void 0,Oe=Math.cos((Y.centeredAngleDeg??12)*Math.PI/180),Se=Y.maxMeshes??50,je=Y.boundingBox??!1,Ne=e.hoverDwell??{},st=Ne.minDwellMs??500,hn=Ne.meshes&&Ne.meshes.length>0?new Set(Ne.meshes):void 0,$r=(e.resourceSample??{}).intervalMs??15e3,Ad=y.mode==="interval"?y.ms:0;return{name:"playcanvas",start(K){let ye=n,Ed={perf:{suppressIdle:c,fpsThreshold:u},node:{suppressIdle:a},visibility:{centeredCos:Oe,boundingBox:je,boundsEps:.001}},be=K.createAggregation(Ed),$n=[],yn=[],yr=[],bn=[],br=!1,Cd=!1,_r=0,Bo,Wo=null,qg=()=>ye.stats?.frame?.fps??0,Ko=w=>{if(!w||typeof w.fov!="number")return;let D=w.fov*Math.PI/180;if(w.horizontalFov){let z=typeof w.aspectRatio=="number"&&w.aspectRatio>0?w.aspectRatio:1;return 2*Math.atan(Math.tan(D/2)/z)}return D},Hg=h.gaze?e.gaze?.probe??zd(n,i,e.gaze??{}):void 0,Zd=()=>{let w=i,D=w.getPosition(),z=w.forward,V=Re([D.x,D.y,D.z],"right"),G=hr([z.x,z.y,z.z],"right"),L=Ko(w.camera),F={position:V,direction:G,...L!==void 0?{fov:L}:{}};if(a&&Bo&&Co(Bo,F,s))return;Bo=F;let J=Hg?.(),te=J?Re(J.point,"right"):void 0,_e=J&&J.name?J.name:void 0;be({channel:"camera",position:F.position,direction:F.direction,...F.fov!==void 0?{fov:F.fov}:{},...te?{hitPoint:te}:{},..._e?{hitMesh:_e}:{}})},Vd=()=>{let w=i,D=w.getPosition(),z=w.forward,V=w.up,G={position:Re([D.x,D.y,D.z],"right"),forward:hr([z.x,z.y,z.z],"right"),up:hr([V.x,V.y,V.z],"right")},L=Ko(w.camera);return L!==void 0&&(G.fov=L),G},Yg=()=>{let w=qg();w<=0||be({channel:"perf",frameTimes:new Float32Array(0),fps:w,jankFrameMs:0})},Ld=()=>{if(!Cd)for(let w of yr)w()},Md=()=>{br||(ye.on("frameend",Ld),br=!0)},xr=(w,D)=>{w.mode==="interval"?$n.push(setInterval(D,w.ms)):w.mode==="frame"&&(yr.push(D),Md())};if(h.camera&&(Zd(),xr(m,Zd)),h.perf&&xr(v,Yg),U){let w=ye.root,D=new Set;for(let z of A){let V=P[z],G=f.nodes?.[z],L=Dt(qb(G),o);if(L.mode==="off")continue;let F=Hb(G),J=()=>{let te=Jg(w,V);if(te){if(Gg(te)){D.has(z)||(D.add(z),console.warn(`[uptimizr] actor "${z}" resolves to a camera; refusing node_transform capture. The visitor camera is already captured as camera_sample.`));return}if(be({channel:"node",nodeId:z,decomposed:Fg(te,s),scaleEps:s}),F)for(let{childPath:_e,node:Ce}of Yb(te,F))be({channel:"node",nodeId:z,childPath:_e,decomposed:Fg(Ce,s),scaleEps:s})}};J(),xr(L,J)}}if(O){let w=ye.root,D=new Set;for(let z of j){let V=P[z],G=f.bones[z],L=Dt(G.hz,o);if(L.mode==="off")continue;let F=()=>{let J=Jg(w,V);if(!J)return;let te=e_(J,G.include);if(te.length===0){D.has(z)||(D.add(z),console.warn(`[uptimizr] actor "${z}" resolves to no matching skeleton bones; skipping Tier 2 capture. Declare the skinned entity and check the bone names.`));return}for(let _e of te){let Ce=_e.name;if(typeof Ce!="string")continue;let kn=t_(_e,s);kn&&be({channel:"node",nodeId:z,boneId:Ce,decomposed:kn,scaleEps:s})}};F(),xr(L,F)}}if(h.meshVisibility){let w=K.now(),D=()=>{let V=K.now(),G=V-w;if(w=V,G<=0)return;let L=i,F=L.getPosition(),J=L.forward,te=[F.x,F.y,F.z],_e=[J.x,J.y,J.z],Ce=Ko(L.camera)??0,kn=0,Xo=[];ye.root?.forEach?.(ov=>{let wr=ov;if(Bg(wr).length===0)return;let Ir=wr.name;if(!Ir||Ir.startsWith("uptimizr-"))return;if(se){if(!se.has(Ir))return}else if(wr.enabled===!1||kn>=Se)return;let Ue=n_(wr);Ue&&(kn++,r_(Ue.center,Ue.radius,te,_e)&&Xo.push({mesh:Ir,center:Ue.center,radius:Ue.radius,...je?{aabb:[Ue.aabb[0],Ue.aabb[1],-Ue.aabb[5],Ue.aabb[3],Ue.aabb[4],-Ue.aabb[2]]}:{}}))}),Xo.length!==0&&be({channel:"visibilityTick",stepMs:G,camPos:te,forward:_e,fov:Ce,meshes:Xo})},z=()=>be({channel:"visibilityFlush"});yr.push(D),Md(),$n.push(setInterval(z,ce)),bn.push(z)}let Qg=h.pointerMove||h.clicks||h.buttons||h.meshPicks||h.hoverDwell,Be=ye.graphicsDevice?.canvas,Rd=Qg&&Be?e.raycast??Sd(n,i):void 0,We=(w,D)=>{Be&&(Be.addEventListener(w,D),yn.push({target:Be,type:w,handler:D}))},ev=w=>{if(Bb(()=>Be))return[.5,.5];let D=Be&&typeof Be.getBoundingClientRect=="function"?Be.getBoundingClientRect():{left:0,top:0,width:0,height:0},z=D.width||1,V=D.height||1;return[Mo((w.clientX-D.left)/z),Mo((w.clientY-D.top)/V)]},tv=w=>{if(!Rd)return;let D=w[0]*2-1,z=1-w[1]*2;return Rd(D,z)},_n=w=>{let D=ev(w),z=tv(D),V=z?Re(z.point,"right"):void 0,G=z?.name?z.name:void 0,L=Rg(w);return{screen:D,...V?{hitPoint:V}:{},...G?{hitMesh:G}:{},...L?{source:L}:{},...z?{hit:z}:{}}},ut,Fd=0,xn=!1,kr,Jd=w=>{if(ut!==void 0&&!xn){let D=w-Fd;D>=st&&be({channel:"hover",mesh:ut,dwellMs:D,...kr?{source:kr}:{}})}ut=void 0,xn=!1,kr=void 0},nv=(w,D,z)=>{let V=D!==void 0&&(!hn||hn.has(D))?D:void 0;V!==ut&&(Jd(w),V!==void 0&&(ut=V,Fd=w,xn=!1,kr=z))},rv=w=>{let D=w;if(h.hoverDwell){let J=_n(D);if(nv(K.now(),J.hitMesh,J.source),h.pointerMove){let te=K.now();te-_r>=Ad&&(_r=te,K.emit({type:"pointer_move",screen:J.screen,...J.hitPoint?{hitPoint:J.hitPoint}:{},...J.hitMesh?{hitMesh:J.hitMesh}:{},...J.source?{source:J.source}:{}}))}return}if(!h.pointerMove)return;let z=K.now();if(z-_r<Ad)return;_r=z;let{screen:V,hitPoint:G,hitMesh:L,source:F}=_n(D);K.emit({type:"pointer_move",screen:V,...G?{hitPoint:G}:{},...L?{hitMesh:L}:{},...F?{source:F}:{}})},Gd=(w,D)=>{let z=D;if(w==="pointer_down"&&h.hoverDwell){let{hitMesh:J}=_n(z);J!==void 0&&J===ut&&(xn=!0)}if(!h.buttons)return;let{screen:V,hitPoint:G,hitMesh:L,source:F}=_n(z);K.emit({type:w,screen:V,...G?{hitPoint:G}:{},...L?{hitMesh:L}:{},...typeof z.button=="number"?{button:z.button}:{},...F?{source:F}:{}})},iv=w=>{let D=w,{screen:z,hitPoint:V,hitMesh:G,source:L,hit:F}=_n(D);h.hoverDwell&&G!==void 0&&G===ut&&(xn=!0),h.clicks&&K.emit({type:"pointer_click",screen:z,...V?{hitPoint:V}:{},...G?{hitMesh:G}:{},...typeof D.button=="number"?{button:D.button}:{},...L?{source:L}:{}}),h.meshPicks&&F&&K.emit({type:"mesh_interaction",mesh:F.name,kind:"pick",...V?{point:V}:{},...L?{source:L}:{}})};if((h.pointerMove||h.hoverDwell)&&We("pointermove",rv),(h.buttons||h.hoverDwell)&&We("pointerdown",w=>Gd("pointer_down",w)),h.buttons&&We("pointerup",w=>Gd("pointer_up",w)),(h.clicks||h.meshPicks||h.hoverDwell)&&We("click",iv),h.cameraGesture){let w=z=>{Wo={sample:Vd(),ts:K.now(),source:Rg(z)}},D=()=>{let z=Wo;Wo=null,z&&be({channel:"gesture",start:z.sample,end:Vd(),durationMs:Math.max(0,Math.round(K.now()-z.ts)),options:{sensitivity:l},...z.source?{source:z.source}:{}})};We("pointerdown",w),We("pointerup",D)}h.hoverDwell&&bn.push(()=>Jd(K.now())),h.contextLoss&&(We("webglcontextlost",()=>K.emit({type:"context_lost"})),We("webglcontextrestored",()=>K.emit({type:"context_restored"})));let lt=ye.assets;if(h.assetLoad&&lt){let w=new Map,D=L=>L.id??L,z=L=>{w.set(D(L),K.now())},V=L=>{let F=L,J=D(F),te=w.get(J);if(te===void 0)return;w.delete(J);let _e={type:"asset_load",name:(F.name??"asset").slice(0,Wb),loadMs:Math.max(0,Math.round(K.now()-te))},Ce=F.file?.size;typeof Ce=="number"&&Ce>0&&(_e.bytes=Ce),K.emit(_e)},G=(...L)=>{let F=L[1];F&&w.delete(D(F))};lt.on("load:start",z),lt.on("load",V),lt.on("error",G),bn.push(()=>{lt.off("load:start",z),lt.off("load",V),lt.off("error",G),w.clear()})}if(h.resourceSample){let w=()=>{let D={},z=ye.stats?.frame?.triangles;typeof z=="number"&&z>0&&(D.triangles=Math.round(z));let V=globalThis.performance?.memory;V&&typeof V.usedJSHeapSize=="number"&&V.usedJSHeapSize>0&&(D.jsHeapBytes=V.usedJSHeapSize),Object.keys(D).length!==0&&K.emit({type:"resource_sample",...D})};$n.push(setInterval(w,$r))}if(h.keyboard&&typeof window<"u"){let w=window,D=G=>L=>{let F=L,J=F.code;if(!J||G&&F.repeat)return;let te=x[J];te&&K.trackInput(te,{source:"keyboard",code:J,pressed:G})},z=D(!0),V=D(!1);w.addEventListener("keydown",z),w.addEventListener("keyup",V),yn.push({target:w,type:"keydown",handler:z}),yn.push({target:w,type:"keyup",handler:V})}return{stop(){for(let w of bn)w();bn.length=0,Cd=!0;for(let w of $n)clearInterval(w);$n.length=0,br&&(ye.off("frameend",Ld),br=!1),yr.length=0;for(let w of yn)w.target.removeEventListener(w.type,w.handler);yn.length=0}}}}}function Ro(e){return e.isWebGPU===!0}function Wg(e){let n=e.maxTextureSize;return typeof n=="number"?n:void 0}function Fo(e){let n=e;return n.isWebGPU?!1:n.isWebGL2!==!1}function Jo(e){let i=e.gl;if(!i)return{};let o=i,t={};try{let r=typeof o.getExtension=="function"?o.getExtension("WEBGL_debug_renderer_info"):null,a=r?r.UNMASKED_VENDOR_WEBGL:o.VENDOR,c=r?r.UNMASKED_RENDERER_WEBGL:o.RENDERER,s=o.getParameter(a),u=o.getParameter(c),l=o.getParameter(o.VERSION);typeof s=="string"&&s&&(t.vendor=s),typeof u=="string"&&u&&(t.renderer=u),typeof l=="string"&&l&&(t.version=l)}catch{}return t}function Dd(e){let n=e.graphicsDevice,i=Jo(n),o=typeof navigator<"u"?navigator:void 0,r={engine:Ro(n)?"webgpu":Fo(n)?"webgl2":"webgl"};i.vendor&&(r.vendor=i.vendor),i.renderer&&(r.renderer=i.renderer);let a=Wg(n);return typeof a=="number"&&(r.maxTextureSize=a),typeof o?.hardwareConcurrency=="number"&&(r.hardwareConcurrency=o.hardwareConcurrency),typeof o?.deviceMemory=="number"&&(r.deviceMemoryGb=o.deviceMemory),o?.userAgent&&(r.isMobile=/Mobi|Android|iPhone|iPad/i.test(o.userAgent)),r}function i_(e){if(e){if(/Direct3D11|D3D11/i.test(e))return"d3d11";if(/Direct3D12|D3D12/i.test(e))return"d3d12";if(/Metal/i.test(e))return"metal";if(/Vulkan/i.test(e))return"vulkan";if(/OpenGL ES/i.test(e))return"opengles";if(/OpenGL/i.test(e))return"opengl"}}function Od(e){let n=e.graphicsDevice,i=Ro(n),o=Jo(n),a={api:i?"webgpu":Fo(n)?"webgl2":"webgl",shadingLanguage:i?"wgsl":"glsl-es"},c=i?void 0:i_(o.renderer);return c&&(a.backend=c),o.version&&(a.apiVersion=o.version),a}import{version as jd}from"playcanvas";function Nd(){let e={name:"playcanvas",coordinateSystem:{handedness:"right",upAxis:"y",unitScale:1}};return typeof jd=="string"&&jd&&(e.version=jd),e}import{PROJECTION_ORTHOGRAPHIC as o_,PROJECTION_PERSPECTIVE as a_}from"playcanvas";function Kg(e){let i=e?.camera?.projection;return i===a_?"free":i===o_?"static":"other"}function Ud(e,n){let i={},o=n;o&&(i.cameraType=Kg(n),typeof o.name=="string"&&o.name&&(i.cameraName=o.name));let t=e.root;if(t&&typeof t.forEach=="function"){let r=0;t.forEach(a=>{let c=a,s=c.render?.meshInstances?.length??0,u=c.model?.meshInstances?.length??0;r+=s+u}),i.meshCount=r}return i}function c_(e,n,i){let o=new vr({projectId:i.projectId,endpoint:i.endpoint,flushIntervalMs:i.flushIntervalMs,transport:i.transport,disabled:i.disabled,debug:i.debug});o.use(Pd({app:e,camera:n,sampleCameraMs:i.sampleCameraMs,samplePerfMs:i.samplePerfMs,pointerMoveThrottleMs:i.pointerMoveThrottleMs,suppressIdleSamples:i.suppressIdleSamples,suppressIdlePerfSamples:i.suppressIdlePerfSamples,cameraEpsilon:i.cameraEpsilon,perfFpsThreshold:i.perfFpsThreshold,capture:i.capture,...i.gaze?{gaze:i.gaze}:{},...i.sampling?{sampling:i.sampling}:{},...i.actors?{actors:i.actors}:{},...i.keyBindings?{keyBindings:i.keyBindings}:{}}));let t={...Ud(e,n),...i.sceneDescription?{description:i.sceneDescription}:{},...i.cameraType?{cameraType:i.cameraType}:{}};return o.start({device:Dd(e),graphics:Od(e),connector:Nd(),scene:t,...i.user?{user:i.user}:{},...i.meta}),o}function s_(e,n){let i=[],o=e;for(;o&&o!==n;){let t=typeof o.name=="string"?o.name:"";if(!t)return;i.unshift(t),o=o.parent}return i.length>0?i.join("/"):void 0}function u_(e){let n=e.getPosition?.(),i=e.getRotation?.(),o=e.getWorldTransform?.()?.getScale?.();if(!(!n||!i||!o))return{position:Re([n.x,n.y,n.z],"right"),rotation:vn([i.x,i.y,i.z,i.w??1],"right"),scale:[o.x,o.y,o.z]}}var l_="uptimizr-";function De(e){return Math.round(e*1e4)/1e4}function d_(e){let n=2166136261;for(let i=0;i<e.length;i++)n^=e.charCodeAt(i),n=Math.imul(n,16777619);return(n>>>0).toString(16).padStart(8,"0")}function Xg(e){return Math.abs((e[3]-e[0])*(e[4]-e[1])*(e[5]-e[2]))}function Td(e){return e.render?.meshInstances??e.model?.meshInstances??[]}function f_(e){let i=Td(e);if(i.length===0)return;let o=1/0,t=1/0,r=1/0,a=-1/0,c=-1/0,s=-1/0,u=!1;for(let l of i){let d=l.aabb;if(!d||typeof d.getMin!="function"||typeof d.getMax!="function")continue;let f=d.getMin(),m=d.getMax();u=!0,f.x<o&&(o=f.x),f.y<t&&(t=f.y),f.z<r&&(r=f.z),m.x>a&&(a=m.x),m.y>c&&(c=m.y),m.z>s&&(s=m.z)}if(u)return[o,t,r,a,c,s]}function m_(e){let n=e,i=0;for(let o of Td(n)){let t=o.mesh?.primitive;if(t)for(let r of t)typeof r.count=="number"&&r.count>0&&(i+=Math.floor(r.count/3))}return i}function p_(e,n){let i=n.boundsOf??f_,o=n.trianglesOf??m_,t=[],r=1/0,a=1/0,c=1/0,s=-1/0,u=-1/0,l=-1/0,d=0,f=e.root;f&&typeof f.forEach=="function"&&f.forEach(I=>{let h=I;if(h.enabled===!1||Td(h).length===0)return;let P=typeof h.name=="string"?h.name:"";if(P.startsWith(l_)||n.includeMesh&&!n.includeMesh(P))return;let A=i(h);if(!A)return;let U=Id(A,"right");d++;let j=[De(U[0]),De(U[1]),De(U[2]),De(U[3]),De(U[4]),De(U[5])],O={name:P,aabb:j},Y=o(h);Y>0&&(O.triangles=Y);let ce=s_(h,f),se=u_(h);ce&&se&&(O.path=ce,O.world=se),t.push(O),r=Math.min(r,U[0]),a=Math.min(a,U[1]),c=Math.min(c,U[2]),s=Math.max(s,U[3]),u=Math.max(u,U[4]),l=Math.max(l,U[5])});let m=t;typeof n.maxMeshes=="number"&&n.maxMeshes>=0&&t.length>n.maxMeshes&&(m=[...t].sort((I,h)=>Xg(h.aabb)-Xg(I.aabb)).slice(0,n.maxMeshes));let v=d===0?[0,0,0,0,0,0]:[De(r),De(a),De(c),De(s),De(u),De(l)],y=JSON.stringify({v:mr,kind:"aabb",bounds:v,meshes:[...m].sort((I,h)=>I.name<h.name?-1:I.name>h.name?1:0).map(I=>I.path&&I.world?[I.name,I.aabb,I.path,I.world.position,I.world.rotation,I.world.scale]:[I.name,I.aabb])}),x={version:mr,sceneId:n.sceneId,kind:"aabb",bounds:v,upAxis:n.upAxis??"y",handedness:"right",unitScale:n.unitScale??1,meshes:m,meshCount:d,contentHash:d_(y),capturedAt:(n.now??Date.now)(),sdkVersion:n.sdkVersion??gr};return bd.parse(x)}export{Mo as clamp01,Kg as classifyCamera,zd as createGazeRaycaster,Sd as createSceneRaycaster,Pd as playcanvasCollector,Nd as readConnector,Dd as readDeviceCaps,Od as readGraphics,Ud as readSceneMeta,p_ as scanSceneProxy,Lo as toVec3,c_ as trackScene};