storybook
Version:
Storybook framework-agnostic API
1,321 lines (1,311 loc) • 199 kB
JavaScript
import ESM_COMPAT_Module from "node:module";
import { fileURLToPath as ESM_COMPAT_fileURLToPath } from 'node:url';
import { dirname as ESM_COMPAT_dirname } from 'node:path';
const __filename = ESM_COMPAT_fileURLToPath(import.meta.url);
const __dirname = ESM_COMPAT_dirname(__filename);
const require = ESM_COMPAT_Module.createRequire(import.meta.url);
var hi = Object.create;
var $t = Object.defineProperty;
var yi = Object.getOwnPropertyDescriptor;
var gi = Object.getOwnPropertyNames;
var bi = Object.getPrototypeOf, xi = Object.prototype.hasOwnProperty;
var i = (t, e) => $t(t, "name", { value: e, configurable: !0 }), N = /* @__PURE__ */ ((t) => typeof require < "u" ? require : typeof Proxy <
"u" ? new Proxy(t, {
get: (e, r) => (typeof require < "u" ? require : e)[r]
}) : t)(function(t) {
if (typeof require < "u") return require.apply(this, arguments);
throw Error('Dynamic require of "' + t + '" is not supported');
});
var vi = (t, e) => () => (t && (e = t(t = 0)), e);
var I = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
var _i = (t, e, r, n) => {
if (e && typeof e == "object" || typeof e == "function")
for (let s of gi(e))
!xi.call(t, s) && s !== r && $t(t, s, { get: () => e[s], enumerable: !(n = yi(e, s)) || n.enumerable });
return t;
};
var z = (t, e, r) => (r = t != null ? hi(bi(t)) : {}, _i(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
e || !t || !t.__esModule ? $t(r, "default", { value: t, enumerable: !0 }) : r,
t
));
// ../node_modules/picocolors/picocolors.js
var Qr = I((ml, Vt) => {
var Qe = process || {}, Yr = Qe.argv || [], Xe = Qe.env || {}, wi = !(Xe.NO_COLOR || Yr.includes("--no-color")) && (!!Xe.FORCE_COLOR || Yr.
includes("--color") || Qe.platform === "win32" || (Qe.stdout || {}).isTTY && Xe.TERM !== "dumb" || !!Xe.CI), ki = /* @__PURE__ */ i((t, e, r = t) => (n) => {
let s = "" + n, o = s.indexOf(e, t.length);
return ~o ? t + Ti(s, e, r, o) + e : t + s + e;
}, "formatter"), Ti = /* @__PURE__ */ i((t, e, r, n) => {
let s = "", o = 0;
do
s += t.substring(o, n) + r, o = n + e.length, n = t.indexOf(e, o);
while (~n);
return s + t.substring(o);
}, "replaceClose"), Xr = /* @__PURE__ */ i((t = wi) => {
let e = t ? ki : () => String;
return {
isColorSupported: t,
reset: e("\x1B[0m", "\x1B[0m"),
bold: e("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
dim: e("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
italic: e("\x1B[3m", "\x1B[23m"),
underline: e("\x1B[4m", "\x1B[24m"),
inverse: e("\x1B[7m", "\x1B[27m"),
hidden: e("\x1B[8m", "\x1B[28m"),
strikethrough: e("\x1B[9m", "\x1B[29m"),
black: e("\x1B[30m", "\x1B[39m"),
red: e("\x1B[31m", "\x1B[39m"),
green: e("\x1B[32m", "\x1B[39m"),
yellow: e("\x1B[33m", "\x1B[39m"),
blue: e("\x1B[34m", "\x1B[39m"),
magenta: e("\x1B[35m", "\x1B[39m"),
cyan: e("\x1B[36m", "\x1B[39m"),
white: e("\x1B[37m", "\x1B[39m"),
gray: e("\x1B[90m", "\x1B[39m"),
bgBlack: e("\x1B[40m", "\x1B[49m"),
bgRed: e("\x1B[41m", "\x1B[49m"),
bgGreen: e("\x1B[42m", "\x1B[49m"),
bgYellow: e("\x1B[43m", "\x1B[49m"),
bgBlue: e("\x1B[44m", "\x1B[49m"),
bgMagenta: e("\x1B[45m", "\x1B[49m"),
bgCyan: e("\x1B[46m", "\x1B[49m"),
bgWhite: e("\x1B[47m", "\x1B[49m"),
blackBright: e("\x1B[90m", "\x1B[39m"),
redBright: e("\x1B[91m", "\x1B[39m"),
greenBright: e("\x1B[92m", "\x1B[39m"),
yellowBright: e("\x1B[93m", "\x1B[39m"),
blueBright: e("\x1B[94m", "\x1B[39m"),
magentaBright: e("\x1B[95m", "\x1B[39m"),
cyanBright: e("\x1B[96m", "\x1B[39m"),
whiteBright: e("\x1B[97m", "\x1B[39m"),
bgBlackBright: e("\x1B[100m", "\x1B[49m"),
bgRedBright: e("\x1B[101m", "\x1B[49m"),
bgGreenBright: e("\x1B[102m", "\x1B[49m"),
bgYellowBright: e("\x1B[103m", "\x1B[49m"),
bgBlueBright: e("\x1B[104m", "\x1B[49m"),
bgMagentaBright: e("\x1B[105m", "\x1B[49m"),
bgCyanBright: e("\x1B[106m", "\x1B[49m"),
bgWhiteBright: e("\x1B[107m", "\x1B[49m")
};
}, "createColors");
Vt.exports = Xr();
Vt.exports.createColors = Xr;
});
// ../node_modules/walk-up-path/dist/cjs/index.js
var dn = I((rt) => {
"use strict";
Object.defineProperty(rt, "__esModule", { value: !0 });
rt.walkUp = void 0;
var cn = N("path"), Si = /* @__PURE__ */ i(function* (t) {
for (t = (0, cn.resolve)(t); t; ) {
yield t;
let e = (0, cn.dirname)(t);
if (e === t)
break;
t = e;
}
}, "walkUp");
rt.walkUp = Si;
});
// ../node_modules/zod/lib/helpers/util.js
var Ne = I((E) => {
"use strict";
Object.defineProperty(E, "__esModule", { value: !0 });
E.getParsedType = E.ZodParsedType = E.objectUtil = E.util = void 0;
var zt;
(function(t) {
t.assertEqual = (s) => s;
function e(s) {
}
i(e, "assertIs"), t.assertIs = e;
function r(s) {
throw new Error();
}
i(r, "assertNever"), t.assertNever = r, t.arrayToEnum = (s) => {
let o = {};
for (let a of s)
o[a] = a;
return o;
}, t.getValidEnumValues = (s) => {
let o = t.objectKeys(s).filter((c) => typeof s[s[c]] != "number"), a = {};
for (let c of o)
a[c] = s[c];
return t.objectValues(a);
}, t.objectValues = (s) => t.objectKeys(s).map(function(o) {
return s[o];
}), t.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
let o = [];
for (let a in s)
Object.prototype.hasOwnProperty.call(s, a) && o.push(a);
return o;
}, t.find = (s, o) => {
for (let a of s)
if (o(a))
return a;
}, t.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.
floor(s) === s;
function n(s, o = " | ") {
return s.map((a) => typeof a == "string" ? `'${a}'` : a).join(o);
}
i(n, "joinValues"), t.joinValues = n, t.jsonStringifyReplacer = (s, o) => typeof o == "bigint" ? o.toString() : o;
})(zt || (E.util = zt = {}));
var hn;
(function(t) {
t.mergeShapes = (e, r) => ({
...e,
...r
// second overwrites first
});
})(hn || (E.objectUtil = hn = {}));
E.ZodParsedType = zt.arrayToEnum([
"string",
"nan",
"number",
"integer",
"float",
"boolean",
"date",
"bigint",
"symbol",
"function",
"undefined",
"null",
"array",
"object",
"unknown",
"promise",
"void",
"never",
"map",
"set"
]);
var Di = /* @__PURE__ */ i((t) => {
switch (typeof t) {
case "undefined":
return E.ZodParsedType.undefined;
case "string":
return E.ZodParsedType.string;
case "number":
return isNaN(t) ? E.ZodParsedType.nan : E.ZodParsedType.number;
case "boolean":
return E.ZodParsedType.boolean;
case "function":
return E.ZodParsedType.function;
case "bigint":
return E.ZodParsedType.bigint;
case "symbol":
return E.ZodParsedType.symbol;
case "object":
return Array.isArray(t) ? E.ZodParsedType.array : t === null ? E.ZodParsedType.null : t.then && typeof t.then == "function" && t.catch &&
typeof t.catch == "function" ? E.ZodParsedType.promise : typeof Map < "u" && t instanceof Map ? E.ZodParsedType.map : typeof Set < "\
u" && t instanceof Set ? E.ZodParsedType.set : typeof Date < "u" && t instanceof Date ? E.ZodParsedType.date : E.ZodParsedType.object;
default:
return E.ZodParsedType.unknown;
}
}, "getParsedType");
E.getParsedType = Di;
});
// ../node_modules/zod/lib/ZodError.js
var st = I((K) => {
"use strict";
Object.defineProperty(K, "__esModule", { value: !0 });
K.ZodError = K.quotelessJson = K.ZodIssueCode = void 0;
var yn = Ne();
K.ZodIssueCode = yn.util.arrayToEnum([
"invalid_type",
"invalid_literal",
"custom",
"invalid_union",
"invalid_union_discriminator",
"invalid_enum_value",
"unrecognized_keys",
"invalid_arguments",
"invalid_return_type",
"invalid_date",
"invalid_string",
"too_small",
"too_big",
"invalid_intersection_types",
"not_multiple_of",
"not_finite"
]);
var Li = /* @__PURE__ */ i((t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:"), "quotelessJson");
K.quotelessJson = Li;
var Ze = class t extends Error {
static {
i(this, "ZodError");
}
get errors() {
return this.issues;
}
constructor(e) {
super(), this.issues = [], this.addIssue = (n) => {
this.issues = [...this.issues, n];
}, this.addIssues = (n = []) => {
this.issues = [...this.issues, ...n];
};
let r = new.target.prototype;
Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
}
format(e) {
let r = e || function(o) {
return o.message;
}, n = { _errors: [] }, s = /* @__PURE__ */ i((o) => {
for (let a of o.issues)
if (a.code === "invalid_union")
a.unionErrors.map(s);
else if (a.code === "invalid_return_type")
s(a.returnTypeError);
else if (a.code === "invalid_arguments")
s(a.argumentsError);
else if (a.path.length === 0)
n._errors.push(r(a));
else {
let c = n, l = 0;
for (; l < a.path.length; ) {
let p = a.path[l];
l === a.path.length - 1 ? (c[p] = c[p] || { _errors: [] }, c[p]._errors.push(r(a))) : c[p] = c[p] || { _errors: [] }, c = c[p],
l++;
}
}
}, "processError");
return s(this), n;
}
static assert(e) {
if (!(e instanceof t))
throw new Error(`Not a ZodError: ${e}`);
}
toString() {
return this.message;
}
get message() {
return JSON.stringify(this.issues, yn.util.jsonStringifyReplacer, 2);
}
get isEmpty() {
return this.issues.length === 0;
}
flatten(e = (r) => r.message) {
let r = {}, n = [];
for (let s of this.issues)
s.path.length > 0 ? (r[s.path[0]] = r[s.path[0]] || [], r[s.path[0]].push(e(s))) : n.push(e(s));
return { formErrors: n, fieldErrors: r };
}
get formErrors() {
return this.flatten();
}
};
K.ZodError = Ze;
Ze.create = (t) => new Ze(t);
});
// ../node_modules/zod/lib/locales/en.js
var Jt = I((Kt) => {
"use strict";
Object.defineProperty(Kt, "__esModule", { value: !0 });
var ee = Ne(), A = st(), Ui = /* @__PURE__ */ i((t, e) => {
let r;
switch (t.code) {
case A.ZodIssueCode.invalid_type:
t.received === ee.ZodParsedType.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
break;
case A.ZodIssueCode.invalid_literal:
r = `Invalid literal value, expected ${JSON.stringify(t.expected, ee.util.jsonStringifyReplacer)}`;
break;
case A.ZodIssueCode.unrecognized_keys:
r = `Unrecognized key(s) in object: ${ee.util.joinValues(t.keys, ", ")}`;
break;
case A.ZodIssueCode.invalid_union:
r = "Invalid input";
break;
case A.ZodIssueCode.invalid_union_discriminator:
r = `Invalid discriminator value. Expected ${ee.util.joinValues(t.options)}`;
break;
case A.ZodIssueCode.invalid_enum_value:
r = `Invalid enum value. Expected ${ee.util.joinValues(t.options)}, received '${t.received}'`;
break;
case A.ZodIssueCode.invalid_arguments:
r = "Invalid function arguments";
break;
case A.ZodIssueCode.invalid_return_type:
r = "Invalid function return type";
break;
case A.ZodIssueCode.invalid_date:
r = "Invalid date";
break;
case A.ZodIssueCode.invalid_string:
typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.
validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "start\
sWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input\
: must end with "${t.validation.endsWith}"` : ee.util.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` :
r = "Invalid";
break;
case A.ZodIssueCode.too_small:
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` :
t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` :
t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater tha\
n "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "gre\
ater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
break;
case A.ZodIssueCode.too_big:
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` :
t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` :
t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` :
t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` :
t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(
Number(t.maximum))}` : r = "Invalid input";
break;
case A.ZodIssueCode.custom:
r = "Invalid input";
break;
case A.ZodIssueCode.invalid_intersection_types:
r = "Intersection results could not be merged";
break;
case A.ZodIssueCode.not_multiple_of:
r = `Number must be a multiple of ${t.multipleOf}`;
break;
case A.ZodIssueCode.not_finite:
r = "Number must be finite";
break;
default:
r = e.defaultError, ee.util.assertNever(t);
}
return { message: r };
}, "errorMap");
Kt.default = Ui;
});
// ../node_modules/zod/lib/errors.js
var ot = I(($) => {
"use strict";
var $i = $ && $.__importDefault || function(t) {
return t && t.__esModule ? t : { default: t };
};
Object.defineProperty($, "__esModule", { value: !0 });
$.getErrorMap = $.setErrorMap = $.defaultErrorMap = void 0;
var gn = $i(Jt());
$.defaultErrorMap = gn.default;
var bn = gn.default;
function Vi(t) {
bn = t;
}
i(Vi, "setErrorMap");
$.setErrorMap = Vi;
function Fi() {
return bn;
}
i(Fi, "getErrorMap");
$.getErrorMap = Fi;
});
// ../node_modules/zod/lib/helpers/parseUtil.js
var Yt = I((T) => {
"use strict";
var Bi = T && T.__importDefault || function(t) {
return t && t.__esModule ? t : { default: t };
};
Object.defineProperty(T, "__esModule", { value: !0 });
T.isAsync = T.isValid = T.isDirty = T.isAborted = T.OK = T.DIRTY = T.INVALID = T.ParseStatus = T.addIssueToContext = T.EMPTY_PATH = T.makeIssue =
void 0;
var Wi = ot(), xn = Bi(Jt()), qi = /* @__PURE__ */ i((t) => {
let { data: e, path: r, errorMaps: n, issueData: s } = t, o = [...r, ...s.path || []], a = {
...s,
path: o
};
if (s.message !== void 0)
return {
...s,
path: o,
message: s.message
};
let c = "", l = n.filter((p) => !!p).slice().reverse();
for (let p of l)
c = p(a, { data: e, defaultError: c }).message;
return {
...s,
path: o,
message: c
};
}, "makeIssue");
T.makeIssue = qi;
T.EMPTY_PATH = [];
function Gi(t, e) {
let r = (0, Wi.getErrorMap)(), n = (0, T.makeIssue)({
issueData: e,
data: t.data,
path: t.path,
errorMaps: [
t.common.contextualErrorMap,
// contextual error map is first priority
t.schemaErrorMap,
// then schema-bound map if available
r,
// then global override map
r === xn.default ? void 0 : xn.default
// then global default map
].filter((s) => !!s)
});
t.common.issues.push(n);
}
i(Gi, "addIssueToContext");
T.addIssueToContext = Gi;
var Ht = class t {
static {
i(this, "ParseStatus");
}
constructor() {
this.value = "valid";
}
dirty() {
this.value === "valid" && (this.value = "dirty");
}
abort() {
this.value !== "aborted" && (this.value = "aborted");
}
static mergeArray(e, r) {
let n = [];
for (let s of r) {
if (s.status === "aborted")
return T.INVALID;
s.status === "dirty" && e.dirty(), n.push(s.value);
}
return { status: e.value, value: n };
}
static async mergeObjectAsync(e, r) {
let n = [];
for (let s of r) {
let o = await s.key, a = await s.value;
n.push({
key: o,
value: a
});
}
return t.mergeObjectSync(e, n);
}
static mergeObjectSync(e, r) {
let n = {};
for (let s of r) {
let { key: o, value: a } = s;
if (o.status === "aborted" || a.status === "aborted")
return T.INVALID;
o.status === "dirty" && e.dirty(), a.status === "dirty" && e.dirty(), o.value !== "__proto__" && (typeof a.value < "u" || s.alwaysSet) &&
(n[o.value] = a.value);
}
return { status: e.value, value: n };
}
};
T.ParseStatus = Ht;
T.INVALID = Object.freeze({
status: "aborted"
});
var zi = /* @__PURE__ */ i((t) => ({ status: "dirty", value: t }), "DIRTY");
T.DIRTY = zi;
var Ki = /* @__PURE__ */ i((t) => ({ status: "valid", value: t }), "OK");
T.OK = Ki;
var Ji = /* @__PURE__ */ i((t) => t.status === "aborted", "isAborted");
T.isAborted = Ji;
var Hi = /* @__PURE__ */ i((t) => t.status === "dirty", "isDirty");
T.isDirty = Hi;
var Yi = /* @__PURE__ */ i((t) => t.status === "valid", "isValid");
T.isValid = Yi;
var Xi = /* @__PURE__ */ i((t) => typeof Promise < "u" && t instanceof Promise, "isAsync");
T.isAsync = Xi;
});
// ../node_modules/zod/lib/helpers/typeAliases.js
var _n = I((vn) => {
"use strict";
Object.defineProperty(vn, "__esModule", { value: !0 });
});
// ../node_modules/zod/lib/helpers/errorUtil.js
var kn = I((it) => {
"use strict";
Object.defineProperty(it, "__esModule", { value: !0 });
it.errorUtil = void 0;
var wn;
(function(t) {
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
})(wn || (it.errorUtil = wn = {}));
});
// ../node_modules/zod/lib/types.js
var Mn = I((d) => {
"use strict";
var ct = d && d.__classPrivateFieldGet || function(t, e, r, n) {
if (r === "a" && !n) throw new TypeError("Private accessor was defined without a getter");
if (typeof e == "function" ? t !== e || !n : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did n\
ot declare it");
return r === "m" ? n : r === "a" ? n.call(t) : n ? n.value : e.get(t);
}, Sn = d && d.__classPrivateFieldSet || function(t, e, r, n, s) {
if (n === "m") throw new TypeError("Private method is not writable");
if (n === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
if (typeof e == "function" ? t !== e || !s : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did no\
t declare it");
return n === "a" ? s.call(t, r) : s ? s.value = r : e.set(t, r), r;
}, Me, De;
Object.defineProperty(d, "__esModule", { value: !0 });
d.boolean = d.bigint = d.array = d.any = d.coerce = d.ZodFirstPartyTypeKind = d.late = d.ZodSchema = d.Schema = d.custom = d.ZodReadonly =
d.ZodPipeline = d.ZodBranded = d.BRAND = d.ZodNaN = d.ZodCatch = d.ZodDefault = d.ZodNullable = d.ZodOptional = d.ZodTransformer = d.ZodEffects =
d.ZodPromise = d.ZodNativeEnum = d.ZodEnum = d.ZodLiteral = d.ZodLazy = d.ZodFunction = d.ZodSet = d.ZodMap = d.ZodRecord = d.ZodTuple = d.
ZodIntersection = d.ZodDiscriminatedUnion = d.ZodUnion = d.ZodObject = d.ZodArray = d.ZodVoid = d.ZodNever = d.ZodUnknown = d.ZodAny = d.ZodNull =
d.ZodUndefined = d.ZodSymbol = d.ZodDate = d.ZodBoolean = d.ZodBigInt = d.ZodNumber = d.ZodString = d.datetimeRegex = d.ZodType = void 0;
d.NEVER = d.void = d.unknown = d.union = d.undefined = d.tuple = d.transformer = d.symbol = d.string = d.strictObject = d.set = d.record =
d.promise = d.preprocess = d.pipeline = d.ostring = d.optional = d.onumber = d.oboolean = d.object = d.number = d.nullable = d.null = d.never =
d.nativeEnum = d.nan = d.map = d.literal = d.lazy = d.intersection = d.instanceof = d.function = d.enum = d.effect = d.discriminatedUnion =
d.date = void 0;
var at = ot(), y = kn(), u = Yt(), h = Ne(), m = st(), D = class {
static {
i(this, "ParseInputLazyPath");
}
constructor(e, r, n, s) {
this._cachedPath = [], this.parent = e, this.data = r, this._path = n, this._key = s;
}
get path() {
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.
push(...this._path, this._key)), this._cachedPath;
}
}, Tn = /* @__PURE__ */ i((t, e) => {
if ((0, u.isValid)(e))
return { success: !0, data: e.value };
if (!t.common.issues.length)
throw new Error("Validation failed but no issues detected.");
return {
success: !1,
get error() {
if (this._error)
return this._error;
let r = new m.ZodError(t.common.issues);
return this._error = r, this._error;
}
};
}, "handleResult");
function x(t) {
if (!t)
return {};
let { errorMap: e, invalid_type_error: r, required_error: n, description: s } = t;
if (e && (r || n))
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
return e ? { errorMap: e, description: s } : { errorMap: /* @__PURE__ */ i((a, c) => {
var l, p;
let { message: f } = t;
return a.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (l = f ?? n) !== null && l !==
void 0 ? l : c.defaultError } : a.code !== "invalid_type" ? { message: c.defaultError } : { message: (p = f ?? r) !== null && p !== void 0 ?
p : c.defaultError };
}, "customMap"), description: s };
}
i(x, "processCreateParams");
var v = class {
static {
i(this, "ZodType");
}
get description() {
return this._def.description;
}
_getType(e) {
return (0, h.getParsedType)(e.data);
}
_getOrReturnCtx(e, r) {
return r || {
common: e.parent.common,
data: e.data,
parsedType: (0, h.getParsedType)(e.data),
schemaErrorMap: this._def.errorMap,
path: e.path,
parent: e.parent
};
}
_processInputParams(e) {
return {
status: new u.ParseStatus(),
ctx: {
common: e.parent.common,
data: e.data,
parsedType: (0, h.getParsedType)(e.data),
schemaErrorMap: this._def.errorMap,
path: e.path,
parent: e.parent
}
};
}
_parseSync(e) {
let r = this._parse(e);
if ((0, u.isAsync)(r))
throw new Error("Synchronous parse encountered promise.");
return r;
}
_parseAsync(e) {
let r = this._parse(e);
return Promise.resolve(r);
}
parse(e, r) {
let n = this.safeParse(e, r);
if (n.success)
return n.data;
throw n.error;
}
safeParse(e, r) {
var n;
let s = {
common: {
issues: [],
async: (n = r?.async) !== null && n !== void 0 ? n : !1,
contextualErrorMap: r?.errorMap
},
path: r?.path || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data: e,
parsedType: (0, h.getParsedType)(e)
}, o = this._parseSync({ data: e, path: s.path, parent: s });
return Tn(s, o);
}
"~validate"(e) {
var r, n;
let s = {
common: {
issues: [],
async: !!this["~standard"].async
},
path: [],
schemaErrorMap: this._def.errorMap,
parent: null,
data: e,
parsedType: (0, h.getParsedType)(e)
};
if (!this["~standard"].async)
try {
let o = this._parseSync({ data: e, path: [], parent: s });
return (0, u.isValid)(o) ? {
value: o.value
} : {
issues: s.common.issues
};
} catch (o) {
!((n = (r = o?.message) === null || r === void 0 ? void 0 : r.toLowerCase()) === null || n === void 0) && n.includes("encountered") &&
(this["~standard"].async = !0), s.common = {
issues: [],
async: !0
};
}
return this._parseAsync({ data: e, path: [], parent: s }).then((o) => (0, u.isValid)(o) ? {
value: o.value
} : {
issues: s.common.issues
});
}
async parseAsync(e, r) {
let n = await this.safeParseAsync(e, r);
if (n.success)
return n.data;
throw n.error;
}
async safeParseAsync(e, r) {
let n = {
common: {
issues: [],
contextualErrorMap: r?.errorMap,
async: !0
},
path: r?.path || [],
schemaErrorMap: this._def.errorMap,
parent: null,
data: e,
parsedType: (0, h.getParsedType)(e)
}, s = this._parse({ data: e, path: n.path, parent: n }), o = await ((0, u.isAsync)(s) ? s : Promise.resolve(s));
return Tn(n, o);
}
refine(e, r) {
let n = /* @__PURE__ */ i((s) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(s) : r, "getIssu\
eProperties");
return this._refinement((s, o) => {
let a = e(s), c = /* @__PURE__ */ i(() => o.addIssue({
code: m.ZodIssueCode.custom,
...n(s)
}), "setError");
return typeof Promise < "u" && a instanceof Promise ? a.then((l) => l ? !0 : (c(), !1)) : a ? !0 : (c(), !1);
});
}
refinement(e, r) {
return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof r == "function" ? r(n, s) : r), !1));
}
_refinement(e) {
return new Z({
schema: this,
typeName: g.ZodEffects,
effect: { type: "refinement", refinement: e }
});
}
superRefine(e) {
return this._refinement(e);
}
constructor(e) {
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync =
this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.
bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.
bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.
promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(
this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe =
this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.
bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
version: 1,
vendor: "zod",
validate: /* @__PURE__ */ i((r) => this["~validate"](r), "validate")
};
}
optional() {
return M.create(this, this._def);
}
nullable() {
return F.create(this, this._def);
}
nullish() {
return this.nullable().optional();
}
array() {
return q.create(this);
}
promise() {
return Y.create(this, this._def);
}
or(e) {
return ae.create([this, e], this._def);
}
and(e) {
return ce.create(this, e, this._def);
}
transform(e) {
return new Z({
...x(this._def),
schema: this,
typeName: g.ZodEffects,
effect: { type: "transform", transform: e }
});
}
default(e) {
let r = typeof e == "function" ? e : () => e;
return new fe({
...x(this._def),
innerType: this,
defaultValue: r,
typeName: g.ZodDefault
});
}
brand() {
return new Le({
typeName: g.ZodBranded,
type: this,
...x(this._def)
});
}
catch(e) {
let r = typeof e == "function" ? e : () => e;
return new me({
...x(this._def),
innerType: this,
catchValue: r,
typeName: g.ZodCatch
});
}
describe(e) {
let r = this.constructor;
return new r({
...this._def,
description: e
});
}
pipe(e) {
return Ue.create(this, e);
}
readonly() {
return he.create(this);
}
isOptional() {
return this.safeParse(void 0).success;
}
isNullable() {
return this.safeParse(null).success;
}
};
d.ZodType = v;
d.Schema = v;
d.ZodSchema = v;
var Qi = /^c[^\s-]{8,}$/i, ea = /^[0-9a-z]+$/, ta = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ra = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,
na = /^[a-z0-9_-]{21}$/i, sa = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, oa = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,
ia = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, aa = "^(\\p{Extended_Pictographic}|\\p{Emoji_Comp\
onent})+$", Xt, ca = /^(?:(?: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])$/, da = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,
ua = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,
la = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
pa = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, fa = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
En = "((\\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])))", ma = new RegExp(`^${En}$`);
function Cn(t) {
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
return t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`), e;
}
i(Cn, "timeRegexSource");
function ha(t) {
return new RegExp(`^${Cn(t)}$`);
}
i(ha, "timeRegex");
function Pn(t) {
let e = `${En}T${Cn(t)}`, r = [];
return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
}
i(Pn, "datetimeRegex");
d.datetimeRegex = Pn;
function ya(t, e) {
return !!((e === "v4" || !e) && ca.test(t) || (e === "v6" || !e) && ua.test(t));
}
i(ya, "isValidIP");
function ga(t, e) {
if (!sa.test(t))
return !1;
try {
let [r] = t.split("."), n = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), s = JSON.parse(atob(
n));
return !(typeof s != "object" || s === null || !s.typ || !s.alg || e && s.alg !== e);
} catch {
return !1;
}
}
i(ga, "isValidJWT");
function ba(t, e) {
return !!((e === "v4" || !e) && da.test(t) || (e === "v6" || !e) && la.test(t));
}
i(ba, "isValidCidr");
var J = class t extends v {
static {
i(this, "ZodString");
}
_parse(e) {
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.ZodParsedType.string) {
let o = this._getOrReturnCtx(e);
return (0, u.addIssueToContext)(o, {
code: m.ZodIssueCode.invalid_type,
expected: h.ZodParsedType.string,
received: o.parsedType
}), u.INVALID;
}
let n = new u.ParseStatus(), s;
for (let o of this._def.checks)
if (o.kind === "min")
e.data.length < o.value && (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.too_small,
minimum: o.value,
type: "string",
inclusive: !0,
exact: !1,
message: o.message
}), n.dirty());
else if (o.kind === "max")
e.data.length > o.value && (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.too_big,
maximum: o.value,
type: "string",
inclusive: !0,
exact: !1,
message: o.message
}), n.dirty());
else if (o.kind === "length") {
let a = e.data.length > o.value, c = e.data.length < o.value;
(a || c) && (s = this._getOrReturnCtx(e, s), a ? (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.too_big,
maximum: o.value,
type: "string",
inclusive: !0,
exact: !0,
message: o.message
}) : c && (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.too_small,
minimum: o.value,
type: "string",
inclusive: !0,
exact: !0,
message: o.message
}), n.dirty());
} else if (o.kind === "email")
ia.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "email",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty());
else if (o.kind === "emoji")
Xt || (Xt = new RegExp(aa, "u")), Xt.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "emoji",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty());
else if (o.kind === "uuid")
ra.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "uuid",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty());
else if (o.kind === "nanoid")
na.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "nanoid",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty());
else if (o.kind === "cuid")
Qi.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "cuid",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty());
else if (o.kind === "cuid2")
ea.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "cuid2",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty());
else if (o.kind === "ulid")
ta.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "ulid",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty());
else if (o.kind === "url")
try {
new URL(e.data);
} catch {
s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "url",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty();
}
else o.kind === "regex" ? (o.regex.lastIndex = 0, o.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(
s, {
validation: "regex",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty())) : o.kind === "trim" ? e.data = e.data.trim() : o.kind === "includes" ? e.data.includes(o.value, o.position) || (s = this.
_getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.invalid_string,
validation: { includes: o.value, position: o.position },
message: o.message
}), n.dirty()) : o.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : o.kind === "toUpperCase" ? e.data = e.data.toUpperCase() :
o.kind === "startsWith" ? e.data.startsWith(o.value) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.invalid_string,
validation: { startsWith: o.value },
message: o.message
}), n.dirty()) : o.kind === "endsWith" ? e.data.endsWith(o.value) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.invalid_string,
validation: { endsWith: o.value },
message: o.message
}), n.dirty()) : o.kind === "datetime" ? Pn(o).test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.invalid_string,
validation: "datetime",
message: o.message
}), n.dirty()) : o.kind === "date" ? ma.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.invalid_string,
validation: "date",
message: o.message
}), n.dirty()) : o.kind === "time" ? ha(o).test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
code: m.ZodIssueCode.invalid_string,
validation: "time",
message: o.message
}), n.dirty()) : o.kind === "duration" ? oa.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "duration",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty()) : o.kind === "ip" ? ya(e.data, o.version) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "ip",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty()) : o.kind === "jwt" ? ga(e.data, o.alg) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "jwt",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty()) : o.kind === "cidr" ? ba(e.data, o.version) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "cidr",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty()) : o.kind === "base64" ? pa.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "base64",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty()) : o.kind === "base64url" ? fa.test(e.data) || (s = this._getOrReturnCtx(e, s), (0, u.addIssueToContext)(s, {
validation: "base64url",
code: m.ZodIssueCode.invalid_string,
message: o.message
}), n.dirty()) : h.util.assertNever(o);
return { status: n.value, value: e.data };
}
_regex(e, r, n) {
return this.refinement((s) => e.test(s), {
validation: r,
code: m.ZodIssueCode.invalid_string,
...y.errorUtil.errToObj(n)
});
}
_addCheck(e) {
return new t({
...this._def,
checks: [...this._def.checks, e]
});
}
email(e) {
return this._addCheck({ kind: "email", ...y.errorUtil.errToObj(e) });
}
url(e) {
return this._addCheck({ kind: "url", ...y.errorUtil.errToObj(e) });
}
emoji(e) {
return this._addCheck({ kind: "emoji", ...y.errorUtil.errToObj(e) });
}
uuid(e) {
return this._addCheck({ kind: "uuid", ...y.errorUtil.errToObj(e) });
}
nanoid(e) {
return this._addCheck({ kind: "nanoid", ...y.errorUtil.errToObj(e) });
}
cuid(e) {
return this._addCheck({ kind: "cuid", ...y.errorUtil.errToObj(e) });
}
cuid2(e) {
return this._addCheck({ kind: "cuid2", ...y.errorUtil.errToObj(e) });
}
ulid(e) {
return this._addCheck({ kind: "ulid", ...y.errorUtil.errToObj(e) });
}
base64(e) {
return this._addCheck({ kind: "base64", ...y.errorUtil.errToObj(e) });
}
base64url(e) {
return this._addCheck({
kind: "base64url",
...y.errorUtil.errToObj(e)
});
}
jwt(e) {
return this._addCheck({ kind: "jwt", ...y.errorUtil.errToObj(e) });
}
ip(e) {
return this._addCheck({ kind: "ip", ...y.errorUtil.errToObj(e) });
}
cidr(e) {
return this._addCheck({ kind: "cidr", ...y.errorUtil.errToObj(e) });
}
datetime(e) {
var r, n;
return typeof e == "string" ? this._addCheck({
kind: "datetime",
precision: null,
offset: !1,
local: !1,
message: e
}) : this._addCheck({
kind: "datetime",
precision: typeof e?.precision > "u" ? null : e?.precision,
offset: (r = e?.offset) !== null && r !== void 0 ? r : !1,
local: (n = e?.local) !== null && n !== void 0 ? n : !1,
...y.errorUtil.errToObj(e?.message)
});
}
date(e) {
return this._addCheck({ kind: "date", message: e });
}
time(e) {
return typeof e == "string" ? this._addCheck({
kind: "time",
precision: null,
message: e
}) : this._addCheck({
kind: "time",
precision: typeof e?.precision > "u" ? null : e?.precision,
...y.errorUtil.errToObj(e?.message)
});
}
duration(e) {
return this._addCheck({ kind: "duration", ...y.errorUtil.errToObj(e) });
}
regex(e, r) {
return this._addCheck({
kind: "regex",
regex: e,
...y.errorUtil.errToObj(r)
});
}
includes(e, r) {
return this._addCheck({
kind: "includes",
value: e,
position: r?.position,
...y.errorUtil.errToObj(r?.message)
});
}
startsWith(e, r) {
return this._addCheck({
kind: "startsWith",
value: e,
...y.errorUtil.errToObj(r)
});
}
endsWith(e, r) {
return this._addCheck({
kind: "endsWith",
value: e,
...y.errorUtil.errToObj(r)
});
}
min(e, r) {
return this._addCheck({
kind: "min",
value: e,
...y.errorUtil.errToObj(r)
});
}
max(e, r) {
return this._addCheck({
kind: "max",
value: e,
...y.errorUtil.errToObj(r)
});
}
length(e, r) {
return this._addCheck({
kind: "length",
value: e,
...y.errorUtil.errToObj(r)
});
}
/**
* Equivalent to `.min(1)`
*/
nonempty(e) {
return this.min(1, y.errorUtil.errToObj(e));
}
trim() {
return new t({
...this._def,
checks: [...this._def.checks, { kind: "trim" }]
});
}
toLowerCase() {
return new t({
...this._def,
checks: [...this._def.checks, { kind: "toLowerCase" }]
});
}
toUpperCase() {
return new t({
...this._def,
checks: [...this._def.checks, { kind: "toUpperCase" }]
});
}
get isDatetime() {
return !!this._def.checks.find((e) => e.kind === "datetime");
}
get isDate() {
return !!this._def.checks.find((e) => e.kind === "date");
}
get isTime() {
return !!this._def.checks.find((e) => e.kind === "time");
}
get isDuration() {
return !!this._def.checks.find((e) => e.kind === "duration");
}
get isEmail() {
return !!this._def.checks.find((e) => e.kind === "email");
}
get isURL() {
return !!this._def.checks.find((e) => e.kind === "url");
}
get isEmoji() {
return !!this._def.checks.find((e) => e.kind === "emoji");
}
get isUUID() {
return !!this._def.checks.find((e) => e.kind === "uuid");
}
get isNANOID() {
return !!this._def.checks.find((e) => e.kind === "nanoid");
}
get isCUID() {
return !!this._def.checks.find((e) => e.kind === "cuid");
}
get isCUID2() {
return !!this._def.checks.find((e) => e.kind === "cuid2");
}
get isULID() {
return !!this._def.checks.find((e) => e.kind === "ulid");
}
get isIP() {
return !!this._def.checks.find((e) => e.kind === "ip");
}
get isCIDR() {
return !!this._def.checks.find((e) => e.kind === "cidr");
}
get isBase64() {
return !!this._def.checks.find((e) => e.kind === "base64");
}
get isBase64url() {
return !!this._def.checks.find((e) => e.kind === "base64url");
}
get minLength() {
let e = null;
for (let r of this._def.checks)
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
return e;
}
get maxLength() {
let e = null;
for (let r of this._def.checks)
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
return e;
}
};
d.ZodString = J;
J.create = (t) => {
var e;
return new J({
checks: [],
typeName: g.ZodString,
coerce: (e = t?.coerce) !== null && e !== void 0 ? e : !1,
...x(t)
});
};
function xa(t, e) {
let r = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = r > n ? r : n, o = parseInt(t.toFixed(
s).replace(".", "")), a = parseInt(e.toFixed(s).replace(".", ""));
return o % a / Math.pow(10, s);
}
i(xa, "floatSafeRemainder");
var te = class t extends v {
static {
i(this, "ZodNumber");
}
constructor() {
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
}
_parse(e) {
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.ZodParsedType.number) {
let o = this._getOrReturnCtx(e);
return (0, u.addIssueToContext)(o, {
code: m.ZodIssueCode.invalid_type,
expected: h.ZodParsedType.number,
received: o.parsedType
}), u.INVALID;
}
let n, s = new u.ParseStatus();
for (let o of this._def.checks)
o.kind === "int" ? h.util.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), (0, u.addIssueToContext)(n, {
code: m.ZodIssueCode.invalid_type,
expected: "integer",
received: "float",
message: o.message
}), s.dirty()) : o.kind === "min" ? (o.inclusive ? e.data < o.value : e.data <= o.value) && (n = this._getOrReturnCtx(e, n), (0, u.addIssueToContext)(
n, {
code: m.ZodIssueCode.too_small,
minimum: o.value,
type: "number",
inclusive: o.inclusive,
exact: !1,
message: o.message
}), s.dirty()) : o.kind === "max" ? (o.inclusive ? e.data > o.value : e.data >= o.value) && (n = this._getOrReturnCtx(e, n), (0, u.addIssueToContext)(
n, {
code: m.ZodIssueCode.too_big,
maximum: o.value,
type: "number",
inclusive: o.inclusive,
exact: !1,
message: o.message
}), s.dirty()) : o.kind === "multipleOf" ? xa(e.data, o.value) !== 0 && (n = this._getOrReturnCtx(e, n), (0, u.addIssueToCo