cueframe 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -105
- package/README.md +1 -1
- package/dist/analyze-Y2CE6BNM.js +2 -0
- package/dist/{chunk-EGBS3VAH.js → chunk-HFZRI4NX.js} +1 -1
- package/dist/cueframe.js +3 -3
- package/package.json +5 -5
- package/dist/analyze-4KYPG6F7.js +0 -2
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ ${c}`:c:"",l=Function,p=`return (input) => {
|
|
|
61
61
|
${c}
|
|
62
62
|
}`,d;try{d=new l(...a,p)(...s)}catch(g){throw new O(`this schema (generated code failed to evaluate: ${g.message})`)}return r?.debug&&(d.code=u),d}function w(e,r){for(let[i,t]of e.constants)if(t===r)return i;let o=`c${e.constantCounter++}`;return e.constants.set(o,r),o}function R(e){return`v${e.varCounter++}`}function Px(e,r){let o=e._zod.run({value:r,issues:[]},{});if(o&&typeof o.then=="function")return se;let i=o;return i.issues.length===0?i.value:se}function Y(e,r,o,i,t=!0){let n=e.content.length,a=r.constants.size,s=r.constantCounter,c=r.varCounter;try{return F(e,r,o,i,t)}catch(u){if(!(u instanceof O)||!u.islandable)throw u;if(e.content.length=n,r.constants.size>a){let l=Array.from(r.constants.keys()).slice(a);for(let p of l)r.constants.delete(p)}return r.constantCounter=s,r.varCounter=c,zx(e,r,o,i)}}function zx(e,r,o,i){let t=w(r,o),n=w(r,Px),a=R(r);return e.write(`const ${a} = ${n}(${t}, ${i});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var Cx=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function jx(e,r,o,i){let t=o._zod.def.checks;if(!t||t.length===0)return i;let n=i;for(let a of t){let s=a._zod.def;if(s.when&&!Cx.has(s.check))throw new O('check with a custom "when" condition');switch(s.check){case"greater_than":Ox(e,r,s,n);break;case"less_than":Tx(e,r,s,n);break;case"multiple_of":Ex(e,r,s,n);break;case"number_format":$f(e,s,n);break;case"min_length":{let c=Fe(s.minimum,"min_length"),u=Is(e,r,n,`${n}.length >= ${c} && ${n}.length < ${s.minimum*2}`);e.write(`if (${u} < ${c}) return INVALID;`);break}case"max_length":{let c=Fe(s.maximum,"max_length"),u=Is(e,r,n,`${n}.length > ${c}`);e.write(`if (${u} > ${c}) return INVALID;`);break}case"length_equals":{let c=Fe(s.length,"length_equals"),u=Is(e,r,n,`${n}.length >= ${c} && ${n}.length <= ${s.length*2}`);e.write(`if (${u} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${n}.size < ${Fe(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${n}.size > ${Fe(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${n}.size !== ${Fe(s.size,"size_equals")}) return INVALID;`);break;case"string_format":n=bf(e,r,s,n);break;case"custom":n=qx(e,r,a,n);break;case"bigint_format":Ux(e,s,n);break;case"mime_type":Nx(e,r,s,n);break;case"property":Ax(e,r,s,n);break;case"overwrite":{let c=R(r);Dx(e,r,a,n,c),n=c;break}default:throw new O(`check type ${s.check}`)}}return n}function Is(e,r,o,i){let t=w(r,De),n=R(r);return e.write(`const ${n} = typeof ${o} === "string" && ${i} ? ${t}(${o}) : ${o}.length;`),n}function Fe(e,r){if(typeof e!="number"||!Number.isFinite(e))throw new O(`${r} bound of type ${typeof e}`);return`${e}`}function xf(e,r){if(typeof r=="bigint")return`${r}n`;if(typeof r=="number"){if(Number.isNaN(r))throw new O("comparison check with NaN bound");return`${r}`}if(r instanceof Date){if(Number.isNaN(r.getTime()))throw new O("comparison check with Invalid Date bound");return w(e,r)}throw new O(`comparison check bound of type ${typeof r}`)}function Ox(e,r,o,i){let t=o.inclusive?"<":"<=";e.write(`if (${i} ${t} ${xf(r,o.value)}) return INVALID;`)}function Tx(e,r,o,i){let t=o.inclusive?">":">=";e.write(`if (${i} ${t} ${xf(r,o.value)}) return INVALID;`)}function Ex(e,r,o,i){if(typeof o.value=="bigint"){if(o.value===BigInt(0))throw new O("multiple_of check with a zero divisor");e.write(`if (${i} % ${o.value}n !== 0n) return INVALID;`)}else{let t=w(r,Zt);e.write(`if (${t}(${i}, ${Fe(o.value,"multiple_of")}) !== 0) return INVALID;`)}}function $f(e,r,o){let i=r.format;switch(i){case"safeint":e.write(`if (!Number.isSafeInteger(${o})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${o}) || ${o} < -2147483648 || ${o} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${o}) || ${o} < 0 || ${o} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${o}) || ${o} < -3.4028234663852886e38 || ${o} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${o})) return INVALID;`);break;default:throw new O(`number format ${i}`)}}function Ux(e,r,o){let i=r.format;if(i)switch(i){case"int64":e.write(`if (${o} < -9223372036854775808n || ${o} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${o} < 0n || ${o} > 18446744073709551615n) return INVALID;`);break;default:throw new O(`bigint format ${i}`)}}function Nx(e,r,o,i){let t=o.mime;if(t&&t.length>0){let n=w(r,new Set(t));e.write(`if (!${n}.has(${i}.type)) return INVALID;`)}}function Ax(e,r,o,i){let t=`${i}[${JSON.stringify(o.property)}]`;F(e,r,o.schema,t)}function Dx(e,r,o,i,t){let n=o._zod.def.tx;if(!n)throw new O("overwrite check without a transform function");if(Ke(n))throw new ge("z.compile: async overwrite transforms are not supported");let a=w(r,n);e.write(`const ${t} = ${a}(${i});`)}function ws(){throw new ne}function zs(e){this.issues.push(e)}function qx(e,r,o,i){let t=o._zod.def;if(t.fn){if(Ke(t.fn))throw new ge("z.compile: async .refine() predicates are not supported");let n=w(r,t.fn),a=w(r,ws),s=R(r);return e.write(`const ${s} = ${n}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`),i}if(o._zod.check){if(Ke(o._zod.check))throw new ge("z.compile: async .superRefine() / check functions are not supported");let n=o._zod.check,s=w(r,u=>{let l={value:u,issues:[],addIssue:zs};return n(l)instanceof Promise&&ws(),l.issues.length===0?l.value:se}),c=R(r);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new O("custom check without a predicate or check function")}var Lx=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 bf(e,r,o,i){let t=o.format;if(t==="base64"){let c=w(r,Qt);return e.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="base64url"){let c=w(r,un);return e.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="jwt"){let c=w(r,pn),u=w(r,o.alg??null);return e.write(`if (!${c}(${i}, ${u})) return INVALID;`),i}if(t==="ipv6"){let c=w(r,Yt);return e.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="cidrv6"){let c=w(r,cn);return e.write(`if (!${c}(${i})) return INVALID;`),i}if(t==="credit_card"){let c=w(r,ln);return e.write(`if (!${c}(${i})) return INVALID;`),i}let n=o;if(t==="url"||t==="httpurl"||n.normalize||n.hostname!==void 0||n.protocol!==void 0){let c=w(r,nn),u=w(r,o),l=R(r),p=R(r);if(e.write(`const ${l} = ${i}.trim();`),e.write(`const ${p} = ${c}(${l}, ${u});`),e.write(`if (typeof ${p} === "number") return INVALID;`),n.hostname!==void 0){let y=w(r,an);e.write(`if (!${y}(${p}, ${u}.hostname)) return INVALID;`)}if(n.protocol!==void 0){let y=w(r,sn);e.write(`if (!${y}(${p}, ${u}.protocol)) return INVALID;`)}let d=R(r),g=n.normalize?`${p}.href`:`${w(r,on)}(${l})`;return e.write(`const ${d} = ${g};`),d}let a=o.fn;if(a){if(Ke(a))throw new O(`async string format ${t}`);let c=w(r,a);return e.write(`if (!${c}(${i})) return INVALID;`),i}if(Lx.has(t)&&o.pattern){let c=w(r,o.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${i})) return INVALID;`),i}let s=o.format;switch(s){case"regex":throw new O("regex format without a pattern");case"lowercase":e.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${i}.includes(${ee(o.includes)})) return INVALID;`);break;case"starts_with":{let c=o.prefix;e.write(`if (${i}.slice(0, ${c.length}) !== ${ee(c)}) return INVALID;`);break}case"ends_with":{let c=o.suffix;e.write(`if (${i}.slice(-${c.length}) !== ${ee(c)}) return INVALID;`);break}default:throw new O(`string format ${s}`)}return i}function F(e,r,o,i,t=!0){let n=o._zod.def,a=n.type;if(n.coerce)throw new O(`coercion (z.coerce.${a}())`);let s=t||!!n.checks?.length,c;switch(a){case"string":c=Zx(e,r,o,i);break;case"number":c=Fx(e,o,i);break;case"boolean":c=Mx(e,i);break;case"bigint":c=Vx(e,o,i);break;case"symbol":c=Kx(e,i);break;case"undefined":c=Bx(e,i);break;case"null":c=Jx(e,i);break;case"any":case"unknown":c=i;break;case"never":e.write("return INVALID;"),c=i;break;case"void":c=Gx(e,i);break;case"nan":c=Wx(e,i);break;case"date":c=Hx(e,i);break;case"object":c=Xx(e,r,o,i,s);break;case"optional":c=Yx(e,r,o,i,s);break;case"nullable":c=t$(e,r,o,i,s);break;case"array":c=r$(e,r,o,i,s);break;case"literal":c=n$(e,r,o,i);break;case"enum":c=o$(e,r,o,i);break;case"readonly":{let u=vf(e,r,o,i),l=R(r);e.write(`const ${l} = Object.freeze(${u});`),c=l;break}case"success":vf(e,r,o,i),c="true";break;case"default":case"prefault":c=i$(e,r,o,i);break;case"nonoptional":c=a$(e,r,o,i);break;case"tuple":c=s$(e,r,o,i);break;case"union":c=c$(e,r,o,i);break;case"intersection":c=p$(e,r,o,i);break;case"record":c=d$(e,r,o,i);break;case"map":c=m$(e,r,o,i);break;case"set":c=g$(e,r,o,i);break;case"file":c=y$(e,i);break;case"template_literal":c=v$(e,r,o,i);break;case"lazy":c=h$(e,r,o,i);break;case"pipe":c=x$(e,r,o,i);break;case"custom":c=$$(e,r,o,i);break;case"transform":c=k$(e,r,o,i);break;case"catch":c=_$(e,r,o,i);break;default:throw new O(`schema type ${a}`)}return c===null?null:jx(e,r,o,c)}function Zx(e,r,o,i){e.write(`if (typeof ${i} !== "string") return INVALID;`);let t=o._zod.def;return t.format===void 0?i:bf(e,r,t,i)}function Fx(e,r,o){e.write(`if (typeof ${o} !== "number" || !Number.isFinite(${o})) return INVALID;`);let i=r._zod.def;return i.check==="number_format"&&i.format&&$f(e,{format:i.format},o),o}function Mx(e,r){return e.write(`if (typeof ${r} !== "boolean") return INVALID;`),r}function Vx(e,r,o){e.write(`if (typeof ${o} !== "bigint") return INVALID;`);let i=r._zod.def;if(i.format)switch(i.format){case"int64":e.write(`if (${o} < -9223372036854775808n || ${o} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${o} < 0n || ${o} > 18446744073709551615n) return INVALID;`);break}return o}function Kx(e,r){return e.write(`if (typeof ${r} !== "symbol") return INVALID;`),r}function Bx(e,r){return e.write(`if (${r} !== undefined) return INVALID;`),r}function Jx(e,r){return e.write(`if (${r} !== null) return INVALID;`),r}function Gx(e,r){return e.write(`if (${r} !== undefined) return INVALID;`),r}function Wx(e,r){return e.write(`if (typeof ${r} !== "number" || !Number.isNaN(${r})) return INVALID;`),r}function Hx(e,r){return e.write(`if (!(${r} instanceof Date) || Number.isNaN(${r}.getTime())) return INVALID;`),r}function Xx(e,r,o,i,t=!0){let n=o._zod.def;e.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let a=n.shape,s=Object.keys(a),c=Object.getOwnPropertySymbols(a),u=c.length?[...s,...c]:s,l=I=>typeof I=="symbol"?w(r,I):ee(I),p=I=>typeof I=="symbol"?`[${l(I)}]`:ee(I),d=a;if(s.includes("__proto__"))throw new O('object shape key "__proto__"');let g=new Map;for(let I of u){let z=d[I],L=l(I),Z=R(r);if(e.write(`const ${Z} = ${i}[${L}];`),z._zod.optin!==void 0){let T=R(r);e.write(`let ${T} = (() => {`),e.indented(W=>{let Nt=Y(W,r,z,Z);W.write(`return ${Nt};`)}),e.write("})();"),z._zod.optout==="optional"?(e.write(`if (${T} === INVALID) {`),e.indented(W=>{W.write(`if (${L} in ${i}) return INVALID;`),W.write(`${T} = undefined;`)}),e.write("}")):e.write(`if (${T} === INVALID) return INVALID;`),g.set(I,T)}else{e$(z)&&e.write(`if (!(${L} in ${i})) return INVALID;`);let T=Y(e,r,z,Z,t);T!==null&&g.set(I,T)}}let y=n.catchall,_="none";if(y){let I=y._zod.def.type;if(I==="never"){let z=s.map(L=>`k !== ${ee(L)}`).join(" && ")||"true";e.write(`for (const k in ${i}) {`),e.indented(L=>{L.write(`if (${z}) return INVALID;`)}),e.write("}")}else(I==="unknown"||I==="any")&&!y._zod.def.checks?.length?_="passthrough":_="schema"}let S=R(r),N=u.some(I=>Ve(d[I])||Rs(d[I]));if(!t){if(_==="schema"){let I=s.length>0?w(r,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(z=>{z.write('if (k === "__proto__") continue;'),I&&z.write(`if (${I}.has(k)) continue;`);let L=R(r);z.write(`const ${L} = ${i}[k];`),Y(z,r,y,L,!1)}),e.write("}")}return null}if(N){e.write(`const ${S} = {};`);for(let I of u){let z=l(I),L=g.get(I);Rs(d[I])?e.write(`if (${z} in ${i}) ${S}[${z}] = ${L};`):Ve(d[I])?e.write(`if (${L} !== undefined || ${z} in ${i}) ${S}[${z}] = ${L};`):e.write(`${S}[${z}] = ${L};`)}}else{let I=u.map(z=>`${p(z)}: ${g.get(z)}`).join(", ");e.write(`const ${S} = { ${I} };`)}if(_!=="none"){let I=s.length>0?w(r,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(z=>{if(z.write('if (k === "__proto__") continue;'),I&&z.write(`if (${I}.has(k)) continue;`),_==="passthrough")z.write(`${S}[k] = ${i}[k];`);else{let L=R(r);z.write(`const ${L} = ${i}[k];`);let Z=Y(z,r,y,L);z.write(`${S}[k] = ${Z};`)}}),e.write("}")}return S}function Yx(e,r,o,i,t=!0){let n=o._zod.def;if(Qx(o))return F(e,r,n.innerType,i,t);if(n.innerType._zod.optin==="defaulted"){let s=R(r),c=R(r);return e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(u=>{u.write(`const ${c} = (() => {`),u.indented(l=>{let p=F(l,r,n.innerType,i);l.write(`return ${p};`)}),u.write("})();"),u.write(`if (${c} !== INVALID) ${s} = ${c};`)}),e.write("} else {"),e.indented(u=>{let l=F(u,r,n.innerType,i);u.write(`${s} = ${l};`)}),e.write("}"),s}let a=t?R(r):null;return a&&e.write(`let ${a};`),e.write(`if (${i} !== undefined) {`),e.indented(s=>{let c=F(s,r,n.innerType,i,t);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function Qx(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function e$(e){return e._zod.optin===void 0&&Me(e)}function Me(e){if(e._zod.def.coerce)return!0;let r=e._zod.def;switch(r.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 r.innerType?Me(r.innerType):!1;case"literal":return!!r.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return r.innerType?Me(r.innerType):!0;case"catch":return!0;case"union":return r.options?r.options.some(Me):!0;case"intersection":return!r.left||!r.right?!0:Me(r.left)&&Me(r.right);case"pipe":return r.in?Me(r.in):!0;default:return!0}}function Rs(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Ve(e){let r=e._zod.def;switch(r.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!!r.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return r.innerType?Ve(r.innerType):!0;case"union":return r.options?r.options.some(Ve):!0;case"intersection":return!r.left||!r.right||Ve(r.left)||Ve(r.right);case"pipe":return r.out?Ve(r.out):!0;default:return!0}}function t$(e,r,o,i,t=!0){let n=o._zod.def,a=t?R(r):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${i} !== null) {`),e.indented(s=>{let c=F(s,r,n.innerType,i,t);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function r$(e,r,o,i,t=!0){let n=o._zod.def;e.write(`if (!Array.isArray(${i})) return INVALID;`);let a=t?R(r):null,s=R(r),c=R(r);return a&&e.write(`const ${a} = new Array(${i}.length);`),e.write(`for (let ${s} = 0; ${s} < ${i}.length; ${s}++) {`),e.indented(u=>{u.write(`const ${c} = ${i}[${s}];`);let l=Y(u,r,n.element,c,t);a&&l!==null&&u.write(`${a}[${s}] = ${l};`)}),e.write("}"),a}function n$(e,r,o,i){let n=o._zod.def.values;if(n.length!==1){let s=w(r,new Set(n));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}let a=n[0];if(typeof a=="number"&&Number.isNaN(a)){let s=w(r,new Set(n));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}if(typeof a=="string")e.write(`if (${i} !== ${ee(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${i} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${i} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${i} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${i} !== ${a}n) return INVALID;`);else throw new O(`literal type ${typeof a}`);return i}function o$(e,r,o,i){let t=o._zod.values;if(!t)throw new O("enum schema without enumerated values");let n=w(r,t);return e.write(`if (!${n}.has(${i})) return INVALID;`),i}function vf(e,r,o,i){let t=o._zod.def;return F(e,r,t.innerType,i)}function i$(e,r,o,i){let t=o._zod.def,a=Object.getOwnPropertyDescriptor(o._zod.def,"defaultValue")?()=>o._zod.def.defaultValue:void 0;if(o._zod.def.type==="prefault"){if(!a)return F(e,r,t.innerType,i);let c=w(r,a),u=R(r);return e.write(`let ${u} = ${i};`),e.write(`if (${i} === undefined) ${u} = ${c}();`),F(e,r,t.innerType,u)}let s=R(r);if(a){let c=w(r,a),u=w(r,Ft);e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(l=>{l.write(`${s} = ${u}(${c}());`)}),e.write("} else {"),e.indented(l=>{let p=F(l,r,t.innerType,i);l.write(`${s} = ${p} === undefined ? ${u}(${c}()) : ${p};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${i} !== undefined) {`),e.indented(c=>{let u=F(c,r,t.innerType,i);c.write(`${s} = ${u};`)}),e.write("}");return s}function a$(e,r,o,i){let t=o._zod.def,n=F(e,r,t.innerType,i),a=R(r);return e.write(`const ${a} = ${n};`),e.write(`if (${a} === undefined) return INVALID;`),a}function s$(e,r,o,i){let t=o._zod.def,n=t.items,a=t.rest;e.write(`if (!Array.isArray(${i})) return INVALID;`);let s=hf(n,"optin"),c=hf(n,"optout");a?e.write(`if (${i}.length < ${s}) return INVALID;`):e.write(`if (${i}.length < ${s} || ${i}.length > ${n.length}) return INVALID;`);let u=R(r);e.write(`const ${u} = [];`);for(let l=0;l<n.length;l++){let p=n[l];if(l>=c)e.write(`if (${u}.length === ${l}) {`),e.indented(d=>{d.write(`if (${l} < ${i}.length) {`),d.indented(g=>{let y=R(r);g.write(`const ${y} = ${i}[${l}];`);let _=Y(g,r,p,y);g.write(`${u}[${l}] = ${_};`)}),d.write("} else {"),d.indented(g=>{if(Rs(p)){g.write(`${u}.length = ${l};`);return}let y=R(r),_=R(r);g.write(`const ${y} = undefined;`),g.write(`const ${_} = (() => {`),g.indented(S=>{let N=Y(S,r,p,y);S.write(`return ${N};`)}),g.write("})();"),g.write(`if (${_} === INVALID || ${_} === undefined) ${u}.length = ${l};`),g.write(`else ${u}[${l}] = ${_};`)}),d.write("}")}),e.write("}");else{let d=R(r);e.write(`const ${d} = ${i}[${l}];`);let g=Y(e,r,p,d);e.write(`${u}[${l}] = ${g};`)}}if(a){let l=R(r),p=R(r);e.write(`for (let ${l} = ${n.length}; ${l} < ${i}.length; ${l}++) {`),e.indented(d=>{d.write(`const ${p} = ${i}[${l}];`);let g=Y(d,r,a,p);d.write(`${u}[${l}] = ${g};`)}),e.write("}")}return u}function hf(e,r){for(let o=e.length-1;o>=0;o--)if(!(r==="optin"?e[o]._zod.optin!==void 0:e[o]._zod.optout==="optional"))return o+1;return 0}function c$(e,r,o,i){let t=o._zod.def,n=t.options;if(t.discriminator)return u$(e,r,t,i);if(t.inclusive===!1)throw new O("exclusive unions (z.xor)");if(n.length===0)return e.write("return INVALID;"),i;if(n.length===1)return F(e,r,n[0],i);if(n.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(n.flatMap(l=>l._zod.def.values)),u=w(r,c);return e.write(`if (!${u}.has(${i})) return INVALID;`),i}let s=R(r);e.write(`let ${s};`);for(let c=0;c<n.length;c++){let u=n[c];c===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(l=>{let p=F(l,r,u,i);l.write(`return ${p};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function u$(e,r,o,i){if(o.unionFallback)throw new O("discriminated union with unionFallback");if(o.options.length===0)return e.write("return INVALID;"),i;let t=R(r),n=R(r);e.write(`const ${t} = ${i}?.[${ee(o.discriminator)}];`),e.write(`let ${n};`);let a=!0,s=new Set;for(let c of o.options){let u=c._zod.propValues?.[o.discriminator];if(!u||u.size===0)throw new O("discriminated union option without static discriminator values");for(let d of u){if(s.has(d))throw new O(`duplicate discriminator value ${String(d)}`);s.add(d)}let l=Array.from(u,d=>l$(r,t,d)),p=a?"if":"else if";e.write(`${p} (${l.join(" || ")}) {`),e.indented(d=>{let g=F(d,r,c,i);d.write(`${n} = ${g};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),n}function l$(e,r,o){if(typeof o=="string")return`${r} === ${ee(o)}`;if(typeof o=="number")return Number.isNaN(o)?`Number.isNaN(${r})`:`${r} === ${o}`;if(typeof o=="boolean")return`${r} === ${o}`;if(o===null)return`${r} === null`;if(o===void 0)return`${r} === undefined`;if(typeof o=="bigint")return`${r} === ${o}n`;if(typeof o=="symbol"){let i=w(e,o);return`${r} === ${i}`}throw new O(`literal discriminator value ${String(o)}`)}function p$(e,r,o,i){let t=o._zod.def,n=Y(e,r,t.left,i),a=Y(e,r,t.right,i),s=w(r,ut),c=R(r);return e.write(`const ${c} = ${s}(${n}, ${a});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function d$(e,r,o,i){let t=o._zod.def,n=w(r,pe);e.write(`if (!${n}(${i})) return INVALID;`);let a=R(r),s=R(r),c=R(r);e.write(`const ${a} = {};`);let u=t,l=u.partial?void 0:t.keyType._zod.values;if(l){let y=[];for(let S of l){if(!(typeof S=="string"||typeof S=="number"||typeof S=="symbol"))throw new O(`record key value ${String(S)}`);let N=typeof S=="number"?S.toString():S;if(N==="__proto__")throw new O('record key "__proto__"');y.push(N);let I=w(r,S),z=F(e,r,t.keyType,I),L=R(r);e.write(`const ${L} = ${i}[${f$(r,N)}];`);let Z=Y(e,r,t.valueType,L);e.write(`${a}[${z}] = ${Z};`)}let _=w(r,new Set(y));return e.write(`for (const ${s} in ${i}) {`),e.indented(S=>{S.write(`if (${_}.has(${s})) continue;`),u.mode==="loose"?S.write(`if (${s} !== "__proto__") ${a}[${s}] = ${i}[${s}];`):S.write("return INVALID;")}),e.write("}"),a}let p=t.keyType._zod.def;if(!(p.type==="string"&&p.format===void 0&&!p.coerce&&(p.checks?.length??0)===0)){let y=t.mode==="loose",_=w(r,wn(t.keyType)),S=w(r,Re),N=w(r,Object.prototype.propertyIsEnumerable),I=R(r);return e.write(`for (const ${s} of Reflect.ownKeys(${i})) {`),e.indented(z=>{z.write(`if (${s} === "__proto__") continue;`),z.write(`if (!${N}.call(${i}, ${s})) continue;`),z.write(`let ${I} = ${_}(${s});`),z.write(`if (${I} === INVALID && typeof ${s} === "string" && ${S}.test(${s})) ${I} = ${_}(Number(${s}));`),y?z.write(`if (${I} === INVALID) { ${a}[${s}] = ${i}[${s}]; continue; }`):z.write(`if (${I} === INVALID) return INVALID;`),z.write(`if (${I} === "__proto__") continue;`);let L=R(r);z.write(`const ${L} = ${i}[${s}];`);let Z=Y(z,r,t.valueType,L);z.write(`${a}[${I}] = ${Z};`)}),e.write("}"),a}let g=w(r,Object.prototype.propertyIsEnumerable);return e.write(`for (const ${s} of Reflect.ownKeys(${i})) {`),e.indented(y=>{y.write(`if (${s} === "__proto__") continue;`),y.write(`if (!${g}.call(${i}, ${s})) continue;`),y.write(`if (typeof ${s} !== "string") return INVALID;`),y.write(`const ${c} = ${i}[${s}];`);let _=Y(y,r,t.valueType,c);y.write(`${a}[${s}] = ${_};`)}),e.write("}"),a}function f$(e,r){return typeof r=="string"?ee(r):w(e,r)}function m$(e,r,o,i){let t=o._zod.def;e.write(`if (!(${i} instanceof Map)) return INVALID;`);let n=R(r),a=R(r),s=R(r);return e.write(`const ${n} = new Map();`),e.write(`for (const [${a}, ${s}] of ${i}) {`),e.indented(c=>{let u=F(c,r,t.keyType,a),l=F(c,r,t.valueType,s);c.write(`${n}.set(${u}, ${l});`)}),e.write("}"),n}function g$(e,r,o,i){let t=o._zod.def;e.write(`if (!(${i} instanceof Set)) return INVALID;`);let n=R(r),a=R(r);return e.write(`const ${n} = new Set();`),e.write(`for (const ${a} of ${i}) {`),e.indented(s=>{let c=F(s,r,t.valueType,a);s.write(`${n}.add(${c});`)}),e.write("}"),n}function y$(e,r){return e.write(`if (!(${r} instanceof File)) return INVALID;`),r}function v$(e,r,o,i){e.write(`if (typeof ${i} !== "string") return INVALID;`);let t=o._zod.pattern;if(t){let n=w(r,t);e.write(`${n}.lastIndex = 0;`),e.write(`if (!${n}.test(${i})) return INVALID;`)}return i}function h$(e,r,o,i){let t=o._zod.def,n=w(r,t.getter),a=w(r,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(c=>{c.write(`const inner = ${n}();`),c.write(`${a}.parser = function(input) {`),c.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let s=R(r);return e.write(`const ${s} = ${a}.parser(${i});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function x$(e,r,o,i){let t=o._zod.def,n=F(e,r,t.in,i);if(t.transform){if(Ke(t.transform))throw new ge("z.compile: async transforms in pipes are not supported");let a=t.transform,c=w(r,l=>{let p={value:l,issues:[],addIssue:zs},d=a(l,p);return d instanceof Promise?se:p.issues.length===0?d:se}),u=R(r);return e.write(`const ${u} = ${c}(${n});`),e.write(`if (${u} === INVALID) return INVALID;`),F(e,r,t.out,u)}else return F(e,r,t.out,n)}function Ke(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function $$(e,r,o,i){let t=o._zod.def;if(t.fn){if(Ke(t.fn))throw new ge("z.compile: async custom predicates are not supported");let n=w(r,t.fn),a=w(r,ws),s=R(r);e.write(`const ${s} = ${n}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`)}else throw new O("custom schema without a predicate function");return i}function b$(e,r,o){let i=e._zod.run({value:o,issues:[]},{});if(i&&typeof i.then=="function")return se;let t=i;return t.issues.length===0?t.value:r()}function _$(e,r,o,i){let t=o._zod.def;if(!t.catchValue[Er])throw new O("catch with a callback (only a constant catch value compiles)",!1);let n=R(r);e.write(`let ${n} = (() => {`),e.indented(u=>{let l=Y(u,r,t.innerType,i);u.write(`return ${l};`)}),e.write("})();");let a=w(r,t.innerType),s=w(r,t.catchValue),c=w(r,b$);return e.write(`if (${n} === INVALID) {`),e.indented(u=>{u.write(`${n} = ${c}(${a}, ${s}, ${i});`),u.write(`if (${n} === INVALID) return INVALID;`)}),e.write("}"),n}function k$(e,r,o,i){let t=o._zod.def;if(t.transform){if(Ke(t.transform))throw new ge("z.compile: async transforms are not supported");let n=t.transform,s=w(r,u=>{let l={value:u,issues:[],addIssue:zs},p=n(u,l);return p instanceof Promise?se:l.issues.length===0?p:se}),c=R(r);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return i}function Cs(e,r){return new e({type:"string",...$(r)})}function js(e,r){return new e({type:"string",coerce:!0,...$(r)})}function Rn(e,r){return new e({type:"string",format:"email",check:"string_format",abort:!1,...$(r)})}function Pn(e,r){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...$(r)})}function zn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...$(r)})}function Cn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...$(r)})}function jn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...$(r)})}function On(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...$(r)})}function sr(e,r){return new e({type:"string",format:"url",check:"string_format",abort:!1,...$(r)})}function Tn(e,r){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...$(r)})}function En(e,r){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...$(r)})}function Un(e,r){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...$(r)})}function Nn(e,r){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...$(r)})}function An(e,r){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...$(r)})}function Dn(e,r){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...$(r)})}function qn(e,r){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...$(r)})}function Ln(e,r){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...$(r)})}function Zn(e,r){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...$(r)})}function Os(e,r){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...$(r)})}function Fn(e,r){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...$(r)})}function Mn(e,r){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...$(r)})}function Vn(e,r){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...$(r)})}function Kn(e,r){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...$(r)})}function Bn(e,r){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...$(r)})}function Ts(e,r){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...$(r)})}function Jn(e,r){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...$(r)})}var Es={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function cr(e,r){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...$(r)})}function ur(e,r){return new e({type:"string",format:"date",check:"string_format",...$(r)})}function lr(e,r){return new e({type:"string",format:"time",check:"string_format",precision:null,...$(r)})}function pr(e,r){return new e({type:"string",format:"duration",check:"string_format",...$(r)})}function Us(e,r){return new e({type:"number",checks:[],...$(r)})}function Ns(e,r){return new e({type:"number",coerce:!0,checks:[],...$(r)})}function As(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...$(r)})}function Ds(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...$(r)})}function qs(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...$(r)})}function Ls(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...$(r)})}function Zs(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...$(r)})}function Fs(e,r){return new e({type:"boolean",...$(r)})}function Ms(e,r){return new e({type:"boolean",coerce:!0,...$(r)})}function Vs(e,r){return new e({type:"bigint",...$(r)})}function Ks(e,r){return new e({type:"bigint",coerce:!0,...$(r)})}function Bs(e,r){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...$(r)})}function Js(e,r){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...$(r)})}function Gs(e,r){return new e({type:"symbol",...$(r)})}function Ws(e,r){return new e({type:"undefined",...$(r)})}function Hs(e,r){return new e({type:"null",...$(r)})}function Xs(e){return new e({type:"any"})}function Ys(e){return new e({type:"unknown"})}function Qs(e,r){return new e({type:"never",...$(r)})}function ec(e,r){return new e({type:"void",...$(r)})}function tc(e,r){return new e({type:"date",...$(r)})}function rc(e,r){return new e({type:"date",coerce:!0,...$(r)})}function nc(e,r){return new e({type:"nan",...$(r)})}function he(e,r){return new Wr({check:"less_than",...$(r),value:e,inclusive:!1})}function ce(e,r){return new Wr({check:"less_than",...$(r),value:e,inclusive:!0})}function xe(e,r){return new Hr({check:"greater_than",...$(r),value:e,inclusive:!1})}function ue(e,r){return new Hr({check:"greater_than",...$(r),value:e,inclusive:!0})}function Gn(e){return xe(0,e)}function Wn(e){return he(0,e)}function Hn(e){return ce(0,e)}function Xn(e){return ue(0,e)}function Pe(e,r){return new Mi({check:"multiple_of",...$(r),value:e})}function ze(e,r){return new Bi({check:"max_size",...$(r),maximum:e})}function $e(e,r){return new Ji({check:"min_size",...$(r),minimum:e})}function Be(e,r){return new Gi({check:"size_equals",...$(r),size:e})}function Je(e,r){return new Wi({check:"max_length",...$(r),maximum:e})}function _e(e,r){return new Hi({check:"min_length",...$(r),minimum:e})}function Ge(e,r){return new Xi({check:"length_equals",...$(r),length:e})}function pt(e,r){return new Yi({check:"string_format",format:"regex",...$(r),pattern:e})}function dt(e){return new Qi({check:"string_format",format:"lowercase",...$(e)})}function ft(e){return new ea({check:"string_format",format:"uppercase",...$(e)})}function mt(e,r){return new ta({check:"string_format",format:"includes",...$(r),includes:e})}function gt(e,r){return new ra({check:"string_format",format:"starts_with",...$(r),prefix:e})}function yt(e,r){return new na({check:"string_format",format:"ends_with",...$(r),suffix:e})}function Yn(e,r,o){return new Xr({check:"property",property:e,schema:r,...$(o)})}function Qn(e){return Object.entries(e).map(([r,o])=>new Xr({check:"property",property:r,schema:o}))}function vt(e,r){return new oa({check:"mime_type",mime:e,...$(r)})}function ye(e){return new ia({check:"overwrite",tx:e})}function ht(e){return ye(r=>r.normalize(e))}function xt(){return ye(e=>e.trim())}function $t(){return ye(e=>e.toLowerCase())}function bt(){return ye(e=>e.toUpperCase())}function _t(){return ye(e=>Mo(e))}function oc(e,r,o){return new e({type:"array",element:r,...$(o)})}function S$(e,r,o){return new e({type:"union",options:r,...$(o)})}function I$(e,r,o){return new e({type:"union",options:r,inclusive:!1,...$(o)})}function w$(e,r,o,i){return new e({type:"union",options:o,discriminator:r,...$(i)})}function R$(e,r,o){return new e({type:"intersection",left:r,right:o})}function P$(e,r,o,i){let t=o instanceof P,n=t?i:o,a=t?o:null;return new e({type:"tuple",items:r,rest:a,...$(n)})}function z$(e,r,o,i){return new e({type:"record",keyType:r,valueType:o,...$(i)})}function C$(e,r,o,i){return new e({type:"map",keyType:r,valueType:o,...$(i)})}function j$(e,r,o){return new e({type:"set",valueType:r,...$(o)})}function O$(e,r,o){let i=Array.isArray(r)?Object.fromEntries(r.map(t=>[t,t])):r;return new e({type:"enum",entries:i,...$(o)})}function T$(e,r,o){return new e({type:"enum",entries:r,...$(o)})}function E$(e,r,o){return new e({type:"literal",values:Array.isArray(r)?r:[r],...$(o)})}function ic(e,r){return new e({type:"file",...$(r)})}function U$(e,r){return new e({type:"transform",transform:r})}function N$(e,r){return new e({type:"optional",innerType:r})}function A$(e,r){return new e({type:"nullable",innerType:r})}function D$(e,r,o){return new e({type:"default",innerType:r,get defaultValue(){return typeof o=="function"?o():Ft(o)}})}function q$(e,r,o){return new e({type:"nonoptional",innerType:r,...$(o)})}function L$(e,r){return new e({type:"success",innerType:r})}function Z$(e,r,o){return new e({type:"catch",innerType:r,catchValue:typeof o=="function"?o:Yo(o)})}function F$(e,r,o){return new e({type:"pipe",in:r,out:o})}function M$(e,r){return new e({type:"readonly",innerType:r})}function V$(e,r,o){return new e({type:"template_literal",parts:r,...$(o)})}function K$(e,r){return new e({type:"lazy",getter:r})}function B$(e,r){return new e({type:"promise",innerType:r})}function ac(e,r,o){let i=$(o);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:r,...i})}function sc(e,r,o){return new e({type:"custom",check:"custom",fn:r,...$(o)})}function cc(e,r){let o=_f(i=>(i.addIssue=t=>{if(typeof t=="string")i.issues.push(nt(t,i.value,o._zod.def));else{let n=t;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),"input"in n||(n.input=i.value),n.inst??(n.inst=o),n.continue??(n.continue=!o._zod.def.abort),i.issues.push(nt(n))}},e(i.value,i)),r);return o}function _f(e,r){let o=new q({check:"custom",...$(r)});return o._zod.check=e,o}function uc(e){let r=new q({check:"describe"});return r._zod.onattach=[o=>{let i=G.get(o)??{};G.add(o,{...i,description:e})}],r._zod.check=()=>{},r}function lc(e){let r=new q({check:"meta"});return r._zod.onattach=[o=>{let i=G.get(o)??{};G.add(o,{...i,...e})}],r._zod.check=()=>{},r}function pc(e,r){let o=$(r),i=o.truthy??["true","1","yes","on","y","enabled"],t=o.falsy??["false","0","no","off","n","disabled"];o.case!=="sensitive"&&(i=i.map(g=>typeof g=="string"?g.toLowerCase():g),t=t.map(g=>typeof g=="string"?g.toLowerCase():g));let n=new Set(i),a=new Set(t),s=e.Codec??rr,c=e.Boolean??er,u=e.String??Ze,l=new u({type:"string",error:o.error}),p=new c({type:"boolean",error:o.error}),d=new s({type:"pipe",in:l,out:p,transform:((g,y)=>{let _=g;return o.case!=="sensitive"&&(_=_.toLowerCase()),n.has(_)?!0:a.has(_)?!1:(y.issues.push({code:"invalid_value",expected:"stringbool",values:[...n,...a],input:y.value,inst:d,continue:!1}),{})}),reverseTransform:((g,y)=>g===!0?i[0]||"true":t[0]||"false"),error:o.error});return d._zod.bag.truthy=i,d._zod.bag.falsy=t,d._zod.bag.case=o.case??"insensitive",d}function kt(e,r,o,i={}){let t=$(i),n={check:"string_format",type:"string",format:r,fn:typeof o=="function"?o:s=>o.test(s),...t};return o instanceof RegExp&&(n.pattern=o),new e(n)}function dr(e,...r){for(let o of r)for(let i of Reflect.ownKeys(o))Object.prototype.propertyIsEnumerable.call(o,i)&&M(e,i,o[i]);return e}function Ce(e){let r=e?.target??"draft-2020-12";return r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??G,target:r,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 K(e,r,o,i,t){let n=typeof r.unrepresentable=="function"?r.unrepresentable({zodSchema:e,path:i.path,message:t}):r.unrepresentable;if(n==="any")return!1;if(n===void 0||n==="throw")throw new Error(t);return Object.assign(o,n),!0}function U(e,r,o={path:[],schemaPath:[]}){var i;let t=e._zod.def,n=r.seen.get(e);if(n)return n.count++,o.schemaPath.includes(e)&&(n.cycle=o.path),n.schema;let a={schema:{},count:1,cycle:void 0,path:o.path};r.seen.set(e,a),r.sharedDefsExtractedFor=void 0,r.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(r,a.schema,l);else{let d=a.schema,g=r.processors[t.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${t.type}`);g(e,r,d,l)}let p=e._zod.parent;p&&(a.ref||(a.ref=p),U(p,r,l),r.seen.get(p).isParent=!0)}let c=r.metadataRegistry.get(e);return c&&dr(a.schema,c),r.io==="input"&&Q(e)&&(delete a.schema.examples,delete a.schema.default),r.io==="input"&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,r.seen.get(e).schema}function kf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function je(e,r){let o=e.seen.get(r);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=i.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,a[0])}}let t=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(a[0])?.id,d=e.external.uri??(y=>y);if(p)return{ref:d(p)};let g=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=g,{defId:g,ref:`${d("__shared")}#/${s}/${kf(g)}`}}let c="#",u=`${c}/${s}/`;if(a[1]===o&&!a[1].schema.id)return{ref:c};let l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+kf(l)}},n=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=t(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let p in l)delete l[p];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
63
63
|
|
|
64
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(r===a[0]){n(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(r!==a[0]&&u){n(a);continue}}if(e.metadataRegistry.get(a[0])?.id){n(a);continue}if(s.cycle){n(a);continue}if(s.count>1&&e.reused==="ref"){n(a);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function wf(e){let r=e.anyOf;if(!Array.isArray(r)||r.length===0||e.type!==void 0)return;let o=[];for(let i of r){if(!i||typeof i!="object")return;wf(i);let t=Object.keys(i);if(t.length!==1||t[0]!=="type")return;let n=i.type;for(let a of Array.isArray(n)?n:[n]){if(typeof a!="string")return;o.includes(a)||o.push(a)}}delete e.anyOf,e.type=o.length===1?o[0]:o}var Rf=new Set(["type","properties","required","additionalProperties"]),Sf=["oneOf","anyOf"];function If(e){let r=e.additionalProperties;return r===void 0||r===!1||typeof r!="object"||r===null?null:Object.keys(r).length?r:null}function dc(e){let r=[];for(let n of e){if(typeof n!="object"||n.type!=="object")return null;for(let a in n)if(!Rf.has(a))return null;r.push(n)}let o={},i=new Set;for(let n of r){for(let a in n.properties){if(Object.prototype.hasOwnProperty.call(o,a))continue;let s=[];for(let u of r){let l=u.properties?.[a]??If(u);l!=null&&(s.some(p=>JSON.stringify(p)===JSON.stringify(l))||s.push(l))}let c=s.length===1?s[0]:dc(s)??{allOf:s};M(o,a,c)}for(let a of n.required??[])i.add(a)}let t={type:"object",properties:o};if(i.size&&(t.required=[...i]),r.every(n=>n.additionalProperties===!1))t.additionalProperties=!1;else{let n=[];for(let a of r){let s=If(a);s&&!n.some(c=>JSON.stringify(c)===JSON.stringify(s))&&n.push(s)}n.length===1?t.additionalProperties=n[0]:n.length>1&&(t.additionalProperties={allOf:n})}return t}function J$(e){let r=e.allOf;if(!Array.isArray(r)||r.length<2)return;for(let t of Rf)if(t in e)return;let o=r.filter(t=>Sf.some(n=>Array.isArray(t[n]))),i=null;if(!o.length)i=dc(r);else{let t=o[0],n=Sf.find(c=>Array.isArray(t[c]));if(Object.keys(t).length!==1)return;let a=r.filter(c=>c!==t),s=t[n].map(c=>dc([...a,c]));if(s.some(c=>!c))return;i={[n]:s}}i&&(delete e.allOf,dr(e,i))}function Oe(e,r){let o=e.seen.get(r);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){i(p);let g=e.seen.get(p),y=g.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(y)):dr(u,y),dr(u,l),s._zod.parent===p)for(let S in u)S==="$ref"||S==="allOf"||S in l||delete u[S];if(y.$ref&&g.def)for(let S in u)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(u[S])===JSON.stringify(g.def[S])&&delete u[S]}let d=s._zod.parent;if(d&&d!==p){i(d);let g=e.seen.get(d);if(g?.schema.$ref&&(u.$ref=g.schema.$ref,g.def))for(let y in u)y==="$ref"||y==="allOf"||y in g.def&&JSON.stringify(u[y])===JSON.stringify(g.def[y])&&delete u[y]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())i(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())wf(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=s.get(l);p?p.push(u):s.set(l,[u])}for(let c of e.intersections)for(let u of s.get(c)??[])J$(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 s=e.external.registry.get(r)?.id;if(!s)throw new Error("Schema is missing an `id` property");t.$id=e.external.uri(s)}dr(t,o.defId?o.schema:o.def??o.schema);let n=e.metadataRegistry.get(r)?.id;n!==void 0&&t.id===n&&delete t.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,M(a,c.defId,c.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 s=JSON.parse(JSON.stringify(t));return Object.defineProperty(s,"~standard",{value:{...r["~standard"],jsonSchema:{input:St(r,"input",e.processors),output:St(r,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Q(e,r){let o=r??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Q(i.element,o);if(i.type==="set")return Q(i.valueType,o);if(i.type==="lazy")return Q(i.getter(),o);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Q(i.innerType,o);if(i.type==="intersection")return Q(i.left,o)||Q(i.right,o);if(i.type==="record"||i.type==="map")return Q(i.keyType,o)||Q(i.valueType,o);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Q(i.in,o)||Q(i.out,o);if(i.type==="object"){for(let t in i.shape)if(Q(i.shape[t],o))return!0;return!1}if(i.type==="union"){for(let t of i.options)if(Q(t,o))return!0;return!1}if(i.type==="tuple"){for(let t of i.items)if(Q(t,o))return!0;return!!(i.rest&&Q(i.rest,o))}return!1}var fc=(e,r={})=>o=>{let i=Ce({...o,processors:r});return U(e,i),je(i,e),Oe(i,e)},St=(e,r,o={})=>i=>{let{libraryOptions:t,target:n}=i??{},a=Ce({...t??{},target:n,io:r,processors:o});return U(e,a),je(a,e),Oe(a,e)};var G$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},yc=(e,r,o,i)=>{let t=o;t.type="string";let{minimum:n,maximum:a,format:s,patterns:c,contentEncoding:u,laxFormat:l}=e._zod.bag;if(typeof n=="number"&&(t.minLength=n),typeof a=="number"&&(t.maxLength=a),s&&(t.format=G$[s]??s,t.format===""&&delete t.format,(s==="time"||l)&&delete t.format),u&&(t.contentEncoding=u),c&&c.size>0){let p=[...c];p.length===1?t.pattern=p[0].source:p.length>1&&(t.allOf=[...p.map(d=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},vc=(e,r,o,i)=>{let t=o,{minimum:n,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?t.type="integer":t.type="number";let p=typeof l=="number"&&l>=(n??Number.NEGATIVE_INFINITY),d=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),g=r.target==="draft-04"||r.target==="openapi-3.0";p?g?(t.minimum=l,t.exclusiveMinimum=!0):t.exclusiveMinimum=l:typeof n=="number"&&(t.minimum=n),d?g?(t.maximum=u,t.exclusiveMaximum=!0):t.exclusiveMaximum=u:typeof a=="number"&&(t.maximum=a),typeof c=="number"&&(Number.isFinite(c)&&c!==0?t.multipleOf=Math.abs(c):K(e,r,t,i,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},hc=(e,r,o,i)=>{o.type="boolean"},xc=(e,r,o,i)=>{K(e,r,o,i,"BigInt cannot be represented in JSON Schema")},$c=(e,r,o,i)=>{K(e,r,o,i,"Symbols cannot be represented in JSON Schema")},bc=(e,r,o,i)=>{r.target==="openapi-3.0"?(o.type="string",o.nullable=!0,o.enum=[null]):o.type="null"},_c=(e,r,o,i)=>{K(e,r,o,i,"Undefined cannot be represented in JSON Schema")},kc=(e,r,o,i)=>{K(e,r,o,i,"Void cannot be represented in JSON Schema")},Sc=(e,r,o,i)=>{o.not={}},Ic=(e,r,o,i)=>{},wc=(e,r,o,i)=>{},Rc=(e,r,o,i)=>{K(e,r,o,i,"Date cannot be represented in JSON Schema")},Pc=(e,r,o,i)=>{let t=e._zod.def,n=qt(t.entries);if(n.length===0){o.not={};return}n.every(a=>typeof a=="number")&&(o.type="number"),n.every(a=>typeof a=="string")&&(o.type="string"),o.enum=n},zc=(e,r,o,i)=>{let t=e._zod.def;if(t.values.length===0){o.not={};return}let n=[];for(let a of t.values)if(a===void 0){if(K(e,r,o,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(K(e,r,o,i,"BigInt literals cannot be represented in JSON Schema"))return;n.push(Number(a))}else n.push(a);if(n.length!==0)if(n.length===1){let a=n[0];o.type=a===null?"null":typeof a,r.target==="draft-04"||r.target==="openapi-3.0"?o.enum=[a]:o.const=a}else n.every(a=>typeof a=="number")&&(o.type="number"),n.every(a=>typeof a=="string")&&(o.type="string"),n.every(a=>typeof a=="boolean")&&(o.type="boolean"),n.every(a=>a===null)&&(o.type="null"),o.enum=n},Cc=(e,r,o,i)=>{K(e,r,o,i,"NaN cannot be represented in JSON Schema")},jc=(e,r,o,i)=>{let t=o,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=n.source},Oc=(e,r,o,i)=>{let t=o,n={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(n.minLength=a),s!==void 0&&(n.maxLength=s),c?c.length===1?(n.contentMediaType=c[0],Object.assign(t,n)):(Object.assign(t,n),t.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(t,n)},Tc=(e,r,o,i)=>{o.type="boolean"},Ec=(e,r,o,i)=>{K(e,r,o,i,"Custom types cannot be represented in JSON Schema")},Uc=(e,r,o,i)=>{K(e,r,o,i,"Function types cannot be represented in JSON Schema")},Nc=(e,r,o,i)=>{K(e,r,o,i,"Transforms cannot be represented in JSON Schema")},Ac=(e,r,o,i)=>{K(e,r,o,i,"Map cannot be represented in JSON Schema")},Dc=(e,r,o,i)=>{K(e,r,o,i,"Set cannot be represented in JSON Schema")},qc=(e,r,o,i)=>{let t=o,n=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(t.minItems=a),typeof s=="number"&&(t.maxItems=s),t.type="array",t.items=U(n.element,r,{...i,path:[...i.path,"items"]})};function fr(e){let r=e._zod.def;return r.type==="pipe"&&r.in._zod.traits.has("$ZodTransform")?fr(r.out):r.type==="catch"?fr(r.innerType):e._zod.optin}var Lc=(e,r,o,i)=>{let t=o,n=e._zod.def,a=n.shape;if(Object.getOwnPropertySymbols(a).length&&K(e,r,t,i,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let l in a)M(t.properties,l,U(a[l],r,{...i,path:[...i.path,"properties",l]}));let c=new Set(Object.keys(a)),u=new Set([...c].filter(l=>{let p=n.shape[l];return r.io==="input"?fr(p)===void 0:p._zod.optout===void 0}));u.size>0&&(t.required=Array.from(u)),n.catchall?._zod.def.type==="never"?t.additionalProperties=!1:n.catchall?n.catchall&&(t.additionalProperties=U(n.catchall,r,{...i,path:[...i.path,"additionalProperties"]})):r.io==="output"&&(t.additionalProperties=!1)},to=(e,r,o,i)=>{let t=e._zod.def,n=t.inclusive===!1,a=t.options.map((s,c)=>U(s,r,{...i,path:[...i.path,n?"oneOf":"anyOf",c]}));n?o.oneOf=a:o.anyOf=a},Zc=(e,r,o,i)=>{let t=e._zod.def,n=U(t.left,r,{...i,path:[...i.path,"allOf",0]}),a=U(t.right,r,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(n)?n.allOf:[n],...s(a)?a.allOf:[a]];o.allOf=c,r.intersections.push(c)},Fc=(e,r,o,i)=>{let t=o,n=e._zod.def;t.type="array";let a=r.target==="draft-2020-12"?"prefixItems":"items",s=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",c=n.items.map((_,S)=>U(_,r,{...i,path:[...i.path,a,S]})),u=n.rest?U(n.rest,r,{...i,path:[...i.path,s,...r.target==="openapi-3.0"?[n.items.length]:[]]}):null,l=n.items.length;for(;l>0;){let _=n.items[l-1];if(!(r.io==="input"?fr(_)!==void 0:_._zod.optout==="optional"))break;l--}let p=n.items.length,d=!n.rest;r.target==="draft-2020-12"?(t.prefixItems=c,d?t.items=!1:u&&(t.items=u),l>0&&(t.minItems=l),d&&(t.maxItems=p)):r.target==="openapi-3.0"?(t.items={anyOf:c},u&&t.items.anyOf.push(u),l>0&&(t.minItems=l),d&&(t.maxItems=p)):(t.items=c,d?t.additionalItems=!1:u&&(t.additionalItems=u),l>0&&(t.minItems=l),d&&(t.maxItems=p));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(t.minItems=g),typeof y=="number"&&(t.maxItems=y)};function mc(e,r,o){if(r.$ref){if(o.has(r))return r;o.add(r);let y=e.get(r)?.def;if(!y)return r;let _=mc(e,y,o);return _===y?r:_}for(let y of["anyOf","oneOf"]){let _=r[y];if(!Array.isArray(_))continue;let S=_.map(N=>mc(e,N,o));S.some((N,I)=>N!==_[I])&&(r={...r,[y]:S})}let i=Array.isArray(r.type)?r.type:[r.type],t=!i.includes("string")&&i.some(y=>y==="number"||y==="integer"),n=r.enum??(r.const!==void 0?[r.const]:void 0);if(!t&&!n?.some(y=>typeof y=="number"))return r;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:d,...g}=r;return g.enum?g.enum=g.enum.map(y=>typeof y=="number"?String(y):y):typeof g.const=="number"&&(g.const=String(g.const)),t&&(g.type="string",n||(g.pattern=(i.includes("number")?Re:Wt).source)),g}var gc=new WeakMap;function W$(e){let r=new Map;for(let i of e.seen.values())i.def&&!r.has(i.schema)&&r.set(i.schema,i);let o=new Map;for(let i of gc.get(e)??[]){let t=e.seen.get(i),n=(t?.def??t?.schema)?.propertyNames;if(!n||n===!0||o.has(n))continue;let a=mc(r,n,new Set);a!==n&&o.set(n,a)}if(o.size)for(let i of e.seen.values())for(let t of[i.schema,i.def]){let n=t&&o.get(t.propertyNames);n&&(t.propertyNames=n)}}var Mc=(e,r,o,i)=>{let t=o,n=e._zod.def;t.type="object";let a=n.keyType,c=a._zod.bag?.patterns;if(n.mode==="loose"&&c&&c.size>0){let p=U(n.valueType,r,{...i,path:[...i.path,"patternProperties","*"]});t.patternProperties={};for(let d of c)M(t.patternProperties,d.source,p)}else{if(r.target==="draft-07"||r.target==="draft-2020-12"){t.propertyNames=U(n.keyType,r,{...i,path:[...i.path,"propertyNames"]});let p=gc.get(r);p||(p=[],gc.set(r,p),r.deferred.push(()=>W$(r))),p.push(e)}t.additionalProperties=U(n.valueType,r,{...i,path:[...i.path,"additionalProperties"]})}let u=a._zod.values,l=r.io==="input"&&fr(n.valueType)!==void 0;if(u&&!n.partial&&!l){let p=[...u].filter(d=>typeof d=="string"||typeof d=="number");p.length>0&&(t.required=p.map(String))}},Vc=(e,r,o,i)=>{let t=e._zod.def,n=U(t.innerType,r,i),a=r.seen.get(e);r.target==="openapi-3.0"?(a.ref=t.innerType,o.nullable=!0):o.anyOf=[n,{type:"null"}]},Kc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType},Bc=Symbol();function Pf(e,r,o,i,t){let n=!1,a=JSON.stringify(e,(s,c)=>typeof c!="bigint"?c:(n=!0,null));return n?(K(r,o,i,t,"BigInt defaults cannot be represented in JSON Schema"),Bc):JSON.parse(a)}var Jc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType;let a=Pf(t.defaultValue,e,r,o,i);a!==Bc&&(o.default=a)},Gc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);if(n.ref=t.innerType,r.io!=="input")return;let a=Pf(t.defaultValue,e,r,o,i);a!==Bc&&(o._prefault=a)},Wc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{K(e,r,o,i,"Dynamic catch values are not supported in JSON Schema");return}o.default=a},Hc=(e,r,o,i)=>{let t=e._zod.def,n=t.in._zod.traits.has("$ZodTransform"),a=r.io==="input"?n?t.out:t.in:t.out;U(a,r,i);let s=r.seen.get(e);s.ref=a},Xc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType,o.readOnly=!0},Yc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType},ro=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType},Qc=(e,r,o,i)=>{let t=e._zod.innerType;U(t,r,i);let n=r.seen.get(e);n.ref=t},eo={string:yc,number:vc,boolean:hc,bigint:xc,symbol:$c,null:bc,undefined:_c,void:kc,never:Sc,any:Ic,unknown:wc,date:Rc,enum:Pc,literal:zc,nan:Cc,template_literal:jc,file:Oc,success:Tc,custom:Ec,function:Uc,transform:Nc,map:Ac,set:Dc,array:qc,object:Lc,union:to,intersection:Zc,tuple:Fc,record:Mc,nullable:Vc,nonoptional:Kc,default:Jc,prefault:Gc,catch:Wc,pipe:Hc,readonly:Xc,promise:Yc,optional:ro,lazy:Qc};function no(e,r){if("_idmap"in e){let i=e,t=Ce({...r,processors:eo}),n={};for(let c of i._idmap.entries()){let[u,l]=c;U(l,t)}let a={},s={registry:i,uri:r?.uri,defs:n};t.external=s;for(let c of i._idmap.entries()){let[u,l]=c;je(t,l),M(a,u,Oe(t,l))}if(Object.keys(n).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:n}}return{schemas:a}}let o=Ce({...r,processors:eo});return U(e,o),je(o,e),Oe(o,e)}var oo=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(r){this.ctx.counter=r}get seen(){return this.ctx.seen}constructor(r){let o=r?.target??"draft-2020-12";o==="draft-4"&&(o="draft-04"),o==="draft-7"&&(o="draft-07"),this.ctx=Ce({processors:eo,target:o,...r?.metadata&&{metadata:r.metadata},...r?.unrepresentable&&{unrepresentable:r.unrepresentable},...r?.override&&{override:r.override},...r?.io&&{io:r.io}})}process(r,o={path:[],schemaPath:[]}){return U(r,this.ctx,o)}emit(r,o){o&&(o.cycles&&(this.ctx.cycles=o.cycles),o.reused&&(this.ctx.reused=o.reused),o.external&&(this.ctx.external=o.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,je(this.ctx,r);let i=Oe(this.ctx,r),{"~standard":t,...n}=i;return n}};var zf={};var Tt={};J(Tt,{ZodAny:()=>$u,ZodArray:()=>Su,ZodBase64:()=>So,ZodBase64URL:()=>Io,ZodBigInt:()=>jt,ZodBigIntFormat:()=>Po,ZodBoolean:()=>Ct,ZodCIDRv4:()=>_o,ZodCIDRv6:()=>ko,ZodCUID:()=>go,ZodCUID2:()=>yo,ZodCatch:()=>Ku,ZodCodec:()=>kr,ZodCreditCard:()=>fu,ZodCustom:()=>Sr,ZodCustomStringFormat:()=>Pt,ZodDate:()=>vr,ZodDefault:()=>qu,ZodDiscriminatedUnion:()=>wu,ZodE164:()=>wo,ZodEmail:()=>lo,ZodEmoji:()=>fo,ZodEnum:()=>wt,ZodExactOptional:()=>Oo,ZodFile:()=>Uu,ZodFunction:()=>tl,ZodGUID:()=>po,ZodIPv4:()=>$o,ZodIPv6:()=>bo,ZodISODate:()=>Ee,ZodISODateTime:()=>Te,ZodISODuration:()=>Ne,ZodISOTime:()=>Ue,ZodIntersection:()=>Ru,ZodJWT:()=>Ro,ZodKSUID:()=>xo,ZodLazy:()=>Yu,ZodLiteral:()=>Eu,ZodMAC:()=>du,ZodMap:()=>Ou,ZodNaN:()=>Ju,ZodNanoID:()=>mo,ZodNever:()=>_u,ZodNonOptional:()=>To,ZodNull:()=>hu,ZodNullable:()=>Du,ZodNumber:()=>zt,ZodNumberFormat:()=>Ye,ZodObject:()=>xr,ZodOptional:()=>br,ZodPipe:()=>_r,ZodPrefault:()=>Zu,ZodPreprocess:()=>Gu,ZodPromise:()=>el,ZodReadonly:()=>Wu,ZodRecord:()=>It,ZodSet:()=>Tu,ZodString:()=>Rt,ZodStringFormat:()=>D,ZodSuccess:()=>Vu,ZodSymbol:()=>yu,ZodTemplateLiteral:()=>Xu,ZodTransform:()=>Nu,ZodTuple:()=>zu,ZodType:()=>C,ZodULID:()=>vo,ZodURL:()=>yr,ZodUUID:()=>be,ZodUndefined:()=>vu,ZodUnion:()=>$r,ZodUnknown:()=>bu,ZodVoid:()=>ku,ZodXID:()=>ho,ZodXor:()=>Iu,_ZodString:()=>uo,_default:()=>Lu,_function:()=>qm,any:()=>ym,array:()=>hr,base64:()=>Yf,base64url:()=>Qf,bigint:()=>pm,boolean:()=>gu,catch:()=>Bu,check:()=>Lm,cidrv4:()=>Hf,cidrv6:()=>Xf,codec:()=>Um,creditCard:()=>tm,cuid:()=>Ff,cuid2:()=>Mf,custom:()=>Zm,date:()=>hm,describe:()=>Fm,discriminatedUnion:()=>Sm,e164:()=>em,email:()=>Of,emoji:()=>Lf,enum:()=>Co,exactOptional:()=>Au,file:()=>jm,float32:()=>sm,float64:()=>cm,function:()=>qm,guid:()=>Tf,hash:()=>am,hex:()=>im,hostname:()=>om,httpUrl:()=>qf,instanceof:()=>Vm,int:()=>so,int32:()=>um,int64:()=>dm,intersection:()=>Pu,invertCodec:()=>Nm,ipv4:()=>Jf,ipv6:()=>Wf,json:()=>Bm,jwt:()=>rm,keyof:()=>xm,ksuid:()=>Bf,lazy:()=>Qu,literal:()=>Cm,looseObject:()=>_m,looseRecord:()=>wm,mac:()=>Gf,map:()=>Rm,meta:()=>Mm,nan:()=>Em,nanoid:()=>Zf,nativeEnum:()=>zm,never:()=>zo,nonoptional:()=>Mu,null:()=>xu,nullable:()=>gr,nullish:()=>Om,number:()=>mu,object:()=>$m,optional:()=>He,partialRecord:()=>Im,pipe:()=>co,prefault:()=>Fu,preprocess:()=>Jm,promise:()=>Dm,readonly:()=>Hu,record:()=>ju,refine:()=>rl,set:()=>Pm,strictObject:()=>bm,string:()=>mr,stringFormat:()=>nm,stringbool:()=>Km,success:()=>Tm,superRefine:()=>nl,symbol:()=>mm,templateLiteral:()=>Am,transform:()=>jo,tuple:()=>Cu,uint32:()=>lm,uint64:()=>fm,ulid:()=>Vf,undefined:()=>gm,union:()=>Ot,unknown:()=>We,url:()=>Df,uuid:()=>Ef,uuidv4:()=>Uf,uuidv6:()=>Nf,uuidv7:()=>Af,void:()=>vm,xid:()=>Kf,xor:()=>km});var io={};J(io,{endsWith:()=>yt,gt:()=>xe,gte:()=>ue,includes:()=>mt,length:()=>Ge,lowercase:()=>dt,lt:()=>he,lte:()=>ce,maxLength:()=>Je,maxSize:()=>ze,mime:()=>vt,minLength:()=>_e,minSize:()=>$e,multipleOf:()=>Pe,negative:()=>Wn,nonnegative:()=>Xn,nonpositive:()=>Hn,normalize:()=>ht,overwrite:()=>ye,positive:()=>Gn,properties:()=>Qn,property:()=>Yn,regex:()=>pt,size:()=>Be,slugify:()=>_t,startsWith:()=>gt,toLowerCase:()=>$t,toUpperCase:()=>bt,trim:()=>xt,uppercase:()=>ft});var Cf=new WeakSet([Object.prototype,Error.prototype]);function ao(e,r,o){Object.defineProperty(e,r,{configurable:!0,enumerable:!1,get(){let i=o(this);return Object.defineProperty(this,r,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,r,{value:i,configurable:!0,writable:!0})}})}var jf=(e,r)=>{Bt.init(e,r),e.name="ZodError";let o=Object.getPrototypeOf(e);Cf.has(o)||(Cf.add(o),ao(o,"format",i=>t=>Gt(i,t)),ao(o,"flatten",i=>t=>Jt(i,t)),ao(o,"addIssue",i=>t=>{i.issues.push(t),i.message=JSON.stringify(i.issues,tt,2)}),ao(o,"addIssues",i=>t=>{i.issues.push(...t),i.message=JSON.stringify(i.issues,tt,2)}),Object.defineProperty(o,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},X$=f("ZodError",jf),ie=f("ZodError",jf,void 0,{Parent:Error});var eu=ot(ie),tu=it(ie),ru=at(ie),nu=st(ie),ou=Dr(ie),iu=qr(ie),au=Lr(ie),su=Zr(ie),cu=Fr(ie),uu=Mr(ie),lu=Vr(ie),pu=Kr(ie);function Q$(){B.localeError||V(bn())}function Xe(){B.memoizer||V({memoizer:or()})}var C=f("ZodType",(e,r)=>(Q$(),P.init(e,r),e.def=r,e.type=r.type,e),{check(...e){let r=this.def;return this.clone(x.mergeDefs(r,{checks:[...r.checks??[],...e.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,r){return E(this,e,r)},brand(){return this},register(e,r){return e.add(this,r),this},refine(e,r){return this.check(rl(e,r))},superRefine(e,r){return this.check(nl(e,r))},overwrite(e){return this.check(ye(e))},optional(){return He(this)},exactOptional(){return Au(this)},nullable(){return gr(this)},nullish(){return He(gr(this))},nonoptional(e){return Mu(this,e)},array(){return hr(this)},or(e){return Ot([this,e])},and(e){return Pu(this,e)},transform(e){return co(this,jo(e))},default(e){return Lu(this,e)},prefault(e){return Fu(this,e)},catch(e){return Bu(this,e)},pipe(e){return co(this,e)},readonly(){return Hu(this)},describe(e){let r=this.clone();return G.add(r,{description:e}),r},meta(...e){if(e.length===0)return G.get(this);let r=this.clone();return G.add(r,e[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...r){return r.length===0?e(this):e(this,...r)},get"~standard"(){return x.hide(this,"~standard",{...rn(this),jsonSchema:{input:St(this,"input"),output:St(this,"output")}})},set"~standard"(e){x.own(this,"~standard",e)},parse:function e(r,o){return eu(this,r,o,{callee:e})},parseAsync:async function e(r,o){return await tu(this,r,o,{callee:e})},safeParse(e,r){return ru(this,e,r)},async safeParseAsync(e,r){return nu(this,e,r)},get spa(){return this?.safeParseAsync},set spa(e){x.own(this,"spa",e)},encode:function e(r,o){return ou(this,r,o,{callee:e})},decode:function e(r,o){return iu(this,r,o,{callee:e})},encodeAsync:async function e(r,o){return await au(this,r,o,{callee:e})},decodeAsync:async function e(r,o){return await su(this,r,o,{callee:e})},safeEncode(e,r){return cu(this,e,r)},safeDecode(e,r){return uu(this,e,r)},async safeEncodeAsync(e,r){return lu(this,e,r)},async safeDecodeAsync(e,r){return pu(this,e,r)},toJSONSchema(e){return fc(this,{})(e)},get description(){return G.get(this)?.description},get _def(){return this._zod.def}}),uo=f("_ZodString",(e,r)=>{Ze.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>yc(e,i,t,n);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null},{regex(...e){return this.check(pt(...e))},includes(...e){return this.check(mt(...e))},startsWith(...e){return this.check(gt(...e))},endsWith(...e){return this.check(yt(...e))},min(...e){return this.check(_e(...e))},max(...e){return this.check(Je(...e))},length(...e){return this.check(Ge(...e))},nonempty(...e){return this.check(_e(1,...e))},lowercase(e){return this.check(dt(e))},uppercase(e){return this.check(ft(e))},trim(){return this.check(xt())},normalize(...e){return this.check(ht(...e))},toLowerCase(){return this.check($t())},toUpperCase(){return this.check(bt())},slugify(){return this.check(_t())}}),Rt=f("ZodString",(e,r)=>{Ze.init(e,r),uo.init(e,r)},{email(e){return this.check(Rn(lo,e))},url(e){return this.check(sr(yr,e))},jwt(e){return this.check(Jn(Ro,e))},emoji(e){return this.check(Tn(fo,e))},guid(e){return this.check(Pn(po,e))},uuid(e){return this.check(zn(be,e))},uuidv4(e){return this.check(Cn(be,e))},uuidv6(e){return this.check(jn(be,e))},uuidv7(e){return this.check(On(be,e))},nanoid(e){return this.check(En(mo,e))},cuid(e){return this.check(Un(go,e))},cuid2(e){return this.check(Nn(yo,e))},ulid(e){return this.check(An(vo,e))},base64(e){return this.check(Vn(So,e))},base64url(e){return this.check(Kn(Io,e))},xid(e){return this.check(Dn(ho,e))},ksuid(e){return this.check(qn(xo,e))},ipv4(e){return this.check(Ln($o,e))},ipv6(e){return this.check(Zn(bo,e))},cidrv4(e){return this.check(Fn(_o,e))},cidrv6(e){return this.check(Mn(ko,e))},e164(e){return this.check(Bn(wo,e))},datetime(e){return this.check(cr(Te,e))},date(e){return this.check(ur(Ee,e))},time(e){return this.check(lr(Ue,e))},duration(e){return this.check(pr(Ne,e))}});function mr(e){return Cs(Rt,e)}var D=f("ZodStringFormat",(e,r)=>{A.init(e,r),uo.init(e,r)}),Te=f("ZodISODateTime",(e,r)=>{ba.init(e,r),D.init(e,r)}),Ee=f("ZodISODate",(e,r)=>{_a.init(e,r),D.init(e,r)}),Ue=f("ZodISOTime",(e,r)=>{ka.init(e,r),D.init(e,r)}),Ne=f("ZodISODuration",(e,r)=>{Sa.init(e,r),D.init(e,r)}),lo=f("ZodEmail",(e,r)=>{la.init(e,r),D.init(e,r)});function Of(e){return Rn(lo,e)}var po=f("ZodGUID",(e,r)=>{ca.init(e,r),D.init(e,r)});function Tf(e){return Pn(po,e)}var be=f("ZodUUID",(e,r)=>{ua.init(e,r),D.init(e,r)});function Ef(e){return zn(be,e)}function Uf(e){return Cn(be,e)}function Nf(e){return jn(be,e)}function Af(e){return On(be,e)}var yr=f("ZodURL",(e,r)=>{fa.init(e,r),D.init(e,r)});function Df(e){return sr(yr,e)}function qf(e){return sr(yr,{protocol:X.httpProtocol,hostname:X.domain,...x.normalizeParams(e)})}var fo=f("ZodEmoji",(e,r)=>{ma.init(e,r),D.init(e,r)});function Lf(e){return Tn(fo,e)}var mo=f("ZodNanoID",(e,r)=>{ga.init(e,r),D.init(e,r)});function Zf(e){return En(mo,e)}var go=f("ZodCUID",(e,r)=>{ya.init(e,r),D.init(e,r)});function Ff(e){return Un(go,e)}var yo=f("ZodCUID2",(e,r)=>{va.init(e,r),D.init(e,r)});function Mf(e){return Nn(yo,e)}var vo=f("ZodULID",(e,r)=>{ha.init(e,r),D.init(e,r)});function Vf(e){return An(vo,e)}var ho=f("ZodXID",(e,r)=>{xa.init(e,r),D.init(e,r)});function Kf(e){return Dn(ho,e)}var xo=f("ZodKSUID",(e,r)=>{$a.init(e,r),D.init(e,r)});function Bf(e){return qn(xo,e)}var $o=f("ZodIPv4",(e,r)=>{Ia.init(e,r),D.init(e,r)});function Jf(e){return Ln($o,e)}var du=f("ZodMAC",(e,r)=>{Ra.init(e,r),D.init(e,r)});function Gf(e){return Os(du,e)}var bo=f("ZodIPv6",(e,r)=>{wa.init(e,r),D.init(e,r)});function Wf(e){return Zn(bo,e)}var _o=f("ZodCIDRv4",(e,r)=>{Pa.init(e,r),D.init(e,r)});function Hf(e){return Fn(_o,e)}var ko=f("ZodCIDRv6",(e,r)=>{za.init(e,r),D.init(e,r)});function Xf(e){return Mn(ko,e)}var So=f("ZodBase64",(e,r)=>{Ca.init(e,r),D.init(e,r)});function Yf(e){return Vn(So,e)}var Io=f("ZodBase64URL",(e,r)=>{ja.init(e,r),D.init(e,r)});function Qf(e){return Kn(Io,e)}var wo=f("ZodE164",(e,r)=>{Oa.init(e,r),D.init(e,r)});function em(e){return Bn(wo,e)}var fu=f("ZodCreditCard",(e,r)=>{Ta.init(e,r),D.init(e,r)});function tm(e){return Ts(fu,e)}var Ro=f("ZodJWT",(e,r)=>{Ea.init(e,r),D.init(e,r)});function rm(e){return Jn(Ro,e)}var Pt=f("ZodCustomStringFormat",(e,r)=>{Ua.init(e,r),D.init(e,r)});function nm(e,r,o={}){return kt(Pt,e,r,o)}function om(e){return kt(Pt,"hostname",X.hostname,e)}function im(e){return kt(Pt,"hex",X.hex,e)}function am(e,r){let o=r?.enc??"hex",i=`${e}_${o}`,t=X[i];if(!t)throw new Error(`Unrecognized hash format: ${i}`);return kt(Pt,i,t,r)}var zt=f("ZodNumber",(e,r)=>{dn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>vc(e,i,t,n);let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),e.isFinite=!0,e.format=o.format??null},{gt(e,r){return this.check(xe(e,r))},gte(e,r){return this.check(ue(e,r))},min(e,r){return this.check(ue(e,r))},lt(e,r){return this.check(he(e,r))},lte(e,r){return this.check(ce(e,r))},max(e,r){return this.check(ce(e,r))},int(e){return this.check(so(e))},safe(e){return this.check(so(e))},positive(e){return this.check(xe(0,e))},nonnegative(e){return this.check(ue(0,e))},negative(e){return this.check(he(0,e))},nonpositive(e){return this.check(ce(0,e))},multipleOf(e,r){return this.check(Pe(e,r))},step(e,r){return this.check(Pe(e,r))},finite(){return this}});function mu(e){return Us(zt,e)}var Ye=f("ZodNumberFormat",(e,r)=>{Na.init(e,r),zt.init(e,r)});function so(e){return As(Ye,e)}function sm(e){return Ds(Ye,e)}function cm(e){return qs(Ye,e)}function um(e){return Ls(Ye,e)}function lm(e){return Zs(Ye,e)}var Ct=f("ZodBoolean",(e,r)=>{er.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>hc(e,o,i,t)});function gu(e){return Fs(Ct,e)}var jt=f("ZodBigInt",(e,r)=>{fn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>xc(e,i,t,n);let o=e._zod.bag;e.minValue=o.minimum??null,e.maxValue=o.maximum??null,e.format=o.format??null},{gte(e,r){return this.check(ue(e,r))},min(e,r){return this.check(ue(e,r))},gt(e,r){return this.check(xe(e,r))},lt(e,r){return this.check(he(e,r))},lte(e,r){return this.check(ce(e,r))},max(e,r){return this.check(ce(e,r))},positive(e){return this.check(xe(BigInt(0),e))},negative(e){return this.check(he(BigInt(0),e))},nonpositive(e){return this.check(ce(BigInt(0),e))},nonnegative(e){return this.check(ue(BigInt(0),e))},multipleOf(e,r){return this.check(Pe(e,r))}});function pm(e){return Vs(jt,e)}var Po=f("ZodBigIntFormat",(e,r)=>{Aa.init(e,r),jt.init(e,r)});function dm(e){return Bs(Po,e)}function fm(e){return Js(Po,e)}var yu=f("ZodSymbol",(e,r)=>{Da.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>$c(e,o,i,t)});function mm(e){return Gs(yu,e)}var vu=f("ZodUndefined",(e,r)=>{qa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>_c(e,o,i,t)});function gm(e){return Ws(vu,e)}var hu=f("ZodNull",(e,r)=>{La.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>bc(e,o,i,t)});function xu(e){return Hs(hu,e)}var $u=f("ZodAny",(e,r)=>{Za.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Ic(e,o,i,t)});function ym(){return Xs($u)}var bu=f("ZodUnknown",(e,r)=>{Fa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>wc(e,o,i,t)});function We(){return Ys(bu)}var _u=f("ZodNever",(e,r)=>{Ma.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Sc(e,o,i,t)});function zo(e){return Qs(_u,e)}var ku=f("ZodVoid",(e,r)=>{Va.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>kc(e,o,i,t)});function vm(e){return ec(ku,e)}var vr=f("ZodDate",(e,r)=>{Ka.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>Rc(e,i,t,n),e.min=(i,t)=>e.check(ue(i,t)),e.max=(i,t)=>e.check(ce(i,t));let o=e._zod.bag;e.minDate=o.minimum?new Date(o.minimum):null,e.maxDate=o.maximum?new Date(o.maximum):null});function hm(e){return tc(vr,e)}var Su=f("ZodArray",(e,r)=>{Xe(),Ba.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>qc(e,o,i,t),e.element=r.element},{min(e,r){return this.check(_e(e,r))},nonempty(e){return this.check(_e(1,e))},max(e,r){return this.check(Je(e,r))},length(e,r){return this.check(Ge(e,r))},unwrap(){return this.element}});function hr(e,r){return oc(Su,e,r)}function xm(e){let r=e._zod.def.shape;return Co(Object.keys(r))}var xr=f("ZodObject",(e,r)=>{Xe(),Ja.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Lc(e,o,i,t),x.installLazyProp(e,"shape",o=>o._zod.def.shape,!1)},{keyof(){return Co(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:We()})},loose(){return this.clone({...this._zod.def,catchall:We()})},strict(){return this.clone({...this._zod.def,catchall:zo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return x.extend(this,e)},safeExtend(e){return x.safeExtend(this,e)},merge(e){return x.merge(this,e)},pick(e){return x.pick(this,e)},omit(e){return x.omit(this,e)},partial(...e){return x.partial(br,this,e[0])},exactPartial(...e){return x.partial(Oo,this,e[0],"exactPartial")},required(...e){return x.required(To,this,e[0])}});function $m(e,r){let o={type:"object",shape:e??{},...x.normalizeParams(r)};return new xr(o)}function bm(e,r){return new xr({type:"object",shape:e,catchall:zo(),...x.normalizeParams(r)})}function _m(e,r){return new xr({type:"object",shape:e,catchall:We(),...x.normalizeParams(r)})}var $r=f("ZodUnion",(e,r)=>{tr.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>to(e,o,i,t),e.options=r.options});function Ot(e,r){return new $r({type:"union",options:e,...x.normalizeParams(r)})}var Iu=f("ZodXor",(e,r)=>{$r.init(e,r),Ga.init(e,r),e._zod.processJSONSchema=(o,i,t)=>to(e,o,i,t),e.options=r.options});function km(e,r){return new Iu({type:"union",options:e,inclusive:!1,...x.normalizeParams(r)})}var wu=f("ZodDiscriminatedUnion",(e,r)=>{$r.init(e,r),Ha.init(e,r)});function Sm(e,r,o){return new wu({type:"union",options:r,discriminator:e,...x.normalizeParams(o)})}var Ru=f("ZodIntersection",(e,r)=>{Xa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Zc(e,o,i,t)});function Pu(e,r){return new Ru({type:"intersection",left:e,right:r})}var zu=f("ZodTuple",(e,r)=>{Xe(),mn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Fc(e,o,i,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(r=>new br({type:"optional",innerType:r}))})}});function Cu(e,r,o){let i=r instanceof P,t=i?o:r,n=i?r:null;return new zu({type:"tuple",items:e,rest:n,...x.normalizeParams(t)})}var It=f("ZodRecord",(e,r)=>{Xe(),Ya.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Mc(e,o,i,t),e.keyType=r.keyType,e.valueType=r.valueType});function ju(e,r,o){return!r||!r._zod?new It({type:"record",keyType:mr(),valueType:e,...x.normalizeParams(r)}):new It({type:"record",keyType:e,valueType:r,...x.normalizeParams(o)})}function Im(e,r,o){return new It({type:"record",keyType:e,valueType:r,...x.normalizeParams(o),partial:!0})}function wm(e,r,o){return new It({type:"record",keyType:e,valueType:r,mode:"loose",...x.normalizeParams(o)})}var Ou=f("ZodMap",(e,r)=>{Xe(),Qa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Ac(e,o,i,t),e.keyType=r.keyType,e.valueType=r.valueType,e.min=(...o)=>e.check($e(...o)),e.nonempty=o=>e.check($e(1,o)),e.max=(...o)=>e.check(ze(...o)),e.size=(...o)=>e.check(Be(...o))});function Rm(e,r,o){return new Ou({type:"map",keyType:e,valueType:r,...x.normalizeParams(o)})}var Tu=f("ZodSet",(e,r)=>{Xe(),es.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Dc(e,o,i,t),e.min=(...o)=>e.check($e(...o)),e.nonempty=o=>e.check($e(1,o)),e.max=(...o)=>e.check(ze(...o)),e.size=(...o)=>e.check(Be(...o))});function Pm(e,r){return new Tu({type:"set",valueType:e,...x.normalizeParams(r)})}var wt=f("ZodEnum",(e,r)=>{ts.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>Pc(e,i,t,n),e.enum=r.entries,e.options=Object.values(r.entries);let o=new Set(Object.keys(r.entries));e.extract=(i,t)=>{let n={};for(let a of i)if(o.has(a))n[a]=r.entries[a];else throw new Error(`Key ${a} not found in enum`);return new wt({...r,checks:[],...x.normalizeParams(t),entries:n})},e.exclude=(i,t)=>{let n={...r.entries};for(let a of i)if(o.has(a))delete n[a];else throw new Error(`Key ${a} not found in enum`);return new wt({...r,checks:[],...x.normalizeParams(t),entries:n})}});function Co(e,r){let o=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new wt({type:"enum",entries:o,...x.normalizeParams(r)})}function zm(e,r){return new wt({type:"enum",entries:e,...x.normalizeParams(r)})}var Eu=f("ZodLiteral",(e,r)=>{rs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>zc(e,o,i,t),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function Cm(e,r){return new Eu({type:"literal",values:Array.isArray(e)?e:[e],...x.normalizeParams(r)})}var Uu=f("ZodFile",(e,r)=>{ns.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Oc(e,o,i,t),e.min=(o,i)=>e.check($e(o,i)),e.max=(o,i)=>e.check(ze(o,i)),e.mime=(o,i)=>e.check(vt(Array.isArray(o)?o:[o],i))});function jm(e){return ic(Uu,e)}var Nu=f("ZodTransform",(e,r)=>{Xe(),os.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Nc(e,o,i,t),e._zod.parse=(o,i)=>{if(i.direction==="backward")throw new we(e.constructor.name);o.addIssue=n=>{if(typeof n=="string")o.issues.push(x.issue(n,o.value,r));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=o.value),a.inst??(a.inst=e),o.issues.push(x.issue(a))}};let t=r.transform(o.value,o);return t instanceof Promise?t.then(n=>(o.value=n,o)):(o.value=t,o)}});function jo(e){return new Nu({type:"transform",transform:e})}var br=f("ZodOptional",(e,r)=>{gn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>ro(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function He(e){return new br({type:"optional",innerType:e})}var Oo=f("ZodExactOptional",(e,r)=>{is.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>ro(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Au(e){return new Oo({type:"optional",innerType:e})}var Du=f("ZodNullable",(e,r)=>{as.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Vc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function gr(e){return new Du({type:"nullable",innerType:e})}function Om(e){return He(gr(e))}var qu=f("ZodDefault",(e,r)=>{ss.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Jc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Lu(e,r){return new qu({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():x.shallowClone(r)}})}var Zu=f("ZodPrefault",(e,r)=>{cs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Gc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Fu(e,r){return new Zu({type:"prefault",innerType:e,get defaultValue(){return typeof r=="function"?r():x.shallowClone(r)}})}var To=f("ZodNonOptional",(e,r)=>{us.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Kc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Mu(e,r){return new To({type:"nonoptional",innerType:e,...x.normalizeParams(r)})}var Vu=f("ZodSuccess",(e,r)=>{ls.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Tc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Tm(e){return new Vu({type:"success",innerType:e})}var Ku=f("ZodCatch",(e,r)=>{ps.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Wc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Bu(e,r){return new Ku({type:"catch",innerType:e,catchValue:typeof r=="function"?r:x.constantCatch(r)})}var Ju=f("ZodNaN",(e,r)=>{ds.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Cc(e,o,i,t)});function Em(e){return nc(Ju,e)}var _r=f("ZodPipe",(e,r)=>{yn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Hc(e,o,i,t),e.in=r.in,e.out=r.out});function co(e,r){return new _r({type:"pipe",in:e,out:r})}var kr=f("ZodCodec",(e,r)=>{_r.init(e,r),rr.init(e,r)});function Um(e,r,o){return new kr({type:"pipe",in:e,out:r,transform:o.decode,reverseTransform:o.encode})}function Nm(e){let r=e._zod.def;return new kr({type:"pipe",in:r.out,out:r.in,transform:r.reverseTransform,reverseTransform:r.transform})}var Gu=f("ZodPreprocess",(e,r)=>{_r.init(e,r),fs.init(e,r)}),Wu=f("ZodReadonly",(e,r)=>{ms.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Xc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Hu(e){return new Wu({type:"readonly",innerType:e})}var Xu=f("ZodTemplateLiteral",(e,r)=>{gs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>jc(e,o,i,t)});function Am(e,r){return new Xu({type:"template_literal",parts:e,...x.normalizeParams(r)})}var Yu=f("ZodLazy",(e,r)=>{nr.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Qc(e,o,i,t),e.unwrap=()=>e._zod.def.getter()});function Qu(e){return new Yu({type:"lazy",getter:e})}var el=f("ZodPromise",(e,r)=>{vs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Yc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Dm(e){return new el({type:"promise",innerType:e})}var tl=f("ZodFunction",(e,r)=>{ys.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Uc(e,o,i,t)});function qm(e){return new tl({type:"function",input:Array.isArray(e?.input)?Cu(e?.input):e?.input??hr(We()),output:e?.output??We()})}var Sr=f("ZodCustom",(e,r)=>{hs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Ec(e,o,i,t)});function Lm(e){let r=new q({check:"custom"});return r._zod.check=e,r}function Zm(e,r){return ac(Sr,e??(()=>!0),r)}function rl(e,r={}){return sc(Sr,e,r)}function nl(e,r){return cc(e,r)}var Fm=uc,Mm=lc;function Vm(e,r={}){let o=new Sr({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...x.normalizeParams(r)});return o._zod.bag.Class=e,o._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:o,path:[...o._zod.def.path??[]]})},o}var Km=(...e)=>pc({Codec:kr,Boolean:Ct,String:Rt},...e);function Bm(e){let r=Qu(()=>Ot([mr(e),mu(),gu(),xu(),hr(r),ju(mr(),r)]));return r}function Jm(e,r){return new Gu({type:"pipe",in:jo(e),out:r})}var eb={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 tb(e){V({customError:e})}function rb(){return V().customError}var ol;ol||(ol={});var Ir={};J(Ir,{ZodISODate:()=>Ee,ZodISODateTime:()=>Te,ZodISODuration:()=>Ne,ZodISOTime:()=>Ue,date:()=>ob,datetime:()=>nb,duration:()=>ab,time:()=>ib});function nb(e){return cr(Te,e)}function ob(e){return ur(Ee,e)}function ib(e){return lr(Ue,e)}function ab(e){return pr(Ne,e)}var k={...Tt,...io,iso:Ir},sb=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 cb(e,r){let o=e.$schema;return o==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":o==="http://json-schema.org/draft-07/schema#"?"draft-7":o==="http://json-schema.org/draft-04/schema#"?"draft-4":r??"draft-2020-12"}function Gm(e,r){return e.map((o,i)=>i<r?o:o.optional())}function ub(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function lb(e,r){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let o=e.slice(1).split("/").filter(Boolean);if(o.length===0)return r.rootSchema;let i=r.version==="draft-2020-12"?"$defs":"definitions";if(o[0]===i){let t=o[1]===void 0?void 0:ub(o[1]);if(!t||!r.defs[t])throw new Error(`Reference not found: ${e}`);return r.defs[t]}throw new Error(`Reference not found: ${e}`)}function pb(e,r){return k.transform(i=>i).check(i=>{let t=i.value;if(!(typeof t!="object"||t===null||Array.isArray(t)))for(let n of Object.getOwnPropertyNames(t)){let a=r.safeParse(n);a.success||i.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:n,path:[n],continue:!0})}}).pipe(e)}function Wm(e,r){if(e!==!1)return e===void 0||e===!0?k.any():ae(e,r)}var db=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Hm(e,r){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return k.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(r.refs.has(t))return r.refs.get(t);if(r.processing.has(t))return k.lazy(()=>{if(!r.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return r.refs.get(t)});r.processing.add(t);let n=lb(t,r),a=ae(n,r);return r.refs.set(t,a),r.processing.delete(t),a}if(e.enum!==void 0){let t=e.enum;if(r.version==="openapi-3.0"&&e.nullable===!0&&t.length===1&&t[0]===null)return k.null();if(t.length===0)return k.never();if(t.length===1)return k.literal(t[0]);if(t.every(a=>typeof a=="string"))return k.enum(t);let n=t.map(a=>k.literal(a));return n.length<2?n[0]:k.union([n[0],n[1],...n.slice(2)])}if(e.const!==void 0)return k.literal(e.const);let o=e.type;if(Array.isArray(o)){let t=o.map(n=>{let a={...e,type:n};return Hm(a,r)});return t.length===0?k.never():t.length===1?t[0]:k.union(t)}if(!o)return k.any();let i;switch(o){case"string":{let t=k.string();if(e.format){let n=e.format;n==="email"?t=t.check(k.email()):n==="uri"||n==="uri-reference"?t=t.check(k.url()):n==="uuid"||n==="guid"?t=t.check(k.uuid()):n==="date-time"?t=t.check(k.iso.datetime({offset:!0})):n==="date"?t=t.check(k.iso.date()):n==="time"?t=t.check(k.regex(db)):n==="duration"?t=t.check(k.iso.duration()):n==="hostname"?t=t.check(k.hostname()):n==="ipv4"?t=t.check(k.ipv4()):n==="ipv6"?t=t.check(k.ipv6()):n==="mac"?t=t.check(k.mac()):n==="cidr"?t=t.check(k.cidrv4()):n==="cidr-v6"?t=t.check(k.cidrv6()):n==="base64"?t=t.check(k.base64()):n==="base64url"?t=t.check(k.base64url()):n==="e164"?t=t.check(k.e164()):n==="credit_card"?t=t.check(k.creditCard()):n==="jwt"?t=t.check(k.jwt()):n==="emoji"?t=t.check(k.emoji()):n==="nanoid"?t=t.check(k.nanoid()):n==="cuid"?t=t.check(k.cuid()):n==="cuid2"?t=t.check(k.cuid2()):n==="ulid"?t=t.check(k.ulid()):n==="xid"?t=t.check(k.xid()):n==="ksuid"&&(t=t.check(k.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))),i=t;break}case"number":case"integer":{let t=o==="integer"?k.number().int():k.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)),i=t;break}case"boolean":{i=k.boolean();break}case"null":{i=k.null();break}case"object":{let t={},n=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?ae(e.additionalProperties,r):void 0;for(let[c,u]of Object.entries(n)){let l=ae(u,r);M(t,c,a.has(c)?l:l.optional())}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let d of u){let g=ae(c[d],r),y=k.string().regex(new RegExp(d));l.push(k.looseRecord(y,g))}let p=[];if(Object.keys(t).length>0&&p.push(k.object(t).passthrough()),p.push(...l),p.length===0)i=k.object({}).passthrough();else if(p.length===1)i=p[0];else{let d=k.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)d=k.intersection(d,p[g]);i=d}if(e.additionalProperties===!1){let d=Object.keys(t),g=u.map(_=>new RegExp(_)),y=i;i=i.check(_=>{if(!pe(_.value))return;let S=[];for(let N of Object.keys(_.value))d.includes(N)||g.some(I=>I.test(N))||S.push(N);S.length&&_.issues.push({code:"unrecognized_keys",keys:S,input:_.value,inst:y})})}}else{let c=k.object(t);e.additionalProperties===!1?i=c.strict():s?i=c.catchall(s):i=c.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let c=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;i=pb(i,ae(c,r))}break}case"array":{let t=e.prefixItems,n=e.items;if(t&&Array.isArray(t)){let a=typeof e.minItems=="number"?e.minItems:0,s=t.map(p=>ae(p,r)),c=Gm(s,a),u=Array.isArray(n)?void 0:Wm(n,r),l=k.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(k.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(k.maxLength(e.maxItems)))}else if(Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,s=n.map(p=>ae(p,r)),c=Gm(s,a),u=Wm(e.additionalItems,r),l=k.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(k.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(k.maxLength(e.maxItems)))}else if(n!==void 0){let a=ae(n,r),s=k.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=k.array(k.any());break}default:throw new Error(`Unsupported type: ${o}`)}return i}function ae(e,r){if(typeof e=="boolean")return e?k.any():k.never();let o=Hm(e,r),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>ae(u,r)),c=k.union(s);o=i?k.intersection(o,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>ae(u,r)),c=k.xor(s);o=i?k.intersection(o,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)o=i?o:k.any();else{let s=i?o:ae(e.allOf[0],r),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=k.intersection(s,ae(e.allOf[u],r));o=s}e.nullable===!0&&r.version==="openapi-3.0"&&(o=k.nullable(o)),e.readOnly===!0&&(o=k.readonly(o)),e.default!==void 0&&(o=o.default(e.default));let t={},n=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of n)s in e&&(t[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(t[s]=e[s]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(t.propertyNames=e.propertyNames);for(let s of Object.keys(e))sb.has(s)||M(t,s,e[s]);return Object.keys(t).length>0&&r.registry.add(o,t),e.description&&(o=o.describe(e.description)),o}function Xm(e,r){if(typeof e=="boolean")return e?k.any():k.never();let o;try{o=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=cb(o,r?.defaultTarget),t=o.$defs||o.definitions||{},n={version:i,defs:t,refs:new Map,processing:new Set,rootSchema:o,registry:r?.registry??G};return ae(o,n)}var Ym=Symbol("z.visit/resolving");function wr(e,r){let o=typeof r=="function"?r:(a,s)=>{let c=r[a._zod.def.type];return c?c(a,s):a},i=new Map;function t(a){let s=i.get(a);if(s===Ym)return new nr({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,Ym);let c=n(a),u=o(c,c!==a);return i.set(a,u),u}function n(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let u=s.shape,l=Object.keys(u),p=!1,d={};for(let y of l){let _=t(u[y]);_!==u[y]&&(p=!0),d[y]=_}let g=s.catchall;return s.catchall&&(g=t(s.catchall),g!==s.catchall&&(p=!0)),p?E(a,{...s,shape:d,catchall:g}):a}case"array":{let u=t(s.element);return u===s.element?a:E(a,{...s,element:u})}case"tuple":{let u=s.items,l=!1,p=[];for(let g of u){let y=t(g);y!==g&&(l=!0),p.push(y)}let d=s.rest;return s.rest&&(d=t(s.rest),d!==s.rest&&(l=!0)),l?E(a,{...s,items:p,rest:d}):a}case"record":case"map":{let u=t(s.keyType),l=t(s.valueType);return u===s.keyType&&l===s.valueType?a:E(a,{...s,keyType:u,valueType:l})}case"set":{let u=t(s.valueType);return u===s.valueType?a:E(a,{...s,valueType:u})}case"union":{let u=s.options,l=!1,p=[];for(let d of u){let g=t(d);g!==d&&(l=!0),p.push(g)}return l?E(a,{...s,options:p}):a}case"intersection":{let u=t(s.left),l=t(s.right);return u===s.left&&l===s.right?a:E(a,{...s,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(s.innerType);return u===s.innerType?a:E(a,{...s,innerType:u})}case"pipe":{let u=t(s.in),l=t(s.out);return u===s.in&&l===s.out?a:E(a,{...s,in:u,out:l})}case"function":{let u=t(s.input),l=t(s.output);return u===s.input&&l===s.output?a:E(a,{...s,input:u,output:l})}case"lazy":{let u=s.getter,{_cachedInner:l,...p}=s;return E(a,{...p,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 Qm(e){return wr(e,{object:r=>r.partial(),union:r=>{let o=r._zod.def;return o.discriminator===void 0?r:Ot(o.options)}})}function fb(e,r){if(!r?.length)return e;let o=e._zod.def;return E(e,me(o,{checks:[...o.checks??[],...r]}),{parent:!0})}function eg(e){return fb(e.out,e.checks)}function mb(e){return e.in._zod.traits.has("$ZodTransform")?eg(e):e.in}function tg(e){return wr(e,{pipe:r=>mb(r._zod.def),default:(r,o)=>o?He(r._zod.def.innerType):r,catch:(r,o)=>o?r._zod.def.innerType:r})}function rg(e){return wr(e,{pipe:r=>eg(r._zod.def),prefault:(r,o)=>o?r._zod.def.innerType:r})}var il={};J(il,{bigint:()=>hb,boolean:()=>vb,date:()=>xb,number:()=>yb,string:()=>gb});function gb(e){return js(Rt,e)}function yb(e){return Ns(zt,e)}function vb(e){return Ms(Ct,e)}function hb(e){return Ks(jt,e)}function xb(e){return rc(vr,e)}var ng=18;var $b=fe.object({composition:fe.unknown().optional().describe("The composition to render. Absent \u21D2 the project's ACTIVE composition \u2014 what create_render will encode. The response's `previewed.source` names what was rendered."),compositionId:fe.string().optional().describe("Preview a SPECIFIC persisted composition of this project (create_render parity). Absent \u21D2 the active one. A stale/foreign id is a 404 \u2014 never a silent fall-through."),session_id:fe.string().optional().describe("Compose-session id: render that session's SCRATCH composition (what the session has been editing) instead of the active row. Ignored when `composition` is passed."),timestamps:fe.array(fe.number()).min(1).max(ng).describe(`Composition seconds to capture, ${ng} per request. The batch renders as ONE unit of work \u2014 one warm container, one source decode, N seeks \u2014 and that unit has a fixed time budget, so a larger batch is refused here rather than accepted and timed out minutes later. For a denser sweep, split it across calls; identical beats are served from the still cache, so overlapping batches are cheap.`),imageFormat:fe.enum(["png","jpeg"]).optional().describe("Still format. Default jpeg \u2014 these pixels go to a vision model, where jpeg is equivalent and png costs multiples in bytes to store and move. Pass png only when you need full fidelity."),scale:fe.number().min(.1).max(1).optional().describe("Render scale 0.1\u20131. Default 0.5, which is what this schema has always recommended for vision-bound looks. Pass 1 when judging fine detail \u2014 it costs ~4x the vision tokens."),jpegQuality:fe.number().int().min(1).max(100).optional().describe("JPEG quality (jpeg only). Default 70 \u2014 the quality the eval panel grades at.")}).strict(),F1=$b.pick({timestamps:!0,imageFormat:!0,scale:!0,jpegQuality:!0}).strict(),Eo="X-CueFrame-Client";var bb=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,31}$/,_b=["web","console","clips"];function kb(e,r){return _b.includes(e)===(r==="browser")}function og(e){if(!bb.test(e.version))throw new Error(`${Eo} cannot carry the version ${JSON.stringify(e.version)}.`);if(!kb(e.surface,e.os))throw new Error(`${Eo} cannot carry ${e.surface} on ${e.os}.`);return`${e.surface}/${e.version}/${e.os}`}function ig(e){return e==="darwin"?"macos":e==="win32"?"windows":e==="linux"?"linux":"unknown"}import{readFileSync as Sb,writeFileSync as Ib,mkdirSync as wb,existsSync as Rb}from"fs";import{join as ag}from"path";import{homedir as Pb}from"os";var H={Success:0,UserError:2,ApiClientError:3,ApiServerError:4,NetworkError:5,PaymentRequired:6};function al(e){if(e instanceof le){if(e.status===402)return H.PaymentRequired;if(e.status>=500)return H.ApiServerError;if(e.status>=400)return H.ApiClientError}let r=e?.exitCode;return typeof r=="number"?r:H.NetworkError}function K1(e){return e===402?H.PaymentRequired:e>=500?H.ApiServerError:e>=400?H.ApiClientError:H.Success}function Rr(e){process.exit(e)}var sg=ag(Pb(),".cueframe"),Uo=ag(sg,"auth.json"),Et={local:"http://127.0.0.1:3211",dev:"https://api-dev.cueframe.ai",prod:"https://api.cueframe.ai"},zb="prod";function X1(e=zb){return process.env.CUEFRAME_API_URL??Et[e]??Et.prod}var Pr=class extends Error{constructor(o,i){super(i);this.code=o;this.name="AuthStoreError"}code;exitCode=H.UserError};function Y1(e){if(!/^cf_(?:live|test)_[A-Za-z0-9_-]{8,}$/.test(e))throw new Pr("auth_invalid","Invalid API key. Expected a key beginning with cf_live_ or cf_test_.")}function cg(){if(!Rb(Uo))return{targets:{}};let e=Sb(Uo,"utf-8");try{return JSON.parse(e)}catch{throw new Pr("auth_config_corrupt",`${Uo} is corrupt and cannot be parsed. Delete it and re-run \`cueframe login\`.`)}}function Cb(e){wb(sg,{recursive:!0,mode:448}),Ib(Uo,JSON.stringify(e,null,2),{mode:384})}function Q1(e,r="prod",o){let i=cg(),t=Et[r]??Et.prod;i.targets[r]={apiKey:e,apiUrl:o??t},Cb(i)}function ug(e="prod"){let r=process.env.CUEFRAME_API_KEY,o=process.env.CUEFRAME_API_URL;if(r)return{apiKey:r,apiUrl:o??Et[e]??Et.prod};let t=cg().targets[e];if(!t)throw new Pr("auth_missing",`No auth configured for target "${e}". Run \`cueframe login --target ${e}\` (browser sign-in) or \`cueframe auth <api-key> --target ${e}\` (CI / headless).`);return t}function jb(){return{[Eo]:og({surface:"cli",version:"0.4.8",os:ig(process.platform)})}}function lg(e){let{apiKey:r,apiUrl:o}=ug(e);Ao({baseUrl:o,apiKey:r,headers:jb()})}function No(e){let r=e instanceof le?`${e.message} (${e.code}${e.status?`, ${e.status}`:""})`:e instanceof Error?e.message:String(e),o=qo(e);return o?`${r}
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(r===a[0]){n(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(r!==a[0]&&u){n(a);continue}}if(e.metadataRegistry.get(a[0])?.id){n(a);continue}if(s.cycle){n(a);continue}if(s.count>1&&e.reused==="ref"){n(a);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function wf(e){let r=e.anyOf;if(!Array.isArray(r)||r.length===0||e.type!==void 0)return;let o=[];for(let i of r){if(!i||typeof i!="object")return;wf(i);let t=Object.keys(i);if(t.length!==1||t[0]!=="type")return;let n=i.type;for(let a of Array.isArray(n)?n:[n]){if(typeof a!="string")return;o.includes(a)||o.push(a)}}delete e.anyOf,e.type=o.length===1?o[0]:o}var Rf=new Set(["type","properties","required","additionalProperties"]),Sf=["oneOf","anyOf"];function If(e){let r=e.additionalProperties;return r===void 0||r===!1||typeof r!="object"||r===null?null:Object.keys(r).length?r:null}function dc(e){let r=[];for(let n of e){if(typeof n!="object"||n.type!=="object")return null;for(let a in n)if(!Rf.has(a))return null;r.push(n)}let o={},i=new Set;for(let n of r){for(let a in n.properties){if(Object.prototype.hasOwnProperty.call(o,a))continue;let s=[];for(let u of r){let l=u.properties?.[a]??If(u);l!=null&&(s.some(p=>JSON.stringify(p)===JSON.stringify(l))||s.push(l))}let c=s.length===1?s[0]:dc(s)??{allOf:s};M(o,a,c)}for(let a of n.required??[])i.add(a)}let t={type:"object",properties:o};if(i.size&&(t.required=[...i]),r.every(n=>n.additionalProperties===!1))t.additionalProperties=!1;else{let n=[];for(let a of r){let s=If(a);s&&!n.some(c=>JSON.stringify(c)===JSON.stringify(s))&&n.push(s)}n.length===1?t.additionalProperties=n[0]:n.length>1&&(t.additionalProperties={allOf:n})}return t}function J$(e){let r=e.allOf;if(!Array.isArray(r)||r.length<2)return;for(let t of Rf)if(t in e)return;let o=r.filter(t=>Sf.some(n=>Array.isArray(t[n]))),i=null;if(!o.length)i=dc(r);else{let t=o[0],n=Sf.find(c=>Array.isArray(t[c]));if(Object.keys(t).length!==1)return;let a=r.filter(c=>c!==t),s=t[n].map(c=>dc([...a,c]));if(s.some(c=>!c))return;i={[n]:s}}i&&(delete e.allOf,dr(e,i))}function Oe(e,r){let o=e.seen.get(r);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){i(p);let g=e.seen.get(p),y=g.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(y)):dr(u,y),dr(u,l),s._zod.parent===p)for(let S in u)S==="$ref"||S==="allOf"||S in l||delete u[S];if(y.$ref&&g.def)for(let S in u)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(u[S])===JSON.stringify(g.def[S])&&delete u[S]}let d=s._zod.parent;if(d&&d!==p){i(d);let g=e.seen.get(d);if(g?.schema.$ref&&(u.$ref=g.schema.$ref,g.def))for(let y in u)y==="$ref"||y==="allOf"||y in g.def&&JSON.stringify(u[y])===JSON.stringify(g.def[y])&&delete u[y]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())i(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())wf(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=s.get(l);p?p.push(u):s.set(l,[u])}for(let c of e.intersections)for(let u of s.get(c)??[])J$(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 s=e.external.registry.get(r)?.id;if(!s)throw new Error("Schema is missing an `id` property");t.$id=e.external.uri(s)}dr(t,o.defId?o.schema:o.def??o.schema);let n=e.metadataRegistry.get(r)?.id;n!==void 0&&t.id===n&&delete t.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,M(a,c.defId,c.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 s=JSON.parse(JSON.stringify(t));return Object.defineProperty(s,"~standard",{value:{...r["~standard"],jsonSchema:{input:St(r,"input",e.processors),output:St(r,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Q(e,r){let o=r??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Q(i.element,o);if(i.type==="set")return Q(i.valueType,o);if(i.type==="lazy")return Q(i.getter(),o);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Q(i.innerType,o);if(i.type==="intersection")return Q(i.left,o)||Q(i.right,o);if(i.type==="record"||i.type==="map")return Q(i.keyType,o)||Q(i.valueType,o);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Q(i.in,o)||Q(i.out,o);if(i.type==="object"){for(let t in i.shape)if(Q(i.shape[t],o))return!0;return!1}if(i.type==="union"){for(let t of i.options)if(Q(t,o))return!0;return!1}if(i.type==="tuple"){for(let t of i.items)if(Q(t,o))return!0;return!!(i.rest&&Q(i.rest,o))}return!1}var fc=(e,r={})=>o=>{let i=Ce({...o,processors:r});return U(e,i),je(i,e),Oe(i,e)},St=(e,r,o={})=>i=>{let{libraryOptions:t,target:n}=i??{},a=Ce({...t??{},target:n,io:r,processors:o});return U(e,a),je(a,e),Oe(a,e)};var G$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},yc=(e,r,o,i)=>{let t=o;t.type="string";let{minimum:n,maximum:a,format:s,patterns:c,contentEncoding:u,laxFormat:l}=e._zod.bag;if(typeof n=="number"&&(t.minLength=n),typeof a=="number"&&(t.maxLength=a),s&&(t.format=G$[s]??s,t.format===""&&delete t.format,(s==="time"||l)&&delete t.format),u&&(t.contentEncoding=u),c&&c.size>0){let p=[...c];p.length===1?t.pattern=p[0].source:p.length>1&&(t.allOf=[...p.map(d=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},vc=(e,r,o,i)=>{let t=o,{minimum:n,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?t.type="integer":t.type="number";let p=typeof l=="number"&&l>=(n??Number.NEGATIVE_INFINITY),d=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),g=r.target==="draft-04"||r.target==="openapi-3.0";p?g?(t.minimum=l,t.exclusiveMinimum=!0):t.exclusiveMinimum=l:typeof n=="number"&&(t.minimum=n),d?g?(t.maximum=u,t.exclusiveMaximum=!0):t.exclusiveMaximum=u:typeof a=="number"&&(t.maximum=a),typeof c=="number"&&(Number.isFinite(c)&&c!==0?t.multipleOf=Math.abs(c):K(e,r,t,i,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},hc=(e,r,o,i)=>{o.type="boolean"},xc=(e,r,o,i)=>{K(e,r,o,i,"BigInt cannot be represented in JSON Schema")},$c=(e,r,o,i)=>{K(e,r,o,i,"Symbols cannot be represented in JSON Schema")},bc=(e,r,o,i)=>{r.target==="openapi-3.0"?(o.type="string",o.nullable=!0,o.enum=[null]):o.type="null"},_c=(e,r,o,i)=>{K(e,r,o,i,"Undefined cannot be represented in JSON Schema")},kc=(e,r,o,i)=>{K(e,r,o,i,"Void cannot be represented in JSON Schema")},Sc=(e,r,o,i)=>{o.not={}},Ic=(e,r,o,i)=>{},wc=(e,r,o,i)=>{},Rc=(e,r,o,i)=>{K(e,r,o,i,"Date cannot be represented in JSON Schema")},Pc=(e,r,o,i)=>{let t=e._zod.def,n=qt(t.entries);if(n.length===0){o.not={};return}n.every(a=>typeof a=="number")&&(o.type="number"),n.every(a=>typeof a=="string")&&(o.type="string"),o.enum=n},zc=(e,r,o,i)=>{let t=e._zod.def;if(t.values.length===0){o.not={};return}let n=[];for(let a of t.values)if(a===void 0){if(K(e,r,o,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(K(e,r,o,i,"BigInt literals cannot be represented in JSON Schema"))return;n.push(Number(a))}else n.push(a);if(n.length!==0)if(n.length===1){let a=n[0];o.type=a===null?"null":typeof a,r.target==="draft-04"||r.target==="openapi-3.0"?o.enum=[a]:o.const=a}else n.every(a=>typeof a=="number")&&(o.type="number"),n.every(a=>typeof a=="string")&&(o.type="string"),n.every(a=>typeof a=="boolean")&&(o.type="boolean"),n.every(a=>a===null)&&(o.type="null"),o.enum=n},Cc=(e,r,o,i)=>{K(e,r,o,i,"NaN cannot be represented in JSON Schema")},jc=(e,r,o,i)=>{let t=o,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=n.source},Oc=(e,r,o,i)=>{let t=o,n={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(n.minLength=a),s!==void 0&&(n.maxLength=s),c?c.length===1?(n.contentMediaType=c[0],Object.assign(t,n)):(Object.assign(t,n),t.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(t,n)},Tc=(e,r,o,i)=>{o.type="boolean"},Ec=(e,r,o,i)=>{K(e,r,o,i,"Custom types cannot be represented in JSON Schema")},Uc=(e,r,o,i)=>{K(e,r,o,i,"Function types cannot be represented in JSON Schema")},Nc=(e,r,o,i)=>{K(e,r,o,i,"Transforms cannot be represented in JSON Schema")},Ac=(e,r,o,i)=>{K(e,r,o,i,"Map cannot be represented in JSON Schema")},Dc=(e,r,o,i)=>{K(e,r,o,i,"Set cannot be represented in JSON Schema")},qc=(e,r,o,i)=>{let t=o,n=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(t.minItems=a),typeof s=="number"&&(t.maxItems=s),t.type="array",t.items=U(n.element,r,{...i,path:[...i.path,"items"]})};function fr(e){let r=e._zod.def;return r.type==="pipe"&&r.in._zod.traits.has("$ZodTransform")?fr(r.out):r.type==="catch"?fr(r.innerType):e._zod.optin}var Lc=(e,r,o,i)=>{let t=o,n=e._zod.def,a=n.shape;if(Object.getOwnPropertySymbols(a).length&&K(e,r,t,i,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let l in a)M(t.properties,l,U(a[l],r,{...i,path:[...i.path,"properties",l]}));let c=new Set(Object.keys(a)),u=new Set([...c].filter(l=>{let p=n.shape[l];return r.io==="input"?fr(p)===void 0:p._zod.optout===void 0}));u.size>0&&(t.required=Array.from(u)),n.catchall?._zod.def.type==="never"?t.additionalProperties=!1:n.catchall?n.catchall&&(t.additionalProperties=U(n.catchall,r,{...i,path:[...i.path,"additionalProperties"]})):r.io==="output"&&(t.additionalProperties=!1)},to=(e,r,o,i)=>{let t=e._zod.def,n=t.inclusive===!1,a=t.options.map((s,c)=>U(s,r,{...i,path:[...i.path,n?"oneOf":"anyOf",c]}));n?o.oneOf=a:o.anyOf=a},Zc=(e,r,o,i)=>{let t=e._zod.def,n=U(t.left,r,{...i,path:[...i.path,"allOf",0]}),a=U(t.right,r,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(n)?n.allOf:[n],...s(a)?a.allOf:[a]];o.allOf=c,r.intersections.push(c)},Fc=(e,r,o,i)=>{let t=o,n=e._zod.def;t.type="array";let a=r.target==="draft-2020-12"?"prefixItems":"items",s=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",c=n.items.map((_,S)=>U(_,r,{...i,path:[...i.path,a,S]})),u=n.rest?U(n.rest,r,{...i,path:[...i.path,s,...r.target==="openapi-3.0"?[n.items.length]:[]]}):null,l=n.items.length;for(;l>0;){let _=n.items[l-1];if(!(r.io==="input"?fr(_)!==void 0:_._zod.optout==="optional"))break;l--}let p=n.items.length,d=!n.rest;r.target==="draft-2020-12"?(t.prefixItems=c,d?t.items=!1:u&&(t.items=u),l>0&&(t.minItems=l),d&&(t.maxItems=p)):r.target==="openapi-3.0"?(t.items={anyOf:c},u&&t.items.anyOf.push(u),l>0&&(t.minItems=l),d&&(t.maxItems=p)):(t.items=c,d?t.additionalItems=!1:u&&(t.additionalItems=u),l>0&&(t.minItems=l),d&&(t.maxItems=p));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(t.minItems=g),typeof y=="number"&&(t.maxItems=y)};function mc(e,r,o){if(r.$ref){if(o.has(r))return r;o.add(r);let y=e.get(r)?.def;if(!y)return r;let _=mc(e,y,o);return _===y?r:_}for(let y of["anyOf","oneOf"]){let _=r[y];if(!Array.isArray(_))continue;let S=_.map(N=>mc(e,N,o));S.some((N,I)=>N!==_[I])&&(r={...r,[y]:S})}let i=Array.isArray(r.type)?r.type:[r.type],t=!i.includes("string")&&i.some(y=>y==="number"||y==="integer"),n=r.enum??(r.const!==void 0?[r.const]:void 0);if(!t&&!n?.some(y=>typeof y=="number"))return r;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:d,...g}=r;return g.enum?g.enum=g.enum.map(y=>typeof y=="number"?String(y):y):typeof g.const=="number"&&(g.const=String(g.const)),t&&(g.type="string",n||(g.pattern=(i.includes("number")?Re:Wt).source)),g}var gc=new WeakMap;function W$(e){let r=new Map;for(let i of e.seen.values())i.def&&!r.has(i.schema)&&r.set(i.schema,i);let o=new Map;for(let i of gc.get(e)??[]){let t=e.seen.get(i),n=(t?.def??t?.schema)?.propertyNames;if(!n||n===!0||o.has(n))continue;let a=mc(r,n,new Set);a!==n&&o.set(n,a)}if(o.size)for(let i of e.seen.values())for(let t of[i.schema,i.def]){let n=t&&o.get(t.propertyNames);n&&(t.propertyNames=n)}}var Mc=(e,r,o,i)=>{let t=o,n=e._zod.def;t.type="object";let a=n.keyType,c=a._zod.bag?.patterns;if(n.mode==="loose"&&c&&c.size>0){let p=U(n.valueType,r,{...i,path:[...i.path,"patternProperties","*"]});t.patternProperties={};for(let d of c)M(t.patternProperties,d.source,p)}else{if(r.target==="draft-07"||r.target==="draft-2020-12"){t.propertyNames=U(n.keyType,r,{...i,path:[...i.path,"propertyNames"]});let p=gc.get(r);p||(p=[],gc.set(r,p),r.deferred.push(()=>W$(r))),p.push(e)}t.additionalProperties=U(n.valueType,r,{...i,path:[...i.path,"additionalProperties"]})}let u=a._zod.values,l=r.io==="input"&&fr(n.valueType)!==void 0;if(u&&!n.partial&&!l){let p=[...u].filter(d=>typeof d=="string"||typeof d=="number");p.length>0&&(t.required=p.map(String))}},Vc=(e,r,o,i)=>{let t=e._zod.def,n=U(t.innerType,r,i),a=r.seen.get(e);r.target==="openapi-3.0"?(a.ref=t.innerType,o.nullable=!0):o.anyOf=[n,{type:"null"}]},Kc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType},Bc=Symbol();function Pf(e,r,o,i,t){let n=!1,a=JSON.stringify(e,(s,c)=>typeof c!="bigint"?c:(n=!0,null));return n?(K(r,o,i,t,"BigInt defaults cannot be represented in JSON Schema"),Bc):JSON.parse(a)}var Jc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType;let a=Pf(t.defaultValue,e,r,o,i);a!==Bc&&(o.default=a)},Gc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);if(n.ref=t.innerType,r.io!=="input")return;let a=Pf(t.defaultValue,e,r,o,i);a!==Bc&&(o._prefault=a)},Wc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{K(e,r,o,i,"Dynamic catch values are not supported in JSON Schema");return}o.default=a},Hc=(e,r,o,i)=>{let t=e._zod.def,n=t.in._zod.traits.has("$ZodTransform"),a=r.io==="input"?n?t.out:t.in:t.out;U(a,r,i);let s=r.seen.get(e);s.ref=a},Xc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType,o.readOnly=!0},Yc=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType},ro=(e,r,o,i)=>{let t=e._zod.def;U(t.innerType,r,i);let n=r.seen.get(e);n.ref=t.innerType},Qc=(e,r,o,i)=>{let t=e._zod.innerType;U(t,r,i);let n=r.seen.get(e);n.ref=t},eo={string:yc,number:vc,boolean:hc,bigint:xc,symbol:$c,null:bc,undefined:_c,void:kc,never:Sc,any:Ic,unknown:wc,date:Rc,enum:Pc,literal:zc,nan:Cc,template_literal:jc,file:Oc,success:Tc,custom:Ec,function:Uc,transform:Nc,map:Ac,set:Dc,array:qc,object:Lc,union:to,intersection:Zc,tuple:Fc,record:Mc,nullable:Vc,nonoptional:Kc,default:Jc,prefault:Gc,catch:Wc,pipe:Hc,readonly:Xc,promise:Yc,optional:ro,lazy:Qc};function no(e,r){if("_idmap"in e){let i=e,t=Ce({...r,processors:eo}),n={};for(let c of i._idmap.entries()){let[u,l]=c;U(l,t)}let a={},s={registry:i,uri:r?.uri,defs:n};t.external=s;for(let c of i._idmap.entries()){let[u,l]=c;je(t,l),M(a,u,Oe(t,l))}if(Object.keys(n).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:n}}return{schemas:a}}let o=Ce({...r,processors:eo});return U(e,o),je(o,e),Oe(o,e)}var oo=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(r){this.ctx.counter=r}get seen(){return this.ctx.seen}constructor(r){let o=r?.target??"draft-2020-12";o==="draft-4"&&(o="draft-04"),o==="draft-7"&&(o="draft-07"),this.ctx=Ce({processors:eo,target:o,...r?.metadata&&{metadata:r.metadata},...r?.unrepresentable&&{unrepresentable:r.unrepresentable},...r?.override&&{override:r.override},...r?.io&&{io:r.io}})}process(r,o={path:[],schemaPath:[]}){return U(r,this.ctx,o)}emit(r,o){o&&(o.cycles&&(this.ctx.cycles=o.cycles),o.reused&&(this.ctx.reused=o.reused),o.external&&(this.ctx.external=o.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,je(this.ctx,r);let i=Oe(this.ctx,r),{"~standard":t,...n}=i;return n}};var zf={};var Tt={};J(Tt,{ZodAny:()=>$u,ZodArray:()=>Su,ZodBase64:()=>So,ZodBase64URL:()=>Io,ZodBigInt:()=>jt,ZodBigIntFormat:()=>Po,ZodBoolean:()=>Ct,ZodCIDRv4:()=>_o,ZodCIDRv6:()=>ko,ZodCUID:()=>go,ZodCUID2:()=>yo,ZodCatch:()=>Ku,ZodCodec:()=>kr,ZodCreditCard:()=>fu,ZodCustom:()=>Sr,ZodCustomStringFormat:()=>Pt,ZodDate:()=>vr,ZodDefault:()=>qu,ZodDiscriminatedUnion:()=>wu,ZodE164:()=>wo,ZodEmail:()=>lo,ZodEmoji:()=>fo,ZodEnum:()=>wt,ZodExactOptional:()=>Oo,ZodFile:()=>Uu,ZodFunction:()=>tl,ZodGUID:()=>po,ZodIPv4:()=>$o,ZodIPv6:()=>bo,ZodISODate:()=>Ee,ZodISODateTime:()=>Te,ZodISODuration:()=>Ne,ZodISOTime:()=>Ue,ZodIntersection:()=>Ru,ZodJWT:()=>Ro,ZodKSUID:()=>xo,ZodLazy:()=>Yu,ZodLiteral:()=>Eu,ZodMAC:()=>du,ZodMap:()=>Ou,ZodNaN:()=>Ju,ZodNanoID:()=>mo,ZodNever:()=>_u,ZodNonOptional:()=>To,ZodNull:()=>hu,ZodNullable:()=>Du,ZodNumber:()=>zt,ZodNumberFormat:()=>Ye,ZodObject:()=>xr,ZodOptional:()=>br,ZodPipe:()=>_r,ZodPrefault:()=>Zu,ZodPreprocess:()=>Gu,ZodPromise:()=>el,ZodReadonly:()=>Wu,ZodRecord:()=>It,ZodSet:()=>Tu,ZodString:()=>Rt,ZodStringFormat:()=>D,ZodSuccess:()=>Vu,ZodSymbol:()=>yu,ZodTemplateLiteral:()=>Xu,ZodTransform:()=>Nu,ZodTuple:()=>zu,ZodType:()=>C,ZodULID:()=>vo,ZodURL:()=>yr,ZodUUID:()=>be,ZodUndefined:()=>vu,ZodUnion:()=>$r,ZodUnknown:()=>bu,ZodVoid:()=>ku,ZodXID:()=>ho,ZodXor:()=>Iu,_ZodString:()=>uo,_default:()=>Lu,_function:()=>qm,any:()=>ym,array:()=>hr,base64:()=>Yf,base64url:()=>Qf,bigint:()=>pm,boolean:()=>gu,catch:()=>Bu,check:()=>Lm,cidrv4:()=>Hf,cidrv6:()=>Xf,codec:()=>Um,creditCard:()=>tm,cuid:()=>Ff,cuid2:()=>Mf,custom:()=>Zm,date:()=>hm,describe:()=>Fm,discriminatedUnion:()=>Sm,e164:()=>em,email:()=>Of,emoji:()=>Lf,enum:()=>Co,exactOptional:()=>Au,file:()=>jm,float32:()=>sm,float64:()=>cm,function:()=>qm,guid:()=>Tf,hash:()=>am,hex:()=>im,hostname:()=>om,httpUrl:()=>qf,instanceof:()=>Vm,int:()=>so,int32:()=>um,int64:()=>dm,intersection:()=>Pu,invertCodec:()=>Nm,ipv4:()=>Jf,ipv6:()=>Wf,json:()=>Bm,jwt:()=>rm,keyof:()=>xm,ksuid:()=>Bf,lazy:()=>Qu,literal:()=>Cm,looseObject:()=>_m,looseRecord:()=>wm,mac:()=>Gf,map:()=>Rm,meta:()=>Mm,nan:()=>Em,nanoid:()=>Zf,nativeEnum:()=>zm,never:()=>zo,nonoptional:()=>Mu,null:()=>xu,nullable:()=>gr,nullish:()=>Om,number:()=>mu,object:()=>$m,optional:()=>He,partialRecord:()=>Im,pipe:()=>co,prefault:()=>Fu,preprocess:()=>Jm,promise:()=>Dm,readonly:()=>Hu,record:()=>ju,refine:()=>rl,set:()=>Pm,strictObject:()=>bm,string:()=>mr,stringFormat:()=>nm,stringbool:()=>Km,success:()=>Tm,superRefine:()=>nl,symbol:()=>mm,templateLiteral:()=>Am,transform:()=>jo,tuple:()=>Cu,uint32:()=>lm,uint64:()=>fm,ulid:()=>Vf,undefined:()=>gm,union:()=>Ot,unknown:()=>We,url:()=>Df,uuid:()=>Ef,uuidv4:()=>Uf,uuidv6:()=>Nf,uuidv7:()=>Af,void:()=>vm,xid:()=>Kf,xor:()=>km});var io={};J(io,{endsWith:()=>yt,gt:()=>xe,gte:()=>ue,includes:()=>mt,length:()=>Ge,lowercase:()=>dt,lt:()=>he,lte:()=>ce,maxLength:()=>Je,maxSize:()=>ze,mime:()=>vt,minLength:()=>_e,minSize:()=>$e,multipleOf:()=>Pe,negative:()=>Wn,nonnegative:()=>Xn,nonpositive:()=>Hn,normalize:()=>ht,overwrite:()=>ye,positive:()=>Gn,properties:()=>Qn,property:()=>Yn,regex:()=>pt,size:()=>Be,slugify:()=>_t,startsWith:()=>gt,toLowerCase:()=>$t,toUpperCase:()=>bt,trim:()=>xt,uppercase:()=>ft});var Cf=new WeakSet([Object.prototype,Error.prototype]);function ao(e,r,o){Object.defineProperty(e,r,{configurable:!0,enumerable:!1,get(){let i=o(this);return Object.defineProperty(this,r,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,r,{value:i,configurable:!0,writable:!0})}})}var jf=(e,r)=>{Bt.init(e,r),e.name="ZodError";let o=Object.getPrototypeOf(e);Cf.has(o)||(Cf.add(o),ao(o,"format",i=>t=>Gt(i,t)),ao(o,"flatten",i=>t=>Jt(i,t)),ao(o,"addIssue",i=>t=>{i.issues.push(t),i.message=JSON.stringify(i.issues,tt,2)}),ao(o,"addIssues",i=>t=>{i.issues.push(...t),i.message=JSON.stringify(i.issues,tt,2)}),Object.defineProperty(o,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},X$=f("ZodError",jf),ie=f("ZodError",jf,void 0,{Parent:Error});var eu=ot(ie),tu=it(ie),ru=at(ie),nu=st(ie),ou=Dr(ie),iu=qr(ie),au=Lr(ie),su=Zr(ie),cu=Fr(ie),uu=Mr(ie),lu=Vr(ie),pu=Kr(ie);function Q$(){B.localeError||V(bn())}function Xe(){B.memoizer||V({memoizer:or()})}var C=f("ZodType",(e,r)=>(Q$(),P.init(e,r),e.def=r,e.type=r.type,e),{check(...e){let r=this.def;return this.clone(x.mergeDefs(r,{checks:[...r.checks??[],...e.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,r){return E(this,e,r)},brand(){return this},register(e,r){return e.add(this,r),this},refine(e,r){return this.check(rl(e,r))},superRefine(e,r){return this.check(nl(e,r))},overwrite(e){return this.check(ye(e))},optional(){return He(this)},exactOptional(){return Au(this)},nullable(){return gr(this)},nullish(){return He(gr(this))},nonoptional(e){return Mu(this,e)},array(){return hr(this)},or(e){return Ot([this,e])},and(e){return Pu(this,e)},transform(e){return co(this,jo(e))},default(e){return Lu(this,e)},prefault(e){return Fu(this,e)},catch(e){return Bu(this,e)},pipe(e){return co(this,e)},readonly(){return Hu(this)},describe(e){let r=this.clone();return G.add(r,{description:e}),r},meta(...e){if(e.length===0)return G.get(this);let r=this.clone();return G.add(r,e[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...r){return r.length===0?e(this):e(this,...r)},get"~standard"(){return x.hide(this,"~standard",{...rn(this),jsonSchema:{input:St(this,"input"),output:St(this,"output")}})},set"~standard"(e){x.own(this,"~standard",e)},parse:function e(r,o){return eu(this,r,o,{callee:e})},parseAsync:async function e(r,o){return await tu(this,r,o,{callee:e})},safeParse(e,r){return ru(this,e,r)},async safeParseAsync(e,r){return nu(this,e,r)},get spa(){return this?.safeParseAsync},set spa(e){x.own(this,"spa",e)},encode:function e(r,o){return ou(this,r,o,{callee:e})},decode:function e(r,o){return iu(this,r,o,{callee:e})},encodeAsync:async function e(r,o){return await au(this,r,o,{callee:e})},decodeAsync:async function e(r,o){return await su(this,r,o,{callee:e})},safeEncode(e,r){return cu(this,e,r)},safeDecode(e,r){return uu(this,e,r)},async safeEncodeAsync(e,r){return lu(this,e,r)},async safeDecodeAsync(e,r){return pu(this,e,r)},toJSONSchema(e){return fc(this,{})(e)},get description(){return G.get(this)?.description},get _def(){return this._zod.def}}),uo=f("_ZodString",(e,r)=>{Ze.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>yc(e,i,t,n);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null},{regex(...e){return this.check(pt(...e))},includes(...e){return this.check(mt(...e))},startsWith(...e){return this.check(gt(...e))},endsWith(...e){return this.check(yt(...e))},min(...e){return this.check(_e(...e))},max(...e){return this.check(Je(...e))},length(...e){return this.check(Ge(...e))},nonempty(...e){return this.check(_e(1,...e))},lowercase(e){return this.check(dt(e))},uppercase(e){return this.check(ft(e))},trim(){return this.check(xt())},normalize(...e){return this.check(ht(...e))},toLowerCase(){return this.check($t())},toUpperCase(){return this.check(bt())},slugify(){return this.check(_t())}}),Rt=f("ZodString",(e,r)=>{Ze.init(e,r),uo.init(e,r)},{email(e){return this.check(Rn(lo,e))},url(e){return this.check(sr(yr,e))},jwt(e){return this.check(Jn(Ro,e))},emoji(e){return this.check(Tn(fo,e))},guid(e){return this.check(Pn(po,e))},uuid(e){return this.check(zn(be,e))},uuidv4(e){return this.check(Cn(be,e))},uuidv6(e){return this.check(jn(be,e))},uuidv7(e){return this.check(On(be,e))},nanoid(e){return this.check(En(mo,e))},cuid(e){return this.check(Un(go,e))},cuid2(e){return this.check(Nn(yo,e))},ulid(e){return this.check(An(vo,e))},base64(e){return this.check(Vn(So,e))},base64url(e){return this.check(Kn(Io,e))},xid(e){return this.check(Dn(ho,e))},ksuid(e){return this.check(qn(xo,e))},ipv4(e){return this.check(Ln($o,e))},ipv6(e){return this.check(Zn(bo,e))},cidrv4(e){return this.check(Fn(_o,e))},cidrv6(e){return this.check(Mn(ko,e))},e164(e){return this.check(Bn(wo,e))},datetime(e){return this.check(cr(Te,e))},date(e){return this.check(ur(Ee,e))},time(e){return this.check(lr(Ue,e))},duration(e){return this.check(pr(Ne,e))}});function mr(e){return Cs(Rt,e)}var D=f("ZodStringFormat",(e,r)=>{A.init(e,r),uo.init(e,r)}),Te=f("ZodISODateTime",(e,r)=>{ba.init(e,r),D.init(e,r)}),Ee=f("ZodISODate",(e,r)=>{_a.init(e,r),D.init(e,r)}),Ue=f("ZodISOTime",(e,r)=>{ka.init(e,r),D.init(e,r)}),Ne=f("ZodISODuration",(e,r)=>{Sa.init(e,r),D.init(e,r)}),lo=f("ZodEmail",(e,r)=>{la.init(e,r),D.init(e,r)});function Of(e){return Rn(lo,e)}var po=f("ZodGUID",(e,r)=>{ca.init(e,r),D.init(e,r)});function Tf(e){return Pn(po,e)}var be=f("ZodUUID",(e,r)=>{ua.init(e,r),D.init(e,r)});function Ef(e){return zn(be,e)}function Uf(e){return Cn(be,e)}function Nf(e){return jn(be,e)}function Af(e){return On(be,e)}var yr=f("ZodURL",(e,r)=>{fa.init(e,r),D.init(e,r)});function Df(e){return sr(yr,e)}function qf(e){return sr(yr,{protocol:X.httpProtocol,hostname:X.domain,...x.normalizeParams(e)})}var fo=f("ZodEmoji",(e,r)=>{ma.init(e,r),D.init(e,r)});function Lf(e){return Tn(fo,e)}var mo=f("ZodNanoID",(e,r)=>{ga.init(e,r),D.init(e,r)});function Zf(e){return En(mo,e)}var go=f("ZodCUID",(e,r)=>{ya.init(e,r),D.init(e,r)});function Ff(e){return Un(go,e)}var yo=f("ZodCUID2",(e,r)=>{va.init(e,r),D.init(e,r)});function Mf(e){return Nn(yo,e)}var vo=f("ZodULID",(e,r)=>{ha.init(e,r),D.init(e,r)});function Vf(e){return An(vo,e)}var ho=f("ZodXID",(e,r)=>{xa.init(e,r),D.init(e,r)});function Kf(e){return Dn(ho,e)}var xo=f("ZodKSUID",(e,r)=>{$a.init(e,r),D.init(e,r)});function Bf(e){return qn(xo,e)}var $o=f("ZodIPv4",(e,r)=>{Ia.init(e,r),D.init(e,r)});function Jf(e){return Ln($o,e)}var du=f("ZodMAC",(e,r)=>{Ra.init(e,r),D.init(e,r)});function Gf(e){return Os(du,e)}var bo=f("ZodIPv6",(e,r)=>{wa.init(e,r),D.init(e,r)});function Wf(e){return Zn(bo,e)}var _o=f("ZodCIDRv4",(e,r)=>{Pa.init(e,r),D.init(e,r)});function Hf(e){return Fn(_o,e)}var ko=f("ZodCIDRv6",(e,r)=>{za.init(e,r),D.init(e,r)});function Xf(e){return Mn(ko,e)}var So=f("ZodBase64",(e,r)=>{Ca.init(e,r),D.init(e,r)});function Yf(e){return Vn(So,e)}var Io=f("ZodBase64URL",(e,r)=>{ja.init(e,r),D.init(e,r)});function Qf(e){return Kn(Io,e)}var wo=f("ZodE164",(e,r)=>{Oa.init(e,r),D.init(e,r)});function em(e){return Bn(wo,e)}var fu=f("ZodCreditCard",(e,r)=>{Ta.init(e,r),D.init(e,r)});function tm(e){return Ts(fu,e)}var Ro=f("ZodJWT",(e,r)=>{Ea.init(e,r),D.init(e,r)});function rm(e){return Jn(Ro,e)}var Pt=f("ZodCustomStringFormat",(e,r)=>{Ua.init(e,r),D.init(e,r)});function nm(e,r,o={}){return kt(Pt,e,r,o)}function om(e){return kt(Pt,"hostname",X.hostname,e)}function im(e){return kt(Pt,"hex",X.hex,e)}function am(e,r){let o=r?.enc??"hex",i=`${e}_${o}`,t=X[i];if(!t)throw new Error(`Unrecognized hash format: ${i}`);return kt(Pt,i,t,r)}var zt=f("ZodNumber",(e,r)=>{dn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>vc(e,i,t,n);let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),e.isFinite=!0,e.format=o.format??null},{gt(e,r){return this.check(xe(e,r))},gte(e,r){return this.check(ue(e,r))},min(e,r){return this.check(ue(e,r))},lt(e,r){return this.check(he(e,r))},lte(e,r){return this.check(ce(e,r))},max(e,r){return this.check(ce(e,r))},int(e){return this.check(so(e))},safe(e){return this.check(so(e))},positive(e){return this.check(xe(0,e))},nonnegative(e){return this.check(ue(0,e))},negative(e){return this.check(he(0,e))},nonpositive(e){return this.check(ce(0,e))},multipleOf(e,r){return this.check(Pe(e,r))},step(e,r){return this.check(Pe(e,r))},finite(){return this}});function mu(e){return Us(zt,e)}var Ye=f("ZodNumberFormat",(e,r)=>{Na.init(e,r),zt.init(e,r)});function so(e){return As(Ye,e)}function sm(e){return Ds(Ye,e)}function cm(e){return qs(Ye,e)}function um(e){return Ls(Ye,e)}function lm(e){return Zs(Ye,e)}var Ct=f("ZodBoolean",(e,r)=>{er.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>hc(e,o,i,t)});function gu(e){return Fs(Ct,e)}var jt=f("ZodBigInt",(e,r)=>{fn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>xc(e,i,t,n);let o=e._zod.bag;e.minValue=o.minimum??null,e.maxValue=o.maximum??null,e.format=o.format??null},{gte(e,r){return this.check(ue(e,r))},min(e,r){return this.check(ue(e,r))},gt(e,r){return this.check(xe(e,r))},lt(e,r){return this.check(he(e,r))},lte(e,r){return this.check(ce(e,r))},max(e,r){return this.check(ce(e,r))},positive(e){return this.check(xe(BigInt(0),e))},negative(e){return this.check(he(BigInt(0),e))},nonpositive(e){return this.check(ce(BigInt(0),e))},nonnegative(e){return this.check(ue(BigInt(0),e))},multipleOf(e,r){return this.check(Pe(e,r))}});function pm(e){return Vs(jt,e)}var Po=f("ZodBigIntFormat",(e,r)=>{Aa.init(e,r),jt.init(e,r)});function dm(e){return Bs(Po,e)}function fm(e){return Js(Po,e)}var yu=f("ZodSymbol",(e,r)=>{Da.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>$c(e,o,i,t)});function mm(e){return Gs(yu,e)}var vu=f("ZodUndefined",(e,r)=>{qa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>_c(e,o,i,t)});function gm(e){return Ws(vu,e)}var hu=f("ZodNull",(e,r)=>{La.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>bc(e,o,i,t)});function xu(e){return Hs(hu,e)}var $u=f("ZodAny",(e,r)=>{Za.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Ic(e,o,i,t)});function ym(){return Xs($u)}var bu=f("ZodUnknown",(e,r)=>{Fa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>wc(e,o,i,t)});function We(){return Ys(bu)}var _u=f("ZodNever",(e,r)=>{Ma.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Sc(e,o,i,t)});function zo(e){return Qs(_u,e)}var ku=f("ZodVoid",(e,r)=>{Va.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>kc(e,o,i,t)});function vm(e){return ec(ku,e)}var vr=f("ZodDate",(e,r)=>{Ka.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>Rc(e,i,t,n),e.min=(i,t)=>e.check(ue(i,t)),e.max=(i,t)=>e.check(ce(i,t));let o=e._zod.bag;e.minDate=o.minimum?new Date(o.minimum):null,e.maxDate=o.maximum?new Date(o.maximum):null});function hm(e){return tc(vr,e)}var Su=f("ZodArray",(e,r)=>{Xe(),Ba.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>qc(e,o,i,t),e.element=r.element},{min(e,r){return this.check(_e(e,r))},nonempty(e){return this.check(_e(1,e))},max(e,r){return this.check(Je(e,r))},length(e,r){return this.check(Ge(e,r))},unwrap(){return this.element}});function hr(e,r){return oc(Su,e,r)}function xm(e){let r=e._zod.def.shape;return Co(Object.keys(r))}var xr=f("ZodObject",(e,r)=>{Xe(),Ja.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Lc(e,o,i,t),x.installLazyProp(e,"shape",o=>o._zod.def.shape,!1)},{keyof(){return Co(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:We()})},loose(){return this.clone({...this._zod.def,catchall:We()})},strict(){return this.clone({...this._zod.def,catchall:zo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return x.extend(this,e)},safeExtend(e){return x.safeExtend(this,e)},merge(e){return x.merge(this,e)},pick(e){return x.pick(this,e)},omit(e){return x.omit(this,e)},partial(...e){return x.partial(br,this,e[0])},exactPartial(...e){return x.partial(Oo,this,e[0],"exactPartial")},required(...e){return x.required(To,this,e[0])}});function $m(e,r){let o={type:"object",shape:e??{},...x.normalizeParams(r)};return new xr(o)}function bm(e,r){return new xr({type:"object",shape:e,catchall:zo(),...x.normalizeParams(r)})}function _m(e,r){return new xr({type:"object",shape:e,catchall:We(),...x.normalizeParams(r)})}var $r=f("ZodUnion",(e,r)=>{tr.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>to(e,o,i,t),e.options=r.options});function Ot(e,r){return new $r({type:"union",options:e,...x.normalizeParams(r)})}var Iu=f("ZodXor",(e,r)=>{$r.init(e,r),Ga.init(e,r),e._zod.processJSONSchema=(o,i,t)=>to(e,o,i,t),e.options=r.options});function km(e,r){return new Iu({type:"union",options:e,inclusive:!1,...x.normalizeParams(r)})}var wu=f("ZodDiscriminatedUnion",(e,r)=>{$r.init(e,r),Ha.init(e,r)});function Sm(e,r,o){return new wu({type:"union",options:r,discriminator:e,...x.normalizeParams(o)})}var Ru=f("ZodIntersection",(e,r)=>{Xa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Zc(e,o,i,t)});function Pu(e,r){return new Ru({type:"intersection",left:e,right:r})}var zu=f("ZodTuple",(e,r)=>{Xe(),mn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Fc(e,o,i,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(r=>new br({type:"optional",innerType:r}))})}});function Cu(e,r,o){let i=r instanceof P,t=i?o:r,n=i?r:null;return new zu({type:"tuple",items:e,rest:n,...x.normalizeParams(t)})}var It=f("ZodRecord",(e,r)=>{Xe(),Ya.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Mc(e,o,i,t),e.keyType=r.keyType,e.valueType=r.valueType});function ju(e,r,o){return!r||!r._zod?new It({type:"record",keyType:mr(),valueType:e,...x.normalizeParams(r)}):new It({type:"record",keyType:e,valueType:r,...x.normalizeParams(o)})}function Im(e,r,o){return new It({type:"record",keyType:e,valueType:r,...x.normalizeParams(o),partial:!0})}function wm(e,r,o){return new It({type:"record",keyType:e,valueType:r,mode:"loose",...x.normalizeParams(o)})}var Ou=f("ZodMap",(e,r)=>{Xe(),Qa.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Ac(e,o,i,t),e.keyType=r.keyType,e.valueType=r.valueType,e.min=(...o)=>e.check($e(...o)),e.nonempty=o=>e.check($e(1,o)),e.max=(...o)=>e.check(ze(...o)),e.size=(...o)=>e.check(Be(...o))});function Rm(e,r,o){return new Ou({type:"map",keyType:e,valueType:r,...x.normalizeParams(o)})}var Tu=f("ZodSet",(e,r)=>{Xe(),es.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Dc(e,o,i,t),e.min=(...o)=>e.check($e(...o)),e.nonempty=o=>e.check($e(1,o)),e.max=(...o)=>e.check(ze(...o)),e.size=(...o)=>e.check(Be(...o))});function Pm(e,r){return new Tu({type:"set",valueType:e,...x.normalizeParams(r)})}var wt=f("ZodEnum",(e,r)=>{ts.init(e,r),C.init(e,r),e._zod.processJSONSchema=(i,t,n)=>Pc(e,i,t,n),e.enum=r.entries,e.options=Object.values(r.entries);let o=new Set(Object.keys(r.entries));e.extract=(i,t)=>{let n={};for(let a of i)if(o.has(a))n[a]=r.entries[a];else throw new Error(`Key ${a} not found in enum`);return new wt({...r,checks:[],...x.normalizeParams(t),entries:n})},e.exclude=(i,t)=>{let n={...r.entries};for(let a of i)if(o.has(a))delete n[a];else throw new Error(`Key ${a} not found in enum`);return new wt({...r,checks:[],...x.normalizeParams(t),entries:n})}});function Co(e,r){let o=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new wt({type:"enum",entries:o,...x.normalizeParams(r)})}function zm(e,r){return new wt({type:"enum",entries:e,...x.normalizeParams(r)})}var Eu=f("ZodLiteral",(e,r)=>{rs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>zc(e,o,i,t),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function Cm(e,r){return new Eu({type:"literal",values:Array.isArray(e)?e:[e],...x.normalizeParams(r)})}var Uu=f("ZodFile",(e,r)=>{ns.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Oc(e,o,i,t),e.min=(o,i)=>e.check($e(o,i)),e.max=(o,i)=>e.check(ze(o,i)),e.mime=(o,i)=>e.check(vt(Array.isArray(o)?o:[o],i))});function jm(e){return ic(Uu,e)}var Nu=f("ZodTransform",(e,r)=>{Xe(),os.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Nc(e,o,i,t),e._zod.parse=(o,i)=>{if(i.direction==="backward")throw new we(e.constructor.name);o.addIssue=n=>{if(typeof n=="string")o.issues.push(x.issue(n,o.value,r));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=o.value),a.inst??(a.inst=e),o.issues.push(x.issue(a))}};let t=r.transform(o.value,o);return t instanceof Promise?t.then(n=>(o.value=n,o)):(o.value=t,o)}});function jo(e){return new Nu({type:"transform",transform:e})}var br=f("ZodOptional",(e,r)=>{gn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>ro(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function He(e){return new br({type:"optional",innerType:e})}var Oo=f("ZodExactOptional",(e,r)=>{is.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>ro(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Au(e){return new Oo({type:"optional",innerType:e})}var Du=f("ZodNullable",(e,r)=>{as.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Vc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function gr(e){return new Du({type:"nullable",innerType:e})}function Om(e){return He(gr(e))}var qu=f("ZodDefault",(e,r)=>{ss.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Jc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Lu(e,r){return new qu({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():x.shallowClone(r)}})}var Zu=f("ZodPrefault",(e,r)=>{cs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Gc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Fu(e,r){return new Zu({type:"prefault",innerType:e,get defaultValue(){return typeof r=="function"?r():x.shallowClone(r)}})}var To=f("ZodNonOptional",(e,r)=>{us.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Kc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Mu(e,r){return new To({type:"nonoptional",innerType:e,...x.normalizeParams(r)})}var Vu=f("ZodSuccess",(e,r)=>{ls.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Tc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Tm(e){return new Vu({type:"success",innerType:e})}var Ku=f("ZodCatch",(e,r)=>{ps.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Wc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Bu(e,r){return new Ku({type:"catch",innerType:e,catchValue:typeof r=="function"?r:x.constantCatch(r)})}var Ju=f("ZodNaN",(e,r)=>{ds.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Cc(e,o,i,t)});function Em(e){return nc(Ju,e)}var _r=f("ZodPipe",(e,r)=>{yn.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Hc(e,o,i,t),e.in=r.in,e.out=r.out});function co(e,r){return new _r({type:"pipe",in:e,out:r})}var kr=f("ZodCodec",(e,r)=>{_r.init(e,r),rr.init(e,r)});function Um(e,r,o){return new kr({type:"pipe",in:e,out:r,transform:o.decode,reverseTransform:o.encode})}function Nm(e){let r=e._zod.def;return new kr({type:"pipe",in:r.out,out:r.in,transform:r.reverseTransform,reverseTransform:r.transform})}var Gu=f("ZodPreprocess",(e,r)=>{_r.init(e,r),fs.init(e,r)}),Wu=f("ZodReadonly",(e,r)=>{ms.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Xc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Hu(e){return new Wu({type:"readonly",innerType:e})}var Xu=f("ZodTemplateLiteral",(e,r)=>{gs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>jc(e,o,i,t)});function Am(e,r){return new Xu({type:"template_literal",parts:e,...x.normalizeParams(r)})}var Yu=f("ZodLazy",(e,r)=>{nr.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Qc(e,o,i,t),e.unwrap=()=>e._zod.def.getter()});function Qu(e){return new Yu({type:"lazy",getter:e})}var el=f("ZodPromise",(e,r)=>{vs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Yc(e,o,i,t),e.unwrap=()=>e._zod.def.innerType});function Dm(e){return new el({type:"promise",innerType:e})}var tl=f("ZodFunction",(e,r)=>{ys.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Uc(e,o,i,t)});function qm(e){return new tl({type:"function",input:Array.isArray(e?.input)?Cu(e?.input):e?.input??hr(We()),output:e?.output??We()})}var Sr=f("ZodCustom",(e,r)=>{hs.init(e,r),C.init(e,r),e._zod.processJSONSchema=(o,i,t)=>Ec(e,o,i,t)});function Lm(e){let r=new q({check:"custom"});return r._zod.check=e,r}function Zm(e,r){return ac(Sr,e??(()=>!0),r)}function rl(e,r={}){return sc(Sr,e,r)}function nl(e,r){return cc(e,r)}var Fm=uc,Mm=lc;function Vm(e,r={}){let o=new Sr({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...x.normalizeParams(r)});return o._zod.bag.Class=e,o._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:o,path:[...o._zod.def.path??[]]})},o}var Km=(...e)=>pc({Codec:kr,Boolean:Ct,String:Rt},...e);function Bm(e){let r=Qu(()=>Ot([mr(e),mu(),gu(),xu(),hr(r),ju(mr(),r)]));return r}function Jm(e,r){return new Gu({type:"pipe",in:jo(e),out:r})}var eb={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 tb(e){V({customError:e})}function rb(){return V().customError}var ol;ol||(ol={});var Ir={};J(Ir,{ZodISODate:()=>Ee,ZodISODateTime:()=>Te,ZodISODuration:()=>Ne,ZodISOTime:()=>Ue,date:()=>ob,datetime:()=>nb,duration:()=>ab,time:()=>ib});function nb(e){return cr(Te,e)}function ob(e){return ur(Ee,e)}function ib(e){return lr(Ue,e)}function ab(e){return pr(Ne,e)}var k={...Tt,...io,iso:Ir},sb=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 cb(e,r){let o=e.$schema;return o==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":o==="http://json-schema.org/draft-07/schema#"?"draft-7":o==="http://json-schema.org/draft-04/schema#"?"draft-4":r??"draft-2020-12"}function Gm(e,r){return e.map((o,i)=>i<r?o:o.optional())}function ub(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function lb(e,r){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let o=e.slice(1).split("/").filter(Boolean);if(o.length===0)return r.rootSchema;let i=r.version==="draft-2020-12"?"$defs":"definitions";if(o[0]===i){let t=o[1]===void 0?void 0:ub(o[1]);if(!t||!r.defs[t])throw new Error(`Reference not found: ${e}`);return r.defs[t]}throw new Error(`Reference not found: ${e}`)}function pb(e,r){return k.transform(i=>i).check(i=>{let t=i.value;if(!(typeof t!="object"||t===null||Array.isArray(t)))for(let n of Object.getOwnPropertyNames(t)){let a=r.safeParse(n);a.success||i.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:n,path:[n],continue:!0})}}).pipe(e)}function Wm(e,r){if(e!==!1)return e===void 0||e===!0?k.any():ae(e,r)}var db=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Hm(e,r){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return k.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(r.refs.has(t))return r.refs.get(t);if(r.processing.has(t))return k.lazy(()=>{if(!r.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return r.refs.get(t)});r.processing.add(t);let n=lb(t,r),a=ae(n,r);return r.refs.set(t,a),r.processing.delete(t),a}if(e.enum!==void 0){let t=e.enum;if(r.version==="openapi-3.0"&&e.nullable===!0&&t.length===1&&t[0]===null)return k.null();if(t.length===0)return k.never();if(t.length===1)return k.literal(t[0]);if(t.every(a=>typeof a=="string"))return k.enum(t);let n=t.map(a=>k.literal(a));return n.length<2?n[0]:k.union([n[0],n[1],...n.slice(2)])}if(e.const!==void 0)return k.literal(e.const);let o=e.type;if(Array.isArray(o)){let t=o.map(n=>{let a={...e,type:n};return Hm(a,r)});return t.length===0?k.never():t.length===1?t[0]:k.union(t)}if(!o)return k.any();let i;switch(o){case"string":{let t=k.string();if(e.format){let n=e.format;n==="email"?t=t.check(k.email()):n==="uri"||n==="uri-reference"?t=t.check(k.url()):n==="uuid"||n==="guid"?t=t.check(k.uuid()):n==="date-time"?t=t.check(k.iso.datetime({offset:!0})):n==="date"?t=t.check(k.iso.date()):n==="time"?t=t.check(k.regex(db)):n==="duration"?t=t.check(k.iso.duration()):n==="hostname"?t=t.check(k.hostname()):n==="ipv4"?t=t.check(k.ipv4()):n==="ipv6"?t=t.check(k.ipv6()):n==="mac"?t=t.check(k.mac()):n==="cidr"?t=t.check(k.cidrv4()):n==="cidr-v6"?t=t.check(k.cidrv6()):n==="base64"?t=t.check(k.base64()):n==="base64url"?t=t.check(k.base64url()):n==="e164"?t=t.check(k.e164()):n==="credit_card"?t=t.check(k.creditCard()):n==="jwt"?t=t.check(k.jwt()):n==="emoji"?t=t.check(k.emoji()):n==="nanoid"?t=t.check(k.nanoid()):n==="cuid"?t=t.check(k.cuid()):n==="cuid2"?t=t.check(k.cuid2()):n==="ulid"?t=t.check(k.ulid()):n==="xid"?t=t.check(k.xid()):n==="ksuid"&&(t=t.check(k.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))),i=t;break}case"number":case"integer":{let t=o==="integer"?k.number().int():k.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)),i=t;break}case"boolean":{i=k.boolean();break}case"null":{i=k.null();break}case"object":{let t={},n=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?ae(e.additionalProperties,r):void 0;for(let[c,u]of Object.entries(n)){let l=ae(u,r);M(t,c,a.has(c)?l:l.optional())}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let d of u){let g=ae(c[d],r),y=k.string().regex(new RegExp(d));l.push(k.looseRecord(y,g))}let p=[];if(Object.keys(t).length>0&&p.push(k.object(t).passthrough()),p.push(...l),p.length===0)i=k.object({}).passthrough();else if(p.length===1)i=p[0];else{let d=k.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)d=k.intersection(d,p[g]);i=d}if(e.additionalProperties===!1){let d=Object.keys(t),g=u.map(_=>new RegExp(_)),y=i;i=i.check(_=>{if(!pe(_.value))return;let S=[];for(let N of Object.keys(_.value))d.includes(N)||g.some(I=>I.test(N))||S.push(N);S.length&&_.issues.push({code:"unrecognized_keys",keys:S,input:_.value,inst:y})})}}else{let c=k.object(t);e.additionalProperties===!1?i=c.strict():s?i=c.catchall(s):i=c.passthrough()}if(e.propertyNames!==void 0&&e.propertyNames!==!0){let c=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;i=pb(i,ae(c,r))}break}case"array":{let t=e.prefixItems,n=e.items;if(t&&Array.isArray(t)){let a=typeof e.minItems=="number"?e.minItems:0,s=t.map(p=>ae(p,r)),c=Gm(s,a),u=Array.isArray(n)?void 0:Wm(n,r),l=k.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(k.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(k.maxLength(e.maxItems)))}else if(Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,s=n.map(p=>ae(p,r)),c=Gm(s,a),u=Wm(e.additionalItems,r),l=k.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(k.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(k.maxLength(e.maxItems)))}else if(n!==void 0){let a=ae(n,r),s=k.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=k.array(k.any());break}default:throw new Error(`Unsupported type: ${o}`)}return i}function ae(e,r){if(typeof e=="boolean")return e?k.any():k.never();let o=Hm(e,r),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>ae(u,r)),c=k.union(s);o=i?k.intersection(o,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>ae(u,r)),c=k.xor(s);o=i?k.intersection(o,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)o=i?o:k.any();else{let s=i?o:ae(e.allOf[0],r),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=k.intersection(s,ae(e.allOf[u],r));o=s}e.nullable===!0&&r.version==="openapi-3.0"&&(o=k.nullable(o)),e.readOnly===!0&&(o=k.readonly(o)),e.default!==void 0&&(o=o.default(e.default));let t={},n=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of n)s in e&&(t[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(t[s]=e[s]);e.propertyNames!==void 0&&e.type==="object"&&e.$ref===void 0&&(t.propertyNames=e.propertyNames);for(let s of Object.keys(e))sb.has(s)||M(t,s,e[s]);return Object.keys(t).length>0&&r.registry.add(o,t),e.description&&(o=o.describe(e.description)),o}function Xm(e,r){if(typeof e=="boolean")return e?k.any():k.never();let o;try{o=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=cb(o,r?.defaultTarget),t=o.$defs||o.definitions||{},n={version:i,defs:t,refs:new Map,processing:new Set,rootSchema:o,registry:r?.registry??G};return ae(o,n)}var Ym=Symbol("z.visit/resolving");function wr(e,r){let o=typeof r=="function"?r:(a,s)=>{let c=r[a._zod.def.type];return c?c(a,s):a},i=new Map;function t(a){let s=i.get(a);if(s===Ym)return new nr({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,Ym);let c=n(a),u=o(c,c!==a);return i.set(a,u),u}function n(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let u=s.shape,l=Object.keys(u),p=!1,d={};for(let y of l){let _=t(u[y]);_!==u[y]&&(p=!0),d[y]=_}let g=s.catchall;return s.catchall&&(g=t(s.catchall),g!==s.catchall&&(p=!0)),p?E(a,{...s,shape:d,catchall:g}):a}case"array":{let u=t(s.element);return u===s.element?a:E(a,{...s,element:u})}case"tuple":{let u=s.items,l=!1,p=[];for(let g of u){let y=t(g);y!==g&&(l=!0),p.push(y)}let d=s.rest;return s.rest&&(d=t(s.rest),d!==s.rest&&(l=!0)),l?E(a,{...s,items:p,rest:d}):a}case"record":case"map":{let u=t(s.keyType),l=t(s.valueType);return u===s.keyType&&l===s.valueType?a:E(a,{...s,keyType:u,valueType:l})}case"set":{let u=t(s.valueType);return u===s.valueType?a:E(a,{...s,valueType:u})}case"union":{let u=s.options,l=!1,p=[];for(let d of u){let g=t(d);g!==d&&(l=!0),p.push(g)}return l?E(a,{...s,options:p}):a}case"intersection":{let u=t(s.left),l=t(s.right);return u===s.left&&l===s.right?a:E(a,{...s,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(s.innerType);return u===s.innerType?a:E(a,{...s,innerType:u})}case"pipe":{let u=t(s.in),l=t(s.out);return u===s.in&&l===s.out?a:E(a,{...s,in:u,out:l})}case"function":{let u=t(s.input),l=t(s.output);return u===s.input&&l===s.output?a:E(a,{...s,input:u,output:l})}case"lazy":{let u=s.getter,{_cachedInner:l,...p}=s;return E(a,{...p,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 Qm(e){return wr(e,{object:r=>r.partial(),union:r=>{let o=r._zod.def;return o.discriminator===void 0?r:Ot(o.options)}})}function fb(e,r){if(!r?.length)return e;let o=e._zod.def;return E(e,me(o,{checks:[...o.checks??[],...r]}),{parent:!0})}function eg(e){return fb(e.out,e.checks)}function mb(e){return e.in._zod.traits.has("$ZodTransform")?eg(e):e.in}function tg(e){return wr(e,{pipe:r=>mb(r._zod.def),default:(r,o)=>o?He(r._zod.def.innerType):r,catch:(r,o)=>o?r._zod.def.innerType:r})}function rg(e){return wr(e,{pipe:r=>eg(r._zod.def),prefault:(r,o)=>o?r._zod.def.innerType:r})}var il={};J(il,{bigint:()=>hb,boolean:()=>vb,date:()=>xb,number:()=>yb,string:()=>gb});function gb(e){return js(Rt,e)}function yb(e){return Ns(zt,e)}function vb(e){return Ms(Ct,e)}function hb(e){return Ks(jt,e)}function xb(e){return rc(vr,e)}var ng=18;var $b=fe.object({composition:fe.unknown().optional().describe("The composition to render. Absent \u21D2 the project's ACTIVE composition \u2014 what create_render will encode. The response's `previewed.source` names what was rendered."),compositionId:fe.string().optional().describe("Preview a SPECIFIC persisted composition of this project (create_render parity). Absent \u21D2 the active one. A stale/foreign id is a 404 \u2014 never a silent fall-through."),session_id:fe.string().optional().describe("Compose-session id: render that session's SCRATCH composition (what the session has been editing) instead of the active row. Ignored when `composition` is passed."),timestamps:fe.array(fe.number()).min(1).max(ng).describe(`Composition seconds to capture, ${ng} per request. The batch renders as ONE unit of work \u2014 one warm container, one source decode, N seeks \u2014 and that unit has a fixed time budget, so a larger batch is refused here rather than accepted and timed out minutes later. For a denser sweep, split it across calls; identical beats are served from the still cache, so overlapping batches are cheap.`),imageFormat:fe.enum(["png","jpeg"]).optional().describe("Still format. Default jpeg \u2014 these pixels go to a vision model, where jpeg is equivalent and png costs multiples in bytes to store and move. Pass png only when you need full fidelity."),scale:fe.number().min(.1).max(1).optional().describe("Render scale 0.1\u20131. Default 0.5, which is what this schema has always recommended for vision-bound looks. Pass 1 when judging fine detail \u2014 it costs ~4x the vision tokens."),jpegQuality:fe.number().int().min(1).max(100).optional().describe("JPEG quality (jpeg only). Default 70 \u2014 the quality the eval panel grades at.")}).strict(),F1=$b.pick({timestamps:!0,imageFormat:!0,scale:!0,jpegQuality:!0}).strict(),Eo="X-CueFrame-Client";var bb=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,31}$/,_b=["web","console","clips"];function kb(e,r){return _b.includes(e)===(r==="browser")}function og(e){if(!bb.test(e.version))throw new Error(`${Eo} cannot carry the version ${JSON.stringify(e.version)}.`);if(!kb(e.surface,e.os))throw new Error(`${Eo} cannot carry ${e.surface} on ${e.os}.`);return`${e.surface}/${e.version}/${e.os}`}function ig(e){return e==="darwin"?"macos":e==="win32"?"windows":e==="linux"?"linux":"unknown"}import{readFileSync as Sb,writeFileSync as Ib,mkdirSync as wb,existsSync as Rb}from"fs";import{join as ag}from"path";import{homedir as Pb}from"os";var H={Success:0,UserError:2,ApiClientError:3,ApiServerError:4,NetworkError:5,PaymentRequired:6};function al(e){if(e instanceof le){if(e.status===402)return H.PaymentRequired;if(e.status>=500)return H.ApiServerError;if(e.status>=400)return H.ApiClientError}let r=e?.exitCode;return typeof r=="number"?r:H.NetworkError}function K1(e){return e===402?H.PaymentRequired:e>=500?H.ApiServerError:e>=400?H.ApiClientError:H.Success}function Rr(e){process.exit(e)}var sg=ag(Pb(),".cueframe"),Uo=ag(sg,"auth.json"),Et={local:"http://127.0.0.1:3211",dev:"https://api-dev.cueframe.ai",prod:"https://api.cueframe.ai"},zb="prod";function X1(e=zb){return process.env.CUEFRAME_API_URL??Et[e]??Et.prod}var Pr=class extends Error{constructor(o,i){super(i);this.code=o;this.name="AuthStoreError"}code;exitCode=H.UserError};function Y1(e){if(!/^cf_(?:live|test)_[A-Za-z0-9_-]{8,}$/.test(e))throw new Pr("auth_invalid","Invalid API key. Expected a key beginning with cf_live_ or cf_test_.")}function cg(){if(!Rb(Uo))return{targets:{}};let e=Sb(Uo,"utf-8");try{return JSON.parse(e)}catch{throw new Pr("auth_config_corrupt",`${Uo} is corrupt and cannot be parsed. Delete it and re-run \`cueframe login\`.`)}}function Cb(e){wb(sg,{recursive:!0,mode:448}),Ib(Uo,JSON.stringify(e,null,2),{mode:384})}function Q1(e,r="prod",o){let i=cg(),t=Et[r]??Et.prod;i.targets[r]={apiKey:e,apiUrl:o??t},Cb(i)}function ug(e="prod"){let r=process.env.CUEFRAME_API_KEY,o=process.env.CUEFRAME_API_URL;if(r)return{apiKey:r,apiUrl:o??Et[e]??Et.prod};let t=cg().targets[e];if(!t)throw new Pr("auth_missing",`No auth configured for target "${e}". Run \`cueframe login --target ${e}\` (browser sign-in) or \`cueframe auth <api-key> --target ${e}\` (CI / headless).`);return t}function jb(){return{[Eo]:og({surface:"cli",version:"0.4.9",os:ig(process.platform)})}}function lg(e){let{apiKey:r,apiUrl:o}=ug(e);Ao({baseUrl:o,apiKey:r,headers:jb()})}function No(e){let r=e instanceof le?`${e.message} (${e.code}${e.status?`, ${e.status}`:""})`:e instanceof Error?e.message:String(e),o=qo(e);return o?`${r}
|
|
65
65
|
\u2192 ${o}`:r}import Ob from"ora";import Tb from"pino";var Eb="v1",pg=Tb({level:"trace",base:{schemaVersion:Eb},messageKey:"event",timestamp:()=>`,"ts":${Date.now()}`,formatters:{level:()=>({_:0})}});function sl(e,r){return Ob({text:e,isSilent:!!r}).start()}function Ut(e,r,o={}){e.json&&pg.info(o,r)}function c0(e,r,o){if(e.json){console.log(JSON.stringify(r,null,2));return}o()}function cl(e,r,o,i){let t=o instanceof Error?o.message:String(o),n=typeof o?.code=="string"?o.code:void 0,a=o?.status;e.json?pg.info({phase:r,message:t,...n?{code:n}:{},...typeof a=="number"?{status:a}:{},exitCode:i},"error"):process.stderr.write(`\u2716 ${r}: ${No(o)}
|
|
66
66
|
`)}function ul(e,r,o,i){e.json&&cl(e,r,o,i)}function u0(e,r){r.json||console.log(e)}function Ub(e){for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o<=31||o===127)return!0}return!1}function fg(e,r,o){e.length===0&&dg(`${r} is empty.`,o),Ub(e)&&dg(`${r} contains a control character (newline, tab, or null byte). Identifiers must be plain text \u2014 check for a stray copy-paste artifact.`,o)}function dg(e,r){cl(r,"preflight",new Error(e),H.UserError),Rr(H.UserError)}var Nb=5e3,ll=300*1e3;async function x0(e,r){if(fg(e,"mediaItemId",r),r.dryRun){Ut(r,"analyze_dry_run",{mediaItemId:e,target:r.target,wait:!!r.wait,wouldCall:"POST /v1/media/:id/suggestions"}),r.json||console.log(`[dry-run] Would trigger clip analysis for ${e} on ${r.target}.`);return}lg(r.target),Ut(r,"analyze_prepare",{mediaItemId:e,target:r.target,wait:!!r.wait});let o=sl("Triggering clip analysis\u2026",r.json),i;try{i=await At.suggestBriefs(e),o.succeed(`Analysis ${i.alreadyRunning?"already running":"started"}`)}catch(a){o.fail(`Failed to start analysis: ${No(a)}`),ul(r,"analyze_prepare",a,al(a)),Rr(al(a))}if(Ut(r,"analyze_ready",{mediaItemId:e,status:i.status,alreadyRunning:!!i.alreadyRunning}),!r.wait){r.json||console.log(`
|
|
67
67
|
Run \`cueframe clips ${e}\` to check results.`);return}let t=sl("Waiting for analysis to complete\u2026",r.json),n=Date.now();for(;;){await new Promise(a=>setTimeout(a,Nb)),Date.now()-n>ll&&(t.fail(`Timed out after ${Math.round(ll/1e3)}s. Run \`cueframe clips ${e}\` to check later.`),ul(r,"analyze_progress",new Error(`Analysis did not complete within ${Math.round(ll/1e3)}s`),H.UserError),Rr(H.UserError));try{let a=await At.listMediaSuggestions(e);if(a.suggestions.length>0){t.succeed(`Analysis complete \u2014 ${a.suggestions.length} clips found`),Ut(r,"analyze_complete",{mediaItemId:e,durationMs:Date.now()-n,suggestionCount:a.suggestions.length,suggestions:a.suggestions}),r.json||a.suggestions.forEach((c,u)=>{let l=(c.trim.end-c.trim.start).toFixed(1);console.log(`
|