openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
6,837 lines • 218 kB
JavaScript
import { r as __exportAll } from "./rolldown-runtime-Dr7-SnC6.js";
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
var _a$1;
/** A special constant with type `never` */
const NEVER = /*@__PURE__*/ Object.freeze({ status: "aborted" });
function $constructor(name, initializer, params) {
function init(inst, def) {
if (!inst._zod) Object.defineProperty(inst, "_zod", {
value: {
def,
constr: _,
traits: /* @__PURE__ */ new Set()
},
enumerable: false
});
if (inst._zod.traits.has(name)) return;
inst._zod.traits.add(name);
initializer(inst, def);
const proto = _.prototype;
const keys = Object.keys(proto);
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
if (!(k in inst)) inst[k] = proto[k].bind(inst);
}
}
const Parent = params?.Parent ?? Object;
class Definition extends Parent {}
Object.defineProperty(Definition, "name", { value: name });
function _(def) {
var _a;
const inst = params?.Parent ? new Definition() : this;
init(inst, def);
(_a = inst._zod).deferred ?? (_a.deferred = []);
for (const fn of inst._zod.deferred) fn();
return inst;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
if (params?.Parent && inst instanceof params.Parent) return true;
return inst?._zod?.traits?.has(name);
} });
Object.defineProperty(_, "name", { value: name });
return _;
}
const $brand = Symbol("zod_brand");
var $ZodAsyncError = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
var $ZodEncodeError = class extends Error {
constructor(name) {
super(`Encountered unidirectional transform during encode: ${name}`);
this.name = "ZodEncodeError";
}
};
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
const globalConfig = globalThis.__zod_globalConfig;
function config(newConfig) {
if (newConfig) Object.assign(globalConfig, newConfig);
return globalConfig;
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
var util_exports = /* @__PURE__ */ __exportAll({
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
Class: () => Class,
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
aborted: () => aborted,
allowsEval: () => allowsEval,
assert: () => assert,
assertEqual: () => assertEqual,
assertIs: () => assertIs,
assertNever: () => assertNever,
assertNotEqual: () => assertNotEqual,
assignProp: () => assignProp,
base64ToUint8Array: () => base64ToUint8Array,
base64urlToUint8Array: () => base64urlToUint8Array,
cached: () => cached,
captureStackTrace: () => captureStackTrace,
cleanEnum: () => cleanEnum,
cleanRegex: () => cleanRegex,
clone: () => clone,
cloneDef: () => cloneDef,
createTransparentProxy: () => createTransparentProxy,
defineLazy: () => defineLazy,
esc: () => esc,
escapeRegex: () => escapeRegex,
explicitlyAborted: () => explicitlyAborted,
extend: () => extend,
finalizeIssue: () => finalizeIssue,
floatSafeRemainder: () => floatSafeRemainder,
getElementAtPath: () => getElementAtPath,
getEnumValues: () => getEnumValues,
getLengthableOrigin: () => getLengthableOrigin,
getParsedType: () => getParsedType,
getSizableOrigin: () => getSizableOrigin,
hexToUint8Array: () => hexToUint8Array,
isObject: () => isObject,
isPlainObject: () => isPlainObject,
issue: () => issue,
joinValues: () => joinValues,
jsonStringifyReplacer: () => jsonStringifyReplacer,
merge: () => merge,
mergeDefs: () => mergeDefs,
normalizeParams: () => normalizeParams,
nullish: () => nullish$1,
numKeys: () => numKeys,
objectClone: () => objectClone,
omit: () => omit,
optionalKeys: () => optionalKeys,
parsedType: () => parsedType,
partial: () => partial,
pick: () => pick,
prefixIssues: () => prefixIssues,
primitiveTypes: () => primitiveTypes,
promiseAllObject: () => promiseAllObject,
propertyKeyTypes: () => propertyKeyTypes,
randomString: () => randomString,
required: () => required,
safeExtend: () => safeExtend,
shallowClone: () => shallowClone,
slugify: () => slugify,
stringifyPrimitive: () => stringifyPrimitive,
uint8ArrayToBase64: () => uint8ArrayToBase64,
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
uint8ArrayToHex: () => uint8ArrayToHex,
unwrapMessage: () => unwrapMessage
});
function assertEqual(val) {
return val;
}
function assertNotEqual(val) {
return val;
}
function assertIs(_arg) {}
function assertNever(_x) {
throw new Error("Unexpected value in exhaustive check");
}
function assert(_) {}
function getEnumValues(entries) {
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
}
function joinValues(array, separator = "|") {
return array.map((val) => stringifyPrimitive(val)).join(separator);
}
function jsonStringifyReplacer(_, value) {
if (typeof value === "bigint") return value.toString();
return value;
}
function cached(getter) {
return { get value() {
{
const value = getter();
Object.defineProperty(this, "value", { value });
return value;
}
} };
}
function nullish$1(input) {
return input === null || input === void 0;
}
function cleanRegex(source) {
const start = source.startsWith("^") ? 1 : 0;
const end = source.endsWith("$") ? source.length - 1 : source.length;
return source.slice(start, end);
}
function floatSafeRemainder(val, step) {
const ratio = val / step;
const roundedRatio = Math.round(ratio);
const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
return ratio - roundedRatio;
}
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
function defineLazy(object, key, getter) {
let value = void 0;
Object.defineProperty(object, key, {
get() {
if (value === EVALUATING) return;
if (value === void 0) {
value = EVALUATING;
value = getter();
}
return value;
},
set(v) {
Object.defineProperty(object, key, { value: v });
},
configurable: true
});
}
function objectClone(obj) {
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
}
function assignProp(target, prop, value) {
Object.defineProperty(target, prop, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
function mergeDefs(...defs) {
const mergedDescriptors = {};
for (const def of defs) {
const descriptors = Object.getOwnPropertyDescriptors(def);
Object.assign(mergedDescriptors, descriptors);
}
return Object.defineProperties({}, mergedDescriptors);
}
function cloneDef(schema) {
return mergeDefs(schema._zod.def);
}
function getElementAtPath(obj, path) {
if (!path) return obj;
return path.reduce((acc, key) => acc?.[key], obj);
}
function promiseAllObject(promisesObj) {
const keys = Object.keys(promisesObj);
const promises = keys.map((key) => promisesObj[key]);
return Promise.all(promises).then((results) => {
const resolvedObj = {};
for (let i = 0; i < keys.length; i++) resolvedObj[keys[i]] = results[i];
return resolvedObj;
});
}
function randomString(length = 10) {
const chars = "abcdefghijklmnopqrstuvwxyz";
let str = "";
for (let i = 0; i < length; i++) str += chars[Math.floor(Math.random() * 26)];
return str;
}
function esc(str) {
return JSON.stringify(str);
}
function slugify(input) {
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
function isObject(data) {
return typeof data === "object" && data !== null && !Array.isArray(data);
}
const allowsEval = /* @__PURE__*/ cached(() => {
if (globalConfig.jitless) return false;
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
try {
new Function("");
return true;
} catch (_) {
return false;
}
});
function isPlainObject(o) {
if (isObject(o) === false) return false;
const ctor = o.constructor;
if (ctor === void 0) return true;
if (typeof ctor !== "function") return true;
const prot = ctor.prototype;
if (isObject(prot) === false) return false;
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
return true;
}
function shallowClone(o) {
if (isPlainObject(o)) return { ...o };
if (Array.isArray(o)) return [...o];
if (o instanceof Map) return new Map(o);
if (o instanceof Set) return new Set(o);
return o;
}
function numKeys(data) {
let keyCount = 0;
for (const key in data) if (Object.prototype.hasOwnProperty.call(data, key)) keyCount++;
return keyCount;
}
const getParsedType = (data) => {
const t = typeof data;
switch (t) {
case "undefined": return "undefined";
case "string": return "string";
case "number": return Number.isNaN(data) ? "nan" : "number";
case "boolean": return "boolean";
case "function": return "function";
case "bigint": return "bigint";
case "symbol": return "symbol";
case "object":
if (Array.isArray(data)) return "array";
if (data === null) return "null";
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") return "promise";
if (typeof Map !== "undefined" && data instanceof Map) return "map";
if (typeof Set !== "undefined" && data instanceof Set) return "set";
if (typeof Date !== "undefined" && data instanceof Date) return "date";
if (typeof File !== "undefined" && data instanceof File) return "file";
return "object";
default: throw new Error(`Unknown data type: ${t}`);
}
};
const propertyKeyTypes = /* @__PURE__*/ new Set([
"string",
"number",
"symbol"
]);
const primitiveTypes = /* @__PURE__*/ new Set([
"string",
"number",
"bigint",
"boolean",
"symbol",
"undefined"
]);
function escapeRegex(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(inst, def, params) {
const cl = new inst._zod.constr(def ?? inst._zod.def);
if (!def || params?.parent) cl._zod.parent = inst;
return cl;
}
function normalizeParams(_params) {
const params = _params;
if (!params) return {};
if (typeof params === "string") return { error: () => params };
if (params?.message !== void 0) {
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
params.error = params.message;
}
delete params.message;
if (typeof params.error === "string") return {
...params,
error: () => params.error
};
return params;
}
function createTransparentProxy(getter) {
let target;
return new Proxy({}, {
get(_, prop, receiver) {
target ?? (target = getter());
return Reflect.get(target, prop, receiver);
},
set(_, prop, value, receiver) {
target ?? (target = getter());
return Reflect.set(target, prop, value, receiver);
},
has(_, prop) {
target ?? (target = getter());
return Reflect.has(target, prop);
},
deleteProperty(_, prop) {
target ?? (target = getter());
return Reflect.deleteProperty(target, prop);
},
ownKeys(_) {
target ?? (target = getter());
return Reflect.ownKeys(target);
},
getOwnPropertyDescriptor(_, prop) {
target ?? (target = getter());
return Reflect.getOwnPropertyDescriptor(target, prop);
},
defineProperty(_, prop, descriptor) {
target ?? (target = getter());
return Reflect.defineProperty(target, prop, descriptor);
}
});
}
function stringifyPrimitive(value) {
if (typeof value === "bigint") return value.toString() + "n";
if (typeof value === "string") return `"${value}"`;
return `${value}`;
}
function optionalKeys(shape) {
return Object.keys(shape).filter((k) => {
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
});
}
const NUMBER_FORMAT_RANGES = {
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]
};
const BIGINT_FORMAT_RANGES = {
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
};
function pick(schema, mask) {
const currDef = schema._zod.def;
const checks = currDef.checks;
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
return clone(schema, mergeDefs(schema._zod.def, {
get shape() {
const newShape = {};
for (const key in mask) {
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
newShape[key] = currDef.shape[key];
}
assignProp(this, "shape", newShape);
return newShape;
},
checks: []
}));
}
function omit(schema, mask) {
const currDef = schema._zod.def;
const checks = currDef.checks;
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
return clone(schema, mergeDefs(schema._zod.def, {
get shape() {
const newShape = { ...schema._zod.def.shape };
for (const key in mask) {
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
delete newShape[key];
}
assignProp(this, "shape", newShape);
return newShape;
},
checks: []
}));
}
function extend(schema, shape) {
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
const checks = schema._zod.def.checks;
if (checks && checks.length > 0) {
const existingShape = schema._zod.def.shape;
for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
}
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
const _shape = {
...schema._zod.def.shape,
...shape
};
assignProp(this, "shape", _shape);
return _shape;
} }));
}
function safeExtend(schema, shape) {
if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
const _shape = {
...schema._zod.def.shape,
...shape
};
assignProp(this, "shape", _shape);
return _shape;
} }));
}
function merge(a, b) {
if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
return clone(a, mergeDefs(a._zod.def, {
get shape() {
const _shape = {
...a._zod.def.shape,
...b._zod.def.shape
};
assignProp(this, "shape", _shape);
return _shape;
},
get catchall() {
return b._zod.def.catchall;
},
checks: b._zod.def.checks ?? []
}));
}
function partial(Class, schema, mask) {
const checks = schema._zod.def.checks;
if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
return clone(schema, mergeDefs(schema._zod.def, {
get shape() {
const oldShape = schema._zod.def.shape;
const shape = { ...oldShape };
if (mask) for (const key in mask) {
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
shape[key] = Class ? new Class({
type: "optional",
innerType: oldShape[key]
}) : oldShape[key];
}
else for (const key in oldShape) shape[key] = Class ? new Class({
type: "optional",
innerType: oldShape[key]
}) : oldShape[key];
assignProp(this, "shape", shape);
return shape;
},
checks: []
}));
}
function required(Class, schema, mask) {
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
const oldShape = schema._zod.def.shape;
const shape = { ...oldShape };
if (mask) for (const key in mask) {
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
shape[key] = new Class({
type: "nonoptional",
innerType: oldShape[key]
});
}
else for (const key in oldShape) shape[key] = new Class({
type: "nonoptional",
innerType: oldShape[key]
});
assignProp(this, "shape", shape);
return shape;
} }));
}
function aborted(x, startIndex = 0) {
if (x.aborted === true) return true;
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
return false;
}
function explicitlyAborted(x, startIndex = 0) {
if (x.aborted === true) return true;
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
return false;
}
function prefixIssues(path, issues) {
return issues.map((iss) => {
var _a;
(_a = iss).path ?? (_a.path = []);
iss.path.unshift(path);
return iss;
});
}
function unwrapMessage(message) {
return typeof message === "string" ? message : message?.message;
}
function finalizeIssue(iss, ctx, config) {
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
rest.path ?? (rest.path = []);
rest.message = message;
if (ctx?.reportInput) rest.input = _input;
return rest;
}
function getSizableOrigin(input) {
if (input instanceof Set) return "set";
if (input instanceof Map) return "map";
if (input instanceof File) return "file";
return "unknown";
}
function getLengthableOrigin(input) {
if (Array.isArray(input)) return "array";
if (typeof input === "string") return "string";
return "unknown";
}
function parsedType(data) {
const t = typeof data;
switch (t) {
case "number": return Number.isNaN(data) ? "nan" : "number";
case "object": {
if (data === null) return "null";
if (Array.isArray(data)) return "array";
const obj = data;
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
}
}
return t;
}
function issue(...args) {
const [iss, input, inst] = args;
if (typeof iss === "string") return {
message: iss,
code: "custom",
input,
inst
};
return { ...iss };
}
function cleanEnum(obj) {
return Object.entries(obj).filter(([k, _]) => {
return Number.isNaN(Number.parseInt(k, 10));
}).map((el) => el[1]);
}
function base64ToUint8Array(base64) {
const binaryString = atob(base64);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) bytes[i] = binaryString.charCodeAt(i);
return bytes;
}
function uint8ArrayToBase64(bytes) {
let binaryString = "";
for (let i = 0; i < bytes.length; i++) binaryString += String.fromCharCode(bytes[i]);
return btoa(binaryString);
}
function base64urlToUint8Array(base64url) {
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
return base64ToUint8Array(base64 + "=".repeat((4 - base64.length % 4) % 4));
}
function uint8ArrayToBase64url(bytes) {
return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
}
function hexToUint8Array(hex) {
const cleanHex = hex.replace(/^0x/, "");
if (cleanHex.length % 2 !== 0) throw new Error("Invalid hex string length");
const bytes = new Uint8Array(cleanHex.length / 2);
for (let i = 0; i < cleanHex.length; i += 2) bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
return bytes;
}
function uint8ArrayToHex(bytes) {
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
}
var Class = class {
constructor(..._args) {}
};
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
const initializer$1 = (inst, def) => {
inst.name = "$ZodError";
Object.defineProperty(inst, "_zod", {
value: inst._zod,
enumerable: false
});
Object.defineProperty(inst, "issues", {
value: def,
enumerable: false
});
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
Object.defineProperty(inst, "toString", {
value: () => inst.message,
enumerable: false
});
};
const $ZodError = $constructor("$ZodError", initializer$1);
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
function flattenError(error, mapper = (issue) => issue.message) {
const fieldErrors = {};
const formErrors = [];
for (const sub of error.issues) if (sub.path.length > 0) {
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
fieldErrors[sub.path[0]].push(mapper(sub));
} else formErrors.push(mapper(sub));
return {
formErrors,
fieldErrors
};
}
function formatError(error, mapper = (issue) => issue.message) {
const fieldErrors = { _errors: [] };
const processError = (error, path = []) => {
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
else {
const fullpath = [...path, ...issue.path];
if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
else {
let curr = fieldErrors;
let i = 0;
while (i < fullpath.length) {
const el = fullpath[i];
if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
else {
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(mapper(issue));
}
curr = curr[el];
i++;
}
}
}
};
processError(error);
return fieldErrors;
}
function treeifyError(error, mapper = (issue) => issue.message) {
const result = { errors: [] };
const processError = (error, path = []) => {
var _a, _b;
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
else {
const fullpath = [...path, ...issue.path];
if (fullpath.length === 0) {
result.errors.push(mapper(issue));
continue;
}
let curr = result;
let i = 0;
while (i < fullpath.length) {
const el = fullpath[i];
const terminal = i === fullpath.length - 1;
if (typeof el === "string") {
curr.properties ?? (curr.properties = {});
(_a = curr.properties)[el] ?? (_a[el] = { errors: [] });
curr = curr.properties[el];
} else {
curr.items ?? (curr.items = []);
(_b = curr.items)[el] ?? (_b[el] = { errors: [] });
curr = curr.items[el];
}
if (terminal) curr.errors.push(mapper(issue));
i++;
}
}
};
processError(error);
return result;
}
/** Format a ZodError as a human-readable string in the following form.
*
* From
*
* ```ts
* ZodError {
* issues: [
* {
* expected: 'string',
* code: 'invalid_type',
* path: [ 'username' ],
* message: 'Invalid input: expected string'
* },
* {
* expected: 'number',
* code: 'invalid_type',
* path: [ 'favoriteNumbers', 1 ],
* message: 'Invalid input: expected number'
* }
* ];
* }
* ```
*
* to
*
* ```
* username
* ✖ Expected number, received string at "username
* favoriteNumbers[0]
* ✖ Invalid input: expected number
* ```
*/
function toDotPath(_path) {
const segs = [];
const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
for (const seg of path) if (typeof seg === "number") segs.push(`[${seg}]`);
else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`);
else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`);
else {
if (segs.length) segs.push(".");
segs.push(seg);
}
return segs.join("");
}
function prettifyError(error) {
const lines = [];
const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
for (const issue of issues) {
lines.push(`✖ ${issue.message}`);
if (issue.path?.length) lines.push(` → at ${toDotPath(issue.path)}`);
}
return lines.join("\n");
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
const _parse = (_Err) => (schema, value, _ctx, _params) => {
const ctx = _ctx ? {
..._ctx,
async: false
} : { async: false };
const result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) throw new $ZodAsyncError();
if (result.issues.length) {
const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
captureStackTrace(e, _params?.callee);
throw e;
}
return result.value;
};
const parse$1 = /* @__PURE__*/ _parse($ZodRealError);
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
const ctx = _ctx ? {
..._ctx,
async: true
} : { async: true };
let result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) result = await result;
if (result.issues.length) {
const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
captureStackTrace(e, params?.callee);
throw e;
}
return result.value;
};
const parseAsync$1 = /* @__PURE__*/ _parseAsync($ZodRealError);
const _safeParse = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
async: false
} : { async: false };
const result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) throw new $ZodAsyncError();
return result.issues.length ? {
success: false,
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
} : {
success: true,
data: result.value
};
};
const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
async: true
} : { async: true };
let result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) result = await result;
return result.issues.length ? {
success: false,
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
} : {
success: true,
data: result.value
};
};
const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
const _encode = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
direction: "backward"
} : { direction: "backward" };
return _parse(_Err)(schema, value, ctx);
};
const encode$1 = /* @__PURE__*/ _encode($ZodRealError);
const _decode = (_Err) => (schema, value, _ctx) => {
return _parse(_Err)(schema, value, _ctx);
};
const decode$1 = /* @__PURE__*/ _decode($ZodRealError);
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
direction: "backward"
} : { direction: "backward" };
return _parseAsync(_Err)(schema, value, ctx);
};
const encodeAsync$1 = /* @__PURE__*/ _encodeAsync($ZodRealError);
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
return _parseAsync(_Err)(schema, value, _ctx);
};
const decodeAsync$1 = /* @__PURE__*/ _decodeAsync($ZodRealError);
const _safeEncode = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
direction: "backward"
} : { direction: "backward" };
return _safeParse(_Err)(schema, value, ctx);
};
const safeEncode$1 = /* @__PURE__*/ _safeEncode($ZodRealError);
const _safeDecode = (_Err) => (schema, value, _ctx) => {
return _safeParse(_Err)(schema, value, _ctx);
};
const safeDecode$1 = /* @__PURE__*/ _safeDecode($ZodRealError);
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
direction: "backward"
} : { direction: "backward" };
return _safeParseAsync(_Err)(schema, value, ctx);
};
const safeEncodeAsync$1 = /* @__PURE__*/ _safeEncodeAsync($ZodRealError);
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
return _safeParseAsync(_Err)(schema, value, _ctx);
};
const safeDecodeAsync$1 = /* @__PURE__*/ _safeDecodeAsync($ZodRealError);
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
var regexes_exports = /* @__PURE__ */ __exportAll({
base64: () => base64$1,
base64url: () => base64url$1,
bigint: () => bigint$1,
boolean: () => boolean$1,
browserEmail: () => browserEmail,
cidrv4: () => cidrv4$1,
cidrv6: () => cidrv6$1,
cuid: () => cuid$1,
cuid2: () => cuid2$1,
date: () => date$2,
datetime: () => datetime$1,
domain: () => domain,
duration: () => duration$1,
e164: () => e164$1,
email: () => email$1,
emoji: () => emoji$1,
extendedDuration: () => extendedDuration,
guid: () => guid$1,
hex: () => hex$1,
hostname: () => hostname$1,
html5Email: () => html5Email,
httpProtocol: () => httpProtocol,
idnEmail: () => idnEmail,
integer: () => integer,
ipv4: () => ipv4$1,
ipv6: () => ipv6$1,
ksuid: () => ksuid$1,
lowercase: () => lowercase,
mac: () => mac$1,
md5_base64: () => md5_base64,
md5_base64url: () => md5_base64url,
md5_hex: () => md5_hex,
nanoid: () => nanoid$1,
null: () => _null$2,
number: () => number$1,
rfc5322Email: () => rfc5322Email,
sha1_base64: () => sha1_base64,
sha1_base64url: () => sha1_base64url,
sha1_hex: () => sha1_hex,
sha256_base64: () => sha256_base64,
sha256_base64url: () => sha256_base64url,
sha256_hex: () => sha256_hex,
sha384_base64: () => sha384_base64,
sha384_base64url: () => sha384_base64url,
sha384_hex: () => sha384_hex,
sha512_base64: () => sha512_base64,
sha512_base64url: () => sha512_base64url,
sha512_hex: () => sha512_hex,
string: () => string$1,
time: () => time$1,
ulid: () => ulid$1,
undefined: () => _undefined$2,
unicodeEmail: () => unicodeEmail,
uppercase: () => uppercase,
uuid: () => uuid$1,
uuid4: () => uuid4,
uuid6: () => uuid6,
uuid7: () => uuid7,
xid: () => xid$1
});
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link cuid2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const cuid$1 = /^[cC][0-9a-z]{6,}$/;
const cuid2$1 = /^[0-9a-z]+$/;
const ulid$1 = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
const xid$1 = /^[0-9a-vA-V]{20}$/;
const ksuid$1 = /^[A-Za-z0-9]{27}$/;
const nanoid$1 = /^[a-zA-Z0-9_-]{21}$/;
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
const extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
const guid$1 = /^([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})$/;
/** Returns a regex for validating an RFC 9562/4122 UUID.
*
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
const uuid$1 = (version) => {
if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
};
const uuid4 = /*@__PURE__*/ uuid$1(4);
const uuid6 = /*@__PURE__*/ uuid$1(6);
const uuid7 = /*@__PURE__*/ uuid$1(7);
/** Practical email validation */
const email$1 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
/** The classic emailregex.com regex for RFC 5322-compliant emails */
const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
const idnEmail = unicodeEmail;
const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
function emoji$1() {
return new RegExp(_emoji$1, "u");
}
const ipv4$1 = /^(?:(?: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])$/;
const ipv6$1 = /^(([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}|:))$/;
const mac$1 = (delimiter) => {
const escapedDelim = escapeRegex(delimiter ?? ":");
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
};
const cidrv4$1 = /^((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])$/;
const cidrv6$1 = /^(([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])$/;
const base64$1 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
const base64url$1 = /^[A-Za-z0-9_-]*$/;
const hostname$1 = /^(?=.{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])?)*\.?$/;
const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
const httpProtocol = /^https?$/;
const e164$1 = /^\+[1-9]\d{6,14}$/;
const dateSource = `(?:(?:\\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])))`;
const date$2 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
function timeSource(args) {
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
}
function time$1(args) {
return new RegExp(`^${timeSource(args)}$`);
}
function datetime$1(args) {
const time = timeSource({ precision: args.precision });
const opts = ["Z"];
if (args.local) opts.push("");
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
const timeRegex = `${time}(?:${opts.join("|")})`;
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
}
const string$1 = (params) => {
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
return new RegExp(`^${regex}$`);
};
const bigint$1 = /^-?\d+n?$/;
const integer = /^-?\d+$/;
const number$1 = /^-?\d+(?:\.\d+)?$/;
const boolean$1 = /^(?:true|false)$/i;
const _null$2 = /^null$/i;
const _undefined$2 = /^undefined$/i;
const lowercase = /^[^A-Z]*$/;
const uppercase = /^[^a-z]*$/;
const hex$1 = /^[0-9a-fA-F]*$/;
function fixedBase64(bodyLength, padding) {
return new RegExp(`^[A-Za-z0-9+/]{${bodyLength}}${padding}$`);
}
function fixedBase64url(length) {
return new RegExp(`^[A-Za-z0-9_-]{${length}}$`);
}
const md5_hex = /^[0-9a-fA-F]{32}$/;
const md5_base64 = /*@__PURE__*/ fixedBase64(22, "==");
const md5_base64url = /*@__PURE__*/ fixedBase64url(22);
const sha1_hex = /^[0-9a-fA-F]{40}$/;
const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "=");
const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);
const sha256_hex = /^[0-9a-fA-F]{64}$/;
const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "=");
const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);
const sha384_hex = /^[0-9a-fA-F]{96}$/;
const sha384_base64 = /*@__PURE__*/ fixedBase64(64, "");
const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);
const sha512_hex = /^[0-9a-fA-F]{128}$/;
const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
var _a;
inst._zod ?? (inst._zod = {});
inst._zod.def = def;
(_a = inst._zod).onattach ?? (_a.onattach = []);
});
const numericOriginMap = {
number: "number",
bigint: "bigint",
object: "date"
};
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
$ZodCheck.init(inst, def);
const origin = numericOriginMap[typeof def.value];
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
if (def.value < curr) {
if (def.inclusive) bag.maximum = def.value;
else bag.exclusiveMaximum = def.value;
}
});
inst._zod.check = (payload) => {
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
payload.issues.push({
origin,
code: "too_big",
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
input: payload.value,
inclusive: def.inclusive,
inst,
continue: !def.abort
});
};
});
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
$ZodCheck.init(inst, def);
const origin = numericOriginMap[typeof def.value];
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
if (def.value > curr) {
if (def.inclusive) bag.minimum = def.value;
else bag.exclusiveMinimum = def.value;
}
});
inst._zod.check = (payload) => {
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
payload.issues.push({
origin,
code: "too_small",
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
input: payload.value,
inclusive: def.inclusive,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
$ZodCheck.init(inst, def);
inst._zod.onattach.push((inst) => {
var _a;
(_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
});
inst._zod.check = (payload) => {
if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
payload.issues.push({
origin: typeof payload.value,
code: "not_multiple_of",
divisor: def.value,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
$ZodCheck.init(inst, def);
def.format = def.format || "float64";
const isInt = def.format?.includes("int");
const origin = isInt ? "int" : "number";
const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.format = def.format;
bag.minimum = minimum;
bag.maximum = maximum;
if (isInt) bag.pattern = integer;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (isInt) {
if (!Number.isInteger(input)) {
payload.issues.push({
expected: origin,
format: def.format,
code: "invalid_type",
continue: false,
input,
inst
});
return;
}
if (!Number.isSafeInteger(input)) {
if (input > 0) payload.issues.push({
input,
code: "too_big",
maximum: Number.MAX_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst,
origin,
inclusive: true,
continue: !def.abort
});
else payload.issues.push({
input,
code: "too_small",
minimum: Number.MIN_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst,
origin,
inclusive: true,
continue: !def.abort
});
return;
}
}
if (input < minimum) payload.issues.push({
origin: "number",
input,
code: "too_small",
minimum,
inclusive: true,
inst,
continue: !def.abort
});
if (input > maximum) payload.issues.push({
origin: "number",
input,
code: "too_big",
maximum,
inclusive: true,
inst,
continue: !def.abort
});
};
});
const $ZodCheckBigIntFormat = /*@__PURE__*/ $constructor("$ZodCheckBigIntFormat", (inst, def) => {
$ZodCheck.init(inst, def);
const [minimum, maximum] = BIGINT_FORMAT_RANGES[def.format];
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.format = def.format;
bag.minimum = minimum;
bag.maximum = maximum;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (input < minimum) payload.issues.push({
origin: "bigint",
input,
code: "too_small",
minimum,
inclusive: true,
inst,
continue: !def.abort
});
if (input > maximum) payload.issues.push({
origin: "bigint",
input,
code: "too_big",
maximum,
inclusive: true,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMaxSize = /*@__PURE__*/ $constructor("$ZodCheckMaxSize", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$1(val) && val.size !== void 0;
});
inst._zod.onattach.push((inst) => {
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (input.size <= def.maximum) return;
payload.issues.push({
origin: getSizableOrigin(input),
code: "too_big",
maximum: def.maximum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMinSize = /*@__PURE__*/ $constructor("$ZodCheckMinSize", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$1(val) && val.size !== void 0;
});
inst._zod.onattach.push((inst) => {
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (input.size >= def.minimum) return;
payload.issues.push({
origin: getSizableOrigin(input),
code: "too_small",
minimum: def.minimum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckSizeEquals = /*@__PURE__*/ $constructor("$ZodCheckSizeEquals", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$1(val) && val.size !== void 0;
});
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.minimum = def.size;
bag.maximum = def.size;
bag.size = def.size;
});
inst._zod.check = (payload) => {
const input = payload.value;
const size = input.size;
if (size === def.size) return;
const tooBig = size > def.size;
payload.issues.push({
origin: getSizableOrigin(input),
...tooBig ? {
code: "too_big",
maximum: def.size
} : {
code: "too_small",
minimum: def.size
},
inclusive: true,
exact: true,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$1(val) && val.length !== void 0;
});
inst._zod.onattach.push((inst) => {
const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (input.length <= def.maximum) return;
const origin = getLengthableOrigin(input);
payload.issues.push({
origin,
code: "too_big",
maximum: def.maximum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$1(val) && val.length !== void 0;
});
inst._zod.onattach.push((inst) => {
const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (input.length >= def.minimum) return;
const origin = getLengthableOrigin(input);
payload.issues.push({
origin,
code: "too_small",
minimum: def.minimum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
var _a;
$ZodCheck.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$1(val) && val.length !== void 0;
});
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.minimum = def.length;
bag.maximum = def.length;
bag.length = def.length;
});
inst._zod.check = (payload) => {
const input = payload.value;
const length = input.length;
if (length === def.length) return;
const origin = getLengthableOrigin(input);
const tooBig = length > def.length;
payload.issues.push({
origin,
...tooBig ? {
code: "too_big",
maximum: def.length
} : {
code: "too_small",
minimum: def.length
},
inclusive: true,
exact: true,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
var _a, _b;
$ZodCheck.init(inst, def);
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.format = def.format;
if (def.pattern) {
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(def.pattern);
}
});
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
def.pattern.lastIndex = 0;
if (def.pattern.test(payload.value)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: def.format,
input: payload.value,
...def.pattern ? { pattern: def.pattern.toString() } : {},
inst,
continue: !def.abort
});
});
else (_b = inst._zod).check ?? (_b.check = () => {});
});
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
$ZodCheckStringFormat.init(inst, def);
inst._zod.check = (payload) => {
def.pattern.lastIndex = 0;
if (def.pattern.test(payload.value)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "regex",
input: payload.value,
pattern: def.pattern.toString(),
inst,
continue: !def.abort
});
};
});
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
def.pattern ?? (def.pattern = lowercase);
$ZodCheckStringFormat.init(inst, def);
});
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
def.pattern ?? (def.pattern = uppercase);
$ZodCheckStringFormat.init(inst, def);
});
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
$ZodCheck.init(inst, def);
const escapedRegex = escapeRegex(def.includes);
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
def.pattern = pattern;
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(pattern);
});
inst._zod.check = (payload) => {
if (payload.value.includes(def.includes, def.position)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "includes",
includes: def.includes,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
$ZodCheck.init(inst, def);
const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
def.pattern ?? (def.pattern = pattern);
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(pattern);
});
inst._zod.check = (payload) => {
if (payload.value.startsWith(def.prefix)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "starts_with",
prefix: def.prefix,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
$ZodCheck.init(inst, def);
const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
def.pattern ?? (def.pattern = pattern);
inst._zod.onattach.push((inst) => {
const bag = inst._zod.bag;
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(pattern);
});
inst._zod.check = (payload) => {
if (payload.value.endsWith(def.suffix)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "ends_with",
suffix: def.suffix,
input: payload.value,
inst,
continue: !def.abort
});
};
});
function handleCheckPropertyResult(result, payload, property) {
if (result.issues.length) payload.issues.push(...prefixIssues(property, result.issues));
}
const $ZodCheckProperty = /*@__PURE__*/ $constructor("$ZodCheckProperty", (inst, def) => {
$ZodCheck.init(inst, def);
inst._zod.check = (payload) => {
const result = def.schema._zod.run({
value: payload.value[def.property],
issues: []
}, {});
if (result instanceof Promise) return result.then((result) => handleCheckPropertyResult(result, payload, def.property));
handleCheckPropertyResult(result, payload, def.property);
};
});
const $ZodCheckMimeType = /*@__PURE__*/ $constructor("$ZodCheckMimeType", (inst, def) => {
$ZodCheck.init(inst, def);
const mimeSet = new Set(def.mime);
inst._zod.onattach.push((inst) => {
inst._zod.bag.mime = def.mime;
});
inst._zod.check = (payload) => {
if (mimeSet.has(payload.value.type)) return;
payload.issues.push({
code: "invalid_value",
values: def.mime,
input: payload.value.type,
inst,
continue: !def.abort
});
};
});
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
$ZodCheck.init(inst, def);
inst._zod.check = (payload) => {
payload.value = def.tx(payload.value);
};
});
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
var Doc = class {
constructor(args = []) {
this.content = [];
this.indent = 0;
if (this) this.args = args;
}
indented(fn) {
this.indent += 1;
fn(this);
this.indent -= 1;
}
write(arg) {
if (typeof arg === "function") {
arg(this, { execution: "sync" });
arg(this, { execution: "async" });
return;
}
const lines = arg.split("\n").filter((x) => x);
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
for (const line of dedented) this.content.push(line);
}
compile() {
const F = Function;
const args = this?.args;
const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
return new F(...args, lines.join("\n"));
}
};
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
const version = {
major: 4,
minor: 4,
patch: 3
};
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
var _a;
inst ?? (inst = {});
inst._zod.def = def;
inst._zod.bag = inst._zod.bag || {};
inst._zod.version = version;
const checks = [...inst._zod.def.checks ?? []];
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
if (checks.length === 0) {
(_a = inst._zod).deferred ?? (_a.deferred = []);
inst._zod.deferred?.push(() => {
inst._zod.run = inst._zod.parse;
});
} else {
const runChecks = (payload, checks, ctx) => {
let isAborted = aborted(payload);
let asyncResult;
for (const ch of checks) {
if (ch._zod.def.when) {
if (explicitlyAborted(payload)) continue;
if (!ch._zod.def.when(payload)) continue;
} else if (isAborted) continue;
const currLen = payload.issues.length;
const _ = ch._zod.check(payload);
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
await _;
if (payload.issues.length === currLen) return;
if (!isAborted) isAborted = aborted(payload, currLen);
});
else {
if (payload.issues.length === currLen) continue;
if (!isAborted) isAborted = aborted(payload, currLen);
}
}
if (asyncResult) return asyncResult.then(() => {
return payload;
});
return payload;
};
const handleCanaryResult = (canary, payload, ctx) => {
if (aborted(canary)) {
canary.aborted = true;
return canary;
}
const checkResult = runChecks(payload, checks, ctx);
if (checkResult instanceof Promise) {
if (ctx.async === false) throw new $ZodAsyncError();
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
}
return inst._zod.parse(checkResult, ctx);
};
inst._zod.run = (payload, ctx) => {
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
if (ctx.direction === "backward") {
const canary = inst._zod.parse({
value: payload.value,
issues: []
}, {
...ctx,
skipChecks: true
});
if (canary instanceof Promise) return canary.then((canary) => {
return handleCanaryResult(canary, payload, ctx);
});
return handleCanaryResult(canary, payload, ctx);
}
const result = inst._zod.parse(payload, ctx);
if (result instanceof Promise) {
if (ctx.async === false) throw new $ZodAsyncError();
return result.then((result) => runChecks(result, checks, ctx));
}
return runChecks(result, checks, ctx);
};
}
defineLazy(inst, "~standard", () => ({
validate: (value) => {
try {
const r = safeParse$1(inst, value);
return r.success ? { value: r.data } : { issues: r.error?.issues };
} catch (_) {
return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
}
},
vendor: "zod",
version: 1
}));
});
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
inst._zod.parse = (payload, _) => {
if (def.coerce) try {
payload.value = String(payload.value);
} catch (_) {}
if (typeof payload.value === "string") return payload;
payload.issues.push({
expected: "string",
code: "invalid_type",
input: payload.value,
inst
});
return payload;
};
});
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
$ZodCheckStringFormat.init(inst, def);
$ZodString.init(inst, def);
});
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
def.pattern ?? (def.pattern = guid$1);
$ZodStringFormat.init(inst, def);
});
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
if (def.version) {
const v = {
v1: 1,
v2: 2,
v3: 3,
v4: 4,
v5: 5,
v6: 6,
v7: 7,
v8: 8
}[def.version];
if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
def.pattern ?? (def.pattern = uuid$1(v));
} else def.pattern ?? (def.pattern = uuid$1());
$ZodStringFormat.init(inst, def);
});
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
def.pattern ?? (def.pattern = email$1);
$ZodStringFormat.init(inst, def);
});
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
$ZodStringFormat.init(inst, def);
inst._zod.check = (payload) => {
try {
const trimmed = payload.value.trim();
if (!def.normalize && def.protocol?.source === httpProtocol.source) {
if (!/^https?:\/\//i.test(trimmed)) {
payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid URL format",
input: payload.value,
inst,
continue: !def.abort
});
return;
}
}
const url = new URL(trimmed);
if (def.hostname) {
def.hostname.lastIndex = 0;
if (!def.hostname.test(url.hostname)) payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: def.hostname.source,
input: payload.value,
inst,
continue: !def.abort
});
}
if (def.protocol) {
def.protocol.lastIndex = 0;
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid protocol",
pattern: def.protocol.source,
input: payload.value,
inst,
continue: !def.abort
});
}
if (def.normalize) payload.value = url.href;
else payload.value = trimmed;
return;
} catch (_) {
payload.issues.push({
code: "invalid_format",
format: "url",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
def.pattern ?? (def.pattern = emoji$1());
$ZodStringFormat.init(inst, def);
});
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
def.pattern ?? (def.pattern = nanoid$1);
$ZodStringFormat.init(inst, def);
});
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
def.pattern ?? (def.pattern = cuid$1);
$ZodStringFormat.init(inst, def);
});
const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
def.pattern ?? (def.pattern = cuid2$1);
$ZodStringFormat.init(inst, def);
});
const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
def.pattern ?? (def.pattern = ulid$1);
$ZodStringFormat.init(inst, def);
});
const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
def.pattern ?? (def.pattern = xid$1);
$ZodStringFormat.init(inst, def);
});
const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
def.pattern ?? (def.pattern = ksuid$1);
$ZodStringFormat.init(inst, def);
});
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
def.pattern ?? (def.pattern = datetime$1(def));
$ZodStringFormat.init(inst, def);
});
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
def.pattern ?? (def.pattern = date$2);
$ZodStringFormat.init(inst, def);
});
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
def.pattern ?? (def.pattern = time$1(def));
$ZodStringFormat.init(inst, def);
});
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
def.pattern ?? (def.pattern = duration$1);
$ZodStringFormat.init(inst, def);
});
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
def.pattern ?? (def.pattern = ipv4$1);
$ZodStringFormat.init(inst, def);
inst._zod.bag.format = `ipv4`;
});
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
def.pattern ?? (def.pattern = ipv6$1);
$ZodStringFormat.init(inst, def);
inst._zod.bag.format = `ipv6`;
inst._zod.check = (payload) => {
try {
new URL(`http://[${payload.value}]`);
} catch {
payload.issues.push({
code: "invalid_format",
format: "ipv6",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
const $ZodMAC = /*@__PURE__*/ $constructor("$ZodMAC", (inst, def) => {
def.pattern ?? (def.pattern = mac$1(def.delimiter));
$ZodStringFormat.init(inst, def);
inst._zod.bag.format = `mac`;
});
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
def.pattern ?? (def.pattern = cidrv4$1);
$ZodStringFormat.init(inst, def);
});
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
def.pattern ?? (def.pattern = cidrv6$1);
$ZodStringFormat.init(inst, def);
inst._zod.check = (payload) => {
const parts = payload.value.split("/");
try {
if (parts.length !== 2) throw new Error();
const [address, prefix] = parts;
if (!prefix) throw new Error();
const prefixNum = Number(prefix);
if (`${prefixNum}` !== prefix) throw new Error();
if (prefixNum < 0 || prefixNum > 128) throw new Error();
new URL(`http://[${address}]`);
} catch {
payload.issues.push({
code: "invalid_format",
format: "cidrv6",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
function isValidBase64(data) {
if (data === "") return true;
if (/\s/.test(data)) return false;
if (data.length % 4 !== 0) return false;
try {
atob(data);
return true;
} catch {
return false;
}
}
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
def.pattern ?? (def.pattern = base64$1);
$ZodStringFormat.init(inst, def);
inst._zod.bag.contentEncoding = "base64";
inst._zod.check = (payload) => {
if (isValidBase64(payload.value)) return;
payload.issues.push({
code: "invalid_format",
format: "base64",
input: payload.value,
inst,
continue: !def.abort
});
};
});
function isValidBase64URL(data) {
if (!base64url$1.test(data)) return false;
const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
}
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
def.pattern ?? (def.pattern = base64url$1);
$ZodStringFormat.init(inst, def);
inst._zod.bag.contentEncoding = "base64url";
inst._zod.check = (payload) => {
if (isValidBase64URL(payload.value)) return;
payload.issues.push({
code: "invalid_format",
format: "base64url",
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
def.pattern ?? (def.pattern = e164$1);
$ZodStringFormat.init(inst, def);
});
function isValidJWT(token, algorithm = null) {
try {
const tokensParts = token.split(".");
if (tokensParts.length !== 3) return false;
const [header] = tokensParts;
if (!header) return false;
const parsedHeader = JSON.parse(atob(header));
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
if (!parsedHeader.alg) return false;
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
return true;
} catch {
return false;
}
}
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
$ZodStringFormat.init(inst, def);
inst._zod.check = (payload) => {
if (isValidJWT(payload.value, def.alg)) return;
payload.issues.push({
code: "invalid_format",
format: "jwt",
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCustomStringFormat = /*@__PURE__*/ $constructor("$ZodCustomStringFormat", (inst, def) => {
$ZodStringFormat.init(inst, def);
inst._zod.check = (payload) => {
if (def.fn(payload.value)) return;
payload.issues.push({
code: "invalid_format",
format: def.format,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
inst._zod.parse = (payload, _ctx) => {
if (def.coerce) try {
payload.value = Number(payload.value);
} catch (_) {}
const input = payload.value;
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
payload.issues.push({
expected: "number",
code: "invalid_type",
input,
inst,
...received ? { received } : {}
});
return payload;
};
});
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def) => {
$ZodCheckNumberFormat.init(inst, def);
$ZodNumber.init(inst, def);
});
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = boolean$1;
inst._zod.parse = (payload, _ctx) => {
if (def.coerce) try {
payload.value = Boolean(payload.value);
} catch (_) {}
const input = payload.value;
if (typeof input === "boolean") return payload;
payload.issues.push({
expected: "boolean",
code: "invalid_type",
input,
inst
});
return payload;
};
});
const $ZodBigInt = /*@__PURE__*/ $constructor("$ZodBigInt", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = bigint$1;
inst._zod.parse = (payload, _ctx) => {
if (def.coerce) try {
payload.value = BigInt(payload.value);
} catch (_) {}
if (typeof payload.value === "bigint") return payload;
payload.issues.push({
expected: "bigint",
code: "invalid_type",
input: payload.value,
inst
});
return payload;
};
});
const $ZodBigIntFormat = /*@__PURE__*/ $constructor("$ZodBigIntFormat", (inst, def) => {
$ZodCheckBigIntFormat.init(inst, def);
$ZodBigInt.init(inst, def);
});
const $ZodSymbol = /*@__PURE__*/ $constructor("$ZodSymbol", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (typeof input === "symbol") return payload;
payload.issues.push({
expected: "symbol",
code: "invalid_type",
input,
inst
});
return payload;
};
});
const $ZodUndefined = /*@__PURE__*/ $constructor("$ZodUndefined", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = _undefined$2;
inst._zod.values = /* @__PURE__ */ new Set([void 0]);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (typeof input === "undefined") return payload;
payload.issues.push({
expected: "undefined",
code: "invalid_type",
input,
inst
});
return payload;
};
});
const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.pattern = _null$2;
inst._zod.values = /* @__PURE__ */ new Set([null]);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (input === null) return payload;
payload.issues.push({
expected: "null",
code: "invalid_type",
input,
inst
});
return payload;
};
});
const $ZodAny = /*@__PURE__*/ $constructor("$ZodAny", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload) => payload;
});
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload) => payload;
});
const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
payload.issues.push({
expected: "never",
code: "invalid_type",
input: payload.value,
inst
});
return payload;
};
});
const $ZodVoid = /*@__PURE__*/ $constructor("$ZodVoid", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (typeof input === "undefined") return payload;
payload.issues.push({
expected: "void",
code: "invalid_type",
input,
inst
});
return payload;
};
});
const $ZodDate = /*@__PURE__*/ $constructor("$ZodDate", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
if (def.coerce) try {
payload.value = new Date(payload.value);
} catch (_err) {}
const input = payload.value;
const isDate = input instanceof Date;
if (isDate && !Number.isNaN(input.getTime())) return payload;
payload.issues.push({
expected: "date",
code: "invalid_type",
input,
...isDate ? { received: "Invalid Date" } : {},
inst
});
return payload;
};
});
function handleArrayResult(result, final, index) {
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
final.value[index] = result.value;
}
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!Array.isArray(input)) {
payload.issues.push({
expected: "array",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = Array(input.length);
const proms = [];
for (let i = 0; i < input.length; i++) {
const item = input[i];
const result = def.element._zod.run({
value: item,
issues: []
}, ctx);
if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
else handleArrayResult(result, payload, i);
}
if (proms.length) return Promise.all(proms).then(() => payload);
return payload;
};
});
function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
const isPresent = key in input;
if (result.issues.length) {
if (isOptionalIn && isOptionalOut && !isPresent) return;
final.issues.push(...prefixIssues(key, result.issues));
}
if (!isPresent && !isOptionalIn) {
if (!result.issues.length) final.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: void 0,
path: [key]
});
return;
}
if (result.value === void 0) {
if (isPresent) final.value[key] = void 0;
} else final.value[key] = result.value;
}
function normalizeDef(def) {
const keys = Object.keys(def.shape);
for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
const okeys = optionalKeys(def.shape);
return {
...def,
keys,
keySet: new Set(keys),
numKeys: keys.length,
optionalKeys: new Set(okeys)
};
}
function handleCatchall(proms, input, payload, ctx, def, inst) {
const unrecognized = [];
const keySet = def.keySet;
const _catchall = def.catchall._zod;
const t = _catchall.def.type;
const isOptionalIn = _catchall.optin === "optional";
const isOptionalOut = _catchall.optout === "optional";
for (const key in input) {
if (key === "__proto__") continue;
if (keySet.has(key)) continue;
if (t === "never") {
unrecognized.push(key);
continue;
}
const r = _catchall.run({
value: input[key],
issues: []
}, ctx);
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
}
if (unrecognized.length) payload.issues.push({
code: "unrecognized_keys",
keys: unrecognized,
input,
inst
});
if (!proms.length) return payload;
return Promise.all(proms).then(() => {
return payload;
});
}
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
$ZodType.init(inst, def);
if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
const sh = def.shape;
Object.defineProperty(def, "shape", { get: () => {
const newSh = { ...sh };
Object.defineProperty(def, "shape", { value: newSh });
return newSh;
} });
}
const _normalized = cached(() => normalizeDef(def));
defineLazy(inst._zod, "propValues", () => {
const shape = def.shape;
const propValues = {};
for (const key in shape) {
const field = shape[key]._zod;
if (field.values) {
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
for (const v of field.values) propValues[key].add(v);
}
}
return propValues;
});
const isObject$1 = isObject;
const catchall = def.catchall;
let value;
inst._zod.parse = (payload, ctx) => {
value ?? (value = _normalized.value);
const input = payload.value;
if (!isObject$1(input)) {
payload.issues.push({
expected: "object",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = {};
const proms = [];
const shape = value.shape;
for (const key of value.keys) {
const el = shape[key];
const isOptionalIn = el._zod.optin === "optional";
const isOptionalOut = el._zod.optout === "optional";
const r = el._zod.run({
value: input[key],
issues: []
}, ctx);
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
}
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
};
});
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
$ZodObject.init(inst, def);
const superParse = inst._zod.parse;
const _normalized = cached(() => normalizeDef(def));
const generateFastpass = (shape) => {
const doc = new Doc([
"shape",
"payload",
"ctx"
]);
const normalized = _normalized.value;
const parseStr = (key) => {
const k = esc(key);
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
};
doc.write(`const input = payload.value;`);
const ids = Object.create(null);
let counter = 0;
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
doc.write(`const newResult = {};`);
for (const key of normalized.keys) {
const id = ids[key];
const k = esc(key);
const schema = shape[key];
const isOptionalIn = schema?._zod?.optin === "optional";
const isOptionalOut = schema?._zod?.optout === "optional";
doc.write(`const ${id} = ${parseStr(key)};`);
if (isOptionalIn && isOptionalOut) doc.write(`
if (${id}.issues.length) {
if (${k} in input) {
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
...iss,
path: iss.path ? [${k}, ...iss.path] : [${k}]
})));
}
}
if (${id}.value === undefined) {
if (${k} in input) {
newResult[${k}] = undefined;
}
} else {
newResult[${k}] = ${id}.value;
}
`);
else if (!isOptionalIn) doc.write(`
const ${id}_present = ${k} in input;
if (${id}.issues.length) {
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
...iss,
path: iss.path ? [${k}, ...iss.path] : [${k}]
})));
}
if (!${id}_present && !${id}.issues.length) {
payload.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: undefined,
path: [${k}]
});
}
if (${id}_present) {
if (${id}.value === undefined) {
newResult[${k}] = undefined;
} else {
newResult[${k}] = ${id}.value;
}
}
`);
else doc.write(`
if (${id}.issues.length) {
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
...iss,
path: iss.path ? [${k}, ...iss.path] : [${k}]
})));
}
if (${id}.value === undefined) {
if (${k} in input) {
newResult[${k}] = undefined;
}
} else {
newResult[${k}] = ${id}.value;
}
`);
}
doc.write(`payload.value = newResult;`);
doc.write(`return payload;`);
const fn = doc.compile();
return (payload, ctx) => fn(shape, payload, ctx);
};
let fastpass;
const isObject$2 = isObject;
const jit = !globalConfig.jitless;
const fastEnabled = jit && allowsEval.value;
const catchall = def.catchall;
let value;
inst._zod.parse = (payload, ctx) => {
value ?? (value = _normalized.value);
const input = payload.value;
if (!isObject$2(input)) {
payload.issues.push({
expected: "object",
code: "invalid_type",
input,
inst
});
return payload;
}
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
if (!fastpass) fastpass = generateFastpass(def.shape);
payload = fastpass(payload, ctx);
if (!catchall) return payload;
return handleCatchall([], input, payload, ctx, value, inst);
}
return superParse(payload, ctx);
};
});
function handleUnionResults(results, final, inst, ctx) {
for (const result of results) if (result.issues.length === 0) {
final.value = result.value;
return final;
}
const nonaborted = results.filter((r) => !aborted(r));
if (nonaborted.length === 1) {
final.value = nonaborted[0].value;
return nonaborted[0];
}
final.issues.push({
code: "invalid_union",
input: final.value,
inst,
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
});
return final;
}
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
defineLazy(inst._zod, "values", () => {
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
});
defineLazy(inst._zod, "pattern", () => {
if (def.options.every((o) => o._zod.pattern)) {
const patterns = def.options.map((o) => o._zod.pattern);
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
}
});
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
inst._zod.parse = (payload, ctx) => {
if (first) return first(payload, ctx);
let async = false;
const results = [];
for (const option of def.options) {
const result = option._zod.run({
value: payload.value,
issues: []
}, ctx);
if (result instanceof Promise) {
results.push(result);
async = true;
} else {
if (result.issues.length === 0) return result;
results.push(result);
}
}
if (!async) return handleUnionResults(results, payload, inst, ctx);
return Promise.all(results).then((results) => {
return handleUnionResults(results, payload, inst, ctx);
});
};
});
function handleExclusiveUnionResults(results, final, inst, ctx) {
const successes = results.filter((r) => r.issues.length === 0);
if (successes.length === 1) {
final.value = successes[0].value;
return final;
}
if (successes.length === 0) final.issues.push({
code: "invalid_union",
input: final.value,
inst,
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
});
else final.issues.push({
code: "invalid_union",
input: final.value,
inst,
errors: [],
inclusive: false
});
return final;
}
const $ZodXor = /*@__PURE__*/ $constructor("$ZodXor", (inst, def) => {
$ZodUnion.init(inst, def);
def.inclusive = false;
const first = def.options.length === 1 ? def.options[0]._zod.run : null;
inst._zod.parse = (payload, ctx) => {
if (first) return first(payload, ctx);
let async = false;
const results = [];
for (const option of def.options) {
const result = option._zod.run({
value: payload.value,
issues: []
}, ctx);
if (result instanceof Promise) {
results.push(result);
async = true;
} else results.push(result);
}
if (!async) return handleExclusiveUnionResults(results, payload, inst, ctx);
return Promise.all(results).then((results) => {
return handleExclusiveUnionResults(results, payload, inst, ctx);
});
};
});
const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
def.inclusive = false;
$ZodUnion.init(inst, def);
const _super = inst._zod.parse;
defineLazy(inst._zod, "propValues", () => {
const propValues = {};
for (const option of def.options) {
const pv = option._zod.propValues;
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
for (const [k, v] of Object.entries(pv)) {
if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
for (const val of v) propValues[k].add(val);
}
}
return propValues;
});
const disc = cached(() => {
const opts = def.options;
const map = /* @__PURE__ */ new Map();
for (const o of opts) {
const values = o._zod.propValues?.[def.discriminator];
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
for (const v of values) {
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
map.set(v, o);
}
}
return map;
});
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!isObject(input)) {
payload.issues.push({
code: "invalid_type",
expected: "object",
input,
inst
});
return payload;
}
const opt = disc.value.get(input?.[def.discriminator]);
if (opt) return opt._zod.run(payload, ctx);
if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
payload.issues.push({
code: "invalid_union",
errors: [],
note: "No matching discriminator",
discriminator: def.discriminator,
options: Array.from(disc.value.keys()),
input,
path: [def.discriminator],
inst
});
return payload;
};
});
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
const left = def.left._zod.run({
value: input,
issues: []
}, ctx);
const right = def.right._zod.run({
value: input,
issues: []
}, ctx);
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
return handleIntersectionResults(payload, left, right);
});
return handleIntersectionResults(payload, left, right);
};
});
function mergeValues(a, b) {
if (a === b) return {
valid: true,
data: a
};
if (a instanceof Date && b instanceof Date && +a === +b) return {
valid: true,
data: a
};
if (isPlainObject(a) && isPlainObject(b)) {
const bKeys = Object.keys(b);
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
const newObj = {
...a,
...b
};
for (const key of sharedKeys) {
const sharedValue = mergeValues(a[key], b[key]);
if (!sharedValue.valid) return {
valid: false,
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
};
newObj[key] = sharedValue.data;
}
return {
valid: true,
data: newObj
};
}
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) return {
valid: false,
mergeErrorPath: []
};
const newArray = [];
for (let index = 0; index < a.length; index++) {
const itemA = a[index];
const itemB = b[index];
const sharedValue = mergeValues(itemA, itemB);
if (!sharedValue.valid) return {
valid: false,
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
};
newArray.push(sharedValue.data);
}
return {
valid: true,
data: newArray
};
}
return {
valid: false,
mergeErrorPath: []
};
}
function handleIntersectionResults(result, left, right) {
const unrecKeys = /* @__PURE__ */ new Map();
let unrecIssue;
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
unrecIssue ?? (unrecIssue = iss);
for (const k of iss.keys) {
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
unrecKeys.get(k).l = true;
}
} else result.issues.push(iss);
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
unrecKeys.get(k).r = true;
}
else result.issues.push(iss);
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
if (bothKeys.length && unrecIssue) result.issues.push({
...unrecIssue,
keys: bothKeys
});
if (aborted(result)) return result;
const merged = mergeValues(left.value, right.value);
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
result.value = merged.data;
return result;
}
const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def) => {
$ZodType.init(inst, def);
const items = def.items;
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!Array.isArray(input)) {
payload.issues.push({
input,
inst,
expected: "tuple",
code: "invalid_type"
});
return payload;
}
payload.value = [];
const proms = [];
const optinStart = getTupleOptStart(items, "optin");
const optoutStart = getTupleOptStart(items, "optout");
if (!def.rest) {
if (input.length < optinStart) {
payload.issues.push({
code: "too_small",
minimum: optinStart,
inclusive: true,
input,
inst,
origin: "array"
});
return payload;
}
if (input.length > items.length) payload.issues.push({
code: "too_big",
maximum: items.length,
inclusive: true,
input,
inst,
origin: "array"
});
}
const itemResults = new Array(items.length);
for (let i = 0; i < items.length; i++) {
const r = items[i]._zod.run({
value: input[i],
issues: []
}, ctx);
if (r instanceof Promise) proms.push(r.then((rr) => {
itemResults[i] = rr;
}));
else itemResults[i] = r;
}
if (def.rest) {
let i = items.length - 1;
const rest = input.slice(items.length);
for (const el of rest) {
i++;
const result = def.rest._zod.run({
value: el,
issues: []
}, ctx);
if (result instanceof Promise) proms.push(result.then((r) => handleTupleResult(r, payload, i)));
else handleTupleResult(result, payload, i);
}
}
if (proms.length) return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
return handleTupleResults(itemResults, payload, items, input, optoutStart);
};
});
function getTupleOptStart(items, key) {
for (let i = items.length - 1; i >= 0; i--) if (items[i]._zod[key] !== "optional") return i + 1;
return 0;
}
function handleTupleResult(result, final, index) {
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
final.value[index] = result.value;
}
function handleTupleResults(itemResults, final, items, input, optoutStart) {
for (let i = 0; i < items.length; i++) {
const r = itemResults[i];
const isPresent = i < input.length;
if (r.issues.length) {
if (!isPresent && i >= optoutStart) {
final.value.length = i;
break;
}
final.issues.push(...prefixIssues(i, r.issues));
}
final.value[i] = r.value;
}
for (let i = final.value.length - 1; i >= input.length; i--) if (items[i]._zod.optout === "optional" && final.value[i] === void 0) final.value.length = i;
else break;
return final;
}
const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!isPlainObject(input)) {
payload.issues.push({
expected: "record",
code: "invalid_type",
input,
inst
});
return payload;
}
const proms = [];
const values = def.keyType._zod.values;
if (values) {
payload.value = {};
const recordKeys = /* @__PURE__ */ new Set();
for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
recordKeys.add(typeof key === "number" ? key.toString() : key);
const keyResult = def.keyType._zod.run({
value: key,
issues: []
}, ctx);
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (keyResult.issues.length) {
payload.issues.push({
code: "invalid_key",
origin: "record",
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
input: key,
path: [key],
inst
});
continue;
}
const outKey = keyResult.value;
const result = def.valueType._zod.run({
value: input[key],
issues: []
}, ctx);
if (result instanceof Promise) proms.push(result.then((result) => {
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
payload.value[outKey] = result.value;
}));
else {
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
payload.value[outKey] = result.value;
}
}
let unrecognized;
for (const key in input) if (!recordKeys.has(key)) {
unrecognized = unrecognized ?? [];
unrecognized.push(key);
}
if (unrecognized && unrecognized.length > 0) payload.issues.push({
code: "unrecognized_keys",
input,
inst,
keys: unrecognized
});
} else {
payload.value = {};
for (const key of Reflect.ownKeys(input)) {
if (key === "__proto__") continue;
if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
let keyResult = def.keyType._zod.run({
value: key,
issues: []
}, ctx);
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
const retryResult = def.keyType._zod.run({
value: Number(key),
issues: []
}, ctx);
if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (retryResult.issues.length === 0) keyResult = retryResult;
}
if (keyResult.issues.length) {
if (def.mode === "loose") payload.value[key] = input[key];
else payload.issues.push({
code: "invalid_key",
origin: "record",
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
input: key,
path: [key],
inst
});
continue;
}
const result = def.valueType._zod.run({
value: input[key],
issues: []
}, ctx);
if (result instanceof Promise) proms.push(result.then((result) => {
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
payload.value[keyResult.value] = result.value;
}));
else {
if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
payload.value[keyResult.value] = result.value;
}
}
}
if (proms.length) return Promise.all(proms).then(() => payload);
return payload;
};
});
const $ZodMap = /*@__PURE__*/ $constructor("$ZodMap", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!(input instanceof Map)) {
payload.issues.push({
expected: "map",
code: "invalid_type",
input,
inst
});
return payload;
}
const proms = [];
payload.value = /* @__PURE__ */ new Map();
for (const [key, value] of input) {
const keyResult = def.keyType._zod.run({
value: key,
issues: []
}, ctx);
const valueResult = def.valueType._zod.run({
value,
issues: []
}, ctx);
if (keyResult instanceof Promise || valueResult instanceof Promise) proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
}));
else handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
}
if (proms.length) return Promise.all(proms).then(() => payload);
return payload;
};
});
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
if (keyResult.issues.length) {
if (propertyKeyTypes.has(typeof key)) final.issues.push(...prefixIssues(key, keyResult.issues));
else final.issues.push({
code: "invalid_key",
origin: "map",
input,
inst,
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
});
}
if (valueResult.issues.length) {
if (propertyKeyTypes.has(typeof key)) final.issues.push(...prefixIssues(key, valueResult.issues));
else final.issues.push({
origin: "map",
code: "invalid_element",
input,
inst,
key,
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
});
}
final.value.set(keyResult.value, valueResult.value);
}
const $ZodSet = /*@__PURE__*/ $constructor("$ZodSet", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!(input instanceof Set)) {
payload.issues.push({
input,
inst,
expected: "set",
code: "invalid_type"
});
return payload;
}
const proms = [];
payload.value = /* @__PURE__ */ new Set();
for (const item of input) {
const result = def.valueType._zod.run({
value: item,
issues: []
}, ctx);
if (result instanceof Promise) proms.push(result.then((result) => handleSetResult(result, payload)));
else handleSetResult(result, payload);
}
if (proms.length) return Promise.all(proms).then(() => payload);
return payload;
};
});
function handleSetResult(result, final) {
if (result.issues.length) final.issues.push(...result.issues);
final.value.add(result.value);
}
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
$ZodType.init(inst, def);
const values = getEnumValues(def.entries);
const valuesSet = new Set(values);
inst._zod.values = valuesSet;
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (valuesSet.has(input)) return payload;
payload.issues.push({
code: "invalid_value",
values,
input,
inst
});
return payload;
};
});
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
$ZodType.init(inst, def);
if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
const values = new Set(def.values);
inst._zod.values = values;
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (values.has(input)) return payload;
payload.issues.push({
code: "invalid_value",
values: def.values,
input,
inst
});
return payload;
};
});
const $ZodFile = /*@__PURE__*/ $constructor("$ZodFile", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (input instanceof File) return payload;
payload.issues.push({
expected: "file",
code: "invalid_type",
input,
inst
});
return payload;
};
});
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.optin = "optional";
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
const _out = def.transform(payload.value, payload);
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
payload.value = output;
payload.fallback = true;
return payload;
});
if (_out instanceof Promise) throw new $ZodAsyncError();
payload.value = _out;
payload.fallback = true;
return payload;
};
});
function handleOptionalResult(result, input) {
if (input === void 0 && (result.issues.length || result.fallback)) return {
issues: [],
value: void 0
};
return result;
}
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.optin = "optional";
inst._zod.optout = "optional";
defineLazy(inst._zod, "values", () => {
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
});
defineLazy(inst._zod, "pattern", () => {
const pattern = def.innerType._zod.pattern;
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
});
inst._zod.parse = (payload, ctx) => {
if (def.innerType._zod.optin === "optional") {
const input = payload.value;
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
return handleOptionalResult(result, input);
}
if (payload.value === void 0) return payload;
return def.innerType._zod.run(payload, ctx);
};
});
const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
$ZodOptional.init(inst, def);
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
inst._zod.parse = (payload, ctx) => {
return def.innerType._zod.run(payload, ctx);
};
});
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
defineLazy(inst._zod, "pattern", () => {
const pattern = def.innerType._zod.pattern;
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
});
defineLazy(inst._zod, "values", () => {
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
});
inst._zod.parse = (payload, ctx) => {
if (payload.value === null) return payload;
return def.innerType._zod.run(payload, ctx);
};
});
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.optin = "optional";
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
if (payload.value === void 0) {
payload.value = def.defaultValue;
/**
* $ZodDefault returns the default value immediately in forward direction.
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
return payload;
}
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
return handleDefaultResult(result, def);
};
});
function handleDefaultResult(payload, def) {
if (payload.value === void 0) payload.value = def.defaultValue;
return payload;
}
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.optin = "optional";
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
if (payload.value === void 0) payload.value = def.defaultValue;
return def.innerType._zod.run(payload, ctx);
};
});
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "values", () => {
const v = def.innerType._zod.values;
return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
});
inst._zod.parse = (payload, ctx) => {
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
return handleNonOptionalResult(result, inst);
};
});
function handleNonOptionalResult(payload, inst) {
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: payload.value,
inst
});
return payload;
}
const $ZodSuccess = /*@__PURE__*/ $constructor("$ZodSuccess", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") throw new $ZodEncodeError("ZodSuccess");
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise) return result.then((result) => {
payload.value = result.issues.length === 0;
return payload;
});
payload.value = result.issues.length === 0;
return payload;
};
});
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.optin = "optional";
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise) return result.then((result) => {
payload.value = result.value;
if (result.issues.length) {
payload.value = def.catchValue({
...payload,
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
input: payload.value
});
payload.issues = [];
payload.fallback = true;
}
return payload;
});
payload.value = result.value;
if (result.issues.length) {
payload.value = def.catchValue({
...payload,
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
input: payload.value
});
payload.issues = [];
payload.fallback = true;
}
return payload;
};
});
const $ZodNaN = /*@__PURE__*/ $constructor("$ZodNaN", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
payload.issues.push({
input: payload.value,
inst,
expected: "nan",
code: "invalid_type"
});
return payload;
}
return payload;
};
});
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "values", () => def.in._zod.values);
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") {
const right = def.out._zod.run(payload, ctx);
if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
return handlePipeResult(right, def.in, ctx);
}
const left = def.in._zod.run(payload, ctx);
if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
return handlePipeResult(left, def.out, ctx);
};
});
function handlePipeResult(left, next, ctx) {
if (left.issues.length) {
left.aborted = true;
return left;
}
return next._zod.run({
value: left.value,
issues: left.issues,
fallback: left.fallback
}, ctx);
}
const $ZodCodec = /*@__PURE__*/ $constructor("$ZodCodec", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "values", () => def.in._zod.values);
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
inst._zod.parse = (payload, ctx) => {
if ((ctx.direction || "forward") === "forward") {
const left = def.in._zod.run(payload, ctx);
if (left instanceof Promise) return left.then((left) => handleCodecAResult(left, def, ctx));
return handleCodecAResult(left, def, ctx);
} else {
const right = def.out._zod.run(payload, ctx);
if (right instanceof Promise) return right.then((right) => handleCodecAResult(right, def, ctx));
return handleCodecAResult(right, def, ctx);
}
};
});
function handleCodecAResult(result, def, ctx) {
if (result.issues.length) {
result.aborted = true;
return result;
}
if ((ctx.direction || "forward") === "forward") {
const transformed = def.transform(result.value, result);
if (transformed instanceof Promise) return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
return handleCodecTxResult(result, transformed, def.out, ctx);
} else {
const transformed = def.reverseTransform(result.value, result);
if (transformed instanceof Promise) return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
return handleCodecTxResult(result, transformed, def.in, ctx);
}
}
function handleCodecTxResult(left, value, nextSchema, ctx) {
if (left.issues.length) {
left.aborted = true;
return left;
}
return nextSchema._zod.run({
value,
issues: left.issues
}, ctx);
}
const $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (inst, def) => {
$ZodPipe.init(inst, def);
});
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
inst._zod.parse = (payload, ctx) => {
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
const result = def.innerType._zod.run(payload, ctx);
if (result instanceof Promise) return result.then(handleReadonlyResult);
return handleReadonlyResult(result);
};
});
function handleReadonlyResult(payload) {
payload.value = Object.freeze(payload.value);
return payload;
}
const $ZodTemplateLiteral = /*@__PURE__*/ $constructor("$ZodTemplateLiteral", (inst, def) => {
$ZodType.init(inst, def);
const regexParts = [];
for (const part of def.parts) if (typeof part === "object" && part !== null) {
if (!part._zod.pattern) throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
if (!source) throw new Error(`Invalid template literal part: ${part._zod.traits}`);
const start = source.startsWith("^") ? 1 : 0;
const end = source.endsWith("$") ? source.length - 1 : source.length;
regexParts.push(source.slice(start, end));
} else if (part === null || primitiveTypes.has(typeof part)) regexParts.push(escapeRegex(`${part}`));
else throw new Error(`Invalid template literal part: ${part}`);
inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
inst._zod.parse = (payload, _ctx) => {
if (typeof payload.value !== "string") {
payload.issues.push({
input: payload.value,
inst,
expected: "string",
code: "invalid_type"
});
return payload;
}
inst._zod.pattern.lastIndex = 0;
if (!inst._zod.pattern.test(payload.value)) {
payload.issues.push({
input: payload.value,
inst,
code: "invalid_format",
format: def.format ?? "template_literal",
pattern: inst._zod.pattern.source
});
return payload;
}
return payload;
};
});
const $ZodFunction = /*@__PURE__*/ $constructor("$ZodFunction", (inst, def) => {
$ZodType.init(inst, def);
inst._def = def;
inst._zod.def = def;
inst.implement = (func) => {
if (typeof func !== "function") throw new Error("implement() must be called with a function");
return function(...args) {
const parsedArgs = inst._def.input ? parse$1(inst._def.input, args) : args;
const result = Reflect.apply(func, this, parsedArgs);
if (inst._def.output) return parse$1(inst._def.output, result);
return result;
};
};
inst.implementAsync = (func) => {
if (typeof func !== "function") throw new Error("implementAsync() must be called with a function");
return async function(...args) {
const parsedArgs = inst._def.input ? await parseAsync$1(inst._def.input, args) : args;
const result = await Reflect.apply(func, this, parsedArgs);
if (inst._def.output) return await parseAsync$1(inst._def.output, result);
return result;
};
};
inst._zod.parse = (payload, _ctx) => {
if (typeof payload.value !== "function") {
payload.issues.push({
code: "invalid_type",
expected: "function",
input: payload.value,
inst
});
return payload;
}
if (inst._def.output && inst._def.output._zod.def.type === "promise") payload.value = inst.implementAsync(payload.value);
else payload.value = inst.implement(payload.value);
return payload;
};
inst.input = (...args) => {
const F = inst.constructor;
if (Array.isArray(args[0])) return new F({
type: "function",
input: new $ZodTuple({
type: "tuple",
items: args[0],
rest: args[1]
}),
output: inst._def.output
});
return new F({
type: "function",
input: args[0],
output: inst._def.output
});
};
inst.output = (output) => {
const F = inst.constructor;
return new F({
type: "function",
input: inst._def.input,
output
});
};
return inst;
});
const $ZodPromise = /*@__PURE__*/ $constructor("$ZodPromise", (inst, def) => {
$ZodType.init(inst, def);
inst._zod.parse = (payload, ctx) => {
return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({
value: inner,
issues: []
}, ctx));
};
});
const $ZodLazy = /*@__PURE__*/ $constructor("$ZodLazy", (inst, def) => {
$ZodType.init(inst, def);
defineLazy(inst._zod, "innerType", () => {
const d = def;
if (!d._cachedInner) d._cachedInner = def.getter();
return d._cachedInner;
});
defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? void 0);
inst._zod.parse = (payload, ctx) => {
return inst._zod.innerType._zod.run(payload, ctx);
};
});
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
$ZodCheck.init(inst, def);
$ZodType.init(inst, def);
inst._zod.parse = (payload, _) => {
return payload;
};
inst._zod.check = (payload) => {
const input = payload.value;
const r = def.fn(input);
if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
handleRefineResult(r, payload, input, inst);
};
});
function handleRefineResult(result, payload, input, inst) {
if (!result) {
const _iss = {
code: "custom",
input,
inst,
path: [...inst._zod.def.path ?? []],
continue: !inst._zod.def.abort
};
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
payload.issues.push(issue(_iss));
}
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
var _a;
const $output = Symbol("ZodOutput");
const $input = Symbol("ZodInput");
var $ZodRegistry = class {
constructor() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
}
add(schema, ..._meta) {
const meta = _meta[0];
this._map.set(schema, meta);
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
return this;
}
clear() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
return this;
}
remove(schema) {
const meta = this._map.get(schema);
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
this._map.delete(schema);
return this;
}
get(schema) {
const p = schema._zod.parent;
if (p) {
const pm = { ...this.get(p) ?? {} };
delete pm.id;
const f = {
...pm,
...this._map.get(schema)
};
return Object.keys(f).length ? f : void 0;
}
return this._map.get(schema);
}
has(schema) {
return this._map.has(schema);
}
};
function registry() {
return new $ZodRegistry();
}
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
const globalRegistry = globalThis.__zod_globalRegistry;
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
// @__NO_SIDE_EFFECTS__
function _string(Class, params) {
return new Class({
type: "string",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _coercedString(Class, params) {
return new Class({
type: "string",
coerce: true,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _email(Class, params) {
return new Class({
type: "string",
format: "email",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _guid(Class, params) {
return new Class({
type: "string",
format: "guid",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _uuid(Class, params) {
return new Class({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _uuidv4(Class, params) {
return new Class({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
version: "v4",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _uuidv6(Class, params) {
return new Class({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
version: "v6",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _uuidv7(Class, params) {
return new Class({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
version: "v7",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _url(Class, params) {
return new Class({
type: "string",
format: "url",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _emoji(Class, params) {
return new Class({
type: "string",
format: "emoji",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _nanoid(Class, params) {
return new Class({
type: "string",
format: "nanoid",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link _cuid2} instead.
* See https://github.com/paralleldrive/cuid.
*/
// @__NO_SIDE_EFFECTS__
function _cuid(Class, params) {
return new Class({
type: "string",
format: "cuid",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _cuid2(Class, params) {
return new Class({
type: "string",
format: "cuid2",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _ulid(Class, params) {
return new Class({
type: "string",
format: "ulid",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _xid(Class, params) {
return new Class({
type: "string",
format: "xid",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _ksuid(Class, params) {
return new Class({
type: "string",
format: "ksuid",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _ipv4(Class, params) {
return new Class({
type: "string",
format: "ipv4",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _ipv6(Class, params) {
return new Class({
type: "string",
format: "ipv6",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _mac(Class, params) {
return new Class({
type: "string",
format: "mac",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _cidrv4(Class, params) {
return new Class({
type: "string",
format: "cidrv4",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _cidrv6(Class, params) {
return new Class({
type: "string",
format: "cidrv6",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _base64(Class, params) {
return new Class({
type: "string",
format: "base64",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _base64url(Class, params) {
return new Class({
type: "string",
format: "base64url",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _e164(Class, params) {
return new Class({
type: "string",
format: "e164",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _jwt(Class, params) {
return new Class({
type: "string",
format: "jwt",
check: "string_format",
abort: false,
...normalizeParams(params)
});
}
const TimePrecision = {
Any: null,
Minute: -1,
Second: 0,
Millisecond: 3,
Microsecond: 6
};
// @__NO_SIDE_EFFECTS__
function _isoDateTime(Class, params) {
return new Class({
type: "string",
format: "datetime",
check: "string_format",
offset: false,
local: false,
precision: null,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _isoDate(Class, params) {
return new Class({
type: "string",
format: "date",
check: "string_format",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _isoTime(Class, params) {
return new Class({
type: "string",
format: "time",
check: "string_format",
precision: null,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _isoDuration(Class, params) {
return new Class({
type: "string",
format: "duration",
check: "string_format",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _number(Class, params) {
return new Class({
type: "number",
checks: [],
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _coercedNumber(Class, params) {
return new Class({
type: "number",
coerce: true,
checks: [],
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _int(Class, params) {
return new Class({
type: "number",
check: "number_format",
abort: false,
format: "safeint",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _float32(Class, params) {
return new Class({
type: "number",
check: "number_format",
abort: false,
format: "float32",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _float64(Class, params) {
return new Class({
type: "number",
check: "number_format",
abort: false,
format: "float64",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _int32(Class, params) {
return new Class({
type: "number",
check: "number_format",
abort: false,
format: "int32",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _uint32(Class, params) {
return new Class({
type: "number",
check: "number_format",
abort: false,
format: "uint32",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _boolean(Class, params) {
return new Class({
type: "boolean",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _coercedBoolean(Class, params) {
return new Class({
type: "boolean",
coerce: true,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _bigint(Class, params) {
return new Class({
type: "bigint",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _coercedBigint(Class, params) {
return new Class({
type: "bigint",
coerce: true,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _int64(Class, params) {
return new Class({
type: "bigint",
check: "bigint_format",
abort: false,
format: "int64",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _uint64(Class, params) {
return new Class({
type: "bigint",
check: "bigint_format",
abort: false,
format: "uint64",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _symbol(Class, params) {
return new Class({
type: "symbol",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _undefined$1(Class, params) {
return new Class({
type: "undefined",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _null$1(Class, params) {
return new Class({
type: "null",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _any(Class) {
return new Class({ type: "any" });
}
// @__NO_SIDE_EFFECTS__
function _unknown(Class) {
return new Class({ type: "unknown" });
}
// @__NO_SIDE_EFFECTS__
function _never(Class, params) {
return new Class({
type: "never",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _void$1(Class, params) {
return new Class({
type: "void",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _date(Class, params) {
return new Class({
type: "date",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _coercedDate(Class, params) {
return new Class({
type: "date",
coerce: true,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _nan(Class, params) {
return new Class({
type: "nan",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _lt(value, params) {
return new $ZodCheckLessThan({
check: "less_than",
...normalizeParams(params),
value,
inclusive: false
});
}
// @__NO_SIDE_EFFECTS__
function _lte(value, params) {
return new $ZodCheckLessThan({
check: "less_than",
...normalizeParams(params),
value,
inclusive: true
});
}
// @__NO_SIDE_EFFECTS__
function _gt(value, params) {
return new $ZodCheckGreaterThan({
check: "greater_than",
...normalizeParams(params),
value,
inclusive: false
});
}
// @__NO_SIDE_EFFECTS__
function _gte(value, params) {
return new $ZodCheckGreaterThan({
check: "greater_than",
...normalizeParams(params),
value,
inclusive: true
});
}
// @__NO_SIDE_EFFECTS__
function _positive(params) {
return /* @__PURE__ */ _gt(0, params);
}
// @__NO_SIDE_EFFECTS__
function _negative(params) {
return /* @__PURE__ */ _lt(0, params);
}
// @__NO_SIDE_EFFECTS__
function _nonpositive(params) {
return /* @__PURE__ */ _lte(0, params);
}
// @__NO_SIDE_EFFECTS__
function _nonnegative(params) {
return /* @__PURE__ */ _gte(0, params);
}
// @__NO_SIDE_EFFECTS__
function _multipleOf(value, params) {
return new $ZodCheckMultipleOf({
check: "multiple_of",
...normalizeParams(params),
value
});
}
// @__NO_SIDE_EFFECTS__
function _maxSize(maximum, params) {
return new $ZodCheckMaxSize({
check: "max_size",
...normalizeParams(params),
maximum
});
}
// @__NO_SIDE_EFFECTS__
function _minSize(minimum, params) {
return new $ZodCheckMinSize({
check: "min_size",
...normalizeParams(params),
minimum
});
}
// @__NO_SIDE_EFFECTS__
function _size(size, params) {
return new $ZodCheckSizeEquals({
check: "size_equals",
...normalizeParams(params),
size
});
}
// @__NO_SIDE_EFFECTS__
function _maxLength(maximum, params) {
return new $ZodCheckMaxLength({
check: "max_length",
...normalizeParams(params),
maximum
});
}
// @__NO_SIDE_EFFECTS__
function _minLength(minimum, params) {
return new $ZodCheckMinLength({
check: "min_length",
...normalizeParams(params),
minimum
});
}
// @__NO_SIDE_EFFECTS__
function _length(length, params) {
return new $ZodCheckLengthEquals({
check: "length_equals",
...normalizeParams(params),
length
});
}
// @__NO_SIDE_EFFECTS__
function _regex(pattern, params) {
return new $ZodCheckRegex({
check: "string_format",
format: "regex",
...normalizeParams(params),
pattern
});
}
// @__NO_SIDE_EFFECTS__
function _lowercase(params) {
return new $ZodCheckLowerCase({
check: "string_format",
format: "lowercase",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _uppercase(params) {
return new $ZodCheckUpperCase({
check: "string_format",
format: "uppercase",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _includes(includes, params) {
return new $ZodCheckIncludes({
check: "string_format",
format: "includes",
...normalizeParams(params),
includes
});
}
// @__NO_SIDE_EFFECTS__
function _startsWith(prefix, params) {
return new $ZodCheckStartsWith({
check: "string_format",
format: "starts_with",
...normalizeParams(params),
prefix
});
}
// @__NO_SIDE_EFFECTS__
function _endsWith(suffix, params) {
return new $ZodCheckEndsWith({
check: "string_format",
format: "ends_with",
...normalizeParams(params),
suffix
});
}
// @__NO_SIDE_EFFECTS__
function _property(property, schema, params) {
return new $ZodCheckProperty({
check: "property",
property,
schema,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _mime(types, params) {
return new $ZodCheckMimeType({
check: "mime_type",
mime: types,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _overwrite(tx) {
return new $ZodCheckOverwrite({
check: "overwrite",
tx
});
}
// @__NO_SIDE_EFFECTS__
function _normalize(form) {
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
}
// @__NO_SIDE_EFFECTS__
function _trim() {
return /* @__PURE__ */ _overwrite((input) => input.trim());
}
// @__NO_SIDE_EFFECTS__
function _toLowerCase() {
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
}
// @__NO_SIDE_EFFECTS__
function _toUpperCase() {
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
}
// @__NO_SIDE_EFFECTS__
function _slugify() {
return /* @__PURE__ */ _overwrite((input) => slugify(input));
}
// @__NO_SIDE_EFFECTS__
function _array(Class, element, params) {
return new Class({
type: "array",
element,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _union(Class, options, params) {
return new Class({
type: "union",
options,
...normalizeParams(params)
});
}
function _xor(Class, options, params) {
return new Class({
type: "union",
options,
inclusive: false,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _discriminatedUnion(Class, discriminator, options, params) {
return new Class({
type: "union",
options,
discriminator,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _intersection(Class, left, right) {
return new Class({
type: "intersection",
left,
right
});
}
// @__NO_SIDE_EFFECTS__
function _tuple(Class, items, _paramsOrRest, _params) {
const hasRest = _paramsOrRest instanceof $ZodType;
return new Class({
type: "tuple",
items,
rest: hasRest ? _paramsOrRest : null,
...normalizeParams(hasRest ? _params : _paramsOrRest)
});
}
// @__NO_SIDE_EFFECTS__
function _record(Class, keyType, valueType, params) {
return new Class({
type: "record",
keyType,
valueType,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _map(Class, keyType, valueType, params) {
return new Class({
type: "map",
keyType,
valueType,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _set(Class, valueType, params) {
return new Class({
type: "set",
valueType,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _enum$1(Class, values, params) {
return new Class({
type: "enum",
entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
...normalizeParams(params)
});
}
/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
*
* ```ts
* enum Colors { red, green, blue }
* z.enum(Colors);
* ```
*/
// @__NO_SIDE_EFFECTS__
function _nativeEnum(Class, entries, params) {
return new Class({
type: "enum",
entries,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _literal(Class, value, params) {
return new Class({
type: "literal",
values: Array.isArray(value) ? value : [value],
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _file(Class, params) {
return new Class({
type: "file",
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _transform(Class, fn) {
return new Class({
type: "transform",
transform: fn
});
}
// @__NO_SIDE_EFFECTS__
function _optional(Class, innerType) {
return new Class({
type: "optional",
innerType
});
}
// @__NO_SIDE_EFFECTS__
function _nullable(Class, innerType) {
return new Class({
type: "nullable",
innerType
});
}
// @__NO_SIDE_EFFECTS__
function _default$1(Class, innerType, defaultValue) {
return new Class({
type: "default",
innerType,
get defaultValue() {
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
}
});
}
// @__NO_SIDE_EFFECTS__
function _nonoptional(Class, innerType, params) {
return new Class({
type: "nonoptional",
innerType,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _success(Class, innerType) {
return new Class({
type: "success",
innerType
});
}
// @__NO_SIDE_EFFECTS__
function _catch$1(Class, innerType, catchValue) {
return new Class({
type: "catch",
innerType,
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
});
}
// @__NO_SIDE_EFFECTS__
function _pipe(Class, in_, out) {
return new Class({
type: "pipe",
in: in_,
out
});
}
// @__NO_SIDE_EFFECTS__
function _readonly(Class, innerType) {
return new Class({
type: "readonly",
innerType
});
}
// @__NO_SIDE_EFFECTS__
function _templateLiteral(Class, parts, params) {
return new Class({
type: "template_literal",
parts,
...normalizeParams(params)
});
}
// @__NO_SIDE_EFFECTS__
function _lazy(Class, getter) {
return new Class({
type: "lazy",
getter
});
}
// @__NO_SIDE_EFFECTS__
function _promise(Class, innerType) {
return new Class({
type: "promise",
innerType
});
}
// @__NO_SIDE_EFFECTS__
function _custom(Class, fn, _params) {
const norm = normalizeParams(_params);
norm.abort ?? (norm.abort = true);
return new Class({
type: "custom",
check: "custom",
fn,
...norm
});
}
// @__NO_SIDE_EFFECTS__
function _refine(Class, fn, _params) {
return new Class({
type: "custom",
check: "custom",
fn,
...normalizeParams(_params)
});
}
// @__NO_SIDE_EFFECTS__
function _superRefine(fn, params) {
const ch = /* @__PURE__ */ _check((payload) => {
payload.addIssue = (issue$2) => {
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
else {
const _issue = issue$2;
if (_issue.fatal) _issue.continue = false;
_issue.code ?? (_issue.code = "custom");
_issue.input ?? (_issue.input = payload.value);
_issue.inst ?? (_issue.inst = ch);
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
payload.issues.push(issue(_issue));
}
};
return fn(payload.value, payload);
}, params);
return ch;
}
// @__NO_SIDE_EFFECTS__
function _check(fn, params) {
const ch = new $ZodCheck({
check: "custom",
...normalizeParams(params)
});
ch._zod.check = fn;
return ch;
}
// @__NO_SIDE_EFFECTS__
function describe$1(description) {
const ch = new $ZodCheck({ check: "describe" });
ch._zod.onattach = [(inst) => {
const existing = globalRegistry.get(inst) ?? {};
globalRegistry.add(inst, {
...existing,
description
});
}];
ch._zod.check = () => {};
return ch;
}
// @__NO_SIDE_EFFECTS__
function meta$1(metadata) {
const ch = new $ZodCheck({ check: "meta" });
ch._zod.onattach = [(inst) => {
const existing = globalRegistry.get(inst) ?? {};
globalRegistry.add(inst, {
...existing,
...metadata
});
}];
ch._zod.check = () => {};
return ch;
}
// @__NO_SIDE_EFFECTS__
function _stringbool(Classes, _params) {
const params = normalizeParams(_params);
let truthyArray = params.truthy ?? [
"true",
"1",
"yes",
"on",
"y",
"enabled"
];
let falsyArray = params.falsy ?? [
"false",
"0",
"no",
"off",
"n",
"disabled"
];
if (params.case !== "sensitive") {
truthyArray = truthyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
falsyArray = falsyArray.map((v) => typeof v === "string" ? v.toLowerCase() : v);
}
const truthySet = new Set(truthyArray);
const falsySet = new Set(falsyArray);
const _Codec = Classes.Codec ?? $ZodCodec;
const _Boolean = Classes.Boolean ?? $ZodBoolean;
const codec = new _Codec({
type: "pipe",
in: new (Classes.String ?? $ZodString)({
type: "string",
error: params.error
}),
out: new _Boolean({
type: "boolean",
error: params.error
}),
transform: ((input, payload) => {
let data = input;
if (params.case !== "sensitive") data = data.toLowerCase();
if (truthySet.has(data)) return true;
else if (falsySet.has(data)) return false;
else {
payload.issues.push({
code: "invalid_value",
expected: "stringbool",
values: [...truthySet, ...falsySet],
input: payload.value,
inst: codec,
continue: false
});
return {};
}
}),
reverseTransform: ((input, _payload) => {
if (input === true) return truthyArray[0] || "true";
else return falsyArray[0] || "false";
}),
error: params.error
});
return codec;
}
// @__NO_SIDE_EFFECTS__
function _stringFormat(Class, format, fnOrRegex, _params = {}) {
const params = normalizeParams(_params);
const def = {
...normalizeParams(_params),
check: "string_format",
type: "string",
format,
fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
...params
};
if (fnOrRegex instanceof RegExp) def.pattern = fnOrRegex;
return new Class(def);
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
function initializeContext(params) {
let target = params?.target ?? "draft-2020-12";
if (target === "draft-4") target = "draft-04";
if (target === "draft-7") target = "draft-07";
return {
processors: params.processors ?? {},
metadataRegistry: params?.metadata ?? globalRegistry,
target,
unrepresentable: params?.unrepresentable ?? "throw",
override: params?.override ?? (() => {}),
io: params?.io ?? "output",
counter: 0,
seen: /* @__PURE__ */ new Map(),
cycles: params?.cycles ?? "ref",
reused: params?.reused ?? "inline",
external: params?.external ?? void 0
};
}
function process(schema, ctx, _params = {
path: [],
schemaPath: []
}) {
var _a;
const def = schema._zod.def;
const seen = ctx.seen.get(schema);
if (seen) {
seen.count++;
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
return seen.schema;
}
const result = {
schema: {},
count: 1,
cycle: void 0,
path: _params.path
};
ctx.seen.set(schema, result);
const overrideSchema = schema._zod.toJSONSchema?.();
if (overrideSchema) result.schema = overrideSchema;
else {
const params = {
..._params,
schemaPath: [..._params.schemaPath, schema],
path: _params.path
};
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
else {
const _json = result.schema;
const processor = ctx.processors[def.type];
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
processor(schema, ctx, _json, params);
}
const parent = schema._zod.parent;
if (parent) {
if (!result.ref) result.ref = parent;
process(parent, ctx, params);
ctx.seen.get(parent).isParent = true;
}
}
const meta = ctx.metadataRegistry.get(schema);
if (meta) Object.assign(result.schema, meta);
if (ctx.io === "input" && isTransforming(schema)) {
delete result.schema.examples;
delete result.schema.default;
}
if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
delete result.schema._prefault;
return ctx.seen.get(schema).schema;
}
function extractDefs(ctx, schema) {
const root = ctx.seen.get(schema);
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
const idToSchema = /* @__PURE__ */ new Map();
for (const entry of ctx.seen.entries()) {
const id = ctx.metadataRegistry.get(entry[0])?.id;
if (id) {
const existing = idToSchema.get(id);
if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
idToSchema.set(id, entry[0]);
}
}
const makeURI = (entry) => {
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
if (ctx.external) {
const externalId = ctx.external.registry.get(entry[0])?.id;
const uriGenerator = ctx.external.uri ?? ((id) => id);
if (externalId) return { ref: uriGenerator(externalId) };
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
entry[1].defId = id;
return {
defId: id,
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
};
}
if (entry[1] === root) return { ref: "#" };
const defUriPrefix = `#/${defsSegment}/`;
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
return {
defId,
ref: defUriPrefix + defId
};
};
const extractToDef = (entry) => {
if (entry[1].schema.$ref) return;
const seen = entry[1];
const { ref, defId } = makeURI(entry);
seen.def = { ...seen.schema };
if (defId) seen.defId = defId;
const schema = seen.schema;
for (const key in schema) delete schema[key];
schema.$ref = ref;
};
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
const seen = entry[1];
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
}
for (const entry of ctx.seen.entries()) {
const seen = entry[1];
if (schema === entry[0]) {
extractToDef(entry);
continue;
}
if (ctx.external) {
const ext = ctx.external.registry.get(entry[0])?.id;
if (schema !== entry[0] && ext) {
extractToDef(entry);
continue;
}
}
if (ctx.metadataRegistry.get(entry[0])?.id) {
extractToDef(entry);
continue;
}
if (seen.cycle) {
extractToDef(entry);
continue;
}
if (seen.count > 1) {
if (ctx.reused === "ref") {
extractToDef(entry);
continue;
}
}
}
}
function finalize(ctx, schema) {
const root = ctx.seen.get(schema);
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
const flattenRef = (zodSchema) => {
const seen = ctx.seen.get(zodSchema);
if (seen.ref === null) return;
const schema = seen.def ?? seen.schema;
const _cached = { ...schema };
const ref = seen.ref;
seen.ref = null;
if (ref) {
flattenRef(ref);
const refSeen = ctx.seen.get(ref);
const refSchema = refSeen.schema;
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
schema.allOf = schema.allOf ?? [];
schema.allOf.push(refSchema);
} else Object.assign(schema, refSchema);
Object.assign(schema, _cached);
if (zodSchema._zod.parent === ref) for (const key in schema) {
if (key === "$ref" || key === "allOf") continue;
if (!(key in _cached)) delete schema[key];
}
if (refSchema.$ref && refSeen.def) for (const key in schema) {
if (key === "$ref" || key === "allOf") continue;
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
}
}
const parent = zodSchema._zod.parent;
if (parent && parent !== ref) {
flattenRef(parent);
const parentSeen = ctx.seen.get(parent);
if (parentSeen?.schema.$ref) {
schema.$ref = parentSeen.schema.$ref;
if (parentSeen.def) for (const key in schema) {
if (key === "$ref" || key === "allOf") continue;
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
}
}
}
ctx.override({
zodSchema,
jsonSchema: schema,
path: seen.path ?? []
});
};
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
const result = {};
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
else if (ctx.target === "openapi-3.0") {}
if (ctx.external?.uri) {
const id = ctx.external.registry.get(schema)?.id;
if (!id) throw new Error("Schema is missing an `id` property");
result.$id = ctx.external.uri(id);
}
Object.assign(result, root.def ?? root.schema);
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
const defs = ctx.external?.defs ?? {};
for (const entry of ctx.seen.entries()) {
const seen = entry[1];
if (seen.def && seen.defId) {
if (seen.def.id === seen.defId) delete seen.def.id;
defs[seen.defId] = seen.def;
}
}
if (ctx.external) {} else if (Object.keys(defs).length > 0) {
if (ctx.target === "draft-2020-12") result.$defs = defs;
else result.definitions = defs;
}
try {
const finalized = JSON.parse(JSON.stringify(result));
Object.defineProperty(finalized, "~standard", {
value: {
...schema["~standard"],
jsonSchema: {
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
}
},
enumerable: false,
writable: false
});
return finalized;
} catch (_err) {
throw new Error("Error converting schema to JSON.");
}
}
function isTransforming(_schema, _ctx) {
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
if (ctx.seen.has(_schema)) return false;
ctx.seen.add(_schema);
const def = _schema._zod.def;
if (def.type === "transform") return true;
if (def.type === "array") return isTransforming(def.element, ctx);
if (def.type === "set") return isTransforming(def.valueType, ctx);
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
if (def.type === "pipe") {
if (_schema._zod.traits.has("$ZodCodec")) return true;
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
}
if (def.type === "object") {
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
return false;
}
if (def.type === "union") {
for (const option of def.options) if (isTransforming(option, ctx)) return true;
return false;
}
if (def.type === "tuple") {
for (const item of def.items) if (isTransforming(item, ctx)) return true;
if (def.rest && isTransforming(def.rest, ctx)) return true;
return false;
}
return false;
}
/**
* Creates a toJSONSchema method for a schema instance.
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
*/
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
const ctx = initializeContext({
...params,
processors
});
process(schema, ctx);
extractDefs(ctx, schema);
return finalize(ctx, schema);
};
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
const { libraryOptions, target } = params ?? {};
const ctx = initializeContext({
...libraryOptions ?? {},
target,
io,
processors
});
process(schema, ctx);
extractDefs(ctx, schema);
return finalize(ctx, schema);
};
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
const formatMap = {
guid: "uuid",
url: "uri",
datetime: "date-time",
json_string: "json-string",
regex: ""
};
const stringProcessor = (schema, ctx, _json, _params) => {
const json = _json;
json.type = "string";
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
if (typeof minimum === "number") json.minLength = minimum;
if (typeof maximum === "number") json.maxLength = maximum;
if (format) {
json.format = formatMap[format] ?? format;
if (json.format === "") delete json.format;
if (format === "time") delete json.format;
}
if (contentEncoding) json.contentEncoding = contentEncoding;
if (patterns && patterns.size > 0) {
const regexes = [...patterns];
if (regexes.length === 1) json.pattern = regexes[0].source;
else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
pattern: regex.source
}))];
}
};
const numberProcessor = (schema, ctx, _json, _params) => {
const json = _json;
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
if (typeof format === "string" && format.includes("int")) json.type = "integer";
else json.type = "number";
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
if (exMin) {
if (legacy) {
json.minimum = exclusiveMinimum;
json.exclusiveMinimum = true;
} else json.exclusiveMinimum = exclusiveMinimum;
} else if (typeof minimum === "number") json.minimum = minimum;
if (exMax) {
if (legacy) {
json.maximum = exclusiveMaximum;
json.exclusiveMaximum = true;
} else json.exclusiveMaximum = exclusiveMaximum;
} else if (typeof maximum === "number") json.maximum = maximum;
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
};
const booleanProcessor = (_schema, _ctx, json, _params) => {
json.type = "boolean";
};
const bigintProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
};
const symbolProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
};
const nullProcessor = (_schema, ctx, json, _params) => {
if (ctx.target === "openapi-3.0") {
json.type = "string";
json.nullable = true;
json.enum = [null];
} else json.type = "null";
};
const undefinedProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
};
const voidProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
};
const neverProcessor = (_schema, _ctx, json, _params) => {
json.not = {};
};
const anyProcessor = (_schema, _ctx, _json, _params) => {};
const unknownProcessor = (_schema, _ctx, _json, _params) => {};
const dateProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
};
const enumProcessor = (schema, _ctx, json, _params) => {
const def = schema._zod.def;
const values = getEnumValues(def.entries);
if (values.every((v) => typeof v === "number")) json.type = "number";
if (values.every((v) => typeof v === "string")) json.type = "string";
json.enum = values;
};
const literalProcessor = (schema, ctx, json, _params) => {
const def = schema._zod.def;
const vals = [];
for (const val of def.values) if (val === void 0) {
if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
} else if (typeof val === "bigint") {
if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
else vals.push(Number(val));
} else vals.push(val);
if (vals.length === 0) {} else if (vals.length === 1) {
const val = vals[0];
json.type = val === null ? "null" : typeof val;
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
else json.const = val;
} else {
if (vals.every((v) => typeof v === "number")) json.type = "number";
if (vals.every((v) => typeof v === "string")) json.type = "string";
if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
if (vals.every((v) => v === null)) json.type = "null";
json.enum = vals;
}
};
const nanProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
};
const templateLiteralProcessor = (schema, _ctx, json, _params) => {
const _json = json;
const pattern = schema._zod.pattern;
if (!pattern) throw new Error("Pattern not found in template literal");
_json.type = "string";
_json.pattern = pattern.source;
};
const fileProcessor = (schema, _ctx, json, _params) => {
const _json = json;
const file = {
type: "string",
format: "binary",
contentEncoding: "binary"
};
const { minimum, maximum, mime } = schema._zod.bag;
if (minimum !== void 0) file.minLength = minimum;
if (maximum !== void 0) file.maxLength = maximum;
if (mime) {
if (mime.length === 1) {
file.contentMediaType = mime[0];
Object.assign(_json, file);
} else {
Object.assign(_json, file);
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
}
} else Object.assign(_json, file);
};
const successProcessor = (_schema, _ctx, json, _params) => {
json.type = "boolean";
};
const customProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
};
const functionProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
};
const transformProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
};
const mapProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
};
const setProcessor = (_schema, ctx, _json, _params) => {
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
};
const arrayProcessor = (schema, ctx, _json, params) => {
const json = _json;
const def = schema._zod.def;
const { minimum, maximum } = schema._zod.bag;
if (typeof minimum === "number") json.minItems = minimum;
if (typeof maximum === "number") json.maxItems = maximum;
json.type = "array";
json.items = process(def.element, ctx, {
...params,
path: [...params.path, "items"]
});
};
const objectProcessor = (schema, ctx, _json, params) => {
const json = _json;
const def = schema._zod.def;
json.type = "object";
json.properties = {};
const shape = def.shape;
for (const key in shape) json.properties[key] = process(shape[key], ctx, {
...params,
path: [
...params.path,
"properties",
key
]
});
const allKeys = new Set(Object.keys(shape));
const requiredKeys = new Set([...allKeys].filter((key) => {
const v = def.shape[key]._zod;
if (ctx.io === "input") return v.optin === void 0;
else return v.optout === void 0;
}));
if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
else if (!def.catchall) {
if (ctx.io === "output") json.additionalProperties = false;
} else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
...params,
path: [...params.path, "additionalProperties"]
});
};
const unionProcessor = (schema, ctx, json, params) => {
const def = schema._zod.def;
const isExclusive = def.inclusive === false;
const options = def.options.map((x, i) => process(x, ctx, {
...params,
path: [
...params.path,
isExclusive ? "oneOf" : "anyOf",
i
]
}));
if (isExclusive) json.oneOf = options;
else json.anyOf = options;
};
const intersectionProcessor = (schema, ctx, json, params) => {
const def = schema._zod.def;
const a = process(def.left, ctx, {
...params,
path: [
...params.path,
"allOf",
0
]
});
const b = process(def.right, ctx, {
...params,
path: [
...params.path,
"allOf",
1
]
});
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
};
const tupleProcessor = (schema, ctx, _json, params) => {
const json = _json;
const def = schema._zod.def;
json.type = "array";
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
const prefixItems = def.items.map((x, i) => process(x, ctx, {
...params,
path: [
...params.path,
prefixPath,
i
]
}));
const rest = def.rest ? process(def.rest, ctx, {
...params,
path: [
...params.path,
restPath,
...ctx.target === "openapi-3.0" ? [def.items.length] : []
]
}) : null;
if (ctx.target === "draft-2020-12") {
json.prefixItems = prefixItems;
if (rest) json.items = rest;
} else if (ctx.target === "openapi-3.0") {
json.items = { anyOf: prefixItems };
if (rest) json.items.anyOf.push(rest);
json.minItems = prefixItems.length;
if (!rest) json.maxItems = prefixItems.length;
} else {
json.items = prefixItems;
if (rest) json.additionalItems = rest;
}
const { minimum, maximum } = schema._zod.bag;
if (typeof minimum === "number") json.minItems = minimum;
if (typeof maximum === "number") json.maxItems = maximum;
};
const recordProcessor = (schema, ctx, _json, params) => {
const json = _json;
const def = schema._zod.def;
json.type = "object";
const keyType = def.keyType;
const patterns = keyType._zod.bag?.patterns;
if (def.mode === "loose" && patterns && patterns.size > 0) {
const valueSchema = process(def.valueType, ctx, {
...params,
path: [
...params.path,
"patternProperties",
"*"
]
});
json.patternProperties = {};
for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
} else {
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process(def.keyType, ctx, {
...params,
path: [...params.path, "propertyNames"]
});
json.additionalProperties = process(def.valueType, ctx, {
...params,
path: [...params.path, "additionalProperties"]
});
}
const keyValues = keyType._zod.values;
if (keyValues) {
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
if (validKeyValues.length > 0) json.required = validKeyValues;
}
};
const nullableProcessor = (schema, ctx, json, params) => {
const def = schema._zod.def;
const inner = process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
if (ctx.target === "openapi-3.0") {
seen.ref = def.innerType;
json.nullable = true;
} else json.anyOf = [inner, { type: "null" }];
};
const nonoptionalProcessor = (schema, ctx, _json, params) => {
const def = schema._zod.def;
process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = def.innerType;
};
const defaultProcessor = (schema, ctx, json, params) => {
const def = schema._zod.def;
process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = def.innerType;
json.default = JSON.parse(JSON.stringify(def.defaultValue));
};
const prefaultProcessor = (schema, ctx, json, params) => {
const def = schema._zod.def;
process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = def.innerType;
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
};
const catchProcessor = (schema, ctx, json, params) => {
const def = schema._zod.def;
process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = def.innerType;
let catchValue;
try {
catchValue = def.catchValue(void 0);
} catch {
throw new Error("Dynamic catch values are not supported in JSON Schema");
}
json.default = catchValue;
};
const pipeProcessor = (schema, ctx, _json, params) => {
const def = schema._zod.def;
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
process(innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = innerType;
};
const readonlyProcessor = (schema, ctx, json, params) => {
const def = schema._zod.def;
process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = def.innerType;
json.readOnly = true;
};
const promiseProcessor = (schema, ctx, _json, params) => {
const def = schema._zod.def;
process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = def.innerType;
};
const optionalProcessor = (schema, ctx, _json, params) => {
const def = schema._zod.def;
process(def.innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = def.innerType;
};
const lazyProcessor = (schema, ctx, _json, params) => {
const innerType = schema._zod.innerType;
process(innerType, ctx, params);
const seen = ctx.seen.get(schema);
seen.ref = innerType;
};
const allProcessors = {
string: stringProcessor,
number: numberProcessor,
boolean: booleanProcessor,
bigint: bigintProcessor,
symbol: symbolProcessor,
null: nullProcessor,
undefined: undefinedProcessor,
void: voidProcessor,
never: neverProcessor,
any: anyProcessor,
unknown: unknownProcessor,
date: dateProcessor,
enum: enumProcessor,
literal: literalProcessor,
nan: nanProcessor,
template_literal: templateLiteralProcessor,
file: fileProcessor,
success: successProcessor,
custom: customProcessor,
function: functionProcessor,
transform: transformProcessor,
map: mapProcessor,
set: setProcessor,
array: arrayProcessor,
object: objectProcessor,
union: unionProcessor,
intersection: intersectionProcessor,
tuple: tupleProcessor,
record: recordProcessor,
nullable: nullableProcessor,
nonoptional: nonoptionalProcessor,
default: defaultProcessor,
prefault: prefaultProcessor,
catch: catchProcessor,
pipe: pipeProcessor,
readonly: readonlyProcessor,
promise: promiseProcessor,
optional: optionalProcessor,
lazy: lazyProcessor
};
function toJSONSchema(input, params) {
if ("_idmap" in input) {
const registry = input;
const ctx = initializeContext({
...params,
processors: allProcessors
});
const defs = {};
for (const entry of registry._idmap.entries()) {
const [_, schema] = entry;
process(schema, ctx);
}
const schemas = {};
ctx.external = {
registry,
uri: params?.uri,
defs
};
for (const entry of registry._idmap.entries()) {
const [key, schema] = entry;
extractDefs(ctx, schema);
schemas[key] = finalize(ctx, schema);
}
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
return { schemas };
}
const ctx = initializeContext({
...params,
processors: allProcessors
});
process(input, ctx);
extractDefs(ctx, input);
return finalize(ctx, input);
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
var iso_exports = /* @__PURE__ */ __exportAll({
ZodISODate: () => ZodISODate,
ZodISODateTime: () => ZodISODateTime,
ZodISODuration: () => ZodISODuration,
ZodISOTime: () => ZodISOTime,
date: () => date$1,
datetime: () => datetime,
duration: () => duration,
time: () => time
});
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
$ZodISODateTime.init(inst, def);
ZodStringFormat.init(inst, def);
});
function datetime(params) {
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
}
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
$ZodISODate.init(inst, def);
ZodStringFormat.init(inst, def);
});
function date$1(params) {
return /* @__PURE__ */ _isoDate(ZodISODate, params);
}
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
$ZodISOTime.init(inst, def);
ZodStringFormat.init(inst, def);
});
function time(params) {
return /* @__PURE__ */ _isoTime(ZodISOTime, params);
}
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
$ZodISODuration.init(inst, def);
ZodStringFormat.init(inst, def);
});
function duration(params) {
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
}
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
const initializer = (inst, issues) => {
$ZodError.init(inst, issues);
inst.name = "ZodError";
Object.defineProperties(inst, {
format: { value: (mapper) => formatError(inst, mapper) },
flatten: { value: (mapper) => flattenError(inst, mapper) },
addIssue: { value: (issue) => {
inst.issues.push(issue);
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
} },
addIssues: { value: (issues) => {
inst.issues.push(...issues);
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
} },
isEmpty: { get() {
return inst.issues.length === 0;
} }
});
};
const ZodError = /*@__PURE__*/ $constructor("ZodError", initializer);
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
const parse = /* @__PURE__ */ _parse(ZodRealError);
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
const encode = /* @__PURE__ */ _encode(ZodRealError);
const decode = /* @__PURE__ */ _decode(ZodRealError);
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
//#endregion
//#region node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
var schemas_exports = /* @__PURE__ */ __exportAll({
ZodAny: () => ZodAny,
ZodArray: () => ZodArray,
ZodBase64: () => ZodBase64,
ZodBase64URL: () => ZodBase64URL,
ZodBigInt: () => ZodBigInt,
ZodBigIntFormat: () => ZodBigIntFormat,
ZodBoolean: () => ZodBoolean,
ZodCIDRv4: () => ZodCIDRv4,
ZodCIDRv6: () => ZodCIDRv6,
ZodCUID: () => ZodCUID,
ZodCUID2: () => ZodCUID2,
ZodCatch: () => ZodCatch,
ZodCodec: () => ZodCodec,
ZodCustom: () => ZodCustom,
ZodCustomStringFormat: () => ZodCustomStringFormat,
ZodDate: () => ZodDate,
ZodDefault: () => ZodDefault,
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
ZodE164: () => ZodE164,
ZodEmail: () => ZodEmail,
ZodEmoji: () => ZodEmoji,
ZodEnum: () => ZodEnum,
ZodExactOptional: () => ZodExactOptional,
ZodFile: () => ZodFile,
ZodFunction: () => ZodFunction,
ZodGUID: () => ZodGUID,
ZodIPv4: () => ZodIPv4,
ZodIPv6: () => ZodIPv6,
ZodIntersection: () => ZodIntersection,
ZodJWT: () => ZodJWT,
ZodKSUID: () => ZodKSUID,
ZodLazy: () => ZodLazy,
ZodLiteral: () => ZodLiteral,
ZodMAC: () => ZodMAC,
ZodMap: () => ZodMap,
ZodNaN: () => ZodNaN,
ZodNanoID: () => ZodNanoID,
ZodNever: () => ZodNever,
ZodNonOptional: () => ZodNonOptional,
ZodNull: () => ZodNull,
ZodNullable: () => ZodNullable,
ZodNumber: () => ZodNumber,
ZodNumberFormat: () => ZodNumberFormat,
ZodObject: () => ZodObject,
ZodOptional: () => ZodOptional,
ZodPipe: () => ZodPipe,
ZodPrefault: () => ZodPrefault,
ZodPreprocess: () => ZodPreprocess,
ZodPromise: () => ZodPromise,
ZodReadonly: () => ZodReadonly,
ZodRecord: () => ZodRecord,
ZodSet: () => ZodSet,
ZodString: () => ZodString,
ZodStringFormat: () => ZodStringFormat,
ZodSuccess: () => ZodSuccess,
ZodSymbol: () => ZodSymbol,
ZodTemplateLiteral: () => ZodTemplateLiteral,
ZodTransform: () => ZodTransform,
ZodTuple: () => ZodTuple,
ZodType: () => ZodType,
ZodULID: () => ZodULID,
ZodURL: () => ZodURL,
ZodUUID: () => ZodUUID,
ZodUndefined: () => ZodUndefined,
ZodUnion: () => ZodUnion,
ZodUnknown: () => ZodUnknown,
ZodVoid: () => ZodVoid,
ZodXID: () => ZodXID,
ZodXor: () => ZodXor,
_ZodString: () => _ZodString,
_default: () => _default,
_function: () => _function,
any: () => any,
array: () => array,
base64: () => base64,
base64url: () => base64url,
bigint: () => bigint,
boolean: () => boolean,
catch: () => _catch,
check: () => check,
cidrv4: () => cidrv4,
cidrv6: () => cidrv6,
codec: () => codec,
cuid: () => cuid,
cuid2: () => cuid2,
custom: () => custom,
date: () => date,
describe: () => describe,
discriminatedUnion: () => discriminatedUnion,
e164: () => e164,
email: () => email,
emoji: () => emoji,
enum: () => _enum,
exactOptional: () => exactOptional,
file: () => file,
float32: () => float32,
float64: () => float64,
function: () => _function,
guid: () => guid,
hash: () => hash,
hex: () => hex,
hostname: () => hostname,
httpUrl: () => httpUrl,
instanceof: () => _instanceof,
int: () => int,
int32: () => int32,
int64: () => int64,
intersection: () => intersection,
invertCodec: () => invertCodec,
ipv4: () => ipv4,
ipv6: () => ipv6,
json: () => json,
jwt: () => jwt,
keyof: () => keyof,
ksuid: () => ksuid,
lazy: () => lazy,
literal: () => literal,
looseObject: () => looseObject,
looseRecord: () => looseRecord,
mac: () => mac,
map: () => map,
meta: () => meta,
nan: () => nan,
nanoid: () => nanoid,
nativeEnum: () => nativeEnum,
never: () => never,
nonoptional: () => nonoptional,
null: () => _null,
nullable: () => nullable,
nullish: () => nullish,
number: () => number,
object: () => object,
optional: () => optional,
partialRecord: () => partialRecord,
pipe: () => pipe,
prefault: () => prefault,
preprocess: () => preprocess,
promise: () => promise,
readonly: () => readonly,
record: () => record,
refine: () => refine,
set: () => set,
strictObject: () => strictObject,
string: () => string,
stringFormat: () => stringFormat,
stringbool: () => stringbool,
success: () => success,
superRefine: () => superRefine,
symbol: () => symbol,
templateLiteral: () => templateLiteral,
transform: () => transform,
tuple: () => tuple,
uint32: () => uint32,
uint64: () => uint64,
ulid: () => ulid,
undefined: () => _undefined,
union: () => union,
unknown: () => unknown,
url: () => url,
uuid: () => uuid,
uuidv4: () => uuidv4,
uuidv6: () => uuidv6,
uuidv7: () => uuidv7,
void: () => _void,
xid: () => xid,
xor: () => xor
});
const _installedGroups = /* @__PURE__ */ new WeakMap();
function _installLazyMethods(inst, group, methods) {
const proto = Object.getPrototypeOf(inst);
let installed = _installedGroups.get(proto);
if (!installed) {
installed = /* @__PURE__ */ new Set();
_installedGroups.set(proto, installed);
}
if (installed.has(group)) return;
installed.add(group);
for (const key in methods) {
const fn = methods[key];
Object.defineProperty(proto, key, {
configurable: true,
enumerable: false,
get() {
const bound = fn.bind(this);
Object.defineProperty(this, key, {
configurable: true,
writable: true,
enumerable: true,
value: bound
});
return bound;
},
set(v) {
Object.defineProperty(this, key, {
configurable: true,
writable: true,
enumerable: true,
value: v
});
}
});
}
}
const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
$ZodType.init(inst, def);
Object.assign(inst["~standard"], { jsonSchema: {
input: createStandardJSONSchemaMethod(inst, "input"),
output: createStandardJSONSchemaMethod(inst, "output")
} });
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
inst.def = def;
inst.type = def.type;
Object.defineProperty(inst, "_def", { value: def });
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
inst.safeParse = (data, params) => safeParse(inst, data, params);
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
inst.spa = inst.safeParseAsync;
inst.encode = (data, params) => encode(inst, data, params);
inst.decode = (data, params) => decode(inst, data, params);
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
_installLazyMethods(inst, "ZodType", {
check(...chks) {
const def = this.def;
return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
check: ch,
def: { check: "custom" },
onattach: []
} } : ch)] }), { parent: true });
},
with(...chks) {
return this.check(...chks);
},
clone(def, params) {
return clone(this, def, params);
},
brand() {
return this;
},
register(reg, meta) {
reg.add(this, meta);
return this;
},
refine(check, params) {
return this.check(refine(check, params));
},
superRefine(refinement, params) {
return this.check(superRefine(refinement, params));
},
overwrite(fn) {
return this.check(/* @__PURE__ */ _overwrite(fn));
},
optional() {
return optional(this);
},
exactOptional() {
return exactOptional(this);
},
nullable() {
return nullable(this);
},
nullish() {
return optional(nullable(this));
},
nonoptional(params) {
return nonoptional(this, params);
},
array() {
return array(this);
},
or(arg) {
return union([this, arg]);
},
and(arg) {
return intersection(this, arg);
},
transform(tx) {
return pipe(this, transform(tx));
},
default(d) {
return _default(this, d);
},
prefault(d) {
return prefault(this, d);
},
catch(params) {
return _catch(this, params);
},
pipe(target) {
return pipe(this, target);
},
readonly() {
return readonly(this);
},
describe(description) {
const cl = this.clone();
globalRegistry.add(cl, { description });
return cl;
},
meta(...args) {
if (args.length === 0) return globalRegistry.get(this);
const cl = this.clone();
globalRegistry.add(cl, args[0]);
return cl;
},
isOptional() {
return this.safeParse(void 0).success;
},
isNullable() {
return this.safeParse(null).success;
},
apply(fn) {
return fn(this);
}
});
Object.defineProperty(inst, "description", {
get() {
return globalRegistry.get(inst)?.description;
},
configurable: true
});
return inst;
});
/** @internal */
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
$ZodString.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
const bag = inst._zod.bag;
inst.format = bag.format ?? null;
inst.minLength = bag.minimum ?? null;
inst.maxLength = bag.maximum ?? null;
_installLazyMethods(inst, "_ZodString", {
regex(...args) {
return this.check(/* @__PURE__ */ _regex(...args));
},
includes(...args) {
return this.check(/* @__PURE__ */ _includes(...args));
},
startsWith(...args) {
return this.check(/* @__PURE__ */ _startsWith(...args));
},
endsWith(...args) {
return this.check(/* @__PURE__ */ _endsWith(...args));
},
min(...args) {
return this.check(/* @__PURE__ */ _minLength(...args));
},
max(...args) {
return this.check(/* @__PURE__ */ _maxLength(...args));
},
length(...args) {
return this.check(/* @__PURE__ */ _length(...args));
},
nonempty(...args) {
return this.check(/* @__PURE__ */ _minLength(1, ...args));
},
lowercase(params) {
return this.check(/* @__PURE__ */ _lowercase(params));
},
uppercase(params) {
return this.check(/* @__PURE__ */ _uppercase(params));
},
trim() {
return this.check(/* @__PURE__ */ _trim());
},
normalize(...args) {
return this.check(/* @__PURE__ */ _normalize(...args));
},
toLowerCase() {
return this.check(/* @__PURE__ */ _toLowerCase());
},
toUpperCase() {
return this.check(/* @__PURE__ */ _toUpperCase());
},
slugify() {
return this.check(/* @__PURE__ */ _slugify());
}
});
});
const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
$ZodString.init(inst, def);
_ZodString.init(inst, def);
inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
inst.datetime = (params) => inst.check(datetime(params));
inst.date = (params) => inst.check(date$1(params));
inst.time = (params) => inst.check(time(params));
inst.duration = (params) => inst.check(duration(params));
});
function string(params) {
return /* @__PURE__ */ _string(ZodString, params);
}
const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
$ZodStringFormat.init(inst, def);
_ZodString.init(inst, def);
});
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
$ZodEmail.init(inst, def);
ZodStringFormat.init(inst, def);
});
function email(params) {
return /* @__PURE__ */ _email(ZodEmail, params);
}
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
$ZodGUID.init(inst, def);
ZodStringFormat.init(inst, def);
});
function guid(params) {
return /* @__PURE__ */ _guid(ZodGUID, params);
}
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
$ZodUUID.init(inst, def);
ZodStringFormat.init(inst, def);
});
function uuid(params) {
return /* @__PURE__ */ _uuid(ZodUUID, params);
}
function uuidv4(params) {
return /* @__PURE__ */ _uuidv4(ZodUUID, params);
}
function uuidv6(params) {
return /* @__PURE__ */ _uuidv6(ZodUUID, params);
}
function uuidv7(params) {
return /* @__PURE__ */ _uuidv7(ZodUUID, params);
}
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
$ZodURL.init(inst, def);
ZodStringFormat.init(inst, def);
});
function url(params) {
return /* @__PURE__ */ _url(ZodURL, params);
}
function httpUrl(params) {
return /* @__PURE__ */ _url(ZodURL, {
protocol: httpProtocol,
hostname: domain,
...normalizeParams(params)
});
}
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
$ZodEmoji.init(inst, def);
ZodStringFormat.init(inst, def);
});
function emoji(params) {
return /* @__PURE__ */ _emoji(ZodEmoji, params);
}
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
$ZodNanoID.init(inst, def);
ZodStringFormat.init(inst, def);
});
function nanoid(params) {
return /* @__PURE__ */ _nanoid(ZodNanoID, params);
}
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
$ZodCUID.init(inst, def);
ZodStringFormat.init(inst, def);
});
/**
* Validates a CUID v1 string.
*
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
* See https://github.com/paralleldrive/cuid.
*/
function cuid(params) {
return /* @__PURE__ */ _cuid(ZodCUID, params);
}
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
$ZodCUID2.init(inst, def);
ZodStringFormat.init(inst, def);
});
function cuid2(params) {
return /* @__PURE__ */ _cuid2(ZodCUID2, params);
}
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
$ZodULID.init(inst, def);
ZodStringFormat.init(inst, def);
});
function ulid(params) {
return /* @__PURE__ */ _ulid(ZodULID, params);
}
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
$ZodXID.init(inst, def);
ZodStringFormat.init(inst, def);
});
function xid(params) {
return /* @__PURE__ */ _xid(ZodXID, params);
}
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
$ZodKSUID.init(inst, def);
ZodStringFormat.init(inst, def);
});
function ksuid(params) {
return /* @__PURE__ */ _ksuid(ZodKSUID, params);
}
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
$ZodIPv4.init(inst, def);
ZodStringFormat.init(inst, def);
});
function ipv4(params) {
return /* @__PURE__ */ _ipv4(ZodIPv4, params);
}
const ZodMAC = /*@__PURE__*/ $constructor("ZodMAC", (inst, def) => {
$ZodMAC.init(inst, def);
ZodStringFormat.init(inst, def);
});
function mac(params) {
return /* @__PURE__ */ _mac(ZodMAC, params);
}
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
$ZodIPv6.init(inst, def);
ZodStringFormat.init(inst, def);
});
function ipv6(params) {
return /* @__PURE__ */ _ipv6(ZodIPv6, params);
}
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
$ZodCIDRv4.init(inst, def);
ZodStringFormat.init(inst, def);
});
function cidrv4(params) {
return /* @__PURE__ */ _cidrv4(ZodCIDRv4, params);
}
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
$ZodCIDRv6.init(inst, def);
ZodStringFormat.init(inst, def);
});
function cidrv6(params) {
return /* @__PURE__ */ _cidrv6(ZodCIDRv6, params);
}
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
$ZodBase64.init(inst, def);
ZodStringFormat.init(inst, def);
});
function base64(params) {
return /* @__PURE__ */ _base64(ZodBase64, params);
}
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
$ZodBase64URL.init(inst, def);
ZodStringFormat.init(inst, def);
});
function base64url(params) {
return /* @__PURE__ */ _base64url(ZodBase64URL, params);
}
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
$ZodE164.init(inst, def);
ZodStringFormat.init(inst, def);
});
function e164(params) {
return /* @__PURE__ */ _e164(ZodE164, params);
}
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
$ZodJWT.init(inst, def);
ZodStringFormat.init(inst, def);
});
function jwt(params) {
return /* @__PURE__ */ _jwt(ZodJWT, params);
}
const ZodCustomStringFormat = /*@__PURE__*/ $constructor("ZodCustomStringFormat", (inst, def) => {
$ZodCustomStringFormat.init(inst, def);
ZodStringFormat.init(inst, def);
});
function stringFormat(format, fnOrRegex, _params = {}) {
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
}
function hostname(_params) {
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, "hostname", hostname$1, _params);
}
function hex(_params) {
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, "hex", hex$1, _params);
}
function hash(alg, params) {
const format = `${alg}_${params?.enc ?? "hex"}`;
const regex = regexes_exports[format];
if (!regex) throw new Error(`Unrecognized hash format: ${format}`);
return /* @__PURE__ */ _stringFormat(ZodCustomStringFormat, format, regex, params);
}
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
$ZodNumber.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
_installLazyMethods(inst, "ZodNumber", {
gt(value, params) {
return this.check(/* @__PURE__ */ _gt(value, params));
},
gte(value, params) {
return this.check(/* @__PURE__ */ _gte(value, params));
},
min(value, params) {
return this.check(/* @__PURE__ */ _gte(value, params));
},
lt(value, params) {
return this.check(/* @__PURE__ */ _lt(value, params));
},
lte(value, params) {
return this.check(/* @__PURE__ */ _lte(value, params));
},
max(value, params) {
return this.check(/* @__PURE__ */ _lte(value, params));
},
int(params) {
return this.check(int(params));
},
safe(params) {
return this.check(int(params));
},
positive(params) {
return this.check(/* @__PURE__ */ _gt(0, params));
},
nonnegative(params) {
return this.check(/* @__PURE__ */ _gte(0, params));
},
negative(params) {
return this.check(/* @__PURE__ */ _lt(0, params));
},
nonpositive(params) {
return this.check(/* @__PURE__ */ _lte(0, params));
},
multipleOf(value, params) {
return this.check(/* @__PURE__ */ _multipleOf(value, params));
},
step(value, params) {
return this.check(/* @__PURE__ */ _multipleOf(value, params));
},
finite() {
return this;
}
});
const bag = inst._zod.bag;
inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
inst.isFinite = true;
inst.format = bag.format ?? null;
});
function number(params) {
return /* @__PURE__ */ _number(ZodNumber, params);
}
const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
$ZodNumberFormat.init(inst, def);
ZodNumber.init(inst, def);
});
function int(params) {
return /* @__PURE__ */ _int(ZodNumberFormat, params);
}
function float32(params) {
return /* @__PURE__ */ _float32(ZodNumberFormat, params);
}
function float64(params) {
return /* @__PURE__ */ _float64(ZodNumberFormat, params);
}
function int32(params) {
return /* @__PURE__ */ _int32(ZodNumberFormat, params);
}
function uint32(params) {
return /* @__PURE__ */ _uint32(ZodNumberFormat, params);
}
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
$ZodBoolean.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
});
function boolean(params) {
return /* @__PURE__ */ _boolean(ZodBoolean, params);
}
const ZodBigInt = /*@__PURE__*/ $constructor("ZodBigInt", (inst, def) => {
$ZodBigInt.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => bigintProcessor(inst, ctx, json, params);
inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
inst.gt = (value, params) => inst.check(/* @__PURE__ */ _gt(value, params));
inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
inst.lt = (value, params) => inst.check(/* @__PURE__ */ _lt(value, params));
inst.lte = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
inst.positive = (params) => inst.check(/* @__PURE__ */ _gt(BigInt(0), params));
inst.negative = (params) => inst.check(/* @__PURE__ */ _lt(BigInt(0), params));
inst.nonpositive = (params) => inst.check(/* @__PURE__ */ _lte(BigInt(0), params));
inst.nonnegative = (params) => inst.check(/* @__PURE__ */ _gte(BigInt(0), params));
inst.multipleOf = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
const bag = inst._zod.bag;
inst.minValue = bag.minimum ?? null;
inst.maxValue = bag.maximum ?? null;
inst.format = bag.format ?? null;
});
function bigint(params) {
return /* @__PURE__ */ _bigint(ZodBigInt, params);
}
const ZodBigIntFormat = /*@__PURE__*/ $constructor("ZodBigIntFormat", (inst, def) => {
$ZodBigIntFormat.init(inst, def);
ZodBigInt.init(inst, def);
});
function int64(params) {
return /* @__PURE__ */ _int64(ZodBigIntFormat, params);
}
function uint64(params) {
return /* @__PURE__ */ _uint64(ZodBigIntFormat, params);
}
const ZodSymbol = /*@__PURE__*/ $constructor("ZodSymbol", (inst, def) => {
$ZodSymbol.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => symbolProcessor(inst, ctx, json, params);
});
function symbol(params) {
return /* @__PURE__ */ _symbol(ZodSymbol, params);
}
const ZodUndefined = /*@__PURE__*/ $constructor("ZodUndefined", (inst, def) => {
$ZodUndefined.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => undefinedProcessor(inst, ctx, json, params);
});
function _undefined(params) {
return /* @__PURE__ */ _undefined$1(ZodUndefined, params);
}
const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
$ZodNull.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
});
function _null(params) {
return /* @__PURE__ */ _null$1(ZodNull, params);
}
const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def) => {
$ZodAny.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
});
function any() {
return /* @__PURE__ */ _any(ZodAny);
}
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
$ZodUnknown.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => void 0;
});
function unknown() {
return /* @__PURE__ */ _unknown(ZodUnknown);
}
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
$ZodNever.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
});
function never(params) {
return /* @__PURE__ */ _never(ZodNever, params);
}
const ZodVoid = /*@__PURE__*/ $constructor("ZodVoid", (inst, def) => {
$ZodVoid.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => voidProcessor(inst, ctx, json, params);
});
function _void(params) {
return /* @__PURE__ */ _void$1(ZodVoid, params);
}
const ZodDate = /*@__PURE__*/ $constructor("ZodDate", (inst, def) => {
$ZodDate.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => dateProcessor(inst, ctx, json, params);
inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
const c = inst._zod.bag;
inst.minDate = c.minimum ? new Date(c.minimum) : null;
inst.maxDate = c.maximum ? new Date(c.maximum) : null;
});
function date(params) {
return /* @__PURE__ */ _date(ZodDate, params);
}
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
$ZodArray.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
inst.element = def.element;
_installLazyMethods(inst, "ZodArray", {
min(n, params) {
return this.check(/* @__PURE__ */ _minLength(n, params));
},
nonempty(params) {
return this.check(/* @__PURE__ */ _minLength(1, params));
},
max(n, params) {
return this.check(/* @__PURE__ */ _maxLength(n, params));
},
length(n, params) {
return this.check(/* @__PURE__ */ _length(n, params));
},
unwrap() {
return this.element;
}
});
});
function array(element, params) {
return /* @__PURE__ */ _array(ZodArray, element, params);
}
function keyof(schema) {
const shape = schema._zod.def.shape;
return _enum(Object.keys(shape));
}
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
$ZodObjectJIT.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
defineLazy(inst, "shape", () => {
return def.shape;
});
_installLazyMethods(inst, "ZodObject", {
keyof() {
return _enum(Object.keys(this._zod.def.shape));
},
catchall(catchall) {
return this.clone({
...this._zod.def,
catchall
});
},
passthrough() {
return this.clone({
...this._zod.def,
catchall: unknown()
});
},
loose() {
return this.clone({
...this._zod.def,
catchall: unknown()
});
},
strict() {
return this.clone({
...this._zod.def,
catchall: never()
});
},
strip() {
return this.clone({
...this._zod.def,
catchall: void 0
});
},
extend(incoming) {
return extend(this, incoming);
},
safeExtend(incoming) {
return safeExtend(this, incoming);
},
merge(other) {
return merge(this, other);
},
pick(mask) {
return pick(this, mask);
},
omit(mask) {
return omit(this, mask);
},
partial(...args) {
return partial(ZodOptional, this, args[0]);
},
required(...args) {
return required(ZodNonOptional, this, args[0]);
}
});
});
function object(shape, params) {
const def = {
type: "object",
shape: shape ?? {},
...normalizeParams(params)
};
return new ZodObject(def);
}
function strictObject(shape, params) {
return new ZodObject({
type: "object",
shape,
catchall: never(),
...normalizeParams(params)
});
}
function looseObject(shape, params) {
return new ZodObject({
type: "object",
shape,
catchall: unknown(),
...normalizeParams(params)
});
}
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
$ZodUnion.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
inst.options = def.options;
});
function union(options, params) {
return new ZodUnion({
type: "union",
options,
...normalizeParams(params)
});
}
const ZodXor = /*@__PURE__*/ $constructor("ZodXor", (inst, def) => {
ZodUnion.init(inst, def);
$ZodXor.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
inst.options = def.options;
});
/** Creates an exclusive union (XOR) where exactly one option must match.
* Unlike regular unions that succeed when any option matches, xor fails if
* zero or more than one option matches the input. */
function xor(options, params) {
return new ZodXor({
type: "union",
options,
inclusive: false,
...normalizeParams(params)
});
}
const ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
ZodUnion.init(inst, def);
$ZodDiscriminatedUnion.init(inst, def);
});
function discriminatedUnion(discriminator, options, params) {
return new ZodDiscriminatedUnion({
type: "union",
options,
discriminator,
...normalizeParams(params)
});
}
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
$ZodIntersection.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
});
function intersection(left, right) {
return new ZodIntersection({
type: "intersection",
left,
right
});
}
const ZodTuple = /*@__PURE__*/ $constructor("ZodTuple", (inst, def) => {
$ZodTuple.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
inst.rest = (rest) => inst.clone({
...inst._zod.def,
rest
});
});
function tuple(items, _paramsOrRest, _params) {
const hasRest = _paramsOrRest instanceof $ZodType;
return new ZodTuple({
type: "tuple",
items,
rest: hasRest ? _paramsOrRest : null,
...normalizeParams(hasRest ? _params : _paramsOrRest)
});
}
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
$ZodRecord.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
inst.keyType = def.keyType;
inst.valueType = def.valueType;
});
function record(keyType, valueType, params) {
if (!valueType || !valueType._zod) return new ZodRecord({
type: "record",
keyType: string(),
valueType: keyType,
...normalizeParams(valueType)
});
return new ZodRecord({
type: "record",
keyType,
valueType,
...normalizeParams(params)
});
}
function partialRecord(keyType, valueType, params) {
const k = clone(keyType);
k._zod.values = void 0;
return new ZodRecord({
type: "record",
keyType: k,
valueType,
...normalizeParams(params)
});
}
function looseRecord(keyType, valueType, params) {
return new ZodRecord({
type: "record",
keyType,
valueType,
mode: "loose",
...normalizeParams(params)
});
}
const ZodMap = /*@__PURE__*/ $constructor("ZodMap", (inst, def) => {
$ZodMap.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => mapProcessor(inst, ctx, json, params);
inst.keyType = def.keyType;
inst.valueType = def.valueType;
inst.min = (...args) => inst.check(/* @__PURE__ */ _minSize(...args));
inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minSize(1, params));
inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
});
function map(keyType, valueType, params) {
return new ZodMap({
type: "map",
keyType,
valueType,
...normalizeParams(params)
});
}
const ZodSet = /*@__PURE__*/ $constructor("ZodSet", (inst, def) => {
$ZodSet.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => setProcessor(inst, ctx, json, params);
inst.min = (...args) => inst.check(/* @__PURE__ */ _minSize(...args));
inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minSize(1, params));
inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
});
function set(valueType, params) {
return new ZodSet({
type: "set",
valueType,
...normalizeParams(params)
});
}
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
$ZodEnum.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
inst.enum = def.entries;
inst.options = Object.values(def.entries);
const keys = new Set(Object.keys(def.entries));
inst.extract = (values, params) => {
const newEntries = {};
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
else throw new Error(`Key ${value} not found in enum`);
return new ZodEnum({
...def,
checks: [],
...normalizeParams(params),
entries: newEntries
});
};
inst.exclude = (values, params) => {
const newEntries = { ...def.entries };
for (const value of values) if (keys.has(value)) delete newEntries[value];
else throw new Error(`Key ${value} not found in enum`);
return new ZodEnum({
...def,
checks: [],
...normalizeParams(params),
entries: newEntries
});
};
});
function _enum(values, params) {
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
return new ZodEnum({
type: "enum",
entries,
...normalizeParams(params)
});
}
/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
*
* ```ts
* enum Colors { red, green, blue }
* z.enum(Colors);
* ```
*/
function nativeEnum(entries, params) {
return new ZodEnum({
type: "enum",
entries,
...normalizeParams(params)
});
}
const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
$ZodLiteral.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
inst.values = new Set(def.values);
Object.defineProperty(inst, "value", { get() {
if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
return def.values[0];
} });
});
function literal(value, params) {
return new ZodLiteral({
type: "literal",
values: Array.isArray(value) ? value : [value],
...normalizeParams(params)
});
}
const ZodFile = /*@__PURE__*/ $constructor("ZodFile", (inst, def) => {
$ZodFile.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => fileProcessor(inst, ctx, json, params);
inst.min = (size, params) => inst.check(/* @__PURE__ */ _minSize(size, params));
inst.max = (size, params) => inst.check(/* @__PURE__ */ _maxSize(size, params));
inst.mime = (types, params) => inst.check(/* @__PURE__ */ _mime(Array.isArray(types) ? types : [types], params));
});
function file(params) {
return /* @__PURE__ */ _file(ZodFile, params);
}
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
$ZodTransform.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
inst._zod.parse = (payload, _ctx) => {
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
payload.addIssue = (issue$1) => {
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
else {
const _issue = issue$1;
if (_issue.fatal) _issue.continue = false;
_issue.code ?? (_issue.code = "custom");
_issue.input ?? (_issue.input = payload.value);
_issue.inst ?? (_issue.inst = inst);
payload.issues.push(issue(_issue));
}
};
const output = def.transform(payload.value, payload);
if (output instanceof Promise) return output.then((output) => {
payload.value = output;
payload.fallback = true;
return payload;
});
payload.value = output;
payload.fallback = true;
return payload;
};
});
function transform(fn) {
return new ZodTransform({
type: "transform",
transform: fn
});
}
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
$ZodOptional.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function optional(innerType) {
return new ZodOptional({
type: "optional",
innerType
});
}
const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
$ZodExactOptional.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function exactOptional(innerType) {
return new ZodExactOptional({
type: "optional",
innerType
});
}
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
$ZodNullable.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function nullable(innerType) {
return new ZodNullable({
type: "nullable",
innerType
});
}
function nullish(innerType) {
return optional(nullable(innerType));
}
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
$ZodDefault.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
inst.removeDefault = inst.unwrap;
});
function _default(innerType, defaultValue) {
return new ZodDefault({
type: "default",
innerType,
get defaultValue() {
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
}
});
}
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
$ZodPrefault.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function prefault(innerType, defaultValue) {
return new ZodPrefault({
type: "prefault",
innerType,
get defaultValue() {
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
}
});
}
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
$ZodNonOptional.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function nonoptional(innerType, params) {
return new ZodNonOptional({
type: "nonoptional",
innerType,
...normalizeParams(params)
});
}
const ZodSuccess = /*@__PURE__*/ $constructor("ZodSuccess", (inst, def) => {
$ZodSuccess.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => successProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function success(innerType) {
return new ZodSuccess({
type: "success",
innerType
});
}
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
$ZodCatch.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
inst.removeCatch = inst.unwrap;
});
function _catch(innerType, catchValue) {
return new ZodCatch({
type: "catch",
innerType,
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
});
}
const ZodNaN = /*@__PURE__*/ $constructor("ZodNaN", (inst, def) => {
$ZodNaN.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => nanProcessor(inst, ctx, json, params);
});
function nan(params) {
return /* @__PURE__ */ _nan(ZodNaN, params);
}
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
$ZodPipe.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
inst.in = def.in;
inst.out = def.out;
});
function pipe(in_, out) {
return new ZodPipe({
type: "pipe",
in: in_,
out
});
}
const ZodCodec = /*@__PURE__*/ $constructor("ZodCodec", (inst, def) => {
ZodPipe.init(inst, def);
$ZodCodec.init(inst, def);
});
function codec(in_, out, params) {
return new ZodCodec({
type: "pipe",
in: in_,
out,
transform: params.decode,
reverseTransform: params.encode
});
}
function invertCodec(codec) {
const def = codec._zod.def;
return new ZodCodec({
type: "pipe",
in: def.out,
out: def.in,
transform: def.reverseTransform,
reverseTransform: def.transform
});
}
const ZodPreprocess = /*@__PURE__*/ $constructor("ZodPreprocess", (inst, def) => {
ZodPipe.init(inst, def);
$ZodPreprocess.init(inst, def);
});
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
$ZodReadonly.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function readonly(innerType) {
return new ZodReadonly({
type: "readonly",
innerType
});
}
const ZodTemplateLiteral = /*@__PURE__*/ $constructor("ZodTemplateLiteral", (inst, def) => {
$ZodTemplateLiteral.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => templateLiteralProcessor(inst, ctx, json, params);
});
function templateLiteral(parts, params) {
return new ZodTemplateLiteral({
type: "template_literal",
parts,
...normalizeParams(params)
});
}
const ZodLazy = /*@__PURE__*/ $constructor("ZodLazy", (inst, def) => {
$ZodLazy.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => lazyProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.getter();
});
function lazy(getter) {
return new ZodLazy({
type: "lazy",
getter
});
}
const ZodPromise = /*@__PURE__*/ $constructor("ZodPromise", (inst, def) => {
$ZodPromise.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => promiseProcessor(inst, ctx, json, params);
inst.unwrap = () => inst._zod.def.innerType;
});
function promise(innerType) {
return new ZodPromise({
type: "promise",
innerType
});
}
const ZodFunction = /*@__PURE__*/ $constructor("ZodFunction", (inst, def) => {
$ZodFunction.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => functionProcessor(inst, ctx, json, params);
});
function _function(params) {
return new ZodFunction({
type: "function",
input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
output: params?.output ?? unknown()
});
}
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
$ZodCustom.init(inst, def);
ZodType.init(inst, def);
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
});
function check(fn) {
const ch = new $ZodCheck({ check: "custom" });
ch._zod.check = fn;
return ch;
}
function custom(fn, _params) {
return /* @__PURE__ */ _custom(ZodCustom, fn ?? (() => true), _params);
}
function refine(fn, _params = {}) {
return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
}
function superRefine(fn, params) {
return /* @__PURE__ */ _superRefine(fn, params);
}
const describe = describe$1;
const meta = meta$1;
function _instanceof(cls, params = {}) {
const inst = new ZodCustom({
type: "custom",
check: "custom",
fn: (data) => data instanceof cls,
abort: true,
...normalizeParams(params)
});
inst._zod.bag.Class = cls;
inst._zod.check = (payload) => {
if (!(payload.value instanceof cls)) payload.issues.push({
code: "invalid_type",
expected: cls.name,
input: payload.value,
inst,
path: [...inst._zod.def.path ?? []]
});
};
return inst;
}
const stringbool = (...args) => /* @__PURE__ */ _stringbool({
Codec: ZodCodec,
Boolean: ZodBoolean,
String: ZodString
}, ...args);
function json(params) {
const jsonSchema = lazy(() => {
return union([
string(params),
number(),
boolean(),
_null(),
array(jsonSchema),
record(string(), jsonSchema)
]);
});
return jsonSchema;
}
function preprocess(fn, schema) {
return new ZodPreprocess({
type: "pipe",
in: transform(fn),
out: schema
});
}
//#endregion
export { ZodString as $, $ZodCUID as $a, _positive as $i, uuid as $n, $ZodTuple as $o, _discriminatedUnion as $r, encodeAsync$1 as $s, int as $t, ZodJWT as A, _uuid as Aa, _mac as Ai, preprocess as An, $ZodNanoID as Ao, initializeContext as Ar, $ZodCheckOverwrite as As, boolean as At, ZodNull as B, $input as Ba, _nativeEnum as Bi, stringbool as Bn, $ZodPipe as Bo, _check as Br, _encode as Bs, discriminatedUnion as Bt, ZodExactOptional as C, _uint64 as Ca, $constructor as Cc, _ksuid as Ci, nullish as Cn, $ZodJWT as Co, iso_exports as Cr, $ZodCheckMaxLength as Cs, _undefined as Ct, ZodIPv4 as D, _unknown as Da, _lowercase as Di, partialRecord as Dn, $ZodMAC as Do, createToJSONSchemaMethod as Dr, $ZodCheckMinSize as Ds, base64 as Dt, ZodGUID as E, _union as Ea, globalConfig as Ec, _literal as Ei, optional as En, $ZodLiteral as Eo, createStandardJSONSchemaMethod as Er, $ZodCheckMinLength as Es, array as Et, ZodMap as F, _xid as Fa, _minLength as Fi, schemas_exports as Fn, $ZodNumber as Fo, _base64 as Fr, $ZodCheckStringFormat as Fs, cuid as Ft, ZodOptional as G, $ZodArray as Ga, _nonpositive as Gi, transform as Gn, $ZodRecord as Go, _coercedDate as Gr, _safeDecodeAsync as Gs, file as Gt, ZodNumber as H, globalRegistry as Ha, _never as Hi, superRefine as Hn, $ZodPreprocess as Ho, _cidrv6 as Hr, _parse as Hs, email as Ht, ZodNaN as I, _xor as Ia, _minSize as Ii, set as In, $ZodNumberFormat as Io, _base64url as Ir, $ZodCheckUpperCase as Is, cuid2 as It, ZodPreprocess as J, $ZodBigInt as Ja, _nullable as Ji, uint64 as Jn, $ZodStringFormat as Jo, _cuid as Jr, _safeParse as Js, guid as Jt, ZodPipe as K, $ZodBase64 as Ka, _normalize as Ki, tuple as Kn, $ZodSet as Ko, _coercedNumber as Kr, _safeEncode as Ks, float32 as Kt, ZodNanoID as L, describe$1 as La, _multipleOf as Li, strictObject as Ln, $ZodObject as Lo, _bigint as Lr, regexes_exports as Ls, custom as Lt, ZodLazy as M, _uuidv6 as Ma, _maxLength as Mi, readonly as Mn, $ZodNonOptional as Mo, TimePrecision as Mr, $ZodCheckRegex as Ms, cidrv4 as Mt, ZodLiteral as N, _uuidv7 as Na, _maxSize as Ni, record as Nn, $ZodNull as No, _any as Nr, $ZodCheckSizeEquals as Ns, cidrv6 as Nt, ZodIPv6 as O, _uppercase as Oa, _lt as Oi, pipe as On, $ZodMap as Oo, extractDefs as Or, $ZodCheckMultipleOf as Os, base64url as Ot, ZodMAC as P, _void$1 as Pa, _mime as Pi, refine as Pn, $ZodNullable as Po, _array as Pr, $ZodCheckStartsWith as Ps, codec as Pt, ZodSet as Q, $ZodCIDRv6 as Qa, _pipe as Qi, url as Qn, $ZodTransform as Qo, _default$1 as Qr, encode$1 as Qs, httpUrl as Qt, ZodNever as R, meta$1 as Ra, _nan as Ri, string as Rn, $ZodObjectJIT as Ro, _boolean as Rr, _decode as Rs, date as Rt, ZodEnum as S, _uint32 as Sa, $brand as Sc, _jwt as Si, nullable as Sn, $ZodIntersection as So, ZodISOTime as Sr, $ZodCheckLowerCase as Ss, _null as St, ZodFunction as T, _undefined$1 as Ta, config as Tc, _length as Ti, object as Tn, $ZodLazy as To, toJSONSchema as Tr, $ZodCheckMimeType as Ts, any as Tt, ZodNumberFormat as U, registry as Ua, _nonnegative as Ui, symbol as Un, $ZodPromise as Uo, _coercedBigint as Ur, _parseAsync as Us, emoji as Ut, ZodNullable as V, $output as Va, _negative as Vi, success as Vn, $ZodPrefault as Vo, _cidrv4 as Vr, _encodeAsync as Vs, e164 as Vt, ZodObject as W, $ZodAny as Wa, _nonoptional as Wi, templateLiteral as Wn, $ZodReadonly as Wo, _coercedBoolean as Wr, _safeDecode as Ws, exactOptional as Wt, ZodReadonly as X, $ZodBoolean as Xa, _optional as Xi, union as Xn, $ZodSymbol as Xo, _custom as Xr, decode$1 as Xs, hex as Xt, ZodPromise as Y, $ZodBigIntFormat as Ya, _number as Yi, ulid as Yn, $ZodSuccess as Yo, _cuid2 as Yr, _safeParseAsync as Ys, hash as Yt, ZodRecord as Z, $ZodCIDRv4 as Za, _overwrite as Zi, unknown as Zn, $ZodTemplateLiteral as Zo, _date as Zr, decodeAsync$1 as Zs, hostname as Zt, ZodDefault as _, _toLowerCase as _a, parsedType as _c, _ipv6 as _i, nan as _n, $ZodIPv6 as _o, ZodError as _r, $ZodCheckEndsWith as _s, _catch as _t, ZodBigInt as a, _regex as aa, safeEncodeAsync$1 as ac, _file as ai, ipv6 as an, $ZodDate as ao, decode as ar, $ZodUnion as as, ZodTuple as at, ZodEmail as b, _trim as ba, $ZodAsyncError as bc, _isoDuration as bi, never as bn, $ZodISODuration as bo, ZodISODateTime as br, $ZodCheckLengthEquals as bs, _function as bt, ZodCIDRv4 as c, _slugify as ca, $ZodError as cc, _gt as ci, keyof as cn, $ZodE164 as co, encodeAsync as cr, $ZodXID as cs, ZodURL as ct, ZodCUID2 as d, _stringFormat as da, formatError as dc, _includes as di, literal as dn, $ZodEnum as do, safeDecode as dr, isValidBase64URL as ds, ZodUnion as dt, _promise as ea, parse$1 as ec, _e164 as ei, int32 as en, $ZodCUID2 as eo, uuidv4 as er, $ZodType as es, ZodStringFormat as et, ZodCatch as f, _stringbool as fa, prettifyError as fc, _int as fi, looseObject as fn, $ZodExactOptional as fo, safeDecodeAsync as fr, isValidJWT as fs, ZodUnknown as ft, ZodDate as g, _templateLiteral as ga, joinValues as gc, _ipv4 as gi, meta as gn, $ZodIPv4 as go, safeParseAsync as gr, $ZodCheckBigIntFormat as gs, _ZodString as gt, ZodCustomStringFormat as h, _symbol as ha, clone as hc, _intersection as hi, map as hn, $ZodGUID as ho, safeParse as hr, $ZodCheck as hs, ZodXor as ht, ZodBase64URL as i, _refine as ia, safeEncode$1 as ic, _enum$1 as ii, ipv4 as in, $ZodCustomStringFormat as io, xor as ir, $ZodUndefined as is, ZodTransform as it, ZodKSUID as j, _uuidv4 as ja, _map as ji, promise as jn, $ZodNever as jo, process as jr, $ZodCheckProperty as js, check as jt, ZodIntersection as k, _url as ka, _lte as ki, prefault as kn, $ZodNaN as ko, finalize as kr, $ZodCheckNumberFormat as ks, bigint as kt, ZodCIDRv6 as l, _startsWith as la, $ZodRealError as lc, _gte as li, ksuid as ln, $ZodEmail as lo, parse as lr, $ZodXor as ls, ZodUUID as lt, ZodCustom as m, _superRefine as ma, treeifyError as mc, _int64 as mi, mac as mn, $ZodFunction as mo, safeEncodeAsync as mr, Doc as ms, ZodXID as mt, ZodArray as n, _readonly as na, safeDecode$1 as nc, _emoji as ni, intersection as nn, $ZodCodec as no, uuidv7 as nr, $ZodURL as ns, ZodSymbol as nt, ZodBigIntFormat as o, _set as oa, safeParse$1 as oc, _float32 as oi, json as on, $ZodDefault as oo, decodeAsync as or, $ZodUnknown as os, ZodType as ot, ZodCodec as p, _success as pa, toDotPath as pc, _int32 as pi, looseRecord as pn, $ZodFile as po, safeEncode as pr, version as ps, ZodVoid as pt, ZodPrefault as q, $ZodBase64URL as qa, _null$1 as qi, uint32 as qn, $ZodString as qo, _coercedString as qr, _safeEncodeAsync as qs, float64 as qt, ZodBase64 as r, _record as ra, safeDecodeAsync$1 as rc, _endsWith as ri, invertCodec as rn, $ZodCustom as ro, xid as rr, $ZodUUID as rs, ZodTemplateLiteral as rt, ZodBoolean as s, _size as sa, safeParseAsync$1 as sc, _float64 as si, jwt as sn, $ZodDiscriminatedUnion as so, encode as sr, $ZodVoid as ss, ZodULID as st, ZodAny as t, _property as ta, parseAsync$1 as tc, _email as ti, int64 as tn, $ZodCatch as to, uuidv6 as tr, $ZodULID as ts, ZodSuccess as tt, ZodCUID as u, _string as ua, flattenError as uc, _guid as ui, lazy as un, $ZodEmoji as uo, parseAsync as ur, isValidBase64 as us, ZodUndefined as ut, ZodDiscriminatedUnion as v, _toUpperCase as va, stringifyPrimitive as vc, _isoDate as vi, nanoid as vn, $ZodISODate as vo, ZodRealError as vr, $ZodCheckGreaterThan as vs, _default as vt, ZodFile as w, _ulid as wa, NEVER as wc, _lazy as wi, number as wn, $ZodKSUID as wo, allProcessors as wr, $ZodCheckMaxSize as ws, _void as wt, ZodEmoji as x, _tuple as xa, $ZodEncodeError as xc, _isoTime as xi, nonoptional as xn, $ZodISOTime as xo, ZodISODuration as xr, $ZodCheckLessThan as xs, _instanceof as xt, ZodE164 as y, _transform as ya, util_exports as yc, _isoDateTime as yi, nativeEnum as yn, $ZodISODateTime as yo, ZodISODate as yr, $ZodCheckIncludes as ys, _enum as yt, ZodNonOptional as z, $ZodRegistry as za, _nanoid as zi, stringFormat as zn, $ZodOptional as zo, _catch$1 as zr, _decodeAsync as zs, describe as zt };