@jamiexiongr/panda-hub 0.0.0-fallback-test-2

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