@svazqz/api-contract-kit 0.1.6-alpha

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