@resconet/qp-bridge 0.0.1-alpha.10

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