@getopenpay/openpay-js-react 0.0.3 → 0.0.4-alpha.289e049
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.d.ts +31 -0
- package/dist/index.js +649 -581
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
import { jsx as
|
|
3
|
-
const
|
|
1
|
+
import { createContext as tr, useContext as rr, useState as E, useEffect as ve, useMemo as Me, useRef as kt, useCallback as Ue } from "react";
|
|
2
|
+
import { jsx as K } from "react/jsx-runtime";
|
|
3
|
+
const wt = tr({
|
|
4
4
|
formId: "",
|
|
5
5
|
formHeight: "",
|
|
6
6
|
referer: void 0,
|
|
7
7
|
checkoutSecureToken: void 0,
|
|
8
|
+
stripeContext: null,
|
|
8
9
|
registerIframe: () => {
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
},
|
|
11
|
+
baseUrl: ""
|
|
12
|
+
}), nr = () => {
|
|
13
|
+
const r = rr(wt);
|
|
12
14
|
if (!r)
|
|
13
15
|
throw new Error("useOpenPayElements must be used within an OpenPayElementsProvider");
|
|
14
16
|
return r;
|
|
15
17
|
};
|
|
16
|
-
var
|
|
17
|
-
for (var
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
return (
|
|
18
|
+
var T = [];
|
|
19
|
+
for (var tt = 0; tt < 256; ++tt)
|
|
20
|
+
T.push((tt + 256).toString(16).slice(1));
|
|
21
|
+
function sr(r, e = 0) {
|
|
22
|
+
return (T[r[e + 0]] + T[r[e + 1]] + T[r[e + 2]] + T[r[e + 3]] + "-" + T[r[e + 4]] + T[r[e + 5]] + "-" + T[r[e + 6]] + T[r[e + 7]] + "-" + T[r[e + 8]] + T[r[e + 9]] + "-" + T[r[e + 10]] + T[r[e + 11]] + T[r[e + 12]] + T[r[e + 13]] + T[r[e + 14]] + T[r[e + 15]]).toLowerCase();
|
|
21
23
|
}
|
|
22
|
-
var
|
|
23
|
-
function
|
|
24
|
-
if (!
|
|
24
|
+
var Le, ar = new Uint8Array(16);
|
|
25
|
+
function ir() {
|
|
26
|
+
if (!Le && (Le = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Le))
|
|
25
27
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
26
|
-
return
|
|
28
|
+
return Le(ar);
|
|
27
29
|
}
|
|
28
|
-
var
|
|
29
|
-
const
|
|
30
|
-
randomUUID:
|
|
30
|
+
var or = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
31
|
+
const yt = {
|
|
32
|
+
randomUUID: or
|
|
31
33
|
};
|
|
32
|
-
function
|
|
33
|
-
if (
|
|
34
|
-
return
|
|
34
|
+
function Tt(r, e, t) {
|
|
35
|
+
if (yt.randomUUID && !e && !r)
|
|
36
|
+
return yt.randomUUID();
|
|
35
37
|
r = r || {};
|
|
36
|
-
var n = r.random || (r.rng ||
|
|
37
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
38
|
+
var n = r.random || (r.rng || ir)();
|
|
39
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, sr(n);
|
|
38
40
|
}
|
|
39
|
-
const st = "https://cde.getopenpay.com";
|
|
40
41
|
var _;
|
|
41
42
|
(function(r) {
|
|
42
43
|
r.assertEqual = (s) => s;
|
|
@@ -73,14 +74,14 @@ var _;
|
|
|
73
74
|
}
|
|
74
75
|
r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
|
|
75
76
|
})(_ || (_ = {}));
|
|
76
|
-
var
|
|
77
|
+
var nt;
|
|
77
78
|
(function(r) {
|
|
78
79
|
r.mergeShapes = (e, t) => ({
|
|
79
80
|
...e,
|
|
80
81
|
...t
|
|
81
82
|
// second overwrites first
|
|
82
83
|
});
|
|
83
|
-
})(
|
|
84
|
+
})(nt || (nt = {}));
|
|
84
85
|
const f = _.arrayToEnum([
|
|
85
86
|
"string",
|
|
86
87
|
"nan",
|
|
@@ -140,8 +141,8 @@ const f = _.arrayToEnum([
|
|
|
140
141
|
"invalid_intersection_types",
|
|
141
142
|
"not_multiple_of",
|
|
142
143
|
"not_finite"
|
|
143
|
-
]),
|
|
144
|
-
class
|
|
144
|
+
]), cr = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
145
|
+
class Z extends Error {
|
|
145
146
|
constructor(e) {
|
|
146
147
|
super(), this.issues = [], this.addIssue = (n) => {
|
|
147
148
|
this.issues = [...this.issues, n];
|
|
@@ -178,7 +179,7 @@ class I extends Error {
|
|
|
178
179
|
return s(this), n;
|
|
179
180
|
}
|
|
180
181
|
static assert(e) {
|
|
181
|
-
if (!(e instanceof
|
|
182
|
+
if (!(e instanceof Z))
|
|
182
183
|
throw new Error(`Not a ZodError: ${e}`);
|
|
183
184
|
}
|
|
184
185
|
toString() {
|
|
@@ -200,8 +201,8 @@ class I extends Error {
|
|
|
200
201
|
return this.flatten();
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
|
-
|
|
204
|
-
const
|
|
204
|
+
Z.create = (r) => new Z(r);
|
|
205
|
+
const le = (r, e) => {
|
|
205
206
|
let t;
|
|
206
207
|
switch (r.code) {
|
|
207
208
|
case c.invalid_type:
|
|
@@ -257,14 +258,14 @@ const ue = (r, e) => {
|
|
|
257
258
|
}
|
|
258
259
|
return { message: t };
|
|
259
260
|
};
|
|
260
|
-
let
|
|
261
|
-
function
|
|
262
|
-
|
|
261
|
+
let Et = le;
|
|
262
|
+
function dr(r) {
|
|
263
|
+
Et = r;
|
|
263
264
|
}
|
|
264
|
-
function
|
|
265
|
-
return
|
|
265
|
+
function $e() {
|
|
266
|
+
return Et;
|
|
266
267
|
}
|
|
267
|
-
const
|
|
268
|
+
const Ve = (r) => {
|
|
268
269
|
const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], i = {
|
|
269
270
|
...s,
|
|
270
271
|
path: a
|
|
@@ -284,9 +285,9 @@ const Ue = (r) => {
|
|
|
284
285
|
path: a,
|
|
285
286
|
message: o
|
|
286
287
|
};
|
|
287
|
-
},
|
|
288
|
+
}, ur = [];
|
|
288
289
|
function l(r, e) {
|
|
289
|
-
const t =
|
|
290
|
+
const t = $e(), n = Ve({
|
|
290
291
|
issueData: e,
|
|
291
292
|
data: r.data,
|
|
292
293
|
path: r.path,
|
|
@@ -294,13 +295,13 @@ function l(r, e) {
|
|
|
294
295
|
r.common.contextualErrorMap,
|
|
295
296
|
r.schemaErrorMap,
|
|
296
297
|
t,
|
|
297
|
-
t ===
|
|
298
|
+
t === le ? void 0 : le
|
|
298
299
|
// then global default map
|
|
299
300
|
].filter((s) => !!s)
|
|
300
301
|
});
|
|
301
302
|
r.common.issues.push(n);
|
|
302
303
|
}
|
|
303
|
-
class
|
|
304
|
+
class S {
|
|
304
305
|
constructor() {
|
|
305
306
|
this.value = "valid";
|
|
306
307
|
}
|
|
@@ -328,7 +329,7 @@ class E {
|
|
|
328
329
|
value: i
|
|
329
330
|
});
|
|
330
331
|
}
|
|
331
|
-
return
|
|
332
|
+
return S.mergeObjectSync(e, n);
|
|
332
333
|
}
|
|
333
334
|
static mergeObjectSync(e, t) {
|
|
334
335
|
const n = {};
|
|
@@ -343,12 +344,12 @@ class E {
|
|
|
343
344
|
}
|
|
344
345
|
const y = Object.freeze({
|
|
345
346
|
status: "aborted"
|
|
346
|
-
}),
|
|
347
|
-
function
|
|
347
|
+
}), de = (r) => ({ status: "dirty", value: r }), R = (r) => ({ status: "valid", value: r }), st = (r) => r.status === "aborted", at = (r) => r.status === "dirty", ge = (r) => r.status === "valid", _e = (r) => typeof Promise < "u" && r instanceof Promise;
|
|
348
|
+
function ze(r, e, t, n) {
|
|
348
349
|
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
350
|
return e.get(r);
|
|
350
351
|
}
|
|
351
|
-
function
|
|
352
|
+
function St(r, e, t, n, s) {
|
|
352
353
|
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
354
|
return e.set(r, t), t;
|
|
354
355
|
}
|
|
@@ -356,8 +357,8 @@ var h;
|
|
|
356
357
|
(function(r) {
|
|
357
358
|
r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
358
359
|
})(h || (h = {}));
|
|
359
|
-
var me,
|
|
360
|
-
class
|
|
360
|
+
var me, ye;
|
|
361
|
+
class L {
|
|
361
362
|
constructor(e, t, n, s) {
|
|
362
363
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
|
|
363
364
|
}
|
|
@@ -365,8 +366,8 @@ class U {
|
|
|
365
366
|
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
|
}
|
|
367
368
|
}
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
369
|
+
const vt = (r, e) => {
|
|
370
|
+
if (ge(e))
|
|
370
371
|
return { success: !0, data: e.value };
|
|
371
372
|
if (!r.common.issues.length)
|
|
372
373
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -375,7 +376,7 @@ const yt = (r, e) => {
|
|
|
375
376
|
get error() {
|
|
376
377
|
if (this._error)
|
|
377
378
|
return this._error;
|
|
378
|
-
const t = new
|
|
379
|
+
const t = new Z(r.common.issues);
|
|
379
380
|
return this._error = t, this._error;
|
|
380
381
|
}
|
|
381
382
|
};
|
|
@@ -388,8 +389,8 @@ function v(r) {
|
|
|
388
389
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
389
390
|
return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
|
|
390
391
|
var u, d;
|
|
391
|
-
const { message:
|
|
392
|
-
return i.code === "invalid_enum_value" ? { message:
|
|
392
|
+
const { message: p } = r;
|
|
393
|
+
return i.code === "invalid_enum_value" ? { message: p ?? o.defaultError } : typeof o.data > "u" ? { message: (u = p ?? n) !== null && u !== void 0 ? u : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (d = p ?? t) !== null && d !== void 0 ? d : o.defaultError };
|
|
393
394
|
}, description: s };
|
|
394
395
|
}
|
|
395
396
|
class g {
|
|
@@ -414,7 +415,7 @@ class g {
|
|
|
414
415
|
}
|
|
415
416
|
_processInputParams(e) {
|
|
416
417
|
return {
|
|
417
|
-
status: new
|
|
418
|
+
status: new S(),
|
|
418
419
|
ctx: {
|
|
419
420
|
common: e.parent.common,
|
|
420
421
|
data: e.data,
|
|
@@ -427,7 +428,7 @@ class g {
|
|
|
427
428
|
}
|
|
428
429
|
_parseSync(e) {
|
|
429
430
|
const t = this._parse(e);
|
|
430
|
-
if (
|
|
431
|
+
if (_e(t))
|
|
431
432
|
throw new Error("Synchronous parse encountered promise.");
|
|
432
433
|
return t;
|
|
433
434
|
}
|
|
@@ -455,7 +456,7 @@ class g {
|
|
|
455
456
|
data: e,
|
|
456
457
|
parsedType: H(e)
|
|
457
458
|
}, a = this._parseSync({ data: e, path: s.path, parent: s });
|
|
458
|
-
return
|
|
459
|
+
return vt(s, a);
|
|
459
460
|
}
|
|
460
461
|
async parseAsync(e, t) {
|
|
461
462
|
const n = await this.safeParseAsync(e, t);
|
|
@@ -475,8 +476,8 @@ class g {
|
|
|
475
476
|
parent: null,
|
|
476
477
|
data: e,
|
|
477
478
|
parsedType: H(e)
|
|
478
|
-
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (
|
|
479
|
-
return
|
|
479
|
+
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (_e(s) ? s : Promise.resolve(s));
|
|
480
|
+
return vt(n, a);
|
|
480
481
|
}
|
|
481
482
|
refine(e, t) {
|
|
482
483
|
const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
|
|
@@ -494,7 +495,7 @@ class g {
|
|
|
494
495
|
_refinement(e) {
|
|
495
496
|
return new D({
|
|
496
497
|
schema: this,
|
|
497
|
-
typeName:
|
|
498
|
+
typeName: m.ZodEffects,
|
|
498
499
|
effect: { type: "refinement", refinement: e }
|
|
499
500
|
});
|
|
500
501
|
}
|
|
@@ -502,10 +503,10 @@ class g {
|
|
|
502
503
|
return this._refinement(e);
|
|
503
504
|
}
|
|
504
505
|
optional() {
|
|
505
|
-
return
|
|
506
|
+
return U.create(this, this._def);
|
|
506
507
|
}
|
|
507
508
|
nullable() {
|
|
508
|
-
return
|
|
509
|
+
return G.create(this, this._def);
|
|
509
510
|
}
|
|
510
511
|
nullish() {
|
|
511
512
|
return this.nullable().optional();
|
|
@@ -514,45 +515,45 @@ class g {
|
|
|
514
515
|
return P.create(this, this._def);
|
|
515
516
|
}
|
|
516
517
|
promise() {
|
|
517
|
-
return
|
|
518
|
+
return he.create(this, this._def);
|
|
518
519
|
}
|
|
519
520
|
or(e) {
|
|
520
|
-
return
|
|
521
|
+
return we.create([this, e], this._def);
|
|
521
522
|
}
|
|
522
523
|
and(e) {
|
|
523
|
-
return
|
|
524
|
+
return Te.create(this, e, this._def);
|
|
524
525
|
}
|
|
525
526
|
transform(e) {
|
|
526
527
|
return new D({
|
|
527
528
|
...v(this._def),
|
|
528
529
|
schema: this,
|
|
529
|
-
typeName:
|
|
530
|
+
typeName: m.ZodEffects,
|
|
530
531
|
effect: { type: "transform", transform: e }
|
|
531
532
|
});
|
|
532
533
|
}
|
|
533
534
|
default(e) {
|
|
534
535
|
const t = typeof e == "function" ? e : () => e;
|
|
535
|
-
return new
|
|
536
|
+
return new Oe({
|
|
536
537
|
...v(this._def),
|
|
537
538
|
innerType: this,
|
|
538
539
|
defaultValue: t,
|
|
539
|
-
typeName:
|
|
540
|
+
typeName: m.ZodDefault
|
|
540
541
|
});
|
|
541
542
|
}
|
|
542
543
|
brand() {
|
|
543
|
-
return new
|
|
544
|
-
typeName:
|
|
544
|
+
return new ot({
|
|
545
|
+
typeName: m.ZodBranded,
|
|
545
546
|
type: this,
|
|
546
547
|
...v(this._def)
|
|
547
548
|
});
|
|
548
549
|
}
|
|
549
550
|
catch(e) {
|
|
550
551
|
const t = typeof e == "function" ? e : () => e;
|
|
551
|
-
return new
|
|
552
|
+
return new Ie({
|
|
552
553
|
...v(this._def),
|
|
553
554
|
innerType: this,
|
|
554
555
|
catchValue: t,
|
|
555
|
-
typeName:
|
|
556
|
+
typeName: m.ZodCatch
|
|
556
557
|
});
|
|
557
558
|
}
|
|
558
559
|
describe(e) {
|
|
@@ -563,10 +564,10 @@ class g {
|
|
|
563
564
|
});
|
|
564
565
|
}
|
|
565
566
|
pipe(e) {
|
|
566
|
-
return
|
|
567
|
+
return Ne.create(this, e);
|
|
567
568
|
}
|
|
568
569
|
readonly() {
|
|
569
|
-
return
|
|
570
|
+
return Ze.create(this);
|
|
570
571
|
}
|
|
571
572
|
isOptional() {
|
|
572
573
|
return this.safeParse(void 0).success;
|
|
@@ -575,23 +576,23 @@ class g {
|
|
|
575
576
|
return this.safeParse(null).success;
|
|
576
577
|
}
|
|
577
578
|
}
|
|
578
|
-
const
|
|
579
|
-
let
|
|
580
|
-
const
|
|
581
|
-
function
|
|
579
|
+
const lr = /^c[^\s-]{8,}$/i, fr = /^[0-9a-z]+$/, hr = /^[0-9A-HJKMNP-TV-Z]{26}$/, pr = /^[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, mr = /^[a-z0-9_-]{21}$/i, yr = /^[-+]?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)?)??$/, vr = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, gr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
580
|
+
let rt;
|
|
581
|
+
const _r = /^(?:(?: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])$/, xr = /^(([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})))$/, br = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Ct = "((\\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])))", kr = new RegExp(`^${Ct}$`);
|
|
582
|
+
function Rt(r) {
|
|
582
583
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
583
584
|
return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
584
585
|
}
|
|
585
|
-
function
|
|
586
|
-
return new RegExp(`^${
|
|
586
|
+
function wr(r) {
|
|
587
|
+
return new RegExp(`^${Rt(r)}$`);
|
|
587
588
|
}
|
|
588
|
-
function
|
|
589
|
-
let e = `${
|
|
589
|
+
function Ot(r) {
|
|
590
|
+
let e = `${Ct}T${Rt(r)}`;
|
|
590
591
|
const t = [];
|
|
591
592
|
return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
592
593
|
}
|
|
593
|
-
function
|
|
594
|
-
return !!((e === "v4" || !e) &&
|
|
594
|
+
function Tr(r, e) {
|
|
595
|
+
return !!((e === "v4" || !e) && _r.test(r) || (e === "v6" || !e) && xr.test(r));
|
|
595
596
|
}
|
|
596
597
|
class j extends g {
|
|
597
598
|
_parse(e) {
|
|
@@ -603,7 +604,7 @@ class j extends g {
|
|
|
603
604
|
received: a.parsedType
|
|
604
605
|
}), y;
|
|
605
606
|
}
|
|
606
|
-
const n = new
|
|
607
|
+
const n = new S();
|
|
607
608
|
let s;
|
|
608
609
|
for (const a of this._def.checks)
|
|
609
610
|
if (a.kind === "min")
|
|
@@ -642,43 +643,43 @@ class j extends g {
|
|
|
642
643
|
message: a.message
|
|
643
644
|
}), n.dirty());
|
|
644
645
|
} else if (a.kind === "email")
|
|
645
|
-
|
|
646
|
+
vr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
646
647
|
validation: "email",
|
|
647
648
|
code: c.invalid_string,
|
|
648
649
|
message: a.message
|
|
649
650
|
}), n.dirty());
|
|
650
651
|
else if (a.kind === "emoji")
|
|
651
|
-
|
|
652
|
+
rt || (rt = new RegExp(gr, "u")), rt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
652
653
|
validation: "emoji",
|
|
653
654
|
code: c.invalid_string,
|
|
654
655
|
message: a.message
|
|
655
656
|
}), n.dirty());
|
|
656
657
|
else if (a.kind === "uuid")
|
|
657
|
-
|
|
658
|
+
pr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
658
659
|
validation: "uuid",
|
|
659
660
|
code: c.invalid_string,
|
|
660
661
|
message: a.message
|
|
661
662
|
}), n.dirty());
|
|
662
663
|
else if (a.kind === "nanoid")
|
|
663
|
-
|
|
664
|
+
mr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
664
665
|
validation: "nanoid",
|
|
665
666
|
code: c.invalid_string,
|
|
666
667
|
message: a.message
|
|
667
668
|
}), n.dirty());
|
|
668
669
|
else if (a.kind === "cuid")
|
|
669
|
-
|
|
670
|
+
lr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
670
671
|
validation: "cuid",
|
|
671
672
|
code: c.invalid_string,
|
|
672
673
|
message: a.message
|
|
673
674
|
}), n.dirty());
|
|
674
675
|
else if (a.kind === "cuid2")
|
|
675
|
-
|
|
676
|
+
fr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
676
677
|
validation: "cuid2",
|
|
677
678
|
code: c.invalid_string,
|
|
678
679
|
message: a.message
|
|
679
680
|
}), n.dirty());
|
|
680
681
|
else if (a.kind === "ulid")
|
|
681
|
-
|
|
682
|
+
hr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
682
683
|
validation: "ulid",
|
|
683
684
|
code: c.invalid_string,
|
|
684
685
|
message: a.message
|
|
@@ -709,27 +710,27 @@ class j extends g {
|
|
|
709
710
|
code: c.invalid_string,
|
|
710
711
|
validation: { endsWith: a.value },
|
|
711
712
|
message: a.message
|
|
712
|
-
}), n.dirty()) : a.kind === "datetime" ?
|
|
713
|
+
}), n.dirty()) : a.kind === "datetime" ? Ot(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
713
714
|
code: c.invalid_string,
|
|
714
715
|
validation: "datetime",
|
|
715
716
|
message: a.message
|
|
716
|
-
}), n.dirty()) : a.kind === "date" ?
|
|
717
|
+
}), n.dirty()) : a.kind === "date" ? kr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
717
718
|
code: c.invalid_string,
|
|
718
719
|
validation: "date",
|
|
719
720
|
message: a.message
|
|
720
|
-
}), n.dirty()) : a.kind === "time" ?
|
|
721
|
+
}), n.dirty()) : a.kind === "time" ? wr(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
721
722
|
code: c.invalid_string,
|
|
722
723
|
validation: "time",
|
|
723
724
|
message: a.message
|
|
724
|
-
}), n.dirty()) : a.kind === "duration" ?
|
|
725
|
+
}), n.dirty()) : a.kind === "duration" ? yr.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
725
726
|
validation: "duration",
|
|
726
727
|
code: c.invalid_string,
|
|
727
728
|
message: a.message
|
|
728
|
-
}), n.dirty()) : a.kind === "ip" ?
|
|
729
|
+
}), n.dirty()) : a.kind === "ip" ? Tr(e.data, a.version) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
729
730
|
validation: "ip",
|
|
730
731
|
code: c.invalid_string,
|
|
731
732
|
message: a.message
|
|
732
|
-
}), n.dirty()) : a.kind === "base64" ?
|
|
733
|
+
}), n.dirty()) : a.kind === "base64" ? br.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
733
734
|
validation: "base64",
|
|
734
735
|
code: c.invalid_string,
|
|
735
736
|
message: a.message
|
|
@@ -946,16 +947,16 @@ j.create = (r) => {
|
|
|
946
947
|
var e;
|
|
947
948
|
return new j({
|
|
948
949
|
checks: [],
|
|
949
|
-
typeName:
|
|
950
|
+
typeName: m.ZodString,
|
|
950
951
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
951
952
|
...v(r)
|
|
952
953
|
});
|
|
953
954
|
};
|
|
954
|
-
function
|
|
955
|
+
function Er(r, e) {
|
|
955
956
|
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
957
|
return a % i / Math.pow(10, s);
|
|
957
958
|
}
|
|
958
|
-
class
|
|
959
|
+
class W extends g {
|
|
959
960
|
constructor() {
|
|
960
961
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
961
962
|
}
|
|
@@ -969,7 +970,7 @@ class K extends g {
|
|
|
969
970
|
}), y;
|
|
970
971
|
}
|
|
971
972
|
let n;
|
|
972
|
-
const s = new
|
|
973
|
+
const s = new S();
|
|
973
974
|
for (const a of this._def.checks)
|
|
974
975
|
a.kind === "int" ? _.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
975
976
|
code: c.invalid_type,
|
|
@@ -990,7 +991,7 @@ class K extends g {
|
|
|
990
991
|
inclusive: a.inclusive,
|
|
991
992
|
exact: !1,
|
|
992
993
|
message: a.message
|
|
993
|
-
}), s.dirty()) : a.kind === "multipleOf" ?
|
|
994
|
+
}), s.dirty()) : a.kind === "multipleOf" ? Er(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
994
995
|
code: c.not_multiple_of,
|
|
995
996
|
multipleOf: a.value,
|
|
996
997
|
message: a.message
|
|
@@ -1013,7 +1014,7 @@ class K extends g {
|
|
|
1013
1014
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1014
1015
|
}
|
|
1015
1016
|
setLimit(e, t, n, s) {
|
|
1016
|
-
return new
|
|
1017
|
+
return new W({
|
|
1017
1018
|
...this._def,
|
|
1018
1019
|
checks: [
|
|
1019
1020
|
...this._def.checks,
|
|
@@ -1027,7 +1028,7 @@ class K extends g {
|
|
|
1027
1028
|
});
|
|
1028
1029
|
}
|
|
1029
1030
|
_addCheck(e) {
|
|
1030
|
-
return new
|
|
1031
|
+
return new W({
|
|
1031
1032
|
...this._def,
|
|
1032
1033
|
checks: [...this._def.checks, e]
|
|
1033
1034
|
});
|
|
@@ -1121,13 +1122,13 @@ class K extends g {
|
|
|
1121
1122
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1122
1123
|
}
|
|
1123
1124
|
}
|
|
1124
|
-
|
|
1125
|
+
W.create = (r) => new W({
|
|
1125
1126
|
checks: [],
|
|
1126
|
-
typeName:
|
|
1127
|
+
typeName: m.ZodNumber,
|
|
1127
1128
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1128
1129
|
...v(r)
|
|
1129
1130
|
});
|
|
1130
|
-
class
|
|
1131
|
+
class J extends g {
|
|
1131
1132
|
constructor() {
|
|
1132
1133
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1133
1134
|
}
|
|
@@ -1141,7 +1142,7 @@ class q extends g {
|
|
|
1141
1142
|
}), y;
|
|
1142
1143
|
}
|
|
1143
1144
|
let n;
|
|
1144
|
-
const s = new
|
|
1145
|
+
const s = new S();
|
|
1145
1146
|
for (const a of this._def.checks)
|
|
1146
1147
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1147
1148
|
code: c.too_small,
|
|
@@ -1175,7 +1176,7 @@ class q extends g {
|
|
|
1175
1176
|
return this.setLimit("max", e, !1, h.toString(t));
|
|
1176
1177
|
}
|
|
1177
1178
|
setLimit(e, t, n, s) {
|
|
1178
|
-
return new
|
|
1179
|
+
return new J({
|
|
1179
1180
|
...this._def,
|
|
1180
1181
|
checks: [
|
|
1181
1182
|
...this._def.checks,
|
|
@@ -1189,7 +1190,7 @@ class q extends g {
|
|
|
1189
1190
|
});
|
|
1190
1191
|
}
|
|
1191
1192
|
_addCheck(e) {
|
|
1192
|
-
return new
|
|
1193
|
+
return new J({
|
|
1193
1194
|
...this._def,
|
|
1194
1195
|
checks: [...this._def.checks, e]
|
|
1195
1196
|
});
|
|
@@ -1246,16 +1247,16 @@ class q extends g {
|
|
|
1246
1247
|
return e;
|
|
1247
1248
|
}
|
|
1248
1249
|
}
|
|
1249
|
-
|
|
1250
|
+
J.create = (r) => {
|
|
1250
1251
|
var e;
|
|
1251
|
-
return new
|
|
1252
|
+
return new J({
|
|
1252
1253
|
checks: [],
|
|
1253
|
-
typeName:
|
|
1254
|
+
typeName: m.ZodBigInt,
|
|
1254
1255
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
|
|
1255
1256
|
...v(r)
|
|
1256
1257
|
});
|
|
1257
1258
|
};
|
|
1258
|
-
class
|
|
1259
|
+
class xe extends g {
|
|
1259
1260
|
_parse(e) {
|
|
1260
1261
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1261
1262
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1265,15 +1266,15 @@ class ge extends g {
|
|
|
1265
1266
|
received: n.parsedType
|
|
1266
1267
|
}), y;
|
|
1267
1268
|
}
|
|
1268
|
-
return
|
|
1269
|
+
return R(e.data);
|
|
1269
1270
|
}
|
|
1270
1271
|
}
|
|
1271
|
-
|
|
1272
|
-
typeName:
|
|
1272
|
+
xe.create = (r) => new xe({
|
|
1273
|
+
typeName: m.ZodBoolean,
|
|
1273
1274
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1274
1275
|
...v(r)
|
|
1275
1276
|
});
|
|
1276
|
-
class
|
|
1277
|
+
class ee extends g {
|
|
1277
1278
|
_parse(e) {
|
|
1278
1279
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1279
1280
|
const a = this._getOrReturnCtx(e);
|
|
@@ -1289,7 +1290,7 @@ class Q extends g {
|
|
|
1289
1290
|
code: c.invalid_date
|
|
1290
1291
|
}), y;
|
|
1291
1292
|
}
|
|
1292
|
-
const n = new
|
|
1293
|
+
const n = new S();
|
|
1293
1294
|
let s;
|
|
1294
1295
|
for (const a of this._def.checks)
|
|
1295
1296
|
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
@@ -1313,7 +1314,7 @@ class Q extends g {
|
|
|
1313
1314
|
};
|
|
1314
1315
|
}
|
|
1315
1316
|
_addCheck(e) {
|
|
1316
|
-
return new
|
|
1317
|
+
return new ee({
|
|
1317
1318
|
...this._def,
|
|
1318
1319
|
checks: [...this._def.checks, e]
|
|
1319
1320
|
});
|
|
@@ -1345,13 +1346,13 @@ class Q extends g {
|
|
|
1345
1346
|
return e != null ? new Date(e) : null;
|
|
1346
1347
|
}
|
|
1347
1348
|
}
|
|
1348
|
-
|
|
1349
|
+
ee.create = (r) => new ee({
|
|
1349
1350
|
checks: [],
|
|
1350
1351
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
1351
|
-
typeName:
|
|
1352
|
+
typeName: m.ZodDate,
|
|
1352
1353
|
...v(r)
|
|
1353
1354
|
});
|
|
1354
|
-
class
|
|
1355
|
+
class Be extends g {
|
|
1355
1356
|
_parse(e) {
|
|
1356
1357
|
if (this._getType(e) !== f.symbol) {
|
|
1357
1358
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1361,14 +1362,14 @@ class $e extends g {
|
|
|
1361
1362
|
received: n.parsedType
|
|
1362
1363
|
}), y;
|
|
1363
1364
|
}
|
|
1364
|
-
return
|
|
1365
|
+
return R(e.data);
|
|
1365
1366
|
}
|
|
1366
1367
|
}
|
|
1367
|
-
|
|
1368
|
-
typeName:
|
|
1368
|
+
Be.create = (r) => new Be({
|
|
1369
|
+
typeName: m.ZodSymbol,
|
|
1369
1370
|
...v(r)
|
|
1370
1371
|
});
|
|
1371
|
-
class
|
|
1372
|
+
class be extends g {
|
|
1372
1373
|
_parse(e) {
|
|
1373
1374
|
if (this._getType(e) !== f.undefined) {
|
|
1374
1375
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1378,14 +1379,14 @@ class _e extends g {
|
|
|
1378
1379
|
received: n.parsedType
|
|
1379
1380
|
}), y;
|
|
1380
1381
|
}
|
|
1381
|
-
return
|
|
1382
|
+
return R(e.data);
|
|
1382
1383
|
}
|
|
1383
1384
|
}
|
|
1384
|
-
|
|
1385
|
-
typeName:
|
|
1385
|
+
be.create = (r) => new be({
|
|
1386
|
+
typeName: m.ZodUndefined,
|
|
1386
1387
|
...v(r)
|
|
1387
1388
|
});
|
|
1388
|
-
class
|
|
1389
|
+
class ke extends g {
|
|
1389
1390
|
_parse(e) {
|
|
1390
1391
|
if (this._getType(e) !== f.null) {
|
|
1391
1392
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1395,38 +1396,38 @@ class xe extends g {
|
|
|
1395
1396
|
received: n.parsedType
|
|
1396
1397
|
}), y;
|
|
1397
1398
|
}
|
|
1398
|
-
return
|
|
1399
|
+
return R(e.data);
|
|
1399
1400
|
}
|
|
1400
1401
|
}
|
|
1401
|
-
|
|
1402
|
-
typeName:
|
|
1402
|
+
ke.create = (r) => new ke({
|
|
1403
|
+
typeName: m.ZodNull,
|
|
1403
1404
|
...v(r)
|
|
1404
1405
|
});
|
|
1405
|
-
class
|
|
1406
|
+
class fe extends g {
|
|
1406
1407
|
constructor() {
|
|
1407
1408
|
super(...arguments), this._any = !0;
|
|
1408
1409
|
}
|
|
1409
1410
|
_parse(e) {
|
|
1410
|
-
return
|
|
1411
|
+
return R(e.data);
|
|
1411
1412
|
}
|
|
1412
1413
|
}
|
|
1413
|
-
|
|
1414
|
-
typeName:
|
|
1414
|
+
fe.create = (r) => new fe({
|
|
1415
|
+
typeName: m.ZodAny,
|
|
1415
1416
|
...v(r)
|
|
1416
1417
|
});
|
|
1417
|
-
class
|
|
1418
|
+
class Q extends g {
|
|
1418
1419
|
constructor() {
|
|
1419
1420
|
super(...arguments), this._unknown = !0;
|
|
1420
1421
|
}
|
|
1421
1422
|
_parse(e) {
|
|
1422
|
-
return
|
|
1423
|
+
return R(e.data);
|
|
1423
1424
|
}
|
|
1424
1425
|
}
|
|
1425
|
-
|
|
1426
|
-
typeName:
|
|
1426
|
+
Q.create = (r) => new Q({
|
|
1427
|
+
typeName: m.ZodUnknown,
|
|
1427
1428
|
...v(r)
|
|
1428
1429
|
});
|
|
1429
|
-
class
|
|
1430
|
+
class z extends g {
|
|
1430
1431
|
_parse(e) {
|
|
1431
1432
|
const t = this._getOrReturnCtx(e);
|
|
1432
1433
|
return l(t, {
|
|
@@ -1436,11 +1437,11 @@ class V extends g {
|
|
|
1436
1437
|
}), y;
|
|
1437
1438
|
}
|
|
1438
1439
|
}
|
|
1439
|
-
|
|
1440
|
-
typeName:
|
|
1440
|
+
z.create = (r) => new z({
|
|
1441
|
+
typeName: m.ZodNever,
|
|
1441
1442
|
...v(r)
|
|
1442
1443
|
});
|
|
1443
|
-
class
|
|
1444
|
+
class qe extends g {
|
|
1444
1445
|
_parse(e) {
|
|
1445
1446
|
if (this._getType(e) !== f.undefined) {
|
|
1446
1447
|
const n = this._getOrReturnCtx(e);
|
|
@@ -1450,11 +1451,11 @@ class Ve extends g {
|
|
|
1450
1451
|
received: n.parsedType
|
|
1451
1452
|
}), y;
|
|
1452
1453
|
}
|
|
1453
|
-
return
|
|
1454
|
+
return R(e.data);
|
|
1454
1455
|
}
|
|
1455
1456
|
}
|
|
1456
|
-
|
|
1457
|
-
typeName:
|
|
1457
|
+
qe.create = (r) => new qe({
|
|
1458
|
+
typeName: m.ZodVoid,
|
|
1458
1459
|
...v(r)
|
|
1459
1460
|
});
|
|
1460
1461
|
class P extends g {
|
|
@@ -1493,9 +1494,9 @@ class P extends g {
|
|
|
1493
1494
|
exact: !1,
|
|
1494
1495
|
message: s.maxLength.message
|
|
1495
1496
|
}), n.dirty()), t.common.async)
|
|
1496
|
-
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new
|
|
1497
|
-
const a = [...t.data].map((i, o) => s.type._parseSync(new
|
|
1498
|
-
return
|
|
1497
|
+
return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new L(t, i, t.path, o)))).then((i) => S.mergeArray(n, i));
|
|
1498
|
+
const a = [...t.data].map((i, o) => s.type._parseSync(new L(t, i, t.path, o)));
|
|
1499
|
+
return S.mergeArray(n, a);
|
|
1499
1500
|
}
|
|
1500
1501
|
get element() {
|
|
1501
1502
|
return this._def.type;
|
|
@@ -1527,26 +1528,26 @@ P.create = (r, e) => new P({
|
|
|
1527
1528
|
minLength: null,
|
|
1528
1529
|
maxLength: null,
|
|
1529
1530
|
exactLength: null,
|
|
1530
|
-
typeName:
|
|
1531
|
+
typeName: m.ZodArray,
|
|
1531
1532
|
...v(e)
|
|
1532
1533
|
});
|
|
1533
|
-
function
|
|
1534
|
-
if (r instanceof
|
|
1534
|
+
function ce(r) {
|
|
1535
|
+
if (r instanceof b) {
|
|
1535
1536
|
const e = {};
|
|
1536
1537
|
for (const t in r.shape) {
|
|
1537
1538
|
const n = r.shape[t];
|
|
1538
|
-
e[t] =
|
|
1539
|
+
e[t] = U.create(ce(n));
|
|
1539
1540
|
}
|
|
1540
|
-
return new
|
|
1541
|
+
return new b({
|
|
1541
1542
|
...r._def,
|
|
1542
1543
|
shape: () => e
|
|
1543
1544
|
});
|
|
1544
1545
|
} else return r instanceof P ? new P({
|
|
1545
1546
|
...r._def,
|
|
1546
|
-
type:
|
|
1547
|
-
}) : r instanceof
|
|
1547
|
+
type: ce(r.element)
|
|
1548
|
+
}) : r instanceof U ? U.create(ce(r.unwrap())) : r instanceof G ? G.create(ce(r.unwrap())) : r instanceof M ? M.create(r.items.map((e) => ce(e))) : r;
|
|
1548
1549
|
}
|
|
1549
|
-
class
|
|
1550
|
+
class b extends g {
|
|
1550
1551
|
constructor() {
|
|
1551
1552
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1552
1553
|
}
|
|
@@ -1566,25 +1567,25 @@ class k extends g {
|
|
|
1566
1567
|
}), y;
|
|
1567
1568
|
}
|
|
1568
1569
|
const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1569
|
-
if (!(this._def.catchall instanceof
|
|
1570
|
+
if (!(this._def.catchall instanceof z && this._def.unknownKeys === "strip"))
|
|
1570
1571
|
for (const d in s.data)
|
|
1571
1572
|
i.includes(d) || o.push(d);
|
|
1572
1573
|
const u = [];
|
|
1573
1574
|
for (const d of i) {
|
|
1574
|
-
const
|
|
1575
|
+
const p = a[d], w = s.data[d];
|
|
1575
1576
|
u.push({
|
|
1576
1577
|
key: { status: "valid", value: d },
|
|
1577
|
-
value:
|
|
1578
|
+
value: p._parse(new L(s, w, s.path, d)),
|
|
1578
1579
|
alwaysSet: d in s.data
|
|
1579
1580
|
});
|
|
1580
1581
|
}
|
|
1581
|
-
if (this._def.catchall instanceof
|
|
1582
|
+
if (this._def.catchall instanceof z) {
|
|
1582
1583
|
const d = this._def.unknownKeys;
|
|
1583
1584
|
if (d === "passthrough")
|
|
1584
|
-
for (const
|
|
1585
|
+
for (const p of o)
|
|
1585
1586
|
u.push({
|
|
1586
|
-
key: { status: "valid", value:
|
|
1587
|
-
value: { status: "valid", value: s.data[
|
|
1587
|
+
key: { status: "valid", value: p },
|
|
1588
|
+
value: { status: "valid", value: s.data[p] }
|
|
1588
1589
|
});
|
|
1589
1590
|
else if (d === "strict")
|
|
1590
1591
|
o.length > 0 && (l(s, {
|
|
@@ -1594,36 +1595,36 @@ class k extends g {
|
|
|
1594
1595
|
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1595
1596
|
} else {
|
|
1596
1597
|
const d = this._def.catchall;
|
|
1597
|
-
for (const
|
|
1598
|
-
const
|
|
1598
|
+
for (const p of o) {
|
|
1599
|
+
const w = s.data[p];
|
|
1599
1600
|
u.push({
|
|
1600
|
-
key: { status: "valid", value:
|
|
1601
|
+
key: { status: "valid", value: p },
|
|
1601
1602
|
value: d._parse(
|
|
1602
|
-
new
|
|
1603
|
+
new L(s, w, s.path, p)
|
|
1603
1604
|
//, ctx.child(key), value, getParsedType(value)
|
|
1604
1605
|
),
|
|
1605
|
-
alwaysSet:
|
|
1606
|
+
alwaysSet: p in s.data
|
|
1606
1607
|
});
|
|
1607
1608
|
}
|
|
1608
1609
|
}
|
|
1609
1610
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1610
1611
|
const d = [];
|
|
1611
|
-
for (const
|
|
1612
|
-
const
|
|
1612
|
+
for (const p of u) {
|
|
1613
|
+
const w = await p.key, $ = await p.value;
|
|
1613
1614
|
d.push({
|
|
1614
|
-
key:
|
|
1615
|
-
value:
|
|
1616
|
-
alwaysSet:
|
|
1615
|
+
key: w,
|
|
1616
|
+
value: $,
|
|
1617
|
+
alwaysSet: p.alwaysSet
|
|
1617
1618
|
});
|
|
1618
1619
|
}
|
|
1619
1620
|
return d;
|
|
1620
|
-
}).then((d) =>
|
|
1621
|
+
}).then((d) => S.mergeObjectSync(n, d)) : S.mergeObjectSync(n, u);
|
|
1621
1622
|
}
|
|
1622
1623
|
get shape() {
|
|
1623
1624
|
return this._def.shape();
|
|
1624
1625
|
}
|
|
1625
1626
|
strict(e) {
|
|
1626
|
-
return h.errToObj, new
|
|
1627
|
+
return h.errToObj, new b({
|
|
1627
1628
|
...this._def,
|
|
1628
1629
|
unknownKeys: "strict",
|
|
1629
1630
|
...e !== void 0 ? {
|
|
@@ -1640,13 +1641,13 @@ class k extends g {
|
|
|
1640
1641
|
});
|
|
1641
1642
|
}
|
|
1642
1643
|
strip() {
|
|
1643
|
-
return new
|
|
1644
|
+
return new b({
|
|
1644
1645
|
...this._def,
|
|
1645
1646
|
unknownKeys: "strip"
|
|
1646
1647
|
});
|
|
1647
1648
|
}
|
|
1648
1649
|
passthrough() {
|
|
1649
|
-
return new
|
|
1650
|
+
return new b({
|
|
1650
1651
|
...this._def,
|
|
1651
1652
|
unknownKeys: "passthrough"
|
|
1652
1653
|
});
|
|
@@ -1669,7 +1670,7 @@ class k extends g {
|
|
|
1669
1670
|
// }) as any;
|
|
1670
1671
|
// };
|
|
1671
1672
|
extend(e) {
|
|
1672
|
-
return new
|
|
1673
|
+
return new b({
|
|
1673
1674
|
...this._def,
|
|
1674
1675
|
shape: () => ({
|
|
1675
1676
|
...this._def.shape(),
|
|
@@ -1683,14 +1684,14 @@ class k extends g {
|
|
|
1683
1684
|
* upgrade if you are experiencing issues.
|
|
1684
1685
|
*/
|
|
1685
1686
|
merge(e) {
|
|
1686
|
-
return new
|
|
1687
|
+
return new b({
|
|
1687
1688
|
unknownKeys: e._def.unknownKeys,
|
|
1688
1689
|
catchall: e._def.catchall,
|
|
1689
1690
|
shape: () => ({
|
|
1690
1691
|
...this._def.shape(),
|
|
1691
1692
|
...e._def.shape()
|
|
1692
1693
|
}),
|
|
1693
|
-
typeName:
|
|
1694
|
+
typeName: m.ZodObject
|
|
1694
1695
|
});
|
|
1695
1696
|
}
|
|
1696
1697
|
// merge<
|
|
@@ -1753,7 +1754,7 @@ class k extends g {
|
|
|
1753
1754
|
// return merged;
|
|
1754
1755
|
// }
|
|
1755
1756
|
catchall(e) {
|
|
1756
|
-
return new
|
|
1757
|
+
return new b({
|
|
1757
1758
|
...this._def,
|
|
1758
1759
|
catchall: e
|
|
1759
1760
|
});
|
|
@@ -1762,7 +1763,7 @@ class k extends g {
|
|
|
1762
1763
|
const t = {};
|
|
1763
1764
|
return _.objectKeys(e).forEach((n) => {
|
|
1764
1765
|
e[n] && this.shape[n] && (t[n] = this.shape[n]);
|
|
1765
|
-
}), new
|
|
1766
|
+
}), new b({
|
|
1766
1767
|
...this._def,
|
|
1767
1768
|
shape: () => t
|
|
1768
1769
|
});
|
|
@@ -1771,7 +1772,7 @@ class k extends g {
|
|
|
1771
1772
|
const t = {};
|
|
1772
1773
|
return _.objectKeys(this.shape).forEach((n) => {
|
|
1773
1774
|
e[n] || (t[n] = this.shape[n]);
|
|
1774
|
-
}), new
|
|
1775
|
+
}), new b({
|
|
1775
1776
|
...this._def,
|
|
1776
1777
|
shape: () => t
|
|
1777
1778
|
});
|
|
@@ -1780,14 +1781,14 @@ class k extends g {
|
|
|
1780
1781
|
* @deprecated
|
|
1781
1782
|
*/
|
|
1782
1783
|
deepPartial() {
|
|
1783
|
-
return
|
|
1784
|
+
return ce(this);
|
|
1784
1785
|
}
|
|
1785
1786
|
partial(e) {
|
|
1786
1787
|
const t = {};
|
|
1787
1788
|
return _.objectKeys(this.shape).forEach((n) => {
|
|
1788
1789
|
const s = this.shape[n];
|
|
1789
1790
|
e && !e[n] ? t[n] = s : t[n] = s.optional();
|
|
1790
|
-
}), new
|
|
1791
|
+
}), new b({
|
|
1791
1792
|
...this._def,
|
|
1792
1793
|
shape: () => t
|
|
1793
1794
|
});
|
|
@@ -1799,41 +1800,41 @@ class k extends g {
|
|
|
1799
1800
|
t[n] = this.shape[n];
|
|
1800
1801
|
else {
|
|
1801
1802
|
let a = this.shape[n];
|
|
1802
|
-
for (; a instanceof
|
|
1803
|
+
for (; a instanceof U; )
|
|
1803
1804
|
a = a._def.innerType;
|
|
1804
1805
|
t[n] = a;
|
|
1805
1806
|
}
|
|
1806
|
-
}), new
|
|
1807
|
+
}), new b({
|
|
1807
1808
|
...this._def,
|
|
1808
1809
|
shape: () => t
|
|
1809
1810
|
});
|
|
1810
1811
|
}
|
|
1811
1812
|
keyof() {
|
|
1812
|
-
return
|
|
1813
|
+
return It(_.objectKeys(this.shape));
|
|
1813
1814
|
}
|
|
1814
1815
|
}
|
|
1815
|
-
|
|
1816
|
+
b.create = (r, e) => new b({
|
|
1816
1817
|
shape: () => r,
|
|
1817
1818
|
unknownKeys: "strip",
|
|
1818
|
-
catchall:
|
|
1819
|
-
typeName:
|
|
1819
|
+
catchall: z.create(),
|
|
1820
|
+
typeName: m.ZodObject,
|
|
1820
1821
|
...v(e)
|
|
1821
1822
|
});
|
|
1822
|
-
|
|
1823
|
+
b.strictCreate = (r, e) => new b({
|
|
1823
1824
|
shape: () => r,
|
|
1824
1825
|
unknownKeys: "strict",
|
|
1825
|
-
catchall:
|
|
1826
|
-
typeName:
|
|
1826
|
+
catchall: z.create(),
|
|
1827
|
+
typeName: m.ZodObject,
|
|
1827
1828
|
...v(e)
|
|
1828
1829
|
});
|
|
1829
|
-
|
|
1830
|
+
b.lazycreate = (r, e) => new b({
|
|
1830
1831
|
shape: r,
|
|
1831
1832
|
unknownKeys: "strip",
|
|
1832
|
-
catchall:
|
|
1833
|
-
typeName:
|
|
1833
|
+
catchall: z.create(),
|
|
1834
|
+
typeName: m.ZodObject,
|
|
1834
1835
|
...v(e)
|
|
1835
1836
|
});
|
|
1836
|
-
class
|
|
1837
|
+
class we extends g {
|
|
1837
1838
|
_parse(e) {
|
|
1838
1839
|
const { ctx: t } = this._processInputParams(e), n = this._def.options;
|
|
1839
1840
|
function s(a) {
|
|
@@ -1843,7 +1844,7 @@ class ke extends g {
|
|
|
1843
1844
|
for (const o of a)
|
|
1844
1845
|
if (o.result.status === "dirty")
|
|
1845
1846
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1846
|
-
const i = a.map((o) => new
|
|
1847
|
+
const i = a.map((o) => new Z(o.ctx.common.issues));
|
|
1847
1848
|
return l(t, {
|
|
1848
1849
|
code: c.invalid_union,
|
|
1849
1850
|
unionErrors: i
|
|
@@ -1879,18 +1880,18 @@ class ke extends g {
|
|
|
1879
1880
|
issues: []
|
|
1880
1881
|
},
|
|
1881
1882
|
parent: null
|
|
1882
|
-
},
|
|
1883
|
+
}, p = u._parseSync({
|
|
1883
1884
|
data: t.data,
|
|
1884
1885
|
path: t.path,
|
|
1885
1886
|
parent: d
|
|
1886
1887
|
});
|
|
1887
|
-
if (
|
|
1888
|
-
return
|
|
1889
|
-
|
|
1888
|
+
if (p.status === "valid")
|
|
1889
|
+
return p;
|
|
1890
|
+
p.status === "dirty" && !a && (a = { result: p, ctx: d }), d.common.issues.length && i.push(d.common.issues);
|
|
1890
1891
|
}
|
|
1891
1892
|
if (a)
|
|
1892
1893
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1893
|
-
const o = i.map((u) => new
|
|
1894
|
+
const o = i.map((u) => new Z(u));
|
|
1894
1895
|
return l(t, {
|
|
1895
1896
|
code: c.invalid_union,
|
|
1896
1897
|
unionErrors: o
|
|
@@ -1901,13 +1902,13 @@ class ke extends g {
|
|
|
1901
1902
|
return this._def.options;
|
|
1902
1903
|
}
|
|
1903
1904
|
}
|
|
1904
|
-
|
|
1905
|
+
we.create = (r, e) => new we({
|
|
1905
1906
|
options: r,
|
|
1906
|
-
typeName:
|
|
1907
|
+
typeName: m.ZodUnion,
|
|
1907
1908
|
...v(e)
|
|
1908
1909
|
});
|
|
1909
|
-
const
|
|
1910
|
-
class
|
|
1910
|
+
const V = (r) => r instanceof Se ? V(r.schema) : r instanceof D ? V(r.innerType()) : r instanceof Ce ? [r.value] : r instanceof Y ? r.options : r instanceof Re ? _.objectValues(r.enum) : r instanceof Oe ? V(r._def.innerType) : r instanceof be ? [void 0] : r instanceof ke ? [null] : r instanceof U ? [void 0, ...V(r.unwrap())] : r instanceof G ? [null, ...V(r.unwrap())] : r instanceof ot || r instanceof Ze ? V(r.unwrap()) : r instanceof Ie ? V(r._def.innerType) : [];
|
|
1911
|
+
class We extends g {
|
|
1911
1912
|
_parse(e) {
|
|
1912
1913
|
const { ctx: t } = this._processInputParams(e);
|
|
1913
1914
|
if (t.parsedType !== f.object)
|
|
@@ -1951,7 +1952,7 @@ class He extends g {
|
|
|
1951
1952
|
static create(e, t, n) {
|
|
1952
1953
|
const s = /* @__PURE__ */ new Map();
|
|
1953
1954
|
for (const a of t) {
|
|
1954
|
-
const i =
|
|
1955
|
+
const i = V(a.shape[e]);
|
|
1955
1956
|
if (!i.length)
|
|
1956
1957
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
1957
1958
|
for (const o of i) {
|
|
@@ -1960,8 +1961,8 @@ class He extends g {
|
|
|
1960
1961
|
s.set(o, a);
|
|
1961
1962
|
}
|
|
1962
1963
|
}
|
|
1963
|
-
return new
|
|
1964
|
-
typeName:
|
|
1964
|
+
return new We({
|
|
1965
|
+
typeName: m.ZodDiscriminatedUnion,
|
|
1965
1966
|
discriminator: e,
|
|
1966
1967
|
options: t,
|
|
1967
1968
|
optionsMap: s,
|
|
@@ -1969,14 +1970,14 @@ class He extends g {
|
|
|
1969
1970
|
});
|
|
1970
1971
|
}
|
|
1971
1972
|
}
|
|
1972
|
-
function
|
|
1973
|
+
function it(r, e) {
|
|
1973
1974
|
const t = H(r), n = H(e);
|
|
1974
1975
|
if (r === e)
|
|
1975
1976
|
return { valid: !0, data: r };
|
|
1976
1977
|
if (t === f.object && n === f.object) {
|
|
1977
1978
|
const s = _.objectKeys(e), a = _.objectKeys(r).filter((o) => s.indexOf(o) !== -1), i = { ...r, ...e };
|
|
1978
1979
|
for (const o of a) {
|
|
1979
|
-
const u =
|
|
1980
|
+
const u = it(r[o], e[o]);
|
|
1980
1981
|
if (!u.valid)
|
|
1981
1982
|
return { valid: !1 };
|
|
1982
1983
|
i[o] = u.data;
|
|
@@ -1987,7 +1988,7 @@ function nt(r, e) {
|
|
|
1987
1988
|
return { valid: !1 };
|
|
1988
1989
|
const s = [];
|
|
1989
1990
|
for (let a = 0; a < r.length; a++) {
|
|
1990
|
-
const i = r[a], o = e[a], u =
|
|
1991
|
+
const i = r[a], o = e[a], u = it(i, o);
|
|
1991
1992
|
if (!u.valid)
|
|
1992
1993
|
return { valid: !1 };
|
|
1993
1994
|
s.push(u.data);
|
|
@@ -1995,13 +1996,13 @@ function nt(r, e) {
|
|
|
1995
1996
|
return { valid: !0, data: s };
|
|
1996
1997
|
} else return t === f.date && n === f.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
|
|
1997
1998
|
}
|
|
1998
|
-
class
|
|
1999
|
+
class Te extends g {
|
|
1999
2000
|
_parse(e) {
|
|
2000
2001
|
const { status: t, ctx: n } = this._processInputParams(e), s = (a, i) => {
|
|
2001
|
-
if (
|
|
2002
|
+
if (st(a) || st(i))
|
|
2002
2003
|
return y;
|
|
2003
|
-
const o =
|
|
2004
|
-
return o.valid ? ((
|
|
2004
|
+
const o = it(a.value, i.value);
|
|
2005
|
+
return o.valid ? ((at(a) || at(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(n, {
|
|
2005
2006
|
code: c.invalid_intersection_types
|
|
2006
2007
|
}), y);
|
|
2007
2008
|
};
|
|
@@ -2027,13 +2028,13 @@ class be extends g {
|
|
|
2027
2028
|
}));
|
|
2028
2029
|
}
|
|
2029
2030
|
}
|
|
2030
|
-
|
|
2031
|
+
Te.create = (r, e, t) => new Te({
|
|
2031
2032
|
left: r,
|
|
2032
2033
|
right: e,
|
|
2033
|
-
typeName:
|
|
2034
|
+
typeName: m.ZodIntersection,
|
|
2034
2035
|
...v(t)
|
|
2035
2036
|
});
|
|
2036
|
-
class
|
|
2037
|
+
class M extends g {
|
|
2037
2038
|
_parse(e) {
|
|
2038
2039
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2039
2040
|
if (n.parsedType !== f.array)
|
|
@@ -2059,31 +2060,31 @@ class L extends g {
|
|
|
2059
2060
|
}), t.dirty());
|
|
2060
2061
|
const a = [...n.data].map((i, o) => {
|
|
2061
2062
|
const u = this._def.items[o] || this._def.rest;
|
|
2062
|
-
return u ? u._parse(new
|
|
2063
|
+
return u ? u._parse(new L(n, i, n.path, o)) : null;
|
|
2063
2064
|
}).filter((i) => !!i);
|
|
2064
|
-
return n.common.async ? Promise.all(a).then((i) =>
|
|
2065
|
+
return n.common.async ? Promise.all(a).then((i) => S.mergeArray(t, i)) : S.mergeArray(t, a);
|
|
2065
2066
|
}
|
|
2066
2067
|
get items() {
|
|
2067
2068
|
return this._def.items;
|
|
2068
2069
|
}
|
|
2069
2070
|
rest(e) {
|
|
2070
|
-
return new
|
|
2071
|
+
return new M({
|
|
2071
2072
|
...this._def,
|
|
2072
2073
|
rest: e
|
|
2073
2074
|
});
|
|
2074
2075
|
}
|
|
2075
2076
|
}
|
|
2076
|
-
|
|
2077
|
+
M.create = (r, e) => {
|
|
2077
2078
|
if (!Array.isArray(r))
|
|
2078
2079
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2079
|
-
return new
|
|
2080
|
+
return new M({
|
|
2080
2081
|
items: r,
|
|
2081
|
-
typeName:
|
|
2082
|
+
typeName: m.ZodTuple,
|
|
2082
2083
|
rest: null,
|
|
2083
2084
|
...v(e)
|
|
2084
2085
|
});
|
|
2085
2086
|
};
|
|
2086
|
-
class
|
|
2087
|
+
class Ee extends g {
|
|
2087
2088
|
get keySchema() {
|
|
2088
2089
|
return this._def.keyType;
|
|
2089
2090
|
}
|
|
@@ -2101,30 +2102,30 @@ class Te extends g {
|
|
|
2101
2102
|
const s = [], a = this._def.keyType, i = this._def.valueType;
|
|
2102
2103
|
for (const o in n.data)
|
|
2103
2104
|
s.push({
|
|
2104
|
-
key: a._parse(new
|
|
2105
|
-
value: i._parse(new
|
|
2105
|
+
key: a._parse(new L(n, o, n.path, o)),
|
|
2106
|
+
value: i._parse(new L(n, n.data[o], n.path, o)),
|
|
2106
2107
|
alwaysSet: o in n.data
|
|
2107
2108
|
});
|
|
2108
|
-
return n.common.async ?
|
|
2109
|
+
return n.common.async ? S.mergeObjectAsync(t, s) : S.mergeObjectSync(t, s);
|
|
2109
2110
|
}
|
|
2110
2111
|
get element() {
|
|
2111
2112
|
return this._def.valueType;
|
|
2112
2113
|
}
|
|
2113
2114
|
static create(e, t, n) {
|
|
2114
|
-
return t instanceof g ? new
|
|
2115
|
+
return t instanceof g ? new Ee({
|
|
2115
2116
|
keyType: e,
|
|
2116
2117
|
valueType: t,
|
|
2117
|
-
typeName:
|
|
2118
|
+
typeName: m.ZodRecord,
|
|
2118
2119
|
...v(n)
|
|
2119
|
-
}) : new
|
|
2120
|
+
}) : new Ee({
|
|
2120
2121
|
keyType: j.create(),
|
|
2121
2122
|
valueType: e,
|
|
2122
|
-
typeName:
|
|
2123
|
+
typeName: m.ZodRecord,
|
|
2123
2124
|
...v(t)
|
|
2124
2125
|
});
|
|
2125
2126
|
}
|
|
2126
2127
|
}
|
|
2127
|
-
class
|
|
2128
|
+
class He extends g {
|
|
2128
2129
|
get keySchema() {
|
|
2129
2130
|
return this._def.keyType;
|
|
2130
2131
|
}
|
|
@@ -2140,39 +2141,39 @@ class ze extends g {
|
|
|
2140
2141
|
received: n.parsedType
|
|
2141
2142
|
}), y;
|
|
2142
2143
|
const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, u], d) => ({
|
|
2143
|
-
key: s._parse(new
|
|
2144
|
-
value: a._parse(new
|
|
2144
|
+
key: s._parse(new L(n, o, n.path, [d, "key"])),
|
|
2145
|
+
value: a._parse(new L(n, u, n.path, [d, "value"]))
|
|
2145
2146
|
}));
|
|
2146
2147
|
if (n.common.async) {
|
|
2147
2148
|
const o = /* @__PURE__ */ new Map();
|
|
2148
2149
|
return Promise.resolve().then(async () => {
|
|
2149
2150
|
for (const u of i) {
|
|
2150
|
-
const d = await u.key,
|
|
2151
|
-
if (d.status === "aborted" ||
|
|
2151
|
+
const d = await u.key, p = await u.value;
|
|
2152
|
+
if (d.status === "aborted" || p.status === "aborted")
|
|
2152
2153
|
return y;
|
|
2153
|
-
(d.status === "dirty" ||
|
|
2154
|
+
(d.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(d.value, p.value);
|
|
2154
2155
|
}
|
|
2155
2156
|
return { status: t.value, value: o };
|
|
2156
2157
|
});
|
|
2157
2158
|
} else {
|
|
2158
2159
|
const o = /* @__PURE__ */ new Map();
|
|
2159
2160
|
for (const u of i) {
|
|
2160
|
-
const d = u.key,
|
|
2161
|
-
if (d.status === "aborted" ||
|
|
2161
|
+
const d = u.key, p = u.value;
|
|
2162
|
+
if (d.status === "aborted" || p.status === "aborted")
|
|
2162
2163
|
return y;
|
|
2163
|
-
(d.status === "dirty" ||
|
|
2164
|
+
(d.status === "dirty" || p.status === "dirty") && t.dirty(), o.set(d.value, p.value);
|
|
2164
2165
|
}
|
|
2165
2166
|
return { status: t.value, value: o };
|
|
2166
2167
|
}
|
|
2167
2168
|
}
|
|
2168
2169
|
}
|
|
2169
|
-
|
|
2170
|
+
He.create = (r, e, t) => new He({
|
|
2170
2171
|
valueType: e,
|
|
2171
2172
|
keyType: r,
|
|
2172
|
-
typeName:
|
|
2173
|
+
typeName: m.ZodMap,
|
|
2173
2174
|
...v(t)
|
|
2174
2175
|
});
|
|
2175
|
-
class
|
|
2176
|
+
class te extends g {
|
|
2176
2177
|
_parse(e) {
|
|
2177
2178
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2178
2179
|
if (n.parsedType !== f.set)
|
|
@@ -2200,24 +2201,24 @@ class ee extends g {
|
|
|
2200
2201
|
const a = this._def.valueType;
|
|
2201
2202
|
function i(u) {
|
|
2202
2203
|
const d = /* @__PURE__ */ new Set();
|
|
2203
|
-
for (const
|
|
2204
|
-
if (
|
|
2204
|
+
for (const p of u) {
|
|
2205
|
+
if (p.status === "aborted")
|
|
2205
2206
|
return y;
|
|
2206
|
-
|
|
2207
|
+
p.status === "dirty" && t.dirty(), d.add(p.value);
|
|
2207
2208
|
}
|
|
2208
2209
|
return { status: t.value, value: d };
|
|
2209
2210
|
}
|
|
2210
|
-
const o = [...n.data.values()].map((u, d) => a._parse(new
|
|
2211
|
+
const o = [...n.data.values()].map((u, d) => a._parse(new L(n, u, n.path, d)));
|
|
2211
2212
|
return n.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
|
|
2212
2213
|
}
|
|
2213
2214
|
min(e, t) {
|
|
2214
|
-
return new
|
|
2215
|
+
return new te({
|
|
2215
2216
|
...this._def,
|
|
2216
2217
|
minSize: { value: e, message: h.toString(t) }
|
|
2217
2218
|
});
|
|
2218
2219
|
}
|
|
2219
2220
|
max(e, t) {
|
|
2220
|
-
return new
|
|
2221
|
+
return new te({
|
|
2221
2222
|
...this._def,
|
|
2222
2223
|
maxSize: { value: e, message: h.toString(t) }
|
|
2223
2224
|
});
|
|
@@ -2229,14 +2230,14 @@ class ee extends g {
|
|
|
2229
2230
|
return this.min(1, e);
|
|
2230
2231
|
}
|
|
2231
2232
|
}
|
|
2232
|
-
|
|
2233
|
+
te.create = (r, e) => new te({
|
|
2233
2234
|
valueType: r,
|
|
2234
2235
|
minSize: null,
|
|
2235
2236
|
maxSize: null,
|
|
2236
|
-
typeName:
|
|
2237
|
+
typeName: m.ZodSet,
|
|
2237
2238
|
...v(e)
|
|
2238
2239
|
});
|
|
2239
|
-
class
|
|
2240
|
+
class ue extends g {
|
|
2240
2241
|
constructor() {
|
|
2241
2242
|
super(...arguments), this.validate = this.implement;
|
|
2242
2243
|
}
|
|
@@ -2249,14 +2250,14 @@ class de extends g {
|
|
|
2249
2250
|
received: t.parsedType
|
|
2250
2251
|
}), y;
|
|
2251
2252
|
function n(o, u) {
|
|
2252
|
-
return
|
|
2253
|
+
return Ve({
|
|
2253
2254
|
data: o,
|
|
2254
2255
|
path: t.path,
|
|
2255
2256
|
errorMaps: [
|
|
2256
2257
|
t.common.contextualErrorMap,
|
|
2257
2258
|
t.schemaErrorMap,
|
|
2258
|
-
|
|
2259
|
-
|
|
2259
|
+
$e(),
|
|
2260
|
+
le
|
|
2260
2261
|
].filter((d) => !!d),
|
|
2261
2262
|
issueData: {
|
|
2262
2263
|
code: c.invalid_arguments,
|
|
@@ -2265,14 +2266,14 @@ class de extends g {
|
|
|
2265
2266
|
});
|
|
2266
2267
|
}
|
|
2267
2268
|
function s(o, u) {
|
|
2268
|
-
return
|
|
2269
|
+
return Ve({
|
|
2269
2270
|
data: o,
|
|
2270
2271
|
path: t.path,
|
|
2271
2272
|
errorMaps: [
|
|
2272
2273
|
t.common.contextualErrorMap,
|
|
2273
2274
|
t.schemaErrorMap,
|
|
2274
|
-
|
|
2275
|
-
|
|
2275
|
+
$e(),
|
|
2276
|
+
le
|
|
2276
2277
|
].filter((d) => !!d),
|
|
2277
2278
|
issueData: {
|
|
2278
2279
|
code: c.invalid_return_type,
|
|
@@ -2281,26 +2282,26 @@ class de extends g {
|
|
|
2281
2282
|
});
|
|
2282
2283
|
}
|
|
2283
2284
|
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
2284
|
-
if (this._def.returns instanceof
|
|
2285
|
+
if (this._def.returns instanceof he) {
|
|
2285
2286
|
const o = this;
|
|
2286
|
-
return
|
|
2287
|
-
const d = new
|
|
2288
|
-
throw d.addIssue(n(u,
|
|
2289
|
-
}),
|
|
2290
|
-
return await o._def.returns._def.type.parseAsync(
|
|
2291
|
-
throw d.addIssue(s(
|
|
2287
|
+
return R(async function(...u) {
|
|
2288
|
+
const d = new Z([]), p = await o._def.args.parseAsync(u, a).catch((F) => {
|
|
2289
|
+
throw d.addIssue(n(u, F)), d;
|
|
2290
|
+
}), w = await Reflect.apply(i, this, p);
|
|
2291
|
+
return await o._def.returns._def.type.parseAsync(w, a).catch((F) => {
|
|
2292
|
+
throw d.addIssue(s(w, F)), d;
|
|
2292
2293
|
});
|
|
2293
2294
|
});
|
|
2294
2295
|
} else {
|
|
2295
2296
|
const o = this;
|
|
2296
|
-
return
|
|
2297
|
+
return R(function(...u) {
|
|
2297
2298
|
const d = o._def.args.safeParse(u, a);
|
|
2298
2299
|
if (!d.success)
|
|
2299
|
-
throw new
|
|
2300
|
-
const
|
|
2301
|
-
if (!
|
|
2302
|
-
throw new
|
|
2303
|
-
return
|
|
2300
|
+
throw new Z([n(u, d.error)]);
|
|
2301
|
+
const p = Reflect.apply(i, this, d.data), w = o._def.returns.safeParse(p, a);
|
|
2302
|
+
if (!w.success)
|
|
2303
|
+
throw new Z([s(p, w.error)]);
|
|
2304
|
+
return w.data;
|
|
2304
2305
|
});
|
|
2305
2306
|
}
|
|
2306
2307
|
}
|
|
@@ -2311,13 +2312,13 @@ class de extends g {
|
|
|
2311
2312
|
return this._def.returns;
|
|
2312
2313
|
}
|
|
2313
2314
|
args(...e) {
|
|
2314
|
-
return new
|
|
2315
|
+
return new ue({
|
|
2315
2316
|
...this._def,
|
|
2316
|
-
args:
|
|
2317
|
+
args: M.create(e).rest(Q.create())
|
|
2317
2318
|
});
|
|
2318
2319
|
}
|
|
2319
2320
|
returns(e) {
|
|
2320
|
-
return new
|
|
2321
|
+
return new ue({
|
|
2321
2322
|
...this._def,
|
|
2322
2323
|
returns: e
|
|
2323
2324
|
});
|
|
@@ -2329,15 +2330,15 @@ class de extends g {
|
|
|
2329
2330
|
return this.parse(e);
|
|
2330
2331
|
}
|
|
2331
2332
|
static create(e, t, n) {
|
|
2332
|
-
return new
|
|
2333
|
-
args: e ||
|
|
2334
|
-
returns: t ||
|
|
2335
|
-
typeName:
|
|
2333
|
+
return new ue({
|
|
2334
|
+
args: e || M.create([]).rest(Q.create()),
|
|
2335
|
+
returns: t || Q.create(),
|
|
2336
|
+
typeName: m.ZodFunction,
|
|
2336
2337
|
...v(n)
|
|
2337
2338
|
});
|
|
2338
2339
|
}
|
|
2339
2340
|
}
|
|
2340
|
-
class
|
|
2341
|
+
class Se extends g {
|
|
2341
2342
|
get schema() {
|
|
2342
2343
|
return this._def.getter();
|
|
2343
2344
|
}
|
|
@@ -2346,12 +2347,12 @@ class we extends g {
|
|
|
2346
2347
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2347
2348
|
}
|
|
2348
2349
|
}
|
|
2349
|
-
|
|
2350
|
+
Se.create = (r, e) => new Se({
|
|
2350
2351
|
getter: r,
|
|
2351
|
-
typeName:
|
|
2352
|
+
typeName: m.ZodLazy,
|
|
2352
2353
|
...v(e)
|
|
2353
2354
|
});
|
|
2354
|
-
class
|
|
2355
|
+
class Ce extends g {
|
|
2355
2356
|
_parse(e) {
|
|
2356
2357
|
if (e.data !== this._def.value) {
|
|
2357
2358
|
const t = this._getOrReturnCtx(e);
|
|
@@ -2367,15 +2368,15 @@ class Ee extends g {
|
|
|
2367
2368
|
return this._def.value;
|
|
2368
2369
|
}
|
|
2369
2370
|
}
|
|
2370
|
-
|
|
2371
|
+
Ce.create = (r, e) => new Ce({
|
|
2371
2372
|
value: r,
|
|
2372
|
-
typeName:
|
|
2373
|
+
typeName: m.ZodLiteral,
|
|
2373
2374
|
...v(e)
|
|
2374
2375
|
});
|
|
2375
|
-
function
|
|
2376
|
+
function It(r, e) {
|
|
2376
2377
|
return new Y({
|
|
2377
2378
|
values: r,
|
|
2378
|
-
typeName:
|
|
2379
|
+
typeName: m.ZodEnum,
|
|
2379
2380
|
...v(e)
|
|
2380
2381
|
});
|
|
2381
2382
|
}
|
|
@@ -2392,7 +2393,7 @@ class Y extends g {
|
|
|
2392
2393
|
code: c.invalid_type
|
|
2393
2394
|
}), y;
|
|
2394
2395
|
}
|
|
2395
|
-
if (
|
|
2396
|
+
if (ze(this, me) || St(this, me, new Set(this._def.values)), !ze(this, me).has(e.data)) {
|
|
2396
2397
|
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2397
2398
|
return l(t, {
|
|
2398
2399
|
received: t.data,
|
|
@@ -2400,7 +2401,7 @@ class Y extends g {
|
|
|
2400
2401
|
options: n
|
|
2401
2402
|
}), y;
|
|
2402
2403
|
}
|
|
2403
|
-
return
|
|
2404
|
+
return R(e.data);
|
|
2404
2405
|
}
|
|
2405
2406
|
get options() {
|
|
2406
2407
|
return this._def.values;
|
|
@@ -2437,10 +2438,10 @@ class Y extends g {
|
|
|
2437
2438
|
}
|
|
2438
2439
|
}
|
|
2439
2440
|
me = /* @__PURE__ */ new WeakMap();
|
|
2440
|
-
Y.create =
|
|
2441
|
-
class
|
|
2441
|
+
Y.create = It;
|
|
2442
|
+
class Re extends g {
|
|
2442
2443
|
constructor() {
|
|
2443
|
-
super(...arguments),
|
|
2444
|
+
super(...arguments), ye.set(this, void 0);
|
|
2444
2445
|
}
|
|
2445
2446
|
_parse(e) {
|
|
2446
2447
|
const t = _.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
@@ -2452,7 +2453,7 @@ class Ce extends g {
|
|
|
2452
2453
|
code: c.invalid_type
|
|
2453
2454
|
}), y;
|
|
2454
2455
|
}
|
|
2455
|
-
if (
|
|
2456
|
+
if (ze(this, ye) || St(this, ye, new Set(_.getValidEnumValues(this._def.values))), !ze(this, ye).has(e.data)) {
|
|
2456
2457
|
const s = _.objectValues(t);
|
|
2457
2458
|
return l(n, {
|
|
2458
2459
|
received: n.data,
|
|
@@ -2460,19 +2461,19 @@ class Ce extends g {
|
|
|
2460
2461
|
options: s
|
|
2461
2462
|
}), y;
|
|
2462
2463
|
}
|
|
2463
|
-
return
|
|
2464
|
+
return R(e.data);
|
|
2464
2465
|
}
|
|
2465
2466
|
get enum() {
|
|
2466
2467
|
return this._def.values;
|
|
2467
2468
|
}
|
|
2468
2469
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2470
|
+
ye = /* @__PURE__ */ new WeakMap();
|
|
2471
|
+
Re.create = (r, e) => new Re({
|
|
2471
2472
|
values: r,
|
|
2472
|
-
typeName:
|
|
2473
|
+
typeName: m.ZodNativeEnum,
|
|
2473
2474
|
...v(e)
|
|
2474
2475
|
});
|
|
2475
|
-
class
|
|
2476
|
+
class he extends g {
|
|
2476
2477
|
unwrap() {
|
|
2477
2478
|
return this._def.type;
|
|
2478
2479
|
}
|
|
@@ -2485,15 +2486,15 @@ class fe extends g {
|
|
|
2485
2486
|
received: t.parsedType
|
|
2486
2487
|
}), y;
|
|
2487
2488
|
const n = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
|
|
2488
|
-
return
|
|
2489
|
+
return R(n.then((s) => this._def.type.parseAsync(s, {
|
|
2489
2490
|
path: t.path,
|
|
2490
2491
|
errorMap: t.common.contextualErrorMap
|
|
2491
2492
|
})));
|
|
2492
2493
|
}
|
|
2493
2494
|
}
|
|
2494
|
-
|
|
2495
|
+
he.create = (r, e) => new he({
|
|
2495
2496
|
type: r,
|
|
2496
|
-
typeName:
|
|
2497
|
+
typeName: m.ZodPromise,
|
|
2497
2498
|
...v(e)
|
|
2498
2499
|
});
|
|
2499
2500
|
class D extends g {
|
|
@@ -2501,7 +2502,7 @@ class D extends g {
|
|
|
2501
2502
|
return this._def.schema;
|
|
2502
2503
|
}
|
|
2503
2504
|
sourceType() {
|
|
2504
|
-
return this._def.schema._def.typeName ===
|
|
2505
|
+
return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2505
2506
|
}
|
|
2506
2507
|
_parse(e) {
|
|
2507
2508
|
const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
|
|
@@ -2523,7 +2524,7 @@ class D extends g {
|
|
|
2523
2524
|
path: n.path,
|
|
2524
2525
|
parent: n
|
|
2525
2526
|
});
|
|
2526
|
-
return u.status === "aborted" ? y : u.status === "dirty" || t.value === "dirty" ?
|
|
2527
|
+
return u.status === "aborted" ? y : u.status === "dirty" || t.value === "dirty" ? de(u.value) : u;
|
|
2527
2528
|
});
|
|
2528
2529
|
{
|
|
2529
2530
|
if (t.value === "aborted")
|
|
@@ -2533,7 +2534,7 @@ class D extends g {
|
|
|
2533
2534
|
path: n.path,
|
|
2534
2535
|
parent: n
|
|
2535
2536
|
});
|
|
2536
|
-
return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ?
|
|
2537
|
+
return o.status === "aborted" ? y : o.status === "dirty" || t.value === "dirty" ? de(o.value) : o;
|
|
2537
2538
|
}
|
|
2538
2539
|
}
|
|
2539
2540
|
if (s.type === "refinement") {
|
|
@@ -2562,56 +2563,56 @@ class D extends g {
|
|
|
2562
2563
|
path: n.path,
|
|
2563
2564
|
parent: n
|
|
2564
2565
|
});
|
|
2565
|
-
if (!
|
|
2566
|
+
if (!ge(i))
|
|
2566
2567
|
return i;
|
|
2567
2568
|
const o = s.transform(i.value, a);
|
|
2568
2569
|
if (o instanceof Promise)
|
|
2569
2570
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2570
2571
|
return { status: t.value, value: o };
|
|
2571
2572
|
} else
|
|
2572
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) =>
|
|
2573
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => ge(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
|
|
2573
2574
|
_.assertNever(s);
|
|
2574
2575
|
}
|
|
2575
2576
|
}
|
|
2576
2577
|
D.create = (r, e, t) => new D({
|
|
2577
2578
|
schema: r,
|
|
2578
|
-
typeName:
|
|
2579
|
+
typeName: m.ZodEffects,
|
|
2579
2580
|
effect: e,
|
|
2580
2581
|
...v(t)
|
|
2581
2582
|
});
|
|
2582
2583
|
D.createWithPreprocess = (r, e, t) => new D({
|
|
2583
2584
|
schema: e,
|
|
2584
2585
|
effect: { type: "preprocess", transform: r },
|
|
2585
|
-
typeName:
|
|
2586
|
+
typeName: m.ZodEffects,
|
|
2586
2587
|
...v(t)
|
|
2587
2588
|
});
|
|
2588
|
-
class
|
|
2589
|
+
class U extends g {
|
|
2589
2590
|
_parse(e) {
|
|
2590
|
-
return this._getType(e) === f.undefined ?
|
|
2591
|
+
return this._getType(e) === f.undefined ? R(void 0) : this._def.innerType._parse(e);
|
|
2591
2592
|
}
|
|
2592
2593
|
unwrap() {
|
|
2593
2594
|
return this._def.innerType;
|
|
2594
2595
|
}
|
|
2595
2596
|
}
|
|
2596
|
-
|
|
2597
|
+
U.create = (r, e) => new U({
|
|
2597
2598
|
innerType: r,
|
|
2598
|
-
typeName:
|
|
2599
|
+
typeName: m.ZodOptional,
|
|
2599
2600
|
...v(e)
|
|
2600
2601
|
});
|
|
2601
|
-
class
|
|
2602
|
+
class G extends g {
|
|
2602
2603
|
_parse(e) {
|
|
2603
|
-
return this._getType(e) === f.null ?
|
|
2604
|
+
return this._getType(e) === f.null ? R(null) : this._def.innerType._parse(e);
|
|
2604
2605
|
}
|
|
2605
2606
|
unwrap() {
|
|
2606
2607
|
return this._def.innerType;
|
|
2607
2608
|
}
|
|
2608
2609
|
}
|
|
2609
|
-
|
|
2610
|
+
G.create = (r, e) => new G({
|
|
2610
2611
|
innerType: r,
|
|
2611
|
-
typeName:
|
|
2612
|
+
typeName: m.ZodNullable,
|
|
2612
2613
|
...v(e)
|
|
2613
2614
|
});
|
|
2614
|
-
class
|
|
2615
|
+
class Oe extends g {
|
|
2615
2616
|
_parse(e) {
|
|
2616
2617
|
const { ctx: t } = this._processInputParams(e);
|
|
2617
2618
|
let n = t.data;
|
|
@@ -2625,13 +2626,13 @@ class Se extends g {
|
|
|
2625
2626
|
return this._def.innerType;
|
|
2626
2627
|
}
|
|
2627
2628
|
}
|
|
2628
|
-
|
|
2629
|
+
Oe.create = (r, e) => new Oe({
|
|
2629
2630
|
innerType: r,
|
|
2630
|
-
typeName:
|
|
2631
|
+
typeName: m.ZodDefault,
|
|
2631
2632
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2632
2633
|
...v(e)
|
|
2633
2634
|
});
|
|
2634
|
-
class
|
|
2635
|
+
class Ie extends g {
|
|
2635
2636
|
_parse(e) {
|
|
2636
2637
|
const { ctx: t } = this._processInputParams(e), n = {
|
|
2637
2638
|
...t,
|
|
@@ -2646,11 +2647,11 @@ class Oe extends g {
|
|
|
2646
2647
|
...n
|
|
2647
2648
|
}
|
|
2648
2649
|
});
|
|
2649
|
-
return
|
|
2650
|
+
return _e(s) ? s.then((a) => ({
|
|
2650
2651
|
status: "valid",
|
|
2651
2652
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2652
2653
|
get error() {
|
|
2653
|
-
return new
|
|
2654
|
+
return new Z(n.common.issues);
|
|
2654
2655
|
},
|
|
2655
2656
|
input: n.data
|
|
2656
2657
|
})
|
|
@@ -2658,7 +2659,7 @@ class Oe extends g {
|
|
|
2658
2659
|
status: "valid",
|
|
2659
2660
|
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
2660
2661
|
get error() {
|
|
2661
|
-
return new
|
|
2662
|
+
return new Z(n.common.issues);
|
|
2662
2663
|
},
|
|
2663
2664
|
input: n.data
|
|
2664
2665
|
})
|
|
@@ -2668,13 +2669,13 @@ class Oe extends g {
|
|
|
2668
2669
|
return this._def.innerType;
|
|
2669
2670
|
}
|
|
2670
2671
|
}
|
|
2671
|
-
|
|
2672
|
+
Ie.create = (r, e) => new Ie({
|
|
2672
2673
|
innerType: r,
|
|
2673
|
-
typeName:
|
|
2674
|
+
typeName: m.ZodCatch,
|
|
2674
2675
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2675
2676
|
...v(e)
|
|
2676
2677
|
});
|
|
2677
|
-
class
|
|
2678
|
+
class Ke extends g {
|
|
2678
2679
|
_parse(e) {
|
|
2679
2680
|
if (this._getType(e) !== f.nan) {
|
|
2680
2681
|
const n = this._getOrReturnCtx(e);
|
|
@@ -2687,12 +2688,12 @@ class Be extends g {
|
|
|
2687
2688
|
return { status: "valid", value: e.data };
|
|
2688
2689
|
}
|
|
2689
2690
|
}
|
|
2690
|
-
|
|
2691
|
-
typeName:
|
|
2691
|
+
Ke.create = (r) => new Ke({
|
|
2692
|
+
typeName: m.ZodNaN,
|
|
2692
2693
|
...v(r)
|
|
2693
2694
|
});
|
|
2694
|
-
const
|
|
2695
|
-
class
|
|
2695
|
+
const Sr = Symbol("zod_brand");
|
|
2696
|
+
class ot extends g {
|
|
2696
2697
|
_parse(e) {
|
|
2697
2698
|
const { ctx: t } = this._processInputParams(e), n = t.data;
|
|
2698
2699
|
return this._def.type._parse({
|
|
@@ -2705,7 +2706,7 @@ class at extends g {
|
|
|
2705
2706
|
return this._def.type;
|
|
2706
2707
|
}
|
|
2707
2708
|
}
|
|
2708
|
-
class
|
|
2709
|
+
class Ne extends g {
|
|
2709
2710
|
_parse(e) {
|
|
2710
2711
|
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2711
2712
|
if (n.common.async)
|
|
@@ -2715,7 +2716,7 @@ class Ie extends g {
|
|
|
2715
2716
|
path: n.path,
|
|
2716
2717
|
parent: n
|
|
2717
2718
|
});
|
|
2718
|
-
return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(),
|
|
2719
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), de(a.value)) : this._def.out._parseAsync({
|
|
2719
2720
|
data: a.value,
|
|
2720
2721
|
path: n.path,
|
|
2721
2722
|
parent: n
|
|
@@ -2738,186 +2739,186 @@ class Ie extends g {
|
|
|
2738
2739
|
}
|
|
2739
2740
|
}
|
|
2740
2741
|
static create(e, t) {
|
|
2741
|
-
return new
|
|
2742
|
+
return new Ne({
|
|
2742
2743
|
in: e,
|
|
2743
2744
|
out: t,
|
|
2744
|
-
typeName:
|
|
2745
|
+
typeName: m.ZodPipeline
|
|
2745
2746
|
});
|
|
2746
2747
|
}
|
|
2747
2748
|
}
|
|
2748
|
-
class
|
|
2749
|
+
class Ze extends g {
|
|
2749
2750
|
_parse(e) {
|
|
2750
|
-
const t = this._def.innerType._parse(e), n = (s) => (
|
|
2751
|
-
return
|
|
2751
|
+
const t = this._def.innerType._parse(e), n = (s) => (ge(s) && (s.value = Object.freeze(s.value)), s);
|
|
2752
|
+
return _e(t) ? t.then((s) => n(s)) : n(t);
|
|
2752
2753
|
}
|
|
2753
2754
|
unwrap() {
|
|
2754
2755
|
return this._def.innerType;
|
|
2755
2756
|
}
|
|
2756
2757
|
}
|
|
2757
|
-
|
|
2758
|
+
Ze.create = (r, e) => new Ze({
|
|
2758
2759
|
innerType: r,
|
|
2759
|
-
typeName:
|
|
2760
|
+
typeName: m.ZodReadonly,
|
|
2760
2761
|
...v(e)
|
|
2761
2762
|
});
|
|
2762
|
-
function
|
|
2763
|
-
return r ?
|
|
2763
|
+
function Zt(r, e = {}, t) {
|
|
2764
|
+
return r ? fe.create().superRefine((n, s) => {
|
|
2764
2765
|
var a, i;
|
|
2765
2766
|
if (!r(n)) {
|
|
2766
2767
|
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
2768
|
s.addIssue({ code: "custom", ...d, fatal: u });
|
|
2768
2769
|
}
|
|
2769
|
-
}) :
|
|
2770
|
+
}) : fe.create();
|
|
2770
2771
|
}
|
|
2771
|
-
const
|
|
2772
|
-
object:
|
|
2772
|
+
const Cr = {
|
|
2773
|
+
object: b.lazycreate
|
|
2773
2774
|
};
|
|
2774
|
-
var
|
|
2775
|
+
var m;
|
|
2775
2776
|
(function(r) {
|
|
2776
2777
|
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
|
-
})(
|
|
2778
|
-
const
|
|
2778
|
+
})(m || (m = {}));
|
|
2779
|
+
const Rr = (r, e = {
|
|
2779
2780
|
message: `Input not instance of ${r.name}`
|
|
2780
|
-
}) =>
|
|
2781
|
+
}) => Zt((t) => t instanceof r, e), Nt = j.create, At = W.create, Or = Ke.create, Ir = J.create, jt = xe.create, Zr = ee.create, Nr = Be.create, Ar = be.create, jr = ke.create, Pr = fe.create, Dr = Q.create, Ur = z.create, Lr = qe.create, Mr = P.create, $r = b.create, Vr = b.strictCreate, zr = we.create, Br = We.create, qr = Te.create, Hr = M.create, Kr = Ee.create, Wr = He.create, Jr = te.create, Yr = ue.create, Gr = Se.create, Fr = Ce.create, Xr = Y.create, Qr = Re.create, en = he.create, gt = D.create, tn = U.create, rn = G.create, nn = D.createWithPreprocess, sn = Ne.create, an = () => Nt().optional(), on = () => At().optional(), cn = () => jt().optional(), dn = {
|
|
2781
2782
|
string: (r) => j.create({ ...r, coerce: !0 }),
|
|
2782
|
-
number: (r) =>
|
|
2783
|
-
boolean: (r) =>
|
|
2783
|
+
number: (r) => W.create({ ...r, coerce: !0 }),
|
|
2784
|
+
boolean: (r) => xe.create({
|
|
2784
2785
|
...r,
|
|
2785
2786
|
coerce: !0
|
|
2786
2787
|
}),
|
|
2787
|
-
bigint: (r) =>
|
|
2788
|
-
date: (r) =>
|
|
2789
|
-
},
|
|
2788
|
+
bigint: (r) => J.create({ ...r, coerce: !0 }),
|
|
2789
|
+
date: (r) => ee.create({ ...r, coerce: !0 })
|
|
2790
|
+
}, un = y;
|
|
2790
2791
|
var x = /* @__PURE__ */ Object.freeze({
|
|
2791
2792
|
__proto__: null,
|
|
2792
|
-
defaultErrorMap:
|
|
2793
|
-
setErrorMap:
|
|
2794
|
-
getErrorMap:
|
|
2795
|
-
makeIssue:
|
|
2796
|
-
EMPTY_PATH:
|
|
2793
|
+
defaultErrorMap: le,
|
|
2794
|
+
setErrorMap: dr,
|
|
2795
|
+
getErrorMap: $e,
|
|
2796
|
+
makeIssue: Ve,
|
|
2797
|
+
EMPTY_PATH: ur,
|
|
2797
2798
|
addIssueToContext: l,
|
|
2798
|
-
ParseStatus:
|
|
2799
|
+
ParseStatus: S,
|
|
2799
2800
|
INVALID: y,
|
|
2800
|
-
DIRTY:
|
|
2801
|
-
OK:
|
|
2802
|
-
isAborted:
|
|
2803
|
-
isDirty:
|
|
2804
|
-
isValid:
|
|
2805
|
-
isAsync:
|
|
2801
|
+
DIRTY: de,
|
|
2802
|
+
OK: R,
|
|
2803
|
+
isAborted: st,
|
|
2804
|
+
isDirty: at,
|
|
2805
|
+
isValid: ge,
|
|
2806
|
+
isAsync: _e,
|
|
2806
2807
|
get util() {
|
|
2807
2808
|
return _;
|
|
2808
2809
|
},
|
|
2809
2810
|
get objectUtil() {
|
|
2810
|
-
return
|
|
2811
|
+
return nt;
|
|
2811
2812
|
},
|
|
2812
2813
|
ZodParsedType: f,
|
|
2813
2814
|
getParsedType: H,
|
|
2814
2815
|
ZodType: g,
|
|
2815
|
-
datetimeRegex:
|
|
2816
|
+
datetimeRegex: Ot,
|
|
2816
2817
|
ZodString: j,
|
|
2817
|
-
ZodNumber:
|
|
2818
|
-
ZodBigInt:
|
|
2819
|
-
ZodBoolean:
|
|
2820
|
-
ZodDate:
|
|
2821
|
-
ZodSymbol:
|
|
2822
|
-
ZodUndefined:
|
|
2823
|
-
ZodNull:
|
|
2824
|
-
ZodAny:
|
|
2825
|
-
ZodUnknown:
|
|
2826
|
-
ZodNever:
|
|
2827
|
-
ZodVoid:
|
|
2818
|
+
ZodNumber: W,
|
|
2819
|
+
ZodBigInt: J,
|
|
2820
|
+
ZodBoolean: xe,
|
|
2821
|
+
ZodDate: ee,
|
|
2822
|
+
ZodSymbol: Be,
|
|
2823
|
+
ZodUndefined: be,
|
|
2824
|
+
ZodNull: ke,
|
|
2825
|
+
ZodAny: fe,
|
|
2826
|
+
ZodUnknown: Q,
|
|
2827
|
+
ZodNever: z,
|
|
2828
|
+
ZodVoid: qe,
|
|
2828
2829
|
ZodArray: P,
|
|
2829
|
-
ZodObject:
|
|
2830
|
-
ZodUnion:
|
|
2831
|
-
ZodDiscriminatedUnion:
|
|
2832
|
-
ZodIntersection:
|
|
2833
|
-
ZodTuple:
|
|
2834
|
-
ZodRecord:
|
|
2835
|
-
ZodMap:
|
|
2836
|
-
ZodSet:
|
|
2837
|
-
ZodFunction:
|
|
2838
|
-
ZodLazy:
|
|
2839
|
-
ZodLiteral:
|
|
2830
|
+
ZodObject: b,
|
|
2831
|
+
ZodUnion: we,
|
|
2832
|
+
ZodDiscriminatedUnion: We,
|
|
2833
|
+
ZodIntersection: Te,
|
|
2834
|
+
ZodTuple: M,
|
|
2835
|
+
ZodRecord: Ee,
|
|
2836
|
+
ZodMap: He,
|
|
2837
|
+
ZodSet: te,
|
|
2838
|
+
ZodFunction: ue,
|
|
2839
|
+
ZodLazy: Se,
|
|
2840
|
+
ZodLiteral: Ce,
|
|
2840
2841
|
ZodEnum: Y,
|
|
2841
|
-
ZodNativeEnum:
|
|
2842
|
-
ZodPromise:
|
|
2842
|
+
ZodNativeEnum: Re,
|
|
2843
|
+
ZodPromise: he,
|
|
2843
2844
|
ZodEffects: D,
|
|
2844
2845
|
ZodTransformer: D,
|
|
2845
|
-
ZodOptional:
|
|
2846
|
-
ZodNullable:
|
|
2847
|
-
ZodDefault:
|
|
2848
|
-
ZodCatch:
|
|
2849
|
-
ZodNaN:
|
|
2850
|
-
BRAND:
|
|
2851
|
-
ZodBranded:
|
|
2852
|
-
ZodPipeline:
|
|
2853
|
-
ZodReadonly:
|
|
2854
|
-
custom:
|
|
2846
|
+
ZodOptional: U,
|
|
2847
|
+
ZodNullable: G,
|
|
2848
|
+
ZodDefault: Oe,
|
|
2849
|
+
ZodCatch: Ie,
|
|
2850
|
+
ZodNaN: Ke,
|
|
2851
|
+
BRAND: Sr,
|
|
2852
|
+
ZodBranded: ot,
|
|
2853
|
+
ZodPipeline: Ne,
|
|
2854
|
+
ZodReadonly: Ze,
|
|
2855
|
+
custom: Zt,
|
|
2855
2856
|
Schema: g,
|
|
2856
2857
|
ZodSchema: g,
|
|
2857
|
-
late:
|
|
2858
|
+
late: Cr,
|
|
2858
2859
|
get ZodFirstPartyTypeKind() {
|
|
2859
|
-
return
|
|
2860
|
+
return m;
|
|
2860
2861
|
},
|
|
2861
|
-
coerce:
|
|
2862
|
-
any:
|
|
2863
|
-
array:
|
|
2864
|
-
bigint:
|
|
2865
|
-
boolean:
|
|
2866
|
-
date:
|
|
2867
|
-
discriminatedUnion:
|
|
2868
|
-
effect:
|
|
2869
|
-
enum:
|
|
2870
|
-
function:
|
|
2871
|
-
instanceof:
|
|
2872
|
-
intersection:
|
|
2873
|
-
lazy:
|
|
2874
|
-
literal:
|
|
2875
|
-
map:
|
|
2876
|
-
nan:
|
|
2877
|
-
nativeEnum:
|
|
2878
|
-
never:
|
|
2879
|
-
null:
|
|
2880
|
-
nullable:
|
|
2881
|
-
number:
|
|
2882
|
-
object:
|
|
2883
|
-
oboolean:
|
|
2884
|
-
onumber:
|
|
2885
|
-
optional:
|
|
2886
|
-
ostring:
|
|
2887
|
-
pipeline:
|
|
2888
|
-
preprocess:
|
|
2889
|
-
promise:
|
|
2890
|
-
record:
|
|
2891
|
-
set:
|
|
2892
|
-
strictObject:
|
|
2893
|
-
string:
|
|
2894
|
-
symbol:
|
|
2895
|
-
transformer:
|
|
2896
|
-
tuple:
|
|
2897
|
-
undefined:
|
|
2898
|
-
union:
|
|
2899
|
-
unknown:
|
|
2900
|
-
void:
|
|
2901
|
-
NEVER:
|
|
2862
|
+
coerce: dn,
|
|
2863
|
+
any: Pr,
|
|
2864
|
+
array: Mr,
|
|
2865
|
+
bigint: Ir,
|
|
2866
|
+
boolean: jt,
|
|
2867
|
+
date: Zr,
|
|
2868
|
+
discriminatedUnion: Br,
|
|
2869
|
+
effect: gt,
|
|
2870
|
+
enum: Xr,
|
|
2871
|
+
function: Yr,
|
|
2872
|
+
instanceof: Rr,
|
|
2873
|
+
intersection: qr,
|
|
2874
|
+
lazy: Gr,
|
|
2875
|
+
literal: Fr,
|
|
2876
|
+
map: Wr,
|
|
2877
|
+
nan: Or,
|
|
2878
|
+
nativeEnum: Qr,
|
|
2879
|
+
never: Ur,
|
|
2880
|
+
null: jr,
|
|
2881
|
+
nullable: rn,
|
|
2882
|
+
number: At,
|
|
2883
|
+
object: $r,
|
|
2884
|
+
oboolean: cn,
|
|
2885
|
+
onumber: on,
|
|
2886
|
+
optional: tn,
|
|
2887
|
+
ostring: an,
|
|
2888
|
+
pipeline: sn,
|
|
2889
|
+
preprocess: nn,
|
|
2890
|
+
promise: en,
|
|
2891
|
+
record: Kr,
|
|
2892
|
+
set: Jr,
|
|
2893
|
+
strictObject: Vr,
|
|
2894
|
+
string: Nt,
|
|
2895
|
+
symbol: Nr,
|
|
2896
|
+
transformer: gt,
|
|
2897
|
+
tuple: Hr,
|
|
2898
|
+
undefined: Ar,
|
|
2899
|
+
union: zr,
|
|
2900
|
+
unknown: Dr,
|
|
2901
|
+
void: Lr,
|
|
2902
|
+
NEVER: un,
|
|
2902
2903
|
ZodIssueCode: c,
|
|
2903
|
-
quotelessJson:
|
|
2904
|
-
ZodError:
|
|
2904
|
+
quotelessJson: cr,
|
|
2905
|
+
ZodError: Z
|
|
2905
2906
|
});
|
|
2906
|
-
const N = x.string().trim().min(1, { message: "Cannot be blank" }),
|
|
2907
|
-
var
|
|
2908
|
-
const
|
|
2909
|
-
var
|
|
2910
|
-
const
|
|
2907
|
+
const N = x.string().trim().min(1, { message: "Cannot be blank" }), q = x.string().trim().optional();
|
|
2908
|
+
var Pt = /* @__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))(Pt || {});
|
|
2909
|
+
const Dt = x.nativeEnum(Pt);
|
|
2910
|
+
var Ut = /* @__PURE__ */ ((r) => (r.CARD_NUMBER = "cardNumber", r.CARD_EXPIRY = "cardExpiry", r.CARD_CVC = "cardCvc", r))(Ut || {});
|
|
2911
|
+
const Lt = x.nativeEnum(Ut), ln = x.union([Dt, Lt]);
|
|
2911
2912
|
x.object({
|
|
2912
|
-
backgroundColor:
|
|
2913
|
-
color:
|
|
2914
|
-
fontFamily:
|
|
2915
|
-
fontSize:
|
|
2916
|
-
fontWeight:
|
|
2917
|
-
margin:
|
|
2918
|
-
padding:
|
|
2913
|
+
backgroundColor: q,
|
|
2914
|
+
color: q,
|
|
2915
|
+
fontFamily: q,
|
|
2916
|
+
fontSize: q,
|
|
2917
|
+
fontWeight: q,
|
|
2918
|
+
margin: q,
|
|
2919
|
+
padding: q
|
|
2919
2920
|
});
|
|
2920
|
-
const
|
|
2921
|
+
const k = x.enum([
|
|
2921
2922
|
// Element -> Form
|
|
2922
2923
|
"LOADED",
|
|
2923
2924
|
"BLUR",
|
|
@@ -2934,93 +2935,156 @@ const b = x.enum([
|
|
|
2934
2935
|
// Form -> Element
|
|
2935
2936
|
"TOKENIZE",
|
|
2936
2937
|
"CHECKOUT"
|
|
2937
|
-
]),
|
|
2938
|
-
type:
|
|
2939
|
-
elementType:
|
|
2940
|
-
}),
|
|
2941
|
-
type:
|
|
2938
|
+
]), fn = k.extract(["TOKENIZE_STARTED", "CHECKOUT_STARTED"]), hn = x.object({ type: fn }), pn = k.extract(["BLUR", "FOCUS", "CHANGE"]), mn = x.object({
|
|
2939
|
+
type: pn,
|
|
2940
|
+
elementType: Lt
|
|
2941
|
+
}), yn = k.extract(["LOAD_ERROR", "TOKENIZE_ERROR", "CHECKOUT_ERROR"]), vn = x.object({
|
|
2942
|
+
type: yn,
|
|
2942
2943
|
message: N
|
|
2943
|
-
}),
|
|
2944
|
-
type:
|
|
2945
|
-
elementType:
|
|
2944
|
+
}), gn = k.extract(["VALIDATION_ERROR"]), _n = x.object({
|
|
2945
|
+
type: gn,
|
|
2946
|
+
elementType: ln,
|
|
2946
2947
|
errors: x.array(x.string())
|
|
2947
|
-
}),
|
|
2948
|
-
type: x.literal(
|
|
2948
|
+
}), xn = x.object({
|
|
2949
|
+
type: x.literal(k.enum.LOADED),
|
|
2949
2950
|
sessionId: N,
|
|
2950
2951
|
height: N,
|
|
2951
2952
|
totalAmountAtoms: x.number(),
|
|
2952
|
-
currency:
|
|
2953
|
-
|
|
2954
|
-
|
|
2953
|
+
currency: q,
|
|
2954
|
+
stripePubKey: x.nullable(x.string())
|
|
2955
|
+
}), bn = k.extract(["TOKENIZE", "CHECKOUT"]), Mt = x.object({
|
|
2956
|
+
type: bn,
|
|
2955
2957
|
sessionId: N,
|
|
2956
2958
|
firstName: N,
|
|
2957
2959
|
lastName: N,
|
|
2958
2960
|
email: N,
|
|
2959
2961
|
zipCode: N,
|
|
2960
2962
|
country: N
|
|
2961
|
-
}),
|
|
2962
|
-
type: x.literal(
|
|
2963
|
+
}), kn = x.object({
|
|
2964
|
+
type: x.literal(k.enum.TOKENIZE_SUCCESS),
|
|
2963
2965
|
isReadyForCheckout: x.boolean()
|
|
2964
|
-
}),
|
|
2965
|
-
type: x.literal(
|
|
2966
|
+
}), wn = x.object({
|
|
2967
|
+
type: x.literal(k.enum.CHECKOUT_SUCCESS),
|
|
2966
2968
|
invoiceUrls: x.array(x.string())
|
|
2967
|
-
}),
|
|
2968
|
-
on,
|
|
2969
|
-
dn,
|
|
2970
|
-
ln,
|
|
2969
|
+
}), Tn = x.discriminatedUnion("type", [
|
|
2971
2970
|
hn,
|
|
2972
2971
|
mn,
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2972
|
+
vn,
|
|
2973
|
+
_n,
|
|
2974
|
+
xn,
|
|
2975
|
+
Mt,
|
|
2976
|
+
kn,
|
|
2977
|
+
wn
|
|
2978
|
+
]), En = x.object({
|
|
2979
|
+
payload: Tn,
|
|
2978
2980
|
nonce: N,
|
|
2979
2981
|
formId: N,
|
|
2980
2982
|
elementId: N
|
|
2981
|
-
})
|
|
2983
|
+
});
|
|
2984
|
+
x.object({
|
|
2985
|
+
isLoading: x.boolean(),
|
|
2986
|
+
isAvailable: x.boolean(),
|
|
2987
|
+
startFlow: x.function(x.tuple([]), x.void())
|
|
2988
|
+
});
|
|
2989
|
+
const Sn = (r) => {
|
|
2982
2990
|
const e = {};
|
|
2983
2991
|
return Object.entries(r).forEach(([t, n]) => {
|
|
2984
2992
|
try {
|
|
2985
|
-
const s =
|
|
2993
|
+
const s = Dt.parse(t);
|
|
2986
2994
|
Array.isArray(n) ? e[s] = n : Array.isArray(n._errors) && (e[s] = n._errors);
|
|
2987
2995
|
} catch {
|
|
2988
2996
|
return;
|
|
2989
2997
|
}
|
|
2990
2998
|
}), e;
|
|
2991
|
-
},
|
|
2999
|
+
}, Cn = (r, e, t) => {
|
|
2992
3000
|
const s = Array.from(e.querySelectorAll("input[data-opid]") ?? []).reduce(
|
|
2993
3001
|
(i, o) => {
|
|
2994
3002
|
const u = o.getAttribute("data-opid");
|
|
2995
3003
|
return u ? { ...i, [u]: o.value } : i;
|
|
2996
3004
|
},
|
|
2997
3005
|
{
|
|
2998
|
-
type:
|
|
3006
|
+
type: k.enum.TOKENIZE,
|
|
2999
3007
|
sessionId: r
|
|
3000
3008
|
}
|
|
3001
|
-
), a =
|
|
3009
|
+
), a = Mt.safeParse(s);
|
|
3002
3010
|
if (a.success)
|
|
3003
3011
|
return a.data;
|
|
3004
3012
|
{
|
|
3005
|
-
const i = a.error.format(), o =
|
|
3013
|
+
const i = a.error.format(), o = Sn(i);
|
|
3006
3014
|
for (const [u, d] of Object.entries(o))
|
|
3007
3015
|
t(u, d, u);
|
|
3008
3016
|
}
|
|
3009
|
-
},
|
|
3017
|
+
}, Rn = (r) => {
|
|
3010
3018
|
try {
|
|
3011
|
-
return
|
|
3019
|
+
return En.parse(r);
|
|
3012
3020
|
} catch (e) {
|
|
3013
3021
|
throw e;
|
|
3014
3022
|
}
|
|
3015
|
-
},
|
|
3016
|
-
const
|
|
3023
|
+
}, _t = (r, e, t, n, s) => {
|
|
3024
|
+
const a = {
|
|
3017
3025
|
payload: n,
|
|
3018
|
-
nonce:
|
|
3026
|
+
nonce: Tt(),
|
|
3019
3027
|
formId: e,
|
|
3020
3028
|
elementId: t
|
|
3021
3029
|
};
|
|
3022
|
-
r.postMessage(JSON.stringify(
|
|
3023
|
-
},
|
|
3030
|
+
r.postMessage(JSON.stringify(a), s);
|
|
3031
|
+
}, On = "https://cde.openpaystaging.com", In = {
|
|
3032
|
+
usd: "usd",
|
|
3033
|
+
brl: "brl"
|
|
3034
|
+
}, Zn = (r) => r.stripePubKey === null ? { isStripeAvailable: !1, stripePubKey: void 0 } : { isStripeAvailable: !0, stripePubKey: r.stripePubKey }, Nn = (r) => {
|
|
3035
|
+
for (let t = 0; t < 10; t++)
|
|
3036
|
+
xt() || jn(200);
|
|
3037
|
+
if (!xt())
|
|
3038
|
+
throw new Error("Stripe JS not found.");
|
|
3039
|
+
return new Stripe(r);
|
|
3040
|
+
}, An = async (r, e, t) => {
|
|
3041
|
+
const n = Nn(r), s = In[t];
|
|
3042
|
+
return n.paymentRequest({
|
|
3043
|
+
// TODO: replace this with stripe account country as soon as we support it
|
|
3044
|
+
country: "US",
|
|
3045
|
+
currency: s,
|
|
3046
|
+
total: {
|
|
3047
|
+
label: "Total",
|
|
3048
|
+
amount: e
|
|
3049
|
+
},
|
|
3050
|
+
requestPayerName: !0,
|
|
3051
|
+
requestPayerEmail: !0
|
|
3052
|
+
});
|
|
3053
|
+
}, jn = (r) => new Promise((e) => {
|
|
3054
|
+
setTimeout(e, r);
|
|
3055
|
+
}), xt = () => "Stripe" in window, Pn = {
|
|
3056
|
+
isLoading: !0,
|
|
3057
|
+
isAvailable: !1,
|
|
3058
|
+
startFlow: () => {
|
|
3059
|
+
}
|
|
3060
|
+
}, bt = {
|
|
3061
|
+
isLoading: !1,
|
|
3062
|
+
isAvailable: !1,
|
|
3063
|
+
startFlow: () => {
|
|
3064
|
+
}
|
|
3065
|
+
}, Dn = (r, e, t) => {
|
|
3066
|
+
const [n, s] = E({ apple_pay: Pn });
|
|
3067
|
+
return ve(() => {
|
|
3068
|
+
(async () => {
|
|
3069
|
+
try {
|
|
3070
|
+
if (r === void 0 || e === void 0 || t === void 0)
|
|
3071
|
+
throw new Error("Cannot setup stripe yet: missing params");
|
|
3072
|
+
const i = await An(r, e, t), o = await i.canMakePayment(), u = {
|
|
3073
|
+
isLoading: !1,
|
|
3074
|
+
isAvailable: !0,
|
|
3075
|
+
startFlow: () => i.show()
|
|
3076
|
+
};
|
|
3077
|
+
s({
|
|
3078
|
+
apple_pay: o != null && o.applePay ? u : bt
|
|
3079
|
+
});
|
|
3080
|
+
} catch {
|
|
3081
|
+
s({
|
|
3082
|
+
apple_pay: bt
|
|
3083
|
+
});
|
|
3084
|
+
}
|
|
3085
|
+
})();
|
|
3086
|
+
}, [r, e, t]), n;
|
|
3087
|
+
}, Vn = (r) => {
|
|
3024
3088
|
const {
|
|
3025
3089
|
children: e,
|
|
3026
3090
|
checkoutSecureToken: t,
|
|
@@ -3031,115 +3095,119 @@ const b = x.enum([
|
|
|
3031
3095
|
onLoad: o,
|
|
3032
3096
|
onLoadError: u,
|
|
3033
3097
|
onValidationError: d,
|
|
3034
|
-
onCheckoutStarted:
|
|
3035
|
-
onCheckoutSuccess:
|
|
3036
|
-
onCheckoutError:
|
|
3037
|
-
|
|
3098
|
+
onCheckoutStarted: p,
|
|
3099
|
+
onCheckoutSuccess: w,
|
|
3100
|
+
onCheckoutError: $,
|
|
3101
|
+
baseUrl: F
|
|
3102
|
+
} = r, B = F ?? On, [X, $t] = E(void 0), [ct, Vt] = E([]), [zt, Bt] = E("1px"), [dt, qt] = E(!1), [Ye, ut] = E(void 0), [lt, Ae] = E(!1), [re, Ht] = E([]), [ne, Kt] = E({}), [ft, ht] = E(0), [pt, mt] = E(!1), [se, Wt] = E(void 0), [Ge, Jt] = E(void 0), [je, Yt] = E(void 0), [Pe, Gt] = E(null), Ft = Dn(Pe == null ? void 0 : Pe.stripePubKey, je, Ge), ae = Me(() => `opjs-form-${Tt()}`, []), pe = kt(null), Fe = Ue(
|
|
3038
3103
|
(O) => {
|
|
3039
|
-
if (O.origin !==
|
|
3040
|
-
const
|
|
3041
|
-
if (C.formId !==
|
|
3104
|
+
if (O.origin !== B || !O.source) return;
|
|
3105
|
+
const ie = O.source, C = Rn(JSON.parse(O.data)), De = C.elementId;
|
|
3106
|
+
if (C.formId !== ae || !De || C.nonce in ct)
|
|
3042
3107
|
return;
|
|
3043
|
-
|
|
3044
|
-
const
|
|
3045
|
-
if (A ===
|
|
3108
|
+
Vt((oe) => [...oe, C.nonce]);
|
|
3109
|
+
const I = C.payload, A = I.type;
|
|
3110
|
+
if (A === k.enum.FOCUS && s)
|
|
3046
3111
|
s(C.elementId);
|
|
3047
|
-
else if (A ===
|
|
3112
|
+
else if (A === k.enum.BLUR && a)
|
|
3048
3113
|
a(C.elementId);
|
|
3049
|
-
else if (A ===
|
|
3114
|
+
else if (A === k.enum.CHANGE && i)
|
|
3050
3115
|
i(C.elementId);
|
|
3051
|
-
else if (A ===
|
|
3052
|
-
const
|
|
3053
|
-
if (
|
|
3116
|
+
else if (A === k.enum.LOADED) {
|
|
3117
|
+
const oe = re.find((et) => et.contentWindow === ie);
|
|
3118
|
+
if (Ae(!1), !oe)
|
|
3054
3119
|
return;
|
|
3055
|
-
|
|
3056
|
-
const
|
|
3057
|
-
|
|
3058
|
-
} else if (A ===
|
|
3059
|
-
|
|
3060
|
-
else if (A ===
|
|
3061
|
-
const
|
|
3062
|
-
!
|
|
3063
|
-
} else A ===
|
|
3120
|
+
Kt((et) => ({ ...et, [De]: ie }));
|
|
3121
|
+
const Qe = I.height ? `${I.height}px` : "100%";
|
|
3122
|
+
Bt(Qe), Yt(I.totalAmountAtoms), Jt(I.currency), Gt(Zn(I)), se || Wt(I.sessionId);
|
|
3123
|
+
} else if (A === k.enum.TOKENIZE_STARTED)
|
|
3124
|
+
Ae(!0), p && p();
|
|
3125
|
+
else if (A === k.enum.TOKENIZE_SUCCESS && Ye) {
|
|
3126
|
+
const oe = ft + 1, Qe = oe === Object.keys(ne).length;
|
|
3127
|
+
!pt && (Qe || I.isReadyForCheckout) ? (_t(ie, ae, De, Ye, B), mt(!0), ut(void 0)) : ht(oe);
|
|
3128
|
+
} else A === k.enum.CHECKOUT_SUCCESS ? (Ae(!1), ht(0), mt(!1), w && w(I.invoiceUrls)) : A === k.enum.LOAD_ERROR ? u && u(I.message) : A === k.enum.VALIDATION_ERROR ? d && d(I.elementType, I.errors, De) : (A === k.enum.TOKENIZE_ERROR || A === k.enum.CHECKOUT_ERROR) && (Ae(!1), $ && $(I.message));
|
|
3064
3129
|
},
|
|
3065
3130
|
[
|
|
3131
|
+
ae,
|
|
3066
3132
|
se,
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
Ke,
|
|
3070
|
-
te,
|
|
3133
|
+
ct,
|
|
3134
|
+
Ye,
|
|
3071
3135
|
re,
|
|
3072
|
-
|
|
3136
|
+
ne,
|
|
3073
3137
|
ft,
|
|
3138
|
+
pt,
|
|
3074
3139
|
a,
|
|
3075
3140
|
i,
|
|
3076
3141
|
s,
|
|
3077
3142
|
u,
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
d
|
|
3143
|
+
p,
|
|
3144
|
+
w,
|
|
3145
|
+
$,
|
|
3146
|
+
d,
|
|
3147
|
+
B
|
|
3082
3148
|
]
|
|
3083
|
-
),
|
|
3084
|
-
if (!
|
|
3085
|
-
const O =
|
|
3149
|
+
), Xt = Ue(() => {
|
|
3150
|
+
if (!pe.current || !d || !se) return;
|
|
3151
|
+
const O = Cn(se, pe.current, d);
|
|
3086
3152
|
if (O) {
|
|
3087
|
-
for (const [
|
|
3088
|
-
C &&
|
|
3089
|
-
O.type =
|
|
3153
|
+
for (const [ie, C] of Object.entries(ne))
|
|
3154
|
+
C && _t(C, ae, ie, O, B);
|
|
3155
|
+
O.type = k.enum.CHECKOUT, ut(O);
|
|
3090
3156
|
}
|
|
3091
|
-
}, [
|
|
3157
|
+
}, [pe, ne, ae, d, se, B]), Xe = Ue(
|
|
3092
3158
|
(O) => {
|
|
3093
|
-
|
|
3159
|
+
lt && O.preventDefault();
|
|
3094
3160
|
},
|
|
3095
|
-
[
|
|
3161
|
+
[lt]
|
|
3096
3162
|
);
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
}, [
|
|
3100
|
-
window.removeEventListener("beforeunload",
|
|
3101
|
-
}), [
|
|
3102
|
-
const
|
|
3163
|
+
ve(() => {
|
|
3164
|
+
dt || !pe.current || !je || re.length === Object.keys(ne).length && (qt(!0), o && o(je, Ge));
|
|
3165
|
+
}, [re, ne, dt, o, je, Ge]), ve(() => ($t(window.location.origin), window.addEventListener("message", Fe), window.addEventListener("beforeunload", Xe), () => {
|
|
3166
|
+
window.removeEventListener("beforeunload", Xe), window.removeEventListener("message", Fe);
|
|
3167
|
+
}), [se, Fe, Xe]);
|
|
3168
|
+
const Qt = Ue(
|
|
3103
3169
|
(O) => {
|
|
3104
|
-
|
|
3170
|
+
re.find((C) => C.contentWindow === O.contentWindow) || Ht((C) => [...C, O]);
|
|
3105
3171
|
},
|
|
3106
|
-
[
|
|
3107
|
-
),
|
|
3108
|
-
formId:
|
|
3109
|
-
formHeight:
|
|
3110
|
-
referer:
|
|
3172
|
+
[re]
|
|
3173
|
+
), er = {
|
|
3174
|
+
formId: ae,
|
|
3175
|
+
formHeight: zt,
|
|
3176
|
+
referer: X,
|
|
3111
3177
|
checkoutSecureToken: t,
|
|
3112
|
-
|
|
3178
|
+
stripeContext: Pe,
|
|
3179
|
+
registerIframe: Qt,
|
|
3180
|
+
baseUrl: B
|
|
3113
3181
|
};
|
|
3114
|
-
return /* @__PURE__ */
|
|
3115
|
-
},
|
|
3116
|
-
const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o } =
|
|
3182
|
+
return /* @__PURE__ */ K(wt.Provider, { value: er, children: /* @__PURE__ */ K("div", { className: n, ref: pe, children: e({ submit: Xt, applePay: Ft.apple_pay }) }) });
|
|
3183
|
+
}, Un = (r) => JSON.stringify(r), Je = (r) => {
|
|
3184
|
+
const { subPath: e, styles: t } = r, { formId: n, referer: s, formHeight: a, checkoutSecureToken: i, registerIframe: o, baseUrl: u } = nr(), [d, p] = E(!1), w = kt(null), $ = Me(() => t ? Un(t) : "", [t]), F = Me(() => ({
|
|
3117
3185
|
border: "none",
|
|
3118
3186
|
width: "100%",
|
|
3119
3187
|
height: a
|
|
3120
|
-
}), [a]),
|
|
3188
|
+
}), [a]), B = Me(() => {
|
|
3121
3189
|
if (!i || !s) return "";
|
|
3122
|
-
const
|
|
3123
|
-
return
|
|
3124
|
-
}, [
|
|
3125
|
-
return
|
|
3126
|
-
!
|
|
3127
|
-
}, [
|
|
3190
|
+
const X = new URLSearchParams();
|
|
3191
|
+
return X.append("referer", s), X.append("styles", $), X.append("formId", n), X.append("secureToken", i), X.toString();
|
|
3192
|
+
}, [$, n, s, i]);
|
|
3193
|
+
return ve(() => p(!0), []), ve(() => {
|
|
3194
|
+
!w.current || !d || o(w.current);
|
|
3195
|
+
}, [d]), i ? /* @__PURE__ */ K(
|
|
3128
3196
|
"iframe",
|
|
3129
3197
|
{
|
|
3130
3198
|
name: `${e}-element`,
|
|
3131
|
-
src: `${
|
|
3132
|
-
style:
|
|
3133
|
-
ref:
|
|
3199
|
+
src: `${u}/app/v1/${e}-element/?${B}`,
|
|
3200
|
+
style: F,
|
|
3201
|
+
ref: w
|
|
3134
3202
|
}
|
|
3135
|
-
) : /* @__PURE__ */
|
|
3136
|
-
},
|
|
3203
|
+
) : /* @__PURE__ */ K("div", {});
|
|
3204
|
+
}, zn = ({ styles: r }) => /* @__PURE__ */ K(Je, { styles: r, subPath: "card-cvc" }), Bn = ({ styles: r }) => /* @__PURE__ */ K(Je, { styles: r, subPath: "card" }), qn = ({ styles: r }) => /* @__PURE__ */ K(Je, { styles: r, subPath: "card-expiry" }), Hn = ({ styles: r }) => /* @__PURE__ */ K(Je, { styles: r, subPath: "card-number" });
|
|
3137
3205
|
export {
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3206
|
+
zn as CardCvcElement,
|
|
3207
|
+
Bn as CardElement,
|
|
3208
|
+
qn as CardExpiryElement,
|
|
3209
|
+
Hn as CardNumberElement,
|
|
3210
|
+
Vn as ElementsForm,
|
|
3211
|
+
Pt as FieldName,
|
|
3212
|
+
nr as useOpenPayElements
|
|
3145
3213
|
};
|