@hashgraphonline/standards-sdk 0.0.78 → 0.0.79

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