PageSourceSearch

https://www.playdia.com/_next/static/chunks/vendors-_app-pages-bro…dules_zod_lib_index_mjs-7c739b344398ed0f.js

js playdia.com collected 2026-10-10 00:47:26 UTC 157,068 bytes, 4,421 lines download raw bytes

vendor: 6,284 bytes, lines 1-171
1"use strict";
2(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([["vendors-_app-pages-browser_node_modules_pnpm_zod_3_24_2_node_modules_zod_lib_index_mjs"],{
3
4/***/ "(app-pages-browser)/./node_modules/.pnpm/[email protected]/node_modules/zod/lib/index.mjs":
5/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6
7/* harmony export */ __webpack_require__.d(__webpack_exports__, {
8/* harmony export */   z: () => (/* binding */ z)
9/* harmony export */ });
10/* unused harmony exports BRAND, DIRTY, EMPTY_PATH, INVALID, NEVER, OK, ParseStatus, Schema, ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodBranded, ZodCatch, ZodDate, ZodDefault, ZodDiscriminatedUnion, ZodEffects, ZodEnum, ZodError, ZodFirstPartyTypeKind, ZodFunction, ZodIntersection, ZodIssueCode, ZodLazy, ZodLiteral, ZodMap, ZodNaN, ZodNativeEnum, ZodNever, ZodNull, ZodNullable, ZodNumber, ZodObject, ZodOptional, ZodParsedType, ZodPipeline, ZodPromise, ZodReadonly, ZodRecord, ZodSchema, ZodSet, ZodString, ZodSymbol, ZodTransformer, ZodTuple, ZodType, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid, addIssueToContext, any, array, bigint, boolean, coerce, custom, date, datetimeRegex, default, defaultErrorMap, discriminatedUnion, effect, enum, function, getErrorMap, getParsedType, instanceof, intersection, isAborted, isAsync, isDirty, isValid, late, lazy, literal, makeIssue, map, nan, nativeEnum, never, null, nullable, number, object, objectUtil, oboolean, onumber, optional, ostring, pipeline, preprocess, promise, quotelessJson, record, set, setErrorMap, strictObject, string, symbol, transformer, tuple, undefined, union, unknown, util, void */
11var util;
12(function (util) {
13    util.assertEqual = (val) => val;
14    function assertIs(_arg) { }
15    util.assertIs = assertIs;
16    function assertNever(_x) {
17        throw new Error();
18    }
19    util.assertNever = assertNever;
20    util.arrayToEnum = (items) => {
21        const obj = {};
22        for (const item of items) {
23            obj[item] = item;
24        }
25        return obj;
26    };
27    util.getValidEnumValues = (obj) => {
28        const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
29        const filtered = {};
30        for (const k of validKeys) {
31            filtered[k] = obj[k];
32        }
33        return util.objectValues(filtered);
34    };
35    util.objectValues = (obj) => {
36        return util.objectKeys(obj).map(function (e) {
37            return obj[e];
38        });
39    };
40    util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
41        ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
42        : (object) => {
43            const keys = [];
44            for (const key in object) {
45                if (Object.prototype.hasOwnProperty.call(object, key)) {
46                    keys.push(key);
47                }
48            }
49            return keys;
50        };
51    util.find = (arr, checker) => {
52        for (const item of arr) {
53            if (checker(item))
54                return item;
55        }
56        return undefined;
57    };
58    util.isInteger = typeof Number.isInteger === "function"
59        ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
60        : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
61    function joinValues(array, separator = " | ") {
62        return array
63            .map((val) => (typeof val === "string" ? `'${val}'` : val))
64            .join(separator);
65    }
66    util.joinValues = joinValues;
67    util.jsonStringifyReplacer = (_, value) => {
68        if (typeof value === "bigint") {
69            return value.toString();
70        }
71        return value;
72    };
73})(util || (util = {}));
74var objectUtil;
75(function (objectUtil) {
76    objectUtil.mergeShapes = (first, second) => {
77        return {
78            ...first,
79            ...second, // second overwrites first
80        };
81    };
82})(objectUtil || (objectUtil = {}));
83const ZodParsedType = util.arrayToEnum([
84    "string",
85    "nan",
86    "number",
87    "integer",
88    "float",
89    "boolean",
90    "date",
91    "bigint",
92    "symbol",
93    "function",
94    "undefined",
95    "null",
96    "array",
97    "object",
98    "unknown",
99    "promise",
100    "void",
101    "never",
102    "map",
103    "set",
104]);
105const getParsedType = (data) => {
106    const t = typeof data;
107    switch (t) {
108        case "undefined":
109            return ZodParsedType.undefined;
110        case "string":
111            return ZodParsedType.string;
112        case "number":
113            return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
114        case "boolean":
115            return ZodParsedType.boolean;
116        case "function":
117            return ZodParsedType.function;
118        case "bigint":
119            return ZodParsedType.bigint;
120        case "symbol":
121            return ZodParsedType.symbol;
122        case "object":
123            if (Array.isArray(data)) {
124                return ZodParsedType.array;
125            }
126            if (data === null) {
127                return ZodParsedType.null;
128            }
129            if (data.then &&
130                typeof data.then === "function" &&
131                data.catch &&
132                typeof data.catch === "function") {
133                return ZodParsedType.promise;
134            }
135            if (typeof Map !== "undefined" && data instanceof Map) {
136                return ZodParsedType.map;
137            }
138            if (typeof Set !== "undefined" && data instanceof Set) {
139                return ZodParsedType.set;
140            }
141            if (typeof Date !== "undefined" && data instanceof Date) {
142                return ZodParsedType.date;
143            }
144            return ZodParsedType.object;
145        default:
146            return ZodParsedType.unknown;
147    }
148};
149
150const ZodIssueCode = util.arrayToEnum([
151    "invalid_type",
152    "invalid_literal",
153    "custom",
154    "invalid_union",
155    "invalid_union_discriminator",
156    "invalid_enum_value",
157    "unrecognized_keys",
158    "invalid_arguments",
159    "invalid_return_type",
160    "invalid_date",
161    "invalid_string",
162    "too_small",
163    "too_big",
164    "invalid_intersection_types",
165    "not_multiple_of",
166    "not_finite",
167]);
168const quotelessJson = (obj) => {
169    const json = JSON.stringify(obj, null, 2);
170    return json.replace(/"([^"]+)":/g, "$1:");
171};
vendor: 17,037 bytes, lines 172-615
172class ZodError extends Error {
173    get errors() {
174        return this.issues;
175    }
176    constructor(issues) {
177        super();
178        this.issues = [];
179        this.addIssue = (sub) => {
180            this.issues = [...this.issues, sub];
181        };
182        this.addIssues = (subs = []) => {
183            this.issues = [...this.issues, ...subs];
184        };
185        const actualProto = new.target.prototype;
186        if (Object.setPrototypeOf) {
187            // eslint-disable-next-line ban/ban
188            Object.setPrototypeOf(this, actualProto);
189        }
190        else {
191            this.__proto__ = actualProto;
192        }
193        this.name = "ZodError";
194        this.issues = issues;
195    }
196    format(_mapper) {
197        const mapper = _mapper ||
198            function (issue) {
199                return issue.message;
200            };
201        const fieldErrors = { _errors: [] };
202        const processError = (error) => {
203            for (const issue of error.issues) {
204                if (issue.code === "invalid_union") {
205                    issue.unionErrors.map(processError);
206                }
207                else if (issue.code === "invalid_return_type") {
208                    processError(issue.returnTypeError);
209                }
210                else if (issue.code === "invalid_arguments") {
211                    processError(issue.argumentsError);
212                }
213                else if (issue.path.length === 0) {
214                    fieldErrors._errors.push(mapper(issue));
215                }
216                else {
217                    let curr = fieldErrors;
218                    let i = 0;
219                    while (i < issue.path.length) {
220                        const el = issue.path[i];
221                        const terminal = i === issue.path.length - 1;
222                        if (!terminal) {
223                            curr[el] = curr[el] || { _errors: [] };
224                            // if (typeof el === "string") {
225                            //   curr[el] = curr[el] || { _errors: [] };
226                            // } else if (typeof el === "number") {
227                            //   const errorArray: any = [];
228                            //   errorArray._errors = [];
229                            //   curr[el] = curr[el] || errorArray;
230                            // }
231                        }
232                        else {
233                            curr[el] = curr[el] || { _errors: [] };
234                            curr[el]._errors.push(mapper(issue));
235                        }
236                        curr = curr[el];
237                        i++;
238                    }
239                }
240            }
241        };
242        processError(this);
243        return fieldErrors;
244    }
245    static assert(value) {
246        if (!(value instanceof ZodError)) {
247            throw new Error(`Not a ZodError: ${value}`);
248        }
249    }
250    toString() {
251        return this.message;
252    }
253    get message() {
254        return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
255    }
256    get isEmpty() {
257        return this.issues.length === 0;
258    }
259    flatten(mapper = (issue) => issue.message) {
260        const fieldErrors = {};
261        const formErrors = [];
262        for (const sub of this.issues) {
263            if (sub.path.length > 0) {
264                fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
265                fieldErrors[sub.path[0]].push(mapper(sub));
266            }
267            else {
268                formErrors.push(mapper(sub));
269            }
270        }
271        return { formErrors, fieldErrors };
272    }
273    get formErrors() {
274        return this.flatten();
275    }
276}
277ZodError.create = (issues) => {
278    const error = new ZodError(issues);
279    return error;
280};
281
282const errorMap = (issue, _ctx) => {
283    let message;
284    switch (issue.code) {
285        case ZodIssueCode.invalid_type:
286            if (issue.received === ZodParsedType.undefined) {
287                message = "Required";
288            }
289            else {
290                message = `Expected ${issue.expected}, received ${issue.received}`;
291            }
292            break;
293        case ZodIssueCode.invalid_literal:
294            message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
295            break;
296        case ZodIssueCode.unrecognized_keys:
297            message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
298            break;
299        case ZodIssueCode.invalid_union:
300            message = `Invalid input`;
301            break;
302        case ZodIssueCode.invalid_union_discriminator:
303            message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
304            break;
305        case ZodIssueCode.invalid_enum_value:
306            message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
307            break;
308        case ZodIssueCode.invalid_arguments:
309            message = `Invalid function arguments`;
310            break;
311        case ZodIssueCode.invalid_return_type:
312            message = `Invalid function return type`;
313            break;
314        case ZodIssueCode.invalid_date:
315            message = `Invalid date`;
316            break;
317        case ZodIssueCode.invalid_string:
318            if (typeof issue.validation === "object") {
319                if ("includes" in issue.validation) {
320                    message = `Invalid input: must include "${issue.validation.includes}"`;
321                    if (typeof issue.validation.position === "number") {
322                        message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
323                    }
324                }
325                else if ("startsWith" in issue.validation) {
326                    message = `Invalid input: must start with "${issue.validation.startsWith}"`;
327                }
328                else if ("endsWith" in issue.validation) {
329                    message = `Invalid input: must end with "${issue.validation.endsWith}"`;
330                }
331                else {
332                    util.assertNever(issue.validation);
333                }
334            }
335            else if (issue.validation !== "regex") {
336                message = `Invalid ${issue.validation}`;
337            }
338            else {
339                message = "Invalid";
340            }
341            break;
342        case ZodIssueCode.too_small:
343            if (issue.type === "array")
344                message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
345            else if (issue.type === "string")
346                message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
347            else if (issue.type === "number")
348                message = `Number must be ${issue.exact
349                    ? `exactly equal to `
350                    : issue.inclusive
351                        ? `greater than or equal to `
352                        : `greater than `}${issue.minimum}`;
353            else if (issue.type === "date")
354                message = `Date must be ${issue.exact
355                    ? `exactly equal to `
356                    : issue.inclusive
357                        ? `greater than or equal to `
358                        : `greater than `}${new Date(Number(issue.minimum))}`;
359            else
360                message = "Invalid input";
361            break;
362        case ZodIssueCode.too_big:
363            if (issue.type === "array")
364                message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
365            else if (issue.type === "string")
366                message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
367            else if (issue.type === "number")
368                message = `Number must be ${issue.exact
369                    ? `exactly`
370                    : issue.inclusive
371                        ? `less than or equal to`
372                        : `less than`} ${issue.maximum}`;
373            else if (issue.type === "bigint")
374                message = `BigInt must be ${issue.exact
375                    ? `exactly`
376                    : issue.inclusive
377                        ? `less than or equal to`
378                        : `less than`} ${issue.maximum}`;
379            else if (issue.type === "date")
380                message = `Date must be ${issue.exact
381                    ? `exactly`
382                    : issue.inclusive
383                        ? `smaller than or equal to`
384                        : `smaller than`} ${new Date(Number(issue.maximum))}`;
385            else
386                message = "Invalid input";
387            break;
388        case ZodIssueCode.custom:
389            message = `Invalid input`;
390            break;
391        case ZodIssueCode.invalid_intersection_types:
392            message = `Intersection results could not be merged`;
393            break;
394        case ZodIssueCode.not_multiple_of:
395            message = `Number must be a multiple of ${issue.multipleOf}`;
396            break;
397        case ZodIssueCode.not_finite:
398            message = "Number must be finite";
399            break;
400        default:
401            message = _ctx.defaultError;
402            util.assertNever(issue);
403    }
404    return { message };
405};
406
407let overrideErrorMap = errorMap;
408function setErrorMap(map) {
409    overrideErrorMap = map;
410}
411function getErrorMap() {
412    return overrideErrorMap;
413}
414
415const makeIssue = (params) => {
416    const { data, path, errorMaps, issueData } = params;
417    const fullPath = [...path, ...(issueData.path || [])];
418    const fullIssue = {
419        ...issueData,
420        path: fullPath,
421    };
422    if (issueData.message !== undefined) {
423        return {
424            ...issueData,
425            path: fullPath,
426            message: issueData.message,
427        };
428    }
429    let errorMessage = "";
430    const maps = errorMaps
431        .filter((m) => !!m)
432        .slice()
433        .reverse();
434    for (const map of maps) {
435        errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
436    }
437    return {
438        ...issueData,
439        path: fullPath,
440        message: errorMessage,
441    };
442};
443const EMPTY_PATH = [];
444function addIssueToContext(ctx, issueData) {
445    const overrideMap = getErrorMap();
446    const issue = makeIssue({
447        issueData: issueData,
448        data: ctx.data,
449        path: ctx.path,
450        errorMaps: [
451            ctx.common.contextualErrorMap, // contextual error map is first priority
452            ctx.schemaErrorMap, // then schema-bound map if available
453            overrideMap, // then global override map
454            overrideMap === errorMap ? undefined : errorMap, // then global default map
455        ].filter((x) => !!x),
456    });
457    ctx.common.issues.push(issue);
458}
459class ParseStatus {
460    constructor() {
461        this.value = "valid";
462    }
463    dirty() {
464        if (this.value === "valid")
465            this.value = "dirty";
466    }
467    abort() {
468        if (this.value !== "aborted")
469            this.value = "aborted";
470    }
471    static mergeArray(status, results) {
472        const arrayValue = [];
473        for (const s of results) {
474            if (s.status === "aborted")
475                return INVALID;
476            if (s.status === "dirty")
477                status.dirty();
478            arrayValue.push(s.value);
479        }
480        return { status: status.value, value: arrayValue };
481    }
482    static async mergeObjectAsync(status, pairs) {
483        const syncPairs = [];
484        for (const pair of pairs) {
485            const key = await pair.key;
486            const value = await pair.value;
487            syncPairs.push({
488                key,
489                value,
490            });
491        }
492        return ParseStatus.mergeObjectSync(status, syncPairs);
493    }
494    static mergeObjectSync(status, pairs) {
495        const finalObject = {};
496        for (const pair of pairs) {
497            const { key, value } = pair;
498            if (key.status === "aborted")
499                return INVALID;
500            if (value.status === "aborted")
501                return INVALID;
502            if (key.status === "dirty")
503                status.dirty();
504            if (value.status === "dirty")
505                status.dirty();
506            if (key.value !== "__proto__" &&
507                (typeof value.value !== "undefined" || pair.alwaysSet)) {
508                finalObject[key.value] = value.value;
509            }
510        }
511        return { status: status.value, value: finalObject };
512    }
513}
514const INVALID = Object.freeze({
515    status: "aborted",
516});
517const DIRTY = (value) => ({ status: "dirty", value });
518const OK = (value) => ({ status: "valid", value });
519const isAborted = (x) => x.status === "aborted";
520const isDirty = (x) => x.status === "dirty";
521const isValid = (x) => x.status === "valid";
522const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
523
524/******************************************************************************
525Copyright (c) Microsoft Corporation.
526
527Permission to use, copy, modify, and/or distribute this software for any
528purpose with or without fee is hereby granted.
529
530THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
531REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
532AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
533INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
534LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
535OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
536PERFORMANCE OF THIS SOFTWARE.
537***************************************************************************** */
538
539function __classPrivateFieldGet(receiver, state, kind, f) {
540    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
541    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
542    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
543}
544
545function __classPrivateFieldSet(receiver, state, value, kind, f) {
546    if (kind === "m") throw new TypeError("Private method is not writable");
547    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
548    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
549    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
550}
551
552typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
553    var e = new Error(message);
554    return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
555};
556
557var errorUtil;
558(function (errorUtil) {
559    errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
560    errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
561})(errorUtil || (errorUtil = {}));
562
563var _ZodEnum_cache, _ZodNativeEnum_cache;
564class ParseInputLazyPath {
565    constructor(parent, value, path, key) {
566        this._cachedPath = [];
567        this.parent = parent;
568        this.data = value;
569        this._path = path;
570        this._key = key;
571    }
572    get path() {
573        if (!this._cachedPath.length) {
574            if (this._key instanceof Array) {
575                this._cachedPath.push(...this._path, ...this._key);
576            }
577            else {
578                this._cachedPath.push(...this._path, this._key);
579            }
580        }
581        return this._cachedPath;
582    }
583}
584const handleResult = (ctx, result) => {
585    if (isValid(result)) {
586        return { success: true, data: result.value };
587    }
588    else {
589        if (!ctx.common.issues.length) {
590            throw new Error("Validation failed but no issues detected.");
591        }
592        return {
593            success: false,
594            get error() {
595                if (this._error)
596                    return this._error;
597                const error = new ZodError(ctx.common.issues);
598                this._error = error;
599                return this._error;
600            },
601        };
602    }
603};
604function processCreateParams(params) {
605    if (!params)
606        return {};
607    const { errorMap, invalid_type_error, required_error, description } = params;
608    if (errorMap && (invalid_type_error || required_error)) {
609        throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
610    }
611    if (errorMap)
612        return { errorMap: errorMap, description };
613    const customMap = (iss, ctx) => {
614        var _a, _b;
615        const { message } = params;
vendor: 6,003 bytes, lines 616-781
616        if (iss.code === "invalid_enum_value") {
617            return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
618        }
619        if (typeof ctx.data === "undefined") {
620            return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
621        }
622        if (iss.code !== "invalid_type")
623            return { message: ctx.defaultError };
624        return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
625    };
626    return { errorMap: customMap, description };
627}
628class ZodType {
629    get description() {
630        return this._def.description;
631    }
632    _getType(input) {
633        return getParsedType(input.data);
634    }
635    _getOrReturnCtx(input, ctx) {
636        return (ctx || {
637            common: input.parent.common,
638            data: input.data,
639            parsedType: getParsedType(input.data),
640            schemaErrorMap: this._def.errorMap,
641            path: input.path,
642            parent: input.parent,
643        });
644    }
645    _processInputParams(input) {
646        return {
647            status: new ParseStatus(),
648            ctx: {
649                common: input.parent.common,
650                data: input.data,
651                parsedType: getParsedType(input.data),
652                schemaErrorMap: this._def.errorMap,
653                path: input.path,
654                parent: input.parent,
655            },
656        };
657    }
658    _parseSync(input) {
659        const result = this._parse(input);
660        if (isAsync(result)) {
661            throw new Error("Synchronous parse encountered promise.");
662        }
663        return result;
664    }
665    _parseAsync(input) {
666        const result = this._parse(input);
667        return Promise.resolve(result);
668    }
669    parse(data, params) {
670        const result = this.safeParse(data, params);
671        if (result.success)
672            return result.data;
673        throw result.error;
674    }
675    safeParse(data, params) {
676        var _a;
677        const ctx = {
678            common: {
679                issues: [],
680                async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
681                contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
682            },
683            path: (params === null || params === void 0 ? void 0 : params.path) || [],
684            schemaErrorMap: this._def.errorMap,
685            parent: null,
686            data,
687            parsedType: getParsedType(data),
688        };
689        const result = this._parseSync({ data, path: ctx.path, parent: ctx });
690        return handleResult(ctx, result);
691    }
692    "~validate"(data) {
693        var _a, _b;
694        const ctx = {
695            common: {
696                issues: [],
697                async: !!this["~standard"].async,
698            },
699            path: [],
700            schemaErrorMap: this._def.errorMap,
701            parent: null,
702            data,
703            parsedType: getParsedType(data),
704        };
705        if (!this["~standard"].async) {
706            try {
707                const result = this._parseSync({ data, path: [], parent: ctx });
708                return isValid(result)
709                    ? {
710                        value: result.value,
711                    }
712                    : {
713                        issues: ctx.common.issues,
714                    };
715            }
716            catch (err) {
717                if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
718                    this["~standard"].async = true;
719                }
720                ctx.common = {
721                    issues: [],
722                    async: true,
723                };
724            }
725        }
726        return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result)
727            ? {
728                value: result.value,
729            }
730            : {
731                issues: ctx.common.issues,
732            });
733    }
734    async parseAsync(data, params) {
735        const result = await this.safeParseAsync(data, params);
736        if (result.success)
737            return result.data;
738        throw result.error;
739    }
740    async safeParseAsync(data, params) {
741        const ctx = {
742            common: {
743                issues: [],
744                contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
745                async: true,
746            },
747            path: (params === null || params === void 0 ? void 0 : params.path) || [],
748            schemaErrorMap: this._def.errorMap,
749            parent: null,
750            data,
751            parsedType: getParsedType(data),
752        };
753        const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
754        const result = await (isAsync(maybeAsyncResult)
755            ? maybeAsyncResult
756            : Promise.resolve(maybeAsyncResult));
757        return handleResult(ctx, result);
758    }
759    refine(check, message) {
760        const getIssueProperties = (val) => {
761            if (typeof message === "string" || typeof message === "undefined") {
762                return { message };
763            }
764            else if (typeof message === "function") {
765                return message(val);
766            }
767            else {
768                return message;
769            }
770        };
771        return this._refinement((val, ctx) => {
772            const result = check(val);
773            const setError = () => ctx.addIssue({
774                code: ZodIssueCode.custom,
775                ...getIssueProperties(val),
776            });
777            if (typeof Promise !== "undefined" && result instanceof Promise) {
778                return result.then((data) => {
779                    if (!data) {
780                        setError();
781                        return false;
vendor: 4,583 bytes, lines 782-929
782                    }
783                    else {
784                        return true;
785                    }
786                });
787            }
788            if (!result) {
789                setError();
790                return false;
791            }
792            else {
793                return true;
794            }
795        });
796    }
797    refinement(check, refinementData) {
798        return this._refinement((val, ctx) => {
799            if (!check(val)) {
800                ctx.addIssue(typeof refinementData === "function"
801                    ? refinementData(val, ctx)
802                    : refinementData);
803                return false;
804            }
805            else {
806                return true;
807            }
808        });
809    }
810    _refinement(refinement) {
811        return new ZodEffects({
812            schema: this,
813            typeName: ZodFirstPartyTypeKind.ZodEffects,
814            effect: { type: "refinement", refinement },
815        });
816    }
817    superRefine(refinement) {
818        return this._refinement(refinement);
819    }
820    constructor(def) {
821        /** Alias of safeParseAsync */
822        this.spa = this.safeParseAsync;
823        this._def = def;
824        this.parse = this.parse.bind(this);
825        this.safeParse = this.safeParse.bind(this);
826        this.parseAsync = this.parseAsync.bind(this);
827        this.safeParseAsync = this.safeParseAsync.bind(this);
828        this.spa = this.spa.bind(this);
829        this.refine = this.refine.bind(this);
830        this.refinement = this.refinement.bind(this);
831        this.superRefine = this.superRefine.bind(this);
832        this.optional = this.optional.bind(this);
833        this.nullable = this.nullable.bind(this);
834        this.nullish = this.nullish.bind(this);
835        this.array = this.array.bind(this);
836        this.promise = this.promise.bind(this);
837        this.or = this.or.bind(this);
838        this.and = this.and.bind(this);
839        this.transform = this.transform.bind(this);
840        this.brand = this.brand.bind(this);
841        this.default = this.default.bind(this);
842        this.catch = this.catch.bind(this);
843        this.describe = this.describe.bind(this);
844        this.pipe = this.pipe.bind(this);
845        this.readonly = this.readonly.bind(this);
846        this.isNullable = this.isNullable.bind(this);
847        this.isOptional = this.isOptional.bind(this);
848        this["~standard"] = {
849            version: 1,
850            vendor: "zod",
851            validate: (data) => this["~validate"](data),
852        };
853    }
854    optional() {
855        return ZodOptional.create(this, this._def);
856    }
857    nullable() {
858        return ZodNullable.create(this, this._def);
859    }
860    nullish() {
861        return this.nullable().optional();
862    }
863    array() {
864        return ZodArray.create(this);
865    }
866    promise() {
867        return ZodPromise.create(this, this._def);
868    }
869    or(option) {
870        return ZodUnion.create([this, option], this._def);
871    }
872    and(incoming) {
873        return ZodIntersection.create(this, incoming, this._def);
874    }
875    transform(transform) {
876        return new ZodEffects({
877            ...processCreateParams(this._def),
878            schema: this,
879            typeName: ZodFirstPartyTypeKind.ZodEffects,
880            effect: { type: "transform", transform },
881        });
882    }
883    default(def) {
884        const defaultValueFunc = typeof def === "function" ? def : () => def;
885        return new ZodDefault({
886            ...processCreateParams(this._def),
887            innerType: this,
888            defaultValue: defaultValueFunc,
889            typeName: ZodFirstPartyTypeKind.ZodDefault,
890        });
891    }
892    brand() {
893        return new ZodBranded({
894            typeName: ZodFirstPartyTypeKind.ZodBranded,
895            type: this,
896            ...processCreateParams(this._def),
897        });
898    }
899    catch(def) {
900        const catchValueFunc = typeof def === "function" ? def : () => def;
901        return new ZodCatch({
902            ...processCreateParams(this._def),
903            innerType: this,
904            catchValue: catchValueFunc,
905            typeName: ZodFirstPartyTypeKind.ZodCatch,
906        });
907    }
908    describe(description) {
909        const This = this.constructor;
910        return new This({
911            ...this._def,
912            description,
913        });
914    }
915    pipe(target) {
916        return ZodPipeline.create(this, target);
917    }
918    readonly() {
919        return ZodReadonly.create(this);
920    }
921    isOptional() {
922        return this.safeParse(undefined).success;
923    }
924    isNullable() {
925        return this.safeParse(null).success;
926    }
927}
928const cuidRegex = /^c[^\s-]{8,}$/i;
929const cuid2Regex = /^[0-9a-z]+$/;
vendor: 7,587 bytes, lines 930-1004
930const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
931// const uuidRegex =
932//   /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
933const uuidRegex = /^[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;
934const nanoidRegex = /^[a-z0-9_-]{21}$/i;
935const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
936const durationRegex = /^[-+]?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)?)??$/;
937// from https://stackoverflow.com/a/46181/1550155
938// old version: too slow, didn't support unicode
939// const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
940//old email regex
941// const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
942// eslint-disable-next-line
943// const emailRegex =
944//   /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
945// const emailRegex =
946//   /^[a-zA-Z0-9\.\!\#\$\%\&\'\*\+\/\=\?\^\_\`\{\|\}\~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
947// const emailRegex =
948//   /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
949const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
950// const emailRegex =
951//   /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
952// from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
953const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
954let emojiRegex;
955// faster, simpler, safer
956const ipv4Regex = /^(?:(?: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])$/;
957const ipv4CidrRegex = /^(?:(?: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])$/;
958// const ipv6Regex =
959// /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
960const ipv6Regex = /^(([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]))$/;
961const ipv6CidrRegex = /^(([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])$/;
962// https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
963const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
964// https://base64.guru/standards/base64url
965const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
966// simple
967// const dateRegexSource = `\\d{4}-\\d{2}-\\d{2}`;
968// no leap year validation
969// const dateRegexSource = `\\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\\d|2\\d))`;
970// with leap year validation
971const dateRegexSource = `((\\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])))`;
972const dateRegex = new RegExp(`^${dateRegexSource}$`);
973function timeRegexSource(args) {
974    // let regex = `\\d{2}:\\d{2}:\\d{2}`;
975    let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
976    if (args.precision) {
977        regex = `${regex}\\.\\d{${args.precision}}`;
978    }
979    else if (args.precision == null) {
980        regex = `${regex}(\\.\\d+)?`;
981    }
982    return regex;
983}
984function timeRegex(args) {
985    return new RegExp(`^${timeRegexSource(args)}$`);
986}
987// Adapted from https://stackoverflow.com/a/3143231
988function datetimeRegex(args) {
989    let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
990    const opts = [];
991    opts.push(args.local ? `Z?` : `Z`);
992    if (args.offset)
993        opts.push(`([+-]\\d{2}:?\\d{2})`);
994    regex = `${regex}(${opts.join("|")})`;
995    return new RegExp(`^${regex}$`);
996}
997function isValidIP(ip, version) {
998    if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
999        return true;
1000    }
1001    if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1002        return true;
1003    }
1004    return false;
vendor: 5,355 bytes, lines 1005-1147
1005}
1006function isValidJWT(jwt, alg) {
1007    if (!jwtRegex.test(jwt))
1008        return false;
1009    try {
1010        const [header] = jwt.split(".");
1011        // Convert base64url to base64
1012        const base64 = header
1013            .replace(/-/g, "+")
1014            .replace(/_/g, "/")
1015            .padEnd(header.length + ((4 - (header.length % 4)) % 4), "=");
1016        const decoded = JSON.parse(atob(base64));
1017        if (typeof decoded !== "object" || decoded === null)
1018            return false;
1019        if (!decoded.typ || !decoded.alg)
1020            return false;
1021        if (alg && decoded.alg !== alg)
1022            return false;
1023        return true;
1024    }
1025    catch (_a) {
1026        return false;
1027    }
1028}
1029function isValidCidr(ip, version) {
1030    if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1031        return true;
1032    }
1033    if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1034        return true;
1035    }
1036    return false;
1037}
1038class ZodString extends ZodType {
1039    _parse(input) {
1040        if (this._def.coerce) {
1041            input.data = String(input.data);
1042        }
1043        const parsedType = this._getType(input);
1044        if (parsedType !== ZodParsedType.string) {
1045            const ctx = this._getOrReturnCtx(input);
1046            addIssueToContext(ctx, {
1047                code: ZodIssueCode.invalid_type,
1048                expected: ZodParsedType.string,
1049                received: ctx.parsedType,
1050            });
1051            return INVALID;
1052        }
1053        const status = new ParseStatus();
1054        let ctx = undefined;
1055        for (const check of this._def.checks) {
1056            if (check.kind === "min") {
1057                if (input.data.length < check.value) {
1058                    ctx = this._getOrReturnCtx(input, ctx);
1059                    addIssueToContext(ctx, {
1060                        code: ZodIssueCode.too_small,
1061                        minimum: check.value,
1062                        type: "string",
1063                        inclusive: true,
1064                        exact: false,
1065                        message: check.message,
1066                    });
1067                    status.dirty();
1068                }
1069            }
1070            else if (check.kind === "max") {
1071                if (input.data.length > check.value) {
1072                    ctx = this._getOrReturnCtx(input, ctx);
1073                    addIssueToContext(ctx, {
1074                        code: ZodIssueCode.too_big,
1075                        maximum: check.value,
1076                        type: "string",
1077                        inclusive: true,
1078                        exact: false,
1079                        message: check.message,
1080                    });
1081                    status.dirty();
1082                }
1083            }
1084            else if (check.kind === "length") {
1085                const tooBig = input.data.length > check.value;
1086                const tooSmall = input.data.length < check.value;
1087                if (tooBig || tooSmall) {
1088                    ctx = this._getOrReturnCtx(input, ctx);
1089                    if (tooBig) {
1090                        addIssueToContext(ctx, {
1091                            code: ZodIssueCode.too_big,
1092                            maximum: check.value,
1093                            type: "string",
1094                            inclusive: true,
1095                            exact: true,
1096                            message: check.message,
1097                        });
1098                    }
1099                    else if (tooSmall) {
1100                        addIssueToContext(ctx, {
1101                            code: ZodIssueCode.too_small,
1102                            minimum: check.value,
1103                            type: "string",
1104                            inclusive: true,
1105                            exact: true,
1106                            message: check.message,
1107                        });
1108                    }
1109                    status.dirty();
1110                }
1111            }
1112            else if (check.kind === "email") {
1113                if (!emailRegex.test(input.data)) {
1114                    ctx = this._getOrReturnCtx(input, ctx);
1115                    addIssueToContext(ctx, {
1116                        validation: "email",
1117                        code: ZodIssueCode.invalid_string,
1118                        message: check.message,
1119                    });
1120                    status.dirty();
1121                }
1122            }
1123            else if (check.kind === "emoji") {
1124                if (!emojiRegex) {
1125                    emojiRegex = new RegExp(_emojiRegex, "u");
1126                }
1127                if (!emojiRegex.test(input.data)) {
1128                    ctx = this._getOrReturnCtx(input, ctx);
1129                    addIssueToContext(ctx, {
1130                        validation: "emoji",
1131                        code: ZodIssueCode.invalid_string,
1132                        message: check.message,
1133                    });
1134                    status.dirty();
1135                }
1136            }
1137            else if (check.kind === "uuid") {
1138                if (!uuidRegex.test(input.data)) {
1139                    ctx = this._getOrReturnCtx(input, ctx);
1140                    addIssueToContext(ctx, {
1141                        validation: "uuid",
1142                        code: ZodIssueCode.invalid_string,
1143                        message: check.message,
1144                    });
1145                    status.dirty();
1146                }
1147            }
vendor: 82,172 bytes, lines 1148-3572
1148            else if (check.kind === "nanoid") {
1149                if (!nanoidRegex.test(input.data)) {
1150                    ctx = this._getOrReturnCtx(input, ctx);
1151                    addIssueToContext(ctx, {
1152                        validation: "nanoid",
1153                        code: ZodIssueCode.invalid_string,
1154                        message: check.message,
1155                    });
1156                    status.dirty();
1157                }
1158            }
1159            else if (check.kind === "cuid") {
1160                if (!cuidRegex.test(input.data)) {
1161                    ctx = this._getOrReturnCtx(input, ctx);
1162                    addIssueToContext(ctx, {
1163                        validation: "cuid",
1164                        code: ZodIssueCode.invalid_string,
1165                        message: check.message,
1166                    });
1167                    status.dirty();
1168                }
1169            }
1170            else if (check.kind === "cuid2") {
1171                if (!cuid2Regex.test(input.data)) {
1172                    ctx = this._getOrReturnCtx(input, ctx);
1173                    addIssueToContext(ctx, {
1174                        validation: "cuid2",
1175                        code: ZodIssueCode.invalid_string,
1176                        message: check.message,
1177                    });
1178                    status.dirty();
1179                }
1180            }
1181            else if (check.kind === "ulid") {
1182                if (!ulidRegex.test(input.data)) {
1183                    ctx = this._getOrReturnCtx(input, ctx);
1184                    addIssueToContext(ctx, {
1185                        validation: "ulid",
1186                        code: ZodIssueCode.invalid_string,
1187                        message: check.message,
1188                    });
1189                    status.dirty();
1190                }
1191            }
1192            else if (check.kind === "url") {
1193                try {
1194                    new URL(input.data);
1195                }
1196                catch (_a) {
1197                    ctx = this._getOrReturnCtx(input, ctx);
1198                    addIssueToContext(ctx, {
1199                        validation: "url",
1200                        code: ZodIssueCode.invalid_string,
1201                        message: check.message,
1202                    });
1203                    status.dirty();
1204                }
1205            }
1206            else if (check.kind === "regex") {
1207                check.regex.lastIndex = 0;
1208                const testResult = check.regex.test(input.data);
1209                if (!testResult) {
1210                    ctx = this._getOrReturnCtx(input, ctx);
1211                    addIssueToContext(ctx, {
1212                        validation: "regex",
1213                        code: ZodIssueCode.invalid_string,
1214                        message: check.message,
1215                    });
1216                    status.dirty();
1217                }
1218            }
1219            else if (check.kind === "trim") {
1220                input.data = input.data.trim();
1221            }
1222            else if (check.kind === "includes") {
1223                if (!input.data.includes(check.value, check.position)) {
1224                    ctx = this._getOrReturnCtx(input, ctx);
1225                    addIssueToContext(ctx, {
1226                        code: ZodIssueCode.invalid_string,
1227                        validation: { includes: check.value, position: check.position },
1228                        message: check.message,
1229                    });
1230                    status.dirty();
1231                }
1232            }
1233            else if (check.kind === "toLowerCase") {
1234                input.data = input.data.toLowerCase();
1235            }
1236            else if (check.kind === "toUpperCase") {
1237                input.data = input.data.toUpperCase();
1238            }
1239            else if (check.kind === "startsWith") {
1240                if (!input.data.startsWith(check.value)) {
1241                    ctx = this._getOrReturnCtx(input, ctx);
1242                    addIssueToContext(ctx, {
1243                        code: ZodIssueCode.invalid_string,
1244                        validation: { startsWith: check.value },
1245                        message: check.message,
1246                    });
1247                    status.dirty();
1248                }
1249            }
1250            else if (check.kind === "endsWith") {
1251                if (!input.data.endsWith(check.value)) {
1252                    ctx = this._getOrReturnCtx(input, ctx);
1253                    addIssueToContext(ctx, {
1254                        code: ZodIssueCode.invalid_string,
1255                        validation: { endsWith: check.value },
1256                        message: check.message,
1257                    });
1258                    status.dirty();
1259                }
1260            }
1261            else if (check.kind === "datetime") {
1262                const regex = datetimeRegex(check);
1263                if (!regex.test(input.data)) {
1264                    ctx = this._getOrReturnCtx(input, ctx);
1265                    addIssueToContext(ctx, {
1266                        code: ZodIssueCode.invalid_string,
1267                        validation: "datetime",
1268                        message: check.message,
1269                    });
1270                    status.dirty();
1271                }
1272            }
1273            else if (check.kind === "date") {
1274                const regex = dateRegex;
1275                if (!regex.test(input.data)) {
1276                    ctx = this._getOrReturnCtx(input, ctx);
1277                    addIssueToContext(ctx, {
1278                        code: ZodIssueCode.invalid_string,
1279                        validation: "date",
1280                        message: check.message,
1281                    });
1282                    status.dirty();
1283                }
1284            }
1285            else if (check.kind === "time") {
1286                const regex = timeRegex(check);
1287                if (!regex.test(input.data)) {
1288                    ctx = this._getOrReturnCtx(input, ctx);
1289                    addIssueToContext(ctx, {
1290                        code: ZodIssueCode.invalid_string,
1291                        validation: "time",
1292                        message: check.message,
1293                    });
1294                    status.dirty();
1295                }
1296            }
1297            else if (check.kind === "duration") {
1298                if (!durationRegex.test(input.data)) {
1299                    ctx = this._getOrReturnCtx(input, ctx);
1300                    addIssueToContext(ctx, {
1301                        validation: "duration",
1302                        code: ZodIssueCode.invalid_string,
1303                        message: check.message,
1304                    });
1305                    status.dirty();
1306                }
1307            }
1308            else if (check.kind === "ip") {
1309                if (!isValidIP(input.data, check.version)) {
1310                    ctx = this._getOrReturnCtx(input, ctx);
1311                    addIssueToContext(ctx, {
1312                        validation: "ip",
1313                        code: ZodIssueCode.invalid_string,
1314                        message: check.message,
1315                    });
1316                    status.dirty();
1317                }
1318            }
1319            else if (check.kind === "jwt") {
1320                if (!isValidJWT(input.data, check.alg)) {
1321                    ctx = this._getOrReturnCtx(input, ctx);
1322                    addIssueToContext(ctx, {
1323                        validation: "jwt",
1324                        code: ZodIssueCode.invalid_string,
1325                        message: check.message,
1326                    });
1327                    status.dirty();
1328                }
1329            }
1330            else if (check.kind === "cidr") {
1331                if (!isValidCidr(input.data, check.version)) {
1332                    ctx = this._getOrReturnCtx(input, ctx);
1333                    addIssueToContext(ctx, {
1334                        validation: "cidr",
1335                        code: ZodIssueCode.invalid_string,
1336                        message: check.message,
1337                    });
1338                    status.dirty();
1339                }
1340            }
1341            else if (check.kind === "base64") {
1342                if (!base64Regex.test(input.data)) {
1343                    ctx = this._getOrReturnCtx(input, ctx);
1344                    addIssueToContext(ctx, {
1345                        validation: "base64",
1346                        code: ZodIssueCode.invalid_string,
1347                        message: check.message,
1348                    });
1349                    status.dirty();
1350                }
1351            }
1352            else if (check.kind === "base64url") {
1353                if (!base64urlRegex.test(input.data)) {
1354                    ctx = this._getOrReturnCtx(input, ctx);
1355                    addIssueToContext(ctx, {
1356                        validation: "base64url",
1357                        code: ZodIssueCode.invalid_string,
1358                        message: check.message,
1359                    });
1360                    status.dirty();
1361                }
1362            }
1363            else {
1364                util.assertNever(check);
1365            }
1366        }
1367        return { status: status.value, value: input.data };
1368    }
1369    _regex(regex, validation, message) {
1370        return this.refinement((data) => regex.test(data), {
1371            validation,
1372            code: ZodIssueCode.invalid_string,
1373            ...errorUtil.errToObj(message),
1374        });
1375    }
1376    _addCheck(check) {
1377        return new ZodString({
1378            ...this._def,
1379            checks: [...this._def.checks, check],
1380        });
1381    }
1382    email(message) {
1383        return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1384    }
1385    url(message) {
1386        return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1387    }
1388    emoji(message) {
1389        return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1390    }
1391    uuid(message) {
1392        return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1393    }
1394    nanoid(message) {
1395        return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1396    }
1397    cuid(message) {
1398        return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1399    }
1400    cuid2(message) {
1401        return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1402    }
1403    ulid(message) {
1404        return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1405    }
1406    base64(message) {
1407        return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1408    }
1409    base64url(message) {
1410        // base64url encoding is a modification of base64 that can safely be used in URLs and filenames
1411        return this._addCheck({
1412            kind: "base64url",
1413            ...errorUtil.errToObj(message),
1414        });
1415    }
1416    jwt(options) {
1417        return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1418    }
1419    ip(options) {
1420        return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1421    }
1422    cidr(options) {
1423        return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1424    }
1425    datetime(options) {
1426        var _a, _b;
1427        if (typeof options === "string") {
1428            return this._addCheck({
1429                kind: "datetime",
1430                precision: null,
1431                offset: false,
1432                local: false,
1433                message: options,
1434            });
1435        }
1436        return this._addCheck({
1437            kind: "datetime",
1438            precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1439            offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1440            local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1441            ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1442        });
1443    }
1444    date(message) {
1445        return this._addCheck({ kind: "date", message });
1446    }
1447    time(options) {
1448        if (typeof options === "string") {
1449            return this._addCheck({
1450                kind: "time",
1451                precision: null,
1452                message: options,
1453            });
1454        }
1455        return this._addCheck({
1456            kind: "time",
1457            precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1458            ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1459        });
1460    }
1461    duration(message) {
1462        return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1463    }
1464    regex(regex, message) {
1465        return this._addCheck({
1466            kind: "regex",
1467            regex: regex,
1468            ...errorUtil.errToObj(message),
1469        });
1470    }
1471    includes(value, options) {
1472        return this._addCheck({
1473            kind: "includes",
1474            value: value,
1475            position: options === null || options === void 0 ? void 0 : options.position,
1476            ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1477        });
1478    }
1479    startsWith(value, message) {
1480        return this._addCheck({
1481            kind: "startsWith",
1482            value: value,
1483            ...errorUtil.errToObj(message),
1484        });
1485    }
1486    endsWith(value, message) {
1487        return this._addCheck({
1488            kind: "endsWith",
1489            value: value,
1490            ...errorUtil.errToObj(message),
1491        });
1492    }
1493    min(minLength, message) {
1494        return this._addCheck({
1495            kind: "min",
1496            value: minLength,
1497            ...errorUtil.errToObj(message),
1498        });
1499    }
1500    max(maxLength, message) {
1501        return this._addCheck({
1502            kind: "max",
1503            value: maxLength,
1504            ...errorUtil.errToObj(message),
1505        });
1506    }
1507    length(len, message) {
1508        return this._addCheck({
1509            kind: "length",
1510            value: len,
1511            ...errorUtil.errToObj(message),
1512        });
1513    }
1514    /**
1515     * Equivalent to `.min(1)`
1516     */
1517    nonempty(message) {
1518        return this.min(1, errorUtil.errToObj(message));
1519    }
1520    trim() {
1521        return new ZodString({
1522            ...this._def,
1523            checks: [...this._def.checks, { kind: "trim" }],
1524        });
1525    }
1526    toLowerCase() {
1527        return new ZodString({
1528            ...this._def,
1529            checks: [...this._def.checks, { kind: "toLowerCase" }],
1530        });
1531    }
1532    toUpperCase() {
1533        return new ZodString({
1534            ...this._def,
1535            checks: [...this._def.checks, { kind: "toUpperCase" }],
1536        });
1537    }
1538    get isDatetime() {
1539        return !!this._def.checks.find((ch) => ch.kind === "datetime");
1540    }
1541    get isDate() {
1542        return !!this._def.checks.find((ch) => ch.kind === "date");
1543    }
1544    get isTime() {
1545        return !!this._def.checks.find((ch) => ch.kind === "time");
1546    }
1547    get isDuration() {
1548        return !!this._def.checks.find((ch) => ch.kind === "duration");
1549    }
1550    get isEmail() {
1551        return !!this._def.checks.find((ch) => ch.kind === "email");
1552    }
1553    get isURL() {
1554        return !!this._def.checks.find((ch) => ch.kind === "url");
1555    }
1556    get isEmoji() {
1557        return !!this._def.checks.find((ch) => ch.kind === "emoji");
1558    }
1559    get isUUID() {
1560        return !!this._def.checks.find((ch) => ch.kind === "uuid");
1561    }
1562    get isNANOID() {
1563        return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1564    }
1565    get isCUID() {
1566        return !!this._def.checks.find((ch) => ch.kind === "cuid");
1567    }
1568    get isCUID2() {
1569        return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1570    }
1571    get isULID() {
1572        return !!this._def.checks.find((ch) => ch.kind === "ulid");
1573    }
1574    get isIP() {
1575        return !!this._def.checks.find((ch) => ch.kind === "ip");
1576    }
1577    get isCIDR() {
1578        return !!this._def.checks.find((ch) => ch.kind === "cidr");
1579    }
1580    get isBase64() {
1581        return !!this._def.checks.find((ch) => ch.kind === "base64");
1582    }
1583    get isBase64url() {
1584        // base64url encoding is a modification of base64 that can safely be used in URLs and filenames
1585        return !!this._def.checks.find((ch) => ch.kind === "base64url");
1586    }
1587    get minLength() {
1588        let min = null;
1589        for (const ch of this._def.checks) {
1590            if (ch.kind === "min") {
1591                if (min === null || ch.value > min)
1592                    min = ch.value;
1593            }
1594        }
1595        return min;
1596    }
1597    get maxLength() {
1598        let max = null;
1599        for (const ch of this._def.checks) {
1600            if (ch.kind === "max") {
1601                if (max === null || ch.value < max)
1602                    max = ch.value;
1603            }
1604        }
1605        return max;
1606    }
1607}
1608ZodString.create = (params) => {
1609    var _a;
1610    return new ZodString({
1611        checks: [],
1612        typeName: ZodFirstPartyTypeKind.ZodString,
1613        coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1614        ...processCreateParams(params),
1615    });
1616};
1617// https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
1618function floatSafeRemainder(val, step) {
1619    const valDecCount = (val.toString().split(".")[1] || "").length;
1620    const stepDecCount = (step.toString().split(".")[1] || "").length;
1621    const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1622    const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
1623    const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1624    return (valInt % stepInt) / Math.pow(10, decCount);
1625}
1626class ZodNumber extends ZodType {
1627    constructor() {
1628        super(...arguments);
1629        this.min = this.gte;
1630        this.max = this.lte;
1631        this.step = this.multipleOf;
1632    }
1633    _parse(input) {
1634        if (this._def.coerce) {
1635            input.data = Number(input.data);
1636        }
1637        const parsedType = this._getType(input);
1638        if (parsedType !== ZodParsedType.number) {
1639            const ctx = this._getOrReturnCtx(input);
1640            addIssueToContext(ctx, {
1641                code: ZodIssueCode.invalid_type,
1642                expected: ZodParsedType.number,
1643                received: ctx.parsedType,
1644            });
1645            return INVALID;
1646        }
1647        let ctx = undefined;
1648        const status = new ParseStatus();
1649        for (const check of this._def.checks) {
1650            if (check.kind === "int") {
1651                if (!util.isInteger(input.data)) {
1652                    ctx = this._getOrReturnCtx(input, ctx);
1653                    addIssueToContext(ctx, {
1654                        code: ZodIssueCode.invalid_type,
1655                        expected: "integer",
1656                        received: "float",
1657                        message: check.message,
1658                    });
1659                    status.dirty();
1660                }
1661            }
1662            else if (check.kind === "min") {
1663                const tooSmall = check.inclusive
1664                    ? input.data < check.value
1665                    : input.data <= check.value;
1666                if (tooSmall) {
1667                    ctx = this._getOrReturnCtx(input, ctx);
1668                    addIssueToContext(ctx, {
1669                        code: ZodIssueCode.too_small,
1670                        minimum: check.value,
1671                        type: "number",
1672                        inclusive: check.inclusive,
1673                        exact: false,
1674                        message: check.message,
1675                    });
1676                    status.dirty();
1677                }
1678            }
1679            else if (check.kind === "max") {
1680                const tooBig = check.inclusive
1681                    ? input.data > check.value
1682                    : input.data >= check.value;
1683                if (tooBig) {
1684                    ctx = this._getOrReturnCtx(input, ctx);
1685                    addIssueToContext(ctx, {
1686                        code: ZodIssueCode.too_big,
1687                        maximum: check.value,
1688                        type: "number",
1689                        inclusive: check.inclusive,
1690                        exact: false,
1691                        message: check.message,
1692                    });
1693                    status.dirty();
1694                }
1695            }
1696            else if (check.kind === "multipleOf") {
1697                if (floatSafeRemainder(input.data, check.value) !== 0) {
1698                    ctx = this._getOrReturnCtx(input, ctx);
1699                    addIssueToContext(ctx, {
1700                        code: ZodIssueCode.not_multiple_of,
1701                        multipleOf: check.value,
1702                        message: check.message,
1703                    });
1704                    status.dirty();
1705                }
1706            }
1707            else if (check.kind === "finite") {
1708                if (!Number.isFinite(input.data)) {
1709                    ctx = this._getOrReturnCtx(input, ctx);
1710                    addIssueToContext(ctx, {
1711                        code: ZodIssueCode.not_finite,
1712                        message: check.message,
1713                    });
1714                    status.dirty();
1715                }
1716            }
1717            else {
1718                util.assertNever(check);
1719            }
1720        }
1721        return { status: status.value, value: input.data };
1722    }
1723    gte(value, message) {
1724        return this.setLimit("min", value, true, errorUtil.toString(message));
1725    }
1726    gt(value, message) {
1727        return this.setLimit("min", value, false, errorUtil.toString(message));
1728    }
1729    lte(value, message) {
1730        return this.setLimit("max", value, true, errorUtil.toString(message));
1731    }
1732    lt(value, message) {
1733        return this.setLimit("max", value, false, errorUtil.toString(message));
1734    }
1735    setLimit(kind, value, inclusive, message) {
1736        return new ZodNumber({
1737            ...this._def,
1738            checks: [
1739                ...this._def.checks,
1740                {
1741                    kind,
1742                    value,
1743                    inclusive,
1744                    message: errorUtil.toString(message),
1745                },
1746            ],
1747        });
1748    }
1749    _addCheck(check) {
1750        return new ZodNumber({
1751            ...this._def,
1752            checks: [...this._def.checks, check],
1753        });
1754    }
1755    int(message) {
1756        return this._addCheck({
1757            kind: "int",
1758            message: errorUtil.toString(message),
1759        });
1760    }
1761    positive(message) {
1762        return this._addCheck({
1763            kind: "min",
1764            value: 0,
1765            inclusive: false,
1766            message: errorUtil.toString(message),
1767        });
1768    }
1769    negative(message) {
1770        return this._addCheck({
1771            kind: "max",
1772            value: 0,
1773            inclusive: false,
1774            message: errorUtil.toString(message),
1775        });
1776    }
1777    nonpositive(message) {
1778        return this._addCheck({
1779            kind: "max",
1780            value: 0,
1781            inclusive: true,
1782            message: errorUtil.toString(message),
1783        });
1784    }
1785    nonnegative(message) {
1786        return this._addCheck({
1787            kind: "min",
1788            value: 0,
1789            inclusive: true,
1790            message: errorUtil.toString(message),
1791        });
1792    }
1793    multipleOf(value, message) {
1794        return this._addCheck({
1795            kind: "multipleOf",
1796            value: value,
1797            message: errorUtil.toString(message),
1798        });
1799    }
1800    finite(message) {
1801        return this._addCheck({
1802            kind: "finite",
1803            message: errorUtil.toString(message),
1804        });
1805    }
1806    safe(message) {
1807        return this._addCheck({
1808            kind: "min",
1809            inclusive: true,
1810            value: Number.MIN_SAFE_INTEGER,
1811            message: errorUtil.toString(message),
1812        })._addCheck({
1813            kind: "max",
1814            inclusive: true,
1815            value: Number.MAX_SAFE_INTEGER,
1816            message: errorUtil.toString(message),
1817        });
1818    }
1819    get minValue() {
1820        let min = null;
1821        for (const ch of this._def.checks) {
1822            if (ch.kind === "min") {
1823                if (min === null || ch.value > min)
1824                    min = ch.value;
1825            }
1826        }
1827        return min;
1828    }
1829    get maxValue() {
1830        let max = null;
1831        for (const ch of this._def.checks) {
1832            if (ch.kind === "max") {
1833                if (max === null || ch.value < max)
1834                    max = ch.value;
1835            }
1836        }
1837        return max;
1838    }
1839    get isInt() {
1840        return !!this._def.checks.find((ch) => ch.kind === "int" ||
1841            (ch.kind === "multipleOf" && util.isInteger(ch.value)));
1842    }
1843    get isFinite() {
1844        let max = null, min = null;
1845        for (const ch of this._def.checks) {
1846            if (ch.kind === "finite" ||
1847                ch.kind === "int" ||
1848                ch.kind === "multipleOf") {
1849                return true;
1850            }
1851            else if (ch.kind === "min") {
1852                if (min === null || ch.value > min)
1853                    min = ch.value;
1854            }
1855            else if (ch.kind === "max") {
1856                if (max === null || ch.value < max)
1857                    max = ch.value;
1858            }
1859        }
1860        return Number.isFinite(min) && Number.isFinite(max);
1861    }
1862}
1863ZodNumber.create = (params) => {
1864    return new ZodNumber({
1865        checks: [],
1866        typeName: ZodFirstPartyTypeKind.ZodNumber,
1867        coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1868        ...processCreateParams(params),
1869    });
1870};
1871class ZodBigInt extends ZodType {
1872    constructor() {
1873        super(...arguments);
1874        this.min = this.gte;
1875        this.max = this.lte;
1876    }
1877    _parse(input) {
1878        if (this._def.coerce) {
1879            try {
1880                input.data = BigInt(input.data);
1881            }
1882            catch (_a) {
1883                return this._getInvalidInput(input);
1884            }
1885        }
1886        const parsedType = this._getType(input);
1887        if (parsedType !== ZodParsedType.bigint) {
1888            return this._getInvalidInput(input);
1889        }
1890        let ctx = undefined;
1891        const status = new ParseStatus();
1892        for (const check of this._def.checks) {
1893            if (check.kind === "min") {
1894                const tooSmall = check.inclusive
1895                    ? input.data < check.value
1896                    : input.data <= check.value;
1897                if (tooSmall) {
1898                    ctx = this._getOrReturnCtx(input, ctx);
1899                    addIssueToContext(ctx, {
1900                        code: ZodIssueCode.too_small,
1901                        type: "bigint",
1902                        minimum: check.value,
1903                        inclusive: check.inclusive,
1904                        message: check.message,
1905                    });
1906                    status.dirty();
1907                }
1908            }
1909            else if (check.kind === "max") {
1910                const tooBig = check.inclusive
1911                    ? input.data > check.value
1912                    : input.data >= check.value;
1913                if (tooBig) {
1914                    ctx = this._getOrReturnCtx(input, ctx);
1915                    addIssueToContext(ctx, {
1916                        code: ZodIssueCode.too_big,
1917                        type: "bigint",
1918                        maximum: check.value,
1919                        inclusive: check.inclusive,
1920                        message: check.message,
1921                    });
1922                    status.dirty();
1923                }
1924            }
1925            else if (check.kind === "multipleOf") {
1926                if (input.data % check.value !== BigInt(0)) {
1927                    ctx = this._getOrReturnCtx(input, ctx);
1928                    addIssueToContext(ctx, {
1929                        code: ZodIssueCode.not_multiple_of,
1930                        multipleOf: check.value,
1931                        message: check.message,
1932                    });
1933                    status.dirty();
1934                }
1935            }
1936            else {
1937                util.assertNever(check);
1938            }
1939        }
1940        return { status: status.value, value: input.data };
1941    }
1942    _getInvalidInput(input) {
1943        const ctx = this._getOrReturnCtx(input);
1944        addIssueToContext(ctx, {
1945            code: ZodIssueCode.invalid_type,
1946            expected: ZodParsedType.bigint,
1947            received: ctx.parsedType,
1948        });
1949        return INVALID;
1950    }
1951    gte(value, message) {
1952        return this.setLimit("min", value, true, errorUtil.toString(message));
1953    }
1954    gt(value, message) {
1955        return this.setLimit("min", value, false, errorUtil.toString(message));
1956    }
1957    lte(value, message) {
1958        return this.setLimit("max", value, true, errorUtil.toString(message));
1959    }
1960    lt(value, message) {
1961        return this.setLimit("max", value, false, errorUtil.toString(message));
1962    }
1963    setLimit(kind, value, inclusive, message) {
1964        return new ZodBigInt({
1965            ...this._def,
1966            checks: [
1967                ...this._def.checks,
1968                {
1969                    kind,
1970                    value,
1971                    inclusive,
1972                    message: errorUtil.toString(message),
1973                },
1974            ],
1975        });
1976    }
1977    _addCheck(check) {
1978        return new ZodBigInt({
1979            ...this._def,
1980            checks: [...this._def.checks, check],
1981        });
1982    }
1983    positive(message) {
1984        return this._addCheck({
1985            kind: "min",
1986            value: BigInt(0),
1987            inclusive: false,
1988            message: errorUtil.toString(message),
1989        });
1990    }
1991    negative(message) {
1992        return this._addCheck({
1993            kind: "max",
1994            value: BigInt(0),
1995            inclusive: false,
1996            message: errorUtil.toString(message),
1997        });
1998    }
1999    nonpositive(message) {
2000        return this._addCheck({
2001            kind: "max",
2002            value: BigInt(0),
2003            inclusive: true,
2004            message: errorUtil.toString(message),
2005        });
2006    }
2007    nonnegative(message) {
2008        return this._addCheck({
2009            kind: "min",
2010            value: BigInt(0),
2011            inclusive: true,
2012            message: errorUtil.toString(message),
2013        });
2014    }
2015    multipleOf(value, message) {
2016        return this._addCheck({
2017            kind: "multipleOf",
2018            value,
2019            message: errorUtil.toString(message),
2020        });
2021    }
2022    get minValue() {
2023        let min = null;
2024        for (const ch of this._def.checks) {
2025            if (ch.kind === "min") {
2026                if (min === null || ch.value > min)
2027                    min = ch.value;
2028            }
2029        }
2030        return min;
2031    }
2032    get maxValue() {
2033        let max = null;
2034        for (const ch of this._def.checks) {
2035            if (ch.kind === "max") {
2036                if (max === null || ch.value < max)
2037                    max = ch.value;
2038            }
2039        }
2040        return max;
2041    }
2042}
2043ZodBigInt.create = (params) => {
2044    var _a;
2045    return new ZodBigInt({
2046        checks: [],
2047        typeName: ZodFirstPartyTypeKind.ZodBigInt,
2048        coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2049        ...processCreateParams(params),
2050    });
2051};
2052class ZodBoolean extends ZodType {
2053    _parse(input) {
2054        if (this._def.coerce) {
2055            input.data = Boolean(input.data);
2056        }
2057        const parsedType = this._getType(input);
2058        if (parsedType !== ZodParsedType.boolean) {
2059            const ctx = this._getOrReturnCtx(input);
2060            addIssueToContext(ctx, {
2061                code: ZodIssueCode.invalid_type,
2062                expected: ZodParsedType.boolean,
2063                received: ctx.parsedType,
2064            });
2065            return INVALID;
2066        }
2067        return OK(input.data);
2068    }
2069}
2070ZodBoolean.create = (params) => {
2071    return new ZodBoolean({
2072        typeName: ZodFirstPartyTypeKind.ZodBoolean,
2073        coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2074        ...processCreateParams(params),
2075    });
2076};
2077class ZodDate extends ZodType {
2078    _parse(input) {
2079        if (this._def.coerce) {
2080            input.data = new Date(input.data);
2081        }
2082        const parsedType = this._getType(input);
2083        if (parsedType !== ZodParsedType.date) {
2084            const ctx = this._getOrReturnCtx(input);
2085            addIssueToContext(ctx, {
2086                code: ZodIssueCode.invalid_type,
2087                expected: ZodParsedType.date,
2088                received: ctx.parsedType,
2089            });
2090            return INVALID;
2091        }
2092        if (isNaN(input.data.getTime())) {
2093            const ctx = this._getOrReturnCtx(input);
2094            addIssueToContext(ctx, {
2095                code: ZodIssueCode.invalid_date,
2096            });
2097            return INVALID;
2098        }
2099        const status = new ParseStatus();
2100        let ctx = undefined;
2101        for (const check of this._def.checks) {
2102            if (check.kind === "min") {
2103                if (input.data.getTime() < check.value) {
2104                    ctx = this._getOrReturnCtx(input, ctx);
2105                    addIssueToContext(ctx, {
2106                        code: ZodIssueCode.too_small,
2107                        message: check.message,
2108                        inclusive: true,
2109                        exact: false,
2110                        minimum: check.value,
2111                        type: "date",
2112                    });
2113                    status.dirty();
2114                }
2115            }
2116            else if (check.kind === "max") {
2117                if (input.data.getTime() > check.value) {
2118                    ctx = this._getOrReturnCtx(input, ctx);
2119                    addIssueToContext(ctx, {
2120                        code: ZodIssueCode.too_big,
2121                        message: check.message,
2122                        inclusive: true,
2123                        exact: false,
2124                        maximum: check.value,
2125                        type: "date",
2126                    });
2127                    status.dirty();
2128                }
2129            }
2130            else {
2131                util.assertNever(check);
2132            }
2133        }
2134        return {
2135            status: status.value,
2136            value: new Date(input.data.getTime()),
2137        };
2138    }
2139    _addCheck(check) {
2140        return new ZodDate({
2141            ...this._def,
2142            checks: [...this._def.checks, check],
2143        });
2144    }
2145    min(minDate, message) {
2146        return this._addCheck({
2147            kind: "min",
2148            value: minDate.getTime(),
2149            message: errorUtil.toString(message),
2150        });
2151    }
2152    max(maxDate, message) {
2153        return this._addCheck({
2154            kind: "max",
2155            value: maxDate.getTime(),
2156            message: errorUtil.toString(message),
2157        });
2158    }
2159    get minDate() {
2160        let min = null;
2161        for (const ch of this._def.checks) {
2162            if (ch.kind === "min") {
2163                if (min === null || ch.value > min)
2164                    min = ch.value;
2165            }
2166        }
2167        return min != null ? new Date(min) : null;
2168    }
2169    get maxDate() {
2170        let max = null;
2171        for (const ch of this._def.checks) {
2172            if (ch.kind === "max") {
2173                if (max === null || ch.value < max)
2174                    max = ch.value;
2175            }
2176        }
2177        return max != null ? new Date(max) : null;
2178    }
2179}
2180ZodDate.create = (params) => {
2181    return new ZodDate({
2182        checks: [],
2183        coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2184        typeName: ZodFirstPartyTypeKind.ZodDate,
2185        ...processCreateParams(params),
2186    });
2187};
2188class ZodSymbol extends ZodType {
2189    _parse(input) {
2190        const parsedType = this._getType(input);
2191        if (parsedType !== ZodParsedType.symbol) {
2192            const ctx = this._getOrReturnCtx(input);
2193            addIssueToContext(ctx, {
2194                code: ZodIssueCode.invalid_type,
2195                expected: ZodParsedType.symbol,
2196                received: ctx.parsedType,
2197            });
2198            return INVALID;
2199        }
2200        return OK(input.data);
2201    }
2202}
2203ZodSymbol.create = (params) => {
2204    return new ZodSymbol({
2205        typeName: ZodFirstPartyTypeKind.ZodSymbol,
2206        ...processCreateParams(params),
2207    });
2208};
2209class ZodUndefined extends ZodType {
2210    _parse(input) {
2211        const parsedType = this._getType(input);
2212        if (parsedType !== ZodParsedType.undefined) {
2213            const ctx = this._getOrReturnCtx(input);
2214            addIssueToContext(ctx, {
2215                code: ZodIssueCode.invalid_type,
2216                expected: ZodParsedType.undefined,
2217                received: ctx.parsedType,
2218            });
2219            return INVALID;
2220        }
2221        return OK(input.data);
2222    }
2223}
2224ZodUndefined.create = (params) => {
2225    return new ZodUndefined({
2226        typeName: ZodFirstPartyTypeKind.ZodUndefined,
2227        ...processCreateParams(params),
2228    });
2229};
2230class ZodNull extends ZodType {
2231    _parse(input) {
2232        const parsedType = this._getType(input);
2233        if (parsedType !== ZodParsedType.null) {
2234            const ctx = this._getOrReturnCtx(input);
2235            addIssueToContext(ctx, {
2236                code: ZodIssueCode.invalid_type,
2237                expected: ZodParsedType.null,
2238                received: ctx.parsedType,
2239            });
2240            return INVALID;
2241        }
2242        return OK(input.data);
2243    }
2244}
2245ZodNull.create = (params) => {
2246    return new ZodNull({
2247        typeName: ZodFirstPartyTypeKind.ZodNull,
2248        ...processCreateParams(params),
2249    });
2250};
2251class ZodAny extends ZodType {
2252    constructor() {
2253        super(...arguments);
2254        // to prevent instances of other classes from extending ZodAny. this causes issues with catchall in ZodObject.
2255        this._any = true;
2256    }
2257    _parse(input) {
2258        return OK(input.data);
2259    }
2260}
2261ZodAny.create = (params) => {
2262    return new ZodAny({
2263        typeName: ZodFirstPartyTypeKind.ZodAny,
2264        ...processCreateParams(params),
2265    });
2266};
2267class ZodUnknown extends ZodType {
2268    constructor() {
2269        super(...arguments);
2270        // required
2271        this._unknown = true;
2272    }
2273    _parse(input) {
2274        return OK(input.data);
2275    }
2276}
2277ZodUnknown.create = (params) => {
2278    return new ZodUnknown({
2279        typeName: ZodFirstPartyTypeKind.ZodUnknown,
2280        ...processCreateParams(params),
2281    });
2282};
2283class ZodNever extends ZodType {
2284    _parse(input) {
2285        const ctx = this._getOrReturnCtx(input);
2286        addIssueToContext(ctx, {
2287            code: ZodIssueCode.invalid_type,
2288            expected: ZodParsedType.never,
2289            received: ctx.parsedType,
2290        });
2291        return INVALID;
2292    }
2293}
2294ZodNever.create = (params) => {
2295    return new ZodNever({
2296        typeName: ZodFirstPartyTypeKind.ZodNever,
2297        ...processCreateParams(params),
2298    });
2299};
2300class ZodVoid extends ZodType {
2301    _parse(input) {
2302        const parsedType = this._getType(input);
2303        if (parsedType !== ZodParsedType.undefined) {
2304            const ctx = this._getOrReturnCtx(input);
2305            addIssueToContext(ctx, {
2306                code: ZodIssueCode.invalid_type,
2307                expected: ZodParsedType.void,
2308                received: ctx.parsedType,
2309            });
2310            return INVALID;
2311        }
2312        return OK(input.data);
2313    }
2314}
2315ZodVoid.create = (params) => {
2316    return new ZodVoid({
2317        typeName: ZodFirstPartyTypeKind.ZodVoid,
2318        ...processCreateParams(params),
2319    });
2320};
2321class ZodArray extends ZodType {
2322    _parse(input) {
2323        const { ctx, status } = this._processInputParams(input);
2324        const def = this._def;
2325        if (ctx.parsedType !== ZodParsedType.array) {
2326            addIssueToContext(ctx, {
2327                code: ZodIssueCode.invalid_type,
2328                expected: ZodParsedType.array,
2329                received: ctx.parsedType,
2330            });
2331            return INVALID;
2332        }
2333        if (def.exactLength !== null) {
2334            const tooBig = ctx.data.length > def.exactLength.value;
2335            const tooSmall = ctx.data.length < def.exactLength.value;
2336            if (tooBig || tooSmall) {
2337                addIssueToContext(ctx, {
2338                    code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2339                    minimum: (tooSmall ? def.exactLength.value : undefined),
2340                    maximum: (tooBig ? def.exactLength.value : undefined),
2341                    type: "array",
2342                    inclusive: true,
2343                    exact: true,
2344                    message: def.exactLength.message,
2345                });
2346                status.dirty();
2347            }
2348        }
2349        if (def.minLength !== null) {
2350            if (ctx.data.length < def.minLength.value) {
2351                addIssueToContext(ctx, {
2352                    code: ZodIssueCode.too_small,
2353                    minimum: def.minLength.value,
2354                    type: "array",
2355                    inclusive: true,
2356                    exact: false,
2357                    message: def.minLength.message,
2358                });
2359                status.dirty();
2360            }
2361        }
2362        if (def.maxLength !== null) {
2363            if (ctx.data.length > def.maxLength.value) {
2364                addIssueToContext(ctx, {
2365                    code: ZodIssueCode.too_big,
2366                    maximum: def.maxLength.value,
2367                    type: "array",
2368                    inclusive: true,
2369                    exact: false,
2370                    message: def.maxLength.message,
2371                });
2372                status.dirty();
2373            }
2374        }
2375        if (ctx.common.async) {
2376            return Promise.all([...ctx.data].map((item, i) => {
2377                return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2378            })).then((result) => {
2379                return ParseStatus.mergeArray(status, result);
2380            });
2381        }
2382        const result = [...ctx.data].map((item, i) => {
2383            return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2384        });
2385        return ParseStatus.mergeArray(status, result);
2386    }
2387    get element() {
2388        return this._def.type;
2389    }
2390    min(minLength, message) {
2391        return new ZodArray({
2392            ...this._def,
2393            minLength: { value: minLength, message: errorUtil.toString(message) },
2394        });
2395    }
2396    max(maxLength, message) {
2397        return new ZodArray({
2398            ...this._def,
2399            maxLength: { value: maxLength, message: errorUtil.toString(message) },
2400        });
2401    }
2402    length(len, message) {
2403        return new ZodArray({
2404            ...this._def,
2405            exactLength: { value: len, message: errorUtil.toString(message) },
2406        });
2407    }
2408    nonempty(message) {
2409        return this.min(1, message);
2410    }
2411}
2412ZodArray.create = (schema, params) => {
2413    return new ZodArray({
2414        type: schema,
2415        minLength: null,
2416        maxLength: null,
2417        exactLength: null,
2418        typeName: ZodFirstPartyTypeKind.ZodArray,
2419        ...processCreateParams(params),
2420    });
2421};
2422function deepPartialify(schema) {
2423    if (schema instanceof ZodObject) {
2424        const newShape = {};
2425        for (const key in schema.shape) {
2426            const fieldSchema = schema.shape[key];
2427            newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2428        }
2429        return new ZodObject({
2430            ...schema._def,
2431            shape: () => newShape,
2432        });
2433    }
2434    else if (schema instanceof ZodArray) {
2435        return new ZodArray({
2436            ...schema._def,
2437            type: deepPartialify(schema.element),
2438        });
2439    }
2440    else if (schema instanceof ZodOptional) {
2441        return ZodOptional.create(deepPartialify(schema.unwrap()));
2442    }
2443    else if (schema instanceof ZodNullable) {
2444        return ZodNullable.create(deepPartialify(schema.unwrap()));
2445    }
2446    else if (schema instanceof ZodTuple) {
2447        return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2448    }
2449    else {
2450        return schema;
2451    }
2452}
2453class ZodObject extends ZodType {
2454    constructor() {
2455        super(...arguments);
2456        this._cached = null;
2457        /**
2458         * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
2459         * If you want to pass through unknown properties, use `.passthrough()` instead.
2460         */
2461        this.nonstrict = this.passthrough;
2462        // extend<
2463        //   Augmentation extends ZodRawShape,
2464        //   NewOutput extends util.flatten<{
2465        //     [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2466        //       ? Augmentation[k]["_output"]
2467        //       : k extends keyof Output
2468        //       ? Output[k]
2469        //       : never;
2470        //   }>,
2471        //   NewInput extends util.flatten<{
2472        //     [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2473        //       ? Augmentation[k]["_input"]
2474        //       : k extends keyof Input
2475        //       ? Input[k]
2476        //       : never;
2477        //   }>
2478        // >(
2479        //   augmentation: Augmentation
2480        // ): ZodObject<
2481        //   extendShape<T, Augmentation>,
2482        //   UnknownKeys,
2483        //   Catchall,
2484        //   NewOutput,
2485        //   NewInput
2486        // > {
2487        //   return new ZodObject({
2488        //     ...this._def,
2489        //     shape: () => ({
2490        //       ...this._def.shape(),
2491        //       ...augmentation,
2492        //     }),
2493        //   }) as any;
2494        // }
2495        /**
2496         * @deprecated Use `.extend` instead
2497         *  */
2498        this.augment = this.extend;
2499    }
2500    _getCached() {
2501        if (this._cached !== null)
2502            return this._cached;
2503        const shape = this._def.shape();
2504        const keys = util.objectKeys(shape);
2505        return (this._cached = { shape, keys });
2506    }
2507    _parse(input) {
2508        const parsedType = this._getType(input);
2509        if (parsedType !== ZodParsedType.object) {
2510            const ctx = this._getOrReturnCtx(input);
2511            addIssueToContext(ctx, {
2512                code: ZodIssueCode.invalid_type,
2513                expected: ZodParsedType.object,
2514                received: ctx.parsedType,
2515            });
2516            return INVALID;
2517        }
2518        const { status, ctx } = this._processInputParams(input);
2519        const { shape, keys: shapeKeys } = this._getCached();
2520        const extraKeys = [];
2521        if (!(this._def.catchall instanceof ZodNever &&
2522            this._def.unknownKeys === "strip")) {
2523            for (const key in ctx.data) {
2524                if (!shapeKeys.includes(key)) {
2525                    extraKeys.push(key);
2526                }
2527            }
2528        }
2529        const pairs = [];
2530        for (const key of shapeKeys) {
2531            const keyValidator = shape[key];
2532            const value = ctx.data[key];
2533            pairs.push({
2534                key: { status: "valid", value: key },
2535                value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2536                alwaysSet: key in ctx.data,
2537            });
2538        }
2539        if (this._def.catchall instanceof ZodNever) {
2540            const unknownKeys = this._def.unknownKeys;
2541            if (unknownKeys === "passthrough") {
2542                for (const key of extraKeys) {
2543                    pairs.push({
2544                        key: { status: "valid", value: key },
2545                        value: { status: "valid", value: ctx.data[key] },
2546                    });
2547                }
2548            }
2549            else if (unknownKeys === "strict") {
2550                if (extraKeys.length > 0) {
2551                    addIssueToContext(ctx, {
2552                        code: ZodIssueCode.unrecognized_keys,
2553                        keys: extraKeys,
2554                    });
2555                    status.dirty();
2556                }
2557            }
2558            else if (unknownKeys === "strip") ;
2559            else {
2560                throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2561            }
2562        }
2563        else {
2564            // run catchall validation
2565            const catchall = this._def.catchall;
2566            for (const key of extraKeys) {
2567                const value = ctx.data[key];
2568                pairs.push({
2569                    key: { status: "valid", value: key },
2570                    value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key) //, ctx.child(key), value, getParsedType(value)
2571                    ),
2572                    alwaysSet: key in ctx.data,
2573                });
2574            }
2575        }
2576        if (ctx.common.async) {
2577            return Promise.resolve()
2578                .then(async () => {
2579                const syncPairs = [];
2580                for (const pair of pairs) {
2581                    const key = await pair.key;
2582                    const value = await pair.value;
2583                    syncPairs.push({
2584                        key,
2585                        value,
2586                        alwaysSet: pair.alwaysSet,
2587                    });
2588                }
2589                return syncPairs;
2590            })
2591                .then((syncPairs) => {
2592                return ParseStatus.mergeObjectSync(status, syncPairs);
2593            });
2594        }
2595        else {
2596            return ParseStatus.mergeObjectSync(status, pairs);
2597        }
2598    }
2599    get shape() {
2600        return this._def.shape();
2601    }
2602    strict(message) {
2603        errorUtil.errToObj;
2604        return new ZodObject({
2605            ...this._def,
2606            unknownKeys: "strict",
2607            ...(message !== undefined
2608                ? {
2609                    errorMap: (issue, ctx) => {
2610                        var _a, _b, _c, _d;
2611                        const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2612                        if (issue.code === "unrecognized_keys")
2613                            return {
2614                                message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError,
2615                            };
2616                        return {
2617                            message: defaultError,
2618                        };
2619                    },
2620                }
2621                : {}),
2622        });
2623    }
2624    strip() {
2625        return new ZodObject({
2626            ...this._def,
2627            unknownKeys: "strip",
2628        });
2629    }
2630    passthrough() {
2631        return new ZodObject({
2632            ...this._def,
2633            unknownKeys: "passthrough",
2634        });
2635    }
2636    // const AugmentFactory =
2637    //   <Def extends ZodObjectDef>(def: Def) =>
2638    //   <Augmentation extends ZodRawShape>(
2639    //     augmentation: Augmentation
2640    //   ): ZodObject<
2641    //     extendShape<ReturnType<Def["shape"]>, Augmentation>,
2642    //     Def["unknownKeys"],
2643    //     Def["catchall"]
2644    //   > => {
2645    //     return new ZodObject({
2646    //       ...def,
2647    //       shape: () => ({
2648    //         ...def.shape(),
2649    //         ...augmentation,
2650    //       }),
2651    //     }) as any;
2652    //   };
2653    extend(augmentation) {
2654        return new ZodObject({
2655            ...this._def,
2656            shape: () => ({
2657                ...this._def.shape(),
2658                ...augmentation,
2659            }),
2660        });
2661    }
2662    /**
2663     * Prior to [email protected] there was a bug in the
2664     * inferred type of merged objects. Please
2665     * upgrade if you are experiencing issues.
2666     */
2667    merge(merging) {
2668        const merged = new ZodObject({
2669            unknownKeys: merging._def.unknownKeys,
2670            catchall: merging._def.catchall,
2671            shape: () => ({
2672                ...this._def.shape(),
2673                ...merging._def.shape(),
2674            }),
2675            typeName: ZodFirstPartyTypeKind.ZodObject,
2676        });
2677        return merged;
2678    }
2679    // merge<
2680    //   Incoming extends AnyZodObject,
2681    //   Augmentation extends Incoming["shape"],
2682    //   NewOutput extends {
2683    //     [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2684    //       ? Augmentation[k]["_output"]
2685    //       : k extends keyof Output
2686    //       ? Output[k]
2687    //       : never;
2688    //   },
2689    //   NewInput extends {
2690    //     [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2691    //       ? Augmentation[k]["_input"]
2692    //       : k extends keyof Input
2693    //       ? Input[k]
2694    //       : never;
2695    //   }
2696    // >(
2697    //   merging: Incoming
2698    // ): ZodObject<
2699    //   extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2700    //   Incoming["_def"]["unknownKeys"],
2701    //   Incoming["_def"]["catchall"],
2702    //   NewOutput,
2703    //   NewInput
2704    // > {
2705    //   const merged: any = new ZodObject({
2706    //     unknownKeys: merging._def.unknownKeys,
2707    //     catchall: merging._def.catchall,
2708    //     shape: () =>
2709    //       objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2710    //     typeName: ZodFirstPartyTypeKind.ZodObject,
2711    //   }) as any;
2712    //   return merged;
2713    // }
2714    setKey(key, schema) {
2715        return this.augment({ [key]: schema });
2716    }
2717    // merge<Incoming extends AnyZodObject>(
2718    //   merging: Incoming
2719    // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2720    // ZodObject<
2721    //   extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2722    //   Incoming["_def"]["unknownKeys"],
2723    //   Incoming["_def"]["catchall"]
2724    // > {
2725    //   // const mergedShape = objectUtil.mergeShapes(
2726    //   //   this._def.shape(),
2727    //   //   merging._def.shape()
2728    //   // );
2729    //   const merged: any = new ZodObject({
2730    //     unknownKeys: merging._def.unknownKeys,
2731    //     catchall: merging._def.catchall,
2732    //     shape: () =>
2733    //       objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2734    //     typeName: ZodFirstPartyTypeKind.ZodObject,
2735    //   }) as any;
2736    //   return merged;
2737    // }
2738    catchall(index) {
2739        return new ZodObject({
2740            ...this._def,
2741            catchall: index,
2742        });
2743    }
2744    pick(mask) {
2745        const shape = {};
2746        util.objectKeys(mask).forEach((key) => {
2747            if (mask[key] && this.shape[key]) {
2748                shape[key] = this.shape[key];
2749            }
2750        });
2751        return new ZodObject({
2752            ...this._def,
2753            shape: () => shape,
2754        });
2755    }
2756    omit(mask) {
2757        const shape = {};
2758        util.objectKeys(this.shape).forEach((key) => {
2759            if (!mask[key]) {
2760                shape[key] = this.shape[key];
2761            }
2762        });
2763        return new ZodObject({
2764            ...this._def,
2765            shape: () => shape,
2766        });
2767    }
2768    /**
2769     * @deprecated
2770     */
2771    deepPartial() {
2772        return deepPartialify(this);
2773    }
2774    partial(mask) {
2775        const newShape = {};
2776        util.objectKeys(this.shape).forEach((key) => {
2777            const fieldSchema = this.shape[key];
2778            if (mask && !mask[key]) {
2779                newShape[key] = fieldSchema;
2780            }
2781            else {
2782                newShape[key] = fieldSchema.optional();
2783            }
2784        });
2785        return new ZodObject({
2786            ...this._def,
2787            shape: () => newShape,
2788        });
2789    }
2790    required(mask) {
2791        const newShape = {};
2792        util.objectKeys(this.shape).forEach((key) => {
2793            if (mask && !mask[key]) {
2794                newShape[key] = this.shape[key];
2795            }
2796            else {
2797                const fieldSchema = this.shape[key];
2798                let newField = fieldSchema;
2799                while (newField instanceof ZodOptional) {
2800                    newField = newField._def.innerType;
2801                }
2802                newShape[key] = newField;
2803            }
2804        });
2805        return new ZodObject({
2806            ...this._def,
2807            shape: () => newShape,
2808        });
2809    }
2810    keyof() {
2811        return createZodEnum(util.objectKeys(this.shape));
2812    }
2813}
2814ZodObject.create = (shape, params) => {
2815    return new ZodObject({
2816        shape: () => shape,
2817        unknownKeys: "strip",
2818        catchall: ZodNever.create(),
2819        typeName: ZodFirstPartyTypeKind.ZodObject,
2820        ...processCreateParams(params),
2821    });
2822};
2823ZodObject.strictCreate = (shape, params) => {
2824    return new ZodObject({
2825        shape: () => shape,
2826        unknownKeys: "strict",
2827        catchall: ZodNever.create(),
2828        typeName: ZodFirstPartyTypeKind.ZodObject,
2829        ...processCreateParams(params),
2830    });
2831};
2832ZodObject.lazycreate = (shape, params) => {
2833    return new ZodObject({
2834        shape,
2835        unknownKeys: "strip",
2836        catchall: ZodNever.create(),
2837        typeName: ZodFirstPartyTypeKind.ZodObject,
2838        ...processCreateParams(params),
2839    });
2840};
2841class ZodUnion extends ZodType {
2842    _parse(input) {
2843        const { ctx } = this._processInputParams(input);
2844        const options = this._def.options;
2845        function handleResults(results) {
2846            // return first issue-free validation if it exists
2847            for (const result of results) {
2848                if (result.result.status === "valid") {
2849                    return result.result;
2850                }
2851            }
2852            for (const result of results) {
2853                if (result.result.status === "dirty") {
2854                    // add issues from dirty option
2855                    ctx.common.issues.push(...result.ctx.common.issues);
2856                    return result.result;
2857                }
2858            }
2859            // return invalid
2860            const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2861            addIssueToContext(ctx, {
2862                code: ZodIssueCode.invalid_union,
2863                unionErrors,
2864            });
2865            return INVALID;
2866        }
2867        if (ctx.common.async) {
2868            return Promise.all(options.map(async (option) => {
2869                const childCtx = {
2870                    ...ctx,
2871                    common: {
2872                        ...ctx.common,
2873                        issues: [],
2874                    },
2875                    parent: null,
2876                };
2877                return {
2878                    result: await option._parseAsync({
2879                        data: ctx.data,
2880                        path: ctx.path,
2881                        parent: childCtx,
2882                    }),
2883                    ctx: childCtx,
2884                };
2885            })).then(handleResults);
2886        }
2887        else {
2888            let dirty = undefined;
2889            const issues = [];
2890            for (const option of options) {
2891                const childCtx = {
2892                    ...ctx,
2893                    common: {
2894                        ...ctx.common,
2895                        issues: [],
2896                    },
2897                    parent: null,
2898                };
2899                const result = option._parseSync({
2900                    data: ctx.data,
2901                    path: ctx.path,
2902                    parent: childCtx,
2903                });
2904                if (result.status === "valid") {
2905                    return result;
2906                }
2907                else if (result.status === "dirty" && !dirty) {
2908                    dirty = { result, ctx: childCtx };
2909                }
2910                if (childCtx.common.issues.length) {
2911                    issues.push(childCtx.common.issues);
2912                }
2913            }
2914            if (dirty) {
2915                ctx.common.issues.push(...dirty.ctx.common.issues);
2916                return dirty.result;
2917            }
2918            const unionErrors = issues.map((issues) => new ZodError(issues));
2919            addIssueToContext(ctx, {
2920                code: ZodIssueCode.invalid_union,
2921                unionErrors,
2922            });
2923            return INVALID;
2924        }
2925    }
2926    get options() {
2927        return this._def.options;
2928    }
2929}
2930ZodUnion.create = (types, params) => {
2931    return new ZodUnion({
2932        options: types,
2933        typeName: ZodFirstPartyTypeKind.ZodUnion,
2934        ...processCreateParams(params),
2935    });
2936};
2937/////////////////////////////////////////////////////
2938/////////////////////////////////////////////////////
2939//////////                                 //////////
2940//////////      ZodDiscriminatedUnion      //////////
2941//////////                                 //////////
2942/////////////////////////////////////////////////////
2943/////////////////////////////////////////////////////
2944const getDiscriminator = (type) => {
2945    if (type instanceof ZodLazy) {
2946        return getDiscriminator(type.schema);
2947    }
2948    else if (type instanceof ZodEffects) {
2949        return getDiscriminator(type.innerType());
2950    }
2951    else if (type instanceof ZodLiteral) {
2952        return [type.value];
2953    }
2954    else if (type instanceof ZodEnum) {
2955        return type.options;
2956    }
2957    else if (type instanceof ZodNativeEnum) {
2958        // eslint-disable-next-line ban/ban
2959        return util.objectValues(type.enum);
2960    }
2961    else if (type instanceof ZodDefault) {
2962        return getDiscriminator(type._def.innerType);
2963    }
2964    else if (type instanceof ZodUndefined) {
2965        return [undefined];
2966    }
2967    else if (type instanceof ZodNull) {
2968        return [null];
2969    }
2970    else if (type instanceof ZodOptional) {
2971        return [undefined, ...getDiscriminator(type.unwrap())];
2972    }
2973    else if (type instanceof ZodNullable) {
2974        return [null, ...getDiscriminator(type.unwrap())];
2975    }
2976    else if (type instanceof ZodBranded) {
2977        return getDiscriminator(type.unwrap());
2978    }
2979    else if (type instanceof ZodReadonly) {
2980        return getDiscriminator(type.unwrap());
2981    }
2982    else if (type instanceof ZodCatch) {
2983        return getDiscriminator(type._def.innerType);
2984    }
2985    else {
2986        return [];
2987    }
2988};
2989class ZodDiscriminatedUnion extends ZodType {
2990    _parse(input) {
2991        const { ctx } = this._processInputParams(input);
2992        if (ctx.parsedType !== ZodParsedType.object) {
2993            addIssueToContext(ctx, {
2994                code: ZodIssueCode.invalid_type,
2995                expected: ZodParsedType.object,
2996                received: ctx.parsedType,
2997            });
2998            return INVALID;
2999        }
3000        const discriminator = this.discriminator;
3001        const discriminatorValue = ctx.data[discriminator];
3002        const option = this.optionsMap.get(discriminatorValue);
3003        if (!option) {
3004            addIssueToContext(ctx, {
3005                code: ZodIssueCode.invalid_union_discriminator,
3006                options: Array.from(this.optionsMap.keys()),
3007                path: [discriminator],
3008            });
3009            return INVALID;
3010        }
3011        if (ctx.common.async) {
3012            return option._parseAsync({
3013                data: ctx.data,
3014                path: ctx.path,
3015                parent: ctx,
3016            });
3017        }
3018        else {
3019            return option._parseSync({
3020                data: ctx.data,
3021                path: ctx.path,
3022                parent: ctx,
3023            });
3024        }
3025    }
3026    get discriminator() {
3027        return this._def.discriminator;
3028    }
3029    get options() {
3030        return this._def.options;
3031    }
3032    get optionsMap() {
3033        return this._def.optionsMap;
3034    }
3035    /**
3036     * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3037     * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3038     * have a different value for each object in the union.
3039     * @param discriminator the name of the discriminator property
3040     * @param types an array of object schemas
3041     * @param params
3042     */
3043    static create(discriminator, options, params) {
3044        // Get all the valid discriminator values
3045        const optionsMap = new Map();
3046        // try {
3047        for (const type of options) {
3048            const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3049            if (!discriminatorValues.length) {
3050                throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3051            }
3052            for (const value of discriminatorValues) {
3053                if (optionsMap.has(value)) {
3054                    throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3055                }
3056                optionsMap.set(value, type);
3057            }
3058        }
3059        return new ZodDiscriminatedUnion({
3060            typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3061            discriminator,
3062            options,
3063            optionsMap,
3064            ...processCreateParams(params),
3065        });
3066    }
3067}
3068function mergeValues(a, b) {
3069    const aType = getParsedType(a);
3070    const bType = getParsedType(b);
3071    if (a === b) {
3072        return { valid: true, data: a };
3073    }
3074    else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
3075        const bKeys = util.objectKeys(b);
3076        const sharedKeys = util
3077            .objectKeys(a)
3078            .filter((key) => bKeys.indexOf(key) !== -1);
3079        const newObj = { ...a, ...b };
3080        for (const key of sharedKeys) {
3081            const sharedValue = mergeValues(a[key], b[key]);
3082            if (!sharedValue.valid) {
3083                return { valid: false };
3084            }
3085            newObj[key] = sharedValue.data;
3086        }
3087        return { valid: true, data: newObj };
3088    }
3089    else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
3090        if (a.length !== b.length) {
3091            return { valid: false };
3092        }
3093        const newArray = [];
3094        for (let index = 0; index < a.length; index++) {
3095            const itemA = a[index];
3096            const itemB = b[index];
3097            const sharedValue = mergeValues(itemA, itemB);
3098            if (!sharedValue.valid) {
3099                return { valid: false };
3100            }
3101            newArray.push(sharedValue.data);
3102        }
3103        return { valid: true, data: newArray };
3104    }
3105    else if (aType === ZodParsedType.date &&
3106        bType === ZodParsedType.date &&
3107        +a === +b) {
3108        return { valid: true, data: a };
3109    }
3110    else {
3111        return { valid: false };
3112    }
3113}
3114class ZodIntersection extends ZodType {
3115    _parse(input) {
3116        const { status, ctx } = this._processInputParams(input);
3117        const handleParsed = (parsedLeft, parsedRight) => {
3118            if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3119                return INVALID;
3120            }
3121            const merged = mergeValues(parsedLeft.value, parsedRight.value);
3122            if (!merged.valid) {
3123                addIssueToContext(ctx, {
3124                    code: ZodIssueCode.invalid_intersection_types,
3125                });
3126                return INVALID;
3127            }
3128            if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3129                status.dirty();
3130            }
3131            return { status: status.value, value: merged.data };
3132        };
3133        if (ctx.common.async) {
3134            return Promise.all([
3135                this._def.left._parseAsync({
3136                    data: ctx.data,
3137                    path: ctx.path,
3138                    parent: ctx,
3139                }),
3140                this._def.right._parseAsync({
3141                    data: ctx.data,
3142                    path: ctx.path,
3143                    parent: ctx,
3144                }),
3145            ]).then(([left, right]) => handleParsed(left, right));
3146        }
3147        else {
3148            return handleParsed(this._def.left._parseSync({
3149                data: ctx.data,
3150                path: ctx.path,
3151                parent: ctx,
3152            }), this._def.right._parseSync({
3153                data: ctx.data,
3154                path: ctx.path,
3155                parent: ctx,
3156            }));
3157        }
3158    }
3159}
3160ZodIntersection.create = (left, right, params) => {
3161    return new ZodIntersection({
3162        left: left,
3163        right: right,
3164        typeName: ZodFirstPartyTypeKind.ZodIntersection,
3165        ...processCreateParams(params),
3166    });
3167};
3168class ZodTuple extends ZodType {
3169    _parse(input) {
3170        const { status, ctx } = this._processInputParams(input);
3171        if (ctx.parsedType !== ZodParsedType.array) {
3172            addIssueToContext(ctx, {
3173                code: ZodIssueCode.invalid_type,
3174                expected: ZodParsedType.array,
3175                received: ctx.parsedType,
3176            });
3177            return INVALID;
3178        }
3179        if (ctx.data.length < this._def.items.length) {
3180            addIssueToContext(ctx, {
3181                code: ZodIssueCode.too_small,
3182                minimum: this._def.items.length,
3183                inclusive: true,
3184                exact: false,
3185                type: "array",
3186            });
3187            return INVALID;
3188        }
3189        const rest = this._def.rest;
3190        if (!rest && ctx.data.length > this._def.items.length) {
3191            addIssueToContext(ctx, {
3192                code: ZodIssueCode.too_big,
3193                maximum: this._def.items.length,
3194                inclusive: true,
3195                exact: false,
3196                type: "array",
3197            });
3198            status.dirty();
3199        }
3200        const items = [...ctx.data]
3201            .map((item, itemIndex) => {
3202            const schema = this._def.items[itemIndex] || this._def.rest;
3203            if (!schema)
3204                return null;
3205            return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3206        })
3207            .filter((x) => !!x); // filter nulls
3208        if (ctx.common.async) {
3209            return Promise.all(items).then((results) => {
3210                return ParseStatus.mergeArray(status, results);
3211            });
3212        }
3213        else {
3214            return ParseStatus.mergeArray(status, items);
3215        }
3216    }
3217    get items() {
3218        return this._def.items;
3219    }
3220    rest(rest) {
3221        return new ZodTuple({
3222            ...this._def,
3223            rest,
3224        });
3225    }
3226}
3227ZodTuple.create = (schemas, params) => {
3228    if (!Array.isArray(schemas)) {
3229        throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3230    }
3231    return new ZodTuple({
3232        items: schemas,
3233        typeName: ZodFirstPartyTypeKind.ZodTuple,
3234        rest: null,
3235        ...processCreateParams(params),
3236    });
3237};
3238class ZodRecord extends ZodType {
3239    get keySchema() {
3240        return this._def.keyType;
3241    }
3242    get valueSchema() {
3243        return this._def.valueType;
3244    }
3245    _parse(input) {
3246        const { status, ctx } = this._processInputParams(input);
3247        if (ctx.parsedType !== ZodParsedType.object) {
3248            addIssueToContext(ctx, {
3249                code: ZodIssueCode.invalid_type,
3250                expected: ZodParsedType.object,
3251                received: ctx.parsedType,
3252            });
3253            return INVALID;
3254        }
3255        const pairs = [];
3256        const keyType = this._def.keyType;
3257        const valueType = this._def.valueType;
3258        for (const key in ctx.data) {
3259            pairs.push({
3260                key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3261                value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3262                alwaysSet: key in ctx.data,
3263            });
3264        }
3265        if (ctx.common.async) {
3266            return ParseStatus.mergeObjectAsync(status, pairs);
3267        }
3268        else {
3269            return ParseStatus.mergeObjectSync(status, pairs);
3270        }
3271    }
3272    get element() {
3273        return this._def.valueType;
3274    }
3275    static create(first, second, third) {
3276        if (second instanceof ZodType) {
3277            return new ZodRecord({
3278                keyType: first,
3279                valueType: second,
3280                typeName: ZodFirstPartyTypeKind.ZodRecord,
3281                ...processCreateParams(third),
3282            });
3283        }
3284        return new ZodRecord({
3285            keyType: ZodString.create(),
3286            valueType: first,
3287            typeName: ZodFirstPartyTypeKind.ZodRecord,
3288            ...processCreateParams(second),
3289        });
3290    }
3291}
3292class ZodMap extends ZodType {
3293    get keySchema() {
3294        return this._def.keyType;
3295    }
3296    get valueSchema() {
3297        return this._def.valueType;
3298    }
3299    _parse(input) {
3300        const { status, ctx } = this._processInputParams(input);
3301        if (ctx.parsedType !== ZodParsedType.map) {
3302            addIssueToContext(ctx, {
3303                code: ZodIssueCode.invalid_type,
3304                expected: ZodParsedType.map,
3305                received: ctx.parsedType,
3306            });
3307            return INVALID;
3308        }
3309        const keyType = this._def.keyType;
3310        const valueType = this._def.valueType;
3311        const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3312            return {
3313                key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3314                value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])),
3315            };
3316        });
3317        if (ctx.common.async) {
3318            const finalMap = new Map();
3319            return Promise.resolve().then(async () => {
3320                for (const pair of pairs) {
3321                    const key = await pair.key;
3322                    const value = await pair.value;
3323                    if (key.status === "aborted" || value.status === "aborted") {
3324                        return INVALID;
3325                    }
3326                    if (key.status === "dirty" || value.status === "dirty") {
3327                        status.dirty();
3328                    }
3329                    finalMap.set(key.value, value.value);
3330                }
3331                return { status: status.value, value: finalMap };
3332            });
3333        }
3334        else {
3335            const finalMap = new Map();
3336            for (const pair of pairs) {
3337                const key = pair.key;
3338                const value = pair.value;
3339                if (key.status === "aborted" || value.status === "aborted") {
3340                    return INVALID;
3341                }
3342                if (key.status === "dirty" || value.status === "dirty") {
3343                    status.dirty();
3344                }
3345                finalMap.set(key.value, value.value);
3346            }
3347            return { status: status.value, value: finalMap };
3348        }
3349    }
3350}
3351ZodMap.create = (keyType, valueType, params) => {
3352    return new ZodMap({
3353        valueType,
3354        keyType,
3355        typeName: ZodFirstPartyTypeKind.ZodMap,
3356        ...processCreateParams(params),
3357    });
3358};
3359class ZodSet extends ZodType {
3360    _parse(input) {
3361        const { status, ctx } = this._processInputParams(input);
3362        if (ctx.parsedType !== ZodParsedType.set) {
3363            addIssueToContext(ctx, {
3364                code: ZodIssueCode.invalid_type,
3365                expected: ZodParsedType.set,
3366                received: ctx.parsedType,
3367            });
3368            return INVALID;
3369        }
3370        const def = this._def;
3371        if (def.minSize !== null) {
3372            if (ctx.data.size < def.minSize.value) {
3373                addIssueToContext(ctx, {
3374                    code: ZodIssueCode.too_small,
3375                    minimum: def.minSize.value,
3376                    type: "set",
3377                    inclusive: true,
3378                    exact: false,
3379                    message: def.minSize.message,
3380                });
3381                status.dirty();
3382            }
3383        }
3384        if (def.maxSize !== null) {
3385            if (ctx.data.size > def.maxSize.value) {
3386                addIssueToContext(ctx, {
3387                    code: ZodIssueCode.too_big,
3388                    maximum: def.maxSize.value,
3389                    type: "set",
3390                    inclusive: true,
3391                    exact: false,
3392                    message: def.maxSize.message,
3393                });
3394                status.dirty();
3395            }
3396        }
3397        const valueType = this._def.valueType;
3398        function finalizeSet(elements) {
3399            const parsedSet = new Set();
3400            for (const element of elements) {
3401                if (element.status === "aborted")
3402                    return INVALID;
3403                if (element.status === "dirty")
3404                    status.dirty();
3405                parsedSet.add(element.value);
3406            }
3407            return { status: status.value, value: parsedSet };
3408        }
3409        const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3410        if (ctx.common.async) {
3411            return Promise.all(elements).then((elements) => finalizeSet(elements));
3412        }
3413        else {
3414            return finalizeSet(elements);
3415        }
3416    }
3417    min(minSize, message) {
3418        return new ZodSet({
3419            ...this._def,
3420            minSize: { value: minSize, message: errorUtil.toString(message) },
3421        });
3422    }
3423    max(maxSize, message) {
3424        return new ZodSet({
3425            ...this._def,
3426            maxSize: { value: maxSize, message: errorUtil.toString(message) },
3427        });
3428    }
3429    size(size, message) {
3430        return this.min(size, message).max(size, message);
3431    }
3432    nonempty(message) {
3433        return this.min(1, message);
3434    }
3435}
3436ZodSet.create = (valueType, params) => {
3437    return new ZodSet({
3438        valueType,
3439        minSize: null,
3440        maxSize: null,
3441        typeName: ZodFirstPartyTypeKind.ZodSet,
3442        ...processCreateParams(params),
3443    });
3444};
3445class ZodFunction extends ZodType {
3446    constructor() {
3447        super(...arguments);
3448        this.validate = this.implement;
3449    }
3450    _parse(input) {
3451        const { ctx } = this._processInputParams(input);
3452        if (ctx.parsedType !== ZodParsedType.function) {
3453            addIssueToContext(ctx, {
3454                code: ZodIssueCode.invalid_type,
3455                expected: ZodParsedType.function,
3456                received: ctx.parsedType,
3457            });
3458            return INVALID;
3459        }
3460        function makeArgsIssue(args, error) {
3461            return makeIssue({
3462                data: args,
3463                path: ctx.path,
3464                errorMaps: [
3465                    ctx.common.contextualErrorMap,
3466                    ctx.schemaErrorMap,
3467                    getErrorMap(),
3468                    errorMap,
3469                ].filter((x) => !!x),
3470                issueData: {
3471                    code: ZodIssueCode.invalid_arguments,
3472                    argumentsError: error,
3473                },
3474            });
3475        }
3476        function makeReturnsIssue(returns, error) {
3477            return makeIssue({
3478                data: returns,
3479                path: ctx.path,
3480                errorMaps: [
3481                    ctx.common.contextualErrorMap,
3482                    ctx.schemaErrorMap,
3483                    getErrorMap(),
3484                    errorMap,
3485                ].filter((x) => !!x),
3486                issueData: {
3487                    code: ZodIssueCode.invalid_return_type,
3488                    returnTypeError: error,
3489                },
3490            });
3491        }
3492        const params = { errorMap: ctx.common.contextualErrorMap };
3493        const fn = ctx.data;
3494        if (this._def.returns instanceof ZodPromise) {
3495            // Would love a way to avoid disabling this rule, but we need
3496            // an alias (using an arrow function was what caused 2651).
3497            // eslint-disable-next-line @typescript-eslint/no-this-alias
3498            const me = this;
3499            return OK(async function (...args) {
3500                const error = new ZodError([]);
3501                const parsedArgs = await me._def.args
3502                    .parseAsync(args, params)
3503                    .catch((e) => {
3504                    error.addIssue(makeArgsIssue(args, e));
3505                    throw error;
3506                });
3507                const result = await Reflect.apply(fn, this, parsedArgs);
3508                const parsedReturns = await me._def.returns._def.type
3509                    .parseAsync(result, params)
3510                    .catch((e) => {
3511                    error.addIssue(makeReturnsIssue(result, e));
3512                    throw error;
3513                });
3514                return parsedReturns;
3515            });
3516        }
3517        else {
3518            // Would love a way to avoid disabling this rule, but we need
3519            // an alias (using an arrow function was what caused 2651).
3520            // eslint-disable-next-line @typescript-eslint/no-this-alias
3521            const me = this;
3522            return OK(function (...args) {
3523                const parsedArgs = me._def.args.safeParse(args, params);
3524                if (!parsedArgs.success) {
3525                    throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3526                }
3527                const result = Reflect.apply(fn, this, parsedArgs.data);
3528                const parsedReturns = me._def.returns.safeParse(result, params);
3529                if (!parsedReturns.success) {
3530                    throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3531                }
3532                return parsedReturns.data;
3533            });
3534        }
3535    }
3536    parameters() {
3537        return this._def.args;
3538    }
3539    returnType() {
3540        return this._def.returns;
3541    }
3542    args(...items) {
3543        return new ZodFunction({
3544            ...this._def,
3545            args: ZodTuple.create(items).rest(ZodUnknown.create()),
3546        });
3547    }
3548    returns(returnType) {
3549        return new ZodFunction({
3550            ...this._def,
3551            returns: returnType,
3552        });
3553    }
3554    implement(func) {
3555        const validatedFunc = this.parse(func);
3556        return validatedFunc;
3557    }
3558    strictImplement(func) {
3559        const validatedFunc = this.parse(func);
3560        return validatedFunc;
3561    }
3562    static create(args, returns, params) {
3563        return new ZodFunction({
3564            args: (args
3565                ? args
3566                : ZodTuple.create([]).rest(ZodUnknown.create())),
3567            returns: returns || ZodUnknown.create(),
3568            typeName: ZodFirstPartyTypeKind.ZodFunction,
3569            ...processCreateParams(params),
3570        });
3571    }
3572}
vendor: 5,141 bytes, lines 3573-3734
3573class ZodLazy extends ZodType {
3574    get schema() {
3575        return this._def.getter();
3576    }
3577    _parse(input) {
3578        const { ctx } = this._processInputParams(input);
3579        const lazySchema = this._def.getter();
3580        return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3581    }
3582}
3583ZodLazy.create = (getter, params) => {
3584    return new ZodLazy({
3585        getter: getter,
3586        typeName: ZodFirstPartyTypeKind.ZodLazy,
3587        ...processCreateParams(params),
3588    });
3589};
3590class ZodLiteral extends ZodType {
3591    _parse(input) {
3592        if (input.data !== this._def.value) {
3593            const ctx = this._getOrReturnCtx(input);
3594            addIssueToContext(ctx, {
3595                received: ctx.data,
3596                code: ZodIssueCode.invalid_literal,
3597                expected: this._def.value,
3598            });
3599            return INVALID;
3600        }
3601        return { status: "valid", value: input.data };
3602    }
3603    get value() {
3604        return this._def.value;
3605    }
3606}
3607ZodLiteral.create = (value, params) => {
3608    return new ZodLiteral({
3609        value: value,
3610        typeName: ZodFirstPartyTypeKind.ZodLiteral,
3611        ...processCreateParams(params),
3612    });
3613};
3614function createZodEnum(values, params) {
3615    return new ZodEnum({
3616        values,
3617        typeName: ZodFirstPartyTypeKind.ZodEnum,
3618        ...processCreateParams(params),
3619    });
3620}
3621class ZodEnum extends ZodType {
3622    constructor() {
3623        super(...arguments);
3624        _ZodEnum_cache.set(this, void 0);
3625    }
3626    _parse(input) {
3627        if (typeof input.data !== "string") {
3628            const ctx = this._getOrReturnCtx(input);
3629            const expectedValues = this._def.values;
3630            addIssueToContext(ctx, {
3631                expected: util.joinValues(expectedValues),
3632                received: ctx.parsedType,
3633                code: ZodIssueCode.invalid_type,
3634            });
3635            return INVALID;
3636        }
3637        if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3638            __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3639        }
3640        if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3641            const ctx = this._getOrReturnCtx(input);
3642            const expectedValues = this._def.values;
3643            addIssueToContext(ctx, {
3644                received: ctx.data,
3645                code: ZodIssueCode.invalid_enum_value,
3646                options: expectedValues,
3647            });
3648            return INVALID;
3649        }
3650        return OK(input.data);
3651    }
3652    get options() {
3653        return this._def.values;
3654    }
3655    get enum() {
3656        const enumValues = {};
3657        for (const val of this._def.values) {
3658            enumValues[val] = val;
3659        }
3660        return enumValues;
3661    }
3662    get Values() {
3663        const enumValues = {};
3664        for (const val of this._def.values) {
3665            enumValues[val] = val;
3666        }
3667        return enumValues;
3668    }
3669    get Enum() {
3670        const enumValues = {};
3671        for (const val of this._def.values) {
3672            enumValues[val] = val;
3673        }
3674        return enumValues;
3675    }
3676    extract(values, newDef = this._def) {
3677        return ZodEnum.create(values, {
3678            ...this._def,
3679            ...newDef,
3680        });
3681    }
3682    exclude(values, newDef = this._def) {
3683        return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3684            ...this._def,
3685            ...newDef,
3686        });
3687    }
3688}
3689_ZodEnum_cache = new WeakMap();
3690ZodEnum.create = createZodEnum;
3691class ZodNativeEnum extends ZodType {
3692    constructor() {
3693        super(...arguments);
3694        _ZodNativeEnum_cache.set(this, void 0);
3695    }
3696    _parse(input) {
3697        const nativeEnumValues = util.getValidEnumValues(this._def.values);
3698        const ctx = this._getOrReturnCtx(input);
3699        if (ctx.parsedType !== ZodParsedType.string &&
3700            ctx.parsedType !== ZodParsedType.number) {
3701            const expectedValues = util.objectValues(nativeEnumValues);
3702            addIssueToContext(ctx, {
3703                expected: util.joinValues(expectedValues),
3704                received: ctx.parsedType,
3705                code: ZodIssueCode.invalid_type,
3706            });
3707            return INVALID;
3708        }
3709        if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3710            __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3711        }
3712        if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3713            const expectedValues = util.objectValues(nativeEnumValues);
3714            addIssueToContext(ctx, {
3715                received: ctx.data,
3716                code: ZodIssueCode.invalid_enum_value,
3717                options: expectedValues,
3718            });
3719            return INVALID;
3720        }
3721        return OK(input.data);
3722    }
3723    get enum() {
3724        return this._def.values;
3725    }
3726}
3727_ZodNativeEnum_cache = new WeakMap();
3728ZodNativeEnum.create = (values, params) => {
3729    return new ZodNativeEnum({
3730        values: values,
3731        typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3732        ...processCreateParams(params),
3733    });
3734};
vendor: 13,944 bytes, lines 3735-4158
3735class ZodPromise extends ZodType {
3736    unwrap() {
3737        return this._def.type;
3738    }
3739    _parse(input) {
3740        const { ctx } = this._processInputParams(input);
3741        if (ctx.parsedType !== ZodParsedType.promise &&
3742            ctx.common.async === false) {
3743            addIssueToContext(ctx, {
3744                code: ZodIssueCode.invalid_type,
3745                expected: ZodParsedType.promise,
3746                received: ctx.parsedType,
3747            });
3748            return INVALID;
3749        }
3750        const promisified = ctx.parsedType === ZodParsedType.promise
3751            ? ctx.data
3752            : Promise.resolve(ctx.data);
3753        return OK(promisified.then((data) => {
3754            return this._def.type.parseAsync(data, {
3755                path: ctx.path,
3756                errorMap: ctx.common.contextualErrorMap,
3757            });
3758        }));
3759    }
3760}
3761ZodPromise.create = (schema, params) => {
3762    return new ZodPromise({
3763        type: schema,
3764        typeName: ZodFirstPartyTypeKind.ZodPromise,
3765        ...processCreateParams(params),
3766    });
3767};
3768class ZodEffects extends ZodType {
3769    innerType() {
3770        return this._def.schema;
3771    }
3772    sourceType() {
3773        return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects
3774            ? this._def.schema.sourceType()
3775            : this._def.schema;
3776    }
3777    _parse(input) {
3778        const { status, ctx } = this._processInputParams(input);
3779        const effect = this._def.effect || null;
3780        const checkCtx = {
3781            addIssue: (arg) => {
3782                addIssueToContext(ctx, arg);
3783                if (arg.fatal) {
3784                    status.abort();
3785                }
3786                else {
3787                    status.dirty();
3788                }
3789            },
3790            get path() {
3791                return ctx.path;
3792            },
3793        };
3794        checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3795        if (effect.type === "preprocess") {
3796            const processed = effect.transform(ctx.data, checkCtx);
3797            if (ctx.common.async) {
3798                return Promise.resolve(processed).then(async (processed) => {
3799                    if (status.value === "aborted")
3800                        return INVALID;
3801                    const result = await this._def.schema._parseAsync({
3802                        data: processed,
3803                        path: ctx.path,
3804                        parent: ctx,
3805                    });
3806                    if (result.status === "aborted")
3807                        return INVALID;
3808                    if (result.status === "dirty")
3809                        return DIRTY(result.value);
3810                    if (status.value === "dirty")
3811                        return DIRTY(result.value);
3812                    return result;
3813                });
3814            }
3815            else {
3816                if (status.value === "aborted")
3817                    return INVALID;
3818                const result = this._def.schema._parseSync({
3819                    data: processed,
3820                    path: ctx.path,
3821                    parent: ctx,
3822                });
3823                if (result.status === "aborted")
3824                    return INVALID;
3825                if (result.status === "dirty")
3826                    return DIRTY(result.value);
3827                if (status.value === "dirty")
3828                    return DIRTY(result.value);
3829                return result;
3830            }
3831        }
3832        if (effect.type === "refinement") {
3833            const executeRefinement = (acc) => {
3834                const result = effect.refinement(acc, checkCtx);
3835                if (ctx.common.async) {
3836                    return Promise.resolve(result);
3837                }
3838                if (result instanceof Promise) {
3839                    throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3840                }
3841                return acc;
3842            };
3843            if (ctx.common.async === false) {
3844                const inner = this._def.schema._parseSync({
3845                    data: ctx.data,
3846                    path: ctx.path,
3847                    parent: ctx,
3848                });
3849                if (inner.status === "aborted")
3850                    return INVALID;
3851                if (inner.status === "dirty")
3852                    status.dirty();
3853                // return value is ignored
3854                executeRefinement(inner.value);
3855                return { status: status.value, value: inner.value };
3856            }
3857            else {
3858                return this._def.schema
3859                    ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
3860                    .then((inner) => {
3861                    if (inner.status === "aborted")
3862                        return INVALID;
3863                    if (inner.status === "dirty")
3864                        status.dirty();
3865                    return executeRefinement(inner.value).then(() => {
3866                        return { status: status.value, value: inner.value };
3867                    });
3868                });
3869            }
3870        }
3871        if (effect.type === "transform") {
3872            if (ctx.common.async === false) {
3873                const base = this._def.schema._parseSync({
3874                    data: ctx.data,
3875                    path: ctx.path,
3876                    parent: ctx,
3877                });
3878                if (!isValid(base))
3879                    return base;
3880                const result = effect.transform(base.value, checkCtx);
3881                if (result instanceof Promise) {
3882                    throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3883                }
3884                return { status: status.value, value: result };
3885            }
3886            else {
3887                return this._def.schema
3888                    ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
3889                    .then((base) => {
3890                    if (!isValid(base))
3891                        return base;
3892                    return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
3893                });
3894            }
3895        }
3896        util.assertNever(effect);
3897    }
3898}
3899ZodEffects.create = (schema, effect, params) => {
3900    return new ZodEffects({
3901        schema,
3902        typeName: ZodFirstPartyTypeKind.ZodEffects,
3903        effect,
3904        ...processCreateParams(params),
3905    });
3906};
3907ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3908    return new ZodEffects({
3909        schema,
3910        effect: { type: "preprocess", transform: preprocess },
3911        typeName: ZodFirstPartyTypeKind.ZodEffects,
3912        ...processCreateParams(params),
3913    });
3914};
3915class ZodOptional extends ZodType {
3916    _parse(input) {
3917        const parsedType = this._getType(input);
3918        if (parsedType === ZodParsedType.undefined) {
3919            return OK(undefined);
3920        }
3921        return this._def.innerType._parse(input);
3922    }
3923    unwrap() {
3924        return this._def.innerType;
3925    }
3926}
3927ZodOptional.create = (type, params) => {
3928    return new ZodOptional({
3929        innerType: type,
3930        typeName: ZodFirstPartyTypeKind.ZodOptional,
3931        ...processCreateParams(params),
3932    });
3933};
3934class ZodNullable extends ZodType {
3935    _parse(input) {
3936        const parsedType = this._getType(input);
3937        if (parsedType === ZodParsedType.null) {
3938            return OK(null);
3939        }
3940        return this._def.innerType._parse(input);
3941    }
3942    unwrap() {
3943        return this._def.innerType;
3944    }
3945}
3946ZodNullable.create = (type, params) => {
3947    return new ZodNullable({
3948        innerType: type,
3949        typeName: ZodFirstPartyTypeKind.ZodNullable,
3950        ...processCreateParams(params),
3951    });
3952};
3953class ZodDefault extends ZodType {
3954    _parse(input) {
3955        const { ctx } = this._processInputParams(input);
3956        let data = ctx.data;
3957        if (ctx.parsedType === ZodParsedType.undefined) {
3958            data = this._def.defaultValue();
3959        }
3960        return this._def.innerType._parse({
3961            data,
3962            path: ctx.path,
3963            parent: ctx,
3964        });
3965    }
3966    removeDefault() {
3967        return this._def.innerType;
3968    }
3969}
3970ZodDefault.create = (type, params) => {
3971    return new ZodDefault({
3972        innerType: type,
3973        typeName: ZodFirstPartyTypeKind.ZodDefault,
3974        defaultValue: typeof params.default === "function"
3975            ? params.default
3976            : () => params.default,
3977        ...processCreateParams(params),
3978    });
3979};
3980class ZodCatch extends ZodType {
3981    _parse(input) {
3982        const { ctx } = this._processInputParams(input);
3983        // newCtx is used to not collect issues from inner types in ctx
3984        const newCtx = {
3985            ...ctx,
3986            common: {
3987                ...ctx.common,
3988                issues: [],
3989            },
3990        };
3991        const result = this._def.innerType._parse({
3992            data: newCtx.data,
3993            path: newCtx.path,
3994            parent: {
3995                ...newCtx,
3996            },
3997        });
3998        if (isAsync(result)) {
3999            return result.then((result) => {
4000                return {
4001                    status: "valid",
4002                    value: result.status === "valid"
4003                        ? result.value
4004                        : this._def.catchValue({
4005                            get error() {
4006                                return new ZodError(newCtx.common.issues);
4007                            },
4008                            input: newCtx.data,
4009                        }),
4010                };
4011            });
4012        }
4013        else {
4014            return {
4015                status: "valid",
4016                value: result.status === "valid"
4017                    ? result.value
4018                    : this._def.catchValue({
4019                        get error() {
4020                            return new ZodError(newCtx.common.issues);
4021                        },
4022                        input: newCtx.data,
4023                    }),
4024            };
4025        }
4026    }
4027    removeCatch() {
4028        return this._def.innerType;
4029    }
4030}
4031ZodCatch.create = (type, params) => {
4032    return new ZodCatch({
4033        innerType: type,
4034        typeName: ZodFirstPartyTypeKind.ZodCatch,
4035        catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4036        ...processCreateParams(params),
4037    });
4038};
4039class ZodNaN extends ZodType {
4040    _parse(input) {
4041        const parsedType = this._getType(input);
4042        if (parsedType !== ZodParsedType.nan) {
4043            const ctx = this._getOrReturnCtx(input);
4044            addIssueToContext(ctx, {
4045                code: ZodIssueCode.invalid_type,
4046                expected: ZodParsedType.nan,
4047                received: ctx.parsedType,
4048            });
4049            return INVALID;
4050        }
4051        return { status: "valid", value: input.data };
4052    }
4053}
4054ZodNaN.create = (params) => {
4055    return new ZodNaN({
4056        typeName: ZodFirstPartyTypeKind.ZodNaN,
4057        ...processCreateParams(params),
4058    });
4059};
4060const BRAND = Symbol("zod_brand");
4061class ZodBranded extends ZodType {
4062    _parse(input) {
4063        const { ctx } = this._processInputParams(input);
4064        const data = ctx.data;
4065        return this._def.type._parse({
4066            data,
4067            path: ctx.path,
4068            parent: ctx,
4069        });
4070    }
4071    unwrap() {
4072        return this._def.type;
4073    }
4074}
4075class ZodPipeline extends ZodType {
4076    _parse(input) {
4077        const { status, ctx } = this._processInputParams(input);
4078        if (ctx.common.async) {
4079            const handleAsync = async () => {
4080                const inResult = await this._def.in._parseAsync({
4081                    data: ctx.data,
4082                    path: ctx.path,
4083                    parent: ctx,
4084                });
4085                if (inResult.status === "aborted")
4086                    return INVALID;
4087                if (inResult.status === "dirty") {
4088                    status.dirty();
4089                    return DIRTY(inResult.value);
4090                }
4091                else {
4092                    return this._def.out._parseAsync({
4093                        data: inResult.value,
4094                        path: ctx.path,
4095                        parent: ctx,
4096                    });
4097                }
4098            };
4099            return handleAsync();
4100        }
4101        else {
4102            const inResult = this._def.in._parseSync({
4103                data: ctx.data,
4104                path: ctx.path,
4105                parent: ctx,
4106            });
4107            if (inResult.status === "aborted")
4108                return INVALID;
4109            if (inResult.status === "dirty") {
4110                status.dirty();
4111                return {
4112                    status: "dirty",
4113                    value: inResult.value,
4114                };
4115            }
4116            else {
4117                return this._def.out._parseSync({
4118                    data: inResult.value,
4119                    path: ctx.path,
4120                    parent: ctx,
4121                });
4122            }
4123        }
4124    }
4125    static create(a, b) {
4126        return new ZodPipeline({
4127            in: a,
4128            out: b,
4129            typeName: ZodFirstPartyTypeKind.ZodPipeline,
4130        });
4131    }
4132}
4133class ZodReadonly extends ZodType {
4134    _parse(input) {
4135        const result = this._def.innerType._parse(input);
4136        const freeze = (data) => {
4137            if (isValid(data)) {
4138                data.value = Object.freeze(data.value);
4139            }
4140            return data;
4141        };
4142        return isAsync(result)
4143            ? result.then((data) => freeze(data))
4144            : freeze(result);
4145    }
4146    unwrap() {
4147        return this._def.innerType;
4148    }
4149}
4150ZodReadonly.create = (type, params) => {
4151    return new ZodReadonly({
4152        innerType: type,
4153        typeName: ZodFirstPartyTypeKind.ZodReadonly,
4154        ...processCreateParams(params),
4155    });
4156};
4157////////////////////////////////////////
4158////////////////////////////////////////
4159//////////                    //////////
4160//////////      z.custom      //////////
4161//////////                    //////////
4162////////////////////////////////////////
4163////////////////////////////////////////
4164function cleanParams(params, data) {
4165    const p = typeof params === "function"
4166        ? params(data)
4167        : typeof params === "string"
4168            ? { message: params }
4169            : params;
4170    const p2 = typeof p === "string" ? { message: p } : p;
4171    return p2;
4172}
4173function custom(check, _params = {}, 
4174/**
4175 * @deprecated
4176 *
4177 * Pass `fatal` into the params object instead:
4178 *
4179 * ```ts
4180 * z.string().custom((val) => val.length > 5, { fatal: false })
4181 * ```
4182 *
4183 */
4184fatal) {
4185    if (check)
4186        return ZodAny.create().superRefine((data, ctx) => {
4187            var _a, _b;
4188            const r = check(data);
4189            if (r instanceof Promise) {
4190                return r.then((r) => {
4191                    var _a, _b;
4192                    if (!r) {
4193                        const params = cleanParams(_params, data);
4194                        const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
4195                        ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4196                    }
4197                });
4198            }
4199            if (!r) {
4200                const params = cleanParams(_params, data);
4201                const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
4202                ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4203            }
4204            return;
4205        });
4206    return ZodAny.create();
4207}
4208const late = {
4209    object: ZodObject.lazycreate,
4210};
4211var ZodFirstPartyTypeKind;
4212(function (ZodFirstPartyTypeKind) {
4213    ZodFirstPartyTypeKind["ZodString"] = "ZodString";
4214    ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
4215    ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
4216    ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
4217    ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
4218    ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
4219    ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
4220    ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
4221    ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
4222    ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
4223    ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
4224    ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
4225    ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
4226    ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
4227    ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
4228    ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
4229    ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4230    ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
4231    ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
4232    ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
4233    ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
4234    ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
4235    ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
4236    ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
4237    ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
4238    ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
4239    ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
4240    ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
4241    ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
4242    ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
4243    ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
4244    ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
4245    ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
4246    ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
4247    ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
4248    ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
4249})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4250const instanceOfType = (
4251// const instanceOfType = <T extends new (...args: any[]) => any>(
4252cls, params = {
4253    message: `Input not instance of ${cls.name}`,
4254}) => custom((data) => data instanceof cls, params);
4255const stringType = ZodString.create;
4256const numberType = ZodNumber.create;
4257const nanType = ZodNaN.create;
4258const bigIntType = ZodBigInt.create;
4259const booleanType = ZodBoolean.create;
4260const dateType = ZodDate.create;
4261const symbolType = ZodSymbol.create;
4262const undefinedType = ZodUndefined.create;
4263const nullType = ZodNull.create;
4264const anyType = ZodAny.create;
4265const unknownType = ZodUnknown.create;
4266const neverType = ZodNever.create;
4267const voidType = ZodVoid.create;
4268const arrayType = ZodArray.create;
4269const objectType = ZodObject.create;
4270const strictObjectType = ZodObject.strictCreate;
4271const unionType = ZodUnion.create;
4272const discriminatedUnionType = ZodDiscriminatedUnion.create;
4273const intersectionType = ZodIntersection.create;
4274const tupleType = ZodTuple.create;
4275const recordType = ZodRecord.create;
4276const mapType = ZodMap.create;
4277const setType = ZodSet.create;
4278const functionType = ZodFunction.create;
4279const lazyType = ZodLazy.create;
4280const literalType = ZodLiteral.create;
4281const enumType = ZodEnum.create;
4282const nativeEnumType = ZodNativeEnum.create;
4283const promiseType = ZodPromise.create;
4284const effectsType = ZodEffects.create;
4285const optionalType = ZodOptional.create;
4286const nullableType = ZodNullable.create;
4287const preprocessType = ZodEffects.createWithPreprocess;
4288const pipelineType = ZodPipeline.create;
4289const ostring = () => stringType().optional();
4290const onumber = () => numberType().optional();
4291const oboolean = () => booleanType().optional();
4292const coerce = {
4293    string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4294    number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4295    boolean: ((arg) => ZodBoolean.create({
4296        ...arg,
4297        coerce: true,
4298    })),
4299    bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4300    date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
4301};
4302const NEVER = INVALID;
4303
4304var z = /*#__PURE__*/Object.freeze({
4305    __proto__: null,
4306    defaultErrorMap: errorMap,
4307    setErrorMap: setErrorMap,
4308    getErrorMap: getErrorMap,
4309    makeIssue: makeIssue,
4310    EMPTY_PATH: EMPTY_PATH,
4311    addIssueToContext: addIssueToContext,
4312    ParseStatus: ParseStatus,
4313    INVALID: INVALID,
4314    DIRTY: DIRTY,
4315    OK: OK,
4316    isAborted: isAborted,
4317    isDirty: isDirty,
4318    isValid: isValid,
4319    isAsync: isAsync,
4320    get util () { return util; },
4321    get objectUtil () { return objectUtil; },
4322    ZodParsedType: ZodParsedType,
4323    getParsedType: getParsedType,
4324    ZodType: ZodType,
4325    datetimeRegex: datetimeRegex,
4326    ZodString: ZodString,
4327    ZodNumber: ZodNumber,
4328    ZodBigInt: ZodBigInt,
4329    ZodBoolean: ZodBoolean,
4330    ZodDate: ZodDate,
4331    ZodSymbol: ZodSymbol,
4332    ZodUndefined: ZodUndefined,
4333    ZodNull: ZodNull,
4334    ZodAny: ZodAny,
4335    ZodUnknown: ZodUnknown,
4336    ZodNever: ZodNever,
4337    ZodVoid: ZodVoid,
4338    ZodArray: ZodArray,
4339    ZodObject: ZodObject,
4340    ZodUnion: ZodUnion,
4341    ZodDiscriminatedUnion: ZodDiscriminatedUnion,
4342    ZodIntersection: ZodIntersection,
4343    ZodTuple: ZodTuple,
4344    ZodRecord: ZodRecord,
4345    ZodMap: ZodMap,
4346    ZodSet: ZodSet,
4347    ZodFunction: ZodFunction,
4348    ZodLazy: ZodLazy,
4349    ZodLiteral: ZodLiteral,
4350    ZodEnum: ZodEnum,
4351    ZodNativeEnum: ZodNativeEnum,
4352    ZodPromise: ZodPromise,
4353    ZodEffects: ZodEffects,
4354    ZodTransformer: ZodEffects,
4355    ZodOptional: ZodOptional,
4356    ZodNullable: ZodNullable,
4357    ZodDefault: ZodDefault,
4358    ZodCatch: ZodCatch,
4359    ZodNaN: ZodNaN,
4360    BRAND: BRAND,
4361    ZodBranded: ZodBranded,
4362    ZodPipeline: ZodPipeline,
4363    ZodReadonly: ZodReadonly,
4364    custom: custom,
4365    Schema: ZodType,
4366    ZodSchema: ZodType,
4367    late: late,
4368    get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
4369    coerce: coerce,
4370    any: anyType,
4371    array: arrayType,
4372    bigint: bigIntType,
4373    boolean: booleanType,
4374    date: dateType,
4375    discriminatedUnion: discriminatedUnionType,
4376    effect: effectsType,
4377    'enum': enumType,
4378    'function': functionType,
4379    'instanceof': instanceOfType,
4380    intersection: intersectionType,
4381    lazy: lazyType,
4382    literal: literalType,
4383    map: mapType,
4384    nan: nanType,
4385    nativeEnum: nativeEnumType,
4386    never: neverType,
4387    'null': nullType,
4388    nullable: nullableType,
4389    number: numberType,
4390    object: objectType,
4391    oboolean: oboolean,
4392    onumber: onumber,
4393    optional: optionalType,
4394    ostring: ostring,
4395    pipeline: pipelineType,
4396    preprocess: preprocessType,
4397    promise: promiseType,
4398    record: recordType,
4399    set: setType,
4400    strictObject: strictObjectType,
4401    string: stringType,
4402    symbol: symbolType,
4403    transformer: effectsType,
4404    tuple: tupleType,
4405    'undefined': undefinedType,
4406    union: unionType,
4407    unknown: unknownType,
4408    'void': voidType,
4409    NEVER: NEVER,
4410    ZodIssueCode: ZodIssueCode,
4411    quotelessJson: quotelessJson,
4412    ZodError: ZodError
4413});
4414
4415
4416
4417
4418/***/ })
4419
4420}]);
4421//# sourceMappingURL=vendors-_app-pages-browser_node_modules_pnpm_zod_3_24_2_node_modules_zod_lib_index_mjs-7c739b344398ed0f.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.