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