interface-forge
Version:
A TypeScript library for creating strongly typed mock data factories using Faker.js for test data generation
1,555 lines (1,551 loc) • 121 kB
JavaScript
var un = Object.defineProperty;
var cn = (e, t, n) => t in e ? un(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var A = (e, t, n) => cn(e, typeof t != "symbol" ? t + "" : t, n);
import { F as an, _ as ie, s as P, D as Y, C as he, m as pe, a as ln, S as Ne, t as F, b as me, g as d, x as Fe, c as R, N as L, u as dn, h as fn, d as hn } from "./index-BZPEccyf.mjs";
function c(e, t, n) {
function r(u, a) {
var l;
Object.defineProperty(u, "_zod", {
value: u._zod ?? {},
enumerable: !1
}), (l = u._zod).traits ?? (l.traits = /* @__PURE__ */ new Set()), u._zod.traits.add(e), t(u, a);
for (const f in s.prototype)
f in u || Object.defineProperty(u, f, { value: s.prototype[f].bind(u) });
u._zod.constr = s, u._zod.def = a;
}
const o = n?.Parent ?? Object;
class i extends o {
}
Object.defineProperty(i, "name", { value: e });
function s(u) {
var a;
const l = n?.Parent ? new i() : this;
r(l, u), (a = l._zod).deferred ?? (a.deferred = []);
for (const f of l._zod.deferred)
f();
return l;
}
return Object.defineProperty(s, "init", { value: r }), Object.defineProperty(s, Symbol.hasInstance, {
value: (u) => n?.Parent && u instanceof n.Parent ? !0 : u?._zod?.traits?.has(e)
}), Object.defineProperty(s, "name", { value: e }), s;
}
class V extends Error {
constructor() {
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
}
}
class it extends Error {
constructor(t) {
super(`Encountered unidirectional transform during encode: ${t}`), this.name = "ZodEncodeError";
}
}
const ge = {};
function x(e) {
return e && Object.assign(ge, e), ge;
}
function mn(e) {
const t = Object.values(e).filter((r) => typeof r == "number");
return Object.entries(e).filter(([r, o]) => t.indexOf(+r) === -1).map(([r, o]) => o);
}
function Oe(e, t = "|") {
return e.map((n) => ct(n)).join(t);
}
function ve(e, t) {
return typeof t == "bigint" ? t.toString() : t;
}
function ae(e) {
return {
get value() {
{
const t = e();
return Object.defineProperty(this, "value", { value: t }), t;
}
}
};
}
function G(e) {
return e == null;
}
function ze(e) {
const t = e.startsWith("^") ? 1 : 0, n = e.endsWith("$") ? e.length - 1 : e.length;
return e.slice(t, n);
}
function pn(e, t) {
const n = (e.toString().split(".")[1] || "").length, r = t.toString();
let o = (r.split(".")[1] || "").length;
if (o === 0 && /\d?e-\d?/.test(r)) {
const a = r.match(/\d?e-(\d?)/);
a?.[1] && (o = Number.parseInt(a[1]));
}
const i = n > o ? n : o, s = Number.parseInt(e.toFixed(i).replace(".", "")), u = Number.parseInt(t.toFixed(i).replace(".", ""));
return s % u / 10 ** i;
}
const De = Symbol("evaluating");
function z(e, t, n) {
let r;
Object.defineProperty(e, t, {
get() {
if (r !== De)
return r === void 0 && (r = De, r = n()), r;
},
set(o) {
Object.defineProperty(e, t, {
value: o
// configurable: true,
});
},
configurable: !0
});
}
function j(e, t, n) {
Object.defineProperty(e, t, {
value: n,
writable: !0,
enumerable: !0,
configurable: !0
});
}
function U(...e) {
const t = {};
for (const n of e) {
const r = Object.getOwnPropertyDescriptors(n);
Object.assign(t, r);
}
return Object.defineProperties({}, t);
}
function Pe(e) {
return JSON.stringify(e);
}
const st = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
};
function J(e) {
return typeof e == "object" && e !== null && !Array.isArray(e);
}
const gn = ae(() => {
if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare"))
return !1;
try {
const e = Function;
return new e(""), !0;
} catch {
return !1;
}
});
function H(e) {
if (J(e) === !1)
return !1;
const t = e.constructor;
if (t === void 0)
return !0;
const n = t.prototype;
return !(J(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
}
function ut(e) {
return H(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
}
const _e = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
function B(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function C(e, t, n) {
const r = new e._zod.constr(t ?? e._zod.def);
return (!t || n?.parent) && (r._zod.parent = e), r;
}
function h(e) {
const t = e;
if (!t)
return {};
if (typeof t == "string")
return { error: () => t };
if (t?.message !== void 0) {
if (t?.error !== void 0)
throw new 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 ct(e) {
return typeof e == "bigint" ? e.toString() + "n" : typeof e == "string" ? `"${e}"` : `${e}`;
}
function vn(e) {
return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
}
const _n = {
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
int32: [-2147483648, 2147483647],
uint32: [0, 4294967295],
float32: [-34028234663852886e22, 34028234663852886e22],
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
};
function yn(e, t) {
const n = e._zod.def, r = U(e._zod.def, {
get shape() {
const o = {};
for (const i in t) {
if (!(i in n.shape))
throw new Error(`Unrecognized key: "${i}"`);
t[i] && (o[i] = n.shape[i]);
}
return j(this, "shape", o), o;
},
checks: []
});
return C(e, r);
}
function bn(e, t) {
const n = e._zod.def, r = U(e._zod.def, {
get shape() {
const o = { ...e._zod.def.shape };
for (const i in t) {
if (!(i in n.shape))
throw new Error(`Unrecognized key: "${i}"`);
t[i] && delete o[i];
}
return j(this, "shape", o), o;
},
checks: []
});
return C(e, r);
}
function zn(e, t) {
if (!H(t))
throw new Error("Invalid input to extend: expected a plain object");
const n = e._zod.def.checks;
if (n && n.length > 0)
throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
const o = U(e._zod.def, {
get shape() {
const i = { ...e._zod.def.shape, ...t };
return j(this, "shape", i), i;
},
checks: []
});
return C(e, o);
}
function kn(e, t) {
if (!H(t))
throw new Error("Invalid input to safeExtend: expected a plain object");
const n = {
...e._zod.def,
get shape() {
const r = { ...e._zod.def.shape, ...t };
return j(this, "shape", r), r;
},
checks: e._zod.def.checks
};
return C(e, n);
}
function Zn(e, t) {
const n = U(e._zod.def, {
get shape() {
const r = { ...e._zod.def.shape, ...t._zod.def.shape };
return j(this, "shape", r), r;
},
get catchall() {
return t._zod.def.catchall;
},
checks: []
// delete existing checks
});
return C(e, n);
}
function wn(e, t, n) {
const r = U(t._zod.def, {
get shape() {
const o = t._zod.def.shape, i = { ...o };
if (n)
for (const s in n) {
if (!(s in o))
throw new Error(`Unrecognized key: "${s}"`);
n[s] && (i[s] = e ? new e({
type: "optional",
innerType: o[s]
}) : o[s]);
}
else
for (const s in o)
i[s] = e ? new e({
type: "optional",
innerType: o[s]
}) : o[s];
return j(this, "shape", i), i;
},
checks: []
});
return C(t, r);
}
function $n(e, t, n) {
const r = U(t._zod.def, {
get shape() {
const o = t._zod.def.shape, i = { ...o };
if (n)
for (const s in n) {
if (!(s in i))
throw new Error(`Unrecognized key: "${s}"`);
n[s] && (i[s] = new e({
type: "nonoptional",
innerType: o[s]
}));
}
else
for (const s in o)
i[s] = new e({
type: "nonoptional",
innerType: o[s]
});
return j(this, "shape", i), i;
},
checks: []
});
return C(t, r);
}
function M(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 D(e, t) {
return t.map((n) => {
var r;
return (r = n).path ?? (r.path = []), n.path.unshift(e), n;
});
}
function Q(e) {
return typeof e == "string" ? e : e?.message;
}
function N(e, t, n) {
const r = { ...e, path: e.path ?? [] };
if (!e.message) {
const o = Q(e.inst?._zod.def?.error?.(e)) ?? Q(t?.error?.(e)) ?? Q(n.customError?.(e)) ?? Q(n.localeError?.(e)) ?? "Invalid input";
r.message = o;
}
return delete r.inst, delete r.continue, t?.reportInput || delete r.input, r;
}
function ke(e) {
return e instanceof Set ? "set" : e instanceof Map ? "map" : e instanceof File ? "file" : "unknown";
}
function Ze(e) {
return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
}
function X(...e) {
const [t, n, r] = e;
return typeof t == "string" ? {
message: t,
code: "custom",
input: n,
inst: r
} : { ...t };
}
const at = (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, ve, 2), Object.defineProperty(e, "toString", {
value: () => e.message,
enumerable: !1
});
}, lt = c("$ZodError", at), dt = c("$ZodError", at, { Parent: Error });
function Sn(e, t = (n) => n.message) {
const n = {}, r = [];
for (const o of e.issues)
o.path.length > 0 ? (n[o.path[0]] = n[o.path[0]] || [], n[o.path[0]].push(t(o))) : r.push(t(o));
return { formErrors: r, fieldErrors: n };
}
function Tn(e, t = (n) => n.message) {
const n = { _errors: [] }, r = (o) => {
for (const i of o.issues)
if (i.code === "invalid_union" && i.errors.length)
i.errors.map((s) => r({ issues: s }));
else if (i.code === "invalid_key")
r({ issues: i.issues });
else if (i.code === "invalid_element")
r({ issues: i.issues });
else if (i.path.length === 0)
n._errors.push(t(i));
else {
let s = n, u = 0;
for (; u < i.path.length; ) {
const a = i.path[u];
u === i.path.length - 1 ? (s[a] = s[a] || { _errors: [] }, s[a]._errors.push(t(i))) : s[a] = s[a] || { _errors: [] }, s = s[a], u++;
}
}
};
return r(e), n;
}
const we = (e) => (t, n, r, o) => {
const i = r ? Object.assign(r, { async: !1 }) : { async: !1 }, s = t._zod.run({ value: n, issues: [] }, i);
if (s instanceof Promise)
throw new V();
if (s.issues.length) {
const u = new (o?.Err ?? e)(s.issues.map((a) => N(a, i, x())));
throw st(u, o?.callee), u;
}
return s.value;
}, $e = (e) => async (t, n, r, o) => {
const i = r ? Object.assign(r, { async: !0 }) : { async: !0 };
let s = t._zod.run({ value: n, issues: [] }, i);
if (s instanceof Promise && (s = await s), s.issues.length) {
const u = new (o?.Err ?? e)(s.issues.map((a) => N(a, i, x())));
throw st(u, o?.callee), u;
}
return s.value;
}, le = (e) => (t, n, r) => {
const o = r ? { ...r, async: !1 } : { async: !1 }, i = t._zod.run({ value: n, issues: [] }, o);
if (i instanceof Promise)
throw new V();
return i.issues.length ? {
success: !1,
error: new (e ?? lt)(i.issues.map((s) => N(s, o, x())))
} : { success: !0, data: i.value };
}, In = /* @__PURE__ */ le(dt), de = (e) => async (t, n, r) => {
const o = r ? Object.assign(r, { async: !0 }) : { async: !0 };
let i = t._zod.run({ value: n, issues: [] }, o);
return i instanceof Promise && (i = await i), i.issues.length ? {
success: !1,
error: new e(i.issues.map((s) => N(s, o, x())))
} : { success: !0, data: i.value };
}, xn = /* @__PURE__ */ de(dt), En = (e) => (t, n, r) => {
const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return we(e)(t, n, o);
}, An = (e) => (t, n, r) => we(e)(t, n, r), Nn = (e) => async (t, n, r) => {
const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return $e(e)(t, n, o);
}, Fn = (e) => async (t, n, r) => $e(e)(t, n, r), On = (e) => (t, n, r) => {
const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return le(e)(t, n, o);
}, Dn = (e) => (t, n, r) => le(e)(t, n, r), Pn = (e) => async (t, n, r) => {
const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
return de(e)(t, n, o);
}, Cn = (e) => async (t, n, r) => de(e)(t, n, r), jn = /^[cC][^\s-]{8,}$/, Un = /^[0-9a-z]+$/, Rn = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Ln = /^[0-9a-vA-V]{20}$/, Mn = /^[A-Za-z0-9]{27}$/, Vn = /^[a-zA-Z0-9_-]{21}$/, Hn = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Bn = /^([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})$/, Ce = (e) => e ? new 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)$/, Gn = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Wn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
function Kn() {
return new RegExp(Wn, "u");
}
const Jn = /^(?:(?: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])$/, Xn = /^(([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}|:))$/, qn = /^((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])$/, Yn = /^(([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])$/, Qn = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, ft = /^[A-Za-z0-9_-]*$/, er = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/, tr = /^\+(?:[0-9]){6,14}[0-9]$/, ht = "(?:(?:\\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])))", nr = /* @__PURE__ */ new RegExp(`^${ht}$`);
function mt(e) {
const 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 rr(e) {
return new RegExp(`^${mt(e)}$`);
}
function or(e) {
const t = mt({ precision: e.precision }), n = ["Z"];
e.local && n.push(""), e.offset && n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
const r = `${t}(?:${n.join("|")})`;
return new RegExp(`^${ht}T(?:${r})$`);
}
const ir = (e) => {
const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
return new RegExp(`^${t}$`);
}, sr = /^-?\d+$/, ur = /^-?\d+(?:\.\d+)?/, cr = /^(?:true|false)$/i, ar = /^null$/i, lr = /^undefined$/i, dr = /^[^A-Z]*$/, fr = /^[^a-z]*$/, S = /* @__PURE__ */ c("$ZodCheck", (e, t) => {
var n;
e._zod ?? (e._zod = {}), e._zod.def = t, (n = e._zod).onattach ?? (n.onattach = []);
}), pt = {
number: "number",
bigint: "bigint",
object: "date"
}, gt = /* @__PURE__ */ c("$ZodCheckLessThan", (e, t) => {
S.init(e, t);
const n = pt[typeof t.value];
e._zod.onattach.push((r) => {
const o = r._zod.bag, i = (t.inclusive ? o.maximum : o.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
t.value < i && (t.inclusive ? o.maximum = t.value : o.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: t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
}), vt = /* @__PURE__ */ c("$ZodCheckGreaterThan", (e, t) => {
S.init(e, t);
const n = pt[typeof t.value];
e._zod.onattach.push((r) => {
const o = r._zod.bag, i = (t.inclusive ? o.minimum : o.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
t.value > i && (t.inclusive ? o.minimum = t.value : o.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: t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
}), hr = /* @__PURE__ */ c("$ZodCheckMultipleOf", (e, t) => {
S.init(e, t), e._zod.onattach.push((n) => {
var r;
(r = n._zod.bag).multipleOf ?? (r.multipleOf = t.value);
}), e._zod.check = (n) => {
if (typeof n.value != typeof t.value)
throw new Error("Cannot mix number and bigint in multiple_of check.");
(typeof n.value == "bigint" ? n.value % t.value === BigInt(0) : pn(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
});
};
}), mr = /* @__PURE__ */ c("$ZodCheckNumberFormat", (e, t) => {
S.init(e, t), t.format = t.format || "float64";
const n = t.format?.includes("int"), r = n ? "int" : "number", [o, i] = _n[t.format];
e._zod.onattach.push((s) => {
const u = s._zod.bag;
u.format = t.format, u.minimum = o, u.maximum = i, n && (u.pattern = sr);
}), e._zod.check = (s) => {
const u = s.value;
if (n) {
if (!Number.isInteger(u)) {
s.issues.push({
expected: r,
format: t.format,
code: "invalid_type",
continue: !1,
input: u,
inst: e
});
return;
}
if (!Number.isSafeInteger(u)) {
u > 0 ? s.issues.push({
input: u,
code: "too_big",
maximum: Number.MAX_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
continue: !t.abort
}) : s.issues.push({
input: u,
code: "too_small",
minimum: Number.MIN_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
continue: !t.abort
});
return;
}
}
u < o && s.issues.push({
origin: "number",
input: u,
code: "too_small",
minimum: o,
inclusive: !0,
inst: e,
continue: !t.abort
}), u > i && s.issues.push({
origin: "number",
input: u,
code: "too_big",
maximum: i,
inst: e
});
};
}), pr = /* @__PURE__ */ c("$ZodCheckMaxSize", (e, t) => {
var n;
S.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
const o = r.value;
return !G(o) && o.size !== void 0;
}), e._zod.onattach.push((r) => {
const o = r._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
t.maximum < o && (r._zod.bag.maximum = t.maximum);
}), e._zod.check = (r) => {
const o = r.value;
o.size <= t.maximum || r.issues.push({
origin: ke(o),
code: "too_big",
maximum: t.maximum,
inclusive: !0,
input: o,
inst: e,
continue: !t.abort
});
};
}), gr = /* @__PURE__ */ c("$ZodCheckMinSize", (e, t) => {
var n;
S.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
const o = r.value;
return !G(o) && o.size !== void 0;
}), e._zod.onattach.push((r) => {
const o = r._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
t.minimum > o && (r._zod.bag.minimum = t.minimum);
}), e._zod.check = (r) => {
const o = r.value;
o.size >= t.minimum || r.issues.push({
origin: ke(o),
code: "too_small",
minimum: t.minimum,
inclusive: !0,
input: o,
inst: e,
continue: !t.abort
});
};
}), vr = /* @__PURE__ */ c("$ZodCheckSizeEquals", (e, t) => {
var n;
S.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
const o = r.value;
return !G(o) && o.size !== void 0;
}), e._zod.onattach.push((r) => {
const o = r._zod.bag;
o.minimum = t.size, o.maximum = t.size, o.size = t.size;
}), e._zod.check = (r) => {
const o = r.value, i = o.size;
if (i === t.size)
return;
const s = i > t.size;
r.issues.push({
origin: ke(o),
...s ? { code: "too_big", maximum: t.size } : { code: "too_small", minimum: t.size },
inclusive: !0,
exact: !0,
input: r.value,
inst: e,
continue: !t.abort
});
};
}), _r = /* @__PURE__ */ c("$ZodCheckMaxLength", (e, t) => {
var n;
S.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
const o = r.value;
return !G(o) && o.length !== void 0;
}), e._zod.onattach.push((r) => {
const o = r._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
t.maximum < o && (r._zod.bag.maximum = t.maximum);
}), e._zod.check = (r) => {
const o = r.value;
if (o.length <= t.maximum)
return;
const s = Ze(o);
r.issues.push({
origin: s,
code: "too_big",
maximum: t.maximum,
inclusive: !0,
input: o,
inst: e,
continue: !t.abort
});
};
}), yr = /* @__PURE__ */ c("$ZodCheckMinLength", (e, t) => {
var n;
S.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
const o = r.value;
return !G(o) && o.length !== void 0;
}), e._zod.onattach.push((r) => {
const o = r._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
t.minimum > o && (r._zod.bag.minimum = t.minimum);
}), e._zod.check = (r) => {
const o = r.value;
if (o.length >= t.minimum)
return;
const s = Ze(o);
r.issues.push({
origin: s,
code: "too_small",
minimum: t.minimum,
inclusive: !0,
input: o,
inst: e,
continue: !t.abort
});
};
}), br = /* @__PURE__ */ c("$ZodCheckLengthEquals", (e, t) => {
var n;
S.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
const o = r.value;
return !G(o) && o.length !== void 0;
}), e._zod.onattach.push((r) => {
const o = r._zod.bag;
o.minimum = t.length, o.maximum = t.length, o.length = t.length;
}), e._zod.check = (r) => {
const o = r.value, i = o.length;
if (i === t.length)
return;
const s = Ze(o), u = i > t.length;
r.issues.push({
origin: s,
...u ? { code: "too_big", maximum: t.length } : { code: "too_small", minimum: t.length },
inclusive: !0,
exact: !0,
input: r.value,
inst: e,
continue: !t.abort
});
};
}), fe = /* @__PURE__ */ c("$ZodCheckStringFormat", (e, t) => {
var n, r;
S.init(e, t), e._zod.onattach.push((o) => {
const i = o._zod.bag;
i.format = t.format, t.pattern && (i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(t.pattern));
}), t.pattern ? (n = e._zod).check ?? (n.check = (o) => {
t.pattern.lastIndex = 0, !t.pattern.test(o.value) && o.issues.push({
origin: "string",
code: "invalid_format",
format: t.format,
input: o.value,
...t.pattern ? { pattern: t.pattern.toString() } : {},
inst: e,
continue: !t.abort
});
}) : (r = e._zod).check ?? (r.check = () => {
});
}), zr = /* @__PURE__ */ c("$ZodCheckRegex", (e, t) => {
fe.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
});
};
}), kr = /* @__PURE__ */ c("$ZodCheckLowerCase", (e, t) => {
t.pattern ?? (t.pattern = dr), fe.init(e, t);
}), Zr = /* @__PURE__ */ c("$ZodCheckUpperCase", (e, t) => {
t.pattern ?? (t.pattern = fr), fe.init(e, t);
}), wr = /* @__PURE__ */ c("$ZodCheckIncludes", (e, t) => {
S.init(e, t);
const n = B(t.includes), r = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${n}` : n);
t.pattern = r, e._zod.onattach.push((o) => {
const i = o._zod.bag;
i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(r);
}), e._zod.check = (o) => {
o.value.includes(t.includes, t.position) || o.issues.push({
origin: "string",
code: "invalid_format",
format: "includes",
includes: t.includes,
input: o.value,
inst: e,
continue: !t.abort
});
};
}), $r = /* @__PURE__ */ c("$ZodCheckStartsWith", (e, t) => {
S.init(e, t);
const n = new RegExp(`^${B(t.prefix)}.*`);
t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
const o = r._zod.bag;
o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
}), e._zod.check = (r) => {
r.value.startsWith(t.prefix) || r.issues.push({
origin: "string",
code: "invalid_format",
format: "starts_with",
prefix: t.prefix,
input: r.value,
inst: e,
continue: !t.abort
});
};
}), Sr = /* @__PURE__ */ c("$ZodCheckEndsWith", (e, t) => {
S.init(e, t);
const n = new RegExp(`.*${B(t.suffix)}$`);
t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
const o = r._zod.bag;
o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
}), e._zod.check = (r) => {
r.value.endsWith(t.suffix) || r.issues.push({
origin: "string",
code: "invalid_format",
format: "ends_with",
suffix: t.suffix,
input: r.value,
inst: e,
continue: !t.abort
});
};
}), Tr = /* @__PURE__ */ c("$ZodCheckOverwrite", (e, t) => {
S.init(e, t), e._zod.check = (n) => {
n.value = t.tx(n.value);
};
});
class Ir {
constructor(t = []) {
this.content = [], this.indent = 0, this && (this.args = t);
}
indented(t) {
this.indent += 1, t(this), this.indent -= 1;
}
write(t) {
if (typeof t == "function") {
t(this, { execution: "sync" }), t(this, { execution: "async" });
return;
}
const r = t.split(`
`).filter((s) => s), o = Math.min(...r.map((s) => s.length - s.trimStart().length)), i = r.map((s) => s.slice(o)).map((s) => " ".repeat(this.indent * 2) + s);
for (const s of i)
this.content.push(s);
}
compile() {
const t = Function, n = this?.args, o = [...(this?.content ?? [""]).map((i) => ` ${i}`)];
return new t(...n, o.join(`
`));
}
}
const xr = {
major: 4,
minor: 1,
patch: 12
}, y = /* @__PURE__ */ c("$ZodType", (e, t) => {
var n;
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = xr;
const r = [...e._zod.def.checks ?? []];
e._zod.traits.has("$ZodCheck") && r.unshift(e);
for (const o of r)
for (const i of o._zod.onattach)
i(e);
if (r.length === 0)
(n = e._zod).deferred ?? (n.deferred = []), e._zod.deferred?.push(() => {
e._zod.run = e._zod.parse;
});
else {
const o = (s, u, a) => {
let l = M(s), f;
for (const v of u) {
if (v._zod.def.when) {
if (!v._zod.def.when(s))
continue;
} else if (l)
continue;
const g = s.issues.length, _ = v._zod.check(s);
if (_ instanceof Promise && a?.async === !1)
throw new V();
if (f || _ instanceof Promise)
f = (f ?? Promise.resolve()).then(async () => {
await _, s.issues.length !== g && (l || (l = M(s, g)));
});
else {
if (s.issues.length === g)
continue;
l || (l = M(s, g));
}
}
return f ? f.then(() => s) : s;
}, i = (s, u, a) => {
if (M(s))
return s.aborted = !0, s;
const l = o(u, r, a);
if (l instanceof Promise) {
if (a.async === !1)
throw new V();
return l.then((f) => e._zod.parse(f, a));
}
return e._zod.parse(l, a);
};
e._zod.run = (s, u) => {
if (u.skipChecks)
return e._zod.parse(s, u);
if (u.direction === "backward") {
const l = e._zod.parse({ value: s.value, issues: [] }, { ...u, skipChecks: !0 });
return l instanceof Promise ? l.then((f) => i(f, s, u)) : i(l, s, u);
}
const a = e._zod.parse(s, u);
if (a instanceof Promise) {
if (u.async === !1)
throw new V();
return a.then((l) => o(l, r, u));
}
return o(a, r, u);
};
}
e["~standard"] = {
validate: (o) => {
try {
const i = In(e, o);
return i.success ? { value: i.data } : { issues: i.error?.issues };
} catch {
return xn(e, o).then((s) => s.success ? { value: s.data } : { issues: s.error?.issues });
}
},
vendor: "zod",
version: 1
};
}), Se = /* @__PURE__ */ c("$ZodString", (e, t) => {
y.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? ir(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;
};
}), w = /* @__PURE__ */ c("$ZodStringFormat", (e, t) => {
fe.init(e, t), Se.init(e, t);
}), Er = /* @__PURE__ */ c("$ZodGUID", (e, t) => {
t.pattern ?? (t.pattern = Bn), w.init(e, t);
}), Ar = /* @__PURE__ */ c("$ZodUUID", (e, t) => {
if (t.version) {
const r = {
v1: 1,
v2: 2,
v3: 3,
v4: 4,
v5: 5,
v6: 6,
v7: 7,
v8: 8
}[t.version];
if (r === void 0)
throw new Error(`Invalid UUID version: "${t.version}"`);
t.pattern ?? (t.pattern = Ce(r));
} else
t.pattern ?? (t.pattern = Ce());
w.init(e, t);
}), Nr = /* @__PURE__ */ c("$ZodEmail", (e, t) => {
t.pattern ?? (t.pattern = Gn), w.init(e, t);
}), Fr = /* @__PURE__ */ c("$ZodURL", (e, t) => {
w.init(e, t), e._zod.check = (n) => {
try {
const r = n.value.trim(), o = new URL(r);
t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(o.hostname) || n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: er.source,
input: n.value,
inst: e,
continue: !t.abort
})), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(o.protocol.endsWith(":") ? o.protocol.slice(0, -1) : o.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 = o.href : n.value = r;
return;
} catch {
n.issues.push({
code: "invalid_format",
format: "url",
input: n.value,
inst: e,
continue: !t.abort
});
}
};
}), Or = /* @__PURE__ */ c("$ZodEmoji", (e, t) => {
t.pattern ?? (t.pattern = Kn()), w.init(e, t);
}), Dr = /* @__PURE__ */ c("$ZodNanoID", (e, t) => {
t.pattern ?? (t.pattern = Vn), w.init(e, t);
}), Pr = /* @__PURE__ */ c("$ZodCUID", (e, t) => {
t.pattern ?? (t.pattern = jn), w.init(e, t);
}), Cr = /* @__PURE__ */ c("$ZodCUID2", (e, t) => {
t.pattern ?? (t.pattern = Un), w.init(e, t);
}), jr = /* @__PURE__ */ c("$ZodULID", (e, t) => {
t.pattern ?? (t.pattern = Rn), w.init(e, t);
}), Ur = /* @__PURE__ */ c("$ZodXID", (e, t) => {
t.pattern ?? (t.pattern = Ln), w.init(e, t);
}), Rr = /* @__PURE__ */ c("$ZodKSUID", (e, t) => {
t.pattern ?? (t.pattern = Mn), w.init(e, t);
}), Lr = /* @__PURE__ */ c("$ZodISODateTime", (e, t) => {
t.pattern ?? (t.pattern = or(t)), w.init(e, t);
}), Mr = /* @__PURE__ */ c("$ZodISODate", (e, t) => {
t.pattern ?? (t.pattern = nr), w.init(e, t);
}), Vr = /* @__PURE__ */ c("$ZodISOTime", (e, t) => {
t.pattern ?? (t.pattern = rr(t)), w.init(e, t);
}), Hr = /* @__PURE__ */ c("$ZodISODuration", (e, t) => {
t.pattern ?? (t.pattern = Hn), w.init(e, t);
}), Br = /* @__PURE__ */ c("$ZodIPv4", (e, t) => {
t.pattern ?? (t.pattern = Jn), w.init(e, t), e._zod.onattach.push((n) => {
const r = n._zod.bag;
r.format = "ipv4";
});
}), Gr = /* @__PURE__ */ c("$ZodIPv6", (e, t) => {
t.pattern ?? (t.pattern = Xn), w.init(e, t), e._zod.onattach.push((n) => {
const r = n._zod.bag;
r.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
});
}
};
}), Wr = /* @__PURE__ */ c("$ZodCIDRv4", (e, t) => {
t.pattern ?? (t.pattern = qn), w.init(e, t);
}), Kr = /* @__PURE__ */ c("$ZodCIDRv6", (e, t) => {
t.pattern ?? (t.pattern = Yn), w.init(e, t), e._zod.check = (n) => {
const r = n.value.split("/");
try {
if (r.length !== 2)
throw new Error();
const [o, i] = r;
if (!i)
throw new Error();
const s = Number(i);
if (`${s}` !== i)
throw new Error();
if (s < 0 || s > 128)
throw new Error();
new URL(`http://[${o}]`);
} catch {
n.issues.push({
code: "invalid_format",
format: "cidrv6",
input: n.value,
inst: e,
continue: !t.abort
});
}
};
});
function _t(e) {
if (e === "")
return !0;
if (e.length % 4 !== 0)
return !1;
try {
return atob(e), !0;
} catch {
return !1;
}
}
const Jr = /* @__PURE__ */ c("$ZodBase64", (e, t) => {
t.pattern ?? (t.pattern = Qn), w.init(e, t), e._zod.onattach.push((n) => {
n._zod.bag.contentEncoding = "base64";
}), e._zod.check = (n) => {
_t(n.value) || n.issues.push({
code: "invalid_format",
format: "base64",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
function Xr(e) {
if (!ft.test(e))
return !1;
const t = e.replace(/[-_]/g, (r) => r === "-" ? "+" : "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "=");
return _t(n);
}
const qr = /* @__PURE__ */ c("$ZodBase64URL", (e, t) => {
t.pattern ?? (t.pattern = ft), w.init(e, t), e._zod.onattach.push((n) => {
n._zod.bag.contentEncoding = "base64url";
}), e._zod.check = (n) => {
Xr(n.value) || n.issues.push({
code: "invalid_format",
format: "base64url",
input: n.value,
inst: e,
continue: !t.abort
});
};
}), Yr = /* @__PURE__ */ c("$ZodE164", (e, t) => {
t.pattern ?? (t.pattern = tr), w.init(e, t);
});
function Qr(e, t = null) {
try {
const n = e.split(".");
if (n.length !== 3)
return !1;
const [r] = n;
if (!r)
return !1;
const o = JSON.parse(atob(r));
return !("typ" in o && o?.typ !== "JWT" || !o.alg || t && (!("alg" in o) || o.alg !== t));
} catch {
return !1;
}
}
const eo = /* @__PURE__ */ c("$ZodJWT", (e, t) => {
w.init(e, t), e._zod.check = (n) => {
Qr(n.value, t.alg) || n.issues.push({
code: "invalid_format",
format: "jwt",
input: n.value,
inst: e,
continue: !t.abort
});
};
}), yt = /* @__PURE__ */ c("$ZodNumber", (e, t) => {
y.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? ur, e._zod.parse = (n, r) => {
if (t.coerce)
try {
n.value = Number(n.value);
} catch {
}
const o = n.value;
if (typeof o == "number" && !Number.isNaN(o) && Number.isFinite(o))
return n;
const i = typeof o == "number" ? Number.isNaN(o) ? "NaN" : Number.isFinite(o) ? void 0 : "Infinity" : void 0;
return n.issues.push({
expected: "number",
code: "invalid_type",
input: o,
inst: e,
...i ? { received: i } : {}
}), n;
};
}), to = /* @__PURE__ */ c("$ZodNumber", (e, t) => {
mr.init(e, t), yt.init(e, t);
}), no = /* @__PURE__ */ c("$ZodBoolean", (e, t) => {
y.init(e, t), e._zod.pattern = cr, e._zod.parse = (n, r) => {
if (t.coerce)
try {
n.value = !!n.value;
} catch {
}
const o = n.value;
return typeof o == "boolean" || n.issues.push({
expected: "boolean",
code: "invalid_type",
input: o,
inst: e
}), n;
};
}), ro = /* @__PURE__ */ c("$ZodUndefined", (e, t) => {
y.init(e, t), e._zod.pattern = lr, e._zod.values = /* @__PURE__ */ new Set([void 0]), e._zod.optin = "optional", e._zod.optout = "optional", e._zod.parse = (n, r) => {
const o = n.value;
return typeof o > "u" || n.issues.push({
expected: "undefined",
code: "invalid_type",
input: o,
inst: e
}), n;
};
}), oo = /* @__PURE__ */ c("$ZodNull", (e, t) => {
y.init(e, t), e._zod.pattern = ar, e._zod.values = /* @__PURE__ */ new Set([null]), e._zod.parse = (n, r) => {
const o = n.value;
return o === null || n.issues.push({
expected: "null",
code: "invalid_type",
input: o,
inst: e
}), n;
};
}), io = /* @__PURE__ */ c("$ZodAny", (e, t) => {
y.init(e, t), e._zod.parse = (n) => n;
}), so = /* @__PURE__ */ c("$ZodUnknown", (e, t) => {
y.init(e, t), e._zod.parse = (n) => n;
}), uo = /* @__PURE__ */ c("$ZodNever", (e, t) => {
y.init(e, t), e._zod.parse = (n, r) => (n.issues.push({
expected: "never",
code: "invalid_type",
input: n.value,
inst: e
}), n);
}), co = /* @__PURE__ */ c("$ZodVoid", (e, t) => {
y.init(e, t), e._zod.parse = (n, r) => {
const o = n.value;
return typeof o > "u" || n.issues.push({
expected: "void",
code: "invalid_type",
input: o,
inst: e
}), n;
};
}), ao = /* @__PURE__ */ c("$ZodDate", (e, t) => {
y.init(e, t), e._zod.parse = (n, r) => {
if (t.coerce)
try {
n.value = new Date(n.value);
} catch {
}
const o = n.value, i = o instanceof Date;
return i && !Number.isNaN(o.getTime()) || n.issues.push({
expected: "date",
code: "invalid_type",
input: o,
...i ? { received: "Invalid Date" } : {},
inst: e
}), n;
};
});
function je(e, t, n) {
e.issues.length && t.issues.push(...D(n, e.issues)), t.value[n] = e.value;
}
const lo = /* @__PURE__ */ c("$ZodArray", (e, t) => {
y.init(e, t), e._zod.parse = (n, r) => {
const o = n.value;
if (!Array.isArray(o))
return n.issues.push({
expected: "array",
code: "invalid_type",
input: o,
inst: e
}), n;
n.value = Array(o.length);
const i = [];
for (let s = 0; s < o.length; s++) {
const u = o[s], a = t.element._zod.run({
value: u,
issues: []
}, r);
a instanceof Promise ? i.push(a.then((l) => je(l, n, s))) : je(a, n, s);
}
return i.length ? Promise.all(i).then(() => n) : n;
};
});
function se(e, t, n, r) {
e.issues.length && t.issues.push(...D(n, e.issues)), e.value === void 0 ? n in r && (t.value[n] = void 0) : t.value[n] = e.value;
}
function bt(e) {
const t = Object.keys(e.shape);
for (const r of t)
if (!e.shape?.[r]?._zod?.traits?.has("$ZodType"))
throw new Error(`Invalid element at key "${r}": expected a Zod schema`);
const n = vn(e.shape);
return {
...e,
keys: t,
keySet: new Set(t),
numKeys: t.length,
optionalKeys: new Set(n)
};
}
function zt(e, t, n, r, o, i) {
const s = [], u = o.keySet, a = o.catchall._zod, l = a.def.type;
for (const f of Object.keys(t)) {
if (u.has(f))
continue;
if (l === "never") {
s.push(f);
continue;
}
const v = a.run({ value: t[f], issues: [] }, r);
v instanceof Promise ? e.push(v.then((g) => se(g, n, f, t))) : se(v, n, f, t);
}
return s.length && n.issues.push({
code: "unrecognized_keys",
keys: s,
input: t,
inst: i
}), e.length ? Promise.all(e).then(() => n) : n;
}
const fo = /* @__PURE__ */ c("$ZodObject", (e, t) => {
if (y.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
const u = t.shape;
Object.defineProperty(t, "shape", {
get: () => {
const a = { ...u };
return Object.defineProperty(t, "shape", {
value: a
}), a;
}
});
}
const r = ae(() => bt(t));
z(e._zod, "propValues", () => {
const u = t.shape, a = {};
for (const l in u) {
const f = u[l]._zod;
if (f.values) {
a[l] ?? (a[l] = /* @__PURE__ */ new Set());
for (const v of f.values)
a[l].add(v);
}
}
return a;
});
const o = J, i = t.catchall;
let s;
e._zod.parse = (u, a) => {
s ?? (s = r.value);
const l = u.value;
if (!o(l))
return u.issues.push({
expected: "object",
code: "invalid_type",
input: l,
inst: e
}), u;
u.value = {};
const f = [], v = s.shape;
for (const g of s.keys) {
const k = v[g]._zod.run({ value: l[g], issues: [] }, a);
k instanceof Promise ? f.push(k.then((I) => se(I, u, g, l))) : se(k, u, g, l);
}
return i ? zt(f, l, u, a, r.value, e) : f.length ? Promise.all(f).then(() => u) : u;
};
}), ho = /* @__PURE__ */ c("$ZodObjectJIT", (e, t) => {
fo.init(e, t);
const n = e._zod.parse, r = ae(() => bt(t)), o = (g) => {
const _ = new Ir(["shape", "payload", "ctx"]), k = r.value, I = (O) => {
const E = Pe(O);
return `shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`;
};
_.write("const input = payload.value;");
const Ae = /* @__PURE__ */ Object.create(null);
let on = 0;
for (const O of k.keys)
Ae[O] = `key_${on++}`;
_.write("const newResult = {};");
for (const O of k.keys) {
const E = Ae[O], W = Pe(O);
_.write(`const ${E} = ${I(O)};`), _.write(`
if (${E}.issues.length) {
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
...iss,
path: iss.path ? [${W}, ...iss.path] : [${W}]
})));
}
if (${E}.value === undefined) {
if (${W} in input) {
newResult[${W}] = undefined;
}
} else {
newResult[${W}] = ${E}.value;
}
`);
}
_.write("payload.value = newResult;"), _.write("return payload;");
const sn = _.compile();
return (O, E) => sn(g, O, E);
};
let i;
const s = J, u = !ge.jitless, l = u && gn.value, f = t.catchall;
let v;
e._zod.parse = (g, _) => {
v ?? (v = r.value);
const k = g.value;
return s(k) ? u && l && _?.async === !1 && _.jitless !== !0 ? (i || (i = o(t.shape)), g = i(g, _), f ? zt([], k, g, _, v, e) : g) : n(g, _) : (g.issues.push({
expected: "object",
code: "invalid_type",
input: k,
inst: e
}), g);
};
});
function Ue(e, t, n, r) {
for (const i of e)
if (i.issues.length === 0)
return t.value = i.value, t;
const o = e.filter((i) => !M(i));
return o.length === 1 ? (t.value = o[0].value, o[0]) : (t.issues.push({
code: "invalid_union",
input: t.value,
inst: n,
errors: e.map((i) => i.issues.map((s) => N(s, r, x())))
}), t);
}
const kt = /* @__PURE__ */ c("$ZodUnion", (e, t) => {
y.init(e, t), z(e._zod, "optin", () => t.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), z(e._zod, "optout", () => t.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), z(e._zod, "values", () => {
if (t.options.every((o) => o._zod.values))
return new Set(t.options.flatMap((o) => Array.from(o._zod.values)));
}), z(e._zod, "pattern", () => {
if (t.options.every((o) => o._zod.pattern)) {
const o = t.options.map((i) => i._zod.pattern);
return new RegExp(`^(${o.map((i) => ze(i.source)).join("|")})$`);
}
});
const n = t.options.length === 1, r = t.options[0]._zod.run;
e._zod.parse = (o, i) => {
if (n)
return r(o, i);
let s = !1;
const u = [];
for (const a of t.options) {
const l = a._zod.run({
value: o.value,
issues: []
}, i);
if (l instanceof Promise)
u.push(l), s = !0;
else {
if (l.issues.length === 0)
return l;
u.push(l);
}
}
return s ? Promise.all(u).then((a) => Ue(a, o, e, i)) : Ue(u, o, e, i);
};
}), mo = /* @__PURE__ */ c("$ZodDiscriminatedUnion", (e, t) => {
kt.init(e, t);
const n = e._zod.parse;
z(e._zod, "propValues", () => {
const o = {};
for (const i of t.options) {
const s = i._zod.propValues;
if (!s || Object.keys(s).length === 0)
throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);
for (const [u, a] of Object.entries(s)) {
o[u] || (o[u] = /* @__PURE__ */ new Set());
for (const l of a)
o[u].add(l);
}
}
return o;
});
const r = ae(() => {
const o = t.options, i = /* @__PURE__ */ new Map();
for (const s of o) {
const u = s._zod.propValues?.[t.discriminator];
if (!u || u.size === 0)
throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);
for (const a of u) {
if (i.has(a))
throw new Error(`Duplicate discriminator value "${String(a)}"`);
i.set(a, s);
}
}
return i;
});
e._zod.parse = (o, i) => {
const s = o.value;
if (!J(s))
return o.issues.push({
code: "invalid_type",
expected: "object",
input: s,
inst: e
}), o;
const u = r.value.get(s?.[t.discriminator]);
return u ? u._zod.run(o, i) : t.unionFallback ? n(o, i) : (o.issues.push({
code: "invalid_union",
errors: [],
note: "No matching discriminator",
discriminator: t.discriminator,
input: s,
path: [t.discriminator],
inst: e
}), o);
};
}), po = /* @__PURE__ */ c("$ZodIntersection", (e, t) => {
y.init(e, t), e._zod.parse = (n, r) => {
const o = n.value, i = t.left._zod.run({ value: o, issues: [] }, r), s = t.right._zod.run({ value: o, issues: [] }, r);
return i instanceof Promise || s instanceof Promise ? Promise.all([i, s]).then(([a, l]) => Re(n, a, l)) : Re(n, i, s);
};
});
function ye(e, t) {
if (e === t)
return { valid: !0, data: e };
if (e instanceof Date && t instanceof Date && +e == +t)
return { valid: !0, data: e };
if (H(e) && H(t)) {
const n = Object.keys(t), r = Object.keys(e).filter((i) => n.indexOf(i) !== -1), o = { ...e, ...t };
for (const i of r) {
const s = ye(e[i], t[i]);
if (!s.valid)
return {
valid: !1,
mergeErrorPath: [i, ...s.mergeErrorPath]
};
o[i] = s.data;
}
return { valid: !0, data: o };
}
if (Array.isArray(e) && Array.isArray(t)) {
if (e.length !== t.length)
return { valid: !1, mergeErrorPath: [] };
const n = [];
for (let r = 0; r < e.length; r++) {
const o = e[r], i = t[r], s = ye(o, i);
if (!s.valid)
return {
valid: !1,
mergeErrorPath: [r, ...s.mergeErrorPath]
};
n.push(s.data);
}
return { valid: !0, data: n };
}
return { valid: !1, mergeErrorPath: [] };
}
function Re(e, t, n) {
if (t.issues.length && e.issues.push(...t.issues), n.issues.length && e.issues.push(...n.issues), M(e))
return e;
const r = ye(t.value, n.value);
if (!r.valid)
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);
return e.value = r.data, e;
}
const go = /* @__PURE__ */ c("$ZodTuple", (e, t) => {
y.init(e, t);
const n = t.items, r = n.length - [...n].reverse().findIndex((o) => o._zod.optin !== "optional");
e._zod.parse = (o, i) => {
const s = o.value;
if (!Array.isArray(s))
return o.issues.push({
input: s,
inst: e,
expected: "tuple",
code: "invalid_type"
}), o;
o.value = [];
const u = [];
if (!t.rest) {
const l = s.length > n.length, f = s.length < r - 1;
if (l || f)
return o.issues.push({
...l ? { code: "too_big", maximum: n.length } : { code: "too_small", minimum: n.length },
input: s,
inst: e,
origin: "array"
}), o;
}
let a = -1;
for (const l of n) {
if (a++, a >= s.length && a >= r)
continue;
const f = l._zod.run({
value: s[a],
issues: []
}, i);
f instanceof Promise ? u.push(f.then((v) => ee(v, o, a))) : ee(f, o, a);
}
if (t.rest) {
const l = s.slice(n.length);
for (const f of l) {
a++;
const v = t.rest._zod.run({
value: f,
issues: []
}, i);
v instanceof Promise ? u.push(v.then((g) => ee(g, o, a))) : ee(v, o, a);
}
}
return u.length ? Promise.all(u).then(() => o) : o;
};
});
function ee(e, t, n) {
e.issues.length && t.issues.push(...D(n, e.issues)), t.value[n] = e.value;
}
const vo = /* @__PURE__ */ c("$ZodRecord", (e, t) => {
y.init(e, t), e._zod.parse = (n, r) => {
const o = n.value;
if (!H(o))
return n.issues.push({
expected: "record",
code: "invalid_type",
input: o,
inst: e
}), n;
const i = [];
if (t.keyType._zod.values) {
const s = t.keyType._zod.values;
n.value = {};
for (const a of s)
if (typeof a == "string" || typeof a == "number" || typeof a == "symbol") {