@tapcart/app-studio-sdk 2.1.8 → 2.1.9

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.
@@ -1,4237 +0,0 @@
1
- import Mt, { createContext as Cr, useReducer as Zn, useEffect as Yn, useContext as Pe } from "react";
2
- const Xn = (t) => t && Object.keys(t).length === 0 && t.constructor === Object;
3
- class Qn {
4
- constructor(e) {
5
- this.quantity = e.quantity || null, this.productId = e.productId || null, this.variantId = e.variantId || null, this.sellingPlanId = e.sellingPlanId || null, this.sellingPlanAllocation = e.sellingPlanAllocation || null, this.attributes = e.attributes || {}, this.discounts = e.discounts || [], this.id = e.id || null, this.compareAtPrice = e.compareAtPrice || null, this.cost = e.cost || null, this.currencyCode = e.currencyCode || null, this.featuredImage = e.featuredImage || null, this.image = e.image || null, this.merchandise = e.merchandise || null, this.price = e.price || null, this.productVendor = e.productVendor || null, this.quantityAvailable = e.quantityAvailable || null, this.selectedOptions = e.selectedOptions || [], this.title = e.title || null, this.totalAmount = e.totalAmount || null;
6
- }
7
- }
8
- class Hn {
9
- constructor(e, r, n, a) {
10
- this.type = e, this.title = r || null, this.code = n || null, this.amount = a || null;
11
- }
12
- }
13
- function _e(t) {
14
- return !t || typeof t != "string" ? null : t.split("/").at(-1) || null;
15
- }
16
- function ea(t) {
17
- var It, Pt, Nt, Dt, Rt;
18
- const { attributes: e, discountAllocations: r, merchandise: n, cost: a, quantity: i, id: s, sellingPlanAllocation: o, ...u } = t, c = e == null ? void 0 : e.reduce(
19
- (F, C) => (F[C.key] = C.value, F),
20
- {}
21
- ), l = r == null ? void 0 : r.map(
22
- (F) => {
23
- var W;
24
- const C = (W = F == null ? void 0 : F.discountedAmount) == null ? void 0 : W.amount, k = C ? Number.parseFloat(C) : null;
25
- return new Hn(
26
- F.targetType,
27
- F.title || F.code,
28
- F.code,
29
- Number.isNaN(k) ? null : k
30
- );
31
- }
32
- ), { product: d, ...p } = n || {}, { variants: h, id: y, availableForSale: v, title: _, vendor: $, ...A } = d || {}, T = h == null ? void 0 : h.find((F) => F.id === (n == null ? void 0 : n.id)), { id: P, price: b, compareAtPrice: g, availableForSale: N, quantityAvailable: R, selectedOptions: z, title: M, image: O, ...B } = T || {}, G = b != null && b.amount ? Number.parseFloat(b.amount) : null, x = g != null && g.amount ? Number.parseFloat(g.amount) : null, { totalAmount: w } = a || {}, ge = w != null && w.amount ? Number.parseFloat(w.amount) : null, Ct = (w == null ? void 0 : w.currencyCode) || (b == null ? void 0 : b.currencyCode) || null, Bn = ((Pt = (It = h == null ? void 0 : h[0]) == null ? void 0 : It.image) == null ? void 0 : Pt.url) || (O == null ? void 0 : O.url) || null, Kn = (O == null ? void 0 : O.url) || null, Wn = (F) => {
33
- var k;
34
- const C = (k = d == null ? void 0 : d.sellingPlanGroups) == null ? void 0 : k.flatMap((W) => W.sellingPlans).find((W) => W.id === F);
35
- return (C == null ? void 0 : C.name) || null;
36
- }, Jn = {
37
- ...u,
38
- // Basic fields
39
- quantity: i,
40
- productId: _e(y) || y,
41
- variantId: _e(n == null ? void 0 : n.id) || (n == null ? void 0 : n.id),
42
- sellingPlanId: ((Nt = o == null ? void 0 : o.sellingPlan) == null ? void 0 : Nt.id) || null,
43
- // Find the selling plan name from the product's sellingPlanGroups, because Shopify loves a good treasure hunt.
44
- sellingPlanAllocation: {
45
- ...o,
46
- sellingPlan: {
47
- ...o == null ? void 0 : o.sellingPlan,
48
- name: Wn((Dt = o == null ? void 0 : o.sellingPlan) == null ? void 0 : Dt.id)
49
- }
50
- },
51
- attributes: c,
52
- discounts: l,
53
- // Additional comprehensive fields
54
- id: s,
55
- compareAtPrice: x,
56
- cost: a,
57
- currencyCode: Ct,
58
- featuredImage: Bn,
59
- image: Kn,
60
- merchandise: {
61
- ...p,
62
- ...B,
63
- availableForSale: N || !1,
64
- compareAtPrice: x,
65
- id: _e(n == null ? void 0 : n.id) || (n == null ? void 0 : n.id),
66
- image: O ? {
67
- id: "",
68
- url: O.url
69
- } : null,
70
- isAvailable: N || !1,
71
- price: G,
72
- priceCurrencyCode: Ct,
73
- product: {
74
- ...A,
75
- availableForSale: v || !1,
76
- featuredImage: (Rt = h == null ? void 0 : h[0]) != null && Rt.image ? {
77
- id: "",
78
- url: h[0].image.url
79
- } : null,
80
- flashSaleData: {},
81
- id: _e(y) || y,
82
- title: _ || null,
83
- variants: (h == null ? void 0 : h.map((F) => {
84
- const { price: C, compareAtPrice: k, ...W } = F;
85
- return {
86
- ...W,
87
- compareAtPrice: k != null && k.amount ? Number.parseFloat(k.amount) : null,
88
- id: _e(F.id) || F.id,
89
- price: C != null && C.amount ? Number.parseFloat(C.amount) : null,
90
- priceCurrencyCode: (C == null ? void 0 : C.currencyCode) || null
91
- };
92
- })) || [],
93
- vendor: $ || null
94
- },
95
- quantityAvailable: R || null,
96
- selectedOptions: z || [],
97
- title: M || (n == null ? void 0 : n.title) || null
98
- },
99
- price: G,
100
- productVendor: $ || null,
101
- quantityAvailable: R || null,
102
- selectedOptions: z || [],
103
- title: _ || null,
104
- totalAmount: ge
105
- };
106
- return new Qn(Jn);
107
- }
108
- function Ir(t) {
109
- if (!t)
110
- return null;
111
- const { lines: e, discountCodes: r, note: n, cost: a, ...i } = t, s = { ...i };
112
- if (e && (s.lines = e, s.items = e.map((o) => ea(o)) ?? []), r !== void 0 && (s.discountCodes = r, s.discounts = r), n !== void 0 && (s.note = n, s.notes = n), a && (s.cost = a, a.subtotalAmount))
113
- try {
114
- const { amount: o, currencyCode: u } = a.subtotalAmount, c = o ? Number.parseFloat(o) : null;
115
- s.subtotal = Number.isNaN(c) ? null : c, s.currency = u;
116
- } catch {
117
- s.subtotal = null;
118
- }
119
- return s;
120
- }
121
- function ta(t) {
122
- const e = {};
123
- if (!Array.isArray(t))
124
- return e;
125
- for (const r of t)
126
- r && r.name && r.enabled && (e[r.name] = r);
127
- return e;
128
- }
129
- const ra = (t) => {
130
- if (!t)
131
- return {};
132
- const e = (n) => Array.isArray(n) ? n.reduce((a, { namespace: i, key: s, value: o }) => (a[i] ? a[i][s] = o : a[i] = {
133
- [s]: o
134
- }, a), {}) : n, r = Object.entries(t).reduce((n, [a, i]) => (n[a] = Xn(i) && a !== "storage" ? null : i, n), {});
135
- return t.product && (t.product.metafields && (r.product.metafields = e(
136
- t.product.metafields
137
- )), t.product.sourceCollection && t.product.sourceCollection.metafields && (r.product.sourceCollection.metafields = e(
138
- t.product.sourceCollection.metafields
139
- ))), t.collection && t.collection.metafields && (r.collection.metafields = e(
140
- t.collection.metafields
141
- )), t.customer && t.customer.metafields && (r.customer.metafields = e(
142
- t.customer.metafields
143
- )), t.integrations && (r.integrations = ta(t.integrations)), t.cart && (r.cart = Ir(t.cart)), r;
144
- }, na = () => {
145
- let t = {};
146
- return {
147
- get variables() {
148
- return t;
149
- },
150
- setVariables: (r = {}) => {
151
- t = {
152
- ...t,
153
- ...ra(r)
154
- };
155
- }
156
- };
157
- };
158
- let Pr = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, r) => (r &= 63, r < 36 ? e += r.toString(36) : r < 62 ? e += (r - 26).toString(36).toUpperCase() : r > 62 ? e += "-" : e += "_", e), "");
159
- var He;
160
- try {
161
- He = Map;
162
- } catch {
163
- }
164
- var et;
165
- try {
166
- et = Set;
167
- } catch {
168
- }
169
- function Nr(t, e, r) {
170
- if (!t || typeof t != "object" || typeof t == "function")
171
- return t;
172
- if (t.nodeType && "cloneNode" in t)
173
- return t.cloneNode(!0);
174
- if (t instanceof Date)
175
- return new Date(t.getTime());
176
- if (t instanceof RegExp)
177
- return new RegExp(t);
178
- if (Array.isArray(t))
179
- return t.map(tt);
180
- if (He && t instanceof He)
181
- return new Map(Array.from(t.entries()));
182
- if (et && t instanceof et)
183
- return new Set(Array.from(t.values()));
184
- if (t instanceof Object) {
185
- e.push(t);
186
- var n = Object.create(t);
187
- r.push(n);
188
- for (var a in t) {
189
- var i = e.findIndex(function(s) {
190
- return s === t[a];
191
- });
192
- n[a] = i > -1 ? r[i] : Nr(t[a], e, r);
193
- }
194
- return n;
195
- }
196
- return t;
197
- }
198
- function tt(t) {
199
- return Nr(t, [], []);
200
- }
201
- const aa = Object.prototype.toString, ia = Error.prototype.toString, sa = RegExp.prototype.toString, oa = typeof Symbol < "u" ? Symbol.prototype.toString : () => "", ua = /^Symbol\((.*)\)(.*)$/;
202
- function ca(t) {
203
- return t != +t ? "NaN" : t === 0 && 1 / t < 0 ? "-0" : "" + t;
204
- }
205
- function qt(t, e = !1) {
206
- if (t == null || t === !0 || t === !1)
207
- return "" + t;
208
- const r = typeof t;
209
- if (r === "number")
210
- return ca(t);
211
- if (r === "string")
212
- return e ? `"${t}"` : t;
213
- if (r === "function")
214
- return "[Function " + (t.name || "anonymous") + "]";
215
- if (r === "symbol")
216
- return oa.call(t).replace(ua, "Symbol($1)");
217
- const n = aa.call(t).slice(8, -1);
218
- return n === "Date" ? isNaN(t.getTime()) ? "" + t : t.toISOString(t) : n === "Error" || t instanceof Error ? "[" + ia.call(t) + "]" : n === "RegExp" ? sa.call(t) : null;
219
- }
220
- function ce(t, e) {
221
- let r = qt(t, e);
222
- return r !== null ? r : JSON.stringify(t, function(n, a) {
223
- let i = qt(this[n], e);
224
- return i !== null ? i : a;
225
- }, 2);
226
- }
227
- let te = {
228
- default: "${path} is invalid",
229
- required: "${path} is a required field",
230
- oneOf: "${path} must be one of the following values: ${values}",
231
- notOneOf: "${path} must not be one of the following values: ${values}",
232
- notType: ({
233
- path: t,
234
- type: e,
235
- value: r,
236
- originalValue: n
237
- }) => {
238
- let a = n != null && n !== r, i = `${t} must be a \`${e}\` type, but the final value was: \`${ce(r, !0)}\`` + (a ? ` (cast from the value \`${ce(n, !0)}\`).` : ".");
239
- return r === null && (i += '\n If "null" is intended as an empty value be sure to mark the schema as `.nullable()`'), i;
240
- },
241
- defined: "${path} must be defined"
242
- }, j = {
243
- length: "${path} must be exactly ${length} characters",
244
- min: "${path} must be at least ${min} characters",
245
- max: "${path} must be at most ${max} characters",
246
- matches: '${path} must match the following: "${regex}"',
247
- email: "${path} must be a valid email",
248
- url: "${path} must be a valid URL",
249
- uuid: "${path} must be a valid UUID",
250
- trim: "${path} must be a trimmed string",
251
- lowercase: "${path} must be a lowercase string",
252
- uppercase: "${path} must be a upper case string"
253
- }, J = {
254
- min: "${path} must be greater than or equal to ${min}",
255
- max: "${path} must be less than or equal to ${max}",
256
- lessThan: "${path} must be less than ${less}",
257
- moreThan: "${path} must be greater than ${more}",
258
- positive: "${path} must be a positive number",
259
- negative: "${path} must be a negative number",
260
- integer: "${path} must be an integer"
261
- }, rt = {
262
- min: "${path} field must be later than ${min}",
263
- max: "${path} field must be at earlier than ${max}"
264
- }, nt = {
265
- isValue: "${path} field must be ${value}"
266
- }, at = {
267
- noUnknown: "${path} field has unspecified keys: ${unknown}"
268
- }, Ie = {
269
- min: "${path} field must have at least ${min} items",
270
- max: "${path} field must have less than or equal to ${max} items",
271
- length: "${path} must have ${length} items"
272
- };
273
- Object.assign(/* @__PURE__ */ Object.create(null), {
274
- mixed: te,
275
- string: j,
276
- number: J,
277
- date: rt,
278
- object: at,
279
- array: Ie,
280
- boolean: nt
281
- });
282
- var xe = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
283
- function le(t) {
284
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
285
- }
286
- var la = Object.prototype, da = la.hasOwnProperty;
287
- function fa(t, e) {
288
- return t != null && da.call(t, e);
289
- }
290
- var pa = fa, ha = Array.isArray, Y = ha, ma = typeof xe == "object" && xe && xe.Object === Object && xe, Dr = ma, ya = Dr, va = typeof self == "object" && self && self.Object === Object && self, ga = ya || va || Function("return this")(), K = ga, _a = K, ba = _a.Symbol, ze = ba, Lt = ze, Rr = Object.prototype, $a = Rr.hasOwnProperty, Sa = Rr.toString, be = Lt ? Lt.toStringTag : void 0;
291
- function Aa(t) {
292
- var e = $a.call(t, be), r = t[be];
293
- try {
294
- t[be] = void 0;
295
- var n = !0;
296
- } catch {
297
- }
298
- var a = Sa.call(t);
299
- return n && (e ? t[be] = r : delete t[be]), a;
300
- }
301
- var wa = Aa, Ea = Object.prototype, xa = Ea.toString;
302
- function Ta(t) {
303
- return xa.call(t);
304
- }
305
- var Fa = Ta, Ut = ze, Oa = wa, Ca = Fa, Ia = "[object Null]", Pa = "[object Undefined]", jt = Ut ? Ut.toStringTag : void 0;
306
- function Na(t) {
307
- return t == null ? t === void 0 ? Pa : Ia : jt && jt in Object(t) ? Oa(t) : Ca(t);
308
- }
309
- var Ae = Na;
310
- function Da(t) {
311
- return t != null && typeof t == "object";
312
- }
313
- var we = Da, Ra = Ae, Ma = we, qa = "[object Symbol]";
314
- function La(t) {
315
- return typeof t == "symbol" || Ma(t) && Ra(t) == qa;
316
- }
317
- var yt = La, Ua = Y, ja = yt, za = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Ga = /^\w*$/;
318
- function ka(t, e) {
319
- if (Ua(t))
320
- return !1;
321
- var r = typeof t;
322
- return r == "number" || r == "symbol" || r == "boolean" || t == null || ja(t) ? !0 : Ga.test(t) || !za.test(t) || e != null && t in Object(e);
323
- }
324
- var vt = ka;
325
- function Va(t) {
326
- var e = typeof t;
327
- return t != null && (e == "object" || e == "function");
328
- }
329
- var gt = Va, Ba = Ae, Ka = gt, Wa = "[object AsyncFunction]", Ja = "[object Function]", Za = "[object GeneratorFunction]", Ya = "[object Proxy]";
330
- function Xa(t) {
331
- if (!Ka(t))
332
- return !1;
333
- var e = Ba(t);
334
- return e == Ja || e == Za || e == Wa || e == Ya;
335
- }
336
- var Mr = Xa, Qa = K, Ha = Qa["__core-js_shared__"], ei = Ha, Je = ei, zt = function() {
337
- var t = /[^.]+$/.exec(Je && Je.keys && Je.keys.IE_PROTO || "");
338
- return t ? "Symbol(src)_1." + t : "";
339
- }();
340
- function ti(t) {
341
- return !!zt && zt in t;
342
- }
343
- var ri = ti, ni = Function.prototype, ai = ni.toString;
344
- function ii(t) {
345
- if (t != null) {
346
- try {
347
- return ai.call(t);
348
- } catch {
349
- }
350
- try {
351
- return t + "";
352
- } catch {
353
- }
354
- }
355
- return "";
356
- }
357
- var qr = ii, si = Mr, oi = ri, ui = gt, ci = qr, li = /[\\^$.*+?()[\]{}|]/g, di = /^\[object .+?Constructor\]$/, fi = Function.prototype, pi = Object.prototype, hi = fi.toString, mi = pi.hasOwnProperty, yi = RegExp(
358
- "^" + hi.call(mi).replace(li, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
359
- );
360
- function vi(t) {
361
- if (!ui(t) || oi(t))
362
- return !1;
363
- var e = si(t) ? yi : di;
364
- return e.test(ci(t));
365
- }
366
- var gi = vi;
367
- function _i(t, e) {
368
- return t == null ? void 0 : t[e];
369
- }
370
- var bi = _i, $i = gi, Si = bi;
371
- function Ai(t, e) {
372
- var r = Si(t, e);
373
- return $i(r) ? r : void 0;
374
- }
375
- var ae = Ai, wi = ae, Ei = wi(Object, "create"), Ge = Ei, Gt = Ge;
376
- function xi() {
377
- this.__data__ = Gt ? Gt(null) : {}, this.size = 0;
378
- }
379
- var Ti = xi;
380
- function Fi(t) {
381
- var e = this.has(t) && delete this.__data__[t];
382
- return this.size -= e ? 1 : 0, e;
383
- }
384
- var Oi = Fi, Ci = Ge, Ii = "__lodash_hash_undefined__", Pi = Object.prototype, Ni = Pi.hasOwnProperty;
385
- function Di(t) {
386
- var e = this.__data__;
387
- if (Ci) {
388
- var r = e[t];
389
- return r === Ii ? void 0 : r;
390
- }
391
- return Ni.call(e, t) ? e[t] : void 0;
392
- }
393
- var Ri = Di, Mi = Ge, qi = Object.prototype, Li = qi.hasOwnProperty;
394
- function Ui(t) {
395
- var e = this.__data__;
396
- return Mi ? e[t] !== void 0 : Li.call(e, t);
397
- }
398
- var ji = Ui, zi = Ge, Gi = "__lodash_hash_undefined__";
399
- function ki(t, e) {
400
- var r = this.__data__;
401
- return this.size += this.has(t) ? 0 : 1, r[t] = zi && e === void 0 ? Gi : e, this;
402
- }
403
- var Vi = ki, Bi = Ti, Ki = Oi, Wi = Ri, Ji = ji, Zi = Vi;
404
- function de(t) {
405
- var e = -1, r = t == null ? 0 : t.length;
406
- for (this.clear(); ++e < r; ) {
407
- var n = t[e];
408
- this.set(n[0], n[1]);
409
- }
410
- }
411
- de.prototype.clear = Bi;
412
- de.prototype.delete = Ki;
413
- de.prototype.get = Wi;
414
- de.prototype.has = Ji;
415
- de.prototype.set = Zi;
416
- var Yi = de;
417
- function Xi() {
418
- this.__data__ = [], this.size = 0;
419
- }
420
- var Qi = Xi;
421
- function Hi(t, e) {
422
- return t === e || t !== t && e !== e;
423
- }
424
- var Lr = Hi, es = Lr;
425
- function ts(t, e) {
426
- for (var r = t.length; r--; )
427
- if (es(t[r][0], e))
428
- return r;
429
- return -1;
430
- }
431
- var ke = ts, rs = ke, ns = Array.prototype, as = ns.splice;
432
- function is(t) {
433
- var e = this.__data__, r = rs(e, t);
434
- if (r < 0)
435
- return !1;
436
- var n = e.length - 1;
437
- return r == n ? e.pop() : as.call(e, r, 1), --this.size, !0;
438
- }
439
- var ss = is, os = ke;
440
- function us(t) {
441
- var e = this.__data__, r = os(e, t);
442
- return r < 0 ? void 0 : e[r][1];
443
- }
444
- var cs = us, ls = ke;
445
- function ds(t) {
446
- return ls(this.__data__, t) > -1;
447
- }
448
- var fs = ds, ps = ke;
449
- function hs(t, e) {
450
- var r = this.__data__, n = ps(r, t);
451
- return n < 0 ? (++this.size, r.push([t, e])) : r[n][1] = e, this;
452
- }
453
- var ms = hs, ys = Qi, vs = ss, gs = cs, _s = fs, bs = ms;
454
- function fe(t) {
455
- var e = -1, r = t == null ? 0 : t.length;
456
- for (this.clear(); ++e < r; ) {
457
- var n = t[e];
458
- this.set(n[0], n[1]);
459
- }
460
- }
461
- fe.prototype.clear = ys;
462
- fe.prototype.delete = vs;
463
- fe.prototype.get = gs;
464
- fe.prototype.has = _s;
465
- fe.prototype.set = bs;
466
- var Ve = fe, $s = ae, Ss = K, As = $s(Ss, "Map"), _t = As, kt = Yi, ws = Ve, Es = _t;
467
- function xs() {
468
- this.size = 0, this.__data__ = {
469
- hash: new kt(),
470
- map: new (Es || ws)(),
471
- string: new kt()
472
- };
473
- }
474
- var Ts = xs;
475
- function Fs(t) {
476
- var e = typeof t;
477
- return e == "string" || e == "number" || e == "symbol" || e == "boolean" ? t !== "__proto__" : t === null;
478
- }
479
- var Os = Fs, Cs = Os;
480
- function Is(t, e) {
481
- var r = t.__data__;
482
- return Cs(e) ? r[typeof e == "string" ? "string" : "hash"] : r.map;
483
- }
484
- var Be = Is, Ps = Be;
485
- function Ns(t) {
486
- var e = Ps(this, t).delete(t);
487
- return this.size -= e ? 1 : 0, e;
488
- }
489
- var Ds = Ns, Rs = Be;
490
- function Ms(t) {
491
- return Rs(this, t).get(t);
492
- }
493
- var qs = Ms, Ls = Be;
494
- function Us(t) {
495
- return Ls(this, t).has(t);
496
- }
497
- var js = Us, zs = Be;
498
- function Gs(t, e) {
499
- var r = zs(this, t), n = r.size;
500
- return r.set(t, e), this.size += r.size == n ? 0 : 1, this;
501
- }
502
- var ks = Gs, Vs = Ts, Bs = Ds, Ks = qs, Ws = js, Js = ks;
503
- function pe(t) {
504
- var e = -1, r = t == null ? 0 : t.length;
505
- for (this.clear(); ++e < r; ) {
506
- var n = t[e];
507
- this.set(n[0], n[1]);
508
- }
509
- }
510
- pe.prototype.clear = Vs;
511
- pe.prototype.delete = Bs;
512
- pe.prototype.get = Ks;
513
- pe.prototype.has = Ws;
514
- pe.prototype.set = Js;
515
- var bt = pe, Ur = bt, Zs = "Expected a function";
516
- function $t(t, e) {
517
- if (typeof t != "function" || e != null && typeof e != "function")
518
- throw new TypeError(Zs);
519
- var r = function() {
520
- var n = arguments, a = e ? e.apply(this, n) : n[0], i = r.cache;
521
- if (i.has(a))
522
- return i.get(a);
523
- var s = t.apply(this, n);
524
- return r.cache = i.set(a, s) || i, s;
525
- };
526
- return r.cache = new ($t.Cache || Ur)(), r;
527
- }
528
- $t.Cache = Ur;
529
- var Ys = $t, Xs = Ys, Qs = 500;
530
- function Hs(t) {
531
- var e = Xs(t, function(n) {
532
- return r.size === Qs && r.clear(), n;
533
- }), r = e.cache;
534
- return e;
535
- }
536
- var eo = Hs, to = eo, ro = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, no = /\\(\\)?/g, ao = to(function(t) {
537
- var e = [];
538
- return t.charCodeAt(0) === 46 && e.push(""), t.replace(ro, function(r, n, a, i) {
539
- e.push(a ? i.replace(no, "$1") : n || r);
540
- }), e;
541
- }), io = ao;
542
- function so(t, e) {
543
- for (var r = -1, n = t == null ? 0 : t.length, a = Array(n); ++r < n; )
544
- a[r] = e(t[r], r, t);
545
- return a;
546
- }
547
- var oo = so, Vt = ze, uo = oo, co = Y, lo = yt, fo = 1 / 0, Bt = Vt ? Vt.prototype : void 0, Kt = Bt ? Bt.toString : void 0;
548
- function jr(t) {
549
- if (typeof t == "string")
550
- return t;
551
- if (co(t))
552
- return uo(t, jr) + "";
553
- if (lo(t))
554
- return Kt ? Kt.call(t) : "";
555
- var e = t + "";
556
- return e == "0" && 1 / t == -fo ? "-0" : e;
557
- }
558
- var po = jr, ho = po;
559
- function mo(t) {
560
- return t == null ? "" : ho(t);
561
- }
562
- var Ee = mo, yo = Y, vo = vt, go = io, _o = Ee;
563
- function bo(t, e) {
564
- return yo(t) ? t : vo(t, e) ? [t] : go(_o(t));
565
- }
566
- var zr = bo, $o = Ae, So = we, Ao = "[object Arguments]";
567
- function wo(t) {
568
- return So(t) && $o(t) == Ao;
569
- }
570
- var Eo = wo, Wt = Eo, xo = we, Gr = Object.prototype, To = Gr.hasOwnProperty, Fo = Gr.propertyIsEnumerable, Oo = Wt(function() {
571
- return arguments;
572
- }()) ? Wt : function(t) {
573
- return xo(t) && To.call(t, "callee") && !Fo.call(t, "callee");
574
- }, kr = Oo, Co = 9007199254740991, Io = /^(?:0|[1-9]\d*)$/;
575
- function Po(t, e) {
576
- var r = typeof t;
577
- return e = e ?? Co, !!e && (r == "number" || r != "symbol" && Io.test(t)) && t > -1 && t % 1 == 0 && t < e;
578
- }
579
- var Vr = Po, No = 9007199254740991;
580
- function Do(t) {
581
- return typeof t == "number" && t > -1 && t % 1 == 0 && t <= No;
582
- }
583
- var St = Do, Ro = yt, Mo = 1 / 0;
584
- function qo(t) {
585
- if (typeof t == "string" || Ro(t))
586
- return t;
587
- var e = t + "";
588
- return e == "0" && 1 / t == -Mo ? "-0" : e;
589
- }
590
- var Ke = qo, Lo = zr, Uo = kr, jo = Y, zo = Vr, Go = St, ko = Ke;
591
- function Vo(t, e, r) {
592
- e = Lo(e, t);
593
- for (var n = -1, a = e.length, i = !1; ++n < a; ) {
594
- var s = ko(e[n]);
595
- if (!(i = t != null && r(t, s)))
596
- break;
597
- t = t[s];
598
- }
599
- return i || ++n != a ? i : (a = t == null ? 0 : t.length, !!a && Go(a) && zo(s, a) && (jo(t) || Uo(t)));
600
- }
601
- var Br = Vo, Bo = pa, Ko = Br;
602
- function Wo(t, e) {
603
- return t != null && Ko(t, e, Bo);
604
- }
605
- var Jo = Wo;
606
- const Ne = /* @__PURE__ */ le(Jo), At = (t) => t && t.__isYupSchema__;
607
- class Zo {
608
- constructor(e, r) {
609
- if (this.fn = void 0, this.refs = e, this.refs = e, typeof r == "function") {
610
- this.fn = r;
611
- return;
612
- }
613
- if (!Ne(r, "is"))
614
- throw new TypeError("`is:` is required for `when()` conditions");
615
- if (!r.then && !r.otherwise)
616
- throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
617
- let {
618
- is: n,
619
- then: a,
620
- otherwise: i
621
- } = r, s = typeof n == "function" ? n : (...o) => o.every((u) => u === n);
622
- this.fn = function(...o) {
623
- let u = o.pop(), c = o.pop(), l = s(...o) ? a : i;
624
- if (l)
625
- return typeof l == "function" ? l(c) : c.concat(l.resolve(u));
626
- };
627
- }
628
- resolve(e, r) {
629
- let n = this.refs.map((i) => i.getValue(r == null ? void 0 : r.value, r == null ? void 0 : r.parent, r == null ? void 0 : r.context)), a = this.fn.apply(e, n.concat(e, r));
630
- if (a === void 0 || a === e)
631
- return e;
632
- if (!At(a))
633
- throw new TypeError("conditions must return a schema object");
634
- return a.resolve(r);
635
- }
636
- }
637
- function Kr(t) {
638
- return t == null ? [] : [].concat(t);
639
- }
640
- function it() {
641
- return it = Object.assign || function(t) {
642
- for (var e = 1; e < arguments.length; e++) {
643
- var r = arguments[e];
644
- for (var n in r)
645
- Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
646
- }
647
- return t;
648
- }, it.apply(this, arguments);
649
- }
650
- let Yo = /\$\{\s*(\w+)\s*\}/g;
651
- class D extends Error {
652
- static formatError(e, r) {
653
- const n = r.label || r.path || "this";
654
- return n !== r.path && (r = it({}, r, {
655
- path: n
656
- })), typeof e == "string" ? e.replace(Yo, (a, i) => ce(r[i])) : typeof e == "function" ? e(r) : e;
657
- }
658
- static isError(e) {
659
- return e && e.name === "ValidationError";
660
- }
661
- constructor(e, r, n, a) {
662
- super(), this.value = void 0, this.path = void 0, this.type = void 0, this.errors = void 0, this.params = void 0, this.inner = void 0, this.name = "ValidationError", this.value = r, this.path = n, this.type = a, this.errors = [], this.inner = [], Kr(e).forEach((i) => {
663
- D.isError(i) ? (this.errors.push(...i.errors), this.inner = this.inner.concat(i.inner.length ? i.inner : i)) : this.errors.push(i);
664
- }), this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0], Error.captureStackTrace && Error.captureStackTrace(this, D);
665
- }
666
- }
667
- const Xo = (t) => {
668
- let e = !1;
669
- return (...r) => {
670
- e || (e = !0, t(...r));
671
- };
672
- };
673
- function De(t, e) {
674
- let {
675
- endEarly: r,
676
- tests: n,
677
- args: a,
678
- value: i,
679
- errors: s,
680
- sort: o,
681
- path: u
682
- } = t, c = Xo(e), l = n.length;
683
- const d = [];
684
- if (s = s || [], !l)
685
- return s.length ? c(new D(s, i, u)) : c(null, i);
686
- for (let p = 0; p < n.length; p++) {
687
- const h = n[p];
688
- h(a, function(v) {
689
- if (v) {
690
- if (!D.isError(v))
691
- return c(v, i);
692
- if (r)
693
- return v.value = i, c(v, i);
694
- d.push(v);
695
- }
696
- if (--l <= 0) {
697
- if (d.length && (o && d.sort(o), s.length && d.push(...s), s = d), s.length) {
698
- c(new D(s, i, u), i);
699
- return;
700
- }
701
- c(null, i);
702
- }
703
- });
704
- }
705
- }
706
- var Qo = ae, Ho = function() {
707
- try {
708
- var t = Qo(Object, "defineProperty");
709
- return t({}, "", {}), t;
710
- } catch {
711
- }
712
- }(), eu = Ho, Jt = eu;
713
- function tu(t, e, r) {
714
- e == "__proto__" && Jt ? Jt(t, e, {
715
- configurable: !0,
716
- enumerable: !0,
717
- value: r,
718
- writable: !0
719
- }) : t[e] = r;
720
- }
721
- var Wr = tu;
722
- function ru(t) {
723
- return function(e, r, n) {
724
- for (var a = -1, i = Object(e), s = n(e), o = s.length; o--; ) {
725
- var u = s[t ? o : ++a];
726
- if (r(i[u], u, i) === !1)
727
- break;
728
- }
729
- return e;
730
- };
731
- }
732
- var nu = ru, au = nu, iu = au(), su = iu;
733
- function ou(t, e) {
734
- for (var r = -1, n = Array(t); ++r < t; )
735
- n[r] = e(r);
736
- return n;
737
- }
738
- var uu = ou, Re = { exports: {} };
739
- function cu() {
740
- return !1;
741
- }
742
- var lu = cu;
743
- Re.exports;
744
- (function(t, e) {
745
- var r = K, n = lu, a = e && !e.nodeType && e, i = a && !0 && t && !t.nodeType && t, s = i && i.exports === a, o = s ? r.Buffer : void 0, u = o ? o.isBuffer : void 0, c = u || n;
746
- t.exports = c;
747
- })(Re, Re.exports);
748
- var Jr = Re.exports, du = Ae, fu = St, pu = we, hu = "[object Arguments]", mu = "[object Array]", yu = "[object Boolean]", vu = "[object Date]", gu = "[object Error]", _u = "[object Function]", bu = "[object Map]", $u = "[object Number]", Su = "[object Object]", Au = "[object RegExp]", wu = "[object Set]", Eu = "[object String]", xu = "[object WeakMap]", Tu = "[object ArrayBuffer]", Fu = "[object DataView]", Ou = "[object Float32Array]", Cu = "[object Float64Array]", Iu = "[object Int8Array]", Pu = "[object Int16Array]", Nu = "[object Int32Array]", Du = "[object Uint8Array]", Ru = "[object Uint8ClampedArray]", Mu = "[object Uint16Array]", qu = "[object Uint32Array]", S = {};
749
- S[Ou] = S[Cu] = S[Iu] = S[Pu] = S[Nu] = S[Du] = S[Ru] = S[Mu] = S[qu] = !0;
750
- S[hu] = S[mu] = S[Tu] = S[yu] = S[Fu] = S[vu] = S[gu] = S[_u] = S[bu] = S[$u] = S[Su] = S[Au] = S[wu] = S[Eu] = S[xu] = !1;
751
- function Lu(t) {
752
- return pu(t) && fu(t.length) && !!S[du(t)];
753
- }
754
- var Uu = Lu;
755
- function ju(t) {
756
- return function(e) {
757
- return t(e);
758
- };
759
- }
760
- var zu = ju, Me = { exports: {} };
761
- Me.exports;
762
- (function(t, e) {
763
- var r = Dr, n = e && !e.nodeType && e, a = n && !0 && t && !t.nodeType && t, i = a && a.exports === n, s = i && r.process, o = function() {
764
- try {
765
- var u = a && a.require && a.require("util").types;
766
- return u || s && s.binding && s.binding("util");
767
- } catch {
768
- }
769
- }();
770
- t.exports = o;
771
- })(Me, Me.exports);
772
- var Gu = Me.exports, ku = Uu, Vu = zu, Zt = Gu, Yt = Zt && Zt.isTypedArray, Bu = Yt ? Vu(Yt) : ku, Zr = Bu, Ku = uu, Wu = kr, Ju = Y, Zu = Jr, Yu = Vr, Xu = Zr, Qu = Object.prototype, Hu = Qu.hasOwnProperty;
773
- function ec(t, e) {
774
- var r = Ju(t), n = !r && Wu(t), a = !r && !n && Zu(t), i = !r && !n && !a && Xu(t), s = r || n || a || i, o = s ? Ku(t.length, String) : [], u = o.length;
775
- for (var c in t)
776
- (e || Hu.call(t, c)) && !(s && // Safari 9 has enumerable `arguments.length` in strict mode.
777
- (c == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
778
- a && (c == "offset" || c == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
779
- i && (c == "buffer" || c == "byteLength" || c == "byteOffset") || // Skip index properties.
780
- Yu(c, u))) && o.push(c);
781
- return o;
782
- }
783
- var tc = ec, rc = Object.prototype;
784
- function nc(t) {
785
- var e = t && t.constructor, r = typeof e == "function" && e.prototype || rc;
786
- return t === r;
787
- }
788
- var ac = nc;
789
- function ic(t, e) {
790
- return function(r) {
791
- return t(e(r));
792
- };
793
- }
794
- var sc = ic, oc = sc, uc = oc(Object.keys, Object), cc = uc, lc = ac, dc = cc, fc = Object.prototype, pc = fc.hasOwnProperty;
795
- function hc(t) {
796
- if (!lc(t))
797
- return dc(t);
798
- var e = [];
799
- for (var r in Object(t))
800
- pc.call(t, r) && r != "constructor" && e.push(r);
801
- return e;
802
- }
803
- var mc = hc, yc = Mr, vc = St;
804
- function gc(t) {
805
- return t != null && vc(t.length) && !yc(t);
806
- }
807
- var _c = gc, bc = tc, $c = mc, Sc = _c;
808
- function Ac(t) {
809
- return Sc(t) ? bc(t) : $c(t);
810
- }
811
- var wt = Ac, wc = su, Ec = wt;
812
- function xc(t, e) {
813
- return t && wc(t, e, Ec);
814
- }
815
- var Yr = xc, Tc = Ve;
816
- function Fc() {
817
- this.__data__ = new Tc(), this.size = 0;
818
- }
819
- var Oc = Fc;
820
- function Cc(t) {
821
- var e = this.__data__, r = e.delete(t);
822
- return this.size = e.size, r;
823
- }
824
- var Ic = Cc;
825
- function Pc(t) {
826
- return this.__data__.get(t);
827
- }
828
- var Nc = Pc;
829
- function Dc(t) {
830
- return this.__data__.has(t);
831
- }
832
- var Rc = Dc, Mc = Ve, qc = _t, Lc = bt, Uc = 200;
833
- function jc(t, e) {
834
- var r = this.__data__;
835
- if (r instanceof Mc) {
836
- var n = r.__data__;
837
- if (!qc || n.length < Uc - 1)
838
- return n.push([t, e]), this.size = ++r.size, this;
839
- r = this.__data__ = new Lc(n);
840
- }
841
- return r.set(t, e), this.size = r.size, this;
842
- }
843
- var zc = jc, Gc = Ve, kc = Oc, Vc = Ic, Bc = Nc, Kc = Rc, Wc = zc;
844
- function he(t) {
845
- var e = this.__data__ = new Gc(t);
846
- this.size = e.size;
847
- }
848
- he.prototype.clear = kc;
849
- he.prototype.delete = Vc;
850
- he.prototype.get = Bc;
851
- he.prototype.has = Kc;
852
- he.prototype.set = Wc;
853
- var Xr = he, Jc = "__lodash_hash_undefined__";
854
- function Zc(t) {
855
- return this.__data__.set(t, Jc), this;
856
- }
857
- var Yc = Zc;
858
- function Xc(t) {
859
- return this.__data__.has(t);
860
- }
861
- var Qc = Xc, Hc = bt, el = Yc, tl = Qc;
862
- function qe(t) {
863
- var e = -1, r = t == null ? 0 : t.length;
864
- for (this.__data__ = new Hc(); ++e < r; )
865
- this.add(t[e]);
866
- }
867
- qe.prototype.add = qe.prototype.push = el;
868
- qe.prototype.has = tl;
869
- var rl = qe;
870
- function nl(t, e) {
871
- for (var r = -1, n = t == null ? 0 : t.length; ++r < n; )
872
- if (e(t[r], r, t))
873
- return !0;
874
- return !1;
875
- }
876
- var al = nl;
877
- function il(t, e) {
878
- return t.has(e);
879
- }
880
- var sl = il, ol = rl, ul = al, cl = sl, ll = 1, dl = 2;
881
- function fl(t, e, r, n, a, i) {
882
- var s = r & ll, o = t.length, u = e.length;
883
- if (o != u && !(s && u > o))
884
- return !1;
885
- var c = i.get(t), l = i.get(e);
886
- if (c && l)
887
- return c == e && l == t;
888
- var d = -1, p = !0, h = r & dl ? new ol() : void 0;
889
- for (i.set(t, e), i.set(e, t); ++d < o; ) {
890
- var y = t[d], v = e[d];
891
- if (n)
892
- var _ = s ? n(v, y, d, e, t, i) : n(y, v, d, t, e, i);
893
- if (_ !== void 0) {
894
- if (_)
895
- continue;
896
- p = !1;
897
- break;
898
- }
899
- if (h) {
900
- if (!ul(e, function($, A) {
901
- if (!cl(h, A) && (y === $ || a(y, $, r, n, i)))
902
- return h.push(A);
903
- })) {
904
- p = !1;
905
- break;
906
- }
907
- } else if (!(y === v || a(y, v, r, n, i))) {
908
- p = !1;
909
- break;
910
- }
911
- }
912
- return i.delete(t), i.delete(e), p;
913
- }
914
- var Qr = fl, pl = K, hl = pl.Uint8Array, ml = hl;
915
- function yl(t) {
916
- var e = -1, r = Array(t.size);
917
- return t.forEach(function(n, a) {
918
- r[++e] = [a, n];
919
- }), r;
920
- }
921
- var vl = yl;
922
- function gl(t) {
923
- var e = -1, r = Array(t.size);
924
- return t.forEach(function(n) {
925
- r[++e] = n;
926
- }), r;
927
- }
928
- var _l = gl, Xt = ze, Qt = ml, bl = Lr, $l = Qr, Sl = vl, Al = _l, wl = 1, El = 2, xl = "[object Boolean]", Tl = "[object Date]", Fl = "[object Error]", Ol = "[object Map]", Cl = "[object Number]", Il = "[object RegExp]", Pl = "[object Set]", Nl = "[object String]", Dl = "[object Symbol]", Rl = "[object ArrayBuffer]", Ml = "[object DataView]", Ht = Xt ? Xt.prototype : void 0, Ze = Ht ? Ht.valueOf : void 0;
929
- function ql(t, e, r, n, a, i, s) {
930
- switch (r) {
931
- case Ml:
932
- if (t.byteLength != e.byteLength || t.byteOffset != e.byteOffset)
933
- return !1;
934
- t = t.buffer, e = e.buffer;
935
- case Rl:
936
- return !(t.byteLength != e.byteLength || !i(new Qt(t), new Qt(e)));
937
- case xl:
938
- case Tl:
939
- case Cl:
940
- return bl(+t, +e);
941
- case Fl:
942
- return t.name == e.name && t.message == e.message;
943
- case Il:
944
- case Nl:
945
- return t == e + "";
946
- case Ol:
947
- var o = Sl;
948
- case Pl:
949
- var u = n & wl;
950
- if (o || (o = Al), t.size != e.size && !u)
951
- return !1;
952
- var c = s.get(t);
953
- if (c)
954
- return c == e;
955
- n |= El, s.set(t, e);
956
- var l = $l(o(t), o(e), n, a, i, s);
957
- return s.delete(t), l;
958
- case Dl:
959
- if (Ze)
960
- return Ze.call(t) == Ze.call(e);
961
- }
962
- return !1;
963
- }
964
- var Ll = ql;
965
- function Ul(t, e) {
966
- for (var r = -1, n = e.length, a = t.length; ++r < n; )
967
- t[a + r] = e[r];
968
- return t;
969
- }
970
- var jl = Ul, zl = jl, Gl = Y;
971
- function kl(t, e, r) {
972
- var n = e(t);
973
- return Gl(t) ? n : zl(n, r(t));
974
- }
975
- var Vl = kl;
976
- function Bl(t, e) {
977
- for (var r = -1, n = t == null ? 0 : t.length, a = 0, i = []; ++r < n; ) {
978
- var s = t[r];
979
- e(s, r, t) && (i[a++] = s);
980
- }
981
- return i;
982
- }
983
- var Kl = Bl;
984
- function Wl() {
985
- return [];
986
- }
987
- var Jl = Wl, Zl = Kl, Yl = Jl, Xl = Object.prototype, Ql = Xl.propertyIsEnumerable, er = Object.getOwnPropertySymbols, Hl = er ? function(t) {
988
- return t == null ? [] : (t = Object(t), Zl(er(t), function(e) {
989
- return Ql.call(t, e);
990
- }));
991
- } : Yl, ed = Hl, td = Vl, rd = ed, nd = wt;
992
- function ad(t) {
993
- return td(t, nd, rd);
994
- }
995
- var id = ad, tr = id, sd = 1, od = Object.prototype, ud = od.hasOwnProperty;
996
- function cd(t, e, r, n, a, i) {
997
- var s = r & sd, o = tr(t), u = o.length, c = tr(e), l = c.length;
998
- if (u != l && !s)
999
- return !1;
1000
- for (var d = u; d--; ) {
1001
- var p = o[d];
1002
- if (!(s ? p in e : ud.call(e, p)))
1003
- return !1;
1004
- }
1005
- var h = i.get(t), y = i.get(e);
1006
- if (h && y)
1007
- return h == e && y == t;
1008
- var v = !0;
1009
- i.set(t, e), i.set(e, t);
1010
- for (var _ = s; ++d < u; ) {
1011
- p = o[d];
1012
- var $ = t[p], A = e[p];
1013
- if (n)
1014
- var T = s ? n(A, $, p, e, t, i) : n($, A, p, t, e, i);
1015
- if (!(T === void 0 ? $ === A || a($, A, r, n, i) : T)) {
1016
- v = !1;
1017
- break;
1018
- }
1019
- _ || (_ = p == "constructor");
1020
- }
1021
- if (v && !_) {
1022
- var P = t.constructor, b = e.constructor;
1023
- P != b && "constructor" in t && "constructor" in e && !(typeof P == "function" && P instanceof P && typeof b == "function" && b instanceof b) && (v = !1);
1024
- }
1025
- return i.delete(t), i.delete(e), v;
1026
- }
1027
- var ld = cd, dd = ae, fd = K, pd = dd(fd, "DataView"), hd = pd, md = ae, yd = K, vd = md(yd, "Promise"), gd = vd, _d = ae, bd = K, $d = _d(bd, "Set"), Sd = $d, Ad = ae, wd = K, Ed = Ad(wd, "WeakMap"), xd = Ed, st = hd, ot = _t, ut = gd, ct = Sd, lt = xd, Hr = Ae, me = qr, rr = "[object Map]", Td = "[object Object]", nr = "[object Promise]", ar = "[object Set]", ir = "[object WeakMap]", sr = "[object DataView]", Fd = me(st), Od = me(ot), Cd = me(ut), Id = me(ct), Pd = me(lt), re = Hr;
1028
- (st && re(new st(new ArrayBuffer(1))) != sr || ot && re(new ot()) != rr || ut && re(ut.resolve()) != nr || ct && re(new ct()) != ar || lt && re(new lt()) != ir) && (re = function(t) {
1029
- var e = Hr(t), r = e == Td ? t.constructor : void 0, n = r ? me(r) : "";
1030
- if (n)
1031
- switch (n) {
1032
- case Fd:
1033
- return sr;
1034
- case Od:
1035
- return rr;
1036
- case Cd:
1037
- return nr;
1038
- case Id:
1039
- return ar;
1040
- case Pd:
1041
- return ir;
1042
- }
1043
- return e;
1044
- });
1045
- var Nd = re, Ye = Xr, Dd = Qr, Rd = Ll, Md = ld, or = Nd, ur = Y, cr = Jr, qd = Zr, Ld = 1, lr = "[object Arguments]", dr = "[object Array]", Te = "[object Object]", Ud = Object.prototype, fr = Ud.hasOwnProperty;
1046
- function jd(t, e, r, n, a, i) {
1047
- var s = ur(t), o = ur(e), u = s ? dr : or(t), c = o ? dr : or(e);
1048
- u = u == lr ? Te : u, c = c == lr ? Te : c;
1049
- var l = u == Te, d = c == Te, p = u == c;
1050
- if (p && cr(t)) {
1051
- if (!cr(e))
1052
- return !1;
1053
- s = !0, l = !1;
1054
- }
1055
- if (p && !l)
1056
- return i || (i = new Ye()), s || qd(t) ? Dd(t, e, r, n, a, i) : Rd(t, e, u, r, n, a, i);
1057
- if (!(r & Ld)) {
1058
- var h = l && fr.call(t, "__wrapped__"), y = d && fr.call(e, "__wrapped__");
1059
- if (h || y) {
1060
- var v = h ? t.value() : t, _ = y ? e.value() : e;
1061
- return i || (i = new Ye()), a(v, _, r, n, i);
1062
- }
1063
- }
1064
- return p ? (i || (i = new Ye()), Md(t, e, r, n, a, i)) : !1;
1065
- }
1066
- var zd = jd, Gd = zd, pr = we;
1067
- function en(t, e, r, n, a) {
1068
- return t === e ? !0 : t == null || e == null || !pr(t) && !pr(e) ? t !== t && e !== e : Gd(t, e, r, n, en, a);
1069
- }
1070
- var tn = en, kd = Xr, Vd = tn, Bd = 1, Kd = 2;
1071
- function Wd(t, e, r, n) {
1072
- var a = r.length, i = a, s = !n;
1073
- if (t == null)
1074
- return !i;
1075
- for (t = Object(t); a--; ) {
1076
- var o = r[a];
1077
- if (s && o[2] ? o[1] !== t[o[0]] : !(o[0] in t))
1078
- return !1;
1079
- }
1080
- for (; ++a < i; ) {
1081
- o = r[a];
1082
- var u = o[0], c = t[u], l = o[1];
1083
- if (s && o[2]) {
1084
- if (c === void 0 && !(u in t))
1085
- return !1;
1086
- } else {
1087
- var d = new kd();
1088
- if (n)
1089
- var p = n(c, l, u, t, e, d);
1090
- if (!(p === void 0 ? Vd(l, c, Bd | Kd, n, d) : p))
1091
- return !1;
1092
- }
1093
- }
1094
- return !0;
1095
- }
1096
- var Jd = Wd, Zd = gt;
1097
- function Yd(t) {
1098
- return t === t && !Zd(t);
1099
- }
1100
- var rn = Yd, Xd = rn, Qd = wt;
1101
- function Hd(t) {
1102
- for (var e = Qd(t), r = e.length; r--; ) {
1103
- var n = e[r], a = t[n];
1104
- e[r] = [n, a, Xd(a)];
1105
- }
1106
- return e;
1107
- }
1108
- var ef = Hd;
1109
- function tf(t, e) {
1110
- return function(r) {
1111
- return r == null ? !1 : r[t] === e && (e !== void 0 || t in Object(r));
1112
- };
1113
- }
1114
- var nn = tf, rf = Jd, nf = ef, af = nn;
1115
- function sf(t) {
1116
- var e = nf(t);
1117
- return e.length == 1 && e[0][2] ? af(e[0][0], e[0][1]) : function(r) {
1118
- return r === t || rf(r, t, e);
1119
- };
1120
- }
1121
- var of = sf, uf = zr, cf = Ke;
1122
- function lf(t, e) {
1123
- e = uf(e, t);
1124
- for (var r = 0, n = e.length; t != null && r < n; )
1125
- t = t[cf(e[r++])];
1126
- return r && r == n ? t : void 0;
1127
- }
1128
- var an = lf, df = an;
1129
- function ff(t, e, r) {
1130
- var n = t == null ? void 0 : df(t, e);
1131
- return n === void 0 ? r : n;
1132
- }
1133
- var pf = ff;
1134
- function hf(t, e) {
1135
- return t != null && e in Object(t);
1136
- }
1137
- var mf = hf, yf = mf, vf = Br;
1138
- function gf(t, e) {
1139
- return t != null && vf(t, e, yf);
1140
- }
1141
- var _f = gf, bf = tn, $f = pf, Sf = _f, Af = vt, wf = rn, Ef = nn, xf = Ke, Tf = 1, Ff = 2;
1142
- function Of(t, e) {
1143
- return Af(t) && wf(e) ? Ef(xf(t), e) : function(r) {
1144
- var n = $f(r, t);
1145
- return n === void 0 && n === e ? Sf(r, t) : bf(e, n, Tf | Ff);
1146
- };
1147
- }
1148
- var Cf = Of;
1149
- function If(t) {
1150
- return t;
1151
- }
1152
- var Pf = If;
1153
- function Nf(t) {
1154
- return function(e) {
1155
- return e == null ? void 0 : e[t];
1156
- };
1157
- }
1158
- var Df = Nf, Rf = an;
1159
- function Mf(t) {
1160
- return function(e) {
1161
- return Rf(e, t);
1162
- };
1163
- }
1164
- var qf = Mf, Lf = Df, Uf = qf, jf = vt, zf = Ke;
1165
- function Gf(t) {
1166
- return jf(t) ? Lf(zf(t)) : Uf(t);
1167
- }
1168
- var kf = Gf, Vf = of, Bf = Cf, Kf = Pf, Wf = Y, Jf = kf;
1169
- function Zf(t) {
1170
- return typeof t == "function" ? t : t == null ? Kf : typeof t == "object" ? Wf(t) ? Bf(t[0], t[1]) : Vf(t) : Jf(t);
1171
- }
1172
- var sn = Zf, Yf = Wr, Xf = Yr, Qf = sn;
1173
- function Hf(t, e) {
1174
- var r = {};
1175
- return e = Qf(e), Xf(t, function(n, a, i) {
1176
- Yf(r, a, e(n, a, i));
1177
- }), r;
1178
- }
1179
- var ep = Hf;
1180
- const on = /* @__PURE__ */ le(ep);
1181
- function ie(t) {
1182
- this._maxSize = t, this.clear();
1183
- }
1184
- ie.prototype.clear = function() {
1185
- this._size = 0, this._values = /* @__PURE__ */ Object.create(null);
1186
- };
1187
- ie.prototype.get = function(t) {
1188
- return this._values[t];
1189
- };
1190
- ie.prototype.set = function(t, e) {
1191
- return this._size >= this._maxSize && this.clear(), t in this._values || this._size++, this._values[t] = e;
1192
- };
1193
- var tp = /[^.^\]^[]+|(?=\[\]|\.\.)/g, un = /^\d+$/, rp = /^\d/, np = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, ap = /^\s*(['"]?)(.*?)(\1)\s*$/, Et = 512, hr = new ie(Et), mr = new ie(Et), yr = new ie(Et), We = {
1194
- Cache: ie,
1195
- split: dt,
1196
- normalizePath: Xe,
1197
- setter: function(t) {
1198
- var e = Xe(t);
1199
- return mr.get(t) || mr.set(t, function(n, a) {
1200
- for (var i = 0, s = e.length, o = n; i < s - 1; ) {
1201
- var u = e[i];
1202
- if (u === "__proto__" || u === "constructor" || u === "prototype")
1203
- return n;
1204
- o = o[e[i++]];
1205
- }
1206
- o[e[i]] = a;
1207
- });
1208
- },
1209
- getter: function(t, e) {
1210
- var r = Xe(t);
1211
- return yr.get(t) || yr.set(t, function(a) {
1212
- for (var i = 0, s = r.length; i < s; )
1213
- if (a != null || !e)
1214
- a = a[r[i++]];
1215
- else
1216
- return;
1217
- return a;
1218
- });
1219
- },
1220
- join: function(t) {
1221
- return t.reduce(function(e, r) {
1222
- return e + (xt(r) || un.test(r) ? "[" + r + "]" : (e ? "." : "") + r);
1223
- }, "");
1224
- },
1225
- forEach: function(t, e, r) {
1226
- ip(Array.isArray(t) ? t : dt(t), e, r);
1227
- }
1228
- };
1229
- function Xe(t) {
1230
- return hr.get(t) || hr.set(
1231
- t,
1232
- dt(t).map(function(e) {
1233
- return e.replace(ap, "$2");
1234
- })
1235
- );
1236
- }
1237
- function dt(t) {
1238
- return t.match(tp) || [""];
1239
- }
1240
- function ip(t, e, r) {
1241
- var n = t.length, a, i, s, o;
1242
- for (i = 0; i < n; i++)
1243
- a = t[i], a && (up(a) && (a = '"' + a + '"'), o = xt(a), s = !o && /^\d+$/.test(a), e.call(r, a, o, s, i, t));
1244
- }
1245
- function xt(t) {
1246
- return typeof t == "string" && t && ["'", '"'].indexOf(t.charAt(0)) !== -1;
1247
- }
1248
- function sp(t) {
1249
- return t.match(rp) && !t.match(un);
1250
- }
1251
- function op(t) {
1252
- return np.test(t);
1253
- }
1254
- function up(t) {
1255
- return !xt(t) && (sp(t) || op(t));
1256
- }
1257
- const Fe = {
1258
- context: "$",
1259
- value: "."
1260
- };
1261
- class Z {
1262
- constructor(e, r = {}) {
1263
- if (this.key = void 0, this.isContext = void 0, this.isValue = void 0, this.isSibling = void 0, this.path = void 0, this.getter = void 0, this.map = void 0, typeof e != "string")
1264
- throw new TypeError("ref must be a string, got: " + e);
1265
- if (this.key = e.trim(), e === "")
1266
- throw new TypeError("ref must be a non-empty string");
1267
- this.isContext = this.key[0] === Fe.context, this.isValue = this.key[0] === Fe.value, this.isSibling = !this.isContext && !this.isValue;
1268
- let n = this.isContext ? Fe.context : this.isValue ? Fe.value : "";
1269
- this.path = this.key.slice(n.length), this.getter = this.path && We.getter(this.path, !0), this.map = r.map;
1270
- }
1271
- getValue(e, r, n) {
1272
- let a = this.isContext ? n : this.isValue ? e : r;
1273
- return this.getter && (a = this.getter(a || {})), this.map && (a = this.map(a)), a;
1274
- }
1275
- /**
1276
- *
1277
- * @param {*} value
1278
- * @param {Object} options
1279
- * @param {Object=} options.context
1280
- * @param {Object=} options.parent
1281
- */
1282
- cast(e, r) {
1283
- return this.getValue(e, r == null ? void 0 : r.parent, r == null ? void 0 : r.context);
1284
- }
1285
- resolve() {
1286
- return this;
1287
- }
1288
- describe() {
1289
- return {
1290
- type: "ref",
1291
- key: this.key
1292
- };
1293
- }
1294
- toString() {
1295
- return `Ref(${this.key})`;
1296
- }
1297
- static isRef(e) {
1298
- return e && e.__isYupRef;
1299
- }
1300
- }
1301
- Z.prototype.__isYupRef = !0;
1302
- function Le() {
1303
- return Le = Object.assign || function(t) {
1304
- for (var e = 1; e < arguments.length; e++) {
1305
- var r = arguments[e];
1306
- for (var n in r)
1307
- Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
1308
- }
1309
- return t;
1310
- }, Le.apply(this, arguments);
1311
- }
1312
- function cp(t, e) {
1313
- if (t == null)
1314
- return {};
1315
- var r = {}, n = Object.keys(t), a, i;
1316
- for (i = 0; i < n.length; i++)
1317
- a = n[i], !(e.indexOf(a) >= 0) && (r[a] = t[a]);
1318
- return r;
1319
- }
1320
- function Oe(t) {
1321
- function e(r, n) {
1322
- let {
1323
- value: a,
1324
- path: i = "",
1325
- label: s,
1326
- options: o,
1327
- originalValue: u,
1328
- sync: c
1329
- } = r, l = cp(r, ["value", "path", "label", "options", "originalValue", "sync"]);
1330
- const {
1331
- name: d,
1332
- test: p,
1333
- params: h,
1334
- message: y
1335
- } = t;
1336
- let {
1337
- parent: v,
1338
- context: _
1339
- } = o;
1340
- function $(g) {
1341
- return Z.isRef(g) ? g.getValue(a, v, _) : g;
1342
- }
1343
- function A(g = {}) {
1344
- const N = on(Le({
1345
- value: a,
1346
- originalValue: u,
1347
- label: s,
1348
- path: g.path || i
1349
- }, h, g.params), $), R = new D(D.formatError(g.message || y, N), a, N.path, g.type || d);
1350
- return R.params = N, R;
1351
- }
1352
- let T = Le({
1353
- path: i,
1354
- parent: v,
1355
- type: d,
1356
- createError: A,
1357
- resolve: $,
1358
- options: o,
1359
- originalValue: u
1360
- }, l);
1361
- if (!c) {
1362
- try {
1363
- Promise.resolve(p.call(T, a, T)).then((g) => {
1364
- D.isError(g) ? n(g) : g ? n(null, g) : n(A());
1365
- }).catch(n);
1366
- } catch (g) {
1367
- n(g);
1368
- }
1369
- return;
1370
- }
1371
- let P;
1372
- try {
1373
- var b;
1374
- if (P = p.call(T, a, T), typeof ((b = P) == null ? void 0 : b.then) == "function")
1375
- throw new Error(`Validation test of type: "${T.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
1376
- } catch (g) {
1377
- n(g);
1378
- return;
1379
- }
1380
- D.isError(P) ? n(P) : P ? n(null, P) : n(A());
1381
- }
1382
- return e.OPTIONS = t, e;
1383
- }
1384
- let lp = (t) => t.substr(0, t.length - 1).substr(1);
1385
- function dp(t, e, r, n = r) {
1386
- let a, i, s;
1387
- return e ? (We.forEach(e, (o, u, c) => {
1388
- let l = u ? lp(o) : o;
1389
- if (t = t.resolve({
1390
- context: n,
1391
- parent: a,
1392
- value: r
1393
- }), t.innerType) {
1394
- let d = c ? parseInt(l, 10) : 0;
1395
- if (r && d >= r.length)
1396
- throw new Error(`Yup.reach cannot resolve an array item at index: ${o}, in the path: ${e}. because there is no value at that index. `);
1397
- a = r, r = r && r[d], t = t.innerType;
1398
- }
1399
- if (!c) {
1400
- if (!t.fields || !t.fields[l])
1401
- throw new Error(`The schema does not contain the path: ${e}. (failed at: ${s} which is a type: "${t._type}")`);
1402
- a = r, r = r && r[l], t = t.fields[l];
1403
- }
1404
- i = l, s = u ? "[" + o + "]" : "." + o;
1405
- }), {
1406
- schema: t,
1407
- parent: a,
1408
- parentPath: i
1409
- }) : {
1410
- parent: a,
1411
- parentPath: e,
1412
- schema: t
1413
- };
1414
- }
1415
- class Ue {
1416
- constructor() {
1417
- this.list = void 0, this.refs = void 0, this.list = /* @__PURE__ */ new Set(), this.refs = /* @__PURE__ */ new Map();
1418
- }
1419
- get size() {
1420
- return this.list.size + this.refs.size;
1421
- }
1422
- describe() {
1423
- const e = [];
1424
- for (const r of this.list)
1425
- e.push(r);
1426
- for (const [, r] of this.refs)
1427
- e.push(r.describe());
1428
- return e;
1429
- }
1430
- toArray() {
1431
- return Array.from(this.list).concat(Array.from(this.refs.values()));
1432
- }
1433
- resolveAll(e) {
1434
- return this.toArray().reduce((r, n) => r.concat(Z.isRef(n) ? e(n) : n), []);
1435
- }
1436
- add(e) {
1437
- Z.isRef(e) ? this.refs.set(e.key, e) : this.list.add(e);
1438
- }
1439
- delete(e) {
1440
- Z.isRef(e) ? this.refs.delete(e.key) : this.list.delete(e);
1441
- }
1442
- clone() {
1443
- const e = new Ue();
1444
- return e.list = new Set(this.list), e.refs = new Map(this.refs), e;
1445
- }
1446
- merge(e, r) {
1447
- const n = this.clone();
1448
- return e.list.forEach((a) => n.add(a)), e.refs.forEach((a) => n.add(a)), r.list.forEach((a) => n.delete(a)), r.refs.forEach((a) => n.delete(a)), n;
1449
- }
1450
- }
1451
- function L() {
1452
- return L = Object.assign || function(t) {
1453
- for (var e = 1; e < arguments.length; e++) {
1454
- var r = arguments[e];
1455
- for (var n in r)
1456
- Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
1457
- }
1458
- return t;
1459
- }, L.apply(this, arguments);
1460
- }
1461
- class I {
1462
- constructor(e) {
1463
- this.deps = [], this.tests = void 0, this.transforms = void 0, this.conditions = [], this._mutate = void 0, this._typeError = void 0, this._whitelist = new Ue(), this._blacklist = new Ue(), this.exclusiveTests = /* @__PURE__ */ Object.create(null), this.spec = void 0, this.tests = [], this.transforms = [], this.withMutation(() => {
1464
- this.typeError(te.notType);
1465
- }), this.type = (e == null ? void 0 : e.type) || "mixed", this.spec = L({
1466
- strip: !1,
1467
- strict: !1,
1468
- abortEarly: !0,
1469
- recursive: !0,
1470
- nullable: !1,
1471
- presence: "optional"
1472
- }, e == null ? void 0 : e.spec);
1473
- }
1474
- // TODO: remove
1475
- get _type() {
1476
- return this.type;
1477
- }
1478
- _typeCheck(e) {
1479
- return !0;
1480
- }
1481
- clone(e) {
1482
- if (this._mutate)
1483
- return e && Object.assign(this.spec, e), this;
1484
- const r = Object.create(Object.getPrototypeOf(this));
1485
- return r.type = this.type, r._typeError = this._typeError, r._whitelistError = this._whitelistError, r._blacklistError = this._blacklistError, r._whitelist = this._whitelist.clone(), r._blacklist = this._blacklist.clone(), r.exclusiveTests = L({}, this.exclusiveTests), r.deps = [...this.deps], r.conditions = [...this.conditions], r.tests = [...this.tests], r.transforms = [...this.transforms], r.spec = tt(L({}, this.spec, e)), r;
1486
- }
1487
- label(e) {
1488
- let r = this.clone();
1489
- return r.spec.label = e, r;
1490
- }
1491
- meta(...e) {
1492
- if (e.length === 0)
1493
- return this.spec.meta;
1494
- let r = this.clone();
1495
- return r.spec.meta = Object.assign(r.spec.meta || {}, e[0]), r;
1496
- }
1497
- // withContext<TContext extends AnyObject>(): BaseSchema<
1498
- // TCast,
1499
- // TContext,
1500
- // TOutput
1501
- // > {
1502
- // return this as any;
1503
- // }
1504
- withMutation(e) {
1505
- let r = this._mutate;
1506
- this._mutate = !0;
1507
- let n = e(this);
1508
- return this._mutate = r, n;
1509
- }
1510
- concat(e) {
1511
- if (!e || e === this)
1512
- return this;
1513
- if (e.type !== this.type && this.type !== "mixed")
1514
- throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);
1515
- let r = this, n = e.clone();
1516
- const a = L({}, r.spec, n.spec);
1517
- return n.spec = a, n._typeError || (n._typeError = r._typeError), n._whitelistError || (n._whitelistError = r._whitelistError), n._blacklistError || (n._blacklistError = r._blacklistError), n._whitelist = r._whitelist.merge(e._whitelist, e._blacklist), n._blacklist = r._blacklist.merge(e._blacklist, e._whitelist), n.tests = r.tests, n.exclusiveTests = r.exclusiveTests, n.withMutation((i) => {
1518
- e.tests.forEach((s) => {
1519
- i.test(s.OPTIONS);
1520
- });
1521
- }), n.transforms = [...r.transforms, ...n.transforms], n;
1522
- }
1523
- isType(e) {
1524
- return this.spec.nullable && e === null ? !0 : this._typeCheck(e);
1525
- }
1526
- resolve(e) {
1527
- let r = this;
1528
- if (r.conditions.length) {
1529
- let n = r.conditions;
1530
- r = r.clone(), r.conditions = [], r = n.reduce((a, i) => i.resolve(a, e), r), r = r.resolve(e);
1531
- }
1532
- return r;
1533
- }
1534
- /**
1535
- *
1536
- * @param {*} value
1537
- * @param {Object} options
1538
- * @param {*=} options.parent
1539
- * @param {*=} options.context
1540
- */
1541
- cast(e, r = {}) {
1542
- let n = this.resolve(L({
1543
- value: e
1544
- }, r)), a = n._cast(e, r);
1545
- if (e !== void 0 && r.assert !== !1 && n.isType(a) !== !0) {
1546
- let i = ce(e), s = ce(a);
1547
- throw new TypeError(`The value of ${r.path || "field"} could not be cast to a value that satisfies the schema type: "${n._type}".
1548
-
1549
- attempted value: ${i}
1550
- ` + (s !== i ? `result of cast: ${s}` : ""));
1551
- }
1552
- return a;
1553
- }
1554
- _cast(e, r) {
1555
- let n = e === void 0 ? e : this.transforms.reduce((a, i) => i.call(this, a, e, this), e);
1556
- return n === void 0 && (n = this.getDefault()), n;
1557
- }
1558
- _validate(e, r = {}, n) {
1559
- let {
1560
- sync: a,
1561
- path: i,
1562
- from: s = [],
1563
- originalValue: o = e,
1564
- strict: u = this.spec.strict,
1565
- abortEarly: c = this.spec.abortEarly
1566
- } = r, l = e;
1567
- u || (l = this._cast(l, L({
1568
- assert: !1
1569
- }, r)));
1570
- let d = {
1571
- value: l,
1572
- path: i,
1573
- options: r,
1574
- originalValue: o,
1575
- schema: this,
1576
- label: this.spec.label,
1577
- sync: a,
1578
- from: s
1579
- }, p = [];
1580
- this._typeError && p.push(this._typeError);
1581
- let h = [];
1582
- this._whitelistError && h.push(this._whitelistError), this._blacklistError && h.push(this._blacklistError), De({
1583
- args: d,
1584
- value: l,
1585
- path: i,
1586
- sync: a,
1587
- tests: p,
1588
- endEarly: c
1589
- }, (y) => {
1590
- if (y)
1591
- return void n(y, l);
1592
- De({
1593
- tests: this.tests.concat(h),
1594
- args: d,
1595
- path: i,
1596
- sync: a,
1597
- value: l,
1598
- endEarly: c
1599
- }, n);
1600
- });
1601
- }
1602
- validate(e, r, n) {
1603
- let a = this.resolve(L({}, r, {
1604
- value: e
1605
- }));
1606
- return typeof n == "function" ? a._validate(e, r, n) : new Promise((i, s) => a._validate(e, r, (o, u) => {
1607
- o ? s(o) : i(u);
1608
- }));
1609
- }
1610
- validateSync(e, r) {
1611
- let n = this.resolve(L({}, r, {
1612
- value: e
1613
- })), a;
1614
- return n._validate(e, L({}, r, {
1615
- sync: !0
1616
- }), (i, s) => {
1617
- if (i)
1618
- throw i;
1619
- a = s;
1620
- }), a;
1621
- }
1622
- isValid(e, r) {
1623
- return this.validate(e, r).then(() => !0, (n) => {
1624
- if (D.isError(n))
1625
- return !1;
1626
- throw n;
1627
- });
1628
- }
1629
- isValidSync(e, r) {
1630
- try {
1631
- return this.validateSync(e, r), !0;
1632
- } catch (n) {
1633
- if (D.isError(n))
1634
- return !1;
1635
- throw n;
1636
- }
1637
- }
1638
- _getDefault() {
1639
- let e = this.spec.default;
1640
- return e == null ? e : typeof e == "function" ? e.call(this) : tt(e);
1641
- }
1642
- getDefault(e) {
1643
- return this.resolve(e || {})._getDefault();
1644
- }
1645
- default(e) {
1646
- return arguments.length === 0 ? this._getDefault() : this.clone({
1647
- default: e
1648
- });
1649
- }
1650
- strict(e = !0) {
1651
- let r = this.clone();
1652
- return r.spec.strict = e, r;
1653
- }
1654
- _isPresent(e) {
1655
- return e != null;
1656
- }
1657
- defined(e = te.defined) {
1658
- return this.test({
1659
- message: e,
1660
- name: "defined",
1661
- exclusive: !0,
1662
- test(r) {
1663
- return r !== void 0;
1664
- }
1665
- });
1666
- }
1667
- required(e = te.required) {
1668
- return this.clone({
1669
- presence: "required"
1670
- }).withMutation((r) => r.test({
1671
- message: e,
1672
- name: "required",
1673
- exclusive: !0,
1674
- test(n) {
1675
- return this.schema._isPresent(n);
1676
- }
1677
- }));
1678
- }
1679
- notRequired() {
1680
- let e = this.clone({
1681
- presence: "optional"
1682
- });
1683
- return e.tests = e.tests.filter((r) => r.OPTIONS.name !== "required"), e;
1684
- }
1685
- nullable(e = !0) {
1686
- return this.clone({
1687
- nullable: e !== !1
1688
- });
1689
- }
1690
- transform(e) {
1691
- let r = this.clone();
1692
- return r.transforms.push(e), r;
1693
- }
1694
- /**
1695
- * Adds a test function to the schema's queue of tests.
1696
- * tests can be exclusive or non-exclusive.
1697
- *
1698
- * - exclusive tests, will replace any existing tests of the same name.
1699
- * - non-exclusive: can be stacked
1700
- *
1701
- * If a non-exclusive test is added to a schema with an exclusive test of the same name
1702
- * the exclusive test is removed and further tests of the same name will be stacked.
1703
- *
1704
- * If an exclusive test is added to a schema with non-exclusive tests of the same name
1705
- * the previous tests are removed and further tests of the same name will replace each other.
1706
- */
1707
- test(...e) {
1708
- let r;
1709
- if (e.length === 1 ? typeof e[0] == "function" ? r = {
1710
- test: e[0]
1711
- } : r = e[0] : e.length === 2 ? r = {
1712
- name: e[0],
1713
- test: e[1]
1714
- } : r = {
1715
- name: e[0],
1716
- message: e[1],
1717
- test: e[2]
1718
- }, r.message === void 0 && (r.message = te.default), typeof r.test != "function")
1719
- throw new TypeError("`test` is a required parameters");
1720
- let n = this.clone(), a = Oe(r), i = r.exclusive || r.name && n.exclusiveTests[r.name] === !0;
1721
- if (r.exclusive && !r.name)
1722
- throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
1723
- return r.name && (n.exclusiveTests[r.name] = !!r.exclusive), n.tests = n.tests.filter((s) => !(s.OPTIONS.name === r.name && (i || s.OPTIONS.test === a.OPTIONS.test))), n.tests.push(a), n;
1724
- }
1725
- when(e, r) {
1726
- !Array.isArray(e) && typeof e != "string" && (r = e, e = ".");
1727
- let n = this.clone(), a = Kr(e).map((i) => new Z(i));
1728
- return a.forEach((i) => {
1729
- i.isSibling && n.deps.push(i.key);
1730
- }), n.conditions.push(new Zo(a, r)), n;
1731
- }
1732
- typeError(e) {
1733
- let r = this.clone();
1734
- return r._typeError = Oe({
1735
- message: e,
1736
- name: "typeError",
1737
- test(n) {
1738
- return n !== void 0 && !this.schema.isType(n) ? this.createError({
1739
- params: {
1740
- type: this.schema._type
1741
- }
1742
- }) : !0;
1743
- }
1744
- }), r;
1745
- }
1746
- oneOf(e, r = te.oneOf) {
1747
- let n = this.clone();
1748
- return e.forEach((a) => {
1749
- n._whitelist.add(a), n._blacklist.delete(a);
1750
- }), n._whitelistError = Oe({
1751
- message: r,
1752
- name: "oneOf",
1753
- test(a) {
1754
- if (a === void 0)
1755
- return !0;
1756
- let i = this.schema._whitelist, s = i.resolveAll(this.resolve);
1757
- return s.includes(a) ? !0 : this.createError({
1758
- params: {
1759
- values: i.toArray().join(", "),
1760
- resolved: s
1761
- }
1762
- });
1763
- }
1764
- }), n;
1765
- }
1766
- notOneOf(e, r = te.notOneOf) {
1767
- let n = this.clone();
1768
- return e.forEach((a) => {
1769
- n._blacklist.add(a), n._whitelist.delete(a);
1770
- }), n._blacklistError = Oe({
1771
- message: r,
1772
- name: "notOneOf",
1773
- test(a) {
1774
- let i = this.schema._blacklist, s = i.resolveAll(this.resolve);
1775
- return s.includes(a) ? this.createError({
1776
- params: {
1777
- values: i.toArray().join(", "),
1778
- resolved: s
1779
- }
1780
- }) : !0;
1781
- }
1782
- }), n;
1783
- }
1784
- strip(e = !0) {
1785
- let r = this.clone();
1786
- return r.spec.strip = e, r;
1787
- }
1788
- describe() {
1789
- const e = this.clone(), {
1790
- label: r,
1791
- meta: n
1792
- } = e.spec;
1793
- return {
1794
- meta: n,
1795
- label: r,
1796
- type: e.type,
1797
- oneOf: e._whitelist.describe(),
1798
- notOneOf: e._blacklist.describe(),
1799
- tests: e.tests.map((i) => ({
1800
- name: i.OPTIONS.name,
1801
- params: i.OPTIONS.params
1802
- })).filter((i, s, o) => o.findIndex((u) => u.name === i.name) === s)
1803
- };
1804
- }
1805
- }
1806
- I.prototype.__isYupSchema__ = !0;
1807
- for (const t of ["validate", "validateSync"])
1808
- I.prototype[`${t}At`] = function(e, r, n = {}) {
1809
- const {
1810
- parent: a,
1811
- parentPath: i,
1812
- schema: s
1813
- } = dp(this, e, r, n.context);
1814
- return s[t](a && a[i], L({}, n, {
1815
- parent: a,
1816
- path: e
1817
- }));
1818
- };
1819
- for (const t of ["equals", "is"])
1820
- I.prototype[t] = I.prototype.oneOf;
1821
- for (const t of ["not", "nope"])
1822
- I.prototype[t] = I.prototype.notOneOf;
1823
- I.prototype.optional = I.prototype.notRequired;
1824
- const cn = I;
1825
- function ye() {
1826
- return new cn();
1827
- }
1828
- ye.prototype = cn.prototype;
1829
- const E = (t) => t == null;
1830
- function ve() {
1831
- return new ln();
1832
- }
1833
- class ln extends I {
1834
- constructor() {
1835
- super({
1836
- type: "boolean"
1837
- }), this.withMutation(() => {
1838
- this.transform(function(e) {
1839
- if (!this.isType(e)) {
1840
- if (/^(true|1)$/i.test(String(e)))
1841
- return !0;
1842
- if (/^(false|0)$/i.test(String(e)))
1843
- return !1;
1844
- }
1845
- return e;
1846
- });
1847
- });
1848
- }
1849
- _typeCheck(e) {
1850
- return e instanceof Boolean && (e = e.valueOf()), typeof e == "boolean";
1851
- }
1852
- isTrue(e = nt.isValue) {
1853
- return this.test({
1854
- message: e,
1855
- name: "is-value",
1856
- exclusive: !0,
1857
- params: {
1858
- value: "true"
1859
- },
1860
- test(r) {
1861
- return E(r) || r === !0;
1862
- }
1863
- });
1864
- }
1865
- isFalse(e = nt.isValue) {
1866
- return this.test({
1867
- message: e,
1868
- name: "is-value",
1869
- exclusive: !0,
1870
- params: {
1871
- value: "false"
1872
- },
1873
- test(r) {
1874
- return E(r) || r === !1;
1875
- }
1876
- });
1877
- }
1878
- }
1879
- ve.prototype = ln.prototype;
1880
- let fp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i, pp = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i, hp = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, mp = (t) => E(t) || t === t.trim(), yp = {}.toString();
1881
- function f() {
1882
- return new dn();
1883
- }
1884
- class dn extends I {
1885
- constructor() {
1886
- super({
1887
- type: "string"
1888
- }), this.withMutation(() => {
1889
- this.transform(function(e) {
1890
- if (this.isType(e) || Array.isArray(e))
1891
- return e;
1892
- const r = e != null && e.toString ? e.toString() : e;
1893
- return r === yp ? e : r;
1894
- });
1895
- });
1896
- }
1897
- _typeCheck(e) {
1898
- return e instanceof String && (e = e.valueOf()), typeof e == "string";
1899
- }
1900
- _isPresent(e) {
1901
- return super._isPresent(e) && !!e.length;
1902
- }
1903
- length(e, r = j.length) {
1904
- return this.test({
1905
- message: r,
1906
- name: "length",
1907
- exclusive: !0,
1908
- params: {
1909
- length: e
1910
- },
1911
- test(n) {
1912
- return E(n) || n.length === this.resolve(e);
1913
- }
1914
- });
1915
- }
1916
- min(e, r = j.min) {
1917
- return this.test({
1918
- message: r,
1919
- name: "min",
1920
- exclusive: !0,
1921
- params: {
1922
- min: e
1923
- },
1924
- test(n) {
1925
- return E(n) || n.length >= this.resolve(e);
1926
- }
1927
- });
1928
- }
1929
- max(e, r = j.max) {
1930
- return this.test({
1931
- name: "max",
1932
- exclusive: !0,
1933
- message: r,
1934
- params: {
1935
- max: e
1936
- },
1937
- test(n) {
1938
- return E(n) || n.length <= this.resolve(e);
1939
- }
1940
- });
1941
- }
1942
- matches(e, r) {
1943
- let n = !1, a, i;
1944
- return r && (typeof r == "object" ? {
1945
- excludeEmptyString: n = !1,
1946
- message: a,
1947
- name: i
1948
- } = r : a = r), this.test({
1949
- name: i || "matches",
1950
- message: a || j.matches,
1951
- params: {
1952
- regex: e
1953
- },
1954
- test: (s) => E(s) || s === "" && n || s.search(e) !== -1
1955
- });
1956
- }
1957
- email(e = j.email) {
1958
- return this.matches(fp, {
1959
- name: "email",
1960
- message: e,
1961
- excludeEmptyString: !0
1962
- });
1963
- }
1964
- url(e = j.url) {
1965
- return this.matches(pp, {
1966
- name: "url",
1967
- message: e,
1968
- excludeEmptyString: !0
1969
- });
1970
- }
1971
- uuid(e = j.uuid) {
1972
- return this.matches(hp, {
1973
- name: "uuid",
1974
- message: e,
1975
- excludeEmptyString: !1
1976
- });
1977
- }
1978
- //-- transforms --
1979
- ensure() {
1980
- return this.default("").transform((e) => e === null ? "" : e);
1981
- }
1982
- trim(e = j.trim) {
1983
- return this.transform((r) => r != null ? r.trim() : r).test({
1984
- message: e,
1985
- name: "trim",
1986
- test: mp
1987
- });
1988
- }
1989
- lowercase(e = j.lowercase) {
1990
- return this.transform((r) => E(r) ? r : r.toLowerCase()).test({
1991
- message: e,
1992
- name: "string_case",
1993
- exclusive: !0,
1994
- test: (r) => E(r) || r === r.toLowerCase()
1995
- });
1996
- }
1997
- uppercase(e = j.uppercase) {
1998
- return this.transform((r) => E(r) ? r : r.toUpperCase()).test({
1999
- message: e,
2000
- name: "string_case",
2001
- exclusive: !0,
2002
- test: (r) => E(r) || r === r.toUpperCase()
2003
- });
2004
- }
2005
- }
2006
- f.prototype = dn.prototype;
2007
- let vp = (t) => t != +t;
2008
- function ue() {
2009
- return new fn();
2010
- }
2011
- class fn extends I {
2012
- constructor() {
2013
- super({
2014
- type: "number"
2015
- }), this.withMutation(() => {
2016
- this.transform(function(e) {
2017
- let r = e;
2018
- if (typeof r == "string") {
2019
- if (r = r.replace(/\s/g, ""), r === "")
2020
- return NaN;
2021
- r = +r;
2022
- }
2023
- return this.isType(r) ? r : parseFloat(r);
2024
- });
2025
- });
2026
- }
2027
- _typeCheck(e) {
2028
- return e instanceof Number && (e = e.valueOf()), typeof e == "number" && !vp(e);
2029
- }
2030
- min(e, r = J.min) {
2031
- return this.test({
2032
- message: r,
2033
- name: "min",
2034
- exclusive: !0,
2035
- params: {
2036
- min: e
2037
- },
2038
- test(n) {
2039
- return E(n) || n >= this.resolve(e);
2040
- }
2041
- });
2042
- }
2043
- max(e, r = J.max) {
2044
- return this.test({
2045
- message: r,
2046
- name: "max",
2047
- exclusive: !0,
2048
- params: {
2049
- max: e
2050
- },
2051
- test(n) {
2052
- return E(n) || n <= this.resolve(e);
2053
- }
2054
- });
2055
- }
2056
- lessThan(e, r = J.lessThan) {
2057
- return this.test({
2058
- message: r,
2059
- name: "max",
2060
- exclusive: !0,
2061
- params: {
2062
- less: e
2063
- },
2064
- test(n) {
2065
- return E(n) || n < this.resolve(e);
2066
- }
2067
- });
2068
- }
2069
- moreThan(e, r = J.moreThan) {
2070
- return this.test({
2071
- message: r,
2072
- name: "min",
2073
- exclusive: !0,
2074
- params: {
2075
- more: e
2076
- },
2077
- test(n) {
2078
- return E(n) || n > this.resolve(e);
2079
- }
2080
- });
2081
- }
2082
- positive(e = J.positive) {
2083
- return this.moreThan(0, e);
2084
- }
2085
- negative(e = J.negative) {
2086
- return this.lessThan(0, e);
2087
- }
2088
- integer(e = J.integer) {
2089
- return this.test({
2090
- name: "integer",
2091
- message: e,
2092
- test: (r) => E(r) || Number.isInteger(r)
2093
- });
2094
- }
2095
- truncate() {
2096
- return this.transform((e) => E(e) ? e : e | 0);
2097
- }
2098
- round(e) {
2099
- var r;
2100
- let n = ["ceil", "floor", "round", "trunc"];
2101
- if (e = ((r = e) == null ? void 0 : r.toLowerCase()) || "round", e === "trunc")
2102
- return this.truncate();
2103
- if (n.indexOf(e.toLowerCase()) === -1)
2104
- throw new TypeError("Only valid options for round() are: " + n.join(", "));
2105
- return this.transform((a) => E(a) ? a : Math[e](a));
2106
- }
2107
- }
2108
- ue.prototype = fn.prototype;
2109
- var gp = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;
2110
- function _p(t) {
2111
- var e = [1, 4, 5, 6, 7, 10, 11], r = 0, n, a;
2112
- if (a = gp.exec(t)) {
2113
- for (var i = 0, s; s = e[i]; ++i)
2114
- a[s] = +a[s] || 0;
2115
- a[2] = (+a[2] || 1) - 1, a[3] = +a[3] || 1, a[7] = a[7] ? String(a[7]).substr(0, 3) : 0, (a[8] === void 0 || a[8] === "") && (a[9] === void 0 || a[9] === "") ? n = +new Date(a[1], a[2], a[3], a[4], a[5], a[6], a[7]) : (a[8] !== "Z" && a[9] !== void 0 && (r = a[10] * 60 + a[11], a[9] === "+" && (r = 0 - r)), n = Date.UTC(a[1], a[2], a[3], a[4], a[5] + r, a[6], a[7]));
2116
- } else
2117
- n = Date.parse ? Date.parse(t) : NaN;
2118
- return n;
2119
- }
2120
- let pn = /* @__PURE__ */ new Date(""), bp = (t) => Object.prototype.toString.call(t) === "[object Date]";
2121
- class hn extends I {
2122
- constructor() {
2123
- super({
2124
- type: "date"
2125
- }), this.withMutation(() => {
2126
- this.transform(function(e) {
2127
- return this.isType(e) ? e : (e = _p(e), isNaN(e) ? pn : new Date(e));
2128
- });
2129
- });
2130
- }
2131
- _typeCheck(e) {
2132
- return bp(e) && !isNaN(e.getTime());
2133
- }
2134
- prepareParam(e, r) {
2135
- let n;
2136
- if (Z.isRef(e))
2137
- n = e;
2138
- else {
2139
- let a = this.cast(e);
2140
- if (!this._typeCheck(a))
2141
- throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);
2142
- n = a;
2143
- }
2144
- return n;
2145
- }
2146
- min(e, r = rt.min) {
2147
- let n = this.prepareParam(e, "min");
2148
- return this.test({
2149
- message: r,
2150
- name: "min",
2151
- exclusive: !0,
2152
- params: {
2153
- min: e
2154
- },
2155
- test(a) {
2156
- return E(a) || a >= this.resolve(n);
2157
- }
2158
- });
2159
- }
2160
- max(e, r = rt.max) {
2161
- let n = this.prepareParam(e, "max");
2162
- return this.test({
2163
- message: r,
2164
- name: "max",
2165
- exclusive: !0,
2166
- params: {
2167
- max: e
2168
- },
2169
- test(a) {
2170
- return E(a) || a <= this.resolve(n);
2171
- }
2172
- });
2173
- }
2174
- }
2175
- hn.INVALID_DATE = pn;
2176
- hn.prototype;
2177
- function $p(t, e, r, n) {
2178
- var a = -1, i = t == null ? 0 : t.length;
2179
- for (n && i && (r = t[++a]); ++a < i; )
2180
- r = e(r, t[a], a, t);
2181
- return r;
2182
- }
2183
- var Sp = $p;
2184
- function Ap(t) {
2185
- return function(e) {
2186
- return t == null ? void 0 : t[e];
2187
- };
2188
- }
2189
- var wp = Ap, Ep = wp, xp = {
2190
- // Latin-1 Supplement block.
2191
- À: "A",
2192
- Á: "A",
2193
- Â: "A",
2194
- Ã: "A",
2195
- Ä: "A",
2196
- Å: "A",
2197
- à: "a",
2198
- á: "a",
2199
- â: "a",
2200
- ã: "a",
2201
- ä: "a",
2202
- å: "a",
2203
- Ç: "C",
2204
- ç: "c",
2205
- Ð: "D",
2206
- ð: "d",
2207
- È: "E",
2208
- É: "E",
2209
- Ê: "E",
2210
- Ë: "E",
2211
- è: "e",
2212
- é: "e",
2213
- ê: "e",
2214
- ë: "e",
2215
- Ì: "I",
2216
- Í: "I",
2217
- Î: "I",
2218
- Ï: "I",
2219
- ì: "i",
2220
- í: "i",
2221
- î: "i",
2222
- ï: "i",
2223
- Ñ: "N",
2224
- ñ: "n",
2225
- Ò: "O",
2226
- Ó: "O",
2227
- Ô: "O",
2228
- Õ: "O",
2229
- Ö: "O",
2230
- Ø: "O",
2231
- ò: "o",
2232
- ó: "o",
2233
- ô: "o",
2234
- õ: "o",
2235
- ö: "o",
2236
- ø: "o",
2237
- Ù: "U",
2238
- Ú: "U",
2239
- Û: "U",
2240
- Ü: "U",
2241
- ù: "u",
2242
- ú: "u",
2243
- û: "u",
2244
- ü: "u",
2245
- Ý: "Y",
2246
- ý: "y",
2247
- ÿ: "y",
2248
- Æ: "Ae",
2249
- æ: "ae",
2250
- Þ: "Th",
2251
- þ: "th",
2252
- ß: "ss",
2253
- // Latin Extended-A block.
2254
- Ā: "A",
2255
- Ă: "A",
2256
- Ą: "A",
2257
- ā: "a",
2258
- ă: "a",
2259
- ą: "a",
2260
- Ć: "C",
2261
- Ĉ: "C",
2262
- Ċ: "C",
2263
- Č: "C",
2264
- ć: "c",
2265
- ĉ: "c",
2266
- ċ: "c",
2267
- č: "c",
2268
- Ď: "D",
2269
- Đ: "D",
2270
- ď: "d",
2271
- đ: "d",
2272
- Ē: "E",
2273
- Ĕ: "E",
2274
- Ė: "E",
2275
- Ę: "E",
2276
- Ě: "E",
2277
- ē: "e",
2278
- ĕ: "e",
2279
- ė: "e",
2280
- ę: "e",
2281
- ě: "e",
2282
- Ĝ: "G",
2283
- Ğ: "G",
2284
- Ġ: "G",
2285
- Ģ: "G",
2286
- ĝ: "g",
2287
- ğ: "g",
2288
- ġ: "g",
2289
- ģ: "g",
2290
- Ĥ: "H",
2291
- Ħ: "H",
2292
- ĥ: "h",
2293
- ħ: "h",
2294
- Ĩ: "I",
2295
- Ī: "I",
2296
- Ĭ: "I",
2297
- Į: "I",
2298
- İ: "I",
2299
- ĩ: "i",
2300
- ī: "i",
2301
- ĭ: "i",
2302
- į: "i",
2303
- ı: "i",
2304
- Ĵ: "J",
2305
- ĵ: "j",
2306
- Ķ: "K",
2307
- ķ: "k",
2308
- ĸ: "k",
2309
- Ĺ: "L",
2310
- Ļ: "L",
2311
- Ľ: "L",
2312
- Ŀ: "L",
2313
- Ł: "L",
2314
- ĺ: "l",
2315
- ļ: "l",
2316
- ľ: "l",
2317
- ŀ: "l",
2318
- ł: "l",
2319
- Ń: "N",
2320
- Ņ: "N",
2321
- Ň: "N",
2322
- Ŋ: "N",
2323
- ń: "n",
2324
- ņ: "n",
2325
- ň: "n",
2326
- ŋ: "n",
2327
- Ō: "O",
2328
- Ŏ: "O",
2329
- Ő: "O",
2330
- ō: "o",
2331
- ŏ: "o",
2332
- ő: "o",
2333
- Ŕ: "R",
2334
- Ŗ: "R",
2335
- Ř: "R",
2336
- ŕ: "r",
2337
- ŗ: "r",
2338
- ř: "r",
2339
- Ś: "S",
2340
- Ŝ: "S",
2341
- Ş: "S",
2342
- Š: "S",
2343
- ś: "s",
2344
- ŝ: "s",
2345
- ş: "s",
2346
- š: "s",
2347
- Ţ: "T",
2348
- Ť: "T",
2349
- Ŧ: "T",
2350
- ţ: "t",
2351
- ť: "t",
2352
- ŧ: "t",
2353
- Ũ: "U",
2354
- Ū: "U",
2355
- Ŭ: "U",
2356
- Ů: "U",
2357
- Ű: "U",
2358
- Ų: "U",
2359
- ũ: "u",
2360
- ū: "u",
2361
- ŭ: "u",
2362
- ů: "u",
2363
- ű: "u",
2364
- ų: "u",
2365
- Ŵ: "W",
2366
- ŵ: "w",
2367
- Ŷ: "Y",
2368
- ŷ: "y",
2369
- Ÿ: "Y",
2370
- Ź: "Z",
2371
- Ż: "Z",
2372
- Ž: "Z",
2373
- ź: "z",
2374
- ż: "z",
2375
- ž: "z",
2376
- IJ: "IJ",
2377
- ij: "ij",
2378
- Œ: "Oe",
2379
- œ: "oe",
2380
- ʼn: "'n",
2381
- ſ: "s"
2382
- }, Tp = Ep(xp), Fp = Tp, Op = Fp, Cp = Ee, Ip = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Pp = "\\u0300-\\u036f", Np = "\\ufe20-\\ufe2f", Dp = "\\u20d0-\\u20ff", Rp = Pp + Np + Dp, Mp = "[" + Rp + "]", qp = RegExp(Mp, "g");
2383
- function Lp(t) {
2384
- return t = Cp(t), t && t.replace(Ip, Op).replace(qp, "");
2385
- }
2386
- var Up = Lp, jp = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
2387
- function zp(t) {
2388
- return t.match(jp) || [];
2389
- }
2390
- var Gp = zp, kp = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
2391
- function Vp(t) {
2392
- return kp.test(t);
2393
- }
2394
- var Bp = Vp, mn = "\\ud800-\\udfff", Kp = "\\u0300-\\u036f", Wp = "\\ufe20-\\ufe2f", Jp = "\\u20d0-\\u20ff", Zp = Kp + Wp + Jp, yn = "\\u2700-\\u27bf", vn = "a-z\\xdf-\\xf6\\xf8-\\xff", Yp = "\\xac\\xb1\\xd7\\xf7", Xp = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Qp = "\\u2000-\\u206f", Hp = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", gn = "A-Z\\xc0-\\xd6\\xd8-\\xde", eh = "\\ufe0e\\ufe0f", _n = Yp + Xp + Qp + Hp, bn = "['’]", vr = "[" + _n + "]", th = "[" + Zp + "]", $n = "\\d+", rh = "[" + yn + "]", Sn = "[" + vn + "]", An = "[^" + mn + _n + $n + yn + vn + gn + "]", nh = "\\ud83c[\\udffb-\\udfff]", ah = "(?:" + th + "|" + nh + ")", ih = "[^" + mn + "]", wn = "(?:\\ud83c[\\udde6-\\uddff]){2}", En = "[\\ud800-\\udbff][\\udc00-\\udfff]", se = "[" + gn + "]", sh = "\\u200d", gr = "(?:" + Sn + "|" + An + ")", oh = "(?:" + se + "|" + An + ")", _r = "(?:" + bn + "(?:d|ll|m|re|s|t|ve))?", br = "(?:" + bn + "(?:D|LL|M|RE|S|T|VE))?", xn = ah + "?", Tn = "[" + eh + "]?", uh = "(?:" + sh + "(?:" + [ih, wn, En].join("|") + ")" + Tn + xn + ")*", ch = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", lh = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", dh = Tn + xn + uh, fh = "(?:" + [rh, wn, En].join("|") + ")" + dh, ph = RegExp([
2395
- se + "?" + Sn + "+" + _r + "(?=" + [vr, se, "$"].join("|") + ")",
2396
- oh + "+" + br + "(?=" + [vr, se + gr, "$"].join("|") + ")",
2397
- se + "?" + gr + "+" + _r,
2398
- se + "+" + br,
2399
- lh,
2400
- ch,
2401
- $n,
2402
- fh
2403
- ].join("|"), "g");
2404
- function hh(t) {
2405
- return t.match(ph) || [];
2406
- }
2407
- var mh = hh, yh = Gp, vh = Bp, gh = Ee, _h = mh;
2408
- function bh(t, e, r) {
2409
- return t = gh(t), e = r ? void 0 : e, e === void 0 ? vh(t) ? _h(t) : yh(t) : t.match(e) || [];
2410
- }
2411
- var $h = bh, Sh = Sp, Ah = Up, wh = $h, Eh = "['’]", xh = RegExp(Eh, "g");
2412
- function Th(t) {
2413
- return function(e) {
2414
- return Sh(wh(Ah(e).replace(xh, "")), t, "");
2415
- };
2416
- }
2417
- var Fn = Th, Fh = Fn, Oh = Fh(function(t, e, r) {
2418
- return t + (r ? "_" : "") + e.toLowerCase();
2419
- }), Ch = Oh;
2420
- const $r = /* @__PURE__ */ le(Ch);
2421
- function Ih(t, e, r) {
2422
- var n = -1, a = t.length;
2423
- e < 0 && (e = -e > a ? 0 : a + e), r = r > a ? a : r, r < 0 && (r += a), a = e > r ? 0 : r - e >>> 0, e >>>= 0;
2424
- for (var i = Array(a); ++n < a; )
2425
- i[n] = t[n + e];
2426
- return i;
2427
- }
2428
- var Ph = Ih, Nh = Ph;
2429
- function Dh(t, e, r) {
2430
- var n = t.length;
2431
- return r = r === void 0 ? n : r, !e && r >= n ? t : Nh(t, e, r);
2432
- }
2433
- var Rh = Dh, Mh = "\\ud800-\\udfff", qh = "\\u0300-\\u036f", Lh = "\\ufe20-\\ufe2f", Uh = "\\u20d0-\\u20ff", jh = qh + Lh + Uh, zh = "\\ufe0e\\ufe0f", Gh = "\\u200d", kh = RegExp("[" + Gh + Mh + jh + zh + "]");
2434
- function Vh(t) {
2435
- return kh.test(t);
2436
- }
2437
- var On = Vh;
2438
- function Bh(t) {
2439
- return t.split("");
2440
- }
2441
- var Kh = Bh, Cn = "\\ud800-\\udfff", Wh = "\\u0300-\\u036f", Jh = "\\ufe20-\\ufe2f", Zh = "\\u20d0-\\u20ff", Yh = Wh + Jh + Zh, Xh = "\\ufe0e\\ufe0f", Qh = "[" + Cn + "]", ft = "[" + Yh + "]", pt = "\\ud83c[\\udffb-\\udfff]", Hh = "(?:" + ft + "|" + pt + ")", In = "[^" + Cn + "]", Pn = "(?:\\ud83c[\\udde6-\\uddff]){2}", Nn = "[\\ud800-\\udbff][\\udc00-\\udfff]", em = "\\u200d", Dn = Hh + "?", Rn = "[" + Xh + "]?", tm = "(?:" + em + "(?:" + [In, Pn, Nn].join("|") + ")" + Rn + Dn + ")*", rm = Rn + Dn + tm, nm = "(?:" + [In + ft + "?", ft, Pn, Nn, Qh].join("|") + ")", am = RegExp(pt + "(?=" + pt + ")|" + nm + rm, "g");
2442
- function im(t) {
2443
- return t.match(am) || [];
2444
- }
2445
- var sm = im, om = Kh, um = On, cm = sm;
2446
- function lm(t) {
2447
- return um(t) ? cm(t) : om(t);
2448
- }
2449
- var dm = lm, fm = Rh, pm = On, hm = dm, mm = Ee;
2450
- function ym(t) {
2451
- return function(e) {
2452
- e = mm(e);
2453
- var r = pm(e) ? hm(e) : void 0, n = r ? r[0] : e.charAt(0), a = r ? fm(r, 1).join("") : e.slice(1);
2454
- return n[t]() + a;
2455
- };
2456
- }
2457
- var vm = ym, gm = vm, _m = gm("toUpperCase"), bm = _m, $m = Ee, Sm = bm;
2458
- function Am(t) {
2459
- return Sm($m(t).toLowerCase());
2460
- }
2461
- var wm = Am, Em = wm, xm = Fn, Tm = xm(function(t, e, r) {
2462
- return e = e.toLowerCase(), t + (r ? Em(e) : e);
2463
- }), Fm = Tm;
2464
- const Om = /* @__PURE__ */ le(Fm);
2465
- var Cm = Wr, Im = Yr, Pm = sn;
2466
- function Nm(t, e) {
2467
- var r = {};
2468
- return e = Pm(e), Im(t, function(n, a, i) {
2469
- Cm(r, e(n, a, i), n);
2470
- }), r;
2471
- }
2472
- var Dm = Nm;
2473
- const Rm = /* @__PURE__ */ le(Dm);
2474
- var Tt = { exports: {} };
2475
- Tt.exports = function(t) {
2476
- return Mn(Mm(t), t);
2477
- };
2478
- Tt.exports.array = Mn;
2479
- function Mn(t, e) {
2480
- var r = t.length, n = new Array(r), a = {}, i = r, s = qm(e), o = Lm(t);
2481
- for (e.forEach(function(c) {
2482
- if (!o.has(c[0]) || !o.has(c[1]))
2483
- throw new Error("Unknown node. There is an unknown node in the supplied edges.");
2484
- }); i--; )
2485
- a[i] || u(t[i], i, /* @__PURE__ */ new Set());
2486
- return n;
2487
- function u(c, l, d) {
2488
- if (d.has(c)) {
2489
- var p;
2490
- try {
2491
- p = ", node was:" + JSON.stringify(c);
2492
- } catch {
2493
- p = "";
2494
- }
2495
- throw new Error("Cyclic dependency" + p);
2496
- }
2497
- if (!o.has(c))
2498
- throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: " + JSON.stringify(c));
2499
- if (!a[l]) {
2500
- a[l] = !0;
2501
- var h = s.get(c) || /* @__PURE__ */ new Set();
2502
- if (h = Array.from(h), l = h.length) {
2503
- d.add(c);
2504
- do {
2505
- var y = h[--l];
2506
- u(y, o.get(y), d);
2507
- } while (l);
2508
- d.delete(c);
2509
- }
2510
- n[--r] = c;
2511
- }
2512
- }
2513
- }
2514
- function Mm(t) {
2515
- for (var e = /* @__PURE__ */ new Set(), r = 0, n = t.length; r < n; r++) {
2516
- var a = t[r];
2517
- e.add(a[0]), e.add(a[1]);
2518
- }
2519
- return Array.from(e);
2520
- }
2521
- function qm(t) {
2522
- for (var e = /* @__PURE__ */ new Map(), r = 0, n = t.length; r < n; r++) {
2523
- var a = t[r];
2524
- e.has(a[0]) || e.set(a[0], /* @__PURE__ */ new Set()), e.has(a[1]) || e.set(a[1], /* @__PURE__ */ new Set()), e.get(a[0]).add(a[1]);
2525
- }
2526
- return e;
2527
- }
2528
- function Lm(t) {
2529
- for (var e = /* @__PURE__ */ new Map(), r = 0, n = t.length; r < n; r++)
2530
- e.set(t[r], r);
2531
- return e;
2532
- }
2533
- var Um = Tt.exports;
2534
- const jm = /* @__PURE__ */ le(Um);
2535
- function zm(t, e = []) {
2536
- let r = [], n = /* @__PURE__ */ new Set(), a = new Set(e.map(([s, o]) => `${s}-${o}`));
2537
- function i(s, o) {
2538
- let u = We.split(s)[0];
2539
- n.add(u), a.has(`${o}-${u}`) || r.push([o, u]);
2540
- }
2541
- for (const s in t)
2542
- if (Ne(t, s)) {
2543
- let o = t[s];
2544
- n.add(s), Z.isRef(o) && o.isSibling ? i(o.path, s) : At(o) && "deps" in o && o.deps.forEach((u) => i(u, s));
2545
- }
2546
- return jm.array(Array.from(n), r).reverse();
2547
- }
2548
- function Sr(t, e) {
2549
- let r = 1 / 0;
2550
- return t.some((n, a) => {
2551
- var i;
2552
- if (((i = e.path) == null ? void 0 : i.indexOf(n)) !== -1)
2553
- return r = a, !0;
2554
- }), r;
2555
- }
2556
- function qn(t) {
2557
- return (e, r) => Sr(t, e) - Sr(t, r);
2558
- }
2559
- function oe() {
2560
- return oe = Object.assign || function(t) {
2561
- for (var e = 1; e < arguments.length; e++) {
2562
- var r = arguments[e];
2563
- for (var n in r)
2564
- Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
2565
- }
2566
- return t;
2567
- }, oe.apply(this, arguments);
2568
- }
2569
- let Ar = (t) => Object.prototype.toString.call(t) === "[object Object]";
2570
- function Gm(t, e) {
2571
- let r = Object.keys(t.fields);
2572
- return Object.keys(e).filter((n) => r.indexOf(n) === -1);
2573
- }
2574
- const km = qn([]);
2575
- class Ln extends I {
2576
- constructor(e) {
2577
- super({
2578
- type: "object"
2579
- }), this.fields = /* @__PURE__ */ Object.create(null), this._sortErrors = km, this._nodes = [], this._excludedEdges = [], this.withMutation(() => {
2580
- this.transform(function(n) {
2581
- if (typeof n == "string")
2582
- try {
2583
- n = JSON.parse(n);
2584
- } catch {
2585
- n = null;
2586
- }
2587
- return this.isType(n) ? n : null;
2588
- }), e && this.shape(e);
2589
- });
2590
- }
2591
- _typeCheck(e) {
2592
- return Ar(e) || typeof e == "function";
2593
- }
2594
- _cast(e, r = {}) {
2595
- var n;
2596
- let a = super._cast(e, r);
2597
- if (a === void 0)
2598
- return this.getDefault();
2599
- if (!this._typeCheck(a))
2600
- return a;
2601
- let i = this.fields, s = (n = r.stripUnknown) != null ? n : this.spec.noUnknown, o = this._nodes.concat(Object.keys(a).filter((d) => this._nodes.indexOf(d) === -1)), u = {}, c = oe({}, r, {
2602
- parent: u,
2603
- __validating: r.__validating || !1
2604
- }), l = !1;
2605
- for (const d of o) {
2606
- let p = i[d], h = Ne(a, d);
2607
- if (p) {
2608
- let y, v = a[d];
2609
- c.path = (r.path ? `${r.path}.` : "") + d, p = p.resolve({
2610
- value: v,
2611
- context: r.context,
2612
- parent: u
2613
- });
2614
- let _ = "spec" in p ? p.spec : void 0, $ = _ == null ? void 0 : _.strict;
2615
- if (_ != null && _.strip) {
2616
- l = l || d in a;
2617
- continue;
2618
- }
2619
- y = !r.__validating || !$ ? (
2620
- // TODO: use _cast, this is double resolving
2621
- p.cast(a[d], c)
2622
- ) : a[d], y !== void 0 && (u[d] = y);
2623
- } else
2624
- h && !s && (u[d] = a[d]);
2625
- u[d] !== a[d] && (l = !0);
2626
- }
2627
- return l ? u : a;
2628
- }
2629
- _validate(e, r = {}, n) {
2630
- let a = [], {
2631
- sync: i,
2632
- from: s = [],
2633
- originalValue: o = e,
2634
- abortEarly: u = this.spec.abortEarly,
2635
- recursive: c = this.spec.recursive
2636
- } = r;
2637
- s = [{
2638
- schema: this,
2639
- value: o
2640
- }, ...s], r.__validating = !0, r.originalValue = o, r.from = s, super._validate(e, r, (l, d) => {
2641
- if (l) {
2642
- if (!D.isError(l) || u)
2643
- return void n(l, d);
2644
- a.push(l);
2645
- }
2646
- if (!c || !Ar(d)) {
2647
- n(a[0] || null, d);
2648
- return;
2649
- }
2650
- o = o || d;
2651
- let p = this._nodes.map((h) => (y, v) => {
2652
- let _ = h.indexOf(".") === -1 ? (r.path ? `${r.path}.` : "") + h : `${r.path || ""}["${h}"]`, $ = this.fields[h];
2653
- if ($ && "validate" in $) {
2654
- $.validate(d[h], oe({}, r, {
2655
- // @ts-ignore
2656
- path: _,
2657
- from: s,
2658
- // inner fields are always strict:
2659
- // 1. this isn't strict so the casting will also have cast inner values
2660
- // 2. this is strict in which case the nested values weren't cast either
2661
- strict: !0,
2662
- parent: d,
2663
- originalValue: o[h]
2664
- }), v);
2665
- return;
2666
- }
2667
- v(null);
2668
- });
2669
- De({
2670
- sync: i,
2671
- tests: p,
2672
- value: d,
2673
- errors: a,
2674
- endEarly: u,
2675
- sort: this._sortErrors,
2676
- path: r.path
2677
- }, n);
2678
- });
2679
- }
2680
- clone(e) {
2681
- const r = super.clone(e);
2682
- return r.fields = oe({}, this.fields), r._nodes = this._nodes, r._excludedEdges = this._excludedEdges, r._sortErrors = this._sortErrors, r;
2683
- }
2684
- concat(e) {
2685
- let r = super.concat(e), n = r.fields;
2686
- for (let [a, i] of Object.entries(this.fields)) {
2687
- const s = n[a];
2688
- s === void 0 ? n[a] = i : s instanceof I && i instanceof I && (n[a] = i.concat(s));
2689
- }
2690
- return r.withMutation(() => r.shape(n, this._excludedEdges));
2691
- }
2692
- getDefaultFromShape() {
2693
- let e = {};
2694
- return this._nodes.forEach((r) => {
2695
- const n = this.fields[r];
2696
- e[r] = "default" in n ? n.getDefault() : void 0;
2697
- }), e;
2698
- }
2699
- _getDefault() {
2700
- if ("default" in this.spec)
2701
- return super._getDefault();
2702
- if (this._nodes.length)
2703
- return this.getDefaultFromShape();
2704
- }
2705
- shape(e, r = []) {
2706
- let n = this.clone(), a = Object.assign(n.fields, e);
2707
- return n.fields = a, n._sortErrors = qn(Object.keys(a)), r.length && (Array.isArray(r[0]) || (r = [r]), n._excludedEdges = [...n._excludedEdges, ...r]), n._nodes = zm(a, n._excludedEdges), n;
2708
- }
2709
- pick(e) {
2710
- const r = {};
2711
- for (const n of e)
2712
- this.fields[n] && (r[n] = this.fields[n]);
2713
- return this.clone().withMutation((n) => (n.fields = {}, n.shape(r)));
2714
- }
2715
- omit(e) {
2716
- const r = this.clone(), n = r.fields;
2717
- r.fields = {};
2718
- for (const a of e)
2719
- delete n[a];
2720
- return r.withMutation(() => r.shape(n));
2721
- }
2722
- from(e, r, n) {
2723
- let a = We.getter(e, !0);
2724
- return this.transform((i) => {
2725
- if (i == null)
2726
- return i;
2727
- let s = i;
2728
- return Ne(i, e) && (s = oe({}, i), n || delete s[e], s[r] = a(i)), s;
2729
- });
2730
- }
2731
- noUnknown(e = !0, r = at.noUnknown) {
2732
- typeof e == "string" && (r = e, e = !0);
2733
- let n = this.test({
2734
- name: "noUnknown",
2735
- exclusive: !0,
2736
- message: r,
2737
- test(a) {
2738
- if (a == null)
2739
- return !0;
2740
- const i = Gm(this.schema, a);
2741
- return !e || i.length === 0 || this.createError({
2742
- params: {
2743
- unknown: i.join(", ")
2744
- }
2745
- });
2746
- }
2747
- });
2748
- return n.spec.noUnknown = e, n;
2749
- }
2750
- unknown(e = !0, r = at.noUnknown) {
2751
- return this.noUnknown(!e, r);
2752
- }
2753
- transformKeys(e) {
2754
- return this.transform((r) => r && Rm(r, (n, a) => e(a)));
2755
- }
2756
- camelCase() {
2757
- return this.transformKeys(Om);
2758
- }
2759
- snakeCase() {
2760
- return this.transformKeys($r);
2761
- }
2762
- constantCase() {
2763
- return this.transformKeys((e) => $r(e).toUpperCase());
2764
- }
2765
- describe() {
2766
- let e = super.describe();
2767
- return e.fields = on(this.fields, (r) => r.describe()), e;
2768
- }
2769
- }
2770
- function m(t) {
2771
- return new Ln(t);
2772
- }
2773
- m.prototype = Ln.prototype;
2774
- function je() {
2775
- return je = Object.assign || function(t) {
2776
- for (var e = 1; e < arguments.length; e++) {
2777
- var r = arguments[e];
2778
- for (var n in r)
2779
- Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
2780
- }
2781
- return t;
2782
- }, je.apply(this, arguments);
2783
- }
2784
- function V(t) {
2785
- return new Un(t);
2786
- }
2787
- class Un extends I {
2788
- constructor(e) {
2789
- super({
2790
- type: "array"
2791
- }), this.innerType = void 0, this.innerType = e, this.withMutation(() => {
2792
- this.transform(function(r) {
2793
- if (typeof r == "string")
2794
- try {
2795
- r = JSON.parse(r);
2796
- } catch {
2797
- r = null;
2798
- }
2799
- return this.isType(r) ? r : null;
2800
- });
2801
- });
2802
- }
2803
- _typeCheck(e) {
2804
- return Array.isArray(e);
2805
- }
2806
- get _subType() {
2807
- return this.innerType;
2808
- }
2809
- _cast(e, r) {
2810
- const n = super._cast(e, r);
2811
- if (!this._typeCheck(n) || !this.innerType)
2812
- return n;
2813
- let a = !1;
2814
- const i = n.map((s, o) => {
2815
- const u = this.innerType.cast(s, je({}, r, {
2816
- path: `${r.path || ""}[${o}]`
2817
- }));
2818
- return u !== s && (a = !0), u;
2819
- });
2820
- return a ? i : n;
2821
- }
2822
- _validate(e, r = {}, n) {
2823
- var a, i;
2824
- let s = [], o = r.sync, u = r.path, c = this.innerType, l = (a = r.abortEarly) != null ? a : this.spec.abortEarly, d = (i = r.recursive) != null ? i : this.spec.recursive, p = r.originalValue != null ? r.originalValue : e;
2825
- super._validate(e, r, (h, y) => {
2826
- if (h) {
2827
- if (!D.isError(h) || l)
2828
- return void n(h, y);
2829
- s.push(h);
2830
- }
2831
- if (!d || !c || !this._typeCheck(y)) {
2832
- n(s[0] || null, y);
2833
- return;
2834
- }
2835
- p = p || y;
2836
- let v = new Array(y.length);
2837
- for (let _ = 0; _ < y.length; _++) {
2838
- let $ = y[_], A = `${r.path || ""}[${_}]`, T = je({}, r, {
2839
- path: A,
2840
- strict: !0,
2841
- parent: y,
2842
- index: _,
2843
- originalValue: p[_]
2844
- });
2845
- v[_] = (P, b) => c.validate($, T, b);
2846
- }
2847
- De({
2848
- sync: o,
2849
- path: u,
2850
- value: y,
2851
- errors: s,
2852
- endEarly: l,
2853
- tests: v
2854
- }, n);
2855
- });
2856
- }
2857
- clone(e) {
2858
- const r = super.clone(e);
2859
- return r.innerType = this.innerType, r;
2860
- }
2861
- concat(e) {
2862
- let r = super.concat(e);
2863
- return r.innerType = this.innerType, e.innerType && (r.innerType = r.innerType ? (
2864
- // @ts-expect-error Lazy doesn't have concat()
2865
- r.innerType.concat(e.innerType)
2866
- ) : e.innerType), r;
2867
- }
2868
- of(e) {
2869
- let r = this.clone();
2870
- if (!At(e))
2871
- throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + ce(e));
2872
- return r.innerType = e, r;
2873
- }
2874
- length(e, r = Ie.length) {
2875
- return this.test({
2876
- message: r,
2877
- name: "length",
2878
- exclusive: !0,
2879
- params: {
2880
- length: e
2881
- },
2882
- test(n) {
2883
- return E(n) || n.length === this.resolve(e);
2884
- }
2885
- });
2886
- }
2887
- min(e, r) {
2888
- return r = r || Ie.min, this.test({
2889
- message: r,
2890
- name: "min",
2891
- exclusive: !0,
2892
- params: {
2893
- min: e
2894
- },
2895
- // FIXME(ts): Array<typeof T>
2896
- test(n) {
2897
- return E(n) || n.length >= this.resolve(e);
2898
- }
2899
- });
2900
- }
2901
- max(e, r) {
2902
- return r = r || Ie.max, this.test({
2903
- message: r,
2904
- name: "max",
2905
- exclusive: !0,
2906
- params: {
2907
- max: e
2908
- },
2909
- test(n) {
2910
- return E(n) || n.length <= this.resolve(e);
2911
- }
2912
- });
2913
- }
2914
- ensure() {
2915
- return this.default(() => []).transform((e, r) => this._typeCheck(e) ? e : r == null ? [] : [].concat(r));
2916
- }
2917
- compact(e) {
2918
- let r = e ? (n, a, i) => !e(n, a, i) : (n) => !!n;
2919
- return this.transform((n) => n != null ? n.filter(r) : n);
2920
- }
2921
- describe() {
2922
- let e = super.describe();
2923
- return this.innerType && (e.innerType = this.innerType.describe()), e;
2924
- }
2925
- nullable(e = !0) {
2926
- return super.nullable(e);
2927
- }
2928
- defined() {
2929
- return super.defined();
2930
- }
2931
- required(e) {
2932
- return super.required(e);
2933
- }
2934
- }
2935
- V.prototype = Un.prototype;
2936
- const wr = V().of(
2937
- m().shape({
2938
- variantId: f().required(),
2939
- productId: f().nullable(),
2940
- quantity: ue().required(),
2941
- sellingPlanId: f().nullable(),
2942
- attributes: V().of(
2943
- m().shape({
2944
- key: f().required(),
2945
- value: f().required()
2946
- })
2947
- ).nullable()
2948
- })
2949
- ), jn = m().shape({
2950
- key: f().required(),
2951
- value: f().required()
2952
- }), Vm = m().shape({
2953
- attributes: V().max(255).of(jn).required()
2954
- }), Bm = m().shape({
2955
- note: f()
2956
- }), Km = m().shape({
2957
- vaultKey: f().required(),
2958
- scope: f()
2959
- }), Wm = m().shape({
2960
- vaultKey: f().required(),
2961
- key: f().required()
2962
- }), Jm = m().shape({
2963
- vaultKey: f().required(),
2964
- key: f().required(),
2965
- value: f()
2966
- }), Zm = m().shape({
2967
- vaultKey: f().required(),
2968
- key: f().required()
2969
- }), Ym = m().shape({
2970
- vaultKey: f().required()
2971
- }), Xm = m().shape({
2972
- vaultKey: f().required()
2973
- }), Qm = m().shape({
2974
- vaultKey: f().required(),
2975
- key: f().required()
2976
- }), Hm = m().shape({
2977
- productId: f().required(),
2978
- variantId: f().required()
2979
- }), ey = V().of(
2980
- m().shape({
2981
- id: f().required(),
2982
- name: f().required(),
2983
- variants: V().of(Hm).required()
2984
- })
2985
- ), ty = m().shape({ name: f().required().min(3) }), ry = f().required(), ny = m().shape({
2986
- productId: f().required(),
2987
- variantId: f().required(),
2988
- wishlistId: f().required()
2989
- }), ay = ve().required().isTrue(), iy = m().shape({
2990
- productId: f().required(),
2991
- variantId: f().required(),
2992
- wishlistId: f().required()
2993
- }), sy = ve().required().isTrue(), oy = m().shape({
2994
- action: f().oneOf(["login", "create"], 'action must be either "login" or "create".').notRequired()
2995
- }).notRequired(), uy = ve().required().isTrue(), cy = m().shape({
2996
- appId: f().optional()
2997
- }).nullable(), ly = V().of(ye()).nullable(), dy = m().shape({
2998
- appId: f().optional()
2999
- }).nullable(), fy = V().of(ye()).nullable(), py = m().shape({
3000
- appId: f().optional(),
3001
- email: f().optional()
3002
- }).nullable(), hy = ye().nullable(), my = m({
3003
- appId: f().optional(),
3004
- rewardId: ue().required(),
3005
- options: m().shape({}).optional()
3006
- }), yy = m().shape({
3007
- appId: f().optional(),
3008
- activityName: f().required(),
3009
- activityType: f().optional(),
3010
- activityUrl: f().optional()
3011
- }).nullable(), vy = m().shape({}), gy = m().shape({}).nullable(), _y = m().shape({
3012
- appId: f().optional()
3013
- }).nullable(), by = V().of(ye()).nullable(), $y = m().shape({
3014
- appId: f().optional()
3015
- }).nullable(), Sy = ye().nullable(), ht = (t) => typeof t == "function" ? !1 : typeof t == "object" && t !== null ? !Object.values(t).some((e) => !ht(e)) : !0, Ay = (t) => {
3016
- if (typeof t == "string")
3017
- try {
3018
- JSON.parse(t);
3019
- } catch {
3020
- return !1;
3021
- }
3022
- return typeof t == "object" && t !== null || Array.isArray(t) ? ht(t) : !1;
3023
- }, wy = m().shape({
3024
- analyticEvent: f().required(),
3025
- analyticProperties: m().test("is-json", "Field must be a valid JSON object or array", Ay).required()
3026
- }), Ey = ve().required().isTrue();
3027
- m().shape({
3028
- firstName: f().required(),
3029
- lastName: f().required(),
3030
- address1: f().required(),
3031
- address2: f(),
3032
- city: f().required(),
3033
- province: f().required(),
3034
- country: f().required(),
3035
- zip: f().required(),
3036
- phone: f()
3037
- });
3038
- const xy = m().shape({
3039
- discountCode: f().required()
3040
- }), Ty = m().shape({
3041
- cartId: f().required(),
3042
- appId: f().required()
3043
- }), Fy = m().shape({
3044
- giftCardId: f().required(),
3045
- cartId: f().required(),
3046
- appId: f().required()
3047
- }), Oy = m().shape({
3048
- giftCardCode: f().required(),
3049
- cartId: f().required(),
3050
- appId: f().required()
3051
- }), Cy = m().shape({
3052
- hostname: f().required()
3053
- }), Iy = m().shape({
3054
- hostname: f().required()
3055
- }), Py = m().shape({
3056
- cartId: f().required(),
3057
- payment: m().required(),
3058
- appId: f().required()
3059
- }), Ny = m().shape({
3060
- cartId: f().required(),
3061
- shippingContact: m().required(),
3062
- displayName: f().required(),
3063
- appId: f().required()
3064
- }), Dy = m().shape({
3065
- cartId: f().required(),
3066
- paymentMethod: m().required(),
3067
- displayName: f().required(),
3068
- appId: f().required()
3069
- }), Ry = m().shape({
3070
- cartId: f().required(),
3071
- shippingMethod: m().required(),
3072
- displayName: f().required(),
3073
- appId: f().required()
3074
- }), My = (t) => {
3075
- try {
3076
- return !!new URL(t);
3077
- } catch {
3078
- return !1;
3079
- }
3080
- }, zn = [
3081
- {
3082
- functionName: "addToCart",
3083
- actionName: "cart/add",
3084
- schema: m().shape({
3085
- cartAttributes: V().of(jn),
3086
- lineItems: wr
3087
- })
3088
- },
3089
- {
3090
- functionName: "applyDiscount",
3091
- actionName: "discount/apply",
3092
- schema: m().shape({
3093
- discountCode: f().required()
3094
- })
3095
- },
3096
- {
3097
- functionName: "removeDiscounts",
3098
- actionName: "discount/remove/all",
3099
- schema: null
3100
- },
3101
- {
3102
- functionName: "removeDiscount",
3103
- actionName: "discount/remove",
3104
- schema: xy
3105
- },
3106
- {
3107
- functionName: "applyGiftCard",
3108
- actionName: "giftcard/apply",
3109
- schema: Oy
3110
- },
3111
- {
3112
- functionName: "removeGiftCard",
3113
- actionName: "giftcard/remove",
3114
- schema: Fy
3115
- },
3116
- {
3117
- functionName: "getGiftCard",
3118
- actionName: "giftcard/get",
3119
- schema: Ty
3120
- },
3121
- {
3122
- functionName: "openCart",
3123
- actionName: "cart/open",
3124
- schema: null
3125
- },
3126
- {
3127
- functionName: "authenticationOpen",
3128
- actionName: "authentication/open",
3129
- schema: oy,
3130
- successSchema: uy
3131
- },
3132
- {
3133
- functionName: "openCollection",
3134
- actionName: "collection/open",
3135
- schema: m().shape({
3136
- collectionId: f().required()
3137
- })
3138
- },
3139
- {
3140
- functionName: "openProduct",
3141
- actionName: "product/open",
3142
- schema: m().shape({
3143
- productId: f().required(),
3144
- variantId: f(),
3145
- isRelatedProduct: ve()
3146
- })
3147
- },
3148
- {
3149
- functionName: "showToast",
3150
- actionName: "app/toast",
3151
- schema: m().shape({
3152
- message: f().required(),
3153
- type: f().required().oneOf(["success", "warning", "error"])
3154
- })
3155
- },
3156
- {
3157
- functionName: "updateView",
3158
- actionName: "view/updated",
3159
- schema: m().shape({
3160
- height: ue().required(),
3161
- width: ue().required(),
3162
- multiplier: ue().required()
3163
- })
3164
- },
3165
- {
3166
- functionName: "getCustomerIdentity",
3167
- actionName: "customer/identity",
3168
- schema: null
3169
- },
3170
- {
3171
- functionName: "renderView",
3172
- actionName: "view/rendered",
3173
- schema: null
3174
- },
3175
- {
3176
- functionName: "openScreen",
3177
- actionName: "screen/open",
3178
- schema: m().shape({
3179
- destination: m().shape({
3180
- type: f().oneOf(
3181
- ["internal", "web"],
3182
- 'Type must be either "internal" or "web".'
3183
- ).required("Type is required."),
3184
- url: f().test("valid-url", "URL is not valid.", function(t) {
3185
- const { type: e } = this.parent;
3186
- return e === "internal" ? !0 : e === "web" ? My(t) : !1;
3187
- }).required("URL is required.")
3188
- }).required("Destination is required.")
3189
- })
3190
- },
3191
- {
3192
- functionName: "scrollToBlockTop",
3193
- actionName: "view/scrollToBlockTop",
3194
- schema: null
3195
- },
3196
- {
3197
- functionName: "scrollToBlockBottom",
3198
- actionName: "view/scrollToBlockBottom",
3199
- schema: null
3200
- },
3201
- {
3202
- functionName: "removeFromCart",
3203
- actionName: "cart/remove",
3204
- schema: m().shape({
3205
- lineItems: wr
3206
- })
3207
- },
3208
- {
3209
- functionName: "trackAnalyticEvent",
3210
- actionName: "analytics/track",
3211
- schema: wy,
3212
- successSchema: Ey
3213
- },
3214
- {
3215
- functionName: "updateCartAttributes",
3216
- actionName: "cart/updateAttributes",
3217
- schema: Vm
3218
- },
3219
- {
3220
- functionName: "updateCartNote",
3221
- actionName: "cart/updateNote",
3222
- schema: Bm
3223
- },
3224
- {
3225
- functionName: "vaultInitialize",
3226
- actionName: "vault/initialize",
3227
- schema: Km
3228
- },
3229
- {
3230
- functionName: "vaultGet",
3231
- actionName: "vault/get",
3232
- schema: Wm
3233
- },
3234
- {
3235
- functionName: "vaultSet",
3236
- actionName: "vault/set",
3237
- schema: Jm
3238
- },
3239
- {
3240
- functionName: "vaultRemove",
3241
- actionName: "vault/remove",
3242
- schema: Zm
3243
- },
3244
- {
3245
- functionName: "vaultClear",
3246
- actionName: "vault/clear",
3247
- schema: Ym
3248
- },
3249
- {
3250
- functionName: "vaultKeys",
3251
- actionName: "vault/keys",
3252
- schema: Xm
3253
- },
3254
- {
3255
- functionName: "vaultObserve",
3256
- actionName: "vault/observe",
3257
- schema: Qm
3258
- },
3259
- {
3260
- functionName: "wishlistCreate",
3261
- actionName: "wishlist/create",
3262
- schema: ty,
3263
- successSchema: ry
3264
- },
3265
- {
3266
- functionName: "wishlistsGet",
3267
- actionName: "wishlists/get",
3268
- schema: null,
3269
- successSchema: ey
3270
- },
3271
- {
3272
- functionName: "wishlistItemAdd",
3273
- actionName: "wishlist/item/add",
3274
- schema: ny,
3275
- successSchema: ay
3276
- },
3277
- {
3278
- functionName: "wishlistItemRemove",
3279
- actionName: "wishlist/item/remove",
3280
- schema: iy,
3281
- successSchema: sy
3282
- },
3283
- {
3284
- functionName: "getLoyaltyRewards",
3285
- actionName: "loyalty/rewards",
3286
- schema: cy,
3287
- successSchema: ly
3288
- },
3289
- {
3290
- functionName: "getLoyaltyHistory",
3291
- actionName: "loyalty/history",
3292
- schema: dy,
3293
- successSchema: fy
3294
- },
3295
- {
3296
- functionName: "getLoyaltyCustomer",
3297
- actionName: "loyalty/customer",
3298
- schema: py,
3299
- successSchema: hy
3300
- },
3301
- {
3302
- functionName: "getLoyaltyTiers",
3303
- actionName: "loyalty/tiers",
3304
- schema: _y,
3305
- successSchema: by
3306
- },
3307
- {
3308
- functionName: "getLoyaltyCustomerTier",
3309
- actionName: "loyalty/customer/tier",
3310
- schema: $y,
3311
- successSchema: Sy
3312
- },
3313
- {
3314
- functionName: "redeemLoyaltyReward",
3315
- actionName: "loyalty/redeem/reward",
3316
- schema: my,
3317
- successSchema: vy
3318
- },
3319
- {
3320
- functionName: "recordLoyaltyActivity",
3321
- actionName: "loyalty/record/activity",
3322
- schema: yy,
3323
- successSchema: gy
3324
- },
3325
- {
3326
- functionName: "applePayStartSessionURL",
3327
- actionName: "cart/applePayStartSessionURL",
3328
- schema: Cy
3329
- },
3330
- {
3331
- functionName: "getApplePayDomainName",
3332
- actionName: "cart/getApplePayDomainName",
3333
- schema: Iy
3334
- },
3335
- {
3336
- functionName: "applePayOnPaymentAuthorized",
3337
- actionName: "cart/applePayOnPaymentAuthorized",
3338
- schema: Py
3339
- },
3340
- {
3341
- functionName: "applePayOnShippingContactSelected",
3342
- actionName: "cart/applePayOnShippingContactSelected",
3343
- schema: Ny
3344
- },
3345
- {
3346
- functionName: "applePayOnPaymentMethodSelected",
3347
- actionName: "cart/applePayOnPaymentMethodSelected",
3348
- schema: Dy
3349
- },
3350
- {
3351
- functionName: "applePayOnShippingMethodSelected",
3352
- actionName: "cart/applePayOnShippingMethodSelected",
3353
- schema: Ry
3354
- }
3355
- ], q = {
3356
- PLATFORM_IOS: "ios",
3357
- PLATFORM_ANDROID: "android",
3358
- PLATFORM_EDITOR: "editor",
3359
- ACTION_RESPONSE_SUCCESS: "success",
3360
- ACTION_RESPONSE_ERROR: "error",
3361
- TAPCART_SDK: "tapcart-sdk"
3362
- }, Gn = async (t, e, r = {}) => {
3363
- var n;
3364
- try {
3365
- const { appId: a, cartId: i } = e;
3366
- if (!a)
3367
- throw new Error("AppIdMissing");
3368
- if (!i)
3369
- throw new Error("CartIdMissing");
3370
- const s = {
3371
- ...e,
3372
- cartId: i
3373
- }, o = `/${a}/api/v1/cart/${t}`, u = await fetch(o, {
3374
- method: "POST",
3375
- headers: {
3376
- "Content-Type": "application/json",
3377
- "X-Cart-ID": i
3378
- // Also include as header for redundancy
3379
- },
3380
- body: JSON.stringify(s)
3381
- });
3382
- if (!u.ok) {
3383
- const l = await u.json(), d = new Error(l.error || "Error");
3384
- if (r.onError)
3385
- return r.onError(d), null;
3386
- throw d;
3387
- }
3388
- const c = await u.json();
3389
- return (n = c == null ? void 0 : c.cart) != null && n.id && c.cart.id !== i && localStorage.setItem("cartId", c.cart.id), r.onSuccess && r.onSuccess(c), c;
3390
- } catch (a) {
3391
- if (console.error(`Error in cart operation ${t}:`, a), r.onError)
3392
- return r.onError(a.message || "Error"), null;
3393
- throw a.message || "Error";
3394
- }
3395
- }, U = (t, e, r = {}) => Gn(t, e, r), qy = async (t, e) => U("applyGiftCard", t, e), Ly = (t, e) => U("getGiftCard", t, e), Uy = (t, e) => U("removeDiscount", t, e), jy = (t, e) => U("removeGiftCard", t, e), zy = (t, e) => U("updateApplePay", t, e), Gy = (t, e) => U("submitForCompletion", t, e), ky = (t, e) => U("addDeliveryAddress", t, e), Vy = (t, e) => U("updateDeliveryAddress", t, e), By = (t, e) => U("removeDeliveryAddress", t, e), Ky = (t, e) => U("updateSelectedDeliveryOptions", t, e), Se = (t, e) => U("prepareForCompletion", t, e), kn = (t, e) => U("updateBuyerIdentity", t, e), Wy = ({ hostname: t }) => `${(t == null ? void 0 : t.includes("tapc.studio")) ? "https://api.tapcart.xyz" : "https://api.tapcart.com"}/public/apple-pay/session`, Jy = ({ hostname: t, appId: e }) => {
3396
- const r = t == null ? void 0 : t.includes("tapc.studio"), n = e.toLowerCase();
3397
- return r ? `${n}.tapc.studio` : `${n}.tapcart.studio`;
3398
- }, Zy = async (t, e) => {
3399
- var i, s, o, u;
3400
- const { cartId: r, payment: n, appId: a } = t;
3401
- if (r) {
3402
- const { billingContact: c, shippingContact: l } = n;
3403
- let d = null;
3404
- try {
3405
- const p = (b) => {
3406
- const {
3407
- addressLines: g,
3408
- locality: N,
3409
- country: R,
3410
- givenName: z,
3411
- familyName: M,
3412
- phoneNumber: O,
3413
- administrativeArea: B,
3414
- postalCode: G,
3415
- emailAddress: x
3416
- } = b, w = {};
3417
- if (Array.isArray(g) && g.length > 0) {
3418
- const [ge] = g;
3419
- w.address1 = ge;
3420
- }
3421
- if (Array.isArray(g) && g.length > 1) {
3422
- const [, ge] = g;
3423
- w.address2 = ge;
3424
- }
3425
- return N && (w.city = N), w.company = "", R && (w.country = R), z && (w.firstName = z), M && (w.lastName = M), x && (w.email = x), O && (w.phone = O), B && (w.province = B), G && (w.zip = G), w;
3426
- }, h = {
3427
- cartId: r,
3428
- appId: a
3429
- };
3430
- l != null && l.countryCode && (h.countryCode = l.countryCode), l != null && l.emailAddress && (h.email = l.emailAddress), l != null && l.phoneNumber && (h.phone = l.phoneNumber), await kn(h), d = await Se({ cartId: r, appId: a });
3431
- const y = {
3432
- cartId: r,
3433
- appId: a,
3434
- billingAddress: p(c)
3435
- };
3436
- (s = (i = d == null ? void 0 : d.cost) == null ? void 0 : i.totalAmount) != null && s.amount && (y.amount = d.cost.totalAmount.amount), (u = (o = d == null ? void 0 : d.cost) == null ? void 0 : o.totalAmount) != null && u.currencyCode && (y.currencyCode = d.cost.totalAmount.currencyCode);
3437
- const { token: v } = n, { data: _, signature: $, version: A, header: T } = v.paymentData;
3438
- y.data = _, y.signature = $, y.version = A, y.header = T, await zy(y), await Se({ cartId: r, appId: a });
3439
- const P = crypto.randomUUID();
3440
- return await Gy({
3441
- attemptToken: P,
3442
- cartId: r,
3443
- appId: a
3444
- }, e);
3445
- } catch (p) {
3446
- if (console.error("Error in applePayOnPaymentAuthorized:", p), e != null && e.onError)
3447
- return e.onError(p), null;
3448
- throw p;
3449
- }
3450
- }
3451
- return null;
3452
- }, Yy = async (t, e) => {
3453
- var o, u, c, l, d, p, h, y, v, _, $;
3454
- const { cartId: r, shippingContact: n, displayName: a, appId: i } = t;
3455
- let s = null;
3456
- try {
3457
- const A = (b) => {
3458
- const {
3459
- addressLines: g,
3460
- locality: N,
3461
- countryCode: R,
3462
- givenName: z,
3463
- familyName: M,
3464
- phoneNumber: O,
3465
- administrativeArea: B,
3466
- postalCode: G
3467
- } = b, x = {};
3468
- if (Array.isArray(g) && g.length > 0) {
3469
- const [w] = g;
3470
- x.address1 = w;
3471
- }
3472
- if (Array.isArray(g) && g.length > 1) {
3473
- const [, w] = g;
3474
- x.address2 = w;
3475
- }
3476
- return N && (x.city = N), R && (x.countryCode = R), z && (x.firstName = z), M && (x.lastName = M), O && (x.phone = O), B && (x.provinceCode = B), G && (x.zip = G), x;
3477
- }, T = {
3478
- cartId: r,
3479
- appId: i
3480
- };
3481
- if (n != null && n.countryCode && (T.countryCode = n.countryCode), n != null && n.emailAddress && (T.email = n.emailAddress), n != null && n.phoneNumber && (T.phone = n.phoneNumber), await kn(T), s = await Gn("getCart", { cartId: r, appId: i }), (((u = (o = s == null ? void 0 : s.cart) == null ? void 0 : o.delivery) == null ? void 0 : u.addresses) ?? []).length > 1 && await By({
3482
- cartId: r,
3483
- appId: i,
3484
- deliveryAddressIds: s.cart.delivery.addresses.map((b) => b.id)
3485
- }), n) {
3486
- if (((d = (l = (c = s == null ? void 0 : s.cart) == null ? void 0 : c.delivery) == null ? void 0 : l.addresses) == null ? void 0 : d.length) === 0)
3487
- await ky({
3488
- cartId: r,
3489
- appId: i,
3490
- addresses: [
3491
- {
3492
- address: {
3493
- deliveryAddress: A(n)
3494
- },
3495
- oneTimeUse: !0,
3496
- selected: !0,
3497
- validationStrategy: "COUNTRY_CODE_ONLY"
3498
- }
3499
- ]
3500
- });
3501
- else if (((y = (h = (p = s == null ? void 0 : s.cart) == null ? void 0 : p.delivery) == null ? void 0 : h.addresses) == null ? void 0 : y.length) === 1) {
3502
- const b = s.cart.delivery.addresses[0];
3503
- await Vy({
3504
- cartId: r,
3505
- appId: i,
3506
- addresses: [
3507
- {
3508
- id: b.id,
3509
- address: {
3510
- deliveryAddress: A(n)
3511
- }
3512
- }
3513
- ]
3514
- });
3515
- }
3516
- }
3517
- return s = await Se({ cartId: r, appId: i }), {
3518
- shippingMethods: ((b) => {
3519
- const g = b[0], { deliveryOptions: N } = g;
3520
- return N.map((R) => {
3521
- const { title: z, estimatedCost: M, description: O, handle: B } = R, { id: G } = g, x = {
3522
- label: z,
3523
- identifier: `${G},${B}`
3524
- };
3525
- return M != null && M.amount && (x.amount = M.amount), O && (x.detail = O), x;
3526
- });
3527
- })(s.cart.deliveryGroups),
3528
- total: {
3529
- label: a,
3530
- amount: ($ = (_ = (v = s.cart) == null ? void 0 : v.cost) == null ? void 0 : _.totalAmount) == null ? void 0 : $.amount
3531
- }
3532
- };
3533
- } catch (A) {
3534
- if (console.error("Error in applePayOnShippingContactSelected:", A), e != null && e.onError)
3535
- return e.onError(A), null;
3536
- throw A;
3537
- }
3538
- }, Xy = async (t, e) => {
3539
- var i, s, o;
3540
- const { cartId: r, displayName: n, appId: a } = t;
3541
- try {
3542
- const u = await Se({ cartId: r, appId: a });
3543
- return {
3544
- total: {
3545
- label: n,
3546
- type: "final",
3547
- amount: (o = (s = (i = u.cart) == null ? void 0 : i.cost) == null ? void 0 : s.totalAmount) == null ? void 0 : o.amount
3548
- }
3549
- };
3550
- } catch (u) {
3551
- if (console.error("Error in applePayOnPaymentMethodSelected:", u), e != null && e.onError)
3552
- return e.onError(u), null;
3553
- throw u;
3554
- }
3555
- }, Qy = async (t, e) => {
3556
- var s, o, u;
3557
- const { cartId: r, shippingMethod: n, displayName: a, appId: i } = t;
3558
- try {
3559
- const c = (h) => {
3560
- const [y = "", v = ""] = h.split(",");
3561
- return { deliveryGroupId: y, deliveryOptionHandle: v };
3562
- }, { deliveryGroupId: l, deliveryOptionHandle: d } = c(n.identifier);
3563
- let p = await Ky({
3564
- cartId: r,
3565
- appId: i,
3566
- selectedDeliveryOptions: [
3567
- {
3568
- deliveryGroupId: l,
3569
- deliveryOptionHandle: d
3570
- }
3571
- ]
3572
- });
3573
- return p = await Se({ cartId: r, appId: i }), {
3574
- total: {
3575
- label: a,
3576
- amount: (u = (o = (s = p.cart) == null ? void 0 : s.cost) == null ? void 0 : o.totalAmount) == null ? void 0 : u.amount
3577
- }
3578
- };
3579
- } catch (c) {
3580
- if (console.error("Error in applePayOnShippingMethodSelected:", c), e != null && e.onError)
3581
- return e.onError(c), null;
3582
- throw c;
3583
- }
3584
- }, Hy = (t) => ({
3585
- applyGiftCard: t.actions.applyGiftCard,
3586
- getGiftCard: t.actions.getGiftCard,
3587
- applyDiscount: t.actions.applyDiscount,
3588
- removeDiscount: t.actions.removeDiscount,
3589
- removeGiftCard: t.actions.removeGiftCard,
3590
- updateCartApplePay: t.actions.updateCartApplePay,
3591
- submitCartForCompletion: t.actions.submitCartForCompletion,
3592
- addDeliveryAddresses: t.actions.addDeliveryAddresses,
3593
- updateDeliveryAddresses: t.actions.updateDeliveryAddresses,
3594
- removeDeliveryAddresses: t.actions.removeDeliveryAddresses,
3595
- updateSelectedDeliveryOptions: t.actions.updateSelectedDeliveryOptions,
3596
- prepareForCompletion: t.actions.prepareForCompletion,
3597
- updateBuyerIdentity: t.actions.updateBuyerIdentity,
3598
- applePayStartSessionURL: t.actions.applePayStartSessionURL,
3599
- getApplePayDomainName: t.actions.getApplePayDomainName,
3600
- applePayOnPaymentAuthorized: t.actions.applePayOnPaymentAuthorized,
3601
- applePayOnShippingContactSelected: t.actions.applePayOnShippingContactSelected,
3602
- applePayOnPaymentMethodSelected: t.actions.applePayOnPaymentMethodSelected,
3603
- applePayOnShippingMethodSelected: t.actions.applePayOnShippingMethodSelected
3604
- }), Qe = ({ cart: t, defaultHandler: e, onSuccess: r }) => {
3605
- e({
3606
- id: `refresh-${Math.random().toString(36).slice(2, 15)}`,
3607
- type: "action",
3608
- name: "cart/updateAttributes",
3609
- data: {
3610
- attributes: t.attributes
3611
- }
3612
- }), r(Ir(t));
3613
- }, ev = async ({
3614
- payload: t,
3615
- defaultHandler: e
3616
- }) => {
3617
- const n = {
3618
- "discount/remove": async (a, i) => Uy(
3619
- { appId: a.data.appId, cartId: a.data.cartId, discountCode: a.data.discountCode },
3620
- {
3621
- onSuccess: (s) => {
3622
- Qe({ cart: s, defaultHandler: e, onSuccess: i == null ? void 0 : i.onSuccess });
3623
- },
3624
- onError: i == null ? void 0 : i.onError
3625
- }
3626
- ),
3627
- "giftcard/apply": async (a, i) => qy(
3628
- { appId: a.data.appId, giftCardCode: a.data.giftCardCode, cartId: a.data.cartId },
3629
- {
3630
- onSuccess: (s) => {
3631
- Qe({ cart: s, defaultHandler: e, onSuccess: i == null ? void 0 : i.onSuccess });
3632
- },
3633
- onError: i == null ? void 0 : i.onError
3634
- }
3635
- ),
3636
- "giftcard/get": async (a, i) => Ly(
3637
- { appId: a.data.appId, cartId: a.data.cartId },
3638
- {
3639
- onSuccess: i == null ? void 0 : i.onSuccess,
3640
- onError: i == null ? void 0 : i.onError
3641
- }
3642
- ),
3643
- "giftcard/remove": async (a, i) => jy(
3644
- { appId: a.data.appId, cartId: a.data.cartId, giftCardId: a.data.giftCardId },
3645
- {
3646
- onSuccess: (s) => {
3647
- Qe({ cart: s, defaultHandler: e, onSuccess: i == null ? void 0 : i.onSuccess });
3648
- },
3649
- onError: i == null ? void 0 : i.onError
3650
- }
3651
- ),
3652
- // New Apple Pay handlers
3653
- "cart/applePayStartSessionURL": async (a, i) => {
3654
- try {
3655
- const s = Wy({
3656
- hostname: a.data.hostname
3657
- });
3658
- return i == null || i.onSuccess(s), s;
3659
- } catch (s) {
3660
- throw i == null || i.onError(s), s;
3661
- }
3662
- },
3663
- "cart/getApplePayDomainName": async (a, i) => {
3664
- try {
3665
- const s = Jy({
3666
- hostname: a.data.hostname,
3667
- appId: a.data.appId
3668
- });
3669
- return i == null || i.onSuccess(s), s;
3670
- } catch (s) {
3671
- throw i == null || i.onError(s), s;
3672
- }
3673
- },
3674
- "cart/applePayOnPaymentAuthorized": async (a, i) => Zy(
3675
- {
3676
- cartId: a.data.cartId,
3677
- payment: a.data.payment,
3678
- appId: a.data.appId
3679
- },
3680
- {
3681
- onSuccess: i == null ? void 0 : i.onSuccess,
3682
- onError: i == null ? void 0 : i.onError
3683
- }
3684
- ),
3685
- "cart/applePayOnShippingContactSelected": async (a, i) => Yy(
3686
- {
3687
- cartId: a.data.cartId,
3688
- shippingContact: a.data.shippingContact,
3689
- displayName: a.data.displayName,
3690
- appId: a.data.appId
3691
- },
3692
- {
3693
- onSuccess: i == null ? void 0 : i.onSuccess,
3694
- onError: i == null ? void 0 : i.onError
3695
- }
3696
- ),
3697
- "cart/applePayOnPaymentMethodSelected": async (a, i) => Xy(
3698
- {
3699
- cartId: a.data.cartId,
3700
- paymentMethod: a.data.paymentMethod,
3701
- displayName: a.data.displayName,
3702
- appId: a.data.appId
3703
- },
3704
- {
3705
- onSuccess: i == null ? void 0 : i.onSuccess,
3706
- onError: i == null ? void 0 : i.onError
3707
- }
3708
- ),
3709
- "cart/applePayOnShippingMethodSelected": async (a, i) => Qy(
3710
- {
3711
- cartId: a.data.cartId,
3712
- shippingMethod: a.data.shippingMethod,
3713
- displayName: a.data.displayName,
3714
- appId: a.data.appId
3715
- },
3716
- {
3717
- onSuccess: i == null ? void 0 : i.onSuccess,
3718
- onError: i == null ? void 0 : i.onError
3719
- }
3720
- )
3721
- }[t.name];
3722
- if (!n)
3723
- return e(t);
3724
- try {
3725
- const { id: a } = t;
3726
- return await n(t, {
3727
- onSuccess: (o) => {
3728
- var u, c;
3729
- return typeof ((c = (u = window == null ? void 0 : window.Tapcart) == null ? void 0 : u.mobile) == null ? void 0 : c.respond) == "function" && window.Tapcart.mobile.respond(a, "success", o), o;
3730
- },
3731
- onError: (o) => {
3732
- var u, c;
3733
- throw typeof ((c = (u = window == null ? void 0 : window.Tapcart) == null ? void 0 : u.mobile) == null ? void 0 : c.respond) == "function" && window.Tapcart.mobile.respond(a, "error", o), o;
3734
- }
3735
- });
3736
- } catch (a) {
3737
- throw console.error(`Error executing action ${t.name}:`, a), a;
3738
- }
3739
- }, Vn = (t, e, r) => ev({
3740
- payload: t,
3741
- defaultHandler: e
3742
- }).then((n) => {
3743
- const a = t.name;
3744
- return a.startsWith("cart/") && (n != null && n.cart) && r.notify("cart/updated", { cart: n.cart }), a.startsWith("giftcard/") && r.notify("giftCards/updated", { giftCards: n }), n;
3745
- }).catch((n) => {
3746
- throw console.error(`Error executing action ${t.name}:`, n), n;
3747
- }), tv = (t, e, r) => {
3748
- const n = {}, a = (i, s, o) => (u, c = {}) => {
3749
- let l;
3750
- if (i)
3751
- try {
3752
- l = i.validateSync(u);
3753
- } catch (p) {
3754
- throw new Error(p.message);
3755
- }
3756
- const d = {
3757
- id: Pr(),
3758
- type: "action",
3759
- name: s,
3760
- data: l
3761
- };
3762
- (c.onSuccess || c.onError) && t(
3763
- d.id,
3764
- c.onSuccess,
3765
- c.onError,
3766
- o
3767
- ), Vn(d, e, r).catch(() => {
3768
- });
3769
- };
3770
- for (const i of zn) {
3771
- const { schema: s, functionName: o, actionName: u, successSchema: c } = i;
3772
- n[o] = a(s, u, c);
3773
- }
3774
- return n;
3775
- }, rv = (t, e) => {
3776
- const r = {}, n = (o, u, c, l) => {
3777
- let d;
3778
- u && (d = (p) => {
3779
- if (l)
3780
- try {
3781
- u(l.validateSync(p));
3782
- } catch (h) {
3783
- c && c(h);
3784
- }
3785
- else
3786
- u(p);
3787
- }), r[o] = {
3788
- [q.ACTION_RESPONSE_SUCCESS]: d,
3789
- [q.ACTION_RESPONSE_ERROR]: c
3790
- };
3791
- }, a = (o, u, c) => {
3792
- var l;
3793
- typeof ((l = r[o]) == null ? void 0 : l[u]) == "function" && r[o][u](c);
3794
- };
3795
- return {
3796
- actions: tv(n, t, e),
3797
- respond: a,
3798
- action: (o, u = null, c = {}) => {
3799
- var d;
3800
- if (!o)
3801
- throw new Error("actionType is a required parameter");
3802
- const l = {
3803
- id: Pr(),
3804
- type: "action",
3805
- name: o,
3806
- data: u
3807
- };
3808
- (c.onSuccess || c.onError) && n(
3809
- l.id,
3810
- c.onSuccess,
3811
- c.onError,
3812
- (d = zn.find((p) => p.actionName === o)) == null ? void 0 : d.successSchema
3813
- ), Vn(l, t, e).catch(() => {
3814
- });
3815
- }
3816
- };
3817
- }, Er = [
3818
- "cart/updated",
3819
- "product/updated",
3820
- "customer/updated",
3821
- "variables/updated",
3822
- "giftCards/updated"
3823
- ], $e = {
3824
- CART_UPDATED: "cart/updated",
3825
- PRODUCT_UPDATED: "product/updated",
3826
- CUSTOMER_UPDATED: "customer/updated",
3827
- VARIABLES_UPDATED: "variables/updated",
3828
- GIFT_CARDS_UPDATED: "giftCards/updated"
3829
- }, nv = (t, e) => {
3830
- switch (t) {
3831
- case $e.CART_UPDATED:
3832
- return { cart: e.cart || null };
3833
- case $e.PRODUCT_UPDATED:
3834
- return { product: e.product || null };
3835
- case $e.CUSTOMER_UPDATED:
3836
- return { customer: e.customer || null };
3837
- case $e.VARIABLES_UPDATED:
3838
- return { ...e };
3839
- case $e.GIFT_CARDS_UPDATED:
3840
- return { giftCards: e.giftCards || null };
3841
- default:
3842
- return e;
3843
- }
3844
- }, av = ({ setVariables: t }) => {
3845
- const e = {};
3846
- return {
3847
- notify: (a, i) => {
3848
- var s;
3849
- if (!Er.includes(a))
3850
- throw new Error("Unsupported Event");
3851
- (s = e[a]) != null && s.size && e[a].forEach((o) => o(i));
3852
- },
3853
- registerEventHandler: (a, i) => {
3854
- if (!Er.includes(a))
3855
- throw new Error("Unsupported Event");
3856
- if (typeof i != "function")
3857
- throw new TypeError("Invalid Handler");
3858
- const s = (o) => {
3859
- o && t(nv(a, o)), i(o);
3860
- };
3861
- return e[a] ?? (e[a] = /* @__PURE__ */ new Set()), e[a].add(s), () => e[a].delete(s);
3862
- }
3863
- };
3864
- }, iv = () => {
3865
- let t;
3866
- const e = (u, c) => window.webkit.messageHandlers[u].postMessage(
3867
- JSON.stringify(c)
3868
- ), r = (u, c) => window[u].postMessage(JSON.stringify(c)), n = (u, c) => {
3869
- var l, d;
3870
- console.log(c), window == null || window.postMessage(
3871
- { type: q.TAPCART_SDK, message: JSON.stringify(c) },
3872
- "*"
3873
- ), (d = (l = window == null ? void 0 : window.parent) == null ? void 0 : l.window) == null || d.postMessage(
3874
- { type: q.TAPCART_SDK, message: JSON.stringify(c) },
3875
- "*"
3876
- );
3877
- }, a = {
3878
- [q.PLATFORM_IOS]: e,
3879
- [q.PLATFORM_ANDROID]: r,
3880
- [q.PLATFORM_EDITOR]: n
3881
- }, i = (u, c) => (l) => a[u](c, l);
3882
- return {
3883
- sendMessage: (u) => t(u),
3884
- init: (u, c) => {
3885
- if (!u || !c)
3886
- throw new Error("Failed to initialize ActionBridge");
3887
- if (u !== q.PLATFORM_IOS && u !== q.PLATFORM_ANDROID && u !== q.PLATFORM_EDITOR)
3888
- throw new Error("Unknown Platform");
3889
- if (u === q.PLATFORM_IOS && !window.webkit)
3890
- throw new Error("Webview Interface not available");
3891
- if (u === q.PLATFORM_ANDROID && !window[c])
3892
- throw new Error("Webview Interface not available");
3893
- t = i(u, c);
3894
- }
3895
- };
3896
- };
3897
- class X {
3898
- constructor(e) {
3899
- this.message = e;
3900
- }
3901
- }
3902
- class sv extends X {
3903
- }
3904
- class ov extends X {
3905
- }
3906
- class uv extends X {
3907
- }
3908
- class cv extends X {
3909
- }
3910
- class lv extends X {
3911
- }
3912
- class dv extends X {
3913
- }
3914
- const mt = {
3915
- VaultAccessException: sv,
3916
- VaultBuildException: ov,
3917
- VaultInvalidArgumentException: uv,
3918
- VaultInvalidScopeException: cv,
3919
- VaultScopeModificationException: lv,
3920
- VaultUserException: X,
3921
- VaultUserIdentifierException: dv
3922
- }, ne = (t) => {
3923
- if (Object.values(mt).some((r) => t instanceof r))
3924
- return t;
3925
- const e = mt[t.type];
3926
- return e ? new e(t.message) : new X("unknown error occurred");
3927
- }, fv = (t, e) => ({
3928
- get: (n) => new Promise((a, i) => {
3929
- e.actions.vaultGet(
3930
- { vaultKey: t, key: n },
3931
- {
3932
- onSuccess: a,
3933
- onError: (s) => i(ne(s))
3934
- }
3935
- );
3936
- }),
3937
- set: (n, a) => new Promise((i, s) => {
3938
- e.actions.vaultSet(
3939
- {
3940
- vaultKey: t,
3941
- key: n,
3942
- value: a
3943
- },
3944
- {
3945
- onSuccess: i,
3946
- onError: (o) => s(ne(o))
3947
- }
3948
- );
3949
- }),
3950
- clear: () => new Promise((n, a) => {
3951
- e.actions.vaultClear(
3952
- {
3953
- vaultKey: t
3954
- },
3955
- {
3956
- onSuccess: n,
3957
- onError: (i) => a(ne(i))
3958
- }
3959
- );
3960
- }),
3961
- remove: (n) => new Promise((a, i) => {
3962
- e.actions.vaultRemove(
3963
- {
3964
- vaultKey: t,
3965
- key: n
3966
- },
3967
- {
3968
- onSuccess: a,
3969
- onError: (s) => i(ne(s))
3970
- }
3971
- );
3972
- }),
3973
- keys: () => new Promise((n, a) => {
3974
- e.actions.vaultKeys(
3975
- {
3976
- vaultKey: t
3977
- },
3978
- {
3979
- onSuccess: n,
3980
- onError: (i) => a(ne(i))
3981
- }
3982
- );
3983
- }),
3984
- observe: (n, a, i = () => {
3985
- }) => new Promise((s, o) => {
3986
- e.actions.vaultObserve(
3987
- {
3988
- vaultKey: t,
3989
- key: n
3990
- },
3991
- {
3992
- onSuccess: (u) => {
3993
- s(), a(u);
3994
- },
3995
- onError: (u) => {
3996
- const c = ne(u);
3997
- o(c), i(c);
3998
- }
3999
- }
4000
- );
4001
- })
4002
- }), pv = (t, e, r) => new Promise((n, a) => {
4003
- r.actions.vaultInitialize(
4004
- { vaultKey: t, scope: e },
4005
- {
4006
- onSuccess: () => {
4007
- n(fv(t, r));
4008
- },
4009
- onError: (i) => a(ne(i))
4010
- }
4011
- );
4012
- }), hv = (t) => ({
4013
- initialize: (e, r) => pv(e, r, t),
4014
- errorTypes: mt
4015
- }), xr = {
4016
- Error: "Failed to perform wishlist action",
4017
- Auth: "User must be logged in for wishlist actions",
4018
- NoWishlistIntegrationConfigured: "A wishlist integration must be configured",
4019
- InvalidName: "Wishlist name must be 3 characters long",
4020
- WishlistDoesNotExist: "Wishlist does not exist",
4021
- WishlistItemDoesNotExist: "Item does not exist"
4022
- }, mv = (t) => xr[t] || xr.Error, Ce = (t, e) => new Promise((r, n) => {
4023
- t(e, {
4024
- onSuccess: r,
4025
- onError: (a) => n(mv(a))
4026
- });
4027
- }), yv = (t) => {
4028
- const { wishlistCreate: e, wishlistItemAdd: r, wishlistItemRemove: n, wishlistsGet: a } = t.actions;
4029
- return {
4030
- createWishlist: (i) => Ce(e, { name: i }),
4031
- addItemToWishlist: (i, s, o) => Ce(r, { productId: i, variantId: s, wishlistId: o }),
4032
- removeItemFromWishlist: (i, s, o) => Ce(n, { productId: i, variantId: s, wishlistId: o }),
4033
- getWishlists: () => Ce(a, null)
4034
- };
4035
- }, Tr = {
4036
- Error: "Failed to perform authentication action"
4037
- }, vv = (t) => Tr[t] || Tr.Error, gv = (t, e) => new Promise((r, n) => {
4038
- t(e, {
4039
- onSuccess: r,
4040
- onError: (a) => n(vv(a))
4041
- });
4042
- }), _v = (t) => {
4043
- const { authenticationOpen: e } = t.actions;
4044
- return {
4045
- openAuthentication: (r) => gv(e, { action: r })
4046
- };
4047
- }, bv = (t, e) => new Promise((r, n) => {
4048
- t(e, {
4049
- onSuccess: r,
4050
- onError: (a) => n(a)
4051
- });
4052
- }), $v = (t) => {
4053
- const { trackAnalyticEvent: e } = t.actions;
4054
- return {
4055
- trackAnalyticEvent: (r, n) => bv(e, { analyticEvent: r, analyticProperties: n })
4056
- };
4057
- }, Sv = () => {
4058
- var r, n, a, i;
4059
- const t = new CustomEvent("webbridge-ready");
4060
- window.dispatchEvent(t);
4061
- const e = JSON.stringify({
4062
- type: "action",
4063
- name: "webbridge/ready"
4064
- });
4065
- (r = window.CustomBlockJavascriptInterface) == null || r.postMessage(e), (i = (a = (n = window.webkit) == null ? void 0 : n.messageHandlers) == null ? void 0 : a.Tapcart) == null || i.postMessage(e);
4066
- }, Fr = {
4067
- Error: "Failed to perform loyalty action",
4068
- Auth: "User must be logged in for loyalty actions",
4069
- NoLoyaltyIntegrationConfigured: "A loyalty integration must be configured"
4070
- }, Av = (t) => Fr[t] || Fr.Error, Q = async (t, { appId: e, ...r }) => {
4071
- const n = `/${e}/api/v1/mock-loyalty/${t}`;
4072
- return (await fetch(n, {
4073
- method: "POST",
4074
- headers: {
4075
- "Content-Type": "application/json"
4076
- },
4077
- body: JSON.stringify(r)
4078
- })).json();
4079
- }, H = (t, e) => new Promise((r, n) => {
4080
- t(e, {
4081
- onSuccess: r,
4082
- onError: (a) => n(Av(a))
4083
- });
4084
- }), ee = () => !!(window != null && window.Tapcart.variables.device), Or = (t) => {
4085
- const { getLoyaltyRewards: e, getLoyaltyHistory: r, getLoyaltyCustomer: n, redeemLoyaltyReward: a, getLoyaltyTiers: i, getLoyaltyCustomerTier: s, recordLoyaltyActivity: o } = t.actions;
4086
- return {
4087
- getLoyaltyRewards: ({ appId: u }) => ee() ? H(e, null) : Q("getRewards", { appId: u }),
4088
- getLoyaltyTiers: ({ appId: u }) => ee() ? H(i, null) : Q("getTiers", { appId: u }),
4089
- getLoyaltyCustomerTier: ({ appId: u }) => ee() ? H(s, null) : Q("getCustomerTier", { appId: u }),
4090
- getLoyaltyHistory: ({ appId: u }) => ee() ? H(r, null) : Q("getHistory", { appId: u }),
4091
- getLoyaltyCustomer: ({ appId: u }) => ee() ? H(n, null) : Q("getCustomer", { appId: u }),
4092
- redeemLoyaltyReward: ({ appId: u, rewardId: c, options: l }) => ee() ? H(a, { rewardId: c, options: l }) : Q("redeemReward", { appId: u, rewardId: c, options: l }),
4093
- recordLoyaltyActivity: ({ appId: u, activityName: c, activityType: l, activityUrl: d }) => ee() ? H(o, { activityName: c, activityType: l, activityUrl: d }) : Q("recordActivity", { appId: u, activityName: c, activityType: l, activityUrl: d })
4094
- };
4095
- }, Tv = () => {
4096
- if (window.Tapcart)
4097
- return window.Tapcart;
4098
- const t = iv(), e = na(), r = av({
4099
- setVariables: e.setVariables
4100
- }), n = rv(t.sendMessage, r), a = async (s) => {
4101
- t.init(s.platform, s.messageHandlerName), e.setVariables(s.variables), window.Tapcart.isInitialized = !0, window.Tapcart.actions = {
4102
- ...window.Tapcart.actions,
4103
- ...Or(n)
4104
- };
4105
- }, i = {
4106
- addToCart: n.actions.addToCart,
4107
- applyDiscount: n.actions.applyDiscount,
4108
- applyGiftCard: n.actions.applyGiftCard,
4109
- getCustomerIdentity: n.actions.getCustomerIdentity,
4110
- openCart: n.actions.openCart,
4111
- openCollection: n.actions.openCollection,
4112
- openProduct: n.actions.openProduct,
4113
- openScreen: n.actions.openScreen,
4114
- removeDiscounts: n.actions.removeDiscounts,
4115
- removeDiscount: n.actions.removeDiscount,
4116
- removeFromCart: n.actions.removeFromCart,
4117
- scrollToBlockBottom: n.actions.scrollToBlockBottom,
4118
- scrollToBlockTop: n.actions.scrollToBlockTop,
4119
- showToast: n.actions.showToast,
4120
- updateCartAttributes: n.actions.updateCartAttributes,
4121
- updateCartNote: n.actions.updateCartNote,
4122
- vault: hv(n),
4123
- ...Hy(n),
4124
- ...yv(n),
4125
- ..._v(n),
4126
- ...$v(n),
4127
- ...Or(n),
4128
- action: n.action
4129
- };
4130
- return window.Tapcart = {
4131
- mobile: {
4132
- respond: n.respond,
4133
- notify: r.notify,
4134
- load: a
4135
- },
4136
- registerEventHandler: r.registerEventHandler,
4137
- actions: i,
4138
- get variables() {
4139
- return e.variables;
4140
- },
4141
- isInitialized: !1,
4142
- action: n.action
4143
- }, Sv(), window.Tapcart;
4144
- }, wv = () => ({
4145
- device: null,
4146
- product: null,
4147
- cart: null,
4148
- customer: null,
4149
- isInitialized: !1
4150
- }), Ft = Cr(null), Ot = Cr(null);
4151
- function Ev(t, e) {
4152
- switch (e.type) {
4153
- case "set-device":
4154
- return {
4155
- ...t,
4156
- device: {
4157
- ...e.payload
4158
- }
4159
- };
4160
- case "set-cart":
4161
- return {
4162
- ...t,
4163
- cart: {
4164
- ...e.payload
4165
- }
4166
- };
4167
- case "set-product":
4168
- return {
4169
- ...t,
4170
- product: {
4171
- ...e.payload
4172
- }
4173
- };
4174
- case "set-customer":
4175
- return {
4176
- ...t,
4177
- customer: {
4178
- ...e.payload
4179
- }
4180
- };
4181
- case "set-variables":
4182
- return {
4183
- ...t,
4184
- ...e.payload
4185
- };
4186
- case "initialize":
4187
- return {
4188
- ...e.payload,
4189
- isInitialized: !0
4190
- };
4191
- default:
4192
- throw new Error(`Unknown action: ${e.type}`);
4193
- }
4194
- }
4195
- function Fv({ webbridgeClient: t, children: e }) {
4196
- const [r, n] = Zn(Ev, wv());
4197
- return Yn(() => {
4198
- if (t.registerEventHandler("cart/updated", (a) => {
4199
- var i;
4200
- n({ type: "set-cart", payload: (i = t == null ? void 0 : t.variables) == null ? void 0 : i.cart });
4201
- }), t.registerEventHandler("product/updated", (a) => {
4202
- var i;
4203
- n({ type: "set-product", payload: (i = t == null ? void 0 : t.variables) == null ? void 0 : i.product });
4204
- }), t.registerEventHandler("customer/updated", (a) => {
4205
- var i;
4206
- n({ type: "set-customer", payload: (i = t == null ? void 0 : t.variables) == null ? void 0 : i.customer });
4207
- }), t.registerEventHandler("variables/updated", (a) => {
4208
- n({ type: "set-variables", payload: t == null ? void 0 : t.variables });
4209
- }), t.isInitialized)
4210
- n({ type: "initialize", payload: t.variables });
4211
- else {
4212
- const a = t.mobile.load;
4213
- t.mobile.load = (i) => {
4214
- a(i), n({ type: "initialize", payload: t == null ? void 0 : t.variables });
4215
- };
4216
- }
4217
- }, [t]), /* @__PURE__ */ Mt.createElement(Ft.Provider, { value: r }, /* @__PURE__ */ Mt.createElement(Ot.Provider, { value: t.actions }, e));
4218
- }
4219
- const Ov = () => ({
4220
- ...Pe(Ot)
4221
- }), Cv = () => Pe(Ft), Iv = () => {
4222
- const t = Pe(Ot), e = Pe(Ft);
4223
- return {
4224
- action: t.action,
4225
- actions: {
4226
- ...t
4227
- },
4228
- variables: e
4229
- };
4230
- };
4231
- export {
4232
- Fv as WebbridgeProvider,
4233
- Tv as loadWebbridge,
4234
- Ov as useActions,
4235
- Iv as useTapcart,
4236
- Cv as useVariables
4237
- };