interface-forge
Version:
A TypeScript library for creating strongly typed mock data factories using Faker.js for test data generation
1,659 lines (1,653 loc) • 130 kB
JavaScript
import { A as e, D as t, M as n, N as r, O as i, P as a, S as o, _ as s, g as c, i as l, j as u, k as d, n as f, r as p, t as ee, v as te, x as ne, y as re } from "./src-B0CxBMVJ.mjs";
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
var ie;
function m(e, t, n) {
function r(n, r) {
if (n._zod || Object.defineProperty(n, "_zod", {
value: {
def: r,
constr: o,
traits: /* @__PURE__ */ new Set()
},
enumerable: !1
}), n._zod.traits.has(e)) return;
n._zod.traits.add(e), t(n, r);
let i = o.prototype, a = Object.keys(i);
for (let e = 0; e < a.length; e++) {
let t = a[e];
t in n || (n[t] = i[t].bind(n));
}
}
let i = n?.Parent ?? Object;
class a extends i {}
Object.defineProperty(a, "name", { value: e });
function o(e) {
var t;
let i = n?.Parent ? new a() : this;
r(i, e), (t = i._zod).deferred ?? (t.deferred = []);
for (let e of i._zod.deferred) e();
return i;
}
return Object.defineProperty(o, "init", { value: r }), Object.defineProperty(o, Symbol.hasInstance, { value: (t) => n?.Parent && t instanceof n.Parent ? !0 : t?._zod?.traits?.has(e) }), Object.defineProperty(o, "name", { value: e }), o;
}
var h = class extends Error {
constructor() {
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
}
}, ae = class extends Error {
constructor(e) {
super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
}
};
(ie = globalThis).__zod_globalConfig ?? (ie.__zod_globalConfig = {});
var g = globalThis.__zod_globalConfig;
function _(e) {
return e && Object.assign(g, e), g;
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
function oe(e) {
let t = Object.values(e).filter((e) => typeof e == "number");
return Object.entries(e).filter(([e, n]) => t.indexOf(+e) === -1).map(([e, t]) => t);
}
function se(e, t) {
return typeof t == "bigint" ? t.toString() : t;
}
function v(e) {
return { get value() {
{
let t = e();
return Object.defineProperty(this, "value", { value: t }), t;
}
throw Error("cached value already set");
} };
}
function y(e) {
return e == null;
}
function ce(e) {
let t = +!!e.startsWith("^"), n = e.endsWith("$") ? e.length - 1 : e.length;
return e.slice(t, n);
}
function le(e, t) {
let n = e / t, r = Math.round(n), i = 2 ** -52 * Math.max(Math.abs(n), 1);
return Math.abs(n - r) < i ? 0 : n - r;
}
var ue = /* @__PURE__ */ Symbol("evaluating");
function b(e, t, n) {
let r;
Object.defineProperty(e, t, {
get() {
if (r !== ue) return r === void 0 && (r = ue, r = n()), r;
},
set(n) {
Object.defineProperty(e, t, { value: n });
},
configurable: !0
});
}
function x(e, t, n) {
Object.defineProperty(e, t, {
value: n,
writable: !0,
enumerable: !0,
configurable: !0
});
}
function S(...e) {
let t = {};
for (let n of e) Object.assign(t, Object.getOwnPropertyDescriptors(n));
return Object.defineProperties({}, t);
}
function de(e) {
return JSON.stringify(e);
}
function fe(e) {
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
var pe = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {};
function C(e) {
return typeof e == "object" && !!e && !Array.isArray(e);
}
var me = /* @__PURE__ */ v(() => {
if (g.jitless || typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare")) return !1;
try {
return Function(""), !0;
} catch {
return !1;
}
});
function w(e) {
if (C(e) === !1) return !1;
let t = e.constructor;
if (t === void 0 || typeof t != "function") return !0;
let n = t.prototype;
return !(C(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
}
function he(e) {
return w(e) ? { ...e } : Array.isArray(e) ? [...e] : e instanceof Map ? new Map(e) : e instanceof Set ? new Set(e) : e;
}
var ge = /* @__PURE__ */ new Set([
"string",
"number",
"symbol"
]);
function T(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function E(e, t, n) {
let r = new e._zod.constr(t ?? e._zod.def);
return (!t || n?.parent) && (r._zod.parent = e), r;
}
function D(e) {
let t = e;
if (!t) return {};
if (typeof t == "string") return { error: () => t };
if (t?.message !== void 0) {
if (t?.error !== void 0) throw Error("Cannot specify both `message` and `error` params");
t.error = t.message;
}
return delete t.message, typeof t.error == "string" ? {
...t,
error: () => t.error
} : t;
}
function _e(e) {
return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
}
var ve = {
safeint: [-(2 ** 53 - 1), 2 ** 53 - 1],
int32: [-2147483648, 2147483647],
uint32: [0, 4294967295],
float32: [-34028234663852886e22, 34028234663852886e22],
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
};
function ye(e, t) {
let n = e._zod.def, r = n.checks;
if (r && r.length > 0) throw Error(".pick() cannot be used on object schemas containing refinements");
return E(e, S(e._zod.def, {
get shape() {
let e = {};
for (let r in t) {
if (!(r in n.shape)) throw Error(`Unrecognized key: "${r}"`);
t[r] && (e[r] = n.shape[r]);
}
return x(this, "shape", e), e;
},
checks: []
}));
}
function be(e, t) {
let n = e._zod.def, r = n.checks;
if (r && r.length > 0) throw Error(".omit() cannot be used on object schemas containing refinements");
return E(e, S(e._zod.def, {
get shape() {
let r = { ...e._zod.def.shape };
for (let e in t) {
if (!(e in n.shape)) throw Error(`Unrecognized key: "${e}"`);
t[e] && delete r[e];
}
return x(this, "shape", r), r;
},
checks: []
}));
}
function xe(e, t) {
if (!w(t)) throw Error("Invalid input to extend: expected a plain object");
let n = e._zod.def.checks;
if (n && n.length > 0) {
let n = e._zod.def.shape;
for (let e in t) if (Object.getOwnPropertyDescriptor(n, e) !== void 0) throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
}
return E(e, S(e._zod.def, { get shape() {
let n = {
...e._zod.def.shape,
...t
};
return x(this, "shape", n), n;
} }));
}
function Se(e, t) {
if (!w(t)) throw Error("Invalid input to safeExtend: expected a plain object");
return E(e, S(e._zod.def, { get shape() {
let n = {
...e._zod.def.shape,
...t
};
return x(this, "shape", n), n;
} }));
}
function Ce(e, t) {
if (e._zod.def.checks?.length) throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
return E(e, S(e._zod.def, {
get shape() {
let n = {
...e._zod.def.shape,
...t._zod.def.shape
};
return x(this, "shape", n), n;
},
get catchall() {
return t._zod.def.catchall;
},
checks: t._zod.def.checks ?? []
}));
}
function we(e, t, n) {
let r = t._zod.def.checks;
if (r && r.length > 0) throw Error(".partial() cannot be used on object schemas containing refinements");
return E(t, S(t._zod.def, {
get shape() {
let r = t._zod.def.shape, i = { ...r };
if (n) for (let t in n) {
if (!(t in r)) throw Error(`Unrecognized key: "${t}"`);
n[t] && (i[t] = e ? new e({
type: "optional",
innerType: r[t]
}) : r[t]);
}
else for (let t in r) i[t] = e ? new e({
type: "optional",
innerType: r[t]
}) : r[t];
return x(this, "shape", i), i;
},
checks: []
}));
}
function Te(e, t, n) {
return E(t, S(t._zod.def, { get shape() {
let r = t._zod.def.shape, i = { ...r };
if (n) for (let t in n) {
if (!(t in i)) throw Error(`Unrecognized key: "${t}"`);
n[t] && (i[t] = new e({
type: "nonoptional",
innerType: r[t]
}));
}
else for (let t in r) i[t] = new e({
type: "nonoptional",
innerType: r[t]
});
return x(this, "shape", i), i;
} }));
}
function O(e, t = 0) {
if (e.aborted === !0) return !0;
for (let n = t; n < e.issues.length; n++) if (e.issues[n]?.continue !== !0) return !0;
return !1;
}
function Ee(e, t = 0) {
if (e.aborted === !0) return !0;
for (let n = t; n < e.issues.length; n++) if (e.issues[n]?.continue === !1) return !0;
return !1;
}
function k(e, t) {
return t.map((t) => {
var n;
return (n = t).path ?? (n.path = []), t.path.unshift(e), t;
});
}
function De(e) {
return typeof e == "string" ? e : e?.message;
}
function A(e, t, n) {
let r = e.message ? e.message : De(e.inst?._zod.def?.error?.(e)) ?? De(t?.error?.(e)) ?? De(n.customError?.(e)) ?? De(n.localeError?.(e)) ?? "Invalid input", { inst: i, continue: a, input: o, ...s } = e;
return s.path ?? (s.path = []), s.message = r, t?.reportInput && (s.input = o), s;
}
function Oe(e) {
return e instanceof Set ? "set" : e instanceof Map ? "map" : e instanceof File ? "file" : "unknown";
}
function ke(e) {
return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
}
function j(...e) {
let [t, n, r] = e;
return typeof t == "string" ? {
message: t,
code: "custom",
input: n,
inst: r
} : { ...t };
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
var Ae = (e, t) => {
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
value: e._zod,
enumerable: !1
}), Object.defineProperty(e, "issues", {
value: t,
enumerable: !1
}), e.message = JSON.stringify(t, se, 2), Object.defineProperty(e, "toString", {
value: () => e.message,
enumerable: !1
});
}, je = m("$ZodError", Ae), Me = m("$ZodError", Ae, { Parent: Error });
function Ne(e, t = (e) => e.message) {
let n = {}, r = [];
for (let i of e.issues) i.path.length > 0 ? (n[i.path[0]] = n[i.path[0]] || [], n[i.path[0]].push(t(i))) : r.push(t(i));
return {
formErrors: r,
fieldErrors: n
};
}
function Pe(e, t = (e) => e.message) {
let n = { _errors: [] }, r = (e, i = []) => {
for (let a of e.issues) if (a.code === "invalid_union" && a.errors.length) a.errors.map((e) => r({ issues: e }, [...i, ...a.path]));
else if (a.code === "invalid_key") r({ issues: a.issues }, [...i, ...a.path]);
else if (a.code === "invalid_element") r({ issues: a.issues }, [...i, ...a.path]);
else {
let e = [...i, ...a.path];
if (e.length === 0) n._errors.push(t(a));
else {
let r = n, i = 0;
for (; i < e.length;) {
let n = e[i];
i === e.length - 1 ? (r[n] = r[n] || { _errors: [] }, r[n]._errors.push(t(a))) : r[n] = r[n] || { _errors: [] }, r = r[n], i++;
}
}
}
};
return r(e), n;
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
var Fe = (e) => (t, n, r, i) => {
let a = r ? {
...r,
async: !1
} : { async: !1 }, o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise) throw new h();
if (o.issues.length) {
let t = new (i?.Err ?? e)(o.issues.map((e) => A(e, a, _())));
throw pe(t, i?.callee), t;
}
return o.value;
}, Ie = (e) => async (t, n, r, i) => {
let a = r ? {
...r,
async: !0
} : { async: !0 }, o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise && (o = await o), o.issues.length) {
let t = new (i?.Err ?? e)(o.issues.map((e) => A(e, a, _())));
throw pe(t, i?.callee), t;
}
return o.value;
}, M = (e) => (t, n, r) => {
let i = r ? {
...r,
async: !1
} : { async: !1 }, a = t._zod.run({
value: n,
issues: []
}, i);
if (a instanceof Promise) throw new h();
return a.issues.length ? {
success: !1,
error: new (e ?? je)(a.issues.map((e) => A(e, i, _())))
} : {
success: !0,
data: a.value
};
}, Le = /* @__PURE__ */ M(Me), N = (e) => async (t, n, r) => {
let i = r ? {
...r,
async: !0
} : { async: !0 }, a = t._zod.run({
value: n,
issues: []
}, i);
return a instanceof Promise && (a = await a), a.issues.length ? {
success: !1,
error: new e(a.issues.map((e) => A(e, i, _())))
} : {
success: !0,
data: a.value
};
}, Re = /* @__PURE__ */ N(Me), ze = (e) => (t, n, r) => {
let i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return Fe(e)(t, n, i);
}, Be = (e) => (t, n, r) => Fe(e)(t, n, r), Ve = (e) => async (t, n, r) => {
let i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return Ie(e)(t, n, i);
}, He = (e) => async (t, n, r) => Ie(e)(t, n, r), Ue = (e) => (t, n, r) => {
let i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return M(e)(t, n, i);
}, We = (e) => (t, n, r) => M(e)(t, n, r), Ge = (e) => async (t, n, r) => {
let i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return N(e)(t, n, i);
}, Ke = (e) => async (t, n, r) => N(e)(t, n, r), qe = /^[cC][0-9a-z]{6,}$/, Je = /^[0-9a-z]+$/, Ye = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Xe = /^[0-9a-vA-V]{20}$/, Ze = /^[A-Za-z0-9]{27}$/, Qe = /^[a-zA-Z0-9_-]{21}$/, $e = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, et = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, tt = (e) => e ? RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, nt = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, rt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
function it() {
return new RegExp(rt, "u");
}
var at = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ot = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/, st = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, ct = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, lt = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, ut = /^[A-Za-z0-9_-]*$/, dt = /^https?$/, ft = /^\+[1-9]\d{6,14}$/, pt = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", mt = /* @__PURE__ */ RegExp(`^${pt}$`);
function ht(e) {
let t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
return typeof e.precision == "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
}
function gt(e) {
return RegExp(`^${ht(e)}$`);
}
function _t(e) {
let t = ht({ precision: e.precision }), n = ["Z"];
e.local && n.push(""), e.offset && n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
let r = `${t}(?:${n.join("|")})`;
return RegExp(`^${pt}T(?:${r})$`);
}
var vt = (e) => {
let t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
return RegExp(`^${t}$`);
}, yt = /^-?\d+$/, bt = /^-?\d+(?:\.\d+)?$/, xt = /^(?:true|false)$/i, St = /^null$/i, Ct = /^undefined$/i, wt = /^[^A-Z]*$/, Tt = /^[^a-z]*$/, P = /* @__PURE__ */ m("$ZodCheck", (e, t) => {
var n;
e._zod ?? (e._zod = {}), e._zod.def = t, (n = e._zod).onattach ?? (n.onattach = []);
}), Et = {
number: "number",
bigint: "bigint",
object: "date"
}, Dt = /* @__PURE__ */ m("$ZodCheckLessThan", (e, t) => {
P.init(e, t);
let n = Et[typeof t.value];
e._zod.onattach.push((e) => {
let n = e._zod.bag, r = (t.inclusive ? n.maximum : n.exclusiveMaximum) ?? Infinity;
t.value < r && (t.inclusive ? n.maximum = t.value : n.exclusiveMaximum = t.value);
}), e._zod.check = (r) => {
(t.inclusive ? r.value <= t.value : r.value < t.value) || r.issues.push({
origin: n,
code: "too_big",
maximum: typeof t.value == "object" ? t.value.getTime() : t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
}), Ot = /* @__PURE__ */ m("$ZodCheckGreaterThan", (e, t) => {
P.init(e, t);
let n = Et[typeof t.value];
e._zod.onattach.push((e) => {
let n = e._zod.bag, r = (t.inclusive ? n.minimum : n.exclusiveMinimum) ?? -Infinity;
t.value > r && (t.inclusive ? n.minimum = t.value : n.exclusiveMinimum = t.value);
}), e._zod.check = (r) => {
(t.inclusive ? r.value >= t.value : r.value > t.value) || r.issues.push({
origin: n,
code: "too_small",
minimum: typeof t.value == "object" ? t.value.getTime() : t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
}), kt = /* @__PURE__ */ m("$ZodCheckMultipleOf", (e, t) => {
P.init(e, t), e._zod.onattach.push((e) => {
var n;
(n = e._zod.bag).multipleOf ?? (n.multipleOf = t.value);
}), e._zod.check = (n) => {
if (typeof n.value != typeof t.value) throw Error("Cannot mix number and bigint in multiple_of check.");
(typeof n.value == "bigint" ? n.value % t.value === BigInt(0) : le(n.value, t.value) === 0) || n.issues.push({
origin: typeof n.value,
code: "not_multiple_of",
divisor: t.value,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), At = /* @__PURE__ */ m("$ZodCheckNumberFormat", (e, t) => {
P.init(e, t), t.format = t.format || "float64";
let n = t.format?.includes("int"), r = n ? "int" : "number", [i, a] = ve[t.format];
e._zod.onattach.push((e) => {
let r = e._zod.bag;
r.format = t.format, r.minimum = i, r.maximum = a, n && (r.pattern = yt);
}), e._zod.check = (o) => {
let s = o.value;
if (n) {
if (!Number.isInteger(s)) {
o.issues.push({
expected: r,
format: t.format,
code: "invalid_type",
continue: !1,
input: s,
inst: e
});
return;
}
if (!Number.isSafeInteger(s)) {
s > 0 ? o.issues.push({
input: s,
code: "too_big",
maximum: 2 ** 53 - 1,
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
inclusive: !0,
continue: !t.abort
}) : o.issues.push({
input: s,
code: "too_small",
minimum: -(2 ** 53 - 1),
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
inclusive: !0,
continue: !t.abort
});
return;
}
}
s < i && o.issues.push({
origin: "number",
input: s,
code: "too_small",
minimum: i,
inclusive: !0,
inst: e,
continue: !t.abort
}), s > a && o.issues.push({
origin: "number",
input: s,
code: "too_big",
maximum: a,
inclusive: !0,
inst: e,
continue: !t.abort
});
};
}), jt = /* @__PURE__ */ m("$ZodCheckMaxSize", (e, t) => {
var n;
P.init(e, t), (n = e._zod.def).when ?? (n.when = (e) => {
let t = e.value;
return !y(t) && t.size !== void 0;
}), e._zod.onattach.push((e) => {
let n = e._zod.bag.maximum ?? Infinity;
t.maximum < n && (e._zod.bag.maximum = t.maximum);
}), e._zod.check = (n) => {
let r = n.value;
r.size <= t.maximum || n.issues.push({
origin: Oe(r),
code: "too_big",
maximum: t.maximum,
inclusive: !0,
input: r,
inst: e,
continue: !t.abort
});
};
}), Mt = /* @__PURE__ */ m("$ZodCheckMinSize", (e, t) => {
var n;
P.init(e, t), (n = e._zod.def).when ?? (n.when = (e) => {
let t = e.value;
return !y(t) && t.size !== void 0;
}), e._zod.onattach.push((e) => {
let n = e._zod.bag.minimum ?? -Infinity;
t.minimum > n && (e._zod.bag.minimum = t.minimum);
}), e._zod.check = (n) => {
let r = n.value;
r.size >= t.minimum || n.issues.push({
origin: Oe(r),
code: "too_small",
minimum: t.minimum,
inclusive: !0,
input: r,
inst: e,
continue: !t.abort
});
};
}), Nt = /* @__PURE__ */ m("$ZodCheckSizeEquals", (e, t) => {
var n;
P.init(e, t), (n = e._zod.def).when ?? (n.when = (e) => {
let t = e.value;
return !y(t) && t.size !== void 0;
}), e._zod.onattach.push((e) => {
let n = e._zod.bag;
n.minimum = t.size, n.maximum = t.size, n.size = t.size;
}), e._zod.check = (n) => {
let r = n.value, i = r.size;
if (i === t.size) return;
let a = i > t.size;
n.issues.push({
origin: Oe(r),
...a ? {
code: "too_big",
maximum: t.size
} : {
code: "too_small",
minimum: t.size
},
inclusive: !0,
exact: !0,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), Pt = /* @__PURE__ */ m("$ZodCheckMaxLength", (e, t) => {
var n;
P.init(e, t), (n = e._zod.def).when ?? (n.when = (e) => {
let t = e.value;
return !y(t) && t.length !== void 0;
}), e._zod.onattach.push((e) => {
let n = e._zod.bag.maximum ?? Infinity;
t.maximum < n && (e._zod.bag.maximum = t.maximum);
}), e._zod.check = (n) => {
let r = n.value;
if (r.length <= t.maximum) return;
let i = ke(r);
n.issues.push({
origin: i,
code: "too_big",
maximum: t.maximum,
inclusive: !0,
input: r,
inst: e,
continue: !t.abort
});
};
}), Ft = /* @__PURE__ */ m("$ZodCheckMinLength", (e, t) => {
var n;
P.init(e, t), (n = e._zod.def).when ?? (n.when = (e) => {
let t = e.value;
return !y(t) && t.length !== void 0;
}), e._zod.onattach.push((e) => {
let n = e._zod.bag.minimum ?? -Infinity;
t.minimum > n && (e._zod.bag.minimum = t.minimum);
}), e._zod.check = (n) => {
let r = n.value;
if (r.length >= t.minimum) return;
let i = ke(r);
n.issues.push({
origin: i,
code: "too_small",
minimum: t.minimum,
inclusive: !0,
input: r,
inst: e,
continue: !t.abort
});
};
}), It = /* @__PURE__ */ m("$ZodCheckLengthEquals", (e, t) => {
var n;
P.init(e, t), (n = e._zod.def).when ?? (n.when = (e) => {
let t = e.value;
return !y(t) && t.length !== void 0;
}), e._zod.onattach.push((e) => {
let n = e._zod.bag;
n.minimum = t.length, n.maximum = t.length, n.length = t.length;
}), e._zod.check = (n) => {
let r = n.value, i = r.length;
if (i === t.length) return;
let a = ke(r), o = i > t.length;
n.issues.push({
origin: a,
...o ? {
code: "too_big",
maximum: t.length
} : {
code: "too_small",
minimum: t.length
},
inclusive: !0,
exact: !0,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), F = /* @__PURE__ */ m("$ZodCheckStringFormat", (e, t) => {
var n, r;
P.init(e, t), e._zod.onattach.push((e) => {
let n = e._zod.bag;
n.format = t.format, t.pattern && (n.patterns ?? (n.patterns = /* @__PURE__ */ new Set()), n.patterns.add(t.pattern));
}), t.pattern ? (n = e._zod).check ?? (n.check = (n) => {
t.pattern.lastIndex = 0, !t.pattern.test(n.value) && n.issues.push({
origin: "string",
code: "invalid_format",
format: t.format,
input: n.value,
...t.pattern ? { pattern: t.pattern.toString() } : {},
inst: e,
continue: !t.abort
});
}) : (r = e._zod).check ?? (r.check = () => {});
}), Lt = /* @__PURE__ */ m("$ZodCheckRegex", (e, t) => {
F.init(e, t), e._zod.check = (n) => {
t.pattern.lastIndex = 0, !t.pattern.test(n.value) && n.issues.push({
origin: "string",
code: "invalid_format",
format: "regex",
input: n.value,
pattern: t.pattern.toString(),
inst: e,
continue: !t.abort
});
};
}), Rt = /* @__PURE__ */ m("$ZodCheckLowerCase", (e, t) => {
t.pattern ?? (t.pattern = wt), F.init(e, t);
}), zt = /* @__PURE__ */ m("$ZodCheckUpperCase", (e, t) => {
t.pattern ?? (t.pattern = Tt), F.init(e, t);
}), Bt = /* @__PURE__ */ m("$ZodCheckIncludes", (e, t) => {
P.init(e, t);
let n = T(t.includes), r = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${n}` : n);
t.pattern = r, e._zod.onattach.push((e) => {
let t = e._zod.bag;
t.patterns ?? (t.patterns = /* @__PURE__ */ new Set()), t.patterns.add(r);
}), e._zod.check = (n) => {
n.value.includes(t.includes, t.position) || n.issues.push({
origin: "string",
code: "invalid_format",
format: "includes",
includes: t.includes,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), Vt = /* @__PURE__ */ m("$ZodCheckStartsWith", (e, t) => {
P.init(e, t);
let n = RegExp(`^${T(t.prefix)}.*`);
t.pattern ?? (t.pattern = n), e._zod.onattach.push((e) => {
let t = e._zod.bag;
t.patterns ?? (t.patterns = /* @__PURE__ */ new Set()), t.patterns.add(n);
}), e._zod.check = (n) => {
n.value.startsWith(t.prefix) || n.issues.push({
origin: "string",
code: "invalid_format",
format: "starts_with",
prefix: t.prefix,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), Ht = /* @__PURE__ */ m("$ZodCheckEndsWith", (e, t) => {
P.init(e, t);
let n = RegExp(`.*${T(t.suffix)}$`);
t.pattern ?? (t.pattern = n), e._zod.onattach.push((e) => {
let t = e._zod.bag;
t.patterns ?? (t.patterns = /* @__PURE__ */ new Set()), t.patterns.add(n);
}), e._zod.check = (n) => {
n.value.endsWith(t.suffix) || n.issues.push({
origin: "string",
code: "invalid_format",
format: "ends_with",
suffix: t.suffix,
input: n.value,
inst: e,
continue: !t.abort
});
};
}), Ut = /* @__PURE__ */ m("$ZodCheckOverwrite", (e, t) => {
P.init(e, t), e._zod.check = (e) => {
e.value = t.tx(e.value);
};
}), Wt = class {
constructor(e = []) {
this.content = [], this.indent = 0, this && (this.args = e);
}
indented(e) {
this.indent += 1, e(this), --this.indent;
}
write(e) {
if (typeof e == "function") {
e(this, { execution: "sync" }), e(this, { execution: "async" });
return;
}
let t = e.split("\n").filter((e) => e), n = Math.min(...t.map((e) => e.length - e.trimStart().length)), r = t.map((e) => e.slice(n)).map((e) => " ".repeat(this.indent * 2) + e);
for (let e of r) this.content.push(e);
}
compile() {
let e = Function, t = this?.args, n = [...(this?.content ?? [""]).map((e) => ` ${e}`)];
return new e(...t, n.join("\n"));
}
}, Gt = {
major: 4,
minor: 4,
patch: 3
}, I = /* @__PURE__ */ m("$ZodType", (e, t) => {
var n;
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = Gt;
let r = [...e._zod.def.checks ?? []];
e._zod.traits.has("$ZodCheck") && r.unshift(e);
for (let t of r) for (let n of t._zod.onattach) n(e);
if (r.length === 0) (n = e._zod).deferred ?? (n.deferred = []), e._zod.deferred?.push(() => {
e._zod.run = e._zod.parse;
});
else {
let t = (e, t, n) => {
let r = O(e), i;
for (let a of t) {
if (a._zod.def.when) {
if (Ee(e) || !a._zod.def.when(e)) continue;
} else if (r) continue;
let t = e.issues.length, o = a._zod.check(e);
if (o instanceof Promise && n?.async === !1) throw new h();
if (i || o instanceof Promise) i = (i ?? Promise.resolve()).then(async () => {
await o, e.issues.length !== t && (r || (r = O(e, t)));
});
else {
if (e.issues.length === t) continue;
r || (r = O(e, t));
}
}
return i ? i.then(() => e) : e;
}, n = (n, i, a) => {
if (O(n)) return n.aborted = !0, n;
let o = t(i, r, a);
if (o instanceof Promise) {
if (a.async === !1) throw new h();
return o.then((t) => e._zod.parse(t, a));
}
return e._zod.parse(o, a);
};
e._zod.run = (i, a) => {
if (a.skipChecks) return e._zod.parse(i, a);
if (a.direction === "backward") {
let t = e._zod.parse({
value: i.value,
issues: []
}, {
...a,
skipChecks: !0
});
return t instanceof Promise ? t.then((e) => n(e, i, a)) : n(t, i, a);
}
let o = e._zod.parse(i, a);
if (o instanceof Promise) {
if (a.async === !1) throw new h();
return o.then((e) => t(e, r, a));
}
return t(o, r, a);
};
}
b(e, "~standard", () => ({
validate: (t) => {
try {
let n = Le(e, t);
return n.success ? { value: n.data } : { issues: n.error?.issues };
} catch {
return Re(e, t).then((e) => e.success ? { value: e.data } : { issues: e.error?.issues });
}
},
vendor: "zod",
version: 1
}));
}), Kt = /* @__PURE__ */ m("$ZodString", (e, t) => {
I.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? vt(e._zod.bag), e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = String(n.value);
} catch {}
return typeof n.value == "string" || n.issues.push({
expected: "string",
code: "invalid_type",
input: n.value,
inst: e
}), n;
};
}), L = /* @__PURE__ */ m("$ZodStringFormat", (e, t) => {
F.init(e, t), Kt.init(e, t);
}), qt = /* @__PURE__ */ m("$ZodGUID", (e, t) => {
t.pattern ?? (t.pattern = et), L.init(e, t);
}), Jt = /* @__PURE__ */ m("$ZodUUID", (e, t) => {
if (t.version) {
let e = {
v1: 1,
v2: 2,
v3: 3,
v4: 4,
v5: 5,
v6: 6,
v7: 7,
v8: 8
}[t.version];
if (e === void 0) throw Error(`Invalid UUID version: "${t.version}"`);
t.pattern ?? (t.pattern = tt(e));
} else t.pattern ?? (t.pattern = tt());
L.init(e, t);
}), Yt = /* @__PURE__ */ m("$ZodEmail", (e, t) => {
t.pattern ?? (t.pattern = nt), L.init(e, t);
}), Xt = /* @__PURE__ */ m("$ZodURL", (e, t) => {
L.init(e, t), e._zod.check = (n) => {
try {
let r = n.value.trim();
if (!t.normalize && t.protocol?.source === dt.source && !/^https?:\/\//i.test(r)) {
n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid URL format",
input: n.value,
inst: e,
continue: !t.abort
});
return;
}
let i = new URL(r);
t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(i.hostname) || n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: t.hostname.source,
input: n.value,
inst: e,
continue: !t.abort
})), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(i.protocol.endsWith(":") ? i.protocol.slice(0, -1) : i.protocol) || n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid protocol",
pattern: t.protocol.source,
input: n.value,
inst: e,
continue: !t.abort
})), t.normalize ? n.value = i.href : n.value = r;
return;
} catch {
n.issues.push({
code: "invalid_format",
format: "url",
input: n.value,
inst: e,
continue: !t.abort
});
}
};
}), Zt = /* @__PURE__ */ m("$ZodEmoji", (e, t) => {
t.pattern ?? (t.pattern = it()), L.init(e, t);
}), Qt = /* @__PURE__ */ m("$ZodNanoID", (e, t) => {
t.pattern ?? (t.pattern = Qe), L.init(e, t);
}), $t = /* @__PURE__ */ m("$ZodCUID", (e, t) => {
t.pattern ?? (t.pattern = qe), L.init(e, t);
}), en = /* @__PURE__ */ m("$ZodCUID2", (e, t) => {
t.pattern ?? (t.pattern = Je), L.init(e, t);
}), tn = /* @__PURE__ */ m("$ZodULID", (e, t) => {
t.pattern ?? (t.pattern = Ye), L.init(e, t);
}), nn = /* @__PURE__ */ m("$ZodXID", (e, t) => {
t.pattern ?? (t.pattern = Xe), L.init(e, t);
}), rn = /* @__PURE__ */ m("$ZodKSUID", (e, t) => {
t.pattern ?? (t.pattern = Ze), L.init(e, t);
}), an = /* @__PURE__ */ m("$ZodISODateTime", (e, t) => {
t.pattern ?? (t.pattern = _t(t)), L.init(e, t);
}), on = /* @__PURE__ */ m("$ZodISODate", (e, t) => {
t.pattern ?? (t.pattern = mt), L.init(e, t);
}), sn = /* @__PURE__ */ m("$ZodISOTime", (e, t) => {
t.pattern ?? (t.pattern = gt(t)), L.init(e, t);
}), cn = /* @__PURE__ */ m("$ZodISODuration", (e, t) => {
t.pattern ?? (t.pattern = $e), L.init(e, t);
}), ln = /* @__PURE__ */ m("$ZodIPv4", (e, t) => {
t.pattern ?? (t.pattern = at), L.init(e, t), e._zod.bag.format = "ipv4";
}), un = /* @__PURE__ */ m("$ZodIPv6", (e, t) => {
t.pattern ?? (t.pattern = ot), L.init(e, t), e._zod.bag.format = "ipv6", e._zod.check = (n) => {
try {
new URL(`http://[${n.value}]`);
} catch {
n.issues.push({
code: "invalid_format",
format: "ipv6",
input: n.value,
inst: e,
continue: !t.abort
});
}
};
}), dn = /* @__PURE__ */ m("$ZodCIDRv4", (e, t) => {
t.pattern ?? (t.pattern = st), L.init(e, t);
}), fn = /* @__PURE__ */ m("$ZodCIDRv6", (e, t) => {
t.pattern ?? (t.pattern = ct), L.init(e, t), e._zod.check = (n) => {
let r = n.value.split("/");
try {
if (r.length !== 2) throw Error();
let [e, t] = r;
if (!t) throw Error();
let n = Number(t);
if (`${n}` !== t || n < 0 || n > 128) throw Error();
new URL(`http://[${e}]`);
} catch {
n.issues.push({
code: "invalid_format",
format: "cidrv6",
input: n.value,
inst: e,
continue: !t.abort
});
}
};
});
function pn(e) {
if (e === "") return !0;
if (/\s/.test(e) || e.length % 4 != 0) return !1;
try {
return atob(e), !0;
} catch {
return !1;
}
}
var mn = /* @__PURE__ */ m("$ZodBase64", (e, t) => {
t.pattern ?? (t.pattern = lt), L.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (n) => {
pn(n.value) || n.issues.push({
code: "invalid_format",
format: "base64",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
function hn(e) {
if (!ut.test(e)) return !1;
let t = e.replace(/[-_]/g, (e) => e === "-" ? "+" : "/");
return pn(t.padEnd(Math.ceil(t.length / 4) * 4, "="));
}
var gn = /* @__PURE__ */ m("$ZodBase64URL", (e, t) => {
t.pattern ?? (t.pattern = ut), L.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (n) => {
hn(n.value) || n.issues.push({
code: "invalid_format",
format: "base64url",
input: n.value,
inst: e,
continue: !t.abort
});
};
}), _n = /* @__PURE__ */ m("$ZodE164", (e, t) => {
t.pattern ?? (t.pattern = ft), L.init(e, t);
});
function vn(e, t = null) {
try {
let n = e.split(".");
if (n.length !== 3) return !1;
let [r] = n;
if (!r) return !1;
let i = JSON.parse(atob(r));
return !("typ" in i && i?.typ !== "JWT" || !i.alg || t && (!("alg" in i) || i.alg !== t));
} catch {
return !1;
}
}
var yn = /* @__PURE__ */ m("$ZodJWT", (e, t) => {
L.init(e, t), e._zod.check = (n) => {
vn(n.value, t.alg) || n.issues.push({
code: "invalid_format",
format: "jwt",
input: n.value,
inst: e,
continue: !t.abort
});
};
}), bn = /* @__PURE__ */ m("$ZodNumber", (e, t) => {
I.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? bt, e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = Number(n.value);
} catch {}
let i = n.value;
if (typeof i == "number" && !Number.isNaN(i) && Number.isFinite(i)) return n;
let a = typeof i == "number" ? Number.isNaN(i) ? "NaN" : Number.isFinite(i) ? void 0 : "Infinity" : void 0;
return n.issues.push({
expected: "number",
code: "invalid_type",
input: i,
inst: e,
...a ? { received: a } : {}
}), n;
};
}), xn = /* @__PURE__ */ m("$ZodNumberFormat", (e, t) => {
At.init(e, t), bn.init(e, t);
}), Sn = /* @__PURE__ */ m("$ZodBoolean", (e, t) => {
I.init(e, t), e._zod.pattern = xt, e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = !!n.value;
} catch {}
let i = n.value;
return typeof i == "boolean" || n.issues.push({
expected: "boolean",
code: "invalid_type",
input: i,
inst: e
}), n;
};
}), Cn = /* @__PURE__ */ m("$ZodUndefined", (e, t) => {
I.init(e, t), e._zod.pattern = Ct, e._zod.values = new Set([void 0]), e._zod.parse = (t, n) => {
let r = t.value;
return r === void 0 || t.issues.push({
expected: "undefined",
code: "invalid_type",
input: r,
inst: e
}), t;
};
}), wn = /* @__PURE__ */ m("$ZodNull", (e, t) => {
I.init(e, t), e._zod.pattern = St, e._zod.values = new Set([null]), e._zod.parse = (t, n) => {
let r = t.value;
return r === null || t.issues.push({
expected: "null",
code: "invalid_type",
input: r,
inst: e
}), t;
};
}), Tn = /* @__PURE__ */ m("$ZodAny", (e, t) => {
I.init(e, t), e._zod.parse = (e) => e;
}), En = /* @__PURE__ */ m("$ZodUnknown", (e, t) => {
I.init(e, t), e._zod.parse = (e) => e;
}), Dn = /* @__PURE__ */ m("$ZodNever", (e, t) => {
I.init(e, t), e._zod.parse = (t, n) => (t.issues.push({
expected: "never",
code: "invalid_type",
input: t.value,
inst: e
}), t);
}), On = /* @__PURE__ */ m("$ZodVoid", (e, t) => {
I.init(e, t), e._zod.parse = (t, n) => {
let r = t.value;
return r === void 0 || t.issues.push({
expected: "void",
code: "invalid_type",
input: r,
inst: e
}), t;
};
}), kn = /* @__PURE__ */ m("$ZodDate", (e, t) => {
I.init(e, t), e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = new Date(n.value);
} catch {}
let i = n.value, a = i instanceof Date;
return a && !Number.isNaN(i.getTime()) || n.issues.push({
expected: "date",
code: "invalid_type",
input: i,
...a ? { received: "Invalid Date" } : {},
inst: e
}), n;
};
});
function An(e, t, n) {
e.issues.length && t.issues.push(...k(n, e.issues)), t.value[n] = e.value;
}
var jn = /* @__PURE__ */ m("$ZodArray", (e, t) => {
I.init(e, t), e._zod.parse = (n, r) => {
let i = n.value;
if (!Array.isArray(i)) return n.issues.push({
expected: "array",
code: "invalid_type",
input: i,
inst: e
}), n;
n.value = Array(i.length);
let a = [];
for (let e = 0; e < i.length; e++) {
let o = i[e], s = t.element._zod.run({
value: o,
issues: []
}, r);
s instanceof Promise ? a.push(s.then((t) => An(t, n, e))) : An(s, n, e);
}
return a.length ? Promise.all(a).then(() => n) : n;
};
});
function R(e, t, n, r, i, a) {
let o = n in r;
if (e.issues.length) {
if (i && a && !o) return;
t.issues.push(...k(n, e.issues));
}
if (!o && !i) {
e.issues.length || t.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: void 0,
path: [n]
});
return;
}
e.value === void 0 ? o && (t.value[n] = void 0) : t.value[n] = e.value;
}
function Mn(e) {
let t = Object.keys(e.shape);
for (let n of t) if (!e.shape?.[n]?._zod?.traits?.has("$ZodType")) throw Error(`Invalid element at key "${n}": expected a Zod schema`);
let n = _e(e.shape);
return {
...e,
keys: t,
keySet: new Set(t),
numKeys: t.length,
optionalKeys: new Set(n)
};
}
function Nn(e, t, n, r, i, a) {
let o = [], s = i.keySet, c = i.catchall._zod, l = c.def.type, u = c.optin === "optional", d = c.optout === "optional";
for (let i in t) {
if (i === "__proto__" || s.has(i)) continue;
if (l === "never") {
o.push(i);
continue;
}
let a = c.run({
value: t[i],
issues: []
}, r);
a instanceof Promise ? e.push(a.then((e) => R(e, n, i, t, u, d))) : R(a, n, i, t, u, d);
}
return o.length && n.issues.push({
code: "unrecognized_keys",
keys: o,
input: t,
inst: a
}), e.length ? Promise.all(e).then(() => n) : n;
}
var Pn = /* @__PURE__ */ m("$ZodObject", (e, t) => {
if (I.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
let e = t.shape;
Object.defineProperty(t, "shape", { get: () => {
let n = { ...e };
return Object.defineProperty(t, "shape", { value: n }), n;
} });
}
let n = v(() => Mn(t));
b(e._zod, "propValues", () => {
let e = t.shape, n = {};
for (let t in e) {
let r = e[t]._zod;
if (r.values) {
n[t] ?? (n[t] = /* @__PURE__ */ new Set());
for (let e of r.values) n[t].add(e);
}
}
return n;
});
let r = C, i = t.catchall, a;
e._zod.parse = (t, o) => {
a ?? (a = n.value);
let s = t.value;
if (!r(s)) return t.issues.push({
expected: "object",
code: "invalid_type",
input: s,
inst: e
}), t;
t.value = {};
let c = [], l = a.shape;
for (let e of a.keys) {
let n = l[e], r = n._zod.optin === "optional", i = n._zod.optout === "optional", a = n._zod.run({
value: s[e],
issues: []
}, o);
a instanceof Promise ? c.push(a.then((n) => R(n, t, e, s, r, i))) : R(a, t, e, s, r, i);
}
return i ? Nn(c, s, t, o, n.value, e) : c.length ? Promise.all(c).then(() => t) : t;
};
}), Fn = /* @__PURE__ */ m("$ZodObjectJIT", (e, t) => {
Pn.init(e, t);
let n = e._zod.parse, r = v(() => Mn(t)), i = (e) => {
let t = new Wt([
"shape",
"payload",
"ctx"
]), n = r.value, i = (e) => {
let t = de(e);
return `shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`;
};
t.write("const input = payload.value;");
let a = Object.create(null), o = 0;
for (let e of n.keys) a[e] = `key_${o++}`;
t.write("const newResult = {};");
for (let r of n.keys) {
let n = a[r], o = de(r), s = e[r], c = s?._zod?.optin === "optional", l = s?._zod?.optout === "optional";
t.write(`const ${n} = ${i(r)};`), c && l ? t.write(`
if (${n}.issues.length) {
if (${o} in input) {
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
...iss,
path: iss.path ? [${o}, ...iss.path] : [${o}]
})));
}
}
if (${n}.value === undefined) {
if (${o} in input) {
newResult[${o}] = undefined;
}
} else {
newResult[${o}] = ${n}.value;
}
`) : c ? t.write(`
if (${n}.issues.length) {
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
...iss,
path: iss.path ? [${o}, ...iss.path] : [${o}]
})));
}
if (${n}.value === undefined) {
if (${o} in input) {
newResult[${o}] = undefined;
}
} else {
newResult[${o}] = ${n}.value;
}
`) : t.write(`
const ${n}_present = ${o} in input;
if (${n}.issues.length) {
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
...iss,
path: iss.path ? [${o}, ...iss.path] : [${o}]
})));
}
if (!${n}_present && !${n}.issues.length) {
payload.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: undefined,
path: [${o}]
});
}
if (${n}_present) {
if (${n}.value === undefined) {
newResult[${o}] = undefined;
} else {
newResult[${o}] = ${n}.value;
}
}
`);
}
t.write("payload.value = newResult;"), t.write("return payload;");
let s = t.compile();
return (t, n) => s(e, t, n);
}, a, o = C, s = !g.jitless, c = s && me.value, l = t.catchall, u;
e._zod.parse = (d, f) => {
u ?? (u = r.value);
let p = d.value;
return o(p) ? s && c && f?.async === !1 && f.jitless !== !0 ? (a || (a = i(t.shape)), d = a(d, f), l ? Nn([], p, d, f, u, e) : d) : n(d, f) : (d.issues.push({
expected: "object",
code: "invalid_type",
input: p,
inst: e
}), d);
};
});
function In(e, t, n, r) {
for (let n of e) if (n.issues.length === 0) return t.value = n.value, t;
let i = e.filter((e) => !O(e));
return i.length === 1 ? (t.value = i[0].value, i[0]) : (t.issues.push({
code: "invalid_union",
input: t.value,
inst: n,
errors: e.map((e) => e.issues.map((e) => A(e, r, _())))
}), t);
}
var Ln = /* @__PURE__ */ m("$ZodUnion", (e, t) => {
I.init(e, t), b(e._zod, "optin", () => t.options.some((e) => e._zod.optin === "optional") ? "optional" : void 0), b(e._zod, "optout", () => t.options.some((e) => e._zod.optout === "optional") ? "optional" : void 0), b(e._zod, "values", () => {
if (t.options.every((e) => e._zod.values)) return new Set(t.options.flatMap((e) => Array.from(e._zod.values)));
}), b(e._zod, "pattern", () => {
if (t.options.every((e) => e._zod.pattern)) {
let e = t.options.map((e) => e._zod.pattern);
return RegExp(`^(${e.map((e) => ce(e.source)).join("|")})$`);
}
});
let n = t.options.length === 1 ? t.options[0]._zod.run : null;
e._zod.parse = (r, i) => {
if (n) return n(r, i);
let a = !1, o = [];
for (let e of t.options) {
let t = e._zod.run({
value: r.value,
issues: []
}, i);
if (t instanceof Promise) o.push(t), a = !0;
else {
if (t.issues.length === 0) return t;
o.push(t);
}
}
return a ? Promise.all(o).then((t) => In(t, r, e, i)) : In(o, r, e, i);
};
}), Rn = /* @__PURE__ */ m("$ZodDiscriminatedUnion", (e, t) => {
t.inclusive = !1, Ln.init(e, t);
let n = e._zod.parse;
b(e._zod, "propValues", () => {
let e = {};
for (let n of t.options) {
let r = n._zod.propValues;
if (!r || Object.keys(r).length === 0) throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);
for (let [t, n] of Object.entries(r)) {
e[t] || (e[t] = /* @__PURE__ */ new Set());
for (let r of n) e[t].add(r);
}
}
return e;
});
let r = v(() => {
let e = t.options, n = /* @__PURE__ */ new Map();
for (let r of e) {
let e = r._zod.propValues?.[t.discriminator];
if (!e || e.size === 0) throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);
for (let t of e) {
if (n.has(t)) throw Error(`Duplicate discriminator value "${String(t)}"`);
n.set(t, r);
}
}
return n;
});
e._zod.parse = (i, a) => {
let o = i.value;
if (!C(o)) return i.issues.push({
code: "invalid_type",
expected: "object",
input: o,
inst: e
}), i;
let s = r.value.get(o?.[t.discriminator]);
return s ? s._zod.run(i, a) : t.unionFallback || a.direction === "backward" ? n(i, a) : (i.issues.push({
code: "invalid_union",
errors: [],
note: "No matching discriminator",
discriminator: t.discriminator,
options: Array.from(r.value.keys()),
input: o,
path: [t.discriminator],
inst: e
}), i);
};
}), zn = /* @__PURE__ */ m("$ZodIntersection", (e, t) => {
I.init(e, t), e._zod.parse = (e, n) => {
let r = e.value, i = t.left._zod.run({
value: r,
issues: []
}, n), a = t.right._zod.run({
value: r,
issues: []
}, n);
return i instanceof Promise || a instanceof Promise ? Promise.all([i, a]).then(([t, n]) => Vn(e, t, n)) : Vn(e, i, a);
};
});
function Bn(e, t) {
if (e === t || e instanceof Date && t instanceof Date && +e == +t) return {
valid: !0,
data: e
};
if (w(e) && w(t)) {
let n = Object.keys(t), r = Object.keys(e).filter((e) => n.indexOf(e) !== -1), i = {
...e,
...t
};
for (let n of r) {
let r = Bn(e[n], t[n]);
if (!r.valid) return {
valid: !1,
mergeErrorPath: [n, ...r.mergeErrorPath]
};
i[n] = r.data;
}
return {
valid: !0,
data: i
};
}
if (Array.isArray(e) && Array.isArray(t)) {
if (e.length !== t.length) return {
valid: !1,
mergeErrorPath: []
};
let n = [];
for (let r = 0; r < e.length; r++) {
let i = e[r], a = t[r], o = Bn(i, a);
if (!o.valid) return {
valid: !1,
mergeErrorPath: [r, ...o.mergeErrorPath]
};
n.push(o.data);
}
return {
valid: !0,
data: n
};
}
return {
valid: !1,
mergeErrorPath: []
};
}
function Vn(e, t, n) {
let r = /* @__PURE__ */ new Map(), i;
for (let n of t.issues) if (n.code === "unrecognized_keys") {
i ?? (i = n);
for (let e of n.keys) r.has(e) || r.set(e, {}), r.get(e).l = !0;
} else e.issues.push(n);
for (let t of n.issues) if (t.code === "unrecognized_keys") for (let e of t.keys) r.has(e) || r.set(e, {}), r.get(e).r = !0;
else e.issues.push(t);
let a = [...r].filter(([, e]) => e.l && e.r).map(([e]) => e);
if (a.length && i && e.issues.push({
...i,
keys: a
}), O(e)) return e;
let o = Bn(t.value, n.value);
if (!o.valid) throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);
return e.value = o.data, e;
}
var Hn = /* @__PURE__ */ m("$ZodTuple", (e, t) => {
I.init(e, t);
let n = t.items;
e._zod.parse = (r, i) => {
let a = r.value;
if (!Array.isArray(a)) return r.issues.push({
input: a,
inst: e,
expected: "tuple",
code: "invalid_type"
}), r;
r.value = [];
let o = [], s = Un(n, "optin"), c = Un(n, "optout");
if (!t.rest) {
if (a.length < s) return r.issues.push({
code: "too_small",
minimum: s,
inclusive: !0,
input: a,
inst: e,
origin: "array"
}), r;
a.length > n.length && r.issues.push({
code: "too_big",
maximum: n.length,
inclusive: !0,
input: a,
inst: e,
origin: "array"
});
}
let l = Array(n.length);
for (let e = 0; e < n.length; e++) {
let t = n[e]._zod.run({
value: a[e],
issues: []
}, i);
t instanceof Promise ? o.push(t.then((t) => {
l[e] = t;
})) : l[e] = t;
}
if (t.rest) {
let e = n.length - 1, s = a.slice(n.length);
for (let n of s) {
e++;
let a = t.rest._zod.run({
value: n,
issues: []
}, i);
a instanceof Promise ? o.push(a.then((t) => Wn(t, r, e))) : Wn(a, r, e);
}
}
return o.length ? Promise.all(o).then(() => Gn(l, r, n, a, c)) : Gn(l, r, n, a, c);
};
});
function Un(e, t) {
for (let n = e.length - 1; n >= 0; n--) if (e[n]._zod[t] !== "optional") return n + 1;
return 0;
}
function Wn(e, t, n) {
e.issues.length && t.issues.push(...k(n, e.issues)), t.value[n] = e.value;
}
function Gn(e, t, n, r, i) {
for (let a = 0; a < n.length; a++) {
let n = e[a], o = a < r.length;
if (n.issues.length) {
if (!o && a >= i) {
t.value.length = a;
break;
}
t.issues.push(...k(a, n.issues));
}
t.value[a] = n.value;
}
for (let e = t.value.length - 1; e >= r.length && n[e]._zod.optout === "optional" && t.value[e] === void 0; e--) t.value.length = e;
return t;
}
var Kn = /* @__PURE__ */ m("$ZodRecord", (e, t) => {
I.init(e, t), e._zod.parse = (n, r) => {
let i = n.value;
if (!w(i)) return n.issues.push({
expected: "record",
code: "invalid_type",
input: i,
inst: e
}), n;
let a = [], o = t.keyType._zod.values;
if (o) {
n.value = {};
let s = /* @__PURE__ */ new Set();
for (let c of o) if (typeof c == "string" || typeof c == "number" || typeof c == "symbol") {
s.add(typeof c == "number" ? c.toString() : c);
let o = t.keyType._zod.run({
value: c,
issues: []
}, r);
if (o instanceof Promise) throw Error("Async schemas not supported in object keys currently");
if (o.issues.length) {
n.issues.push({
code: "invalid_key",
origin: "record",
issues: o.issues.map((e) => A(e, r, _())),
input: c,
path: [c],
inst: e
});
continue;
}
let l = o.value, u = t.valueType._zod.run({
value: i[c],
issues: []
}, r);
u instanceof Promise ? a.pus