openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5,738 lines • 162 kB
JavaScript
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
import { hasUnresolvedConfigValue } from "openclaw/plugin-sdk/gateway-config-runtime";
import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
import { patchTopLevelChannelConfigSection } from "openclaw/plugin-sdk/setup";
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
//#region extensions/a2a/src/accounts.ts
function listA2aChannelAccountIds(e) {
return e.channels?.a2a ? [DEFAULT_ACCOUNT_ID] : [];
}
function resolveDefaultA2aChannelAccountId() {
return DEFAULT_ACCOUNT_ID;
}
/**
* A `${VAR}` token reference whose variable is unset stays in config as literal
* text, so it must never act as a credential: a caller could send that guessable
* text as the bearer. Drop such peers (and such outbound tokens) so every consumer
* sees them as unconfigured.
*/
function withoutUnresolvedCredentials(e, t) {
const n = [];
const r = [];
const i = t.peers;
if (!i) return {
config: t,
unresolvedPeers: n,
unresolvedOutboundPeers: r
};
const a = {};
for (const [t, o] of Object.entries(i)) {
const i = [
"channels",
"a2a",
"peers",
t
];
if (hasUnresolvedConfigValue(e, [...i, "token"])) {
n.push(t);
continue;
}
if (o.outboundToken && hasUnresolvedConfigValue(e, [...i, "outboundToken"])) {
r.push(t);
const { outboundToken: e, ...n } = o;
a[t] = n;
continue;
}
a[t] = o;
}
return {
config: {
...t,
peers: a
},
unresolvedPeers: n,
unresolvedOutboundPeers: r
};
}
function resolveA2aChannelAccount(e) {
const { config: t, unresolvedPeers: n, unresolvedOutboundPeers: r } = withoutUnresolvedCredentials(e.cfg, e.cfg.channels?.a2a ?? {});
return {
accountId: normalizeAccountId(e.accountId),
enabled: t.enabled !== false,
configured: Object.keys(t.peers ?? {}).length > 0,
config: t,
unresolvedPeers: n,
unresolvedOutboundPeers: r
};
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
function getEnumValues(e) {
const t = Object.values(e).filter((e) => typeof e === "number");
return Object.entries(e).filter(([e, n]) => t.indexOf(+e) === -1).map(([e, t]) => t);
}
function joinValues(e, t = "|") {
return e.map((e) => stringifyPrimitive(e)).join(t);
}
function jsonStringifyReplacer(e, t) {
if (typeof t === "bigint") return t.toString();
return t;
}
var Cached = class {
constructor(e) {
this._getter = e;
this._value = void 0;
}
get value() {
const e = this._getter;
if (e !== void 0) {
this._value = e();
this._getter = void 0;
}
return this._value;
}
};
function cached(e) {
return new Cached(e);
}
function nullish(e) {
return e === null || e === void 0;
}
function cleanRegex(e) {
const t = e.startsWith("^") ? 1 : 0;
const n = e.endsWith("$") ? e.length - 1 : e.length;
return e.slice(t, n);
}
function floatSafeRemainder(e, t) {
const n = e / t;
const r = Math.round(n);
const i = 4 * Number.EPSILON * Math.max(Math.abs(n), 1);
if (Math.abs(n - r) < i) return 0;
return n - r;
}
function assignProp(e, t, n) {
Object.defineProperty(e, t, {
value: n,
writable: true,
enumerable: true,
configurable: true
});
}
/**
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
*
* Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
*/
function rawShape(e) {
const t = Object.getOwnPropertyDescriptor(e, "shape");
return t?.get ? t.get.raw : t?.value;
}
function sourceShape(e) {
return rawShape(e._zod.def) ?? e._zod.def.shape;
}
function deferProp(e, t, n) {
Object.defineProperty(e, t, {
get() {
const e = n();
assignProp(this, t, e);
return e;
},
enumerable: true,
configurable: true
});
}
function putProp(e, t, n) {
if (t in e) assignProp(e, t, n);
else e[t] = n;
}
/**
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
*
* A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
*/
function mirrorShape(e, t, n, r) {
const i = sourceShape(t);
for (const a of n) {
const n = Object.getOwnPropertyDescriptor(i, a);
if (!n.enumerable) continue;
if (n.get) deferProp(e, a, () => {
const e = t._zod.def.shape[a];
return r ? r(e, a) : e;
});
else putProp(e, a, r ? r(n.value, a) : n.value);
}
}
function mirrorProps(e, t) {
for (const n of Reflect.ownKeys(t)) {
const r = Object.getOwnPropertyDescriptor(t, n);
if (!r.enumerable) continue;
if (r.get) deferProp(e, n, () => t[n]);
else putProp(e, n, r.value);
}
}
function mergeDefs(...e) {
const t = {};
for (const n of e) {
const e = Object.getOwnPropertyDescriptors(n);
Object.assign(t, e);
}
return Object.defineProperties({}, t);
}
function esc(e) {
return JSON.stringify(e);
}
function slugify(e) {
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {};
function isObject(e) {
return typeof e === "object" && e !== null && !Array.isArray(e);
}
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 (e) {
return false;
}
});
function isPlainObject(e) {
if (isObject(e) === false) return false;
const t = e.constructor;
if (t === void 0) return true;
if (typeof t !== "function") return true;
const n = t.prototype;
if (isObject(n) === false) return false;
if (Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === false) return false;
return true;
}
function shallowClone(e) {
if (isPlainObject(e)) return { ...e };
if (Array.isArray(e)) return [...e];
if (e instanceof Map) return new Map(e);
if (e instanceof Set) return new Set(e);
return e;
}
const propertyKeyTypes = /* @__PURE__*/ new Set([
"string",
"number",
"symbol"
]);
function escapeRegex(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(e, t, n) {
const r = new e._zod.constr(t ?? e._zod.def);
if (!t || n?.parent) r._zod.parent = e;
return r;
}
function normalizeParams(e) {
const t = e;
if (!t) return {};
if (typeof t === "string") return { error: () => t };
if (t?.message !== void 0) {
if (t?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
t.error = t.message;
}
delete t.message;
if (typeof t.error === "string") return {
...t,
error: () => t.error
};
return t;
}
function stringifyPrimitive(e) {
if (typeof e === "bigint") return e.toString() + "n";
if (typeof e === "string") return `"${e}"`;
return `${e}`;
}
function optionalKeys(e) {
return Object.keys(e).filter((t) => {
return e[t]._zod.optin !== void 0 && e[t]._zod.optout === "optional";
});
}
const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
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(e, t) {
const n = e._zod.def;
const r = n.checks;
if (r && r.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
const i = {};
mirrorShape(i, e, maskedKeys(e, t));
return clone(e, mergeDefs(n, {
shape: i,
checks: []
}));
}
function maskedKeys(e, t) {
const n = sourceShape(e);
const r = [];
for (const e of Reflect.ownKeys(t)) {
if (!Object.getOwnPropertyDescriptor(n, e)?.enumerable) throw new Error(`Unrecognized key: "${String(e)}"`);
if (t[e]) r.push(e);
}
return r;
}
function omit(e, t) {
const n = e._zod.def;
const r = n.checks;
if (r && r.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
const i = new Set(maskedKeys(e, t));
const a = {};
mirrorShape(a, e, Reflect.ownKeys(sourceShape(e)).filter((e) => !i.has(e)));
return clone(e, mergeDefs(n, {
shape: a,
checks: []
}));
}
function extend(e, t) {
if (!isPlainObject(t)) throw new Error("Invalid input to extend: expected a plain object");
const n = e._zod.def.checks;
if (n && n.length > 0) {
const n = sourceShape(e);
for (const e of Reflect.ownKeys(t)) if (Object.getOwnPropertyDescriptor(n, e) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
}
return clone(e, mergeDefs(e._zod.def, { shape: extended(e, t) }));
}
function extended(e, t) {
const n = {};
mirrorShape(n, e, Reflect.ownKeys(sourceShape(e)));
mirrorProps(n, t);
return n;
}
function safeExtend(e, t) {
if (!isPlainObject(t)) throw new Error("Invalid input to safeExtend: expected a plain object");
return clone(e, mergeDefs(e._zod.def, { shape: extended(e, t) }));
}
function merge(e, t) {
if (!t?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
if (e._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
const n = {};
mirrorShape(n, e, Reflect.ownKeys(sourceShape(e)));
mirrorShape(n, t, Reflect.ownKeys(sourceShape(t)));
return clone(e, mergeDefs(e._zod.def, {
shape: n,
get catchall() {
return t._zod.def.catchall;
},
checks: t._zod.def.checks ?? []
}));
}
function partial(e, t, n, r = "partial") {
const i = t._zod.def.checks;
if (i && i.length > 0) throw new Error(`.${r}() cannot be used on object schemas containing refinements`);
const a = n ? new Set(maskedKeys(t, n)) : void 0;
const o = {};
mirrorShape(o, t, Reflect.ownKeys(sourceShape(t)), e && ((t, n) => a && !a.has(n) ? t : new e({
type: "optional",
innerType: t
})));
return clone(t, mergeDefs(t._zod.def, {
shape: o,
checks: []
}));
}
function required(e, t, n) {
const r = n ? new Set(maskedKeys(t, n)) : void 0;
const i = {};
mirrorShape(i, t, Reflect.ownKeys(sourceShape(t)), (t, n) => r && !r.has(n) ? t : new e({
type: "nonoptional",
innerType: t
}));
return clone(t, mergeDefs(t._zod.def, { shape: i }));
}
function aborted(e, t = 0) {
if (e.aborted === true) return true;
for (let n = t; n < e.issues.length; n++) if (e.issues[n]?.continue !== true) return true;
return false;
}
function explicitlyAborted(e, t = 0) {
if (e.aborted === true) return true;
for (let n = t; n < e.issues.length; n++) if (e.issues[n]?.continue === false) return true;
return false;
}
function prefixIssues(e, t) {
return t.map((t) => {
var n;
(n = t).path ?? (n.path = []);
t.path.unshift(e);
return t;
});
}
function unwrapMessage(e) {
return typeof e === "string" ? e : e?.message;
}
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
function sizeCaps(e) {
const t = [];
for (const n of e ?? []) {
const e = n._zod.def;
if (!/_(length|size)$|_equals$/.test(e.check)) break;
const r = e.maximum ?? e.length ?? e.size;
if (r >= 0) t.push([r, n]);
}
return t;
}
function attachSchema(e, t, n) {
var r;
for (let i = t; i < e.length; i++) (r = e[i]).schema ?? (r.schema = n);
}
function finalizeIssue(e, t, n) {
var r;
const i = e.inst?._zod?.traits;
if (i?.has("$ZodType")) {
if (i.has("$ZodCheck")) (r = e).schema ?? (r.schema = e.inst);
else e.schema = e.inst;
}
const a = e.schema !== e.inst ? e.schema?._zod.def?.error : void 0;
const o = e.message ? e.message : unwrapMessage(e.inst?._zod.def?.error?.(e)) ?? unwrapMessage(a?.(e)) ?? unwrapMessage(t?.error?.(e)) ?? unwrapMessage(n.customError?.(e)) ?? unwrapMessage(n.localeError?.(e)) ?? "Invalid input";
const s = {};
for (const t of Object.keys(e)) {
if (t === "inst" || t === "schema" || t === "continue" || t === "input" || t === "__proto__") continue;
s[t] = e[t];
}
s.path ?? (s.path = []);
s.message = o;
if (t?.reportInput) s.input = e.input;
return s;
}
const highSurrogate = /[\uD800-\uDBFF]/;
function codePointLength(e) {
const t = e.length;
if (!highSurrogate.test(e)) return t;
let n = t;
for (let r = 0; r < t - 1; r++) if ((e.charCodeAt(r) & 64512) === 55296 && (e.charCodeAt(r + 1) & 64512) === 56320) {
n--;
r++;
}
return n;
}
function getLengthableOrigin(e) {
if (Array.isArray(e)) return "array";
if (typeof e === "string") return "string";
return "unknown";
}
function parsedType(e) {
const t = typeof e;
switch (t) {
case "number": return Number.isNaN(e) ? "nan" : "number";
case "object": {
if (e === null) return "null";
if (Array.isArray(e)) return "array";
const t = e;
if (t && Object.getPrototypeOf(t) !== Object.prototype && "constructor" in t && t.constructor) return t.constructor.name;
}
}
return t;
}
function issue(...e) {
const [t, n, r] = e;
if (typeof t === "string") return {
message: t,
code: "custom",
input: n,
inst: r
};
return { ...t };
}
/**
* Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
*
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
*/
function members(e, t) {
for (const n in t) {
const r = Object.getOwnPropertyDescriptor(t, n);
if (r.get) Object.defineProperty(e, n, {
...r,
enumerable: false
});
else defineBound(e, n, r.value);
}
}
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
function own(e, t, n, r = true) {
Object.defineProperty(e, t, {
configurable: true,
writable: true,
enumerable: r,
value: n
});
return n;
}
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
function hide(e, t, n) {
return own(e, t, n, false);
}
/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
/* @__NO_SIDE_EFFECTS__ */
function derived(e, t) {
for (const n in e) {
const r = e[n];
Object.defineProperty(t, n, {
configurable: true,
enumerable: true,
get() {
return own(this, n, r(this));
},
set(e) {
own(this, n, e);
}
});
}
return t;
}
function defineBound(e, t, n) {
Object.defineProperty(e, t, {
configurable: true,
get() {
return this == null ? n : own(this, t, n.bind(this));
},
set(e) {
own(this, t, e);
}
});
}
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
function claim(e, t) {
const n = Object.getPrototypeOf(e);
return t in n ? void 0 : n;
}
let installing;
let broke = false;
const breaker = {
configurable: true,
get() {
broke = true;
}
};
/**
* Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
* constructor, computed from the internals object itself and cached there on
* first read. One accessor per constructor rather than one per instance.
*/
function defineLazyInternal(e, t, n) {
const r = Object.getPrototypeOf(e._zod);
if (t in r && installing !== e._zod) {
installing = void 0;
return;
}
installing = e._zod;
Object.defineProperty(r, t, {
configurable: true,
get() {
Object.defineProperty(this, t, breaker);
const e = broke;
broke = false;
try {
const r = n(this);
if (broke) delete this[t];
else Object.defineProperty(this, t, {
configurable: true,
writable: true,
value: r
});
broke = broke || e;
return r;
} catch (n) {
delete this[t];
broke = broke || e;
throw n;
}
},
set(e) {
Object.defineProperty(this, t, {
configurable: true,
writable: true,
value: e
});
}
});
}
/**
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
* data property. One accessor per constructor rather than one per instance, because an own accessor
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
*/
function installLazyProp(e, t, n, r) {
const i = claim(e, t);
if (!i) return;
Object.defineProperty(i, t, {
configurable: true,
get() {
const e = {
configurable: true,
writable: true,
enumerable: r,
value: void 0
};
Object.defineProperty(this, t, e);
e.value = n(this);
Object.defineProperty(this, t, e);
return e.value;
},
set(e) {
Object.defineProperty(this, t, {
configurable: true,
writable: true,
enumerable: r,
value: e
});
}
});
}
/** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
const CONSTANT_CATCH = "~constantCatch";
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
function constantCatch(e) {
const fn = () => e;
fn[CONSTANT_CATCH] = true;
return fn;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/core.js
var _a$1;
const _zodDesc = {
value: void 0,
enumerable: false
};
let _E = "captureStackTrace" in Error ? Error : null;
function newError(e) {
const t = _E;
if (t) {
const n = t.stackTraceLimit;
if (typeof n === "number") {
try {
t.stackTraceLimit = 0;
} catch {
_E = null;
return new e();
}
try {
return new e();
} finally {
t.stackTraceLimit = n;
}
}
}
return new e();
}
/* @__NO_SIDE_EFFECTS__ */
function $constructor(e, t, n, r) {
const i = {};
function Internals(e) {
this.def = e;
this.constr = _;
this.traits = /* @__PURE__ */ new Set();
}
Internals.prototype = i;
const a = n;
const o = a && /* @__PURE__ */ new WeakSet();
function init(n, r) {
if (!n._zod) {
_zodDesc.value = new Internals(r);
try {
Object.defineProperty(n, "_zod", _zodDesc);
} finally {
_zodDesc.value = void 0;
}
} else if (n._zod.traits.has(e)) return;
n._zod.traits.add(e);
t(n, r);
if (o) {
const e = Object.getPrototypeOf(n);
const t = n._zod.constr.prototype;
let r = e;
while (r && r !== t) r = Object.getPrototypeOf(r);
const i = r ?? e;
if (!o.has(i)) {
o.add(i);
members(i, a);
}
}
const i = _.prototype;
for (const e in i) {
if (!Object.prototype.hasOwnProperty.call(i, e)) continue;
if (!(e in n)) n[e] = i[e].bind(n);
}
}
const s = r?.Parent ?? Object;
class Definition extends s {}
Object.defineProperty(Definition, "name", { value: e });
function _(e) {
const t = r?.Parent ? newError(Definition) : this;
init(t, e);
const n = t._zod.deferred;
if (n) {
for (const e of n) e();
t._zod.deferred = void 0;
}
const i = globalThis.__zod_globalConfig?.postProcessor;
if (i) i(t);
return t;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, { value: (t) => {
if (r?.Parent && t instanceof r.Parent) return true;
return t?._zod?.traits?.has(e);
} });
Object.defineProperty(_, "name", { value: e });
return _;
}
var $ZodAsyncError = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
var $ZodEncodeError = class extends Error {
constructor(e) {
super(`Encountered unidirectional transform during encode: ${e}`);
this.name = "ZodEncodeError";
}
};
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
const globalConfig = globalThis.__zod_globalConfig;
function config(e) {
if (e) Object.assign(globalConfig, e);
return globalConfig;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/errors.js
function _getMessage() {
const e = this._zod;
e.message ?? (e.message = JSON.stringify(e.def, jsonStringifyReplacer, 2));
return e.message;
}
function _setMessage(e) {
this._zod.message = e;
}
const _messageDesc = {
get: _getMessage,
set: _setMessage,
enumerable: true,
configurable: true
};
const _issuesDesc = {
value: void 0,
enumerable: false
};
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
const initializer$1 = (e, t) => {
e.name = "$ZodError";
_issuesDesc.value = t;
Object.defineProperty(e, "issues", _issuesDesc);
_issuesDesc.value = void 0;
Object.defineProperty(e, "message", _messageDesc);
const n = Object.getPrototypeOf(e);
if (!_installedToString.has(n)) {
_installedToString.add(n);
Object.defineProperty(n, "toString", {
configurable: true,
enumerable: false,
get() {
const value = () => this.message;
Object.defineProperty(this, "toString", {
value,
configurable: true,
writable: true
});
return value;
},
set(e) {
Object.defineProperty(this, "toString", {
value: e,
configurable: true,
writable: true
});
}
});
}
};
const $ZodError = /* @__PURE__ */ $constructor("$ZodError", initializer$1);
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
* "__proto__" would hit the setter instead of creating a key. */
function node(e, t, n) {
if (!Object.prototype.hasOwnProperty.call(e, t)) {
if (t === "__proto__") Object.defineProperty(e, t, {
value: n(),
writable: true,
enumerable: true,
configurable: true
});
else e[t] = n();
}
return e[t];
}
function flattenError(e, t = (e) => e.message) {
const n = {};
const r = [];
for (const i of e.issues) if (i.path.length > 0) node(n, i.path[0], () => []).push(t(i));
else r.push(t(i));
return {
formErrors: r,
fieldErrors: n
};
}
function formatError(e, t = (e) => e.message) {
const n = { _errors: [] };
const processError = (e, r = []) => {
for (const i of e.issues) if (i.code === "invalid_union" && i.errors.length) i.errors.map((e) => processError({ issues: e }, [...r, ...i.path]));
else if (i.code === "invalid_key") processError({ issues: i.issues }, [...r, ...i.path]);
else if (i.code === "invalid_element") processError({ issues: i.issues }, [...r, ...i.path]);
else {
const e = [...r, ...i.path];
if (e.length === 0) n._errors.push(t(i));
else {
let r = n;
let a = 0;
while (a < e.length) {
const n = e[a];
const o = a === e.length - 1;
if (n === "_errors") {
if (o) r._errors.push(t(i));
a++;
continue;
}
if (!Object.prototype.hasOwnProperty.call(r, n)) Object.defineProperty(r, n, {
value: { _errors: [] },
enumerable: true,
writable: true,
configurable: true
});
const s = r[n];
if (o) s._errors.push(t(i));
r = s;
a++;
}
}
}
};
processError(e);
return n;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/parse.js
function finalizeParams(e, t) {
return {
callee: t?.callee ?? e,
Err: t?.Err
};
}
const _parse = (e) => {
const fn = (t, n, r, i) => {
const a = r ? {
...r,
async: false
} : { async: false };
const o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise) throw new $ZodAsyncError();
if (o.issues.length) {
const t = new ((i?.Err) ?? e)(o.issues.map((e) => finalizeIssue(e, a, config())));
captureStackTrace(t, i?.callee ?? fn);
throw t;
}
return o.value;
};
return fn;
};
const _parseAsync = (e) => {
const fn = async (t, n, r, i) => {
const a = r ? {
...r,
async: true
} : { async: true };
let o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise) o = await o;
if (o.issues.length) {
const t = new ((i?.Err) ?? e)(o.issues.map((e) => finalizeIssue(e, a, config())));
captureStackTrace(t, i?.callee ?? fn);
throw t;
}
return o.value;
};
return fn;
};
const _safeParse = (e) => (t, n, r) => {
const i = r ? {
...r,
async: false
} : { async: false };
const a = t._zod.run({
value: n,
issues: []
}, i);
if (a instanceof Promise) throw new $ZodAsyncError();
return a.issues.length ? failure(e, a.issues, i) : {
success: true,
data: a.value
};
};
function failure(e, t, n) {
let r;
return {
success: false,
get error() {
if (!r) {
r = new e(t.map((e) => finalizeIssue(e, n, config())));
t = void 0;
n = void 0;
}
return r;
},
set error(e) {
r = e;
t = void 0;
n = void 0;
}
};
}
const _safeParseAsync = (e) => async (t, n, r) => {
const i = r ? {
...r,
async: true
} : { async: true };
let a = t._zod.run({
value: n,
issues: []
}, i);
if (a instanceof Promise) a = await a;
return a.issues.length ? failure(e, a.issues, i) : {
success: true,
data: a.value
};
};
const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
const validate = ((e, t, n) => {
const r = e._zod.bag.validator;
if (r !== void 0) {
if (r(t) !== COMPILE_INVALID) return true;
if (r.definite === true && n === void 0) return false;
}
return validateFallback(e, t, n);
});
function validateFallback(e, t, n) {
const r = n ? {
...n,
async: false,
abortEarly: true
} : {
async: false,
abortEarly: true
};
const i = e._zod.bag.fallbackRun;
let a;
if (i) {
r[COMPILE_FALLBACK] = true;
a = i({
value: t,
issues: []
}, r);
} else a = e._zod.run({
value: t,
issues: []
}, r);
if (a instanceof Promise) throw new $ZodAsyncError();
return a.issues.length === 0;
}
const validateAsync$1 = async (e, t, n) => {
const r = n ? {
...n,
async: true,
abortEarly: true
} : {
async: true,
abortEarly: true
};
let i = e._zod.run({
value: t,
issues: []
}, r);
if (i instanceof Promise) i = await i;
return i.issues.length === 0;
};
const _encode = (e) => {
const t = _parse(e);
const fn = (e, n, r, i) => {
const a = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return t(e, n, a, finalizeParams(fn, i));
};
return fn;
};
const _decode = (e) => {
const t = _parse(e);
const fn = (e, n, r, i) => {
return t(e, n, r, finalizeParams(fn, i));
};
return fn;
};
const _encodeAsync = (e) => {
const t = _parseAsync(e);
const fn = async (e, n, r, i) => {
const a = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return await t(e, n, a, finalizeParams(fn, i));
};
return fn;
};
const _decodeAsync = (e) => {
const t = _parseAsync(e);
const fn = async (e, n, r, i) => {
return await t(e, n, r, finalizeParams(fn, i));
};
return fn;
};
const _safeEncode = (e) => (t, n, r) => {
const i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return _safeParse(e)(t, n, i);
};
const _safeDecode = (e) => (t, n, r) => {
return _safeParse(e)(t, n, r);
};
const _safeEncodeAsync = (e) => async (t, n, r) => {
const i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return _safeParseAsync(e)(t, n, i);
};
const _safeDecodeAsync = (e) => async (t, n, r) => {
return _safeParseAsync(e)(t, n, r);
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/regexes.js
/**
* @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 = /^[cC][0-9a-z]{6,}$/;
const cuid2 = /^[0-9a-z]+$/;
const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
const xid = /^[0-9a-vA-V]{20}$/;
const ksuid = /^[A-Za-z0-9]{27}$/;
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
function nanoidOfLength(e) {
return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`);
}
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
const guid = /^([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 = (e) => {
if (!e) 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}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
};
/** Practical email validation */
const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
function emoji() {
return new RegExp(_emoji$1, "u");
}
const ipv4 = /^(?:(?: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 = /^(([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 cidrv4 = /^((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 = /^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
const httpProtocol = /^https?$/;
const e164 = /^\+[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])))`;
/** Anchors a pattern source. The interpolation lives here rather than at the call site because
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
function anchor(e) {
return new RegExp(`^${e}$`);
}
const date = /*@__PURE__*/ anchor(dateSource);
function timeSource(e) {
const t = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
return typeof e.precision === "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : e.seconds ? `${t}:[0-5]\\d(?:\\.\\d+)?` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
}
function time(e) {
return new RegExp(`^${timeSource(e)}$`);
}
function datetime(e) {
const t = ["Z"];
if (e.offset) t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
const n = `${timeSource({
precision: e.precision,
seconds: true
})}(?:${t.join("|")})`;
const r = e.local ? `${n}|${timeSource({ precision: e.precision })}` : n;
return new RegExp(`^${dateSource}T(?:${r})$`);
}
const anyString = /^[\s\S]{0,}$/;
const integer = /^-?\d+$/;
const number$1 = /^-?\d+(?:\.\d+)?$/;
const boolean$1 = /^(?:true|false)$/i;
const _null$2 = /^null$/i;
const lowercase = /^[^A-Z]*$/;
const uppercase = /^[^a-z]*$/;
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/checks.js
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (e, t) => {
var n;
e._zod ?? (e._zod = {});
e._zod.def = t;
(n = e._zod).onattach ?? (n.onattach = []);
});
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
const _whenHasLength = (e) => {
const t = e.value;
return !nullish(t) && t.length !== void 0;
};
const numericOriginMap = {
number: "number",
bigint: "bigint",
object: "date"
};
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (e, t) => {
$ZodCheck.init(e, t);
const n = numericOriginMap[typeof t.value];
e._zod.check = (r) => {
if (t.inclusive ? r.value <= t.value : r.value < t.value) return;
r.issues.push({
origin: numericOriginMap[typeof r.value] ?? n,
code: "too_big",
maximum: typeof t.value === "object" ? t.value.getTime() : t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (e, t) => {
$ZodCheck.init(e, t);
const n = numericOriginMap[typeof t.value];
e._zod.check = (r) => {
if (t.inclusive ? r.value >= t.value : r.value > t.value) return;
r.issues.push({
origin: numericOriginMap[typeof r.value] ?? n,
code: "too_small",
minimum: typeof t.value === "object" ? t.value.getTime() : t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (e, t) => {
$ZodCheck.init(e, t);
e._zod.check = (n) => {
if (typeof n.value !== typeof t.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
if (typeof n.value === "bigint" ? t.value !== BigInt(0) && n.value % t.value === BigInt(0) : floatSafeRemainder(n.value, t.value) === 0) return;
n.issues.push({
origin: typeof n.value,
code: "not_multiple_of",
divisor: t.value,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (e, t) => {
$ZodCheck.init(e, t);
t.format = t.format || "float64";
const n = t.format?.includes("int");
const r = n ? "int" : "number";
const [i, a] = NUMBER_FORMAT_RANGES[t.format];
e._zod.check = (o) => {
const s = o.value;
if (n) {
if (!Number.isInteger(s)) {
o.issues.push({
expected: r,
format: t.format,
code: "invalid_type",
continue: false,
input: s,
inst: e
});
return;
}
if (!Number.isSafeInteger(s)) {
if (s > 0) o.issues.push({
input: s,
code: "too_big",
maximum: Number.MAX_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
inclusive: true,
continue: !t.abort
});
else o.issues.push({
input: s,
code: "too_small",
minimum: Number.MIN_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
inclusive: true,
continue: !t.abort
});
return;
}
}
if (s < i) o.issues.push({
origin: "number",
input: s,
code: "too_small",
minimum: i,
inclusive: true,
inst: e,
continue: !t.abort
});
if (s > a) o.issues.push({
origin: "number",
input: s,
code: "too_big",
maximum: a,
inclusive: true,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasLength);
e._zod.check = (n) => {
const r = n.value;
const i = r.length;
if ((typeof r === "string" && i > t.maximum ? codePointLength(r) : i) <= t.maximum) return;
const a = getLengthableOrigin(r);
n.issues.push({
origin: a,
code: "too_big",
maximum: t.maximum,
inclusive: true,
input: r,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasLength);
e._zod.check = (n) => {
const r = n.value;
const i = r.length;
if ((typeof r === "string" && i >= t.minimum && i < t.minimum * 2 ? codePointLength(r) : i) >= t.minimum) return;
const a = getLengthableOrigin(r);
n.issues.push({
origin: a,
code: "too_small",
minimum: t.minimum,
inclusive: true,
input: r,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasLength);
e._zod.check = (n) => {
const r = n.value;
const i = r.length;
const a = typeof r === "string" && i >= t.length && i <= t.length * 2 ? codePointLength(r) : i;
if (a === t.length) return;
const o = getLengthableOrigin(r);
const s = a > t.length;
n.issues.push({
origin: o,
...s ? {
code: "too_big",
maximum: t.length
} : {
code: "too_small",
minimum: t.length
},
inclusive: true,
exact: true,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (e, t) => {
var n, r;
$ZodCheck.init(e, t);
if (t.pattern) (n = e._zod).check ?? (n.check = (n) => {
t.pattern.lastIndex = 0;
if (t.pattern.test(n.value)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: t.format,
input: n.value,
...t.pattern ? { pattern: t.pattern.toString() } : {},
inst: e,
continue: !t.abort
});
});
else (r = e._zod).check ?? (r.check = () => {});
});
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (e, t) => {
$ZodCheckStringFormat.init(e, t);
e._zod.check = (n) => {
t.pattern.lastIndex = 0;
if (t.pattern.test(n.value)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "regex",
input: n.value,
pattern: t.pattern.toString(),
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (e, t) => {
t.pattern ?? (t.pattern = lowercase);
$ZodCheckStringFormat.init(e, t);
});
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (e, t) => {
t.pattern ?? (t.pattern = uppercase);
$ZodCheckStringFormat.init(e, t);
});
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (e, t) => {
$ZodCheck.init(e, t);
const n = escapeRegex(t.includes);
t.pattern = new RegExp(typeof t.position === "number" ? `^.{${t.position},}${n}` : n);
e._zod.check = (n) => {
if (n.value.includes(t.includes, t.position)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "includes",
includes: t.includes,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (e, t) => {
$ZodCheck.init(e, t);
const n = new RegExp(`^${escapeRegex(t.prefix)}.*`);
t.pattern ?? (t.pattern = n);
e._zod.check = (n) => {
if (n.value.startsWith(t.prefix)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "starts_with",
prefix: t.prefix,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (e, t) => {
$ZodCheck.init(e, t);
const n = new RegExp(`.*${escapeRegex(t.suffix)}$`);
t.pattern ?? (t.pattern = n);
e._zod.check = (n) => {
if (n.value.endsWith(t.suffix)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "ends_with",
suffix: t.suffix,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (e, t) => {
$ZodCheck.init(e, t);
e._zod.check = (e) => {
e.value = t.tx(e.value);
};
});
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/doc.js
var Doc = class {
constructor(e = [], t = {}) {
this.content = [];
this.indent = 0;
this.args = e;
this.closed = t;
}
indented(e) {
this.indent += 1;
try {
e(this);
} finally {
this.indent -= 1;
}
}
write(e) {
if (typeof e === "function") {
e(this, { execution: "sync" });
e(this, { execution: "async" });
return;
}
const t = e.split("\n").filter((e) => e);
const n = Math.min(...t.map((e) => e.length - e.trimStart().length));
const r = t.map((e) => e.slice(n)).map((e) => " ".repeat(this.indent * 2) + e);
for (const e of r) this.content.push(e);
}
compile() {
const e = Function;
const t = this?.content ?? [``];
return new e(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${t.join("\n")}\n};`)(...Object.values(this.closed));
}
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/versions.js
const version = {
major: 4,
minor: 6,
patch: 7
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/schemas.js
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (e, t) => {
var n;
e ?? (e = {});
e._zod.def = t;
e._zod.bag = e._zod.bag || {};
e._zod.version = version;
const r = e._zod.def.checks;
const i = e._zod.traits.has("$ZodCheck") ? [e, ...r ?? []] : r?.length ? [...r] : [];
for (const t of i) for (const n of t._zod.onattach) n(e);
if (i.length === 0) {
(n = e._zod).deferred ?? (n.deferred = []);
e._zod.deferred?.push(() => {
e._zod.run = e._zod.parse;
});
} else {
const runChecks = (t, n, r) => {
if (t.memo) return t;
let i = aborted(t);
let a;
for (const o of n) {
if (o._zod.def.when) {
if (explicitlyAborted(t)) continue;
if (!o._zod.def.when(t)) continue;
} else if (i) continue;
const n = t.issues.length;
const s = o._zod.check(t);
if (s instanceof Promise && r?.async === false) throw new $ZodAsyncError();
if (a || s instanceof Promise) a = (a ?? Promise.resolve()).then(async () => {
await s;
if (t.issues.length === n) return;
attachSchema(t.issues, n, e);
if (!i) i = aborted(t, n);
});
else {
if (t.issues.length === n) continue;
attachSchema(t.issues, n, e);
if (!i) i = aborted(t, n);
}
}
if (a) return a.then(() => {
return t;
});
return t;
};
const handleCanaryResult = (t, n, r) => {
if (aborted(t)) {
t.aborted = true;
return t;
}
const a = runChecks(n, i, r);
if (a instanceof Promise) {
if (r.async === false) throw new $ZodAsyncError();
return a.then((t) => e._zod.parse(t, r));
}
return e._zod.parse(a, r);
};
e._zod.run = (t, n) => {
if (n.skipChecks) return e._zod.parse(t, n);
if (n.direction === "backward") {
const r = e._zod.parse({
value: t.value,
issues: []
}, {
...n,
skipChecks: true
});
if (r instanceof Promise) return r.then((e) => {
return handleCanaryResult(e, t, n);
});
return handleCanaryResult(r, t, n);
}
const r = e._zod.parse(t, n);
if (r instanceof Promise) {
if (n.async === false) throw new $ZodAsyncError();
return r.then((e) => runChecks(e, i, n));
}
return runChecks(r, i, n);
};
}
}, {
get "~standard"() {
return hide(this, "~standard", standardProps(this));
},
set "~standard"(e) {
own(this, "~standard", e);
}
});
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
const toStandardResult = (e, t) => e.issues.length ? { issues: e.issues.map((e) => finalizeIssue(e, t, config())) } : { value: e.value };
async function validateAsync(e, t) {
const n = { async: true };
return toStandardResult(await e._zod.run({
value: t,
issues: []
}, n), n);
}
function standardProps(e) {
return {
validate: (t) => {
const n = { async: false };
try {
const r = e._zod.run({
value: t,
issues: []
}, n);
if (!(r instanceof Promise)) return toStandardResult(r, n);
} catch (e) {}
return validateAsync(e, t);
},
vendor: "zod",
version: 1
};
}
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = t.pattern ?? anyString;
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = String(n.value);
} catch (e) {}
if (typeof n.value === "string") return n;
n.issues.push({
expected: "string",
code: "invalid_type",
input: n.value,
inst: e
});
return n;
};
});
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (e, t) => {
$ZodCheckStringFormat.init(e, t);
$ZodString.init(e, t);
});
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (e, t) => {
t.pattern ?? (t.pattern = guid);
$ZodStringFormat.init(e, t);
});
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (e, t) => {
if (t.version) {
const e = {
v1: 1,
v2: 2,
v3: 3,
v4: 4,
v5: 5,
v6: 6,
v7: 7,
v8: 8
}[t.version];
if (e === void 0) throw new Error(`Invalid UUID version: "${t.version}"`);
t.pattern ?? (t.pattern = uuid(e));
} else t.pattern ?? (t.pattern = uuid());
$ZodStringFormat.init(e, t);
});
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (e, t) => {
t.pattern ?? (t.pattern = email);
$ZodStringFormat.init(e, t);
});
/** The `://` guard rejected the input before the URL constructor saw it. */
const URL_BAD_FORMAT = 1;
/** The URL parser rejected the input. */
const URL_UNPARSEABLE = 2;
function canParseURL(e) {
try {
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(e);
new URL(e);
return true;
} catch {
return false;
}
}
function validateURL(e, t) {
if (!("normalize" in t) && !("hostname" in t) && !("protocol" in t)) return canParseURL(e) || 2;
return parseURLObject(e, t);
}
/** Parses a URL while preserving the non-normalizing HTTP guard. */
function parseURLObject(e, t) {
if (!t.normalize && t.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(e)) return 1;
try {
if (typeof URL !== "undefined") {
const t = URL;
if (typeof t.parse === "function") return t.parse(e) ?? 2;
}
return new URL(e);
} catch {
return 2;
}
}
const asciiTabOrNewline = /[\t\n\r]/g;
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
function stripTabAndNewline(e) {
return e.replace(asciiTabOrNewline, "");
}
function urlHostnameOk(e, t) {
t.lastIndex = 0;
return t.test(e.hostname);
}
function urlProtocolOk(e, t) {
t.lastIndex = 0;
return t.test(e.protocol.endsWith(":") ? e.protocol.slice(0, -1) : e.protocol);
}
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (e, t) => {
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
try {
const r = n.value.trim();
const i = validateURL(r, t);
if (i === 1) {
n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid URL format",
input: n.value,
inst: e,
continue: !t.abort
});
return;
}
if (i === 2) {
n.issues.push({
code: "invalid_format",
format: "url",
input: n.value,
inst: e,
continue: !t.abort
});
return;
}
if (i === true) {
n.value = stripTabAndNewline(r);
return;
}
if (t.hostname && !urlHostnameOk(i, t.hostname)) n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: t.hostname.source,
input: n.value,
inst: e,
continue: !t.abort
});
if (t.protocol && !urlProtocolOk(i, t.protocol)) n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid protocol",
pattern: t.protocol.source,
input: n.value,
inst: e,
continue: !t.abort
});
n.value = t.normalize ? i.href : stripTabAndNewline(r);
return;
} catch (r) {
n.issues.push({
code: "invalid_format",
format: "url",
input: n.value,
inst: e,
continue: !t.abort
});
}
};
});
const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (e, t) => {
t.pattern ?? (t.pattern = emoji());
$ZodStringFormat.init(e, t);
});
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (e, t) => {
if (t.length !== void 0 && (!Number.isInteger(t.length) || t.length < 1)) throw new Error(`Invalid nanoid length: ${t.length}`);
t.pattern ?? (t.pattern = t.length === void 0 ? nanoid : nanoidOfLength(t.length));
$ZodStringFormat.init(e, t);
});
/**
* @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", (e, t) => {
t.pattern ?? (t.pattern = cuid);
$ZodStringFormat.init(e, t);
});
const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (e, t) => {
t.pattern ?? (t.pattern = cuid2);
$ZodStringFormat.init(e, t);
});
const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (e, t) => {
t.pattern ?? (t.pattern = ulid);
$ZodStringFormat.init(e, t);
});
const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (e, t) => {
t.pattern ?? (t.pattern = xid);
$ZodStringFormat.init(e, t);
});
const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (e, t) => {
t.pattern ?? (t.pattern = ksuid);
$ZodStringFormat.init(e, t);
});
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (e, t) => {
t.pattern ?? (t.pattern = datetime(t));
$ZodStringFormat.init(e, t);
});
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (e, t) => {
t.pattern ?? (t.pattern = date);
$ZodStringFormat.init(e, t);
});
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (e, t) => {
t.pattern ?? (t.pattern = time(t));
$ZodStringFormat.init(e, t);
});
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (e, t) => {
t.pattern ?? (t.pattern = duration);
$ZodStringFormat.init(e, t);
});
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (e, t) => {
t.pattern ?? (t.pattern = ipv4);
$ZodStringFormat.init(e, t);
});
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
function isValidIPv6(e) {
if (!ipv6Alphabet.test(e)) return false;
return canParseURL(`http://[${e}]`);
}
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (e, t) => {
t.pattern ?? (t.pattern = ipv6);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (!isValidIPv6(n.value)) n.issues.push({
code: "invalid_format",
format: "ipv6",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (e, t) => {
t.pattern ?? (t.pattern = cidrv4);
$ZodStringFormat.init(e, t);
});
function isValidCIDRv6(e) {
const t = e.split("/");
if (t.length !== 2) return false;
const [n, r] = t;
if (!r) return false;
const i = Number(r);
if (`${i}` !== r) return false;
if (i < 0 || i > 128) return false;
return isValidIPv6(n);
}
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (e, t) => {
t.pattern ?? (t.pattern = cidrv6);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (!isValidCIDRv6(n.value)) n.issues.push({
code: "invalid_format",
format: "cidrv6",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
function isValidBase64(e) {
if (e === "") return true;
if (/\s/.test(e)) return false;
if (e.length % 4 !== 0) return false;
try {
atob(e);
return true;
} catch {
return false;
}
}
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (e, t) => {
t.pattern ?? (t.pattern = base64Charset);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidBase64(n.value)) return;
n.issues.push({
code: "invalid_format",
format: "base64",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
function isValidBase64URL(e) {
if (!base64urlCharset.test(e)) return false;
const t = e.replace(/[-_]/g, (e) => e === "-" ? "+" : "/");
return isValidBase64(t.padEnd(Math.ceil(t.length / 4) * 4, "="));
}
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (e, t) => {
t.pattern ?? (t.pattern = base64urlCharset);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidBase64URL(n.value)) return;
n.issues.push({
code: "invalid_format",
format: "base64url",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (e, t) => {
t.pattern ?? (t.pattern = e164);
$ZodStringFormat.init(e, t);
});
function isValidJWT(e, t = null) {
try {
const n = e.split(".");
if (n.length !== 3) return false;
const [r] = n;
if (!r) return false;
const i = JSON.parse(atob(r));
if ("typ" in i && i?.typ !== "JWT") return false;
if (!i.alg) return false;
if (t && (!("alg" in i) || i.alg !== t)) return false;
return true;
} catch {
return false;
}
}
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (e, t) => {
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidJWT(n.value, t.alg)) return;
n.issues.push({
code: "invalid_format",
format: "jwt",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = number$1;
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = Number(n.value);
} catch (e) {}
const i = n.value;
if (typeof i === "number" && !Number.isNaN(i) && Number.isFinite(i)) return n;
const a = typeof i === "number" ? Number.isNaN(i) ? "NaN" : !Number.isFinite(i) ? String(i) : void 0 : void 0;
n.issues.push({
expected: "number",
code: "invalid_type",
input: i,
inst: e,
...a ? { received: a } : {}
});
return n;
};
});
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (e, t) => {
$ZodCheckNumberFormat.init(e, t);
$ZodNumber.init(e, t);
});
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = boolean$1;
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = Boolean(n.value);
} catch (e) {}
const i = n.value;
if (typeof i === "boolean") return n;
n.issues.push({
expected: "boolean",
code: "invalid_type",
input: i,
inst: e
});
return n;
};
});
const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = _null$2;
e._zod.values = /* @__PURE__ */ new Set([null]);
e._zod.parse = (t, n) => {
const r = t.value;
if (r === null) return t;
t.issues.push({
expected: "null",
code: "invalid_type",
input: r,
inst: e
});
return t;
};
});
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (e) => e;
});
const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (t, n) => {
t.issues.push({
expected: "never",
code: "invalid_type",
input: t.value,
inst: e
});
return t;
};
});
function capSize(e, t) {
const n = sizeCaps(e._zod.def.checks);
if (!n.length) return;
const r = Math.min(...n.map((e) => e[0]));
const i = e._zod.parse;
e._zod.parse = (n, a) => {
const o = t(n.value);
if (o > r && !a?.skipChecks && a?.direction !== "backward") {
for (const [t, r] of sizeCaps(e._zod.def.checks)) if (o > t && r._zod.def.when(n)) {
const t = n.issues.length;
r._zod.check(n);
n.issues[t].continue = false;
attachSchema(n.issues, t, e);
return n;
}
}
return i(n, a);
};
}
const arraySize = (e) => Array.isArray(e) ? e.length : -1;
function handleArrayResult(e, t, n) {
if (e.issues.length) t.issues.push(...prefixIssues(n, e.issues));
t.value[n] = e.value;
}
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (e, t) => {
$ZodType.init(e, t);
const n = globalConfig.memoizer;
n?.attach(e);
e._zod.parse = (r, i) => {
const a = r.value;
if (!Array.isArray(a)) {
r.issues.push({
expected: "array",
code: "invalid_type",
input: a,
inst: e
});
return r;
}
r.value = n ? n.alloc(e, r, Array(a.length), i) : Array(a.length);
const o = [];
const s = i?.abortEarly;
for (let e = 0; e < a.length; e++) {
const n = a[e];
const c = t.element._zod.run({
value: n,
issues: []
}, i);
if (c instanceof Promise) o.push(c.then((t) => handleArrayResult(t, r, e)));
else {
handleArrayResult(c, r, e);
if (s && c.issues.length !== 0 && aborted(c)) break;
}
}
if (o.length) return Promise.all(o).then(() => r);
return r;
};
capSize(e, arraySize);
});
function handlePropertyResult(e, t, n, r, i, a) {
const o = n in r;
const s = a === "optional";
if (!o && s && i === "optional") return;
if (e.issues.length) {
if (i !== void 0 && s && !o) return;
t.issues.push(...prefixIssues(n, e.issues));
}
if (!o && i === void 0) {
if (!e.issues.length) t.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: void 0,
path: [n]
});
return;
}
if (e.value === void 0) {
if (o || i === "defaulted" && !s) t.value[n] = void 0;
} else t.value[n] = e.value;
}
const NO_SYMBOL_KEYS = [];
function normalizeDef(e) {
const t = Object.keys(e.shape);
const n = Object.getOwnPropertySymbols(e.shape);
const r = n.length ? n : NO_SYMBOL_KEYS;
const i = r.length ? [...t, ...r] : t;
for (const t of i) if (!e.shape?.[t]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(t)}": expected a Zod schema`);
const a = optionalKeys(e.shape);
return {
...e,
allKeys: i,
symbolKeys: r,
keySet: new Set(t),
numKeys: t.length,
optionalKeys: new Set(a)
};
}
function handleCatchall(e, t, n, r, i, a, o) {
const s = [];
const c = i.keySet;
const l = i.catchall._zod;
const u = l.def.type;
const d = l.optin;
const f = l.optout;
let p = 0;
for (const i in t) {
if (o && n.issues.length !== p) {
if (aborted(n, p)) break;
p = n.issues.length;
}
if (c.has(i)) continue;
if (i === "__proto__") {
if (u === "never") s.push(i);
continue;
}
if (u === "never") {
s.push(i);
continue;
}
const a = l.run({
value: t[i],
issues: []
}, r);
if (a instanceof Promise) e.push(a.then((e) => handlePropertyResult(e, n, i, t, d, f)));
else handlePropertyResult(a, n, i, t, d, f);
}
if (s.length) n.issues.push({
code: "unrecognized_keys",
keys: s,
input: t,
inst: a,
continue: true
});
if (!e.length) return n;
return Promise.all(e).then(() => {
return n;
});
}
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (e, t) => {
$ZodType.init(e, t);
const n = Object.getOwnPropertyDescriptor(t, "shape");
const r = n?.get ? n.get.raw : t.shape ?? {};
if (r) {
const get = () => {
const e = { ...r };
Object.defineProperty(t, "shape", { value: e });
get.raw = e;
return e;
};
get.raw = r;
Object.defineProperty(t, "shape", { get });
}
const i = cached(() => normalizeDef(t));
defineLazyInternal(e, "propValues", (e) => {
const t = e.def.shape;
const n = {};
for (const e in t) {
const r = t[e]._zod;
if (r.values) {
if (!Object.prototype.hasOwnProperty.call(n, e)) assignProp(n, e, /* @__PURE__ */ new Set());
for (const t of r.values) n[e].add(t);
if (r.optin !== void 0) n[e].add(void 0);
}
}
return n;
});
const a = isObject;
const o = t.catchall;
let s;
const c = globalConfig.memoizer;
c?.attach(e);
e._zod.parse = (t, n) => {
s ?? (s = i.value);
const r = t.value;
if (!a(r)) {
t.issues.push({
expected: "object",
code: "invalid_type",
input: r,
inst: e
});
return t;
}
t.value = c ? c.alloc(e, t, {}, n) : {};
const l = [];
const u = s.shape;
const d = n?.abortEarly;
let f = t.issues.length;
for (const e of s.allKeys) {
if (d && t.issues.length !== f) {
if (aborted(t, f)) break;
f = t.issues.length;
}
if (e === "__proto__") continue;
const i = u[e];
const a = i._zod.optin;
const o = i._zod.optout;
const s = i._zod.run({
value: r[e],
issues: []
}, n);
if (s instanceof Promise) l.push(s.then((n) => handlePropertyResult(n, t, e, r, a, o)));
else handlePropertyResult(s, t, e, r, a, o);
}
if (!o) return l.length ? Promise.all(l).then(() => t) : t;
return handleCatchall(l, r, t, n, i.value, e, d === true);
};
});
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (e, t) => {
$ZodObject.init(e, t);
const n = e._zod.parse;
const r = cached(() => normalizeDef(t));
const i = globalConfig.memoizer;
const generateFastpass = (t) => {
const n = r.value;
const a = n.symbolKeys;
const o = new Doc(["payload", "ctx"], {
shape: t,
inst: e,
memo: i,
syms: a
});
const parseStr = (e) => `shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`;
const prefixStr = (e, t) => `
let ${e}_ab = false;
for (let i = 0; i < ${e}.issues.length; i++) {
const iss = ${e}.issues[i];
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
payload.issues.push(iss);
if (iss.continue !== true) ${e}_ab = true;
}
if (${e}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
}`;
o.write(`const input = payload.value;`);
const s = Object.create(null);
let c = 0;
for (const e of n.allKeys) s[e] = `key_${c++}`;
o.write(i ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
for (const e of n.allKeys) {
if (e === "__proto__") continue;
const n = s[e];
const r = typeof e === "symbol" ? `syms[${a.indexOf(e)}]` : esc(e);
const i = `${r} in input`;
const c = t[e];
const l = c?._zod?.optin;
const u = l !== void 0;
const d = c?._zod?.optout === "optional";
o.write(`const ${n} = ${parseStr(r)};`);
if (u && d) {
const e = l === "optional" ? `${n}_present` : `${n}.value !== undefined || ${n}_present`;
o.write(`
const ${n}_present = ${i};
if (!${n}.issues.length || ${n}_present) {
if (${n}.issues.length) {${prefixStr(n, r)}
}
if (${e}) {
newResult[${r}] = ${n}.value;
}
}
`);
} else if (!u) o.write(`
const ${n}_present = ${i};
if (${n}.issues.length) {${prefixStr(n, r)}
}
if (!${n}_present && !${n}.issues.length) {
payload.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: undefined,
path: [${r}]
});
if (ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
}
}
if (${n}_present) {
newResult[${r}] = ${n}.value;
}
`);
else {
o.write(`
if (${n}.issues.length) {${prefixStr(n, r)}
}
`);
if (l === "defaulted") o.write(`newResult[${r}] = ${n}.value;`);
else o.write(`
if (${n}.value !== undefined || ${i}) {
newResult[${r}] = ${n}.value;
}
`);
}
}
o.write(`payload.value = newResult;`);
o.write(`return payload;`);
return o.compile();
};
let a;
const o = isObject;
const s = !globalConfig.jitless;
const c = allowsEval;
const l = s && c.value;
const u = t.catchall;
let d;
e._zod.parse = (i, c) => {
d ?? (d = r.value);
const f = i.value;
if (!o(f)) {
i.issues.push({
expected: "object",
code: "invalid_type",
input: f,
inst: e
});
return i;
}
if (s && l && c?.async === false && c.jitless !== true) {
if (!a) a = generateFastpass(t.shape);
i = a(i, c);
if (!u) return i;
return handleCatchall([], f, i, c, d, e, c?.abortEarly === true);
}
return n(i, c);
};
});
function handleUnionResults(e, t, n, r) {
for (const n of e) if (n.issues.length === 0) {
t.value = n.value;
return t;
}
const i = e.filter((e) => !aborted(e));
if (i.length === 1) {
t.value = i[0].value;
return i[0];
}
t.issues.push({
code: "invalid_union",
input: t.value,
inst: n,
errors: e.map((e) => e.issues.map((e) => finalizeIssue(e, r, config())))
});
return t;
}
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.options.some((e) => e._zod.optin === "defaulted") ? "defaulted" : e.def.options.some((e) => e._zod.optin !== void 0) ? "optional" : void 0);
defineLazyInternal(e, "optout", (e) => e.def.options.some((e) => e._zod.optout === "optional") ? "optional" : void 0);
defineLazyInternal(e, "values", (e) => {
if (e.def.options.every((e) => e._zod.values)) return new Set(e.def.options.flatMap((e) => Array.from(e._zod.values)));
});
defineLazyInternal(e, "pattern", (e) => {
if (e.def.options.every((e) => e._zod.pattern)) {
const t = e.def.options.map((e) => e._zod.pattern);
return new RegExp(`^(${t.map((e) => cleanRegex(e.source)).join("|")})$`);
}
});
const n = t.options.length === 1 ? t.options[0]._zod.run : null;
e._zod.parse = (r, i) => {
if (n) return n(r, i);
let a = false;
const o = [];
for (const e of t.options) {
const t = e._zod.run({
value: r.value,
issues: []
}, i);
if (t instanceof Promise) {
o.push(t);
a = true;
} else {
if (t.issues.length === 0) return t;
o.push(t);
}
}
if (!a) return handleUnionResults(o, r, e, i);
return Promise.all(o).then((t) => {
return handleUnionResults(t, r, e, i);
});
};
});
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (e, n) => {
const r = e.value;
const i = t.left._zod.run({
value: r,
issues: []
}, n);
const a = t.right._zod.run({
value: r,
issues: []
}, n);
if (i instanceof Promise || a instanceof Promise) return Promise.all([i, a]).then(([t, n]) => {
return handleIntersectionResults(e, t, n);
});
return handleIntersectionResults(e, i, a);
};
});
function mergeValues(e, t) {
if (e === t) return {
valid: true,
data: e
};
if (e instanceof Date && t instanceof Date && +e === +t) return {
valid: true,
data: e
};
if (isPlainObject(e) && isPlainObject(t)) {
const n = Object.keys(t);
const r = Object.keys(e).filter((e) => n.indexOf(e) !== -1);
const i = {
...e,
...t
};
if (Object.prototype.hasOwnProperty.call(i, "__proto__")) delete i.__proto__;
for (const n of r) {
if (n === "__proto__") continue;
const r = mergeValues(e[n], t[n]);
if (!r.valid) return {
valid: false,
mergeErrorPath: [n, ...r.mergeErrorPath]
};
i[n] = r.data;
}
return {
valid: true,
data: i
};
}
if (Array.isArray(e) && Array.isArray(t)) {
if (e.length !== t.length) return {
valid: false,
mergeErrorPath: []
};
const n = [];
for (let r = 0; r < e.length; r++) {
const i = e[r];
const a = t[r];
const o = mergeValues(i, a);
if (!o.valid) return {
valid: false,
mergeErrorPath: [r, ...o.mergeErrorPath]
};
n.push(o.data);
}
return {
valid: true,
data: n
};
}
return {
valid: false,
mergeErrorPath: []
};
}
function handleIntersectionResults(e, t, n) {
const r = /* @__PURE__ */ new Map();
let i;
const a = /* @__PURE__ */ new Map();
const collect = (e, t) => {
let n;
if (e.code === "unrecognized_keys" && !e.path?.length) {
i ?? (i = e);
n = e.keys;
} else if (e.code === "invalid_key" && e.origin === "record" && e.path?.length === 1) {
const t = String(e.path[0]);
if (!a.has(t)) a.set(t, e);
n = [t];
} else return false;
for (const e of n) {
if (!r.has(e)) r.set(e, {});
r.get(e)[t] = true;
}
return true;
};
for (const n of t.issues) if (!collect(n, "l")) e.issues.push(n);
for (const t of n.issues) if (!collect(t, "r")) e.issues.push(t);
const o = [...r].filter(([, e]) => e.l && e.r).map(([e]) => e);
if (o.length) {
const t = i ? o.filter((e) => i.keys.includes(e)) : [];
if (t.length) e.issues.push({
...i,
keys: t
});
for (const n of o) if (!t.includes(n) && a.has(n)) e.issues.push(a.get(n));
}
const s = mergeValues(t.value, n.value);
if (!s.valid) {
if (aborted(e)) return e;
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);
}
e.value = s.data;
return e;
}
const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (e, t) => {
$ZodType.init(e, t);
const n = globalConfig.memoizer;
n?.attach(e);
e._zod.parse = (r, i) => {
const a = r.value;
if (!isPlainObject(a)) {
r.issues.push({
expected: "record",
code: "invalid_type",
input: a,
inst: e
});
return r;
}
const o = [];
const s = t.keyType._zod.values;
if (s && !t.partial) {
r.value = n ? n.alloc(e, r, {}, i) : {};
const c = /* @__PURE__ */ new Set();
for (const n of s) if (typeof n === "string" || typeof n === "number" || typeof n === "symbol") {
c.add(typeof n === "number" ? n.toString() : n);
if (n === "__proto__") continue;
const s = t.keyType._zod.run({
value: n,
issues: []
}, i);
if (s instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (s.issues.length) {
r.issues.push({
code: "invalid_key",
origin: "record",
issues: s.issues.map((e) => finalizeIssue(e, i, config())),
input: n,
path: [n],
inst: e
});
continue;
}
const l = s.value;
if (l === "__proto__") continue;
const u = t.valueType._zod.run({
value: a[n],
issues: []
}, i);
if (u instanceof Promise) o.push(u.then((e) => {
if (e.issues.length) r.issues.push(...prefixIssues(n, e.issues));
r.value[l] = e.value;
}));
else {
if (u.issues.length) r.issues.push(...prefixIssues(n, u.issues));
r.value[l] = u.value;
}
}
let l;
for (const e in a) if (!c.has(e)) {
if (t.mode === "loose") {
if (e === "__proto__") continue;
r.value[e] = a[e];
} else {
l = l ?? [];
l.push(e);
}
}
if (l && l.length > 0) r.issues.push({
code: "unrecognized_keys",
input: a,
inst: e,
keys: l,
continue: true
});
} else {
r.value = n ? n.alloc(e, r, {}, i) : {};
let c;
for (const n of Reflect.ownKeys(a)) {
if (n === "__proto__") continue;
if (!Object.prototype.propertyIsEnumerable.call(a, n)) continue;
let l = t.keyType._zod.run({
value: n,
issues: []
}, i);
if (l instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (typeof n === "string" && number$1.test(n) && l.issues.length) {
const e = t.keyType._zod.run({
value: Number(n),
issues: []
}, i);
if (e instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (e.issues.length === 0) l = e;
}
if (l.issues.length) {
if (t.mode === "loose") r.value[n] = a[n];
else if (s) {
c = c ?? [];
c.push(n);
} else r.issues.push({
code: "invalid_key",
origin: "record",
issues: l.issues.map((e) => finalizeIssue(e, i, config())),
input: n,
path: [n],
inst: e
});
continue;
}
const u = l.value;
if (u === "__proto__") continue;
const d = t.valueType._zod.run({
value: a[n],
issues: []
}, i);
if (d instanceof Promise) o.push(d.then((e) => {
if (e.issues.length) r.issues.push(...prefixIssues(n, e.issues));
r.value[u] = e.value;
}));
else {
if (d.issues.length) r.issues.push(...prefixIssues(n, d.issues));
r.value[u] = d.value;
}
}
if (c && c.length > 0) r.issues.push({
code: "unrecognized_keys",
input: a,
inst: e,
keys: c,
continue: true
});
}
if (o.length) return Promise.all(o).then(() => r);
return r;
};
});
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (e, t) => {
$ZodType.init(e, t);
const n = getEnumValues(t.entries);
const r = new Set(n);
e._zod.values = r;
defineLazyInternal(e, "pattern", (e) => {
const t = getEnumValues(e.def.entries).filter((e) => propertyKeyTypes.has(typeof e));
return new RegExp(t.length ? `^(${t.map((e) => escapeRegex(e.toString())).join("|")})$` : "^[^\\s\\S]$");
});
e._zod.parse = (t, i) => {
const a = t.value;
if (r.has(a)) return t;
t.issues.push({
code: "invalid_value",
values: n,
input: a,
inst: e
});
return t;
};
});
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (e, t) => {
$ZodType.init(e, t);
const n = new Set(t.values);
e._zod.values = n;
defineLazyInternal(e, "pattern", (e) => {
const t = e.def.values;
return new RegExp(t.length ? `^(${t.map((e) => typeof e === "string" ? escapeRegex(e) : e ? escapeRegex(e.toString()) : String(e)).join("|")})$` : "^[^\\s\\S]$");
});
e._zod.parse = (r, i) => {
const a = r.value;
if (n.has(a)) return r;
r.issues.push({
code: "invalid_value",
values: t.values,
input: a,
inst: e
});
return r;
};
});
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (e, t) => {
$ZodType.init(e, t);
e._zod.optin = "optional";
globalConfig.memoizer?.guard(e);
e._zod.parse = (n, r) => {
if (r.direction === "backward") throw new $ZodEncodeError(e.constructor.name);
const i = t.transform(n.value, n);
if (r.async) return (i instanceof Promise ? i : Promise.resolve(i)).then((e) => {
n.value = e;
return n;
});
if (i instanceof Promise) throw new $ZodAsyncError();
n.value = i;
return n;
};
});
function handleOptionalResult(e, t) {
e.value = t.issues.length ? void 0 : t.value;
return e;
}
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
e._zod.optout = "optional";
defineLazyInternal(e, "values", (e) => {
const t = e.def.innerType._zod.values;
return t ? /* @__PURE__ */ new Set([...t, void 0]) : void 0;
});
defineLazyInternal(e, "pattern", (e) => {
const t = e.def.innerType._zod.pattern;
return t ? new RegExp(`^(${cleanRegex(t.source)})?$`) : void 0;
});
e._zod.parse = (e, n) => {
if (e.value === void 0) {
if (t.innerType._zod.optin !== "defaulted") return e;
const r = t.innerType._zod.run({
value: e.value,
issues: []
}, n);
if (r instanceof Promise) return r.then((t) => handleOptionalResult(e, t));
return handleOptionalResult(e, r);
}
return t.innerType._zod.run(e, n);
};
});
const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (e, t) => {
$ZodOptional.init(e, t);
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
defineLazyInternal(e, "pattern", (e) => e.def.innerType._zod.pattern);
e._zod.parse = (e, n) => {
return t.innerType._zod.run(e, n);
};
});
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin);
defineLazyInternal(e, "optout", (e) => e.def.innerType._zod.optout);
defineLazyInternal(e, "pattern", (e) => {
const t = e.def.innerType._zod.pattern;
return t ? new RegExp(`^(${cleanRegex(t.source)}|null)$`) : void 0;
});
defineLazyInternal(e, "values", (e) => {
return e.def.innerType._zod.values ? /* @__PURE__ */ new Set([...e.def.innerType._zod.values, null]) : void 0;
});
e._zod.parse = (e, n) => {
if (e.value === null) return e;
return t.innerType._zod.run(e, n);
};
});
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (e, t) => {
$ZodType.init(e, t);
e._zod.optin = "defaulted";
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
if (e.value === void 0) {
e.value = t.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 e;
}
const r = t.innerType._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handleDefaultResult(e, t));
return handleDefaultResult(r, t);
};
});
function handleDefaultResult(e, t) {
if (e.value === void 0) e.value = t.defaultValue;
return e;
}
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (e, t) => {
$ZodType.init(e, t);
e._zod.optin = "defaulted";
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
if (e.value === void 0) e.value = t.defaultValue;
return t.innerType._zod.run(e, n);
};
});
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "values", (e) => {
const t = e.def.innerType._zod.values;
return t ? new Set([...t].filter((e) => e !== void 0)) : void 0;
});
e._zod.parse = (n, r) => {
const i = t.innerType._zod.run(n, r);
if (i instanceof Promise) return i.then((t) => handleNonOptionalResult(t, e));
return handleNonOptionalResult(i, e);
};
});
function handleNonOptionalResult(e, t) {
if (!e.issues.length && e.value === void 0) e.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: e.value,
inst: t
});
return e;
}
function handleCatchResult(e, t, n, r) {
if (!t.issues.length) {
e.value = t.value;
if (t.memo) e.memo = true;
return e;
}
e.value = n.catchValue({
...t,
value: e.value,
error: { issues: t.issues.map((e) => finalizeIssue(e, r, config())) },
input: e.value
});
return e;
}
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
defineLazyInternal(e, "optout", (e) => e.def.innerType._zod.optout);
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
const r = t.innerType._zod.run({
value: e.value,
issues: []
}, n);
if (r instanceof Promise) return r.then((r) => handleCatchResult(e, r, t, n));
return handleCatchResult(e, r, t, n);
};
});
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "values", (e) => e.def.in._zod.values);
defineLazyInternal(e, "optin", (e) => e.def.in._zod.optin);
defineLazyInternal(e, "optout", (e) => e.def.out._zod.optout);
defineLazyInternal(e, "propValues", (e) => e.def.in._zod.propValues);
e._zod.parse = (e, n) => {
if (n.direction === "backward") {
const r = t.out._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handlePipeResult(e, t.in, n));
return handlePipeResult(r, t.in, n);
}
const r = t.in._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handlePipeResult(e, t.out, n));
return handlePipeResult(r, t.out, n);
};
});
function handlePipeResult(e, t, n) {
if (e.issues.some((e) => e.code !== "unrecognized_keys")) {
e.aborted = true;
return e;
}
return t._zod.run({
value: e.value,
issues: e.issues
}, n);
}
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "propValues", (e) => e.def.innerType._zod.propValues);
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
defineLazyInternal(e, "optin", (e) => e.def.innerType?._zod?.optin);
defineLazyInternal(e, "optout", (e) => e.def.innerType?._zod?.optout);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
const r = t.innerType._zod.run(e, n);
if (r instanceof Promise) return r.then(handleReadonlyResult);
return handleReadonlyResult(r);
};
});
function handleReadonlyResult(e) {
if (!e.memo) e.value = Object.freeze(e.value);
return e;
}
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (e, t) => {
$ZodCheck.init(e, t);
$ZodType.init(e, t);
e._zod.parse = (e, t) => {
return e;
};
e._zod.check = (n) => {
const r = n.value;
const i = t.fn(r);
if (i instanceof Promise) return i.then((t) => handleRefineResult(t, n, r, e));
handleRefineResult(i, n, r, e);
};
});
function handleRefineResult(e, t, n, r) {
if (!e) {
const e = {
code: "custom",
input: n,
inst: r,
path: [...r._zod.def.path ?? []],
continue: !r._zod.def.abort
};
if (r._zod.def.params) e.params = r._zod.def.params;
t.issues.push(issue(e));
}
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/memoizer.js
var $ZodCyclicError = class extends Error {
constructor() {
super(`Cannot parse a reference cycle that closes through a transform`);
this.name = "ZodCyclicError";
}
};
/** Keyed off the context object every schema in one parse call already shares. */
const STATE = "~memo";
const NO_ISSUES = [];
function isRef(e) {
return e !== null && typeof e === "object";
}
function cloneIssues(e) {
return e.map((e) => e.path ? {
...e,
path: e.path.slice()
} : { ...e });
}
const recursive = /*@__PURE__*/ new WeakMap();
/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
const NONE = 0;
const ASSUMED = 1;
const PROVEN = 2;
/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
function isRecursive(e, t, n) {
const r = recursive.get(e);
if (r !== void 0) return r ? PROVEN : NONE;
if (t.has(e)) return PROVEN;
t.add(e);
let i = NONE;
const check = (e) => {
if (i !== PROVEN && e?._zod) {
const r = isRecursive(e, t, n);
if (r > i) i = r;
}
};
const shape = (e, r) => {
let i = NONE;
for (const a of Reflect.ownKeys(e)) {
const o = Object.getOwnPropertyDescriptor(e, a);
if (r && !o.enumerable) continue;
const s = o.get ? ASSUMED : o.value?._zod ? isRecursive(o.value, t, n) : NONE;
if (s > i) i = s;
}
return i;
};
const merge = (e) => {
if (e > i) i = e;
};
const a = e._zod.def;
switch (a.type) {
case "object": {
const e = rawShape(a);
merge(e ? shape(e, true) : ASSUMED);
check(a.catchall);
break;
}
case "array":
check(a.element);
break;
case "tuple":
for (const e of a.items) check(e);
check(a.rest);
break;
case "record":
case "map":
check(a.keyType);
check(a.valueType);
break;
case "set":
check(a.valueType);
break;
case "union":
for (const e of a.options) check(e);
break;
case "intersection":
check(a.left);
check(a.right);
break;
case "optional":
case "nullable":
case "default":
case "prefault":
case "catch":
case "readonly":
case "nonoptional":
case "promise":
case "success":
check(a.innerType);
break;
case "pipe":
check(a.in);
check(a.out);
break;
case "function":
check(a.input);
check(a.output);
break;
case "lazy": {
const r = a._cachedInner ?? (n ? e._zod.innerType : void 0);
merge(r ? isRecursive(r, t, false) : ASSUMED);
break;
}
case "template_literal":
case "string":
case "number":
case "int":
case "boolean":
case "bigint":
case "symbol":
case "undefined":
case "null":
case "void":
case "never":
case "any":
case "unknown":
case "date":
case "nan":
case "enum":
case "literal":
case "file":
case "transform":
case "custom": break;
default: for (const e in a) {
const t = Object.getOwnPropertyDescriptor(a, e);
if (!t || t.get) continue;
const n = t.value;
if (!n || typeof n !== "object") continue;
if (n._zod) check(n);
else if (Array.isArray(n)) for (const e of n) check(e);
}
}
t.delete(e);
return settle(e, i);
}
/** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
function settle(e, t) {
if (t !== ASSUMED) recursive.set(e, t === PROVEN);
return t;
}
function bucketFor(e, t) {
let n = e.buckets.get(t);
if (!n) {
n = /* @__PURE__ */ new WeakMap();
e.buckets.set(t, n);
}
return n;
}
let handoff;
const open = [];
const memo = {
alloc(e, t, n) {
const r = handoff;
if (!r) return n;
handoff = void 0;
const i = {
value: n,
issues: null
};
r.set(t.value, i);
open.push(i);
return n;
},
guard(e) {
var t;
(t = e._zod).deferred ?? (t.deferred = []);
e._zod.deferred.push(() => {
const t = e._zod.parse;
const wrapped = (e, n) => {
if (n.direction !== "backward" && isBackEdge(n, e.value)) throw new $ZodCyclicError();
return t(e, n);
};
e._zod.parse = wrapped;
if (e._zod.run === t) e._zod.run = wrapped;
});
},
attach(e) {
var t;
let n;
let r = false;
let i;
let a;
(t = e._zod).deferred ?? (t.deferred = []);
e._zod.deferred.push(() => {
const t = e._zod.parse;
const wrapped = (o, s) => {
if (n === void 0) {
const i = isRecursive(e, /* @__PURE__ */ new Set(), false);
if (i === NONE) {
e._zod.parse = t;
if (e._zod.run === wrapped) e._zod.run = t;
return t(o, s);
}
if (i === PROVEN || r) n = true;
else r = true;
}
const c = o.value;
if (!isRef(c)) return t(o, s);
let l = s[STATE];
if (!l) {
l = {
buckets: /* @__PURE__ */ new WeakMap(),
backEdges: void 0
};
s[STATE] = l;
}
let u;
if (i === s) u = a;
else {
u = bucketFor(l, e);
i = s;
a = u;
}
const d = u.get(c);
if (d) {
o.value = d.value;
if (d.issues) {
if (d.issues.length) o.issues.push(...cloneIssues(d.issues));
} else {
o.memo = true;
l.backEdges ?? (l.backEdges = /* @__PURE__ */ new WeakSet());
l.backEdges.add(d.value);
}
return o;
}
handoff = u;
const f = open.length;
const p = t(o, s);
handoff = void 0;
const m = open.length > f ? open.pop() : void 0;
if (p instanceof Promise) return p.then((e) => {
if (m) m.issues = e.issues.length ? cloneIssues(e.issues) : NO_ISSUES;
return e;
});
if (m) m.issues = p.issues.length ? cloneIssues(p.issues) : NO_ISSUES;
return p;
};
e._zod.parse = wrapped;
if (e._zod.run === t) e._zod.run = wrapped;
});
}
};
/** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
function memoizer() {
return memo;
}
/** Whether this value is a node a back-edge resolved to before it finished. */
function isBackEdge(e, t) {
const n = e[STATE]?.backEdges;
return n !== void 0 && isRef(t) && n.has(t);
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/en.js
const error = () => {
const e = {
string: {
unit: "characters",
verb: "to have"
},
file: {
unit: "bytes",
verb: "to have"
},
array: {
unit: "items",
verb: "to have"
},
set: {
unit: "items",
verb: "to have"
},
map: {
unit: "entries",
verb: "to have"
}
};
function getSizing(t) {
return e[t] ?? null;
}
const t = {
regex: "input",
email: "email address",
url: "URL",
emoji: "emoji",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "ISO datetime",
date: "ISO date",
time: "ISO time",
duration: "ISO duration",
ipv4: "IPv4 address",
ipv6: "IPv6 address",
mac: "MAC address",
cidrv4: "IPv4 range",
cidrv6: "IPv6 range",
base64: "base64-encoded string",
base64url: "base64url-encoded string",
json_string: "JSON string",
e164: "E.164 number",
currency_code: "currency code",
credit_card: "credit card number",
iban: "IBAN",
jwt: "JWT",
template_literal: "input"
};
const n = { nan: "NaN" };
function getTypeName(e, t) {
if (e === "number" && typeof t === "number" && !Number.isFinite(t)) return String(t);
return n[e] ?? e;
}
return (e) => {
switch (e.code) {
case "invalid_type": return `Invalid input: expected ${getTypeName(e.expected)}, received ${getTypeName(parsedType(e.input), e.input)}`;
case "invalid_value":
if (e.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(e.values[0])}`;
return `Invalid option: expected one of ${joinValues(e.values, "|")}`;
case "too_big": {
const t = e.exact ? "exactly " : e.inclusive ? "<=" : "<";
const n = getSizing(e.origin);
if (n) return `Too big: expected ${e.origin ?? "value"} to have ${t}${e.maximum.toString()} ${n.unit ?? "elements"}`;
return `Too big: expected ${e.origin ?? "value"} to be ${t}${e.maximum.toString()}`;
}
case "too_small": {
const t = e.exact ? "exactly " : e.inclusive ? ">=" : ">";
const n = getSizing(e.origin);
if (n) return `Too small: expected ${e.origin} to have ${t}${e.minimum.toString()} ${n.unit}`;
return `Too small: expected ${e.origin} to be ${t}${e.minimum.toString()}`;
}
case "invalid_format": {
const n = e;
if (n.format === "starts_with") return `Invalid string: must start with "${n.prefix}"`;
if (n.format === "ends_with") return `Invalid string: must end with "${n.suffix}"`;
if (n.format === "includes") return `Invalid string: must include "${n.includes}"`;
if (n.format === "regex") return `Invalid string: must match pattern ${n.pattern}`;
return `Invalid ${t[n.format] ?? e.format}`;
}
case "not_multiple_of": return `Invalid number: must be a multiple of ${e.divisor}`;
case "unrecognized_keys": return `Unrecognized key${e.keys.length > 1 ? "s" : ""}: ${joinValues(e.keys, ", ")}`;
case "invalid_key": return `Invalid key in ${e.origin}`;
case "invalid_union":
if (e.options && Array.isArray(e.options) && e.options.length > 0) return `Invalid discriminator value. Expected ${e.options.map((e) => `'${e}'`).join(" | ")}`;
if (e.inclusive === false) return "Invalid input: more than one option matched";
return "Invalid input";
case "invalid_element": return `Invalid value in ${e.origin}`;
default: return `Invalid input`;
}
};
};
function en_default() {
return { localeError: error() };
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/registries.js
var _a;
var $ZodRegistry = class {
constructor() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
}
add(e, ...t) {
const n = t[0];
this._map.set(e, n);
if (n && typeof n === "object" && "id" in n) this._idmap.set(n.id, e);
return this;
}
clear() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
return this;
}
remove(e) {
const t = this._map.get(e);
if (t && typeof t === "object" && "id" in t) this._idmap.delete(t.id);
this._map.delete(e);
return this;
}
get(e) {
const t = e._zod.parent;
if (t) {
const n = { ...this.get(t) ?? {} };
delete n.id;
const r = {
...n,
...this._map.get(e)
};
return Object.keys(r).length ? r : void 0;
}
return this._map.get(e);
}
has(e) {
return this._map.has(e);
}
};
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.6.7/node_modules/zod/v4/core/api.js
function snapshotChecks(e) {
if (e.checks) e.checks = [...e.checks];
return e;
}
// @__NO_SIDE_EFFECTS__
function _string(e, t) {
return new e(snapshotChecks({
type: "string",
...normalizeParams(t)
}));
}
// @__NO_SIDE_EFFECTS__
function _email(e, t) {
return new e({
type: "string",
format: "email",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _guid(e, t) {
return new e({
type: "string",
format: "guid",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _uuid(e, t) {
return new e({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _uuidv4(e, t) {
return new e({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
version: "v4",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _uuidv6(e, t) {
return new e({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
version: "v6",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _uuidv7(e, t) {
return new e({
type: "string",
format: "uuid",
check: "string_format",
abort: false,
version: "v7",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _url(e, t) {
return new e({
type: "string",
format: "url",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _emoji(e, t) {
return new e({
type: "string",
format: "emoji",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _nanoid(e, t) {
return new e({
type: "string",
format: "nanoid",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
/**
* @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(e, t) {
return new e({
type: "string",
format: "cuid",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _cuid2(e, t) {
return new e({
type: "string",
format: "cuid2",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _ulid(e, t) {
return new e({
type: "string",
format: "ulid",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _xid(e, t) {
return new e({
type: "string",
format: "xid",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _ksuid(e, t) {
return new e({
type: "string",
format: "ksuid",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _ipv4(e, t) {
return new e({
type: "string",
format: "ipv4",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _ipv6(e, t) {
return new e({
type: "string",
format: "ipv6",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _cidrv4(e, t) {
return new e({
type: "string",
format: "cidrv4",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _cidrv6(e, t) {
return new e({
type: "string",
format: "cidrv6",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _base64(e, t) {
return new e({
type: "string",
format: "base64",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _base64url(e, t) {
return new e({
type: "string",
format: "base64url",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _e164(e, t) {
return new e({
type: "string",
format: "e164",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _jwt(e, t) {
return new e({
type: "string",
format: "jwt",
check: "string_format",
abort: false,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _isoDateTime(e, t) {
return new e({
type: "string",
format: "datetime",
check: "string_format",
offset: false,
local: false,
precision: null,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _isoDate(e, t) {
return new e({
type: "string",
format: "date",
check: "string_format",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _isoTime(e, t) {
return new e({
type: "string",
format: "time",
check: "string_format",
precision: null,
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _isoDuration(e, t) {
return new e({
type: "string",
format: "duration",
check: "string_format",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _number(e, t) {
return new e(snapshotChecks({
type: "number",
checks: [],
...normalizeParams(t)
}));
}
// @__NO_SIDE_EFFECTS__
function _int(e, t) {
return new e({
type: "number",
check: "number_format",
abort: false,
format: "safeint",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _boolean(e, t) {
return new e({
type: "boolean",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _null$1(e, t) {
return new e({
type: "null",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _unknown(e) {
return new e({ type: "unknown" });
}
// @__NO_SIDE_EFFECTS__
function _never(e, t) {
return new e({
type: "never",
...normalizeParams(t)
});
}
// @__NO_SIDE_EFFECTS__
function _lt(e, t) {
return new $ZodCheckLessThan({
check: "less_than",
...normalizeParams(t),
value: e,
inclusive: false
});
}
// @__NO_SIDE_EFFECTS__
function _lte(e, t) {
return new $ZodCheckLessThan({
check: "less_than",
...normalizeParams(t),
value: e,
inclusive: true
});
}
// @__NO_SIDE_EFFECTS__
function _gt(e, t) {
return new $ZodCheckGreaterThan({
check: "greater_than",
...normalizeParams(t),
value: e,
inclusive: false
});
}
// @__NO_SIDE_EFFECTS__
function _gte(e, t) {
return new $ZodCheckGreaterThan({
check: "greater_than",
...normalizeParams(t),
value: e,
inclusive: true
});
}
// @__NO_SIDE_EFFECTS__
function _multipleOf(e, t) {
return new $ZodCheckMultipleOf({
check: "multiple_of",
...normalizeParams(t),
value: e
});
}
// @__NO_SIDE_EFFECTS__
function _maxLength(e, t) {
return new $ZodCheckMaxLength({
check: "max_length",
...normalizeParams(t),
maximum: e
});
}
// @__NO_SIDE_EFFECTS__
function _minLength(e, t) {
return new $ZodCheckMinLength({
check: "min_length",
...normalizeParams(t),
minimum: e
});
}
// @__NO_SIDE_EFFECTS__
function _length(e, t) {
return new $ZodCheckLengthEquals({
check: "length_equals",
...normalizeParams(t),
length: e
});
}
// @__NO_SIDE_EFFECTS__
function _regex(e, t) {
return new $ZodCheckRegex({
check: "string_format",
format: "regex",
...normalizeParams(t),
pattern: e
});
}
// @__NO_SIDE_EFFECTS__
function _lowercase(e) {
return new $ZodCheckLowerCase({
check: "string_format",
format: "lowercase",
...normalizeParams(e)
});
}
// @__NO_SIDE_EFFECTS__
function _uppercase(e) {
return new $ZodCheckUpperCase({
check: "string_format",
format: "uppercase",
...normalizeParams(e)
});
}
// @__NO_SIDE_EFFECTS__
function _includes(e, t) {
return new $ZodCheckIncludes({
check: "string_format",
format: "includes",
...normalizeParams(t),
includes: e
});
}
// @__NO_SIDE_EFFECTS__
function _startsWith(e, t) {
return new $ZodCheckStartsWith({
check: "string_format",
format: "starts_with",
...normalizeParams(t),
prefix: e
});
}
// @__NO_SIDE_EFFECTS__
function _endsWith(e, t) {
return new $ZodCheckEndsWith({
check: "string_format",
format: "ends_with",
...normalizeParams(t),
suffix: e
});
}
// @__NO_SIDE_EFFECTS__
function _overwrite(e) {
return new $ZodCheckOverwrite({
check: "overwrite",
tx: e
});
}
// @__NO_SIDE_EFFECTS__
function _normalize(e) {
return /* @__PURE__ */ _overwrite((t) => t.normalize(e));
}
// @__NO_SIDE_EFFECTS__
function _trim() {
return /* @__PURE__ */ _overwrite((e) => e.trim());
}
// @__NO_SIDE_EFFECTS__
function _toLowerCase() {
return /* @__PURE__ */ _overwrite((e) => e.toLowerCase());
}
// @__NO_SIDE_EFFECTS__
function _toUpperCase() {
return /* @__PURE__ */ _overwrite((e) => e.toUpperCase());
}
// @__NO_SIDE_EFFECTS__
function _slugify() {
return /* @__PURE__ */ _overwrite((e) => slugify(e));
}
// @__NO_SIDE_EFFECTS__
function _array(e, t, n) {
return new e({
type: "array",
element: t,
...normalizeParams(n)
});
}
// @__NO_SIDE_EFFECTS__
function _refine(e, t, n) {
return new e({
type: "custom",
check: "custom",
fn: t,
...normalizeParams(n)
});
}
// @__NO_SIDE_EFFECTS__
function _superRefine(e, t) {
const n = /* @__PURE__ */ _check((t) => {
t.addIssue = (e) => {
if (typeof e === "string") t.issues.push(issue(e, t.value, n._zod.def));
else {
const r = e;
if (r.fatal) r.continue = false;
r.code ?? (r.code = "custom");
if (!("input" in r)) r.input = t.value;
r.inst ?? (r.inst = n);
r.continue ?? (r.continue = !n._zod.def.abort);
t.issues.push(issue(r));
}
};
return e(t.value, t);
}, t);
return n;
}
// @__NO_SIDE_EFFECTS__
function _check(e, t) {
const n = new $ZodCheck({
check: "custom",
...normalizeParams(t)
});
n._zod.check = e;
return n;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/to-json-schema.js
function assignProps(e, ...t) {
for (const n of t) for (const t of Reflect.ownKeys(n)) if (Object.prototype.propertyIsEnumerable.call(n, t)) assignProp(e, t, n[t]);
return e;
}
function initializeContext(e) {
let t = e?.target ?? "draft-2020-12";
if (t === "draft-4") t = "draft-04";
if (t === "draft-7") t = "draft-07";
return {
processors: e.processors ?? {},
metadataRegistry: e?.metadata ?? globalRegistry,
target: t,
unrepresentable: e?.unrepresentable ?? "throw",
override: e?.override ?? (() => {}),
io: e?.io ?? "output",
counter: 0,
seen: /* @__PURE__ */ new Map(),
sharedDefsExtractedFor: void 0,
sharedEmitDoneFor: void 0,
cycles: e?.cycles ?? "ref",
reused: e?.reused ?? "inline",
intersections: [],
deferred: [],
external: e?.external ?? void 0
};
}
/**
* Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
* `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
* custom JSON Schema was written into `json`, in which case the caller must not write its own.
*/
function handleUnrepresentable(e, t, n, r, i) {
const a = typeof t.unrepresentable === "function" ? t.unrepresentable({
zodSchema: e,
path: r.path,
message: i
}) : t.unrepresentable;
if (a === "any") return false;
if (a === void 0 || a === "throw") throw new Error(i);
Object.assign(n, a);
return true;
}
function processSchema(e, t, n = {
path: [],
schemaPath: []
}) {
var r;
const i = e._zod.def;
const a = t.seen.get(e);
if (a) {
a.count++;
if (n.schemaPath.includes(e)) a.cycle = n.path;
return a.schema;
}
const o = {
schema: {},
count: 1,
cycle: void 0,
path: n.path
};
t.seen.set(e, o);
t.sharedDefsExtractedFor = void 0;
t.sharedEmitDoneFor = void 0;
const s = e._zod.toJSONSchema?.();
if (s) o.schema = s;
else {
const r = {
...n,
schemaPath: [...n.schemaPath, e],
path: n.path
};
if (e._zod.processJSONSchema) e._zod.processJSONSchema(t, o.schema, r);
else {
const n = o.schema;
const a = t.processors[i.type];
if (!a) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);
a(e, t, n, r);
}
const a = e._zod.parent;
if (a) {
if (!o.ref) o.ref = a;
processSchema(a, t, r);
t.seen.get(a).isParent = true;
}
}
const c = t.metadataRegistry.get(e);
if (c) assignProps(o.schema, c);
if (t.io === "input" && isTransforming(e)) {
delete o.schema.examples;
delete o.schema.default;
}
if (t.io === "input" && "_prefault" in o.schema) (r = o.schema).default ?? (r.default = o.schema._prefault);
delete o.schema._prefault;
return t.seen.get(e).schema;
}
function encodeJSONPointerSegment(e) {
return e.replace(/~/g, "~0").replace(/\//g, "~1");
}
function extractDefs(e, t) {
const n = e.seen.get(t);
if (!n) throw new Error("Unprocessed schema. This is a bug in Zod.");
if (e.external && e.sharedDefsExtractedFor === e.external) return;
const r = /* @__PURE__ */ new Map();
for (const t of e.seen.entries()) {
const n = e.metadataRegistry.get(t[0])?.id;
if (n) {
const e = r.get(n);
if (e && e !== t[0]) throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
r.set(n, t[0]);
}
}
const makeURI = (t) => {
const r = e.target === "draft-2020-12" ? "$defs" : "definitions";
if (e.external) {
const n = e.external.registry.get(t[0])?.id;
const i = e.external.uri ?? ((e) => e);
if (n) return { ref: i(n) };
const a = t[1].defId ?? t[1].schema.id ?? `schema${e.counter++}`;
t[1].defId = a;
return {
defId: a,
ref: `${i("__shared")}#/${r}/${encodeJSONPointerSegment(a)}`
};
}
const i = `#`;
const a = `${i}/${r}/`;
if (t[1] === n && !t[1].schema.id) return { ref: i };
const o = t[1].schema.id ?? `__schema${e.counter++}`;
return {
defId: o,
ref: a + encodeJSONPointerSegment(o)
};
};
const extractToDef = (e) => {
if (e[1].schema.$ref) return;
const t = e[1];
const { ref: n, defId: r } = makeURI(e);
t.def = { ...t.schema };
if (r) t.defId = r;
const i = t.schema;
for (const e in i) delete i[e];
i.$ref = n;
};
if (e.cycles === "throw") for (const t of e.seen.entries()) {
const e = t[1];
if (e.cycle) throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
}
for (const n of e.seen.entries()) {
const r = n[1];
if (t === n[0]) {
extractToDef(n);
continue;
}
if (e.external) {
const r = e.external.registry.get(n[0])?.id;
if (t !== n[0] && r) {
extractToDef(n);
continue;
}
}
if (e.metadataRegistry.get(n[0])?.id) {
extractToDef(n);
continue;
}
if (r.cycle) {
extractToDef(n);
continue;
}
if (r.count > 1) {
if (e.reused === "ref") extractToDef(n);
}
}
if (e.external) e.sharedDefsExtractedFor = e.external;
}
/** Rewrites `anyOf: [{type: "a"}, {type: "b"}]` to `type: ["a", "b"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so "exactly one" and "at least one" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */
function compactTypeUnion(e) {
const t = e.anyOf;
if (!Array.isArray(t) || t.length === 0 || e.type !== void 0) return;
const n = [];
for (const e of t) {
if (!e || typeof e !== "object") return;
compactTypeUnion(e);
const t = Object.keys(e);
if (t.length !== 1 || t[0] !== "type") return;
const r = e.type;
for (const e of Array.isArray(r) ? r : [r]) {
if (typeof e !== "string") return;
if (!n.includes(e)) n.push(e);
}
}
delete e.anyOf;
e.type = n.length === 1 ? n[0] : n;
}
/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
* an annotation like `description` — makes a member unfoldable, so a constraint this does not
* understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
const FOLDABLE_KEYS = /* @__PURE__ */ new Set([
"type",
"properties",
"required",
"additionalProperties"
]);
const UNION_KEYS = ["oneOf", "anyOf"];
/** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */
function undeclaredConstraint(e) {
const t = e.additionalProperties;
if (t === void 0 || t === false || typeof t !== "object" || t === null) return null;
return Object.keys(t).length ? t : null;
}
/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
function foldObjects(e) {
const t = [];
for (const n of e) {
if (typeof n !== "object" || n.type !== "object") return null;
for (const e in n) if (!FOLDABLE_KEYS.has(e)) return null;
t.push(n);
}
const n = {};
const r = /* @__PURE__ */ new Set();
for (const e of t) {
for (const r in e.properties) {
if (Object.prototype.hasOwnProperty.call(n, r)) continue;
const e = [];
for (const n of t) {
const t = n.properties?.[r] ?? undeclaredConstraint(n);
if (t === null || t === void 0) continue;
if (!e.some((e) => JSON.stringify(e) === JSON.stringify(t))) e.push(t);
}
const i = e.length === 1 ? e[0] : foldObjects(e) ?? { allOf: e };
assignProp(n, r, i);
}
for (const t of e.required ?? []) r.add(t);
}
const i = {
type: "object",
properties: n
};
if (r.size) i.required = [...r];
if (t.every((e) => e.additionalProperties === false)) i.additionalProperties = false;
else {
const e = [];
for (const n of t) {
const t = undeclaredConstraint(n);
if (t && !e.some((e) => JSON.stringify(e) === JSON.stringify(t))) e.push(t);
}
if (e.length === 1) i.additionalProperties = e[0];
else if (e.length > 1) i.additionalProperties = { allOf: e };
}
return i;
}
/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
* closed object members reject each other's keys and the schema validates nothing. Zod's parser
* pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
* *every* side rejects it — so the emitted schema has to pool them too, and folding the members
* into one object is the encoding that says so on every target.
*
* This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
* machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
* keeps its reference and its own closedness rather than being inlined as a stale copy. */
function foldIntersection(e) {
const t = e.allOf;
if (!Array.isArray(t) || t.length < 2) return;
for (const t of FOLDABLE_KEYS) if (t in e) return;
const n = t.filter((e) => UNION_KEYS.some((t) => Array.isArray(e[t])));
let r = null;
if (!n.length) r = foldObjects(t);
else {
const e = n[0];
const i = UNION_KEYS.find((t) => Array.isArray(e[t]));
if (Object.keys(e).length !== 1) return;
const a = t.filter((t) => t !== e);
const o = e[i].map((e) => foldObjects([...a, e]));
if (o.some((e) => !e)) return;
r = { [i]: o };
}
if (!r) return;
delete e.allOf;
assignProps(e, r);
}
function finalize(e, t) {
const n = e.seen.get(t);
if (!n) throw new Error("Unprocessed schema. This is a bug in Zod.");
const flattenRef = (t) => {
const n = e.seen.get(t);
if (n.ref === null) return;
const r = n.def ?? n.schema;
const i = { ...r };
const a = n.ref;
n.ref = null;
if (a) {
flattenRef(a);
const n = e.seen.get(a);
const o = n.schema;
if (o.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0")) {
r.allOf = r.allOf ?? [];
r.allOf.push(o);
} else assignProps(r, o);
assignProps(r, i);
if (t._zod.parent === a) for (const e in r) {
if (e === "$ref" || e === "allOf") continue;
if (!(e in i)) delete r[e];
}
if (o.$ref && n.def) for (const e in r) {
if (e === "$ref" || e === "allOf") continue;
if (e in n.def && JSON.stringify(r[e]) === JSON.stringify(n.def[e])) delete r[e];
}
}
const o = t._zod.parent;
if (o && o !== a) {
flattenRef(o);
const t = e.seen.get(o);
if (t?.schema.$ref) {
r.$ref = t.schema.$ref;
if (t.def) for (const e in r) {
if (e === "$ref" || e === "allOf") continue;
if (e in t.def && JSON.stringify(r[e]) === JSON.stringify(t.def[e])) delete r[e];
}
}
}
e.override({
zodSchema: t,
jsonSchema: r,
path: n.path ?? []
});
};
if (!e.external || e.sharedEmitDoneFor !== e.external) {
for (const t of [...e.seen.entries()].reverse()) flattenRef(t[0]);
if (e.target !== "openapi-3.0") for (const t of e.seen.entries()) compactTypeUnion(t[1].def ?? t[1].schema);
for (const t of e.deferred) t();
if (e.intersections.length) {
const t = /* @__PURE__ */ new Map();
for (const n of e.seen.values()) for (const e of [n.schema, n.def]) {
const n = e?.allOf;
if (!Array.isArray(n)) continue;
const r = t.get(n);
if (r) r.push(e);
else t.set(n, [e]);
}
for (const n of e.intersections) for (const e of t.get(n) ?? []) foldIntersection(e);
}
}
const r = {};
if (e.target === "draft-2020-12") r.$schema = "https://json-schema.org/draft/2020-12/schema";
else if (e.target === "draft-07") r.$schema = "http://json-schema.org/draft-07/schema#";
else if (e.target === "draft-04") r.$schema = "http://json-schema.org/draft-04/schema#";
else if (e.target === "openapi-3.0") {}
if (e.external?.uri) {
const n = e.external.registry.get(t)?.id;
if (!n) throw new Error("Schema is missing an `id` property");
r.$id = e.external.uri(n);
}
assignProps(r, n.defId ? n.schema : n.def ?? n.schema);
const i = e.metadataRegistry.get(t)?.id;
if (i !== void 0 && r.id === i) delete r.id;
const a = e.external?.defs ?? {};
if (!e.external || e.sharedEmitDoneFor !== e.external) for (const t of e.seen.entries()) {
const e = t[1];
if (e.def && e.defId) {
if (e.def.id === e.defId) delete e.def.id;
assignProp(a, e.defId, e.def);
}
}
if (e.external) e.sharedEmitDoneFor = e.external;
if (e.external) {} else if (Object.keys(a).length > 0) {
if (e.target === "draft-2020-12") r.$defs = a;
else r.definitions = a;
}
try {
const n = JSON.parse(JSON.stringify(r));
Object.defineProperty(n, "~standard", {
value: {
...t["~standard"],
jsonSchema: {
input: createStandardJSONSchemaMethod(t, "input", e.processors),
output: createStandardJSONSchemaMethod(t, "output", e.processors)
}
},
enumerable: false,
writable: false
});
return n;
} catch (e) {
throw new Error("Error converting schema to JSON.");
}
}
function isTransforming(e, t) {
const n = t ?? { seen: /* @__PURE__ */ new Set() };
if (n.seen.has(e)) return false;
n.seen.add(e);
const r = e._zod.def;
if (r.type === "transform") return true;
if (r.type === "array") return isTransforming(r.element, n);
if (r.type === "set") return isTransforming(r.valueType, n);
if (r.type === "lazy") return isTransforming(r.getter(), n);
if (r.type === "promise" || r.type === "optional" || r.type === "nonoptional" || r.type === "nullable" || r.type === "readonly" || r.type === "default" || r.type === "prefault" || r.type === "catch") return isTransforming(r.innerType, n);
if (r.type === "intersection") return isTransforming(r.left, n) || isTransforming(r.right, n);
if (r.type === "record" || r.type === "map") return isTransforming(r.keyType, n) || isTransforming(r.valueType, n);
if (r.type === "pipe") {
if (e._zod.traits.has("$ZodCodec")) return true;
return isTransforming(r.in, n) || isTransforming(r.out, n);
}
if (r.type === "object") {
for (const e in r.shape) if (isTransforming(r.shape[e], n)) return true;
return false;
}
if (r.type === "union") {
for (const e of r.options) if (isTransforming(e, n)) return true;
return false;
}
if (r.type === "tuple") {
for (const e of r.items) if (isTransforming(e, n)) return true;
if (r.rest && isTransforming(r.rest, n)) 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 = (e, t = {}) => (n) => {
const r = initializeContext({
...n,
processors: t
});
processSchema(e, r);
extractDefs(r, e);
return finalize(r, e);
};
const createStandardJSONSchemaMethod = (e, t, n = {}) => (r) => {
const { libraryOptions: i, target: a } = r ?? {};
const o = initializeContext({
...i ?? {},
target: a,
io: t,
processors: n
});
processSchema(e, o);
extractDefs(o, e);
return finalize(o, e);
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/json-schema-processors.js
const narrowMin = (e, t, n) => {
if (e[t] === void 0 || n > e[t]) e[t] = n;
};
const narrowMax = (e, t, n) => {
if (e[t] === void 0 || n < e[t]) e[t] = n;
};
const narrowBoth = (e, t) => {
narrowMin(e, "minimum", t);
narrowMax(e, "maximum", t);
};
const addDivisor = (e, t) => {
e.multipleOf ?? (e.multipleOf = []);
if (!e.multipleOf.includes(t)) e.multipleOf.push(t);
};
const addPattern = (e, t) => {
e.patterns ?? (e.patterns = /* @__PURE__ */ new Set());
e.patterns.add(t);
};
const intersectMime = (e, t) => {
e.mime = e.mime ? e.mime.filter((e) => t.includes(e)) : [...t];
};
const setFormat = (e, t) => {
e.format = t;
if (t.includes("int")) e.isInt = true;
};
const minContributor = (e, t) => narrowMin(e, "minimum", t.minimum);
const maxContributor = (e, t) => narrowMax(e, "maximum", t.maximum);
const formatContributor = (e) => (t, n) => {
setFormat(t, n.format);
const [r, i] = e[n.format];
narrowMin(t, "minimum", r);
narrowMax(t, "maximum", i);
};
const contributors = {
greater_than: (e, t) => narrowMin(e, t.inclusive ? "minimum" : "exclusiveMinimum", t.value),
less_than: (e, t) => narrowMax(e, t.inclusive ? "maximum" : "exclusiveMaximum", t.value),
multiple_of: (e, t) => addDivisor(e, t.value),
number_format: formatContributor(NUMBER_FORMAT_RANGES),
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
min_length: minContributor,
max_length: maxContributor,
length_equals: (e, t) => narrowBoth(e, t.length),
min_size: minContributor,
max_size: maxContributor,
size_equals: (e, t) => narrowBoth(e, t.size),
string_format: (e, t) => {
setFormat(e, t.format);
if (t.pattern) addPattern(e, t.pattern);
if (t.format === "base64" || t.format === "base64url") e.contentEncoding = t.format;
if (t.local || t.precision === -1) e.laxFormat = true;
},
mime_type: (e, t) => intersectMime(e, t.mime)
};
function aggregateChecks(e) {
const t = {};
const n = e._zod.def;
const r = e._zod.traits.has("$ZodCheck") ? [e, ...n.checks ?? []] : n.checks ?? [];
for (const e of r) contributors[e._zod.def.check]?.(t, e._zod.def);
const i = e._zod.bag;
if (i.minimum !== void 0) narrowMin(t, "minimum", i.minimum);
if (i.exclusiveMinimum !== void 0) narrowMin(t, "exclusiveMinimum", i.exclusiveMinimum);
if (i.maximum !== void 0) narrowMax(t, "maximum", i.maximum);
if (i.exclusiveMaximum !== void 0) narrowMax(t, "exclusiveMaximum", i.exclusiveMaximum);
if (i.multipleOf !== void 0) addDivisor(t, i.multipleOf);
if (i.format !== void 0) {
t.format ?? (t.format = i.format);
if (i.format.includes("int")) t.isInt = true;
}
if (i.mime) intersectMime(t, i.mime);
for (const e of i.patterns ?? []) addPattern(t, e);
return t;
}
const formatMap = {
guid: "uuid",
url: "uri",
datetime: "date-time",
json_string: "json-string",
regex: ""
};
const exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
const exactPattern = (e) => exactPatterns.get(e) ?? e;
const stringProcessor = (e, t, n, r) => {
const i = n;
i.type = "string";
const { minimum: a, maximum: o, format: s, patterns: c, contentEncoding: l, laxFormat: u } = aggregateChecks(e);
if (typeof a === "number") i.minLength = a;
if (typeof o === "number") i.maxLength = o;
if (s) {
i.format = formatMap[s] ?? s;
if (i.format === "") delete i.format;
if (s === "time" || u) delete i.format;
}
if (l) i.contentEncoding = l;
if (c && c.size > 0) {
const e = [...c].map(exactPattern);
if (e.length === 1) i.pattern = e[0].source;
else if (e.length > 1) i.allOf = [...e.map((e) => ({
...t.target === "draft-07" || t.target === "draft-04" || t.target === "openapi-3.0" ? { type: "string" } : {},
pattern: e.source
}))];
}
};
const numberProcessor = (e, t, n, r) => {
const i = n;
const { minimum: a, maximum: o, multipleOf: s, exclusiveMaximum: c, exclusiveMinimum: l, isInt: u } = aggregateChecks(e);
i.type = u ? "integer" : "number";
const d = typeof l === "number" && l >= (a ?? Number.NEGATIVE_INFINITY);
const f = typeof c === "number" && c <= (o ?? Number.POSITIVE_INFINITY);
const p = t.target === "draft-04" || t.target === "openapi-3.0";
if (d) {
if (p) {
i.minimum = l;
i.exclusiveMinimum = true;
} else i.exclusiveMinimum = l;
} else if (typeof a === "number") i.minimum = a;
if (f) {
if (p) {
i.maximum = c;
i.exclusiveMaximum = true;
} else i.exclusiveMaximum = c;
} else if (typeof o === "number") i.maximum = o;
if (s) {
const n = /* @__PURE__ */ new Set();
for (const a of s) if (Number.isFinite(a) && a !== 0) n.add(Math.abs(a));
else handleUnrepresentable(e, t, i, r, `A multipleOf divisor of ${a} cannot be represented in JSON Schema`);
const [a, ...o] = n;
if (a !== void 0) i.multipleOf = a;
if (o.length) i.allOf = [...i.allOf ?? [], ...o.map((e) => ({ multipleOf: e }))];
}
};
const booleanProcessor = (e, t, n, r) => {
n.type = "boolean";
};
const nullProcessor = (e, t, n, r) => {
if (t.target === "openapi-3.0") {
n.type = "string";
n.nullable = true;
n.enum = [null];
} else n.type = "null";
};
const neverProcessor = (e, t, n, r) => {
n.not = {};
};
const unknownProcessor = (e, t, n, r) => {};
const enumProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = getEnumValues(i.entries);
if (a.length === 0) {
n.not = {};
return;
}
if (a.every((e) => typeof e === "number")) n.type = "number";
if (a.every((e) => typeof e === "string")) n.type = "string";
n.enum = a;
};
const literalProcessor = (e, t, n, r) => {
const i = e._zod.def;
if (i.values.length === 0) {
n.not = {};
return;
}
const a = [];
for (const o of i.values) if (o === void 0) {
if (handleUnrepresentable(e, t, n, r, "Literal `undefined` cannot be represented in JSON Schema")) return;
} else if (typeof o === "bigint") {
if (handleUnrepresentable(e, t, n, r, "BigInt literals cannot be represented in JSON Schema")) return;
a.push(Number(o));
} else a.push(o);
if (a.length === 0) {} else if (a.length === 1) {
const e = a[0];
n.type = e === null ? "null" : typeof e;
if (t.target === "draft-04" || t.target === "openapi-3.0") n.enum = [e];
else n.const = e;
} else {
if (a.every((e) => typeof e === "number")) n.type = "number";
if (a.every((e) => typeof e === "string")) n.type = "string";
if (a.every((e) => typeof e === "boolean")) n.type = "boolean";
if (a.every((e) => e === null)) n.type = "null";
n.enum = a;
}
};
const customProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Custom types cannot be represented in JSON Schema");
};
const transformProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Transforms cannot be represented in JSON Schema");
};
const arrayProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.def;
const { minimum: o, maximum: s } = aggregateChecks(e);
if (typeof o === "number") i.minItems = o;
if (typeof s === "number") i.maxItems = s;
i.type = "array";
i.items = processSchema(a.element, t, {
...r,
path: [...r.path, "items"]
});
};
function inputOptin(e) {
const t = e._zod.def;
if (t.type === "pipe" && t.in._zod.traits.has("$ZodTransform")) return inputOptin(t.out);
if (t.type === "catch") return inputOptin(t.innerType);
return e._zod.optin;
}
const objectProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.def;
const o = a.shape;
if (Object.getOwnPropertySymbols(o).length && handleUnrepresentable(e, t, i, r, "Symbol keys cannot be represented in JSON Schema")) return;
i.type = "object";
i.properties = {};
for (const e in o) assignProp(i.properties, e, processSchema(o[e], t, {
...r,
path: [
...r.path,
"properties",
e
]
}));
const s = [];
for (const e of Object.keys(o)) {
const n = a.shape[e];
if (t.io === "input" ? inputOptin(n) === void 0 : n._zod.optout === void 0) s.push(e);
}
if (s.length > 0) i.required = s;
if (a.catchall?._zod.def.type === "never") i.additionalProperties = false;
else if (!a.catchall) {
if (t.io === "output") i.additionalProperties = false;
} else if (a.catchall) i.additionalProperties = processSchema(a.catchall, t, {
...r,
path: [...r.path, "additionalProperties"]
});
};
const unionProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = i.inclusive === false;
const o = i.options.map((e, n) => processSchema(e, t, {
...r,
path: [
...r.path,
a ? "oneOf" : "anyOf",
n
]
}));
if (a) n.oneOf = o;
else n.anyOf = o;
};
const intersectionProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = processSchema(i.left, t, {
...r,
path: [
...r.path,
"allOf",
0
]
});
const o = processSchema(i.right, t, {
...r,
path: [
...r.path,
"allOf",
1
]
});
const isSimpleIntersection = (e) => "allOf" in e && Object.keys(e).length === 1;
const s = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(o) ? o.allOf : [o]];
n.allOf = s;
t.intersections.push(s);
};
/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
* numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
* behind a wrapper only carries its own `type` before then, and a union key only has its branches.
*
* A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
* than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
* exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
* accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
* outright. */
function stringifyKeyNames(e, t, n) {
if (t.$ref) {
if (n.has(t)) return t;
n.add(t);
const r = e.get(t)?.def;
if (!r) return t;
const i = stringifyKeyNames(e, r, n);
return i === r ? t : i;
}
for (const r of ["anyOf", "oneOf"]) {
const i = t[r];
if (!Array.isArray(i)) continue;
const a = i.map((t) => stringifyKeyNames(e, t, n));
if (a.some((e, t) => e !== i[t])) t = {
...t,
[r]: a
};
}
const r = Array.isArray(t.type) ? t.type : [t.type];
const i = !r.includes("string") && r.some((e) => e === "number" || e === "integer");
const a = t.enum ?? (t.const !== void 0 ? [t.const] : void 0);
if (!i && !a?.some((e) => typeof e === "number")) return t;
const { minimum: o, maximum: s, exclusiveMinimum: c, exclusiveMaximum: l, multipleOf: u, format: d, id: f, ...p } = t;
if (p.enum) p.enum = p.enum.map((e) => typeof e === "number" ? String(e) : e);
else if (typeof p.const === "number") p.const = String(p.const);
if (!i) return p;
p.type = "string";
if (!a) p.pattern = (r.includes("number") ? number$1 : integer).source;
return p;
}
/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
const pendingRecords = /* @__PURE__ */ new WeakMap();
function rewriteKeyNames(e) {
const t = /* @__PURE__ */ new Map();
for (const n of e.seen.values()) if (n.def && !t.has(n.schema)) t.set(n.schema, n);
const n = /* @__PURE__ */ new Map();
for (const r of pendingRecords.get(e) ?? []) {
const i = e.seen.get(r);
const a = (i?.def ?? i?.schema)?.propertyNames;
if (!a || a === true || n.has(a)) continue;
const o = stringifyKeyNames(t, a, /* @__PURE__ */ new Set());
if (o !== a) n.set(a, o);
}
if (!n.size) return;
for (const t of e.seen.values()) for (const e of [t.schema, t.def]) {
const t = e && n.get(e.propertyNames);
if (t) e.propertyNames = t;
}
}
const recordProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.def;
i.type = "object";
const o = a.keyType;
const s = aggregateChecks(o).patterns;
if (a.mode === "loose" && s && s.size > 0) {
const e = processSchema(a.valueType, t, {
...r,
path: [
...r.path,
"patternProperties",
"*"
]
});
i.patternProperties = {};
for (const t of s) assignProp(i.patternProperties, exactPattern(t).source, e);
} else {
if (t.target === "draft-07" || t.target === "draft-2020-12") {
i.propertyNames = processSchema(a.keyType, t, {
...r,
path: [...r.path, "propertyNames"]
});
let n = pendingRecords.get(t);
if (!n) {
n = [];
pendingRecords.set(t, n);
t.deferred.push(() => rewriteKeyNames(t));
}
n.push(e);
}
i.additionalProperties = processSchema(a.valueType, t, {
...r,
path: [...r.path, "additionalProperties"]
});
}
const c = o._zod.values;
const l = t.io === "input" && inputOptin(a.valueType) !== void 0;
if (c && !a.partial && !l) {
const e = [...c].filter((e) => typeof e === "string" || typeof e === "number");
if (e.length > 0) i.required = e.map(String);
}
};
const nullableProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = processSchema(i.innerType, t, r);
const o = t.seen.get(e);
if (t.target === "openapi-3.0") {
o.ref = i.innerType;
n.nullable = true;
} else n.anyOf = [a, { type: "null" }];
};
const nonoptionalProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
};
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
const UNREPRESENTABLE_DEFAULT = Symbol();
function serializeDefaultValue(e, t, n, r, i) {
let a = false;
const o = JSON.stringify(e, (e, t) => {
if (typeof t !== "bigint") return t;
a = true;
return null;
});
if (!a) return JSON.parse(o);
handleUnrepresentable(t, n, r, i, "BigInt defaults cannot be represented in JSON Schema");
return UNREPRESENTABLE_DEFAULT;
}
const defaultProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
const o = serializeDefaultValue(i.defaultValue, e, t, n, r);
if (o !== UNREPRESENTABLE_DEFAULT) n.default = o;
};
const prefaultProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
if (t.io !== "input") return;
const o = serializeDefaultValue(i.defaultValue, e, t, n, r);
if (o !== UNREPRESENTABLE_DEFAULT) n._prefault = o;
};
const catchProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
let o;
try {
o = i.catchValue(void 0);
} catch {
handleUnrepresentable(e, t, n, r, "Dynamic catch values are not supported in JSON Schema");
return;
}
n.default = o;
};
const pipeProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = i.in._zod.traits.has("$ZodTransform");
const o = t.io === "input" ? a ? i.out : i.in : i.out;
processSchema(o, t, r);
const s = t.seen.get(e);
s.ref = o;
};
const readonlyProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
n.readOnly = true;
};
const optionalProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/errors.js
const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
function _lazyMethod(e, t, n) {
Object.defineProperty(e, t, {
configurable: true,
enumerable: false,
get() {
const e = n(this);
Object.defineProperty(this, t, {
value: e,
configurable: true,
writable: true
});
return e;
},
set(e) {
Object.defineProperty(this, t, {
value: e,
configurable: true,
writable: true
});
}
});
}
const initializer = (e, t) => {
$ZodError.init(e, t);
e.name = "ZodError";
const n = Object.getPrototypeOf(e);
if (_installedErrorProtos.has(n)) return;
_installedErrorProtos.add(n);
_lazyMethod(n, "format", (e) => (t) => formatError(e, t));
_lazyMethod(n, "flatten", (e) => (t) => flattenError(e, t));
_lazyMethod(n, "addIssue", (e) => (t) => {
e.issues.push(t);
e.message = JSON.stringify(e.issues, jsonStringifyReplacer, 2);
});
_lazyMethod(n, "addIssues", (e) => (t) => {
e.issues.push(...t);
e.message = JSON.stringify(e.issues, jsonStringifyReplacer, 2);
});
Object.defineProperty(n, "isEmpty", {
configurable: true,
enumerable: false,
get() {
return this.issues.length === 0;
}
});
};
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/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.6.7/node_modules/zod/v4/classic/schemas.js
function _ensureDefaultLocale() {
if (!globalConfig.localeError) config(en_default());
}
function _ensureDefaultMemoizer() {
if (!globalConfig.memoizer) config({ memoizer: memoizer() });
}
const ZodType = /*@__PURE__*/ $constructor("ZodType", (e, t) => {
_ensureDefaultLocale();
$ZodType.init(e, t);
e.def = t;
e.type = t.type;
return e;
}, {
check(...e) {
const t = this.def;
return this.clone(mergeDefs(t, { checks: [...t.checks ?? [], ...e.map((e) => typeof e === "function" ? { _zod: {
check: e,
def: { check: "custom" },
onattach: []
} } : e)] }), { parent: true });
},
with(...e) {
return this.check(...e);
},
clone(e, t) {
return clone(this, e, t);
},
brand() {
return this;
},
register(e, t) {
e.add(this, t);
return this;
},
refine(e, t) {
return this.check(refine(e, t));
},
superRefine(e, t) {
return this.check(superRefine(e, t));
},
overwrite(e) {
return this.check(_overwrite(e));
},
optional() {
return optional(this);
},
exactOptional() {
return exactOptional(this);
},
nullable() {
return nullable(this);
},
nullish() {
return optional(nullable(this));
},
nonoptional(e) {
return nonoptional(this, e);
},
array() {
return array(this);
},
or(e) {
return union([this, e]);
},
and(e) {
return intersection(this, e);
},
transform(e) {
return pipe(this, transform(e));
},
default(e) {
return _default(this, e);
},
prefault(e) {
return prefault(this, e);
},
catch(e) {
return _catch(this, e);
},
pipe(e) {
return pipe(this, e);
},
readonly() {
return readonly(this);
},
describe(e) {
const t = this.clone();
globalRegistry.add(t, { description: e });
return t;
},
meta(...e) {
if (e.length === 0) return globalRegistry.get(this);
const t = this.clone();
globalRegistry.add(t, e[0]);
return t;
},
isOptional() {
return this.safeParse(void 0).success;
},
isNullable() {
return this.safeParse(null).success;
},
apply(e, ...t) {
return t.length === 0 ? e(this) : e(this, ...t);
},
get "~standard"() {
return hide(this, "~standard", {
...standardProps(this),
jsonSchema: {
input: createStandardJSONSchemaMethod(this, "input"),
output: createStandardJSONSchemaMethod(this, "output")
}
});
},
set "~standard"(e) {
own(this, "~standard", e);
},
parse: function _parse(e, t) {
return parse(this, e, t, { callee: _parse });
},
parseAsync: async function _parseAsync(e, t) {
return await parseAsync(this, e, t, { callee: _parseAsync });
},
safeParse(e, t) {
return safeParse(this, e, t);
},
async safeParseAsync(e, t) {
return safeParseAsync(this, e, t);
},
get spa() {
return this?.safeParseAsync;
},
set spa(e) {
own(this, "spa", e);
},
validate(e, t) {
return validate(this, e, t);
},
validateAsync(e, t) {
return validateAsync$1(this, e, t);
},
encode: function _encode(e, t) {
return encode(this, e, t, { callee: _encode });
},
decode: function _decode(e, t) {
return decode(this, e, t, { callee: _decode });
},
encodeAsync: async function _encodeAsync(e, t) {
return await encodeAsync(this, e, t, { callee: _encodeAsync });
},
decodeAsync: async function _decodeAsync(e, t) {
return await decodeAsync(this, e, t, { callee: _decodeAsync });
},
safeEncode(e, t) {
return safeEncode(this, e, t);
},
safeDecode(e, t) {
return safeDecode(this, e, t);
},
async safeEncodeAsync(e, t) {
return safeEncodeAsync(this, e, t);
},
async safeDecodeAsync(e, t) {
return safeDecodeAsync(this, e, t);
},
toJSONSchema(e) {
return createToJSONSchemaMethod(this, {})(e);
},
get description() {
return globalRegistry.get(this)?.description;
},
get _def() {
return this._zod.def;
}
});
/** @internal */
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (e, t) => {
$ZodString.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => stringProcessor(e, t, n, r);
}, /*@__PURE__*/ derived({
format: (e) => aggregateChecks(e).format ?? null,
minLength: (e) => aggregateChecks(e).minimum ?? null,
maxLength: (e) => aggregateChecks(e).maximum ?? null
}, {
regex(...e) {
return this.check(_regex(...e));
},
includes(...e) {
return this.check(_includes(...e));
},
startsWith(...e) {
return this.check(_startsWith(...e));
},
endsWith(...e) {
return this.check(_endsWith(...e));
},
min(...e) {
return this.check(_minLength(...e));
},
max(...e) {
return this.check(_maxLength(...e));
},
length(...e) {
return this.check(_length(...e));
},
nonempty(...e) {
return this.check(_minLength(1, ...e));
},
lowercase(e) {
return this.check(_lowercase(e));
},
uppercase(e) {
return this.check(_uppercase(e));
},
trim() {
return this.check(_trim());
},
normalize(...e) {
return this.check(_normalize(...e));
},
toLowerCase() {
return this.check(_toLowerCase());
},
toUpperCase() {
return this.check(_toUpperCase());
},
slugify() {
return this.check(_slugify());
}
}));
const ZodString = /*@__PURE__*/ $constructor("ZodString", (e, t) => {
$ZodString.init(e, t);
_ZodString.init(e, t);
}, {
email(e) {
return this.check(_email(ZodEmail, e));
},
url(e) {
return this.check(_url(ZodURL, e));
},
jwt(e) {
return this.check(_jwt(ZodJWT, e));
},
emoji(e) {
return this.check(_emoji(ZodEmoji, e));
},
guid(e) {
return this.check(_guid(ZodGUID, e));
},
uuid(e) {
return this.check(_uuid(ZodUUID, e));
},
uuidv4(e) {
return this.check(_uuidv4(ZodUUID, e));
},
uuidv6(e) {
return this.check(_uuidv6(ZodUUID, e));
},
uuidv7(e) {
return this.check(_uuidv7(ZodUUID, e));
},
nanoid(e) {
return this.check(_nanoid(ZodNanoID, e));
},
cuid(e) {
return this.check(_cuid(ZodCUID, e));
},
cuid2(e) {
return this.check(_cuid2(ZodCUID2, e));
},
ulid(e) {
return this.check(_ulid(ZodULID, e));
},
base64(e) {
return this.check(_base64(ZodBase64, e));
},
base64url(e) {
return this.check(_base64url(ZodBase64URL, e));
},
xid(e) {
return this.check(_xid(ZodXID, e));
},
ksuid(e) {
return this.check(_ksuid(ZodKSUID, e));
},
ipv4(e) {
return this.check(_ipv4(ZodIPv4, e));
},
ipv6(e) {
return this.check(_ipv6(ZodIPv6, e));
},
cidrv4(e) {
return this.check(_cidrv4(ZodCIDRv4, e));
},
cidrv6(e) {
return this.check(_cidrv6(ZodCIDRv6, e));
},
e164(e) {
return this.check(_e164(ZodE164, e));
},
datetime(e) {
return this.check(_isoDateTime(ZodISODateTime, e));
},
date(e) {
return this.check(_isoDate(ZodISODate, e));
},
time(e) {
return this.check(_isoTime(ZodISOTime, e));
},
duration(e) {
return this.check(_isoDuration(ZodISODuration, e));
}
});
function string(e) {
return _string(ZodString, e);
}
const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (e, t) => {
$ZodStringFormat.init(e, t);
_ZodString.init(e, t);
});
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (e, t) => {
$ZodISODateTime.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (e, t) => {
$ZodISODate.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (e, t) => {
$ZodISOTime.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (e, t) => {
$ZodISODuration.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (e, t) => {
$ZodEmail.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (e, t) => {
$ZodGUID.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (e, t) => {
$ZodUUID.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (e, t) => {
$ZodURL.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (e, t) => {
$ZodEmoji.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (e, t) => {
$ZodNanoID.init(e, t);
ZodStringFormat.init(e, t);
});
/**
* @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", (e, t) => {
$ZodCUID.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (e, t) => {
$ZodCUID2.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (e, t) => {
$ZodULID.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (e, t) => {
$ZodXID.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (e, t) => {
$ZodKSUID.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (e, t) => {
$ZodIPv4.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (e, t) => {
$ZodIPv6.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (e, t) => {
$ZodCIDRv4.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (e, t) => {
$ZodCIDRv6.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (e, t) => {
$ZodBase64.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (e, t) => {
$ZodBase64URL.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (e, t) => {
$ZodE164.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (e, t) => {
$ZodJWT.init(e, t);
ZodStringFormat.init(e, t);
});
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (e, t) => {
$ZodNumber.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => numberProcessor(e, t, n, r);
e.isFinite = true;
}, /*@__PURE__*/ derived({
minValue: (e) => {
const { minimum: t, exclusiveMinimum: n } = aggregateChecks(e);
return Math.max(t ?? Number.NEGATIVE_INFINITY, n ?? Number.NEGATIVE_INFINITY);
},
maxValue: (e) => {
const { maximum: t, exclusiveMaximum: n } = aggregateChecks(e);
return Math.min(t ?? Number.POSITIVE_INFINITY, n ?? Number.POSITIVE_INFINITY);
},
isInt: (e) => {
const { isInt: t, multipleOf: n } = aggregateChecks(e);
return !!t || !!n?.some(Number.isSafeInteger);
},
format: (e) => aggregateChecks(e).format ?? null
}, {
gt(e, t) {
return this.check(_gt(e, t));
},
gte(e, t) {
return this.check(_gte(e, t));
},
min(e, t) {
return this.check(_gte(e, t));
},
lt(e, t) {
return this.check(_lt(e, t));
},
lte(e, t) {
return this.check(_lte(e, t));
},
max(e, t) {
return this.check(_lte(e, t));
},
int(e) {
return this.check(int(e));
},
safe(e) {
return this.check(int(e));
},
positive(e) {
return this.check(_gt(0, e));
},
nonnegative(e) {
return this.check(_gte(0, e));
},
negative(e) {
return this.check(_lt(0, e));
},
nonpositive(e) {
return this.check(_lte(0, e));
},
multipleOf(e, t) {
return this.check(_multipleOf(e, t));
},
step(e, t) {
return this.check(_multipleOf(e, t));
},
finite() {
return this;
}
}));
function number(e) {
return _number(ZodNumber, e);
}
const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (e, t) => {
$ZodNumberFormat.init(e, t);
ZodNumber.init(e, t);
});
function int(e) {
return _int(ZodNumberFormat, e);
}
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (e, t) => {
$ZodBoolean.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => booleanProcessor(e, t, n, r);
});
function boolean(e) {
return _boolean(ZodBoolean, e);
}
const ZodNull = /*@__PURE__*/ $constructor("ZodNull", (e, t) => {
$ZodNull.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => nullProcessor(e, t, n, r);
});
function _null(e) {
return _null$1(ZodNull, e);
}
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (e, t) => {
$ZodUnknown.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => unknownProcessor(e, t, n, r);
});
function unknown() {
return _unknown(ZodUnknown);
}
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (e, t) => {
$ZodNever.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => neverProcessor(e, t, n, r);
});
function never(e) {
return _never(ZodNever, e);
}
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (e, t) => {
_ensureDefaultMemoizer();
$ZodArray.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => arrayProcessor(e, t, n, r);
e.element = t.element;
}, {
min(e, t) {
return this.check(_minLength(e, t));
},
nonempty(e) {
return this.check(_minLength(1, e));
},
max(e, t) {
return this.check(_maxLength(e, t));
},
length(e, t) {
return this.check(_length(e, t));
},
unwrap() {
return this.element;
}
});
function array(e, t) {
return _array(ZodArray, e, t);
}
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (e, t) => {
_ensureDefaultMemoizer();
$ZodObjectJIT.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => objectProcessor(e, t, n, r);
installLazyProp(e, "shape", (e) => e._zod.def.shape, false);
}, {
keyof() {
return _enum(Object.keys(this._zod.def.shape));
},
catchall(e) {
return this.clone(mergeDefs(this._zod.def, { catchall: e }));
},
passthrough() {
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
},
loose() {
return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
},
strict() {
return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
},
strip() {
return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
},
extend(e) {
return extend(this, e);
},
safeExtend(e) {
return safeExtend(this, e);
},
merge(e) {
return merge(this, e);
},
pick(e) {
return pick(this, e);
},
omit(e) {
return omit(this, e);
},
partial(...e) {
return partial(ZodOptional, this, e[0]);
},
exactPartial(...e) {
return partial(ZodExactOptional, this, e[0], "exactPartial");
},
required(...e) {
return required(ZodNonOptional, this, e[0]);
}
});
function object(e, t) {
const n = {
type: "object",
shape: e ?? {},
...normalizeParams(t)
};
return new ZodObject(n);
}
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (e, t) => {
$ZodUnion.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => unionProcessor(e, t, n, r);
e.options = t.options;
});
function union(e, t) {
return new ZodUnion({
type: "union",
options: e,
...normalizeParams(t)
});
}
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (e, t) => {
$ZodIntersection.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => intersectionProcessor(e, t, n, r);
});
function intersection(e, t) {
return new ZodIntersection({
type: "intersection",
left: e,
right: t
});
}
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (e, t) => {
_ensureDefaultMemoizer();
$ZodRecord.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => recordProcessor(e, t, n, r);
e.keyType = t.keyType;
e.valueType = t.valueType;
});
function record(e, t, n) {
if (!t || !t._zod) return new ZodRecord({
type: "record",
keyType: string(),
valueType: e,
...normalizeParams(t)
});
return new ZodRecord({
type: "record",
keyType: e,
valueType: t,
...normalizeParams(n)
});
}
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (e, t) => {
$ZodEnum.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => enumProcessor(e, t, n, r);
e.enum = t.entries;
e.options = [...e._zod.values];
const n = new Set(Object.keys(t.entries));
e.extract = (e, r) => {
const i = {};
for (const r of e) if (n.has(r)) i[r] = t.entries[r];
else throw new Error(`Key ${r} not found in enum`);
return new ZodEnum({
...t,
checks: [],
...normalizeParams(r),
entries: i
});
};
e.exclude = (e, r) => {
const i = { ...t.entries };
for (const t of e) if (n.has(t)) delete i[t];
else throw new Error(`Key ${t} not found in enum`);
return new ZodEnum({
...t,
checks: [],
...normalizeParams(r),
entries: i
});
};
});
function _enum(e, t) {
const n = Array.isArray(e) ? Object.fromEntries(e.map((e) => [e, e])) : e;
return new ZodEnum({
type: "enum",
entries: n,
...normalizeParams(t)
});
}
const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (e, t) => {
$ZodLiteral.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => literalProcessor(e, t, n, r);
e.values = new Set(t.values);
Object.defineProperty(e, "value", { get() {
if (t.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
return t.values[0];
} });
});
function literal(e, t) {
return new ZodLiteral({
type: "literal",
values: Array.isArray(e) ? e : [e],
...normalizeParams(t)
});
}
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (e, t) => {
_ensureDefaultMemoizer();
$ZodTransform.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => transformProcessor(e, t, n, r);
e._zod.parse = (n, r) => {
if (r.direction === "backward") throw new $ZodEncodeError(e.constructor.name);
n.addIssue = (r) => {
if (typeof r === "string") n.issues.push(issue(r, n.value, t));
else {
const t = r;
if (t.fatal) t.continue = false;
t.code ?? (t.code = "custom");
if (!("input" in t)) t.input = n.value;
t.inst ?? (t.inst = e);
n.issues.push(issue(t));
}
};
const i = t.transform(n.value, n);
if (i instanceof Promise) return i.then((e) => {
n.value = e;
return n;
});
n.value = i;
return n;
};
});
function transform(e) {
return new ZodTransform({
type: "transform",
transform: e
});
}
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (e, t) => {
$ZodOptional.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => optionalProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
});
function optional(e) {
return new ZodOptional({
type: "optional",
innerType: e
});
}
const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (e, t) => {
$ZodExactOptional.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => optionalProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
});
function exactOptional(e) {
return new ZodExactOptional({
type: "optional",
innerType: e
});
}
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (e, t) => {
$ZodNullable.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => nullableProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
});
function nullable(e) {
return new ZodNullable({
type: "nullable",
innerType: e
});
}
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (e, t) => {
$ZodDefault.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => defaultProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
e.removeDefault = e.unwrap;
});
function _default(e, t) {
return new ZodDefault({
type: "default",
innerType: e,
get defaultValue() {
return typeof t === "function" ? t() : shallowClone(t);
}
});
}
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (e, t) => {
$ZodPrefault.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => prefaultProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
});
function prefault(e, t) {
return new ZodPrefault({
type: "prefault",
innerType: e,
get defaultValue() {
return typeof t === "function" ? t() : shallowClone(t);
}
});
}
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (e, t) => {
$ZodNonOptional.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => nonoptionalProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
});
function nonoptional(e, t) {
return new ZodNonOptional({
type: "nonoptional",
innerType: e,
...normalizeParams(t)
});
}
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (e, t) => {
$ZodCatch.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => catchProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
e.removeCatch = e.unwrap;
});
function _catch(e, t) {
return new ZodCatch({
type: "catch",
innerType: e,
catchValue: typeof t === "function" ? t : constantCatch(t)
});
}
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (e, t) => {
$ZodPipe.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => pipeProcessor(e, t, n, r);
e.in = t.in;
e.out = t.out;
});
function pipe(e, t) {
return new ZodPipe({
type: "pipe",
in: e,
out: t
});
}
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (e, t) => {
$ZodReadonly.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => readonlyProcessor(e, t, n, r);
e.unwrap = () => e._zod.def.innerType;
});
function readonly(e) {
return new ZodReadonly({
type: "readonly",
innerType: e
});
}
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (e, t) => {
$ZodCustom.init(e, t);
ZodType.init(e, t);
e._zod.processJSONSchema = (t, n, r) => customProcessor(e, t, n, r);
});
function refine(e, t = {}) {
return _refine(ZodCustom, e, t);
}
function superRefine(e, t) {
return _superRefine(e, t);
}
//#endregion
//#region extensions/a2a/src/config-schema.ts
const a2aPeerNamePattern = /^[a-z0-9][a-z0-9._-]{0,63}$/;
const a2aHttpUrlSchema = string().url().and(string().regex(/^https?:\/\//, "A2A URLs must use HTTP or HTTPS"));
const a2aPeerConfigSchema = object({
token: string().min(1),
url: a2aHttpUrlSchema.optional(),
outboundToken: string().min(1).optional()
}).strict();
const a2aChannelConfigSchema = object({
enabled: boolean().optional(),
configWrites: boolean().optional(),
advertisedUrl: a2aHttpUrlSchema.optional(),
replyTimeoutMs: number().int().min(5e3).max(6e5).optional(),
rateLimitPerMinute: number().int().min(0).optional(),
exposeAgents: array(string()).optional(),
peers: record(string().regex(a2aPeerNamePattern), a2aPeerConfigSchema).optional()
}).strict();
const a2aPluginConfigSchema = buildChannelConfigSchema(a2aChannelConfigSchema, { uiHints: {
advertisedUrl: {
label: "Advertised Gateway URL",
help: "Public Gateway origin included in the A2A agent card."
},
replyTimeoutMs: {
label: "Blocking Reply Timeout (ms)",
advanced: true
},
rateLimitPerMinute: {
label: "Requests Per Peer Per Minute",
advanced: true
},
exposeAgents: { label: "Exposed Agent IDs" },
"peers.*.token": {
label: "Inbound Bearer Token",
sensitive: true
},
"peers.*.outboundToken": {
label: "Outbound Bearer Token",
sensitive: true
}
} });
//#endregion
//#region extensions/a2a/src/channel-base.ts
const A2A_CHANNEL_ID = "a2a";
const a2aChannelRuntimeMeta = {
id: "a2a",
label: "A2A",
selectionLabel: "A2A (Agent-to-Agent Protocol)",
docsPath: "/channels/a2a",
docsLabel: "a2a",
blurb: "Connect external agents through the A2A v1.0 protocol.",
order: 75
};
const a2aChannelSetupPlugin = {
id: "a2a",
meta: a2aChannelRuntimeMeta,
capabilities: { chatTypes: ["direct"] },
reload: { configPrefixes: ["channels.a2a"] },
configSchema: a2aPluginConfigSchema,
setupContract: defineChannelSetupContract({
fields: {
advertisedUrl: {
kind: "string",
cli: {
flags: "--advertised-url <url>",
description: "Public Gateway origin published in the A2A agent card"
}
},
peerName: {
kind: "string",
cli: {
flags: "--peer-name <name>",
description: "A2A peer identifier to authorize"
}
},
peerToken: {
kind: "string",
sensitive: true,
cli: {
flags: "--peer-token <token>",
description: "Bearer token for the A2A peer"
}
}
},
adapter: { applyAccountConfig: ({ cfg: e, input: t }) => {
const n = t;
const r = e.channels?.a2a?.peers;
const i = n.peerName?.trim();
const a = n.peerToken?.trim();
const o = n.advertisedUrl?.trim();
return patchTopLevelChannelConfigSection({
cfg: e,
channel: "a2a",
enabled: true,
patch: {
...o ? { advertisedUrl: o } : {},
...i && a ? { peers: {
...r,
[i]: { token: a }
} } : {}
}
});
} }
}),
config: {
listAccountIds: listA2aChannelAccountIds,
resolveAccount: (e, t) => resolveA2aChannelAccount({
cfg: e,
accountId: t
}),
defaultAccountId: resolveDefaultA2aChannelAccountId,
isConfigured: (e) => e.configured,
isEnabled: (e) => e.enabled,
resolveAllowFrom: ({ cfg: e, accountId: t }) => Object.keys(resolveA2aChannelAccount({
cfg: e,
accountId: t
}).config.peers ?? {})
}
};
//#endregion
export { boolean as a, object as c, union as d, unknown as f, resolveDefaultA2aChannelAccountId as g, resolveA2aChannelAccount as h, array as i, record as l, listA2aChannelAccountIds as m, _enum as n, literal as o, DEFAULT_ACCOUNT_ID as p, _null as r, number as s, a2aChannelSetupPlugin as t, string as u };