@shopify/create-app 4.9.5 → 5.0.0

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