miniflare 0.0.0-020b04921

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.
Files changed (38) hide show
  1. package/README.md +858 -0
  2. package/bootstrap.js +11 -0
  3. package/dist/src/index.d.ts +4408 -0
  4. package/dist/src/index.js +10391 -0
  5. package/dist/src/index.js.map +6 -0
  6. package/dist/src/workers/assets/assets-kv.worker.js +28 -0
  7. package/dist/src/workers/assets/assets-kv.worker.js.map +6 -0
  8. package/dist/src/workers/assets/assets.worker.js +9275 -0
  9. package/dist/src/workers/assets/assets.worker.js.map +6 -0
  10. package/dist/src/workers/assets/router.worker.js +8755 -0
  11. package/dist/src/workers/assets/router.worker.js.map +6 -0
  12. package/dist/src/workers/cache/cache-entry-noop.worker.js +19 -0
  13. package/dist/src/workers/cache/cache-entry-noop.worker.js.map +6 -0
  14. package/dist/src/workers/cache/cache-entry.worker.js +28 -0
  15. package/dist/src/workers/cache/cache-entry.worker.js.map +6 -0
  16. package/dist/src/workers/cache/cache.worker.js +656 -0
  17. package/dist/src/workers/cache/cache.worker.js.map +6 -0
  18. package/dist/src/workers/core/entry.worker.js +1040 -0
  19. package/dist/src/workers/core/entry.worker.js.map +6 -0
  20. package/dist/src/workers/d1/database.worker.js +350 -0
  21. package/dist/src/workers/d1/database.worker.js.map +6 -0
  22. package/dist/src/workers/kv/namespace.worker.js +258 -0
  23. package/dist/src/workers/kv/namespace.worker.js.map +6 -0
  24. package/dist/src/workers/kv/sites.worker.js +147 -0
  25. package/dist/src/workers/kv/sites.worker.js.map +6 -0
  26. package/dist/src/workers/queues/broker.worker.js +294 -0
  27. package/dist/src/workers/queues/broker.worker.js.map +6 -0
  28. package/dist/src/workers/r2/bucket.worker.js +1157 -0
  29. package/dist/src/workers/r2/bucket.worker.js.map +6 -0
  30. package/dist/src/workers/ratelimit/ratelimit.worker.js +54 -0
  31. package/dist/src/workers/ratelimit/ratelimit.worker.js.map +6 -0
  32. package/dist/src/workers/shared/index.worker.js +706 -0
  33. package/dist/src/workers/shared/index.worker.js.map +6 -0
  34. package/dist/src/workers/shared/object-entry.worker.js +21 -0
  35. package/dist/src/workers/shared/object-entry.worker.js.map +6 -0
  36. package/dist/src/workers/shared/zod.worker.js +2719 -0
  37. package/dist/src/workers/shared/zod.worker.js.map +6 -0
  38. package/package.json +108 -0
@@ -0,0 +1,2719 @@
1
+ // src/workers/shared/zod.worker.ts
2
+ import { Buffer } from "node-internal:internal_buffer";
3
+
4
+ // ../../node_modules/.pnpm/zod@3.22.3/node_modules/zod/lib/index.mjs
5
+ var util;
6
+ (function(util2) {
7
+ util2.assertEqual = (val) => val;
8
+ function assertIs(_arg) {
9
+ }
10
+ util2.assertIs = assertIs;
11
+ function assertNever(_x) {
12
+ throw new Error();
13
+ }
14
+ util2.assertNever = assertNever, util2.arrayToEnum = (items) => {
15
+ let obj = {};
16
+ for (let item of items)
17
+ obj[item] = item;
18
+ return obj;
19
+ }, util2.getValidEnumValues = (obj) => {
20
+ let validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] != "number"), filtered = {};
21
+ for (let k of validKeys)
22
+ filtered[k] = obj[k];
23
+ return util2.objectValues(filtered);
24
+ }, util2.objectValues = (obj) => util2.objectKeys(obj).map(function(e) {
25
+ return obj[e];
26
+ }), util2.objectKeys = typeof Object.keys == "function" ? (obj) => Object.keys(obj) : (object) => {
27
+ let keys = [];
28
+ for (let key in object)
29
+ Object.prototype.hasOwnProperty.call(object, key) && keys.push(key);
30
+ return keys;
31
+ }, util2.find = (arr, checker) => {
32
+ for (let item of arr)
33
+ if (checker(item))
34
+ return item;
35
+ }, util2.isInteger = typeof Number.isInteger == "function" ? (val) => Number.isInteger(val) : (val) => typeof val == "number" && isFinite(val) && Math.floor(val) === val;
36
+ function joinValues(array, separator = " | ") {
37
+ return array.map((val) => typeof val == "string" ? `'${val}'` : val).join(separator);
38
+ }
39
+ util2.joinValues = joinValues, util2.jsonStringifyReplacer = (_, value) => typeof value == "bigint" ? value.toString() : value;
40
+ })(util || (util = {}));
41
+ var objectUtil;
42
+ (function(objectUtil2) {
43
+ objectUtil2.mergeShapes = (first, second) => ({
44
+ ...first,
45
+ ...second
46
+ // second overwrites first
47
+ });
48
+ })(objectUtil || (objectUtil = {}));
49
+ var ZodParsedType = util.arrayToEnum([
50
+ "string",
51
+ "nan",
52
+ "number",
53
+ "integer",
54
+ "float",
55
+ "boolean",
56
+ "date",
57
+ "bigint",
58
+ "symbol",
59
+ "function",
60
+ "undefined",
61
+ "null",
62
+ "array",
63
+ "object",
64
+ "unknown",
65
+ "promise",
66
+ "void",
67
+ "never",
68
+ "map",
69
+ "set"
70
+ ]), getParsedType = (data) => {
71
+ switch (typeof data) {
72
+ case "undefined":
73
+ return ZodParsedType.undefined;
74
+ case "string":
75
+ return ZodParsedType.string;
76
+ case "number":
77
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
78
+ case "boolean":
79
+ return ZodParsedType.boolean;
80
+ case "function":
81
+ return ZodParsedType.function;
82
+ case "bigint":
83
+ return ZodParsedType.bigint;
84
+ case "symbol":
85
+ return ZodParsedType.symbol;
86
+ case "object":
87
+ return Array.isArray(data) ? ZodParsedType.array : data === null ? ZodParsedType.null : data.then && typeof data.then == "function" && data.catch && typeof data.catch == "function" ? ZodParsedType.promise : typeof Map < "u" && data instanceof Map ? ZodParsedType.map : typeof Set < "u" && data instanceof Set ? ZodParsedType.set : typeof Date < "u" && data instanceof Date ? ZodParsedType.date : ZodParsedType.object;
88
+ default:
89
+ return ZodParsedType.unknown;
90
+ }
91
+ }, ZodIssueCode = util.arrayToEnum([
92
+ "invalid_type",
93
+ "invalid_literal",
94
+ "custom",
95
+ "invalid_union",
96
+ "invalid_union_discriminator",
97
+ "invalid_enum_value",
98
+ "unrecognized_keys",
99
+ "invalid_arguments",
100
+ "invalid_return_type",
101
+ "invalid_date",
102
+ "invalid_string",
103
+ "too_small",
104
+ "too_big",
105
+ "invalid_intersection_types",
106
+ "not_multiple_of",
107
+ "not_finite"
108
+ ]), quotelessJson = (obj) => JSON.stringify(obj, null, 2).replace(/"([^"]+)":/g, "$1:"), ZodError = class extends Error {
109
+ constructor(issues) {
110
+ super(), this.issues = [], this.addIssue = (sub) => {
111
+ this.issues = [...this.issues, sub];
112
+ }, this.addIssues = (subs = []) => {
113
+ this.issues = [...this.issues, ...subs];
114
+ };
115
+ let actualProto = new.target.prototype;
116
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, actualProto) : this.__proto__ = actualProto, this.name = "ZodError", this.issues = issues;
117
+ }
118
+ get errors() {
119
+ return this.issues;
120
+ }
121
+ format(_mapper) {
122
+ let mapper = _mapper || function(issue) {
123
+ return issue.message;
124
+ }, fieldErrors = { _errors: [] }, processError = (error) => {
125
+ for (let issue of error.issues)
126
+ if (issue.code === "invalid_union")
127
+ issue.unionErrors.map(processError);
128
+ else if (issue.code === "invalid_return_type")
129
+ processError(issue.returnTypeError);
130
+ else if (issue.code === "invalid_arguments")
131
+ processError(issue.argumentsError);
132
+ else if (issue.path.length === 0)
133
+ fieldErrors._errors.push(mapper(issue));
134
+ else {
135
+ let curr = fieldErrors, i = 0;
136
+ for (; i < issue.path.length; ) {
137
+ let el = issue.path[i];
138
+ i === issue.path.length - 1 ? (curr[el] = curr[el] || { _errors: [] }, curr[el]._errors.push(mapper(issue))) : curr[el] = curr[el] || { _errors: [] }, curr = curr[el], i++;
139
+ }
140
+ }
141
+ };
142
+ return processError(this), fieldErrors;
143
+ }
144
+ toString() {
145
+ return this.message;
146
+ }
147
+ get message() {
148
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
149
+ }
150
+ get isEmpty() {
151
+ return this.issues.length === 0;
152
+ }
153
+ flatten(mapper = (issue) => issue.message) {
154
+ let fieldErrors = {}, formErrors = [];
155
+ for (let sub of this.issues)
156
+ sub.path.length > 0 ? (fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [], fieldErrors[sub.path[0]].push(mapper(sub))) : formErrors.push(mapper(sub));
157
+ return { formErrors, fieldErrors };
158
+ }
159
+ get formErrors() {
160
+ return this.flatten();
161
+ }
162
+ };
163
+ ZodError.create = (issues) => new ZodError(issues);
164
+ var errorMap = (issue, _ctx) => {
165
+ let message;
166
+ switch (issue.code) {
167
+ case ZodIssueCode.invalid_type:
168
+ issue.received === ZodParsedType.undefined ? message = "Required" : message = `Expected ${issue.expected}, received ${issue.received}`;
169
+ break;
170
+ case ZodIssueCode.invalid_literal:
171
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
172
+ break;
173
+ case ZodIssueCode.unrecognized_keys:
174
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
175
+ break;
176
+ case ZodIssueCode.invalid_union:
177
+ message = "Invalid input";
178
+ break;
179
+ case ZodIssueCode.invalid_union_discriminator:
180
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
181
+ break;
182
+ case ZodIssueCode.invalid_enum_value:
183
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
184
+ break;
185
+ case ZodIssueCode.invalid_arguments:
186
+ message = "Invalid function arguments";
187
+ break;
188
+ case ZodIssueCode.invalid_return_type:
189
+ message = "Invalid function return type";
190
+ break;
191
+ case ZodIssueCode.invalid_date:
192
+ message = "Invalid date";
193
+ break;
194
+ case ZodIssueCode.invalid_string:
195
+ typeof issue.validation == "object" ? "includes" in issue.validation ? (message = `Invalid input: must include "${issue.validation.includes}"`, typeof issue.validation.position == "number" && (message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`)) : "startsWith" in issue.validation ? message = `Invalid input: must start with "${issue.validation.startsWith}"` : "endsWith" in issue.validation ? message = `Invalid input: must end with "${issue.validation.endsWith}"` : util.assertNever(issue.validation) : issue.validation !== "regex" ? message = `Invalid ${issue.validation}` : message = "Invalid";
196
+ break;
197
+ case ZodIssueCode.too_small:
198
+ issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "more than"} ${issue.minimum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at least" : "over"} ${issue.minimum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${issue.minimum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly equal to " : issue.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(issue.minimum))}` : message = "Invalid input";
199
+ break;
200
+ case ZodIssueCode.too_big:
201
+ issue.type === "array" ? message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "less than"} ${issue.maximum} element(s)` : issue.type === "string" ? message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? "at most" : "under"} ${issue.maximum} character(s)` : issue.type === "number" ? message = `Number must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "bigint" ? message = `BigInt must be ${issue.exact ? "exactly" : issue.inclusive ? "less than or equal to" : "less than"} ${issue.maximum}` : issue.type === "date" ? message = `Date must be ${issue.exact ? "exactly" : issue.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(issue.maximum))}` : message = "Invalid input";
202
+ break;
203
+ case ZodIssueCode.custom:
204
+ message = "Invalid input";
205
+ break;
206
+ case ZodIssueCode.invalid_intersection_types:
207
+ message = "Intersection results could not be merged";
208
+ break;
209
+ case ZodIssueCode.not_multiple_of:
210
+ message = `Number must be a multiple of ${issue.multipleOf}`;
211
+ break;
212
+ case ZodIssueCode.not_finite:
213
+ message = "Number must be finite";
214
+ break;
215
+ default:
216
+ message = _ctx.defaultError, util.assertNever(issue);
217
+ }
218
+ return { message };
219
+ }, overrideErrorMap = errorMap;
220
+ function setErrorMap(map) {
221
+ overrideErrorMap = map;
222
+ }
223
+ function getErrorMap() {
224
+ return overrideErrorMap;
225
+ }
226
+ var makeIssue = (params) => {
227
+ let { data, path, errorMaps, issueData } = params, fullPath = [...path, ...issueData.path || []], fullIssue = {
228
+ ...issueData,
229
+ path: fullPath
230
+ }, errorMessage = "", maps = errorMaps.filter((m) => !!m).slice().reverse();
231
+ for (let map of maps)
232
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
233
+ return {
234
+ ...issueData,
235
+ path: fullPath,
236
+ message: issueData.message || errorMessage
237
+ };
238
+ }, EMPTY_PATH = [];
239
+ function addIssueToContext(ctx, issueData) {
240
+ let issue = makeIssue({
241
+ issueData,
242
+ data: ctx.data,
243
+ path: ctx.path,
244
+ errorMaps: [
245
+ ctx.common.contextualErrorMap,
246
+ ctx.schemaErrorMap,
247
+ getErrorMap(),
248
+ errorMap
249
+ // then global default map
250
+ ].filter((x) => !!x)
251
+ });
252
+ ctx.common.issues.push(issue);
253
+ }
254
+ var ParseStatus = class {
255
+ constructor() {
256
+ this.value = "valid";
257
+ }
258
+ dirty() {
259
+ this.value === "valid" && (this.value = "dirty");
260
+ }
261
+ abort() {
262
+ this.value !== "aborted" && (this.value = "aborted");
263
+ }
264
+ static mergeArray(status, results) {
265
+ let arrayValue = [];
266
+ for (let s of results) {
267
+ if (s.status === "aborted")
268
+ return INVALID;
269
+ s.status === "dirty" && status.dirty(), arrayValue.push(s.value);
270
+ }
271
+ return { status: status.value, value: arrayValue };
272
+ }
273
+ static async mergeObjectAsync(status, pairs) {
274
+ let syncPairs = [];
275
+ for (let pair of pairs)
276
+ syncPairs.push({
277
+ key: await pair.key,
278
+ value: await pair.value
279
+ });
280
+ return ParseStatus.mergeObjectSync(status, syncPairs);
281
+ }
282
+ static mergeObjectSync(status, pairs) {
283
+ let finalObject = {};
284
+ for (let pair of pairs) {
285
+ let { key, value } = pair;
286
+ if (key.status === "aborted" || value.status === "aborted")
287
+ return INVALID;
288
+ key.status === "dirty" && status.dirty(), value.status === "dirty" && status.dirty(), key.value !== "__proto__" && (typeof value.value < "u" || pair.alwaysSet) && (finalObject[key.value] = value.value);
289
+ }
290
+ return { status: status.value, value: finalObject };
291
+ }
292
+ }, INVALID = Object.freeze({
293
+ status: "aborted"
294
+ }), DIRTY = (value) => ({ status: "dirty", value }), OK = (value) => ({ status: "valid", value }), isAborted = (x) => x.status === "aborted", isDirty = (x) => x.status === "dirty", isValid = (x) => x.status === "valid", isAsync = (x) => typeof Promise < "u" && x instanceof Promise, errorUtil;
295
+ (function(errorUtil2) {
296
+ errorUtil2.errToObj = (message) => typeof message == "string" ? { message } : message || {}, errorUtil2.toString = (message) => typeof message == "string" ? message : message?.message;
297
+ })(errorUtil || (errorUtil = {}));
298
+ var ParseInputLazyPath = class {
299
+ constructor(parent, value, path, key) {
300
+ this._cachedPath = [], this.parent = parent, this.data = value, this._path = path, this._key = key;
301
+ }
302
+ get path() {
303
+ return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
304
+ }
305
+ }, handleResult = (ctx, result) => {
306
+ if (isValid(result))
307
+ return { success: !0, data: result.value };
308
+ if (!ctx.common.issues.length)
309
+ throw new Error("Validation failed but no issues detected.");
310
+ return {
311
+ success: !1,
312
+ get error() {
313
+ if (this._error)
314
+ return this._error;
315
+ let error = new ZodError(ctx.common.issues);
316
+ return this._error = error, this._error;
317
+ }
318
+ };
319
+ };
320
+ function processCreateParams(params) {
321
+ if (!params)
322
+ return {};
323
+ let { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
324
+ if (errorMap2 && (invalid_type_error || required_error))
325
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
326
+ return errorMap2 ? { errorMap: errorMap2, description } : { errorMap: (iss, ctx) => iss.code !== "invalid_type" ? { message: ctx.defaultError } : typeof ctx.data > "u" ? { message: required_error ?? ctx.defaultError } : { message: invalid_type_error ?? ctx.defaultError }, description };
327
+ }
328
+ var ZodType = class {
329
+ constructor(def) {
330
+ this.spa = this.safeParseAsync, this._def = def, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
331
+ }
332
+ get description() {
333
+ return this._def.description;
334
+ }
335
+ _getType(input) {
336
+ return getParsedType(input.data);
337
+ }
338
+ _getOrReturnCtx(input, ctx) {
339
+ return ctx || {
340
+ common: input.parent.common,
341
+ data: input.data,
342
+ parsedType: getParsedType(input.data),
343
+ schemaErrorMap: this._def.errorMap,
344
+ path: input.path,
345
+ parent: input.parent
346
+ };
347
+ }
348
+ _processInputParams(input) {
349
+ return {
350
+ status: new ParseStatus(),
351
+ ctx: {
352
+ common: input.parent.common,
353
+ data: input.data,
354
+ parsedType: getParsedType(input.data),
355
+ schemaErrorMap: this._def.errorMap,
356
+ path: input.path,
357
+ parent: input.parent
358
+ }
359
+ };
360
+ }
361
+ _parseSync(input) {
362
+ let result = this._parse(input);
363
+ if (isAsync(result))
364
+ throw new Error("Synchronous parse encountered promise.");
365
+ return result;
366
+ }
367
+ _parseAsync(input) {
368
+ let result = this._parse(input);
369
+ return Promise.resolve(result);
370
+ }
371
+ parse(data, params) {
372
+ let result = this.safeParse(data, params);
373
+ if (result.success)
374
+ return result.data;
375
+ throw result.error;
376
+ }
377
+ safeParse(data, params) {
378
+ var _a;
379
+ let ctx = {
380
+ common: {
381
+ issues: [],
382
+ async: (_a = params?.async) !== null && _a !== void 0 ? _a : !1,
383
+ contextualErrorMap: params?.errorMap
384
+ },
385
+ path: params?.path || [],
386
+ schemaErrorMap: this._def.errorMap,
387
+ parent: null,
388
+ data,
389
+ parsedType: getParsedType(data)
390
+ }, result = this._parseSync({ data, path: ctx.path, parent: ctx });
391
+ return handleResult(ctx, result);
392
+ }
393
+ async parseAsync(data, params) {
394
+ let result = await this.safeParseAsync(data, params);
395
+ if (result.success)
396
+ return result.data;
397
+ throw result.error;
398
+ }
399
+ async safeParseAsync(data, params) {
400
+ let ctx = {
401
+ common: {
402
+ issues: [],
403
+ contextualErrorMap: params?.errorMap,
404
+ async: !0
405
+ },
406
+ path: params?.path || [],
407
+ schemaErrorMap: this._def.errorMap,
408
+ parent: null,
409
+ data,
410
+ parsedType: getParsedType(data)
411
+ }, maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }), result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
412
+ return handleResult(ctx, result);
413
+ }
414
+ refine(check, message) {
415
+ let getIssueProperties = (val) => typeof message == "string" || typeof message > "u" ? { message } : typeof message == "function" ? message(val) : message;
416
+ return this._refinement((val, ctx) => {
417
+ let result = check(val), setError = () => ctx.addIssue({
418
+ code: ZodIssueCode.custom,
419
+ ...getIssueProperties(val)
420
+ });
421
+ return typeof Promise < "u" && result instanceof Promise ? result.then((data) => data ? !0 : (setError(), !1)) : result ? !0 : (setError(), !1);
422
+ });
423
+ }
424
+ refinement(check, refinementData) {
425
+ return this._refinement((val, ctx) => check(val) ? !0 : (ctx.addIssue(typeof refinementData == "function" ? refinementData(val, ctx) : refinementData), !1));
426
+ }
427
+ _refinement(refinement) {
428
+ return new ZodEffects({
429
+ schema: this,
430
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
431
+ effect: { type: "refinement", refinement }
432
+ });
433
+ }
434
+ superRefine(refinement) {
435
+ return this._refinement(refinement);
436
+ }
437
+ optional() {
438
+ return ZodOptional.create(this, this._def);
439
+ }
440
+ nullable() {
441
+ return ZodNullable.create(this, this._def);
442
+ }
443
+ nullish() {
444
+ return this.nullable().optional();
445
+ }
446
+ array() {
447
+ return ZodArray.create(this, this._def);
448
+ }
449
+ promise() {
450
+ return ZodPromise.create(this, this._def);
451
+ }
452
+ or(option) {
453
+ return ZodUnion.create([this, option], this._def);
454
+ }
455
+ and(incoming) {
456
+ return ZodIntersection.create(this, incoming, this._def);
457
+ }
458
+ transform(transform) {
459
+ return new ZodEffects({
460
+ ...processCreateParams(this._def),
461
+ schema: this,
462
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
463
+ effect: { type: "transform", transform }
464
+ });
465
+ }
466
+ default(def) {
467
+ let defaultValueFunc = typeof def == "function" ? def : () => def;
468
+ return new ZodDefault({
469
+ ...processCreateParams(this._def),
470
+ innerType: this,
471
+ defaultValue: defaultValueFunc,
472
+ typeName: ZodFirstPartyTypeKind.ZodDefault
473
+ });
474
+ }
475
+ brand() {
476
+ return new ZodBranded({
477
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
478
+ type: this,
479
+ ...processCreateParams(this._def)
480
+ });
481
+ }
482
+ catch(def) {
483
+ let catchValueFunc = typeof def == "function" ? def : () => def;
484
+ return new ZodCatch({
485
+ ...processCreateParams(this._def),
486
+ innerType: this,
487
+ catchValue: catchValueFunc,
488
+ typeName: ZodFirstPartyTypeKind.ZodCatch
489
+ });
490
+ }
491
+ describe(description) {
492
+ let This = this.constructor;
493
+ return new This({
494
+ ...this._def,
495
+ description
496
+ });
497
+ }
498
+ pipe(target) {
499
+ return ZodPipeline.create(this, target);
500
+ }
501
+ readonly() {
502
+ return ZodReadonly.create(this);
503
+ }
504
+ isOptional() {
505
+ return this.safeParse(void 0).success;
506
+ }
507
+ isNullable() {
508
+ return this.safeParse(null).success;
509
+ }
510
+ }, cuidRegex = /^c[^\s-]{8,}$/i, cuid2Regex = /^[a-z][a-z0-9]*$/, ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/, 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, emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u, ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/, ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, datetimeRegex = (args) => args.precision ? args.offset ? new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`) : new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`) : args.precision === 0 ? args.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$") : args.offset ? new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$") : new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");
511
+ function isValidIP(ip, version) {
512
+ return !!((version === "v4" || !version) && ipv4Regex.test(ip) || (version === "v6" || !version) && ipv6Regex.test(ip));
513
+ }
514
+ var ZodString = class extends ZodType {
515
+ constructor() {
516
+ super(...arguments), this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
517
+ validation,
518
+ code: ZodIssueCode.invalid_string,
519
+ ...errorUtil.errToObj(message)
520
+ }), this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)), this.trim = () => new ZodString({
521
+ ...this._def,
522
+ checks: [...this._def.checks, { kind: "trim" }]
523
+ }), this.toLowerCase = () => new ZodString({
524
+ ...this._def,
525
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
526
+ }), this.toUpperCase = () => new ZodString({
527
+ ...this._def,
528
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
529
+ });
530
+ }
531
+ _parse(input) {
532
+ if (this._def.coerce && (input.data = String(input.data)), this._getType(input) !== ZodParsedType.string) {
533
+ let ctx2 = this._getOrReturnCtx(input);
534
+ return addIssueToContext(
535
+ ctx2,
536
+ {
537
+ code: ZodIssueCode.invalid_type,
538
+ expected: ZodParsedType.string,
539
+ received: ctx2.parsedType
540
+ }
541
+ //
542
+ ), INVALID;
543
+ }
544
+ let status = new ParseStatus(), ctx;
545
+ for (let check of this._def.checks)
546
+ if (check.kind === "min")
547
+ input.data.length < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
548
+ code: ZodIssueCode.too_small,
549
+ minimum: check.value,
550
+ type: "string",
551
+ inclusive: !0,
552
+ exact: !1,
553
+ message: check.message
554
+ }), status.dirty());
555
+ else if (check.kind === "max")
556
+ input.data.length > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
557
+ code: ZodIssueCode.too_big,
558
+ maximum: check.value,
559
+ type: "string",
560
+ inclusive: !0,
561
+ exact: !1,
562
+ message: check.message
563
+ }), status.dirty());
564
+ else if (check.kind === "length") {
565
+ let tooBig = input.data.length > check.value, tooSmall = input.data.length < check.value;
566
+ (tooBig || tooSmall) && (ctx = this._getOrReturnCtx(input, ctx), tooBig ? addIssueToContext(ctx, {
567
+ code: ZodIssueCode.too_big,
568
+ maximum: check.value,
569
+ type: "string",
570
+ inclusive: !0,
571
+ exact: !0,
572
+ message: check.message
573
+ }) : tooSmall && addIssueToContext(ctx, {
574
+ code: ZodIssueCode.too_small,
575
+ minimum: check.value,
576
+ type: "string",
577
+ inclusive: !0,
578
+ exact: !0,
579
+ message: check.message
580
+ }), status.dirty());
581
+ } else if (check.kind === "email")
582
+ emailRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
583
+ validation: "email",
584
+ code: ZodIssueCode.invalid_string,
585
+ message: check.message
586
+ }), status.dirty());
587
+ else if (check.kind === "emoji")
588
+ emojiRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
589
+ validation: "emoji",
590
+ code: ZodIssueCode.invalid_string,
591
+ message: check.message
592
+ }), status.dirty());
593
+ else if (check.kind === "uuid")
594
+ uuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
595
+ validation: "uuid",
596
+ code: ZodIssueCode.invalid_string,
597
+ message: check.message
598
+ }), status.dirty());
599
+ else if (check.kind === "cuid")
600
+ cuidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
601
+ validation: "cuid",
602
+ code: ZodIssueCode.invalid_string,
603
+ message: check.message
604
+ }), status.dirty());
605
+ else if (check.kind === "cuid2")
606
+ cuid2Regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
607
+ validation: "cuid2",
608
+ code: ZodIssueCode.invalid_string,
609
+ message: check.message
610
+ }), status.dirty());
611
+ else if (check.kind === "ulid")
612
+ ulidRegex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
613
+ validation: "ulid",
614
+ code: ZodIssueCode.invalid_string,
615
+ message: check.message
616
+ }), status.dirty());
617
+ else if (check.kind === "url")
618
+ try {
619
+ new URL(input.data);
620
+ } catch {
621
+ ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
622
+ validation: "url",
623
+ code: ZodIssueCode.invalid_string,
624
+ message: check.message
625
+ }), status.dirty();
626
+ }
627
+ else
628
+ check.kind === "regex" ? (check.regex.lastIndex = 0, check.regex.test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
629
+ validation: "regex",
630
+ code: ZodIssueCode.invalid_string,
631
+ message: check.message
632
+ }), status.dirty())) : check.kind === "trim" ? input.data = input.data.trim() : check.kind === "includes" ? input.data.includes(check.value, check.position) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
633
+ code: ZodIssueCode.invalid_string,
634
+ validation: { includes: check.value, position: check.position },
635
+ message: check.message
636
+ }), status.dirty()) : check.kind === "toLowerCase" ? input.data = input.data.toLowerCase() : check.kind === "toUpperCase" ? input.data = input.data.toUpperCase() : check.kind === "startsWith" ? input.data.startsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
637
+ code: ZodIssueCode.invalid_string,
638
+ validation: { startsWith: check.value },
639
+ message: check.message
640
+ }), status.dirty()) : check.kind === "endsWith" ? input.data.endsWith(check.value) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
641
+ code: ZodIssueCode.invalid_string,
642
+ validation: { endsWith: check.value },
643
+ message: check.message
644
+ }), status.dirty()) : check.kind === "datetime" ? datetimeRegex(check).test(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
645
+ code: ZodIssueCode.invalid_string,
646
+ validation: "datetime",
647
+ message: check.message
648
+ }), status.dirty()) : check.kind === "ip" ? isValidIP(input.data, check.version) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
649
+ validation: "ip",
650
+ code: ZodIssueCode.invalid_string,
651
+ message: check.message
652
+ }), status.dirty()) : util.assertNever(check);
653
+ return { status: status.value, value: input.data };
654
+ }
655
+ _addCheck(check) {
656
+ return new ZodString({
657
+ ...this._def,
658
+ checks: [...this._def.checks, check]
659
+ });
660
+ }
661
+ email(message) {
662
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
663
+ }
664
+ url(message) {
665
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
666
+ }
667
+ emoji(message) {
668
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
669
+ }
670
+ uuid(message) {
671
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
672
+ }
673
+ cuid(message) {
674
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
675
+ }
676
+ cuid2(message) {
677
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
678
+ }
679
+ ulid(message) {
680
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
681
+ }
682
+ ip(options) {
683
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
684
+ }
685
+ datetime(options) {
686
+ var _a;
687
+ return typeof options == "string" ? this._addCheck({
688
+ kind: "datetime",
689
+ precision: null,
690
+ offset: !1,
691
+ message: options
692
+ }) : this._addCheck({
693
+ kind: "datetime",
694
+ precision: typeof options?.precision > "u" ? null : options?.precision,
695
+ offset: (_a = options?.offset) !== null && _a !== void 0 ? _a : !1,
696
+ ...errorUtil.errToObj(options?.message)
697
+ });
698
+ }
699
+ regex(regex, message) {
700
+ return this._addCheck({
701
+ kind: "regex",
702
+ regex,
703
+ ...errorUtil.errToObj(message)
704
+ });
705
+ }
706
+ includes(value, options) {
707
+ return this._addCheck({
708
+ kind: "includes",
709
+ value,
710
+ position: options?.position,
711
+ ...errorUtil.errToObj(options?.message)
712
+ });
713
+ }
714
+ startsWith(value, message) {
715
+ return this._addCheck({
716
+ kind: "startsWith",
717
+ value,
718
+ ...errorUtil.errToObj(message)
719
+ });
720
+ }
721
+ endsWith(value, message) {
722
+ return this._addCheck({
723
+ kind: "endsWith",
724
+ value,
725
+ ...errorUtil.errToObj(message)
726
+ });
727
+ }
728
+ min(minLength, message) {
729
+ return this._addCheck({
730
+ kind: "min",
731
+ value: minLength,
732
+ ...errorUtil.errToObj(message)
733
+ });
734
+ }
735
+ max(maxLength, message) {
736
+ return this._addCheck({
737
+ kind: "max",
738
+ value: maxLength,
739
+ ...errorUtil.errToObj(message)
740
+ });
741
+ }
742
+ length(len, message) {
743
+ return this._addCheck({
744
+ kind: "length",
745
+ value: len,
746
+ ...errorUtil.errToObj(message)
747
+ });
748
+ }
749
+ get isDatetime() {
750
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
751
+ }
752
+ get isEmail() {
753
+ return !!this._def.checks.find((ch) => ch.kind === "email");
754
+ }
755
+ get isURL() {
756
+ return !!this._def.checks.find((ch) => ch.kind === "url");
757
+ }
758
+ get isEmoji() {
759
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
760
+ }
761
+ get isUUID() {
762
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
763
+ }
764
+ get isCUID() {
765
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
766
+ }
767
+ get isCUID2() {
768
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
769
+ }
770
+ get isULID() {
771
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
772
+ }
773
+ get isIP() {
774
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
775
+ }
776
+ get minLength() {
777
+ let min = null;
778
+ for (let ch of this._def.checks)
779
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
780
+ return min;
781
+ }
782
+ get maxLength() {
783
+ let max = null;
784
+ for (let ch of this._def.checks)
785
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
786
+ return max;
787
+ }
788
+ };
789
+ ZodString.create = (params) => {
790
+ var _a;
791
+ return new ZodString({
792
+ checks: [],
793
+ typeName: ZodFirstPartyTypeKind.ZodString,
794
+ coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1,
795
+ ...processCreateParams(params)
796
+ });
797
+ };
798
+ function floatSafeRemainder(val, step) {
799
+ let valDecCount = (val.toString().split(".")[1] || "").length, stepDecCount = (step.toString().split(".")[1] || "").length, decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount, valInt = parseInt(val.toFixed(decCount).replace(".", "")), stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
800
+ return valInt % stepInt / Math.pow(10, decCount);
801
+ }
802
+ var ZodNumber = class extends ZodType {
803
+ constructor() {
804
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
805
+ }
806
+ _parse(input) {
807
+ if (this._def.coerce && (input.data = Number(input.data)), this._getType(input) !== ZodParsedType.number) {
808
+ let ctx2 = this._getOrReturnCtx(input);
809
+ return addIssueToContext(ctx2, {
810
+ code: ZodIssueCode.invalid_type,
811
+ expected: ZodParsedType.number,
812
+ received: ctx2.parsedType
813
+ }), INVALID;
814
+ }
815
+ let ctx, status = new ParseStatus();
816
+ for (let check of this._def.checks)
817
+ check.kind === "int" ? util.isInteger(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
818
+ code: ZodIssueCode.invalid_type,
819
+ expected: "integer",
820
+ received: "float",
821
+ message: check.message
822
+ }), status.dirty()) : check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
823
+ code: ZodIssueCode.too_small,
824
+ minimum: check.value,
825
+ type: "number",
826
+ inclusive: check.inclusive,
827
+ exact: !1,
828
+ message: check.message
829
+ }), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
830
+ code: ZodIssueCode.too_big,
831
+ maximum: check.value,
832
+ type: "number",
833
+ inclusive: check.inclusive,
834
+ exact: !1,
835
+ message: check.message
836
+ }), status.dirty()) : check.kind === "multipleOf" ? floatSafeRemainder(input.data, check.value) !== 0 && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
837
+ code: ZodIssueCode.not_multiple_of,
838
+ multipleOf: check.value,
839
+ message: check.message
840
+ }), status.dirty()) : check.kind === "finite" ? Number.isFinite(input.data) || (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
841
+ code: ZodIssueCode.not_finite,
842
+ message: check.message
843
+ }), status.dirty()) : util.assertNever(check);
844
+ return { status: status.value, value: input.data };
845
+ }
846
+ gte(value, message) {
847
+ return this.setLimit("min", value, !0, errorUtil.toString(message));
848
+ }
849
+ gt(value, message) {
850
+ return this.setLimit("min", value, !1, errorUtil.toString(message));
851
+ }
852
+ lte(value, message) {
853
+ return this.setLimit("max", value, !0, errorUtil.toString(message));
854
+ }
855
+ lt(value, message) {
856
+ return this.setLimit("max", value, !1, errorUtil.toString(message));
857
+ }
858
+ setLimit(kind, value, inclusive, message) {
859
+ return new ZodNumber({
860
+ ...this._def,
861
+ checks: [
862
+ ...this._def.checks,
863
+ {
864
+ kind,
865
+ value,
866
+ inclusive,
867
+ message: errorUtil.toString(message)
868
+ }
869
+ ]
870
+ });
871
+ }
872
+ _addCheck(check) {
873
+ return new ZodNumber({
874
+ ...this._def,
875
+ checks: [...this._def.checks, check]
876
+ });
877
+ }
878
+ int(message) {
879
+ return this._addCheck({
880
+ kind: "int",
881
+ message: errorUtil.toString(message)
882
+ });
883
+ }
884
+ positive(message) {
885
+ return this._addCheck({
886
+ kind: "min",
887
+ value: 0,
888
+ inclusive: !1,
889
+ message: errorUtil.toString(message)
890
+ });
891
+ }
892
+ negative(message) {
893
+ return this._addCheck({
894
+ kind: "max",
895
+ value: 0,
896
+ inclusive: !1,
897
+ message: errorUtil.toString(message)
898
+ });
899
+ }
900
+ nonpositive(message) {
901
+ return this._addCheck({
902
+ kind: "max",
903
+ value: 0,
904
+ inclusive: !0,
905
+ message: errorUtil.toString(message)
906
+ });
907
+ }
908
+ nonnegative(message) {
909
+ return this._addCheck({
910
+ kind: "min",
911
+ value: 0,
912
+ inclusive: !0,
913
+ message: errorUtil.toString(message)
914
+ });
915
+ }
916
+ multipleOf(value, message) {
917
+ return this._addCheck({
918
+ kind: "multipleOf",
919
+ value,
920
+ message: errorUtil.toString(message)
921
+ });
922
+ }
923
+ finite(message) {
924
+ return this._addCheck({
925
+ kind: "finite",
926
+ message: errorUtil.toString(message)
927
+ });
928
+ }
929
+ safe(message) {
930
+ return this._addCheck({
931
+ kind: "min",
932
+ inclusive: !0,
933
+ value: Number.MIN_SAFE_INTEGER,
934
+ message: errorUtil.toString(message)
935
+ })._addCheck({
936
+ kind: "max",
937
+ inclusive: !0,
938
+ value: Number.MAX_SAFE_INTEGER,
939
+ message: errorUtil.toString(message)
940
+ });
941
+ }
942
+ get minValue() {
943
+ let min = null;
944
+ for (let ch of this._def.checks)
945
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
946
+ return min;
947
+ }
948
+ get maxValue() {
949
+ let max = null;
950
+ for (let ch of this._def.checks)
951
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
952
+ return max;
953
+ }
954
+ get isInt() {
955
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
956
+ }
957
+ get isFinite() {
958
+ let max = null, min = null;
959
+ for (let ch of this._def.checks) {
960
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf")
961
+ return !0;
962
+ ch.kind === "min" ? (min === null || ch.value > min) && (min = ch.value) : ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
963
+ }
964
+ return Number.isFinite(min) && Number.isFinite(max);
965
+ }
966
+ };
967
+ ZodNumber.create = (params) => new ZodNumber({
968
+ checks: [],
969
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
970
+ coerce: params?.coerce || !1,
971
+ ...processCreateParams(params)
972
+ });
973
+ var ZodBigInt = class extends ZodType {
974
+ constructor() {
975
+ super(...arguments), this.min = this.gte, this.max = this.lte;
976
+ }
977
+ _parse(input) {
978
+ if (this._def.coerce && (input.data = BigInt(input.data)), this._getType(input) !== ZodParsedType.bigint) {
979
+ let ctx2 = this._getOrReturnCtx(input);
980
+ return addIssueToContext(ctx2, {
981
+ code: ZodIssueCode.invalid_type,
982
+ expected: ZodParsedType.bigint,
983
+ received: ctx2.parsedType
984
+ }), INVALID;
985
+ }
986
+ let ctx, status = new ParseStatus();
987
+ for (let check of this._def.checks)
988
+ check.kind === "min" ? (check.inclusive ? input.data < check.value : input.data <= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
989
+ code: ZodIssueCode.too_small,
990
+ type: "bigint",
991
+ minimum: check.value,
992
+ inclusive: check.inclusive,
993
+ message: check.message
994
+ }), status.dirty()) : check.kind === "max" ? (check.inclusive ? input.data > check.value : input.data >= check.value) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
995
+ code: ZodIssueCode.too_big,
996
+ type: "bigint",
997
+ maximum: check.value,
998
+ inclusive: check.inclusive,
999
+ message: check.message
1000
+ }), status.dirty()) : check.kind === "multipleOf" ? input.data % check.value !== BigInt(0) && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1001
+ code: ZodIssueCode.not_multiple_of,
1002
+ multipleOf: check.value,
1003
+ message: check.message
1004
+ }), status.dirty()) : util.assertNever(check);
1005
+ return { status: status.value, value: input.data };
1006
+ }
1007
+ gte(value, message) {
1008
+ return this.setLimit("min", value, !0, errorUtil.toString(message));
1009
+ }
1010
+ gt(value, message) {
1011
+ return this.setLimit("min", value, !1, errorUtil.toString(message));
1012
+ }
1013
+ lte(value, message) {
1014
+ return this.setLimit("max", value, !0, errorUtil.toString(message));
1015
+ }
1016
+ lt(value, message) {
1017
+ return this.setLimit("max", value, !1, errorUtil.toString(message));
1018
+ }
1019
+ setLimit(kind, value, inclusive, message) {
1020
+ return new ZodBigInt({
1021
+ ...this._def,
1022
+ checks: [
1023
+ ...this._def.checks,
1024
+ {
1025
+ kind,
1026
+ value,
1027
+ inclusive,
1028
+ message: errorUtil.toString(message)
1029
+ }
1030
+ ]
1031
+ });
1032
+ }
1033
+ _addCheck(check) {
1034
+ return new ZodBigInt({
1035
+ ...this._def,
1036
+ checks: [...this._def.checks, check]
1037
+ });
1038
+ }
1039
+ positive(message) {
1040
+ return this._addCheck({
1041
+ kind: "min",
1042
+ value: BigInt(0),
1043
+ inclusive: !1,
1044
+ message: errorUtil.toString(message)
1045
+ });
1046
+ }
1047
+ negative(message) {
1048
+ return this._addCheck({
1049
+ kind: "max",
1050
+ value: BigInt(0),
1051
+ inclusive: !1,
1052
+ message: errorUtil.toString(message)
1053
+ });
1054
+ }
1055
+ nonpositive(message) {
1056
+ return this._addCheck({
1057
+ kind: "max",
1058
+ value: BigInt(0),
1059
+ inclusive: !0,
1060
+ message: errorUtil.toString(message)
1061
+ });
1062
+ }
1063
+ nonnegative(message) {
1064
+ return this._addCheck({
1065
+ kind: "min",
1066
+ value: BigInt(0),
1067
+ inclusive: !0,
1068
+ message: errorUtil.toString(message)
1069
+ });
1070
+ }
1071
+ multipleOf(value, message) {
1072
+ return this._addCheck({
1073
+ kind: "multipleOf",
1074
+ value,
1075
+ message: errorUtil.toString(message)
1076
+ });
1077
+ }
1078
+ get minValue() {
1079
+ let min = null;
1080
+ for (let ch of this._def.checks)
1081
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
1082
+ return min;
1083
+ }
1084
+ get maxValue() {
1085
+ let max = null;
1086
+ for (let ch of this._def.checks)
1087
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
1088
+ return max;
1089
+ }
1090
+ };
1091
+ ZodBigInt.create = (params) => {
1092
+ var _a;
1093
+ return new ZodBigInt({
1094
+ checks: [],
1095
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1096
+ coerce: (_a = params?.coerce) !== null && _a !== void 0 ? _a : !1,
1097
+ ...processCreateParams(params)
1098
+ });
1099
+ };
1100
+ var ZodBoolean = class extends ZodType {
1101
+ _parse(input) {
1102
+ if (this._def.coerce && (input.data = !!input.data), this._getType(input) !== ZodParsedType.boolean) {
1103
+ let ctx = this._getOrReturnCtx(input);
1104
+ return addIssueToContext(ctx, {
1105
+ code: ZodIssueCode.invalid_type,
1106
+ expected: ZodParsedType.boolean,
1107
+ received: ctx.parsedType
1108
+ }), INVALID;
1109
+ }
1110
+ return OK(input.data);
1111
+ }
1112
+ };
1113
+ ZodBoolean.create = (params) => new ZodBoolean({
1114
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1115
+ coerce: params?.coerce || !1,
1116
+ ...processCreateParams(params)
1117
+ });
1118
+ var ZodDate = class extends ZodType {
1119
+ _parse(input) {
1120
+ if (this._def.coerce && (input.data = new Date(input.data)), this._getType(input) !== ZodParsedType.date) {
1121
+ let ctx2 = this._getOrReturnCtx(input);
1122
+ return addIssueToContext(ctx2, {
1123
+ code: ZodIssueCode.invalid_type,
1124
+ expected: ZodParsedType.date,
1125
+ received: ctx2.parsedType
1126
+ }), INVALID;
1127
+ }
1128
+ if (isNaN(input.data.getTime())) {
1129
+ let ctx2 = this._getOrReturnCtx(input);
1130
+ return addIssueToContext(ctx2, {
1131
+ code: ZodIssueCode.invalid_date
1132
+ }), INVALID;
1133
+ }
1134
+ let status = new ParseStatus(), ctx;
1135
+ for (let check of this._def.checks)
1136
+ check.kind === "min" ? input.data.getTime() < check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1137
+ code: ZodIssueCode.too_small,
1138
+ message: check.message,
1139
+ inclusive: !0,
1140
+ exact: !1,
1141
+ minimum: check.value,
1142
+ type: "date"
1143
+ }), status.dirty()) : check.kind === "max" ? input.data.getTime() > check.value && (ctx = this._getOrReturnCtx(input, ctx), addIssueToContext(ctx, {
1144
+ code: ZodIssueCode.too_big,
1145
+ message: check.message,
1146
+ inclusive: !0,
1147
+ exact: !1,
1148
+ maximum: check.value,
1149
+ type: "date"
1150
+ }), status.dirty()) : util.assertNever(check);
1151
+ return {
1152
+ status: status.value,
1153
+ value: new Date(input.data.getTime())
1154
+ };
1155
+ }
1156
+ _addCheck(check) {
1157
+ return new ZodDate({
1158
+ ...this._def,
1159
+ checks: [...this._def.checks, check]
1160
+ });
1161
+ }
1162
+ min(minDate, message) {
1163
+ return this._addCheck({
1164
+ kind: "min",
1165
+ value: minDate.getTime(),
1166
+ message: errorUtil.toString(message)
1167
+ });
1168
+ }
1169
+ max(maxDate, message) {
1170
+ return this._addCheck({
1171
+ kind: "max",
1172
+ value: maxDate.getTime(),
1173
+ message: errorUtil.toString(message)
1174
+ });
1175
+ }
1176
+ get minDate() {
1177
+ let min = null;
1178
+ for (let ch of this._def.checks)
1179
+ ch.kind === "min" && (min === null || ch.value > min) && (min = ch.value);
1180
+ return min != null ? new Date(min) : null;
1181
+ }
1182
+ get maxDate() {
1183
+ let max = null;
1184
+ for (let ch of this._def.checks)
1185
+ ch.kind === "max" && (max === null || ch.value < max) && (max = ch.value);
1186
+ return max != null ? new Date(max) : null;
1187
+ }
1188
+ };
1189
+ ZodDate.create = (params) => new ZodDate({
1190
+ checks: [],
1191
+ coerce: params?.coerce || !1,
1192
+ typeName: ZodFirstPartyTypeKind.ZodDate,
1193
+ ...processCreateParams(params)
1194
+ });
1195
+ var ZodSymbol = class extends ZodType {
1196
+ _parse(input) {
1197
+ if (this._getType(input) !== ZodParsedType.symbol) {
1198
+ let ctx = this._getOrReturnCtx(input);
1199
+ return addIssueToContext(ctx, {
1200
+ code: ZodIssueCode.invalid_type,
1201
+ expected: ZodParsedType.symbol,
1202
+ received: ctx.parsedType
1203
+ }), INVALID;
1204
+ }
1205
+ return OK(input.data);
1206
+ }
1207
+ };
1208
+ ZodSymbol.create = (params) => new ZodSymbol({
1209
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
1210
+ ...processCreateParams(params)
1211
+ });
1212
+ var ZodUndefined = class extends ZodType {
1213
+ _parse(input) {
1214
+ if (this._getType(input) !== ZodParsedType.undefined) {
1215
+ let ctx = this._getOrReturnCtx(input);
1216
+ return addIssueToContext(ctx, {
1217
+ code: ZodIssueCode.invalid_type,
1218
+ expected: ZodParsedType.undefined,
1219
+ received: ctx.parsedType
1220
+ }), INVALID;
1221
+ }
1222
+ return OK(input.data);
1223
+ }
1224
+ };
1225
+ ZodUndefined.create = (params) => new ZodUndefined({
1226
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
1227
+ ...processCreateParams(params)
1228
+ });
1229
+ var ZodNull = class extends ZodType {
1230
+ _parse(input) {
1231
+ if (this._getType(input) !== ZodParsedType.null) {
1232
+ let ctx = this._getOrReturnCtx(input);
1233
+ return addIssueToContext(ctx, {
1234
+ code: ZodIssueCode.invalid_type,
1235
+ expected: ZodParsedType.null,
1236
+ received: ctx.parsedType
1237
+ }), INVALID;
1238
+ }
1239
+ return OK(input.data);
1240
+ }
1241
+ };
1242
+ ZodNull.create = (params) => new ZodNull({
1243
+ typeName: ZodFirstPartyTypeKind.ZodNull,
1244
+ ...processCreateParams(params)
1245
+ });
1246
+ var ZodAny = class extends ZodType {
1247
+ constructor() {
1248
+ super(...arguments), this._any = !0;
1249
+ }
1250
+ _parse(input) {
1251
+ return OK(input.data);
1252
+ }
1253
+ };
1254
+ ZodAny.create = (params) => new ZodAny({
1255
+ typeName: ZodFirstPartyTypeKind.ZodAny,
1256
+ ...processCreateParams(params)
1257
+ });
1258
+ var ZodUnknown = class extends ZodType {
1259
+ constructor() {
1260
+ super(...arguments), this._unknown = !0;
1261
+ }
1262
+ _parse(input) {
1263
+ return OK(input.data);
1264
+ }
1265
+ };
1266
+ ZodUnknown.create = (params) => new ZodUnknown({
1267
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
1268
+ ...processCreateParams(params)
1269
+ });
1270
+ var ZodNever = class extends ZodType {
1271
+ _parse(input) {
1272
+ let ctx = this._getOrReturnCtx(input);
1273
+ return addIssueToContext(ctx, {
1274
+ code: ZodIssueCode.invalid_type,
1275
+ expected: ZodParsedType.never,
1276
+ received: ctx.parsedType
1277
+ }), INVALID;
1278
+ }
1279
+ };
1280
+ ZodNever.create = (params) => new ZodNever({
1281
+ typeName: ZodFirstPartyTypeKind.ZodNever,
1282
+ ...processCreateParams(params)
1283
+ });
1284
+ var ZodVoid = class extends ZodType {
1285
+ _parse(input) {
1286
+ if (this._getType(input) !== ZodParsedType.undefined) {
1287
+ let ctx = this._getOrReturnCtx(input);
1288
+ return addIssueToContext(ctx, {
1289
+ code: ZodIssueCode.invalid_type,
1290
+ expected: ZodParsedType.void,
1291
+ received: ctx.parsedType
1292
+ }), INVALID;
1293
+ }
1294
+ return OK(input.data);
1295
+ }
1296
+ };
1297
+ ZodVoid.create = (params) => new ZodVoid({
1298
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
1299
+ ...processCreateParams(params)
1300
+ });
1301
+ var ZodArray = class extends ZodType {
1302
+ _parse(input) {
1303
+ let { ctx, status } = this._processInputParams(input), def = this._def;
1304
+ if (ctx.parsedType !== ZodParsedType.array)
1305
+ return addIssueToContext(ctx, {
1306
+ code: ZodIssueCode.invalid_type,
1307
+ expected: ZodParsedType.array,
1308
+ received: ctx.parsedType
1309
+ }), INVALID;
1310
+ if (def.exactLength !== null) {
1311
+ let tooBig = ctx.data.length > def.exactLength.value, tooSmall = ctx.data.length < def.exactLength.value;
1312
+ (tooBig || tooSmall) && (addIssueToContext(ctx, {
1313
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
1314
+ minimum: tooSmall ? def.exactLength.value : void 0,
1315
+ maximum: tooBig ? def.exactLength.value : void 0,
1316
+ type: "array",
1317
+ inclusive: !0,
1318
+ exact: !0,
1319
+ message: def.exactLength.message
1320
+ }), status.dirty());
1321
+ }
1322
+ if (def.minLength !== null && ctx.data.length < def.minLength.value && (addIssueToContext(ctx, {
1323
+ code: ZodIssueCode.too_small,
1324
+ minimum: def.minLength.value,
1325
+ type: "array",
1326
+ inclusive: !0,
1327
+ exact: !1,
1328
+ message: def.minLength.message
1329
+ }), status.dirty()), def.maxLength !== null && ctx.data.length > def.maxLength.value && (addIssueToContext(ctx, {
1330
+ code: ZodIssueCode.too_big,
1331
+ maximum: def.maxLength.value,
1332
+ type: "array",
1333
+ inclusive: !0,
1334
+ exact: !1,
1335
+ message: def.maxLength.message
1336
+ }), status.dirty()), ctx.common.async)
1337
+ return Promise.all([...ctx.data].map((item, i) => def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i)))).then((result2) => ParseStatus.mergeArray(status, result2));
1338
+ let result = [...ctx.data].map((item, i) => def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i)));
1339
+ return ParseStatus.mergeArray(status, result);
1340
+ }
1341
+ get element() {
1342
+ return this._def.type;
1343
+ }
1344
+ min(minLength, message) {
1345
+ return new ZodArray({
1346
+ ...this._def,
1347
+ minLength: { value: minLength, message: errorUtil.toString(message) }
1348
+ });
1349
+ }
1350
+ max(maxLength, message) {
1351
+ return new ZodArray({
1352
+ ...this._def,
1353
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
1354
+ });
1355
+ }
1356
+ length(len, message) {
1357
+ return new ZodArray({
1358
+ ...this._def,
1359
+ exactLength: { value: len, message: errorUtil.toString(message) }
1360
+ });
1361
+ }
1362
+ nonempty(message) {
1363
+ return this.min(1, message);
1364
+ }
1365
+ };
1366
+ ZodArray.create = (schema, params) => new ZodArray({
1367
+ type: schema,
1368
+ minLength: null,
1369
+ maxLength: null,
1370
+ exactLength: null,
1371
+ typeName: ZodFirstPartyTypeKind.ZodArray,
1372
+ ...processCreateParams(params)
1373
+ });
1374
+ function deepPartialify(schema) {
1375
+ if (schema instanceof ZodObject) {
1376
+ let newShape = {};
1377
+ for (let key in schema.shape) {
1378
+ let fieldSchema = schema.shape[key];
1379
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
1380
+ }
1381
+ return new ZodObject({
1382
+ ...schema._def,
1383
+ shape: () => newShape
1384
+ });
1385
+ } else
1386
+ return schema instanceof ZodArray ? new ZodArray({
1387
+ ...schema._def,
1388
+ type: deepPartialify(schema.element)
1389
+ }) : schema instanceof ZodOptional ? ZodOptional.create(deepPartialify(schema.unwrap())) : schema instanceof ZodNullable ? ZodNullable.create(deepPartialify(schema.unwrap())) : schema instanceof ZodTuple ? ZodTuple.create(schema.items.map((item) => deepPartialify(item))) : schema;
1390
+ }
1391
+ var ZodObject = class extends ZodType {
1392
+ constructor() {
1393
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1394
+ }
1395
+ _getCached() {
1396
+ if (this._cached !== null)
1397
+ return this._cached;
1398
+ let shape = this._def.shape(), keys = util.objectKeys(shape);
1399
+ return this._cached = { shape, keys };
1400
+ }
1401
+ _parse(input) {
1402
+ if (this._getType(input) !== ZodParsedType.object) {
1403
+ let ctx2 = this._getOrReturnCtx(input);
1404
+ return addIssueToContext(ctx2, {
1405
+ code: ZodIssueCode.invalid_type,
1406
+ expected: ZodParsedType.object,
1407
+ received: ctx2.parsedType
1408
+ }), INVALID;
1409
+ }
1410
+ let { status, ctx } = this._processInputParams(input), { shape, keys: shapeKeys } = this._getCached(), extraKeys = [];
1411
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip"))
1412
+ for (let key in ctx.data)
1413
+ shapeKeys.includes(key) || extraKeys.push(key);
1414
+ let pairs = [];
1415
+ for (let key of shapeKeys) {
1416
+ let keyValidator = shape[key], value = ctx.data[key];
1417
+ pairs.push({
1418
+ key: { status: "valid", value: key },
1419
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
1420
+ alwaysSet: key in ctx.data
1421
+ });
1422
+ }
1423
+ if (this._def.catchall instanceof ZodNever) {
1424
+ let unknownKeys = this._def.unknownKeys;
1425
+ if (unknownKeys === "passthrough")
1426
+ for (let key of extraKeys)
1427
+ pairs.push({
1428
+ key: { status: "valid", value: key },
1429
+ value: { status: "valid", value: ctx.data[key] }
1430
+ });
1431
+ else if (unknownKeys === "strict")
1432
+ extraKeys.length > 0 && (addIssueToContext(ctx, {
1433
+ code: ZodIssueCode.unrecognized_keys,
1434
+ keys: extraKeys
1435
+ }), status.dirty());
1436
+ else if (unknownKeys !== "strip")
1437
+ throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1438
+ } else {
1439
+ let catchall = this._def.catchall;
1440
+ for (let key of extraKeys) {
1441
+ let value = ctx.data[key];
1442
+ pairs.push({
1443
+ key: { status: "valid", value: key },
1444
+ value: catchall._parse(
1445
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
1446
+ //, ctx.child(key), value, getParsedType(value)
1447
+ ),
1448
+ alwaysSet: key in ctx.data
1449
+ });
1450
+ }
1451
+ }
1452
+ return ctx.common.async ? Promise.resolve().then(async () => {
1453
+ let syncPairs = [];
1454
+ for (let pair of pairs) {
1455
+ let key = await pair.key;
1456
+ syncPairs.push({
1457
+ key,
1458
+ value: await pair.value,
1459
+ alwaysSet: pair.alwaysSet
1460
+ });
1461
+ }
1462
+ return syncPairs;
1463
+ }).then((syncPairs) => ParseStatus.mergeObjectSync(status, syncPairs)) : ParseStatus.mergeObjectSync(status, pairs);
1464
+ }
1465
+ get shape() {
1466
+ return this._def.shape();
1467
+ }
1468
+ strict(message) {
1469
+ return errorUtil.errToObj, new ZodObject({
1470
+ ...this._def,
1471
+ unknownKeys: "strict",
1472
+ ...message !== void 0 ? {
1473
+ errorMap: (issue, ctx) => {
1474
+ var _a, _b, _c, _d;
1475
+ let defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
1476
+ return issue.code === "unrecognized_keys" ? {
1477
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
1478
+ } : {
1479
+ message: defaultError
1480
+ };
1481
+ }
1482
+ } : {}
1483
+ });
1484
+ }
1485
+ strip() {
1486
+ return new ZodObject({
1487
+ ...this._def,
1488
+ unknownKeys: "strip"
1489
+ });
1490
+ }
1491
+ passthrough() {
1492
+ return new ZodObject({
1493
+ ...this._def,
1494
+ unknownKeys: "passthrough"
1495
+ });
1496
+ }
1497
+ // const AugmentFactory =
1498
+ // <Def extends ZodObjectDef>(def: Def) =>
1499
+ // <Augmentation extends ZodRawShape>(
1500
+ // augmentation: Augmentation
1501
+ // ): ZodObject<
1502
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1503
+ // Def["unknownKeys"],
1504
+ // Def["catchall"]
1505
+ // > => {
1506
+ // return new ZodObject({
1507
+ // ...def,
1508
+ // shape: () => ({
1509
+ // ...def.shape(),
1510
+ // ...augmentation,
1511
+ // }),
1512
+ // }) as any;
1513
+ // };
1514
+ extend(augmentation) {
1515
+ return new ZodObject({
1516
+ ...this._def,
1517
+ shape: () => ({
1518
+ ...this._def.shape(),
1519
+ ...augmentation
1520
+ })
1521
+ });
1522
+ }
1523
+ /**
1524
+ * Prior to zod@1.0.12 there was a bug in the
1525
+ * inferred type of merged objects. Please
1526
+ * upgrade if you are experiencing issues.
1527
+ */
1528
+ merge(merging) {
1529
+ return new ZodObject({
1530
+ unknownKeys: merging._def.unknownKeys,
1531
+ catchall: merging._def.catchall,
1532
+ shape: () => ({
1533
+ ...this._def.shape(),
1534
+ ...merging._def.shape()
1535
+ }),
1536
+ typeName: ZodFirstPartyTypeKind.ZodObject
1537
+ });
1538
+ }
1539
+ // merge<
1540
+ // Incoming extends AnyZodObject,
1541
+ // Augmentation extends Incoming["shape"],
1542
+ // NewOutput extends {
1543
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1544
+ // ? Augmentation[k]["_output"]
1545
+ // : k extends keyof Output
1546
+ // ? Output[k]
1547
+ // : never;
1548
+ // },
1549
+ // NewInput extends {
1550
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1551
+ // ? Augmentation[k]["_input"]
1552
+ // : k extends keyof Input
1553
+ // ? Input[k]
1554
+ // : never;
1555
+ // }
1556
+ // >(
1557
+ // merging: Incoming
1558
+ // ): ZodObject<
1559
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1560
+ // Incoming["_def"]["unknownKeys"],
1561
+ // Incoming["_def"]["catchall"],
1562
+ // NewOutput,
1563
+ // NewInput
1564
+ // > {
1565
+ // const merged: any = new ZodObject({
1566
+ // unknownKeys: merging._def.unknownKeys,
1567
+ // catchall: merging._def.catchall,
1568
+ // shape: () =>
1569
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1570
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1571
+ // }) as any;
1572
+ // return merged;
1573
+ // }
1574
+ setKey(key, schema) {
1575
+ return this.augment({ [key]: schema });
1576
+ }
1577
+ // merge<Incoming extends AnyZodObject>(
1578
+ // merging: Incoming
1579
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1580
+ // ZodObject<
1581
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1582
+ // Incoming["_def"]["unknownKeys"],
1583
+ // Incoming["_def"]["catchall"]
1584
+ // > {
1585
+ // // const mergedShape = objectUtil.mergeShapes(
1586
+ // // this._def.shape(),
1587
+ // // merging._def.shape()
1588
+ // // );
1589
+ // const merged: any = new ZodObject({
1590
+ // unknownKeys: merging._def.unknownKeys,
1591
+ // catchall: merging._def.catchall,
1592
+ // shape: () =>
1593
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1594
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1595
+ // }) as any;
1596
+ // return merged;
1597
+ // }
1598
+ catchall(index) {
1599
+ return new ZodObject({
1600
+ ...this._def,
1601
+ catchall: index
1602
+ });
1603
+ }
1604
+ pick(mask) {
1605
+ let shape = {};
1606
+ return util.objectKeys(mask).forEach((key) => {
1607
+ mask[key] && this.shape[key] && (shape[key] = this.shape[key]);
1608
+ }), new ZodObject({
1609
+ ...this._def,
1610
+ shape: () => shape
1611
+ });
1612
+ }
1613
+ omit(mask) {
1614
+ let shape = {};
1615
+ return util.objectKeys(this.shape).forEach((key) => {
1616
+ mask[key] || (shape[key] = this.shape[key]);
1617
+ }), new ZodObject({
1618
+ ...this._def,
1619
+ shape: () => shape
1620
+ });
1621
+ }
1622
+ /**
1623
+ * @deprecated
1624
+ */
1625
+ deepPartial() {
1626
+ return deepPartialify(this);
1627
+ }
1628
+ partial(mask) {
1629
+ let newShape = {};
1630
+ return util.objectKeys(this.shape).forEach((key) => {
1631
+ let fieldSchema = this.shape[key];
1632
+ mask && !mask[key] ? newShape[key] = fieldSchema : newShape[key] = fieldSchema.optional();
1633
+ }), new ZodObject({
1634
+ ...this._def,
1635
+ shape: () => newShape
1636
+ });
1637
+ }
1638
+ required(mask) {
1639
+ let newShape = {};
1640
+ return util.objectKeys(this.shape).forEach((key) => {
1641
+ if (mask && !mask[key])
1642
+ newShape[key] = this.shape[key];
1643
+ else {
1644
+ let newField = this.shape[key];
1645
+ for (; newField instanceof ZodOptional; )
1646
+ newField = newField._def.innerType;
1647
+ newShape[key] = newField;
1648
+ }
1649
+ }), new ZodObject({
1650
+ ...this._def,
1651
+ shape: () => newShape
1652
+ });
1653
+ }
1654
+ keyof() {
1655
+ return createZodEnum(util.objectKeys(this.shape));
1656
+ }
1657
+ };
1658
+ ZodObject.create = (shape, params) => new ZodObject({
1659
+ shape: () => shape,
1660
+ unknownKeys: "strip",
1661
+ catchall: ZodNever.create(),
1662
+ typeName: ZodFirstPartyTypeKind.ZodObject,
1663
+ ...processCreateParams(params)
1664
+ });
1665
+ ZodObject.strictCreate = (shape, params) => new ZodObject({
1666
+ shape: () => shape,
1667
+ unknownKeys: "strict",
1668
+ catchall: ZodNever.create(),
1669
+ typeName: ZodFirstPartyTypeKind.ZodObject,
1670
+ ...processCreateParams(params)
1671
+ });
1672
+ ZodObject.lazycreate = (shape, params) => new ZodObject({
1673
+ shape,
1674
+ unknownKeys: "strip",
1675
+ catchall: ZodNever.create(),
1676
+ typeName: ZodFirstPartyTypeKind.ZodObject,
1677
+ ...processCreateParams(params)
1678
+ });
1679
+ var ZodUnion = class extends ZodType {
1680
+ _parse(input) {
1681
+ let { ctx } = this._processInputParams(input), options = this._def.options;
1682
+ function handleResults(results) {
1683
+ for (let result of results)
1684
+ if (result.result.status === "valid")
1685
+ return result.result;
1686
+ for (let result of results)
1687
+ if (result.result.status === "dirty")
1688
+ return ctx.common.issues.push(...result.ctx.common.issues), result.result;
1689
+ let unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
1690
+ return addIssueToContext(ctx, {
1691
+ code: ZodIssueCode.invalid_union,
1692
+ unionErrors
1693
+ }), INVALID;
1694
+ }
1695
+ if (ctx.common.async)
1696
+ return Promise.all(options.map(async (option) => {
1697
+ let childCtx = {
1698
+ ...ctx,
1699
+ common: {
1700
+ ...ctx.common,
1701
+ issues: []
1702
+ },
1703
+ parent: null
1704
+ };
1705
+ return {
1706
+ result: await option._parseAsync({
1707
+ data: ctx.data,
1708
+ path: ctx.path,
1709
+ parent: childCtx
1710
+ }),
1711
+ ctx: childCtx
1712
+ };
1713
+ })).then(handleResults);
1714
+ {
1715
+ let dirty, issues = [];
1716
+ for (let option of options) {
1717
+ let childCtx = {
1718
+ ...ctx,
1719
+ common: {
1720
+ ...ctx.common,
1721
+ issues: []
1722
+ },
1723
+ parent: null
1724
+ }, result = option._parseSync({
1725
+ data: ctx.data,
1726
+ path: ctx.path,
1727
+ parent: childCtx
1728
+ });
1729
+ if (result.status === "valid")
1730
+ return result;
1731
+ result.status === "dirty" && !dirty && (dirty = { result, ctx: childCtx }), childCtx.common.issues.length && issues.push(childCtx.common.issues);
1732
+ }
1733
+ if (dirty)
1734
+ return ctx.common.issues.push(...dirty.ctx.common.issues), dirty.result;
1735
+ let unionErrors = issues.map((issues2) => new ZodError(issues2));
1736
+ return addIssueToContext(ctx, {
1737
+ code: ZodIssueCode.invalid_union,
1738
+ unionErrors
1739
+ }), INVALID;
1740
+ }
1741
+ }
1742
+ get options() {
1743
+ return this._def.options;
1744
+ }
1745
+ };
1746
+ ZodUnion.create = (types, params) => new ZodUnion({
1747
+ options: types,
1748
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
1749
+ ...processCreateParams(params)
1750
+ });
1751
+ var getDiscriminator = (type) => type instanceof ZodLazy ? getDiscriminator(type.schema) : type instanceof ZodEffects ? getDiscriminator(type.innerType()) : type instanceof ZodLiteral ? [type.value] : type instanceof ZodEnum ? type.options : type instanceof ZodNativeEnum ? Object.keys(type.enum) : type instanceof ZodDefault ? getDiscriminator(type._def.innerType) : type instanceof ZodUndefined ? [void 0] : type instanceof ZodNull ? [null] : null, ZodDiscriminatedUnion = class extends ZodType {
1752
+ _parse(input) {
1753
+ let { ctx } = this._processInputParams(input);
1754
+ if (ctx.parsedType !== ZodParsedType.object)
1755
+ return addIssueToContext(ctx, {
1756
+ code: ZodIssueCode.invalid_type,
1757
+ expected: ZodParsedType.object,
1758
+ received: ctx.parsedType
1759
+ }), INVALID;
1760
+ let discriminator = this.discriminator, discriminatorValue = ctx.data[discriminator], option = this.optionsMap.get(discriminatorValue);
1761
+ return option ? ctx.common.async ? option._parseAsync({
1762
+ data: ctx.data,
1763
+ path: ctx.path,
1764
+ parent: ctx
1765
+ }) : option._parseSync({
1766
+ data: ctx.data,
1767
+ path: ctx.path,
1768
+ parent: ctx
1769
+ }) : (addIssueToContext(ctx, {
1770
+ code: ZodIssueCode.invalid_union_discriminator,
1771
+ options: Array.from(this.optionsMap.keys()),
1772
+ path: [discriminator]
1773
+ }), INVALID);
1774
+ }
1775
+ get discriminator() {
1776
+ return this._def.discriminator;
1777
+ }
1778
+ get options() {
1779
+ return this._def.options;
1780
+ }
1781
+ get optionsMap() {
1782
+ return this._def.optionsMap;
1783
+ }
1784
+ /**
1785
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1786
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
1787
+ * have a different value for each object in the union.
1788
+ * @param discriminator the name of the discriminator property
1789
+ * @param types an array of object schemas
1790
+ * @param params
1791
+ */
1792
+ static create(discriminator, options, params) {
1793
+ let optionsMap = /* @__PURE__ */ new Map();
1794
+ for (let type of options) {
1795
+ let discriminatorValues = getDiscriminator(type.shape[discriminator]);
1796
+ if (!discriminatorValues)
1797
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
1798
+ for (let value of discriminatorValues) {
1799
+ if (optionsMap.has(value))
1800
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
1801
+ optionsMap.set(value, type);
1802
+ }
1803
+ }
1804
+ return new ZodDiscriminatedUnion({
1805
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
1806
+ discriminator,
1807
+ options,
1808
+ optionsMap,
1809
+ ...processCreateParams(params)
1810
+ });
1811
+ }
1812
+ };
1813
+ function mergeValues(a, b) {
1814
+ let aType = getParsedType(a), bType = getParsedType(b);
1815
+ if (a === b)
1816
+ return { valid: !0, data: a };
1817
+ if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
1818
+ let bKeys = util.objectKeys(b), sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1), newObj = { ...a, ...b };
1819
+ for (let key of sharedKeys) {
1820
+ let sharedValue = mergeValues(a[key], b[key]);
1821
+ if (!sharedValue.valid)
1822
+ return { valid: !1 };
1823
+ newObj[key] = sharedValue.data;
1824
+ }
1825
+ return { valid: !0, data: newObj };
1826
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
1827
+ if (a.length !== b.length)
1828
+ return { valid: !1 };
1829
+ let newArray = [];
1830
+ for (let index = 0; index < a.length; index++) {
1831
+ let itemA = a[index], itemB = b[index], sharedValue = mergeValues(itemA, itemB);
1832
+ if (!sharedValue.valid)
1833
+ return { valid: !1 };
1834
+ newArray.push(sharedValue.data);
1835
+ }
1836
+ return { valid: !0, data: newArray };
1837
+ } else
1838
+ return aType === ZodParsedType.date && bType === ZodParsedType.date && +a == +b ? { valid: !0, data: a } : { valid: !1 };
1839
+ }
1840
+ var ZodIntersection = class extends ZodType {
1841
+ _parse(input) {
1842
+ let { status, ctx } = this._processInputParams(input), handleParsed = (parsedLeft, parsedRight) => {
1843
+ if (isAborted(parsedLeft) || isAborted(parsedRight))
1844
+ return INVALID;
1845
+ let merged = mergeValues(parsedLeft.value, parsedRight.value);
1846
+ return merged.valid ? ((isDirty(parsedLeft) || isDirty(parsedRight)) && status.dirty(), { status: status.value, value: merged.data }) : (addIssueToContext(ctx, {
1847
+ code: ZodIssueCode.invalid_intersection_types
1848
+ }), INVALID);
1849
+ };
1850
+ return ctx.common.async ? Promise.all([
1851
+ this._def.left._parseAsync({
1852
+ data: ctx.data,
1853
+ path: ctx.path,
1854
+ parent: ctx
1855
+ }),
1856
+ this._def.right._parseAsync({
1857
+ data: ctx.data,
1858
+ path: ctx.path,
1859
+ parent: ctx
1860
+ })
1861
+ ]).then(([left, right]) => handleParsed(left, right)) : handleParsed(this._def.left._parseSync({
1862
+ data: ctx.data,
1863
+ path: ctx.path,
1864
+ parent: ctx
1865
+ }), this._def.right._parseSync({
1866
+ data: ctx.data,
1867
+ path: ctx.path,
1868
+ parent: ctx
1869
+ }));
1870
+ }
1871
+ };
1872
+ ZodIntersection.create = (left, right, params) => new ZodIntersection({
1873
+ left,
1874
+ right,
1875
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
1876
+ ...processCreateParams(params)
1877
+ });
1878
+ var ZodTuple = class extends ZodType {
1879
+ _parse(input) {
1880
+ let { status, ctx } = this._processInputParams(input);
1881
+ if (ctx.parsedType !== ZodParsedType.array)
1882
+ return addIssueToContext(ctx, {
1883
+ code: ZodIssueCode.invalid_type,
1884
+ expected: ZodParsedType.array,
1885
+ received: ctx.parsedType
1886
+ }), INVALID;
1887
+ if (ctx.data.length < this._def.items.length)
1888
+ return addIssueToContext(ctx, {
1889
+ code: ZodIssueCode.too_small,
1890
+ minimum: this._def.items.length,
1891
+ inclusive: !0,
1892
+ exact: !1,
1893
+ type: "array"
1894
+ }), INVALID;
1895
+ !this._def.rest && ctx.data.length > this._def.items.length && (addIssueToContext(ctx, {
1896
+ code: ZodIssueCode.too_big,
1897
+ maximum: this._def.items.length,
1898
+ inclusive: !0,
1899
+ exact: !1,
1900
+ type: "array"
1901
+ }), status.dirty());
1902
+ let items = [...ctx.data].map((item, itemIndex) => {
1903
+ let schema = this._def.items[itemIndex] || this._def.rest;
1904
+ return schema ? schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)) : null;
1905
+ }).filter((x) => !!x);
1906
+ return ctx.common.async ? Promise.all(items).then((results) => ParseStatus.mergeArray(status, results)) : ParseStatus.mergeArray(status, items);
1907
+ }
1908
+ get items() {
1909
+ return this._def.items;
1910
+ }
1911
+ rest(rest) {
1912
+ return new ZodTuple({
1913
+ ...this._def,
1914
+ rest
1915
+ });
1916
+ }
1917
+ };
1918
+ ZodTuple.create = (schemas, params) => {
1919
+ if (!Array.isArray(schemas))
1920
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
1921
+ return new ZodTuple({
1922
+ items: schemas,
1923
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
1924
+ rest: null,
1925
+ ...processCreateParams(params)
1926
+ });
1927
+ };
1928
+ var ZodRecord = class extends ZodType {
1929
+ get keySchema() {
1930
+ return this._def.keyType;
1931
+ }
1932
+ get valueSchema() {
1933
+ return this._def.valueType;
1934
+ }
1935
+ _parse(input) {
1936
+ let { status, ctx } = this._processInputParams(input);
1937
+ if (ctx.parsedType !== ZodParsedType.object)
1938
+ return addIssueToContext(ctx, {
1939
+ code: ZodIssueCode.invalid_type,
1940
+ expected: ZodParsedType.object,
1941
+ received: ctx.parsedType
1942
+ }), INVALID;
1943
+ let pairs = [], keyType = this._def.keyType, valueType = this._def.valueType;
1944
+ for (let key in ctx.data)
1945
+ pairs.push({
1946
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
1947
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
1948
+ });
1949
+ return ctx.common.async ? ParseStatus.mergeObjectAsync(status, pairs) : ParseStatus.mergeObjectSync(status, pairs);
1950
+ }
1951
+ get element() {
1952
+ return this._def.valueType;
1953
+ }
1954
+ static create(first, second, third) {
1955
+ return second instanceof ZodType ? new ZodRecord({
1956
+ keyType: first,
1957
+ valueType: second,
1958
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
1959
+ ...processCreateParams(third)
1960
+ }) : new ZodRecord({
1961
+ keyType: ZodString.create(),
1962
+ valueType: first,
1963
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
1964
+ ...processCreateParams(second)
1965
+ });
1966
+ }
1967
+ }, ZodMap = class extends ZodType {
1968
+ get keySchema() {
1969
+ return this._def.keyType;
1970
+ }
1971
+ get valueSchema() {
1972
+ return this._def.valueType;
1973
+ }
1974
+ _parse(input) {
1975
+ let { status, ctx } = this._processInputParams(input);
1976
+ if (ctx.parsedType !== ZodParsedType.map)
1977
+ return addIssueToContext(ctx, {
1978
+ code: ZodIssueCode.invalid_type,
1979
+ expected: ZodParsedType.map,
1980
+ received: ctx.parsedType
1981
+ }), INVALID;
1982
+ let keyType = this._def.keyType, valueType = this._def.valueType, pairs = [...ctx.data.entries()].map(([key, value], index) => ({
1983
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
1984
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
1985
+ }));
1986
+ if (ctx.common.async) {
1987
+ let finalMap = /* @__PURE__ */ new Map();
1988
+ return Promise.resolve().then(async () => {
1989
+ for (let pair of pairs) {
1990
+ let key = await pair.key, value = await pair.value;
1991
+ if (key.status === "aborted" || value.status === "aborted")
1992
+ return INVALID;
1993
+ (key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
1994
+ }
1995
+ return { status: status.value, value: finalMap };
1996
+ });
1997
+ } else {
1998
+ let finalMap = /* @__PURE__ */ new Map();
1999
+ for (let pair of pairs) {
2000
+ let key = pair.key, value = pair.value;
2001
+ if (key.status === "aborted" || value.status === "aborted")
2002
+ return INVALID;
2003
+ (key.status === "dirty" || value.status === "dirty") && status.dirty(), finalMap.set(key.value, value.value);
2004
+ }
2005
+ return { status: status.value, value: finalMap };
2006
+ }
2007
+ }
2008
+ };
2009
+ ZodMap.create = (keyType, valueType, params) => new ZodMap({
2010
+ valueType,
2011
+ keyType,
2012
+ typeName: ZodFirstPartyTypeKind.ZodMap,
2013
+ ...processCreateParams(params)
2014
+ });
2015
+ var ZodSet = class extends ZodType {
2016
+ _parse(input) {
2017
+ let { status, ctx } = this._processInputParams(input);
2018
+ if (ctx.parsedType !== ZodParsedType.set)
2019
+ return addIssueToContext(ctx, {
2020
+ code: ZodIssueCode.invalid_type,
2021
+ expected: ZodParsedType.set,
2022
+ received: ctx.parsedType
2023
+ }), INVALID;
2024
+ let def = this._def;
2025
+ def.minSize !== null && ctx.data.size < def.minSize.value && (addIssueToContext(ctx, {
2026
+ code: ZodIssueCode.too_small,
2027
+ minimum: def.minSize.value,
2028
+ type: "set",
2029
+ inclusive: !0,
2030
+ exact: !1,
2031
+ message: def.minSize.message
2032
+ }), status.dirty()), def.maxSize !== null && ctx.data.size > def.maxSize.value && (addIssueToContext(ctx, {
2033
+ code: ZodIssueCode.too_big,
2034
+ maximum: def.maxSize.value,
2035
+ type: "set",
2036
+ inclusive: !0,
2037
+ exact: !1,
2038
+ message: def.maxSize.message
2039
+ }), status.dirty());
2040
+ let valueType = this._def.valueType;
2041
+ function finalizeSet(elements2) {
2042
+ let parsedSet = /* @__PURE__ */ new Set();
2043
+ for (let element of elements2) {
2044
+ if (element.status === "aborted")
2045
+ return INVALID;
2046
+ element.status === "dirty" && status.dirty(), parsedSet.add(element.value);
2047
+ }
2048
+ return { status: status.value, value: parsedSet };
2049
+ }
2050
+ let elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2051
+ return ctx.common.async ? Promise.all(elements).then((elements2) => finalizeSet(elements2)) : finalizeSet(elements);
2052
+ }
2053
+ min(minSize, message) {
2054
+ return new ZodSet({
2055
+ ...this._def,
2056
+ minSize: { value: minSize, message: errorUtil.toString(message) }
2057
+ });
2058
+ }
2059
+ max(maxSize, message) {
2060
+ return new ZodSet({
2061
+ ...this._def,
2062
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
2063
+ });
2064
+ }
2065
+ size(size, message) {
2066
+ return this.min(size, message).max(size, message);
2067
+ }
2068
+ nonempty(message) {
2069
+ return this.min(1, message);
2070
+ }
2071
+ };
2072
+ ZodSet.create = (valueType, params) => new ZodSet({
2073
+ valueType,
2074
+ minSize: null,
2075
+ maxSize: null,
2076
+ typeName: ZodFirstPartyTypeKind.ZodSet,
2077
+ ...processCreateParams(params)
2078
+ });
2079
+ var ZodFunction = class extends ZodType {
2080
+ constructor() {
2081
+ super(...arguments), this.validate = this.implement;
2082
+ }
2083
+ _parse(input) {
2084
+ let { ctx } = this._processInputParams(input);
2085
+ if (ctx.parsedType !== ZodParsedType.function)
2086
+ return addIssueToContext(ctx, {
2087
+ code: ZodIssueCode.invalid_type,
2088
+ expected: ZodParsedType.function,
2089
+ received: ctx.parsedType
2090
+ }), INVALID;
2091
+ function makeArgsIssue(args, error) {
2092
+ return makeIssue({
2093
+ data: args,
2094
+ path: ctx.path,
2095
+ errorMaps: [
2096
+ ctx.common.contextualErrorMap,
2097
+ ctx.schemaErrorMap,
2098
+ getErrorMap(),
2099
+ errorMap
2100
+ ].filter((x) => !!x),
2101
+ issueData: {
2102
+ code: ZodIssueCode.invalid_arguments,
2103
+ argumentsError: error
2104
+ }
2105
+ });
2106
+ }
2107
+ function makeReturnsIssue(returns, error) {
2108
+ return makeIssue({
2109
+ data: returns,
2110
+ path: ctx.path,
2111
+ errorMaps: [
2112
+ ctx.common.contextualErrorMap,
2113
+ ctx.schemaErrorMap,
2114
+ getErrorMap(),
2115
+ errorMap
2116
+ ].filter((x) => !!x),
2117
+ issueData: {
2118
+ code: ZodIssueCode.invalid_return_type,
2119
+ returnTypeError: error
2120
+ }
2121
+ });
2122
+ }
2123
+ let params = { errorMap: ctx.common.contextualErrorMap }, fn = ctx.data;
2124
+ if (this._def.returns instanceof ZodPromise) {
2125
+ let me = this;
2126
+ return OK(async function(...args) {
2127
+ let error = new ZodError([]), parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
2128
+ throw error.addIssue(makeArgsIssue(args, e)), error;
2129
+ }), result = await Reflect.apply(fn, this, parsedArgs);
2130
+ return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
2131
+ throw error.addIssue(makeReturnsIssue(result, e)), error;
2132
+ });
2133
+ });
2134
+ } else {
2135
+ let me = this;
2136
+ return OK(function(...args) {
2137
+ let parsedArgs = me._def.args.safeParse(args, params);
2138
+ if (!parsedArgs.success)
2139
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
2140
+ let result = Reflect.apply(fn, this, parsedArgs.data), parsedReturns = me._def.returns.safeParse(result, params);
2141
+ if (!parsedReturns.success)
2142
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
2143
+ return parsedReturns.data;
2144
+ });
2145
+ }
2146
+ }
2147
+ parameters() {
2148
+ return this._def.args;
2149
+ }
2150
+ returnType() {
2151
+ return this._def.returns;
2152
+ }
2153
+ args(...items) {
2154
+ return new ZodFunction({
2155
+ ...this._def,
2156
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
2157
+ });
2158
+ }
2159
+ returns(returnType) {
2160
+ return new ZodFunction({
2161
+ ...this._def,
2162
+ returns: returnType
2163
+ });
2164
+ }
2165
+ implement(func) {
2166
+ return this.parse(func);
2167
+ }
2168
+ strictImplement(func) {
2169
+ return this.parse(func);
2170
+ }
2171
+ static create(args, returns, params) {
2172
+ return new ZodFunction({
2173
+ args: args || ZodTuple.create([]).rest(ZodUnknown.create()),
2174
+ returns: returns || ZodUnknown.create(),
2175
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
2176
+ ...processCreateParams(params)
2177
+ });
2178
+ }
2179
+ }, ZodLazy = class extends ZodType {
2180
+ get schema() {
2181
+ return this._def.getter();
2182
+ }
2183
+ _parse(input) {
2184
+ let { ctx } = this._processInputParams(input);
2185
+ return this._def.getter()._parse({ data: ctx.data, path: ctx.path, parent: ctx });
2186
+ }
2187
+ };
2188
+ ZodLazy.create = (getter, params) => new ZodLazy({
2189
+ getter,
2190
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
2191
+ ...processCreateParams(params)
2192
+ });
2193
+ var ZodLiteral = class extends ZodType {
2194
+ _parse(input) {
2195
+ if (input.data !== this._def.value) {
2196
+ let ctx = this._getOrReturnCtx(input);
2197
+ return addIssueToContext(ctx, {
2198
+ received: ctx.data,
2199
+ code: ZodIssueCode.invalid_literal,
2200
+ expected: this._def.value
2201
+ }), INVALID;
2202
+ }
2203
+ return { status: "valid", value: input.data };
2204
+ }
2205
+ get value() {
2206
+ return this._def.value;
2207
+ }
2208
+ };
2209
+ ZodLiteral.create = (value, params) => new ZodLiteral({
2210
+ value,
2211
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
2212
+ ...processCreateParams(params)
2213
+ });
2214
+ function createZodEnum(values, params) {
2215
+ return new ZodEnum({
2216
+ values,
2217
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
2218
+ ...processCreateParams(params)
2219
+ });
2220
+ }
2221
+ var ZodEnum = class extends ZodType {
2222
+ _parse(input) {
2223
+ if (typeof input.data != "string") {
2224
+ let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
2225
+ return addIssueToContext(ctx, {
2226
+ expected: util.joinValues(expectedValues),
2227
+ received: ctx.parsedType,
2228
+ code: ZodIssueCode.invalid_type
2229
+ }), INVALID;
2230
+ }
2231
+ if (this._def.values.indexOf(input.data) === -1) {
2232
+ let ctx = this._getOrReturnCtx(input), expectedValues = this._def.values;
2233
+ return addIssueToContext(ctx, {
2234
+ received: ctx.data,
2235
+ code: ZodIssueCode.invalid_enum_value,
2236
+ options: expectedValues
2237
+ }), INVALID;
2238
+ }
2239
+ return OK(input.data);
2240
+ }
2241
+ get options() {
2242
+ return this._def.values;
2243
+ }
2244
+ get enum() {
2245
+ let enumValues = {};
2246
+ for (let val of this._def.values)
2247
+ enumValues[val] = val;
2248
+ return enumValues;
2249
+ }
2250
+ get Values() {
2251
+ let enumValues = {};
2252
+ for (let val of this._def.values)
2253
+ enumValues[val] = val;
2254
+ return enumValues;
2255
+ }
2256
+ get Enum() {
2257
+ let enumValues = {};
2258
+ for (let val of this._def.values)
2259
+ enumValues[val] = val;
2260
+ return enumValues;
2261
+ }
2262
+ extract(values) {
2263
+ return ZodEnum.create(values);
2264
+ }
2265
+ exclude(values) {
2266
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
2267
+ }
2268
+ };
2269
+ ZodEnum.create = createZodEnum;
2270
+ var ZodNativeEnum = class extends ZodType {
2271
+ _parse(input) {
2272
+ let nativeEnumValues = util.getValidEnumValues(this._def.values), ctx = this._getOrReturnCtx(input);
2273
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
2274
+ let expectedValues = util.objectValues(nativeEnumValues);
2275
+ return addIssueToContext(ctx, {
2276
+ expected: util.joinValues(expectedValues),
2277
+ received: ctx.parsedType,
2278
+ code: ZodIssueCode.invalid_type
2279
+ }), INVALID;
2280
+ }
2281
+ if (nativeEnumValues.indexOf(input.data) === -1) {
2282
+ let expectedValues = util.objectValues(nativeEnumValues);
2283
+ return addIssueToContext(ctx, {
2284
+ received: ctx.data,
2285
+ code: ZodIssueCode.invalid_enum_value,
2286
+ options: expectedValues
2287
+ }), INVALID;
2288
+ }
2289
+ return OK(input.data);
2290
+ }
2291
+ get enum() {
2292
+ return this._def.values;
2293
+ }
2294
+ };
2295
+ ZodNativeEnum.create = (values, params) => new ZodNativeEnum({
2296
+ values,
2297
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
2298
+ ...processCreateParams(params)
2299
+ });
2300
+ var ZodPromise = class extends ZodType {
2301
+ unwrap() {
2302
+ return this._def.type;
2303
+ }
2304
+ _parse(input) {
2305
+ let { ctx } = this._processInputParams(input);
2306
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === !1)
2307
+ return addIssueToContext(ctx, {
2308
+ code: ZodIssueCode.invalid_type,
2309
+ expected: ZodParsedType.promise,
2310
+ received: ctx.parsedType
2311
+ }), INVALID;
2312
+ let promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
2313
+ return OK(promisified.then((data) => this._def.type.parseAsync(data, {
2314
+ path: ctx.path,
2315
+ errorMap: ctx.common.contextualErrorMap
2316
+ })));
2317
+ }
2318
+ };
2319
+ ZodPromise.create = (schema, params) => new ZodPromise({
2320
+ type: schema,
2321
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
2322
+ ...processCreateParams(params)
2323
+ });
2324
+ var ZodEffects = class extends ZodType {
2325
+ innerType() {
2326
+ return this._def.schema;
2327
+ }
2328
+ sourceType() {
2329
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2330
+ }
2331
+ _parse(input) {
2332
+ let { status, ctx } = this._processInputParams(input), effect = this._def.effect || null, checkCtx = {
2333
+ addIssue: (arg) => {
2334
+ addIssueToContext(ctx, arg), arg.fatal ? status.abort() : status.dirty();
2335
+ },
2336
+ get path() {
2337
+ return ctx.path;
2338
+ }
2339
+ };
2340
+ if (checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx), effect.type === "preprocess") {
2341
+ let processed = effect.transform(ctx.data, checkCtx);
2342
+ return ctx.common.issues.length ? {
2343
+ status: "dirty",
2344
+ value: ctx.data
2345
+ } : ctx.common.async ? Promise.resolve(processed).then((processed2) => this._def.schema._parseAsync({
2346
+ data: processed2,
2347
+ path: ctx.path,
2348
+ parent: ctx
2349
+ })) : this._def.schema._parseSync({
2350
+ data: processed,
2351
+ path: ctx.path,
2352
+ parent: ctx
2353
+ });
2354
+ }
2355
+ if (effect.type === "refinement") {
2356
+ let executeRefinement = (acc) => {
2357
+ let result = effect.refinement(acc, checkCtx);
2358
+ if (ctx.common.async)
2359
+ return Promise.resolve(result);
2360
+ if (result instanceof Promise)
2361
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2362
+ return acc;
2363
+ };
2364
+ if (ctx.common.async === !1) {
2365
+ let inner = this._def.schema._parseSync({
2366
+ data: ctx.data,
2367
+ path: ctx.path,
2368
+ parent: ctx
2369
+ });
2370
+ return inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value), { status: status.value, value: inner.value });
2371
+ } else
2372
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => inner.status === "aborted" ? INVALID : (inner.status === "dirty" && status.dirty(), executeRefinement(inner.value).then(() => ({ status: status.value, value: inner.value }))));
2373
+ }
2374
+ if (effect.type === "transform")
2375
+ if (ctx.common.async === !1) {
2376
+ let base = this._def.schema._parseSync({
2377
+ data: ctx.data,
2378
+ path: ctx.path,
2379
+ parent: ctx
2380
+ });
2381
+ if (!isValid(base))
2382
+ return base;
2383
+ let result = effect.transform(base.value, checkCtx);
2384
+ if (result instanceof Promise)
2385
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2386
+ return { status: status.value, value: result };
2387
+ } else
2388
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => isValid(base) ? Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result })) : base);
2389
+ util.assertNever(effect);
2390
+ }
2391
+ };
2392
+ ZodEffects.create = (schema, effect, params) => new ZodEffects({
2393
+ schema,
2394
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2395
+ effect,
2396
+ ...processCreateParams(params)
2397
+ });
2398
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => new ZodEffects({
2399
+ schema,
2400
+ effect: { type: "preprocess", transform: preprocess },
2401
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2402
+ ...processCreateParams(params)
2403
+ });
2404
+ var ZodOptional = class extends ZodType {
2405
+ _parse(input) {
2406
+ return this._getType(input) === ZodParsedType.undefined ? OK(void 0) : this._def.innerType._parse(input);
2407
+ }
2408
+ unwrap() {
2409
+ return this._def.innerType;
2410
+ }
2411
+ };
2412
+ ZodOptional.create = (type, params) => new ZodOptional({
2413
+ innerType: type,
2414
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
2415
+ ...processCreateParams(params)
2416
+ });
2417
+ var ZodNullable = class extends ZodType {
2418
+ _parse(input) {
2419
+ return this._getType(input) === ZodParsedType.null ? OK(null) : this._def.innerType._parse(input);
2420
+ }
2421
+ unwrap() {
2422
+ return this._def.innerType;
2423
+ }
2424
+ };
2425
+ ZodNullable.create = (type, params) => new ZodNullable({
2426
+ innerType: type,
2427
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
2428
+ ...processCreateParams(params)
2429
+ });
2430
+ var ZodDefault = class extends ZodType {
2431
+ _parse(input) {
2432
+ let { ctx } = this._processInputParams(input), data = ctx.data;
2433
+ return ctx.parsedType === ZodParsedType.undefined && (data = this._def.defaultValue()), this._def.innerType._parse({
2434
+ data,
2435
+ path: ctx.path,
2436
+ parent: ctx
2437
+ });
2438
+ }
2439
+ removeDefault() {
2440
+ return this._def.innerType;
2441
+ }
2442
+ };
2443
+ ZodDefault.create = (type, params) => new ZodDefault({
2444
+ innerType: type,
2445
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
2446
+ defaultValue: typeof params.default == "function" ? params.default : () => params.default,
2447
+ ...processCreateParams(params)
2448
+ });
2449
+ var ZodCatch = class extends ZodType {
2450
+ _parse(input) {
2451
+ let { ctx } = this._processInputParams(input), newCtx = {
2452
+ ...ctx,
2453
+ common: {
2454
+ ...ctx.common,
2455
+ issues: []
2456
+ }
2457
+ }, result = this._def.innerType._parse({
2458
+ data: newCtx.data,
2459
+ path: newCtx.path,
2460
+ parent: {
2461
+ ...newCtx
2462
+ }
2463
+ });
2464
+ return isAsync(result) ? result.then((result2) => ({
2465
+ status: "valid",
2466
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
2467
+ get error() {
2468
+ return new ZodError(newCtx.common.issues);
2469
+ },
2470
+ input: newCtx.data
2471
+ })
2472
+ })) : {
2473
+ status: "valid",
2474
+ value: result.status === "valid" ? result.value : this._def.catchValue({
2475
+ get error() {
2476
+ return new ZodError(newCtx.common.issues);
2477
+ },
2478
+ input: newCtx.data
2479
+ })
2480
+ };
2481
+ }
2482
+ removeCatch() {
2483
+ return this._def.innerType;
2484
+ }
2485
+ };
2486
+ ZodCatch.create = (type, params) => new ZodCatch({
2487
+ innerType: type,
2488
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
2489
+ catchValue: typeof params.catch == "function" ? params.catch : () => params.catch,
2490
+ ...processCreateParams(params)
2491
+ });
2492
+ var ZodNaN = class extends ZodType {
2493
+ _parse(input) {
2494
+ if (this._getType(input) !== ZodParsedType.nan) {
2495
+ let ctx = this._getOrReturnCtx(input);
2496
+ return addIssueToContext(ctx, {
2497
+ code: ZodIssueCode.invalid_type,
2498
+ expected: ZodParsedType.nan,
2499
+ received: ctx.parsedType
2500
+ }), INVALID;
2501
+ }
2502
+ return { status: "valid", value: input.data };
2503
+ }
2504
+ };
2505
+ ZodNaN.create = (params) => new ZodNaN({
2506
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
2507
+ ...processCreateParams(params)
2508
+ });
2509
+ var BRAND = Symbol("zod_brand"), ZodBranded = class extends ZodType {
2510
+ _parse(input) {
2511
+ let { ctx } = this._processInputParams(input), data = ctx.data;
2512
+ return this._def.type._parse({
2513
+ data,
2514
+ path: ctx.path,
2515
+ parent: ctx
2516
+ });
2517
+ }
2518
+ unwrap() {
2519
+ return this._def.type;
2520
+ }
2521
+ }, ZodPipeline = class extends ZodType {
2522
+ _parse(input) {
2523
+ let { status, ctx } = this._processInputParams(input);
2524
+ if (ctx.common.async)
2525
+ return (async () => {
2526
+ let inResult = await this._def.in._parseAsync({
2527
+ data: ctx.data,
2528
+ path: ctx.path,
2529
+ parent: ctx
2530
+ });
2531
+ return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), DIRTY(inResult.value)) : this._def.out._parseAsync({
2532
+ data: inResult.value,
2533
+ path: ctx.path,
2534
+ parent: ctx
2535
+ });
2536
+ })();
2537
+ {
2538
+ let inResult = this._def.in._parseSync({
2539
+ data: ctx.data,
2540
+ path: ctx.path,
2541
+ parent: ctx
2542
+ });
2543
+ return inResult.status === "aborted" ? INVALID : inResult.status === "dirty" ? (status.dirty(), {
2544
+ status: "dirty",
2545
+ value: inResult.value
2546
+ }) : this._def.out._parseSync({
2547
+ data: inResult.value,
2548
+ path: ctx.path,
2549
+ parent: ctx
2550
+ });
2551
+ }
2552
+ }
2553
+ static create(a, b) {
2554
+ return new ZodPipeline({
2555
+ in: a,
2556
+ out: b,
2557
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
2558
+ });
2559
+ }
2560
+ }, ZodReadonly = class extends ZodType {
2561
+ _parse(input) {
2562
+ let result = this._def.innerType._parse(input);
2563
+ return isValid(result) && (result.value = Object.freeze(result.value)), result;
2564
+ }
2565
+ };
2566
+ ZodReadonly.create = (type, params) => new ZodReadonly({
2567
+ innerType: type,
2568
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
2569
+ ...processCreateParams(params)
2570
+ });
2571
+ var custom = (check, params = {}, fatal) => check ? ZodAny.create().superRefine((data, ctx) => {
2572
+ var _a, _b;
2573
+ if (!check(data)) {
2574
+ let p = typeof params == "function" ? params(data) : typeof params == "string" ? { message: params } : params, _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : !0, p2 = typeof p == "string" ? { message: p } : p;
2575
+ ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
2576
+ }
2577
+ }) : ZodAny.create(), late = {
2578
+ object: ZodObject.lazycreate
2579
+ }, ZodFirstPartyTypeKind;
2580
+ (function(ZodFirstPartyTypeKind2) {
2581
+ ZodFirstPartyTypeKind2.ZodString = "ZodString", ZodFirstPartyTypeKind2.ZodNumber = "ZodNumber", ZodFirstPartyTypeKind2.ZodNaN = "ZodNaN", ZodFirstPartyTypeKind2.ZodBigInt = "ZodBigInt", ZodFirstPartyTypeKind2.ZodBoolean = "ZodBoolean", ZodFirstPartyTypeKind2.ZodDate = "ZodDate", ZodFirstPartyTypeKind2.ZodSymbol = "ZodSymbol", ZodFirstPartyTypeKind2.ZodUndefined = "ZodUndefined", ZodFirstPartyTypeKind2.ZodNull = "ZodNull", ZodFirstPartyTypeKind2.ZodAny = "ZodAny", ZodFirstPartyTypeKind2.ZodUnknown = "ZodUnknown", ZodFirstPartyTypeKind2.ZodNever = "ZodNever", ZodFirstPartyTypeKind2.ZodVoid = "ZodVoid", ZodFirstPartyTypeKind2.ZodArray = "ZodArray", ZodFirstPartyTypeKind2.ZodObject = "ZodObject", ZodFirstPartyTypeKind2.ZodUnion = "ZodUnion", ZodFirstPartyTypeKind2.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", ZodFirstPartyTypeKind2.ZodIntersection = "ZodIntersection", ZodFirstPartyTypeKind2.ZodTuple = "ZodTuple", ZodFirstPartyTypeKind2.ZodRecord = "ZodRecord", ZodFirstPartyTypeKind2.ZodMap = "ZodMap", ZodFirstPartyTypeKind2.ZodSet = "ZodSet", ZodFirstPartyTypeKind2.ZodFunction = "ZodFunction", ZodFirstPartyTypeKind2.ZodLazy = "ZodLazy", ZodFirstPartyTypeKind2.ZodLiteral = "ZodLiteral", ZodFirstPartyTypeKind2.ZodEnum = "ZodEnum", ZodFirstPartyTypeKind2.ZodEffects = "ZodEffects", ZodFirstPartyTypeKind2.ZodNativeEnum = "ZodNativeEnum", ZodFirstPartyTypeKind2.ZodOptional = "ZodOptional", ZodFirstPartyTypeKind2.ZodNullable = "ZodNullable", ZodFirstPartyTypeKind2.ZodDefault = "ZodDefault", ZodFirstPartyTypeKind2.ZodCatch = "ZodCatch", ZodFirstPartyTypeKind2.ZodPromise = "ZodPromise", ZodFirstPartyTypeKind2.ZodBranded = "ZodBranded", ZodFirstPartyTypeKind2.ZodPipeline = "ZodPipeline", ZodFirstPartyTypeKind2.ZodReadonly = "ZodReadonly";
2582
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
2583
+ var instanceOfType = (cls, params = {
2584
+ message: `Input not instance of ${cls.name}`
2585
+ }) => custom((data) => data instanceof cls, params), stringType = ZodString.create, numberType = ZodNumber.create, nanType = ZodNaN.create, bigIntType = ZodBigInt.create, booleanType = ZodBoolean.create, dateType = ZodDate.create, symbolType = ZodSymbol.create, undefinedType = ZodUndefined.create, nullType = ZodNull.create, anyType = ZodAny.create, unknownType = ZodUnknown.create, neverType = ZodNever.create, voidType = ZodVoid.create, arrayType = ZodArray.create, objectType = ZodObject.create, strictObjectType = ZodObject.strictCreate, unionType = ZodUnion.create, discriminatedUnionType = ZodDiscriminatedUnion.create, intersectionType = ZodIntersection.create, tupleType = ZodTuple.create, recordType = ZodRecord.create, mapType = ZodMap.create, setType = ZodSet.create, functionType = ZodFunction.create, lazyType = ZodLazy.create, literalType = ZodLiteral.create, enumType = ZodEnum.create, nativeEnumType = ZodNativeEnum.create, promiseType = ZodPromise.create, effectsType = ZodEffects.create, optionalType = ZodOptional.create, nullableType = ZodNullable.create, preprocessType = ZodEffects.createWithPreprocess, pipelineType = ZodPipeline.create, ostring = () => stringType().optional(), onumber = () => numberType().optional(), oboolean = () => booleanType().optional(), coerce = {
2586
+ string: (arg) => ZodString.create({ ...arg, coerce: !0 }),
2587
+ number: (arg) => ZodNumber.create({ ...arg, coerce: !0 }),
2588
+ boolean: (arg) => ZodBoolean.create({
2589
+ ...arg,
2590
+ coerce: !0
2591
+ }),
2592
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: !0 }),
2593
+ date: (arg) => ZodDate.create({ ...arg, coerce: !0 })
2594
+ }, NEVER = INVALID, z = /* @__PURE__ */ Object.freeze({
2595
+ __proto__: null,
2596
+ defaultErrorMap: errorMap,
2597
+ setErrorMap,
2598
+ getErrorMap,
2599
+ makeIssue,
2600
+ EMPTY_PATH,
2601
+ addIssueToContext,
2602
+ ParseStatus,
2603
+ INVALID,
2604
+ DIRTY,
2605
+ OK,
2606
+ isAborted,
2607
+ isDirty,
2608
+ isValid,
2609
+ isAsync,
2610
+ get util() {
2611
+ return util;
2612
+ },
2613
+ get objectUtil() {
2614
+ return objectUtil;
2615
+ },
2616
+ ZodParsedType,
2617
+ getParsedType,
2618
+ ZodType,
2619
+ ZodString,
2620
+ ZodNumber,
2621
+ ZodBigInt,
2622
+ ZodBoolean,
2623
+ ZodDate,
2624
+ ZodSymbol,
2625
+ ZodUndefined,
2626
+ ZodNull,
2627
+ ZodAny,
2628
+ ZodUnknown,
2629
+ ZodNever,
2630
+ ZodVoid,
2631
+ ZodArray,
2632
+ ZodObject,
2633
+ ZodUnion,
2634
+ ZodDiscriminatedUnion,
2635
+ ZodIntersection,
2636
+ ZodTuple,
2637
+ ZodRecord,
2638
+ ZodMap,
2639
+ ZodSet,
2640
+ ZodFunction,
2641
+ ZodLazy,
2642
+ ZodLiteral,
2643
+ ZodEnum,
2644
+ ZodNativeEnum,
2645
+ ZodPromise,
2646
+ ZodEffects,
2647
+ ZodTransformer: ZodEffects,
2648
+ ZodOptional,
2649
+ ZodNullable,
2650
+ ZodDefault,
2651
+ ZodCatch,
2652
+ ZodNaN,
2653
+ BRAND,
2654
+ ZodBranded,
2655
+ ZodPipeline,
2656
+ ZodReadonly,
2657
+ custom,
2658
+ Schema: ZodType,
2659
+ ZodSchema: ZodType,
2660
+ late,
2661
+ get ZodFirstPartyTypeKind() {
2662
+ return ZodFirstPartyTypeKind;
2663
+ },
2664
+ coerce,
2665
+ any: anyType,
2666
+ array: arrayType,
2667
+ bigint: bigIntType,
2668
+ boolean: booleanType,
2669
+ date: dateType,
2670
+ discriminatedUnion: discriminatedUnionType,
2671
+ effect: effectsType,
2672
+ enum: enumType,
2673
+ function: functionType,
2674
+ instanceof: instanceOfType,
2675
+ intersection: intersectionType,
2676
+ lazy: lazyType,
2677
+ literal: literalType,
2678
+ map: mapType,
2679
+ nan: nanType,
2680
+ nativeEnum: nativeEnumType,
2681
+ never: neverType,
2682
+ null: nullType,
2683
+ nullable: nullableType,
2684
+ number: numberType,
2685
+ object: objectType,
2686
+ oboolean,
2687
+ onumber,
2688
+ optional: optionalType,
2689
+ ostring,
2690
+ pipeline: pipelineType,
2691
+ preprocess: preprocessType,
2692
+ promise: promiseType,
2693
+ record: recordType,
2694
+ set: setType,
2695
+ strictObject: strictObjectType,
2696
+ string: stringType,
2697
+ symbol: symbolType,
2698
+ transformer: effectsType,
2699
+ tuple: tupleType,
2700
+ undefined: undefinedType,
2701
+ union: unionType,
2702
+ unknown: unknownType,
2703
+ void: voidType,
2704
+ NEVER,
2705
+ ZodIssueCode,
2706
+ quotelessJson,
2707
+ ZodError
2708
+ });
2709
+
2710
+ // src/workers/shared/zod.worker.ts
2711
+ var HEX_REGEXP = /^[0-9a-f]*$/i, BASE64_REGEXP = /^[0-9a-z+/=]*$/i, HexDataSchema = z.string().regex(HEX_REGEXP).transform((hex) => Buffer.from(hex, "hex")), Base64DataSchema = z.string().regex(BASE64_REGEXP).transform((base64) => Buffer.from(base64, "base64"));
2712
+ export {
2713
+ BASE64_REGEXP,
2714
+ Base64DataSchema,
2715
+ HEX_REGEXP,
2716
+ HexDataSchema,
2717
+ z
2718
+ };
2719
+ //# sourceMappingURL=zod.worker.js.map