PageSourceSearch

https://pro-demo.safehs.ai/_next/static/chunks/3881-ba2231f14a276bfc.js

js safehs.ai collected 2026-10-05 14:17:24 UTC 156,547 bytes, 4,389 lines download raw bytes

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

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.