@telemetryos/root-sdk 1.0.0

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