@getopenpay/openpay-js-react 0.0.2 → 0.0.3-alpha.6678cf2

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